Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71392 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66937 invoked from network); 21 Jan 2014 22:21:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2014 22:21:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=willfitch@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=willfitch@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 66.111.4.28 as permitted sender) X-PHP-List-Original-Sender: willfitch@php.net X-Host-Fingerprint: 66.111.4.28 out4-smtp.messagingengine.com Received: from [66.111.4.28] ([66.111.4.28:37134] helo=out4-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/35-40896-4F2FED25 for ; Tue, 21 Jan 2014 17:21:41 -0500 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 48F3E209B2; Tue, 21 Jan 2014 17:21:38 -0500 (EST) Received: from web6 ([10.202.2.216]) by compute4.internal (MEProxy); Tue, 21 Jan 2014 17:21:38 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=o++VkOvJJ+H3qpIqEKQO5xbdDF8=; b=MFO jKuLThhKHNc2OKGpRxbHtdC4qjYUdAoDCnv/7UUpRKnovJxBFMb6pADVV78hi8UT 7zzj1ALqzj1DzgYwBi/Saz39vmbGGT+SaGdAeLnXdKc/5am9wRSNdqO7mbfXhILA Qkn0RYBquhkl35jZNf38vc9BYInwGnNgkOoggk68= Received: by web6.nyi.mail.srv.osa (Postfix, from userid 99) id 28141299DEB; Tue, 21 Jan 2014 17:21:38 -0500 (EST) Message-ID: <1390342898.4170.73673993.2C28BAEC@webmail.messagingengine.com> X-Sasl-Enc: iiTa9O/xsO9v9SDF0Z16H5SJXUxpWLRwEr5mtm/hVz4I 1390342898 To: Crypto Compress , PHP Developers Mailing List MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-e8d433be In-Reply-To: <52DEF226.6050500@googlemail.com> References: <1390341389.11834.90.camel@guybrush> <52DEF226.6050500@googlemail.com> Date: Tue, 21 Jan 2014 14:21:38 -0800 Subject: Re: [PHP-DEV] [RFC] __debug_info() From: willfitch@php.net (Will Fitch) On Tue, Jan 21, 2014, at 02:18 PM, Crypto Compress wrote: > Hi, > > why not use __toString? > > class File { > // "Resource(stream)" isn't all that useful > private $fp; > > // But all the stream meta data is > public function __toString() { > return $this->fp ? print_r(stream_get_meta_data($this->fp), > true) : ''; // var export, what ever you like > } > > public function open($filename, $mode = 'r'){ > $this->fp = fopen($filename, $mode); > } > } > > $f = new File; > echo $f; // object(File)#1 { } > $f->open('http://php.net'); > echo $f; > > cryptocompress Because the __toString allows a class to decide how to react when treated like a string. Sure, that could be debug info, but it could be printing a full-blow decorator implementation (e.g. Zend\Form\Form), a number, class name, etc. What Sara is proposing is specific to object debugging. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >