|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 16 13:03:34 2021 UTC