diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Query/QueryException.php | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Query/QueryException.php')
-rw-r--r-- | vendor/doctrine/orm/src/Query/QueryException.php | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Query/QueryException.php b/vendor/doctrine/orm/src/Query/QueryException.php new file mode 100644 index 0000000..ae945b1 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/QueryException.php | |||
@@ -0,0 +1,155 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query; | ||
6 | |||
7 | use Doctrine\ORM\Exception\ORMException; | ||
8 | use Doctrine\ORM\Mapping\AssociationMapping; | ||
9 | use Doctrine\ORM\Query\AST\PathExpression; | ||
10 | use Exception; | ||
11 | use Stringable; | ||
12 | use Throwable; | ||
13 | |||
14 | class QueryException extends Exception implements ORMException | ||
15 | { | ||
16 | public static function dqlError(string $dql): self | ||
17 | { | ||
18 | return new self($dql); | ||
19 | } | ||
20 | |||
21 | public static function syntaxError(string $message, Throwable|null $previous = null): self | ||
22 | { | ||
23 | return new self('[Syntax Error] ' . $message, 0, $previous); | ||
24 | } | ||
25 | |||
26 | public static function semanticalError(string $message, Throwable|null $previous = null): self | ||
27 | { | ||
28 | return new self('[Semantical Error] ' . $message, 0, $previous); | ||
29 | } | ||
30 | |||
31 | public static function invalidLockMode(): self | ||
32 | { | ||
33 | return new self('Invalid lock mode hint provided.'); | ||
34 | } | ||
35 | |||
36 | public static function invalidParameterType(string $expected, string $received): self | ||
37 | { | ||
38 | return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.'); | ||
39 | } | ||
40 | |||
41 | public static function invalidParameterPosition(string $pos): self | ||
42 | { | ||
43 | return new self('Invalid parameter position: ' . $pos); | ||
44 | } | ||
45 | |||
46 | public static function tooManyParameters(int $expected, int $received): self | ||
47 | { | ||
48 | return new self('Too many parameters: the query defines ' . $expected . ' parameters and you bound ' . $received); | ||
49 | } | ||
50 | |||
51 | public static function tooFewParameters(int $expected, int $received): self | ||
52 | { | ||
53 | return new self('Too few parameters: the query defines ' . $expected . ' parameters but you only bound ' . $received); | ||
54 | } | ||
55 | |||
56 | public static function invalidParameterFormat(string $value): self | ||
57 | { | ||
58 | return new self('Invalid parameter format, ' . $value . ' given, but :<name> or ?<num> expected.'); | ||
59 | } | ||
60 | |||
61 | public static function unknownParameter(string $key): self | ||
62 | { | ||
63 | return new self('Invalid parameter: token ' . $key . ' is not defined in the query.'); | ||
64 | } | ||
65 | |||
66 | public static function parameterTypeMismatch(): self | ||
67 | { | ||
68 | return new self('DQL Query parameter and type numbers mismatch, but have to be exactly equal.'); | ||
69 | } | ||
70 | |||
71 | public static function invalidPathExpression(PathExpression $pathExpr): self | ||
72 | { | ||
73 | return new self( | ||
74 | "Invalid PathExpression '" . $pathExpr->identificationVariable . '.' . $pathExpr->field . "'.", | ||
75 | ); | ||
76 | } | ||
77 | |||
78 | public static function invalidLiteral(string|Stringable $literal): self | ||
79 | { | ||
80 | return new self("Invalid literal '" . $literal . "'"); | ||
81 | } | ||
82 | |||
83 | public static function iterateWithFetchJoinCollectionNotAllowed(AssociationMapping $assoc): self | ||
84 | { | ||
85 | return new self( | ||
86 | 'Invalid query operation: Not allowed to iterate over fetch join collections ' . | ||
87 | 'in class ' . $assoc->sourceEntity . ' association ' . $assoc->fieldName, | ||
88 | ); | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * @param string[] $assoc | ||
93 | * @psalm-param array<string, string> $assoc | ||
94 | */ | ||
95 | public static function overwritingJoinConditionsNotYetSupported(array $assoc): self | ||
96 | { | ||
97 | return new self( | ||
98 | 'Unsupported query operation: It is not yet possible to overwrite the join ' . | ||
99 | 'conditions in class ' . $assoc['sourceEntityName'] . ' association ' . $assoc['fieldName'] . '. ' . | ||
100 | 'Use WITH to append additional join conditions to the association.', | ||
101 | ); | ||
102 | } | ||
103 | |||
104 | public static function associationPathInverseSideNotSupported(PathExpression $pathExpr): self | ||
105 | { | ||
106 | return new self( | ||
107 | 'A single-valued association path expression to an inverse side is not supported in DQL queries. ' . | ||
108 | 'Instead of "' . $pathExpr->identificationVariable . '.' . $pathExpr->field . '" use an explicit join.', | ||
109 | ); | ||
110 | } | ||
111 | |||
112 | public static function iterateWithFetchJoinNotAllowed(AssociationMapping $assoc): self | ||
113 | { | ||
114 | return new self( | ||
115 | 'Iterate with fetch join in class ' . $assoc->sourceEntity . | ||
116 | ' using association ' . $assoc->fieldName . ' not allowed.', | ||
117 | ); | ||
118 | } | ||
119 | |||
120 | public static function eagerFetchJoinWithNotAllowed(string $sourceEntity, string $fieldName): self | ||
121 | { | ||
122 | return new self( | ||
123 | 'Associations with fetch-mode=EAGER may not be using WITH conditions in | ||
124 | "' . $sourceEntity . '#' . $fieldName . '".', | ||
125 | ); | ||
126 | } | ||
127 | |||
128 | public static function iterateWithMixedResultNotAllowed(): self | ||
129 | { | ||
130 | return new self('Iterating a query with mixed results (using scalars) is not supported.'); | ||
131 | } | ||
132 | |||
133 | public static function associationPathCompositeKeyNotSupported(): self | ||
134 | { | ||
135 | return new self( | ||
136 | 'A single-valued association path expression to an entity with a composite primary ' . | ||
137 | 'key is not supported. Explicitly name the components of the composite primary key ' . | ||
138 | 'in the query.', | ||
139 | ); | ||
140 | } | ||
141 | |||
142 | public static function instanceOfUnrelatedClass(string $className, string $rootClass): self | ||
143 | { | ||
144 | return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " . | ||
145 | 'inheritance hierarchy does not exists between these two classes.'); | ||
146 | } | ||
147 | |||
148 | public static function invalidQueryComponent(string $dqlAlias): self | ||
149 | { | ||
150 | return new self( | ||
151 | "Invalid query component given for DQL alias '" . $dqlAlias . "', " . | ||
152 | "requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys.", | ||
153 | ); | ||
154 | } | ||
155 | } | ||