<?php

namespace Config;

use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;

/**
 * @phpstan-type parser_callable (callable(mixed): mixed)
 * @phpstan-type parser_callable_string (callable(mixed): mixed)&string
 */
class View extends BaseView
{
    /**
     * When false, the view method will clear the data between each
     * call. This keeps your data safe and ensures there is no accidental
     * leaking between calls, so you would need to explicitly pass the data
     * to each view. You might prefer to have the data stick around between
     * calls so that it is available to all views. If that is the case,
     * set $saveData to true.
     *
     * @var bool
     */
    public $saveData = true;

    /**
     * View Namespaces
     *
     * Allows loading views from application modules.
     *
     * Usage:
     * return view('frontend::home/index');
     *
     * @var array<string, string>
     */
    public array $viewPaths = [
        'frontend' => APPPATH . 'Modules/Frontend/Views/',
    ];

    /**
     * Parser Filters map a filter name with any PHP callable.
     *
     * @var         array<string, string>
     * @phpstan-var array<string, parser_callable_string>
     */
    public $filters = [];

    /**
     * Parser Plugins provide a way to extend the functionality provided
     * by the core Parser.
     *
     * @var         array<string, callable|list<string>|string>
     * @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
     */
    public $plugins = [];

    /**
     * View Decorators are class methods that will be run in sequence
     * to alter the generated output just prior to caching the results.
     *
     * @var list<class-string<ViewDecoratorInterface>>
     */
    public array $decorators = [];
}
