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 0dae5ef34..168572e7d 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 efffdbad4..460bde45b 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -249,6 +249,32 @@ class AttributeTest extends TestCase [], '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 460bde45b..d8c851d02 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -254,7 +254,9 @@ class AttributeTest extends TestCase namespace AllowDynamicPropertiesAttribute; - #[\AllowDynamicProperties] + use AllowDynamicProperties; + + #[AllowDynamicProperties] class Foo {}', [], @@ -266,9 +268,11 @@ class AttributeTest extends TestCase 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 f8c887340..abe54ff20 100644 --- a/src/Psalm/Internal/CliUtils.php +++ b/src/Psalm/Internal/CliUtils.php @@ -636,7 +636,7 @@ HELP; 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 d8c851d02..b77b9d6aa 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -258,10 +258,8 @@ class AttributeTest extends TestCase #[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 abe54ff20..f8c887340 100644 --- a/src/Psalm/Internal/CliUtils.php +++ b/src/Psalm/Internal/CliUtils.php @@ -636,7 +636,7 @@ HELP; 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';