Re: [RFC] Cast in foreach

From: Date: Thu, 21 Feb 2019 19:37:44 +0000
Subject: Re: [RFC] Cast in foreach
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-104496@lists.php.net to get a copy of this message
Hi! > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { > $i=(int) $i; > } This doesn't seem to add anything to existing functionality - what's wrong with just making explicit cast, so that it's clear what is being done? Traditionally, PHP opts to the side of clarity rather than brevity. -- Stas Malyshev smalyshev@gmail.com

« previous php.internals (#104496) next »