|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Phalcon Framework. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Phalcon Team <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE.txt |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* Implementation of this file has been influenced by AuraPHP |
|
12
|
|
|
* |
|
13
|
|
|
* @link https://github.com/auraphp/Aura.Di |
|
14
|
|
|
* @license https://github.com/auraphp/Aura.Di/blob/4.x/LICENSE |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
declare(strict_types=1); |
|
18
|
|
|
|
|
19
|
|
|
namespace Phalcon\Container; |
|
20
|
|
|
|
|
21
|
|
|
use Phalcon\Container\Exception\ContainerLocked; |
|
22
|
|
|
use Phalcon\Container\Exception\MissingParameter; |
|
23
|
|
|
use Phalcon\Container\Exception\MutationDoesNotImplementInterface; |
|
24
|
|
|
use Phalcon\Container\Exception\NoSuchProperty; |
|
25
|
|
|
use Phalcon\Container\Exception\ServiceNotFound; |
|
26
|
|
|
use Phalcon\Container\Exception\ServiceNotObject; |
|
27
|
|
|
use Phalcon\Container\Exception\SetterMethodNotFound; |
|
28
|
|
|
use Psr\Container\ContainerExceptionInterface; |
|
29
|
|
|
use Throwable; |
|
30
|
|
|
|
|
31
|
|
|
use function gettype; |
|
32
|
|
|
use function is_object; |
|
33
|
|
|
|
|
34
|
|
|
class Exception extends \Exception implements ContainerExceptionInterface, Throwable |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* A mutation was lazy and returned a value that is not an instanceof |
|
38
|
|
|
* MutationInterface. |
|
39
|
|
|
* |
|
40
|
|
|
* @param mixed $value The returned value. |
|
41
|
|
|
* |
|
42
|
|
|
* @return SetterMethodNotFound |
|
43
|
|
|
* @throws MutationDoesNotImplementInterface |
|
44
|
|
|
*/ |
|
45
|
1 |
|
public static function mutationDoesNotImplementInterface($value): SetterMethodNotFound |
|
46
|
|
|
{ |
|
47
|
1 |
|
if (is_object($value)) { |
|
48
|
|
|
$className = get_class($value); |
|
49
|
|
|
throw new MutationDoesNotImplementInterface( |
|
50
|
|
|
"Mutation does not implement interface: {$className}" |
|
51
|
|
|
); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
1 |
|
$typeName = gettype($value); |
|
55
|
1 |
|
throw new MutationDoesNotImplementInterface( |
|
56
|
1 |
|
"Expected Mutation interface, got: {$typeName}" |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* A requested property does not exist. |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $name The property name. |
|
64
|
|
|
* |
|
65
|
|
|
* @return NoSuchProperty |
|
66
|
|
|
* @throws NoSuchProperty |
|
67
|
|
|
*/ |
|
68
|
|
|
public static function noSuchProperty(string $name): NoSuchProperty |
|
69
|
|
|
{ |
|
70
|
|
|
throw new NoSuchProperty("Property does not exist: \${$name}"); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|