> Am 13.11.2015 um 11:57 schrieb François Laupretre <franc...@php.net>: > > 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
The alternative is replacing the resources by proper objects, without methods and public properties. Then we could integrate it into our object hierarchy in a very lightweight way with proper typing. Having special syntax doesn't really improve it much... Bob