Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75132 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27947 invoked from network); 29 Jun 2014 14:03:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2014 14:03:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.41 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.41 mail-qa0-f41.google.com Received: from [209.85.216.41] ([209.85.216.41:46331] helo=mail-qa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/63-27136-1BC10B35 for ; Sun, 29 Jun 2014 10:03:30 -0400 Received: by mail-qa0-f41.google.com with SMTP id cm18so5604054qab.28 for ; Sun, 29 Jun 2014 07:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Fcc66tFarz//qrQvnoGghr1y36pm3SpZuUsfdeEzwho=; b=ssyN1vCSRHdlPKqRBBvI6a5QQNX9rqVfnRstSTJVdNvvttOCWr859jx/Gjrv6gSrIw Fx/qx/7NWyMP6HDWrX4vdk3/HOUmKsMdTQkic4c+kSbUi4xw/8WQNXuQkAkZykmz/H5u ZKdUO3ItEesU2YwF77Hej9vgGX57tfHgoFQ4CZeGnSIGw3QXzsKdxlJVgtrDuMEFnqpO A6Cjfe6Mekh4S+h/wUrQboR/LFLLhSaDe6WyESv21Mbefosy9dYcCvfsxn65U92qUFFp HjiRGlqBxT2PEwCgtEb9acjngVoD2TDH3lfRY121sk77Zcc1EbXWcq9CR4JK25tIG3QR HlPA== X-Received: by 10.140.107.132 with SMTP id h4mr23403415qgf.83.1404050607289; Sun, 29 Jun 2014 07:03:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.51.161 with HTTP; Sun, 29 Jun 2014 07:03:07 -0700 (PDT) In-Reply-To: <53A62AFF.4080302@sugarcrm.com> References: <53A1C722.9060501@fedoraproject.org> <53A21137.6010705@sugarcrm.com> <53A2A9BD.1070603@sugarcrm.com> <53A3874E.20704@sugarcrm.com> <53A62AFF.4080302@sugarcrm.com> Date: Sun, 29 Jun 2014 16:03:07 +0200 Message-ID: To: Stas Malyshev Cc: Ferenc Kovacs , Sebastian Bergmann , Julien Pauli , Remi Collet , PHP Internals Content-Type: multipart/alternative; boundary=001a113a7996b1bea804fcfa010f Subject: Re: [PHP-DEV] Re: Problems with the fix for the BC break introduced in 5.4.29 and 5.5.13 From: ocramius@gmail.com (Marco Pivetta) --001a113a7996b1bea804fcfa010f Content-Type: text/plain; charset=UTF-8 Just a follow-up on this: it looks like the most common use-cases affected by the breakage are about classes extending `ArrayObject`, which is reasonable. Creating a new instance without invoking their constructor is now not possible in 5.4.30, 5.5.14 and 5.6.0-rc.1 because of the "invalid serialization format" error. The only workaround I found is creating a new class at runtime, overriding the constructor and instantiating it, which has the horrible side-effect of `get_class()` obviously returning something different from expectations, and is going to break other things in codebases that highly rely on reflection. Can anybody suggest a workaround for this problem? Should `ReflectionClass#newInstanceWithoutConstructor()` be enabled for those classes? If so, in 5.4/5.5? Is this just a dead end and are we supposed to just disallow mocking on those particular classes? My other solution would be to build a map (case-by-case) of internal PHP classes and custom ways of instantiating/serializing them. Something like following example, which is horror: http://3v4l.org/oSPvF An additional problem is when a userland class extends an internal class AND implements the `Serializable` interface on its own. In such cases, knowing the serialization format is impossible for us, and `ReflectionClass#newInstanceWithoutConstructor()` still cannot be used. Any direction here would be useful. I'm considering going down the "exception thrown" way, as suggested by Ferenc, but for 50600 it would be neat to just have `ReflectionClass` doing the trick. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a113a7996b1bea804fcfa010f--