Skip to content

Commit 3e0d7e1

Browse files
authored
[ci] add run with rector-laravel, to improve its support (#7740)
* [ci] add run with rector-laravel, to improve its support * restore used resolveMethodReflectionFromClassMethod()
1 parent d98976c commit 3e0d7e1

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Rector Laravel with dev-main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request: null
8+
9+
env:
10+
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
11+
COMPOSER_ROOT_VERSION: "dev-main"
12+
13+
jobs:
14+
rector_laravel_rector_dev:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
-
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.3
22+
coverage: none
23+
24+
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
25+
env:
26+
COMPOSER_TOKEN: ${{ secrets.ACCESS_TOKEN }}
27+
28+
- run: git clone https://github.com/driftingly/rector-laravel.git
29+
- run: composer require rector/rector:dev-main --working-dir rector-laravel
30+
- run: cd rector-laravel && vendor/bin/phpunit

src/Reflection/ReflectionResolver.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PhpParser\Node\Name;
1818
use PhpParser\Node\Stmt\Class_;
1919
use PhpParser\Node\Stmt\ClassLike;
20+
use PhpParser\Node\Stmt\ClassMethod;
2021
use PHPStan\Analyser\Scope;
2122
use PHPStan\Reflection\ClassReflection;
2223
use PHPStan\Reflection\FunctionReflection;
@@ -214,6 +215,22 @@ public function resolveFunctionLikeReflectionFromCall(
214215
return null;
215216
}
216217

218+
/**
219+
* @api used in rector-laravel
220+
*/
221+
public function resolveMethodReflectionFromClassMethod(ClassMethod $classMethod, Scope $scope): ?MethodReflection
222+
{
223+
$classReflection = $scope->getClassReflection();
224+
if (! $classReflection instanceof ClassReflection) {
225+
return null;
226+
}
227+
228+
$className = $classReflection->getName();
229+
$methodName = $this->nodeNameResolver->getName($classMethod);
230+
231+
return $this->resolveMethodReflection($className, $methodName, $scope);
232+
}
233+
217234
public function resolveMethodReflectionFromNew(New_ $new): ?MethodReflection
218235
{
219236
$newClassType = $this->nodeTypeResolver->getType($new->class);

0 commit comments

Comments
 (0)