From 63915d1e2c88f96e0deaeec50720b72943d24507 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 22 Aug 2022 16:44:55 +0200 Subject: [PATCH 1/5] added SensitiveParameter, AllowDynamicProperties php 8.2 attributes --- stubs/CoreGenericClasses.phpstub | 12 ++++++++++++ tests/AttributeTest.php | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/stubs/CoreGenericClasses.phpstub b/stubs/CoreGenericClasses.phpstub index 0dae5ef34d2..168572e7de7 100644 --- a/stubs/CoreGenericClasses.phpstub +++ b/stubs/CoreGenericClasses.phpstub @@ -501,3 +501,15 @@ final class ReturnTypeWillChange { public function __construct() {} } + +#[Attribute] +final class SensitiveParameter +{ + public function __construct() {} +} + +#[Attribute] +final class AllowDynamicProperties +{ + public function __construct() {} +} diff --git a/tests/AttributeTest.php b/tests/AttributeTest.php index efffdbad4de..460bde45b13 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -249,6 +249,32 @@ public function getIterator() [], '8.1' ], + 'allowDynamicProperties' => [ + ' [ + ' [ ' Date: Mon, 22 Aug 2022 16:55:26 +0200 Subject: [PATCH 2/5] imports --- tests/AttributeTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/AttributeTest.php b/tests/AttributeTest.php index 460bde45b13..d8c851d0266 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -254,7 +254,9 @@ public function getIterator() namespace AllowDynamicPropertiesAttribute; - #[\AllowDynamicProperties] + use AllowDynamicProperties; + + #[AllowDynamicProperties] class Foo {}', [], @@ -266,9 +268,11 @@ class Foo namespace SensitiveParameter; + use SensitiveParameter; + class HelloWorld { public function __construct( - #[\SensitiveParameter] string $password + #[SensitiveParameter] string $password ) {} }', [], From 8407cacc023c6471c91703655c0f5c321e8b2c82 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 22 Aug 2022 16:55:32 +0200 Subject: [PATCH 3/5] improve CI error message --- src/Psalm/Internal/CliUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/CliUtils.php b/src/Psalm/Internal/CliUtils.php index f8c88734001..abe54ff20db 100644 --- a/src/Psalm/Internal/CliUtils.php +++ b/src/Psalm/Internal/CliUtils.php @@ -636,7 +636,7 @@ public static function initPhpVersion(array $options, Config $config, ProjectAna if (isset($options['php-version'])) { if (!is_string($options['php-version'])) { - die('Expecting a version number in the format x.y' . PHP_EOL); + die('Expecting a version number in the format x.y, got'. get_debug_type($options['php-version']) . PHP_EOL); } $version = $options['php-version']; $source = 'cli'; From 198347fac7626b269bc45c3249911c661e933ed8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 22 Aug 2022 16:58:23 +0200 Subject: [PATCH 4/5] fix test --- tests/AttributeTest.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/AttributeTest.php b/tests/AttributeTest.php index d8c851d0266..b77b9d6aa67 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -258,10 +258,8 @@ public function getIterator() #[AllowDynamicProperties] class Foo - {}', - [], - [], - '8.2' + {} + ', ], 'sensitiveParameter' => [ ' [ ' Date: Mon, 22 Aug 2022 16:59:27 +0200 Subject: [PATCH 5/5] Restore CliUtils.php --- src/Psalm/Internal/CliUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/CliUtils.php b/src/Psalm/Internal/CliUtils.php index abe54ff20db..f8c88734001 100644 --- a/src/Psalm/Internal/CliUtils.php +++ b/src/Psalm/Internal/CliUtils.php @@ -636,7 +636,7 @@ public static function initPhpVersion(array $options, Config $config, ProjectAna if (isset($options['php-version'])) { if (!is_string($options['php-version'])) { - die('Expecting a version number in the format x.y, got'. get_debug_type($options['php-version']) . PHP_EOL); + die('Expecting a version number in the format x.y' . PHP_EOL); } $version = $options['php-version']; $source = 'cli';