diff --git a/stubs/laminas/view/model/ViewModel.stub b/stubs/laminas/view/model/ViewModel.stub new file mode 100644 index 0000000..e1cdf5e --- /dev/null +++ b/stubs/laminas/view/model/ViewModel.stub @@ -0,0 +1,318 @@ + + */ + protected array $children = []; + + /** + * Renderer options + * + * @var array + */ + protected array $options = []; + + /** + * Template to use when rendering this model + */ + protected string $template = ''; + + /** + * Is this a standalone, or terminal, model? + */ + protected bool $terminate = false; + + /** + * View variables + * + * @var array|ArrayAccess|Traversable + * @psalm-var array|ArrayAccess&Traversable + * @phpstan-var array|ArrayAccess&Traversable + */ + protected array | ArrayAccess | Traversable $variables = []; + + /** + * Is this append to child with the same capture? + */ + protected bool $append = false; + + /** + * Constructor + * + * @param array|Traversable|ArrayAccess|null $variables + * @param array|Traversable|null $options + * + * @throws InvalidArgumentException + */ + public function __construct( + array | Traversable | ArrayAccess | null $variables = null, + array | Traversable | null $options = null, + ); + + /** + * Property overloading: set variable value + * + * @throws void + */ + public function __set(string $name, mixed $value): void; + + /** + * Property overloading: get variable value + * + * @throws void + */ + public function __get(string $name): mixed; + + /** + * Property overloading: do we have the requested variable value? + * + * @throws void + */ + public function __isset(string $name): bool; + + /** + * Property overloading: unset the requested variable + * + * @throws void + */ + public function __unset(string $name): void; + + /** + * Called after this view model is cloned. + * + * Clones $variables property so changes done to variables in the new + * instance don't change the current one. + * + * @return void + * + * @throws void + */ + public function __clone(); + + /** + * Set a single option + * + * @throws void + */ + public function setOption(string $name, mixed $value): self; + + /** + * Get a single option + * + * @param string $name The option to get. + * @param mixed|null $default (optional) A default value if the option is not yet set. + * + * @throws void + */ + public function getOption(string $name, mixed $default = null): mixed; + + /** + * Set renderer options/hints en masse + * + * @param array|Traversable $options + * + * @throws InvalidArgumentException + */ + public function setOptions(array | Traversable $options): self; + + /** + * Get renderer options/hints + * + * @return array + * + * @throws void + */ + public function getOptions(): array; + + /** + * Clear any existing renderer options/hints + * + * @throws void + */ + public function clearOptions(): self; + + /** + * Get a single view variable + * + * @param mixed|null $default (optional) default value if the variable is not present. + * + * @throws void + */ + public function getVariable(string $name, mixed $default = null): mixed; + + /** + * Set view variable + * + * @throws void + */ + public function setVariable(string $name, mixed $value): self; + + /** + * Set view variables en masse + * + * Can be an array or a Traversable + ArrayAccess object. + * + * @param bool $overwrite Whether or not to overwrite the internal container with $variables + * + * @throws InvalidArgumentException + */ + public function setVariables(array | ArrayAccess | Traversable $variables, bool $overwrite = false): self; + + /** + * Get view variables + * + * @psalm-return array|ArrayAccess&Traversable + * @phpstan-return array|ArrayAccess&Traversable + * + * @throws void + */ + public function getVariables(): array | ArrayAccess | Traversable; + + /** + * Clear all variables + * + * Resets the internal variable container to an empty container. + * + * @throws void + */ + public function clearVariables(): self; + + /** + * Set the template to be used by this model + * + * @throws void + */ + public function setTemplate(string $template): self; + + /** + * Get the template to be used by this model + * + * @throws void + */ + public function getTemplate(): string; + + /** + * Add a child model + * + * @param string|null $captureTo Optional; if specified, the "capture to" value to set on the child + * @param bool|null $append Optional; if specified, append to child with the same capture + * + * @throws void + */ + public function addChild(ModelInterface $child, string | null $captureTo = null, bool | null $append = null): self; + + /** + * Return all children. + * + * Return specifies an array, but may be any iterable object. + * + * @return list + * + * @throws void + */ + public function getChildren(): array; + + /** + * Does the model have any children? + * + * @throws void + */ + public function hasChildren(): bool; + + /** + * Clears out all child models + * + * @throws void + */ + public function clearChildren(): self; + + /** + * Returns an array of Viewmodels with captureTo value $capture + * + * @param bool $recursive search recursive through children, default true + * + * @return list + * + * @throws void + */ + public function getChildrenByCaptureTo(string $capture, bool $recursive = true): array; + + /** + * Set the name of the variable to capture this model to, if it is a child model + * + * @throws void + */ + public function setCaptureTo(string $capture): self; + + /** + * Get the name of the variable to which to capture this model + * + * @throws void + */ + public function captureTo(): string; + + /** + * Set flag indicating whether or not this is considered a terminal or standalone model + * + * @throws void + */ + public function setTerminal(bool $terminate): self; + + /** + * Is this considered a terminal or standalone model? + * + * @throws void + */ + public function terminate(): bool; + + /** + * Set flag indicating whether or not append to child with the same capture + * + * @throws void + */ + public function setAppend(bool $append): self; + + /** + * Is this append to child with the same capture? + * + * @throws void + */ + public function isAppend(): bool; + + /** + * Return count of children + * + * @throws void + */ + #[ReturnTypeWillChange] + public function count(): int; + + /** + * Get iterator of children + * + * @return Traversable + * + * @throws void + */ + #[ReturnTypeWillChange] + public function getIterator(): Traversable; +}