Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/css-selector
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.4.3
Choose a base ref
...
head repository: symfony/css-selector
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7.2
Choose a head ref

Commits on May 19, 2021

  1. Copy the full SHA
    447944d View commit details

Commits on May 26, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Fix CS in README files
      Fix markdown
      [HttpKernel] Fixes tests for PHP7.4+
      fix test
      [HttpKernel] Throw when HttpKernel is created and the env is empty
      [FrameworkBundle] Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
      [Filesystem] fix readlink for Windows
    nicolas-grekas committed May 26, 2021
    Copy the full SHA
    4ca626a View commit details

Commits on May 28, 2021

  1. Copy the full SHA
    e3a55cd View commit details

Commits on Jun 2, 2021

  1. Copy the full SHA
    d289f5d View commit details

Commits on Jun 29, 2021

  1. Add union types

    nicolas-grekas committed Jun 29, 2021
    Copy the full SHA
    d8206f5 View commit details

Commits on Jul 5, 2021

  1. [CssSelector] Add types to private properties

    Signed-off-by: Alexander M. Turek <me@derrabus.de>
    derrabus committed Jul 5, 2021
    Copy the full SHA
    4742e79 View commit details

Commits on Jul 21, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Leverage str_contains/str_starts_with
      Leverage str_ends_with
    nicolas-grekas committed Jul 21, 2021
    Copy the full SHA
    5fd56a0 View commit details

Commits on Aug 12, 2021

  1. Copy the full SHA
    8a7b08e View commit details

Commits on Aug 17, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Serializer] cs fix
      Cleanup more `@return` annotations
      [Form] Fix phpdoc on FormBuilderInterface
    nicolas-grekas committed Aug 17, 2021
    Copy the full SHA
    a627373 View commit details

Commits on Sep 9, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [DoctrineBridge] Remove dead code
      [Lock] Remove unused variable
      [DoctrineBridge] Replace string with FQCN resolution in EntityType
      Add missing `@return $this` annotations
      [Notifier] Add missing types to SmscTransport
    nicolas-grekas committed Sep 9, 2021
    Copy the full SHA
    00849ec View commit details
  2. Fix return types

    nicolas-grekas committed Sep 9, 2021
    Copy the full SHA
    3a61e2e View commit details

Commits on Dec 8, 2021

  1. Copy the full SHA
    ede53ca View commit details

Commits on Dec 16, 2021

  1. [6.0] cs fixes

    nicolas-grekas committed Dec 16, 2021
    Copy the full SHA
    380f86c View commit details
  2. Merge branch '6.0' into 6.1

    * 6.0:
      [6.0] cs fixes
      [5.4] cs fixes
      [5.3] cs fixes
      [Cache] Fix saving items with no expiration through ProxyAdapter
      CS fixes
      fix merge
      Remove pointless assignment
      [HttpClient] Fix tracing requests made after calling withOptions()
      [Cache] disable lock on CLI
      Revert "feature #41989 [Cache] make `LockRegistry` use semaphores when possible (nicolas-grekas)"
      [HttpKernel] fix how configuring log-level and status-code by exception works
      [VarDumper] add more "transient-on-macos" groups
    nicolas-grekas committed Dec 16, 2021
    Copy the full SHA
    235e1bb View commit details
  3. Copy the full SHA
    7be7e43 View commit details

Commits on Jan 2, 2022

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Bump license year
      Bump license year
      [Validator] Error using CssColor with doctrine annotations
      [HttpClient] Turn negative timeout to a very long timeout
      Features goes to 6.x branch
      [Translation] [LocoProvider] Fix use of asset ids
      fix lowest required PropertyInfo component release
      [Validator] throw when Constraint::_construct() has not been called
      Bump Symfony version to 5.4.3
      Update VERSION for 5.4.2
      Update CHANGELOG for 5.4.2
      Bump Symfony version to 5.3.14
      Update VERSION for 5.3.13
      Update CHANGELOG for 5.3.13
      Bump Symfony version to 4.4.37
      Update VERSION for 4.4.36
      Update CONTRIBUTORS for 4.4.36
      Update CHANGELOG for 4.4.36
      Allow symfony/runtime plugin
    fabpot committed Jan 2, 2022
    Copy the full SHA
    1955d59 View commit details
  2. Merge branch '6.0' into 6.1

    * 6.0: (22 commits)
      Bump license year
      Bump license year
      [Validator] Error using CssColor with doctrine annotations
      [HttpClient] Turn negative timeout to a very long timeout
      Features goes to 6.x branch
      [Translation] [LocoProvider] Fix use of asset ids
      fix lowest required PropertyInfo component release
      [Validator] throw when Constraint::_construct() has not been called
      Bump Symfony version to 6.0.3
      Update VERSION for 6.0.2
      Update CHANGELOG for 6.0.2
      Bump Symfony version to 5.4.3
      Update VERSION for 5.4.2
      Update CHANGELOG for 5.4.2
      Bump Symfony version to 5.3.14
      Update VERSION for 5.3.13
      Update CHANGELOG for 5.3.13
      Bump Symfony version to 4.4.37
      Update VERSION for 4.4.36
      Update CONTRIBUTORS for 4.4.36
      ...
    fabpot committed Jan 2, 2022
    Copy the full SHA
    f2bc51d View commit details

Commits on Feb 25, 2022

  1. Bump minimum version of PHP to 8.1

    nicolas-grekas authored and fabpot committed Feb 25, 2022
    Copy the full SHA
    05c40f0 View commit details

Commits on Jun 27, 2022

  1. CS fixes

    nicolas-grekas committed Jun 27, 2022
    Copy the full SHA
    bd0a673 View commit details
  2. Merge branch '4.4' into 5.4

    * 4.4:
      CS fixes
      Bump Symfony version to 4.4.44
      Update VERSION for 4.4.43
      Update CONTRIBUTORS for 4.4.43
      Update CHANGELOG for 4.4.43
    nicolas-grekas committed Jun 27, 2022
    Copy the full SHA
    c168178 View commit details
  3. Merge branch '5.4' into 6.0

    * 5.4:
      CS fixes
      Bump Symfony version to 5.4.11
      Update VERSION for 5.4.10
      Update CHANGELOG for 5.4.10
      Bump Symfony version to 4.4.44
      Update VERSION for 4.4.43
      Update CONTRIBUTORS for 4.4.43
      Update CHANGELOG for 4.4.43
    nicolas-grekas committed Jun 27, 2022
    Copy the full SHA
    ab2746a View commit details
  4. Merge branch '6.0' into 6.1

    * 6.0:
      CS fixes
      Bump Symfony version to 6.0.11
      Update VERSION for 6.0.10
      Update CHANGELOG for 6.0.10
      Bump Symfony version to 5.4.11
      Update VERSION for 5.4.10
      Update CHANGELOG for 5.4.10
      Bump Symfony version to 4.4.44
      Update VERSION for 4.4.43
      Update CONTRIBUTORS for 4.4.43
      Update CHANGELOG for 4.4.43
    nicolas-grekas committed Jun 27, 2022
    Copy the full SHA
    0dd5e36 View commit details

Commits on Aug 25, 2022

  1. [CS] Remove @inheritdoc PHPDoc

    lyrixx committed Aug 25, 2022
    Copy the full SHA
    021fd05 View commit details

Commits on Aug 26, 2022

  1. Copy the full SHA
    b4491ac View commit details
  2. minor #47390 [CS] Remove @inheritdoc PHPDoc (lyrixx)

    This PR was merged into the 6.2 branch.
    
    Discussion
    ----------
    
    [CS] Remove `@inheritdoc` PHPDoc
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.2
    | Bug fix?      | no
    | New feature?  | no
    | Deprecations? | no
    | Tickets       |
    | License       | MIT
    | Doc PR        |
    
    ---
    
    It looks like this PHP Doc is useless. IDEs are able to inherit the doc (at least VS Code
    and PHP Storm). And tools like PHP Stan are able to too https://phpstan.org/r/74a2c008-ff2b-42c0-8edf-8da87c1a7b5f
    
    I could have open an RFC before doing the PR, but it was easy :) So let's discuss here
    
    Commits
    -------
    
    015d5015e3 [CS] Remove `@inheritdoc` PHPDoc
    fabpot committed Aug 26, 2022
    Copy the full SHA
    91c342f View commit details

Commits on Dec 23, 2022

  1. Copy the full SHA
    052ef49 View commit details

Commits on Dec 28, 2022

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Console] Correctly overwrite progressbars with different line count per step
      [DependencyInjection] Fix deduplicating service instances in circular graphs
      [Form] Make `ButtonType` handle `form_attr` option
      [PhpUnitBridge] Use verbose deprecation output for quiet types only when it reaches the threshold
      [CssSelector] Fix escape patterns
    nicolas-grekas committed Dec 28, 2022
    Copy the full SHA
    3e526b7 View commit details
  2. Merge branch '6.0' into 6.1

    * 6.0:
      [Console] Correctly overwrite progressbars with different line count per step
      [DependencyInjection] Fix deduplicating service instances in circular graphs
      [Form] Make `ButtonType` handle `form_attr` option
      [PhpUnitBridge] Use verbose deprecation output for quiet types only when it reaches the threshold
      [CssSelector] Fix escape patterns
    nicolas-grekas committed Dec 28, 2022
    Copy the full SHA
    a90ee25 View commit details
  3. Merge branch '6.1' into 6.2

    * 6.1:
      [Console] Correctly overwrite progressbars with different line count per step
      [DependencyInjection] Fix deduplicating service instances in circular graphs
      [Form] Make `ButtonType` handle `form_attr` option
      [PhpUnitBridge] Use verbose deprecation output for quiet types only when it reaches the threshold
      [CssSelector] Fix escape patterns
    nicolas-grekas committed Dec 28, 2022
    Copy the full SHA
    ab1df4b View commit details

Commits on Jan 1, 2023

  1. Bump license year to 2023

    fabpot committed Jan 1, 2023
    Copy the full SHA
    f4a7d15 View commit details
  2. Merge branch '5.4' into 6.0

    * 5.4:
      Fix LICENSE year
      Bump license year to 2023
    fabpot committed Jan 1, 2023
    Copy the full SHA
    f1d00bd View commit details
  3. Merge branch '6.0' into 6.1

    * 6.0:
      Fix LICENSE year
      Bump license year to 2023
    fabpot committed Jan 1, 2023
    Copy the full SHA
    750a731 View commit details
  4. Merge branch '6.1' into 6.2

    * 6.1:
      Bump LICENSE year
      Fix LICENSE year
      Bump license year to 2023
    fabpot committed Jan 1, 2023
    Copy the full SHA
    bf1b9d4 View commit details

Commits on Jan 13, 2023

  1. Copy the full SHA
    952d70d View commit details
  2. minor #48793 Leverage arrow function syntax for closure (tigitz)

    This PR was merged into the 6.3 branch.
    
    Discussion
    ----------
    
    Leverage arrow function syntax for closure
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.3
    | Bug fix?      | no
    | New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
    | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
    | Tickets       | Fix #47658 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
    | License       | MIT
    | Doc PR        | <!-- required for new features -->
    
    Rationale in the RFC [here](https://wiki.php.net/rfc/arrow_functions_v2#introduction)
    
    It's also notable that using arrow function syntax rather than the classic one has been enforced in the past by symfony core member: symfony/symfony#48069 (comment)
    
    So this PR would be consistent.
    
    Commits
    -------
    
    f5802d3a2a Leverage arrow function syntax for closure
    nicolas-grekas committed Jan 13, 2023
    Copy the full SHA
    9136206 View commit details

Commits on Jan 24, 2023

  1. Copy the full SHA
    162786d View commit details

Commits on Feb 2, 2023

  1. Merge branch '5.4' into 6.2

    * 5.4:
      Fix LICENSE CI check
      fixes retrieving multiple values for extra fields
      [String] Remove duplicates in fold maps
      fail with a meaningful error when a needed package is missing
      [DependencyInjection] Fix combinatory explosion when autowiring union and intersection types
      Update license years (last time)
      [Tests] New iteration of removing `$this` occurrences in future static data providers
    fabpot committed Feb 2, 2023
    Copy the full SHA
    bbac8cc View commit details
  2. Merge branch '6.2' into 6.3

    * 6.2:
      Fix LICENSE year
      Fix LICENSE CI check
      [Notifier] Mention Prisma Media as backer of v6.2
      fixes retrieving multiple values for extra fields
      Clarifies when to update UPGRADE-7.0.md
      [String] Remove duplicates in fold maps
      fail with a meaningful error when a needed package is missing
      [6.2] Remove mentions of v6.1 backers
      [Translation] Crowdin renewed their sponsorship for v6.2
      [DependencyInjection] Fix combinatory explosion when autowiring union and intersection types
      Update license years (last time)
      [Tests] New iteration of removing `$this` occurrences in future static data providers
    fabpot committed Feb 2, 2023
    Copy the full SHA
    eb4dc72 View commit details

Commits on Feb 6, 2023

  1. Copy the full SHA
    e61859c View commit details
  2. Merge branch '5.4' into 6.2

    * 5.4:
      [Serializer] Fix CsvEncoder decode on empty data
      [Tests] Migrate data providers to static ones
      stop using assertObjectHasAttribute()/assertObjectHasNotAttribute()
      [Dotenv] Fix phpdoc Dotenv
      [Config] Fix phpdoc nullable
      Fix some typos
    nicolas-grekas committed Feb 6, 2023
    Copy the full SHA
    4a405b2 View commit details

Commits on Feb 7, 2023

  1. Copy the full SHA
    36cd558 View commit details
  2. minor #49253 [PHPUnit 10] Use TestCase suffix for abstract tests in…

    … `/Tests/` (OskarStark)
    
    This PR was merged into the 6.3 branch.
    
    Discussion
    ----------
    
    [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/`
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.3
    | Bug fix?      | no
    | New feature?  | no
    | Deprecations? | no
    | Tickets       | Refs symfony/symfony#49233
    | License       | MIT
    | Doc PR        | n/a
    
    Replaces #49234
    
    Using `Test` suffix is deprecated since PHPUnit 10
    
    Spotted in
    * symfony/symfony#49233
    
    Commits
    -------
    
    cb3db968e4 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/`
    nicolas-grekas committed Feb 7, 2023
    Copy the full SHA
    66d6be3 View commit details
  3. Merge branch '5.4' into 6.2

    * 5.4:
      minor #49253 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` (OskarStark)
    nicolas-grekas committed Feb 7, 2023
    Copy the full SHA
    7cb4a07 View commit details
  4. Merge branch '6.2' into 6.3

    * 6.2:
      minor #49253 [PHPUnit 10] Use `TestCase` suffix for abstract tests in `/Tests/` (OskarStark)
      [Intl] Generate all emoji short name returned by slack api
      [Serializer] Fix CsvEncoder decode on empty data
      [Tests] Migrate data providers to static ones
      stop using assertObjectHasAttribute()/assertObjectHasNotAttribute()
      [Cache] Fix Redis proxies
      [Dotenv] Fix phpdoc Dotenv
      [Config] Fix phpdoc nullable
      Replace deprecated/removed way to configure enabled_locales
      fix typo
      Fix some typos
    nicolas-grekas committed Feb 7, 2023
    Copy the full SHA
    cda0fa7 View commit details

Commits on Feb 13, 2023

  1. Copy the full SHA
    5436c3d View commit details
  2. Add void return types

    wouterj authored and nicolas-grekas committed Feb 13, 2023
    Copy the full SHA
    275d858 View commit details

Commits on Feb 14, 2023

  1. Copy the full SHA
    95f3c74 View commit details
  2. Merge branch '5.4' into 6.2

    * 5.4:
      Migrate to `static` data providers using `rector/rector`
    nicolas-grekas committed Feb 14, 2023
    Copy the full SHA
    aedf3cb View commit details
  3. Merge branch '6.2' into 6.3

    * 6.2:
      Fix merge
      Migrate to `static` data providers using `rector/rector`
    nicolas-grekas committed Feb 14, 2023
    Copy the full SHA
    efc0747 View commit details

Commits on Mar 20, 2023

  1. Copy the full SHA
    88453e6 View commit details
Showing with 744 additions and 580 deletions.
  1. +1 −2 .gitattributes
  2. +8 −0 .github/PULL_REQUEST_TEMPLATE.md
  3. +20 −0 .github/workflows/close-pull-request.yml
  4. +11 −0 CHANGELOG.md
  5. +6 −8 CssSelectorConverter.php
  6. +13 −23 Exception/SyntaxErrorException.php
  7. +1 −1 LICENSE
  8. +2 −9 Node/AbstractNode.php
  9. +9 −18 Node/AttributeNode.php
  10. +5 −11 Node/ClassNode.php
  11. +6 −13 Node/CombinedSelectorNode.php
  12. +5 −11 Node/ElementNode.php
  13. +8 −14 Node/FunctionNode.php
  14. +5 −11 Node/HashNode.php
  15. +55 −0 Node/MatchingNode.php
  16. +5 −11 Node/NegationNode.php
  17. +1 −3 Node/NodeInterface.php
  18. +6 −9 Node/PseudoNode.php
  19. +6 −9 Node/SelectorNode.php
  20. +5 −9 Node/Specificity.php
  21. +49 −0 Node/SpecificityAdjustmentNode.php
  22. +0 −3 Parser/Handler/CommentHandler.php
  23. +4 −10 Parser/Handler/HashHandler.php
  24. +4 −10 Parser/Handler/IdentifierHandler.php
  25. +3 −8 Parser/Handler/NumberHandler.php
  26. +5 −11 Parser/Handler/StringHandler.php
  27. +0 −3 Parser/Handler/WhitespaceHandler.php
  28. +52 −20 Parser/Parser.php
  29. +9 −13 Parser/Reader.php
  30. +0 −3 Parser/Shortcut/ClassParser.php
  31. +0 −3 Parser/Shortcut/ElementParser.php
  32. +0 −3 Parser/Shortcut/EmptyStringParser.php
  33. +0 −3 Parser/Shortcut/HashParser.php
  34. +9 −13 Parser/Token.php
  35. +8 −19 Parser/TokenStream.php
  36. +1 −1 Parser/Tokenizer/Tokenizer.php
  37. +3 −5 Parser/Tokenizer/TokenizerEscaping.php
  38. +17 −17 Parser/Tokenizer/TokenizerPatterns.php
  39. +2 −3 Tests/CssSelectorConverterTest.php
  40. +3 −3 Tests/Node/{AbstractNodeTest.php → AbstractNodeTestCase.php}
  41. +3 −3 Tests/Node/AttributeNodeTest.php
  42. +3 −3 Tests/Node/ClassNodeTest.php
  43. +3 −3 Tests/Node/CombinedSelectorNodeTest.php
  44. +3 −3 Tests/Node/ElementNodeTest.php
  45. +3 −3 Tests/Node/FunctionNodeTest.php
  46. +3 −3 Tests/Node/HashNodeTest.php
  47. +48 −0 Tests/Node/MatchingNodeTest.php
  48. +3 −3 Tests/Node/NegationNodeTest.php
  49. +3 −3 Tests/Node/PseudoNodeTest.php
  50. +3 −3 Tests/Node/SelectorNodeTest.php
  51. +44 −0 Tests/Node/SpecificityAdjustmentNodeTest.php
  52. +2 −2 Tests/Node/SpecificityTest.php
  53. +3 −4 Tests/Parser/Handler/{AbstractHandlerTest.php → AbstractHandlerTestCase.php}
  54. +3 −3 Tests/Parser/Handler/CommentHandlerTest.php
  55. +3 −3 Tests/Parser/Handler/HashHandlerTest.php
  56. +3 −3 Tests/Parser/Handler/IdentifierHandlerTest.php
  57. +3 −3 Tests/Parser/Handler/NumberHandlerTest.php
  58. +3 −3 Tests/Parser/Handler/StringHandlerTest.php
  59. +3 −3 Tests/Parser/Handler/WhitespaceHandlerTest.php
  60. +43 −11 Tests/Parser/ParserTest.php
  61. +0 −1 Tests/Parser/ReaderTest.php
  62. +1 −1 Tests/Parser/Shortcut/ClassParserTest.php
  63. +1 −1 Tests/Parser/Shortcut/ElementParserTest.php
  64. +1 −1 Tests/Parser/Shortcut/HashParserTest.php
  65. +6 −4 Tests/Parser/TokenStreamTest.php
  66. +5 −1 Tests/XPath/Fixtures/ids.html
  67. +51 −20 Tests/XPath/TranslatorTest.php
  68. +0 −15 XPath/Extension/AbstractExtension.php
  69. +15 −21 XPath/Extension/AttributeMatchingExtension.php
  70. +4 −10 XPath/Extension/CombinationExtension.php
  71. +11 −17 XPath/Extension/FunctionExtension.php
  72. +10 −19 XPath/Extension/HtmlExtension.php
  73. +49 −25 XPath/Extension/NodeExtension.php
  74. +15 −15 XPath/Extension/PseudoClassExtension.php
  75. +20 −26 XPath/Translator.php
  76. +12 −16 XPath/XPathExpr.php
  77. +1 −2 composer.json
  78. +10 −10 phpunit.xml.dist
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.git* export-ignore
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---

Please submit your PR here instead:
https://github.com/symfony/symfony

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
20 changes: 20 additions & 0 deletions .github/workflows/close-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Close Pull Request

on:
pull_request_target:
types: [opened]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.
However, you should instead open your PR on the main repository:
https://github.com/symfony/symfony
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
CHANGELOG
=========

7.1
---

* Add support for `:is()`
* Add support for `:where()`

6.3
---

* Add support for `:scope`

4.4.0
-----

14 changes: 6 additions & 8 deletions CssSelectorConverter.php
Original file line number Diff line number Diff line change
@@ -26,11 +26,11 @@
*/
class CssSelectorConverter
{
private $translator;
private $cache;
private Translator $translator;
private array $cache;

private static $xmlCache = [];
private static $htmlCache = [];
private static array $xmlCache = [];
private static array $htmlCache = [];

/**
* @param bool $html Whether HTML support should be enabled. Disable it for XML documents
@@ -59,11 +59,9 @@ public function __construct(bool $html = true)
*
* Optionally, a prefix can be added to the resulting XPath
* expression with the $prefix parameter.
*
* @return string
*/
public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::')
public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
{
return $this->cache[$prefix][$cssExpr] ?? $this->cache[$prefix][$cssExpr] = $this->translator->cssToXPath($cssExpr, $prefix);
return $this->cache[$prefix][$cssExpr] ??= $this->translator->cssToXPath($cssExpr, $prefix);
}
}
36 changes: 13 additions & 23 deletions Exception/SyntaxErrorException.php
Original file line number Diff line number Diff line change
@@ -23,42 +23,32 @@
*/
class SyntaxErrorException extends ParseException
{
/**
* @return self
*/
public static function unexpectedToken(string $expectedValue, Token $foundToken)
public static function unexpectedToken(string $expectedValue, Token $foundToken): self
{
return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
return new self(\sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
}

/**
* @return self
*/
public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation)
public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation): self
{
return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
return new self(\sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
}

/**
* @return self
*/
public static function unclosedString(int $position)
public static function unclosedString(int $position): self
{
return new self(sprintf('Unclosed/invalid string at %s.', $position));
return new self(\sprintf('Unclosed/invalid string at %s.', $position));
}

/**
* @return self
*/
public static function nestedNot()
public static function nestedNot(): self
{
return new self('Got nested ::not().');
}

/**
* @return self
*/
public static function stringAsFunctionArgument()
public static function notAtTheStartOfASelector(string $pseudoElement): self
{
return new self(\sprintf('Got immediate child pseudo-element ":%s" not at the start of a selector', $pseudoElement));
}

public static function stringAsFunctionArgument(): self
{
return new self('String not allowed as function argument.');
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2004-2022 Fabien Potencier
Copyright (c) 2004-present Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
11 changes: 2 additions & 9 deletions Node/AbstractNode.php
Original file line number Diff line number Diff line change
@@ -23,17 +23,10 @@
*/
abstract class AbstractNode implements NodeInterface
{
/**
* @var string
*/
private $nodeName;
private string $nodeName;

public function getNodeName(): string
{
if (null === $this->nodeName) {
$this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', static::class);
}

return $this->nodeName;
return $this->nodeName ??= preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', static::class);
}
}
27 changes: 9 additions & 18 deletions Node/AttributeNode.php
Original file line number Diff line number Diff line change
@@ -23,19 +23,13 @@
*/
class AttributeNode extends AbstractNode
{
private $selector;
private $namespace;
private $attribute;
private $operator;
private $value;

public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value)
{
$this->selector = $selector;
$this->namespace = $namespace;
$this->attribute = $attribute;
$this->operator = $operator;
$this->value = $value;
public function __construct(
private NodeInterface $selector,
private ?string $namespace,
private string $attribute,
private string $operator,
private ?string $value,
) {
}

public function getSelector(): NodeInterface
@@ -63,9 +57,6 @@ public function getValue(): ?string
return $this->value;
}

/**
* {@inheritdoc}
*/
public function getSpecificity(): Specificity
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
@@ -76,7 +67,7 @@ public function __toString(): string
$attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute;

return 'exists' === $this->operator
? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute)
: sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value);
? \sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute)
: \sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value);
}
}
16 changes: 5 additions & 11 deletions Node/ClassNode.php
Original file line number Diff line number Diff line change
@@ -23,13 +23,10 @@
*/
class ClassNode extends AbstractNode
{
private $selector;
private $name;

public function __construct(NodeInterface $selector, string $name)
{
$this->selector = $selector;
$this->name = $name;
public function __construct(
private NodeInterface $selector,
private string $name,
) {
}

public function getSelector(): NodeInterface
@@ -42,16 +39,13 @@ public function getName(): string
return $this->name;
}

/**
* {@inheritdoc}
*/
public function getSpecificity(): Specificity
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
}

public function __toString(): string
{
return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name);
return \sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name);
}
}
19 changes: 6 additions & 13 deletions Node/CombinedSelectorNode.php
Original file line number Diff line number Diff line change
@@ -23,15 +23,11 @@
*/
class CombinedSelectorNode extends AbstractNode
{
private $selector;
private $combinator;
private $subSelector;

public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector)
{
$this->selector = $selector;
$this->combinator = $combinator;
$this->subSelector = $subSelector;
public function __construct(
private NodeInterface $selector,
private string $combinator,
private NodeInterface $subSelector,
) {
}

public function getSelector(): NodeInterface
@@ -49,9 +45,6 @@ public function getSubSelector(): NodeInterface
return $this->subSelector;
}

/**
* {@inheritdoc}
*/
public function getSpecificity(): Specificity
{
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
@@ -61,6 +54,6 @@ public function __toString(): string
{
$combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator;

return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector);
return \sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector);
}
}
16 changes: 5 additions & 11 deletions Node/ElementNode.php
Original file line number Diff line number Diff line change
@@ -23,13 +23,10 @@
*/
class ElementNode extends AbstractNode
{
private $namespace;
private $element;

public function __construct(string $namespace = null, string $element = null)
{
$this->namespace = $namespace;
$this->element = $element;
public function __construct(
private ?string $namespace = null,
private ?string $element = null,
) {
}

public function getNamespace(): ?string
@@ -42,9 +39,6 @@ public function getElement(): ?string
return $this->element;
}

/**
* {@inheritdoc}
*/
public function getSpecificity(): Specificity
{
return new Specificity(0, 0, $this->element ? 1 : 0);
@@ -54,6 +48,6 @@ public function __toString(): string
{
$element = $this->element ?: '*';

return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element);
return \sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element);
}
}
22 changes: 8 additions & 14 deletions Node/FunctionNode.php
Original file line number Diff line number Diff line change
@@ -25,18 +25,17 @@
*/
class FunctionNode extends AbstractNode
{
private $selector;
private $name;
private $arguments;
private string $name;

/**
* @param Token[] $arguments
*/
public function __construct(NodeInterface $selector, string $name, array $arguments = [])
{
$this->selector = $selector;
public function __construct(
private NodeInterface $selector,
string $name,
private array $arguments = [],
) {
$this->name = strtolower($name);
$this->arguments = $arguments;
}

public function getSelector(): NodeInterface
@@ -57,20 +56,15 @@ public function getArguments(): array
return $this->arguments;
}

/**
* {@inheritdoc}
*/
public function getSpecificity(): Specificity
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
}

public function __toString(): string
{
$arguments = implode(', ', array_map(function (Token $token) {
return "'".$token->getValue()."'";
}, $this->arguments));
$arguments = implode(', ', array_map(fn (Token $token) => "'".$token->getValue()."'", $this->arguments));

return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : '');
return \sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : '');
}
}
Loading