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 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);