File tree Expand file tree Collapse file tree 6 files changed +55
-3
lines changed Expand file tree Collapse file tree 6 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 31
31
$x = '\\Symfony\\Component\\Yaml\\Ya_1';
32
32
$x = 'Humbug\\Symfony\\Component\\Yaml\\Ya_1';
33
33
$x = '\\Humbug\\Symfony\\Component\\Yaml\\Ya_1';
34
+ $x = '1\2';
34
35
35
36
----
36
37
<?php
45
46
$x = 'Humbug\Symfony\Component\Yaml\Ya_1';
46
47
$x = 'Humbug\Symfony\Component\Yaml\Ya_1';
47
48
$x = 'Humbug\Symfony\Component\Yaml\Ya_1';
49
+ $x = '1\2';
48
50
49
51
PHP,
50
52
Original file line number Diff line number Diff line change @@ -102,7 +102,8 @@ final class StringScalarPrefixer extends NodeVisitorAbstract
102
102
/^
103
103
(\\)? # leading backslash
104
104
(
105
- [\p{L}_\d]+ # class-like name
105
+ [\p{L}_] # class-like name first character
106
+ [\p{L}_\d]* # class-like name
106
107
\\ # separator
107
108
)*
108
109
[\p{L}_\d]+ # class-like name
Original file line number Diff line number Diff line change 35
35
{
36
36
private const XML_EXTENSION_REGEX = '/\.xml$/i ' ;
37
37
private const NAMESPACE_PATTERN = '/<prototype.*\snamespace="(?:(?<namespace>(?:[^ \\\\]+(?<separator> \\\\(?: \\\\)?))))"/ ' ;
38
- private const SINGLE_CLASS_PATTERN = '/(?:(?<singleClass>(?:[\p{L}_\d]+ (?<singleSeparator> \\\\(?: \\\\)?))):)|(?<class>(?:[\p{L}_\d]+ (?<separator> \\\\(?: \\\\)?)+)+[\p{L}_\d]+)/u ' ;
38
+ private const SINGLE_CLASS_PATTERN = '/(?:(?<singleClass>(?:[\p{L}_][\p{L}_\d]* (?<singleSeparator> \\\\(?: \\\\)?))):)|(?<class>(?:[\p{L}_][\p{L}_\d]* (?<separator> \\\\(?: \\\\)?)+)+[\p{L}_\d]+)/u ' ;
39
39
40
40
public function __construct (
41
41
private Scoper $ decoratedScoper ,
Original file line number Diff line number Diff line change 34
34
final readonly class YamlScoper implements Scoper
35
35
{
36
36
private const YAML_EXTENSION_REGEX = '/\.ya?ml$/i ' ;
37
- private const CLASS_PATTERN = '/(?:(?<singleClass>(?:[\p{L}_\d]+ (?<singleSeparator> \\\\(?: \\\\)?))):)|(?<class>(?:[\p{L}_\d]+ (?<separator> \\\\(?: \\\\)?)+)+[\p{L}_\d]+)/u ' ;
37
+ private const CLASS_PATTERN = '/(?:(?<singleClass>(?:[\p{L}_][\p{L}_\d]* (?<singleSeparator> \\\\(?: \\\\)?))):)|(?<class>(?:[\p{L}_][\p{L}_\d]* (?<separator> \\\\(?: \\\\)?)+)+[\p{L}_\d]+)/u ' ;
38
38
39
39
public function __construct (
40
40
private Scoper $ decoratedScoper ,
Original file line number Diff line number Diff line change @@ -387,6 +387,45 @@ public static function provideXmlFiles(): iterable
387
387
[],
388
388
];
389
389
390
+ yield 'class-like pattern ' => [
391
+ <<<'XML'
392
+ <!-- config/services.xml -->
393
+ <?xml version="1.0" encoding="UTF-8" ?>
394
+ <container xmlns="http://symfony.com/schema/dic/services"
395
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
396
+ xsi:schemaLocation="http://symfony.com/schema/dic/services
397
+ http://symfony.com/schema/dic/services/services-1.0.xsd">
398
+
399
+ <services>
400
+ <service id="App\Mail\PhpMailer" />
401
+ <service id="1\2" />
402
+
403
+ <service id="s1" class="App\Mail\PhpMailer" alias="App\Mail\PhpMailer" />
404
+ <service id="s2" class="1\2" alias="1\2" />
405
+ </services>
406
+ </container>
407
+ XML,
408
+ SymbolsConfiguration::create (),
409
+ <<<'XML'
410
+ <!-- config/services.xml -->
411
+ <?xml version="1.0" encoding="UTF-8" ?>
412
+ <container xmlns="http://symfony.com/schema/dic/services"
413
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
414
+ xsi:schemaLocation="http://symfony.com/schema/dic/services
415
+ http://symfony.com/schema/dic/services/services-1.0.xsd">
416
+
417
+ <services>
418
+ <service id="Humbug\App\Mail\PhpMailer" />
419
+ <service id="1\2" />
420
+
421
+ <service id="s1" class="Humbug\App\Mail\PhpMailer" alias="Humbug\App\Mail\PhpMailer" />
422
+ <service id="s2" class="1\2" alias="1\2" />
423
+ </services>
424
+ </container>
425
+ XML,
426
+ [],
427
+ ];
428
+
390
429
yield 'service with argument ' => [
391
430
<<<'XML'
392
431
<!-- app/config/services.xml -->
Original file line number Diff line number Diff line change @@ -152,6 +152,11 @@ public static function provideYamlFiles(): iterable
152
152
Symfony\Component\Console\Input\InputInterface:
153
153
alias: 'Symfony\Component\Console\Input\ArgvInput'
154
154
Symfony\Component\Console\Output\OutputInterface: '@Symfony\Component\Console\Output\ConsoleOutput'
155
+ 1\2: ~
156
+ Service2:
157
+ class: 1\2
158
+ Service3:
159
+ alias: 1\2
155
160
YAML,
156
161
SymbolsConfiguration::create (),
157
162
<<<'YAML'
@@ -160,6 +165,11 @@ public static function provideYamlFiles(): iterable
160
165
Humbug\Symfony\Component\Console\Input\InputInterface:
161
166
alias: 'Humbug\Symfony\Component\Console\Input\ArgvInput'
162
167
Humbug\Symfony\Component\Console\Output\OutputInterface: '@Humbug\Symfony\Component\Console\Output\ConsoleOutput'
168
+ 1\2: ~
169
+ Service2:
170
+ class: 1\2
171
+ Service3:
172
+ alias: 1\2
163
173
YAML,
164
174
[],
165
175
];
You can’t perform that action at this time.
0 commit comments