Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94968 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97730 invoked from network); 9 Aug 2016 14:20:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Aug 2016 14:20:01 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:37220] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/33-03404-096E9A75 for ; Tue, 09 Aug 2016 10:20:00 -0400 Received: by mail-wm0-f54.google.com with SMTP id i5so38688148wmg.0 for ; Tue, 09 Aug 2016 07:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=MsVNSmT5tcsblygMR6n0T6GksLBAatwHvffBqIL5PxU=; b=rYLATL4Yiho26S1pVNTWTxTrXVbupeVvmn+LcTYphkIe7fWy0Hlmb0Qpzv57pxiYTX 5TEAmgbe+WTTzYgoTmXxEDtjy18DK2ylUcDucfjiP+PhmOvnMhAnuBFKxJbgzEzGBTmd 0LeDWMyzBA8Z0pTqL6HX1TdYWo716xzY3F+fGp62SzjfORHtLkOquyeQEBUC92lfwg+b tQWucIBuCIA4rSy1G0TTvb8AuXiTRAqrDNsNxHN66UH4N86FuMHPLT3l6xhorxkZLsJD Vm6kOjgVzVChAH79j9Ak2Yvjg+ZzKv/w7tEnYVjRDhA9+E5GSPMq6GO3kahXLM1guPS0 oD+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=MsVNSmT5tcsblygMR6n0T6GksLBAatwHvffBqIL5PxU=; b=Uo/Xc1W/OruKZ1vvSvpNBiNM9Ccwb+LQlaBZftaOsPxh4nwtZays7WKCb9JNq+U1cx II6Dz3eSlaWEwK8xZgpJPzjzUmJYOatFpVk57LOer2kCdiv9f4Q5UKeXzR0Ldw2YGvVb tBNZLWhq9fVfPQjdkSpSnzhAW9nvgmZ/oVz3t/0zLfpVKN4RgdEbywkbdt+P6LE0A6ck oOmh/QejGw2aDWWgW/MAPx83ixvzmefybbbc9ZPBxeDZWnu/A+TBXgp7rhyVswox7VqZ 8xXLneNj3NPRe4g4XiizDzN36Z2+5gS2yhbRk4VkCme+plXthzs0Ql09jqhlLwBgeP2k Ionw== X-Gm-Message-State: AEkoouuWP07EolRv3j6fRsjf506SnYyENGwA1MafL5Alry6PRD+bdiOyw6INrNCvJxEGqQ== X-Received: by 10.194.242.71 with SMTP id wo7mr87105708wjc.179.1470752397427; Tue, 09 Aug 2016 07:19:57 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id gg10sm38239573wjd.4.2016.08.09.07.19.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Aug 2016 07:19:56 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <172b4c6c-695d-a2ca-e2fe-19ac6fde0f18@gmail.com> Date: Tue, 9 Aug 2016 15:17:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Treats raw types if used as object From: rowan.collins@gmail.com (Rowan Collins) On 09/08/2016 14:49, David Rodrigues wrote: > In this case, I suggests to have some handler to treat raw types as > objects in an indirect way. Objects are not created, but it methods > are called on demand statically. > > For instance: > > // It should be declared by PHP internally (default handler). > register_type_handler('string', \SplString::class); > > // It is an user defined handler, should extends SplInteger. > register_type_handler('int', \Types\MyInt::class); Hi David, You and your friend are not alone in thinking this would be a nice feature to have, and the good news is that a few people have already worked on proof-of-concept implementations. Most notably, there's https://github.com/nikic/scalar_objects which has a "register_primitive_type_handler" function almost identical to your example. A few people have taken that and played around with what a good set of methods to implement would be, e.g. https://github.com/rossriley/php-scalar-objects and https://github.com/RikudouSage/scalar-objects Right now, there's no concrete plan for if/how/when this might end up a proper part of the language, though. It might be a good idea to search one of the archives of this list to see where previous discussions ended up. Regards, -- Rowan Collins [IMSoP]