php.net |  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: -
Votes:1
Avg. Score:5.0 ± 0.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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michaelrfairhurst at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-11 19:58 UTC] michaelrfairhurst at gmail dot com
Description:
------------
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;
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Tue Nov 13 04:01:25 2018 UTC