Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Parameter Removal

Parameter removal is the operation to remove a parameter in a method’s signature.

This may happen in two ways:

  • Between versions of the code. A method may see one of its parameter being deprecated then removed.
  • In a function relay, where the method doesn’t transmit all its incoming parameters to the next.
<?php

// get_defined_functions's only paramter was removed in PHP 8.4
$list = get_defined_functions(false);

class Elephpant {
    public function trumpet($trunk, $tusk) {
        // $tusk is ignored, and set to a fixed value.
        // $tusk is actually removed for 'public' usage
        $this->forage($trunk, 2);
    }

    private function forage($trunk, $tusk = 1) {
        // do Something
    }
}
?>

Documentation

See Also