Re: Re: Resource typehint and return type

From: Date: Fri, 13 Nov 2015 10:56:41 +0000
Subject: Re: Re: Resource typehint and return type
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-89202@lists.php.net to get a copy of this message
Hi, Le 13/11/2015 04:30, Stanislav Malyshev a écrit :
Hi!
The reason for this is that the resource type is an anachronism from an age in which PHP did not have objects, yet still needed to make certain types of data opaque. The resource type is a type that exists only to
I think more specific reason is not that resource type is outdated, but that resource is not really a type - it's a collection of types. Mysql connection is a resource, and file is a resource, but they are certainly not interchangeable. So typing a value as "resource" would not achieve you much.
I agree. Some resources may disappear in the future but others, like opened streams, are not obsolete at all. As 'resource' is not specific enough. What about including the resource type in some way ? Something like '@stream', '[stream]', '{stream}' ? Just need to replace spaces with underscores (e.g. 'persistent_stream'). Regards François

« previous php.internals (#89202) next »