Skip to content

Commit

Permalink
Replace class names hard-coded in strings with proper references
Browse files Browse the repository at this point in the history
Change-Id: I4dd6387c2de2d422a3746216c6ff53d657e136e2
  • Loading branch information
thiemowmde authored and umherirrender committed Oct 1, 2023
1 parent b24f721 commit 9fb8812
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
22 changes: 7 additions & 15 deletions lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public function round( $n, $f = false ) {
$fraction = $f->value;
}

return $this->_math( 'Less_Parser::round', null, $n, $fraction );
return $this->_math( [ Less_Parser::class, 'round' ], null, $n, $fraction );
}

public function pi() {
Expand Down Expand Up @@ -778,23 +778,23 @@ public function color( $n ) {
}

public function iscolor( $n ) {
return $this->_isa( $n, 'Less_Tree_Color' );
return new Less_Tree_Keyword( $n instanceof Less_Tree_Color ? 'true' : 'false' );
}

public function isnumber( $n ) {
return $this->_isa( $n, 'Less_Tree_Dimension' );
return new Less_Tree_Keyword( $n instanceof Less_Tree_Dimension ? 'true' : 'false' );
}

public function isstring( $n ) {
return $this->_isa( $n, 'Less_Tree_Quoted' );
return new Less_Tree_Keyword( $n instanceof Less_Tree_Quoted ? 'true' : 'false' );
}

public function iskeyword( $n ) {
return $this->_isa( $n, 'Less_Tree_Keyword' );
return new Less_Tree_Keyword( $n instanceof Less_Tree_Keyword ? 'true' : 'false' );
}

public function isurl( $n ) {
return $this->_isa( $n, 'Less_Tree_Url' );
return new Less_Tree_Keyword( $n instanceof Less_Tree_Url ? 'true' : 'false' );
}

public function ispixel( $n ) {
Expand All @@ -818,15 +818,7 @@ public function isunit( $n, $unit ) {
$unit = $unit->value;
}

return ( $n instanceof Less_Tree_Dimension ) && $n->unit->is( $unit ) ? new Less_Tree_Keyword( 'true' ) : new Less_Tree_Keyword( 'false' );
}

/**
* @param Less_Tree $n
* @param string $type
*/
private function _isa( $n, $type ) {
return is_a( $n, $type ) ? new Less_Tree_Keyword( 'true' ) : new Less_Tree_Keyword( 'false' );
return new Less_Tree_Keyword( $n instanceof Less_Tree_Dimension && $n->unit->is( $unit ) ? 'true' : 'false' );
}

public function tint( $color, $amount = null ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Tree/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function compile( $env = null ) {
$result = Less_Tree_DefaultFunc::compile();
} else {
$func = null;
if ( method_exists( 'Less_Functions', $nameLC ) ) {
if ( method_exists( Less_Functions::class, $nameLC ) ) {
$functions = new Less_Functions( $env, $this->currentFileInfo );
$func = [ $functions, $nameLC ];
} elseif ( isset( $env->functions[$nameLC] ) && is_callable( $env->functions[$nameLC] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion test/phpunit/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testFunction() {
}

public static function reverse( $arg ) {
if ( is_a( $arg, 'Less_Tree_Quoted' ) ) {
if ( $arg instanceof Less_Tree_Quoted ) {
$arg->value = strrev( $arg->value );
return $arg;
}
Expand Down

0 comments on commit 9fb8812

Please sign in to comment.