-
-
Notifications
You must be signed in to change notification settings - Fork 22
Improve regex to also match Type[][]
#421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
Could we stop mixing |
|
|
|
These are coming from WordPress?! We are not using |
|
At the end of the day |
|
[
[
[
'font-family' => 'Font Family',
'src' => ['src.woff2'],
'font-style' => 'normal',
'font-weight' => '400',
// ...
],
[
'font-family' => 'Font Family',
'src' => ['src-700.woff2'],
'font-style' => 'normal',
'font-weight' => '700',
// ...
],
],
[
[
'font-family' => 'Other Font Family',
'src' => ['other-src.woff2'],
'font-style' => 'normal',
'font-weight' => '400',
// ...
],
[
'font-family' => 'Other Font Family',
'src' => ['other-src-700.woff2'],
'font-style' => 'normal',
'font-weight' => '700',
// ...
],
],
]; |
|
I see!
Is it okay? |
|
The formatting in |
PHPStan does not support the bracketed generic array syntax (
string[]). When transforming WordPress’@typearray annotations, the visitor therefore uses a regular expression to replaceType[]patterns witharray.At present, the regex matches only a single level (
Type[]) and misses nested forms (Type[][]), which also occur in the WordPress codebase. Missing these nested arrays results in invalid types like@phpstan-param array[]<int|string, array{...This PR generalises the pattern to support multiple levels of nesting. Because the visitor derives array nesting from indentation, its behaviour is unchanged apart from correctly replacing these
Type[][]…cases.