Loading core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php +28 −4 Original line number Diff line number Diff line Loading @@ -937,10 +937,16 @@ private function Constant() } } // checks if identifier ends with ::class, \strlen('::class') === 7 $classPos = stripos($identifier, '::class'); if ($classPos === strlen($identifier) - 7) { return substr($identifier, 0, $classPos); /** * Checks if identifier ends with ::class and remove the leading backslash if it exists. */ if ($this->identifierEndsWithClassConstant($identifier) && ! $this->identifierStartsWithBackslash($identifier)) { return substr($identifier, 0, $this->getClassConstantPositionInIdentifier($identifier)); } if ($this->identifierEndsWithClassConstant($identifier) && $this->identifierStartsWithBackslash($identifier)) { return substr($identifier, 1, $this->getClassConstantPositionInIdentifier($identifier) - 1); } if (!defined($identifier)) { Loading @@ -950,6 +956,24 @@ private function Constant() return constant($identifier); } private function identifierStartsWithBackslash(string $identifier) : bool { return '\\' === $identifier[0]; } private function identifierEndsWithClassConstant(string $identifier) : bool { return $this->getClassConstantPositionInIdentifier($identifier) === strlen($identifier) - strlen('::class'); } /** * @return int|false */ private function getClassConstantPositionInIdentifier(string $identifier) { return stripos($identifier, '::class'); } /** * Identifier ::= string * Loading core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -764,6 +764,10 @@ public function getConstantsProvider() '@AnnotationWithConstants(PHP_EOL)', PHP_EOL ); $provider[] = array( '@AnnotationWithConstants(\SimpleXMLElement::class)', \SimpleXMLElement::class ); $provider[] = array( '@AnnotationWithConstants(AnnotationWithConstants::INTEGER)', AnnotationWithConstants::INTEGER Loading Loading
core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php +28 −4 Original line number Diff line number Diff line Loading @@ -937,10 +937,16 @@ private function Constant() } } // checks if identifier ends with ::class, \strlen('::class') === 7 $classPos = stripos($identifier, '::class'); if ($classPos === strlen($identifier) - 7) { return substr($identifier, 0, $classPos); /** * Checks if identifier ends with ::class and remove the leading backslash if it exists. */ if ($this->identifierEndsWithClassConstant($identifier) && ! $this->identifierStartsWithBackslash($identifier)) { return substr($identifier, 0, $this->getClassConstantPositionInIdentifier($identifier)); } if ($this->identifierEndsWithClassConstant($identifier) && $this->identifierStartsWithBackslash($identifier)) { return substr($identifier, 1, $this->getClassConstantPositionInIdentifier($identifier) - 1); } if (!defined($identifier)) { Loading @@ -950,6 +956,24 @@ private function Constant() return constant($identifier); } private function identifierStartsWithBackslash(string $identifier) : bool { return '\\' === $identifier[0]; } private function identifierEndsWithClassConstant(string $identifier) : bool { return $this->getClassConstantPositionInIdentifier($identifier) === strlen($identifier) - strlen('::class'); } /** * @return int|false */ private function getClassConstantPositionInIdentifier(string $identifier) { return stripos($identifier, '::class'); } /** * Identifier ::= string * Loading
core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -764,6 +764,10 @@ public function getConstantsProvider() '@AnnotationWithConstants(PHP_EOL)', PHP_EOL ); $provider[] = array( '@AnnotationWithConstants(\SimpleXMLElement::class)', \SimpleXMLElement::class ); $provider[] = array( '@AnnotationWithConstants(AnnotationWithConstants::INTEGER)', AnnotationWithConstants::INTEGER Loading