Skip to content

Commit

Permalink
[Transform] Check str_contains * before fnmatch() early on AddAllowDy…
Browse files Browse the repository at this point in the history
…namicPropertiesAttributeRector (#4991)

* [Php55] Check str_contains * before fnmatch() early on AddAllowDynamicPropertiesAttributeRector

* fix
  • Loading branch information
samsonasik committed Sep 11, 2023
1 parent 878f381 commit 27d4c55
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 27d4c55

Please sign in to comment.