public function scan($scanners)
    {
        $scanners = $this->filterScanners($scanners);

        foreach ($scanners as $key => $scanner) {

            /** @var ScannerInterface $scanner */
            $success = false;
            foreach ($scanner->scan($this) as $token) {
                if (!($token instanceof TokenInterface)) {
                    $this->throwException(
                        'Scanner '.get_class($scanner).' generated a result that is not a '.TokenInterface::class
                    );
                }

                yield $token;
                $success = true;
            }

            if ($success) {
                return;
            }
        }
    }
public function scan($scanners)
    {
        $scanners = $this->filterScanners($scanners);

        foreach ($scanners as $key => $scanner) {

            /** @var ScannerInterface $scanner */
            $success = false;
            foreach ($scanner->scan($this) as $token) {
                if (!($token instanceof TokenInterface)) {
                    $this->throwException(
                        'Scanner '.get_class($scanner).' generated a result that is not a '.TokenInterface::class
                    );
                }

                yield $token;
                $success = true;
            }

            if ($success) {
                return;
            }
        }
    }
public function scan ( $ scanners ) { $ scanners = $ this -> filterScanners ( $ scanners ) ; foreach ( $ scanners as $ key => $ scanner ) { /** @var ScannerInterface $scanner */ $ success = false ; foreach ( $ scanner -> scan ( $ this ) as $ token ) { if ( ! ( $ token instanceof TokenInterface ) ) { $ this -> throwException ( 'Scanner ' . get_class ( $ scanner ) . ' generated a result that is not a ' . TokenInterface :: class ) ; } yield $ token ; $ success = true ; } if ( $ success ) { return ; } } }
Runs all passed scanners once on the input string.

The first scan that returns valid tokens will stop the scanning and
yields these tokens. If you want to continuously scan on something, rather
use the `loopScan`-method

@param array|string $scanners the scanners to run

@throws LexerException

@return \Generator the generator yielding all tokens found
Runs all passed scanners once on the input string .