Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57284 invoked from network); 8 Jun 2011 12:11:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 12:11:59 -0000 Authentication-Results: pb1.pair.com header.from=christian.kaps@mohiva.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=christian.kaps@mohiva.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mohiva.com from 178.63.228.54 cause and error) X-PHP-List-Original-Sender: christian.kaps@mohiva.com X-Host-Fingerprint: 178.63.228.54 elvis.mohiva.com Linux 2.6 Received: from [178.63.228.54] ([178.63.228.54:52239] helo=elvis.mohiva.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/51-48516-D076FED4 for ; Wed, 08 Jun 2011 08:11:58 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by elvis.mohiva.com (Postfix) with ESMTP id 0E6301D24013 for ; Wed, 8 Jun 2011 14:11:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at mohiva.com Received: from elvis.mohiva.com ([127.0.0.1]) by localhost (elvis.mohiva.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KuptEGiExKUB for ; Wed, 8 Jun 2011 14:11:51 +0200 (CEST) Received: from elvis.mohiva.com (elvis.mohiva.com [178.63.228.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: christian.kaps@mohiva.com) by elvis.mohiva.com (Postfix) with ESMTPSA id 5995E1D24011 for ; Wed, 8 Jun 2011 14:11:51 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 08 Jun 2011 14:11:51 +0200 To: In-Reply-To: References: <67f900ce904612afdba7650ccbed6ed4@mohiva.com> Message-ID: <4ec16f049f8a5946bca7e81ecec50b45@mohiva.com> X-Sender: christian.kaps@mohiva.com User-Agent: Roundcube Webmail/0.5.2 Subject: Re: [PHP-DEV] Re: $arr =?UTF-8?Q?=3D=20array=28=27Hello=27=2C=20?= =?UTF-8?Q?=27world=27=29=3B=20=24arr=28=29=3B?= From: christian.kaps@mohiva.com (Christian Kaps) On Wed, 8 Jun 2011 08:57:48 -0300, Felipe Pena wrote: > Hi, > > 2011/6/8 Christian Kaps > >> Hi, >> >> >> what happens if I use this code. >> >> class Foo { >> >> public $bar; >> >> public function __construct() { >> >> $this->bar = array($this, 'baz'); >> $this->bar(); >> } >> >> public function bar() { >> echo 'bar'; >> } >> >> public function baz() { >> echo 'baz'; >> } >> } >> >> new Foo(); >> >> What is the output of this snippet? >> >> Are there the same rules as for closures? >> >> Christian >> >> > Yes, the same rules. Hi, I think for the sake of consistency it should be possible to use the following code. class Bar { public function __construct($dispatcher) { $dispatcher->addEventListener('onUpdate', $this->onUpdate); } public function onUpdate() {} } If a property $onUpdate exists then it will be ignored. The same rules as for Closures or for array callbacks. Christian