mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-12 22:22:24 +00:00
1f621e91a4
88eed987cc
Ensure check isFirstClassCallable() before node->getArgs() on CallLike (#4049)
23 lines
645 B
PHP
23 lines
645 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Php80\ValueObjectFactory;
|
|
|
|
use PhpParser\Node\Expr\FuncCall;
|
|
use Rector\Php80\ValueObject\StrStartsWith;
|
|
final class StrStartsWithFactory
|
|
{
|
|
public function createFromFuncCall(FuncCall $funcCall, bool $isPositive) : ?StrStartsWith
|
|
{
|
|
if ($funcCall->isFirstClassCallable()) {
|
|
return null;
|
|
}
|
|
if (\count($funcCall->getArgs()) < 2) {
|
|
return null;
|
|
}
|
|
$haystack = $funcCall->getArgs()[0]->value;
|
|
$needle = $funcCall->getArgs()[1]->value;
|
|
return new StrStartsWith($funcCall, $haystack, $needle, $isPositive);
|
|
}
|
|
}
|