|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63264 Type hinting in list()
Submitted: 2012-10-11 19:58 UTC Modified: 2021-08-25 15:43 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: michaelrfairhurst at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: Arrays related
PHP Version: 5.3.17 OS: CentOs 6
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: michaelrfairhurst at gmail dot com
New email:
PHP Version: OS:


 [2012-10-11 19:58 UTC] michaelrfairhurst at gmail dot com
Since list is a language construct, it would be great if it had type hinting.

list(ContractPrice $price, Adjustment $adj) = $deps;

truth be told I got this whim from PHPUnit, where I like having type hinting on 
my @dependent tests -- example is based on that.

Test script:
 * @depends testReturns_ContractPrice
function testReturnsArray(ContractPrice $price) {
    $adjustment = new Adjustment;
    $this->assertEquals('stuff', $price->stuff($adjustment));

    return array($price, $adjustment);

 *@depends testReturns_Array
function testTypeHintingLists(array $deps) {
    list(ContractPrice $price, Adjustment $adjustment) = $deps;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-25 15:43 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-08-25 15:43 UTC]
This doesn't make much sense on its own; I mean other local
variables should be typeable as well, if we do that.  Anyhow, this
would require the RFC process[1], and given that there has been no
feedback on this ticket so far, I'm closing as WONTFIX.

For now you can use a static analyzer.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 06:01:30 2024 UTC