UnexpectedValueException.php 1.7 KB

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