-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Transform] Check str_contains * before fnmatch() early on AddAllowDynamicPropertiesAttributeRector #4991
[Transform] Check str_contains * before fnmatch() early on AddAllowDynamicPropertiesAttributeRector #4991
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,16 +139,18 @@ private function addAllowDynamicPropertiesAttribute(Class_ $class): Class_ | |
|
||
private function shouldSkip(Class_ $class): bool | ||
{ | ||
if ($this->transformOnNamespaces !== []) { | ||
$className = (string) $this->nodeNameResolver->getName($class); | ||
foreach ($this->transformOnNamespaces as $transformOnNamespace) { | ||
if ($this->nodeNameResolver->isStringName($className, $transformOnNamespace)) { | ||
continue; | ||
} | ||
|
||
$className = (string) $this->nodeNameResolver->getName($class); | ||
foreach ($this->transformOnNamespaces as $transformOnNamespace) { | ||
if (str_contains($transformOnNamespace, '*')) { | ||
if (! fnmatch($transformOnNamespace, $className, FNM_NOESCAPE)) { | ||
return true; | ||
} | ||
|
||
continue; | ||
} | ||
|
||
if ($this->nodeNameResolver->isStringName($className, $transformOnNamespace)) { | ||
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm actually I am not sure. is this area covered by tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going to add new fixture to cover this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not, it need to be processed as exists |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomasVotruba @staabm this conditions seems need to be on last resort to check because it returns true on negation early, I will create separate PR to cover too late check.