for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Railt package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Railt\SDL\Compiler\Ast\Dependent;
use Railt\Parser\Ast\Rule;
use Railt\Reflection\Contracts\Invocation\TypeInvocation;
use Railt\Reflection\Invocation\Dependent\ArgumentInvocation;
use Railt\Reflection\Invocation\DirectiveInvocation;
use Railt\SDL\Compiler\Ast\Value\ValueInterface;
use Railt\SDL\Compiler\Ast\Value\ValueNode;
* Class DirectiveArgumentNode
class DirectiveArgumentNode extends Rule
{
* @param DirectiveInvocation $parent
* @return TypeInvocation|ArgumentInvocation
public function getTypeInvocation(DirectiveInvocation $parent): TypeInvocation
$argument = new ArgumentInvocation($parent, $this->getArgumentName(), $this->getArgumentValue()->toPrimitive());
ArgumentInvocation::__construct()
$value
This check looks for function calls that miss required arguments.
$this->getArgumentName()
string
object<Railt\Reflection\Document>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$argument->withOffset($this->getOffset());
return $argument;
}
* @return string
public function getArgumentName(): string
return $this->first('T_NAME', 1)->getValue();
getValue()
Railt\Parser\Ast\NodeInterface
getValues()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
* @return ValueInterface
public function getArgumentValue(): ValueInterface
/** @var ValueNode $value */
$value = $this->first('Value', 1);
return $value->getInnerValue();
This check looks for function calls that miss required arguments.