Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10747 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67836 invoked by uid 1010); 24 Jun 2004 09:28:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 67812 invoked from network); 24 Jun 2004 09:28:11 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 24 Jun 2004 09:28:11 -0000 Received: (qmail 26791 invoked from network); 24 Jun 2004 09:28:10 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 24 Jun 2004 09:28:10 -0000 Message-ID: <5.1.0.14.2.20040624094922.02044458@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Thu, 24 Jun 2004 09:50:20 +0100 To: "Aidan Lister" ,internals@lists.php.net In-Reply-To: <20040624014649.30099.qmail@pb1.pair.com> References: <20040622164209.23239.qmail@pb1.pair.com> <5.1.0.14.2.20040622180046.02e53768@127.0.0.1> <20040622171622.64014.qmail@pb1.pair.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Bug 28879: Populating arrays with resources and objects as offsets From: andi@zend.com (Andi Gutmans) Maybe we should move this to an E_STRICT? E_WARNING is more consistent with existing warnings but I wouldn't want to be over strict, especially when making this change a couple of weeks before release. We could escalate the warning for 5.1 if we feel we need to do so. Andi At 11:33 AM 6/24/2004 +1000, Aidan Lister wrote: > > But since there's no BC need to allow resources in array initialization, > > then sure, leave it to the scripter to cast it to an int if that's REALLY > > what they want. (Again "why?" comes to mind). > >PEAR::DB uses this method - I'm seeing a million errors on sites that have >updated to latest CVS version. > >You're forced to i use this method if you want to link a resource back to >it's creation information. > >If you have an array of IPs, and you create an array of resources from each >IP, a third array linking the IP back to the casted interger value of the >resource is required if you want to get the IP back. (This is very confusing >to write). > >Here's an example: > >$servers[] = "139.134.253.11:27025"; >$servers[] = "203.114.130.7:27015"; > >foreach ($servers as $server) >{ > list($ip, $port) = explode(':', $server); > $sock = @fsockopen("udp://" . $ip, $port, $errno, $errstr, 1); > if ($sock !== false) > { > $sockets[] = $sock; > // Create an array so we can link the socket back to the server > $server_keys[$sock] = array_search($server, $servers); > > } >} > >while (stream_select($r, $w = null, $e = null, 0, calctimeout($maxtime, >$starttime)) !== 0) >{ > ++$i; > foreach ($r as $socket) > { > $response = stream_get_contents($socket); > // Put the response into an array with the original IP as the key > $results[$server_keys[$socket]][] = $response; > } >} >?> > >I hope that demonstrates the purpose properly. > >Ofcourse this method can still be used, it just requires an extra cast >(which is a cleaner solution anyway). > >Regards, >Aidan > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php