Skip to content

Commit

Permalink
Merge pull request #249 from stof/drop_old_symfony
Browse files Browse the repository at this point in the history
Remove support for unmaintained Symfony versions
  • Loading branch information
stof authored Dec 17, 2024
2 parents 97b4134 + f2b583c commit e2aa8c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -32,7 +32,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "2.x-dev"
}
}
}
15 changes: 5 additions & 10 deletions src/CssToInlineStyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e2aa8c9

Please sign in to comment.