Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6 fixes #10310

Merged
merged 68 commits into from
Oct 22, 2023
Merged

V6 fixes #10310

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
aa04c00
Allow Stringable in sprintf() values
MidnightDesign Sep 26, 2023
87e0bbc
Allow passing `stringable-object`s to sprintf() in all PHP versions
MidnightDesign Sep 28, 2023
c4c8ef5
Delete an invalid test
MidnightDesign Sep 29, 2023
db07b05
Merge pull request #10231 from MidnightDesign/sprintf-stringable-values
orklah Sep 29, 2023
f8c225c
fix: #10239
ging-dev Sep 30, 2023
c312c76
chore: add test
ging-dev Sep 30, 2023
c67dce7
Merge pull request #10240 from ging-dev/cache
orklah Sep 30, 2023
4807086
Fix https://psalm.dev/r/77be914054
kkmuffme Oct 1, 2023
1306b62
code style
kkmuffme Oct 1, 2023
94a98cc
Allow tainted numerics except for 'html' and 'has_quotes'
cgocast Oct 2, 2023
2eca720
Merge branch '5.x' of https://github.com/cgocast/psalm into 5.x
cgocast Oct 2, 2023
6eb40e7
Fix code style
cgocast Oct 2, 2023
e0c24cb
Remove unused parents_nodes
cgocast Oct 2, 2023
3a8f2d2
Merge pull request #10241 from kkmuffme/remove-duplicate-namespace-in…
orklah Oct 2, 2023
b05ffea
Add socket_shutdown stream_socket_shutdown functions to impure list
tuqqu Oct 3, 2023
2baa094
Remove duplicate from impure list
tuqqu Oct 3, 2023
9f9e5f1
Emit MethodSignatureMismatch when descendant does not return by refer…
tuqqu Oct 3, 2023
8d35034
Merge pull request #10244 from tuqqu/socket-shutdown-fix
orklah Oct 3, 2023
69d5881
Merge pull request #10248 from tuqqu/check-return-by-ref-in-descendan…
orklah Oct 3, 2023
413f1d6
Fix error message for returning function with never return type
tuqqu Oct 4, 2023
2a910d1
Changed error message for never return error
tuqqu Oct 4, 2023
2bc3309
Add tests for never return type
tuqqu Oct 4, 2023
a93b358
Allow names in callable docblocks
robchett Oct 7, 2023
c71a252
Add tests for callable docblock parsing
robchett Oct 7, 2023
fc7f846
Fix test case for named variadic callable docblock
robchett Oct 7, 2023
c729fcd
Negated class_exist check on class-string converts to string instead …
robchett Oct 8, 2023
d874aab
Add alias support to psalm-check-type
robchett Oct 8, 2023
b65e095
Merge pull request #10264 from robchett/support_aliases_for_check_type
orklah Oct 8, 2023
67ac81e
Merge pull request #10261 from robchett/allow_named_params_for_callables
orklah Oct 8, 2023
16be90c
Merge pull request #10262 from robchett/negated_class_exist_convert_c…
orklah Oct 8, 2023
a4cebb2
Disallow never type for parameters
tuqqu Oct 8, 2023
cad10a1
Merge pull request #10266 from tuqqu/never-parameter-type
orklah Oct 8, 2023
eea7c33
Merge branch 'vimeo:5.x' into 5.x
cgocast Oct 9, 2023
56926ee
Fix return of BadSqlTainter::afterExpressionAnalysis()
cgocast Oct 9, 2023
a3df650
Type check nested templates
klimick Oct 9, 2023
3f7306d
Merge pull request #10254 from tuqqu/never-function-return-error-message
orklah Oct 9, 2023
ee4e8aa
Merge pull request #10271 from klimick/type-check-nested-templates
orklah Oct 9, 2023
f1fc9c4
Merge pull request #10270 from cgocast/issue10269
orklah Oct 9, 2023
6039e2b
Fix for inferring enum case value from a class constant
tuqqu Oct 10, 2023
d0825b5
Fix for inferring enum case value from a class constant, const test fix
tuqqu Oct 12, 2023
545e21b
fix final class constant type
kk-daniel Oct 13, 2023
7a7d6a2
Merge pull request #10242 from cgocast/5.x
orklah Oct 16, 2023
c9c3067
Merge pull request #10279 from trusting-thompson/final-static-constan…
orklah Oct 16, 2023
b432d81
Merge pull request #10274 from tuqqu/enum-case-value-type-from-class-…
orklah Oct 16, 2023
0162e75
fix: #10080
ging-dev Oct 16, 2023
54a31b6
str_replace / substr_replace signature improvements
mathroc Oct 11, 2023
db82d26
Merge pull request #10228 from ging-dev/fix
orklah Oct 16, 2023
8ee8750
chore: add failing test
ging-dev Oct 17, 2023
18c037e
fix: bug fixes for test cases
ging-dev Oct 17, 2023
e2d1e83
Fix memory explosion with calls to method_exists
robchett Oct 17, 2023
1cdef40
Merge pull request #10290 from robchett/method_exists_exponential_growth
orklah Oct 17, 2023
5a86278
Merge pull request #10289 from ging-dev/add-fix
orklah Oct 17, 2023
d6186ec
Merge pull request #10277 from mathroc/patch-3
orklah Oct 17, 2023
a652db4
Update IssueBuffer.php
aleksandr-shevchenko Oct 19, 2023
576e4d2
Fix method calls and property accesses after extension_loaded
danog Oct 19, 2023
8ca610a
Fix
danog Oct 19, 2023
3ddceb3
Merge pull request #10294 from aleksandr-shevchenko/patch-1
orklah Oct 19, 2023
915d801
Merge pull request #10295 from nicelocal/fix_extension_loaded
orklah Oct 21, 2023
cddf6a9
Rector fixes
danog Oct 21, 2023
3b66272
More rector fixes
danog Oct 21, 2023
596ee11
cs-fix
danog Oct 21, 2023
4c656f0
Revert
danog Oct 21, 2023
c7d7b48
Merge pull request #10306 from nicelocal/rector_5.x
orklah Oct 22, 2023
71483b7
Merge remote-tracking branch 'origin/5.x' into v6_fixes
danog Oct 22, 2023
e8b7b30
Fixes
danog Oct 22, 2023
292ed06
Fix
danog Oct 22, 2023
8fadd1b
cs-fix
danog Oct 22, 2023
e72fb5a
Fix
danog Oct 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@

- [BC] `Psalm\CodeLocation\Raw`, `Psalm\CodeLocation\ParseErrorLocation`, `Psalm\CodeLocation\DocblockTypeLocation`, `Psalm\Report\CountReport`, `Psalm\Type\Atomic\TNonEmptyArray` are now all final.

- [BC] `Psalm\Config` is now final.

- [BC] The return type of `Psalm\Plugin\ArgTypeInferer::infer` changed from `Union|false` to `Union|null`

- [BC] The `extra_types` property and `setIntersectionTypes` method of `Psalm\Type\Atomic\TTypeAlias` were removed.

- [BC] Methods `convertSeverity` and `calculateFingerprint` of `Psalm\Report\CodeClimateReport` were removed.

# Upgrading from Psalm 4 to Psalm 5
## Changed

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"amphp/phpunit-util": "^3",
"bamarni/composer-bin-plugin": "^1.4",
"brianium/paratest": "^6.9",
"dg/bypass-finals": "^1.5",
"mockery/mockery": "^1.5",
"nunomaduro/mock-final-classes": "^1.1",
"php-parallel-lint/php-parallel-lint": "^1.2",
Expand Down
13 changes: 10 additions & 3 deletions dictionaries/CallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12886,10 +12886,16 @@
'str_contains' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
'str_ends_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
'str_getcsv' => ['non-empty-list<?string>', 'string'=>'string', 'separator='=>'string', 'enclosure='=>'string', 'escape='=>'string'],
'str_ireplace' => ['string|string[]', 'search'=>'string|array', 'replace'=>'string|array', 'subject'=>'string|array', '&w_count='=>'int'],
'str_ireplace' => ['string', 'search'=>'string', 'replace'=>'string', 'subject'=>'string', '&w_count='=>'int'],
'str_ireplace\'1' => ['string[]', 'search'=>'string', 'replace'=>'string', 'subject'=>'array', '&w_count='=>'int'],
'str_ireplace\'2' => ['string', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'string', '&w_count='=>'int'],
'str_ireplace\'3' => ['string[]', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'array', '&w_count='=>'int'],
'str_pad' => ['string', 'string'=>'string', 'length'=>'int', 'pad_string='=>'string', 'pad_type='=>'int'],
'str_repeat' => ['string', 'string'=>'string', 'times'=>'int'],
'str_replace' => ['string|string[]', 'search'=>'string|array', 'replace'=>'string|array', 'subject'=>'string|array', '&w_count='=>'int'],
'str_replace' => ['string', 'search'=>'string', 'replace'=>'string', 'subject'=>'string', '&w_count='=>'int'],
'str_replace\'1' => ['string[]', 'search'=>'string', 'replace'=>'string', 'subject'=>'array', '&w_count='=>'int'],
'str_replace\'2' => ['string', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'string', '&w_count='=>'int'],
'str_replace\'3' => ['string[]', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'array', '&w_count='=>'int'],
'str_rot13' => ['string', 'string'=>'string'],
'str_shuffle' => ['string', 'string'=>'string'],
'str_split' => ['list<non-empty-string>', 'string'=>'string', 'length='=>'positive-int'],
Expand Down Expand Up @@ -13015,7 +13021,8 @@
'substr' => ['string', 'string'=>'string', 'offset'=>'int', 'length='=>'?int'],
'substr_compare' => ['int', 'haystack'=>'string', 'needle'=>'string', 'offset'=>'int', 'length='=>'?int', 'case_insensitive='=>'bool'],
'substr_count' => ['int', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'length='=>'?int'],
'substr_replace' => ['string|string[]', 'string'=>'string|string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]|null'],
'substr_replace' => ['string', 'string'=>'string', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]|null'],
'substr_replace\'1' => ['string[]', 'string'=>'string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]|null'],
'suhosin_encrypt_cookie' => ['string|false', 'name'=>'string', 'value'=>'string'],
'suhosin_get_raw_cookies' => ['array'],
'SVM::__construct' => ['void'],
Expand Down
8 changes: 6 additions & 2 deletions dictionaries/CallMap_80_delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -2589,8 +2589,12 @@
'new' => ['string', 'string'=>'string', 'offset'=>'int', 'length='=>'?int'],
],
'substr_replace' => [
'old' => ['string|string[]', 'string'=>'string|string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]'],
'new' => ['string|string[]', 'string'=>'string|string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]|null'],
'old' => ['string', 'string'=>'string', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]'],
'new' => ['string', 'string'=>'string', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]|null'],
],
'substr_replace\'1' => [
'old' => ['string[]', 'string'=>'string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]'],
'new' => ['string[]', 'string'=>'string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]|null'],
],
'tidy_parse_file' => [
'old' => ['tidy', 'filename'=>'string', 'config='=>'array|string', 'encoding='=>'string', 'useIncludePath='=>'bool'],
Expand Down
13 changes: 10 additions & 3 deletions dictionaries/CallMap_historical.php
Original file line number Diff line number Diff line change
Expand Up @@ -14303,10 +14303,16 @@
'stomp_unsubscribe' => ['bool', 'link'=>'resource', 'destination'=>'string', 'headers='=>'?array'],
'stomp_version' => ['string'],
'str_getcsv' => ['non-empty-list<?string>', 'string'=>'string', 'separator='=>'string', 'enclosure='=>'string', 'escape='=>'string'],
'str_ireplace' => ['string|string[]', 'search'=>'string|array', 'replace'=>'string|array', 'subject'=>'string|array', '&w_count='=>'int'],
'str_ireplace' => ['string', 'search'=>'string', 'replace'=>'string', 'subject'=>'string', '&w_count='=>'int'],
'str_ireplace\'1' => ['string[]', 'search'=>'string', 'replace'=>'string', 'subject'=>'array', '&w_count='=>'int'],
'str_ireplace\'2' => ['string', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'string', '&w_count='=>'int'],
'str_ireplace\'3' => ['string[]', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'array', '&w_count='=>'int'],
'str_pad' => ['string', 'string'=>'string', 'length'=>'int', 'pad_string='=>'string', 'pad_type='=>'int'],
'str_repeat' => ['string', 'string'=>'string', 'times'=>'int'],
'str_replace' => ['string|string[]', 'search'=>'string|array', 'replace'=>'string|array', 'subject'=>'string|array', '&w_count='=>'int'],
'str_replace' => ['string', 'search'=>'string', 'replace'=>'string', 'subject'=>'string', '&w_count='=>'int'],
'str_replace\'1' => ['string[]', 'search'=>'string', 'replace'=>'string', 'subject'=>'array', '&w_count='=>'int'],
'str_replace\'2' => ['string', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'string', '&w_count='=>'int'],
'str_replace\'3' => ['string[]', 'search'=>'array', 'replace'=>'string|string[]', 'subject'=>'array', '&w_count='=>'int'],
'str_rot13' => ['string', 'string'=>'string'],
'str_shuffle' => ['string', 'string'=>'string'],
'str_split' => ['non-empty-list<string>', 'string'=>'string', 'length='=>'positive-int'],
Expand Down Expand Up @@ -14430,7 +14436,8 @@
'substr' => ['string|false', 'string'=>'string', 'offset'=>'int', 'length='=>'int'],
'substr_compare' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset'=>'int', 'length='=>'int', 'case_insensitive='=>'bool'],
'substr_count' => ['int', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'length='=>'int'],
'substr_replace' => ['string|string[]', 'string'=>'string|string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]'],
'substr_replace' => ['string', 'string'=>'string', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]'],
'substr_replace\'1' => ['string[]', 'string'=>'string[]', 'replace'=>'string|string[]', 'offset'=>'int|int[]', 'length='=>'int|int[]'],
'suhosin_encrypt_cookie' => ['string|false', 'name'=>'string', 'value'=>'string'],
'suhosin_get_raw_cookies' => ['array'],
'svm::crossvalidate' => ['float', 'problem'=>'array', 'number_of_folds'=>'int'],
Expand Down
3 changes: 2 additions & 1 deletion dictionaries/ImpureFunctionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
'socket_set_block' => true,
'socket_set_nonblock' => true,
'socket_listen' => true,
'stream_socket_shutdown' => true,
'socket_shutdown' => true,
// meta calls
'call_user_func' => true,
'call_user_func_array' => true,
Expand All @@ -93,7 +95,6 @@
'mcrypt_generic_deinit' => true,
'mcrypt_module_close' => true,
// internal optimisation
'opcache_compile_file' => true,
'clearstatcache' => true,
// process-related
'pcntl_signal' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$removed_foreign_functions
);

uksort($new_local, fn($a, $b) => strtolower($a) <=> strtolower($b));
uksort($new_local, static fn($a, $b) => strtolower($a) <=> strtolower($b));

foreach ($new_local as $name => $data) {
if (!is_array($data)) {
Expand Down
1 change: 1 addition & 0 deletions docs/security_analysis/custom_taint_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class BadSqlTainter implements AfterExpressionAnalysisInterface
);
}
}
return null;
}
}
```
2 changes: 1 addition & 1 deletion examples/plugins/ClassUnqualifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function afterClassLikeExistenceCheck(
$new_candidate_type = implode(
'',
array_map(
fn($f) => $f[0],
static fn($f) => $f[0],
$type_tokens,
),
);
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
bootstrap="tests/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
Expand Down
15 changes: 14 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@973a3fa554b4a2016e2a551dce2206fb47084050">
<files psalm-version="dev-master@292ed063233e29d59d0bde61bb6daedee94d55bb">
<file src="examples/TemplateChecker.php">
<PossiblyUndefinedIntArrayOffset>
<code><![CDATA[$comment_block->tags['variablesfrom'][0]]]></code>
Expand All @@ -16,6 +16,9 @@
<PossiblyNullArgument>
<code>$deprecated_element_xml</code>
</PossiblyNullArgument>
<PropertyTypeCoercion>
<code>$this</code>
</PropertyTypeCoercion>
</file>
<file src="src/Psalm/Config/FileFilter.php">
<PossiblyUndefinedIntArrayOffset>
Expand Down Expand Up @@ -622,6 +625,16 @@
<code>hasLowercaseString</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/TestConfig.php">
<InvalidExtendClass>
<code>Config</code>
</InvalidExtendClass>
<MethodSignatureMismatch>
<code>public function __construct()</code>
<code>public function getComposerFilePathForClassLike(string $fq_classlike_name): bool</code>
<code>public function getProjectDirectories(): array</code>
</MethodSignatureMismatch>
</file>
<file src="vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php">
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$subNodes['expr']]]></code>
Expand Down
3 changes: 1 addition & 2 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
use UnexpectedValueException;

use function array_combine;
use function array_merge;
use function array_pop;
use function array_reverse;
use function array_values;
Expand Down Expand Up @@ -1605,7 +1604,7 @@ public function getCompletionItemsForClassishThing(
);
}

$completion_items = array_merge($completion_items, array_values($pseudo_property_types));
$completion_items = [...$completion_items, ...array_values($pseudo_property_types)];

foreach ($class_storage->declaring_property_ids as $property_name => $declaring_class) {
$property_storage = $this->properties->getStorage(
Expand Down
43 changes: 22 additions & 21 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
use function flock;
use function fopen;
use function function_exists;
use function get_class;
use function get_defined_constants;
use function get_defined_functions;
use function getcwd;
Expand Down Expand Up @@ -98,7 +97,9 @@
use function scandir;
use function sha1;
use function simplexml_import_dom;
use function str_contains;
use function str_replace;
use function str_starts_with;
use function strlen;
use function strpos;
use function strrpos;
Expand Down Expand Up @@ -127,13 +128,13 @@
* @psalm-suppress PropertyNotSetInConstructor
* @psalm-consistent-constructor
*/
class Config
final class Config

Check failure on line 131 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Class Psalm\Config became final

Check failure on line 131 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$universal_object_crates was removed

Check failure on line 131 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$project_files was removed

Check failure on line 131 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$extra_files was removed

Check failure on line 131 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$taint_analysis_ignored_files was removed
{
private const DEFAULT_FILE_NAME = 'psalm.xml';
public const CONFIG_NAMESPACE = 'https://getpsalm.org/schema/config';
public const REPORT_INFO = 'info';
public const REPORT_ERROR = 'error';
public const REPORT_SUPPRESS = 'suppress';
final public const CONFIG_NAMESPACE = 'https://getpsalm.org/schema/config';
final public const REPORT_INFO = 'info';
final public const REPORT_ERROR = 'error';
final public const REPORT_SUPPRESS = 'suppress';

/**
* @var array<string>
Expand Down Expand Up @@ -172,7 +173,7 @@
*
* @var array<int, lowercase-string>
*/
protected array $universal_object_crates;
private array $universal_object_crates;

Check failure on line 176 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$universal_object_crates visibility reduced from protected to private

/**
* @var static|null
Expand Down Expand Up @@ -222,7 +223,7 @@

protected ?ProjectFileFilter $project_files = null;

protected ?ProjectFileFilter $extra_files = null;
private ?ProjectFileFilter $extra_files = null;

Check failure on line 226 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$extra_files visibility reduced from protected to private

/**
* The base directory of this config file
Expand Down Expand Up @@ -426,7 +427,7 @@

private ?IncludeCollector $include_collector = null;

protected ?TaintAnalysisFileFilter $taint_analysis_ignored_files = null;
private ?TaintAnalysisFileFilter $taint_analysis_ignored_files = null;

Check failure on line 430 in src/Psalm/Config.php

View workflow job for this annotation

GitHub Actions / Check backward compatibility

Property Psalm\Config#$taint_analysis_ignored_files visibility reduced from protected to private

/**
* @var bool whether to emit a backtrace of emitted issues to stderr
Expand Down Expand Up @@ -874,7 +875,6 @@
/**
* @param non-empty-string $file_contents
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedArgument
* @psalm-suppress MixedPropertyFetch
* @throws ConfigException
*/
Expand Down Expand Up @@ -963,15 +963,15 @@
if (file_exists($composer_json_path)) {
$composer_json_contents = file_get_contents($composer_json_path);
assert($composer_json_contents !== false);
$composer_json = json_decode($composer_json_contents, true);
$composer_json = json_decode($composer_json_contents, true, 512, JSON_THROW_ON_ERROR);
if (!is_array($composer_json)) {
throw new UnexpectedValueException('Invalid composer.json at ' . $composer_json_path);
}
}
$required_extensions = [];
foreach (($composer_json["require"] ?? []) as $required => $_) {
if (strpos($required, "ext-") === 0) {
$required_extensions[strtolower(substr($required, 4))] = true;
if (str_starts_with((string) $required, "ext-")) {
$required_extensions[strtolower(substr((string) $required, 4))] = true;
}
}
foreach ($required_extensions as $required_ext => $_) {
Expand Down Expand Up @@ -1649,7 +1649,7 @@
try {
$file_storage = $codebase->file_storage_provider->get($file_path);
$dependent_files += $file_storage->required_by_file_paths;
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException) {
// do nothing
}
}
Expand Down Expand Up @@ -1700,7 +1700,7 @@

public function getReportingLevelForIssue(CodeIssue $e): string
{
$fqcn_parts = explode('\\', get_class($e));
$fqcn_parts = explode('\\', $e::class);
$issue_type = array_pop($fqcn_parts);

$reporting_level = null;
Expand Down Expand Up @@ -1765,17 +1765,17 @@
return null;
}

if (strpos($issue_type, 'Possibly') === 0) {
if (str_starts_with($issue_type, 'Possibly')) {
$stripped_issue_type = (string) preg_replace('/^Possibly(False|Null)?/', '', $issue_type, 1);

if (strpos($stripped_issue_type, 'Invalid') === false && strpos($stripped_issue_type, 'Un') !== 0) {
if (!str_contains($stripped_issue_type, 'Invalid') && !str_starts_with($stripped_issue_type, 'Un')) {
$stripped_issue_type = 'Invalid' . $stripped_issue_type;
}

return $stripped_issue_type;
}

if (strpos($issue_type, 'Tainted') === 0) {
if (str_starts_with($issue_type, 'Tainted')) {
return 'TaintedInput';
}

Expand Down Expand Up @@ -2298,7 +2298,7 @@
$codebase->classlikes->forgetMissingClassLikes();

$this->include_collector->runAndCollect(
[$this, 'requireAutoloader'],
$this->requireAutoloader(...),
);
}

Expand All @@ -2324,7 +2324,8 @@
}
}

public function getComposerFilePathForClassLike(string $fq_classlike_name): string|false
/** @return string|false */
public function getComposerFilePathForClassLike(string $fq_classlike_name): string|bool
{
if (!$this->composer_class_loader) {
return false;
Expand Down Expand Up @@ -2502,7 +2503,7 @@
$composer_json_contents = file_get_contents($composer_json_path);
assert($composer_json_contents !== false);
$composer_json = json_decode($composer_json_contents, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
} catch (JsonException) {
$composer_json = null;
}

Expand Down
6 changes: 5 additions & 1 deletion src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public static function checkFullyQualifiedClassLikeName(
?string $calling_method_id,
array $suppressed_issues,
?ClassLikeNameOptions $options = null,
bool $check_classes = true,
): ?bool {
if ($options === null) {
$options = new ClassLikeNameOptions();
Expand Down Expand Up @@ -278,6 +279,9 @@ public static function checkFullyQualifiedClassLikeName(
&& !($interface_exists && $options->allow_interface)
&& !($enum_exists && $options->allow_enum)
) {
if (!$check_classes) {
return null;
}
if (!$options->allow_trait || !$codebase->classlikes->traitExists($fq_class_name, $code_location)) {
if ($options->from_docblock) {
if (IssueBuffer::accepts(
Expand Down Expand Up @@ -703,7 +707,7 @@ protected function checkTemplateParams(
&& $storage->template_types
&& $storage->template_covariants
&& ($local_offset
= array_search($t->param_name, array_keys($storage->template_types)))
= array_search($t->param_name, array_keys($storage->template_types), true))
!== false
&& !empty($storage->template_covariants[$local_offset])
) {
Expand Down
Loading