diff --git a/composer.json b/composer.json index 59e4ef2..3c49bea 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,10 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.2.5 || ^8.0", "ext-dom": "*", "ext-libxml": "*", - "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" + "symfony/css-selector": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^8.5.21 || ^9.5.10" @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "2.x-dev" } } } diff --git a/src/CssToInlineStyles.php b/src/CssToInlineStyles.php index e40ae25..53d6323 100644 --- a/src/CssToInlineStyles.php +++ b/src/CssToInlineStyles.php @@ -2,7 +2,6 @@ namespace TijsVerkoyen\CssToInlineStyles; -use Symfony\Component\CssSelector\CssSelector; use Symfony\Component\CssSelector\CssSelectorConverter; use Symfony\Component\CssSelector\Exception\ExceptionInterface; use TijsVerkoyen\CssToInlineStyles\Css\Processor; @@ -11,13 +10,14 @@ class CssToInlineStyles { + /** + * @var CssSelectorConverter + */ private $cssConverter; public function __construct() { - if (class_exists('Symfony\Component\CssSelector\CssSelectorConverter')) { - $this->cssConverter = new CssSelectorConverter(); - } + $this->cssConverter = new CssSelectorConverter(); } /** @@ -166,12 +166,7 @@ protected function inline(\DOMDocument $document, array $rules) foreach ($rules as $rule) { try { - if (null !== $this->cssConverter) { - $expression = $this->cssConverter->toXPath($rule->getSelector()); - } else { - // Compatibility layer for Symfony 2.7 and older - $expression = CssSelector::toXPath($rule->getSelector()); - } + $expression = $this->cssConverter->toXPath($rule->getSelector()); } catch (ExceptionInterface $e) { continue; }