Skip to content

Commit

Permalink
Merge branch '2.11.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.11.x:
  Leverage get_debug_type() (doctrine#9297)
  Fix return type (doctrine#9295)
  Synchronize Psalm baseline (doctrine#9296)
  Fix union type on QueryExpressionVisitorTest::testWalkComparison() (doctrine#9294)
  Allow arithmetic expressions within IN operator (doctrine#9242)
  Bump reusable workflows
  • Loading branch information
derrabus committed Dec 28, 2021
2 parents 9c07649 + 70dcffa commit 3f2cc10
Show file tree
Hide file tree
Showing 35 changed files with 130 additions and 109 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ on:

jobs:
release:
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.1.1"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1"
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/dql-doctrine-query-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ Literal Values
.. code-block:: php
Literal ::= string | char | integer | float | boolean
InParameter ::= Literal | InputParameter
InParameter ::= ArithmeticExpression | InputParameter
Input Parameter
~~~~~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

use Doctrine\Common\Cache\Cache;

use function get_class;
use function get_debug_type;

final class MetadataCacheUsesNonPersistentCache extends CacheException
{
public static function fromDriver(Cache $cache): self
{
return new self(
'Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'
'Metadata Cache uses a non-persistent cache driver, ' . get_debug_type($cache) . '.'
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

use Doctrine\Common\Cache\Cache;

use function get_class;
use function get_debug_type;

final class QueryCacheUsesNonPersistentCache extends CacheException
{
public static function fromDriver(Cache $cache): self
{
return new self(
'Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'
'Query Cache uses a non-persistent cache driver, ' . get_debug_type($cache) . '.'
);
}
}
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
use Throwable;

use function array_keys;
use function get_class;
use function gettype;
use function get_debug_type;
use function is_array;
use function is_object;
use function is_string;
Expand Down Expand Up @@ -905,7 +904,7 @@ protected static function createConnection($connection, Configuration $config, ?
throw new InvalidArgumentException(
sprintf(
'Invalid $connection argument of type %s given%s.',
is_object($connection) ? get_class($connection) : gettype($connection),
get_debug_type($connection),
is_object($connection) ? '' : ': "' . $connection . '"'
)
);
Expand Down
2 changes: 0 additions & 2 deletions lib/Doctrine/ORM/EntityNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public static function fromClassNameAndIdentifier($className, array $id)

/**
* Instance for which no identifier can be found
*
* @psalm-param class-string $className
*/
public static function noIdentifierFound(string $className): self
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\ORM\PersistentCollection;
use InvalidArgumentException;

use function get_class;
use function get_debug_type;
use function sprintf;

/**
Expand Down Expand Up @@ -108,7 +108,7 @@ private function assertValidField(string $field): void
throw new InvalidArgumentException(sprintf(
'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
$field,
get_class($this->getEntity())
get_debug_type($this->getEntity())
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use LogicException;

use function get_class;
use function get_debug_type;

final class EntityMissingAssignedId extends LogicException implements ORMException
{
Expand All @@ -15,7 +15,7 @@ final class EntityMissingAssignedId extends LogicException implements ORMExcepti
*/
public static function forField($entity, string $field): self
{
return new self('Entity of type ' . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " .
return new self('Entity of type ' . get_debug_type($entity) . " is missing an assigned ID for field '" . $field . "'. " .
'The identifier generation strategy for this entity requires the ID field to be populated before ' .
'EntityManager#persist() is called. If you want automatically generated identifiers instead ' .
'you need to adjust the metadata mapping accordingly.');
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\ORM\Exception\ORMException;
use LogicException;

use function get_class;
use function get_debug_type;
use function sprintf;

final class CannotGenerateIds extends LogicException implements ORMException
Expand All @@ -17,7 +17,7 @@ public static function withPlatform(AbstractPlatform $platform): self
{
return new self(sprintf(
'Platform %s does not support generating identifiers',
get_class($platform)
get_debug_type($platform)
));
}
}
9 changes: 4 additions & 5 deletions lib/Doctrine/ORM/ORMInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

use function array_map;
use function count;
use function get_class;
use function get_debug_type;
use function gettype;
use function implode;
use function is_object;
use function method_exists;
use function reset;
use function spl_object_id;
Expand Down Expand Up @@ -218,7 +217,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a
$expectedType,
$assoc['sourceEntity'],
$assoc['fieldName'],
is_object($actualValue) ? get_class($actualValue) : gettype($actualValue)
get_debug_type($actualValue)
));
}

Expand All @@ -231,7 +230,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a
*/
public static function invalidEntityName($entityName)
{
return new self(sprintf('Entity name must be a string, %s given', gettype($entityName)));
return new self(sprintf('Entity name must be a string, %s given', get_debug_type($entityName)));
}

/**
Expand All @@ -241,7 +240,7 @@ public static function invalidEntityName($entityName)
*/
private static function objToStr($obj): string
{
return method_exists($obj, '__toString') ? (string) $obj : get_class($obj) . '@' . spl_object_id($obj);
return method_exists($obj, '__toString') ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/AST/ASTException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\ORM\Query\QueryException;

use function get_class;
use function get_debug_type;

/**
* Base exception class for AST exceptions.
Expand All @@ -20,6 +20,6 @@ class ASTException extends QueryException
*/
public static function noDispatchForNode($node)
{
return new self('Double-dispatch for node ' . get_class($node) . ' is not supported.');
return new self('Double-dispatch for node ' . get_debug_type($node) . ' is not supported.');
}
}
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Query/AST/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\ORM\Query\SqlWalker;

use function get_class;
use function get_debug_type;
use function get_object_vars;
use function is_array;
use function is_object;
Expand Down Expand Up @@ -60,7 +60,7 @@ public function dump($obj)
$str = '';

if ($obj instanceof Node) {
$str .= get_class($obj) . '(' . PHP_EOL;
$str .= get_debug_type($obj) . '(' . PHP_EOL;
$props = get_object_vars($obj);

foreach ($props as $name => $prop) {
Expand All @@ -85,7 +85,7 @@ public function dump($obj)
$ident -= 4;
$str .= ($some ? PHP_EOL . str_repeat(' ', $ident) : '') . ')';
} elseif (is_object($obj)) {
$str .= 'instanceof(' . get_class($obj) . ')';
$str .= 'instanceof(' . get_debug_type($obj) . ')';
} else {
$str .= var_export($obj, true);
}
Expand Down
15 changes: 6 additions & 9 deletions lib/Doctrine/ORM/Query/Expr/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use function count;
use function get_class;
use function get_debug_type;
use function implode;
use function in_array;
use function is_string;
Expand Down Expand Up @@ -69,15 +70,11 @@ public function add($arg)
{
if ($arg !== null && (! $arg instanceof self || $arg->count() > 0)) {
// If we decide to keep Expr\Base instances, we can use this check
if (! is_string($arg)) {
$class = get_class($arg);

if (! in_array($class, $this->allowedClasses, true)) {
throw new InvalidArgumentException(sprintf(
"Expression of type '%s' not allowed in this context.",
$class
));
}
if (! is_string($arg) && ! in_array(get_class($arg), $this->allowedClasses, true)) {
throw new InvalidArgumentException(sprintf(
"Expression of type '%s' not allowed in this context.",
get_debug_type($arg)
));
}

$this->parts[] = $arg;
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2758,17 +2758,17 @@ public function Literal()
}

/**
* InParameter ::= Literal | InputParameter
* InParameter ::= ArithmeticExpression | InputParameter
*
* @return AST\InputParameter|AST\Literal
* @return AST\InputParameter|AST\ArithmeticExpression
*/
public function InParameter()
{
if ($this->lexer->lookahead['type'] === Lexer::T_INPUT_PARAMETER) {
return $this->InputParameter();
}

return $this->Literal();
return $this->ArithmeticExpression();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/SqlWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ public function walkInParameter($inParam)
{
return $inParam instanceof AST\InputParameter
? $this->walkInputParameter($inParam)
: $this->walkLiteral($inParam);
: $this->walkArithmeticExpression($inParam);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

use function get_class;
use function gettype;
use function is_object;
use function get_debug_type;
use function sprintf;

/**
Expand Down Expand Up @@ -93,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! $collectionRegion instanceof DefaultRegion) {
throw new InvalidArgumentException(sprintf(
'The option "--flush" expects a "Doctrine\ORM\Cache\Region\DefaultRegion", but got "%s".',
is_object($collectionRegion) ? get_class($collectionRegion) : gettype($collectionRegion)
get_debug_type($collectionRegion)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

use function get_class;
use function gettype;
use function is_object;
use function get_debug_type;
use function sprintf;

/**
Expand Down Expand Up @@ -91,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! $entityRegion instanceof DefaultRegion) {
throw new InvalidArgumentException(sprintf(
'The option "--flush" expects a "Doctrine\ORM\Cache\Region\DefaultRegion", but got "%s".',
is_object($entityRegion) ? get_class($entityRegion) : gettype($entityRegion)
get_debug_type($entityRegion)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

use function get_class;
use function get_debug_type;
use function sprintf;

/**
Expand Down Expand Up @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! ($cacheDriver instanceof ClearableCache)) {
throw new LogicException(sprintf(
'Can only clear cache when ClearableCache interface is implemented, %s does not implement.',
get_class($cacheDriver)
get_debug_type($cacheDriver)
));
}

Expand All @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! ($cacheDriver instanceof FlushableCache)) {
throw new LogicException(sprintf(
'Can only clear cache when FlushableCache interface is implemented, %s does not implement.',
get_class($cacheDriver)
get_debug_type($cacheDriver)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

use function get_class;
use function gettype;
use function is_object;
use function get_debug_type;
use function sprintf;

/**
Expand Down Expand Up @@ -90,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! $queryRegion instanceof DefaultRegion) {
throw new InvalidArgumentException(sprintf(
'The option "--flush" expects a "Doctrine\ORM\Cache\Region\DefaultRegion", but got "%s".',
is_object($queryRegion) ? get_class($queryRegion) : gettype($queryRegion)
get_debug_type($queryRegion)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

use function get_class;
use function get_debug_type;
use function method_exists;
use function sprintf;

Expand Down Expand Up @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! $cache && ! ($cacheDriver instanceof ClearableCache)) {
throw new LogicException(sprintf(
'Can only clear cache when ClearableCache interface is implemented, %s does not implement.',
get_class($cacheDriver)
get_debug_type($cacheDriver)
));
}

Expand All @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (! ($cacheDriver instanceof FlushableCache)) {
throw new LogicException(sprintf(
'Can only clear cache when FlushableCache interface is implemented, %s does not implement.',
get_class($cacheDriver)
get_debug_type($cacheDriver)
));
}

Expand Down
Loading

0 comments on commit 3f2cc10

Please sign in to comment.