Skip to content

Commit 921ca7c

Browse files
Narrow types
1 parent eb9bfeb commit 921ca7c

File tree

20 files changed

+83
-169
lines changed

20 files changed

+83
-169
lines changed

src/Framework/Constraint/Type/IsType.php

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -28,75 +28,24 @@
2828
*/
2929
final class IsType extends Constraint
3030
{
31-
/**
32-
* @var string
33-
*/
34-
public const TYPE_ARRAY = 'array';
35-
36-
/**
37-
* @var string
38-
*/
39-
public const TYPE_BOOL = 'bool';
40-
41-
/**
42-
* @var string
43-
*/
44-
public const TYPE_FLOAT = 'float';
45-
46-
/**
47-
* @var string
48-
*/
49-
public const TYPE_INT = 'int';
50-
51-
/**
52-
* @var string
53-
*/
54-
public const TYPE_NULL = 'null';
55-
56-
/**
57-
* @var string
58-
*/
59-
public const TYPE_NUMERIC = 'numeric';
60-
61-
/**
62-
* @var string
63-
*/
64-
public const TYPE_OBJECT = 'object';
65-
66-
/**
67-
* @var string
68-
*/
69-
public const TYPE_RESOURCE = 'resource';
70-
71-
/**
72-
* @var string
73-
*/
74-
public const TYPE_CLOSED_RESOURCE = 'resource (closed)';
75-
76-
/**
77-
* @var string
78-
*/
79-
public const TYPE_STRING = 'string';
80-
81-
/**
82-
* @var string
83-
*/
84-
public const TYPE_SCALAR = 'scalar';
85-
86-
/**
87-
* @var string
88-
*/
89-
public const TYPE_CALLABLE = 'callable';
90-
91-
/**
92-
* @var string
93-
*/
94-
public const TYPE_ITERABLE = 'iterable';
95-
96-
/**
97-
* @var array<string,bool>
98-
*/
99-
private const KNOWN_TYPES = [
31+
public const string TYPE_ARRAY = 'array';
32+
public const string TYPE_BOOL = 'bool';
33+
public const string TYPE_FLOAT = 'float';
34+
public const string TYPE_INT = 'int';
35+
public const string TYPE_NULL = 'null';
36+
public const string TYPE_NUMERIC = 'numeric';
37+
public const string TYPE_OBJECT = 'object';
38+
public const string TYPE_RESOURCE = 'resource';
39+
public const string TYPE_CLOSED_RESOURCE = 'resource (closed)';
40+
public const string TYPE_STRING = 'string';
41+
public const string TYPE_SCALAR = 'scalar';
42+
public const string TYPE_CALLABLE = 'callable';
43+
public const string TYPE_ITERABLE = 'iterable';
44+
45+
/**
46+
* @var non-empty-array<non-empty-string, bool>
47+
*/
48+
private const array KNOWN_TYPES = [
10049
'array' => true,
10150
'boolean' => true,
10251
'bool' => true,

src/Framework/MockObject/Generator/Generator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ final class Generator
6464
use TemplateLoader;
6565

6666
/**
67-
* @var array<non-empty-string, true>
67+
* @var non-empty-array<non-empty-string, true>
6868
*/
69-
private const EXCLUDED_METHOD_NAMES = [
69+
private const array EXCLUDED_METHOD_NAMES = [
7070
'__CLASS__' => true,
7171
'__DIR__' => true,
7272
'__FILE__' => true,

src/Logging/TestDox/HtmlRenderer.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
*/
1919
final readonly class HtmlRenderer
2020
{
21-
/**
22-
* @var string
23-
*/
24-
private const PAGE_HEADER = <<<'EOT'
21+
private const string PAGE_HEADER = <<<'EOT'
2522
<!doctype html>
2623
<html lang="en">
2724
<head>
@@ -76,28 +73,16 @@
7673
</head>
7774
<body>
7875
EOT;
79-
80-
/**
81-
* @var string
82-
*/
83-
private const CLASS_HEADER = <<<'EOT'
76+
private const string CLASS_HEADER = <<<'EOT'
8477
8578
<h2>%s</h2>
8679
<ul>
8780

8881
EOT;
89-
90-
/**
91-
* @var string
92-
*/
93-
private const CLASS_FOOTER = <<<'EOT'
82+
private const string CLASS_FOOTER = <<<'EOT'
9483
</ul>
9584
EOT;
96-
97-
/**
98-
* @var string
99-
*/
100-
private const PAGE_FOOTER = <<<'EOT'
85+
private const string PAGE_FOOTER = <<<'EOT'
10186
10287
</body>
10388
</html>

src/Runner/Baseline/Baseline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
final class Baseline
1818
{
19-
public const VERSION = 1;
19+
public const int VERSION = 1;
2020

2121
/**
2222
* @var array<non-empty-string, array<positive-int, list<Issue>>>

src/Runner/ResultCache/DefaultResultCache.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,8 @@
3333
*/
3434
final class DefaultResultCache implements ResultCache
3535
{
36-
/**
37-
* @var int
38-
*/
39-
private const VERSION = 1;
40-
41-
/**
42-
* @var string
43-
*/
44-
private const DEFAULT_RESULT_CACHE_FILENAME = '.phpunit.result.cache';
36+
private const int VERSION = 1;
37+
private const string DEFAULT_RESULT_CACHE_FILENAME = '.phpunit.result.cache';
4538
private readonly string $cacheFilename;
4639

4740
/**

src/Runner/TestSuiteSorter.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,17 @@
3333
*/
3434
final class TestSuiteSorter
3535
{
36-
/**
37-
* @var int
38-
*/
39-
public const ORDER_DEFAULT = 0;
40-
41-
/**
42-
* @var int
43-
*/
44-
public const ORDER_RANDOMIZED = 1;
45-
46-
/**
47-
* @var int
48-
*/
49-
public const ORDER_REVERSED = 2;
36+
public const int ORDER_DEFAULT = 0;
37+
public const int ORDER_RANDOMIZED = 1;
38+
public const int ORDER_REVERSED = 2;
39+
public const int ORDER_DEFECTS_FIRST = 3;
40+
public const int ORDER_DURATION = 4;
41+
public const int ORDER_SIZE = 5;
5042

5143
/**
52-
* @var int
44+
* @var non-empty-array<non-empty-string, positive-int>
5345
*/
54-
public const ORDER_DEFECTS_FIRST = 3;
55-
56-
/**
57-
* @var int
58-
*/
59-
public const ORDER_DURATION = 4;
60-
61-
/**
62-
* @var int
63-
*/
64-
public const ORDER_SIZE = 5;
65-
66-
private const SIZE_SORT_WEIGHT = [
46+
private const array SIZE_SORT_WEIGHT = [
6747
'small' => 1,
6848
'medium' => 2,
6949
'large' => 3,

src/TextUI/Command/Result.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
final readonly class Result
2020
{
21-
public const SUCCESS = 0;
22-
public const FAILURE = 1;
23-
public const EXCEPTION = 2;
24-
public const CRASH = 255;
21+
public const int SUCCESS = 0;
22+
public const int FAILURE = 1;
23+
public const int EXCEPTION = 2;
24+
public const int CRASH = 255;
2525
private string $output;
2626
private int $shellExitCode;
2727

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
*/
3232
final class Builder
3333
{
34-
private const LONG_OPTIONS = [
34+
/**
35+
* @var non-empty-list<non-empty-string>
36+
*/
37+
private const array LONG_OPTIONS = [
3538
'atleast-version=',
3639
'bootstrap=',
3740
'cache-result',
@@ -137,7 +140,8 @@ final class Builder
137140
'debug',
138141
'extension=',
139142
];
140-
private const SHORT_OPTIONS = 'd:c:h';
143+
144+
private const string SHORT_OPTIONS = 'd:c:h';
141145

142146
/**
143147
* @var array<string, non-negative-int>

src/TextUI/Configuration/Configuration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
*/
1717
final readonly class Configuration
1818
{
19-
public const COLOR_NEVER = 'never';
20-
public const COLOR_AUTO = 'auto';
21-
public const COLOR_ALWAYS = 'always';
22-
public const COLOR_DEFAULT = self::COLOR_NEVER;
19+
public const string COLOR_NEVER = 'never';
20+
public const string COLOR_AUTO = 'auto';
21+
public const string COLOR_ALWAYS = 'always';
22+
public const string COLOR_DEFAULT = self::COLOR_NEVER;
2323

2424
/**
2525
* @var list<non-empty-string>

src/TextUI/Configuration/Xml/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @var string
2323
*/
24-
private const TEMPLATE = <<<'EOT'
24+
private const string TEMPLATE = <<<'EOT'
2525
<?xml version="1.0" encoding="UTF-8"?>
2626
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2727
xsi:noNamespaceSchemaLocation="{schema_location}"

0 commit comments

Comments
 (0)