Skip to content

Conversation

oliverklee
Copy link
Collaborator

Part of #756

@coveralls
Copy link

Coverage Status

coverage: 55.567%. remained the same
when pulling 4bc6c1b on cleanup/hungarian/maximum-length
into 008d2fb on main.

@JakeQZ JakeQZ merged commit 337f861 into main Mar 8, 2025
21 checks passed
@JakeQZ JakeQZ deleted the cleanup/hungarian/maximum-length branch March 8, 2025 18:43
npghub added a commit to NitroPack/PHP-CSS-Parser that referenced this pull request Oct 6, 2025
* [TASK] Extract value parsing functional tests (part 1) (MyIntervals#1084)

In the tests, we should test parsing and rendering separately
as this makes debugging test failures a lot easier.

Part of MyIntervals#1057

* [TASK] Drop special support for vendor prefixes (MyIntervals#1083)

In the past, vendor prefixes like `-moz-` or `-webkit-` were
used for experimental CSS features in browsers. Nowadays,
the browsers use features for this instead. Hence, special
support for vendor prefixes is no longer needed.

https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix

* [CLEANUP] Avoid Hungarian notation for `size` (MyIntervals#1085)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `unit` and `sizeUnits` (MyIntervals#1088)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `isColorComponent` (MyIntervals#1090)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `Size::render()` (MyIntervals#1092)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `url` (MyIntervals#1093)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `tokenLength` (MyIntervals#1089)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `character` (MyIntervals#1094)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `sizeUnit` (MyIntervals#1095)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `useUrl` (MyIntervals#1096)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormatter` (MyIntervals#1097)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 1) (MyIntervals#1098)

Part of MyIntervals#756

* [CLEANUP] Improve some `OutputFormat` property and getter names (MyIntervals#1099)

As suggested in MyIntervals#1098.

The setters are not changed as those are part of the public
API.

* [CLEANUP] Avoid Hungarian notation in the tests (MyIntervals#1101)

Part of MyIntervals#756

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [CLEANUP] Avoid Hungarian notation in `SpecificityCalculator` (MyIntervals#1102)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `CSSBlockList` (MyIntervals#1104)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `DeclarationBlock` (MyIntervals#1105)

Part of MyIntervals#756

* [CLEANUP] Use the explicit `OutputFormat` setters in the tests (MyIntervals#1106)

The `set()` method will be removed soon.

Also unify the tests a bit.

Part of MyIntervals#1103

* [TASK] Remove `OutputFormat::get()` (MyIntervals#1108)

We now have beautiful, cleanly-typed getters to use instead.

Part of MyIntervals#1103

* [CLEANUP] Avoid Hungarian notation in comments (MyIntervals#1109)

Part of MyIntervals#756

* [TASK ] Remove `OutputFormat::set()` (MyIntervals#1110)

Part of MyIntervals#1103
Closes MyIntervals#1103

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 2) (MyIntervals#1100)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `Size` (MyIntervals#1111)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `numberOfLines` (MyIntervals#1112)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `matches` (MyIntervals#1113)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 3) (MyIntervals#1114)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 4) (MyIntervals#1115)

Also rename the (internal) getters to match the changed property
names.

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `input` (MyIntervals#1116)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 5) (MyIntervals#1117)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 6) (MyIntervals#1118)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `expression` (MyIntervals#1119)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `peek` (MyIntervals#1120)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 7) (MyIntervals#1121)

Also rename the getters to match the new property names.

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `maximumLength` (MyIntervals#1122)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `comment` (MyIntervals#1123)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation for `stopCharacters` (MyIntervals#1124)

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 8) (MyIntervals#1125)

Also rename the getters to match the new property names.

Part of MyIntervals#756

* [CLEANUP] Avoid Hungarian notation in `OutputFormat` (part 9) (MyIntervals#1126)

Also rename the getters to match the new property names.

Part of MyIntervals#756

* [CLEANUP] Improve some variable names in `ParserState` (MyIntervals#1129)

* [CLEANUP] Fix some type annotations in `ParserState` (MyIntervals#1130)

Also make the parameter names non-Hungarian.

Part of MyIntervals#756

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [BUGFIX] Fix a typo in `indentationLevel` (MyIntervals#1132)

* [TASK] Mark `OutputFormat` as not extendable (MyIntervals#1131)

Also mark the constructor as `@internal`.

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [TASK] Make `OutputFormat` `final` (MyIntervals#1128)

This class is not intended to be extended, and it's intended to
be created using the factory methods anyway.

(Also, we most probably won't need to have mocks of this class
in the tests as it's mostly a data object.)

* [CLEANUP] Drop empty `OutputFormat` constructor (MyIntervals#1127)

* [TASK] Use native type declarations for `$lineNumber` (MyIntervals#1134)

Part of MyIntervals#811

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [TASK] Add some rendering tests for `Document` (MyIntervals#1138)

Part of MyIntervals#757

* [TASK] Add some more type declarations (MyIntervals#1139)

These are some random changes the Rector would do as a result
of the changes of some open PRs.

* [TASK] Use native type declarations in `Document` (MyIntervals#1137)

Part of MyIntervals#811

* [TASK] Use native type declarations in `ParserState` (MyIntervals#1136)

Part of MyIntervals#811

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [TASK] Use native type declarations in `Parser` (MyIntervals#1140)

Part of MyIntervals#811

* [TASK] Use native type declarations in `Anchor` (MyIntervals#1141)

Part of MyIntervals#811

* [CLEANUP] Make a type annotation more specific (MyIntervals#1143)

* [CLEANUP] Drop an unused internal constant (MyIntervals#1144)

* [TASK] Initialize `KeyFrame` properties (MyIntervals#1146)

They fortunately have obvious default values.
This change means it can be enforced that they are always non-empty strings.
Type declarations have been updated to reflect that.

* [TASK] Add native type declarations for `atRuleName()` (MyIntervals#1145)

Part of MyIntervals#811

* [CLEANUP] Avoid magic method forwarding in `AtRuleBlockList` (MyIntervals#1148)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `ValueList` (MyIntervals#1149)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `Rule` (MyIntervals#1150)

Part of MyIntervals#1147

* [TASK] Drop `atRuleArgs()` from the `AtRule` interface (MyIntervals#1142)

The classes implementing this interface use a wide variaty
of inconsistent return types when they implement this method.

This is a hard blocker for introducing native return type
declaration for this method.

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [CLEANUP] Avoid magic method forwarding in `CSSList` (MyIntervals#1151)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `Color` (MyIntervals#1152)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `AtRuleSet` (MyIntervals#1153)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `Document` (MyIntervals#1155)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `Import` (MyIntervals#1156)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `CalcRuleValueList` (MyIntervals#1157)

Part of MyIntervals#1147

* [DOCS] Avoid Hungarian notation in the README (MyIntervals#1154)

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [CLEANUP] Avoid magic method forwarding in `KeyFrame` (MyIntervals#1158)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `RuleSet` (MyIntervals#1159)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `Charset` (MyIntervals#1160)

Part of MyIntervals#1147

* [CLEANUP] Avoid magic method forwarding in `DeclarationBlock` (MyIntervals#1161)

Part of MyIntervals#1147

* [TASK] Add native type declarations in `Size` (MyIntervals#1162)

Part of MyIntervals#811

* [TASK] Add more unit tests for `Size` (MyIntervals#1165)

Part of MyIntervals#757

* [TASK] Add some basic unit tests for `URL` (MyIntervals#1164)

Part of MyIntervals#757

Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>

* [TASK] Add native type declarations in `URL` (MyIntervals#1163)

Part of MyIntervals#811

* [TASK] Add native return type for `render*` methods (MyIntervals#1166)

Part of MyIntervals#811

* [TASK] Drop magic method forwarding in `OutputFormat` (MyIntervals#898)

* [CLEANUP] Fix method name casing in a call (MyIntervals#1167)

* [BUGFIX] Include comments for all rules in declaration block (MyIntervals#1169)

- `Rule::parse()` will no longer consume anything after the semicolon
  terminating the rule - it does not belong to that rule;
- The whitespace and comments before a rule will be processed by
  `RuleSet::parseRuleSet()` and passed as a parameter to `Rule::parse()` -
  - This is only required while 'strict mode' parsing is an option,
    to avoid having an exception thrown during normal operation
    (i.e. when `Rule::parse()` encounters normal `}`
    as opposed to some other junk, which is not distinguished).

Fixes MyIntervals#173.
See also MyIntervals#672, MyIntervals#741.

* [CLEANUP] Clean up `ParserState` a bit (MyIntervals#1173)

* [TASK] Add native type declarations for `Import` (MyIntervals#1172)

Part of MyIntervals#811

* [BUGFIX] Fix the return type of `Selector::isValid()` (MyIntervals#1174)

Fixes MyIntervals#1043
Part of MyIntervals#811

* [CLEANUP] Make `Commentable` type annotations more specific (MyIntervals#1171)

* [TASK] Add native type declarations for `Charset` (MyIntervals#1178)

Part of MyIntervals#811

* [TASK] Add native type declarations for `CSSString` (MyIntervals#1179)

Part of MyIntervals#811

* [TASK] Avoid the deprecated `__toString()` in tests (MyIntervals#1180)

Moving some tests to functional tests and splitting them up
will come in later changes for MyIntervals#1057.

* [TASK] Remove `__toString()` (MyIntervals#1046)

Closes MyIntervals#998

* [TASK] Add native type declarations for `CSSList` (MyIntervals#1181)

Part of MyIntervals#811

* [CLEANUP] Fix type annotation of `::getSelectors()` (MyIntervals#1184)

Also add a native type declaration.

This will need more cleanup and refactoring later on.

* [TASK] Add native type declarations for `CSSBlockList` (MyIntervals#1183)

Also add some more type checks to ensure that the corresponding
types are actually returned.

Part of MyIntervals#811

* [TASK] Add native type declarations for `RuleSet` (MyIntervals#1186)

Part of MyIntervals#811

* [TASK] Add native type declarations for `CSSNamespace` (MyIntervals#1187)

Part of MyIntervals#811

* [TASK] Reduce and finetune the scope of `@covers` annotations (MyIntervals#1188)

The legacy tests are not very focused. Until we have split them
up, try to avoid false positives for code coverage.

Also add `@covers` annotations for the parent classes of the
tested classes.

* [TASK] Add native type declarations for `Rule` (MyIntervals#1190)

Part of MyIntervals#811

* [TASK] Add native type declarations for `AtRuleSet` (MyIntervals#1192)

Part of MyIntervals#811

* [TASK] Add native type declarations for `DeclarationBlock` (MyIntervals#1193)

Part of MyIntervals#811

* [TASK] Add native type declarations for `ValueList` (MyIntervals#1196)

Also polish some PHPDoc type annotations.

Part of MyIntervals#811.

* [TASK] Add native type declarations for `CSSFunction` (MyIntervals#1197)

Also improve the related type annotations and declarations
in other classes in order to keep things consistent and
to keep Rector from changing things.

* [CLEANUP] And some more annotations for non-empty strings (MyIntervals#1199)

* [CLEANUP] Make annotations for `OutputFormat` more specific (MyIntervals#1200)

* [TASK] Drop the unused `ParserState::strpos()` method (MyIntervals#1202)

* [TASK] Add native type declarations for `RuleValueList` (MyIntervals#1203)

Part of MyIntervals#811

* [CLEANUP] Improve type annotations in `LineName` (MyIntervals#1198)

* [TASK] Add native type declarations for `Color` (MyIntervals#1204)

Also make some types more specific. Also improve code
formatting a bit.

Part of MyIntervals#811

* [CLEANUP] Return `null` from `DeclarationBlock::parse()` on failure (MyIntervals#1209)

Also add clarification of meaning of return value from
`CSSList::parseListItem()`, where `null` and `false` have different meanings.

Part of MyIntervals#1176.

* [TASK] Add (and use) a `CSSListItem` type (MyIntervals#1212)

This allows a single type to be used for the contents of a `CSSList`,
instead of a long list of orred types, and helps with static analysis.

Various `assertInstanceOf()` tests are added to the test cases to confirm that
the list items are of the type expected.

Some `implements` and `exetends` lists are now alphabetically sorted.

Also don't implement interfaces extended by another that is also implemented

PHP<7.4 does not allow this.
Instead, for clarity,
add a DocBlock comment stating which additional interfaces should be
implemented that are not explicitly listed in the `implements` section.

When our minimum PHP version becomes 7.4 or above, we can revisit this.

* [TASK] Configure the target PHP version for PHPStan (MyIntervals#1216)

This will help avoid it suggesting things that are only
possile in later PHP versions.

Fixes MyIntervals#1214

* [TASK] Add trait providing standard implementation of `Commentable` (MyIntervals#1206)

Part of MyIntervals#813.

* [TASK] Use `CommentContainer` trait to implement `Commentable` (MyIntervals#1217)

Closes MyIntervals#813.

* [TASK] Prevent Dependabot updating "rawr/cross-data-providers" (MyIntervals#1219)

Version 3.0 of this package is not compatible.

* [TASK] Add rebasing guidelines to `CONTRIBUTING.md` (MyIntervals#1220)

This section is copied directly from the sister project, Emogrifier.

Resolves MyIntervals#1215.

* [TASK] Integrate changelog entries from 8.8 release (MyIntervals#1222)

(And one that was missed from 8.7.)

* [TASK] Add to UML diagram that `Selector` implements `Renderable` (MyIntervals#1224)

Followup to MyIntervals#1017

* [TASK] Add `Positionable` interface and implementing trait (MyIntervals#1221)

This is for CSS items which have a position in the document.

New methods are added:
- `getLineNumber` to replace `getLineNo`;
- `getColumnNumber` to replace `getColNo`.

These return a nullable `int`, instead of using zero to indicate absence.

The old methods are now deprecated,
but defined in the interface and implemented in the trait.

Note that this change only adds the interface and trait.
It does not modify any classes to actually implement or use these.

Part of MyIntervals#1207.

* [TASK] Update class diagram to include `CSSListItem` (MyIntervals#1226)

Follow-up to MyIntervals#1212.

* [CLEANUP] Autoformat the code and drop unused imports (MyIntervals#1228)

* [CLEANUP] Fix typos in test method names (MyIntervals#1229)

* [TASK] Migrate to `rawr/phpunit-data-provider` (MyIntervals#1227)

The package `rawr/cross-data-providers` that we used has been
abandoned and should not be used anymore.

* [TASK] Implement `Positionable` (MyIntervals#1225)

Closes MyIntervals#1207.

* [TASK] Deprecate `getLineNo()` etc. in v8.9.0 (MyIntervals#1233)

The deprecation and changes from MyIntervals#1207 can be merged to 8.x.
See MyIntervals#1232.

So the deprecation can be brought forward.

* [TASK] Update CHANGELOG for MyIntervals#1233 (MyIntervals#1235)

* [BUGFIX] Correct `AtRuleBlockListTest::implementsAtRule()` (MyIntervals#1238)

Use the interface type to be tested for in the assertion,
not the type of the object itself.

* [TASK] Add and implement `CSSElement` interface (MyIntervals#1231)

Also add tests to confirm that the supplanted types in the DocBlock actually
implement the new interface.

And correct a DocBlock type to also allow `string`,
which is currently possible.

cf. MyIntervals#1230

* [TASK] Add `assertInstanceOf` tests for `CSSListItem` (MyIntervals#1237)

These should probably have been added as part of MyIntervals#1212.
They confirm that the various types supplanted by `CSSListItem` in the API all
implement the new interface.

Resolves MyIntervals#1236.

* [CLEANUP] Remove `CSSBlockList::allDeclarationBlocks()` (MyIntervals#1239)

Change the one remaining usage instance to use `getAllDeclarationBlocks()`,
which was refactored in MyIntervals#990.

Part of MyIntervals#994.

* [TASK] Move `getAllValues()` to `CSSBlockList` (MyIntervals#1240)

Also add unit tests for this method.

Part of MyIntervals#994.  Relates to MyIntervals#1230.

* [TASK] Deconflate `getAllValues()` parameters (MyIntervals#1241)

The `$element` parameter was overloaded with a dual purpose.

A second separate parameter has been added for rule filtering,
which is not actually mutually exclusive with CSS subtree selection.

Since `getAllValues()` is part of the public API,
the method now supports being called with the old or new signatures,
with the old signature being deprecated.

Once the deprecation has been included in the 8.x release branch,
the messiness of supporting the previous API can be removed.

Part of MyIntervals#994.  Also relates to MyIntervals#1230.

* [TASK] Remove original `getAllValues()` API (MyIntervals#1243)

The method still exists with the same (slightly improved) functionality,
but the optional arguments have been refactored, and may require changes.

Part of MyIntervals#994.  Closes MyIntervals#1230.

* [TASK] Refactor `getAllValues()` (MyIntervals#1244)

Move functionality from `allValues()` directly into to `getAllValues()`,
so as to avoid passing array by reference, removing `allValues()`.
Avoid making the recursive call for nested items that are not `CSSElement`s.

Part of MyIntervals#994.
Closes MyIntervals#1230.

* [CLEANUP] `allSelectors()` -> `getAllSelectors()` (MyIntervals#1245)

The renamed (internal) method now returns the result,
instead of having a reference parameter for it.

Closes MyIntervals#994.

* [CLEANUP] Avoid negated non-Boolean in `RuleSet` (MyIntervals#1246)

Use `=== null` instead to be more precise.

* [TASK] Deprecate passing `Rule` to `RuleSet::getRules()` (MyIntervals#1248)

And also `getRulesAssoc()`.

Relates to MyIntervals#1247.

* [Dependabot] Update phpunit/phpunit requirement from 8.5.41 to 8.5.42 (MyIntervals#1250)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.42/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.41...8.5.42)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.42
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [TASK] Add separate methods for `RuleSet::removeRule()`, with deprecation (MyIntervals#1249)

Passing `string` or `null` to `removeRule()` is deprecated.
The new method handles that functionality.

Relates to MyIntervals#1247.

* [CLEANUP] Use `RuleSet::removeMatchingRules()` in tests (MyIntervals#1254)

Now this method has been added, using it appropriately in the tests,
rather than the deprecated functionality, will eliminate a PHPStan warning.

Note that PHPStan seems to erroneously place the warning against the callee
rather than the caller.

* [TASK] Drop allowing `Rule` to be passed to `RuleSet::getRules()` (MyIntervals#1253)

... and `getRulesAssoc()`.

Relates to MyIntervals#1247.

* [TASK] Allow only `Rule` to be passed to `RuleSet::removeRule()` (MyIntervals#1255)

Relates to MyIntervals#1247.

* [CLEANUP] Check for `Positionable` in `lineNumbersParsing()` test (MyIntervals#1257)

Now the interface has been added,
it is no longer necessary to check the object is one of a long list of types.

Also use the new `getLineNumber()` instead of the deprecated `getLineNo()`.

* [TASK] Add interface `RuleContainer` for `RuleSet` (MyIntervals#1256)

This covers the maniplation of `Rule`s within the container,
and may be implemented by other classes in future (e.g. MyIntervals#1194).

Note that the naming is consistent with the current codebase,
rather than what the CSS entities are now called:
- `Rule` represents what is now called a "declaration";
- `RuleSet` represents what is now called a "declaration block";
- `DeclarationBlock` represents what is now called a "style rule";
- `CSSListItem` (closely) represents what is now generically called a "rule".

Renaming things is part of a longer-term plan touched on in MyIntervals#1189.

* [TASK] Have `setPosition()` implement fluent interface (MyIntervals#1259)

This will aid writing tests for `RuleSet`.

Note that the PHP type annotation cannot be `self` because an interface is
involved and PHP 7 is still supported.

Part of MyIntervals#974.

* [BUGFIX] Don't return objects from data providers (MyIntervals#1260)

The same objects may be provided to multiple tests.
If a test manipulates an object,
it will no longer be in the initial expected state for other tests.

* [TASK] Add tests for `RuleSet::addRule()` without sibling argument (MyIntervals#1261)

Some are currently skipped, pending some minor bug fixes.

* [BUGFIX] Ensure column number set after `RuleSet::addRule()` (MyIntervals#1263)

Note that this bug (or inconsistency) only occurs following the addtion of
`getColumnNumber()` returning a nullable `int` (MyIntervals#1221 and MyIntervals#1225).
These changes are not yet included in any release.

Part of MyIntervals#974.

* [BUGFIX] Ensure valid position for first `Rule` added to `RuleSet` (MyIntervals#1262)

Part of MyIntervals#974.

* [BUGFIX] Set line number for `AddRule()` with only column number (MyIntervals#1265)

Continue to preserve the column number.
Also tighten the test to confirm the `Rule` is added at the end.

Note that the reason for `markTestSkipped()` was incorrect - the line number
was not being set at all.

Part of MyIntervals#974.

* [TASK] Add tests for `addRule()` with a sibling (MyIntervals#1266)

Some tests are skipped pending bug fixes.

Part of MyIntervals#974.

* [BUGFIX] Ensure non-negative column number in `RuleSet` (MyIntervals#1268)

When inserting a `Rule` before a sibling, increment the column number of
other `Rule`s, instead of assigning a lower column number.

Part of MyIntervals#974.

* [CLEANUP] Extract method `RuleSet::comparePositionable` (MyIntervals#1272)

As well as being used with `usort()`, it may have other uses.

The deprecated `getLineNo()` and `getColNo()` are still used for now.
Replacing these will be done separately.

Relates to MyIntervals#974.

* [BUGFIX] `AddRule` before sibling with different property name (MyIntervals#1270)

Part of MyIntervals#974.

* [TASK] Add unit tests for `RuleSet::removeRule` (MyIntervals#1273)

This re-uses some data providers, which have been renamed to reflect their
more generic usage.
Also, the PHPDoc type has been tightened to `non-empty-list` where applicable.

Part of MyIntervals#974.

* [CLEANUP] Separate some test methods in `RuleSetTest` (MyIntervals#1274)

These were previously testing more than one aspect of a `RuleSet` method.
Now each behaviour has a dedicated test method (albeit with some duplication
of the set-up).

Also added an additional assertion when there are no expected remaining items
following removal, so that an assertion is made.

* [DOCS] Switch to the new CoC email address (MyIntervals#1275)

* [TASK] Add unit tests for `RuleSet::setRules` (MyIntervals#1276)

Also rename a data provider to indicate its (now) more generic purpose.

* [TASK] Add unit tests for `RuleSet::getRules` (MyIntervals#1277)

Part of MyIntervals#974.

* [TASK] Add tests for `RuleSet::getRules` with `$searchPattern` (MyIntervals#1278)

Part of MyIntervals#974.

* [TASK] Add unit tests for `RuleSet::getRulesAssoc` (MyIntervals#1279)

Part of MyIntervals#974.

* [CLEANUP] Split data provider for search pattern (MyIntervals#1281)

A separate data provider now provides patterns which don't match any property
names, and a separate test caters for the non-matching situation.

* [TASK] Add tests for `RuleSet::getRulesAssoc` with `$searchPattern` (MyIntervals#1280)

Part of MyIntervals#974.

* [CLEANUP] Streamline tests for `getRules` with matching pattern (MyIntervals#1282)

Combine two tests into one, by asserting an exact set match,
instead of two-way subset matches.

* [TASK] Update `RuleSet::addRule` to use `getLineNumber` (MyIntervals#1284)

Part of MyIntervals#974

* [TASK] Update `RuleSet::comparePositionable` to use new methods (MyIntervals#1283)

`getLineNo` and `getColNo` are deprecated.
When the titled method was extracted, use of the above-mentioned methods was
retained to ease backporting and transition to their replacement counterparts:
`getLineNumber` and `getColumnNumber`,
which differ by returning `null` in the case of 'not set'.

This replaces all instances of calls to `getColNo`.

Part of MyIntervals#974

* [TASK] Add tests for `getLineNumber` (MyIntervals#1286)

These correspond to the existing tests for `getLineNo` for classes that
implement `Positionable`.

Also correct an existing test method name to refer to `getLineNo`.

* [TASK] Use `getLineNumber` in `ParserTest` (MyIntervals#1285)

`getLineNo` is deprecated and will be removed.

Part of MyIntervals#974

* [TASK] Remove `getColNo()` (MyIntervals#1287)

Note that the removed tests are in `UnitDeprecated`.
Equivalent tests already exist for the replacement `getColumnNumber()`.

Part of MyIntervals#974

* [TASK] Set line number to `null` by default (MyIntervals#1288)

No longer allow or support `0` as a default line or column number.

Part of MyIntervals#974

* [TASK] Remove `getLineNo()` (MyIntervals#1258)

Closes MyIntervals#974.

* [BUGFIX] Exclude absent line number from exception message (MyIntervals#1290)

The bug was introduced by MyIntervals#1288, so has not been included in any release;
thus a changelog entry is not justified.

* [TASK] Add `RuleContainerTest` trait, use in `RuleSetTest` (MyIntervals#1291)

The trait provides tests for classes implementing `RuleContainer`.
The test methods and data providers have been moved verbatim to the trait from
`RuleSetTest`.

Will be needed for MyIntervals#1194

* [BUGFIX] Allow comma in selectors (MyIntervals#1293)

Also add a note that the specificity is incorrectly calculated in such cases.
This will be addressed with a separate fix.

* [CLEANUP] Tidy up `DeclarationBlock::parse()` (MyIntervals#1294)

- Assign the result of `ParserState::peek()` to a local variable, for
  efficiency;
- Use a switch statement to branch on its value, for extensibility (e.g.
  MyIntervals#1292);
- Don't unnecessarily test that a quote character is not escaped when not
  within a string.

* [TASK] Add `assertInstanceOf` tests for `DeclarationBlock` (MyIntervals#1295)

* [BUGFIX] Correct an exception message (MyIntervals#1296)

This correction is not worthy of a changelog entry or any tests.

* [CLEANUP] Avoid spaces before colons in the Mermaid code (MyIntervals#1300)

* [CLEANUP] Order class names in the class diagram alphabetically (MyIntervals#1299)

* [DOCS] Fix class list in class diagram (MyIntervals#1301)

- adapt the sorting to how the diagram generator sorts
- add `SpecificityCalculator` which had been missing

* [DOCS] Remove cardinalities from the class diagram (MyIntervals#1303)

This brings our class diagram closer to what the latest version
of the diagram generator creates.

* [DOCS] Make the class diagram markers generator-friendly (MyIntervals#1302)

This is in preparation for adding a script for generating
the class diagram in MyIntervals#1297.

* [DOCS] Change some arrow types in the class diagram (MyIntervals#1304)

* [DOCS] Label dependencies in the class diagram as such (MyIntervals#1305)

This corresponds to what the latest version of our diagram
generator does.

* [DOCS] Temporarily drop some markers from the class diagram (MyIntervals#1307)

As long as we manually edit the source of the class diagram,
having markers for a part being autogenerated does not make
sense.

* [DOCS] Reorder some lines in the class diagram (part 1) (MyIntervals#1306)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 2) (MyIntervals#1308)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 3) (MyIntervals#1309)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 4) (MyIntervals#1310)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 5) (MyIntervals#1311)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 6) (MyIntervals#1312)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 7) (MyIntervals#1313)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 8) (MyIntervals#1314)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 9) (MyIntervals#1315)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 10) (MyIntervals#1316)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 11) (MyIntervals#1317)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 12) (MyIntervals#1318)

This is in preparation for MyIntervals#1298.

* [DOCS] Reorder some lines in the class diagram (part 13) (MyIntervals#1319)

This is in preparation for MyIntervals#1298.

* [CLEANUP] Use static variable for stop characters (MyIntervals#1321)

... in `DeclarationBlock::parse()`.

This improves readability in preparation for MyIntervals#1292 which will extend the list.
(It may also slightly improve performance.)

* [TASK] Add unit tests for selector parsing (MyIntervals#1322)

The tests broadly cover what currently works, and will be extended to cover
the fixes in MyIntervals#1292.

* [BUGFIX] Allow comma in quoted string in selector (MyIntervals#1323)

Split by commas during parsing, not after.

* [BUGFIX] Allow comma-separated arguments in selectors (MyIntervals#1292)

Fixes MyIntervals#138.
Fixes MyIntervals#360.
Fixes MyIntervals#1289.

* [TASK] Update the development tools (MyIntervals#786)

* [DOCS] Integrate the 8.9.0 changelog into main changelog (MyIntervals#1329)

This way, the upcoming 9.0.0 release won't have changes
in the changelog that already are part of the 8.9.0 changelog.

* [TASK] Raise PHPStan to level 4 (MyIntervals#1201)

Also allow `assertInstanceOf` checks in the tests (as we find
those useful).

* [TASK] Use strict equality (MyIntervals#1331)

One instance is left out, but is covered by MyIntervals#1330.

* [TASK] Make Boolean tests explicit (MyIntervals#1332)

* [CLEANUP] Remove superfluous Rector rule (MyIntervals#1333)

Since MyIntervals#1201, this becomes a duplicate.

* [TASK] Add tests for `removeDeclarationBlockBySelector()` (MyIntervals#1335)

* [CLEANUP] Avoid use of short-ternary operator (MyIntervals#1336)

(I share a birthday with Elvis, but needs must.)

* [CLEANUP] Remove impossible conditional (MyIntervals#1337)

The parameter `$parserState` is specified to be a `ParserState`, so it can
never be a string.

* [BUGFIX] Correct DocBlock for `ParserState::consumeUntil()` (MyIntervals#1338)

The special `EOF` constant is actually defined as `null`, so the stop
characters may be strings or `null`.

* [BUGFIX] Provide the authentication token for PHIVE on CI (MyIntervals#1340)

This will hopefully avoid the 403 errors when installing the
PHIVE packages.

Fixes MyIntervals#1339

* [TASK] Make `RuleSet` concrete (MyIntervals#1341)

... adding internal `render` method.

Precursor to MyIntervals#1194.

* [CLEANUP] Update `RuleSet` DocBlock (MyIntervals#1343)

... to be consistent with the class now being concrete.

Missed in MyIntervals#1341.

* [CLEANUP] Reorder `use`s in `DeclarationBlockTest` (MyIntervals#1344)

Order alphabetically.

* [BUGFIX] Remove trailing semicolon with compact format (MyIntervals#1345)

Fixes MyIntervals#1342.

* [CLEANUP] Use `getAllDeclarationBlocks` in `colorParsing` test (MyIntervals#1346)

... instead of `getAllRuleSets`.

This avoids testing if `RuleSet`s are `DeclarationBlock`s, and will be needed
for MyIntervals#1194.

* [TASK] Add tests for `RuleSet` constructor (MyIntervals#1348)

* [BUGFIX] Correct an `assert` added in MyIntervals#1348 (MyIntervals#1349)

* [TASK] Add tests for `DeclarationBlock` constructor (MyIntervals#1350)

The class extends `RuleSet`, but the constructor behaviour needs to be tested
for each class.

* [TASK] Test `RuleSet` constructor with `null` explicitly passed (MyIntervals#1351)

* [BUGFIX] Update class diagram to show `RuleSet` as concrete (MyIntervals#1352)

Missed in MyIntervals#1341.

* [TASK] Use delegation for `DeclarationBlock` -> `RuleSet` (MyIntervals#1194)

... rather than inheritance.

This will allow `DeclarationBlock` to instead extend `CSSBlockList` in order
to support
[CSS nesting](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting).

This is a slightly-breaking change, since now `CSSBlockList::getAllRuleSets()`
will include the `RuleSet` property of the `DeclarationBlock` instead of the
`DeclarationBlock` itself.

Part of MyIntervals#1170.

* [TASK] Update the development tools (MyIntervals#1334)

* [TASK] Prepare release of version 9.0.0 (MyIntervals#1328)

Closes MyIntervals#1326

* [DOCS] Correct `}` to `)` in changelog (MyIntervals#1354)

* [TASK] Raise PHPStan to level 5 (MyIntervals#1356)

* [CLEANUP] Ignore warnings for explicitly invalid values in tests (MyIntervals#1358)

* [Dependabot] Update phpunit/phpunit requirement from 8.5.42 to 8.5.43 (MyIntervals#1360)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.43/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.42...8.5.43)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.43
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [Dependabot] Bump actions/checkout from 4 to 5 (MyIntervals#1361)

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [Dependabot] Update phpunit/phpunit requirement from 8.5.43 to 8.5.44 (MyIntervals#1362)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.44/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.43...8.5.44)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.44
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [TASK] Raise PHPStan to level 6 (MyIntervals#1364)

* [TASK] Add `thecodingmachine/safe` (#1453) (MyIntervals#1366)

Safe-PHP https://github.com/thecodingmachine/safe provides
rewrites of PHP functions to throw an exception instead of
returning `false` when an error is encountered.

This will allow us to drop out custom `preg_*` wrapper class
and to increase type safety in our codebase.

Also drop the PHP-CS-Fixer rule that adds a trailing backslash
to calls to native PHP functions (as this would change the
Safe-PHP calls back to their unsafe versions).

The actual code changes will come in subsequent commits.

Part of MyIntervals#1168

* [BUGFIX] Use the safe `file_get_contents` in `quickdump.php` (MyIntervals#1367)

* [BUGFIX] Use the safe regexp functions in `CSSList` (MyIntervals#1368)

* [CLEANUP] Avoid Hungarian notation in `quickdump.php` (MyIntervals#1369)

* [BUGFIX] Use the safe regexp functions in `ParserState` (MyIntervals#1370)

Part of MyIntervals#1168

* [BUGFIX] Improve selector validation performance (MyIntervals#1372)

Avoid [catastrophic backtracking](https://www.regular-expressions.info/catastrophic.html)
in selector validation regular expression by using possessive quantifier with
mutually exclusive alternations.

Also remove outdated description from DocBlock,
but add description for extended class summarizing differences.

* [BUGFIX] Use the safe regexp functions in `Selector` (MyIntervals#1371)

Part of MyIntervals#1168

* [BUGFIX] Use safe `file_get_contents` in `LenientParsingTest` (MyIntervals#1373)

Part of MyIntervals#1168

* [Dependabot] Update phpunit/phpunit requirement from 8.5.44 to 8.5.45 (MyIntervals#1375)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.45/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.44...8.5.45)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.45
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [TASK] Update the development tools (MyIntervals#1353)

* [FEATURE] Add support for PHP 8.5 (MyIntervals#1355)

* [TASK] Prepare release of version 9.1.0 (MyIntervals#1376)

* [Dependabot] Update phpunit/phpunit requirement from 8.5.45 to 8.5.46 (MyIntervals#1377)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.46/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.45...8.5.46)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.46
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [BUGFIX] Use safe file functions in `ParserTest` (MyIntervals#1378)

Part of MyIntervals#1168

* [BUGFIX] Use safe preg functions in `Value` (MyIntervals#1379)

Also use typesafe comparisons in the affected line.

Part of MyIntervals#1168

* [BUGFIX] Use safe preg functions in `Size` (MyIntervals#1380)

Also use typesafe comparisons in the affected line.

Part of MyIntervals#1168

* [BUGFIX] Use safe preg functions in `CSSString` (MyIntervals#1382)

Part of MyIntervals#1168

* [BUGFIX] Use safe preg functions in `Rule` (MyIntervals#1383)

Part of MyIntervals#1168

* [BUGFIX] Use safe preg functions in `SpecificityCalculator` (MyIntervals#1384)

Part of MyIntervals#1168

* [TASK] Add PHPStan rules for Safe-PHP (MyIntervals#1385)

This will prevent unsafe function usage from getting added.

Closes MyIntervals#1168

* [Dependabot] Update phpunit/phpunit requirement from 8.5.46 to 8.5.47 (MyIntervals#1386)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.47/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.46...8.5.47)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.47
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [Dependabot] Update phpunit/phpunit requirement from 8.5.47 to 8.5.48 (MyIntervals#1387)

Updates the requirements on [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) to permit the latest version.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/8.5.48/ChangeLog-8.5.md)
- [Commits](sebastianbergmann/phpunit@8.5.47...8.5.48)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 8.5.48
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Oliver Klee <github@oliverklee.de>
Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants