MDL-72321 question: Ensure that all instance props are defined

Since PHP 8.2, all properties on a class must be defined as the PHP
Dynamic Property feature has been deprecated.

This commit goes one step further and switches this class to using
constructor property promotion. This language feature has been available
since PHP 8.0 and allows for simplified creation of class properties
which are initially defined in the constructor.
This commit is contained in:
Andrew Nicols 2023-09-01 09:21:33 +08:00 committed by Ilya Tregubov
parent b36bc08686
commit 47cc73fe1a
No known key found for this signature in database
GPG Key ID: 0F58186F748E55C1

View File

@ -30,41 +30,19 @@ use stdClass;
*/
class question_bank_filter_ui extends datafilter {
/** @var array $searchconditions Searchconditions for the filter. */
protected $searchconditions = array();
/** @var int $perpage number of records per page. */
protected $perpage = 0;
/**
* @var string Component for calling the fragment callback.
*/
protected $component;
/**
* @var string Fragment callback.
*/
protected $callback;
/**
* @var string View class name.
*/
protected $view;
/**
* @var int|null if in an activity, the cmid.
*/
protected $cmid;
/**
* @var array Parameters for the page URL.
*/
/** @var array Parameters for the page URL. */
protected $pagevars;
/**
* @var array Additional parameters used by view classes.
*/
protected $extraparams;
/** @var array $searchconditions Searchconditions for the filter. */
/** @var array $additionalparams Conditino objects for the current filter. */
/** @var string $component Component for calling the fragment callback. */
/** @var string $callback Fragment callback. */
/** @var string $view View class name. */
/** @var int|null $cmid if in an activity, the cmid. */
/** @var array $extraparams Additional parameters used by view classes. */
/**
* Create a new datafilter
@ -82,24 +60,17 @@ class question_bank_filter_ui extends datafilter {
*/
public function __construct(
\context $context,
array $searchconditions,
array $additionalparams,
string $component,
string $callback,
string $view,
protected array $searchconditions,
protected array $additionalparams,
protected string $component,
protected string $callback,
protected string $view,
?string $tableregionid = null,
?int $cmid = null,
protected ?int $cmid = null,
array $pagevars = [],
array $extraparams = []
protected array $extraparams = []
) {
parent::__construct($context, $tableregionid);
$this->searchconditions = $searchconditions;
$this->additionalparams = $additionalparams;
$this->component = $component;
$this->callback = $callback;
$this->view = $view;
$this->cmid = $cmid;
$this->extraparams = $extraparams;
if (array_key_exists('sortData', $pagevars)) {
foreach ($pagevars['sortData'] as $sortname => $sortorder) {
unset($pagevars['sortData'][$sortname]);