@@ -26,87 +26,87 @@ |
||
| 26 | 26 | class NullView implements View, NullFindable |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Check whether the Findable can handle an individual criterion. |
|
| 31 | - * |
|
| 32 | - * @since 0.1.0 |
|
| 33 | - * |
|
| 34 | - * @param mixed $criterion Criterion to check. |
|
| 35 | - * |
|
| 36 | - * @return bool Whether the Findable can handle the criterion. |
|
| 37 | - */ |
|
| 38 | - public function canHandle($criterion): bool |
|
| 39 | - { |
|
| 40 | - return true; |
|
| 41 | - } |
|
| 29 | + /** |
|
| 30 | + * Check whether the Findable can handle an individual criterion. |
|
| 31 | + * |
|
| 32 | + * @since 0.1.0 |
|
| 33 | + * |
|
| 34 | + * @param mixed $criterion Criterion to check. |
|
| 35 | + * |
|
| 36 | + * @return bool Whether the Findable can handle the criterion. |
|
| 37 | + */ |
|
| 38 | + public function canHandle($criterion): bool |
|
| 39 | + { |
|
| 40 | + return true; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Render the view. |
|
| 45 | - * |
|
| 46 | - * @since 0.1.0 |
|
| 47 | - * |
|
| 48 | - * @param array $context Optional. The context in which to render the view. |
|
| 49 | - * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
| 50 | - * |
|
| 51 | - * @return string Rendered HTML. |
|
| 52 | - */ |
|
| 53 | - public function render(array $context = [], bool $echo = false): string |
|
| 54 | - { |
|
| 55 | - return ''; |
|
| 56 | - } |
|
| 43 | + /** |
|
| 44 | + * Render the view. |
|
| 45 | + * |
|
| 46 | + * @since 0.1.0 |
|
| 47 | + * |
|
| 48 | + * @param array $context Optional. The context in which to render the view. |
|
| 49 | + * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
| 50 | + * |
|
| 51 | + * @return string Rendered HTML. |
|
| 52 | + */ |
|
| 53 | + public function render(array $context = [], bool $echo = false): string |
|
| 54 | + { |
|
| 55 | + return ''; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Render a partial view (or section) for a given URI. |
|
| 60 | - * |
|
| 61 | - * @since 0.2.0 |
|
| 62 | - * |
|
| 63 | - * @param string $view View identifier to create a view for. |
|
| 64 | - * @param array $context Optional. The context in which to render the view. |
|
| 65 | - * @param string|null $type Type of view to create. |
|
| 66 | - * |
|
| 67 | - * @return string Rendered HTML content. |
|
| 68 | - */ |
|
| 69 | - public function section(string $view, array $context = [], $type = null): string |
|
| 70 | - { |
|
| 71 | - return ''; |
|
| 72 | - } |
|
| 58 | + /** |
|
| 59 | + * Render a partial view (or section) for a given URI. |
|
| 60 | + * |
|
| 61 | + * @since 0.2.0 |
|
| 62 | + * |
|
| 63 | + * @param string $view View identifier to create a view for. |
|
| 64 | + * @param array $context Optional. The context in which to render the view. |
|
| 65 | + * @param string|null $type Type of view to create. |
|
| 66 | + * |
|
| 67 | + * @return string Rendered HTML content. |
|
| 68 | + */ |
|
| 69 | + public function section(string $view, array $context = [], $type = null): string |
|
| 70 | + { |
|
| 71 | + return ''; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get the entire array of contextual data. |
|
| 76 | - * |
|
| 77 | - * @since 0.4.0 |
|
| 78 | - * |
|
| 79 | - * @return array Array of contextual data. |
|
| 80 | - */ |
|
| 81 | - public function getContext(): array |
|
| 82 | - { |
|
| 83 | - return []; |
|
| 84 | - } |
|
| 74 | + /** |
|
| 75 | + * Get the entire array of contextual data. |
|
| 76 | + * |
|
| 77 | + * @since 0.4.0 |
|
| 78 | + * |
|
| 79 | + * @return array Array of contextual data. |
|
| 80 | + */ |
|
| 81 | + public function getContext(): array |
|
| 82 | + { |
|
| 83 | + return []; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Add information to the context. |
|
| 88 | - * |
|
| 89 | - * @param string $key Context key to add. |
|
| 90 | - * @param mixed $value Value to add under the given key. |
|
| 91 | - * @param string $behavior Behavior to use for adapting the context. |
|
| 92 | - * @return View |
|
| 93 | - */ |
|
| 94 | - public function addToContext(string $key, $value, string $behavior): View |
|
| 95 | - { |
|
| 96 | - return $this; |
|
| 97 | - } |
|
| 86 | + /** |
|
| 87 | + * Add information to the context. |
|
| 88 | + * |
|
| 89 | + * @param string $key Context key to add. |
|
| 90 | + * @param mixed $value Value to add under the given key. |
|
| 91 | + * @param string $behavior Behavior to use for adapting the context. |
|
| 92 | + * @return View |
|
| 93 | + */ |
|
| 94 | + public function addToContext(string $key, $value, string $behavior): View |
|
| 95 | + { |
|
| 96 | + return $this; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Associate a view builder with this view. |
|
| 101 | - * |
|
| 102 | - * @since 0.2.0 |
|
| 103 | - * |
|
| 104 | - * @param ViewBuilder $builder |
|
| 105 | - * |
|
| 106 | - * @return View |
|
| 107 | - */ |
|
| 108 | - public function setBuilder(ViewBuilder $builder): View |
|
| 109 | - { |
|
| 110 | - return $this; |
|
| 111 | - } |
|
| 99 | + /** |
|
| 100 | + * Associate a view builder with this view. |
|
| 101 | + * |
|
| 102 | + * @since 0.2.0 |
|
| 103 | + * |
|
| 104 | + * @param ViewBuilder $builder |
|
| 105 | + * |
|
| 106 | + * @return View |
|
| 107 | + */ |
|
| 108 | + public function setBuilder(ViewBuilder $builder): View |
|
| 109 | + { |
|
| 110 | + return $this; |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -31,234 +31,234 @@ |
||
| 31 | 31 | abstract class AbstractView implements View |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * URI of the view. |
|
| 36 | - * |
|
| 37 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 38 | - * |
|
| 39 | - * @since 0.1.0 |
|
| 40 | - * |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 43 | - protected $_uri_; |
|
| 34 | + /** |
|
| 35 | + * URI of the view. |
|
| 36 | + * |
|
| 37 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 38 | + * |
|
| 39 | + * @since 0.1.0 |
|
| 40 | + * |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | + protected $_uri_; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Engine to use for the view. |
|
| 47 | - * |
|
| 48 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 49 | - * |
|
| 50 | - * @since 0.1.0 |
|
| 51 | - * |
|
| 52 | - * @var Engine |
|
| 53 | - */ |
|
| 54 | - protected $_engine_; |
|
| 45 | + /** |
|
| 46 | + * Engine to use for the view. |
|
| 47 | + * |
|
| 48 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 49 | + * |
|
| 50 | + * @since 0.1.0 |
|
| 51 | + * |
|
| 52 | + * @var Engine |
|
| 53 | + */ |
|
| 54 | + protected $_engine_; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * ViewBuilder instance. |
|
| 58 | - * |
|
| 59 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 60 | - * |
|
| 61 | - * @since 0.2.0 |
|
| 62 | - * |
|
| 63 | - * @var ViewBuilder |
|
| 64 | - */ |
|
| 65 | - protected $_builder_; |
|
| 56 | + /** |
|
| 57 | + * ViewBuilder instance. |
|
| 58 | + * |
|
| 59 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 60 | + * |
|
| 61 | + * @since 0.2.0 |
|
| 62 | + * |
|
| 63 | + * @var ViewBuilder |
|
| 64 | + */ |
|
| 65 | + protected $_builder_; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * The context with which the view will be rendered. |
|
| 69 | - * |
|
| 70 | - * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 71 | - * |
|
| 72 | - * @since 0.4.0 |
|
| 73 | - * |
|
| 74 | - * @var array |
|
| 75 | - */ |
|
| 76 | - protected $_context_; |
|
| 67 | + /** |
|
| 68 | + * The context with which the view will be rendered. |
|
| 69 | + * |
|
| 70 | + * The underscores are used to prevent accidental use of these properties from within the rendering closure. |
|
| 71 | + * |
|
| 72 | + * @since 0.4.0 |
|
| 73 | + * |
|
| 74 | + * @var array |
|
| 75 | + */ |
|
| 76 | + protected $_context_; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Instantiate an AbstractView object. |
|
| 80 | - * |
|
| 81 | - * @since 0.1.0 |
|
| 82 | - * |
|
| 83 | - * @param string $uri URI for the view. |
|
| 84 | - * @param Engine $engine Engine to use for the view. |
|
| 85 | - * @param ViewBuilder $viewBuilder View builder instance to use. |
|
| 86 | - * @param array $context Initial context to use. |
|
| 87 | - */ |
|
| 88 | - public function __construct(string $uri, Engine $engine, ViewBuilder $viewBuilder = null, array $context = []) |
|
| 89 | - { |
|
| 90 | - $this->_uri_ = $uri; |
|
| 91 | - $this->_engine_ = $engine; |
|
| 92 | - $this->_builder_ = $viewBuilder ?? Views::getViewBuilder(); |
|
| 93 | - $this->_context_ = $context; |
|
| 94 | - } |
|
| 78 | + /** |
|
| 79 | + * Instantiate an AbstractView object. |
|
| 80 | + * |
|
| 81 | + * @since 0.1.0 |
|
| 82 | + * |
|
| 83 | + * @param string $uri URI for the view. |
|
| 84 | + * @param Engine $engine Engine to use for the view. |
|
| 85 | + * @param ViewBuilder $viewBuilder View builder instance to use. |
|
| 86 | + * @param array $context Initial context to use. |
|
| 87 | + */ |
|
| 88 | + public function __construct(string $uri, Engine $engine, ViewBuilder $viewBuilder = null, array $context = []) |
|
| 89 | + { |
|
| 90 | + $this->_uri_ = $uri; |
|
| 91 | + $this->_engine_ = $engine; |
|
| 92 | + $this->_builder_ = $viewBuilder ?? Views::getViewBuilder(); |
|
| 93 | + $this->_context_ = $context; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Render the view. |
|
| 98 | - * |
|
| 99 | - * @since 0.1.0 |
|
| 100 | - * |
|
| 101 | - * @param array $context Optional. The context in which to render the view. |
|
| 102 | - * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
| 103 | - * |
|
| 104 | - * @return string Rendered HTML. |
|
| 105 | - * @throws FailedToProcessConfigException If the Config could not be processed. |
|
| 106 | - */ |
|
| 107 | - public function render(array $context = [], bool $echo = false): string |
|
| 108 | - { |
|
| 109 | - $this->assimilateContext($context); |
|
| 96 | + /** |
|
| 97 | + * Render the view. |
|
| 98 | + * |
|
| 99 | + * @since 0.1.0 |
|
| 100 | + * |
|
| 101 | + * @param array $context Optional. The context in which to render the view. |
|
| 102 | + * @param bool $echo Optional. Whether to echo the output immediately. Defaults to false. |
|
| 103 | + * |
|
| 104 | + * @return string Rendered HTML. |
|
| 105 | + * @throws FailedToProcessConfigException If the Config could not be processed. |
|
| 106 | + */ |
|
| 107 | + public function render(array $context = [], bool $echo = false): string |
|
| 108 | + { |
|
| 109 | + $this->assimilateContext($context); |
|
| 110 | 110 | |
| 111 | - $closure = Closure::bind( |
|
| 112 | - $this->_engine_->getRenderCallback($this->_uri_, $context), |
|
| 113 | - $this, |
|
| 114 | - static::class |
|
| 115 | - ); |
|
| 111 | + $closure = Closure::bind( |
|
| 112 | + $this->_engine_->getRenderCallback($this->_uri_, $context), |
|
| 113 | + $this, |
|
| 114 | + static::class |
|
| 115 | + ); |
|
| 116 | 116 | |
| 117 | - $output = $closure(); |
|
| 117 | + $output = $closure(); |
|
| 118 | 118 | |
| 119 | - if ($echo) { |
|
| 120 | - echo $output; |
|
| 121 | - } |
|
| 119 | + if ($echo) { |
|
| 120 | + echo $output; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - return $output; |
|
| 124 | - } |
|
| 123 | + return $output; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Render a partial view (or section) for a given URI. |
|
| 128 | - * |
|
| 129 | - * @since 0.2.0 |
|
| 130 | - * |
|
| 131 | - * @param string $view View identifier to create a view for. |
|
| 132 | - * @param array $context Optional. The context in which to render the view. |
|
| 133 | - * @param string|null $type Type of view to create. |
|
| 134 | - * |
|
| 135 | - * @return string Rendered HTML content. |
|
| 136 | - * @throws FailedToProcessConfigException If the Config could not be processed. |
|
| 137 | - * @throws FailedToInstantiateView If the View could not be instantiated. |
|
| 138 | - */ |
|
| 139 | - public function section(string $view, array $context = null, $type = null): string |
|
| 140 | - { |
|
| 141 | - $context = (null === $context) |
|
| 142 | - ? $this->_context_ |
|
| 143 | - : array_merge($this->_context_, $context); |
|
| 126 | + /** |
|
| 127 | + * Render a partial view (or section) for a given URI. |
|
| 128 | + * |
|
| 129 | + * @since 0.2.0 |
|
| 130 | + * |
|
| 131 | + * @param string $view View identifier to create a view for. |
|
| 132 | + * @param array $context Optional. The context in which to render the view. |
|
| 133 | + * @param string|null $type Type of view to create. |
|
| 134 | + * |
|
| 135 | + * @return string Rendered HTML content. |
|
| 136 | + * @throws FailedToProcessConfigException If the Config could not be processed. |
|
| 137 | + * @throws FailedToInstantiateView If the View could not be instantiated. |
|
| 138 | + */ |
|
| 139 | + public function section(string $view, array $context = null, $type = null): string |
|
| 140 | + { |
|
| 141 | + $context = (null === $context) |
|
| 142 | + ? $this->_context_ |
|
| 143 | + : array_merge($this->_context_, $context); |
|
| 144 | 144 | |
| 145 | - $viewObject = $this->_builder_->create($view, $type); |
|
| 145 | + $viewObject = $this->_builder_->create($view, $type); |
|
| 146 | 146 | |
| 147 | - return $viewObject->render($context); |
|
| 148 | - } |
|
| 147 | + return $viewObject->render($context); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Get the entire array of contextual data. |
|
| 152 | - * |
|
| 153 | - * @since 0.4.0 |
|
| 154 | - * |
|
| 155 | - * @return array Array of contextual data. |
|
| 156 | - */ |
|
| 157 | - public function getContext(): array |
|
| 158 | - { |
|
| 159 | - return $this->_context_; |
|
| 160 | - } |
|
| 150 | + /** |
|
| 151 | + * Get the entire array of contextual data. |
|
| 152 | + * |
|
| 153 | + * @since 0.4.0 |
|
| 154 | + * |
|
| 155 | + * @return array Array of contextual data. |
|
| 156 | + */ |
|
| 157 | + public function getContext(): array |
|
| 158 | + { |
|
| 159 | + return $this->_context_; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Add information to the context. |
|
| 164 | - * |
|
| 165 | - * @param string $key Context key to add. |
|
| 166 | - * @param mixed $value Value to add under the given key. |
|
| 167 | - * @param string $behavior Behavior to use for adapting the context. |
|
| 168 | - * @return View |
|
| 169 | - */ |
|
| 170 | - public function addToContext(string $key, $value, string $behavior): View |
|
| 171 | - { |
|
| 172 | - switch ($behavior) { |
|
| 173 | - case View::REPLACE: |
|
| 174 | - $this->_context_[$key] = $value; |
|
| 175 | - return $this; |
|
| 176 | - case View::MERGE: |
|
| 177 | - if (array_key_exists($key, $this->_context_)) { |
|
| 178 | - $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
| 179 | - return $this; |
|
| 180 | - } |
|
| 181 | - $this->_context_[$key] = $value; |
|
| 182 | - return $this; |
|
| 183 | - case View::ADD_ONLY: |
|
| 184 | - if (array_key_exists($key, $this->_context_)) { |
|
| 185 | - return $this; |
|
| 186 | - } |
|
| 187 | - $this->_context_[$key] = $value; |
|
| 188 | - return $this; |
|
| 189 | - case View::REPLACE_ONLY: |
|
| 190 | - if (! array_key_exists($key, $this->_context_)) { |
|
| 191 | - return $this; |
|
| 192 | - } |
|
| 193 | - $this->_context_[$key] = $value; |
|
| 194 | - return $this; |
|
| 195 | - case View::MERGE_ONLY: |
|
| 196 | - if (! array_key_exists($key, $this->_context_)) { |
|
| 197 | - return $this; |
|
| 198 | - } |
|
| 199 | - $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
| 200 | - return $this; |
|
| 201 | - default: |
|
| 202 | - throw new InvalidContextAddingBehavior( |
|
| 203 | - sprintf( |
|
| 204 | - _('Invalid behavior "%s" for adding to the context of view "%s".'), |
|
| 205 | - $key, |
|
| 206 | - $this->_uri_ |
|
| 207 | - ) |
|
| 208 | - ); |
|
| 209 | - } |
|
| 210 | - } |
|
| 162 | + /** |
|
| 163 | + * Add information to the context. |
|
| 164 | + * |
|
| 165 | + * @param string $key Context key to add. |
|
| 166 | + * @param mixed $value Value to add under the given key. |
|
| 167 | + * @param string $behavior Behavior to use for adapting the context. |
|
| 168 | + * @return View |
|
| 169 | + */ |
|
| 170 | + public function addToContext(string $key, $value, string $behavior): View |
|
| 171 | + { |
|
| 172 | + switch ($behavior) { |
|
| 173 | + case View::REPLACE: |
|
| 174 | + $this->_context_[$key] = $value; |
|
| 175 | + return $this; |
|
| 176 | + case View::MERGE: |
|
| 177 | + if (array_key_exists($key, $this->_context_)) { |
|
| 178 | + $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
| 179 | + return $this; |
|
| 180 | + } |
|
| 181 | + $this->_context_[$key] = $value; |
|
| 182 | + return $this; |
|
| 183 | + case View::ADD_ONLY: |
|
| 184 | + if (array_key_exists($key, $this->_context_)) { |
|
| 185 | + return $this; |
|
| 186 | + } |
|
| 187 | + $this->_context_[$key] = $value; |
|
| 188 | + return $this; |
|
| 189 | + case View::REPLACE_ONLY: |
|
| 190 | + if (! array_key_exists($key, $this->_context_)) { |
|
| 191 | + return $this; |
|
| 192 | + } |
|
| 193 | + $this->_context_[$key] = $value; |
|
| 194 | + return $this; |
|
| 195 | + case View::MERGE_ONLY: |
|
| 196 | + if (! array_key_exists($key, $this->_context_)) { |
|
| 197 | + return $this; |
|
| 198 | + } |
|
| 199 | + $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
|
| 200 | + return $this; |
|
| 201 | + default: |
|
| 202 | + throw new InvalidContextAddingBehavior( |
|
| 203 | + sprintf( |
|
| 204 | + _('Invalid behavior "%s" for adding to the context of view "%s".'), |
|
| 205 | + $key, |
|
| 206 | + $this->_uri_ |
|
| 207 | + ) |
|
| 208 | + ); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * Associate a view builder with this view. |
|
| 214 | - * |
|
| 215 | - * @since 0.2.0 |
|
| 216 | - * |
|
| 217 | - * @param ViewBuilder $builder |
|
| 218 | - * |
|
| 219 | - * @return View |
|
| 220 | - */ |
|
| 221 | - public function setBuilder(ViewBuilder $builder): View |
|
| 222 | - { |
|
| 223 | - $this->_builder_ = $builder; |
|
| 212 | + /** |
|
| 213 | + * Associate a view builder with this view. |
|
| 214 | + * |
|
| 215 | + * @since 0.2.0 |
|
| 216 | + * |
|
| 217 | + * @param ViewBuilder $builder |
|
| 218 | + * |
|
| 219 | + * @return View |
|
| 220 | + */ |
|
| 221 | + public function setBuilder(ViewBuilder $builder): View |
|
| 222 | + { |
|
| 223 | + $this->_builder_ = $builder; |
|
| 224 | 224 | |
| 225 | - return $this; |
|
| 226 | - } |
|
| 225 | + return $this; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Assimilate the context to make it available as properties. |
|
| 230 | - * |
|
| 231 | - * @since 0.2.0 |
|
| 232 | - * |
|
| 233 | - * @param array $context Context to assimilate. |
|
| 234 | - */ |
|
| 235 | - protected function assimilateContext(array $context = []) |
|
| 236 | - { |
|
| 237 | - $this->_context_ = $context; |
|
| 238 | - foreach ($context as $key => $value) { |
|
| 239 | - $this->$key = $value; |
|
| 240 | - } |
|
| 241 | - } |
|
| 228 | + /** |
|
| 229 | + * Assimilate the context to make it available as properties. |
|
| 230 | + * |
|
| 231 | + * @since 0.2.0 |
|
| 232 | + * |
|
| 233 | + * @param array $context Context to assimilate. |
|
| 234 | + */ |
|
| 235 | + protected function assimilateContext(array $context = []) |
|
| 236 | + { |
|
| 237 | + $this->_context_ = $context; |
|
| 238 | + foreach ($context as $key => $value) { |
|
| 239 | + $this->$key = $value; |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Turn invokable objects as properties into methods of the view. |
|
| 245 | - * |
|
| 246 | - * @param string $method Method that was called on the view. |
|
| 247 | - * @param array $arguments Array of arguments that were used. |
|
| 248 | - * @return mixed Return value of the invokable object. |
|
| 249 | - */ |
|
| 250 | - public function __call($method, $arguments) |
|
| 251 | - { |
|
| 252 | - if (! property_exists($this, $method) |
|
| 253 | - || ! is_callable($this->$method)) { |
|
| 254 | - trigger_error( |
|
| 255 | - "Call to undefined method {$method} on a view.", |
|
| 256 | - E_USER_ERROR |
|
| 257 | - ); |
|
| 258 | - } |
|
| 243 | + /** |
|
| 244 | + * Turn invokable objects as properties into methods of the view. |
|
| 245 | + * |
|
| 246 | + * @param string $method Method that was called on the view. |
|
| 247 | + * @param array $arguments Array of arguments that were used. |
|
| 248 | + * @return mixed Return value of the invokable object. |
|
| 249 | + */ |
|
| 250 | + public function __call($method, $arguments) |
|
| 251 | + { |
|
| 252 | + if (! property_exists($this, $method) |
|
| 253 | + || ! is_callable($this->$method)) { |
|
| 254 | + trigger_error( |
|
| 255 | + "Call to undefined method {$method} on a view.", |
|
| 256 | + E_USER_ERROR |
|
| 257 | + ); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - $callable = $this->$method; |
|
| 260 | + $callable = $this->$method; |
|
| 261 | 261 | |
| 262 | - return $callable(...$arguments); |
|
| 263 | - } |
|
| 262 | + return $callable(...$arguments); |
|
| 263 | + } |
|
| 264 | 264 | } |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | $this->_context_[$key] = $value; |
| 188 | 188 | return $this; |
| 189 | 189 | case View::REPLACE_ONLY: |
| 190 | - if (! array_key_exists($key, $this->_context_)) { |
|
| 190 | + if ( ! array_key_exists($key, $this->_context_)) { |
|
| 191 | 191 | return $this; |
| 192 | 192 | } |
| 193 | 193 | $this->_context_[$key] = $value; |
| 194 | 194 | return $this; |
| 195 | 195 | case View::MERGE_ONLY: |
| 196 | - if (! array_key_exists($key, $this->_context_)) { |
|
| 196 | + if ( ! array_key_exists($key, $this->_context_)) { |
|
| 197 | 197 | return $this; |
| 198 | 198 | } |
| 199 | 199 | $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function __call($method, $arguments) |
| 251 | 251 | { |
| 252 | - if (! property_exists($this, $method) |
|
| 252 | + if ( ! property_exists($this, $method) |
|
| 253 | 253 | || ! is_callable($this->$method)) { |
| 254 | 254 | trigger_error( |
| 255 | 255 | "Call to undefined method {$method} on a view.", |
@@ -24,34 +24,34 @@ |
||
| 24 | 24 | class NullEngine implements Engine, NullFindable |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Check whether the Findable can handle an individual criterion. |
|
| 29 | - * |
|
| 30 | - * @since 0.1.0 |
|
| 31 | - * |
|
| 32 | - * @param mixed $criterion Criterion to check. |
|
| 33 | - * |
|
| 34 | - * @return bool Whether the Findable can handle the criterion. |
|
| 35 | - */ |
|
| 36 | - public function canHandle($criterion): bool |
|
| 37 | - { |
|
| 38 | - return true; |
|
| 39 | - } |
|
| 27 | + /** |
|
| 28 | + * Check whether the Findable can handle an individual criterion. |
|
| 29 | + * |
|
| 30 | + * @since 0.1.0 |
|
| 31 | + * |
|
| 32 | + * @param mixed $criterion Criterion to check. |
|
| 33 | + * |
|
| 34 | + * @return bool Whether the Findable can handle the criterion. |
|
| 35 | + */ |
|
| 36 | + public function canHandle($criterion): bool |
|
| 37 | + { |
|
| 38 | + return true; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Get the rendering callback for a given URI. |
|
| 43 | - * |
|
| 44 | - * @since 0.1.0 |
|
| 45 | - * |
|
| 46 | - * @param string $uri URI to render. |
|
| 47 | - * @param array $context Context in which to render. |
|
| 48 | - * |
|
| 49 | - * @return callable Rendering callback. |
|
| 50 | - */ |
|
| 51 | - public function getRenderCallback(string $uri, array $context = []): callable |
|
| 52 | - { |
|
| 53 | - return function () { |
|
| 54 | - return ''; |
|
| 55 | - }; |
|
| 56 | - } |
|
| 41 | + /** |
|
| 42 | + * Get the rendering callback for a given URI. |
|
| 43 | + * |
|
| 44 | + * @since 0.1.0 |
|
| 45 | + * |
|
| 46 | + * @param string $uri URI to render. |
|
| 47 | + * @param array $context Context in which to render. |
|
| 48 | + * |
|
| 49 | + * @return callable Rendering callback. |
|
| 50 | + */ |
|
| 51 | + public function getRenderCallback(string $uri, array $context = []): callable |
|
| 52 | + { |
|
| 53 | + return function () { |
|
| 54 | + return ''; |
|
| 55 | + }; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function getRenderCallback(string $uri, array $context = []): callable |
| 52 | 52 | { |
| 53 | - return function () { |
|
| 53 | + return function() { |
|
| 54 | 54 | return ''; |
| 55 | 55 | }; |
| 56 | 56 | } |