Skip to content

Commit cc2d038

Browse files
committed
run fixer
1 parent 2e95621 commit cc2d038

File tree

418 files changed

+74834
-58592
lines changed

Some content is hidden

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

418 files changed

+74834
-58592
lines changed

src/DocBlock/TypeExpression.php

Lines changed: 136 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -38,143 +38,151 @@ final class TypeExpression
3838
*
3939
* @internal
4040
*/
41-
public const REGEX_TYPES = '(?<types>(?x) # one or several types separated by `|` or `&`
42-
'.self::REGEX_TYPE.'
43-
(?:
44-
\h*(?<glue>[|&])\h*
45-
(?&type)
46-
)*+
47-
)';
48-
49-
private const REGEX_TYPE = '(?<type>(?x) # single type
50-
(?<nullable>\??\h*)
51-
(?:
52-
(?<array_shape>
53-
(?<array_shape_start>(?i)(?:array|list|object)(?-i)\h*\{\h*)
54-
(?<array_shape_inners>
55-
(?<array_shape_inner>
56-
(?<array_shape_inner_key>(?:(?&constant)|(?&identifier))\h*\??\h*:\h*|)
57-
(?<array_shape_inner_value>(?&types_inner))
41+
public const REGEX_TYPES = <<<'EOD'
42+
(?<types>(?x) # one or several types separated by `|` or `&`
43+
44+
EOD.self::REGEX_TYPE.<<<'EOD'
45+
46+
(?:
47+
\h*(?<glue>[|&])\h*
48+
(?&type)
49+
)*+
50+
)
51+
EOD;
52+
53+
private const REGEX_TYPE = <<<'EOD'
54+
(?<type>(?x) # single type
55+
(?<nullable>\??\h*)
56+
(?:
57+
(?<array_shape>
58+
(?<array_shape_start>(?i)(?:array|list|object)(?-i)\h*\{\h*)
59+
(?<array_shape_inners>
60+
(?<array_shape_inner>
61+
(?<array_shape_inner_key>(?:(?&constant)|(?&identifier))\h*\??\h*:\h*|)
62+
(?<array_shape_inner_value>(?&types_inner))
63+
)
64+
(?:
65+
\h*,\h*
66+
(?&array_shape_inner)
67+
)*
68+
(?:\h*,\h*)?
69+
|)
70+
\h*\}
5871
)
59-
(?:
60-
\h*,\h*
61-
(?&array_shape_inner)
62-
)*
63-
(?:\h*,\h*)?
64-
|)
65-
\h*\}
66-
)
67-
|
68-
(?<callable> # callable syntax, e.g. `callable(string, int...): bool`
69-
(?<callable_start>(?&name)\h*\(\h*)
70-
(?<callable_arguments>
71-
(?<callable_argument>
72-
(?<callable_argument_type>(?&types_inner))
73-
(?<callable_argument_is_reference>\h*&|)
74-
(?<callable_argument_is_variadic>\h*\.\.\.|)
75-
(?<callable_argument_name>\h*\$(?&identifier)|)
76-
(?<callable_argument_is_optional>\h*=|)
72+
|
73+
(?<callable> # callable syntax, e.g. `callable(string, int...): bool`
74+
(?<callable_start>(?&name)\h*\(\h*)
75+
(?<callable_arguments>
76+
(?<callable_argument>
77+
(?<callable_argument_type>(?&types_inner))
78+
(?<callable_argument_is_reference>\h*&|)
79+
(?<callable_argument_is_variadic>\h*\.\.\.|)
80+
(?<callable_argument_name>\h*\$(?&identifier)|)
81+
(?<callable_argument_is_optional>\h*=|)
82+
)
83+
(?:
84+
\h*,\h*
85+
(?&callable_argument)
86+
)*
87+
(?:\h*,\h*)?
88+
|)
89+
\h*\)
90+
(?:
91+
\h*\:\h*
92+
(?<callable_return>(?&type))
93+
)?
7794
)
78-
(?:
79-
\h*,\h*
80-
(?&callable_argument)
81-
)*
82-
(?:\h*,\h*)?
83-
|)
84-
\h*\)
85-
(?:
86-
\h*\:\h*
87-
(?<callable_return>(?&type))
88-
)?
89-
)
90-
|
91-
(?<generic> # generic syntax, e.g.: `array<int, \Foo\Bar>`
92-
(?<generic_start>(?&name)\h*<\h*)
93-
(?<generic_types>
94-
(?&types_inner)
95-
(?:
96-
\h*,\h*
97-
(?&types_inner)
98-
)*
99-
(?:\h*,\h*)?
100-
)
101-
\h*>
102-
)
103-
|
104-
(?<class_constant> # class constants with optional wildcard, e.g.: `Foo::*`, `Foo::CONST_A`, `FOO::CONST_*`
105-
(?&name)::\*?(?:(?&identifier)\*?)*
106-
)
107-
|
108-
(?<constant> # single constant value (case insensitive), e.g.: 1, -1.8E+6, `\'a\'`
109-
(?i)
110-
# all sorts of numbers: with or without sign, supports literal separator and several numeric systems,
111-
# e.g.: 1, +1.1, 1., .1, -1, 123E+8, 123_456_789, 0x7Fb4, 0b0110, 0o777
112-
[+-]?(?:
113-
(?:0b[01]++(?:_[01]++)*+)
114-
| (?:0o[0-7]++(?:_[0-7]++)*+)
115-
| (?:0x[\da-f]++(?:_[\da-f]++)*+)
116-
| (?:(?<constant_digits>\d++(?:_\d++)*+)|(?=\.\d))
117-
(?:\.(?&constant_digits)|(?<=\d)\.)?+
118-
(?:e[+-]?(?&constant_digits))?+
119-
)
120-
| \'(?:[^\'\\\\]|\\\\.)*+\'
121-
| "(?:[^"\\\\]|\\\\.)*+"
122-
(?-i)
123-
)
124-
|
125-
(?<this> # self reference, e.g.: $this, $self, @static
126-
(?i)
127-
[@$](?:this | self | static)
128-
(?-i)
129-
)
130-
|
131-
(?<name> # full name, e.g.: `int`, `\DateTime`, `\Foo\Bar`, `positive-int`
132-
\\\\?+
133-
(?<identifier>'.self::REGEX_IDENTIFIER.')
134-
(?:[\\\\\-](?&identifier))*+
135-
)
136-
|
137-
(?<parenthesized> # parenthesized type, e.g.: `(int)`, `(int|\stdClass)`
138-
(?<parenthesized_start>
139-
\(\h*
140-
)
141-
(?:
142-
(?<parenthesized_types>
143-
(?&types_inner)
95+
|
96+
(?<generic> # generic syntax, e.g.: `array<int, \Foo\Bar>`
97+
(?<generic_start>(?&name)\h*<\h*)
98+
(?<generic_types>
99+
(?&types_inner)
100+
(?:
101+
\h*,\h*
102+
(?&types_inner)
103+
)*
104+
(?:\h*,\h*)?
105+
)
106+
\h*>
144107
)
145108
|
146-
(?<conditional> # conditional type, e.g.: `$foo is \Throwable ? false : $foo`
147-
(?<conditional_cond_left>
148-
(?:\$(?&identifier))
149-
|
150-
(?<conditional_cond_left_types>(?&types_inner))
109+
(?<class_constant> # class constants with optional wildcard, e.g.: `Foo::*`, `Foo::CONST_A`, `FOO::CONST_*`
110+
(?&name)::\*?(?:(?&identifier)\*?)*
111+
)
112+
|
113+
(?<constant> # single constant value (case insensitive), e.g.: 1, -1.8E+6, `'a'`
114+
(?i)
115+
# all sorts of numbers: with or without sign, supports literal separator and several numeric systems,
116+
# e.g.: 1, +1.1, 1., .1, -1, 123E+8, 123_456_789, 0x7Fb4, 0b0110, 0o777
117+
[+-]?(?:
118+
(?:0b[01]++(?:_[01]++)*+)
119+
| (?:0o[0-7]++(?:_[0-7]++)*+)
120+
| (?:0x[\da-f]++(?:_[\da-f]++)*+)
121+
| (?:(?<constant_digits>\d++(?:_\d++)*+)|(?=\.\d))
122+
(?:\.(?&constant_digits)|(?<=\d)\.)?+
123+
(?:e[+-]?(?&constant_digits))?+
151124
)
152-
(?<conditional_cond_middle>
153-
\h+(?i)is(?:\h+not)?(?-i)\h+
125+
| '(?:[^'\\]|\\.)*+'
126+
| "(?:[^"\\]|\\.)*+"
127+
(?-i)
128+
)
129+
|
130+
(?<this> # self reference, e.g.: $this, $self, @static
131+
(?i)
132+
[@$](?:this | self | static)
133+
(?-i)
134+
)
135+
|
136+
(?<name> # full name, e.g.: `int`, `\DateTime`, `\Foo\Bar`, `positive-int`
137+
\\?+
138+
(?<identifier>
139+
EOD.self::REGEX_IDENTIFIER.<<<'EOD'
140+
)
141+
(?:[\\\-](?&identifier))*+
142+
)
143+
|
144+
(?<parenthesized> # parenthesized type, e.g.: `(int)`, `(int|\stdClass)`
145+
(?<parenthesized_start>
146+
\(\h*
154147
)
155-
(?<conditional_cond_right_types>(?&types_inner))
156-
(?<conditional_true_start>\h*\?\h*)
157-
(?<conditional_true_types>(?&types_inner))
158-
(?<conditional_false_start>\h*:\h*)
159-
(?<conditional_false_types>(?&types_inner))
148+
(?:
149+
(?<parenthesized_types>
150+
(?&types_inner)
151+
)
152+
|
153+
(?<conditional> # conditional type, e.g.: `$foo is \Throwable ? false : $foo`
154+
(?<conditional_cond_left>
155+
(?:\$(?&identifier))
156+
|
157+
(?<conditional_cond_left_types>(?&types_inner))
158+
)
159+
(?<conditional_cond_middle>
160+
\h+(?i)is(?:\h+not)?(?-i)\h+
161+
)
162+
(?<conditional_cond_right_types>(?&types_inner))
163+
(?<conditional_true_start>\h*\?\h*)
164+
(?<conditional_true_types>(?&types_inner))
165+
(?<conditional_false_start>\h*:\h*)
166+
(?<conditional_false_types>(?&types_inner))
167+
)
168+
)
169+
\h*\)
160170
)
161171
)
162-
\h*\)
163-
)
164-
)
165-
(?<array> # array, e.g.: `string[]`, `array<int, string>[][]`
166-
(\h*\[\h*\])*
167-
)
168-
(?:(?=1)0
169-
(?<types_inner>
170-
(?&type)
171-
(?:
172-
\h*[|&]\h*
173-
(?&type)
174-
)*+
172+
(?<array> # array, e.g.: `string[]`, `array<int, string>[][]`
173+
(\h*\[\h*\])*
174+
)
175+
(?:(?=1)0
176+
(?<types_inner>
177+
(?&type)
178+
(?:
179+
\h*[|&]\h*
180+
(?&type)
181+
)*+
182+
)
183+
|)
175184
)
176-
|)
177-
)';
185+
EOD;
178186

179187
private string $value;
180188

src/Fixer/Alias/MbStrFunctionsFixer.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,22 @@ public function getDefinition(): FixerDefinitionInterface
8585
'Replace non multibyte-safe functions with corresponding mb function.',
8686
[
8787
new CodeSample(
88-
'<?php
89-
$a = strlen($a);
90-
$a = strpos($a, $b);
91-
$a = strrpos($a, $b);
92-
$a = substr($a, $b);
93-
$a = strtolower($a);
94-
$a = strtoupper($a);
95-
$a = stripos($a, $b);
96-
$a = strripos($a, $b);
97-
$a = strstr($a, $b);
98-
$a = stristr($a, $b);
99-
$a = strrchr($a, $b);
100-
$a = substr_count($a, $b);
101-
'
88+
<<<'EOD'
89+
<?php
90+
$a = strlen($a);
91+
$a = strpos($a, $b);
92+
$a = strrpos($a, $b);
93+
$a = substr($a, $b);
94+
$a = strtolower($a);
95+
$a = strtoupper($a);
96+
$a = stripos($a, $b);
97+
$a = strripos($a, $b);
98+
$a = strstr($a, $b);
99+
$a = stristr($a, $b);
100+
$a = strrchr($a, $b);
101+
$a = substr_count($a, $b);
102+
103+
EOD
102104
),
103105
],
104106
null,

src/Fixer/Alias/ModernizeStrposFixer.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ public function getDefinition(): FixerDefinitionInterface
6161
'Replace `strpos()` calls with `str_starts_with()` or `str_contains()` if possible.',
6262
[
6363
new CodeSample(
64-
'<?php
65-
if (strpos($haystack, $needle) === 0) {}
66-
if (strpos($haystack, $needle) !== 0) {}
67-
if (strpos($haystack, $needle) !== false) {}
68-
if (strpos($haystack, $needle) === false) {}
69-
'
64+
<<<'EOD'
65+
<?php
66+
if (strpos($haystack, $needle) === 0) {}
67+
if (strpos($haystack, $needle) !== 0) {}
68+
if (strpos($haystack, $needle) !== false) {}
69+
if (strpos($haystack, $needle) === false) {}
70+
71+
EOD
7072
),
7173
],
7274
null,

0 commit comments

Comments
 (0)