Update packages-tests github action to use latest phpdoc-parser (#2467)

* Update packages-tests github action to use latest phpdoc-parser

* fix compat

* [ci-review] Rector Rectify

* update to use ExtendedMethodReflection

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2022-06-09 20:26:15 +07:00 committed by GitHub
parent 6f3eaff305
commit 712174b300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 13 deletions

View File

@ -47,9 +47,7 @@ jobs:
# test with current commit in a pull-request # test with current commit in a pull-request
- -
run: | run: composer require rector/rector-src dev-main#${{github.event.pull_request.head.sha}} --no-update
composer require phpstan/phpdoc-parser:1.5.* --no-update
composer require rector/rector-src dev-main#${{github.event.pull_request.head.sha}} --no-update
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
- run: composer install --ansi - run: composer install --ansi

View File

@ -7,7 +7,7 @@
], ],
"require": { "require": {
"php": "^7.2|^8.0", "php": "^7.2|^8.0",
"phpstan/phpstan": "^1.7.10" "phpstan/phpstan": "^1.7.12"
}, },
"autoload": { "autoload": {
"files": [ "files": [

View File

@ -120,8 +120,8 @@ CODE_SAMPLE
return new MethodCall(new Variable('this'), $arrayCallable->getMethod()); return new MethodCall(new Variable('this'), $arrayCallable->getMethod());
} }
$methodReflection = $classReflection->getNativeMethod($arrayCallable->getMethod()); $extendedMethodReflection = $classReflection->getNativeMethod($arrayCallable->getMethod());
return $this->nodeFactory->createClosureFromMethodReflection($methodReflection); return $this->nodeFactory->createClosureFromMethodReflection($extendedMethodReflection);
} }
private function isAssignedToNetteMagicOnProperty(Array_ $array): bool private function isAssignedToNetteMagicOnProperty(Array_ $array): bool

View File

@ -11,7 +11,7 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\VariadicPlaceholder; use PhpParser\Node\VariadicPlaceholder;
use PHPStan\Analyser\Scope; use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ExtendedMethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Reflection\ParametersAcceptorSelector;
use Rector\Core\Enum\ObjectReference; use Rector\Core\Enum\ObjectReference;
use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Exception\ShouldNotHappenException;
@ -138,26 +138,26 @@ final class CurrentAndParentClassMethodComparator
throw new ShouldNotHappenException(); throw new ShouldNotHappenException();
} }
$parentMethodReflection = $classReflection->getMethod($methodName, $scope); $extendedMethodReflection = $classReflection->getMethod($methodName, $scope);
// 3rd party code // 3rd party code
if (! $parentMethodReflection->isPrivate() && ! $parentMethodReflection->isPublic() && $classMethod->isPublic()) { if (! $extendedMethodReflection->isPrivate() && ! $extendedMethodReflection->isPublic() && $classMethod->isPublic()) {
return true; return true;
} }
if ($parentMethodReflection->isInternal()->yes()) { if ($extendedMethodReflection->isInternal()->yes()) {
// we can't know for certain so we assume its a override with purpose // we can't know for certain so we assume its a override with purpose
return true; return true;
} }
return $this->areParameterDefaultsDifferent($classMethod, $parentMethodReflection); return $this->areParameterDefaultsDifferent($classMethod, $extendedMethodReflection);
} }
private function areParameterDefaultsDifferent( private function areParameterDefaultsDifferent(
ClassMethod $classMethod, ClassMethod $classMethod,
MethodReflection $methodReflection ExtendedMethodReflection $extendedMethodReflection
): bool { ): bool {
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); $parametersAcceptor = ParametersAcceptorSelector::selectSingle($extendedMethodReflection->getVariants());
foreach ($parametersAcceptor->getParameters() as $key => $parameterReflection) { foreach ($parametersAcceptor->getParameters() as $key => $parameterReflection) {
if (! isset($classMethod->params[$key])) { if (! isset($classMethod->params[$key])) {