Skip to content

Commit f13bd41

Browse files
Merge pull request #18247 from kamil-tekiela/Native-param-types
Native param types
2 parents ec12d8d + 8a5ce0b commit f13bd41

210 files changed

Lines changed: 1793 additions & 2194 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libraries/classes/Advisory/Advisor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private function setVariables(): void
136136
* @param string|int $variable Variable to set
137137
* @param mixed $value Value to set
138138
*/
139-
public function setVariable(string|int $variable, $value): void
139+
public function setVariable(string|int $variable, mixed $value): void
140140
{
141141
$this->variables[$variable] = $value;
142142
}

libraries/classes/Cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Cache
2020
* @param string $cacheKey The key to use
2121
* @param mixed $value The value to cache
2222
*/
23-
public static function set(string $cacheKey, $value): void
23+
public static function set(string $cacheKey, mixed $value): void
2424
{
2525
self::$cacheData[$cacheKey] = $value;
2626
}
@@ -43,7 +43,7 @@ public static function has(string $cacheKey): bool
4343
*
4444
* @return mixed The cached value
4545
*/
46-
public static function get(string $cacheKey, $defaultValue = null): mixed
46+
public static function get(string $cacheKey, mixed $defaultValue = null): mixed
4747
{
4848
return self::$cacheData[$cacheKey] ?? $defaultValue;
4949
}

libraries/classes/Config.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ public function loadUserPreferences(bool $isMinimumCommon = false): void
542542
public function setUserValue(
543543
string|null $cookie_name,
544544
string $cfg_path,
545-
$new_cfg_value,
546-
$default_value = null,
545+
string $new_cfg_value,
546+
string|null $default_value = null,
547547
): bool|Message {
548548
$userPreferences = new UserPreferences($GLOBALS['dbi']);
549549
$result = true;
@@ -578,7 +578,7 @@ public function setUserValue(
578578
* @param string $cookie_name cookie name
579579
* @param mixed $cfg_value config value
580580
*/
581-
public function getUserValue(string $cookie_name, $cfg_value): mixed
581+
public function getUserValue(string $cookie_name, mixed $cfg_value): mixed
582582
{
583583
$cookie_exists = ! empty($this->getCookie($cookie_name));
584584
$prefs_type = $this->get('user_preferences');
@@ -712,7 +712,7 @@ public function get(string $setting): mixed
712712
* @param string $setting configuration option
713713
* @param mixed $value new value for configuration option
714714
*/
715-
public function set(string $setting, $value): void
715+
public function set(string $setting, mixed $value): void
716716
{
717717
if (isset($this->settings[$setting]) && $this->settings[$setting] === $value) {
718718
return;

libraries/classes/Config/ConfigFile.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ConfigFile
7777
* {@link PhpMyAdmin\Config::$base_config},
7878
* use only when not in PMA Setup
7979
*/
80-
public function __construct($baseConfig = null)
80+
public function __construct(array|null $baseConfig = null)
8181
{
8282
// load default config values
8383
$settings = new Settings([]);
@@ -132,7 +132,7 @@ public function getPersistKeysMap(): array
132132
*
133133
* @param array|null $keys array of allowed keys or null to remove filter
134134
*/
135-
public function setAllowedKeys($keys): void
135+
public function setAllowedKeys(array|null $keys): void
136136
{
137137
if ($keys === null) {
138138
$this->setFilter = null;
@@ -178,12 +178,8 @@ public function setConfigData(array $cfg): void
178178

179179
/**
180180
* Sets config value
181-
*
182-
* @param string $path Path
183-
* @param mixed $value Value
184-
* @param string $canonicalPath Canonical path
185181
*/
186-
public function set($path, $value, $canonicalPath = null): void
182+
public function set(string $path, mixed $value, string|null $canonicalPath = null): void
187183
{
188184
if ($canonicalPath === null) {
189185
$canonicalPath = $this->getCanonicalPath($path);
@@ -284,7 +280,7 @@ public function updateWithGlobalConfig(array $cfg): void
284280
* @param string $path Path of config file
285281
* @param mixed $default Default values
286282
*/
287-
public function get($path, $default = null): mixed
283+
public function get(string $path, mixed $default = null): mixed
288284
{
289285
return Core::arrayRead($path, $_SESSION[$this->id], $default);
290286
}
@@ -297,7 +293,7 @@ public function get($path, $default = null): mixed
297293
* @param string $canonicalPath Canonical path
298294
* @param mixed $default Default value
299295
*/
300-
public function getDefault($canonicalPath, $default = null): mixed
296+
public function getDefault(string $canonicalPath, mixed $default = null): mixed
301297
{
302298
return Core::arrayRead($canonicalPath, $this->defaultCfg, $default);
303299
}
@@ -309,7 +305,7 @@ public function getDefault($canonicalPath, $default = null): mixed
309305
* @param string $path Path
310306
* @param mixed $default Default value
311307
*/
312-
public function getValue($path, $default = null): mixed
308+
public function getValue(string $path, mixed $default = null): mixed
313309
{
314310
$v = Core::arrayRead($path, $_SESSION[$this->id], null);
315311
if ($v !== null) {
@@ -326,7 +322,7 @@ public function getValue($path, $default = null): mixed
326322
*
327323
* @param string $path Path
328324
*/
329-
public function getCanonicalPath($path): string
325+
public function getCanonicalPath(string $path): string
330326
{
331327
return preg_replace('#^Servers/([\d]+)/#', 'Servers/1/', $path);
332328
}
@@ -337,7 +333,7 @@ public function getCanonicalPath($path): string
337333
* @param string $path path of the variable in config db
338334
* @param mixed $default default value
339335
*/
340-
public function getDbEntry($path, $default = null): mixed
336+
public function getDbEntry(string $path, mixed $default = null): mixed
341337
{
342338
return Core::arrayRead($path, $this->cfgDb, $default);
343339
}
@@ -367,7 +363,7 @@ public function getServers(): array
367363
*
368364
* @param int $server server index
369365
*/
370-
public function getServerDSN($server): string
366+
public function getServerDSN(int $server): string
371367
{
372368
if (! isset($_SESSION[$this->id]['Servers'][$server])) {
373369
return '';
@@ -402,7 +398,7 @@ public function getServerDSN($server): string
402398
*
403399
* @param int $id server index
404400
*/
405-
public function getServerName($id): string
401+
public function getServerName(int $id): string
406402
{
407403
if (! isset($_SESSION[$this->id]['Servers'][$id])) {
408404
return '';
@@ -423,7 +419,7 @@ public function getServerName($id): string
423419
*
424420
* @param int $server server index
425421
*/
426-
public function removeServer($server): void
422+
public function removeServer(int $server): void
427423
{
428424
if (! isset($_SESSION[$this->id]['Servers'][$server])) {
429425
return;

libraries/classes/Config/Descriptions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Descriptions
2424
* @param string $path Path of configuration
2525
* @param string $type Type of message, either 'name', 'cmt' or 'desc'
2626
*/
27-
public static function get($path, $type = 'name'): string
27+
public static function get(string $path, string $type = 'name'): string
2828
{
2929
$key = str_replace(
3030
[
@@ -988,7 +988,7 @@ private static function getNames(): array
988988
*
989989
* @return string|null Null if not found
990990
*/
991-
public static function getString($path, $type = 'name'): string|null
991+
public static function getString(string $path, string $type = 'name'): string|null
992992
{
993993
$descriptions = [];
994994

libraries/classes/Config/Form.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ class Form
8181
* @param int|null $index arbitrary index, stored in Form::$index
8282
*/
8383
public function __construct(
84-
$formName,
84+
string $formName,
8585
array $form,
8686
ConfigFile $cf,
87-
$index = null,
87+
int|null $index = null,
8888
) {
8989
$this->index = $index;
9090
$this->configFile = $cf;
@@ -98,7 +98,7 @@ public function __construct(
9898
*
9999
* @return string|null one of: boolean, integer, double, string, select, array
100100
*/
101-
public function getOptionType($optionName): string|null
101+
public function getOptionType(string $optionName): string|null
102102
{
103103
$key = ltrim(
104104
mb_substr(
@@ -118,7 +118,7 @@ public function getOptionType($optionName): string|null
118118
*
119119
* @return array
120120
*/
121-
public function getOptionValueList($optionPath): array
121+
public function getOptionValueList(string $optionPath): array
122122
{
123123
$value = $this->configFile->getDbEntry($optionPath);
124124
if ($value === null) {
@@ -171,7 +171,7 @@ public function getOptionValueList($optionPath): array
171171
* @param mixed $key Key
172172
* @param mixed $prefix Prefix
173173
*/
174-
private function readFormPathsCallback($value, $key, $prefix): void
174+
private function readFormPathsCallback(mixed $value, mixed $key, mixed $prefix): void
175175
{
176176
if (is_array($value)) {
177177
$prefix .= $key . '/';
@@ -293,7 +293,7 @@ protected function cleanGroupPaths(array $form): array
293293
* @param string $formName Form name
294294
* @param array $form Form
295295
*/
296-
public function loadForm($formName, array $form): void
296+
public function loadForm(string $formName, array $form): void
297297
{
298298
$this->name = $formName;
299299
$form = $this->cleanGroupPaths($form);

libraries/classes/Config/FormDisplay.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ public function getConfigFile(): ConfigFile
124124
/**
125125
* Registers form in form manager
126126
*
127-
* @param string $formName Form name
128-
* @param array $form Form data
129-
* @param int $serverId 0 if new server, validation; >= 1 if editing a server
127+
* @param string $formName Form name
128+
* @param array $form Form data
129+
* @param int|null $serverId 0 if new server, validation; >= 1 if editing a server
130130
*/
131-
public function registerForm($formName, array $form, $serverId = null): void
131+
public function registerForm(string $formName, array $form, int|null $serverId = null): void
132132
{
133133
$this->forms[$formName] = new Form($formName, $form, $this->configFile, $serverId);
134134
$this->isValidated = false;
@@ -148,7 +148,7 @@ public function registerForm($formName, array $form, $serverId = null): void
148148
* on failed validation
149149
* @param bool $checkFormSubmit whether check for $_POST['submit_save']
150150
*/
151-
public function process($allowPartialSave = true, $checkFormSubmit = true): bool
151+
public function process(bool $allowPartialSave = true, bool $checkFormSubmit = true): bool
152152
{
153153
if ($checkFormSubmit && ! isset($_POST['submit_save'])) {
154154
return false;
@@ -207,17 +207,17 @@ private function validate(): void
207207
/**
208208
* Outputs HTML for forms
209209
*
210-
* @param bool $showButtons whether show submit and reset button
211-
* @param string $formAction action attribute for the form
212-
* @param array|null $hiddenFields array of form hidden fields (key: field
213-
* name)
210+
* @param bool $showButtons whether show submit and reset button
211+
* @param string|null $formAction action attribute for the form
212+
* @param array|null $hiddenFields array of form hidden fields (key: field
213+
* name)
214214
*
215215
* @return string HTML for forms
216216
*/
217217
public function getDisplay(
218-
$showButtons = true,
219-
$formAction = null,
220-
$hiddenFields = null,
218+
bool $showButtons = true,
219+
string|null $formAction = null,
220+
array|null $hiddenFields = null,
221221
): string {
222222
$js = [];
223223
$jsDefault = [];
@@ -325,11 +325,11 @@ public function getDisplay(
325325
*/
326326
private function displayFieldInput(
327327
Form $form,
328-
$field,
329-
$systemPath,
330-
$workPath,
331-
$translatedPath,
332-
$userPrefsAllow,
328+
string $field,
329+
string $systemPath,
330+
string $workPath,
331+
string $translatedPath,
332+
bool|null $userPrefsAllow,
333333
array &$jsDefault,
334334
): string|null {
335335
$name = Descriptions::get($systemPath);
@@ -514,7 +514,7 @@ public function fixErrors(): void
514514
* @param string|bool $value Current value
515515
* @param array $allowed List of allowed values
516516
*/
517-
private function validateSelect(&$value, array $allowed): bool
517+
private function validateSelect(string|bool &$value, array $allowed): bool
518518
{
519519
$valueCmp = is_bool($value)
520520
? (int) $value
@@ -717,7 +717,7 @@ public function hasErrors(): bool
717717
*
718718
* @param string $path Path to documentation
719719
*/
720-
public function getDocLink($path): string
720+
public function getDocLink(string $path): string
721721
{
722722
$test = mb_substr($path, 0, 6);
723723
if ($test === 'Import' || $test === 'Export') {
@@ -736,7 +736,7 @@ public function getDocLink($path): string
736736
*
737737
* @param string $path Path
738738
*/
739-
private function getOptName($path): string
739+
private function getOptName(string $path): string
740740
{
741741
return str_replace(['Servers/1/', '/'], ['Servers/', '_'], $path);
742742
}
@@ -764,7 +764,7 @@ private function loadUserprefsInfo(): void
764764
* @param string $systemPath Path to settings
765765
* @param array $opts Chosen options
766766
*/
767-
private function setComments($systemPath, array &$opts): void
767+
private function setComments(string $systemPath, array &$opts): void
768768
{
769769
// RecodingEngine - mark unavailable types
770770
if ($systemPath === 'RecodingEngine') {
@@ -851,7 +851,7 @@ private function setComments($systemPath, array &$opts): void
851851
* @param array $postValues List of parameters
852852
* @param string $key Array key
853853
*/
854-
private function fillPostArrayParameters(array $postValues, $key): void
854+
private function fillPostArrayParameters(array $postValues, string $key): void
855855
{
856856
foreach ($postValues as $v) {
857857
$v = Util::requestString($v);

libraries/classes/Config/FormDisplayTemplate.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ public function __construct(protected Config $config)
5656
* @param array|null $opts see above description
5757
*/
5858
public function displayInput(
59-
$path,
60-
$name,
61-
$type,
62-
$value,
63-
$description = '',
64-
$valueIsDefault = true,
65-
$opts = null,
59+
string $path,
60+
string $name,
61+
string $type,
62+
mixed $value,
63+
string $description = '',
64+
bool $valueIsDefault = true,
65+
array|null $opts = null,
6666
): string {
6767
$isSetupScript = $this->config->get('is_setup');
6868
$optionIsDisabled = ! $isSetupScript && isset($opts['userprefs_allow']) && ! $opts['userprefs_allow'];
@@ -131,7 +131,7 @@ public function displayGroupFooter(): void
131131
* @param string|array $validators validators callback
132132
* @param array $jsArray will be updated with javascript code
133133
*/
134-
public function addJsValidate($fieldId, string|array $validators, array &$jsArray): void
134+
public function addJsValidate(string $fieldId, string|array $validators, array &$jsArray): void
135135
{
136136
foreach ((array) $validators as $validator) {
137137
$validator = (array) $validator;
@@ -150,7 +150,7 @@ public function addJsValidate($fieldId, string|array $validators, array &$jsArra
150150
*
151151
* @return string HTML for errors
152152
*/
153-
public function displayErrors($name, array $errorList): string
153+
public function displayErrors(string $name, array $errorList): string
154154
{
155155
return $this->template->render('config/form_display/errors', [
156156
'name' => $name,

libraries/classes/Config/Forms/BaseForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class BaseForm extends FormDisplay
2121
* @param ConfigFile $cf Config file instance
2222
* @param int|null $serverId 0 if new server, validation; >= 1 if editing a server
2323
*/
24-
final public function __construct(ConfigFile $cf, $serverId = null)
24+
final public function __construct(ConfigFile $cf, int|null $serverId = null)
2525
{
2626
parent::__construct($cf);
2727

libraries/classes/Config/Forms/BaseFormList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ final public function __construct(ConfigFile $cf)
6767
* on failed validation
6868
* @param bool $checkFormSubmit whether check for $_POST['submit_save']
6969
*/
70-
public function process($allowPartialSave = true, $checkFormSubmit = true): bool
70+
public function process(bool $allowPartialSave = true, bool $checkFormSubmit = true): bool
7171
{
7272
$ret = true;
7373
foreach ($this->forms as $form) {

0 commit comments

Comments
 (0)