Skip to content

Commit b01ecdd

Browse files
anny21Krinkle
authored andcommitted
Less_Tree_Color: Fix "Undefined property" warning for $value
This is accessed from Less_Tree_Variable when compiling a variable variable name (e.g. `@@example`) where the inner value is a string that happens to also be a color keyword. Bug: T352830 Change-Id: I3e5b6daeefa4f0528464a479dc790d0e10f28b02
1 parent 9fad91e commit b01ecdd

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

lib/Less/Parser.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,15 +1053,20 @@ private function parseEntitiesKeyword() {
10531053

10541054
// duplicate of Less_Tree_Color::FromKeyword
10551055
private function FromKeyword( $keyword ) {
1056-
$keyword = strtolower( $keyword );
1056+
$c = $keyword = strtolower( $keyword );
10571057

10581058
if ( Less_Colors::hasOwnProperty( $keyword ) ) {
10591059
// detect named color
1060-
return new Less_Tree_Color( substr( Less_Colors::color( $keyword ), 1 ) );
1060+
$c = new Less_Tree_Color( substr( Less_Colors::color( $keyword ), 1 ) );
10611061
}
10621062

10631063
if ( $keyword === 'transparent' ) {
1064-
return new Less_Tree_Color( [ 0, 0, 0 ], 0, true );
1064+
$c = new Less_Tree_Color( [ 0, 0, 0 ], 0, true );
1065+
}
1066+
1067+
if ( isset( $c ) && is_object( $c ) ) {
1068+
$c->value = $keyword;
1069+
return $c;
10651070
}
10661071
}
10671072

lib/Less/Tree/Color.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Less_Tree_Color extends Less_Tree {
66
public $rgb;
77
public $alpha;
88
public $isTransparentKeyword;
9+
public $value;
910

1011
public function __construct( $rgb, $a = 1, $isTransparentKeyword = null ) {
1112
if ( $isTransparentKeyword ) {
@@ -213,15 +214,20 @@ public function toHex( $v ) {
213214
* @param string $keyword
214215
*/
215216
public static function fromKeyword( $keyword ) {
216-
$keyword = strtolower( $keyword );
217+
$c = $keyword = strtolower( $keyword );
217218

218219
if ( Less_Colors::hasOwnProperty( $keyword ) ) {
219220
// detect named color
220-
return new self( substr( Less_Colors::color( $keyword ), 1 ) );
221+
$c = new self( substr( Less_Colors::color( $keyword ), 1 ) );
221222
}
222223

223224
if ( $keyword === 'transparent' ) {
224-
return new self( [ 0, 0, 0 ], 0, true );
225+
$c = new self( [ 0, 0, 0 ], 0, true );
226+
}
227+
228+
if ( isset( $c ) && is_object( $c ) ) {
229+
$c->value = $keyword;
230+
return $c;
225231
}
226232
}
227233

test/phpunit/FixturesTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ class phpunit_FixturesTest extends phpunit_bootstrap {
2525
'mixins' => true,
2626

2727
// Temporary disabled; Bug logged here T352830
28+
// If T352866 is fixed, this is should also be resolved
2829
'variables' => true,
29-
'functions' => true, // resolved if T352830 is fixed;
30+
31+
// Temporary disabled; Bug logged here T353289
32+
'functions' => true,
3033

3134
// Temporary disabled; Bug logged here T352859
3235
'selectors' => true,

0 commit comments

Comments
 (0)