Docs: Fully qualify the SimplePie cache type in a WP_Feed_Cache_Transient docblock. - #12970
Conversation
…ient docblock. The `@param` annotation for `$type` in `WP_Feed_Cache_Transient::__construct()` referenced `Base::TYPE_FEED|Base::TYPE_IMAGE`. The class is declared in the global namespace and imports nothing, writing `implements SimplePie\Cache\Base` in full, so the bare `Base` resolved to `\Base`, which does not exist. The annotation was copied from `SimplePie\Cache\Base`, where it is correct because that file declares `namespace SimplePie\Cache;`. Qualifying both constants resolves the reference without changing any behaviour. This was the only `parameter.unresolvableType` occurrence, so the baseline is emptied. The file is removed along with its `includes` entry in `phpstan.neon.dist`. Props CallumBW95. See #65817.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The `@param` annotation for `$type` in `WP_Feed_Cache_Transient::__construct()` documented the type as `Base::TYPE_FEED|Base::TYPE_IMAGE`. The class is declared in the global namespace and imports nothing—it writes `implements SimplePie\Cache\Base` out in full—so the bare `Base` resolved to `\Base`, which exists nowhere in core. The shorthand was carried over in r59141 from `SimplePie\Cache\Base` itself, where it is correct because that file declares `namespace SimplePie\Cache;`. Qualifying both constants makes the annotation consistent with the rest of the docblock, which already spells the interface out in full. This was the only `parameter.unresolvableType` occurrence, so the change empties `tests/phpstan/baselines/parameter.unresolvableType.neon`. As the baseline header directs, the file is deleted along with its `includes` entry in `phpstan.neon.dist`. The baseline was regenerated with: {{{ composer phpstan:baselines -- --identifier=parameter.unresolvableType }}} Developed in #12970. Follow-up to r59141, r63020. Props callumbw95. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@63181 602fd350-edb4-49c9-b593-d223f7449a82
The `@param` annotation for `$type` in `WP_Feed_Cache_Transient::__construct()` documented the type as `Base::TYPE_FEED|Base::TYPE_IMAGE`. The class is declared in the global namespace and imports nothing—it writes `implements SimplePie\Cache\Base` out in full—so the bare `Base` resolved to `\Base`, which exists nowhere in core. The shorthand was carried over in r59141 from `SimplePie\Cache\Base` itself, where it is correct because that file declares `namespace SimplePie\Cache;`. Qualifying both constants makes the annotation consistent with the rest of the docblock, which already spells the interface out in full.
This was the only `parameter.unresolvableType` occurrence, so the change empties `tests/phpstan/baselines/parameter.unresolvableType.neon`. As the baseline header directs, the file is deleted along with its `includes` entry in `phpstan.neon.dist`. The baseline was regenerated with:
{{{
composer phpstan:baselines -- --identifier=parameter.unresolvableType
}}}
Developed in WordPress/wordpress-develop#12970.
Follow-up to r59141, r63020.
Props callumbw95.
See #65817.
Built from https://develop.svn.wordpress.org/trunk@63181
git-svn-id: http://core.svn.wordpress.org/trunk@62378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
✅ Committed in r63181 (e2ae46d).
The
@paramannotation for$typeonWP_Feed_Cache_Transient::__construct()documents the type asBase::TYPE_FEED|Base::TYPE_IMAGE.WP_Feed_Cache_Transientis declared in the global namespace and imports nothing, so PHPStan resolves the bareBaseto\Base, which does not exist anywhere in core. That is the singleparameter.unresolvableTypeoccurrence in the baseline:Qualifying both constants fixes the reference. The annotation is the only thing that changes, so there is no behaviour to affect.
This empties
tests/phpstan/baselines/parameter.unresolvableType.neon, so the file is deleted along with itsincludesentry inphpstan.neon.dist, per the instruction in the baseline's own header.Where the annotation came from
SimplePie\Cache\Basecarries the same line in the bundled library, atsrc/wp-includes/SimplePie/src/Cache/Base.php:39:There it is correct, because that file opens with
namespace SimplePie\Cache;andBaseresolves to the interface being declared. The line was carried across to the core implementation in r59141 (2024-09-30), the SimplePie 1.8.0 update that namespaced the library and updatedWP_Feed_Cache_Transientto match the new interface signature. The destination file has no namespace and nousestatement, so the shorthand stopped resolving at that point and has been baselined ever since.The rest of the file already spells the interface out in full: the class declaration reads
implements SimplePie\Cache\Base, the@since 6.7.0line in this same docblock saysSimplePie\Cache\Base, andsave()below annotatesarray|SimplePie\SimplePie. Qualifying the constants makes the@paramconsistent with its neighbours rather than introducing a new convention.Adding
use SimplePie\Cache\Base;would be shorter, but only two files in the root ofwp-includes/use imports at all, both added recently, so ausestatement here would be the novel choice. Fully qualifying keeps this a documentation-only change.On the column widths
The type column widens by 32 characters, which pushes the longest line in the block to 137 characters. Keeping the
@paramname and description columns aligned is what the inline documentation standards ask for, and there is ample precedent: 47@paramlines insrc/wp-includes/are already 137 characters or longer, the longest being 189.composer lintpasses on the file either way, so this is alignment rather than a constraint.Testing instructions
trunk,npm run typecheck:phpreports[OK] No errors, because the occurrence is baselined.tests/phpstan/baselines/parameter.unresolvableType.neonand itsincludesentry, then run it again. PHPStan reportsPHPDoc tag @param for parameter $type contains unresolvable type.insrc/wp-includes/class-wp-feed-cache-transient.php.npm run typecheck:phpreports[OK] No errorswith the baseline gone and nothing new elsewhere. The baseline directory goes from 73 files to 72.composer lintis clean on the changed file.npm run test:phppasses: 30853 tests, 4559514 assertions, 86 warnings, 44 skipped, exit 0, no failures or errors. Run against this branch at996c6d6864.Trac ticket: https://core.trac.wordpress.org/ticket/65817
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: tracing the unresolvable type to the missing namespace context,
git log -Sarchaeology identifying r59141 as the origin, checking the bundled SimplePie source for the original annotation, surveying existingusestatements and@paramline lengths acrosswp-includes/, and drafting this description. The diagnosis, the choice to fully qualify rather than add an import, the baseline regeneration, and verification against full PHPStan, PHPCS and PHPUnit runs were reviewed and confirmed by me in a local development environment.