Commit dfe1c16
feature: Bump phpstan to the level10, enable PHP8.5 (#156)
* feat: Initialize Claude for the repository
* feat: use phpstan in the pipeline with level:5
* chore: fix all PHPStan level 5 errors
- Fix type mismatches in NodeExpressionResolver, TypeExpressionResolver,
ReflectionClassLikeTrait, and ReflectionFunctionLikeTrait
- Remove unused constructor parameter from TypeExpressionResolver
- Fix ClassLike property access with proper instanceof narrowing in ReflectionClass
- Fix array key types and dead code in ReflectionClassLikeTrait
- Add ignoreErrors for unset.possiblyHookedProperty in final classes
ReflectionFunction and ReflectionMethod (false positive: final classes
cannot have subclasses with hooks)
- Replace array_reduce with foreach to fix callable type inference
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix PHPStan level 6 errors
Add missing PHPDoc type annotations for generic types and iterable value
types across all source files:
- Add @extends ReflectionClass<object> and ReflectionAttribute<object>
- Type all array<K, V> properties and return types
- Add ReflectionClass<object> generics to method return types
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix PHPStan level 7 errors
Fix actual type errors surfaced at level 7:
- Fix PathResolver::realpath() return type to reflect recursive return
- Add instanceof guards before accessing Arg::$value and Const_::$value
- Fix ReflectionAttribute::getTypeNode() union type check
- Add false-check around fetchReflectionClass() calls in NodeExpressionResolver
- Fix constants property key type (int|string instead of string)
- Add @return class-string and non-empty-string overrides for getName/getShortName
- Fix getNamespaceName() method.notFound by guarding against ReflectionAttribute
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix PHPStan level 8 errors
Fix null-safety and type-safety issues:
- Add null guards for ReflectionEngine::$locator before use
- Fix NodeTraverser::traverse() call with null-safe ?? []
- Add null checks before TypeExpressionResolver::process() calls
- Add null check for Identifier::toString() in findClassLikeNodeByClassName
- Fix offsetAccess.notFound in PathResolver by guarding string|null
- Add null guards around method_exists() calls in NodeExpressionResolver
- Fix $constOrEnumCaseNode null assignment in ReflectionClassConstant
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix PHPStan level 9 errors
Fix mixed-type propagation from PhpParser Node::getAttribute() calls:
- Use hasAttribute() + explicit casts for getStartLine/getEndLine/getFileName
- Add instanceof Name guards before calling toString() on getAttribute() results
- Fix array key types by guarding with is_string()/is_int() checks
- Fix StaticVariablesCollector context type to match NodeExpressionResolver
- Fix sprintf with mixed value in ReflectionClassConstant
- Fix TypeExpressionResolver return types with explicit typed returns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: fix PHPStan level 10 errors
Fix remaining mixed-type and type-safety issues at level 10:
- Add abstract getNodeForAttributes() to AttributeResolverTrait for typed node access
- Fix CallableLocator return type with explicit string|false narrowing
- Fix ReflectionClassConstant::gettype() usage with proper array key narrowing
- Fix NodeExpressionResolver getAttribute() mixed results with type guards
- Fix ReflectionFileNamespace getAttribute() calls with proper int|false returns
- Fix ReflectionUnionType array_search with proper array type
- Filter Stringable objects in ReflectionClassLikeTrait::__toString() buildString
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: resolve self/parent type hints to actual class names
Native PHP reflection resolves 'self' to the declaring class FQCN and
'parent' to the parent class FQCN in type hints. The parser-based
TypeExpressionResolver was returning the literals 'self'/'parent'.
- Add optional $selfClassName/$parentClassName to TypeExpressionResolver
- Add getDeclaringClassNameForTypes()/getParentClassNameForTypes() hook
methods to ReflectionFunctionLikeTrait (default null for functions)
- Override both hooks in ReflectionMethod with the declaring class names
- Pass declaring class context when constructing TypeExpressionResolver
in ReflectionParameter, ReflectionProperty, ReflectionClassConstant
- Keep 'static' unresolved (preserved as-is by native PHP reflection)
Fixes all 4 previously failing PHPUnit tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: Remove the treatPhpDocTypesAsCertain: false for phpstan
* fix: Remove old source code that causes deprecation warnings
* fix: address PR review comments
- Remove class_alias() from resolveAsClassString() and resolveAttributeClassName()
(global side-effect; class names from AST are semantically class-strings by
construction). Add ignoreErrors entries for these two known PHPStan limitations.
- Convert silent continue statements to explicit ReflectionException throws in
NodeExpressionResolver (variadic placeholders, non-scalar named arg keys,
non-scalar array keys) and ReflectionFileNamespace (define() with unsupported args).
- Fix PathResolver::realpath() unsafe $path[1] indexing — use regex-based Windows
drive letter detection (matches PR suggestion).
- Fix ReflectionProperty::setValue() to check isStatic() before validating object arg,
consistent with native ReflectionProperty behavior.
- Remove always-true PHP_VERSION_ID >= 80400 guards in ReflectionProperty::getModifiers()
since composer.json now requires PHP >= 8.4.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tests): Cover misc deprecations
* fix: resolve self/parent types only on PHP 8.5+ to match native behavior
PHP 8.5 changed ReflectionNamedType::getName() to return the actual FQCN
for 'self' and 'parent' type hints, whereas PHP 8.4 and earlier return
the keywords as-is. Gate the resolution behind PHP_VERSION_ID >= 80500
so the library mirrors native reflection behavior on all supported versions.
Fixes CI failures on PHP 8.4 builds.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(property): restore single-arg setValue() for static properties
setValue(\$value) with one argument is the canonical PHP 8.4+ way to set
a static property value. The previous implementation silently forwarded
null as the value because \$value defaulted to null.
Also update CLAUDE.md to reflect the actual PHP >=8.4 requirement.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent dcd0363 commit dfe1c16
33 files changed
Lines changed: 1033 additions & 347 deletions
File tree
- .github/workflows
- src
- Instrument
- Locator
- NodeVisitor
- Resolver
- Traits
- tests
- Stub
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | | - | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 24 | | |
28 | | - | |
| 25 | + | |
29 | 26 | | |
30 | | - | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
37 | 33 | | |
38 | 34 | | |
39 | 35 | | |
40 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
41 | 39 | | |
42 | 40 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
| 27 | + | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
| |||
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | | - | |
| 55 | + | |
| 56 | + | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | | - | |
| 30 | + | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | | - | |
| 40 | + | |
35 | 41 | | |
36 | | - | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
| |||
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
65 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
| |||
75 | 85 | | |
76 | 86 | | |
77 | 87 | | |
| 88 | + | |
| 89 | + | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| |||
0 commit comments