mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2025-09-14 01:28:27 +02:00
Upate less.php 5.4.0
less_version = '3.13.1';
This commit is contained in:
parent
81566b6cdd
commit
39a2e7221f
11 changed files with 670 additions and 59 deletions
18
include/thirdparty/less.php/API.md
vendored
18
include/thirdparty/less.php/API.md
vendored
|
@ -147,7 +147,23 @@ $css = file_get_contents( '/var/www/writable_folder/' . $cssOutputFile );
|
|||
|
||||
#### Incremental caching
|
||||
|
||||
In addition to the whole-output caching described above, Less.php also has the ability to keep an internal cache which allows re-parses to be faster by effectively only re-compiling portions that have changed.
|
||||
**Warning:** The incremental cache in Less_Parser is significantly slower and more memory-intense than `Less_Cache`! If you call Less.php during web requests, or otherwise call it repeatedly with files that might be unchanged, use `Less_Cache` instead.
|
||||
|
||||
You can turn off the incremental cache to save memory and disk space ([ref](https://github.com/wikimedia/less.php/issues/104)). Without incremental cache, cache misses may be slower.
|
||||
|
||||
```php
|
||||
// Disable incremental cache
|
||||
$lessFiles = [ __DIR__ . '/assets/bootstrap.less' => '/mysite/assets/' ];
|
||||
$options = [
|
||||
'cache_dir' => '/var/www/writable_folder',
|
||||
'cache_incremental' => false,
|
||||
];
|
||||
$css = Less_Cache::Get( $lessFiles, $options );
|
||||
```
|
||||
|
||||
When you instantiate Less_Parser, and call `parseFile()` or `getCss()`, it is assumed that at least one input file has changed (i.e. the whole-output cache from Less_Cache was a cache miss). The incremental cache exists to speed up cache misses on very large code bases, and is enabled by default when you call Less_Cache.
|
||||
|
||||
It is inherent to the Less language that later imports may change variables or extend mixins used in earlier files, and that imports may reference variables defined by earlier imports. Thus one can't actually cache the CSS output of an import. All inputs needs to be re-compiled together to produce the correct CSS output. The incremental cache merely allows the `parseFile()` method to skip parsing for unchanged files (i.e. interpreting Less syntax into an object structure). The `getCss()` method will still traverse and compile the representation of all input files.
|
||||
|
||||
## Source maps
|
||||
|
||||
|
|
274
include/thirdparty/less.php/CHANGES.md
vendored
Normal file
274
include/thirdparty/less.php/CHANGES.md
vendored
Normal file
|
@ -0,0 +1,274 @@
|
|||
# Changelog
|
||||
|
||||
## v5.4.0
|
||||
|
||||
Added:
|
||||
* Add support for Logical Functions `if()` and `boolean()`. (Hannah Okwelum) [T393383](https://phabricator.wikimedia.org/T393383)
|
||||
|
||||
Changed:
|
||||
* Remove support for PHP 7.4 and 8.0. Raise requirement to PHP 8.1+. (James D. Forrester)
|
||||
|
||||
## v5.3.1
|
||||
|
||||
Fixed:
|
||||
* Fix `PHP Warning: Undefined property $value` in `extract()`. (Timo Tijhof) [T391735](https://phabricator.wikimedia.org/T391735)
|
||||
|
||||
## v5.3.0
|
||||
|
||||
Added:
|
||||
* Less_Parser: Add `cache_incremental` option. Set this to false via `Less_Cache` to use the fast whole-output cache without the memory-intensive incremental cache. (Timo Tijhof)
|
||||
|
||||
Deprecated:
|
||||
* Deprecate `Less_Cache::CheckCacheDir()` as public method. This is called automatically.
|
||||
* Deprecate `Less_Cache::CleanCache()` as public method. This is called automatically.
|
||||
* Deprecate `Less_Parser::SetCacheDir()`. Set the `cache_dir` option, or use `Less_Cache::SetCacheDir()` instead.
|
||||
|
||||
## v5.2.2
|
||||
|
||||
Fixed:
|
||||
* Fix ParseError on CSS variable when there is no trailing semicolon (Hannah Okwelum) [T386077](https://phabricator.wikimedia.org/T386077)
|
||||
* Support functions calls in CSS variable value after first comma (Hannah Okwelum) [T386079](https://phabricator.wikimedia.org/T386079)
|
||||
|
||||
## v5.2.1
|
||||
|
||||
Fixed:
|
||||
* Fix un-parenthesized nested operation via a variable (Hannah Okwelum) [T386074](https://phabricator.wikimedia.org/T386074)
|
||||
* Faster Less_Visitor_joinSelector by skipping Declaration blocks (ubermanu)
|
||||
|
||||
## v5.2.0
|
||||
|
||||
Added:
|
||||
* Add support for BrianHenryIE/strauss codemod in Less_Visitor (Stefan Warnat)
|
||||
|
||||
Fixed:
|
||||
* Fix "PHP Warning: Undefined array key currentUri" when using `@import (inline)` (tck) [T380641](https://phabricator.wikimedia.org/T380641)
|
||||
* Fix "Implicit conversion from float to int" PHP 8.1 warning when using `hsv()` (Peter Knut)
|
||||
* Less_Visitor: Faster class mapping in `visitObj` by using inline cache (Thiemo Kreuz)
|
||||
|
||||
## v5.1.2
|
||||
|
||||
Fixed:
|
||||
* Less_Functions: Fix "Implicitly nullable parameter" PHP 8.4 warning (Reedy) [T376276](https://phabricator.wikimedia.org/T376276)
|
||||
|
||||
## v5.1.1
|
||||
|
||||
Fixed:
|
||||
* Fix compiling of PHP-injected variables with false, null or empty string (Hannah Okwelum)
|
||||
|
||||
## v5.1.0
|
||||
|
||||
Added:
|
||||
* Add support for property acessors (Piotr Miazga) [T368408](https://phabricator.wikimedia.org/T368408)
|
||||
* Increase parsing flexibility around at-rule blocks and custom properties (Piotr Miazga) [T368408](https://phabricator.wikimedia.org/T368408)
|
||||
* Add support for Namespaces and Accessors (Piotr Miazga) [T368409](https://phabricator.wikimedia.org/T368409)
|
||||
|
||||
Fixed:
|
||||
* Fix parse error when opacity is set to zero in `alpha()` function (Hannah Okwelum) [T371606](https://phabricator.wikimedia.org/T371606)
|
||||
|
||||
## v5.0.0
|
||||
|
||||
Added:
|
||||
* Add support for Lessjs 3.5.0 `calc()` exception (Piotr Miazga) [T367186](https://phabricator.wikimedia.org/T367186)
|
||||
* Add support for CSS Grid syntax (Dringsim) [T288498](https://phabricator.wikimedia.org/T288498)
|
||||
* Add support for `\9` escapes in CSS keyword (Dringsim) [T288498](https://phabricator.wikimedia.org/T288498)
|
||||
* Add Less_Parser "math" option, renamed from strictMath (Hannah Okwelum) [T366445](https://phabricator.wikimedia.org/T366445)
|
||||
|
||||
Changed:
|
||||
* Change Less_Parser "math" default from "always" to "parens-division" (Hannah Okwelum) [T366445](https://phabricator.wikimedia.org/T366445)
|
||||
* Change `Less_Version::less_version` to "3.13.3". This end compatibility support of Less.js 2.5.3.
|
||||
Less.php 5.0 and later will target Less.js 3.13.1 behaviour instead. (Piotr Miazga)
|
||||
|
||||
Removed:
|
||||
* Remove `import_callback` Less_Parser option (Hannah Okwelum)
|
||||
* Remove backtick evaluation inside quoted strings (Bartosz Dziewoński)
|
||||
* Remove `Less_Parser::AllParsedFiles()` (Hannah Okwelum)
|
||||
* Remove Less_Parser->SetInput() public method, now private (Hannah Okwelum)
|
||||
* Remove Less_Parser->CacheFile() public method, now private (Hannah Okwelum)
|
||||
* Remove Less_Parser->UnsetInput() public method, now private (Hannah Okwelum)
|
||||
* Remove Less_Parser->save() public method, now private (Hannah Okwelum)
|
||||
|
||||
## v4.4.1
|
||||
|
||||
Fixed:
|
||||
* Update `Less_Version::version` and bump `Less_Version::cache_version` (Timo Tijhof)
|
||||
|
||||
## v4.4.0
|
||||
|
||||
Added:
|
||||
* Add `image-size()` function, disable base64 for SVG `data-uri()` (Hannah Okwelum) [T353147](https://phabricator.wikimedia.org/T353147)
|
||||
* Improve support for preserving `!important` via variables (Piotr Miazga) [T362341](https://phabricator.wikimedia.org/T362341)
|
||||
* Add support for include path inside `data-uri()` (Hannah Okwelum) [T364871](https://phabricator.wikimedia.org/T364871)
|
||||
|
||||
Changed, to match Less.js 2.5.3:
|
||||
* Fix multiplication of mixed units to preserve the first unit (Piotr Miazga) [T362341](https://phabricator.wikimedia.org/T362341)
|
||||
|
||||
Fixed:
|
||||
* Fix checking of guard conditions in nested mixins (Hannah Okwelum) [T352867](https://phabricator.wikimedia.org/T352867)
|
||||
* Less_Functions: Avoid clobbering `clamp()` with internal helper (Timo Tijhof) [T363728](https://phabricator.wikimedia.org/T363728)
|
||||
|
||||
## v4.3.0
|
||||
|
||||
Added:
|
||||
* Support interpolated variable imports, via ImportVisitor (Hannah Okwelum) [T353133](https://phabricator.wikimedia.org/T353133)
|
||||
* Support rulesets as default values of a mixin parameter (Hannah Okwelum) [T353143](https://phabricator.wikimedia.org/T353143)
|
||||
* Support `...` expand operator in mixin calls (Piotr Miazga) [T352897](https://phabricator.wikimedia.org/T352897)
|
||||
* Improve support for `@import (reference)` matching Less.js 2.x (Hannah Okwelum) [T362647](https://phabricator.wikimedia.org/T362647)
|
||||
|
||||
Changed:
|
||||
* Improve `mix()` argument exception message to mention given arg type (Timo Tijhof)
|
||||
* The `Less_Tree_Import->getPath()` method now reflects the path as written in the source code,
|
||||
without auto-appended `.less` suffix, matching upstream Less.js 2.5.3 behaviour.
|
||||
This internal detail is exposed via the deprecated `import_callback` parser option.
|
||||
It is recommended to migrate to `Less_Parser->SetImportDirs`, which doesn't expose internals,
|
||||
and is unaffected by this change.
|
||||
|
||||
Deprecated:
|
||||
* Deprecate `import_callback` Less_Parser option. Use `Less_Parser->SetImportDirs` with callback instead.
|
||||
* Deprecate `Less_Parser->SetInput()` as public method. Use `Less_Parser->parseFile()` instead.
|
||||
* Deprecate `Less_Parser->CacheFile()` as public method. Use `Less_Cache` API instead.
|
||||
* Deprecate `Less_Parser::AllParsedFiles()` as static method. Use `Less_Parser->getParsedFiles()` instead.
|
||||
* Deprecate `Less_Parser->UnsetInput()` as public method, considered internal.
|
||||
* Deprecate `Less_Parser->save()` as public method, considered internal.
|
||||
|
||||
Fixed:
|
||||
* Fix `replace()` when passed multiple replacements (Roan Kattouw) [T358631](https://phabricator.wikimedia.org/T358631)
|
||||
* Fix unexpected duplicating of uncalled mixin rules (Hannah Okwelum) [T363076](https://phabricator.wikimedia.org/T363076)
|
||||
* Fix ParseError for comments after rule name or in `@keyframes` (Piotr Miazga) [T353131](https://phabricator.wikimedia.org/T353131)
|
||||
* Fix ParseError for comments in more places and preserve them (Piotr Miazga) [T353132](https://phabricator.wikimedia.org/T353132)
|
||||
* Fix ParseError effecting pseudo classes with `when` guards (Piotr Miazga) [T353144](https://phabricator.wikimedia.org/T353144)
|
||||
* Fix preservation of units in some cases (Timo Tijhof) [T360065](https://phabricator.wikimedia.org/T360065)
|
||||
* Less_Parser: Faster matching by inlining `matcher()` chains (Timo Tijhof)
|
||||
* Less_Parser: Faster matching with `matchStr()` method (Timo Tijhof)
|
||||
|
||||
## v4.2.1
|
||||
|
||||
Added:
|
||||
* Add support for `/deep/` selectors (Hannah Okwelum) [T352862](https://phabricator.wikimedia.org/T352862)
|
||||
|
||||
Fixed:
|
||||
* Fix ParseError in some division expressions (Hannah Okwelum) [T358256](https://phabricator.wikimedia.org/T358256)
|
||||
* Fix `when()` matching between string and non-string (Timo Tijhof) [T358159](https://phabricator.wikimedia.org/T358159)
|
||||
* Preserve whitespace before `;` or `!` in simple rules (Hannah Okwelum) [T352911](https://phabricator.wikimedia.org/T352911)
|
||||
|
||||
## v4.2.0
|
||||
|
||||
Added:
|
||||
* Add `isruleset()` function (Hannah Okwelum) [T354895](https://phabricator.wikimedia.org/T354895)
|
||||
* Add source details to "Operation on an invalid type" error (Hannah Okwelum) [T344197](https://phabricator.wikimedia.org/T344197)
|
||||
* Add support for `method=relative` parameter in color functions (Hannah Okwelum) [T354895](https://phabricator.wikimedia.org/T354895)
|
||||
* Add support for comments in variables and function parameters (Hannah Okwelum) [T354895](https://phabricator.wikimedia.org/T354895)
|
||||
* Less_Parser: Add `functions` parser option API (Hannah Okwelum)
|
||||
|
||||
Changed, to match Less.js 2.5.3:
|
||||
* Preserve original color keywords and shorthand hex (Hannah Okwelum) [T352866](https://phabricator.wikimedia.org/T352866)
|
||||
|
||||
Fixed:
|
||||
* Fix PHP Warning when using a dynamic variable name like `@@name` (Hannah Okwelum) [T352830](https://phabricator.wikimedia.org/T352830)
|
||||
* Fix PHP Warning when `@extend` path contains non-quoted attribute (Gr8b) [T349433](https://phabricator.wikimedia.org/T349433)
|
||||
* Less_Parser: Faster `skipWhitespace` by using native `strspn` (Umherirrender)
|
||||
* Less_Parser: Fix Less_Tree_JavaScript references to consistently be in camel-case (Stefan Fröhlich)
|
||||
* Fix `!important` in nested mixins (Hannah Okwelum) [T353141](https://phabricator.wikimedia.org/T353141)
|
||||
* Fix crash when using recursive mixins (Timo Tijhof) [T352829](https://phabricator.wikimedia.org/T352829)
|
||||
* Fix disappearing selectors in certain nested blocks (Hannah Okwelum) [T352859](https://phabricator.wikimedia.org/T352859)
|
||||
* Fix Less_Exception_Compiler when passing unquoted value to `color()` (Hannah Okwelum) [T353289](https://phabricator.wikimedia.org/T353289)
|
||||
* Fix order of comments in `@font-face` blocks (Timo Tijhof) [T356706](https://phabricator.wikimedia.org/T356706)
|
||||
* Fix string comparison to ignore quote type (Timo Tijhof) [T357160](https://phabricator.wikimedia.org/T357160)
|
||||
* Fix string interpolation in selectors (Hannah Okwelum) [T353142](https://phabricator.wikimedia.org/T353142)
|
||||
|
||||
## v4.1.1
|
||||
|
||||
* Less_Parser: Faster `MatchQuoted` by using native `strcspn`. (Thiemo Kreuz)
|
||||
* Less_Parser: Faster `parseEntitiesQuoted` by inlining `MatchQuoted`. (Thiemo Kreuz)
|
||||
* Less_Parser: Faster `parseUnicodeDescriptor` and `parseEntitiesJavascript` by first-char checks. (Thiemo Kreuz)
|
||||
* Less_Tree_Mixin_Call: Include mixin name in error message (Jeremy P)
|
||||
* Fix mismatched casing in class names to fix autoloading on case-sensitive filesystems (Jeremy P)
|
||||
|
||||
## v4.1.0
|
||||
|
||||
* Add support for `@supports` blocks. (Anne Tomasevich) [T332923](http://phabricator.wikimedia.org/T332923)
|
||||
* Less_Parser: Returning a URI from `SetImportDirs()` callbacks is now optional. (Timo Tijhof)
|
||||
|
||||
## v4.0.0
|
||||
|
||||
* Remove support for PHP 7.2 and 7.3. Raise requirement to PHP 7.4+.
|
||||
* Remove support for `cache_method=php` and `cache_method=var_export`, only the faster and more secure `cache_method=serialize` is now available. The built-in cache remains disabled by default.
|
||||
* Fix `url(#myid)` to be treated as absolute URL. [T331649](https://phabricator.wikimedia.org/T331688)
|
||||
* Fix "Undefined property" PHP 8.1 warning when `calc()` is used with CSS `var()`. [T331688](https://phabricator.wikimedia.org/T331688)
|
||||
* Less_Parser: Improve performance by removing MatchFuncs and NewObj overhead. (Timo Tijhof)
|
||||
|
||||
## v3.2.1
|
||||
|
||||
* Tree_Ruleset: Fix support for nested parent selectors (Timo Tijhof) [T204816](https://phabricator.wikimedia.org/T204816)
|
||||
* Fix ParseError when interpolating variable after colon in selector (Timo Tijhof) [T327163](https://phabricator.wikimedia.org/T327163)
|
||||
* Functions: Fix "Undefined property" warning on bad minmax arg
|
||||
* Tree_Call: Include previous exception when catching functions (Robert Frunzke)
|
||||
|
||||
## v3.2.0
|
||||
|
||||
* Fix "Implicit conversion" PHP 8.1 warnings (Ayokunle Odusan)
|
||||
* Fix "Creation of dynamic property" PHP 8.2 warnings (Bas Couwenberg)
|
||||
* Fix "Creation of dynamic property" PHP 8.2 warnings (Rajesh Kumar)
|
||||
* Tree_Url: Add support for "Url" type to `Parser::getVariables()` (ciroarcadio) [#51](https://github.com/wikimedia/less.php/pull/51)
|
||||
* Tree_Import: Add support for importing URLs without file extension (Timo Tijhof) [#27](https://github.com/wikimedia/less.php/issues/27)
|
||||
|
||||
## v3.1.0
|
||||
|
||||
* Add PHP 8.0 support: Drop use of curly braces for sub-string eval (James D. Forrester)
|
||||
* Make `Directive::__construct` $rules arg optional (fix PHP 7.4 warning) (Sam Reed)
|
||||
* ProcessExtends: Improve performance by using a map for selectors and parents (Andrey Legayev)
|
||||
|
||||
## v3.0.0
|
||||
|
||||
* Raise PHP requirement from 7.1 to 7.2.9 (James Forrester)
|
||||
|
||||
## v2.0.0
|
||||
|
||||
* Relax PHP requirement down to 7.1, from 7.2.9 (Franz Liedke)
|
||||
* Reflect recent breaking changes properly with the semantic versioning (James Forrester)
|
||||
|
||||
## v1.8.2
|
||||
|
||||
* Require PHP 7.2.9+, up from 5.3+ (James Forrester)
|
||||
* release: Update Version.php with the current release ID (COBadger)
|
||||
* Fix access array offset on value of type null (Michele Locati)
|
||||
* Fix test suite on PHP 7.4 (Sergei Morozov)
|
||||
|
||||
## v1.8.1
|
||||
|
||||
* Another PHP 7.3 compatibility tweak
|
||||
|
||||
## v1.8.0
|
||||
|
||||
Library forked by Wikimedia, from [oyejorge/less.php](https://github.com/oyejorge/less.php).
|
||||
|
||||
* Supports up to PHP 7.3
|
||||
* No longer tested against PHP 5, though it's still remains allowed in `composer.json` for HHVM compatibility
|
||||
* Switched to [semantic versioning](https://semver.org/), hence version numbers now use 3 digits
|
||||
|
||||
## v1.7.0.13
|
||||
|
||||
* Fix composer.json (PSR-4 was invalid)
|
||||
|
||||
## v1.7.0.12
|
||||
|
||||
* set bin/lessc bit executable
|
||||
* Add `gettingVariables` method to `Less_Parser`
|
||||
|
||||
## v1.7.0.11
|
||||
|
||||
* Fix realpath issue (windows)
|
||||
* Set Less_Tree_Call property back to public ( Fix 258 266 267 issues from oyejorge/less.php)
|
||||
|
||||
## v1.7.0.10
|
||||
|
||||
* Add indentation option
|
||||
* Add `optional` modifier for `@import`
|
||||
* Fix $color in Exception messages
|
||||
* take relative-url into account when building the cache filename
|
||||
* urlArgs should be string no array()
|
||||
* fix missing on NameValue type [#269](https://github.com/oyejorge/less.php/issues/269)
|
||||
|
||||
## v1.7.0.9
|
||||
|
||||
* Remove space at beginning of Version.php
|
||||
* Revert require() paths in test interface
|
79
include/thirdparty/less.php/CONTRIBUTING.md
vendored
Normal file
79
include/thirdparty/less.php/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
# Maintainers guide
|
||||
|
||||
## Release process
|
||||
|
||||
1. **Changelog.** Add a new section to the top of `CHANGES.md` with the output from `composer changelog`.
|
||||
|
||||
Edit your new section by following the [Keep a changelog](https://keepachangelog.com/en/1.0.0/) conventions, where by bullet points are under one of the "Added", "Changed", "Fixed", "Deprecated", or "Removed" labels.
|
||||
|
||||
Review each point and make sure it is phrased in a way that explains the impact on end-users of the library. If the change does not affect the public API or CSS output, remove the bullet point.
|
||||
|
||||
2. **Version bump.** Update `/lib/Less/Version.php` and set `version` to the version that you're about to release. Also increase `cache_version` to increment the last number.
|
||||
|
||||
3. **Commit.** Stage and commit your changes with the message `Tag vX.Y.Z`, and then push the commit for review.
|
||||
|
||||
4. **Tag.** After the above release commit is merged, checkout the master branch and pull down the latest changes. Then create a `vX.Y.Z` tag and push the tag.
|
||||
|
||||
Remember to, after the commit is merged, first checkout the master branch and pull down the latest changes. This is to make sure you have the merged version and not the draft commit that you pushed for review.
|
||||
|
||||
## Internal overview
|
||||
|
||||
This is an overview of the high-level steps during the transformation
|
||||
from Less to CSS, and how they compare between Less.js and Less.php.
|
||||
|
||||
Less.js:
|
||||
|
||||
* `less.render(input, { paths: … })`
|
||||
* `Parser.parse` normalizes input
|
||||
* `Parser.parse` parses input into rules via `parsers.primary`
|
||||
* `Parser.parse` creates the "root" ruleset object
|
||||
* `Parser.parse` applies ImportVisitor
|
||||
* `ImportVisitor` applies these steps to each `Import` node:
|
||||
* `ImportVisitor#processImportNode`
|
||||
* `Import#evalForImport`
|
||||
* `ImportVisitor` ends with `ImporVisitor#tryRun` loop (async, after last call to `ImportVisitor#onImported`.
|
||||
* `less.render` callback
|
||||
* `ParseTree.prototype.toCSS`
|
||||
* `transformTree` applies pre-visitors, compiles all rules, and applies post-visitors.
|
||||
* `ParseTree.prototype.toCSS` runs toCSS transform on the "root" ruleset.
|
||||
* CSS result ready!
|
||||
|
||||
Less.php
|
||||
|
||||
* `Less_Parser->parseFile`
|
||||
* `Less_Parser->_parse`
|
||||
* `Less_Parser->GetRules` normalizes input (via `Less_Parser->SetInput`)
|
||||
* `Less_Parser->GetRules` parses input into rules via `Less_Parser->parsePrimary`
|
||||
* `Less_Parser->getCss`
|
||||
* `Less_Parser->getCss` creates the "root" ruleset object
|
||||
* `Less_Parser->getCss` applies Less_ImportVisitor
|
||||
* `Less_ImportVisitor` applies these steps to each `Import` node:
|
||||
* `ImportVisitor->processImportNode`
|
||||
* `Less_Tree_Import->compileForImport`
|
||||
* `ImportVisitor` ends with `ImporVisitor#tryRun` loop (all sync, no async needed).
|
||||
* `Less_Parser->getCss` applies pre-visitors, compiles all rules, and applies post-visitors.
|
||||
* `Less_Parser->getCss` runs toCSS transform on the "root" ruleset.
|
||||
* CSS result ready!
|
||||
|
||||
## Compatibility
|
||||
|
||||
The `wikimedia/less.php` package inherits a long history of loosely compatible
|
||||
and interchangable Less compilers written in PHP.
|
||||
|
||||
Starting with less.php v3.2.1 (released in 2023), the public API is more clearly
|
||||
documented, and internal code is now consistently marked `@private`.
|
||||
|
||||
The public API includes the `Less_Parser` class and several of its public methods.
|
||||
For legacy reasons, some of its internal methods remain public. Maintainers must
|
||||
take care to search the following downstream applications when changing or
|
||||
removing public methods. If a method has one or more references in the below
|
||||
codebases, treat it as a breaking change and document a migration path in the
|
||||
commit message (and later in CHANGES.md), even if the method was undocumented
|
||||
or feels like it is for internal use only.
|
||||
|
||||
* [MediaWiki (source code)](https://codesearch.wmcloud.org/core/?q=Less_Parser&files=php%24)
|
||||
* [Matomo (source code)](https://github.com/matomo-org/matomo/blob/5.0.2/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php)
|
||||
* [Adobe Magento (source code)](https://github.com/magento/magento2/blob/2.4.6/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php)
|
||||
* [Shopware 5 (source code)](https://github.com/shopware5/shopware/blob/5.7/engine/Shopware/Components/Theme/LessCompiler/Oyejorge.php)
|
||||
* [Winter CMS Assetic (source code)](https://github.com/assetic-php/assetic/tree/v3.1.0/src/Assetic/Filter)
|
||||
* [Flarum Framework (source code)](https://github.com/flarum/framework)
|
|
@ -32,6 +32,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||
|
||||
$this->Chunks();
|
||||
$this->genMessage();
|
||||
$this->getFinalMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
12
include/thirdparty/less.php/Exception/Parser.php
vendored
12
include/thirdparty/less.php/Exception/Parser.php
vendored
|
@ -19,6 +19,9 @@ class Less_Exception_Parser extends Exception {
|
|||
*/
|
||||
public $index;
|
||||
|
||||
/** @var string */
|
||||
public $finalMessage = '';
|
||||
|
||||
/** @var string|null */
|
||||
protected $input;
|
||||
|
||||
|
@ -49,14 +52,14 @@ class Less_Exception_Parser extends Exception {
|
|||
*/
|
||||
public function genMessage() {
|
||||
if ( $this->currentFile && $this->currentFile['filename'] ) {
|
||||
$this->message .= ' in ' . basename( $this->currentFile['filename'] );
|
||||
$this->finalMessage .= ' in ' . basename( $this->currentFile['filename'] );
|
||||
}
|
||||
|
||||
if ( $this->index !== null ) {
|
||||
$this->getInput();
|
||||
if ( $this->input ) {
|
||||
$line = self::getLineNumber();
|
||||
$this->message .= ' on line ' . $line . ', column ' . self::getColumn();
|
||||
$this->finalMessage .= ' on line ' . $line . ', column ' . self::getColumn();
|
||||
|
||||
$lines = explode( "\n", $this->input );
|
||||
|
||||
|
@ -65,7 +68,7 @@ class Less_Exception_Parser extends Exception {
|
|||
$last_line = min( $count, $start_line + 6 );
|
||||
$num_len = strlen( $last_line );
|
||||
for ( $i = $start_line; $i < $last_line; $i++ ) {
|
||||
$this->message .= "\n" . str_pad( (string)( $i + 1 ), $num_len, '0', STR_PAD_LEFT ) . '| ' . $lines[$i];
|
||||
$this->finalMessage .= "\n" . str_pad( (string)( $i + 1 ), $num_len, '0', STR_PAD_LEFT ) . '| ' . $lines[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,4 +102,7 @@ class Less_Exception_Parser extends Exception {
|
|||
return $this->index - $pos;
|
||||
}
|
||||
|
||||
public function getFinalMessage() {
|
||||
$this->message .= $this->finalMessage;
|
||||
}
|
||||
}
|
||||
|
|
9
include/thirdparty/less.php/Functions.php
vendored
9
include/thirdparty/less.php/Functions.php
vendored
|
@ -1388,4 +1388,13 @@ class Less_Functions {
|
|||
|
||||
// ~ End of Color Blending
|
||||
|
||||
public function if( $condition, $trueValue, $falseValue = null ) {
|
||||
return $condition->compile( $this->env ) ? $trueValue->compile( $this->env )
|
||||
: ( $falseValue ? $falseValue->compile( $this->env ) : new Less_Tree_Anonymous( '' ) );
|
||||
}
|
||||
|
||||
public function boolean( $condition ) {
|
||||
return $condition ? new Less_Tree_Keyword( 'true' ) : new Less_Tree_Keyword( 'false' );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
194
include/thirdparty/less.php/Parser.php
vendored
194
include/thirdparty/less.php/Parser.php
vendored
|
@ -282,6 +282,9 @@ class Less_Parser {
|
|||
|
||||
// Rethrow exception after we handled resetting the environment
|
||||
if ( !empty( $exc ) ) {
|
||||
if ( $exc instanceof Less_Exception_Parser ) {
|
||||
$exc->getFinalMessage();
|
||||
}
|
||||
throw $exc;
|
||||
}
|
||||
|
||||
|
@ -1216,6 +1219,7 @@ class Less_Parser {
|
|||
?? $this->parseRuleset()
|
||||
?? $this->parseMixinCall( false, false )
|
||||
?? $this->parseVariableCall()
|
||||
?? $this->parseEntitiesCall()
|
||||
?? $this->parseAtRule();
|
||||
|
||||
if ( $node ) {
|
||||
|
@ -1318,7 +1322,7 @@ class Less_Parser {
|
|||
//
|
||||
// The arguments are parsed with the `entities.arguments` parser.
|
||||
//
|
||||
// @see less-2.5.3.js#parsers.entities.call
|
||||
// @see less-3.13.1.js#parsers.entities.call
|
||||
private function parseEntitiesCall() {
|
||||
$index = $this->pos;
|
||||
|
||||
|
@ -1334,17 +1338,25 @@ class Less_Parser {
|
|||
return;
|
||||
}
|
||||
|
||||
$name = $name[1];
|
||||
$nameLC = strtolower( $name );
|
||||
$args = null;
|
||||
|
||||
$name = $name[1];
|
||||
|
||||
// NOTE: Inline equivalent of less-3.13.1.js#customFuncCall
|
||||
$nameLC = strtolower( $name );
|
||||
if ( $nameLC === 'alpha' ) {
|
||||
$alpha_ret = $this->parseAlpha();
|
||||
if ( $alpha_ret ) {
|
||||
return $alpha_ret;
|
||||
$args = $this->parseAlpha();
|
||||
// NOTE: Equivalent of stop=true for parseAlpha in customFuncCall()
|
||||
if ( $args ) {
|
||||
$this->forget();
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
if ( $nameLC === 'boolean' || $nameLC === 'if' ) {
|
||||
$args = [ $this->parseCondition() ?? $this->Error( 'expected condition' ) ];
|
||||
}
|
||||
|
||||
$args = $this->parseEntitiesArguments();
|
||||
$args = $this->parseEntitiesArguments( $args );
|
||||
|
||||
if ( !$this->matchChar( ')' ) ) {
|
||||
$this->restore();
|
||||
|
@ -1359,21 +1371,45 @@ class Less_Parser {
|
|||
* Parse a list of arguments
|
||||
*
|
||||
* @return array<Less_Tree_Assignment|Less_Tree_Expression>
|
||||
* @see less-3.13.1.js#parsers.entities.arguments
|
||||
*/
|
||||
private function parseEntitiesArguments() {
|
||||
$args = [];
|
||||
private function parseEntitiesArguments( $prevArgs = null ) {
|
||||
// NOTE: In Less.js, prevArgs can be undefined (no args parsed) or false (set below).
|
||||
// We treat both of those as null in PHP so that we can use ?? to easily distinguish
|
||||
// these, without treating empty array the same as false.
|
||||
$argsComma = $prevArgs ?? [];
|
||||
$argsSemiColon = [];
|
||||
$isSemiColonSeparated = false;
|
||||
$this->save();
|
||||
while ( true ) {
|
||||
$arg = $this->parseEntitiesAssignment() ?? $this->parseExpression();
|
||||
if ( !$arg ) {
|
||||
break;
|
||||
if ( $prevArgs !== null ) {
|
||||
$prevArgs = null;
|
||||
} else {
|
||||
$value = $this->parseDetachedRuleset() ?? $this->parseEntitiesAssignment() ?? $this->parseExpression();
|
||||
if ( !$value ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $value instanceof Less_Tree_Expression && count( $value->value ) == 1 ) {
|
||||
$value = $value->value[0];
|
||||
}
|
||||
$argsComma[] = $value;
|
||||
}
|
||||
|
||||
$args[] = $arg;
|
||||
if ( !$this->matchChar( ',' ) ) {
|
||||
break;
|
||||
if ( $this->matchChar( ',' ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $this->matchChar( ';' ) || $isSemiColonSeparated ) {
|
||||
$isSemiColonSeparated = true;
|
||||
// NOTE: Avoid apparent Less.js bug, accessing undefined argsComma[0]
|
||||
$value = !$argsComma ? null : new Less_Tree_Value( $argsComma );
|
||||
$argsSemiColon[] = $value;
|
||||
$argsComma = [];
|
||||
}
|
||||
|
||||
}
|
||||
return $args;
|
||||
$this->forget();
|
||||
return $isSemiColonSeparated ? $argsSemiColon : $argsComma;
|
||||
}
|
||||
|
||||
/** @return Less_Tree_Dimension|Less_Tree_Color|Less_Tree_Quoted|Less_Tree_UnicodeDescriptor|null */
|
||||
|
@ -2111,7 +2147,7 @@ class Less_Parser {
|
|||
//
|
||||
// alpha(opacity=88)
|
||||
//
|
||||
// @see less-2.5.3.js#parsers.alpha
|
||||
// @see less-3.13.1.js#parsers.ieAlpha
|
||||
private function parseAlpha() {
|
||||
if ( !$this->matchReg( '/\\Gopacity=/i' ) ) {
|
||||
return;
|
||||
|
@ -2120,10 +2156,11 @@ class Less_Parser {
|
|||
$value = $this->matchReg( '/\\G[0-9]+/' );
|
||||
if ( $value === null ) {
|
||||
$value = $this->parseEntitiesVariable() ?? $this->Error( 'Could not parse alpha' );
|
||||
$value = "@{" . substr( $value->name, 1 ) . "}";
|
||||
}
|
||||
|
||||
$this->expectChar( ')' );
|
||||
return new Less_Tree_Alpha( $value );
|
||||
return new Less_Tree_Quoted( '', "alpha(opacity=" . $value . ")" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3019,13 +3056,13 @@ class Less_Parser {
|
|||
*/
|
||||
private function parseConditions() {
|
||||
$index = $this->pos;
|
||||
$return = $a = $this->parseCondition();
|
||||
$return = $a = $this->parseCondition( true );
|
||||
if ( $a ) {
|
||||
while ( true ) {
|
||||
if ( !$this->peekReg( '/\\G,\s*(not\s*)?\(/' ) || !$this->matchChar( ',' ) ) {
|
||||
break;
|
||||
}
|
||||
$b = $this->parseCondition();
|
||||
$b = $this->parseCondition( true );
|
||||
if ( !$b ) {
|
||||
break;
|
||||
}
|
||||
|
@ -3037,18 +3074,106 @@ class Less_Parser {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see less-2.5.3.js#parsers.condition
|
||||
* @see less-3.13.1.js#parsers.condition
|
||||
*/
|
||||
private function parseCondition() {
|
||||
$index = $this->pos;
|
||||
$negate = false;
|
||||
$c = null;
|
||||
|
||||
if ( $this->matchStr( 'not' ) ) {
|
||||
$negate = true;
|
||||
private function parseCondition( $needsParens = false ) {
|
||||
$result = $this->parseConditionAnd( $needsParens );
|
||||
if ( !$result ) {
|
||||
return null;
|
||||
}
|
||||
$this->expectChar( '(' );
|
||||
/** @see less-3.13.1.js parsers.atomicCondition */
|
||||
|
||||
if ( $this->matchStr( 'or' ) ) {
|
||||
$next = $this->parseCondition( $needsParens );
|
||||
if ( $next ) {
|
||||
$result = new Less_Tree_Condition( 'or', $result, $next );
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see less-3.13.1.js#Parser.conditionAnd
|
||||
*/
|
||||
public function parseConditionAnd( $needsParens ) {
|
||||
// NOTE: Simplified inline equivalent of insideCondition()
|
||||
$cond = $this->negatedCondition( $needsParens ) ?? $this->parenthesisCondition( $needsParens );
|
||||
if ( !$cond && !$needsParens ) {
|
||||
$cond = $this->atomicCondition();
|
||||
}
|
||||
|
||||
if ( $this->matchStr( 'and' ) ) {
|
||||
$next = $this->parseConditionAnd( $needsParens );
|
||||
if ( $next ) {
|
||||
$cond = new Less_Tree_Condition( 'and', $cond, $next );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return $cond;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see less-3.13.1.js#Parser.negatedCondition
|
||||
*/
|
||||
public function negatedCondition( $needsParens ) {
|
||||
if ( $this->matchStr( 'not' ) ) {
|
||||
$result = $this->parenthesisCondition( $needsParens );
|
||||
if ( $result ) {
|
||||
$result->negate = !$result->negate;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see less-3.13.1.js#Parser.parenthesisCondition
|
||||
*/
|
||||
public function parenthesisCondition( $needsParens ) {
|
||||
$tryConditionFollowedByParenthesis = function () use ( $needsParens ) {
|
||||
$this->save();
|
||||
$body = $this->parseCondition( $needsParens );
|
||||
if ( !$body ) {
|
||||
$this->restore();
|
||||
return;
|
||||
}
|
||||
if ( !$this->matchChar( ')' ) ) {
|
||||
$this->restore();
|
||||
return;
|
||||
}
|
||||
$this->forget();
|
||||
return $body;
|
||||
};
|
||||
|
||||
$this->save();
|
||||
if ( !$this->matchChar( '(' ) ) {
|
||||
$this->restore();
|
||||
return;
|
||||
}
|
||||
$body = $tryConditionFollowedByParenthesis();
|
||||
if ( $body ) {
|
||||
$this->forget();
|
||||
return $body;
|
||||
}
|
||||
$body = $this->atomicCondition();
|
||||
if ( !$body ) {
|
||||
$this->restore();
|
||||
return;
|
||||
}
|
||||
if ( !$this->matchChar( ')' ) ) {
|
||||
$this->restore();
|
||||
}
|
||||
|
||||
$this->forget();
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see less-3.13.1.js#Parser.atomicCondition
|
||||
*/
|
||||
public function atomicCondition() {
|
||||
$index = $this->pos;
|
||||
$a = $this->parseAddition()
|
||||
?? $this->parseEntitiesKeyword()
|
||||
?? $this->parseEntitiesQuoted()
|
||||
|
@ -3057,23 +3182,20 @@ class Less_Parser {
|
|||
if ( $a ) {
|
||||
$op = $this->matchReg( '/\\G(?:>=|<=|=<|[<=>])/' );
|
||||
if ( $op ) {
|
||||
/** @see less-3.13.1.js parsers.atomicCondition */
|
||||
$b = $this->parseAddition()
|
||||
?? $this->parseEntitiesKeyword()
|
||||
?? $this->parseEntitiesQuoted()
|
||||
?? $this->parseEntitiesMixinLookup();
|
||||
if ( $b ) {
|
||||
$c = new Less_Tree_Condition( $op, $a, $b, $index, $negate );
|
||||
$c = new Less_Tree_Condition( $op, $a, $b, $index, false );
|
||||
} else {
|
||||
$this->Error( 'Unexpected expression' );
|
||||
}
|
||||
} else {
|
||||
$k = new Less_Tree_Keyword( 'true' );
|
||||
$c = new Less_Tree_Condition( '=', $a, $k, $index, $negate );
|
||||
$c = new Less_Tree_Condition( '=', $a, $k, $index, false );
|
||||
}
|
||||
$this->expectChar( ')' );
|
||||
// @phan-suppress-next-line PhanPossiblyInfiniteRecursionSameParams
|
||||
return $this->matchStr( 'and' ) ? new Less_Tree_Condition( 'and', $c, $this->parseCondition() ) : $c;
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
84
include/thirdparty/less.php/README.md
vendored
Normal file
84
include/thirdparty/less.php/README.md
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
[](https://packagist.org/packages/wikimedia/less.php)
|
||||
|
||||
Less.php
|
||||
========
|
||||
|
||||
This is a PHP port of the [official LESS processor](https://lesscss.org).
|
||||
|
||||
## About
|
||||
|
||||
The code structure of Less.php mirrors that of upstream Less.js to ensure compatibility and help reduce maintenance. The port aims to be compatible with Less.js 3.13.1. Please note that "inline JavaScript expressions" (via eval or backticks) are not supported.
|
||||
|
||||
* [API § Caching](./API.md#caching), Less.php includes a file-based cache.
|
||||
* [API § Source maps](./API.md#source-maps), Less.php supports v3 sourcemaps.
|
||||
* [API § Command line](./API.md#command-line), the `lessc` command includes a watch mode.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the library with Composer or standalone.
|
||||
|
||||
If you have [Composer](https://getcomposer.org/download/) installed:
|
||||
|
||||
1. Run `composer require wikimedia/less.php`
|
||||
2. Use `Less_Parser` in your code.
|
||||
|
||||
Or standalone:
|
||||
|
||||
1. [Download Less.php](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+archive/HEAD.tar.gz) and upload the PHP files to your server.
|
||||
2. Include the library:
|
||||
```php
|
||||
require_once '[path to]/less.php/lib/Less/Autoloader.php';
|
||||
Less_Autoloader::register();
|
||||
```
|
||||
3. Use `Less_Parser` in your code.
|
||||
|
||||
## Security
|
||||
|
||||
The LESS processor language is powerful and includes features that may read or embed arbitrary files that the web server has access to, and features that may be computationally exensive if misused.
|
||||
|
||||
In general you should treat LESS files as being in the same trust domain as other server-side executables, such as PHP code. In particular, it is not recommended to allow people that use your web service to provide arbitrary LESS code for server-side processing.
|
||||
|
||||
_See also [SECURITY](./SECURITY.md)._
|
||||
|
||||
## Who uses Less.php?
|
||||
|
||||
* **[Wikipedia](https://en.wikipedia.org/wiki/MediaWiki)** and the MediaWiki platform ([docs](https://www.mediawiki.org/wiki/ResourceLoader/Architecture#Resource:_Styles)).
|
||||
* **[Matomo](https://en.wikipedia.org/wiki/Matomo_(software))** ([docs](https://developer.matomo.org/guides/asset-pipeline#vanilla-javascript-css-and-less-files)).
|
||||
* **[Magento](https://en.wikipedia.org/wiki/Magento)** as part of Adobe Commerce ([docs](https://developer.adobe.com/commerce/frontend-core/guide/css/preprocess/)).
|
||||
* **[Icinga](https://en.wikipedia.org/wiki/Icinga)** in Icinga Web ([docs](https://github.com/Icinga/icingaweb2)).
|
||||
* **[Shopware](https://de.wikipedia.org/wiki/Shopware)** ([docs](https://developers.shopware.com/designers-guide/less/)).
|
||||
* **[Winter CMS](https://wintercms.com/)** ([docs](https://wintercms.com/docs/v1.2/docs/themes/development))
|
||||
* **[Flarum](https://en.wikipedia.org/wiki/Flarum)** ([docs](https://docs.flarum.org/themes/))
|
||||
|
||||
## Integrations
|
||||
|
||||
Less.php has been integrated with various other projects.
|
||||
|
||||
#### Transitioning from Leafo/lessphp
|
||||
|
||||
If you're looking to transition from the [Leafo/lessphp](https://github.com/leafo/lessphp) library, use the `lessc.inc.php` adapter file that comes with Less.php.
|
||||
|
||||
This allows Less.php to be a drop-in replacement for Leafo/lessphp.
|
||||
|
||||
[Download Less.php](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+archive/HEAD.tar.gz), unzip the files into your project, and include its `lessc.inc.php` instead.
|
||||
|
||||
Note: The `setPreserveComments` option is ignored. Less.php already preserves CSS block comments by default, and removes LESS inline comments.
|
||||
|
||||
#### Drupal
|
||||
|
||||
Less.php can be used with [Drupal's less module](https://drupal.org/project/less) via the `lessc.inc.php` adapter. [Download Less.php](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+archive/HEAD.tar.gz) and unzip it so that `lessc.inc.php` is located at `sites/all/libraries/lessphp/lessc.inc.php`, then install the Drupal less module as usual.
|
||||
|
||||
#### WordPress
|
||||
|
||||
* [wp_enqueue_less](https://github.com/Ed-ITSolutions/wp_enqueue_less) is a Composer package for use in WordPress themes and plugins. It provides a `wp_enqueue_less()` function to automatically manage caching and compilation on-demand, and loads the compressed CSS on the page.
|
||||
* [JBST framework](https://github.com/bassjobsen/jamedo-bootstrap-start-theme) bundles a copy of Less.php.
|
||||
* The [lessphp plugin](https://wordpress.org/plugins/lessphp/) bundles a copy of Less.php for use in other plugins or themes. This dependency can also be combined with the [TGM Library](http://tgmpluginactivation.com/).
|
||||
|
||||
## Credits
|
||||
|
||||
Less.php was originally ported to PHP in 2011 by [Matt Agar](https://github.com/agar) and then updated by [Martin Jantošovič](https://github.com/Mordred) in 2012. From 2013 to 2017, [Josh Schmidt](https://github.com/oyejorge) lead development of the library. Since 2019, the library is maintained by Wikimedia Foundation.
|
||||
|
||||
## Contribute
|
||||
|
||||
* Issue tracker: https://phabricator.wikimedia.org/tag/less.php/
|
||||
* Source code: https://gerrit.wikimedia.org/g/mediawiki/libs/less.php ([Get started with Gerrit](https://www.mediawiki.org/wiki/Gerrit/Tutorial/tl;dr))
|
51
include/thirdparty/less.php/Tree/Call.php
vendored
51
include/thirdparty/less.php/Tree/Call.php
vendored
|
@ -28,12 +28,21 @@ class Less_Tree_Call extends Less_Tree {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see less-2.5.3.js#functionCaller.prototype.call
|
||||
* @see less-3.13.1.js#functionCaller.prototype.call
|
||||
*/
|
||||
private function functionCaller( $function, array $arguments ) {
|
||||
private function functionCaller( $function, array $arguments, $env, $evalArgs ) {
|
||||
// This code is terrible and should be replaced as per this issue...
|
||||
// https://github.com/less/less.js/issues/2477
|
||||
$filtered = [];
|
||||
|
||||
if ( $evalArgs !== false ) {
|
||||
foreach ( $arguments as $a ) {
|
||||
$filtered[] = $a->compile( $env );
|
||||
}
|
||||
$arguments = $filtered;
|
||||
$filtered = [];
|
||||
}
|
||||
|
||||
foreach ( $arguments as $argument ) {
|
||||
if ( $argument instanceof Less_Tree_Comment ) {
|
||||
continue;
|
||||
|
@ -45,6 +54,7 @@ class Less_Tree_Call extends Less_Tree {
|
|||
$filtered[$index] = $argument->mapToFunctionCallArgument();
|
||||
}
|
||||
}
|
||||
|
||||
return $function( ...$filtered );
|
||||
}
|
||||
|
||||
|
@ -76,32 +86,25 @@ class Less_Tree_Call extends Less_Tree {
|
|||
*/
|
||||
$currentMathContext = $env->mathOn;
|
||||
$env->mathOn = !$this->calc;
|
||||
$evalArgs = null;
|
||||
|
||||
if ( $this->calc || $env->inCalc ) {
|
||||
$env->enterCalc();
|
||||
}
|
||||
$nameLC = strtolower( $this->name );
|
||||
|
||||
$args = [];
|
||||
foreach ( $this->args as $a ) {
|
||||
$args[] = $a->compile( $env );
|
||||
}
|
||||
|
||||
$env->mathOn = $currentMathContext;
|
||||
|
||||
$nameLC = strtolower( $this->name );
|
||||
switch ( $nameLC ) {
|
||||
case '%':
|
||||
$nameLC = '_percent';
|
||||
break;
|
||||
|
||||
case 'get-unit':
|
||||
$nameLC = 'getunit';
|
||||
break;
|
||||
|
||||
case 'data-uri':
|
||||
$nameLC = 'datauri';
|
||||
break;
|
||||
|
||||
case 'svg-gradient':
|
||||
$nameLC = 'svggradient';
|
||||
break;
|
||||
|
@ -114,6 +117,9 @@ class Less_Tree_Call extends Less_Tree {
|
|||
case 'image-height':
|
||||
$nameLC = 'imageheight';
|
||||
break;
|
||||
case 'if':
|
||||
$evalArgs = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$result = null;
|
||||
|
@ -132,16 +138,25 @@ class Less_Tree_Call extends Less_Tree {
|
|||
// If the function name isn't known to LESS, output it unchanged as CSS.
|
||||
if ( $func ) {
|
||||
try {
|
||||
$result = $this->functionCaller( $func, $args );
|
||||
$result = $this->functionCaller( $func, $this->args, $env, $evalArgs );
|
||||
$this->exitCalc( $env, $currentMathContext );
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
// Preserve original trace, especially from custom functions.
|
||||
// https://github.com/wikimedia/less.php/issues/38
|
||||
|
||||
// Check if 'error evaluating function' is the start of the error message
|
||||
// less.js does this by checking if line and column already set
|
||||
if ( strpos( $e->getMessage(), 'error evaluating function' ) === 0 ) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw new Less_Exception_Compiler(
|
||||
'error evaluating function `' . $this->name . '` ' . $e->getMessage()
|
||||
. ' index: ' . $this->index,
|
||||
$e
|
||||
);
|
||||
'error evaluating function `' . $this->name . '`' . ( $e->getMessage() ? ': ' . $e->getMessage() : '' ),
|
||||
$e,
|
||||
$this->index,
|
||||
$this->currentFileInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +164,11 @@ class Less_Tree_Call extends Less_Tree {
|
|||
if ( $result !== null ) {
|
||||
return $result;
|
||||
}
|
||||
foreach ( $this->args as $a ) {
|
||||
$args[] = $a->compile( $env );
|
||||
}
|
||||
$this->exitCalc( $env, $currentMathContext );
|
||||
|
||||
return new self( $this->name, $args, $this->index, $this->currentFileInfo );
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ class Less_Tree_Variable extends Less_Tree {
|
|||
throw new Less_Exception_Compiler(
|
||||
"Recursive variable definition for " . $name,
|
||||
null,
|
||||
$this->index, $this->currentFileInfo
|
||||
$this->index,
|
||||
$this->currentFileInfo
|
||||
);
|
||||
}
|
||||
|
||||
|
|
4
include/thirdparty/less.php/Version.php
vendored
4
include/thirdparty/less.php/Version.php
vendored
|
@ -6,11 +6,11 @@
|
|||
class Less_Version {
|
||||
|
||||
/* Current release version of less.php */
|
||||
public const version = '5.3.1';
|
||||
public const version = '5.4.0';
|
||||
|
||||
/* Upstream less.js version that this release should be compatible with */
|
||||
public const less_version = '3.13.1';
|
||||
|
||||
/* Parser cache version */
|
||||
public const cache_version = '3131-9';
|
||||
public const cache_version = '3131-10';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue