Skip to content

Commit

Permalink
Merge pull request #704 from stof/upmerge
Browse files Browse the repository at this point in the history
Merge 1.12.1 into main
  • Loading branch information
stof committed Jan 13, 2024
2 parents 277f0a6 + 56d7dd6 commit 5659341
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MAINTENANCE.md
Expand Up @@ -4,7 +4,7 @@ This file contains documentation targeted at the scssphp maintainers.

### Prepare the release

1. Ensure that the documentation (in `docs/docs/index.md`) is up-to-date
1. Ensure that the documentation (in `docs/docs/README.md`) is up-to-date
2. Update the changelog in `docs/docs/changelog.md`
3. Update the version in `src/Version.php`
4. Update the version in `docs/_config.yml` (this should be the tag name that will be created)
Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
@@ -1,6 +1,6 @@
# Site settings
title: SCSS Compiler in PHP
current_version: v1.12.0
current_version: v1.12.1
description: >
SCSS compiler written in PHP
url: https://scssphp.github.io
Expand Down
7 changes: 7 additions & 0 deletions docs/docs/changelog.md
@@ -1,5 +1,12 @@
# Changelog

## **1.12.1** -- January 13, 2024

**Fixed**

* Fix the handling of leading spaces in interpolated media queries (@stof)
* Fix the compilation cache key when using numbers in variables (@stof)

## **1.12.0** -- November 14, 2023

**Deprecated**
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml.dist
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<ruleset name="PSR12 (adapted for PHP 5.6+)">
<ruleset name="PSR12 (adapted for PHP 5.6+)" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<rule ref="PSR12">
<!-- Ignore this PHP 7.1+ sniff as long as we support PHP 5.6+ -->
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>

<!-- This sniff does not properly support functions returning never and so terminating the branch. -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment"/>

<!-- PSR12 does not actually has a hard line length -->
<!-- PSR12 does not actually have a hard line length -->
<exclude name="Generic.Files.LineLength"/>
</rule>
</ruleset>
52 changes: 46 additions & 6 deletions phpstan-baseline.neon
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Cannot cast T of array\\<string\\|Stringable\\>\\|string\\|Stringable\\|null to string\\.$#"
count: 1
path: src/Ast/Css/CssValue.php

-
message: "#^Property ScssPhp\\\\ScssPhp\\\\Block\\:\\:\\$children type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -30,6 +25,11 @@ parameters:
count: 1
path: src/Block/AtRootBlock.php

-
message: "#^Property ScssPhp\\\\ScssPhp\\\\Block\\\\CallableBlock\\:\\:\\$args type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Block/CallableBlock.php

-
message: "#^Property ScssPhp\\\\ScssPhp\\\\Block\\\\ContentBlock\\:\\:\\$child type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -150,6 +150,11 @@ parameters:
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:applyArguments\\(\\) has parameter \\$argDef with no value type specified in iterable type array\\.$#"
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:applyArguments\\(\\) has parameter \\$argValues with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -170,6 +175,11 @@ parameters:
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:applyArgumentsToDeclaration\\(\\) has parameter \\$prototype with no value type specified in iterable type array\\.$#"
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:applyArgumentsToDeclaration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -260,6 +270,11 @@ parameters:
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:checkPrototypeMatches\\(\\) has parameter \\$prototype with no value type specified in iterable type array\\.$#"
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:checkSelectorArgType\\(\\) has parameter \\$arg with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -497,7 +512,7 @@ parameters:

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:evaluateArguments\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
count: 2
path: src/Compiler.php

-
Expand Down Expand Up @@ -1145,6 +1160,11 @@ parameters:
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:parseFunctionPrototype\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:prependSelectors\\(\\) has parameter \\$parts with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1200,6 +1220,11 @@ parameters:
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:selectFunctionPrototype\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:selectorAppend\\(\\) has parameter \\$selectors with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1290,6 +1315,11 @@ parameters:
count: 1
path: src/Compiler.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Compiler\\:\\:verifyPrototype\\(\\) has parameter \\$prototype with no value type specified in iterable type array\\.$#"
count: 1
path: src/Compiler.php

-
message: "#^Offset 2 does not exist on array\\{\\}\\.$#"
count: 1
Expand Down Expand Up @@ -1490,6 +1520,11 @@ parameters:
count: 1
path: src/Formatter/OutputBlock.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Importer\\\\FilesystemImporter\\:\\:load\\(\\) never returns null so it can be removed from the return type\\.$#"
count: 1
path: src/Importer/FilesystemImporter.php

-
message: "#^Left side of && is always true\\.$#"
count: 1
Expand Down Expand Up @@ -1684,3 +1719,8 @@ parameters:
message: "#^Parameter \\#1 \\$value of method ScssPhp\\\\ScssPhp\\\\Base\\\\Range\\:\\:includes\\(\\) expects float\\|int, float\\|int\\|string given\\.$#"
count: 1
path: src/Util.php

-
message: "#^Method ScssPhp\\\\ScssPhp\\\\Value\\\\SassMap\\:\\:tryMap\\(\\) never returns null so it can be removed from the return type\\.$#"
count: 1
path: src/Value/SassMap.php
2 changes: 1 addition & 1 deletion src/Ast/Css/CssValue.php
Expand Up @@ -24,7 +24,7 @@
* This is used to associate a span with a value that doesn't otherwise track
* its span. It has value equality semantics.
*
* @template T of string|\Stringable|array<string|\Stringable>|Combinator|null
* @template-covariant T of string|\Stringable|array<string|\Stringable>|Combinator|null
*
* @internal
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler.php
Expand Up @@ -444,7 +444,7 @@ public function compileString(string $source, ?string $path = null): Compilation

$sourceMap = null;

if (! empty($out) && $this->sourceMap !== self::SOURCE_MAP_NONE) {
if (! empty($out) && $this->sourceMap !== self::SOURCE_MAP_NONE && $this->sourceMap) {
assert($sourceMapGenerator !== null);
$sourceMap = $sourceMapGenerator->generateJson($prefix);
$sourceMapUrl = null;
Expand Down
12 changes: 11 additions & 1 deletion src/Node/Number.php
Expand Up @@ -33,7 +33,7 @@
*
* @template-implements \ArrayAccess<int, mixed>
*/
final class Number extends Node implements \ArrayAccess
final class Number extends Node implements \ArrayAccess, \JsonSerializable
{
const PRECISION = 10;

Expand Down Expand Up @@ -140,6 +140,16 @@ public function getDenominatorUnits()
return $this->denominatorUnits;
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
// Passing a compiler instance makes the method output a Sass representation instead of a CSS one, supporting full units.
return $this->output(new Compiler());
}

/**
* @return bool
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Parser.php
Expand Up @@ -348,10 +348,13 @@ public function parseMediaQueryList(string $buffer, &$out): bool
$this->inParens = false;
$this->eatWhiteDefault = true;
$this->buffer = $buffer;
$this->discardComments = true;

$this->saveEncoding();
$this->extractLineNumbers($this->buffer);

$this->whitespace();

$isMediaQuery = $this->mediaQueryList($out);

$this->restoreEncoding();
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Expand Up @@ -19,5 +19,5 @@
*/
final class Version
{
const VERSION = '1.12.0';
const VERSION = '1.12.1';
}
20 changes: 20 additions & 0 deletions tests/inputs/media_query_interpolation_spaces.scss
@@ -0,0 +1,20 @@
// Leading space
@media #{" (max-width: 300px)"} {
a {
font-size: 10px;
}
}

// No space
@media #{"(max-width: 300px)"} {
a {
font-size: 10px;
}
}

// Trailing Space
@media #{"(max-width: 300px) "} {
a {
font-size: 10px;
}
}
15 changes: 15 additions & 0 deletions tests/outputs/media_query_interpolation_spaces.css
@@ -0,0 +1,15 @@
@media (max-width: 300px) {
a {
font-size: 10px;
}
}
@media (max-width: 300px) {
a {
font-size: 10px;
}
}
@media (max-width: 300px) {
a {
font-size: 10px;
}
}
2 changes: 1 addition & 1 deletion vendor-bin/phpstan/composer.json
Expand Up @@ -4,7 +4,7 @@
},
"require": {
"jiripudil/phpstan-sealed-classes": "^1.1",
"phpstan/phpstan": "1.10.35",
"phpstan/phpstan": "1.10.55",
"phpstan/phpstan-deprecation-rules": "^1.1"
}
}

0 comments on commit 5659341

Please sign in to comment.