Skip to content

Commit 6fa8c53

Browse files
committed
Read regex shapes with PHPRegex instead of the Hoa grammar
The shapes of preg_match(), preg_match_all() and preg_replace_callback() are read from the AST and the capture shape analysis of PHPRegex, a PCRE2 pattern parser that runs on PHP 7.4. The Hoa packages, their patches, the grammar file and the scoper and autoload workarounds for them are removed, and ignoreErrors patterns are validated with the same parser. Patterns are read for the analysed PHP version and the PCRE2 version it bundles; a pcreVersion parameter, or config.platform.lib-pcre in composer.json, can set that version. With bleeding edge, RegularExpressionPatternRule also reports a pattern the running PHP compiles but the analysed PHP does not. A new test matches every constant pattern of the preg_* fixtures with the engine, on generated subjects and with every flag combination, and checks that the inferred type accepts what the engine writes.
1 parent 74c549b commit 6fa8c53

73 files changed

Lines changed: 2585 additions & 2865 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.

‎bin/phpstan‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ use Symfony\Component\Console\Helper\ProgressBar;
5252
}
5353
$devOrPharLoader->unregister();
5454

55-
// fix missing key for vendor/hoa/protocol/Wrapper.php
56-
$existingComposerAutoloadFiles = $GLOBALS['__composer_autoload_files'] ?? [];
57-
$GLOBALS['__composer_autoload_files'] = array_merge(
58-
$existingComposerAutoloadFiles,
59-
array_fill_keys(['3e76f7f02b41af8cea96018933f6b7e3'], true),
60-
);
61-
6255
$autoloaderInWorkingDirectory = $vendorDirectory . '/autoload.php';
6356
$composerAutoloaderProjectPaths = [];
6457

‎build/phpstan.neon‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ parameters:
3939
- ../tests/PHPStan/Reflection/MixedTypeTest.php
4040
- ../tests/e2e/magic-setter/*
4141
- ../tests/PHPStan/Rules/Properties/UninitializedPropertyRuleTest.php
42-
- ../tests/PHPStan/Command/IgnoredRegexValidatorTest.php
43-
- ../src/Command/IgnoredRegexValidator.php
4442
exceptions:
4543
uncheckedExceptionClasses:
4644
- 'PHPStan\ShouldNotHappenException'

‎compiler/build/scoper-namespaces.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
'PHPStanTurbo',
1414
'PHPUnit',
1515
'PhpParser',
16-
'Hoa',
1716
'Symfony\Polyfill\Php80',
1817
'Symfony\Polyfill\Php81',
1918
'Symfony\Polyfill\Php83',

‎compiler/build/scoper.inc.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
$namespaces = require __DIR__ . '/scoper-namespaces.php';
66

77
$stubs = [
8-
'../../vendor/hoa/consistency/Prelude.php',
98
'../../vendor/composer/InstalledVersions.php',
109
'../../vendor/composer/installed.php',
1110
];
@@ -106,10 +105,6 @@ function (string $filePath, string $prefix, string $content): string {
106105
return $class;
107106
}
108107

109-
if (strpos($class, 'Hoa\\') === 0) {
110-
return $class;
111-
}
112-
113108
if (strpos($class, '@') === 0) {
114109
return $class;
115110
}

‎composer.json‎

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
"composer/semver": "^3.4",
2323
"fidry/cpu-core-counter": "^1.4",
2424
"guzzlehttp/guzzle": "^7.9",
25-
"hoa/compiler": "3.17.08.08",
26-
"hoa/exception": "^1.0",
27-
"hoa/file": "1.17.07.11",
2825
"jetbrains/phpstorm-stubs": "dev-master#e4f5f6c3de39f3bab3e9f3fca4b8cdb8b061e681",
2926
"nette/bootstrap": "^3.0",
3027
"nette/di": "^3.1.10",
@@ -37,6 +34,7 @@
3734
"ondrejmirtes/better-reflection": "6.75.0.2",
3835
"ondrejmirtes/composer-attribute-collector": "^1.2.0",
3936
"ondrejmirtes/php-merge": "^4.1",
37+
"php-regex/regex-parser-php74": "2.x-dev#0574849c08256c582d7cf0571dfcafd3c8d2ae55",
4038
"phpstan/php-8-stubs": "0.4.43",
4139
"phpstan/phpdoc-parser": "2.3.6",
4240
"react/child-process": "^0.7",
@@ -102,36 +100,6 @@
102100
"composer/ca-bundle": [
103101
"patches/cloudflare-ca.patch"
104102
],
105-
"hoa/exception": [
106-
"patches/Idle.patch"
107-
],
108-
"hoa/file": [
109-
"patches/File.patch",
110-
"patches/Read.patch"
111-
],
112-
"hoa/iterator": [
113-
"patches/Buffer.patch",
114-
"patches/Lookahead.patch"
115-
],
116-
"hoa/compiler": [
117-
"patches/HoaException.patch",
118-
"patches/HoaParser.patch",
119-
"patches/Invocation.patch",
120-
"patches/Rule.patch",
121-
"patches/Lexer.patch",
122-
"patches/TreeNode.patch"
123-
],
124-
"hoa/consistency": [
125-
"patches/Consistency.patch",
126-
"patches/Prelude.patch"
127-
],
128-
"hoa/protocol": [
129-
"patches/Node.patch",
130-
"patches/Wrapper.patch"
131-
],
132-
"hoa/stream": [
133-
"patches/Stream.patch"
134-
],
135103
"jetbrains/phpstorm-stubs": [
136104
"patches/ReflectionProperty.patch",
137105
"patches/SessionHandler.patch",
@@ -174,5 +142,10 @@
174142
"prefer-stable": true,
175143
"bin": [
176144
"bin/phpstan"
177-
]
145+
],
146+
"repositories": [{
147+
"name": "phpregex",
148+
"type": "vcs",
149+
"url": "https://github.com/php-regex/regex-parser-php74"
150+
}]
178151
}

0 commit comments

Comments
 (0)