UnexpectedValueException.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Doctrine\Common\Proxy\Exception;
  3. use UnexpectedValueException as BaseUnexpectedValueException;
  4. /**
  5. * Proxy Unexpected Value Exception.
  6. *
  7. * @link www.doctrine-project.org
  8. * @since 2.4
  9. * @author Marco Pivetta <ocramius@gmail.com>
  10. *
  11. * @deprecated The Doctrine\Common\Proxy component is deprecated, please use ocramius/proxy-manager instead.
  12. */
  13. class UnexpectedValueException extends BaseUnexpectedValueException implements ProxyException
  14. {
  15. /**
  16. * @param string $proxyDirectory
  17. *
  18. * @return self
  19. */
  20. public static function proxyDirectoryNotWritable($proxyDirectory)
  21. {
  22. return new self(sprintf('Your proxy directory "%s" must be writable', $proxyDirectory));
  23. }
  24. /**
  25. * @param string $className
  26. * @param string $methodName
  27. * @param string $parameterName
  28. * @param \Exception|null $previous
  29. *
  30. * @return self
  31. */
  32. public static function invalidParameterTypeHint(
  33. $className,
  34. $methodName,
  35. $parameterName,
  36. \Exception $previous = null
  37. ) {
  38. return new self(
  39. sprintf(
  40. 'The type hint of parameter "%s" in method "%s" in class "%s" is invalid.',
  41. $parameterName,
  42. $methodName,
  43. $className
  44. ),
  45. 0,
  46. $previous
  47. );
  48. }
  49. /**
  50. * @param $className
  51. * @param $methodName
  52. * @param \Exception|null $previous
  53. *
  54. * @return self
  55. */
  56. public static function invalidReturnTypeHint($className, $methodName, \Exception $previous = null)
  57. {
  58. return new self(
  59. sprintf(
  60. 'The return type of method "%s" in class "%s" is invalid.',
  61. $methodName,
  62. $className
  63. ),
  64. 0,
  65. $previous
  66. );
  67. }
  68. }