Repository navigation
Conversation
…ctor Inflector is marked @deprecated 5.0 but gave users no notice before the removal. rules() and reset() are empty methods kept for the former interface, so custom inflection rules were accepted and silently ignored. Every call also built a new Doctrine inflector. Trigger a deprecation notice in every public method, with a specific message for rules() and reset(), and build the Doctrine inflector only once. Fix the upgrade guide, which pointed to the Doctrine\Common\Inflector API that doctrine/inflector 2.x no longer has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Joomla\String\Inflectoris marked@deprecated 5.0, but users get no notice before it is removed. Itsrules()andreset()are empty methods kept "to suffice the former interface", so custom inflection rules are accepted and silently ignored. The upgrade guide points toDoctrine\Common\Inflector\Inflector::rules(), which does not exist indoctrine/inflector2.x. Every proxy call also builds a new Doctrine inflector withInflectorFactory::create()->build(), which is expensive.This PR:
trigger_deprecation('joomla/string', '__DEPLOY_VERSION__', …)) in every public method ofInflector;rules()andreset()their own message: they have no effect, and rules belong inInflectorFactory::create()->withSingularRules()/withPluralRules(). They are also marked@deprecated 5.0in the docblock. The privateaddRule()reachesrules()for non-countable types and so triggers the same notice;isPlural()andisSingular()call it directly, so each call triggers one notice instead of three;docs/v3-to-v4-update.mdto the doctrine/inflector 2.x API, with a tested example of configuring rules.Results do not change, apart from the notices.
Testing Instructions
New tests in
InflectorTest:testPluralizeTriggersDeprecation,testRulesTriggersDeprecation(which also checks that a rule passed torules()has no effect),testResetTriggersDeprecation(all withexpectUserDeprecationMessage()), andtestDoctrineInflectorIsReused. All four fail before the change and pass after it, and the existing Inflector tests still pass. The docs example was run against doctrine/inflector 2.1.vendor/bin/phpunitis green, phpcs is clean, and PHPStan reports no errors locally. The PHPStan job in CI fails on4.x-devas well (mb_trimand the other PHP 8.4 polyfill functions are not found), and #66 fixes that.Documentation Changes Required
docs/v3-to-v4-update.md: the Doctrine replacements for the removed methods are corrected, a paragraph onrules()/reset()is added, and the deprecation section says that the class now triggers notices. Removing the class is a separate 5.x PR, which adds the 5.0 update guide entry.The owner's docs PR #72 also edits
docs/v3-to-v4-update.md(it appends sections at the end) and has an "Inflector— deprecated" section indocs/overview.mdwith the correctInflectorFactoryusage. That section should mention the deprecation notices once both are merged. Expect a small conflict at the end ofdocs/v3-to-v4-update.md.🤖 Generated with Claude Code