Skip to content

Commit 0bdcaba

Browse files
Add native property types (#18143)
* Add native property types Includes TypeHints.UnionTypeHintFormat Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Set some default values for properties Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Format and promote properties Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove redundant asserts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant cast Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $tmanager->theme is never null Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant variable Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix empty on $statementInfo bool Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant casts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant issets Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * getPacked() returns nullable string Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant if Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $this->content can be null Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify ThemeManager::getInstance() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use isset for checking if property is initialized Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use nullable instead of uninitialized property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * password is no longer nullable I can't verify that none of the globals ever tried to set it to null, but the variable should never be nullable. Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Update baselines Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $same_wide_width param can be float or int Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Update Message.php Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Cast Sub_part to int Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix one line doc comments Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent c459f4d commit 0bdcaba

180 files changed

Lines changed: 1195 additions & 3219 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
class Advisor
3333
{
3434
/** @var array */
35-
private $variables;
35+
private array $variables = [];
3636

3737
/** @var array */
38-
private $globals;
38+
private array $globals = [];
3939

4040
/**
4141
* @var array<int, array<string, string>>
4242
* @psalm-var list<RuleType>
4343
*/
44-
private $rules = [];
44+
private array $rules = [];
4545

4646
/** @var array{fired:array, notfired:array, unchecked:array, errors:array} */
47-
private $runResult = [
47+
private array $runResult = [
4848
'fired' => [],
4949
'notfired' => [],
5050
'unchecked' => [],

libraries/classes/Bookmark.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,24 @@ class Bookmark
2727
{
2828
/**
2929
* ID of the bookmark
30-
*
31-
* @var int
3230
*/
33-
private $id;
31+
private int $id = 0;
3432
/**
3533
* Database the bookmark belongs to
36-
*
37-
* @var string
3834
*/
39-
private $database;
35+
private string $database = '';
4036
/**
4137
* The user to whom the bookmark belongs, empty for public bookmarks
42-
*
43-
* @var string
4438
*/
45-
private $currentUser;
39+
private string $currentUser = '';
4640
/**
4741
* Label of the bookmark
48-
*
49-
* @var string
5042
*/
51-
private $label;
43+
private string $label = '';
5244
/**
5345
* SQL query that is bookmarked
54-
*
55-
* @var string
5646
*/
57-
private $query;
47+
private string $query = '';
5848

5949
public function __construct(private DatabaseInterface $dbi, private Relation $relation)
6050
{

libraries/classes/BrowseForeigners.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@ class BrowseForeigners
2727
private int $repeatCells;
2828
private bool $showAll;
2929

30-
/** @var Template */
31-
public $template;
32-
33-
public function __construct(Template $template)
30+
public function __construct(public Template $template)
3431
{
35-
$this->template = $template;
36-
3732
$this->limitChars = (int) $GLOBALS['cfg']['LimitChars'];
3833
$this->maxRows = (int) $GLOBALS['cfg']['MaxRows'];
3934
$this->repeatCells = (int) $GLOBALS['cfg']['RepeatCells'];

libraries/classes/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Cache
1313
{
1414
/** @var array<string,mixed> */
15-
private static $cacheData = [];
15+
private static array $cacheData = [];
1616

1717
/**
1818
* Store a value

libraries/classes/Charsets.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Charsets
2929
*
3030
* @var array<string, string>
3131
*/
32-
public static $mysqlCharsetMap = [
32+
public static array $mysqlCharsetMap = [
3333
'big5' => 'big5',
3434
'cp-866' => 'cp866',
3535
'euc-jp' => 'ujis',
@@ -57,16 +57,14 @@ class Charsets
5757

5858
/**
5959
* The charset for the server
60-
*
61-
* @var Charset|null
6260
*/
63-
private static $serverCharset = null;
61+
private static Charset|null $serverCharset = null;
6462

6563
/** @var array<string, Charset> */
66-
private static $charsets = [];
64+
private static array $charsets = [];
6765

6866
/** @var array<string, array<string, Collation>> */
69-
private static $collations = [];
67+
private static array $collations = [];
7068

7169
/**
7270
* Loads charset data from the server

libraries/classes/Common.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656

5757
final class Common
5858
{
59-
/** @var ServerRequest|null */
60-
private static $request = null;
59+
private static ServerRequest|null $request = null;
6160

6261
/**
6362
* Misc stuff and REQUIRED by ALL the scripts.

libraries/classes/Config.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,24 @@
7474
class Config
7575
{
7676
/** @var array default configuration settings */
77-
public $default = [];
77+
public array $default = [];
7878

7979
/** @var array configuration settings, without user preferences applied */
80-
public $baseSettings = [];
80+
public array $baseSettings = [];
8181

8282
/** @var array configuration settings */
83-
public $settings = [];
83+
public array $settings = [];
8484

8585
/** @var string config source */
86-
public $source = '';
86+
public string $source = '';
8787

8888
/** @var int source modification time */
89-
public $sourceMtime = 0;
89+
public int $sourceMtime = 0;
9090

91-
/** @var bool */
92-
public $errorConfigFile = false;
91+
public bool $errorConfigFile = false;
9392

9493
/** @var array */
95-
public $defaultServer = [];
94+
public array $defaultServer = [];
9695

9796
/**
9897
* @param string|null $source source to read config from
@@ -483,8 +482,7 @@ public function loadUserPreferences(bool $isMinimumCommon = false): void
483482
} else {
484483
// no cookie - read default from settings
485484
if (
486-
$tmanager->theme !== null
487-
&& $this->settings['ThemeDefault'] != $tmanager->theme->getId()
485+
$this->settings['ThemeDefault'] != $tmanager->theme->getId()
488486
&& $tmanager->checkTheme($this->settings['ThemeDefault'])
489487
) {
490488
$tmanager->setActiveTheme($this->settings['ThemeDefault']);

libraries/classes/Config/ConfigFile.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ class ConfigFile
3434
*
3535
* @var array
3636
*/
37-
private $cfgDb;
37+
private array $cfgDb;
3838

3939
/**
4040
* Stores original PMA config, not modified by user preferences
41-
*
42-
* @var array|null
4341
*/
44-
private $baseCfg;
42+
private array|null $baseCfg = null;
4543

4644
/**
4745
* Whether we are currently working in PMA Setup context
@@ -53,22 +51,20 @@ class ConfigFile
5351
*
5452
* @var array
5553
*/
56-
private $persistKeys = [];
54+
private array $persistKeys = [];
5755

5856
/**
5957
* Changes keys while updating config in {@link updateWithGlobalConfig()}
6058
* or reading by {@link getConfig()} or {@link getConfigArray()}
6159
*
6260
* @var array
6361
*/
64-
private $cfgUpdateReadMapping = [];
62+
private array $cfgUpdateReadMapping = [];
6563

6664
/**
6765
* Key filter for {@link set()}
68-
*
69-
* @var array|null
7066
*/
71-
private $setFilter;
67+
private array|null $setFilter = null;
7268

7369
/**
7470
* Instance id (key in $_SESSION array, separate for each server -

libraries/classes/Config/Form.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,34 @@ class Form
3333
{
3434
/**
3535
* Form name
36-
*
37-
* @var string
3836
*/
39-
public $name;
37+
public string $name;
4038

4139
/**
4240
* Arbitrary index, doesn't affect class' behavior
43-
*
44-
* @var int
4541
*/
46-
public $index;
42+
public int|null $index;
4743

4844
/**
4945
* Form fields (paths), filled by {@link readFormPaths()}, indexed by field name
5046
*
5147
* @var array
5248
*/
53-
public $fields;
49+
public array $fields;
5450

5551
/**
5652
* Stores default values for some fields (eg. pmadb tables)
5753
*
5854
* @var array
5955
*/
60-
public $default;
56+
public array $default;
6157

6258
/**
6359
* Caches field types, indexed by field names
6460
*
6561
* @var array
6662
*/
67-
private $fieldsTypes;
63+
private array $fieldsTypes;
6864

6965
/**
7066
* ConfigFile instance
@@ -73,18 +69,16 @@ class Form
7369

7470
/**
7571
* A counter for the number of groups
76-
*
77-
* @var int
7872
*/
79-
private static $groupCounter = 0;
73+
private static int $groupCounter = 0;
8074

8175
/**
8276
* Reads default config values
8377
*
8478
* @param string $formName Form name
8579
* @param array $form Form data
8680
* @param ConfigFile $cf Config file instance
87-
* @param int $index arbitrary index, stored in Form::$index
81+
* @param int|null $index arbitrary index, stored in Form::$index
8882
*/
8983
public function __construct(
9084
$formName,

libraries/classes/Config/FormDisplay.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class FormDisplay
5656
*
5757
* @var array<string, Form>
5858
*/
59-
private $forms = [];
59+
private array $forms = [];
6060

6161
/**
6262
* Stores validation errors, indexed by paths
@@ -65,43 +65,39 @@ class FormDisplay
6565
*
6666
* @var array
6767
*/
68-
private $errors = [];
68+
private array $errors = [];
6969

7070
/**
7171
* Paths changed so that they can be used as HTML ids, indexed by paths
7272
*
7373
* @var array
7474
*/
75-
private $translatedPaths = [];
75+
private array $translatedPaths = [];
7676

7777
/**
7878
* Server paths change indexes so we define maps from current server
7979
* path to the first one, indexed by work path
8080
*
8181
* @var array
8282
*/
83-
private $systemPaths = [];
83+
private array $systemPaths = [];
8484

8585
/**
8686
* Tells whether forms have been validated
87-
*
88-
* @var bool
8987
*/
90-
private $isValidated = true;
88+
private bool $isValidated = true;
9189

9290
/**
9391
* Dictionary with user preferences keys
94-
*
95-
* @var array|null
9692
*/
97-
private $userprefsKeys;
93+
private array|null $userprefsKeys = null;
9894

9995
/**
10096
* Dictionary with disallowed user preferences keys
10197
*
10298
* @var array
10399
*/
104-
private $userprefsDisallow;
100+
private array $userprefsDisallow = [];
105101

106102
private FormDisplayTemplate $formDisplayTemplate;
107103

0 commit comments

Comments
 (0)