Evaluating a PHP library I found the following code, which seemed to me to be redundant, it makes me think
Why would you want a class to have callable property?
class OpenIDConnectClient
{
...
/**
* @var callable validator function for issuer claim
*/
private $issuerValidator;
...
public function __construct($provider_url = null, $client_id = null, $client_secret = null, $issuer = null) {
...
$this->issuerValidator = function($iss){
return ($iss === $this->getIssuer() || $iss === $this->getWellKnownIssuer() || $iss === $this->getWellKnownIssuer(true));
};
}
...
}
In the above example the callable property will be the same every time, so it is not about being dynamic, there seems no need to instantiate this in the constructor either, and why not just make it a method of the class?
Addendum Why on PHP Type declarations docs does it say this (emphasis mine):
callable - The value must be a valid callable. Cannot be used as a class property type declaration.