Req #43456 [Asn->Csd]: Class property type hints

From: Date: Fri, 25 Jan 2019 16:10:28 +0000
Subject: Req #43456 [Asn->Csd]: Class property type hints
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219208@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=43456&edit=1 ID: 43456 Updated by: nikic@php.net Reported by: kjarli at gmail dot com Summary: Class property type hints -Status: Assigned +Status: Closed Type: Feature/Change Request Package: Class/Object related Operating System: * PHP Version: * Assigned To: nikic Block user comment: N Private report: N New Comment: The implementation for the aforementioned RFC has been merged, and typed properties will be available in PHP 7.4. Previous Comments: ------------------------------------------------------------------------ [2018-08-22 02:31:19] carusogabriel@php.net An RFC about this topic has been opened: https://wiki.php.net/rfc/typed_properties_v2 ------------------------------------------------------------------------ [2007-11-29 16:55:05] kjarli at gmail dot com Description: ------------ Why not adding something like this in classes: public $array:Array; private $bool:Bool = false; protected $number:Number = 40; var $string:String = 'a text'; This is like forcing a variable into a bool, array, number etc. This should be pure for classes only. Assigning an array value to like a :Number, will cause a notice error. This is usefull for 1. Debugging 2. accessing public values 3. If you are working with more than 1 person, your class won't get messed up. 4. if you use like :Number, and you insert '10', it can force it into a number. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=43456&edit=1

« previous php.bugs (#219208) next »