Skip to content

Commit 66d7701

Browse files
curry684ondrejmirtes
authored andcommitted
Add PCRE_VERSION predefined constant
Refs phpstan/phpstan#11202
1 parent f513931 commit 66d7701

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Analyser/ConstantResolver.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
278278
if ($resolvedConstantName === 'OPENSSL_VERSION_NUMBER') {
279279
return IntegerRangeType::fromInterval(1, null);
280280
}
281+
282+
// pcre, https://www.php.net/manual/en/pcre.constants.php
283+
if ($resolvedConstantName === 'PCRE_VERSION') {
284+
return new IntersectionType([
285+
new StringType(),
286+
new AccessoryNonFalsyStringType(),
287+
]);
288+
}
289+
281290
if (in_array($resolvedConstantName, ['STDIN', 'STDOUT', 'STDERR'], true)) {
282291
return new ResourceType();
283292
}

tests/PHPStan/Analyser/nsrt/predefined-constants.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
// openssl, https://www.php.net/manual/en/openssl.constants.php
7272
assertType('int<1, max>', OPENSSL_VERSION_NUMBER);
7373

74+
// pcre, https://www.php.net/manual/en/pcre.constants.php
75+
assertType('non-falsy-string', PCRE_VERSION);
76+
7477
// other
7578
assertType('bool', ZEND_DEBUG_BUILD);
7679
assertType('bool', ZEND_THREAD_SAFE);

0 commit comments

Comments
 (0)