Skip to content

Conversation

terabytesoftw
Copy link
Member

@terabytesoftw terabytesoftw commented Jun 12, 2025

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

Summary by CodeRabbit

  • New Features

    • Added comprehensive tests validating PHPStan type inference for Yii Active Record queries, relations, and static methods, covering array and object result modes.
    • Introduced new stub classes: Category, Post, and PostQuery for enhanced testing scenarios.
    • Enhanced User and MyActiveRecord stubs to improve static analysis coverage.
  • Bug Fixes

    • Improved accuracy and robustness of dynamic return type inference for Yii ActiveQuery and ActiveRecord methods.
  • Refactor

    • Replaced custom PHPStan object types with native generic types for clearer and more precise type inference.
    • Removed deprecated custom PHPStan object types for ActiveQuery and ActiveRecord.
    • Improved documentation and code clarity in type extension classes.
  • Chores

    • Updated static analysis configuration to include tests directory and Yii2-specific settings.
    • Adjusted dependency version constraints for better compatibility.
    • Expanded symbol whitelist for static analysis tools.

…ensions for improved type inference and error handling; remove deprecated `ActiveQueryObjectType` and `ActiveRecordObjectType` classes.
@terabytesoftw terabytesoftw added the enhancement New feature or request label Jun 12, 2025
Copy link

coderabbitai bot commented Jun 12, 2025

Walkthrough

This update refactors and enhances PHPStan return type extensions for Yii2 Active Record, replacing custom type classes with PHPStan generics, improving type inference logic, and expanding test coverage. It also updates configuration files, removes obsolete stubs, and introduces comprehensive tests to validate dynamic return type inference for queries and relations.

Changes

Files/Groups Change Summary
composer.json Changed Yii2 dependency version constraint from range to branch alias (dev-master).
extension.neon Reordered service definitions; no functional change.
phpstan.neon Included tests directory for analysis and added Yii2-specific config path.
src/type/ActiveQueryDynamicMethodReturnTypeExtension.php Major refactor: switched to PHPStan generics, improved type inference for ActiveQuery methods, added PHPDoc property extraction, enhanced control flow, and added new helper methods.
src/type/ActiveRecordDynamicMethodReturnTypeExtension.php Refactored to use PHPStan generics, improved documentation, and stricter argument checks.
src/type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php Enhanced type checks, improved generic type inference, added helper methods, and clarified documentation.
src/type/ActiveQueryObjectType.php
src/type/ActiveRecordObjectType.php
Deleted custom type classes for ActiveQuery and ActiveRecord; replaced by PHPStan generics in extensions.
tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php
tests/fixture/data/types/ActiveRecordDynamicMethodReturnType.php
tests/fixture/data/types/ActiveRecordDynamicStaticMethodReturnType.php
Added comprehensive test classes for dynamic return type inference in ActiveQuery, ActiveRecord relations, and static methods.
tests/stub/Category.php Added new Category ActiveRecord stub class for testing.
tests/stub/MyActiveRecord.php Revised PHPDoc for clarity and detail; no code changes.
tests/stub/User.php Refactored: removed identity interface and methods, added explicit properties, table name, and rules.
tests/stub/MyController.php Deleted obsolete controller stub used for property and service access tests.
tests/type/ActiveQueryDynamicReturnTypeExtensionTest.php
tests/type/ActiveRecordDynamicMethodReturnTypeExtensionTest.php
tests/type/ActiveRecordDynamicStaticMethodReturnTypeExtensionTest.php
Added new test classes to validate type inference for dynamic return type extensions using data providers and fixture files.
composer-require-checker.json Added PHPStan classes to symbol whitelist to support new generic and constant array types.
tests/stub/Post.php
tests/stub/PostQuery.php
Added new Post ActiveRecord stub and corresponding PostQuery class with a custom query method.

Sequence Diagram(s)

sequenceDiagram
    participant TestSuite
    participant PHPStanExtension
    participant YiiActiveRecord
    participant PHPStanTypeSystem

    TestSuite->>PHPStanExtension: Invoke method/chain (e.g., find()->asArray()->all())
    PHPStanExtension->>YiiActiveRecord: Analyze method call and arguments
    PHPStanExtension->>PHPStanTypeSystem: Extract model type, infer return type (using generics)
    PHPStanTypeSystem-->>PHPStanExtension: Return inferred type (e.g., ActiveQuery<Model>, array<Model>, Model|null)
    PHPStanExtension-->>TestSuite: Provide inferred type for assertion
Loading

Suggested labels

bug

Poem

In the warren of code, the rabbits hopped fast,
Swapping custom types for generics at last.
With tests all a-bloom and config anew,
The queries and records now type-checked true.
🐇✨ Static analysis, rejoice and delight—
For PHPStan and Yii2 now see the light!


📜 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 91c54f3 and ba717e9.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

🪧 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

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b8ac51b) to head (ba717e9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #36   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity        60        60           
===========================================
  Files              1         1           
  Lines             91        91           
===========================================
  Hits              91        91           

☔ 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 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: 4

🔭 Outside diff range comments (1)
src/type/ActiveRecordDynamicMethodReturnTypeExtension.php (1)

89-96: 🛠️ Refactor suggestion

Prefer instanceof for clarity & safety

$arg::class !== Arg::class works but:

  1. It’s harder to read than ! $arg instanceof Arg.
  2. It assumes $arg is an object; if a non-object sneaks in the expression will fatal-error before the null-check.
-        if ($arg === null || $arg::class !== Arg::class) {
+        if (! $arg instanceof Arg) {

Same null-safety and intent, fewer pitfalls.

🧹 Nitpick comments (12)
tests/stub/MyActiveRecord.php (2)

32-34: PHPDoc generic self<string, mixed> is not a recognised PHPStan notation.

self is already the concrete class; providing two generic parameters to it is meaningless and will be ignored (or flagged) by PHPStan.
Drop the parameters or use the proper ActiveQuery<self> pattern when you need generics.

- * @return self<string, mixed>|null
+ * @return self|null

24-25: Dynamic property $flag ought to be declared to avoid PHP 8.2 deprecation notices.

The docblock advertises @property bool $flag, but there is no typed property nor __get() implementation.
Either add a real property or remove the annotation to keep the stub noise-free.

tests/stub/Category.php (1)

42-49: Minor: validation rules can omit defaults when using typed nullable property.

Because $parent_id is already nullable and initialised to null, the 'default' rule can be removed:

-            [['parent_id'], 'default', 'value' => null],

Nit-level only.

tests/stub/User.php (1)

32-34: Public properties may shadow AR attributes

Declaring $id, $name, and $email as public properties hard-codes default values that will override any values loaded from the DB, which can lead to confusing test failures if the fixture ever exercises persistence.
Leaving them un-initialised or making them protected and relying on AR’s magic access is usually safer for stubs.

-    public int $id = 1;
-    public string $name = 'John Doe';
-    public string $email = 'john@example.com';
+    /** @var int */
+    public $id;
+
+    /** @var string */
+    public $name;
+
+    /** @var string */
+    public $email;
tests/type/ActiveQueryDynamicReturnTypeExtensionTest.php (1)

7-10: Remove unused import

yii\db\ActiveQuery is never referenced in this test class. Keeping the import can trip strict-rules linters.

-use yii\db\ActiveQuery;
src/type/ActiveRecordDynamicMethodReturnTypeExtension.php (1)

102-115: Handle multiple constant-string arguments

Currently the first constant string is taken blindly:

$modelClass = $constantStrings[0]->getValue();

If the analyser sees a union like User::class|Category::class, only User is used, losing precision.
Iterating and building a union (or a GenericObjectType per item merged via TypeCombinator::union()) would keep inference exact.

src/type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (2)

54-57: Docblock references deleted class

ActiveQueryObjectType was removed in this PR, yet the constructor doc still says “Creates a new instance of the ActiveQueryObjectType”. Update the comment to avoid confusion.


212-218: Custom query subclasses lose their identity

When the return type is a generic ActiveQuery, the extension correctly wraps the model type, but for subclasses you still replace the concrete class with plain ActiveQuery::class.

Consider:

class PostQuery extends ActiveQuery {}
Post::find(); // should return GenericObjectType(PostQuery::class, [Post::class])

Preserve $classNames[0] instead of hard-coding.

src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (1)

462-472: Fluent chain drops concrete query subclass

preserveModelType() always returns a new ActiveQuery generic when $calledOnType isn’t the generic root type.
Instead, construct the generic with the original class name to keep IDE autocompletion for custom query APIs.

tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php (1)

12-34: Overly verbose docblock

The 20-line header repeats information already covered by the filename and test names.
Trimming it will keep fixtures lightweight.

tests/fixture/data/types/ActiveRecordDynamicMethodReturnType.php (1)

12-33: Consider slimming down the header

Large per-fixture docblocks add noise; a brief sentence is sufficient.

tests/fixture/data/types/ActiveRecordDynamicStaticMethodReturnType.php (1)

12-34: Reduce boilerplate in test header

Keeping fixtures minimal improves readability and diff clarity.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8ac51b and 8f0655a.

📒 Files selected for processing (18)
  • composer.json (1 hunks)
  • extension.neon (1 hunks)
  • phpstan.neon (2 hunks)
  • src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (5 hunks)
  • src/type/ActiveQueryObjectType.php (0 hunks)
  • src/type/ActiveRecordDynamicMethodReturnTypeExtension.php (5 hunks)
  • src/type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (4 hunks)
  • src/type/ActiveRecordObjectType.php (0 hunks)
  • tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php (1 hunks)
  • tests/fixture/data/types/ActiveRecordDynamicMethodReturnType.php (1 hunks)
  • tests/fixture/data/types/ActiveRecordDynamicStaticMethodReturnType.php (1 hunks)
  • tests/stub/Category.php (1 hunks)
  • tests/stub/MyActiveRecord.php (1 hunks)
  • tests/stub/MyController.php (0 hunks)
  • tests/stub/User.php (1 hunks)
  • tests/type/ActiveQueryDynamicReturnTypeExtensionTest.php (1 hunks)
  • tests/type/ActiveRecordDynamicMethodReturnTypeExtensionTest.php (1 hunks)
  • tests/type/ActiveRecordDynamicStaticMethodReturnTypeExtensionTest.php (1 hunks)
💤 Files with no reviewable changes (3)
  • src/type/ActiveQueryObjectType.php
  • tests/stub/MyController.php
  • src/type/ActiveRecordObjectType.php
🧰 Additional context used
🧬 Code Graph Analysis (9)
tests/stub/Category.php (1)
tests/stub/User.php (2)
  • tableName (36-39)
  • rules (41-48)
tests/stub/User.php (1)
tests/stub/Category.php (2)
  • tableName (37-40)
  • rules (42-49)
tests/type/ActiveQueryDynamicReturnTypeExtensionTest.php (2)
tests/type/ActiveRecordDynamicMethodReturnTypeExtensionTest.php (3)
  • DataProvider (48-52)
  • dataFileAsserts (36-41)
  • getAdditionalConfigFiles (43-46)
tests/type/ActiveRecordDynamicStaticMethodReturnTypeExtensionTest.php (3)
  • DataProvider (50-54)
  • dataFileAsserts (36-43)
  • getAdditionalConfigFiles (45-48)
tests/type/ActiveRecordDynamicMethodReturnTypeExtensionTest.php (2)
tests/type/ActiveQueryDynamicReturnTypeExtensionTest.php (3)
  • DataProvider (48-52)
  • dataFileAsserts (36-41)
  • getAdditionalConfigFiles (43-46)
tests/type/ActiveRecordDynamicStaticMethodReturnTypeExtensionTest.php (3)
  • DataProvider (50-54)
  • dataFileAsserts (36-43)
  • getAdditionalConfigFiles (45-48)
tests/type/ActiveRecordDynamicStaticMethodReturnTypeExtensionTest.php (2)
tests/type/ActiveQueryDynamicReturnTypeExtensionTest.php (3)
  • DataProvider (48-52)
  • dataFileAsserts (36-41)
  • getAdditionalConfigFiles (43-46)
tests/type/ActiveRecordDynamicMethodReturnTypeExtensionTest.php (3)
  • DataProvider (48-52)
  • dataFileAsserts (36-41)
  • getAdditionalConfigFiles (43-46)
tests/fixture/data/types/ActiveRecordDynamicMethodReturnType.php (3)
tests/stub/Category.php (1)
  • Category (31-50)
tests/stub/MyActiveRecord.php (1)
  • MyActiveRecord (29-54)
tests/stub/User.php (1)
  • User (30-49)
tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php (1)
tests/stub/MyActiveRecord.php (1)
  • MyActiveRecord (29-54)
tests/fixture/data/types/ActiveRecordDynamicStaticMethodReturnType.php (3)
tests/stub/Category.php (1)
  • Category (31-50)
tests/stub/MyActiveRecord.php (1)
  • MyActiveRecord (29-54)
tests/stub/User.php (1)
  • User (30-49)
src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (4)
src/type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (2)
  • __construct (58-58)
  • getClass (73-76)
src/reflection/UserPropertiesClassReflectionExtension.php (1)
  • __construct (57-61)
src/reflection/ComponentPropertyReflection.php (4)
  • __construct (46-50)
  • getDocComment (111-116)
  • getReadableType (129-132)
  • getType (145-148)
src/type/ActiveRecordDynamicMethodReturnTypeExtension.php (2)
  • isMethodSupported (127-130)
  • getClass (62-65)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: phpunit / PHP 8.1-windows-latest
  • GitHub Check: phpunit / PHP 8.3-windows-latest
  • GitHub Check: phpunit / PHP 8.4-windows-latest
  • GitHub Check: phpunit / PHP 8.2-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.4-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.3-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.2-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
🔇 Additional comments (5)
composer.json (1)

14-15: Avoid pinning to dev-master; prefer a tagged constraint or explicit branch alias.

Requiring yiisoft/yii2 at dev-master forces every downstream consumer of this library into minimum-stability=dev, which is generally discouraged for published packages.
Consider one of the following instead:

-        "yiisoft/yii2": "dev-master"
+        "yiisoft/yii2": "^2.0.52 || ^2.2@dev"   # keep dev only for 2.2 line

or add "minimum-stability": "dev", "prefer-stable": true so that consumers understand the intent.

Would you double-check whether any feature used in the new extensions actually requires code that is only available on the master branch?

phpstan.neon (1)

30-32:

✅ Verification successful

Verify that tests/fixture/config/config.php exists and is load-safe.

A wrong path will make PHPStan silently ignore the bootstrap and the new return-type extensions will misbehave.


🏁 Script executed:

#!/bin/bash
# Ensure the referenced config file actually exists
test -f tests/fixture/config/config.php && echo "✓ config present" || echo "✗ missing config"

Length of output: 84


🏁 Script executed:

#!/bin/bash
# Verify that config.php is syntactically valid (load-safe)
php -l tests/fixture/config/config.php && echo "✓ config.php syntax is valid" || echo "✗ syntax errors detected"

Length of output: 168


phpstan.neon config_path verified

  • tests/fixture/config/config.php exists
  • Syntax check passed (no errors)
extension.neon (1)

44-46: Service reorder looks fine.

Moving HeaderCollectionDynamicMethodReturnTypeExtension further down does not affect autowiring; DI container order is preserved. No action required.

tests/type/ActiveRecordDynamicMethodReturnTypeExtensionTest.php (1)

31-53: Looks good

Clean, minimal test harness that follows the pattern used in the companion suites.
No issues found.

tests/type/ActiveRecordDynamicStaticMethodReturnTypeExtensionTest.php (1)

31-55: Looks good

Consistent with the other type-inference tests and correctly wired to the shared extension.neon.

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: 3

♻️ Duplicate comments (1)
src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (1)

226-233: Model type extraction still ignores custom ActiveQuery subclasses

The check is limited to getClassName() === ActiveQuery::class, so a subclass such as PostQuery degrades to mixed, breaking all downstream inference.
This was already pointed out in a previous review and has not been addressed.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 711e058 and 2cfa3d9.

📒 Files selected for processing (3)
  • src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (5 hunks)
  • tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php (1 hunks)
  • tests/stub/Category.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/stub/Category.php
  • tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php

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: 0

♻️ Duplicate comments (4)
src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (4)

393-398: Simplify guard for default asArray() argument
The Arg::class comparison is redundant (it is always true) and obscures intent.

-        if (isset($methodCall->args[0]) === false || ($methodCall->args[0]::class === Arg::class) === false) {
-            return new ConstantBooleanType(true);
-        }
-
-        return $scope->getType($methodCall->args[0]->value);
+        if ($methodCall->args === []) {
+            // `asArray()` default in Yii is `true`.
+            return new ConstantBooleanType(true);
+        }
+
+        return $scope->getType($methodCall->args[0]->value);

467-469: Same instanceof issue when preserving fluent return type

-            if ($returnType::class === ThisType::class) {
+            if ($returnType instanceof ThisType) {

496-503: Fluent type preservation should keep custom query subclasses

Currently a non-generic $calledOnType (e.g. an intersection) downgrades to ActiveQuery, losing the concrete subclass. Re-use the original class when possible:

-        if ($modelType::class !== MixedType::class) {
-            return new GenericObjectType(ActiveQuery::class, [$modelType]);
+        if ($modelType::class !== MixedType::class) {
+            $queryClass = $calledOnType instanceof GenericObjectType
+                ? $calledOnType->getClassName()
+                : ActiveQuery::class;
+
+            return new GenericObjectType($queryClass, [$modelType]);
         }

151-157: 🛠️ Refactor suggestion

Prefer instanceof over strict class‐string comparison
The current check fails if the return type is wrapped or proxied. Using instanceof is safer and idiomatic.

-            $returnType = $variants[0]->getReturnType();
-
-            return $returnType::class === ThisType::class;
+            $returnType = $variants[0]->getReturnType();
+
+            return $returnType instanceof ThisType;
🧹 Nitpick comments (1)
src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (1)

222-228: Use instanceof to detect GenericObjectType
Relying on class-string equality breaks when $calledOnType is an intersection or union containing GenericObjectType.

-        if ($calledOnType::class === GenericObjectType::class) {
+        if ($calledOnType instanceof GenericObjectType) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2cfa3d9 and 91c54f3.

📒 Files selected for processing (4)
  • src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (5 hunks)
  • tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php (1 hunks)
  • tests/stub/Post.php (1 hunks)
  • tests/stub/PostQuery.php (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/stub/Post.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/fixture/data/types/ActiveQueryDynamicMethodReturnType.php
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/type/ActiveQueryDynamicMethodReturnTypeExtension.php (2)
src/type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php (2)
  • __construct (58-58)
  • getClass (73-76)
src/type/ActiveRecordDynamicMethodReturnTypeExtension.php (2)
  • isMethodSupported (127-130)
  • getClass (62-65)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: phpunit / PHP 8.3-windows-latest
  • GitHub Check: phpunit / PHP 8.2-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.3-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.2-windows-latest
  • GitHub Check: phpunit-compatibility / PHP 8.1-windows-latest
🔇 Additional comments (1)
tests/stub/PostQuery.php (1)

15-21: Looks good – concise custom query helper
Implementation is minimal, type-safe, and matches Yii’s fluent API expectations.
No issues spotted.

@terabytesoftw terabytesoftw requested a review from Copilot June 12, 2025 20:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the dynamic return type extensions for Yii ActiveRecord and ActiveQuery to improve type inference and error handling, while also removing deprecated custom object types.

  • Refactors type extensions to use native generic types and improves return type inference for both static and dynamic methods.
  • Updates test stubs and fixture files to validate enhanced type analysis, and revises configuration files and dependency constraints.
  • Removes deprecated classes (ActiveRecordObjectType and ActiveQueryObjectType) and adjusts extension configurations.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/* Added and updated test cases for dynamic method and static method return types.
tests/stub/User.php, Post.php, etc. Updated stubs for improved type inference and documentation.
src/type/* Refactored dynamic return type extensions; removed deprecated object type classes.
phpstan.neon, extension.neon, composer.json Updated configuration and dependency version constraints.
CHANGELOG.md Updated changelog to reflect refactor and removal of deprecated classes.

@terabytesoftw terabytesoftw merged commit 4a19ff1 into main Jun 12, 2025
24 checks passed
@terabytesoftw terabytesoftw deleted the feat-mini-2 branch June 12, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants