Skip to content

Commit

Permalink
Merge pull request #9595 from greg0ire/deprecate-more-ns-aliases
Browse files Browse the repository at this point in the history
Deprecate more occurrences of namespace aliases
  • Loading branch information
greg0ire authored Mar 20, 2022
2 parents 98b468d + 1790334 commit 0f04a82
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use function sprintf;

/**
* @deprecated No replacement planned.
*/
final class UnknownEntityNamespace extends ORMException implements ConfigurationException
{
public static function fromNamespaceAlias(string $entityNamespaceAlias): self
Expand Down
9 changes: 9 additions & 0 deletions lib/Doctrine/ORM/Query/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Query;

use Doctrine\Common\Lexer\AbstractLexer;
use Doctrine\Deprecations\Deprecation;

use function constant;
use function ctype_alpha;
Expand Down Expand Up @@ -44,6 +45,7 @@ class Lexer extends AbstractLexer
public const T_CLOSE_CURLY_BRACE = 19;

// All tokens that are identifiers or keywords that could be considered as identifiers should be >= 100
/** @deprecated No Replacement planned. */
public const T_ALIASED_NAME = 100;
public const T_FULLY_QUALIFIED_NAME = 101;
public const T_IDENTIFIER = 102;
Expand Down Expand Up @@ -174,6 +176,13 @@ protected function getType(&$value)
}

if (str_contains($value, ':')) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8818',
'Short namespace aliases such as "%s" are deprecated and will be removed in Doctrine ORM 3.0.',
$value
);

return self::T_ALIASED_NAME;
}

Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,13 @@ public function AbstractSchemaName()

$this->match(Lexer::T_ALIASED_NAME);

Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8818',
'Short namespace aliases such as "%s" are deprecated and will be removed in Doctrine ORM 3.0.',
$this->lexer->token['value']
);

[$namespaceAlias, $simpleClassName] = explode(':', $this->lexer->token['value']);

return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
Expand Down
10 changes: 9 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@
<!-- The exception is thrown by a deprecated method. -->
<referencedClass name="Doctrine\ORM\Cache\Exception\InvalidResultCacheDriver"/>
<!-- Remove on 3.0.x -->
<referencedClass name="Doctrine\Common\Persistence\PersistentObject"/>
<referencedClass name="Doctrine\ORM\Exception\UnknownEntityNamespace"/>
<referencedClass name="Doctrine\ORM\Mapping\Driver\YamlDriver"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand"/>
<referencedClass name="Doctrine\Common\Persistence\PersistentObject"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedConstant>
<errorLevel type="suppress">
<file name="lib/Doctrine/ORM/Configuration.php"/>
<file name="lib/Doctrine/ORM/Query/Lexer.php"/>
<file name="lib/Doctrine/ORM/Query/Parser.php"/>
</errorLevel>
</DeprecatedConstant>
<DeprecatedInterface>
<errorLevel type="suppress">
<referencedClass name="Doctrine\ORM\Cache\MultiGetRegion"/>
Expand Down

0 comments on commit 0f04a82

Please sign in to comment.