Re: Type casting syntax

From: Date: Mon, 12 Jul 2021 21:16:18 +0000
Subject: Re: Type casting syntax
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-115419@lists.php.net to get a copy of this message
On Mon, Jul 12, 2021 at 10:36 PM Mike Schinkel <mike@newclarity.net> wrote: > > In your hypothetical view here, what happens when the $container does not > have SomeService to provide? Does it throw an Exception? > > Up to the developer that implements it. If the signature would be get<T>(?string $id): T; then I would assume an error should be thrown by PHP, or an Exception by the method, or handled by the developer to always return T. ?SomeException as T could let the developer not throw an exception if needed and return null instead.

« previous php.internals (#115419) next »