Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
12 changes: 12 additions & 0 deletions config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ parameters:
count: 1
path: ../src/Parsing/ParserState.php

-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 1
path: ../src/Rule/Rule.php

-
message: '#^Parameters should have "string" types as the only types passed to this method$#'
identifier: typePerfect.narrowPublicClassMethodParamType
count: 1
path: ../src/RuleSet/DeclarationBlock.php

-
message: '#^Negated boolean expression is always true\.$#'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be PHPStan annotations in the code with the error code and a short explanation why we do it this way. This will allow us to keep the baseline as a to-do list of thing we'd like to fix.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the annotations, but they only seem to work to silence the booleanAnd.alwaysTrue warnings (introduced by having the class_exists and interface_exists combined), and seem to have no effect on the booleanNot.alwaysTrue warning.

It looks like this may be a bug in PHPStan, and we may have to use @phpstan-ignore-next-line for the time being.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use @phpstan-ignore-next-line, since @phpstan-ignore is not working. If you can figure out why, it would be nice to only exclude certain things, but I can't, and I think it's a bug in PHPStan.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the annotations, but they only seem to work to silence the booleanAnd.alwaysTrue warnings (introduced by having the class_exists and interface_exists combined), and seem to have no effect on the booleanNot.alwaysTrue warning.

I finally realized that putting booleanNot.alwaysTrue was silencing one of the warnings, but not both of them. Having it repeated silences both warnings.

identifier: booleanNot.alwaysTrue
count: 1
path: ../src/RuleSet/RuleContainer.php

-
message: '#^Parameter \#2 \$arguments of class Sabberworm\\CSS\\Value\\CSSFunction constructor expects array\<Sabberworm\\CSS\\Value\\Value\|string\>\|Sabberworm\\CSS\\Value\\RuleValueList, Sabberworm\\CSS\\Value\\Value\|string given\.$#'
identifier: argument.type
Expand Down
11 changes: 7 additions & 4 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
use function Safe\class_alias;

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
* replacement.
*/
class_alias(Declaration::class, Rule::class);
if (!\class_exists(Rule::class, false)) {
Comment thread
oliverklee marked this conversation as resolved.
Outdated
/**
* @deprecated in v9.2, will be removed in v10.0. Use `Property\Declaration` instead, which is a direct
* replacement.
*/
class Rule {}
}
}
9 changes: 6 additions & 3 deletions src/RuleSet/RuleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
use function Safe\class_alias;

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.
*/
class_alias(DeclarationList::class, RuleContainer::class);
if (!\interface_exists(RuleContainer::class, false)) {
/**
* @deprecated in v9.2, will be removed in v10.0. Use `DeclarationList` instead, which is a direct replacement.
*/
interface RuleContainer {}
}
}