38
38
use WikibaseSolutions \CypherDSL \Clauses \WhereClause ;
39
39
use WikibaseSolutions \CypherDSL \Clauses \WithClause ;
40
40
use WikibaseSolutions \CypherDSL \Functions \FunctionCall ;
41
+ use WikibaseSolutions \CypherDSL \ErrorHandling \ErrorTextHelper ;
41
42
use WikibaseSolutions \CypherDSL \Literals \Boolean ;
42
43
use WikibaseSolutions \CypherDSL \Literals \Decimal ;
43
44
use WikibaseSolutions \CypherDSL \Literals \Literal ;
@@ -235,7 +236,9 @@ public function match($patterns): self
235
236
236
237
foreach ($ patterns as $ pattern ) {
237
238
if (!($ pattern instanceof StructuralType)) {
238
- throw new TypeError ("\$patterns should only consist of StructuralType objects " );
239
+ throw new TypeError (
240
+ ErrorTextHelper::getTypeErrorObjectArrayText ('patterns ' , 'StructuralType ' , $ pattern )
241
+ );
239
242
}
240
243
241
244
$ matchClause ->addPattern ($ pattern );
@@ -268,7 +271,13 @@ public function returning($expressions, bool $distinct = false): self
268
271
269
272
foreach ($ expressions as $ maybeAlias => $ expression ) {
270
273
if (!($ expression instanceof AnyType)) {
271
- throw new TypeError ("\$expressions should only consist of AnyType objects " );
274
+ throw new TypeError (
275
+ ErrorTextHelper::getTypeErrorObjectArrayText (
276
+ 'expressions ' ,
277
+ 'AnyType ' ,
278
+ $ expression
279
+ )
280
+ );
272
281
}
273
282
274
283
if ($ expression instanceof Node) {
@@ -305,7 +314,13 @@ public function create($patterns): self
305
314
306
315
foreach ($ patterns as $ pattern ) {
307
316
if (!($ pattern instanceof StructuralType)) {
308
- throw new TypeError ("\$patterns should only consist of StructuralType objects " );
317
+ throw new TypeError (
318
+ ErrorTextHelper::getTypeErrorObjectArrayText (
319
+ 'patterns ' ,
320
+ 'StructuralType ' ,
321
+ $ pattern
322
+ )
323
+ );
309
324
}
310
325
311
326
$ createClause ->addPattern ($ pattern );
@@ -335,7 +350,13 @@ public function delete($nodes): self
335
350
336
351
foreach ($ nodes as $ node ) {
337
352
if (!($ node instanceof NodeType)) {
338
- throw new TypeError ("\$nodes should exist of only NodeType objects " );
353
+ throw new TypeError (
354
+ ErrorTextHelper::getTypeErrorObjectArrayText (
355
+ 'nodes ' ,
356
+ 'NodeType ' ,
357
+ $ node
358
+ )
359
+ );
339
360
}
340
361
341
362
$ deleteClause ->addNode ($ node );
@@ -366,7 +387,13 @@ public function detachDelete($nodes): self
366
387
367
388
foreach ($ nodes as $ node ) {
368
389
if (!($ node instanceof NodeType)) {
369
- throw new TypeError ("\$nodes should exist of only NodeType objects " );
390
+ throw new TypeError (
391
+ ErrorTextHelper::getTypeErrorObjectArrayText (
392
+ 'nodes ' ,
393
+ 'NodeType ' ,
394
+ $ node
395
+ )
396
+ );
370
397
}
371
398
372
399
$ deleteClause ->addNode ($ node );
@@ -444,7 +471,13 @@ public function optionalMatch($patterns): self
444
471
445
472
foreach ($ patterns as $ pattern ) {
446
473
if (!($ pattern instanceof StructuralType)) {
447
- throw new TypeError ("\$patterns should only consist of StructuralType objects " );
474
+ throw new TypeError (
475
+ ErrorTextHelper::getTypeErrorObjectArrayText (
476
+ 'patterns ' ,
477
+ 'StructuralType ' ,
478
+ $ pattern
479
+ )
480
+ );
448
481
}
449
482
450
483
$ optionalMatchClause ->addPattern ($ pattern );
@@ -476,7 +509,13 @@ public function orderBy($properties, bool $descending = false): self
476
509
477
510
foreach ($ properties as $ property ) {
478
511
if (!($ property instanceof Property)) {
479
- throw new TypeError ("\$properties should only consist of Property objects " );
512
+ throw new TypeError (
513
+ ErrorTextHelper::getTypeErrorObjectArrayText (
514
+ 'properties ' ,
515
+ 'PropertyType ' ,
516
+ $ property
517
+ )
518
+ );
480
519
}
481
520
482
521
$ orderByClause ->addProperty ($ property );
@@ -506,7 +545,13 @@ public function remove($expressions): self
506
545
507
546
foreach ($ expressions as $ expression ) {
508
547
if (!($ expression instanceof Property) && !($ expression instanceof Label)) {
509
- throw new TypeError ("\$expressions should consist of only Property or Label objects " );
548
+ throw new TypeError (
549
+ ErrorTextHelper::getTypeErrorObjectArrayText (
550
+ 'expressions ' ,
551
+ 'Property or Label ' ,
552
+ $ expression
553
+ )
554
+ );
510
555
}
511
556
512
557
$ removeClause ->addExpression ($ expression );
@@ -536,7 +581,11 @@ public function set($expressions): self
536
581
537
582
foreach ($ expressions as $ expression ) {
538
583
if (!($ expression instanceof Assignment) && !($ expression instanceof Label)) {
539
- throw new TypeError ("\$expressions should only consist of Assignment and Label objects " );
584
+ throw new TypeError (
585
+ 'expressions ' ,
586
+ 'Assignment and Label ' ,
587
+ $ expression
588
+ );
540
589
}
541
590
542
591
$ setClause ->addAssignment ($ expression );
@@ -586,7 +635,13 @@ public function with($expressions): self
586
635
587
636
foreach ($ expressions as $ maybeAlias => $ expression ) {
588
637
if (!($ expression instanceof AnyType)) {
589
- throw new TypeError ("\$expressions should only consist of AnyType objects " );
638
+ throw new TypeError (
639
+ ErrorTextHelper::getTypeErrorObjectArrayText (
640
+ 'expressions ' ,
641
+ 'AnyType ' ,
642
+ $ expression
643
+ )
644
+ );
590
645
}
591
646
592
647
if ($ expression instanceof Node) {
@@ -678,4 +733,4 @@ public function build(): string
678
733
" " , array_filter ($ builtClauses , fn ($ clause ) => !empty ($ clause ))
679
734
);
680
735
}
681
- }
736
+ }
0 commit comments