123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- namespace Doctrine\Common\Annotations;
- class AnnotationException extends \Exception
- {
-
- public static function syntaxError($message)
- {
- return new self('[Syntax Error] ' . $message);
- }
-
- public static function semanticalError($message)
- {
- return new self('[Semantical Error] ' . $message);
- }
-
- public static function creationError($message)
- {
- return new self('[Creation Error] ' . $message);
- }
-
- public static function typeError($message)
- {
- return new self('[Type Error] ' . $message);
- }
-
- public static function semanticalErrorConstants($identifier, $context = null)
- {
- return self::semanticalError(sprintf(
- "Couldn't find constant %s%s.",
- $identifier,
- $context ? ', ' . $context : ''
- ));
- }
-
- public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual)
- {
- return self::typeError(sprintf(
- 'Attribute "%s" of @%s declared on %s expects %s, but got %s.',
- $attributeName,
- $annotationName,
- $context,
- $expected,
- is_object($actual) ? 'an instance of ' . get_class($actual) : gettype($actual)
- ));
- }
-
- public static function requiredError($attributeName, $annotationName, $context, $expected)
- {
- return self::typeError(sprintf(
- 'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.',
- $attributeName,
- $annotationName,
- $context,
- $expected
- ));
- }
-
- public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
- {
- return new self(sprintf(
- '[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
- $attributeName,
- $annotationName,
- $context,
- implode(', ', $available),
- is_object($given) ? get_class($given) : $given
- ));
- }
-
- public static function optimizerPlusSaveComments()
- {
- return new self(
- "You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1."
- );
- }
-
- public static function optimizerPlusLoadComments()
- {
- return new self(
- "You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1."
- );
- }
- }
|