Skip to content

Expand support for PHPStan/Psalm syntax#377

Merged
samdark merged 12 commits intomasterfrom
use-new-type-resolver
Mar 10, 2026
Merged

Expand support for PHPStan/Psalm syntax#377
samdark merged 12 commits intomasterfrom
use-new-type-resolver

Conversation

@mspirkov
Copy link
Copy Markdown
Contributor

@mspirkov mspirkov commented Mar 9, 2026

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

Video: https://skr.sh/vaRmC8xyYZs

What's done:

  1. Added support for new types
  2. Added links to the Psalm documentation
  3. Tests have been rewritten
  4. The minimum version of PHP has been upgraded. Dead code has been removed.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.55%. Comparing base (95df1fb) to head (a7125b3).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #377      +/-   ##
============================================
+ Coverage     80.84%   85.55%   +4.71%     
- Complexity      828      841      +13     
============================================
  Files            58       58              
  Lines          2714     2770      +56     
============================================
+ Hits           2194     2370     +176     
+ Misses          520      400     -120     

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

Comment thread composer.json
"phpdocumentor/reflection": "^5.3.0 || ^6.0.0",
"phpdocumentor/type-resolver": "^1.12",
"nikic/php-parser": "^4.0 || ^5.0",
"phpdocumentor/reflection": "7.x-dev",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For now, we're using this version. Later, I'll replace it with ^7.0.

@mspirkov mspirkov marked this pull request as ready for review March 9, 2026 08:45
@terabytesoftw terabytesoftw requested a review from Copilot March 9, 2026 08:52
Copy link
Copy Markdown
Contributor

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 yii2-apidoc to support additional PHPStan/Psalm type syntax (including new pseudo-types and callable signatures), refreshes the test fixtures accordingly, and raises the minimum supported PHP/tooling versions to align with the updated parsing/rendering stack.

Changes:

  • Extend type link rendering to handle more PHPStan/Psalm pseudo-types (and add Psalm documentation links) in BaseRenderer.
  • Rewrite/refresh tests and test fixtures to cover the expanded type syntax surface.
  • Raise minimum PHP version to 8.2 and update dev tooling (PHPUnit, phpdocumentor/type-resolver, php-parser), plus CI/workflow adjustments.

Reviewed changes

Copilot reviewed 61 out of 147 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/helpers/TypeHelperTest.php Migrates data providers to PHPUnit attribute syntax.
tests/helpers/TextHelperTest.php Migrates data providers to PHPUnit attribute syntax.
tests/commands/GuideControllerTest.php Migrates data provider to PHPUnit attribute syntax.
tests/commands/ApiControllerTest.php Migrates data provider to PHPUnit attribute syntax.
tests/data/api/web/SomeSubInterface.php Removes old test fixture (web namespace).
tests/data/api/web/SomeInterface.php Removes old test fixture (web namespace).
tests/data/api/web/ErrorAction.php Removes old test fixture (web namespace).
tests/data/api/web/AssetManager.php Removes old test fixture (web namespace) that included phpstan/psalm type definitions.
tests/data/api/web/AssetBundle.php Removes old test fixture (web namespace) that included type imports.
tests/data/api/di/Container.php Removes old DI test fixture that included conditional/template annotations.
tests/data/api/db/BatchQueryResult.php Removes old DB test fixture (Iterator + ReturnTypeWillChange attributes).
tests/data/api/db/ActiveRelationTrait.php Removes old DB trait fixture with method/property tags.
tests/data/api/db/ActiveQueryInterface.php Removes old DB interface fixture.
tests/data/api/db/ActiveQuery.php Removes old DB class fixture with template/method tags.
tests/data/api/base/Controller.php Removes old base fixture.
tests/data/api/base/Component.php Removes old base fixture.
tests/data/api/base/Behavior.php Removes old base fixture with templates.
tests/data/api/base/Application.php Removes old base fixture with generic property annotation.
tests/data/api/base/Action.php Removes old base fixture with templates.
tests/data/api/animal/Animal.php Removes old animal fixture set used for type syntax coverage.
tests/data/api/animal/Dog.php Removes old animal fixture set used for type syntax coverage.
tests/data/api/animal/Cat.php Removes old animal fixture set used for type syntax coverage.
tests/data/api/animal/Doberman.php Removes old animal fixture set used for type syntax coverage.
tests/data/api/traits/ChildTrait.php Refactors fixture from a class into a trait under a traits namespace.
tests/data/api/traits/BaseTrait.php Adds new base trait fixture for trait parsing/visibility/constants/properties.
tests/data/api/interfaces/BaseInterface.php Adds new interface fixture with constants, method signature, and property tag.
tests/data/api/interfaces/SubInterface.php Adds new sub-interface fixture extending BaseInterface.
tests/data/api/classes/AbstractClass.php Adds new abstract class fixture with author/since/package/see tags.
tests/data/api/classes/BaseClass.php Adds new base class fixture covering tags (deprecated/event/todo/throws) and inheritance.
tests/data/api/classes/ChildClass.php Adds child class fixture to exercise {inheritdoc} on class/members.
tests/data/api/classes/BaseObjectChildClass.php Adds BaseObject-derived fixture to exercise getter/setter-style docs.
tests/data/api/classes/BasicTypes.php Adds fixture for basic native/user types in hints and docblocks.
tests/data/api/classes/CallableTypes.php Adds fixture for callable/Closure types and advanced callable signatures in docs.
tests/data/api/classes/CompoundTypes.php Adds fixture for union/intersection-like compound type syntax.
tests/data/api/classes/ConditionalTypes.php Adds fixture for conditional types (including conditional-for-parameter).
tests/data/api/classes/Event.php Moves/renames fixture into classes namespace as Event.
tests/data/api/classes/EmptyClass.php Moves/renames fixture into classes namespace as EmptyClass.
tests/data/api/classes/GenericTypes.php Adds fixture covering many generic pseudo-types and templated self/static.
tests/data/api/classes/InlineTags.php Adds fixture for inline {@see}/{@link} variations and invalid cases.
tests/data/api/classes/IntersectionTypes.php Adds fixture for intersection types with and without generics.
tests/data/api/classes/InvalidTags.php Adds fixture to exercise invalid phpstan/psalm tags and invalid param/return tags.
tests/data/api/classes/MethodTags.php Adds fixture covering @method tags with params and generic return.
tests/data/api/classes/OffsetAccessTypes.php Adds fixture for offset-access types like SomeData['name'].
tests/data/api/classes/OtherTypes.php Adds fixture for assorted advanced scalar/utility types and true/false return types.
tests/data/api/classes/PropertyTags.php Adds fixture for @property, @property-read, @property-write tags.
tests/data/api/classes/PseudoTypes.php Adds fixture defining phpstan/psalm @*-type aliases.
tests/data/api/classes/PseudoTypesImports.php Adds fixture importing phpstan/psalm types via @*-import-type.
tests/data/api/classes/ShapeTypes.php Adds fixture for array/list/object shape syntaxes.
tests/data/api/classes/Templates.php Adds fixture for templates and conditional return types based on key-of access.
renderers/BaseRenderer.php Extends type rendering/linking for Psalm + more pseudo-types and callable types.
models/PropertyDoc.php Simplifies default value extraction now that minimum PHP is raised.
models/ParamDoc.php Simplifies default value extraction now that minimum PHP is raised.
models/ConstDoc.php Simplifies constant value extraction now that minimum PHP is raised.
phpcs.xml.dist Adjusts PHPCS config to explicitly include repo directories/files.
phpstan-baseline.neon Drops baseline entries that should no longer be needed after reflection API changes.
phpunit-7x.xml.dist Removes legacy PHPUnit 7 config.
composer.json Raises PHP minimum to 8.2, updates dependencies, and adds common scripts.
README.md Removes the prior “minimum PHP 7.4 / works best with PHP 8” installation note.
CHANGELOG.md Updates changelog entries for the new enhancements and version requirement bumps.
.github/workflows/static.yml Updates PHP versions used in static analysis workflow.
.github/workflows/linter.yml Updates linter workflow inputs (PHP versions).
.github/workflows/build.yml Removes PHPUnit-7 job and updates PHP versions for PHPUnit workflow.
.gitattributes Removes export-ignore for the deleted phpunit-7x.xml.dist.
Comments suppressed due to low confidence (1)

README.md:27

  • The README no longer states the minimum supported PHP version, but this PR raises it to PHP 8.2 in composer.json. Add the updated requirement back (and/or update any installation examples) so users don't hit unexpected composer resolution failures.
## Installation

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```sh
composer require --prefer-dist yiisoft/yii2-apidoc:"~3.0.8"
</details>



---

💡 <a href="/yiisoft/yii2-apidoc/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

Comment thread composer.json
Comment thread renderers/BaseRenderer.php Outdated
Comment thread renderers/BaseRenderer.php
Comment thread tests/data/api/classes/OtherTypes.php
Comment thread tests/data/api/classes/ConditionalTypes.php
Comment thread tests/data/api/classes/AbstractClass.php Outdated
Copy link
Copy Markdown
Contributor

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread tests/data/api/classes/BaseClass.php Outdated
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 61 out of 147 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/data/api/classes/BaseObjectChildClass.php
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 61 out of 147 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread composer.json
"ext-dom": "*",
"ext-mbstring": "*",
"php": "^7.4 || ^8.0",
"php": "^8.2",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PHP 7.4.33 is used at yiiframework.com still.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I need to update it at the server...

Comment thread CHANGELOG.md Outdated
@samdark samdark merged commit a7ce37d into master Mar 10, 2026
16 checks passed
@samdark samdark deleted the use-new-type-resolver branch March 10, 2026 06:38
@samdark
Copy link
Copy Markdown
Member

samdark commented Mar 10, 2026

👍

@mspirkov mspirkov changed the title Add support for PHPStan/Psalm syntax Expand support for PHPStan/Psalm syntax Mar 10, 2026
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.

4 participants