Skip to content

Commit

Permalink
[CLEANUP] Move CSS parsing to a separate class
Browse files Browse the repository at this point in the history
Also remove a redundant cache for the parsed CSS - the CSS is only ever parsed
once per `CssInliner` instance.

Part of #734 and #544.  Relates to #994.
  • Loading branch information
JakeQZ committed Apr 13, 2021
1 parent 302c2d0 commit e1cc71d
Show file tree
Hide file tree
Showing 4 changed files with 348 additions and 299 deletions.
24 changes: 6 additions & 18 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="src/CssInliner.php">
<ArgumentTypeCoercion occurrences="2">
<ArgumentTypeCoercion occurrences="1">
<code>$node</code>
</ArgumentTypeCoercion>
<DocblockTypeContradiction occurrences="1">
<code>\is_array($this-&gt;matchingUninlinableCssRules)</code>
</DocblockTypeContradiction>
<InvalidArgument occurrences="3">
<InvalidArgument occurrences="1">
<code>$cssRule</code>
<code>$cssRule</code>
</InvalidArgument>
Expand All @@ -17,55 +17,43 @@
<MixedArgumentTypeCoercion occurrences="1">
<code>$attributeName</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess occurrences="4">
<MixedArrayAccess occurrences="3">
<code>$this-&gt;caches[self::CACHE_KEY_COMBINED_STYLES][$cacheKey]</code>
<code>$this-&gt;caches[self::CACHE_KEY_CSS][$cssKey]</code>
<code>$this-&gt;caches[self::CACHE_KEY_CSS_DECLARATIONS_BLOCK][$cssDeclarationsBlock]</code>
<code>$this-&gt;caches[self::CACHE_KEY_SELECTOR][$selectorKey]</code>
</MixedArrayAccess>
<MixedArrayAssignment occurrences="4">
<MixedArrayAssignment occurrences="3">
<code>$this-&gt;caches[self::CACHE_KEY_COMBINED_STYLES][$cacheKey]</code>
<code>$this-&gt;caches[self::CACHE_KEY_CSS][$cssKey]</code>
<code>$this-&gt;caches[self::CACHE_KEY_CSS_DECLARATIONS_BLOCK][$cssDeclarationsBlock]</code>
<code>$this-&gt;caches[self::CACHE_KEY_SELECTOR][$selectorKey]</code>
</MixedArrayAssignment>
<MixedAssignment occurrences="2">
<code>$nodePath</code>
<code>$path</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="4">
<MixedInferredReturnType occurrences="3">
<code>int</code>
<code>string</code>
<code>string[]</code>
<code>string[][][]</code>
</MixedInferredReturnType>
<MixedOperand occurrences="1">
<code>$path</code>
</MixedOperand>
<MixedPropertyTypeCoercion occurrences="1">
<code>$this-&gt;styleAttributesForNodes</code>
</MixedPropertyTypeCoercion>
<MixedReturnStatement occurrences="4">
<MixedReturnStatement occurrences="3">
<code>$this-&gt;caches[self::CACHE_KEY_COMBINED_STYLES][$cacheKey]</code>
<code>$this-&gt;caches[self::CACHE_KEY_CSS][$cssKey]</code>
<code>$this-&gt;caches[self::CACHE_KEY_CSS_DECLARATIONS_BLOCK][$cssDeclarationsBlock]</code>
<code>$this-&gt;caches[self::CACHE_KEY_SELECTOR][$selectorKey]</code>
</MixedReturnStatement>
<MixedReturnTypeCoercion occurrences="3">
<code>$cssRules</code>
<code>\array_column($this-&gt;matchingUninlinableCssRules, 'selector')</code>
<code>string[]</code>
</MixedReturnTypeCoercion>
<PossiblyNullPropertyAssignmentValue occurrences="1">
<code>null</code>
</PossiblyNullPropertyAssignmentValue>
<PossiblyUndefinedVariable occurrences="2">
<code>$matchingNodes</code>
<code>$nodesMatchingCssSelectors</code>
</PossiblyUndefinedVariable>
<UnnecessaryVarAnnotation occurrences="1">
<code>string[]</code>
</UnnecessaryVarAnnotation>
</file>
<file src="src/HtmlProcessor/CssToAttributeConverter.php">
<MixedArgument occurrences="3">
Expand Down
Loading

0 comments on commit e1cc71d

Please sign in to comment.