I've been seeing multiple question regarding similar problem but, I can't recall seeing one regarding mine, as I couldn't really "implement" the other solution to get my problem solved, so I'm asking you guys, how to correctly pass a class method to a function in the __construct, or if if it's even possible to pass one before class has initiated.
So, when I initiate the class A i have some config values to be increased, in order to have them set and available.
function __construct(){
require 'configs/production.php';
function increase(&$value,$key){
$value += DB::$speed * 0.05 * $value;
}
array_walk($production,'increase');
$this->production = $production;
}
Ok so this is working, but, I'd like to make the define the increase as a public function in order to have it available for future use. So using this, will give me an error no matter how I pass the function.
function __construct(){
require 'configs/production.php';
array_walk($production,callable 'increase'); // gives error
array_walk($production,$this 'increase'); // gives error too
array_walk($production,A 'increase'); // gives error again
array_walk($production,$this->increase); // is of course undefined
array_walk($production,$this-> increase()); // of course, lacking paramas
$this->production = $production;
}
public function increase(&$value,$key){
$value += DB::$speed * 0.05 * $value;
}
Remember, I'm inside class A. And I'm trying to use type hinting, though, OtherClass $var should work, how am I supposed to send a method from same object.
PHP Version on dev/production: same, 5.5.11