|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46865 Typed variables and class members
Submitted: 2008-12-14 20:25 UTC Modified: 2016-12-30 15:13 UTC
Avg. Score:4.6 ± 0.5
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:3 (60.0%)
From: zyss at mail dot zp dot ua Assigned:
Status: Suspended Package: *General Issues
PHP Version: 5.2.8 OS: Linux, Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zyss at mail dot zp dot ua
New email:
PHP Version: OS:


 [2008-12-14 20:25 UTC] zyss at mail dot zp dot ua
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;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-30 15:13 UTC]
-Status: Open +Status: Suspended -Package: Feature/Change Request +Package: *General Issues
 [2016-12-30 15:13 UTC]
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] <>
[2] <>
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC