|  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: -
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:
Status: Open Package: Arrays related
PHP Version: 5.3.17 OS: CentOs 6
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: 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

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jun 24 10:01:23 2021 UTC