From 10c9d8bf8491f4b80a7233582110b2b04426036f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 22:51:35 +0100 Subject: [PATCH 1/2] [ci] add run with rector-laravel, to improve its support --- .../rector_laravel_rector_dev.yaml.yml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/rector_laravel_rector_dev.yaml.yml diff --git a/.github/workflows/rector_laravel_rector_dev.yaml.yml b/.github/workflows/rector_laravel_rector_dev.yaml.yml new file mode 100644 index 00000000000..ad80c419076 --- /dev/null +++ b/.github/workflows/rector_laravel_rector_dev.yaml.yml @@ -0,0 +1,30 @@ +name: Rector Laravel with dev-main + +on: + push: + branches: + - main + pull_request: null + +env: + # see https://github.com/composer/composer/issues/9368#issuecomment-718112361 + COMPOSER_ROOT_VERSION: "dev-main" + +jobs: + rector_laravel_rector_dev: + runs-on: ubuntu-latest + + steps: + - + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + coverage: none + + # fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth + env: + COMPOSER_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + - run: git clone https://github.com/driftingly/rector-laravel.git + - run: composer require rector/rector:dev-main --working-dir rector-laravel + - run: cd rector-laravel && vendor/bin/phpunit From 5d1150ceb30b4ffee12825c9aba0516254bbde0d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 22:56:32 +0100 Subject: [PATCH 2/2] restore used resolveMethodReflectionFromClassMethod() --- src/Reflection/ReflectionResolver.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Reflection/ReflectionResolver.php b/src/Reflection/ReflectionResolver.php index 2ff0ca16f5c..deb23cddf9f 100644 --- a/src/Reflection/ReflectionResolver.php +++ b/src/Reflection/ReflectionResolver.php @@ -17,6 +17,7 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassLike; +use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\FunctionReflection; @@ -214,6 +215,22 @@ public function resolveFunctionLikeReflectionFromCall( return null; } + /** + * @api used in rector-laravel + */ + public function resolveMethodReflectionFromClassMethod(ClassMethod $classMethod, Scope $scope): ?MethodReflection + { + $classReflection = $scope->getClassReflection(); + if (! $classReflection instanceof ClassReflection) { + return null; + } + + $className = $classReflection->getName(); + $methodName = $this->nodeNameResolver->getName($classMethod); + + return $this->resolveMethodReflection($className, $methodName, $scope); + } + public function resolveMethodReflectionFromNew(New_ $new): ?MethodReflection { $newClassType = $this->nodeTypeResolver->getType($new->class);