Skip to content

Upgrade to phpstan 2.0 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 2, 2025

Conversation

glpzzz
Copy link
Contributor

@glpzzz glpzzz commented Jan 12, 2025

Q A
Is bugfix?
New feature? ✔️
Breaks BC? ✔️
Fixed issues Trying to upgrade to PHPStan 2.0

Just starting this by following https://github.com/phpstan/phpstan-src/blob/2.0.x/UPGRADING.md.

Any help is appreciated. Still getting some errors that I don't understand.

Summary by CodeRabbit

  • Chores
    • Updated static analysis workflow and configuration for improved rule coverage.
    • Bumped versions of PHPStan and related dependencies.
  • Refactor
    • Enhanced type checking and return type inference for more precise static analysis.
    • Improved code formatting and consistency, including the use of trailing commas.
    • Improved type resolution using reflection and argument-aware selection.
    • Adjusted property reflection instantiation for better property identification.
  • Tests
    • Minor formatting updates to test cases for consistency.

Copy link

codecov bot commented Jan 12, 2025

Codecov Report

Attention: Patch coverage is 0% with 58 lines in your changes missing coverage. Please review.

Project coverage is 15.38%. Comparing base (1788f68) to head (5746f6f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...veRecordDynamicStaticMethodReturnTypeExtension.php 0.00% 25 Missing ⚠️
...pe/ActiveQueryDynamicMethodReturnTypeExtension.php 0.00% 14 Missing ⚠️
...e/ActiveRecordDynamicMethodReturnTypeExtension.php 0.00% 6 Missing ⚠️
src/Type/ActiveRecordObjectType.php 0.00% 5 Missing ⚠️
...Type/ContainerDynamicMethodReturnTypeExtension.php 0.00% 5 Missing ⚠️
.../ApplicationPropertiesClassReflectionExtension.php 0.00% 1 Missing ⚠️
...lection/UserPropertiesClassReflectionExtension.php 0.00% 1 Missing ⚠️
...aderCollectionDynamicMethodReturnTypeExtension.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #12      +/-   ##
============================================
- Coverage     17.16%   15.38%   -1.78%     
- Complexity      125      131       +6     
============================================
  Files            14       14              
  Lines           268      299      +31     
============================================
  Hits             46       46              
- Misses          222      253      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

coderabbitai bot commented Jun 2, 2025

Walkthrough

The GitHub Actions workflow job was renamed from psalm to phpstan. Dependency versions for PHPStan and related packages were updated in composer.json. The PHPStan configuration was extended with bleeding edge rules. Various dynamic return type extensions and reflection classes were refined for improved type checks, argument-aware return type inference, and formatting consistency. Minor formatting changes and argument passing improvements were applied in code and tests.

Changes

File(s) Change Summary
.github/workflows/static.yml Renamed job from psalm to phpstan in GitHub Actions workflow.
composer.json Updated version constraints for phpstan/phpstan, phpstan/phpstan-phpunit, and yiisoft/yii2.
phpstan.neon Added inclusion of bleeding edge rules configuration.
src/Reflection/ApplicationPropertiesClassReflectionExtension.php, src/Reflection/UserPropertiesClassReflectionExtension.php Added trailing comma in constructor parameter list; passed $propertyName to DummyPropertyReflection constructor.
src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php Removed import; refactored method variants access; improved boolean argument checks; added trailing commas; updated signature.
src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php Removed unused import; changed argument type validation; improved exception formatting; updated method signature.
src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php Added ReflectionProvider injection; refactored type checks to use reflection; improved return type selection; formatting.
src/Type/ActiveRecordObjectType.php Replaced instance checks with constant string count checks for offset handling.
src/Type/ContainerDynamicMethodReturnTypeExtension.php Changed return type selection to argument-aware variant selection.
src/Type/HeaderCollectionDynamicMethodReturnTypeExtension.php Changed constant name extraction from direct property access to method call.
tests/ServiceMapTest.php Added trailing commas to constructor argument lists for formatting consistency.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant PHPStan
    participant Composer

    Developer->>Composer: Update phpstan and related package versions
    Developer->>phpstan.neon: Add bleeding edge rules include
    Developer->>GitHub Actions: Rename static analysis job to phpstan
    GitHub Actions->>PHPStan: Run static analysis with updated config
    PHPStan-->>Developer: Report analysis results
Loading

Poem

🐇
A rabbit hops through fields of code,
With PHPStan's new rules in its load.
Trailing commas, types checked twice,
Deprecations spotted—oh, that's nice!
Static analysis, sharp and bright,
The burrow's code now feels just right.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03e1a9a and 5746f6f.

📒 Files selected for processing (8)
  • composer.json (1 hunks)
  • phpstan.neon (1 hunks)
  • src/Reflection/ApplicationPropertiesClassReflectionExtension.php (2 hunks)
  • src/Reflection/UserPropertiesClassReflectionExtension.php (1 hunks)
  • src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (5 hunks)
  • src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php (2 hunks)
  • src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (3 hunks)
  • src/Type/ActiveRecordObjectType.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • phpstan.neon
  • composer.json
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/Reflection/UserPropertiesClassReflectionExtension.php (1)
src/Reflection/ComponentPropertyReflection.php (1)
  • ComponentPropertyReflection (12-85)
src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (2)
src/Type/ActiveQueryObjectType.php (3)
  • ActiveQueryObjectType (11-32)
  • getModelClass (18-21)
  • isAsArray (23-26)
src/Type/ActiveRecordObjectType.php (1)
  • ActiveRecordObjectType (14-42)
src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (4)
src/Reflection/RequestMethodsClassReflectionExtension.php (1)
  • __construct (17-17)
src/Reflection/RequestPropertiesClassReflectionExtension.php (1)
  • __construct (18-18)
src/Reflection/ResponsePropertiesClassReflectionExtension.php (1)
  • __construct (18-18)
src/Type/ActiveRecordObjectType.php (1)
  • ActiveRecordObjectType (14-42)
🪛 GitHub Check: codecov/patch
src/Reflection/UserPropertiesClassReflectionExtension.php

[warning] 36-36: src/Reflection/UserPropertiesClassReflectionExtension.php#L36
Added line #L36 was not covered by tests

src/Reflection/ApplicationPropertiesClassReflectionExtension.php

[warning] 52-52: src/Reflection/ApplicationPropertiesClassReflectionExtension.php#L52
Added line #L52 was not covered by tests

src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php

[warning] 40-44: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L40-L44
Added lines #L40 - L44 were not covered by tests


[warning] 66-66: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L66
Added line #L66 was not covered by tests


[warning] 76-80: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L76-L80
Added lines #L76 - L80 were not covered by tests


[warning] 87-87: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L87
Added line #L87 was not covered by tests


[warning] 99-99: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L99
Added line #L99 was not covered by tests


[warning] 107-107: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L107
Added line #L107 was not covered by tests

src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php

[warning] 47-47: src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php#L47
Added line #L47 was not covered by tests


[warning] 53-54: src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php#L53-L54
Added lines #L53 - L54 were not covered by tests


[warning] 59-60: src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php#L59-L60
Added lines #L59 - L60 were not covered by tests


[warning] 64-64: src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php#L64
Added line #L64 was not covered by tests

src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php

[warning] 27-27: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L27
Added line #L27 was not covered by tests


[warning] 30-30: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L30
Added line #L30 was not covered by tests


[warning] 43-45: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L43-L45
Added lines #L43 - L45 were not covered by tests


[warning] 48-48: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L48
Added line #L48 was not covered by tests


[warning] 55-60: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L55-L60
Added lines #L55 - L60 were not covered by tests


[warning] 66-71: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L66-L71
Added lines #L66 - L71 were not covered by tests


[warning] 75-75: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L75
Added line #L75 was not covered by tests


[warning] 84-88: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L84-L88
Added lines #L84 - L88 were not covered by tests


[warning] 103-103: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L103
Added line #L103 was not covered by tests

src/Type/ActiveRecordObjectType.php

[warning] 21-22: src/Type/ActiveRecordObjectType.php#L21-L22
Added lines #L21 - L22 were not covered by tests


[warning] 27-27: src/Type/ActiveRecordObjectType.php#L27
Added line #L27 was not covered by tests


[warning] 35-36: src/Type/ActiveRecordObjectType.php#L35-L36
Added lines #L35 - L36 were not covered by tests

🔇 Additional comments (16)
src/Reflection/ApplicationPropertiesClassReflectionExtension.php (2)

24-24: LGTM: Formatting improvement

The trailing comma addition follows modern PHP formatting conventions and improves maintainability.


52-52: LGTM: Correct PHPStan 2.0 API migration

The DummyPropertyReflection constructor now correctly receives the $propertyName argument, which aligns with PHPStan 2.0's updated API requirements. This change is consistent with the same update in UserPropertiesClassReflectionExtension.php.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 52-52: src/Reflection/ApplicationPropertiesClassReflectionExtension.php#L52
Added line #L52 was not covered by tests

src/Reflection/UserPropertiesClassReflectionExtension.php (1)

36-36: LGTM: Consistent PHPStan 2.0 API migration

The DummyPropertyReflection constructor change is correctly implemented, matching the same pattern applied in ApplicationPropertiesClassReflectionExtension.php on line 52. This ensures consistent usage of the updated PHPStan 2.0 API across reflection extensions.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 36-36: src/Reflection/UserPropertiesClassReflectionExtension.php#L36
Added line #L36 was not covered by tests

src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php (3)

37-37: LGTM: Formatting improvement

Adding the trailing comma follows modern PHP conventions and improves maintainability.


47-47: LGTM: Consistent formatting in error messages

The trailing commas in sprintf calls maintain consistency with the updated formatting style throughout the codebase.

Also applies to: 59-60

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 47-47: src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php#L47
Added line #L47 was not covered by tests


53-54: LGTM: Correct PHPStan 2.0 API migration for constant string handling

The migration from direct ConstantStringType instance checks to using getConstantStrings() correctly adapts to PHPStan 2.0's updated API. The logic maintains the same behavior:

  1. $argType->getConstantStrings() replaces the instanceof check
  2. count($constantStrings) === 0 ensures there are constant strings available
  3. $constantStrings[0]->getValue() safely accesses the first constant string's value

This pattern is consistent with similar changes in ActiveRecordObjectType.php.

Also applies to: 64-64

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 53-54: src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php#L53-L54
Added lines #L53 - L54 were not covered by tests

src/Type/ActiveRecordObjectType.php (2)

21-22: LGTM: Correct PHPStan 2.0 API migration in hasOffsetValueType

The migration from ConstantStringType instanceof checks to using getConstantStrings() correctly adapts to PHPStan 2.0's API changes. The logic flow is preserved:

  1. $offsetType->getConstantStrings() replaces direct type checking
  2. count($constantStrings) === 0 ensures there are constant strings
  3. $constantStrings[0]->getValue() safely retrieves the property name

This pattern is consistent with the changes in ActiveRecordDynamicMethodReturnTypeExtension.php.

Also applies to: 27-27

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 21-22: src/Type/ActiveRecordObjectType.php#L21-L22
Added lines #L21 - L22 were not covered by tests


35-36: LGTM: Consistent API migration in setOffsetValueType

The same PHPStan 2.0 API migration pattern is correctly applied here, ensuring consistent usage of the new constant string handling throughout the class.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 35-36: src/Type/ActiveRecordObjectType.php#L35-L36
Added lines #L35 - L36 were not covered by tests

src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (4)

25-31: Constructor implementation looks good.

The dependency injection of ReflectionProvider follows standard patterns and aligns with similar implementations in other reflection extension classes.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 27-27: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L27
Added line #L27 was not covered by tests


[warning] 30-30: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L30
Added line #L30 was not covered by tests


43-46: Good defensive programming with variants check.

Adding an explicit check for zero variants prevents potential issues and makes the code more robust.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 43-45: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L43-L45
Added lines #L43 - L45 were not covered by tests


66-74: Modernized type checking approach looks good.

The transition from ObjectType checks to getObjectClassNames() with reflection-based subclass checking aligns well with PHPStan 2.0 patterns and provides more precise type analysis.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 66-71: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L66-L71
Added lines #L66 - L71 were not covered by tests


84-88: Improved return type selection with argument awareness.

The change from ParametersAcceptorSelector::selectSingle() to ParametersAcceptorSelector::selectFromArgs() enables argument-aware and scope-aware return type resolution, which is a significant improvement for type inference accuracy.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 84-88: src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php#L84-L88
Added lines #L84 - L88 were not covered by tests

src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (4)

40-46: Simplified method variant access looks good.

The direct array access to method variants is cleaner and more straightforward than using ParametersAcceptorSelector::selectSingle(). The logic correctly checks for variants and examines the return type.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 40-44: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L40-L44
Added lines #L40 - L44 were not covered by tests


57-57: Consistent formatting with trailing comma.

Adding the trailing comma improves code consistency and makes future parameter additions cleaner.


76-87: Improved type checking precision for asArray method.

The change from checking ConstantBooleanType instances to explicitly using isTrue()->yes() and isFalse()->yes() provides more precise type introspection. This approach is more explicit and aligns with modern PHPStan type checking patterns.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 76-80: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L76-L80
Added lines #L76 - L80 were not covered by tests


[warning] 87-87: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L87
Added line #L87 was not covered by tests


99-99: Consistent formatting improvements.

The trailing commas after ActiveRecordObjectType instances improve code consistency across the file.

Also applies to: 107-107

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 99-99: src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php#L99
Added line #L99 was not covered by tests

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (1)

74-82: ⚠️ Potential issue

getValue() may throw when argument isn’t a ConstantBooleanType

$argType is only checked with $argType->isBoolean()->no().
For a variable boolean (e.g. $flag), the type can be BooleanType, which passes the boolean check but has no getValue() method.
Calling it will trigger a fatal error inside PHPStan’s runtime.

-$argType = isset($methodCall->args[0]) && $methodCall->args[0] instanceof Arg
-    ? $scope->getType($methodCall->args[0]->value) : new ConstantBooleanType(true);
-if ($argType->isBoolean()->no()) {
+$argType = isset($methodCall->args[0]) && $methodCall->args[0] instanceof Arg
+    ? $scope->getType($methodCall->args[0]->value)
+    : new ConstantBooleanType(true);
+
+// ensure we can safely call getValue()
+if (
+    !$argType instanceof ConstantBooleanType
+    || $argType->isBoolean()->no()
+) {
     throw new ShouldNotHappenException(
         sprintf('Invalid argument provided to asArray method at line %d', $methodCall->getLine()),
     );
 }
 
 return new ActiveQueryObjectType(
     $calledOnType->getModelClass(),
     $argType->getValue(),
 );

This guarantees getValue() is invoked only on a compatible type and avoids unexpected crashes during analysis.

🧹 Nitpick comments (2)
src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (1)

25-31: Consider constructor property promotion & immutability

Since PHP 8.1 you can shrink the boiler-plate and make the dependency immutable in one go:

-    private ReflectionProvider $reflectionProvider;
-
-    public function __construct(
-        ReflectionProvider $reflectionProvider,
-    ) {
-        $this->reflectionProvider = $reflectionProvider;
-    }
+    public function __construct(
+        private readonly ReflectionProvider $reflectionProvider,
+    ) {
+    }

This reduces noise and clearly communicates that the provider should not change after instantiation.

src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (1)

41-44: Use selectFromArgs() for argument-aware support checks

isMethodSupported() still relies on selectSingle(), which disregards actual call arguments.
Switching to ParametersAcceptorSelector::selectFromArgs() (as done elsewhere) would make the support check consistent with the upgraded return-type logic and prevent false negatives when a method has multiple variants.

No functional bug, but worth aligning for completeness.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1788f68 and 03e1a9a.

📒 Files selected for processing (11)
  • .github/workflows/static.yml (1 hunks)
  • composer.json (1 hunks)
  • phpstan.neon (1 hunks)
  • src/Reflection/ApplicationPropertiesClassReflectionExtension.php (1 hunks)
  • src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (5 hunks)
  • src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php (2 hunks)
  • src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (3 hunks)
  • src/Type/ActiveRecordObjectType.php (2 hunks)
  • src/Type/ContainerDynamicMethodReturnTypeExtension.php (1 hunks)
  • src/Type/HeaderCollectionDynamicMethodReturnTypeExtension.php (1 hunks)
  • tests/ServiceMapTest.php (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/Reflection/ApplicationPropertiesClassReflectionExtension.php (1)
src/ServiceMap.php (1)
  • ServiceMap (26-141)
src/Type/ActiveRecordObjectType.php (4)
src/Reflection/ApplicationPropertiesClassReflectionExtension.php (1)
  • hasProperty (27-40)
src/Reflection/ResponsePropertiesClassReflectionExtension.php (1)
  • hasProperty (20-27)
src/Reflection/UserPropertiesClassReflectionExtension.php (1)
  • hasProperty (20-28)
src/Reflection/RequestPropertiesClassReflectionExtension.php (1)
  • hasProperty (20-27)
src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php (2)
src/Type/ActiveRecordObjectType.php (1)
  • ActiveRecordObjectType (14-40)
src/Type/ActiveQueryObjectType.php (2)
  • getModelClass (18-21)
  • isAsArray (23-26)
🔇 Additional comments (11)
composer.json (1)

18-18: LGTM! Appropriate dependency for PHPStan 2.0 upgrade.

The addition of phpstan-deprecation-rules is a standard and recommended dependency when upgrading to PHPStan 2.0, as it helps identify deprecated features during static analysis.

src/Reflection/ApplicationPropertiesClassReflectionExtension.php (1)

24-24: LGTM! Good code style improvement.

The trailing comma addition improves diff readability and is consistent with modern PHP best practices. Since the project requires PHP 8.1+, this syntax is fully supported.

tests/ServiceMapTest.php (1)

48-48: LGTM! Consistent code style improvements.

The trailing comma additions across multiple test methods improve code style consistency and diff readability when modifying constructor arguments.

Also applies to: 61-61, 74-74

src/Type/HeaderCollectionDynamicMethodReturnTypeExtension.php (1)

48-48: LGTM! Necessary API adaptation for PHPStan 2.0.

The change from direct property access (parts[0]) to method call (getParts()[0]) is a typical API evolution in PHPStan 2.0, where direct property access is replaced with method calls for better encapsulation while maintaining the same functionality.

src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php (2)

37-37: LGTM! Code style improvements.

The trailing comma additions improve code consistency and readability, aligning with the broader style improvements across the codebase.

Also applies to: 47-47, 58-59


53-53: LGTM! Correct API adaptation for PHPStan 2.0.

The change from instanceof ConstantStringType to count($argType->getConstantStrings()) === 0 is a proper adaptation to PHPStan 2.0's API changes. The logic remains correct - checking if there are no constant strings available rather than checking the type instance directly.

src/Type/ActiveRecordObjectType.php (2)

21-21: LGTM! Correct PHPStan 2.0 API migration.

The change from instanceof ConstantStringType to count($offsetType->getConstantStrings()) === 0 correctly implements the PHPStan 2.0 API migration pattern.


34-34: LGTM! Consistent API migration pattern.

The change to use count($offsetType->getConstantStrings()) > 0 instead of instanceof checks aligns with the PHPStan 2.0 upgrade and maintains the same logical behavior.

phpstan.neon (1)

5-6: LGTM! Enhanced PHPStan 2.0 configuration.

The addition of bleeding edge rules and deprecation rules enhances the static analysis capabilities and aligns well with the PHPStan 2.0 upgrade objectives.

.github/workflows/static.yml (1)

25-25: LGTM! Correct job name update.

The job name change from psalm to phpstan correctly reflects the migration to PHPStan 2.0 for static analysis.

src/Type/ContainerDynamicMethodReturnTypeExtension.php (1)

45-49: LGTM! Improved argument-aware type inference.

The change from ParametersAcceptorSelector::selectSingle to selectFromArgs with scope and arguments consideration provides more accurate return type inference by selecting the appropriate variant based on the actual method call context.

@terabytesoftw terabytesoftw merged commit 1aecdf2 into yii2-extensions:main Jun 2, 2025
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants