← All changes
|
vendor/php-di/invoker/src/Exception/NotCallableException.php
+12
-14
3.0
→
3.5.9
View file →
| @@ -1,34 +1,32 @@ | ||
| 1 | -<?php | |
| 1 | +<?php declare(strict_types=1); | |
| 2 | 2 | |
| 3 | 3 | namespace Invoker\Exception; |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * The given callable is not actually callable. |
| 7 | - * | |
| 8 | - * @author Matthieu Napoli <matthieu@mnapoli.fr> | |
| 9 | 7 | */ |
| 10 | 8 | class NotCallableException extends InvocationException |
| 11 | 9 | { |
| 12 | 10 | /** |
| 13 | - * @param string $value | |
| 14 | - * @param bool $containerEntry | |
| 15 | - * @return self | |
| 11 | + * @param mixed $value | |
| 16 | 12 | */ |
| 17 | - public static function fromInvalidCallable($value, $containerEntry = false) | |
| 13 | + public static function fromInvalidCallable($value, bool $containerEntry = false): self | |
| 18 | 14 | { |
| 19 | 15 | if (is_object($value)) { |
| 20 | 16 | $message = sprintf('Instance of %s is not a callable', get_class($value)); |
| 21 | - } elseif (is_array($value) && isset($value[0]) && isset($value[1])) { | |
| 17 | + } elseif (is_array($value) && isset($value[0], $value[1])) { | |
| 22 | 18 | $class = is_object($value[0]) ? get_class($value[0]) : $value[0]; |
| 23 | - $extra = method_exists($class, '__call') ? ' A __call() method exists but magic methods are not supported.' : ''; | |
| 19 | + | |
| 20 | + $extra = method_exists($class, '__call') || method_exists($class, '__callStatic') | |
| 21 | + ? ' A __call() or __callStatic() method exists but magic methods are not supported.' | |
| 22 | + : ''; | |
| 23 | + | |
| 24 | 24 | $message = sprintf('%s::%s() is not a callable.%s', $class, $value[1], $extra); |
| 25 | + } elseif ($containerEntry) { | |
| 26 | + $message = var_export($value, true) . ' is neither a callable nor a valid container entry'; | |
| 25 | 27 | } else { |
| 26 | - if ($containerEntry) { | |
| 27 | - $message = var_export($value, true) . ' is neither a callable nor a valid container entry'; | |
| 28 | - } else { | |
| 29 | - $message = var_export($value, true) . ' is not a callable'; | |
| 30 | - } | |
| 28 | + $message = var_export($value, true) . ' is not a callable'; | |
| 31 | 29 | } |
| 32 | 30 | |
| 33 | 31 | return new self($message); |
| 34 | 32 | } |