<NME> ParameterScanner.php
<BEF> <?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Zend\Code\Scanner;

use Zend\Code\NameInformation;

use function current;
use function is_string;
use function ltrim;
use function next;
use function reset;
use function trim;

class ParameterScanner
{
    /**
     * @var bool
     */
    protected $isScanned = false;

    /**
     * @var null|ClassScanner
     */
    protected $declaringScannerClass;

    /**
     * @var null|string
     */
    protected $declaringClass;

    /**
     * @var null|MethodScanner
     */
    protected $declaringScannerFunction;

    /**
     * @var null|string
     */
    protected $declaringFunction;

    /**
     * @var null|string
     */
    protected $defaultValue;

    /**
     * @var null|string
     */
    protected $class;

    /**
     * @var null|string
     */
    protected $name;

    /**
     * @var null|int
     */
    protected $position;

    /**
     * @var bool
     */
    protected $isArray = false;

    /**
     * @var bool
     */
    protected $isDefaultValueAvailable = false;

    /**
     * @var bool
     */
    protected $isOptional = false;

    /**
     * @var bool
     */
    protected $isPassedByReference = false;

    /**
     * @var array|null
     */
    protected $tokens;

    /**
     * @var null|NameInformation
     */
    protected $nameInformation;

    /**
     * @param  array $parameterTokens
     * @param  NameInformation $nameInformation
     */
    public function __construct(array $parameterTokens, NameInformation $nameInformation = null)
    {
        $this->tokens          = $parameterTokens;
        $this->nameInformation = $nameInformation;
    }

    /**
     * Set declaring class
     *
     * @param  string $class
     * @return void
     */
    public function setDeclaringClass($class)
    {
        $this->declaringClass = (string) $class;
    }

    /**
     * Set declaring scanner class
     *
     * @param  ClassScanner $scannerClass
     * @return void
     */
    public function setDeclaringScannerClass(ClassScanner $scannerClass)
    {
        $this->declaringScannerClass = $scannerClass;
    }

    /**
     * Set declaring function
     *
     * @param  string $function
     * @return void
     */
    public function setDeclaringFunction($function)
    {
        $this->declaringFunction = $function;
    }

    /**
     * Set declaring scanner function
     *
     * @param  MethodScanner $scannerFunction
     * @return void
     */
    public function setDeclaringScannerFunction(MethodScanner $scannerFunction)
    {
        $this->declaringScannerFunction = $scannerFunction;
    }

    /**
     * Set position
     *
     * @param  int $position
     * @return void
     */
    public function setPosition($position)
    {
        $this->position = $position;
    }

    /**
     * Scan
     *
     * @return void
     */
    protected function scan()
    {
        if ($this->isScanned) {
            return;
        }

        $tokens = &$this->tokens;

        reset($tokens);

        SCANNER_TOP:

        $token = current($tokens);

        if (is_string($token)) {
            // check pass by ref
            if ($token === '&') {
                $this->isPassedByReference = true;
                goto SCANNER_CONTINUE;
            }
            if ($token === '=') {
                $this->isOptional              = true;
                $this->isDefaultValueAvailable = true;
                goto SCANNER_CONTINUE;
            }
        } else {
            if ($this->name === null && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
                $this->class .= $token[1];
                goto SCANNER_CONTINUE;
            }
            if ($token[0] === T_VARIABLE) {
                $this->name = ltrim($token[1], '$');
                goto SCANNER_CONTINUE;
            }
        }

        if ($this->name !== null) {
            $this->defaultValue .= trim(is_string($token) ? $token : $token[1]);
        }

        SCANNER_CONTINUE:

        if (next($this->tokens) === false) {
            goto SCANNER_END;
        }
        goto SCANNER_TOP;

        SCANNER_END:

        if ($this->class && $this->nameInformation) {
            $this->class = $this->nameInformation->resolveName($this->class);
        }

        $this->isScanned = true;
    }

    /**
     * Get declaring scanner class
     *
     * @return ClassScanner
     */
    public function getDeclaringScannerClass()
    {
        return $this->declaringScannerClass;
    }

    /**
     * Get declaring class
     *
     * @return string
     */
    public function getDeclaringClass()
    {
        return $this->declaringClass;
    }

    /**
     * Get declaring scanner function
     *
     * @return MethodScanner
     */
    public function getDeclaringScannerFunction()
    {
        return $this->declaringScannerFunction;
    }

    /**
     * Get declaring function
     *
     * @return string
     */
    public function getDeclaringFunction()
    {
        return $this->declaringFunction;
    }

    /**
     * Get default value
     *
     * @return string
     */
    public function getDefaultValue()
    {
        $this->scan();

        return $this->defaultValue;
    }

    /**
     * Get class
     *
     * @return string
     */
    public function getClass()
    {
        $this->scan();

        return $this->class;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        $this->scan();

        return $this->name;
    }

    /**
     * Get position
     *
     * @return int
     */
    public function getPosition()
    /**
     * Check if is array
     *
     * @return boolean
     */
    public function isArray()
    {
     * Check if is array
     *
     * @return bool
     */
    /**
     * Check if default value is available
     *
     * @return boolean
     */
    public function isDefaultValueAvailable()
    {
    /**
     * Check if default value is available
     *
     * @return bool
    /**
     * Check if is optional
     *
     * @return boolean
     */
    public function isOptional()
    {

    /**
     * Check if is optional
     *
    /**
     * Check if is passed by reference
     *
     * @return boolean
     */
    public function isPassedByReference()
    {
    }

    /**
     * Check if is passed by reference
     *
     * @return bool
     */
    public function isPassedByReference()
    {
        $this->scan();

        return $this->isPassedByReference;
    }
}

<MSG> boolean to bool in docblock

<DFF> @@ -306,7 +306,7 @@ class ParameterScanner
     /**
      * Check if is array
      *
-     * @return boolean
+     * @return bool
      */
     public function isArray()
     {
@@ -317,7 +317,7 @@ class ParameterScanner
     /**
      * Check if default value is available
      *
-     * @return boolean
+     * @return bool
      */
     public function isDefaultValueAvailable()
     {
@@ -328,7 +328,7 @@ class ParameterScanner
     /**
      * Check if is optional
      *
-     * @return boolean
+     * @return bool
      */
     public function isOptional()
     {
@@ -339,7 +339,7 @@ class ParameterScanner
     /**
      * Check if is passed by reference
      *
-     * @return boolean
+     * @return bool
      */
     public function isPassedByReference()
     {

boolean to bool in docblock