__invoke() On New¶
It is possible to create a new object by calling new on a previous object: PHP fetches the name of the class, then its constructor.
With the PHP 8.4 new syntax without parenthesis, it is also possible to chain the instantiation with a direct call. This calls the __invoke method.
This was not possible in previous versions.
See Also¶
invoke on new [Try me]