diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index bd9b970c..4de3e3dd 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -66,6 +66,18 @@ 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: '#^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/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 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.