Req #63264 [Opn->Wfx]: Type hinting in list()

From: Date: Wed, 25 Aug 2021 15:43:30 +0000
Subject: Req #63264 [Opn->Wfx]: Type hinting in list()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236073@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63264&edit=1

 ID:                 63264
 Updated by:         cmb@php.net
 Reported by:        michaelrfairhurst at gmail dot com
 Summary:            Type hinting in list()
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Arrays related
 Operating System:   CentOs 6
 PHP Version:        5.3.17
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

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] <https://wiki.php.net/rfc/howto>


Previous Comments:
------------------------------------------------------------------------
[2012-10-11 19:58:10] 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;
}



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=63264&edit=1


Thread (2 messages)

« previous php.bugs (#236073) next »