Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Scanner.php

function Scanner::isAfterSlash

Checks if the given position follows a slash.

Parameters

Position $position Position to check:

Return value

bool

2 calls to Scanner::isAfterSlash()
Scanner::getToken in vendor/mck89/peast/lib/Peast/Syntax/Scanner.php
Returns the current token
Scanner::scanPunctuator in vendor/mck89/peast/lib/Peast/Syntax/Scanner.php
Punctuator scanning method

File

vendor/mck89/peast/lib/Peast/Syntax/Scanner.php, line 985

Class

Scanner
Base class for scanners.

Namespace

Peast\Syntax

Code

protected function isAfterSlash($position) {
    
    //Start from the previous index and loop until the begin of the file is reached
    $idx = $position->getIndex() - 1;
    while ($idx >= 0) {
        
        //Get the char at the index to check
        $char = $this->charAt($idx);
        
        //If the char is actually a slash check that it's not a multiline comment closing slash
        if ($char === "/") {
            return $idx === 0 || $this->charAt($idx - 1) !== "*";
        }
        elseif (in_array($char, $this->whitespaces) && !in_array($char, $this->lineTerminators)) {
            $idx--;
        }
        elseif ($char === "=" && $this->charAt($idx - 1) === "/") {
            return true;
        }
        else {
            break;
        }
    }
    return false;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal