1 | <?php |
||
28 | abstract class AbstractView implements View |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * URI of the view. |
||
33 | * |
||
34 | * @since 0.1.0 |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $uri; |
||
39 | |||
40 | /** |
||
41 | * Engine to use for the view. |
||
42 | * |
||
43 | * @since 0.1.0 |
||
44 | * |
||
45 | * @var Engine |
||
46 | */ |
||
47 | protected $engine; |
||
48 | |||
49 | /** |
||
50 | * ViewBuilder instance. |
||
51 | * |
||
52 | * @since 0.2.0 |
||
53 | * |
||
54 | * @var ViewBuilder |
||
55 | */ |
||
56 | protected $builder; |
||
57 | |||
58 | /** |
||
59 | * Instantiate an AbstractView object. |
||
60 | * |
||
61 | * @since 0.1.0 |
||
62 | * |
||
63 | * @param string $uri URI for the view. |
||
64 | * @param Engine $engine Engine to use for the view. |
||
65 | */ |
||
66 | 29 | public function __construct($uri, Engine $engine) |
|
71 | |||
72 | /** |
||
73 | * Render the view. |
||
74 | * |
||
75 | * @since 0.1.0 |
||
76 | * |
||
77 | * @param array $context Optional. The context in which to render the view. |
||
78 | * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
||
79 | * |
||
80 | * @return string|void Rendered HTML or nothing, depending on $echo argument. |
||
81 | */ |
||
82 | 29 | public function render(array $context = [], $echo = false) |
|
99 | |||
100 | /** |
||
101 | * Render a partial view for a given URI. |
||
102 | * |
||
103 | * @since 0.2.0 |
||
104 | * |
||
105 | * @param string $view View identifier to create a view for. |
||
106 | * @param array $context Optional. The context in which to render the view. |
||
|
|||
107 | * @param string|null $type Type of view to create. |
||
108 | * |
||
109 | * @return string Rendered HTML content. |
||
110 | */ |
||
111 | 1 | public function renderPart($view, array $context = null, $type = null) |
|
122 | |||
123 | /** |
||
124 | * Associate a view builder with this view. |
||
125 | * |
||
126 | * @since 0.2.0 |
||
127 | * |
||
128 | * @param ViewBuilder $builder |
||
129 | * |
||
130 | * @return static |
||
131 | */ |
||
132 | 29 | public function setBuilder(ViewBuilder $builder) |
|
138 | |||
139 | /** |
||
140 | * Initialize the view builder associated with the view. |
||
141 | * |
||
142 | * @since 0.2.0 |
||
143 | */ |
||
144 | 29 | protected function initializeViewBuilder() |
|
150 | |||
151 | /** |
||
152 | * Assimilate the context to make it available as properties. |
||
153 | * |
||
154 | * @since 0.2.0 |
||
155 | * |
||
156 | * @param array $context Context to assimilate. |
||
157 | */ |
||
158 | 29 | protected function assimilateContext(array $context = []) |
|
165 | } |
||
166 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.