Repository navigation
Rewrite Api rules as restricted usage extensions, add tip to RestrictedUsage - #7010
Merged
Merged
Conversation
RestrictedUsage::create() accepts an optional tip that is attached to the reported error. Amp-Thread-ID: https://ampcode.com/threads/T-01a1bf5f-ca34-7733-8886-c850b9908584
…lass name usage extension Amp-Thread-ID: https://ampcode.com/threads/T-01a1bf5f-ca34-7733-8886-c850b9908584
…onRule's PHP-version-specific errors Amp-Thread-ID: https://ampcode.com/threads/T-01a1bf5f-ca34-7733-8886-c850b9908584
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.
Rewrites part of
src/Rules/Apion top of the restricted usage extension framework, and adds tip support toRestrictedUsage, which the BC-promise rules need.Commits
RestrictedUsage::create()takes an optional?string $tip. This is backward compatible for the@apiclass. All 12 places that turn aRestrictedUsageinto a rule error now attach the tip: the 10Restricted*UsageRuleclasses,ClassNameCheck, and the constructor check inInstantiationRule.RuntimeReflectionFunctionRule→RuntimeReflectionFunctionUsageExtension(function usage)RuntimeReflectionInstantiationRule→RuntimeReflectionInstantiationUsageExtension(class name usage at thenewlocation)ApiClassExtendsRule,ApiClassImplementsRule,ApiInterfaceExtendsRuleandApiTraitUseRule→ApiClassNameUsageExtension, which switches onClassNameUsageLocation.Messages, identifiers, tips and lines are unchanged. The tests now run through the host rules (
ExistingClassInClassExtendsRule,InstantiationRule, …), so they also expect the host rules' own errors on the existing data, e.g. "extends final class FileTypeMapper".Small behaviour differences
is_a(...)and similar first-class callables are now reported too, throughRestrictedFunctionCallableUsageRule.new parent()that resolves to aReflection*class is not reported any more. Host rules don't passself,staticorparentto class-name extensions.Still rules, and why
ApiMethodCallRule,ApiStaticCallRule,ApiInstantiationRuleRestrictedMethodUsageExtensionhas no usage location. One extension is called for->m(),::m(), first-class callables and the constructor onnew X, but these rules treat__constructdifferently.ApiInstantiationRulealso can't use class-name usage:InstantiationRuleskipsself/static/parentand drops class-name errors when it returns early for abstract classes, interfaces, traits or enums.ApiClassConstFetchRuleCLASS_CONSTANT_ACCESSlocation carries no constant name when the constant doesn't exist or is::class.ApiInstanceofRule,ApiInstanceofTypeRuleTypeTraverserInstanceofVisitorattribute, and the class name as written in the source are all unavailable.GetTemplateTypeRule,NodeConnectingVisitorAttributesRulePhpStanNamespaceIn3rdPartyPackageRule,OldPhpParser4ClassRule