Skip to content

Commit ea74072

Browse files
authored
Merge branch 'master' into feature/ext-amqp-phpstub
2 parents 6bb0b7a + 79ab7e2 commit ea74072

File tree

1,307 files changed

+198494
-47257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,307 files changed

+198494
-47257
lines changed

.circleci/config.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# See https://app.circleci.com/pipelines/github/vimeo/psalm
33
version: 2.1
44
executors:
5-
php-74:
6-
docker:
7-
- image: thecodingmachine/php:7.4-v4-cli
8-
php-80:
9-
docker:
10-
- image: thecodingmachine/php:8.0-v4-cli
115
php-81:
126
docker:
137
- image: thecodingmachine/php:8.1-v4-cli
@@ -16,7 +10,7 @@ executors:
1610
- image: thecodingmachine/php:8.2-v4-cli
1711
jobs:
1812
"Code Style Analysis":
19-
executor: php-74
13+
executor: php-81
2014
steps:
2115
- checkout
2216

@@ -44,7 +38,7 @@ jobs:
4438
command: vendor/bin/phpcs -d memory_limit=512M
4539

4640
phar-build:
47-
executor: php-74
41+
executor: php-81
4842
steps:
4943
- attach_workspace:
5044
at: /home/docker/project/

.github/workflows/build-phar.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Set up PHP
3939
uses: shivammathur/setup-php@v2
4040
with:
41-
php-version: '7.4'
41+
php-version: '8.1'
4242
tools: composer:v2
4343
coverage: none
4444
env:

.github/workflows/ci.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Set up PHP
1313
uses: shivammathur/setup-php@v2
1414
with:
15-
php-version: '7.4'
15+
php-version: '8.1'
1616
tools: composer:v2
1717
coverage: none
1818
env:
@@ -32,6 +32,12 @@ jobs:
3232
env:
3333
COMPOSER_ROOT_VERSION: dev-master
3434

35+
- name: Check all classes are autoloadable
36+
run: |
37+
composer dump-autoload -o --strict-psr
38+
env:
39+
COMPOSER_ROOT_VERSION: dev-master
40+
3541
- name: Cache composer cache
3642
uses: actions/cache@v4
3743
with:
@@ -57,7 +63,7 @@ jobs:
5763
- name: Set up PHP
5864
uses: shivammathur/setup-php@v2
5965
with:
60-
php-version: '7.4'
66+
php-version: '8.1'
6167
tools: composer:v2
6268
coverage: none
6369
env:
@@ -125,7 +131,6 @@ jobs:
125131
fail-fast: false
126132
matrix:
127133
php-version:
128-
- "8.0"
129134
- "8.1"
130135
- "8.2"
131136
- "8.3"

.github/workflows/macos-scan.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Run Psalm (mac OS)
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
build:
10+
runs-on: macos-15
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.4'
17+
ini-values: zend.assertions=1
18+
tools: composer:v2
19+
coverage: none
20+
env:
21+
fail-fast: true
22+
23+
- name: Install dependencies
24+
run: composer install --prefer-dist --no-progress --no-suggest
25+
env:
26+
COMPOSER_ROOT_VERSION: dev-master
27+
28+
- name: Run Psalm
29+
run: ./psalm --output-format=github --force-jit

.github/workflows/shepherd.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: shivammathur/setup-php@v2
1515
with:
16-
php-version: '8.2'
16+
php-version: '8.4'
1717
ini-values: zend.assertions=1
1818
tools: composer:v2
1919
coverage: none
@@ -26,4 +26,4 @@ jobs:
2626
COMPOSER_ROOT_VERSION: dev-master
2727

2828
- name: Run Psalm
29-
run: ./psalm --threads=2 --output-format=github --shepherd
29+
run: ./psalm --output-format=github --shepherd --force-jit

.github/workflows/windows-ci.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,21 @@ jobs:
5454
- name: Set up PHP
5555
uses: shivammathur/setup-php@v2
5656
with:
57-
php-version: '8.0'
58-
ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
57+
php-version: '8.1'
58+
#ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
59+
ini-values: zend.assertions=1, assert.exception=1
5960
tools: composer:v2
6061
coverage: none
61-
extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, opcache, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter
62+
#extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, opcache, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter
63+
extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter
6264
env:
6365
fail-fast: true
6466

67+
- name: PHP Version
68+
run: |
69+
php -v
70+
php -r 'var_dump(PHP_VERSION_ID);'
71+
6572
- uses: actions/checkout@v4
6673

6774
- name: Get Composer Cache Directories

UPGRADING.md

+46
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,59 @@
11
# Upgrading from Psalm 5 to Psalm 6
22
## Changed
33

4+
- The minimum PHP version was raised to PHP 8.1.17.
5+
6+
- [BC] The configuration settings `ignoreInternalFunctionFalseReturn` and `ignoreInternalFunctionNullReturn` are now defaulted to `false`
7+
48
- [BC] Switched the internal representation of `list<T>` and `non-empty-list<T>` from the TList and TNonEmptyList classes to an unsealed list shape: the TList, TNonEmptyList and TCallableList classes were removed.
59
Nothing will change for users: the `list<T>` and `non-empty-list<T>` syntax will remain supported and its semantics unchanged.
610
Psalm 5 already deprecates the `TList`, `TNonEmptyList` and `TCallableList` classes: use `\Psalm\Type::getListAtomic`, `\Psalm\Type::getNonEmptyListAtomic` and `\Psalm\Type::getCallableListAtomic` to instantiate list atomics, or directly instantiate TKeyedArray objects with `is_list=true` where appropriate.
711

812
- [BC] The only optional boolean parameter of `TKeyedArray::getGenericArrayType` was removed, and was replaced with a string parameter with a different meaning.
913

1014
- [BC] The `TDependentListKey` type was removed and replaced with an optional property of the `TIntRange` type.
15+
-
16+
- [BC] `TCallableArray` and `TCallableList` removed and replaced with `TCallableKeyedArray`.
17+
18+
- [BC] Class `Psalm\Issue\MixedInferredReturnType` was removed
19+
20+
- [BC] Value of constant `Psalm\Type\TaintKindGroup::ALL_INPUT` changed to reflect new `TaintKind::INPUT_EXTRACT`, `TaintKind::INPUT_SLEEP` and `TaintKind::INPUT_XPATH` have been added. Accordingly, default values for `$taint` parameters of `Psalm\Codebase::addTaintSource()` and `Psalm\Codebase::addTaintSink()` have been changed as well.
21+
22+
- [BC] Property `Config::$shepherd_host` was replaced with `Config::$shepherd_endpoint`
23+
24+
- [BC] Methods `Codebase::getSymbolLocation()` and `Codebase::getSymbolInformation()` were replaced with `Codebase::getSymbolLocationByReference()`
25+
26+
- [BC] Method `Psalm\Type\Atomic\TKeyedArray::getList()` was removed
27+
28+
- [BC] Method `Psalm\Storage\FunctionLikeStorage::getSignature()` was replaced with `FunctionLikeStorage::getCompletionSignature()`
29+
30+
- [BC] Property `Psalm\Storage\FunctionLikeStorage::$unused_docblock_params` was replaced with `FunctionLikeStorage::$unused_docblock_parameters`
31+
32+
- [BC] Method `Plugin\Shepherd::getCurlErrorMessage()` was removed
33+
34+
- [BC] Property `Config::$find_unused_code` changed default value from false to true
35+
36+
- [BC] Property `Config::$find_unused_baseline_entry` changed default value from false to true
37+
38+
- [BC] The return type of `Psalm\Internal\LanguageServer\ProtocolWriter#write() changed from `Amp\Promise` to `void` due to the switch to Amp v3
39+
40+
- [BC] All parameters, properties and return typehints are now strictly typed.
41+
42+
- [BC] `strict_types` is now applied to all files of the Psalm codebase.
43+
44+
- [BC] Properties `Psalm\Type\Atomic\TLiteralFloat::$value` and `Psalm\Type\Atomic\TLiteralInt::$value` became typed (`float` and `int` respectively)
45+
46+
- [BC] Property `Psalm\Storage\EnumCaseStorage::$value` changed from `int|string|null` to `TLiteralInt|TLiteralString|null`
47+
48+
- [BC] `Psalm\CodeLocation\Raw`, `Psalm\CodeLocation\ParseErrorLocation`, `Psalm\CodeLocation\DocblockTypeLocation`, `Psalm\Report\CountReport`, `Psalm\Type\Atomic\TNonEmptyArray` are now all final.
49+
50+
- [BC] `Psalm\Config` is now final.
51+
52+
- [BC] The return type of `Psalm\Plugin\ArgTypeInferer::infer` changed from `Union|false` to `Union|null`
53+
54+
- [BC] The `extra_types` property and `setIntersectionTypes` method of `Psalm\Type\Atomic\TTypeAlias` were removed.
55+
56+
- [BC] Methods `convertSeverity` and `calculateFingerprint` of `Psalm\Report\CodeClimateReport` were removed.
1157

1258
# Upgrading from Psalm 4 to Psalm 5
1359
## Changed

bin/generate_issues_list_doc.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env php
22
<?php
33

4+
declare(strict_types=1);
5+
46
$docs_dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . "docs"
57
. DIRECTORY_SEPARATOR . "running_psalm" . DIRECTORY_SEPARATOR;
68
$issues_index = "{$docs_dir}issues.md";

bin/generate_levels_doc.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Psalm\Config\IssueHandler;
46
use Psalm\Issue\CodeIssue;
57

bin/generate_testsuites.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
if (count($argv) < 2) {
46
fwrite(STDERR, 'Usage: ' . $argv[0] . ' <number_of_chunks>' . PHP_EOL);
57
exit(1);
@@ -35,7 +37,7 @@
3537
);
3638
array_multisort($order, $files);
3739

38-
$chunks = array_chunk($files, ceil(count($files) / $number_of_chunks));
40+
$chunks = array_chunk($files, (int) ceil(count($files) / $number_of_chunks));
3941

4042
$phpunit_config = new DOMDocument('1.0', 'UTF-8');
4143
$phpunit_config->preserveWhiteSpace = false;

bin/improve_class_alias.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$vendor_path = 'vendor-bin/box/vendor/humbug/php-scoper/src/PhpParser/NodeVisitor/ClassAliasStmtAppender.php';
46

57
if (!file_exists($vendor_path)) {

bin/max_used_shortcode.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env php
22
<?php
33

4+
declare(strict_types=1);
5+
46
use Psalm\Config\IssueHandler;
57

68
require_once(dirname(__DIR__) . '/vendor/autoload.php');

bin/normalize-callmap.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require 'vendor/autoload.php';
6+
7+
use DG\BypassFinals;
8+
use Psalm\Internal\Analyzer\ProjectAnalyzer;
9+
use Psalm\Internal\Provider\FileProvider;
10+
use Psalm\Internal\Provider\Providers;
11+
use Psalm\Tests\TestConfig;
12+
use Psalm\Type;
13+
14+
BypassFinals::enable();
15+
16+
new ProjectAnalyzer(new TestConfig, new Providers(new FileProvider));
17+
18+
$codebase = ProjectAnalyzer::getInstance()->getCodebase();
19+
20+
chdir(__DIR__.'/../');
21+
22+
foreach (glob("dictionaries/CallMap*.php") as $file) {
23+
$callMap = require $file;
24+
25+
array_walk_recursive($callMap, function (string &$type): void {
26+
$type = Type::parseString($type === '' ? 'mixed' : $type)->getId(true);
27+
});
28+
29+
file_put_contents($file, '<?php // phpcs:ignoreFile
30+
31+
return '.var_export($callMap, true).';');
32+
}

bin/test-with-real-projects.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ collections)
2626
git clone --depth=1 [email protected]:psalm/endtoend-test-collections.git
2727
cd endtoend-test-collections
2828
composer install
29+
rm vendor/amphp/amp/lib/functions.php; touch vendor/amphp/amp/lib/functions.php;
30+
rm vendor/amphp/amp/lib/Internal/functions.php; touch vendor/amphp/amp/lib/Internal/functions.php
31+
rm vendor/amphp/byte-stream/lib/functions.php; touch vendor/amphp/byte-stream/lib/functions.php
2932
"$PSALM" --monochrome --show-info=false
3033
;;
3134

@@ -36,11 +39,13 @@ psl)
3639

3740
git clone [email protected]:psalm/endtoend-test-psl.git
3841
cd endtoend-test-psl
39-
git checkout 2.3.x
42+
git checkout 2.3.x_master
4043
composer install
44+
# Avoid conflicts with old psalm when running phar tests
45+
rm -rf vendor/vimeo/psalm
4146
sed 's/ErrorOutputBehavior::Packed, ErrorOutputBehavior::Discard/ErrorOutputBehavior::Discard/g' -i src/Psl/Shell/execute.php
42-
"$PSALM" --monochrome -c config/psalm.xml
43-
"$PSALM" --monochrome -c config/psalm.xml tests/static-analysis
47+
"$PSALM_PHAR" --monochrome -c config/psalm.xml
48+
"$PSALM_PHAR" --monochrome -c config/psalm.xml tests/static-analysis
4449
;;
4550

4651
laravel)

bin/update-property-map.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ function extractClassesFromStatements(array $statements): array
9393
foreach ($files as $file) {
9494
$contents = file_get_contents($file);
9595
// FIXME: find a way to ignore custom entities, for now we strip them.
96-
$contents = preg_replace('#&[a-zA-Z\d.\-_]+;#', '', $contents);
97-
$contents = preg_replace('#%[a-zA-Z\d.\-_]+;#', '', $contents);
98-
$contents = preg_replace('#<!ENTITY[^>]+>#', '', $contents);
96+
$contents = (string) preg_replace('#&[a-zA-Z\d.\-_]+;#', '', $contents);
97+
$contents = (string) preg_replace('#%[a-zA-Z\d.\-_]+;#', '', $contents);
98+
$contents = (string) preg_replace('#<!ENTITY[^>]+>#', '', $contents);
9999
try {
100100
$simple = new SimpleXMLElement($contents);
101101
} catch (Throwable $exception) {

0 commit comments

Comments
 (0)