Skip to content

Commit 2ba497e

Browse files
ENGCOM-9121: Generator matching optimization #31613
- Merge Pull Request #31613 from kirmorozov/magento2:2.4-generator-matching-optimization - Merged commits: 1. d32684d 2. aa240d4 3. d082e59
2 parents dfe7b89 + d082e59 commit 2ba497e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/Magento/Framework/Code/Generator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ public function generateClass($className)
105105
$resultEntityType = null;
106106
$sourceClassName = null;
107107
foreach ($this->_generatedEntities as $entityType => $generatorClass) {
108+
$suffixLen = strlen($entityType);
108109
$entitySuffix = ucfirst($entityType);
109110
// If $className string ends with $entitySuffix substring
110-
if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) {
111+
if (substr_compare($className, $entitySuffix, -$suffixLen, $suffixLen) == 0) {
111112
$resultEntityType = $entityType;
112113
$sourceClassName = rtrim(
113-
substr($className, 0, -1 * strlen($entitySuffix)),
114+
substr($className, 0, -$suffixLen),
114115
'\\'
115116
);
116117
break;

0 commit comments

Comments
 (0)