PHP 8.5.0 Alpha 4 available for testing

Voting

: min(five, two)?
(Example: nine)

The Note You're Voting On

joey
6 years ago
The only way to type hint this would appear to be as object.

If you need multiple instances of an anonymous class in a function you can use:

$class = function(string $arg):object {
return new class($arg) {
public function __construct(string $arg) {
$this->ow = $arg;
}
};
};

Though for the sake of structure it's ill advised to do something like this outside of a single scope or that's used across multiple files. If you class is only used in one scope however then it's probably not a code mess problem.

<< Back to user notes page

To Top