vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\ORM\Query;
  4. use Doctrine\ORM\Exception\ORMException;
  5. use Doctrine\ORM\Query\AST\PathExpression;
  6. use Exception;
  7. use Stringable;
  8. class QueryException extends ORMException
  9. {
  10.     /**
  11.      * @param string $dql
  12.      *
  13.      * @return QueryException
  14.      */
  15.     public static function dqlError($dql)
  16.     {
  17.         return new self($dql);
  18.     }
  19.     /**
  20.      * @param string         $message
  21.      * @param Exception|null $previous
  22.      *
  23.      * @return QueryException
  24.      */
  25.     public static function syntaxError($message$previous null)
  26.     {
  27.         return new self('[Syntax Error] ' $message0$previous);
  28.     }
  29.     /**
  30.      * @param string         $message
  31.      * @param Exception|null $previous
  32.      *
  33.      * @return QueryException
  34.      */
  35.     public static function semanticalError($message$previous null)
  36.     {
  37.         return new self('[Semantical Error] ' $message0$previous);
  38.     }
  39.     /**
  40.      * @return QueryException
  41.      */
  42.     public static function invalidLockMode()
  43.     {
  44.         return new self('Invalid lock mode hint provided.');
  45.     }
  46.     /**
  47.      * @param string $expected
  48.      * @param string $received
  49.      *
  50.      * @return QueryException
  51.      */
  52.     public static function invalidParameterType($expected$received)
  53.     {
  54.         return new self('Invalid parameter type, ' $received ' given, but ' $expected ' expected.');
  55.     }
  56.     /**
  57.      * @param string $pos
  58.      *
  59.      * @return QueryException
  60.      */
  61.     public static function invalidParameterPosition($pos)
  62.     {
  63.         return new self('Invalid parameter position: ' $pos);
  64.     }
  65.     /**
  66.      * @param int $expected
  67.      * @param int $received
  68.      *
  69.      * @return QueryException
  70.      */
  71.     public static function tooManyParameters($expected$received)
  72.     {
  73.         return new self('Too many parameters: the query defines ' $expected ' parameters and you bound ' $received);
  74.     }
  75.     /**
  76.      * @param int $expected
  77.      * @param int $received
  78.      *
  79.      * @return QueryException
  80.      */
  81.     public static function tooFewParameters($expected$received)
  82.     {
  83.         return new self('Too few parameters: the query defines ' $expected ' parameters but you only bound ' $received);
  84.     }
  85.     /**
  86.      * @param string $value
  87.      *
  88.      * @return QueryException
  89.      */
  90.     public static function invalidParameterFormat($value)
  91.     {
  92.         return new self('Invalid parameter format, ' $value ' given, but :<name> or ?<num> expected.');
  93.     }
  94.     /**
  95.      * @param string $key
  96.      *
  97.      * @return QueryException
  98.      */
  99.     public static function unknownParameter($key)
  100.     {
  101.         return new self('Invalid parameter: token ' $key ' is not defined in the query.');
  102.     }
  103.     /**
  104.      * @return QueryException
  105.      */
  106.     public static function parameterTypeMismatch()
  107.     {
  108.         return new self('DQL Query parameter and type numbers mismatch, but have to be exactly equal.');
  109.     }
  110.     /**
  111.      * @param PathExpression $pathExpr
  112.      *
  113.      * @return QueryException
  114.      */
  115.     public static function invalidPathExpression($pathExpr)
  116.     {
  117.         return new self(
  118.             "Invalid PathExpression '" $pathExpr->identificationVariable '.' $pathExpr->field "'."
  119.         );
  120.     }
  121.     /**
  122.      * @param string|Stringable $literal
  123.      *
  124.      * @return QueryException
  125.      */
  126.     public static function invalidLiteral($literal)
  127.     {
  128.         return new self("Invalid literal '" $literal "'");
  129.     }
  130.     /**
  131.      * @param string[] $assoc
  132.      * @psalm-param array<string, string> $assoc
  133.      *
  134.      * @return QueryException
  135.      */
  136.     public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
  137.     {
  138.         return new self(
  139.             'Invalid query operation: Not allowed to iterate over fetch join collections ' .
  140.             'in class ' $assoc['sourceEntity'] . ' association ' $assoc['fieldName']
  141.         );
  142.     }
  143.     /**
  144.      * @return QueryException
  145.      */
  146.     public static function partialObjectsAreDangerous()
  147.     {
  148.         return new self(
  149.             'Loading partial objects is dangerous. Fetch full objects or consider ' .
  150.             'using a different fetch mode. If you really want partial objects, ' .
  151.             'set the doctrine.forcePartialLoad query hint to TRUE.'
  152.         );
  153.     }
  154.     /**
  155.      * @param string[] $assoc
  156.      * @psalm-param array<string, string> $assoc
  157.      *
  158.      * @return QueryException
  159.      */
  160.     public static function overwritingJoinConditionsNotYetSupported($assoc)
  161.     {
  162.         return new self(
  163.             'Unsupported query operation: It is not yet possible to overwrite the join ' .
  164.             'conditions in class ' $assoc['sourceEntityName'] . ' association ' $assoc['fieldName'] . '. ' .
  165.             'Use WITH to append additional join conditions to the association.'
  166.         );
  167.     }
  168.     /**
  169.      * @return QueryException
  170.      */
  171.     public static function associationPathInverseSideNotSupported(PathExpression $pathExpr)
  172.     {
  173.         return new self(
  174.             'A single-valued association path expression to an inverse side is not supported in DQL queries. ' .
  175.             'Instead of "' $pathExpr->identificationVariable '.' $pathExpr->field '" use an explicit join.'
  176.         );
  177.     }
  178.     /**
  179.      * @param string[] $assoc
  180.      * @psalm-param array<string, string> $assoc
  181.      *
  182.      * @return QueryException
  183.      */
  184.     public static function iterateWithFetchJoinNotAllowed($assoc)
  185.     {
  186.         return new self(
  187.             'Iterate with fetch join in class ' $assoc['sourceEntity'] .
  188.             ' using association ' $assoc['fieldName'] . ' not allowed.'
  189.         );
  190.     }
  191.     public static function iterateWithMixedResultNotAllowed(): QueryException
  192.     {
  193.         return new self('Iterating a query with mixed results (using scalars) is not supported.');
  194.     }
  195.     /**
  196.      * @return QueryException
  197.      */
  198.     public static function associationPathCompositeKeyNotSupported()
  199.     {
  200.         return new self(
  201.             'A single-valued association path expression to an entity with a composite primary ' .
  202.             'key is not supported. Explicitly name the components of the composite primary key ' .
  203.             'in the query.'
  204.         );
  205.     }
  206.     /**
  207.      * @param string $className
  208.      * @param string $rootClass
  209.      *
  210.      * @return QueryException
  211.      */
  212.     public static function instanceOfUnrelatedClass($className$rootClass)
  213.     {
  214.         return new self("Cannot check if a child of '" $rootClass "' is instanceof '" $className "', " .
  215.             'inheritance hierarchy does not exists between these two classes.');
  216.     }
  217.     /**
  218.      * @param string $dqlAlias
  219.      *
  220.      * @return QueryException
  221.      */
  222.     public static function invalidQueryComponent($dqlAlias)
  223.     {
  224.         return new self(
  225.             "Invalid query component given for DQL alias '" $dqlAlias "', " .
  226.             "requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys."
  227.         );
  228.     }
  229. }