Re: [RFC] [DISCUSSION] Scalar Pseudo-type

From: Date: Tue, 26 Dec 2017 22:39:45 +0000
Subject: Re: [RFC] [DISCUSSION] Scalar Pseudo-type
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-101427@lists.php.net to get a copy of this message
On 12/26/2017 5:20 PM, Alexander Lisachenko wrote: > In some distant future it could be implemented in more natural way with > classes for primitive types and automatic boxing/unboxing for primitive > built-in types: > > Php\Type\Object > Php\Type\Scalar > ⌊ Php\Type\String > ⌊ Php\Type\Integer > ⌊ Php\Type\Float > ⌊ Php\Type\Boolean > Php\Type\Array > > And it will be easy to typehint all scalars via common parent class: > > public function acceptsScalar(Scalar $scalarValue). > > But all scalar objects in this case should be implemented as immutable or > should be passed as copy (like arrays). So, I would vote no for adding > special scalar typehint without mapping it to the common class or > interface, like iterable => Traversable, callable => Closure, etc > > Best regards, Alexander > This is what I would like to see but making the primitives objects without too much BC is a complicated thing to achieve. Auto-boxing could be a solution. However, we would need many new things and new things are in general not well received in the PHP world if they replace other things. -- Richard "Fleshgrinder" Fussenegger

« previous php.internals (#101427) next »