Skip to content

Commit

Permalink
Replace outdated func_get_args() calls with the ... operator
Browse files Browse the repository at this point in the history
Change-Id: I2f5244a1470383a9dd10b063bc954784fdbbe460
  • Loading branch information
thiemowmde authored and umherirrender committed Aug 23, 2023
1 parent 29acea5 commit f09b1f3
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,7 @@ public static function replace_flags( $flags ) {
return $new_flags;
}

public function _percent() {
$string = func_get_arg( 0 );

$args = func_get_args();
array_shift( $args );
public function _percent( $string, ...$args ) {
$result = $string->value;

foreach ( $args as $arg ) {
Expand Down Expand Up @@ -652,13 +648,8 @@ public function acos( $n ) {
return $this->_math( 'acos', 'rad', $n );
}

private function _math() {
$args = func_get_args();
$fn = array_shift( $args );
$unit = array_shift( $args );

private function _math( $fn, $unit, ...$args ) {
if ( $args[0] instanceof Less_Tree_Dimension ) {

if ( $unit === null ) {
$unit = $args[0]->unit;
} else {
Expand Down Expand Up @@ -761,13 +752,11 @@ private function _minmax( $isMin, $args ) {
return new Less_Tree_Anonymous( ( $isMin ? 'min(' : 'max(' ) . implode( Less_Environment::$_outputMap[','], $args ) . ')' );
}

public function min() {
$args = func_get_args();
public function min( ...$args ) {
return $this->_minmax( true, $args );
}

public function max() {
$args = func_get_args();
public function max( ...$args ) {
return $this->_minmax( false, $args );
}

Expand Down Expand Up @@ -961,15 +950,13 @@ public function datauri( $mimetypeNode, $filePathNode = null ) {
}

// svg-gradient
public function svggradient( $direction ) {
public function svggradient( $direction, ...$stops ) {
$throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]';
$arguments = func_get_args();

if ( count( $arguments ) < 3 ) {
if ( count( $stops ) < 2 ) {
throw new Less_Exception_Compiler( $throw_message );
}

$stops = array_slice( $arguments, 1 );
$gradientType = 'linear';
$rectangleDimension = 'x="0" y="0" width="1" height="1"';
$useBase64 = true;
Expand Down

0 comments on commit f09b1f3

Please sign in to comment.