Proposal for developers

From: Date: Wed, 20 May 2015 02:56:29 +0000
Subject: Proposal for developers
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-21179@lists.php.net to get a copy of this message
I apologize for my bad English, I used Google translate. I would propose developers to add the ability to use the classes in the type conversion, adding in class a new magical method, for example, __converting() For example: <?php class ClassName { private $myProperty; public function __construct($value) { $this->myProperty = $value; } public function show() { echo $this->myProperty; } public function __converting($value) { return new self($value); } } // Example of use $value = 123; $value = (ClassName)$value; $value->show(); // Result: 123 ?> Similarly, for the classes in the namespace: <?php /* A class declaration in namespace: MyNamespace\ClassName */ $value = 123; $value = (MyNamespace\ClassName)$value; // Or $value = (\MyNamespace\ClassName)$value; $value->show(); // Result: 123 ?> Thank you for your attention.

« previous php.webmaster (#21179) next »