Skip to content

Commit

Permalink
NodeNameResolver: Throw exception in BC breaking path
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Sep 11, 2023
1 parent 878f381 commit af242c3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/NodeNameResolver/NodeNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ final class NodeNameResolver
*/
private array $nodeNameResolversByClass = [];

/**
* Used to check if a string might contain a regex or fnmatch pattern
*/
private const REGEX_WILDCARD_CHARS = ['*', '#', '~', '/'];

/**
* @param NodeNameResolverInterface[] $nodeNameResolvers
*/
Expand Down Expand Up @@ -181,6 +186,12 @@ public function isStringName(string $resolvedName, string $desiredName): bool
return $desiredName === $resolvedName;
}

foreach(self::REGEX_WILDCARD_CHARS as $char) {
if (str_contains($desiredName, $char)) {
throw new ShouldNotHappenException('Matching of regular expressions is no longer supported. Use $this->getName() and compare with e.g. str_ends_with() or str_starts_with() instead.');
}
}

return strcasecmp($resolvedName, $desiredName) === 0;
}

Expand Down

0 comments on commit af242c3

Please sign in to comment.