php.net |  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
Votes:5
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
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;
    }
  }



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-30 15:13 UTC] cmb@php.net
-Status: Open +Status: Suspended -Package: Feature/Change Request +Package: *General Issues
 [2016-12-30 15:13 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC