Skip to content

Commit

Permalink
Improve type for predefined constant
Browse files Browse the repository at this point in the history
  • Loading branch information
zonuexe committed May 8, 2024
1 parent 4e5020d commit 6b9adf0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Analyser/ConstantResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHPStan\Reflection\NamespaceAnswerer;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Reflection\ReflectionProvider\ReflectionProviderProvider;
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
use PHPStan\Type\Constant\ConstantFloatType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Constant\ConstantStringType;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
if ($resolvedConstantName === 'PHP_VERSION') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_MAJOR_VERSION') {
Expand Down Expand Up @@ -106,7 +106,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
if ($resolvedConstantName === 'PHP_OS') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_OS_FAMILY') {
Expand All @@ -132,7 +132,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
new ConstantStringType('phpdbg'),
new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]),
]);
}
Expand Down Expand Up @@ -165,61 +165,61 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
if ($resolvedConstantName === 'PHP_EXTENSION_DIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_PREFIX') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_BINDIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_BINARY') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_MANDIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_LIBDIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_DATADIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_SYSCONFDIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_LOCALSTATEDIR') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_CONFIG_FILE_PATH') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
if ($resolvedConstantName === 'PHP_SHLIB_SUFFIX') {
Expand All @@ -232,7 +232,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
return IntegerRangeType::fromInterval(1, null);
}
if ($resolvedConstantName === '__COMPILER_HALT_OFFSET__') {
return IntegerRangeType::fromInterval(0, null);
return IntegerRangeType::fromInterval(1, null);
}
// core other, https://www.php.net/manual/en/info.constants.php
if ($resolvedConstantName === 'PHP_WINDOWS_VERSION_MAJOR') {
Expand Down Expand Up @@ -261,7 +261,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
if ($resolvedConstantName === 'ICONV_IMPL') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
// libxml, https://www.php.net/manual/en/libxml.constants.php
Expand All @@ -271,7 +271,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
if ($resolvedConstantName === 'LIBXML_DOTTED_VERSION') {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
new AccessoryNonFalsyStringType(),
]);
}
// openssl, https://www.php.net/manual/en/openssl.constants.php
Expand Down

0 comments on commit 6b9adf0

Please sign in to comment.