diff --git a/.gitignore b/.gitignore index 1da9aca99..5fab998e6 100644 --- a/.gitignore +++ b/.gitignore @@ -251,4 +251,4 @@ rackspace/php-opencloud/samples mtdowling/jmespath.php/tests -leafo/scssphp/example +scssphp/scssphp/example diff --git a/composer.json b/composer.json index b45e85402..6a9f9df02 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "icewind/streams": "v0.7.1", "interfasys/lognormalizer": "^v1.0", "jeremeamia/superclosure": "^2.4", - "leafo/scssphp": "0.8.4", "league/flysystem": "^1.0", "microsoft/azure-storage-blob": "1.2.0", "nikic/php-parser": "^4.2", @@ -36,6 +35,7 @@ "pimple/pimple": "3.2.3", "punic/punic": "^1.6", "sabre/dav": "^3.2.0", + "scssphp/scssphp": "1.0.3", "stecman/symfony-console-completion": "^0.8.0", "swiftmailer/swiftmailer": "^6.0", "symfony/console": "4.3.4", diff --git a/composer.lock b/composer.lock index e860dd33c..a8ac871af 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "29f99efaaffa9e997730b7edbcca09c6", + "content-hash": "26311e0cefed3ed8e23fd6ce2ed2b7a3", "packages": [ { "name": "aws/aws-sdk-php", @@ -1285,6 +1285,7 @@ } ], "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", + "abandoned": true, "time": "2015-05-20T03:37:09+00:00" }, { @@ -1473,7 +1474,7 @@ "time": "2015-08-01T16:27:37+00:00" }, { - "name": "jeremeamia/superclosure", + "name": "jeremeamia/SuperClosure", "version": "2.4.0", "source": { "type": "git", @@ -1596,60 +1597,6 @@ ], "time": "2019-01-14T23:55:14+00:00" }, - { - "name": "leafo/scssphp", - "version": "v0.8.4", - "source": { - "type": "git", - "url": "https://github.com/leafo/scssphp.git", - "reference": "b9cdea3e42c3bcb1a9faafd04ccce4e8ec860ad9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafo/scssphp/zipball/b9cdea3e42c3bcb1a9faafd04ccce4e8ec860ad9", - "reference": "b9cdea3e42c3bcb1a9faafd04ccce4e8ec860ad9", - "shasum": "" - }, - "require": { - "php": "^5.4.0 || ^7" - }, - "require-dev": { - "phpunit/phpunit": "~4.6", - "squizlabs/php_codesniffer": "~2.5", - "twbs/bootstrap": "~4.3", - "zurb/foundation": "~6.5" - }, - "bin": [ - "bin/pscss" - ], - "type": "library", - "autoload": { - "psr-4": { - "Leafo\\ScssPhp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Leaf Corcoran", - "email": "leafot@gmail.com", - "homepage": "http://leafo.net" - } - ], - "description": "scssphp is a compiler for SCSS written in PHP.", - "homepage": "http://leafo.github.io/scssphp/", - "keywords": [ - "css", - "less", - "sass", - "scss", - "stylesheet" - ], - "time": "2019-06-18T21:15:44+00:00" - }, { "name": "league/flysystem", "version": "1.0.37", @@ -3371,6 +3318,65 @@ ], "time": "2016-10-09T22:57:52+00:00" }, + { + "name": "scssphp/scssphp", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/scssphp/scssphp.git", + "reference": "616c518333c656eaa23182ac6cfc01453f1e7c78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/scssphp/scssphp/zipball/616c518333c656eaa23182ac6cfc01453f1e7c78", + "reference": "616c518333c656eaa23182ac6cfc01453f1e7c78", + "shasum": "" + }, + "require": { + "php": "^5.6.0 || ^7" + }, + "require-dev": { + "phpunit/phpunit": "~4.6", + "squizlabs/php_codesniffer": "~2.5", + "twbs/bootstrap": "~4.3", + "zurb/foundation": "~6.5" + }, + "bin": [ + "bin/pscss" + ], + "type": "library", + "autoload": { + "psr-4": { + "ScssPhp\\ScssPhp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthon Pang", + "email": "apang@softwaredevelopment.ca", + "homepage": "https://github.com/robocoder" + }, + { + "name": "Cédric Morin", + "email": "cedric@yterium.com", + "homepage": "https://github.com/Cerdic" + } + ], + "description": "scssphp is a compiler for SCSS written in PHP.", + "homepage": "http://scssphp.github.io/scssphp/", + "keywords": [ + "css", + "less", + "sass", + "scss", + "stylesheet" + ], + "time": "2019-08-07T20:16:04+00:00" + }, { "name": "stecman/symfony-console-completion", "version": "0.8.0", diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 9bc3dff1f..51675fc30 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -1180,34 +1180,6 @@ 'JsonSchema\\Uri\\UriResolver' => $vendorDir . '/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php', 'JsonSchema\\Uri\\UriRetriever' => $vendorDir . '/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php', 'JsonSchema\\Validator' => $vendorDir . '/justinrainbow/json-schema/src/JsonSchema/Validator.php', - 'Leafo\\ScssPhp\\Base\\Range' => $vendorDir . '/leafo/scssphp/src/Base/Range.php', - 'Leafo\\ScssPhp\\Block' => $vendorDir . '/leafo/scssphp/src/Block.php', - 'Leafo\\ScssPhp\\Cache' => $vendorDir . '/leafo/scssphp/src/Cache.php', - 'Leafo\\ScssPhp\\Colors' => $vendorDir . '/leafo/scssphp/src/Colors.php', - 'Leafo\\ScssPhp\\Compiler' => $vendorDir . '/leafo/scssphp/src/Compiler.php', - 'Leafo\\ScssPhp\\Compiler\\Environment' => $vendorDir . '/leafo/scssphp/src/Compiler/Environment.php', - 'Leafo\\ScssPhp\\Exception\\CompilerException' => $vendorDir . '/leafo/scssphp/src/Exception/CompilerException.php', - 'Leafo\\ScssPhp\\Exception\\ParserException' => $vendorDir . '/leafo/scssphp/src/Exception/ParserException.php', - 'Leafo\\ScssPhp\\Exception\\RangeException' => $vendorDir . '/leafo/scssphp/src/Exception/RangeException.php', - 'Leafo\\ScssPhp\\Exception\\ServerException' => $vendorDir . '/leafo/scssphp/src/Exception/ServerException.php', - 'Leafo\\ScssPhp\\Formatter' => $vendorDir . '/leafo/scssphp/src/Formatter.php', - 'Leafo\\ScssPhp\\Formatter\\Compact' => $vendorDir . '/leafo/scssphp/src/Formatter/Compact.php', - 'Leafo\\ScssPhp\\Formatter\\Compressed' => $vendorDir . '/leafo/scssphp/src/Formatter/Compressed.php', - 'Leafo\\ScssPhp\\Formatter\\Crunched' => $vendorDir . '/leafo/scssphp/src/Formatter/Crunched.php', - 'Leafo\\ScssPhp\\Formatter\\Debug' => $vendorDir . '/leafo/scssphp/src/Formatter/Debug.php', - 'Leafo\\ScssPhp\\Formatter\\Expanded' => $vendorDir . '/leafo/scssphp/src/Formatter/Expanded.php', - 'Leafo\\ScssPhp\\Formatter\\Nested' => $vendorDir . '/leafo/scssphp/src/Formatter/Nested.php', - 'Leafo\\ScssPhp\\Formatter\\OutputBlock' => $vendorDir . '/leafo/scssphp/src/Formatter/OutputBlock.php', - 'Leafo\\ScssPhp\\Node' => $vendorDir . '/leafo/scssphp/src/Node.php', - 'Leafo\\ScssPhp\\Node\\Number' => $vendorDir . '/leafo/scssphp/src/Node/Number.php', - 'Leafo\\ScssPhp\\Parser' => $vendorDir . '/leafo/scssphp/src/Parser.php', - 'Leafo\\ScssPhp\\SourceMap\\Base64' => $vendorDir . '/leafo/scssphp/src/SourceMap/Base64.php', - 'Leafo\\ScssPhp\\SourceMap\\Base64VLQ' => $vendorDir . '/leafo/scssphp/src/SourceMap/Base64VLQ.php', - 'Leafo\\ScssPhp\\SourceMap\\Base64VLQEncoder' => $vendorDir . '/leafo/scssphp/src/SourceMap/Base64VLQEncoder.php', - 'Leafo\\ScssPhp\\SourceMap\\SourceMapGenerator' => $vendorDir . '/leafo/scssphp/src/SourceMap/SourceMapGenerator.php', - 'Leafo\\ScssPhp\\Type' => $vendorDir . '/leafo/scssphp/src/Type.php', - 'Leafo\\ScssPhp\\Util' => $vendorDir . '/leafo/scssphp/src/Util.php', - 'Leafo\\ScssPhp\\Version' => $vendorDir . '/leafo/scssphp/src/Version.php', 'League\\Flysystem\\AdapterInterface' => $vendorDir . '/league/flysystem/src/AdapterInterface.php', 'League\\Flysystem\\Adapter\\AbstractAdapter' => $vendorDir . '/league/flysystem/src/Adapter/AbstractAdapter.php', 'League\\Flysystem\\Adapter\\AbstractFtpAdapter' => $vendorDir . '/league/flysystem/src/Adapter/AbstractFtpAdapter.php', @@ -2141,6 +2113,34 @@ 'Sabre\\Xml\\Writer' => $vendorDir . '/sabre/xml/lib/Writer.php', 'Sabre\\Xml\\XmlDeserializable' => $vendorDir . '/sabre/xml/lib/XmlDeserializable.php', 'Sabre\\Xml\\XmlSerializable' => $vendorDir . '/sabre/xml/lib/XmlSerializable.php', + 'ScssPhp\\ScssPhp\\Base\\Range' => $vendorDir . '/scssphp/scssphp/src/Base/Range.php', + 'ScssPhp\\ScssPhp\\Block' => $vendorDir . '/scssphp/scssphp/src/Block.php', + 'ScssPhp\\ScssPhp\\Cache' => $vendorDir . '/scssphp/scssphp/src/Cache.php', + 'ScssPhp\\ScssPhp\\Colors' => $vendorDir . '/scssphp/scssphp/src/Colors.php', + 'ScssPhp\\ScssPhp\\Compiler' => $vendorDir . '/scssphp/scssphp/src/Compiler.php', + 'ScssPhp\\ScssPhp\\Compiler\\Environment' => $vendorDir . '/scssphp/scssphp/src/Compiler/Environment.php', + 'ScssPhp\\ScssPhp\\Exception\\CompilerException' => $vendorDir . '/scssphp/scssphp/src/Exception/CompilerException.php', + 'ScssPhp\\ScssPhp\\Exception\\ParserException' => $vendorDir . '/scssphp/scssphp/src/Exception/ParserException.php', + 'ScssPhp\\ScssPhp\\Exception\\RangeException' => $vendorDir . '/scssphp/scssphp/src/Exception/RangeException.php', + 'ScssPhp\\ScssPhp\\Exception\\ServerException' => $vendorDir . '/scssphp/scssphp/src/Exception/ServerException.php', + 'ScssPhp\\ScssPhp\\Formatter' => $vendorDir . '/scssphp/scssphp/src/Formatter.php', + 'ScssPhp\\ScssPhp\\Formatter\\Compact' => $vendorDir . '/scssphp/scssphp/src/Formatter/Compact.php', + 'ScssPhp\\ScssPhp\\Formatter\\Compressed' => $vendorDir . '/scssphp/scssphp/src/Formatter/Compressed.php', + 'ScssPhp\\ScssPhp\\Formatter\\Crunched' => $vendorDir . '/scssphp/scssphp/src/Formatter/Crunched.php', + 'ScssPhp\\ScssPhp\\Formatter\\Debug' => $vendorDir . '/scssphp/scssphp/src/Formatter/Debug.php', + 'ScssPhp\\ScssPhp\\Formatter\\Expanded' => $vendorDir . '/scssphp/scssphp/src/Formatter/Expanded.php', + 'ScssPhp\\ScssPhp\\Formatter\\Nested' => $vendorDir . '/scssphp/scssphp/src/Formatter/Nested.php', + 'ScssPhp\\ScssPhp\\Formatter\\OutputBlock' => $vendorDir . '/scssphp/scssphp/src/Formatter/OutputBlock.php', + 'ScssPhp\\ScssPhp\\Node' => $vendorDir . '/scssphp/scssphp/src/Node.php', + 'ScssPhp\\ScssPhp\\Node\\Number' => $vendorDir . '/scssphp/scssphp/src/Node/Number.php', + 'ScssPhp\\ScssPhp\\Parser' => $vendorDir . '/scssphp/scssphp/src/Parser.php', + 'ScssPhp\\ScssPhp\\SourceMap\\Base64' => $vendorDir . '/scssphp/scssphp/src/SourceMap/Base64.php', + 'ScssPhp\\ScssPhp\\SourceMap\\Base64VLQ' => $vendorDir . '/scssphp/scssphp/src/SourceMap/Base64VLQ.php', + 'ScssPhp\\ScssPhp\\SourceMap\\Base64VLQEncoder' => $vendorDir . '/scssphp/scssphp/src/SourceMap/Base64VLQEncoder.php', + 'ScssPhp\\ScssPhp\\SourceMap\\SourceMapGenerator' => $vendorDir . '/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php', + 'ScssPhp\\ScssPhp\\Type' => $vendorDir . '/scssphp/scssphp/src/Type.php', + 'ScssPhp\\ScssPhp\\Util' => $vendorDir . '/scssphp/scssphp/src/Util.php', + 'ScssPhp\\ScssPhp\\Version' => $vendorDir . '/scssphp/scssphp/src/Version.php', 'SearchDAV\\Backend\\ISearchBackend' => $vendorDir . '/icewind/searchdav/src/Backend/ISearchBackend.php', 'SearchDAV\\Backend\\SearchPropertyDefinition' => $vendorDir . '/icewind/searchdav/src/Backend/SearchPropertyDefinition.php', 'SearchDAV\\Backend\\SearchResult' => $vendorDir . '/icewind/searchdav/src/Backend/SearchResult.php', diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php index f38a7f203..05f0b7118 100644 --- a/composer/autoload_psr4.php +++ b/composer/autoload_psr4.php @@ -29,6 +29,7 @@ 'Stecman\\Component\\Symfony\\Console\\BashCompletion\\' => array($vendorDir . '/stecman/symfony-console-completion/src'), 'SearchDAV\\Test\\' => array($vendorDir . '/icewind/searchdav/tests'), 'SearchDAV\\' => array($vendorDir . '/icewind/searchdav/src'), + 'ScssPhp\\ScssPhp\\' => array($vendorDir . '/scssphp/scssphp/src'), 'Sabre\\Xml\\' => array($vendorDir . '/sabre/xml/lib'), 'Sabre\\VObject\\' => array($vendorDir . '/sabre/vobject/lib'), 'Sabre\\Uri\\' => array($vendorDir . '/sabre/uri/lib'), @@ -50,7 +51,6 @@ 'MicrosoftAzure\\Storage\\Common\\' => array($vendorDir . '/microsoft/azure-storage-common/src/Common'), 'MicrosoftAzure\\Storage\\Blob\\' => array($vendorDir . '/microsoft/azure-storage-blob/src/Blob'), 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), - 'Leafo\\ScssPhp\\' => array($vendorDir . '/leafo/scssphp/src'), 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'), 'JmesPath\\' => array($vendorDir . '/mtdowling/jmespath.php/src'), 'InterfaSys\\LogNormalizer\\' => array($vendorDir . '/interfasys/lognormalizer/src'), diff --git a/composer/autoload_static.php b/composer/autoload_static.php index d7911ca33..28ad194ff 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -69,6 +69,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Stecman\\Component\\Symfony\\Console\\BashCompletion\\' => 49, 'SearchDAV\\Test\\' => 15, 'SearchDAV\\' => 10, + 'ScssPhp\\ScssPhp\\' => 16, 'Sabre\\Xml\\' => 10, 'Sabre\\VObject\\' => 14, 'Sabre\\Uri\\' => 10, @@ -105,7 +106,6 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'L' => array ( 'League\\Flysystem\\' => 17, - 'Leafo\\ScssPhp\\' => 14, ), 'J' => array ( @@ -245,6 +245,10 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 array ( 0 => __DIR__ . '/..' . '/icewind/searchdav/src', ), + 'ScssPhp\\ScssPhp\\' => + array ( + 0 => __DIR__ . '/..' . '/scssphp/scssphp/src', + ), 'Sabre\\Xml\\' => array ( 0 => __DIR__ . '/..' . '/sabre/xml/lib', @@ -330,10 +334,6 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 array ( 0 => __DIR__ . '/..' . '/league/flysystem/src', ), - 'Leafo\\ScssPhp\\' => - array ( - 0 => __DIR__ . '/..' . '/leafo/scssphp/src', - ), 'JsonSchema\\' => array ( 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema', @@ -1641,34 +1641,6 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'JsonSchema\\Uri\\UriResolver' => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php', 'JsonSchema\\Uri\\UriRetriever' => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php', 'JsonSchema\\Validator' => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema/Validator.php', - 'Leafo\\ScssPhp\\Base\\Range' => __DIR__ . '/..' . '/leafo/scssphp/src/Base/Range.php', - 'Leafo\\ScssPhp\\Block' => __DIR__ . '/..' . '/leafo/scssphp/src/Block.php', - 'Leafo\\ScssPhp\\Cache' => __DIR__ . '/..' . '/leafo/scssphp/src/Cache.php', - 'Leafo\\ScssPhp\\Colors' => __DIR__ . '/..' . '/leafo/scssphp/src/Colors.php', - 'Leafo\\ScssPhp\\Compiler' => __DIR__ . '/..' . '/leafo/scssphp/src/Compiler.php', - 'Leafo\\ScssPhp\\Compiler\\Environment' => __DIR__ . '/..' . '/leafo/scssphp/src/Compiler/Environment.php', - 'Leafo\\ScssPhp\\Exception\\CompilerException' => __DIR__ . '/..' . '/leafo/scssphp/src/Exception/CompilerException.php', - 'Leafo\\ScssPhp\\Exception\\ParserException' => __DIR__ . '/..' . '/leafo/scssphp/src/Exception/ParserException.php', - 'Leafo\\ScssPhp\\Exception\\RangeException' => __DIR__ . '/..' . '/leafo/scssphp/src/Exception/RangeException.php', - 'Leafo\\ScssPhp\\Exception\\ServerException' => __DIR__ . '/..' . '/leafo/scssphp/src/Exception/ServerException.php', - 'Leafo\\ScssPhp\\Formatter' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter.php', - 'Leafo\\ScssPhp\\Formatter\\Compact' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/Compact.php', - 'Leafo\\ScssPhp\\Formatter\\Compressed' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/Compressed.php', - 'Leafo\\ScssPhp\\Formatter\\Crunched' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/Crunched.php', - 'Leafo\\ScssPhp\\Formatter\\Debug' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/Debug.php', - 'Leafo\\ScssPhp\\Formatter\\Expanded' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/Expanded.php', - 'Leafo\\ScssPhp\\Formatter\\Nested' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/Nested.php', - 'Leafo\\ScssPhp\\Formatter\\OutputBlock' => __DIR__ . '/..' . '/leafo/scssphp/src/Formatter/OutputBlock.php', - 'Leafo\\ScssPhp\\Node' => __DIR__ . '/..' . '/leafo/scssphp/src/Node.php', - 'Leafo\\ScssPhp\\Node\\Number' => __DIR__ . '/..' . '/leafo/scssphp/src/Node/Number.php', - 'Leafo\\ScssPhp\\Parser' => __DIR__ . '/..' . '/leafo/scssphp/src/Parser.php', - 'Leafo\\ScssPhp\\SourceMap\\Base64' => __DIR__ . '/..' . '/leafo/scssphp/src/SourceMap/Base64.php', - 'Leafo\\ScssPhp\\SourceMap\\Base64VLQ' => __DIR__ . '/..' . '/leafo/scssphp/src/SourceMap/Base64VLQ.php', - 'Leafo\\ScssPhp\\SourceMap\\Base64VLQEncoder' => __DIR__ . '/..' . '/leafo/scssphp/src/SourceMap/Base64VLQEncoder.php', - 'Leafo\\ScssPhp\\SourceMap\\SourceMapGenerator' => __DIR__ . '/..' . '/leafo/scssphp/src/SourceMap/SourceMapGenerator.php', - 'Leafo\\ScssPhp\\Type' => __DIR__ . '/..' . '/leafo/scssphp/src/Type.php', - 'Leafo\\ScssPhp\\Util' => __DIR__ . '/..' . '/leafo/scssphp/src/Util.php', - 'Leafo\\ScssPhp\\Version' => __DIR__ . '/..' . '/leafo/scssphp/src/Version.php', 'League\\Flysystem\\AdapterInterface' => __DIR__ . '/..' . '/league/flysystem/src/AdapterInterface.php', 'League\\Flysystem\\Adapter\\AbstractAdapter' => __DIR__ . '/..' . '/league/flysystem/src/Adapter/AbstractAdapter.php', 'League\\Flysystem\\Adapter\\AbstractFtpAdapter' => __DIR__ . '/..' . '/league/flysystem/src/Adapter/AbstractFtpAdapter.php', @@ -2602,6 +2574,34 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Sabre\\Xml\\Writer' => __DIR__ . '/..' . '/sabre/xml/lib/Writer.php', 'Sabre\\Xml\\XmlDeserializable' => __DIR__ . '/..' . '/sabre/xml/lib/XmlDeserializable.php', 'Sabre\\Xml\\XmlSerializable' => __DIR__ . '/..' . '/sabre/xml/lib/XmlSerializable.php', + 'ScssPhp\\ScssPhp\\Base\\Range' => __DIR__ . '/..' . '/scssphp/scssphp/src/Base/Range.php', + 'ScssPhp\\ScssPhp\\Block' => __DIR__ . '/..' . '/scssphp/scssphp/src/Block.php', + 'ScssPhp\\ScssPhp\\Cache' => __DIR__ . '/..' . '/scssphp/scssphp/src/Cache.php', + 'ScssPhp\\ScssPhp\\Colors' => __DIR__ . '/..' . '/scssphp/scssphp/src/Colors.php', + 'ScssPhp\\ScssPhp\\Compiler' => __DIR__ . '/..' . '/scssphp/scssphp/src/Compiler.php', + 'ScssPhp\\ScssPhp\\Compiler\\Environment' => __DIR__ . '/..' . '/scssphp/scssphp/src/Compiler/Environment.php', + 'ScssPhp\\ScssPhp\\Exception\\CompilerException' => __DIR__ . '/..' . '/scssphp/scssphp/src/Exception/CompilerException.php', + 'ScssPhp\\ScssPhp\\Exception\\ParserException' => __DIR__ . '/..' . '/scssphp/scssphp/src/Exception/ParserException.php', + 'ScssPhp\\ScssPhp\\Exception\\RangeException' => __DIR__ . '/..' . '/scssphp/scssphp/src/Exception/RangeException.php', + 'ScssPhp\\ScssPhp\\Exception\\ServerException' => __DIR__ . '/..' . '/scssphp/scssphp/src/Exception/ServerException.php', + 'ScssPhp\\ScssPhp\\Formatter' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter.php', + 'ScssPhp\\ScssPhp\\Formatter\\Compact' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/Compact.php', + 'ScssPhp\\ScssPhp\\Formatter\\Compressed' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/Compressed.php', + 'ScssPhp\\ScssPhp\\Formatter\\Crunched' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/Crunched.php', + 'ScssPhp\\ScssPhp\\Formatter\\Debug' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/Debug.php', + 'ScssPhp\\ScssPhp\\Formatter\\Expanded' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/Expanded.php', + 'ScssPhp\\ScssPhp\\Formatter\\Nested' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/Nested.php', + 'ScssPhp\\ScssPhp\\Formatter\\OutputBlock' => __DIR__ . '/..' . '/scssphp/scssphp/src/Formatter/OutputBlock.php', + 'ScssPhp\\ScssPhp\\Node' => __DIR__ . '/..' . '/scssphp/scssphp/src/Node.php', + 'ScssPhp\\ScssPhp\\Node\\Number' => __DIR__ . '/..' . '/scssphp/scssphp/src/Node/Number.php', + 'ScssPhp\\ScssPhp\\Parser' => __DIR__ . '/..' . '/scssphp/scssphp/src/Parser.php', + 'ScssPhp\\ScssPhp\\SourceMap\\Base64' => __DIR__ . '/..' . '/scssphp/scssphp/src/SourceMap/Base64.php', + 'ScssPhp\\ScssPhp\\SourceMap\\Base64VLQ' => __DIR__ . '/..' . '/scssphp/scssphp/src/SourceMap/Base64VLQ.php', + 'ScssPhp\\ScssPhp\\SourceMap\\Base64VLQEncoder' => __DIR__ . '/..' . '/scssphp/scssphp/src/SourceMap/Base64VLQEncoder.php', + 'ScssPhp\\ScssPhp\\SourceMap\\SourceMapGenerator' => __DIR__ . '/..' . '/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php', + 'ScssPhp\\ScssPhp\\Type' => __DIR__ . '/..' . '/scssphp/scssphp/src/Type.php', + 'ScssPhp\\ScssPhp\\Util' => __DIR__ . '/..' . '/scssphp/scssphp/src/Util.php', + 'ScssPhp\\ScssPhp\\Version' => __DIR__ . '/..' . '/scssphp/scssphp/src/Version.php', 'SearchDAV\\Backend\\ISearchBackend' => __DIR__ . '/..' . '/icewind/searchdav/src/Backend/ISearchBackend.php', 'SearchDAV\\Backend\\SearchPropertyDefinition' => __DIR__ . '/..' . '/icewind/searchdav/src/Backend/SearchPropertyDefinition.php', 'SearchDAV\\Backend\\SearchResult' => __DIR__ . '/..' . '/icewind/searchdav/src/Backend/SearchResult.php', diff --git a/composer/installed.json b/composer/installed.json index 6db82b029..13dd30029 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1318,7 +1318,8 @@ "homepage": "https://github.com/mtdowling" } ], - "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function." + "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", + "abandoned": true }, { "name": "guzzlehttp/streams", @@ -1641,62 +1642,6 @@ "schema" ] }, - { - "name": "leafo/scssphp", - "version": "v0.8.4", - "version_normalized": "0.8.4.0", - "source": { - "type": "git", - "url": "https://github.com/leafo/scssphp.git", - "reference": "b9cdea3e42c3bcb1a9faafd04ccce4e8ec860ad9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafo/scssphp/zipball/b9cdea3e42c3bcb1a9faafd04ccce4e8ec860ad9", - "reference": "b9cdea3e42c3bcb1a9faafd04ccce4e8ec860ad9", - "shasum": "" - }, - "require": { - "php": "^5.4.0 || ^7" - }, - "require-dev": { - "phpunit/phpunit": "~4.6", - "squizlabs/php_codesniffer": "~2.5", - "twbs/bootstrap": "~4.3", - "zurb/foundation": "~6.5" - }, - "time": "2019-06-18T21:15:44+00:00", - "bin": [ - "bin/pscss" - ], - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Leafo\\ScssPhp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Leaf Corcoran", - "email": "leafot@gmail.com", - "homepage": "http://leafo.net" - } - ], - "description": "scssphp is a compiler for SCSS written in PHP.", - "homepage": "http://leafo.github.io/scssphp/", - "keywords": [ - "css", - "less", - "sass", - "scss", - "stylesheet" - ] - }, { "name": "league/flysystem", "version": "1.0.37", @@ -3478,6 +3423,67 @@ "xml" ] }, + { + "name": "scssphp/scssphp", + "version": "1.0.3", + "version_normalized": "1.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/scssphp/scssphp.git", + "reference": "616c518333c656eaa23182ac6cfc01453f1e7c78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/scssphp/scssphp/zipball/616c518333c656eaa23182ac6cfc01453f1e7c78", + "reference": "616c518333c656eaa23182ac6cfc01453f1e7c78", + "shasum": "" + }, + "require": { + "php": "^5.6.0 || ^7" + }, + "require-dev": { + "phpunit/phpunit": "~4.6", + "squizlabs/php_codesniffer": "~2.5", + "twbs/bootstrap": "~4.3", + "zurb/foundation": "~6.5" + }, + "time": "2019-08-07T20:16:04+00:00", + "bin": [ + "bin/pscss" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "ScssPhp\\ScssPhp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthon Pang", + "email": "apang@softwaredevelopment.ca", + "homepage": "https://github.com/robocoder" + }, + { + "name": "Cédric Morin", + "email": "cedric@yterium.com", + "homepage": "https://github.com/Cerdic" + } + ], + "description": "scssphp is a compiler for SCSS written in PHP.", + "homepage": "http://scssphp.github.io/scssphp/", + "keywords": [ + "css", + "less", + "sass", + "scss", + "stylesheet" + ] + }, { "name": "stecman/symfony-console-completion", "version": "0.8.0", diff --git a/leafo/scssphp/src/Formatter/Nested.php b/leafo/scssphp/src/Formatter/Nested.php deleted file mode 100644 index 8f72206fd..000000000 --- a/leafo/scssphp/src/Formatter/Nested.php +++ /dev/null @@ -1,201 +0,0 @@ - - */ -class Nested extends Formatter -{ - /** - * @var integer - */ - private $depth; - - /** - * {@inheritdoc} - */ - public function __construct() - { - $this->indentLevel = 0; - $this->indentChar = ' '; - $this->break = "\n"; - $this->open = ' {'; - $this->close = ' }'; - $this->tagSeparator = ', '; - $this->assignSeparator = ': '; - $this->keepSemicolons = true; - } - - /** - * {@inheritdoc} - */ - protected function indentStr() - { - $n = $this->depth - 1; - - return str_repeat($this->indentChar, max($this->indentLevel + $n, 0)); - } - - /** - * {@inheritdoc} - */ - protected function blockLines(OutputBlock $block) - { - $inner = $this->indentStr(); - - $glue = $this->break . $inner; - - foreach ($block->lines as $index => $line) { - if (substr($line, 0, 2) === '/*') { - $block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line); - } - } - - $this->write($inner . implode($glue, $block->lines)); - - if (! empty($block->children)) { - $this->write($this->break); - } - } - - /** - * {@inheritdoc} - */ - protected function blockSelectors(OutputBlock $block) - { - $inner = $this->indentStr(); - - $this->write($inner - . implode($this->tagSeparator, $block->selectors) - . $this->open . $this->break); - } - - /** - * {@inheritdoc} - */ - protected function blockChildren(OutputBlock $block) - { - foreach ($block->children as $i => $child) { - $this->block($child); - - if ($i < count($block->children) - 1) { - $this->write($this->break); - - if (isset($block->children[$i + 1])) { - $next = $block->children[$i + 1]; - - if ($next->depth === max($block->depth, 1) && $child->depth >= $next->depth) { - $this->write($this->break); - } - } - } - } - } - - /** - * {@inheritdoc} - */ - protected function block(OutputBlock $block) - { - if ($block->type === 'root') { - $this->adjustAllChildren($block); - } - - if (empty($block->lines) && empty($block->children)) { - return; - } - - $this->currentBlock = $block; - - - $this->depth = $block->depth; - - if (! empty($block->selectors)) { - $this->blockSelectors($block); - - $this->indentLevel++; - } - - if (! empty($block->lines)) { - $this->blockLines($block); - } - - if (! empty($block->children)) { - $this->blockChildren($block); - } - - if (! empty($block->selectors)) { - $this->indentLevel--; - - $this->write($this->close); - } - - if ($block->type === 'root') { - $this->write($this->break); - } - } - - /** - * Adjust the depths of all children, depth first - * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block - */ - private function adjustAllChildren(OutputBlock $block) - { - // flatten empty nested blocks - $children = []; - - foreach ($block->children as $i => $child) { - if (empty($child->lines) && empty($child->children)) { - if (isset($block->children[$i + 1])) { - $block->children[$i + 1]->depth = $child->depth; - } - - continue; - } - - $children[] = $child; - } - - $count = count($children); - - for ($i = 0; $i < $count; $i++) { - $depth = $children[$i]->depth; - $j = $i + 1; - - if (isset($children[$j]) && $depth < $children[$j]->depth) { - $childDepth = $children[$j]->depth; - - for (; $j < $count; $j++) { - if ($depth < $children[$j]->depth && $childDepth >= $children[$j]->depth) { - $children[$j]->depth = $depth + 1; - } - } - } - } - - $block->children = $children; - - // make relative to parent - foreach ($block->children as $child) { - $this->adjustAllChildren($child); - - $child->depth = $child->depth - $block->depth; - } - } -} diff --git a/leafo/scssphp/LICENSE.md b/scssphp/scssphp/LICENSE.md similarity index 93% rename from leafo/scssphp/LICENSE.md rename to scssphp/scssphp/LICENSE.md index 2f5412f9b..afcfdfb26 100644 --- a/leafo/scssphp/LICENSE.md +++ b/scssphp/scssphp/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2015 Leaf Corcoran, http://leafo.github.io/scssphp +Copyright (c) 2015 Leaf Corcoran, http://scssphp.github.io/scssphp Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/leafo/scssphp/README.md b/scssphp/scssphp/README.md similarity index 79% rename from leafo/scssphp/README.md rename to scssphp/scssphp/README.md index d3fbf154a..f541e4888 100644 --- a/leafo/scssphp/README.md +++ b/scssphp/scssphp/README.md @@ -1,17 +1,14 @@ -# This repo has been archived +# scssphp +### - -#### Please go to https://github.com/scssphp/scssphp - ----- - -## scssphp - -![License](https://poser.pugx.org/leafo/scssphp/license.svg) +[![Build](https://travis-ci.org/scssphp/scssphp.svg?branch=master)](http://travis-ci.org/scssphp/scssphp) +[![License](https://poser.pugx.org/scssphp/scssphp/license)](https://packagist.org/packages/scssphp/scssphp) `scssphp` is a compiler for SCSS written in PHP. -### Running Tests +Checkout the homepage, , for directions on how to use. + +## Running Tests `scssphp` uses [PHPUnit](https://github.com/sebastianbergmann/phpunit) for testing. @@ -41,7 +38,7 @@ To enable the `scss` compatibility tests: TEST_SCSS_COMPAT=1 vendor/bin/phpunit tests -### Coding Standard +## Coding Standard `scssphp` source conforms to [PSR2](http://www.php-fig.org/psr/psr-2/). diff --git a/leafo/scssphp/composer.json b/scssphp/scssphp/composer.json similarity index 58% rename from leafo/scssphp/composer.json rename to scssphp/scssphp/composer.json index eaa8e87be..cbeb96578 100644 --- a/leafo/scssphp/composer.json +++ b/scssphp/scssphp/composer.json @@ -1,27 +1,32 @@ { - "name": "leafo/scssphp", + "name": "scssphp/scssphp", "type": "library", "description": "scssphp is a compiler for SCSS written in PHP.", "keywords": ["css", "stylesheet", "scss", "sass", "less"], - "homepage": "http://leafo.github.io/scssphp/", + "homepage": "http://scssphp.github.io/scssphp/", "license": [ "MIT" ], "authors": [ { - "name": "Leaf Corcoran", - "email": "leafot@gmail.com", - "homepage": "http://leafo.net" + "name": "Anthon Pang", + "email": "apang@softwaredevelopment.ca", + "homepage": "https://github.com/robocoder" + }, + { + "name": "Cédric Morin", + "email": "cedric@yterium.com", + "homepage": "https://github.com/Cerdic" } ], "autoload": { - "psr-4": { "Leafo\\ScssPhp\\": "src/" } + "psr-4": { "ScssPhp\\ScssPhp\\": "src/" } }, "autoload-dev": { - "psr-4": { "Leafo\\ScssPhp\\Test\\": "tests/" } + "psr-4": { "ScssPhp\\ScssPhp\\Test\\": "tests/" } }, "require": { - "php": "^5.4.0 || ^7" + "php": "^5.6.0 || ^7" }, "require-dev": { "squizlabs/php_codesniffer": "~2.5", @@ -39,6 +44,5 @@ "/phpunit.xml.dist", "/tests" ] - }, - "abandoned": "scssphp/scssphp" + } } diff --git a/leafo/scssphp/scss.inc.php b/scssphp/scssphp/scss.inc.php similarity index 89% rename from leafo/scssphp/scss.inc.php rename to scssphp/scssphp/scss.inc.php index 2a5f07740..e4ec7f181 100644 --- a/leafo/scssphp/scss.inc.php +++ b/scssphp/scssphp/scss.inc.php @@ -1,9 +1,9 @@ $lastModified) - && $cacheTime + self::$gcLifetime > time() + if ((is_null($lastModified) || $cacheTime > $lastModified) && + $cacheTime + self::$gcLifetime > time() ) { $c = file_get_contents($fileCache); $c = unserialize($c); diff --git a/leafo/scssphp/src/Colors.php b/scssphp/scssphp/src/Colors.php similarity index 98% rename from leafo/scssphp/src/Colors.php rename to scssphp/scssphp/src/Colors.php index 2314ea58d..ad459246a 100644 --- a/leafo/scssphp/src/Colors.php +++ b/scssphp/scssphp/src/Colors.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; /** * CSS Colors diff --git a/leafo/scssphp/src/Compiler.php b/scssphp/scssphp/src/Compiler.php similarity index 86% rename from leafo/scssphp/src/Compiler.php rename to scssphp/scssphp/src/Compiler.php index d22d0a35a..8655ef9df 100644 --- a/leafo/scssphp/src/Compiler.php +++ b/scssphp/scssphp/src/Compiler.php @@ -2,27 +2,27 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; - -use Leafo\ScssPhp\Base\Range; -use Leafo\ScssPhp\Block; -use Leafo\ScssPhp\Cache; -use Leafo\ScssPhp\Colors; -use Leafo\ScssPhp\Compiler\Environment; -use Leafo\ScssPhp\Exception\CompilerException; -use Leafo\ScssPhp\Formatter\OutputBlock; -use Leafo\ScssPhp\Node; -use Leafo\ScssPhp\SourceMap\SourceMapGenerator; -use Leafo\ScssPhp\Type; -use Leafo\ScssPhp\Parser; -use Leafo\ScssPhp\Util; +namespace ScssPhp\ScssPhp; + +use ScssPhp\ScssPhp\Base\Range; +use ScssPhp\ScssPhp\Block; +use ScssPhp\ScssPhp\Cache; +use ScssPhp\ScssPhp\Colors; +use ScssPhp\ScssPhp\Compiler\Environment; +use ScssPhp\ScssPhp\Exception\CompilerException; +use ScssPhp\ScssPhp\Formatter\OutputBlock; +use ScssPhp\ScssPhp\Node; +use ScssPhp\ScssPhp\SourceMap\SourceMapGenerator; +use ScssPhp\ScssPhp\Type; +use ScssPhp\ScssPhp\Parser; +use ScssPhp\ScssPhp\Util; /** * The scss compiler and parser. @@ -130,15 +130,15 @@ class Compiler protected $sourceMapOptions = []; /** - * @var string|\Leafo\ScssPhp\Formatter + * @var string|\ScssPhp\ScssPhp\Formatter */ - protected $formatter = 'Leafo\ScssPhp\Formatter\Nested'; + protected $formatter = 'ScssPhp\ScssPhp\Formatter\Nested'; protected $rootEnv; protected $rootBlock; /** - * @var \Leafo\ScssPhp\Compiler\Environment + * @var \ScssPhp\ScssPhp\Compiler\Environment */ protected $env; protected $scope; @@ -203,19 +203,14 @@ public function getCompileOptions() public function compile($code, $path = null) { if ($this->cache) { - $cacheKey = ($path ? $path : "(stdin)") . ":" . md5($code); + $cacheKey = ($path ? $path : "(stdin)") . ":" . md5($code); $compileOptions = $this->getCompileOptions(); - $cache = $this->cache->getCache("compile", $cacheKey, $compileOptions); + $cache = $this->cache->getCache("compile", $cacheKey, $compileOptions); - if (is_array($cache) - && isset($cache['dependencies']) - && isset($cache['out']) - ) { + if (is_array($cache) && isset($cache['dependencies']) && isset($cache['out'])) { // check if any dependency file changed before accepting the cache foreach ($cache['dependencies'] as $file => $mtime) { - if (! file_exists($file) - || filemtime($file) !== $mtime - ) { + if (! file_exists($file) || filemtime($file) !== $mtime) { unset($cache); break; } @@ -242,7 +237,7 @@ public function compile($code, $path = null) $this->stderr = fopen('php://stderr', 'w'); $this->parser = $this->parserFactory($path); - $tree = $this->parser->parse($code); + $tree = $this->parser->parse($code); $this->parser = null; $this->formatter = new $this->formatter(); @@ -300,7 +295,7 @@ public function compile($code, $path = null) * * @param string $path * - * @return \Leafo\ScssPhp\Parser + * @return \ScssPhp\ScssPhp\Parser */ protected function parserFactory($path) { @@ -362,7 +357,7 @@ protected function pushExtends($target, $origin, $block) * @param string $type * @param array $selectors * - * @return \Leafo\ScssPhp\Formatter\OutputBlock + * @return \ScssPhp\ScssPhp\Formatter\OutputBlock */ protected function makeOutputBlock($type, $selectors = null) { @@ -390,7 +385,7 @@ protected function makeOutputBlock($type, $selectors = null) /** * Compile root * - * @param \Leafo\ScssPhp\Block $rootBlock + * @param \ScssPhp\ScssPhp\Block $rootBlock */ protected function compileRoot(Block $rootBlock) { @@ -429,8 +424,8 @@ protected function missingSelectors() /** * Flatten selectors * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block - * @param string $parentKey + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block + * @param string $parentKey */ protected function flattenSelectors(OutputBlock $block, $parentKey = null) { @@ -503,8 +498,8 @@ protected function glueFunctionSelectors($parts) } else { // a selector part finishing with a ) is the last part of a :not( or :nth-child( // and need to be joined to this - if (count($new) && is_string($new[count($new) - 1]) - && strlen($part) && substr($part, -1) === ')' && strpos($part, '(') === false + if (count($new) && is_string($new[count($new) - 1]) && + strlen($part) && substr($part, -1) === ')' && strpos($part, '(') === false ) { $new[count($new) - 1] .= $part; } else { @@ -530,6 +525,10 @@ protected function matchExtends($selector, &$out, $from = 0, $initial = true) $selector = $this->glueFunctionSelectors($selector); + if (count($selector) == 1 && in_array(reset($selector), $partsPile)) { + return; + } + foreach ($selector as $i => $part) { if ($i < $from) { continue; @@ -796,7 +795,7 @@ protected function combineSelectorSingle($base, $other) /** * Compile media * - * @param \Leafo\ScssPhp\Block $media + * @param \ScssPhp\ScssPhp\Block $media */ protected function compileMedia(Block $media) { @@ -879,9 +878,9 @@ protected function compileMedia(Block $media) /** * Media parent * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope * - * @return \Leafo\ScssPhp\Formatter\OutputBlock + * @return \ScssPhp\ScssPhp\Formatter\OutputBlock */ protected function mediaParent(OutputBlock $scope) { @@ -899,7 +898,7 @@ protected function mediaParent(OutputBlock $scope) /** * Compile directive * - * @param \Leafo\ScssPhp\Block $block + * @param \ScssPhp\ScssPhp\Block $block */ protected function compileDirective(Block $block) { @@ -919,13 +918,13 @@ protected function compileDirective(Block $block) /** * Compile at-root * - * @param \Leafo\ScssPhp\Block $block + * @param \ScssPhp\ScssPhp\Block $block */ protected function compileAtRoot(Block $block) { $env = $this->pushEnv($block); $envs = $this->compactEnv($env); - $without = isset($block->with) ? $this->compileWith($block->with) : static::WITH_RULE; + list($with, $without) = $this->compileWith(isset($block->with) ? $block->with : null); // wrap inline selector if ($block->selector) { @@ -952,10 +951,10 @@ protected function compileAtRoot(Block $block) $selfParent = $block->parent; } - $this->env = $this->filterWithout($envs, $without); + $this->env = $this->filterWithWithout($envs, $with, $without); $saveScope = $this->scope; - $this->scope = $this->filterScopeWithout($saveScope, $without); + $this->scope = $this->filterScopeWithWithout($saveScope, $with, $without); // propagate selfParent to the children where they still can be useful $this->compileChildrenNoReturn($block->children, $this->scope, $selfParent); @@ -970,14 +969,16 @@ protected function compileAtRoot(Block $block) /** * Filter at-root scope depending of with/without option * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope - * @param mixed $without + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope + * @param array $with + * @param array $without * * @return mixed */ - protected function filterScopeWithout($scope, $without) + protected function filterScopeWithWithout($scope, $with, $without) { $filteredScopes = []; + $childStash = []; if ($scope->type === TYPE::T_ROOT) { return $scope; @@ -985,6 +986,7 @@ protected function filterScopeWithout($scope, $without) // start from the root while ($scope->parent && $scope->parent->type !== TYPE::T_ROOT) { + array_unshift($childStash, $scope); $scope = $scope->parent; } @@ -993,7 +995,7 @@ protected function filterScopeWithout($scope, $without) break; } - if (! $this->isWithout($without, $scope)) { + if ($this->isWith($scope, $with, $without)) { $s = clone $scope; $s->children = []; $s->lines = []; @@ -1006,7 +1008,9 @@ protected function filterScopeWithout($scope, $without) $filteredScopes[] = $s; } - if ($scope->children) { + if (count($childStash)) { + $scope = array_shift($childStash); + } elseif ($scope->children) { $scope = end($scope->children); } else { $scope = null; @@ -1027,8 +1031,9 @@ protected function filterScopeWithout($scope, $without) while (count($filteredScopes)) { $s = array_shift($filteredScopes); $s->parent = $p; - $p->children[] = &$s; - $p = $s; + $p->children[] = $s; + $newScope = &$p->children[0]; + $p = &$p->children[0]; } return $newScope; @@ -1038,8 +1043,8 @@ protected function filterScopeWithout($scope, $without) * found missing selector from a at-root compilation in the previous scope * (if at-root is just enclosing a property, the selector is in the parent tree) * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope - * @param \Leafo\ScssPhp\Formatter\OutputBlock $previousScope + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $previousScope * * @return mixed */ @@ -1061,8 +1066,8 @@ protected function completeScope($scope, $previousScope) /** * Find a selector by the depth node in the scope * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $scope - * @param integer $depth + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $scope + * @param integer $depth * * @return array */ @@ -1084,69 +1089,60 @@ protected function findScopeSelectors($scope, $depth) } /** - * Compile @at-root's with: inclusion / without: exclusion into filter flags + * Compile @at-root's with: inclusion / without: exclusion into 2 lists uses to filter scope/env later * - * @param array $with + * @param array $withCondition * - * @return integer + * @return array */ - protected function compileWith($with) + protected function compileWith($withCondition) { - static $mapping = [ - 'rule' => self::WITH_RULE, - 'media' => self::WITH_MEDIA, - 'supports' => self::WITH_SUPPORTS, - 'all' => self::WITH_ALL, - ]; + // just compile what we have in 2 lists + $with = []; + $without = ['rule' => true]; - // exclude selectors by default - $without = static::WITH_RULE; + if ($withCondition) { + if ($this->libMapHasKey([$withCondition, static::$with])) { + $without = []; // cancel the default + $list = $this->coerceList($this->libMapGet([$withCondition, static::$with])); - if ($this->libMapHasKey([$with, static::$with])) { - $without = static::WITH_ALL; - - $list = $this->coerceList($this->libMapGet([$with, static::$with])); - - foreach ($list[2] as $item) { - $keyword = $this->compileStringContent($this->coerceString($item)); + foreach ($list[2] as $item) { + $keyword = $this->compileStringContent($this->coerceString($item)); - if (array_key_exists($keyword, $mapping)) { - $without &= ~($mapping[$keyword]); + $with[$keyword] = true; } } - } - if ($this->libMapHasKey([$with, static::$without])) { - $without = 0; + if ($this->libMapHasKey([$withCondition, static::$without])) { + $without = []; // cancel the default + $list = $this->coerceList($this->libMapGet([$withCondition, static::$without])); - $list = $this->coerceList($this->libMapGet([$with, static::$without])); - - foreach ($list[2] as $item) { - $keyword = $this->compileStringContent($this->coerceString($item)); + foreach ($list[2] as $item) { + $keyword = $this->compileStringContent($this->coerceString($item)); - if (array_key_exists($keyword, $mapping)) { - $without |= $mapping[$keyword]; + $without[$keyword] = true; } } } - return $without; + return [$with, $without]; } /** * Filter env stack * * @param array $envs - * @param integer $without + * @param array $with + * @param array $without * - * @return \Leafo\ScssPhp\Compiler\Environment + * @return \ScssPhp\ScssPhp\Compiler\Environment */ - protected function filterWithout($envs, $without) + protected function filterWithWithout($envs, $with, $without) { $filtered = []; foreach ($envs as $e) { - if ($e->block && $this->isWithout($without, $e->block)) { + if ($e->block && ! $this->isWith($e->block, $with, $without)) { $ec = clone $e; $ec->block = null; $ec->selectors = []; @@ -1162,41 +1158,72 @@ protected function filterWithout($envs, $without) /** * Filter WITH rules * - * @param integer $without - * @param \Leafo\ScssPhp\Block|\Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Block|\ScssPhp\ScssPhp\Formatter\OutputBlock $block + * @param array $with + * @param array $without * * @return boolean */ - protected function isWithout($without, $block) + protected function isWith($block, $with, $without) { if (isset($block->type)) { if ($block->type === Type::T_MEDIA) { - return ($without & static::WITH_MEDIA) ? true : false; + return $this->testWithWithout('media', $with, $without); } if ($block->type === Type::T_DIRECTIVE) { - if (isset($block->name) && $block->name === 'supports') { - return ($without & static::WITH_SUPPORTS) ? true : false; + if (isset($block->name)) { + return $this->testWithWithout($block->name, $with, $without); + } elseif (isset($block->selectors) && preg_match(',@(\w+),ims', json_encode($block->selectors), $m)) { + return $this->testWithWithout($m[1], $with, $without); + } else { + return $this->testWithWithout('???', $with, $without); } - - if (isset($block->selectors) && strpos(serialize($block->selectors), '@supports') !== false) { - return ($without & static::WITH_SUPPORTS) ? true : false; + } + } elseif (isset($block->selectors)) { + // a selector starting with number is a keyframe rule + if (count($block->selectors)) { + $s = reset($block->selectors); + while (is_array($s)) { + $s = reset($s); + } + if (is_object($s) && get_class($s) === 'ScssPhp\ScssPhp\Node\Number') { + return $this->testWithWithout('keyframes', $with, $without); } } + return $this->testWithWithout('rule', $with, $without); } - if ((($without & static::WITH_RULE) && isset($block->selectors))) { - return true; + return true; + } + + /** + * Test a single type of block against with/without lists + * + * @param string $what + * @param array $with + * @param array $without + * @return bool + * true if the block should be kept, false to reject + */ + protected function testWithWithout($what, $with, $without) + { + + // if without, reject only if in the list (or 'all' is in the list) + if (count($without)) { + return (isset($without[$what]) || isset($without['all'])) ? false : true; } - return false; + // otherwise reject all what is not in the with list + return (isset($with[$what]) || isset($with['all'])) ? true : false; } + /** * Compile keyframe block * - * @param \Leafo\ScssPhp\Block $block - * @param array $selectors + * @param \ScssPhp\ScssPhp\Block $block + * @param array $selectors */ protected function compileKeyframeBlock(Block $block, $selectors) { @@ -1220,11 +1247,44 @@ protected function compileKeyframeBlock(Block $block, $selectors) $this->popEnv(); } + /** + * Compile nested properties lines + * + * @param \ScssPhp\ScssPhp\Block $block + * @param OutputBlock $out + */ + protected function compileNestedPropertiesBlock(Block $block, OutputBlock $out) + { + $prefix = $this->compileValue($block->prefix) . '-'; + + $nested = $this->makeOutputBlock($block->type); + $nested->parent = $out; + + if ($block->hasValue) { + $nested->depth = $out->depth + 1; + } + + $out->children[] = $nested; + + foreach ($block->children as $child) { + switch ($child[0]) { + case Type::T_ASSIGN: + array_unshift($child[1][2], $prefix); + break; + + case Type::T_NESTED_PROPERTY: + array_unshift($child[1]->prefix[2], $prefix); + break; + } + $this->compileChild($child, $nested); + } + } + /** * Compile nested block * - * @param \Leafo\ScssPhp\Block $block - * @param array $selectors + * @param \ScssPhp\ScssPhp\Block $block + * @param array $selectors */ protected function compileNestedBlock(Block $block, $selectors) { @@ -1285,7 +1345,7 @@ protected function compileNestedBlock(Block $block, $selectors) * * @see Compiler::compileChild() * - * @param \Leafo\ScssPhp\Block $block + * @param \ScssPhp\ScssPhp\Block $block */ protected function compileBlock(Block $block) { @@ -1640,9 +1700,9 @@ protected function popCallStack() /** * Compile children and return result * - * @param array $stms - * @param \Leafo\ScssPhp\Formatter\OutputBlock $out - * @param string $traceName + * @param array $stms + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out + * @param string $traceName * * @return array|null */ @@ -1666,10 +1726,10 @@ protected function compileChildren($stms, OutputBlock $out, $traceName = '') /** * Compile children and throw exception if unexpected @return * - * @param array $stms - * @param \Leafo\ScssPhp\Formatter\OutputBlock $out - * @param \Leafo\ScssPhp\Block $selfParent - * @param string $traceName + * @param array $stms + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out + * @param \ScssPhp\ScssPhp\Block $selfParent + * @param string $traceName * * @throws \Exception */ @@ -1682,7 +1742,7 @@ protected function compileChildrenNoReturn($stms, OutputBlock $out, $selfParent $stm[1]->selfParent = $selfParent; $ret = $this->compileChild($stm, $out); $stm[1]->selfParent = null; - } elseif ($selfParent && $stm[0] === TYPE::T_INCLUDE) { + } elseif ($selfParent && in_array($stm[0], [TYPE::T_INCLUDE, TYPE::T_EXTEND])) { $stm['selfParent'] = $selfParent; $ret = $this->compileChild($stm, $out); unset($stm['selfParent']); @@ -1710,52 +1770,50 @@ protected function compileChildrenNoReturn($stms, OutputBlock $out, $selfParent */ protected function evaluateMediaQuery($queryList) { + static $parser = null; + $outQueryList = []; foreach ($queryList as $kql => $query) { + $shouldReparse = false; foreach ($query as $kq => $q) { for ($i = 1; $i < count($q); $i++) { $value = $this->compileValue($q[$i]); // the parser had no mean to know if media type or expression if it was an interpolation + // so you need to reparse if the T_MEDIA_TYPE looks like anything else a media type if ($q[0] == Type::T_MEDIA_TYPE && (strpos($value, '(') !== false || strpos($value, ')') !== false || - strpos($value, ':') !== false) + strpos($value, ':') !== false || + strpos($value, ',') !== false) ) { - $queryList[$kql][$kq][0] = Type::T_MEDIA_EXPRESSION; - - if (strpos($value, 'and') !== false) { - $values = explode('and', $value); - $value = trim(array_pop($values)); - - while ($v = trim(array_pop($values))) { - $type = Type::T_MEDIA_EXPRESSION; - - if (strpos($v, '(') === false && - strpos($v, ')') === false && - strpos($v, ':') === false - ) { - $type = Type::T_MEDIA_TYPE; - } - - if (substr($v, 0, 1) === '(' && substr($v, -1) === ')') { - $v = substr($v, 1, -1); - } - - $queryList[$kql][] = [$type,[Type::T_KEYWORD, $v]]; - } - } - - if (substr($value, 0, 1) === '(' && substr($value, -1) === ')') { - $value = substr($value, 1, -1); - } + $shouldReparse = true; } $queryList[$kql][$kq][$i] = [Type::T_KEYWORD, $value]; } } + if ($shouldReparse) { + if (is_null($parser)) { + $parser = $this->parserFactory(__METHOD__); + } + $queryString = $this->compileMediaQuery([$queryList[$kql]]); + $queryString = reset($queryString); + if (strpos($queryString, '@media ') === 0) { + $queryString = substr($queryString, 7); + $queries = []; + if ($parser->parseMediaQueryList($queryString, $queries)) { + $queries = $this->evaluateMediaQuery($queries[2]); + while (count($queries)) { + $outQueryList[] = array_shift($queries); + } + continue; + } + } + } + $outQueryList[] = $queryList[$kql]; } - return $queryList; + return $outQueryList; } /** @@ -1993,9 +2051,9 @@ protected function mergeMediaTypes($type1, $type2) /** * Compile import; returns true if the value was something that could be imported * - * @param array $rawPath - * @param \Leafo\ScssPhp\Formatter\OutputBlock $out - * @param boolean $once + * @param array $rawPath + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out + * @param boolean $once * * @return boolean */ @@ -2013,6 +2071,8 @@ protected function compileImport($rawPath, OutputBlock $out, $once = false) return true; } + $this->appendRootDirective('@import ' . $this->compileValue($rawPath). ';', $out); + return false; } @@ -2024,25 +2084,120 @@ protected function compileImport($rawPath, OutputBlock $out, $once = false) foreach ($rawPath[2] as $path) { if ($path[0] !== Type::T_STRING) { + $this->appendRootDirective('@import ' . $this->compileValue($rawPath) . ';', $out); return false; } } foreach ($rawPath[2] as $path) { - $this->compileImport($path, $out); + $this->compileImport($path, $out, $once); } return true; } + $this->appendRootDirective('@import ' . $this->compileValue($rawPath) . ';', $out); + return false; } + + /** + * Append a root directive like @import or @charset as near as the possible from the source code + * (keeping before comments, @import and @charset coming before in the source code) + * + * @param string $line + * @param @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out + * @param array $allowed + */ + protected function appendRootDirective($line, $out, $allowed = [Type::T_COMMENT]) + { + $root = $out; + + while ($root->parent) { + $root = $root->parent; + } + + $i = 0; + + while ($i < count($root->children)) { + if (! isset($root->children[$i]->type) || ! in_array($root->children[$i]->type, $allowed)) { + break; + } + + $i++; + } + + // remove incompatible children from the bottom of the list + $saveChildren = []; + + while ($i < count($root->children)) { + $saveChildren[] = array_pop($root->children); + } + + // insert the directive as a comment + $child = $this->makeOutputBlock(Type::T_COMMENT); + $child->lines[] = $line; + $child->sourceName = $this->sourceNames[$this->sourceIndex]; + $child->sourceLine = $this->sourceLine; + $child->sourceColumn = $this->sourceColumn; + + $root->children[] = $child; + + // repush children + while (count($saveChildren)) { + $root->children[] = array_pop($saveChildren); + } + } + + /** + * Append lines to the courrent output block: + * directly to the block or through a child if necessary + * + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out + * @param string $type + * @param string $line + */ + protected function appendOutputLine(OutputBlock $out, $type, $line) + { + $outWrite = &$out; + + if ($type === Type::T_COMMENT) { + $parent = $out->parent; + + if (end($parent->children) !== $out) { + $outWrite = &$parent->children[count($parent->children)-1]; + } + + if (!is_string($line)) { + $line = $this->compileValue($line); + } + } + + // check if it's a flat output or not + if (count($out->children)) { + $lastChild = &$out->children[count($out->children) -1]; + + if ($lastChild->depth === $out->depth && is_null($lastChild->selectors) && ! count($lastChild->children)) { + $outWrite = $lastChild; + } else { + $nextLines = $this->makeOutputBlock($type); + $nextLines->parent = $out; + $nextLines->depth = $out->depth; + + $out->children[] = $nextLines; + $outWrite = &$nextLines; + } + } + + $outWrite->lines[] = $line; + } + /** * Compile child; returns a value to halt execution * - * @param array $child - * @param \Leafo\ScssPhp\Formatter\OutputBlock $out + * @param array $child + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out * * @return array */ @@ -2069,17 +2224,13 @@ protected function compileChild($child, OutputBlock $out) case Type::T_SCSSPHP_IMPORT_ONCE: $rawPath = $this->reduce($child[1]); - if (! $this->compileImport($rawPath, $out, true)) { - $out->lines[] = '@import ' . $this->compileValue($rawPath) . ';'; - } + $this->compileImport($rawPath, $out, true); break; case Type::T_IMPORT: $rawPath = $this->reduce($child[1]); - if (! $this->compileImport($rawPath, $out)) { - $out->lines[] = '@import ' . $this->compileValue($rawPath) . ';'; - } + $this->compileImport($rawPath, $out); break; case Type::T_DIRECTIVE: @@ -2101,8 +2252,7 @@ protected function compileChild($child, OutputBlock $out) case Type::T_CHARSET: if (! $this->charsetSeen) { $this->charsetSeen = true; - - $out->lines[] = '@charset ' . $this->compileValue($child[1]) . ';'; + $this->appendRootDirective('@charset ' . $this->compileValue($child[1]) . ';', $out); } break; @@ -2120,8 +2270,8 @@ protected function compileChild($child, OutputBlock $out) } $shouldSet = $isDefault && - (($result = $this->get($name[1], false)) === null - || $result === static::$null); + (($result = $this->get($name[1], false)) === null || + $result === static::$null); if (! $isDefault || $shouldSet) { $this->set($name[1], $this->reduce($value), true, null, $value); @@ -2170,10 +2320,11 @@ protected function compileChild($child, OutputBlock $out) $compiledValue = $this->compileValue($value); - $out->lines[] = $this->formatter->property( + $line = $this->formatter->property( $compiledName, $compiledValue ); + $this->appendOutputLine($out, Type::T_ASSIGN, $line); break; case Type::T_COMMENT: @@ -2182,14 +2333,14 @@ protected function compileChild($child, OutputBlock $out) break; } - $out->lines[] = $child[1]; + $this->appendOutputLine($out, Type::T_COMMENT, $child[1]); break; case Type::T_MIXIN: case Type::T_FUNCTION: list(, $block) = $child; - $this->set(static::$namespaces[$block->type] . $block->name, $block); + $this->set(static::$namespaces[$block->type] . $block->name, $block, true); break; case Type::T_EXTEND: @@ -2199,8 +2350,11 @@ protected function compileChild($child, OutputBlock $out) foreach ($results as $result) { // only use the first one $result = current($result); - - $this->pushExtends($result, $out->selectors, $child); + $selectors = $out->selectors; + if (!$selectors && isset($child['selfParent'])) { + $selectors = $this->multiplySelectors($this->env, $child['selfParent']); + } + $this->pushExtends($result, $selectors, $child); } } break; @@ -2327,31 +2481,12 @@ protected function compileChild($child, OutputBlock $out) return $this->reduce($child[1], true); case Type::T_NESTED_PROPERTY: - list(, $prop) = $child; - - $prefixed = []; - $prefix = $this->compileValue($prop->prefix) . '-'; - - foreach ($prop->children as $child) { - switch ($child[0]) { - case Type::T_ASSIGN: - array_unshift($child[1][2], $prefix); - break; - - case Type::T_NESTED_PROPERTY: - array_unshift($child[1]->prefix[2], $prefix); - break; - } - - $prefixed[] = $child; - } - - $this->compileChildrenNoReturn($prefixed, $out); + $this->compileNestedPropertiesBlock($child[1], $out); break; case Type::T_INCLUDE: // including a mixin - list(, $name, $argValues, $content) = $child; + list(, $name, $argValues, $content, $argUsing) = $child; $mixin = $this->get(static::$namespaces['mixin'] . $name, false); @@ -2394,9 +2529,18 @@ protected function compileChild($child, OutputBlock $out) // i.e., recursive @include of the same mixin if (isset($content)) { $copyContent = clone $content; - $copyContent->scope = $callingScope; + $copyContent->scope = clone $callingScope; $this->setRaw(static::$namespaces['special'] . 'content', $copyContent, $this->env); + } else { + $this->setRaw(static::$namespaces['special'] . 'content', null, $this->env); + } + + // save the "using" argument list for applying it to when "@content" is invoked + if (isset($argUsing)) { + $this->setRaw(static::$namespaces['special'] . 'using', $argUsing, $this->env); + } else { + $this->setRaw(static::$namespaces['special'] . 'using', null, $this->env); } if (isset($mixin->args)) { @@ -2415,16 +2559,32 @@ protected function compileChild($child, OutputBlock $out) case Type::T_MIXIN_CONTENT: $env = isset($this->storeEnv) ? $this->storeEnv : $this->env; $content = $this->get(static::$namespaces['special'] . 'content', false, $env); + $argUsing = $this->get(static::$namespaces['special'] . 'using', false, $env); + $argContent = $child[1]; if (! $content) { $content = new \stdClass(); $content->scope = new \stdClass(); - $content->children = $this->storeEnv->parent->block->children; + $content->children = $env->parent->block->children; break; } $storeEnv = $this->storeEnv; + + $varsUsing = []; + if (isset($argUsing) && isset($argContent)) { + // Get the arguments provided for the content with the names provided in the "using" argument list + $this->storeEnv = $this->env; + $varsUsing = $this->applyArguments($argUsing, $argContent, false); + } + + // restore the scope from the @content $this->storeEnv = $content->scope; + // append the vars from using if any + foreach ($varsUsing as $name => $val) { + $this->set($name, $val, true, $this->storeEnv); + } + $this->compileChildrenNoReturn($content->children, $out); $this->storeEnv = $storeEnv; @@ -2548,7 +2708,7 @@ protected function shouldEval($value) * @param array $value * @param boolean $inExp * - * @return array|\Leafo\ScssPhp\Node\Number + * @return array|\ScssPhp\ScssPhp\Node\Number */ protected function reduce($value, $inExp = false) { @@ -2567,9 +2727,9 @@ protected function reduce($value, $inExp = false) } // special case: looks like css shorthand - if ($opName == 'div' && ! $inParens && ! $inExp && isset($right[2]) - && (($right[0] !== Type::T_NUMBER && $right[2] != '') - || ($right[0] === Type::T_NUMBER && ! $right->unitless())) + if ($opName == 'div' && ! $inParens && ! $inExp && isset($right[2]) && + (($right[0] !== Type::T_NUMBER && $right[2] != '') || + ($right[0] === Type::T_NUMBER && ! $right->unitless())) ) { return $this->expToString($value); } @@ -2825,7 +2985,7 @@ public function normalizeValue($value) * @param array $left * @param array $right * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ protected function opAddNumberNumber($left, $right) { @@ -2838,7 +2998,7 @@ protected function opAddNumberNumber($left, $right) * @param array $left * @param array $right * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ protected function opMulNumberNumber($left, $right) { @@ -2851,7 +3011,7 @@ protected function opMulNumberNumber($left, $right) * @param array $left * @param array $right * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ protected function opSubNumberNumber($left, $right) { @@ -2864,7 +3024,7 @@ protected function opSubNumberNumber($left, $right) * @param array $left * @param array $right * - * @return array|\Leafo\ScssPhp\Node\Number + * @return array|\ScssPhp\ScssPhp\Node\Number */ protected function opDivNumberNumber($left, $right) { @@ -2881,7 +3041,7 @@ protected function opDivNumberNumber($left, $right) * @param array $left * @param array $right * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ protected function opModNumberNumber($left, $right) { @@ -3181,7 +3341,7 @@ protected function opLtNumberNumber($left, $right) * @param array $left * @param array $right * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ protected function opCmpNumberNumber($left, $right) { @@ -3311,11 +3471,19 @@ public function compileValue($value) list(, $interpolate, $left, $right) = $value; list(,, $whiteLeft, $whiteRight) = $interpolate; + $delim = $left[1]; + if ($delim && $delim !== ' ' && !$whiteLeft) { + $delim .= ' '; + } $left = count($left[2]) > 0 ? - $this->compileValue($left) . $whiteLeft : ''; + $this->compileValue($left) . $delim . $whiteLeft: ''; + $delim = $right[1]; + if ($delim && $delim !== ' ') { + $delim .= ' '; + } $right = count($right[2]) > 0 ? - $whiteRight . $this->compileValue($right) : ''; + $whiteRight . $delim . $this->compileValue($right) : ''; return $left . $this->compileValue($interpolate) . $right; @@ -3371,7 +3539,7 @@ public function compileValue($value) return 'null'; default: - $this->throwError("unknown value type: $value[0]"); + $this->throwError("unknown value type: ".json_encode($value)); } } @@ -3435,8 +3603,8 @@ protected function extractInterpolation($list) /** * Find the final set of selectors * - * @param \Leafo\ScssPhp\Compiler\Environment $env - * @param \Leafo\ScssPhp\Block $selfParent + * @param \ScssPhp\ScssPhp\Compiler\Environment $env + * @param \ScssPhp\ScssPhp\Block $selfParent * * @return array */ @@ -3551,8 +3719,8 @@ protected function joinSelectors($parent, $child, &$stillHasSelf, $selfParentSel /** * Multiply media * - * @param \Leafo\ScssPhp\Compiler\Environment $env - * @param array $childQueries + * @param \ScssPhp\ScssPhp\Compiler\Environment $env + * @param array $childQueries * * @return array */ @@ -3602,7 +3770,7 @@ protected function multiplyMedia(Environment $env = null, $childQueries = null) /** * Convert env linked list to stack * - * @param \Leafo\ScssPhp\Compiler\Environment $env + * @param \ScssPhp\ScssPhp\Compiler\Environment $env * * @return array */ @@ -3620,7 +3788,7 @@ protected function compactEnv(Environment $env) * * @param array $envs * - * @return \Leafo\ScssPhp\Compiler\Environment + * @return \ScssPhp\ScssPhp\Compiler\Environment */ protected function extractEnv($envs) { @@ -3635,9 +3803,9 @@ protected function extractEnv($envs) /** * Push environment * - * @param \Leafo\ScssPhp\Block $block + * @param \ScssPhp\ScssPhp\Block $block * - * @return \Leafo\ScssPhp\Compiler\Environment + * @return \ScssPhp\ScssPhp\Compiler\Environment */ protected function pushEnv(Block $block = null) { @@ -3663,7 +3831,7 @@ protected function popEnv() /** * Get store environment * - * @return \Leafo\ScssPhp\Compiler\Environment + * @return \ScssPhp\ScssPhp\Compiler\Environment */ protected function getStoreEnv() { @@ -3673,11 +3841,11 @@ protected function getStoreEnv() /** * Set variable * - * @param string $name - * @param mixed $value - * @param boolean $shadow - * @param \Leafo\ScssPhp\Compiler\Environment $env - * @param mixed $valueUnreduced + * @param string $name + * @param mixed $value + * @param boolean $shadow + * @param \ScssPhp\ScssPhp\Compiler\Environment $env + * @param mixed $valueUnreduced */ protected function set($name, $value, $shadow = false, Environment $env = null, $valueUnreduced = null) { @@ -3697,10 +3865,10 @@ protected function set($name, $value, $shadow = false, Environment $env = null, /** * Set existing variable * - * @param string $name - * @param mixed $value - * @param \Leafo\ScssPhp\Compiler\Environment $env - * @param mixed $valueUnreduced + * @param string $name + * @param mixed $value + * @param \ScssPhp\ScssPhp\Compiler\Environment $env + * @param mixed $valueUnreduced */ protected function setExisting($name, $value, Environment $env, $valueUnreduced = null) { @@ -3736,10 +3904,10 @@ protected function setExisting($name, $value, Environment $env, $valueUnreduced /** * Set raw variable * - * @param string $name - * @param mixed $value - * @param \Leafo\ScssPhp\Compiler\Environment $env - * @param mixed $valueUnreduced + * @param string $name + * @param mixed $value + * @param \ScssPhp\ScssPhp\Compiler\Environment $env + * @param mixed $valueUnreduced */ protected function setRaw($name, $value, Environment $env, $valueUnreduced = null) { @@ -3755,10 +3923,10 @@ protected function setRaw($name, $value, Environment $env, $valueUnreduced = nul * * @api * - * @param string $name - * @param boolean $shouldThrow - * @param \Leafo\ScssPhp\Compiler\Environment $env - * @param boolean $unreduced + * @param string $name + * @param boolean $shouldThrow + * @param \ScssPhp\ScssPhp\Compiler\Environment $env + * @param boolean $unreduced * * @return mixed|null */ @@ -3817,8 +3985,8 @@ public function get($name, $shouldThrow = true, Environment $env = null, $unredu /** * Has variable? * - * @param string $name - * @param \Leafo\ScssPhp\Compiler\Environment $env + * @param string $name + * @param \ScssPhp\ScssPhp\Compiler\Environment $env * * @return boolean */ @@ -4042,8 +4210,8 @@ public function addFeature($name) /** * Import file * - * @param string $path - * @param \Leafo\ScssPhp\Formatter\OutputBlock $out + * @param string $path + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $out */ protected function importFile($path, OutputBlock $out) { @@ -4138,7 +4306,7 @@ public function setEncoding($encoding) * * @param boolean $ignoreErrors * - * @return \Leafo\ScssPhp\Compiler + * @return \ScssPhp\ScssPhp\Compiler */ public function setIgnoreErrors($ignoreErrors) { @@ -4154,7 +4322,7 @@ public function setIgnoreErrors($ignoreErrors) * * @param string $msg Message with optional sprintf()-style vararg parameters * - * @throws \Leafo\ScssPhp\Exception\CompilerException + * @throws \ScssPhp\ScssPhp\Exception\CompilerException */ public function throwError($msg) { @@ -4317,11 +4485,15 @@ protected function callNativeFunction($name, $args, &$returnValue) return false; } - @list($sorted, $kwargs) = $this->sortArgs($prototype, $args); + @list($sorted, $kwargs) = $this->sortNativeFunctionArgs($prototype, $args); if ($name !== 'if' && $name !== 'call') { + $inExp = true; + if ($name === 'join') { + $inExp = false; + } foreach ($sorted as &$val) { - $val = $this->reduce($val, true); + $val = $this->reduce($val, $inExp); } } @@ -4364,40 +4536,118 @@ function ($m) { * * @return array */ - protected function sortArgs($prototype, $args) + protected function sortNativeFunctionArgs($prototypes, $args) { - $keyArgs = []; - $posArgs = []; + static $parser = null; - // separate positional and keyword arguments - foreach ($args as $arg) { - list($key, $value) = $arg; + if (! isset($prototypes)) { + $keyArgs = []; + $posArgs = []; + + // separate positional and keyword arguments + foreach ($args as $arg) { + list($key, $value) = $arg; - $key = $key[1]; + $key = $key[1]; - if (empty($key)) { - $posArgs[] = empty($arg[2]) ? $value : $arg; - } else { - $keyArgs[$key] = $value; + if (empty($key)) { + $posArgs[] = empty($arg[2]) ? $value : $arg; + } else { + $keyArgs[$key] = $value; + } } - } - if (! isset($prototype)) { return [$posArgs, $keyArgs]; } - // copy positional args - $finalArgs = array_pad($posArgs, count($prototype), null); + $finalArgs = []; + + if (! is_array(reset($prototypes))) { + $prototypes = [$prototypes]; + } + + $keyArgs = []; + + // trying each prototypes + $prototypeHasMatch = false; + $exceptionMessage = ''; + + foreach ($prototypes as $prototype) { + $argDef = []; + + foreach ($prototype as $i => $p) { + $default = null; + $p = explode(':', $p, 2); + $name = array_shift($p); + + if (count($p)) { + $p = trim(reset($p)); + + if ($p === 'null') { + // differentiate this null from the static::$null + $default = [Type::T_KEYWORD, 'null']; + } else { + if (is_null($parser)) { + $parser = $this->parserFactory(__METHOD__); + } + + $parser->parseValue($p, $default); + } + } + + $isVariable = false; + + if (substr($name, -3) === '...') { + $isVariable = true; + $name = substr($name, 0, -3); + } + + $argDef[] = [$name, $default, $isVariable]; + } + + try { + $vars = $this->applyArguments($argDef, $args, false, false); + + // ensure all args are populated + foreach ($prototype as $i => $p) { + $name = explode(':', $p)[0]; + + if (! isset($finalArgs[$i])) { + $finalArgs[$i] = null; + } + } + + // apply positional args + foreach (array_values($vars) as $i => $val) { + $finalArgs[$i] = $val; + } + + $keyArgs = array_merge($keyArgs, $vars); + $prototypeHasMatch = true; + + // overwrite positional args with keyword args + foreach ($prototype as $i => $p) { + $name = explode(':', $p)[0]; + + if (isset($keyArgs[$name])) { + $finalArgs[$i] = $keyArgs[$name]; + } - // overwrite positional args with keyword args - foreach ($prototype as $i => $names) { - foreach ((array) $names as $name) { - if (isset($keyArgs[$name])) { - $finalArgs[$i] = $keyArgs[$name]; + // special null value as default: translate to real null here + if ($finalArgs[$i] === [Type::T_KEYWORD, 'null']) { + $finalArgs[$i] = null; + } } + // should we break if this prototype seems fulfilled? + } catch (CompilerException $e) { + $exceptionMessage = $e->getMessage(); } } + if ($exceptionMessage && ! $prototypeHasMatch) { + $this->throwError($exceptionMessage); + } + return [$finalArgs, $keyArgs]; } @@ -4406,15 +4656,21 @@ protected function sortArgs($prototype, $args) * * @param array $argDef * @param array $argValues - * + * @param bool $storeInEnv + * @param bool $reduce + * only used if $storeInEnv = false * @throws \Exception */ - protected function applyArguments($argDef, $argValues) + protected function applyArguments($argDef, $argValues, $storeInEnv = true, $reduce = true) { - $storeEnv = $this->getStoreEnv(); + $output = []; - $env = new Environment; - $env->store = $storeEnv->store; + if ($storeInEnv) { + $storeEnv = $this->getStoreEnv(); + + $env = new Environment; + $env->store = $storeEnv->store; + } $hasVariable = false; $args = []; @@ -4426,14 +4682,18 @@ protected function applyArguments($argDef, $argValues) $hasVariable |= $isVariable; } - $keywordArgs = []; + $splatSeparator = null; + $keywordArgs = []; $deferredKeywordArgs = []; - $remaining = []; + $remaining = []; + $hasKeywordArgument = false; // assign the keyword args foreach ((array) $argValues as $arg) { if (! empty($arg[0])) { - if (! isset($args[$arg[0][1]])) { + $hasKeywordArgument = true; + + if (! isset($args[$arg[0][1]]) || $args[$arg[0][1]][3]) { if ($hasVariable) { $deferredKeywordArgs[$arg[0][1]] = $arg[1]; } else { @@ -4446,17 +4706,30 @@ protected function applyArguments($argDef, $argValues) } else { $keywordArgs[$arg[0][1]] = $arg[1]; } - } elseif (count($keywordArgs)) { - $this->throwError('Positional arguments must come before keyword arguments.'); - break; } elseif ($arg[2] === true) { $val = $this->reduce($arg[1], true); if ($val[0] === Type::T_LIST) { foreach ($val[2] as $name => $item) { if (! is_numeric($name)) { - $keywordArgs[$name] = $item; + if (!isset($args[$name])) { + foreach (array_keys($args) as $an) { + if (str_replace("_", "-", $an) === str_replace("_", "-", $name)) { + $name = $an; + break; + } + } + } + + if ($hasVariable) { + $deferredKeywordArgs[$name] = $item; + } else { + $keywordArgs[$name] = $item; + } } else { + if (is_null($splatSeparator)) { + $splatSeparator = $val[1]; + } $remaining[] = $item; } } @@ -4466,14 +4739,32 @@ protected function applyArguments($argDef, $argValues) $item = $val[2][$i]; if (! is_numeric($name)) { - $keywordArgs[$name] = $item; + if (!isset($args[$name])) { + foreach (array_keys($args) as $an) { + if (str_replace("_", "-", $an) === str_replace("_", "-", $name)) { + $name = $an; + break; + } + } + } + if ($hasVariable) { + $deferredKeywordArgs[$name] = $item; + } else { + $keywordArgs[$name] = $item; + } } else { + if (is_null($splatSeparator)) { + $splatSeparator = $val[1]; + } $remaining[] = $item; } } } else { $remaining[] = $val; } + } elseif ($hasKeywordArgument) { + $this->throwError('Positional arguments must come before keyword arguments.'); + break; } else { $remaining[] = $arg[1]; } @@ -4483,7 +4774,7 @@ protected function applyArguments($argDef, $argValues) list($i, $name, $default, $isVariable) = $arg; if ($isVariable) { - $val = [Type::T_LIST, ',', [], $isVariable]; + $val = [Type::T_LIST, is_null($splatSeparator) ? ',' : $splatSeparator , [], $isVariable]; for ($count = count($remaining); $i < $count; $i++) { $val[2][] = $remaining[$i]; @@ -4503,10 +4794,16 @@ protected function applyArguments($argDef, $argValues) break; } - $this->set($name, $this->reduce($val, true), true, $env); + if ($storeInEnv) { + $this->set($name, $this->reduce($val, true), true, $env); + } else { + $output[$name] = ($reduce ? $this->reduce($val, true) : $val); + } } - $storeEnv->store = $env->store; + if ($storeInEnv) { + $storeEnv->store = $env->store; + } foreach ($args as $arg) { list($i, $name, $default, $isVariable) = $arg; @@ -4515,8 +4812,14 @@ protected function applyArguments($argDef, $argValues) continue; } - $this->set($name, $this->reduce($default, true), true); + if ($storeInEnv) { + $this->set($name, $this->reduce($default, true), true); + } else { + $output[$name] = ($reduce ? $this->reduce($default, true) : $default); + } } + + return $output; } /** @@ -4524,7 +4827,7 @@ protected function applyArguments($argDef, $argValues) * * @param mixed $value * - * @return array|\Leafo\ScssPhp\Node\Number + * @return array|\ScssPhp\ScssPhp\Node\Number */ protected function coerceValue($value) { @@ -4617,10 +4920,20 @@ protected function coerceList($item, $delim = ',') $key = $keys[$i]; $value = $values[$i]; + switch ($key[0]) { + case Type::T_LIST: + case Type::T_MAP: + break; + + default: + $key = [Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))]; + break; + } + $list[] = [ Type::T_LIST, '', - [[Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))], $value] + [$key, $value] ]; } @@ -4923,46 +5236,27 @@ public function toRGB($hue, $saturation, $lightness) // Built in functions - //protected static $libCall = ['name', 'args...']; + protected static $libCall = ['name', 'args...']; protected function libCall($args, $kwargs) { $name = $this->compileStringContent($this->coerceString($this->reduce(array_shift($args), true))); + $callArgs = []; - $posArgs = []; - - foreach ($args as $arg) { - if (empty($arg[0])) { - if ($arg[2] === true) { - $tmp = $this->reduce($arg[1]); - - if ($tmp[0] === Type::T_LIST) { - foreach ($tmp[2] as $item) { - $posArgs[] = [null, $item, false]; - } - } else { - $posArgs[] = [null, $tmp, true]; - } - - continue; - } - - $posArgs[] = [null, $this->reduce($arg), false]; - continue; + // $kwargs['args'] is [Type::T_LIST, ',', [..]] + foreach ($kwargs['args'][2] as $varname => $arg) { + if (is_numeric($varname)) { + $varname = null; + } else { + $varname = [ 'var', $varname]; } - $posArgs[] = [null, $arg, false]; + $callArgs[] = [$varname, $arg, false]; } - if (count($kwargs)) { - foreach ($kwargs as $key => $value) { - $posArgs[] = [[Type::T_VARIABLE, $key], $value, false]; - } - } - - return $this->reduce([Type::T_FUNCTION_CALL, $name, $posArgs]); + return $this->reduce([Type::T_FUNCTION_CALL, $name, $callArgs]); } - protected static $libIf = ['condition', 'if-true', 'if-false']; + protected static $libIf = ['condition', 'if-true', 'if-false:']; protected function libIf($args) { list($cond, $t, $f) = $args; @@ -5015,8 +5309,8 @@ protected function libRgb($args) } protected static $libRgba = [ - ['red', 'color'], - 'green', 'blue', 'alpha']; + ['color', 'alpha:1'], + ['red', 'green', 'blue', 'alpha:1'] ]; protected function libRgba($args) { if ($color = $this->coerceColor($args[0])) { @@ -5045,11 +5339,11 @@ protected function alterColor($args, $fn) } } - if (isset($args[4]) || isset($args[5]) || isset($args[6])) { + if (! empty($args[4]) || ! empty($args[5]) || ! empty($args[6])) { $hsl = $this->toHSL($color[1], $color[2], $color[3]); foreach ([4, 5, 6] as $i) { - if (isset($args[$i])) { + if (! empty($args[$i])) { $val = $this->assertNumber($args[$i]); $hsl[$i - 3] = call_user_func($fn, $hsl[$i - 3], $val, $i); } @@ -5068,8 +5362,8 @@ protected function alterColor($args, $fn) } protected static $libAdjustColor = [ - 'color', 'red', 'green', 'blue', - 'hue', 'saturation', 'lightness', 'alpha' + 'color', 'red:null', 'green:null', 'blue:null', + 'hue:null', 'saturation:null', 'lightness:null', 'alpha:null' ]; protected function libAdjustColor($args) { @@ -5079,8 +5373,8 @@ protected function libAdjustColor($args) } protected static $libChangeColor = [ - 'color', 'red', 'green', 'blue', - 'hue', 'saturation', 'lightness', 'alpha' + 'color', 'red:null', 'green:null', 'blue:null', + 'hue:null', 'saturation:null', 'lightness:null', 'alpha:null' ]; protected function libChangeColor($args) { @@ -5090,8 +5384,8 @@ protected function libChangeColor($args) } protected static $libScaleColor = [ - 'color', 'red', 'green', 'blue', - 'hue', 'saturation', 'lightness', 'alpha' + 'color', 'red:null', 'green:null', 'blue:null', + 'hue:null', 'saturation:null', 'lightness:null', 'alpha:null' ]; protected function libScaleColor($args) { @@ -5185,7 +5479,7 @@ protected function libOpacity($args) } // mix two colors - protected static $libMix = ['color-1', 'color-2', 'weight']; + protected static $libMix = ['color-1', 'color-2', 'weight:0.5']; protected function libMix($args) { list($first, $second, $weight) = $args; @@ -5307,7 +5601,7 @@ protected function libDarken($args) return $this->adjustHsl($color, 3, -$amount); } - protected static $libSaturate = ['color', 'amount']; + protected static $libSaturate = [['color', 'amount'], ['number']]; protected function libSaturate($args) { $value = $args[0]; @@ -5599,11 +5893,14 @@ protected function libSetNth($args) protected function libMapGet($args) { $map = $this->assertMap($args[0]); - $key = $this->compileStringContent($this->coerceString($args[1])); + $key = $args[1]; - for ($i = count($map[1]) - 1; $i >= 0; $i--) { - if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { - return $map[2][$i]; + if (! is_null($key)) { + $key = $this->compileStringContent($this->coerceString($key)); + for ($i = count($map[1]) - 1; $i >= 0; $i--) { + if ($key === $this->compileStringContent($this->coerceString($map[1][$i]))) { + return $map[2][$i]; + } } } @@ -5709,14 +6006,14 @@ protected function listSeparatorForJoin($list1, $sep) return ','; case 'space': - return ''; + return ' '; default: return $list1[1]; } } - protected static $libJoin = ['list1', 'list2', 'separator']; + protected static $libJoin = ['list1', 'list2', 'separator:null']; protected function libJoin($args) { list($list1, $list2, $sep) = $args; @@ -5728,7 +6025,7 @@ protected function libJoin($args) return [Type::T_LIST, $sep, array_merge($list1[2], $list2[2])]; } - protected static $libAppend = ['list', 'val', 'separator']; + protected static $libAppend = ['list', 'val', 'separator:null']; protected function libAppend($args) { list($list1, $value, $sep) = $args; @@ -5873,7 +6170,7 @@ protected function libStrLength($args) return new Node\Number(strlen($stringContent), ''); } - protected static $libStrSlice = ['string', 'start-at', 'end-at']; + protected static $libStrSlice = ['string', 'start-at', 'end-at:null']; protected function libStrSlice($args) { if (isset($args[2]) && $args[2][1] == 0) { @@ -6182,9 +6479,12 @@ protected function isSuperPart($superParts, $subParts) return true; } - //protected static $libSelectorAppend = ['selector...']; + protected static $libSelectorAppend = ['selector...']; protected function libSelectorAppend($args) { + // get the selector... list + $args = reset($args); + $args = $args[2]; if (count($args) < 1) { $this->throwError("selector-append() needs at least 1 argument"); } @@ -6201,7 +6501,7 @@ protected function libSelectorAppend($args) * * @return array * - * @throws \Leafo\ScssPhp\Exception\CompilerException + * @throws \ScssPhp\ScssPhp\Exception\CompilerException */ protected function selectorAppend($selectors) { @@ -6328,9 +6628,12 @@ protected function extendOrReplaceSelectors($selectors, $extendee, $extender, $r return $extended; } - //protected static $libSelectorNest = ['selector...']; + protected static $libSelectorNest = ['selector...']; protected function libSelectorNest($args) { + // get the selector... list + $args = reset($args); + $args = $args[2]; if (count($args) < 1) { $this->throwError("selector-nest() needs at least 1 argument"); } diff --git a/leafo/scssphp/src/Compiler/Environment.php b/scssphp/scssphp/src/Compiler/Environment.php similarity index 68% rename from leafo/scssphp/src/Compiler/Environment.php rename to scssphp/scssphp/src/Compiler/Environment.php index 99231f368..03eb86a5d 100644 --- a/leafo/scssphp/src/Compiler/Environment.php +++ b/scssphp/scssphp/src/Compiler/Environment.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Compiler; +namespace ScssPhp\ScssPhp\Compiler; /** * Compiler environment @@ -19,12 +19,12 @@ class Environment { /** - * @var \Leafo\ScssPhp\Block + * @var \ScssPhp\ScssPhp\Block */ public $block; /** - * @var \Leafo\ScssPhp\Compiler\Environment + * @var \ScssPhp\ScssPhp\Compiler\Environment */ public $parent; diff --git a/leafo/scssphp/src/Exception/CompilerException.php b/scssphp/scssphp/src/Exception/CompilerException.php similarity index 65% rename from leafo/scssphp/src/Exception/CompilerException.php rename to scssphp/scssphp/src/Exception/CompilerException.php index 7ca2e2b3b..a9d134fca 100644 --- a/leafo/scssphp/src/Exception/CompilerException.php +++ b/scssphp/scssphp/src/Exception/CompilerException.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Exception; +namespace ScssPhp\ScssPhp\Exception; /** * Compiler exception diff --git a/leafo/scssphp/src/Exception/ParserException.php b/scssphp/scssphp/src/Exception/ParserException.php similarity index 64% rename from leafo/scssphp/src/Exception/ParserException.php rename to scssphp/scssphp/src/Exception/ParserException.php index 6d64335fe..2fa12dd7a 100644 --- a/leafo/scssphp/src/Exception/ParserException.php +++ b/scssphp/scssphp/src/Exception/ParserException.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Exception; +namespace ScssPhp\ScssPhp\Exception; /** * Parser Exception diff --git a/leafo/scssphp/src/Exception/RangeException.php b/scssphp/scssphp/src/Exception/RangeException.php similarity index 64% rename from leafo/scssphp/src/Exception/RangeException.php rename to scssphp/scssphp/src/Exception/RangeException.php index 3ba6bf143..ee36c97e1 100644 --- a/leafo/scssphp/src/Exception/RangeException.php +++ b/scssphp/scssphp/src/Exception/RangeException.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Exception; +namespace ScssPhp\ScssPhp\Exception; /** * Range exception diff --git a/leafo/scssphp/src/Exception/ServerException.php b/scssphp/scssphp/src/Exception/ServerException.php similarity index 64% rename from leafo/scssphp/src/Exception/ServerException.php rename to scssphp/scssphp/src/Exception/ServerException.php index d0ed08427..d4a207aff 100644 --- a/leafo/scssphp/src/Exception/ServerException.php +++ b/scssphp/scssphp/src/Exception/ServerException.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Exception; +namespace ScssPhp\ScssPhp\Exception; /** * Server Exception diff --git a/leafo/scssphp/src/Formatter.php b/scssphp/scssphp/src/Formatter.php similarity index 74% rename from leafo/scssphp/src/Formatter.php rename to scssphp/scssphp/src/Formatter.php index 1403859db..478aa6a56 100644 --- a/leafo/scssphp/src/Formatter.php +++ b/scssphp/scssphp/src/Formatter.php @@ -2,17 +2,17 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; -use Leafo\ScssPhp\Formatter\OutputBlock; -use Leafo\ScssPhp\SourceMap\SourceMapGenerator; +use ScssPhp\ScssPhp\Formatter\OutputBlock; +use ScssPhp\ScssPhp\SourceMap\SourceMapGenerator; /** * Base formatter @@ -62,7 +62,7 @@ abstract class Formatter public $keepSemicolons; /** - * @var \Leafo\ScssPhp\Formatter\OutputBlock + * @var \ScssPhp\ScssPhp\Formatter\OutputBlock */ protected $currentBlock; @@ -77,7 +77,7 @@ abstract class Formatter protected $currentColumn; /** - * @var \Leafo\ScssPhp\SourceMap\SourceMapGenerator + * @var \ScssPhp\ScssPhp\SourceMap\SourceMapGenerator */ protected $sourceMapGenerator; @@ -126,9 +126,7 @@ public function stripSemicolon(&$lines) return; } - if (($count = count($lines)) - && substr($lines[$count - 1], -1) === ';' - ) { + if (($count = count($lines)) && substr($lines[$count - 1], -1) === ';') { $lines[$count - 1] = substr($lines[$count - 1], 0, -1); } } @@ -136,7 +134,7 @@ public function stripSemicolon(&$lines) /** * Output lines inside a block * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block */ protected function blockLines(OutputBlock $block) { @@ -154,7 +152,7 @@ protected function blockLines(OutputBlock $block) /** * Output block selectors * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block */ protected function blockSelectors(OutputBlock $block) { @@ -168,7 +166,7 @@ protected function blockSelectors(OutputBlock $block) /** * Output block children * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block */ protected function blockChildren(OutputBlock $block) { @@ -180,7 +178,7 @@ protected function blockChildren(OutputBlock $block) /** * Output non-empty block * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block */ protected function block(OutputBlock $block) { @@ -217,13 +215,37 @@ protected function block(OutputBlock $block) } } + /** + * Test and clean safely empty children + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block + * @return bool + */ + protected function testEmptyChildren($block) + { + $isEmpty = empty($block->lines); + + if ($block->children) { + foreach ($block->children as $k => &$child) { + if (! $this->testEmptyChildren($child)) { + $isEmpty = false; + } else { + if ($child->type === Type::T_MEDIA || $child->type === Type::T_DIRECTIVE) { + $child->children = []; + $child->selectors = null; + } + } + } + } + return $isEmpty; + } + /** * Entry point to formatting a block * * @api * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block An abstract syntax tree - * @param \Leafo\ScssPhp\SourceMap\SourceMapGenerator|null $sourceMapGenerator Optional source map generator + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block An abstract syntax tree + * @param \ScssPhp\ScssPhp\SourceMap\SourceMapGenerator|null $sourceMapGenerator Optional source map generator * * @return string */ @@ -237,6 +259,8 @@ public function format(OutputBlock $block, SourceMapGenerator $sourceMapGenerato $this->sourceMapGenerator = $sourceMapGenerator; } + $this->testEmptyChildren($block); + ob_start(); $this->block($block); diff --git a/leafo/scssphp/src/Formatter/Compact.php b/scssphp/scssphp/src/Formatter/Compact.php similarity index 81% rename from leafo/scssphp/src/Formatter/Compact.php rename to scssphp/scssphp/src/Formatter/Compact.php index 4efa1a089..591f0c92e 100644 --- a/leafo/scssphp/src/Formatter/Compact.php +++ b/scssphp/scssphp/src/Formatter/Compact.php @@ -2,16 +2,16 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Formatter; +namespace ScssPhp\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter; +use ScssPhp\ScssPhp\Formatter; /** * Compact formatter diff --git a/leafo/scssphp/src/Formatter/Compressed.php b/scssphp/scssphp/src/Formatter/Compressed.php similarity index 86% rename from leafo/scssphp/src/Formatter/Compressed.php rename to scssphp/scssphp/src/Formatter/Compressed.php index ab38529dd..ec4722eaf 100644 --- a/leafo/scssphp/src/Formatter/Compressed.php +++ b/scssphp/scssphp/src/Formatter/Compressed.php @@ -2,17 +2,17 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Formatter; +namespace ScssPhp\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; +use ScssPhp\ScssPhp\Formatter; +use ScssPhp\ScssPhp\Formatter\OutputBlock; /** * Compressed formatter @@ -63,7 +63,7 @@ public function blockLines(OutputBlock $block) /** * Output block selectors * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block */ protected function blockSelectors(OutputBlock $block) { diff --git a/leafo/scssphp/src/Formatter/Crunched.php b/scssphp/scssphp/src/Formatter/Crunched.php similarity index 85% rename from leafo/scssphp/src/Formatter/Crunched.php rename to scssphp/scssphp/src/Formatter/Crunched.php index da740ccd1..51ccb516d 100644 --- a/leafo/scssphp/src/Formatter/Crunched.php +++ b/scssphp/scssphp/src/Formatter/Crunched.php @@ -2,17 +2,17 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Formatter; +namespace ScssPhp\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; +use ScssPhp\ScssPhp\Formatter; +use ScssPhp\ScssPhp\Formatter\OutputBlock; /** * Crunched formatter @@ -61,7 +61,7 @@ public function blockLines(OutputBlock $block) /** * Output block selectors * - * @param \Leafo\ScssPhp\Formatter\OutputBlock $block + * @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block */ protected function blockSelectors(OutputBlock $block) { diff --git a/leafo/scssphp/src/Formatter/Debug.php b/scssphp/scssphp/src/Formatter/Debug.php similarity index 92% rename from leafo/scssphp/src/Formatter/Debug.php rename to scssphp/scssphp/src/Formatter/Debug.php index bfcbf41ad..94e70c815 100644 --- a/leafo/scssphp/src/Formatter/Debug.php +++ b/scssphp/scssphp/src/Formatter/Debug.php @@ -2,17 +2,17 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Formatter; +namespace ScssPhp\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; +use ScssPhp\ScssPhp\Formatter; +use ScssPhp\ScssPhp\Formatter\OutputBlock; /** * Debug formatter diff --git a/leafo/scssphp/src/Formatter/Expanded.php b/scssphp/scssphp/src/Formatter/Expanded.php similarity index 86% rename from leafo/scssphp/src/Formatter/Expanded.php rename to scssphp/scssphp/src/Formatter/Expanded.php index d8c1e8879..8eec47587 100644 --- a/leafo/scssphp/src/Formatter/Expanded.php +++ b/scssphp/scssphp/src/Formatter/Expanded.php @@ -2,17 +2,17 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Formatter; +namespace ScssPhp\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; +use ScssPhp\ScssPhp\Formatter; +use ScssPhp\ScssPhp\Formatter\OutputBlock; /** * Expanded formatter diff --git a/scssphp/scssphp/src/Formatter/Nested.php b/scssphp/scssphp/src/Formatter/Nested.php new file mode 100644 index 000000000..50a70ce6a --- /dev/null +++ b/scssphp/scssphp/src/Formatter/Nested.php @@ -0,0 +1,212 @@ + + */ +class Nested extends Formatter +{ + /** + * @var integer + */ + private $depth; + + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->indentLevel = 0; + $this->indentChar = ' '; + $this->break = "\n"; + $this->open = ' {'; + $this->close = ' }'; + $this->tagSeparator = ', '; + $this->assignSeparator = ': '; + $this->keepSemicolons = true; + } + + /** + * {@inheritdoc} + */ + protected function indentStr() + { + $n = $this->depth - 1; + + return str_repeat($this->indentChar, max($this->indentLevel + $n, 0)); + } + + /** + * {@inheritdoc} + */ + protected function blockLines(OutputBlock $block) + { + $inner = $this->indentStr(); + + $glue = $this->break . $inner; + + foreach ($block->lines as $index => $line) { + if (substr($line, 0, 2) === '/*') { + $block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line); + } + } + + $this->write($inner . implode($glue, $block->lines)); + } + + protected function hasFlatChild($block) + { + foreach ($block->children as $child) { + if (empty($child->selectors)) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function block(OutputBlock $block) + { + static $depths; + static $downLevel; + static $closeBlock; + static $previousEmpty; + static $previousHasSelector; + + if ($block->type === 'root') { + $depths = [ 0 ]; + $downLevel = ''; + $closeBlock = ''; + $this->depth = 0; + $previousEmpty = false; + $previousHasSelector = false; + } + + $isMediaOrDirective = in_array($block->type, [Type::T_DIRECTIVE, Type::T_MEDIA]); + $isSupport = ($block->type === Type::T_DIRECTIVE + && $block->selectors && strpos(implode('', $block->selectors), '@supports') !== false); + + while ($block->depth < end($depths) || ($block->depth == 1 && end($depths) == 1)) { + array_pop($depths); + $this->depth--; + + if (!$this->depth && ($block->depth <= 1 || (!$this->indentLevel && $block->type === Type::T_COMMENT)) && + (($block->selectors && ! $isMediaOrDirective) || $previousHasSelector) + ) { + $downLevel = $this->break; + } + + if (empty($block->lines) && empty($block->children)) { + $previousEmpty = true; + } + } + + if (empty($block->lines) && empty($block->children)) { + return; + } + + $this->currentBlock = $block; + + if (! empty($block->lines) || (! empty($block->children) && ($this->depth < 1 || $isSupport))) { + if ($block->depth > end($depths)) { + if (! $previousEmpty || $this->depth < 1) { + $this->depth++; + $depths[] = $block->depth; + } else { + // keep the current depth unchanged but take the block depth as a new reference for following blocks + array_pop($depths); + $depths[] = $block->depth; + } + } + } + + $previousEmpty = ($block->type === Type::T_COMMENT); + $previousHasSelector = false; + + if (! empty($block->selectors)) { + if ($closeBlock) { + $this->write($closeBlock); + $closeBlock = ''; + } + + if ($downLevel) { + $this->write($downLevel); + $downLevel = ''; + } + + $this->blockSelectors($block); + + $this->indentLevel++; + } + + if (! empty($block->lines)) { + if ($closeBlock) { + $this->write($closeBlock); + $closeBlock = ''; + } + + if ($downLevel) { + $this->write($downLevel); + $downLevel = ''; + } + + $this->blockLines($block); + $closeBlock = $this->break; + } + + if (! empty($block->children)) { + if ($this->depth>0 && ($isMediaOrDirective || ! $this->hasFlatChild($block))) { + array_pop($depths); + $this->depth--; + $this->blockChildren($block); + $this->depth++; + $depths[] = $block->depth; + } else { + $this->blockChildren($block); + } + } + + // reclear to not be spoiled by children if T_DIRECTIVE + if ($block->type === Type::T_DIRECTIVE) { + $previousHasSelector = false; + } + + if (! empty($block->selectors)) { + $this->indentLevel--; + + $this->write($this->close); + $closeBlock = $this->break; + + if ($this->depth > 1 && ! empty($block->children)) { + array_pop($depths); + $this->depth--; + } + if (! $isMediaOrDirective) { + $previousHasSelector = true; + } + } + + if ($block->type === 'root') { + $this->write($this->break); + } + } +} diff --git a/leafo/scssphp/src/Formatter/OutputBlock.php b/scssphp/scssphp/src/Formatter/OutputBlock.php similarity index 80% rename from leafo/scssphp/src/Formatter/OutputBlock.php rename to scssphp/scssphp/src/Formatter/OutputBlock.php index 5eb589c94..3e6fd9289 100644 --- a/leafo/scssphp/src/Formatter/OutputBlock.php +++ b/scssphp/scssphp/src/Formatter/OutputBlock.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Formatter; +namespace ScssPhp\ScssPhp\Formatter; /** * Output block @@ -44,7 +44,7 @@ class OutputBlock public $children; /** - * @var \Leafo\ScssPhp\Formatter\OutputBlock + * @var \ScssPhp\ScssPhp\Formatter\OutputBlock */ public $parent; diff --git a/leafo/scssphp/src/Node.php b/scssphp/scssphp/src/Node.php similarity index 79% rename from leafo/scssphp/src/Node.php rename to scssphp/scssphp/src/Node.php index b9f7945a3..dab565a63 100644 --- a/leafo/scssphp/src/Node.php +++ b/scssphp/scssphp/src/Node.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; /** * Base node diff --git a/leafo/scssphp/src/Node/Number.php b/scssphp/scssphp/src/Node/Number.php similarity index 94% rename from leafo/scssphp/src/Node/Number.php rename to scssphp/scssphp/src/Node/Number.php index 42c168037..1e83bf8ce 100644 --- a/leafo/scssphp/src/Node/Number.php +++ b/scssphp/scssphp/src/Node/Number.php @@ -2,18 +2,18 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\Node; +namespace ScssPhp\ScssPhp\Node; -use Leafo\ScssPhp\Compiler; -use Leafo\ScssPhp\Node; -use Leafo\ScssPhp\Type; +use ScssPhp\ScssPhp\Compiler; +use ScssPhp\ScssPhp\Node; +use ScssPhp\ScssPhp\Type; /** * Dimension + optional units @@ -100,7 +100,7 @@ public function __construct($dimension, $initialUnit) * * @param array $units * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ public function coerce($units) { @@ -123,7 +123,7 @@ public function coerce($units) /** * Normalize number * - * @return \Leafo\ScssPhp\Node\Number + * @return \ScssPhp\ScssPhp\Node\Number */ public function normalize() { @@ -148,10 +148,10 @@ public function offsetExists($offset) return $this->sourceLine !== null; } - if ($offset === -1 - || $offset === 0 - || $offset === 1 - || $offset === 2 + if ($offset === -1 || + $offset === 0 || + $offset === 1 || + $offset === 2 ) { return true; } @@ -259,7 +259,7 @@ public function unitStr() /** * Output number * - * @param \Leafo\ScssPhp\Compiler $compiler + * @param \ScssPhp\ScssPhp\Compiler $compiler * * @return string */ diff --git a/leafo/scssphp/src/Parser.php b/scssphp/scssphp/src/Parser.php similarity index 86% rename from leafo/scssphp/src/Parser.php rename to scssphp/scssphp/src/Parser.php index c05e4ee8a..9b409e0b8 100644 --- a/leafo/scssphp/src/Parser.php +++ b/scssphp/scssphp/src/Parser.php @@ -2,21 +2,21 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; -use Leafo\ScssPhp\Block; -use Leafo\ScssPhp\Cache; -use Leafo\ScssPhp\Compiler; -use Leafo\ScssPhp\Exception\ParserException; -use Leafo\ScssPhp\Node; -use Leafo\ScssPhp\Type; +use ScssPhp\ScssPhp\Block; +use ScssPhp\ScssPhp\Cache; +use ScssPhp\ScssPhp\Compiler; +use ScssPhp\ScssPhp\Exception\ParserException; +use ScssPhp\ScssPhp\Node; +use ScssPhp\ScssPhp\Type; /** * Parser @@ -64,6 +64,7 @@ class Parser private $env; private $inParens; private $eatWhiteDefault; + private $discardComments; private $buffer; private $utf8; private $encoding; @@ -75,10 +76,10 @@ class Parser * * @api * - * @param string $sourceName - * @param integer $sourceIndex - * @param string $encoding - * @param \Leafo\ScssPhp\Cache $cache + * @param string $sourceName + * @param integer $sourceIndex + * @param string $encoding + * @param \ScssPhp\ScssPhp\Cache $cache */ public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8', $cache = null) { @@ -88,6 +89,7 @@ public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8', $this->utf8 = ! $encoding || strtolower($encoding) === 'utf-8'; $this->patternModifiers = $this->utf8 ? 'Aisu' : 'Ais'; $this->commentsSeen = []; + $this->discardComments = false; if (empty(static::$operatorPattern)) { static::$operatorPattern = '([*\/%+-]|[!=]\=|\>\=?|\<\=\>|\<\=?|and|or)'; @@ -126,7 +128,7 @@ public function getSourceName() * * @param string $msg * - * @throws \Leafo\ScssPhp\Exception\ParserException + * @throws \ScssPhp\ScssPhp\Exception\ParserException */ public function throwParseError($msg = 'parse error') { @@ -150,7 +152,7 @@ public function throwParseError($msg = 'parse error') * * @param string $buffer * - * @return \Leafo\ScssPhp\Block + * @return \ScssPhp\ScssPhp\Block */ public function parse($buffer) { @@ -265,6 +267,34 @@ public function parseSelector($buffer, &$out) return $selector; } + /** + * Parse a media Query + * + * @api + * + * @param string $buffer + * @param string $out + * + * @return array + */ + public function parseMediaQueryList($buffer, &$out) + { + $this->count = 0; + $this->env = null; + $this->inParens = false; + $this->eatWhiteDefault = true; + $this->buffer = (string) $buffer; + + $this->saveEncoding(); + + + $isMediaQuery = $this->mediaQueryList($out); + + $this->restoreEncoding(); + + return $isMediaQuery; + } + /** * Parse a single chunk off the head of the buffer and append it to the * current parse environment. @@ -313,7 +343,10 @@ protected function parseChunk() if ($this->literal('@at-root', 8) && ($this->selectors($selector) || true) && ($this->map($with) || true) && - $this->matchChar('{') + (($this->matchChar('(') + && $this->interpolation($with) + && $this->matchChar(')')) || true) && + $this->matchChar('{', false) ) { $atRoot = $this->pushSpecialBlock(Type::T_AT_ROOT, $s); $atRoot->selector = $selector; @@ -324,7 +357,7 @@ protected function parseChunk() $this->seek($s); - if ($this->literal('@media', 6) && $this->mediaQueryList($mediaQueryList) && $this->matchChar('{')) { + if ($this->literal('@media', 6) && $this->mediaQueryList($mediaQueryList) && $this->matchChar('{', false)) { $media = $this->pushSpecialBlock(Type::T_MEDIA, $s); $media->queryList = $mediaQueryList[2]; @@ -336,7 +369,7 @@ protected function parseChunk() if ($this->literal('@mixin', 6) && $this->keyword($mixinName) && ($this->argumentDef($args) || true) && - $this->matchChar('{') + $this->matchChar('{', false) ) { $mixin = $this->pushSpecialBlock(Type::T_MIXIN, $s); $mixin->name = $mixinName; @@ -353,9 +386,12 @@ protected function parseChunk() ($this->argValues($argValues) || true) && $this->matchChar(')') || true) && ($this->end() || + ($this->literal('using', 5) && + $this->argumentDef($argUsing) && + ($this->end() || $this->matchChar('{') && $hasBlock = true)) || $this->matchChar('{') && $hasBlock = true) ) { - $child = [Type::T_INCLUDE, $mixinName, isset($argValues) ? $argValues : null, null]; + $child = [Type::T_INCLUDE, $mixinName, isset($argValues) ? $argValues : null, null, isset($argUsing) ? $argUsing : null]; if (! empty($hasBlock)) { $include = $this->pushSpecialBlock(Type::T_INCLUDE, $s); @@ -418,7 +454,7 @@ protected function parseChunk() if ($this->literal('@function', 9) && $this->keyword($fnName) && $this->argumentDef($args) && - $this->matchChar('{') + $this->matchChar('{', false) ) { $func = $this->pushSpecialBlock(Type::T_FUNCTION, $s); $func->name = $fnName; @@ -457,7 +493,7 @@ protected function parseChunk() $this->genericList($varNames, 'variable', ',', false) && $this->literal('in', 2) && $this->valueList($list) && - $this->matchChar('{') + $this->matchChar('{', false) ) { $each = $this->pushSpecialBlock(Type::T_EACH, $s); @@ -474,7 +510,7 @@ protected function parseChunk() if ($this->literal('@while', 6) && $this->expression($cond) && - $this->matchChar('{') + $this->matchChar('{', false) ) { $while = $this->pushSpecialBlock(Type::T_WHILE, $s); $while->cond = $cond; @@ -491,7 +527,7 @@ protected function parseChunk() ($this->literal('through', 7) || ($forUntil = true && $this->literal('to', 2))) && $this->expression($end) && - $this->matchChar('{') + $this->matchChar('{', false) ) { $for = $this->pushSpecialBlock(Type::T_FOR, $s); $for->var = $varName[1]; @@ -504,7 +540,7 @@ protected function parseChunk() $this->seek($s); - if ($this->literal('@if', 3) && $this->valueList($cond) && $this->matchChar('{')) { + if ($this->literal('@if', 3) && $this->valueList($cond) && $this->matchChar('{', false)) { $if = $this->pushSpecialBlock(Type::T_IF, $s); $if->cond = $cond; $if->cases = []; @@ -547,8 +583,15 @@ protected function parseChunk() $this->seek($s); - if ($this->literal('@content', 8) && $this->end()) { - $this->append([Type::T_MIXIN_CONTENT], $s); + #if ($this->literal('@content', 8)) + + if ($this->literal('@content', 8) && + ($this->end() || + $this->matchChar('(') && + $this->argValues($argContent) && + $this->matchChar(')') && + $this->end())) { + $this->append([Type::T_MIXIN_CONTENT, isset($argContent) ? $argContent : null], $s); return true; } @@ -561,9 +604,9 @@ protected function parseChunk() list(, $if) = $last; if ($this->literal('@else', 5)) { - if ($this->matchChar('{')) { + if ($this->matchChar('{', false)) { $else = $this->pushSpecialBlock(Type::T_ELSE, $s); - } elseif ($this->literal('if', 2) && $this->valueList($cond) && $this->matchChar('{')) { + } elseif ($this->literal('if', 2) && $this->valueList($cond) && $this->matchChar('{', false)) { $else = $this->pushSpecialBlock(Type::T_ELSEIF, $s); $else->cond = $cond; } @@ -601,11 +644,23 @@ protected function parseChunk() $this->seek($s); + if ($this->literal('@supports', 9) && + ($t1=$this->supportsQuery($supportQuery)) && + ($t2=$this->matchChar('{', false)) ) { + $directive = $this->pushSpecialBlock(Type::T_DIRECTIVE, $s); + $directive->name = 'supports'; + $directive->value = $supportQuery; + + return true; + } + + $this->seek($s); + // doesn't match built in directive, do generic one if ($this->matchChar('@', false) && $this->keyword($dirName) && ($this->variable($dirValue) || $this->openString('{', $dirValue) || true) && - $this->matchChar('{') + $this->matchChar('{', false) ) { if ($dirName === 'media') { $directive = $this->pushSpecialBlock(Type::T_MEDIA, $s); @@ -688,9 +743,11 @@ protected function parseChunk() $foundSomething = true; } - if ($this->matchChar('{')) { + if ($this->matchChar('{', false)) { $propBlock = $this->pushSpecialBlock(Type::T_NESTED_PROPERTY, $s); $propBlock->prefix = $name; + $propBlock->hasValue = $foundSomething; + $foundSomething = true; } elseif ($foundSomething) { $foundSomething = $this->end(); @@ -704,9 +761,15 @@ protected function parseChunk() $this->seek($s); // closing a block - if ($this->matchChar('}')) { + if ($this->matchChar('}', false)) { $block = $this->popBlock(); + if (!isset($block->type) || $block->type !== Type::T_IF) { + if ($this->env->parent) { + $this->append(null); // collect comments before next statement if needed + } + } + if (isset($block->type) && $block->type === Type::T_INCLUDE) { $include = $block->child; unset($block->child); @@ -717,6 +780,15 @@ protected function parseChunk() $this->append([$type, $block], $s); } + // collect comments just after the block closing if needed + if ($this->eatWhiteDefault) { + $this->whitespace(); + + if ($this->env->comments) { + $this->append(null); + } + } + return true; } @@ -736,7 +808,7 @@ protected function parseChunk() * @param array $selectors * @param integer $pos * - * @return \Leafo\ScssPhp\Block + * @return \ScssPhp\ScssPhp\Block */ protected function pushBlock($selectors, $pos = 0) { @@ -764,6 +836,15 @@ protected function pushBlock($selectors, $pos = 0) $this->env = $b; + // collect comments at the begining of a block if needed + if ($this->eatWhiteDefault) { + $this->whitespace(); + + if ($this->env->comments) { + $this->append(null); + } + } + return $b; } @@ -773,7 +854,7 @@ protected function pushBlock($selectors, $pos = 0) * @param string $type * @param integer $pos * - * @return \Leafo\ScssPhp\Block + * @return \ScssPhp\ScssPhp\Block */ protected function pushSpecialBlock($type, $pos) { @@ -786,12 +867,19 @@ protected function pushSpecialBlock($type, $pos) /** * Pop scope and return last block * - * @return \Leafo\ScssPhp\Block + * @return \ScssPhp\ScssPhp\Block * * @throws \Exception */ protected function popBlock() { + + // collect comments ending just before of a block closing + if ($this->env->comments) { + $this->append(null); + } + + // pop the block $block = $this->env; if (empty($block->parent)) { @@ -807,13 +895,6 @@ protected function popBlock() unset($block->parent); - $comments = $block->comments; - - if ($comments) { - $this->env->comments = $comments; - unset($block->comments); - } - return $block; } @@ -1049,11 +1130,13 @@ protected function whitespace() */ protected function appendComment($comment) { - if ($comment[0] === Type::T_COMMENT && is_string($comment[1])) { - $comment[1] = substr(preg_replace(['/^\s+/m', '/^(.)/m'], ['', ' \1'], $comment[1]), 1); - } + if (! $this->discardComments) { + if ($comment[0] === Type::T_COMMENT && is_string($comment[1])) { + $comment[1] = substr(preg_replace(['/^\s+/m', '/^(.)/m'], ['', ' \1'], $comment[1]), 1); + } - $this->env->comments[] = $comment; + $this->env->comments[] = $comment; + } } /** @@ -1162,6 +1245,118 @@ protected function mediaQuery(&$out) return true; } + /** + * Parse supports query + * + * @param array $out + * + * @return boolean + */ + protected function supportsQuery(&$out) + { + $expressions = null; + $parts = []; + + $s = $this->count; + + $not = false; + if (($this->literal('not', 3) && ($not = true) || true) && + $this->matchChar('(') && + ($this->expression($property)) && + $this->literal(': ', 2) && + $this->valueList($value) && + $this->matchChar(')')) { + $support = [Type::T_STRING, '', [[Type::T_KEYWORD, ($not ? 'not ' : '') . '(']]]; + $support[2][] = $property; + $support[2][] = [Type::T_KEYWORD, ': ']; + $support[2][] = $value; + $support[2][] = [Type::T_KEYWORD, ')']; + + $parts[] = $support; + $s = $this->count; + } else { + $this->seek($s); + } + + if ($this->matchChar('(') && + $this->supportsQuery($subQuery) && + $this->matchChar(')')) { + $parts[] = [Type::T_STRING, '', [[Type::T_KEYWORD, '('], $subQuery, [Type::T_KEYWORD, ')']]]; + $s = $this->count; + } else { + $this->seek($s); + } + + if ($this->literal('not', 3) && + $this->supportsQuery($subQuery)) { + $parts[] = [Type::T_STRING, '', [[Type::T_KEYWORD, 'not '], $subQuery]]; + $s = $this->count; + } else { + $this->seek($s); + } + + if ($this->literal('selector(', 9) && + $this->selector($selector) && + $this->matchChar(')')) { + $support = [Type::T_STRING, '', [[Type::T_KEYWORD, 'selector(']]]; + + $selectorList = [Type::T_LIST, '', []]; + foreach ($selector as $sc) { + $compound = [Type::T_STRING, '', []]; + foreach ($sc as $scp) { + if (is_array($scp)) { + $compound[2][] = $scp; + } else { + $compound[2][] = [Type::T_KEYWORD, $scp]; + } + } + $selectorList[2][] = $compound; + } + $support[2][] = $selectorList; + $support[2][] = [Type::T_KEYWORD, ')']; + $parts[] = $support; + $s = $this->count; + } else { + $this->seek($s); + } + + if ($this->variable($var) or $this->interpolation($var)) { + $parts[] = $var; + $s = $this->count; + } else { + $this->seek($s); + } + + if ($this->literal('and', 3) && + $this->genericList($expressions, 'supportsQuery', ' and', false)) { + array_unshift($expressions[2], [Type::T_STRING, '', $parts]); + $parts = [$expressions]; + $s = $this->count; + } else { + $this->seek($s); + } + + if ($this->literal('or', 2) && + $this->genericList($expressions, 'supportsQuery', ' or', false)) { + array_unshift($expressions[2], [Type::T_STRING, '', $parts]); + $parts = [$expressions]; + $s = $this->count; + } else { + $this->seek($s); + } + + if (count($parts)) { + if ($this->eatWhiteDefault) { + $this->whitespace(); + } + $out = [Type::T_STRING, '', $parts]; + return true; + } + + return false; + } + + /** * Parse media expression * @@ -1254,7 +1449,11 @@ protected function argValue(&$out) */ protected function valueList(&$out) { - return $this->genericList($out, 'spaceList', ','); + $discardComments = $this->discardComments; + $this->discardComments = true; + $res = $this->genericList($out, 'spaceList', ','); + $this->discardComments = $discardComments; + return $res; } /** @@ -1320,9 +1519,12 @@ protected function genericList(&$out, $parseItem, $delim = '', $flatten = true) protected function expression(&$out) { $s = $this->count; + $discard = $this->discardComments; + $this->discardComments = true; if ($this->matchChar('(')) { if ($this->parenExpression($out, $s, ")")) { + $this->discardComments = $discard; return true; } @@ -1335,6 +1537,7 @@ protected function expression(&$out) $out = [Type::T_STRING, '', [ '[', $out, ']' ]]; } + $this->discardComments = $discard; return true; } @@ -1344,9 +1547,11 @@ protected function expression(&$out) if ($this->value($lhs)) { $out = $this->expHelper($lhs, 0); + $this->discardComments = $discard; return true; } + $this->discardComments = $discard; return false; } @@ -1467,7 +1672,7 @@ protected function value(&$out) $this->seek($s); - if ($this->literal('url(', 4, false) && $this->match('\s*(\/\/\S+)\s*', $m)) { + if ($this->literal('url(', 4, false) && $this->match('\s*(\/\/[^\s\)]+)\s*', $m)) { $content = 'url(' . $m[1]; if ($this->matchChar(')')) { @@ -1978,10 +2183,11 @@ protected function string(&$out) $content[] = $m[2] . "'"; } elseif ($this->literal("\\", 1, false)) { $content[] = $m[2] . "\\"; - } elseif ($this->literal("\r\n", 2, false) - || $this->matchChar("\r", false) - || $this->matchChar("\n", false) - || $this->matchChar("\f", false)) { + } elseif ($this->literal("\r\n", 2, false) || + $this->matchChar("\r", false) || + $this->matchChar("\n", false) || + $this->matchChar("\f", false) + ) { // this is a continuation escaping, to be ignored } else { $content[] = $m[2]; @@ -2022,11 +2228,12 @@ protected function string(&$out) /** * Parse keyword or interpolation * - * @param array $out + * @param array $out + * @param boolean $restricted * * @return boolean */ - protected function mixedKeyword(&$out) + protected function mixedKeyword(&$out, $restricted = false) { $parts = []; @@ -2034,7 +2241,7 @@ protected function mixedKeyword(&$out) $this->eatWhiteDefault = false; for (;;) { - if ($this->keyword($key)) { + if ($restricted ? $this->restrictedKeyword($key) : $this->keyword($key)) { $parts[] = $key; continue; } @@ -2149,7 +2356,7 @@ protected function interpolation(&$out, $lookWhite = true) $out = $value; } else { if ($lookWhite) { - $left = preg_match('/\s/', $this->buffer[$s - 1]) ? ' ' : ''; + $left = ($s > 0 && preg_match('/\s/', $this->buffer[$s - 1])) ? ' ' : ''; $right = preg_match('/\s/', $this->buffer[$this->count]) ? ' ': ''; } else { $left = $right = false; @@ -2282,9 +2489,16 @@ protected function selector(&$out, $subSelector = false) $selector = []; for (;;) { + $s = $this->count; if ($this->match('[>+~]+', $m, true)) { - $selector[] = [$m[0]]; - continue; + if ($subSelector && is_string($subSelector) && strpos($subSelector, 'nth-') === 0 + && $m[0] === '+' && $this->match("(\d+|n\b)", $counter)) { + $this->seek($s); + } + else { + $selector[] = [$m[0]]; + continue; + } } if ($this->selectorSingle($part, $subSelector)) { @@ -2406,7 +2620,7 @@ protected function selectorSingle(&$out, $subSelector = false) $part = ':'; } - if ($this->mixedKeyword($nameParts)) { + if ($this->mixedKeyword($nameParts, true)) { $parts[] = $part; foreach ($nameParts as $sub) { @@ -2416,10 +2630,12 @@ protected function selectorSingle(&$out, $subSelector = false) $ss = $this->count; if ($nameParts === ['not'] || $nameParts === ['is'] || - $nameParts === ['has'] || $nameParts === ['where'] + $nameParts === ['has'] || $nameParts === ['where'] || + $nameParts === ['nth-child'] || $nameParts == ['nth-last-child'] || + $nameParts === ['nth-of-type'] || $nameParts == ['nth-last-of-type'] ) { - if ($this->matchChar('(') && - ($this->selectors($subs, true) || true) && + if ($this->matchChar('(', true) && + ($this->selectors($subs, reset($nameParts)) || true) && $this->matchChar(')') ) { $parts[] = '('; @@ -2465,6 +2681,17 @@ protected function selectorSingle(&$out, $subSelector = false) $this->seek($s); + // 2n+1 + if ($subSelector && is_string($subSelector) && strpos($subSelector, 'nth-') === 0) { + if ($this->match("(\s*(\+\s*|\-\s*)?(\d+|n|\d+n))+", $counter)) { + $parts[] = $counter[0]; + //$parts[] = str_replace(' ', '', $counter[0]); + continue; + } + } + + $this->seek($s); + // attribute selector if ($char === '[' && $this->matchChar('[') && @@ -2489,7 +2716,7 @@ protected function selectorSingle(&$out, $subSelector = false) continue; } - if ($this->keyword($name)) { + if ($this->restrictedKeyword($name)) { $parts[] = $name; continue; } @@ -2555,6 +2782,27 @@ protected function keyword(&$word, $eatWhitespace = null) return false; } + /** + * Parse a keyword that should not start with a number + * + * @param string $word + * @param boolean $eatWhitespace + * + * @return boolean + */ + protected function restrictedKeyword(&$word, $eatWhitespace = null) + { + $s = $this->count; + + if ($this->keyword($word, $eatWhitespace) && (ord($word[0]) > 57 || ord($word[0]) < 48)) { + return true; + } + + $this->seek($s); + + return false; + } + /** * Parse a placeholder * diff --git a/leafo/scssphp/src/SourceMap/Base64.php b/scssphp/scssphp/src/SourceMap/Base64.php similarity index 96% rename from leafo/scssphp/src/SourceMap/Base64.php rename to scssphp/scssphp/src/SourceMap/Base64.php index 54015bb91..93c6c1b47 100644 --- a/leafo/scssphp/src/SourceMap/Base64.php +++ b/scssphp/scssphp/src/SourceMap/Base64.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\SourceMap; +namespace ScssPhp\ScssPhp\SourceMap; /** * Base 64 Encode/Decode diff --git a/leafo/scssphp/src/SourceMap/Base64VLQ.php b/scssphp/scssphp/src/SourceMap/Base64VLQ.php similarity index 95% rename from leafo/scssphp/src/SourceMap/Base64VLQ.php rename to scssphp/scssphp/src/SourceMap/Base64VLQ.php index 6de3b5ee0..d6f6452b5 100644 --- a/leafo/scssphp/src/SourceMap/Base64VLQ.php +++ b/scssphp/scssphp/src/SourceMap/Base64VLQ.php @@ -2,16 +2,16 @@ /** * SCSSPHP * - * @copyright 2012-2015 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\SourceMap; +namespace ScssPhp\ScssPhp\SourceMap; -use Leafo\ScssPhp\SourceMap\Base64; +use ScssPhp\ScssPhp\SourceMap\Base64; /** * Base 64 VLQ diff --git a/leafo/scssphp/src/SourceMap/Base64VLQEncoder.php b/scssphp/scssphp/src/SourceMap/Base64VLQEncoder.php similarity index 98% rename from leafo/scssphp/src/SourceMap/Base64VLQEncoder.php rename to scssphp/scssphp/src/SourceMap/Base64VLQEncoder.php index caf56c771..365b4d930 100644 --- a/leafo/scssphp/src/SourceMap/Base64VLQEncoder.php +++ b/scssphp/scssphp/src/SourceMap/Base64VLQEncoder.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\SourceMap; +namespace ScssPhp\ScssPhp\SourceMap; /** * Base64 VLQ Encoder diff --git a/leafo/scssphp/src/SourceMap/SourceMapGenerator.php b/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php similarity index 96% rename from leafo/scssphp/src/SourceMap/SourceMapGenerator.php rename to scssphp/scssphp/src/SourceMap/SourceMapGenerator.php index fb11a0bfa..d0231b49d 100644 --- a/leafo/scssphp/src/SourceMap/SourceMapGenerator.php +++ b/scssphp/scssphp/src/SourceMap/SourceMapGenerator.php @@ -2,16 +2,16 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp\SourceMap; +namespace ScssPhp\ScssPhp\SourceMap; -use Leafo\ScssPhp\Exception\CompilerException; +use ScssPhp\ScssPhp\Exception\CompilerException; /** * Source Map Generator @@ -61,7 +61,7 @@ class SourceMapGenerator /** * The base64 VLQ encoder * - * @var \Leafo\ScssPhp\SourceMap\Base64VLQ + * @var \ScssPhp\ScssPhp\SourceMap\Base64VLQ */ protected $encoder; @@ -127,7 +127,7 @@ public function addMapping($generatedLine, $generatedColumn, $originalLine, $ori * * @return string * - * @throws \Leafo\ScssPhp\Exception\CompilerException If the file could not be saved + * @throws \ScssPhp\ScssPhp\Exception\CompilerException If the file could not be saved */ public function saveMap($content) { diff --git a/leafo/scssphp/src/Type.php b/scssphp/scssphp/src/Type.php similarity index 94% rename from leafo/scssphp/src/Type.php rename to scssphp/scssphp/src/Type.php index e84c47e40..a12da72f2 100644 --- a/leafo/scssphp/src/Type.php +++ b/scssphp/scssphp/src/Type.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; /** * Block/node types diff --git a/leafo/scssphp/src/Util.php b/scssphp/scssphp/src/Util.php similarity index 83% rename from leafo/scssphp/src/Util.php rename to scssphp/scssphp/src/Util.php index a1e506588..b0b76fdb4 100644 --- a/leafo/scssphp/src/Util.php +++ b/scssphp/scssphp/src/Util.php @@ -2,17 +2,17 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; -use Leafo\ScssPhp\Base\Range; -use Leafo\ScssPhp\Exception\RangeException; +use ScssPhp\ScssPhp\Base\Range; +use ScssPhp\ScssPhp\Exception\RangeException; /** * Utilty functions @@ -26,13 +26,13 @@ class Util * room for slight floating-point errors. * * @param string $name The name of the value. Used in the error message. - * @param \Leafo\ScssPhp\Base\Range $range Range of values. + * @param \ScssPhp\ScssPhp\Base\Range $range Range of values. * @param array $value The value to check. * @param string $unit The unit of the value. Used in error reporting. * * @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin. * - * @throws \Leafo\ScssPhp\Exception\RangeException + * @throws \ScssPhp\ScssPhp\Exception\RangeException */ public static function checkRange($name, Range $range, $value, $unit = '') { diff --git a/leafo/scssphp/src/Version.php b/scssphp/scssphp/src/Version.php similarity index 56% rename from leafo/scssphp/src/Version.php rename to scssphp/scssphp/src/Version.php index fe163a789..cc616c0fe 100644 --- a/leafo/scssphp/src/Version.php +++ b/scssphp/scssphp/src/Version.php @@ -2,14 +2,14 @@ /** * SCSSPHP * - * @copyright 2012-2018 Leaf Corcoran + * @copyright 2012-2019 Leaf Corcoran * * @license http://opensource.org/licenses/MIT MIT * - * @link http://leafo.github.io/scssphp + * @link http://scssphp.github.io/scssphp */ -namespace Leafo\ScssPhp; +namespace ScssPhp\ScssPhp; /** * SCSSPHP version @@ -18,5 +18,5 @@ */ class Version { - const VERSION = 'v0.8.4'; + const VERSION = 'v1.0.3'; }