1 | <?php |
||
10 | abstract class ContainerBuilder |
||
11 | { |
||
12 | /** |
||
13 | * ContainerBuilder constructor. |
||
14 | * @param array $annotations 需加载的注释和顺序 |
||
15 | * @param Cache $cache |
||
16 | * 语法 http://jmespath.org/tutorial.html |
||
17 | * |
||
18 | * [ |
||
19 | * [PropertyAnnotationHandler::class, 'property'], |
||
20 | * ... |
||
21 | * ]; |
||
22 | * |
||
23 | */ |
||
24 | 87 | public function __construct(array $annotations, Cache $cache) |
|
29 | |||
30 | 1 | public function setCache(Cache $cache) |
|
34 | /** |
||
35 | * load from class with local cache |
||
36 | * @param string $className |
||
37 | * @return object |
||
38 | */ |
||
39 | 87 | public function build($className) |
|
63 | |||
64 | /** |
||
65 | * @param string $className |
||
66 | * @return object |
||
67 | */ |
||
68 | abstract protected function createContainer($className); |
||
69 | |||
70 | 20 | protected function postCreateContainer($object) |
|
78 | /** |
||
79 | * @param $className |
||
80 | * @return object |
||
81 | */ |
||
82 | 20 | public function buildWithoutCache($className) |
|
101 | |||
102 | /** |
||
103 | * @var array |
||
104 | */ |
||
105 | private $annotations=[]; |
||
106 | /** |
||
107 | * @var Cache |
||
108 | */ |
||
109 | private $cache; |
||
110 | } |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.