Passed
Pull Request — master (#7448)
by Ilya
14:31
created

MappingException::invalidClassInDiscriminatorMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
use Doctrine\ORM\Exception\ORMException;
8
use LogicException;
9
use ReflectionException;
10
use function array_map;
11
use function get_parent_class;
12
use function implode;
13
use function sprintf;
14
15
/**
16
 * A MappingException indicates that something is wrong with the mapping setup.
17
 */
18
class MappingException extends LogicException implements ORMException
19
{
20
    /**
21
     * @return MappingException
22
     */
23
    public static function pathRequired()
24
    {
25
        return new self('Specifying the paths to your entities is required ' .
26
            'in the AnnotationDriver to retrieve all class names.');
27
    }
28
29
    /**
30
     * @param string $entityName
31
     *
32
     * @return MappingException
33
     */
34 4
    public static function identifierRequired($entityName)
35
    {
36 4
        $parent = get_parent_class($entityName);
37
38 4
        if ($parent !== false) {
39 2
            return new self(sprintf(
40 2
                'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.',
41 2
                $entityName,
42 2
                $parent
43
            ));
44
        }
45
46 2
        return new self(sprintf(
47 2
            'No identifier/primary key specified for Entity "%s". Every Entity must have an identifier/primary key.',
48 2
            $entityName
49
        ));
50
    }
51
52
    /**
53
     * @param string $entityName
54
     * @param string $type
55
     *
56
     * @return MappingException
57
     */
58
    public static function invalidInheritanceType($entityName, $type)
59
    {
60
        return new self(sprintf("The inheritance type '%s' specified for '%s' does not exist.", $type, $entityName));
61
    }
62
63
    /**
64
     * @return MappingException
65
     */
66
    public static function generatorNotAllowedWithCompositeId()
67
    {
68
        return new self("Id generators can't be used with a composite id.");
69
    }
70
71
    /**
72
     * @param string $entity
73
     *
74
     * @return MappingException
75
     */
76 1
    public static function missingFieldName($entity)
77
    {
78 1
        return new self(sprintf("The field or association mapping misses the 'fieldName' attribute in entity '%s'.", $entity));
79
    }
80
81
    /**
82
     * @param string $fieldName
83
     *
84
     * @return MappingException
85
     */
86
    public static function missingTargetEntity($fieldName)
87
    {
88
        return new self(sprintf("The association mapping '%s' misses the 'targetEntity' attribute.", $fieldName));
89
    }
90
91
    /**
92
     * @param string $fieldName
93
     *
94
     * @return MappingException
95
     */
96
    public static function missingSourceEntity($fieldName)
97
    {
98
        return new self(sprintf("The association mapping '%s' misses the 'sourceEntity' attribute.", $fieldName));
99
    }
100
101
    /**
102
     * @param string $fieldName
103
     *
104
     * @return MappingException
105
     */
106
    public static function missingEmbeddedClass($fieldName)
107
    {
108
        return new self(sprintf("The embed mapping '%s' misses the 'class' attribute.", $fieldName));
109
    }
110
111
    /**
112
     * @param string $entityName
113
     * @param string $fileName
114
     *
115
     * @return MappingException
116
     */
117
    public static function mappingFileNotFound($entityName, $fileName)
118
    {
119
        return new self(sprintf("No mapping file found named '%s' for class '%s'.", $fileName, $entityName));
120
    }
121
122
    /**
123
     * Exception for invalid property name override.
124
     *
125
     * @param string $className The entity's name.
126
     * @param string $fieldName
127
     *
128
     * @return MappingException
129
     */
130 2
    public static function invalidOverrideFieldName($className, $fieldName)
131
    {
132 2
        return new self(sprintf("Invalid field override named '%s' for class '%s'.", $fieldName, $className));
133
    }
134
135
    /**
136
     * Exception for invalid property type override.
137
     *
138
     * @param string $className The entity's name.
139
     * @param string $fieldName
140
     *
141
     * @return MappingException
142
     */
143
    public static function invalidOverridePropertyType($className, $fieldName)
144
    {
145
        return new self(sprintf("Invalid property override named '%s' for class '%s'.", $fieldName, $className));
146
    }
147
148
    /**
149
     * Exception for invalid version property override.
150
     *
151
     * @param string $className The entity's name.
152
     * @param string $fieldName
153
     *
154
     * @return MappingException
155
     */
156
    public static function invalidOverrideVersionField($className, $fieldName)
157
    {
158
        return new self(sprintf("Invalid version field override named '%s' for class '%s'.", $fieldName, $className));
159
    }
160
161
    /**
162
     * Exception for invalid property type override.
163
     *
164
     * @param string $className The entity's name.
165
     * @param string $fieldName
166
     *
167
     * @return MappingException
168
     */
169
    public static function invalidOverrideFieldType($className, $fieldName)
170
    {
171
        return new self(sprintf("The column type of attribute '%s' on class '%s' could not be changed.", $fieldName, $className));
172
    }
173
174
    /**
175
     * @param string $className
176
     * @param string $fieldName
177
     *
178
     * @return MappingException
179
     */
180
    public static function mappingNotFound($className, $fieldName)
181
    {
182
        return new self(sprintf("No mapping found for field '%s' on class '%s'.", $fieldName, $className));
183
    }
184
185
    /**
186
     * @param string $className
187
     * @param string $queryName
188
     *
189
     * @return MappingException
190
     */
191
    public static function queryNotFound($className, $queryName)
192
    {
193
        return new self(sprintf("No query found named '%s' on class '%s'.", $queryName, $className));
194
    }
195
196
    /**
197
     * @param string $className
198
     * @param string $resultName
199
     *
200
     * @return MappingException
201
     */
202
    public static function resultMappingNotFound($className, $resultName)
203
    {
204
        return new self(sprintf("No result set mapping found named '%s' on class '%s'.", $resultName, $className));
205
    }
206
207
    /**
208
     * @param string $entity
209
     * @param string $queryName
210
     *
211
     * @return MappingException
212
     */
213
    public static function missingQueryMapping($entity, $queryName)
214
    {
215
        return new self('Query named "' . $queryName . '" in "' . $entity . ' requires a result class or result set mapping.');
216
    }
217
218
    /**
219
     * @param string $entity
220
     * @param string $resultName
221
     *
222
     * @return MappingException
223
     */
224
    public static function missingResultSetMappingEntity($entity, $resultName)
225
    {
226
        return new self('Result set mapping named "' . $resultName . '" in "' . $entity . ' requires a entity class name.');
227
    }
228
229
    /**
230
     * @param string $entity
231
     * @param string $resultName
232
     *
233
     * @return MappingException
234
     */
235
    public static function missingResultSetMappingFieldName($entity, $resultName)
236
    {
237
        return new self('Result set mapping named "' . $resultName . '" in "' . $entity . ' requires a field name.');
238
    }
239
240
    /**
241
     * @param string $className
242
     *
243
     * @return MappingException
244
     */
245
    public static function nameIsMandatoryForSqlResultSetMapping($className)
246
    {
247
        return new self(sprintf("Result set mapping name on entity class '%s' is not defined.", $className));
248
    }
249
250
    /**
251
     * @param string $fieldName
252
     *
253
     * @return MappingException
254
     */
255
    public static function oneToManyRequiresMappedBy($fieldName)
256
    {
257
        return new self(sprintf("OneToMany mapping on field '%s' requires the 'mappedBy' attribute.", $fieldName));
258
    }
259
260
    /**
261
     * @param string $fieldName
262
     *
263
     * @return MappingException
264
     */
265
    public static function joinTableRequired($fieldName)
266
    {
267
        return new self(sprintf("The mapping of field '%s' requires an the 'joinTable' attribute.", $fieldName));
268
    }
269
270
    /**
271
     * Called if a required option was not found but is required
272
     *
273
     * @param string $field          Which field cannot be processed?
274
     * @param string $expectedOption Which option is required
275
     * @param string $hint           Can optionally be used to supply a tip for common mistakes,
276
     *                               e.g. "Did you think of the plural s?"
277
     *
278
     * @return MappingException
279
     */
280
    public static function missingRequiredOption($field, $expectedOption, $hint = '')
281
    {
282
        $message = sprintf("The mapping of field '%s' is invalid: The option '%s' is required.", $field, $expectedOption);
283
284
        if (! empty($hint)) {
285
            $message .= ' (Hint: ' . $hint . ')';
286
        }
287
288
        return new self($message);
289
    }
290
291
    /**
292
     * Generic exception for invalid mappings.
293
     *
294
     * @param string $fieldName
295
     *
296
     * @return MappingException
297
     */
298
    public static function invalidMapping($fieldName)
299
    {
300
        return new self(sprintf("The mapping of field '%s' is invalid.", $fieldName));
301
    }
302
303
    /**
304
     * Exception for reflection exceptions - adds the entity name,
305
     * because there might be long classnames that will be shortened
306
     * within the stacktrace
307
     *
308
     * @param string $entity The entity's name
309
     *
310
     * @return MappingException
311
     */
312
    public static function reflectionFailure($entity, ReflectionException $previousException)
313
    {
314
        return new self('An error occurred in ' . $entity, 0, $previousException);
315
    }
316
317
    /**
318
     * @param string $className
319
     * @param string $joinColumn
320
     *
321
     * @return MappingException
322
     */
323
    public static function joinColumnMustPointToMappedField($className, $joinColumn)
324
    {
325
        return new self('The column ' . $joinColumn . ' must be mapped to a field in class '
326
            . $className . ' since it is referenced by a join column of another class.');
327
    }
328
329
    /**
330
     * @param string $className
331
     *
332
     * @return MappingException
333
     */
334 3
    public static function classIsNotAValidEntityOrMappedSuperClass($className)
335
    {
336 3
        $parent = get_parent_class($className);
337
338 3
        if ($parent !== false) {
339 1
            return new self(sprintf(
340 1
                'Class "%s" sub class of "%s" is not a valid entity or mapped super class.',
341 1
                $className,
342 1
                $parent
343
            ));
344
        }
345
346 2
        return new self(sprintf(
347 2
            'Class "%s" is not a valid entity or mapped super class.',
348 2
            $className
349
        ));
350
    }
351
352
    /**
353
     * @param string $className
354
     * @param string $propertyName
355
     *
356
     * @return MappingException
357
     */
358
    public static function propertyTypeIsRequired($className, $propertyName)
359
    {
360
        return new self("The attribute 'type' is required for the column description of property " . $className . '::$' . $propertyName . '.');
361
    }
362
363
    /**
364
     * @param string $className
365
     *
366
     * @return MappingException
367
     */
368
    public static function tableIdGeneratorNotImplemented($className)
369
    {
370
        return new self('TableIdGenerator is not yet implemented for use with class ' . $className);
371
    }
372
373
    /**
374
     * @param string $className
375
     *
376
     * @return MappingException
377
     */
378 3
    public static function duplicateProperty($className, Property $property)
379
    {
380 3
        return new self(sprintf(
381 3
            'Property "%s" in "%s" was already declared in "%s", but it must be declared only once',
382 3
            $property->getName(),
383 3
            $className,
384 3
            $property->getDeclaringClass()->getClassName()
385
        ));
386
    }
387
388
    /**
389
     * @param string $entity
390
     * @param string $queryName
391
     *
392
     * @return MappingException
393
     */
394
    public static function duplicateQueryMapping($entity, $queryName)
395
    {
396
        return new self('Query named "' . $queryName . '" in "' . $entity . '" was already declared, but it must be declared only once');
397
    }
398
399
    /**
400
     * @param string $entity
401
     * @param string $resultName
402
     *
403
     * @return MappingException
404
     */
405
    public static function duplicateResultSetMapping($entity, $resultName)
406
    {
407
        return new self('Result set mapping named "' . $resultName . '" in "' . $entity . '" was already declared, but it must be declared only once');
408
    }
409
410
    /**
411
     * @param string $entity
412
     *
413
     * @return MappingException
414
     */
415 1
    public static function singleIdNotAllowedOnCompositePrimaryKey($entity)
416
    {
417 1
        return new self('Single id is not allowed on composite primary key in entity ' . $entity);
418
    }
419
420
    /**
421
     * @param string $entity
422
     *
423
     * @return MappingException
424
     */
425 1
    public static function noIdDefined($entity)
426
    {
427 1
        return new self('No ID defined for entity ' . $entity);
428
    }
429
430
    /**
431
     * @param string $unsupportedType
432
     *
433
     * @return MappingException
434
     */
435 1
    public static function unsupportedOptimisticLockingType($unsupportedType)
436
    {
437 1
        return new self('Locking type "' . $unsupportedType . '" is not supported by Doctrine.');
438
    }
439
440
    /**
441
     * @param string|null $path
442
     *
443
     * @return MappingException
444
     */
445
    public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null)
446
    {
447
        if (! empty($path)) {
448
            $path = '[' . $path . ']';
449
        }
450
451
        return new self(
452
            'File mapping drivers must have a valid directory path, ' .
453
            'however the given path ' . $path . ' seems to be incorrect!'
454
        );
455
    }
456
457
    /**
458
     * Returns an exception that indicates that a class used in a discriminator map does not exist.
459
     * An example would be an outdated (maybe renamed) classname.
460
     *
461
     * @param string $className   The class that could not be found
462
     * @param string $owningClass The class that declares the discriminator map.
463
     *
464
     * @return MappingException
465
     */
466
    public static function invalidClassInDiscriminatorMap($className, $owningClass)
467
    {
468
        return new self(sprintf(
469
            "Entity class '%s' used in the discriminator map of class '%s' " .
470
            'does not exist.',
471
            $className,
472
            $owningClass
473
        ));
474
    }
475
476
    /**
477
     * @param string $className
478
     *
479
     * @return MappingException
480
     */
481 3
    public static function missingDiscriminatorMap($className)
482
    {
483 3
        return new self(sprintf("Entity class '%s' is using inheritance but no discriminator map was defined.", $className));
484
    }
485
486
    /**
487
     * @param string $className
488
     *
489
     * @return MappingException
490
     */
491
    public static function missingDiscriminatorColumn($className)
492
    {
493
        return new self(sprintf("Entity class '%s' is using inheritance but no discriminator column was defined.", $className));
494
    }
495
496
    /**
497
     * @param string $type
498
     *
499
     * @return MappingException
500
     */
501
    public static function invalidDiscriminatorColumnType($type)
502
    {
503
        return new self(sprintf("Discriminator column type is not allowed to be '%s'. 'string' or 'integer' type variables are suggested!", $type));
504
    }
505
506
    /**
507
     * @param string $className
508
     *
509
     * @return MappingException
510
     */
511
    public static function nameIsMandatoryForDiscriminatorColumns($className)
512
    {
513
        return new self(sprintf("Discriminator column name on entity class '%s' is not defined.", $className));
514
    }
515
516
    /**
517
     * @param string $className
518
     * @param string $fieldName
519
     *
520
     * @return MappingException
521
     */
522
    public static function cannotVersionIdField($className, $fieldName)
523
    {
524
        return new self(sprintf("Setting Id field '%s' as versionable in entity class '%s' is not supported.", $fieldName, $className));
525
    }
526
527
    /**
528
     * @param string $className
529
     *
530
     * @return MappingException
531
     */
532
    public static function sqlConversionNotAllowedForPrimaryKeyProperties($className, Property $property)
533
    {
534
        return new self(sprintf(
535
            'It is not possible to set id field "%s" to type "%s" in entity class "%s". ' .
536
            'The type "%s" requires conversion SQL which is not allowed for identifiers.',
537
            $property->getName(),
538
            $property->getTypeName(),
0 ignored issues
show
Bug introduced by
The method getTypeName() does not exist on Doctrine\ORM\Mapping\Property. It seems like you code against a sub-type of Doctrine\ORM\Mapping\Property such as Doctrine\ORM\Mapping\FieldMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

538
            $property->/** @scrutinizer ignore-call */ 
539
                       getTypeName(),
Loading history...
539
            $className,
540
            $property->getTypeName()
541
        ));
542
    }
543
544
    /**
545
     * @param string $className
546
     * @param string $fieldName
547
     * @param string $type
548
     *
549
     * @return MappingException
550
     */
551
    public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type)
552
    {
553
        return new self(sprintf(
554
            "It is not possible to set id field '%s' to type '%s' in entity class '%s'. The type '%s' "
555
                . 'requires conversion SQL which is not allowed for identifiers.',
556
            $fieldName,
557
            $type,
558
            $className,
559
            $type
560
        ));
561
    }
562
563
    /**
564
     * @param string $className
565
     * @param string $columnName
566
     *
567
     * @return MappingException
568
     */
569 3
    public static function duplicateColumnName($className, $columnName)
570
    {
571 3
        return new self("Duplicate definition of column '" . $columnName . "' on entity '" . $className . "' in a field or discriminator column mapping.");
572
    }
573
574
    /**
575
     * @param string $className
576
     * @param string $field
577
     *
578
     * @return MappingException
579
     */
580 1
    public static function illegalToManyAssociationOnMappedSuperclass($className, $field)
581
    {
582 1
        return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '" . $className . '#' . $field . "'.");
583
    }
584
585
    /**
586
     * @param string $className
587
     * @param string $targetEntity
588
     * @param string $targetField
589
     *
590
     * @return MappingException
591
     */
592
    public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId($className, $targetEntity, $targetField)
593
    {
594
        return new self("It is not possible to map entity '" . $className . "' with a composite primary key " .
595
            "as part of the primary key of another entity '" . $targetEntity . '#' . $targetField . "'.");
596
    }
597
598
    /**
599
     * @param string $className
600
     * @param string $field
601
     *
602
     * @return MappingException
603
     */
604
    public static function noSingleAssociationJoinColumnFound($className, $field)
605
    {
606
        return new self(sprintf("'%s#%s' is not an association with a single join column.", $className, $field));
607
    }
608
609
    /**
610
     * @param string $className
611
     * @param string $column
612
     *
613
     * @return MappingException
614
     */
615
    public static function noFieldNameFoundForColumn($className, $column)
616
    {
617
        return new self(sprintf(
618
            "Cannot find a field on '%s' that is mapped to column '%s'. Either the "
619
                . 'field does not exist or an association exists but it has multiple join columns.',
620
            $className,
621
            $column
622
        ));
623
    }
624
625
    /**
626
     * @param string $className
627
     * @param string $field
628
     *
629
     * @return MappingException
630
     */
631 1
    public static function illegalOrphanRemovalOnIdentifierAssociation($className, $field)
632
    {
633 1
        return new self(sprintf(
634
            'The orphan removal option is not allowed on an association that is '
635 1
                . "part of the identifier in '%s#%s'.",
636 1
            $className,
637 1
            $field
638
        ));
639
    }
640
641
    /**
642
     * @param string $className
643
     * @param string $field
644
     *
645
     * @return MappingException
646
     */
647
    public static function illegalOrphanRemoval($className, $field)
648
    {
649
        return new self('Orphan removal is only allowed on one-to-one and one-to-many ' .
650
            'associations, but ' . $className . '#' . $field . ' is not.');
651
    }
652
653
    /**
654
     * @param string $className
655
     * @param string $field
656
     *
657
     * @return MappingException
658
     */
659 1
    public static function illegalInverseIdentifierAssociation($className, $field)
660
    {
661 1
        return new self(sprintf("An inverse association is not allowed to be identifier in '%s#%s'.", $className, $field));
662
    }
663
664
    /**
665
     * @param string $className
666
     * @param string $field
667
     *
668
     * @return MappingException
669
     */
670 1
    public static function illegalToManyIdentifierAssociation($className, $field)
671
    {
672 1
        return new self(sprintf("Many-to-many or one-to-many associations are not allowed to be identifier in '%s#%s'.", $className, $field));
673
    }
674
675
    /**
676
     * @param string $className
677
     *
678
     * @return MappingException
679
     */
680
    public static function noInheritanceOnMappedSuperClass($className)
681
    {
682
        return new self("It is not supported to define inheritance information on a mapped superclass '" . $className . "'.");
683
    }
684
685
    /**
686
     * @param string $className
687
     * @param string $rootClassName
688
     *
689
     * @return MappingException
690
     */
691 1
    public static function mappedClassNotPartOfDiscriminatorMap($className, $rootClassName)
692
    {
693 1
        return new self(
694 1
            "Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " .
695 1
            "to be properly mapped in the inheritance hierarchy. Alternatively you can make '" . $className . "' an abstract class " .
696 1
            'to avoid this exception from occurring.'
697
        );
698
    }
699
700
    /**
701
     * @param string $className
702
     * @param string $methodName
703
     *
704
     * @return MappingException
705
     */
706 1
    public static function lifecycleCallbackMethodNotFound($className, $methodName)
707
    {
708 1
        return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback.");
709
    }
710
711
    /**
712
     * @param string $listenerName
713
     * @param string $className
714
     *
715
     * @return \Doctrine\ORM\Mapping\MappingException
716
     */
717 1
    public static function entityListenerClassNotFound($listenerName, $className)
718
    {
719 1
        return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className));
720
    }
721
722
    /**
723
     * @param string $listenerName
724
     * @param string $methodName
725
     * @param string $className
726
     *
727
     * @return \Doctrine\ORM\Mapping\MappingException
728
     */
729 1
    public static function entityListenerMethodNotFound($listenerName, $methodName, $className)
730
    {
731 1
        return new self(sprintf('Entity Listener "%s" declared on "%s" has no method "%s".', $listenerName, $className, $methodName));
732
    }
733
734
    /**
735
     * @param string $listenerName
736
     * @param string $methodName
737
     * @param string $className
738
     *
739
     * @return \Doctrine\ORM\Mapping\MappingException
740
     */
741 1
    public static function duplicateEntityListener($listenerName, $methodName, $className)
742
    {
743 1
        return new self(sprintf('Entity Listener "%s#%s()" in "%s" was already declared, but it must be declared only once.', $listenerName, $methodName, $className));
744
    }
745
746
    /**
747
     * @param string $className
748
     * @param string $annotation
749
     *
750
     * @return MappingException
751
     */
752
    public static function invalidFetchMode($className, $annotation)
753
    {
754
        return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $annotation . "'");
755
    }
756
757
    /**
758
     * @param string $className
759
     *
760
     * @return MappingException
761
     */
762
    public static function compositeKeyAssignedIdGeneratorRequired($className)
763
    {
764
        return new self("Entity '" . $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported.");
765
    }
766
767
    /**
768
     * @param string $targetEntity
769
     * @param string $sourceEntity
770
     * @param string $associationName
771
     *
772
     * @return MappingException
773
     */
774 1
    public static function invalidTargetEntityClass($targetEntity, $sourceEntity, $associationName)
775
    {
776 1
        return new self("The target-entity '" . $targetEntity . "' cannot be found in '" . $sourceEntity . '#' . $associationName . "'.");
777
    }
778
779
    /**
780
     * @param string[] $cascades
781
     * @param string   $className
782
     * @param string   $propertyName
783
     *
784
     * @return MappingException
785
     */
786 1
    public static function invalidCascadeOption(array $cascades, $className, $propertyName)
787
    {
788
        $cascades = implode(', ', array_map(static function ($e) {
789 1
            return "'" . $e . "'";
790 1
        }, $cascades));
791
792 1
        return new self(sprintf(
793 1
            "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', and 'refresh'",
794 1
            $className,
795 1
            $propertyName,
796 1
            $cascades
797
        ));
798
    }
799
800
    /**
801
     * @param string $className
802
     *
803
     * @return MappingException
804
     */
805
    public static function missingSequenceName($className)
806
    {
807
        return new self(
808
            sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className)
809
        );
810
    }
811
812
    /**
813
     * @param string $className
814
     * @param string $propertyName
815
     *
816
     * @return MappingException
817
     */
818
    public static function infiniteEmbeddableNesting($className, $propertyName)
819
    {
820
        return new self(
821
            sprintf(
822
                'Infinite nesting detected for embedded property %s::%s. ' .
823
                'You cannot embed an embeddable from the same type inside an embeddable.',
824
                $className,
825
                $propertyName
826
            )
827
        );
828
    }
829
830
    /**
831
     * @param string[] $namespaces
832
     */
833
    public static function classNotFoundInNamespaces(string $className, array $namespaces) : self
834
    {
835
        return new self(
836
            sprintf(
837
                'Class %s not found in namespaces %s.' .
838
                $className,
839
                implode(', ', $namespaces)
840
            )
841
        );
842
    }
843
}
844