Skip to content

Commit

Permalink
phan: update Less_Tree_Variable::compile() return types
Browse files Browse the repository at this point in the history
The Variable::compile() can return different subtypes of
Less_Tree. In mentioned specified scenario it can return
Less_Tree_Keyword or Less_Tree_Quoted, therefore the node
will have always have the $value property.
To satisfy phan, it's good enough to add additional
possible return types to @return statemenmt.

Bug: T327082
Change-Id: I412dfd2258a7352e2d8a03e5dc187b53ebf3c843
  • Loading branch information
polishdeveloper committed Oct 27, 2023
1 parent b47906c commit c20cc90
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/Less/Tree/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ public function __construct( $name, $index = null, $currentFileInfo = null ) {

/**
* @param Less_Environment $env
* @return Less_Tree
* @return Less_Tree|Less_Tree_Keyword|Less_Tree_Quoted
* @see less-2.5.3.js#Ruleset.prototype.eval
*/
public function compile( $env ) {
if ( $this->name[1] === '@' ) {
$v = new self( substr( $this->name, 1 ), $this->index + 1, $this->currentFileInfo );
// While some Less_Tree nodes have no 'value', we know these can't ocurr after a variable
// assignment (would have been a ParseError).
// TODO: Solve better (https://phabricator.wikimedia.org/T327082).
// @phan-suppress-next-line PhanUndeclaredProperty
// While some Less_Tree nodes have no 'value', we know these can't occur after a
// variable assignment (would have been a ParseError).
$name = '@' . $v->compile( $env )->value;
} else {
$name = $this->name;
Expand Down

0 comments on commit c20cc90

Please sign in to comment.