Pull updates from wikimedia/less.php#2
Open
wpmvangroesen wants to merge 385 commits intobeerntea:masterfrom
Open
Pull updates from wikimedia/less.php#2wpmvangroesen wants to merge 385 commits intobeerntea:masterfrom
wpmvangroesen wants to merge 385 commits intobeerntea:masterfrom
Conversation
Move testOptionFunctions and testOptionRootpath from FixturesTest to ParserTest. These verify options of the Less_Parser class, covered by ParserTest. FixturesTest is for integration tests that verify the output of a "Fixtures/" subdirectory. Change-Id: I6a96a70aa6366cce3e4d5e50e5455d7b1bd378b9
Change-Id: I7f7d58913ea23170561105821ad35b6ae0c557d4
…or functions A lot of changes from upstream Less.js 2.x were ported in this patch, but let's go over them; Firstly, comments nodes are now allowed in function arguments, see less/less.js@7d86a5e We added support for isruleset, see less/less.js@297ac17 Support optional relative amounts for color functions, see less/less.js@622a521 Less_Tree_Quoted escape now defaults to true, see less/less.js@ccd49bb And a minor fix for replace function and _percent, see less/less.js@13ef5b7 Bug: T354895 Change-Id: I2fcb32e5eb67bbcbdcc76e96a6b8b1c6fec50c7e
see less/less.js@996947d Bug: T353141 Change-Id: Ib7adee6a61ebab6bfe3d76c11fd57bb809050a48
Bug: T352859 Change-Id: I3787ba8cab5c9943cdf467d065f4dc129dc8843b
Bug: T342110 Change-Id: Ia7c69137e7543cca4b89c0439b1a73e0e1ed078e
string interpolation should run in a loop as long as the string keeps being modified see less/less.js@796d37c Bug: T353142 Change-Id: I9eae221cbb3fe93b17d79a66e9b3425cbe24163b
Change-Id: I9c769775a4e5457804a6961508c6866a0de7fdb8
* (v2.5.0) "Bubble import only above other non comment, non charset rules." less/less.js@e0dff5308c * (v1.7.4) "Fix ordering of import and charset directives" less/less.js@864c63d27b Also follow-up 9fad91e, which modified lessjs-2.5.3/expected/media.css to tolerate one extra line break (compared to lessjs-2.5.3/css/media.css from upstream). After this commit, we now produces the same output as upstream for this test, so the override must be removed. Bug: T356706 Change-Id: I658d507e474afd20f02e9aca2b07c9fcf98d0984
Change-Id: I8cbf2160f3aee9ac074fdf7e6f6856f523992868
* Ported Quoted change from upstream less/less.js@5647d4d2761 * Sync other compare() implementations to move logic to nodeCompare() and acknowledge the null/undefined outcome. Bug: T357160 Change-Id: I657e7a950ae16ba194d14e438d71e691d0c96f33
Change-Id: I4fc064da95fc093301229ca2cac62ebeffcc499a
see less/less.js@7476669 Bug: T352862 Change-Id: I8d981a86834b23ce5a343fa5484fa756197a2cb1
Port surrounding code to match the 2.5.3 less.js implementation. Bug: T352862 Change-Id: I8f4a6256dbd374a7fd063ca8732b898a12d64300
Follows-up 6d652ed (I657e7a950a), which ported over the upstream Less.js concept of a special outcome in Less_Tree::nodeCompare that represents "not comparable". Callers cast this to false regardless of what is requested (akin to how NaN is neither equal, less, nor greater than any number). Unfortunately, due to behaviour differences in the runtime language, a regression crept it. The new code used `null` in PHP as the closest equivalent to JS undefined. However, there are two cases where this differs: 1. When casted to a number (in Tree.php), undefined because NaN in JS (e.g. +undefined, or -undefined), whereas in both JS and PHP, -null becomes 0. 2. The switch case in PHP performs loose comparison, this means the `0` case becomes a match candidate for `null`, and thus never makes it to the `default` case (in Condition.php), where we're meant to catch null and cast result to false. Bug: T358159 Change-Id: I1157480c560b2eccec9c27200a0fda0448d2932a
Bug: T352911 Change-Id: I42df2ece6f36f092f4699ba1e6288bd5c579971c
Restore current position from stack after parseOperand(). Same as parsers.multiplication() in less-2.5.3.js. Bug: T358256 Change-Id: I576fe46a951a3716d51f1ff0cd13292d6ef3c943
Change-Id: I3d3368ecbaa8e1459311e1dcbceb4f509e881a39
Also fix a broken link in README.md. Bug: T353133 Change-Id: Id6dbbbd916993d7f71fc4fe34766559982bb3847
I2fcb32e5eb (29cf2b9) fixed a bug in the `replace` function where the absence of the 'g' modified was ignored, and all occurrences were always replaced. However, in fixing this bug, it created a new one: when the 'g' modified was present, the replacement was run twice, first as a single replace and then as a multiple replace. This caused all sorts of buggy output. Fix this by running the replacement only once, either with the limit set to 1 (if 'g' is not set) or with the limit not set (if 'g' is set). Bug: T358631 Change-Id: Ica9de4b14385167ad300ad05e1c3995af0ad8ade
I suspect these were marked public to allow them to be used via callbacks between parts of the same class, which sometimes required the function to be public in PHP 5. However, these callbacks have been removed since and the library now requires PHP 7. * d49bb25 Less_Parser: Remove 'MatchFuncs' indirection * 2370bbe Less_Parser: Remove 'NewObj' indirection * 3fa04e4 Less_Parser: Only support `cache_method=serialized` Obvious internal ones that have no known usage in consumers (as per CONTRIBUTING.md) are turned private immediately. Others are marked internal or deprecated to be removed or made private in a major release. Change-Id: I3d6439551b8343074e242f0474b8b371d351e5cc
This is not a port of any specific upstream Less.js changes. For many years, whenever we ported upstream changes in Parser or Envirnment, we mapped the logic onto static equivalents, to keep the changes simpler. However, upstream is now for the most part based on instance state and by-reference objects. This hasn't yet caused any obvious bugs, but it does decrease confidence in how things work, and it makes some big changes part of T353133 difficult to port. This patchs should help prevent future bugs as result from upcoming porting commits by re-synchronising the code to match upstream not just in how the code looks, but also in the behaviour (instance vs static). Sync with Less.js: * Manage math state in Less_Environment object, instead of modifying Less_Parser::$options or Less_Environment::$mathOn. * Manage list of imported files in Less_Environment object. In Less.js, this is kept in the ImportVisitor, but we haven't implemented that yet. I'm leaving that for a future change by Hannah, and now only moving it away from static state as first step. Also: * Move SetOptions() in Less_Parser::__construct to Reset(). This was causing a problem because $this->env is not yet defined during that call. Without this, SetOption() can't pass strictMath to Less_Environment. Bug: T353133 Change-Id: If4a0a7ce052fb378f078e767fdb7449bd7e78de2
The css/ directory contains the upstream specification. The expected/ directory is a duplicate with minor differences where we've accepted a difference where we believe the test is useful to enable even if it is not yet completely passing (instead of disabling the test entirely in FixturesTest::KNOWN_FAILURE). To make this easier to maintain, let's keep only the files that are different, and update FixtureTest.php to compare against css/ by default, unless an override/ file exists. The name "override" is probably clearer this way, instead of "expected" which did not make it obvious since css/ is also the expected output. Change-Id: I1f358a359dea839c880f96c85041cbcd6a32aef2
Bug: T349580 Change-Id: I2778b7449495cc51376b243b9c67dce065db8c29
This unversioned directory was a mixture of various different less.js 1.x and 2.x specs from upstream. In T349580, we added the latest Less.js 2.x spec from Less.js 2.5.3 at test/Fixtures/lessjs-2.5.3/ which is what PHPUnit and compare.php use now. The last remaining reference was from bench.php where I had included one of its files (strings.less). Preserve this for benchmark continuity in a new bench-strings directory, and rename it to reflect that it came from <https://github.com/less/less.js/blob/v1.5.0/test/less/strings.less> The second benchmark was unnamed, but largely about Bootstrap with a few small files thrown in as well. This was already unstable since the directories it used do get changed sometimes (e.g. less.php/ and lessjs/), so remove those from it in one last changed and rename it to more clearly be about a pinned version. Change-Id: I715358f7c284e0e4905c18aa053d6590610beb42
Upstream changes: * Add boolean and if. less/less.js@006ce2651d * Allow conditional evaluation of function args. less/less.js@d5aa9d1503 Bug: T393383 Change-Id: Ia5ab234e807a86c1c2f356d35bc745f554011cef
Change-Id: I168806026da76a6da0ec588c7267c97131556d12
Change-Id: I9de9d4a247e01cd6fb28e82fcd1b3a1fb162bc7e
…with For readability of the conditions Change-Id: Ie14da92125a4288d22c093e6f2311402f8541615
https://www.php.net/manual/en/mbstring.overload.php Also remove use of ini setting mbstring.internal_encoding, deprecated as well and not called. https://www.php.net/manual/en/mbstring.configuration.php#ini.mbstring.internal-encoding Change-Id: I85f790899c82dfac2ecba828d40f98266b17a001
The callback for spl_autoload_register has return type void. Use type declaration on whole class Change-Id: Ia7b60e658dbecd7620f96c041027e76463b267dd
Change-Id: Iba1f95ec9c415f23474373e15161a41fd87f8990
Introduced in 2014 with commit b6df4c2. It was not used there, and it is not used now. Found via https://doc.wikimedia.org/cover/mediawiki-libs-less.php/Output.php.html as method that lacked test coverage. Change-Id: I7efb04d4b1af19d6641303f7359f42a2d4c2b9af
Change-Id: Ied6663cf1b83feef56ec278d46112130d09d5bce
- Update PHPUnit config for version 10 with `--migrate-configuration` - Enabled options to display all notices, deprecations, etc. Change-Id: I3e9c217a49ddc2de6ca95a6599c6fc6f32d5c880
This fixes hex colors compiling to invalid syntax when using 4-char or 8-char notations with an alpha channel. A major change in this patch was matching Less.js 3.13 output of hsl and hsla functions in CSS output, instead of converting to hex or rgb format. All browsers we support, including Grade C browsers, support this as they have been part of browsers for a long time. See https://caniuse.com/?search=hsla Bug: T403056 Change-Id: I3022d677f2f99ccb2f78e105928ae178acc41f68
It seems update-alternatives used to happen by default but not anymore. Thus, all builds at https://github.com/wikimedia/less.php/actions/ for forks and pull-requests silently switched to the same PHP 8.3 build. Remove PHP 7.4 and 8.0 as those will (correctly) fail after this, because phpunit 10 and mediawiki-codesniffer 48 requires PHP 8.1 as of Ied6663cf1b (ff0163a) and I3e9c217a49 (c544fa9). Change-Id: If4836e474c8647d67f5b84cfd3d2bdfafc2e6e7e
This was fixed upstream in Less.js v2.6.0. I caught this during a review of the nearby parseEntitiesDimension as part of T403056. Remove the unneeded "@" silence operator from the ord() call. This was added in 2013 with commit 51e29cb to deal with null when the position has reached outside the bounds of $this->input. A better fix was added in Ie8d5da3ed4 (67807cb) using `?? ''`, which removes the need for error silencing, because it is now always passed a string. Ref less/less.js#2462 Ref oyejorge#293 Change-Id: I968056b7e45c9752b8ce3833979729ac8230dc6d
…rning Our implementation diverged from upstream Less.js 3.13.1 by using an associative array instead of a list array. Change this so that null values naturally work, without creating an amguity between null and the empty string (since only strings can be valid array keys). This change triggered a Phan warning, because Phan creates a simplified analysis of the parseMixinArgs()['args'] array that mixes up the types of the 'name' and 'value' fields, because it ignored the keys. ``` lib/Less/Tree/Mixin/Definition.php:45 PhanTypeMismatchProperty Assigning ($p['name'] as a field) of type non-empty-array<int,?\Less_Tree|?string> to property but \Less_Tree_Mixin_Definition->optionalParameters is string[] ``` Fix this by declaring the array shape. Bug: T410596 Change-Id: Ic0b5274febea3d2318282619b5f762d11d2530f9
Preserve unsupported color values passed to Less functions, by outputting them as CSS functions instead. Bug: T405815 Change-Id: I0a088edc63b0a18406557b5c5c6212f361ea32dd
In less.js, they do something like "fullPath in importVisitor.recursionDetector" which is kind of the equivalent to array_key_exists. We would also still encounter this error if we use array_key_exists because less.js also passes in null to the function. These values are set in ImportManager.prototype.push and if you narrow down, the actual callback is ImportVisitor.prototype.onImported. Bug: T411400 Change-Id: I4ad03834f87e01ae316494fab1f8205480722f46
… 8.5 warnings Bug: T411398 Change-Id: Iae43dea05b7af91f8002b764259e80f6b050e0df
… 8.5 warning Bug: T411397 Change-Id: I7cebc53ac0a3952575bdee4231f27136baa5d187
Bug: T406326 Bug: T411213 Change-Id: I3db3f3e2eff1d9d9cb329e836f38158406cd47f8
The code does the same as before but utilizes some more recent native features from the PHP language. Change-Id: I669afff34ebe6e4e00e546feb268bd01ff9b79b2
Bug: T411213 Change-Id: Idda7f5dd8e06c1d48ad24f58a9aa2e643df1b31f
* Consistent formatting. * Fix mistaken reference to "gettingVariables" instead of "getVariables". * Add links. Change-Id: I8f79f3193aa18d03e0d72bef8409697f907b7fe6
… key The way this is used in practice, in MediaWiki, in ParserTest::testSetImportDirs, and in the parameter documentation on this very method, is without a (meaningless) string key. During a downstream PR at https://github.com/flarum/framework/pull/4225/files, I found PHPStan failing on: ``` $parser->SetImportDirs([ $function ]); // PHPStan: // Parameter #1 $dirs of method Less_Parser::SetImportDirs() // expects // array<string, (callable(): mixed)|string>, // array{callable(): mixed} // given. ``` Note that PHPStan 1.11.0 understands `phan-param` as alias for `param`, so it will parse it the same way, which is good, this isn't an issue with Phan vs PHPStan. Our documented typehint is actually incomplete. Ref phpstan/phpstan#10996 Change-Id: Id5953eaa3e3a62f6b29ec533a5393ef32dbb1098
Bug: T415723 Change-Id: Iea9643a8b56d656b8ab9dfe0ceb39a02a2d92441
Change-Id: I737d458cf6219bf100efcdcc6c85b02760c3faaa
Bug: T406326 Change-Id: I90a2fd1aa8fd1a644ef831e19d0cea67687a44e8
Change-Id: I8f186bde6aee226934250e99e31a4537c1647fc9
GitHub CI, this library still supports PHP 8.1, validated from time to time there. Phan only needs to run once, the version doesn't matter. Change-Id: If1ec3f2618eb1bbef0a6967afa6b49caa4b19ea2
* mediawiki/mediawiki-codesniffer: 48.0.0 → 50.0.0 * mediawiki/minus-x: 1.1.3 → 2.0.1 Change-Id: Iae11993bb00addcd47cf99e6d9d9017d6252bf22
Change-Id: Iedcdc14f60a7a7a3c49e02888d6fcb2ec022dd63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.