From b4da670b7496d4aa22947242c30f5d629d03f132 Mon Sep 17 00:00:00 2001 From: Sjors Ottjes Date: Sat, 22 Aug 2026 06:13:46 +0200 Subject: [PATCH 1/2] update Rule --- Build/phpstan/phpstan-baseline.neon | 6 ++++++ src/Rule/Rule.php | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index bd9b970c..247a7f44 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -66,6 +66,12 @@ parameters: count: 2 path: ../../src/Property/Selector/SpecificityCalculator.php + - + message: '#^Function class_alias is unsafe to use\. It can return FALSE instead of throwing an exception\. Please add ''use function Safe\\class_alias;'' at the beginning of the file to use the variant provided by the ''thecodingmachine/safe'' library\.$#' + identifier: theCodingMachineSafe.function + count: 1 + path: ../../src/Rule/Rule.php + - message: '#^Parameter \#2 \$arguments of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects array\\|Sabberworm\\CSS\\Value\\RuleValueList, Sabberworm\\CSS\\Value\\Value\|string given\.$#' identifier: argument.type diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index c20f6696..1b041032 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -6,14 +6,13 @@ use Sabberworm\CSS\Property\Declaration; -use function Safe\class_alias; - // @phpstan-ignore function.impossibleType if (!\class_exists(Rule::class, false) && !\interface_exists(Rule::class, false)) { - class_alias(Declaration::class, Rule::class); + $aliasWasCreated = \class_alias(Declaration::class, Rule::class); + \assert($aliasWasCreated); // The test is expected to evaluate to false, // but allows for the deprecation notice to be picked up by IDEs like PHPStorm. - // @phpstan-ignore function.impossibleType + // @phpstan-ignore function.impossibleType, booleanNot.alwaysTrue, booleanAnd.alwaysTrue if (!\class_exists(Rule::class, false) && !\interface_exists(Rule::class, false)) { /** * @deprecated in v9.2, will be removed in v10.0. Use `Property\Declaration` instead, which is a direct From 123683332dfbb2232a2c19e67e1aed240825572a Mon Sep 17 00:00:00 2001 From: Sjors Ottjes Date: Sat, 22 Aug 2026 06:18:37 +0200 Subject: [PATCH 2/2] update RuleContainer --- Build/phpstan/phpstan-baseline.neon | 6 ++++++ src/RuleSet/RuleContainer.php | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index 247a7f44..4de3e3dd 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -72,6 +72,12 @@ parameters: count: 1 path: ../../src/Rule/Rule.php + - + message: '#^Function class_alias is unsafe to use\. It can return FALSE instead of throwing an exception\. Please add ''use function Safe\\class_alias;'' at the beginning of the file to use the variant provided by the ''thecodingmachine/safe'' library\.$#' + identifier: theCodingMachineSafe.function + count: 1 + path: ../../src/RuleSet/RuleContainer.php + - message: '#^Parameter \#2 \$arguments of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects array\\|Sabberworm\\CSS\\Value\\RuleValueList, Sabberworm\\CSS\\Value\\Value\|string given\.$#' identifier: argument.type diff --git a/src/RuleSet/RuleContainer.php b/src/RuleSet/RuleContainer.php index 7bfa7b8a..0dc71371 100644 --- a/src/RuleSet/RuleContainer.php +++ b/src/RuleSet/RuleContainer.php @@ -4,14 +4,13 @@ namespace Sabberworm\CSS\RuleSet; -use function Safe\class_alias; - // @phpstan-ignore function.impossibleType if (!\class_exists(RuleContainer::class, false) && !\interface_exists(RuleContainer::class, false)) { - class_alias(DeclarationList::class, RuleContainer::class); + $aliasWasCreated = \class_alias(DeclarationList::class, RuleContainer::class); + \assert($aliasWasCreated); // The test is expected to evaluate to false, // but allows for the deprecation notice to be picked up by IDEs like PHPStorm. - // @phpstan-ignore function.impossibleType + // @phpstan-ignore function.impossibleType, booleanNot.alwaysTrue, booleanAnd.alwaysTrue if (!\class_exists(RuleContainer::class, false) && !\interface_exists(RuleContainer::class, false)) { /** * @deprecated in v9.2, will be removed in v10.0. Use `DeclarationList` instead, which is a direct replacement.