Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
28da9eb
Report what PHP 8.6 deprecates, whatever PHP version is analysed
danog Nov 20, 2026
ef19f4a
Describe the API PHP 8.6 adds: generics, capabilities and the new met…
danog Nov 20, 2026
53718e3
Require symfony/polyfill-php85
danog Nov 20, 2026
b4f85e4
ci: run the single-version jobs on PHP 8.6
danog Nov 20, 2026
05ca9be
Report PHP 8.6 deprecations from the analyzers of the deprecated code
danog Nov 20, 2026
c750bc8
Report the builtins and syntax PHP 8.1 to 8.5 deprecate
danog Nov 20, 2026
d36071f
Report only the ternary's own negated condition as redundant
danog Nov 20, 2026
6a9687b
Show the syntax PHP 8.1 to 8.5 deprecates in the DeprecatedSyntax docs
danog Nov 20, 2026
9dcd5ee
Ignore deprecations in test cases about other behaviour
danog Nov 21, 2026
9fa8c61
Don't count the functions of Psalm's own dependencies as the project's
danog Nov 21, 2026
437c2a9
Check that Psalm's polyfill-php86 doesn't define clamp() for the project
danog Nov 21, 2026
b30fee2
Stub the classes and enums PHP 8.3 to 8.5 introduce
danog Nov 21, 2026
c1b7e9f
Let test snippets that use PHPUnit's functions depend on PHPUnit
danog Nov 21, 2026
0a5dad0
Annotate the capabilities of Config::setProjectPackages()
danog Nov 21, 2026
053d7eb
Charge io for the random keys, salts and nonces of sodium, OpenSSL an…
danog Nov 21, 2026
6e7489d
Report declaring __sleep() and __wakeup(), which PHP 8.5 soft-deprecates
danog Nov 21, 2026
fc76d29
Report the deprecated string increments and decrements of PHP 8.3 wit…
danog Nov 21, 2026
20e6665
Report fetching a global constant declared deprecated
danog Nov 21, 2026
515bfbe
Use the native type of a parent class constant as the type its overri…
danog Nov 21, 2026
c31d660
Charge the capabilities of the impure functions PHP 8.1 to 8.5 add
danog Nov 21, 2026
862bd90
Read the installed packages and autoloaded files from the project's v…
danog Nov 21, 2026
b1c5c8a
Fix the tests that CI ran on other runtimes and Windows
danog Nov 21, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/bcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
with:
php-version: '8.5'
php-version: '8.6'
tools: composer:v2
coverage: none
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
with:
php-version: '8.2'
php-version: '8.6'
tools: composer:v2
coverage: none
env:
Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
with:
php-version: '8.3'
php-version: '8.6'
tools: composer:v2
coverage: none
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: '8.5'
php-version: '8.6'
ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=off
tools: composer:v2
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
with:
php-version: '8.5'
php-version: '8.6'
#ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
# Windows workers share OPcache; cached final classes bypass BypassFinals' source rewriting.
ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=0, opcache.jit=off
Expand Down
2 changes: 1 addition & 1 deletion bin/perf/corpus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# psalm.dirs / ignore / attributes / extensions (generate psalm-perf.xml; attributes override the fixed ones,
# errorLevel defaults to 1).

php: "8.5"
php: "8.6"
install_timeout: 180
memory_limit: 12G
php_ini:
Expand Down
15 changes: 5 additions & 10 deletions bin/stubs/build_docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@
const VERSIONS = ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6'];

/** The tag of the PHP base image of versions with no release yet (php:<version>-alpine otherwise). */
const BASE_IMAGE_TAGS = [
'8.6' => '8.6-rc-alpine',
];
const BASE_IMAGE_TAGS = [];

/** Alpine packages installed first, for extensions the base image of a version lacks the libraries of. */
const BASE_IMAGE_PACKAGES = [
// the 8.6 release candidate images are built without mbstring
'8.6' => ['oniguruma-dev'],
];
const BASE_IMAGE_PACKAGES = [];

/** Extensions installed in every image. */
const EXTENSIONS = [
Expand All @@ -60,8 +55,8 @@
const EXCLUDES = [
// php-zmq does not build on PHP 8.5 (it calls zend_exception_get_default(), removed in 8.5).
'8.5' => ['zmq'],
// these don't build on the PHP 8.6 release candidates yet (8.6 removed XtOffsetOf, zval_dtor, INI_STR, ...)
'8.6' => ['zmq', 'amqp', 'apcu', 'ds', 'ev', 'grpc', 'igbinary', 'memcached', 'redis', 'swoole', 'zookeeper'],
// php-zmq still calls zend_exception_get_default()
'8.6' => ['zmq'],
];

/** Extension versions pinned for specific versions, by base extension name. */
Expand Down Expand Up @@ -618,7 +613,7 @@ function generateDockerfile(string $version, array $extensions, array $pieInstal
. " && \\\n php /tmp/pear.phar && rm /tmp/pear.phar";
}
// 8.6 dropped XtOffsetOf, an alias of offsetof, which imagick still uses
$cflags = isset(BASE_IMAGE_TAGS[$version]) ? "CFLAGS='-DXtOffsetOf=offsetof' " : '';
$cflags = version_compare($version, '8.6', '>=') ? "CFLAGS='-DXtOffsetOf=offsetof' " : '';
$packages = BASE_IMAGE_PACKAGES[$version] ?? [];
$packageStep = $packages === []
? ''
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"psalm/plugin-mockery": "^1.3.2",
"psalm/plugin-phpunit": "^0.21 || ^0.22 || ^1.0",
"psalm/plugin-symfony": "^5.9.1",
"weirdan/doctrine-psalm-plugin": "^2.12.0",
"psalm/psalm-plugin-api": "0.5.1",
"sebastian/diff": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"spatie/array-to-xml": "^2.17.0 || ^3.0",
"symfony/console": "^6.0 || ^7.0 || ^8.0",
"symfony/filesystem": "~6.3.12 || ~6.4.3 || ^7.0.3 || ^8.0",
"symfony/polyfill-php84": "^1.31.0"
"symfony/polyfill-php84": "^1.31.0",
"symfony/polyfill-php85": "^1.43",
"symfony/polyfill-php86": "^1.43",
"weirdan/doctrine-psalm-plugin": "^2.12.0"
},
"provide": {
"psalm/psalm": "self.version"
Expand Down
1 change: 1 addition & 0 deletions config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
<xs:element name="DeprecatedInterface" type="ClassIssueHandlerType" minOccurs="0" />
<xs:element name="DeprecatedMethod" type="MethodIssueHandlerType" minOccurs="0" />
<xs:element name="DeprecatedProperty" type="PropertyIssueHandlerType" minOccurs="0" />
<xs:element name="DeprecatedSyntax" type="IssueHandlerType" minOccurs="0" />
<xs:element name="DeprecatedTrait" type="IssueHandlerType" minOccurs="0" />
<xs:element name="DirectConstructorCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="DocblockTypeContradiction" type="IssueHandlerType" minOccurs="0" />
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_86.php
Original file line number Diff line number Diff line change
Expand Up @@ -93263,7 +93263,7 @@
),
'stream_last_errors' =>
array (
-1 => 'array<array-key, mixed>',
-1 => 'list<StreamError>',
),
'stream_notification_callback' =>
array (
Expand Down
28 changes: 28 additions & 0 deletions dictionaries/ImpureFunctionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
'socket_set_nonblock' => Capabilities::IO,
'socket_listen' => Capabilities::IO,
'stream_socket_shutdown' => Capabilities::IO,
'stream_socket_get_crypto_status' => Capabilities::IO,
'socket_shutdown' => Capabilities::IO,
'fsockopen' => Capabilities::IO | Capabilities::WRITE_REFS,
'pfsockopen' => Capabilities::IO | Capabilities::WRITE_REFS,
Expand Down Expand Up @@ -368,6 +369,26 @@
'rand' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'random_int' => Capabilities::IO,
'random_bytes' => Capabilities::IO,
// a random key, nonce or tweak
'sodium_crypto_ipcrypt_keygen' => Capabilities::IO,
'sodium_crypto_ipcrypt_nd_keygen' => Capabilities::IO,
'sodium_crypto_ipcrypt_ndx_keygen' => Capabilities::IO,
'sodium_crypto_ipcrypt_pfx_keygen' => Capabilities::IO,
'sodium_crypto_ipcrypt_nd_encrypt' => Capabilities::IO,
'sodium_crypto_ipcrypt_ndx_encrypt' => Capabilities::IO,
'sodium_crypto_kem_keypair' => Capabilities::IO,
'sodium_crypto_kem_enc' => Capabilities::IO,
'sodium_crypto_kem_mlkem768_keypair' => Capabilities::IO,
'sodium_crypto_kem_mlkem768_enc' => Capabilities::IO,
// they absorb into or squeeze from the state they are given
'sodium_crypto_xof_shake128_update' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_shake128_squeeze' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_shake256_update' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_shake256_squeeze' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_turboshake128_update' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_turboshake128_squeeze' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_turboshake256_update' => Capabilities::WRITE_PROPS,
'sodium_crypto_xof_turboshake256_squeeze' => Capabilities::WRITE_PROPS,
'wincache_ucache_delete' => Capabilities::IO,
'wincache_ucache_set' => Capabilities::IO,
'wincache_ucache_inc' => Capabilities::IO,
Expand Down Expand Up @@ -424,6 +445,13 @@
// the call stack differs per call site
'debug_backtrace' => Capabilities::READ_GLOBALS,
'error_clear_last' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'stream_last_errors' => Capabilities::READ_GLOBALS,
'stream_clear_errors' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
// the MIB and output settings of the snmp extension
'snmp_init_mib' => Capabilities::IO | Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'snmp_set_mib_option' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'snmp_set_output_option' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'snmp_set_string_output_format' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'array_rand' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
'set_include_path' => Capabilities::WRITE_GLOBALS | Capabilities::READ_GLOBALS,
// logging
Expand Down
1 change: 1 addition & 0 deletions docs/running_psalm/error_levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ These issues become info (non-blocking) at level 3 and higher.
- [DeprecatedInterface](issues/DeprecatedInterface.md)
- [DeprecatedMethod](issues/DeprecatedMethod.md)
- [DeprecatedProperty](issues/DeprecatedProperty.md)
- [DeprecatedSyntax](issues/DeprecatedSyntax.md)
- [DeprecatedTrait](issues/DeprecatedTrait.md)
- [DirectConstructorCall](issues/DirectConstructorCall.md)
- [DocblockTypeContradiction](issues/DocblockTypeContradiction.md)
Expand Down
1 change: 1 addition & 0 deletions docs/running_psalm/issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [DeprecatedInterface](issues/DeprecatedInterface.md)
- [DeprecatedMethod](issues/DeprecatedMethod.md)
- [DeprecatedProperty](issues/DeprecatedProperty.md)
- [DeprecatedSyntax](issues/DeprecatedSyntax.md)
- [DeprecatedTrait](issues/DeprecatedTrait.md)
- [DirectConstructorCall](issues/DirectConstructorCall.md)
- [DocblockTypeContradiction](issues/DocblockTypeContradiction.md)
Expand Down
9 changes: 9 additions & 0 deletions docs/running_psalm/issues/DeprecatedConstant.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ enum B {
echo B::B;
```

Psalm also reports the builtin constants PHP deprecates, whatever PHP version you analyse:

```php
<?php

$names = ['b', 'a'];
sort($names, SORT_LOCALE_STRING); // DeprecatedConstant: use Collator::sort() instead
```

## Why this is bad

The `@deprecated` tag is normally indicative of code that will stop working in the near future.
Expand Down
16 changes: 16 additions & 0 deletions docs/running_psalm/issues/DeprecatedFunction.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ function foo() : void {}
foo();
```

Psalm also reports the builtin functions PHP deprecates, and the arguments it deprecates, whatever PHP version you
analyse:

```php
<?php

function describe(mixed $value, object $object): string {
$float = is_double($value); // DeprecatedFunction: use is_float() instead
$id = spl_object_hash($object); // DeprecatedFunction: use spl_object_id() instead
$query = http_build_query($object); // DeprecatedFunction: pass an array
return $id . $query . ($float ? 'f' : '');
}

define('DEBUG', true, false); // DeprecatedFunction: leave out the third argument
```

## Why this is bad

The `@deprecated` tag is normally indicative of code that will stop working in the near future.
Expand Down
11 changes: 11 additions & 0 deletions docs/running_psalm/issues/DeprecatedMethod.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ class A {
(new A())->foo();
```

Psalm also reports the builtin methods PHP deprecates, whatever PHP version you analyse:

```php
<?php

function sortItems(ArrayIterator $items, SplFileObject $file): void {
$items->asort(); // DeprecatedMethod
$row = $file->fgetcsv(); // DeprecatedMethod: use fgetcsv() on a stream instead
}
```

## Why this is bad

The `@deprecated` tag is normally indicative of code that will stop working in the near future.
Expand Down
46 changes: 46 additions & 0 deletions docs/running_psalm/issues/DeprecatedSyntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# DeprecatedSyntax

Emitted when code uses a statement or declaration that PHP deprecates, whatever PHP version you analyse:

```php
<?php

function load(): string {
try {
return file_get_contents('a.txt') ?: '';
} finally {
return ''; // DeprecatedSyntax: discards the exception and the value returned in try
}
}
```

It covers:

```php
<?php

final class Connection
{
const namespace = 'db'; // DeprecatedSyntax: rename it

public function __construct()
{
yield 1; // DeprecatedSyntax: a constructor can't be a generator
}

public function __destruct()
{
return true; // DeprecatedSyntax: a destructor can't return a value
}

/** @return array<string, string>|null */
public function __debugInfo(): ?array // DeprecatedSyntax: declare array
{
return null;
}
}
```

## How to fix

Move the `return` out of the `finally` block, rename the constant, and drop the value or the `yield`.
10 changes: 10 additions & 0 deletions docs/running_psalm/issues/ReservedWord.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ function foo(mixed $a): bool {
return $a instanceof iterable; // ReservedWord
}
```

Names PHP reserves in a later version are reported too, whatever PHP version you analyse:

```php
<?php

final class let {} // ReservedWord: let becomes a keyword in PHP 8.6
function readonly(): void {} // ReservedWord
const _ = 1; // ReservedWord
```
Loading
Loading