for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Patsura Dmitry https://github.com/ovr <[email protected]>
*/
namespace PHPSA\Analyzer\Helper;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Stmt\Return_;
use PHPSA\Context;
trait ResolveExpressionTrait
{
* @param FuncCall $funcCall
* @param Context $context
* @return string|bool
* @throws \PHPSA\Exception\RuntimeException
public function resolveFunctionName(FuncCall $funcCall, Context $context)
$funcNameCompiledExpression = $context->getExpressionCompiler()->compile($funcCall->name);
$funcNameCompiledExpression
20
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.
if ($funcNameCompiledExpression->isString() && $funcNameCompiledExpression->isCorrectValue()) {
return $funcNameCompiledExpression->getValue();
} else {
$context->debug(
'Unexpected function name type ' . $funcNameCompiledExpression->getType(),
$funcCall->name
);
}
return false;
* @param \PhpParser\Node[] $nodes
* @return \PhpParser\Node\Stmt\Return_
private function findReturnStatement(array $nodes)
foreach ($nodes as $node) {
if ($node instanceof Return_) {
yield $node;
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.