Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75147 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27889 invoked from network); 30 Jun 2014 16:43:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jun 2014 16:43:03 -0000 Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:51640] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/71-19922-59391B35 for ; Mon, 30 Jun 2014 12:43:02 -0400 Received: by mail-wg0-f44.google.com with SMTP id x13so8391043wgg.15 for ; Mon, 30 Jun 2014 09:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:cc:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=kIQYtAUwtlNMRfsd3ZywD1FfO0T5JWzgbYsX3chSLuQ=; b=cwApjJeJvm2UbFDEja+wSN5s5qHSitfbXWEz+EIwa64YtBf5y13dZqNTDwm+lyt+Dq XUGWVZ/esGgkBj6nfrYzY0seNjqy5Bop01sEBJt0Rfh0w7hT+u6C+z36NcZdOKUkHOVG NX9nCXlnFqX6+CaN3Fj1C9qrdTEgpGbYYu00Sos2npXYkv5GegjN1md890gKlWmV4aHk QDOQw7fTtFWLJyjcY03tBQvmg5hdZCdi5I+ltjUldD9Y3cVevSDJQ7avQh0u3UgYKLCn S+hwyisD1B0xM51XkK8F+E1CM6vW5uGupwqV9NnrpyTtr2khmvFX0oOwmOM0CUaoHklx lTTg== X-Received: by 10.180.24.66 with SMTP id s2mr29906009wif.33.1404146578111; Mon, 30 Jun 2014 09:42:58 -0700 (PDT) Received: from nikita-pc ([91.75.241.118]) by mx.google.com with ESMTPSA id lk7sm42360582wjb.24.2014.06.30.09.42.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 30 Jun 2014 09:42:57 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: internals@lists.php.net References: <53A1C722.9060501@fedoraproject.org> <53A21137.6010705@sugarcrm.com> <53A2A9BD.1070603@sugarcrm.com> <53A3874E.20704@sugarcrm.com> <53A62AFF.4080302@sugarcrm.com> <53B10D59.4060206@sugarcrm.com> Date: Mon, 30 Jun 2014 20:42:57 +0400 Cc: "Ferenc Kovacs" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/12.17 (Win32) Subject: Re: [PHP-DEV] Re: Problems with the fix for the BC break introduced in 5.4.29 and 5.5.13 From: inefedor@gmail.com ("Nikita Nefedov") On Mon, 30 Jun 2014 20:10:52 +0400, Ferenc Kovacs wrote: >> >> Perhaps anonymous classes ? >> > > yeah, that is one of the proposed solution. I can't really understand how would they help with the internal classes? Would they call constructor or not? If not - the problem is still there isn't it? >> That way you'd be able to create an object using "new" , and redefine >> the methods you want to make them return what you want. am I wrong ? >> >> > but this will still produce incomplete/unstable objects which are exposed > to the dos/security problems. > so I think that supporting the creation of mocks/doubles natively(through > Reflection) Natively. But again, how can we do this generically? I mean not touching definition of the classes itself. You will still need to instantiate an object with the internal class entry, or am I wrong here? If it comes only to the problem of mocking the solution could also be to allow usage of classes as an interfaces. So for example if we will be able to write something like this: class MockedSplFileInfo implements \SplFileInfo { public function getBaseName(){ /* some mocking logic */ } ... and so on ... } I don't see any way to keep the ability to instantiate internal class without constructor *and* to guarantee its stability at the same time. The only way is to not instantiate it. (assuming we don't ask classes to make init checks on every possible call)