Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency tijsverkoyen/css-to-inline-styles to v2.3.0 #982

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"require": {
"symfony/css-selector": "5.4.45",
"hizzle/store": "^0",
"tijsverkoyen/css-to-inline-styles": "2.2.7"
"tijsverkoyen/css-to-inline-styles": "2.3.0"
},
"autoload": {
"psr-4": {
Expand Down
30 changes: 16 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 23 additions & 4 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class InstalledVersions
*/
private static $installed;

/**
* @var bool
*/
private static $installedIsLocalDir;

/**
* @var bool|null
*/
Expand Down Expand Up @@ -309,6 +314,12 @@ public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();

// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = false;
}

/**
Expand All @@ -322,19 +333,27 @@ private static function getInstalled()
}

$installed = array();
$copiedLocalDir = false;

if (self::$canGetVendors) {
$selfDir = strtr(__DIR__, '\\', '/');
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = true;
}
}
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
$copiedLocalDir = true;
}
}
}

Expand All @@ -350,7 +369,7 @@ private static function getInstalled()
}
}

if (self::$installed !== array()) {
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}

Expand Down
24 changes: 13 additions & 11 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,33 +205,35 @@
},
{
"name": "tijsverkoyen/css-to-inline-styles",
"version": "v2.2.7",
"version_normalized": "2.2.7.0",
"version": "v2.3.0",
"version_normalized": "2.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
"reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb"
"reference": "0d72ac1c00084279c1816675284073c5a337c20d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/83ee6f38df0a63106a9e4536e3060458b74ccedb",
"reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/0d72ac1c00084279c1816675284073c5a337c20d",
"reference": "0d72ac1c00084279c1816675284073c5a337c20d",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"php": "^5.5 || ^7.0 || ^8.0",
"symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"
"php": "^7.4 || ^8.0",
"symfony/css-selector": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10"
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^8.5.21 || ^9.5.10"
},
"time": "2023-12-08T13:03:43+00:00",
"time": "2024-12-21T16:25:41+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "2.x-dev"
}
},
"installation-source": "dist",
Expand All @@ -255,7 +257,7 @@
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"support": {
"issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues",
"source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.2.7"
"source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.3.0"
},
"install-path": "../tijsverkoyen/css-to-inline-styles"
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'hizzle-co/noptin',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7a1b71e1525dddf4a2c58b39ca7adf48b52c388b',
'reference' => '1384e3b1013dba915f2354be071d3923de868cfb',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'hizzle-co/noptin' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7a1b71e1525dddf4a2c58b39ca7adf48b52c388b',
'reference' => '1384e3b1013dba915f2354be071d3923de868cfb',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -47,9 +47,9 @@
'dev_requirement' => false,
),
'tijsverkoyen/css-to-inline-styles' => array(
'pretty_version' => 'v2.2.7',
'version' => '2.2.7.0',
'reference' => '83ee6f38df0a63106a9e4536e3060458b74ccedb',
'pretty_version' => 'v2.3.0',
'version' => '2.3.0.0',
'reference' => '0d72ac1c00084279c1816675284073c5a337c20d',
'type' => 'library',
'install_path' => __DIR__ . '/../tijsverkoyen/css-to-inline-styles',
'aliases' => array(),
Expand Down
10 changes: 6 additions & 4 deletions vendor/tijsverkoyen/css-to-inline-styles/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
}
],
"require": {
"php": "^5.5 || ^7.0 || ^8.0",
"php": "^7.4 || ^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": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10"
"phpunit/phpunit": "^8.5.21 || ^9.5.10",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -32,7 +34,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "2.x-dev"
}
}
}
10 changes: 5 additions & 5 deletions vendor/tijsverkoyen/css-to-inline-styles/src/Css/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getCssFromStyleTags($html)
{
$css = '';
$matches = array();
$htmlNoComments = preg_replace('|<!--.*?-->|s', '', $html);
$htmlNoComments = preg_replace('|<!--.*?-->|s', '', $html) ?? $html;
preg_match_all('|<style(?:\s.*)?>(.*)</style>|isU', $htmlNoComments, $matches);

if (!empty($matches[1])) {
Expand All @@ -55,15 +55,15 @@ public function getCssFromStyleTags($html)
private function doCleanup($css)
{
// remove charset
$css = preg_replace('/@charset "[^"]++";/', '', $css);
$css = preg_replace('/@charset "[^"]++";/', '', $css) ?? $css;
// remove media queries
$css = preg_replace('/@media [^{]*+{([^{}]++|{[^{}]*+})*+}/', '', $css);
$css = preg_replace('/@media [^{]*+{([^{}]++|{[^{}]*+})*+}/', '', $css) ?? $css;

$css = str_replace(array("\r", "\n"), '', $css);
$css = str_replace(array("\t"), ' ', $css);
$css = str_replace('"', '\'', $css);
$css = preg_replace('|/\*.*?\*/|', '', $css);
$css = preg_replace('/\s\s++/', ' ', $css);
$css = preg_replace('|/\*.*?\*/|', '', $css) ?? $css;
$css = preg_replace('/\s\s++/', ' ', $css) ?? $css;
$css = trim($css);

return $css;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ private function cleanup($string)
$string = str_replace(array("\r", "\n"), '', $string);
$string = str_replace(array("\t"), ' ', $string);
$string = str_replace('"', '\'', $string);
$string = preg_replace('|/\*.*?\*/|', '', $string);
$string = preg_replace('/\s\s+/', ' ', $string);
$string = preg_replace('|/\*.*?\*/|', '', $string) ?? $string;
$string = preg_replace('/\s\s+/', ' ', $string) ?? $string;

$string = trim($string);
$string = rtrim($string, ';');
Expand All @@ -66,7 +66,7 @@ private function cleanup($string)
*
* @return Property|null
*/
public function convertToObject($property, Specificity $specificity = null)
public function convertToObject($property, ?Specificity $specificity = null)
{
if (strpos($property, ':') === false) {
return null;
Expand All @@ -91,7 +91,7 @@ public function convertToObject($property, Specificity $specificity = null)
*
* @return Property[]
*/
public function convertArrayToObjects(array $properties, Specificity $specificity = null)
public function convertArrayToObjects(array $properties, ?Specificity $specificity = null)
{
$objects = array();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class Property
private $value;

/**
* @var Specificity
* @var Specificity|null
*/
private $originalSpecificity;

Expand All @@ -27,7 +27,7 @@ final class Property
* @param string $value
* @param Specificity|null $specificity
*/
public function __construct($name, $value, Specificity $specificity = null)
public function __construct($name, $value, ?Specificity $specificity = null)
{
$this->name = $name;
$this->value = $value;
Expand Down Expand Up @@ -57,7 +57,7 @@ public function getValue()
/**
* Get originalSpecificity
*
* @return Specificity
* @return Specificity|null
*/
public function getOriginalSpecificity()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ private function cleanup($string)
$string = str_replace(array("\r", "\n"), '', $string);
$string = str_replace(array("\t"), ' ', $string);
$string = str_replace('"', '\'', $string);
$string = preg_replace('|/\*.*?\*/|', '', $string);
$string = preg_replace('/\s\s+/', ' ', $string);
$string = preg_replace('|/\*.*?\*/|', '', $string) ?? $string;
$string = preg_replace('/\s\s+/', ' ', $string) ?? $string;

$string = trim($string);
$string = rtrim($string, '}');
Expand Down Expand Up @@ -88,7 +88,7 @@ public function convertToObjects($rule, $originalOrder)
*/
public function calculateSpecificityBasedOnASelector($selector)
{
$idSelectorsPattern = " \#";
$idSelectorCount = preg_match_all("/ \#/ix", $selector, $matches);
$classAttributesPseudoClassesSelectorsPattern = " (\.[\w]+) # classes
|
\[(\w+) # attributes
Expand All @@ -105,6 +105,7 @@ public function calculateSpecificityBasedOnASelector($selector)
|only-child|only-of-type
|empty|contains
))";
$classAttributesPseudoClassesSelectorCount = preg_match_all("/{$classAttributesPseudoClassesSelectorsPattern}/ix", $selector, $matches);

$typePseudoElementsSelectorPattern = " ((^|[\s\+\>\~]+)[\w]+ # elements
|
Expand All @@ -114,11 +115,16 @@ public function calculateSpecificityBasedOnASelector($selector)
|selection
)
)";
$typePseudoElementsSelectorCount = preg_match_all("/{$typePseudoElementsSelectorPattern}/ix", $selector, $matches);

if ($idSelectorCount === false || $classAttributesPseudoClassesSelectorCount === false || $typePseudoElementsSelectorCount === false) {
throw new \RuntimeException('Failed to calculate specificity based on selector.');
}

return new Specificity(
preg_match_all("/{$idSelectorsPattern}/ix", $selector, $matches),
preg_match_all("/{$classAttributesPseudoClassesSelectorsPattern}/ix", $selector, $matches),
preg_match_all("/{$typePseudoElementsSelectorPattern}/ix", $selector, $matches)
$idSelectorCount,
$classAttributesPseudoClassesSelectorCount,
$typePseudoElementsSelectorCount
);
}

Expand Down
Loading