88use Doctrine \Persistence \Mapping \MappingException ;
99
1010use function array_keys ;
11+ use function rtrim ;
1112use function spl_object_hash ;
1213use function strpos ;
1314
@@ -73,7 +74,7 @@ public function getDrivers()
7374 public function loadMetadataForClass (string $ className , ClassMetadata $ metadata )
7475 {
7576 foreach ($ this ->drivers as $ namespace => $ driver ) {
76- if (strpos ($ className , $ namespace ) === 0 ) {
77+ if ($ this -> isInNamespace ($ className , $ namespace )) {
7778 $ driver ->loadMetadataForClass ($ className , $ metadata );
7879
7980 return ;
@@ -105,7 +106,7 @@ public function getAllClassNames()
105106 }
106107
107108 foreach ($ driverClasses [$ oid ] as $ className ) {
108- if (strpos ($ className , $ namespace ) !== 0 ) {
109+ if (! $ this -> isInNamespace ($ className , $ namespace )) {
109110 continue ;
110111 }
111112
@@ -128,7 +129,7 @@ public function getAllClassNames()
128129 public function isTransient (string $ className )
129130 {
130131 foreach ($ this ->drivers as $ namespace => $ driver ) {
131- if (strpos ($ className , $ namespace ) === 0 ) {
132+ if ($ this -> isInNamespace ($ className , $ namespace )) {
132133 return $ driver ->isTransient ($ className );
133134 }
134135 }
@@ -139,4 +140,11 @@ public function isTransient(string $className)
139140
140141 return true ;
141142 }
143+
144+ private function isInNamespace (string $ className , string $ namespace ): bool
145+ {
146+ $ namespace = rtrim ($ namespace , '\\' ) . '\\' ;
147+
148+ return strpos ($ className , $ namespace ) === 0 ;
149+ }
142150}
0 commit comments