for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Vanderlee\Comprehend\Match;
use Exception;
use InvalidArgumentException;
use Vanderlee\Comprehend\Core\Token;
/**
* Description of ParserToken.
*
* @author Martijn
* @property-read bool $match Success or failure?
* @property-read int $length Length of the match
* @property-read array $results List of output results
* @property-read string|array|null $result Default output result
* @property-read Token|null $token
*/
abstract class AbstractMatch
{
protected $length;
* @param string $name
* @return mixed
* @throws Exception
public function __get(string $name)
switch ($name) {
case 'length':
return $this->length;
case 'results':
return [];
case 'result':
case 'token':
return null;
}
throw new InvalidArgumentException('Property name `' . $name . '` not recognized');
* Create a new match.
* @param int $length
public function __construct(int $length = 0)
$this->length = $length;
length
Vanderlee\Comprehend\Match\AbstractMatch
* Resolve any match stuff (should only ever be called from AbstractParser).
* Not for human consumption.
* @return $this
public function resolve(): AbstractMatch
return $this;
* Return the result for the name specified or the default value if not set.
* @param string|null $name
* @param mixed $default
public function getResult(string $name = null, $default = null)
$name
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function getResult(/** @scrutinizer ignore-unused */ string $name = null, $default = null)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return $default;
* Return whether there is a result for the name specified.
* @return bool
public function hasResult(string $name = null): bool
public function hasResult(/** @scrutinizer ignore-unused */ string $name = null): bool
return false;