Skip to content

Commit

Permalink
Update nikic/php-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 20, 2021
1 parent d484ea8 commit 1c6ce5d
Show file tree
Hide file tree
Showing 144 changed files with 452 additions and 438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public function isMethodSupported(MethodReflection $methodReflection): bool

public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
{
if (count($methodCall->args) === 0) {
if (count($methodCall->getArgs()) === 0) {
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
}
$argType = $scope->getType($methodCall->args[0]->value);
$argType = $scope->getType($methodCall->getArgs()[0]->value);
if (!$argType instanceof ConstantStringType) {
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
}

$type = new ObjectType($argType->getValue());
if ($methodReflection->getName() === 'getByType' && count($methodCall->args) >= 2) {
$argType = $scope->getType($methodCall->args[1]->value);
if ($methodReflection->getName() === 'getByType' && count($methodCall->getArgs()) >= 2) {
$argType = $scope->getType($methodCall->getArgs()[1]->value);
if ($argType instanceof ConstantBooleanType && $argType->getValue()) {
$type = TypeCombinator::addNull($type);
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"nette/neon": "^3.0",
"nette/schema": "^1.0",
"nette/utils": "^3.1.3",
"nikic/php-parser": "dev-master as 4.12.0",
"nikic/php-parser": "4.13.0",
"ondram/ci-detector": "^3.4.0",
"ondrejmirtes/better-reflection": "4.3.69",
"ondrejmirtes/better-reflection": "4.3.70",
"phpstan/php-8-stubs": "^0.1.23",
"phpstan/phpdoc-parser": "^1.2.0",
"react/child-process": "^0.6.1",
Expand Down
41 changes: 16 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -1505,15 +1505,15 @@ private function resolveType(Expr $node): Type
if (
$functionName === 'array_map'
&& $argOrder === 0
&& isset($funcCall->args[1])
&& isset($funcCall->getArgs()[1])
) {
if (!isset($funcCall->args[2])) {
if (!isset($funcCall->getArgs()[2])) {
$callableParameters = [
new DummyParameter('item', $this->getType($funcCall->args[1]->value)->getIterableValueType(), false, PassedByReference::createNo(), false, null),
new DummyParameter('item', $this->getType($funcCall->getArgs()[1]->value)->getIterableValueType(), false, PassedByReference::createNo(), false, null),
];
} else {
$callableParameters = [];
foreach ($funcCall->args as $i => $funcCallArg) {
foreach ($funcCall->getArgs() as $i => $funcCallArg) {
if ($i === 0) {
continue;
}
Expand Down Expand Up @@ -2269,7 +2269,7 @@ private function resolveType(Expr $node): Type

return ParametersAcceptorSelector::selectFromArgs(
$this,
$node->args,
$node->getArgs(),
$calledOnType->getCallableParametersAcceptors($this)
)->getReturnType();
}
Expand All @@ -2289,7 +2289,7 @@ private function resolveType(Expr $node): Type

return ParametersAcceptorSelector::selectFromArgs(
$this,
$node->args,
$node->getArgs(),
$functionReflection->getVariants()
)->getReturnType();
}
Expand Down Expand Up @@ -3358,7 +3358,7 @@ public function isParameterValueNullable(Node\Param $parameter): bool

/**
* @api
* @param \PhpParser\Node\Name|\PhpParser\Node\Identifier|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|null $type
* @param \PhpParser\Node\Name|\PhpParser\Node\Identifier|\PhpParser\Node\ComplexType|null $type
* @param bool $isNullable
* @param bool $isVariadic
* @return Type
Expand Down Expand Up @@ -4891,7 +4891,7 @@ private function exactInstantiation(New_ $node, string $className): ?Type
$methodCall = new Expr\StaticCall(
new Name($resolvedClassName),
new Node\Identifier($constructorMethod->getName()),
$node->args
$node->getArgs()
);

foreach ($this->dynamicReturnTypeExtensionRegistry->getDynamicStaticMethodReturnTypeExtensionsForClass($classReflection->getName()) as $dynamicStaticMethodReturnTypeExtension) {
Expand Down Expand Up @@ -4958,7 +4958,7 @@ private function exactInstantiation(New_ $node, string $className): ?Type

$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
$this,
$methodCall->args,
$methodCall->getArgs(),
$constructorMethod->getVariants()
);

Expand Down Expand Up @@ -5070,7 +5070,7 @@ private function methodCallReturnType(Type $typeWithMethod, string $methodName,

return ParametersAcceptorSelector::selectFromArgs(
$this,
$methodCall->args,
$methodCall->getArgs(),
$methodReflection->getVariants()
)->getReturnType();
}
Expand Down

0 comments on commit 1c6ce5d

Please sign in to comment.