Req #46865 [Opn->Sus]: Typed variables and class members
| From: | cmb@php.net | Date: | Fri, 30 Dec 2016 15:13:24 +0000 |
| Subject: | Req #46865 [Opn->Sus]: Typed variables and class members | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206243@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46865&edit=1
ID: 46865
Updated by: cmb@php.net
Reported by: zyss at mail dot zp dot ua
Summary: Typed variables and class members
-Status: Open
+Status: Suspended
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Linux, Windows
PHP Version: 5.2.8
Block user comment: N
Private report: N
New Comment:
FTR: return type declarations are available as of PHP 7.0.0. An
RFC to add optional property type declarations[1] has been
declined not long ago.
Anyhow, any such feature would require the RFC process[2], so I'm
suspending this request.
[1] <https://wiki.php.net/rfc/typed-properties>
[2] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2008-12-14 20:25:18] zyss at mail dot zp dot ua
Description:
------------
Currently it is possible to specify class types for function arguments. It would be very helpful to
also add an ability to set types for function return values, variables (local and global) and
especially for class members. In general - to improve types checking when it is required by
programmer, it will help to eliminate hidden errors that are sometimes hard to find now. For
example:
class Foo {
private Foo $next;
function Foo getNext() {
return $this->next;
}
}
class Bar {
private Foo $foo;
function doo(Foo $prevFoo) {
Foo $newFoo = $prevFoo->getNext();
$this->foo = $newFoo;
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=46865&edit=1