From 5758d3116117423f540c15c721d8213edc22e47b Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Wed, 5 Jan 2022 01:00:05 +0200 Subject: [PATCH 1/3] Apply literal number separator rector I opted for customary 3-digit groups, except version id, where 2-digit groups are used to match the version id encoding. --- examples/TemplateScanner.php | 2 +- src/Psalm/Codebase.php | 4 +-- src/Psalm/Config.php | 10 +++---- src/Psalm/Internal/Algebra.php | 12 ++++----- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 2 +- .../FunctionLike/ReturnTypeAnalyzer.php | 2 +- .../Analyzer/FunctionLikeAnalyzer.php | 2 +- .../Internal/Analyzer/MethodComparator.php | 10 +++---- .../Internal/Analyzer/ProjectAnalyzer.php | 2 +- .../Block/IfElse/ElseIfAnalyzer.php | 2 +- .../Statements/Expression/ArrayAnalyzer.php | 4 +-- .../Expression/Call/ArgumentAnalyzer.php | 10 ++++--- .../Statements/Expression/CallAnalyzer.php | 4 +-- .../Statements/Expression/CastAnalyzer.php | 2 +- .../Statements/ExpressionAnalyzer.php | 6 ++--- src/Psalm/Internal/Cli/LanguageServer.php | 2 +- src/Psalm/Internal/Cli/Psalm.php | 2 +- src/Psalm/Internal/Cli/Psalter.php | 4 +-- src/Psalm/Internal/CliUtils.php | 6 ++--- src/Psalm/Internal/Fork/Pool.php | 4 +-- .../Reflector/FunctionLikeNodeScanner.php | 2 +- .../Internal/PhpVisitor/ReflectorVisitor.php | 4 +-- .../Internal/Provider/StatementsProvider.php | 6 ++--- .../Stubs/Generator/StubsGenerator.php | 2 +- .../Type/Comparator/AtomicTypeComparator.php | 2 +- src/Psalm/IssueBuffer.php | 4 +-- src/Psalm/PluginRegistrationSocket.php | 8 +++--- src/Psalm/Progress/DefaultProgress.php | 2 +- src/Psalm/Type/Atomic.php | 14 +++++----- .../Type/Atomic/TAnonymousClassInstance.php | 2 +- src/Psalm/Type/Atomic/TBool.php | 2 +- src/Psalm/Type/Atomic/TCallableObject.php | 2 +- src/Psalm/Type/Atomic/TFloat.php | 2 +- src/Psalm/Type/Atomic/TGenericObject.php | 2 +- src/Psalm/Type/Atomic/TInt.php | 2 +- src/Psalm/Type/Atomic/TIterable.php | 2 +- src/Psalm/Type/Atomic/TMixed.php | 4 +-- src/Psalm/Type/Atomic/TNamedObject.php | 8 +++--- src/Psalm/Type/Atomic/TObject.php | 2 +- src/Psalm/Type/Atomic/TString.php | 2 +- src/Psalm/Type/Atomic/TVoid.php | 2 +- src/Psalm/Type/Union.php | 10 +++---- tests/AlgebraTest.php | 4 +-- .../GetMemoryLimitInBytesTest.php | 26 +++++++++---------- tests/Config/ConfigTest.php | 8 +++--- tests/EndToEnd/PsalmEndToEndTest.php | 2 +- tests/FileDiffTest.php | 12 ++++----- 47 files changed, 116 insertions(+), 114 deletions(-) diff --git a/examples/TemplateScanner.php b/examples/TemplateScanner.php index 4775758e325..2ed2caae02f 100644 --- a/examples/TemplateScanner.php +++ b/examples/TemplateScanner.php @@ -25,7 +25,7 @@ public function scan( ): void { $stmts = $codebase->statements_provider->getStatementsForFile( $file_storage->file_path, - 70400, + 7_04_00, $progress ); diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php index de0878130e0..7ac7bba4925 100644 --- a/src/Psalm/Codebase.php +++ b/src/Psalm/Codebase.php @@ -1999,12 +1999,12 @@ public function addTaintSink( public function getMinorAnalysisPhpVersion(): int { - return self::transformPhpVersionId($this->analysis_php_version_id % 10000, 100); + return self::transformPhpVersionId($this->analysis_php_version_id % 10_000, 100); } public function getMajorAnalysisPhpVersion(): int { - return self::transformPhpVersionId($this->analysis_php_version_id, 10000); + return self::transformPhpVersionId($this->analysis_php_version_id, 10_000); } public static function transformPhpVersionId(int $php_version_id, int $div): int diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index a24c9c952e6..4e2978649cd 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -522,7 +522,7 @@ class Config /** * @var int */ - public $max_string_length = 1000; + public $max_string_length = 1_000; /** @var ?IncludeCollector */ private $include_collector; @@ -1865,7 +1865,7 @@ public function visitPreloadedStubFiles(Codebase $codebase, ?Progress $progress $core_generic_files = []; - if (PHP_VERSION_ID < 80000 && $codebase->analysis_php_version_id >= 80000) { + if (PHP_VERSION_ID < 8_00_00 && $codebase->analysis_php_version_id >= 8_00_00) { $stringable_path = dirname(__DIR__, 2) . '/stubs/Php80.phpstub'; if (!file_exists($stringable_path)) { @@ -1875,7 +1875,7 @@ public function visitPreloadedStubFiles(Codebase $codebase, ?Progress $progress $core_generic_files[] = $stringable_path; } - if (PHP_VERSION_ID < 80100 && $codebase->analysis_php_version_id >= 80100) { + if (PHP_VERSION_ID < 8_01_00 && $codebase->analysis_php_version_id >= 8_01_00) { $stringable_path = dirname(__DIR__, 2) . '/stubs/Php81.phpstub'; if (!file_exists($stringable_path)) { @@ -1926,12 +1926,12 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null): $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'SPL.phpstub', ]; - if (PHP_VERSION_ID >= 80000 && $codebase->analysis_php_version_id >= 80000) { + if (PHP_VERSION_ID >= 8_00_00 && $codebase->analysis_php_version_id >= 8_00_00) { $stringable_path = $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'Php80.phpstub'; $this->internal_stubs[] = $stringable_path; } - if (PHP_VERSION_ID >= 80100 && $codebase->analysis_php_version_id >= 80100) { + if (PHP_VERSION_ID >= 8_01_00 && $codebase->analysis_php_version_id >= 8_01_00) { $stringable_path = $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'Php81.phpstub'; $this->internal_stubs[] = $stringable_path; } diff --git a/src/Psalm/Internal/Algebra.php b/src/Psalm/Internal/Algebra.php index 8f6b08c4dee..a622de7d437 100644 --- a/src/Psalm/Internal/Algebra.php +++ b/src/Psalm/Internal/Algebra.php @@ -99,7 +99,7 @@ public static function simplifyCNF(array $clauses): array //65536 seems to be a significant threshold, when put at 65537, the code https://psalm.dev/r/216f362ea6 goes //from seconds in analysis to many minutes - if ($clause_count > 65536) { + if ($clause_count > 65_536) { return []; } @@ -443,7 +443,7 @@ public static function groupImpossibilities(array $clauses): array ++$complexity; - if ($complexity > 20000) { + if ($complexity > 20_000) { throw new ComplicatedExpressionException(); } } @@ -469,7 +469,7 @@ public static function combineOredClauses( array $right_clauses, int $conditional_object_id ): array { - if (count($left_clauses) > 60000 || count($right_clauses) > 60000) { + if (count($left_clauses) > 60_000 || count($right_clauses) > 60_000) { return []; } @@ -601,7 +601,7 @@ function ($clause) { ); if (!$clauses) { - $cond_id = mt_rand(0, 100000000); + $cond_id = mt_rand(0, 100_000_000); return [new Clause([], $cond_id, $cond_id, true)]; } @@ -616,14 +616,14 @@ function ($clause) { $impossible_clauses = self::groupImpossibilities($clauses_with_impossibilities); if (!$impossible_clauses) { - $cond_id = mt_rand(0, 100000000); + $cond_id = mt_rand(0, 100_000_000); return [new Clause([], $cond_id, $cond_id, true)]; } $negated = self::simplifyCNF($impossible_clauses); if (!$negated) { - $cond_id = mt_rand(0, 100000000); + $cond_id = mt_rand(0, 100_000_000); return [new Clause([], $cond_id, $cond_id, true)]; } diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 97ec0ed11f5..0726a3ea3e9 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -1608,7 +1608,7 @@ private static function addOrUpdatePropertyType( $codebase = $project_analyzer->getCodebase(); $allow_native_type = !$docblock_only - && $codebase->analysis_php_version_id >= 70400 + && $codebase->analysis_php_version_id >= 7_04_00 && $codebase->allow_backwards_incompatible_changes; $manipulator->setType( diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php index a7fd0690f15..1512bf9d64f 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php @@ -940,7 +940,7 @@ private static function addOrUpdateReturnType( } $allow_native_type = !$docblock_only - && $codebase->analysis_php_version_id >= 70000 + && $codebase->analysis_php_version_id >= 7_00_00 && ( $codebase->allow_backwards_incompatible_changes || $is_final diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 864c3c81087..afce62eaac8 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -1442,7 +1442,7 @@ public function addOrUpdateParamType( } $allow_native_type = !$docblock_only - && $codebase->analysis_php_version_id >= 70000 + && $codebase->analysis_php_version_id >= 7_00_00 && ( $codebase->allow_backwards_incompatible_changes || $is_final diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php index beb533876d7..0de16d9ef99 100644 --- a/src/Psalm/Internal/Analyzer/MethodComparator.php +++ b/src/Psalm/Internal/Analyzer/MethodComparator.php @@ -95,7 +95,7 @@ public static function compare( $cased_implementer_method_id, $prevent_method_signature_mismatch, $prevent_abstract_override, - $codebase->analysis_php_version_id >= 80000, + $codebase->analysis_php_version_id >= 8_00_00, $code_location, $suppressed_issues ); @@ -562,7 +562,7 @@ private static function compareMethodSignatureParams( $implementer_classlike_storage->parent_class ); - $is_contained_by = $codebase->analysis_php_version_id >= 70400 + $is_contained_by = $codebase->analysis_php_version_id >= 7_04_00 && $guide_param_signature_type ? UnionTypeComparator::isContainedBy( $codebase, @@ -576,7 +576,7 @@ private static function compareMethodSignatureParams( if (!$is_contained_by) { $config = Config::getInstance(); - if ($codebase->analysis_php_version_id >= 80000 + if ($codebase->analysis_php_version_id >= 8_00_00 || $guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait || !in_array($guide_classlike_storage->name, $implementer_classlike_storage->used_traits) || $implementer_method_storage->defining_fqcln !== $implementer_classlike_storage->name @@ -854,7 +854,7 @@ private static function compareMethodSignatureReturnTypes( $implementer_classlike_storage->parent_class ) : null; - $is_contained_by = $codebase->analysis_php_version_id >= 70400 + $is_contained_by = $codebase->analysis_php_version_id >= 7_04_00 && $implementer_signature_return_type ? UnionTypeComparator::isContainedBy( $codebase, @@ -864,7 +864,7 @@ private static function compareMethodSignatureReturnTypes( : UnionTypeComparator::isContainedByInPhp($implementer_signature_return_type, $guide_signature_return_type); if (!$is_contained_by) { - if ($codebase->analysis_php_version_id >= 80000 + if ($codebase->analysis_php_version_id >= 8_00_00 || $guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait || !in_array($guide_classlike_storage->name, $implementer_classlike_storage->used_traits) || $implementer_method_storage->defining_fqcln !== $implementer_classlike_storage->name diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index abe4d6e562b..fe3b80318df 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -1297,7 +1297,7 @@ public function setPhpVersion(string $version, string $source): void $php_major_version = (int) $php_major_version; $php_minor_version = (int) $php_minor_version; - $analysis_php_version_id = $php_major_version * 10000 + $php_minor_version * 100; + $analysis_php_version_id = $php_major_version * 10_000 + $php_minor_version * 100; if ($this->codebase->analysis_php_version_id !== $analysis_php_version_id) { // reset lexer and parser when php version changes diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php index 26f0c3f2670..0f95381a6b7 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php @@ -341,7 +341,7 @@ function (array $carry, Clause $clause): array { $reasonable_clause_count = count($if_scope->reasonable_clauses); - if ($reasonable_clause_count && $reasonable_clause_count < 20000 && $elseif_clauses) { + if ($reasonable_clause_count && $reasonable_clause_count < 20_000 && $elseif_clauses) { $if_scope->reasonable_clauses = Algebra::combineOredClauses( $if_scope->reasonable_clauses, $elseif_clauses, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php index 98dc159f6fe..a3f7b191afc 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php @@ -510,7 +510,7 @@ private static function handleUnpackedArray( if ($unpacked_atomic_type instanceof TKeyedArray) { foreach ($unpacked_atomic_type->properties as $key => $property_value) { if (is_string($key)) { - if ($codebase->analysis_php_version_id <= 80000) { + if ($codebase->analysis_php_version_id <= 8_00_00) { IssueBuffer::maybeAdd( new DuplicateArrayKey( 'String keys are not supported in unpacked arrays', @@ -553,7 +553,7 @@ private static function handleUnpackedArray( $array_creation_info->can_create_objectlike = false; if ($unpacked_atomic_type->type_params[0]->hasString()) { - if ($codebase->analysis_php_version_id <= 80000) { + if ($codebase->analysis_php_version_id <= 8_00_00) { IssueBuffer::maybeAdd( new DuplicateArrayKey( 'String keys are not supported in unpacked arrays', diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index 40e510735c7..bc82d57d329 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -486,7 +486,7 @@ private static function checkFunctionLikeTypeMatches( if ($function_param->is_variadic) { $arg_type = $unpacked_atomic_array->getGenericValueType(); - } elseif ($codebase->analysis_php_version_id >= 80000 + } elseif ($codebase->analysis_php_version_id >= 8_00_00 && $allow_named_args && isset($unpacked_atomic_array->properties[$function_param->name]) ) { @@ -552,7 +552,9 @@ private static function checkFunctionLikeTypeMatches( continue; } - if (($codebase->analysis_php_version_id < 80000 || !$allow_named_args) && !$key_type->isInt()) { + if (($codebase->analysis_php_version_id < 8_00_00 || !$allow_named_args) + && !$key_type->isInt() + ) { $invalid_string_key = true; continue; @@ -578,7 +580,7 @@ private static function checkFunctionLikeTypeMatches( 'Method ' . $cased_method_id . ' called with unpacked iterable ' . $arg_type->getId() . ' with invalid key (must be ' - . ($codebase->analysis_php_version_id < 80000 ? 'int' : 'int|string') . ')', + . ($codebase->analysis_php_version_id < 8_00_00 ? 'int' : 'int|string') . ')', new CodeLocation($statements_analyzer->getSource(), $arg->value), $cased_method_id ), @@ -586,7 +588,7 @@ private static function checkFunctionLikeTypeMatches( ); } if ($invalid_string_key) { - if ($codebase->analysis_php_version_id < 80000) { + if ($codebase->analysis_php_version_id < 8_00_00) { IssueBuffer::maybeAdd( new $issue_type( 'String keys not supported in unpacked arguments', diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index b40ec32f97d..851172f3aca 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -831,8 +831,8 @@ public static function applyAssertionsToContext( ); $assert_clauses = FormulaGenerator::getFormula( - mt_rand(0, 1000000), - mt_rand(0, 1000000), + mt_rand(0, 1_000_000), + mt_rand(0, 1_000_000), $conditional, $context->self, $statements_analyzer, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php index e8b67fbb49d..3d34b3f44f2 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php @@ -264,7 +264,7 @@ public static function analyze( } if ($stmt instanceof PhpParser\Node\Expr\Cast\Unset_ - && $statements_analyzer->getCodebase()->analysis_php_version_id <= 70400 + && $statements_analyzer->getCodebase()->analysis_php_version_id <= 7_04_00 ) { if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { return false; diff --git a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php index bbb020fab50..552a3ecaedf 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php @@ -473,17 +473,17 @@ private static function handleExpression( $codebase = $statements_analyzer->getCodebase(); $analysis_php_version_id = $codebase->analysis_php_version_id; - if ($stmt instanceof PhpParser\Node\Expr\Match_ && $analysis_php_version_id >= 80000) { + if ($stmt instanceof PhpParser\Node\Expr\Match_ && $analysis_php_version_id >= 8_00_00) { return MatchAnalyzer::analyze($statements_analyzer, $stmt, $context); } - if ($stmt instanceof PhpParser\Node\Expr\Throw_ && $analysis_php_version_id >= 80000) { + if ($stmt instanceof PhpParser\Node\Expr\Throw_ && $analysis_php_version_id >= 8_00_00) { return ThrowAnalyzer::analyze($statements_analyzer, $stmt, $context); } if (($stmt instanceof PhpParser\Node\Expr\NullsafePropertyFetch || $stmt instanceof PhpParser\Node\Expr\NullsafeMethodCall) - && $analysis_php_version_id >= 80000 + && $analysis_php_version_id >= 8_00_00 ) { return NullsafeAnalyzer::analyze($statements_analyzer, $stmt, $context); } diff --git a/src/Psalm/Internal/Cli/LanguageServer.php b/src/Psalm/Internal/Cli/LanguageServer.php index 94a0d2ad549..0d5a5b91dbc 100644 --- a/src/Psalm/Internal/Cli/LanguageServer.php +++ b/src/Psalm/Internal/Cli/LanguageServer.php @@ -121,7 +121,7 @@ function (string $arg) use ($valid_long_options): void { if (!array_key_exists('use-ini-defaults', $options)) { ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); - ini_set('memory_limit', (string) (8 * 1024 * 1024 * 1024)); + ini_set('memory_limit', (string) (8 * 1_024 * 1_024 * 1_024)); } if (array_key_exists('help', $options)) { diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index ee170e5c1b7..44f8abfff14 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -475,7 +475,7 @@ private static function setMemoryLimit(array $options): void ini_set('display_errors', 'stderr'); ini_set('display_startup_errors', '1'); - $memoryLimit = (8 * 1024 * 1024 * 1024); + $memoryLimit = (8 * 1_024 * 1_024 * 1_024); if (array_key_exists('memory-limit', $options)) { $memoryLimit = $options['memory-limit']; diff --git a/src/Psalm/Internal/Cli/Psalter.php b/src/Psalm/Internal/Cli/Psalter.php index d2765a2bd46..4172dd6131f 100644 --- a/src/Psalm/Internal/Cli/Psalter.php +++ b/src/Psalm/Internal/Cli/Psalter.php @@ -424,8 +424,8 @@ private static function setMemoryLimit(): void { $memLimit = CliUtils::getMemoryLimitInBytes(); // Magic number is 4096M in bytes - if ($memLimit > 0 && $memLimit < 8 * 1024 * 1024 * 1024) { - ini_set('memory_limit', (string) (8 * 1024 * 1024 * 1024)); + if ($memLimit > 0 && $memLimit < 8 * 1_024 * 1_024 * 1_024) { + ini_set('memory_limit', (string) (8 * 1_024 * 1_024 * 1_024)); } } diff --git a/src/Psalm/Internal/CliUtils.php b/src/Psalm/Internal/CliUtils.php index 74b8d34b40c..37b7782be66 100644 --- a/src/Psalm/Internal/CliUtils.php +++ b/src/Psalm/Internal/CliUtils.php @@ -456,13 +456,13 @@ public static function convertMemoryLimitToBytes(string $limit): int $limit = (int)$matches[1]; switch (strtoupper($matches[2] ?? '')) { case 'G': - $limit *= 1024 * 1024 * 1024; + $limit *= 1_024 * 1_024 * 1_024; break; case 'M': - $limit *= 1024 * 1024; + $limit *= 1_024 * 1_024; break; case 'K': - $limit *= 1024; + $limit *= 1_024; break; } } diff --git a/src/Psalm/Internal/Fork/Pool.php b/src/Psalm/Internal/Fork/Pool.php index 25113319f52..e97604a68b5 100644 --- a/src/Psalm/Internal/Fork/Pool.php +++ b/src/Psalm/Internal/Fork/Pool.php @@ -266,7 +266,7 @@ public function __construct( if ($bytes_written < $bytes_to_write) { // wait a bit - usleep(500000); + usleep(500_000); } } @@ -368,7 +368,7 @@ private function readResultsFromChildren(): array // For each stream that was ready, read the content. foreach ($needs_read as $file) { - $buffer = fread($file, 1024); + $buffer = fread($file, 1_024); if ($buffer !== false) { $content[(int)$file] .= $buffer; } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index 9d4c218cbda..5abb9b7cc98 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -1077,7 +1077,7 @@ private function createStorageForFunctionLike( if ($method_name_lc === strtolower($class_name) && !isset($classlike_storage->methods['__construct']) && strpos($fq_classlike_name, '\\') === false - && $this->codebase->analysis_php_version_id <= 70400 + && $this->codebase->analysis_php_version_id <= 7_04_00 ) { $this->codebase->methods->setDeclaringMethodId( $fq_classlike_name, diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index 1dccc6dc6f5..85fa7351967 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -237,7 +237,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->functionlike_node_scanners[] = $functionlike_node_scanner; if ($classlike_storage - && $this->codebase->analysis_php_version_id >= 80000 + && $this->codebase->analysis_php_version_id >= 8_00_00 && $node instanceof PhpParser\Node\Stmt\ClassMethod && strtolower($node->name->name) === '__tostring' ) { @@ -247,7 +247,7 @@ public function enterNode(PhpParser\Node $node): ?int $classlike_storage->class_implements['stringable'] = 'Stringable'; } - if (PHP_VERSION_ID >= 80000) { + if (PHP_VERSION_ID >= 8_00_00) { $this->codebase->scanner->queueClassLikeForScanning('Stringable'); } } diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index 92ab2887653..b157026799c 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -180,7 +180,7 @@ public function getStatementsForFile( if ($existing_statements && $existing_file_contents - && abs(strlen($existing_file_contents) - strlen($file_contents)) < 5000 + && abs(strlen($existing_file_contents) - strlen($file_contents)) < 5_000 ) { $file_changes = FileDiffer::getDiff($existing_file_contents, $file_contents); @@ -433,8 +433,8 @@ public static function parseStatements( ]; if (!self::$lexer) { - $major_version = Codebase::transformPhpVersionId($analysis_php_version_id, 10000); - $minor_version = Codebase::transformPhpVersionId($analysis_php_version_id % 10000, 100); + $major_version = Codebase::transformPhpVersionId($analysis_php_version_id, 10_000); + $minor_version = Codebase::transformPhpVersionId($analysis_php_version_id % 10_000, 100); self::$lexer = new PhpParser\Lexer\Emulative([ 'usedAttributes' => $attributes, 'phpVersion' => $major_version . '.' . $minor_version, diff --git a/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php b/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php index c9888361380..9504c12ff74 100644 --- a/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php +++ b/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php @@ -386,7 +386,7 @@ public static function getParserTypeFromPsalmType(Union $type): ?PhpParser\NodeA || $atomic_type instanceof TArray || $atomic_type instanceof TIterable ) { - $identifier_string = $atomic_type->toPhpString(null, [], null, 80000); + $identifier_string = $atomic_type->toPhpString(null, [], null, 8_00_00); if ($identifier_string === null) { throw new UnexpectedValueException( diff --git a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php index ed209cacdf5..881d34c2dc7 100644 --- a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php @@ -508,7 +508,7 @@ public static function isContainedBy( if ($input_type_part instanceof TNamedObject) { // check whether the object has a __toString method if ($codebase->classOrInterfaceExists($input_type_part->value)) { - if ($codebase->analysis_php_version_id >= 80000 + if ($codebase->analysis_php_version_id >= 8_00_00 && ($input_type_part->value === 'Stringable' || ($codebase->classlikes->classExists($input_type_part->value) && $codebase->classlikes->classImplements($input_type_part->value, 'Stringable')) diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index 45632b51023..49defb85280 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -726,7 +726,7 @@ function (IssueData $d1, IssueData $d2): int { if ($start_time) { echo 'Checks took ' . number_format(microtime(true) - $start_time, 2) . ' seconds'; - echo ' and used ' . number_format(memory_get_peak_usage() / (1024 * 1024), 3) . 'MB of memory' . "\n"; + echo ' and used ' . number_format(memory_get_peak_usage() / (1_024 * 1_024), 3) . 'MB of memory' . "\n"; $analysis_summary = $codebase->analyzer->getTypeInferenceSummary($codebase); echo $analysis_summary . "\n"; @@ -753,7 +753,7 @@ function (IssueData $d1, IssueData $d2): int { break; } - echo $function_id . ': ' . round(1000 * $time, 2) . 'ms per node' . "\n"; + echo $function_id . ': ' . round(1_000 * $time, 2) . 'ms per node' . "\n"; } echo "\n"; diff --git a/src/Psalm/PluginRegistrationSocket.php b/src/Psalm/PluginRegistrationSocket.php index f9f85268cfc..6a24935ee93 100644 --- a/src/Psalm/PluginRegistrationSocket.php +++ b/src/Psalm/PluginRegistrationSocket.php @@ -123,7 +123,7 @@ public function addFileTypeScanner(string $fileExtension, string $className): vo $className, FileScanner::class ), - 1622727271 + 1_622_727_271 ); } if (!empty($this->config->getFiletypeScanners()[$fileExtension]) @@ -131,7 +131,7 @@ public function addFileTypeScanner(string $fileExtension, string $className): vo ) { throw new LogicException( sprintf('Cannot redeclare scanner for file-type %s', $fileExtension), - 1622727272 + 1_622_727_272 ); } $this->additionalFileTypeScanners[$fileExtension] = $className; @@ -159,7 +159,7 @@ public function addFileTypeAnalyzer(string $fileExtension, string $className): v $className, FileAnalyzer::class ), - 1622727281 + 1_622_727_281 ); } if (!empty($this->config->getFiletypeAnalyzers()[$fileExtension]) @@ -167,7 +167,7 @@ public function addFileTypeAnalyzer(string $fileExtension, string $className): v ) { throw new LogicException( sprintf('Cannot redeclare analyzer for file-type %s', $fileExtension), - 1622727282 + 1_622_727_282 ); } $this->additionalFileTypeAnalyzers[$fileExtension] = $className; diff --git a/src/Psalm/Progress/DefaultProgress.php b/src/Psalm/Progress/DefaultProgress.php index 76f91e98297..2bacfb0758f 100644 --- a/src/Psalm/Progress/DefaultProgress.php +++ b/src/Psalm/Progress/DefaultProgress.php @@ -9,7 +9,7 @@ class DefaultProgress extends LongProgress { - private const TOO_MANY_FILES = 1500; + private const TOO_MANY_FILES = 1_500; // Update the progress bar at most once per 0.1 seconds. // This reduces flickering and reduces the amount of time spent writing to STDERR and updating the terminal. diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index e548df58219..1655de15f12 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -135,7 +135,7 @@ public static function create( return new TBool(); case 'void': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 70100) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 7_01_00) { return new TVoid(); } @@ -145,14 +145,14 @@ public static function create( return new TArrayKey(); case 'iterable': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 70100) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 7_01_00) { return new TIterable(); } break; case 'never': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 80100) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 8_01_00) { return new TNever(); } @@ -164,7 +164,7 @@ public static function create( return new TNever(); case 'object': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 70200) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 7_02_00) { return new TObject(); } @@ -223,7 +223,7 @@ public static function create( return $analysis_php_version_id !== null ? new TNamedObject($value) : new TTrue(); case 'false': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 80000) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 8_00_00) { return new TFalse(); } @@ -236,14 +236,14 @@ public static function create( return $analysis_php_version_id !== null ? new TNamedObject($value) : new TScalar(); case 'null': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 80000) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 8_00_00) { return new TNull(); } return new TNamedObject($value); case 'mixed': - if ($analysis_php_version_id === null || $analysis_php_version_id >= 80000) { + if ($analysis_php_version_id === null || $analysis_php_version_id >= 8_00_00) { return new TMixed(); } diff --git a/src/Psalm/Type/Atomic/TAnonymousClassInstance.php b/src/Psalm/Type/Atomic/TAnonymousClassInstance.php index 57cda6dc01d..83189316e4e 100644 --- a/src/Psalm/Type/Atomic/TAnonymousClassInstance.php +++ b/src/Psalm/Type/Atomic/TAnonymousClassInstance.php @@ -28,7 +28,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70200 ? ($this->extends ?? 'object') : null; + return $analysis_php_version_id >= 7_02_00 ? ($this->extends ?? 'object') : null; } /** diff --git a/src/Psalm/Type/Atomic/TBool.php b/src/Psalm/Type/Atomic/TBool.php index bdd48fb463d..936085be193 100644 --- a/src/Psalm/Type/Atomic/TBool.php +++ b/src/Psalm/Type/Atomic/TBool.php @@ -26,6 +26,6 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70000 ? 'bool' : null; + return $analysis_php_version_id >= 7_00_00 ? 'bool' : null; } } diff --git a/src/Psalm/Type/Atomic/TCallableObject.php b/src/Psalm/Type/Atomic/TCallableObject.php index c210976beec..a10ea30526e 100644 --- a/src/Psalm/Type/Atomic/TCallableObject.php +++ b/src/Psalm/Type/Atomic/TCallableObject.php @@ -26,7 +26,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 72000 ? 'object' : null; + return $analysis_php_version_id >= 7_20_00 ? 'object' : null; } public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool diff --git a/src/Psalm/Type/Atomic/TFloat.php b/src/Psalm/Type/Atomic/TFloat.php index d5ac7ea901b..0acdbff07d0 100644 --- a/src/Psalm/Type/Atomic/TFloat.php +++ b/src/Psalm/Type/Atomic/TFloat.php @@ -26,6 +26,6 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70000 ? 'float' : null; + return $analysis_php_version_id >= 7_00_00 ? 'float' : null; } } diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php index 79bff4589a0..8b05040a4b9 100644 --- a/src/Psalm/Type/Atomic/TGenericObject.php +++ b/src/Psalm/Type/Atomic/TGenericObject.php @@ -73,7 +73,7 @@ public function toPhpString( ): ?string { $result = $this->toNamespacedString($namespace, $aliased_classes, $this_class, true); $intersection = strrpos($result, '&'); - if ($intersection === false || $analysis_php_version_id >= 80100) { + if ($intersection === false || $analysis_php_version_id >= 8_01_00) { return $result; } return substr($result, $intersection+1); diff --git a/src/Psalm/Type/Atomic/TInt.php b/src/Psalm/Type/Atomic/TInt.php index c40c6d23244..5cdccd63a38 100644 --- a/src/Psalm/Type/Atomic/TInt.php +++ b/src/Psalm/Type/Atomic/TInt.php @@ -26,6 +26,6 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70000 ? 'int' : null; + return $analysis_php_version_id >= 7_00_00 ? 'int' : null; } } diff --git a/src/Psalm/Type/Atomic/TIterable.php b/src/Psalm/Type/Atomic/TIterable.php index 010dcd2aac7..c0c1970a614 100644 --- a/src/Psalm/Type/Atomic/TIterable.php +++ b/src/Psalm/Type/Atomic/TIterable.php @@ -91,7 +91,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70100 ? 'iterable' : null; + return $analysis_php_version_id >= 7_01_00 ? 'iterable' : null; } public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool diff --git a/src/Psalm/Type/Atomic/TMixed.php b/src/Psalm/Type/Atomic/TMixed.php index bbb21545d2f..b31dfe21e72 100644 --- a/src/Psalm/Type/Atomic/TMixed.php +++ b/src/Psalm/Type/Atomic/TMixed.php @@ -36,12 +36,12 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 80000 ? 'mixed' : null; + return $analysis_php_version_id >= 8_00_00 ? 'mixed' : null; } public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool { - return $analysis_php_version_id >= 80000; + return $analysis_php_version_id >= 8_00_00; } public function getAssertionString(bool $exact = false): string diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php index 1e5113fbe29..2ad72a83233 100644 --- a/src/Psalm/Type/Atomic/TNamedObject.php +++ b/src/Psalm/Type/Atomic/TNamedObject.php @@ -121,16 +121,16 @@ public function toPhpString( int $analysis_php_version_id ): ?string { if ($this->value === 'static') { - return $analysis_php_version_id >= 80000 ? 'static' : null; + return $analysis_php_version_id >= 8_00_00 ? 'static' : null; } if ($this->was_static && $this->value === $this_class) { - return $analysis_php_version_id >= 80000 ? 'static' : 'self'; + return $analysis_php_version_id >= 8_00_00 ? 'static' : 'self'; } $result = $this->toNamespacedString($namespace, $aliased_classes, $this_class, false); $intersection = strrpos($result, '&'); - if ($intersection === false || $analysis_php_version_id >= 80100) { + if ($intersection === false || $analysis_php_version_id >= 8_01_00) { return $result; } return substr($result, $intersection+1); @@ -138,7 +138,7 @@ public function toPhpString( public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool { - return ($this->value !== 'static' && $this->was_static === false) || $analysis_php_version_id >= 80000; + return ($this->value !== 'static' && $this->was_static === false) || $analysis_php_version_id >= 8_00_00; } public function replaceTemplateTypesWithArgTypes( diff --git a/src/Psalm/Type/Atomic/TObject.php b/src/Psalm/Type/Atomic/TObject.php index c7cc67fff5b..5b8e81743ed 100644 --- a/src/Psalm/Type/Atomic/TObject.php +++ b/src/Psalm/Type/Atomic/TObject.php @@ -28,7 +28,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70200 ? $this->getKey() : null; + return $analysis_php_version_id >= 7_02_00 ? $this->getKey() : null; } public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool diff --git a/src/Psalm/Type/Atomic/TString.php b/src/Psalm/Type/Atomic/TString.php index 986d585b85a..88ddebd0a6f 100644 --- a/src/Psalm/Type/Atomic/TString.php +++ b/src/Psalm/Type/Atomic/TString.php @@ -16,7 +16,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70000 ? 'string' : null; + return $analysis_php_version_id >= 7_00_00 ? 'string' : null; } public function __toString(): string diff --git a/src/Psalm/Type/Atomic/TVoid.php b/src/Psalm/Type/Atomic/TVoid.php index 4241c5e0818..9c5eb290f9c 100644 --- a/src/Psalm/Type/Atomic/TVoid.php +++ b/src/Psalm/Type/Atomic/TVoid.php @@ -28,7 +28,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 70100 ? $this->getKey() : null; + return $analysis_php_version_id >= 7_01_00 ? $this->getKey() : null; } public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index 843fd742dd7..9d864da44c2 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -516,11 +516,11 @@ public function toPhpString( int $analysis_php_version_id ): ?string { if (!$this->isSingleAndMaybeNullable()) { - if ($analysis_php_version_id < 80000) { + if ($analysis_php_version_id < 8_00_00) { return null; } - } elseif ($analysis_php_version_id < 70000 - || (isset($this->types['null']) && $analysis_php_version_id < 70100) + } elseif ($analysis_php_version_id < 7_00_00 + || (isset($this->types['null']) && $analysis_php_version_id < 7_01_00) ) { return null; } @@ -569,7 +569,7 @@ public function toPhpString( return implode('|', array_unique($php_types)); } - if ($analysis_php_version_id < 80000) { + if ($analysis_php_version_id < 8_00_00) { return ($nullable ? '?' : '') . implode('|', array_unique($php_types)); } if ($nullable) { @@ -580,7 +580,7 @@ public function toPhpString( public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool { - if (!$this->isSingleAndMaybeNullable() && $analysis_php_version_id < 80000) { + if (!$this->isSingleAndMaybeNullable() && $analysis_php_version_id < 8_00_00) { return false; } diff --git a/tests/AlgebraTest.php b/tests/AlgebraTest.php index 406e66816d6..401029f2aa4 100644 --- a/tests/AlgebraTest.php +++ b/tests/AlgebraTest.php @@ -85,7 +85,7 @@ public function testCombinatorialExpansion(): void $has_errors = false; - $dnf_stmt = StatementsProvider::parseStatements($dnf, 70400, $has_errors)[0]; + $dnf_stmt = StatementsProvider::parseStatements($dnf, 7_04_00, $has_errors)[0]; $this->assertInstanceOf(PhpParser\Node\Stmt\Expression::class, $dnf_stmt); @@ -101,7 +101,7 @@ public function testCombinatorialExpansion(): void $statements_analyzer ); - $this->assertCount(6561, $dnf_clauses); + $this->assertCount(6_561, $dnf_clauses); $simplified_dnf_clauses = Algebra::simplifyCNF($dnf_clauses); diff --git a/tests/CommandFunctions/GetMemoryLimitInBytesTest.php b/tests/CommandFunctions/GetMemoryLimitInBytesTest.php index d2dee3f6ec0..b842143df06 100644 --- a/tests/CommandFunctions/GetMemoryLimitInBytesTest.php +++ b/tests/CommandFunctions/GetMemoryLimitInBytesTest.php @@ -18,21 +18,21 @@ public function memoryLimitSettingProvider(): array // byte values [1, 1], [512, 512], - [2048, 2048], + [2_048, 2_048], // uppercase units - ['1K', 1024], - ['24K', 24576], - ['1M', 1048576], - ['24M', 25165824], - ['1G', 1073741824], - ['24G', 25769803776], + ['1K', 1_024], + ['24K', 24_576], + ['1M', 1_048_576], + ['24M', 25_165_824], + ['1G', 1_073_741_824], + ['24G', 25_769_803_776], // lowercase units - ['1k', 1024], - ['24k', 24576], - ['1m', 1048576], - ['24m', 25165824], - ['1g', 1073741824], - ['24g', 25769803776], + ['1k', 1_024], + ['24k', 24_576], + ['1m', 1_048_576], + ['24m', 25_165_824], + ['1g', 1_073_741_824], + ['24g', 25_769_803_776], ]; } diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index ab00b72775b..2ec4fcfac9d 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -1353,10 +1353,10 @@ public function pluginRegistersScannerAndAnalyzerDataProvider(): array { return [ 'regular' => [0, null], // flags, expected exception code - 'invalid scanner class' => [FileTypeSelfRegisteringPlugin::FLAG_SCANNER_INVALID, 1622727271], - 'invalid analyzer class' => [FileTypeSelfRegisteringPlugin::FLAG_ANALYZER_INVALID, 1622727281], - 'override scanner' => [FileTypeSelfRegisteringPlugin::FLAG_SCANNER_TWICE, 1622727272], - 'override analyzer' => [FileTypeSelfRegisteringPlugin::FLAG_ANALYZER_TWICE, 1622727282], + 'invalid scanner class' => [FileTypeSelfRegisteringPlugin::FLAG_SCANNER_INVALID, 1_622_727_271], + 'invalid analyzer class' => [FileTypeSelfRegisteringPlugin::FLAG_ANALYZER_INVALID, 1_622_727_281], + 'override scanner' => [FileTypeSelfRegisteringPlugin::FLAG_SCANNER_TWICE, 1_622_727_272], + 'override analyzer' => [FileTypeSelfRegisteringPlugin::FLAG_ANALYZER_TWICE, 1_622_727_282], ]; } diff --git a/tests/EndToEnd/PsalmEndToEndTest.php b/tests/EndToEnd/PsalmEndToEndTest.php index efc0d396c0b..4388a7a911f 100644 --- a/tests/EndToEnd/PsalmEndToEndTest.php +++ b/tests/EndToEnd/PsalmEndToEndTest.php @@ -152,7 +152,7 @@ public function testPsalmWithPHPVersionFromConfig(): void public function testPsalmDiff(): void { - if (PHP_VERSION_ID < 70400) { + if (PHP_VERSION_ID < 7_04_00) { $this->markTestSkipped('Only works on 7.4+'); } diff --git a/tests/FileDiffTest.php b/tests/FileDiffTest.php index f634abbc530..821e35b687f 100644 --- a/tests/FileDiffTest.php +++ b/tests/FileDiffTest.php @@ -37,8 +37,8 @@ public function testCode( $has_errors = false; - $a_stmts = StatementsProvider::parseStatements($a, 70400, $has_errors); - $b_stmts = StatementsProvider::parseStatements($b, 70400, $has_errors); + $a_stmts = StatementsProvider::parseStatements($a, 7_04_00, $has_errors); + $b_stmts = StatementsProvider::parseStatements($b, 7_04_00, $has_errors); $diff = FileStatementsDiffer::diff($a_stmts, $b_stmts, $a, $b); @@ -101,7 +101,7 @@ public function testPartialAstDiff( $has_errors = false; - $a_stmts = StatementsProvider::parseStatements($a, 70400, $has_errors); + $a_stmts = StatementsProvider::parseStatements($a, 7_04_00, $has_errors); $traverser = new PhpParser\NodeTraverser; $traverser->addVisitor(new CloningVisitor); @@ -111,8 +111,8 @@ public function testPartialAstDiff( $this->assertTreesEqual($a_stmts, $a_stmts_copy); - $b_stmts = StatementsProvider::parseStatements($b, 70400, $has_errors, null, $a, $a_stmts_copy, $file_changes); - $b_clean_stmts = StatementsProvider::parseStatements($b, 70400, $has_errors); + $b_stmts = StatementsProvider::parseStatements($b, 7_04_00, $has_errors, null, $a, $a_stmts_copy, $file_changes); + $b_clean_stmts = StatementsProvider::parseStatements($b, 7_04_00, $has_errors); $this->assertTreesEqual($b_clean_stmts, $b_stmts); @@ -1643,7 +1643,7 @@ public function bar() { [], ['c\a::foo', 'c\a::bar', 'c\a::zap', 'c\a::top', 'c\a::rot', 'c\a::bar'], [], - [[124, 405], [432, 711], [738, 1016], [1043, 1284]], + [[124, 405], [432, 711], [738, 1_016], [1_043, 1_284]], ], 'noUseChange' => [ ' Date: Wed, 5 Jan 2022 01:16:15 +0200 Subject: [PATCH 2/3] Fix version id for the callable object typehint --- src/Psalm/Type/Atomic/TCallableObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Type/Atomic/TCallableObject.php b/src/Psalm/Type/Atomic/TCallableObject.php index a10ea30526e..086fc4140c5 100644 --- a/src/Psalm/Type/Atomic/TCallableObject.php +++ b/src/Psalm/Type/Atomic/TCallableObject.php @@ -26,7 +26,7 @@ public function toPhpString( ?string $this_class, int $analysis_php_version_id ): ?string { - return $analysis_php_version_id >= 7_20_00 ? 'object' : null; + return $analysis_php_version_id >= 7_02_00 ? 'object' : null; } public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool From d30d527aeb3396e61f8b314d2319ef7a4bfa6404 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Wed, 5 Jan 2022 04:11:52 +0200 Subject: [PATCH 3/3] Ensure separator is used for long numbers I would like to set minDigitsBeforeDecimalPoint to 4, but it causes false positives with octal numbers (slevomat/coding-standard#1324). --- phpcs.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpcs.xml b/phpcs.xml index 627943d181d..7bd45e97fdf 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -190,4 +190,11 @@ + + + + + + +