for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JMS\Serializer\Type;
use Doctrine\Common\Lexer\AbstractLexer;
use Hoa\Exception\Exception;
use JMS\Serializer\Type\Exception\SyntaxError;
class Lexer extends AbstractLexer implements ParserInterface
{
public function parse(string $type): array
try {
return $this->getType($type);
return $this->getType($type)
null
array
$this->getType($type)
JMS\Serializer\Type\Lexer::getType()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
} catch (Exception $e) {
throw new SyntaxError($e->getMessage(), 0, $e);
}
protected function getCatchablePatterns(): array
return [
'(?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\)*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', // name
'(\+|\-)?(0|[1-9]\d*)(\.\d+)?', // number
'null',
'""|\'\'', // empty string
'"[^"]+"', // quoted string
"'[^']+'", // apostrophed string
];
protected function getNonCatchablePatterns(): array
// TODO: Implement getNonCatchablePatterns() method.
protected function getType(&$value)
// TODO: Implement getType() method.