Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83798 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72029 invoked from network); 25 Feb 2015 15:25:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:25:07 -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 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:36726] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3C/16-62407-159EDE45 for ; Wed, 25 Feb 2015 10:25:06 -0500 Received: by lbvp9 with SMTP id p9so4577756lbv.3 for ; Wed, 25 Feb 2015 07:25:01 -0800 (PST) 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=3U/zXG4yTOwMlHik1SvwVxAhk6v5k5Grpml4GIV4ePA=; b=Pk5WjHlrqP60jIFnpghnN3qgE50NPK8vGhxt1KfFTvrpfmabnXujNaNkX4RZMscvEq T4DVuGjx5R6Gg1pB61ngWik1Yy378cnbv1gWGYdJ3uK9pES0k4nd0j0Sucob5xtgaIem 8HNX9Znhl2a+TS/NQdxO3ReA5omXotqkSO58545Wzm64JUTtI5XQpkBNz6Uy06Q53aYV gpP8uurYozjz9pnLNB6EZKVUXRYs1LCt8hQHmcbq5Z9amZGSM6cZ7tIpllDR8s6QQaA4 iYyj7VcPQQmLIrhnGS6ygMCjM0e0DQlXoweEMxjo4VlB+rXy2i4LFkcQO5l01OLdYT7a 7wiA== X-Received: by 10.112.172.131 with SMTP id bc3mr3215520lbc.79.1424877901650; Wed, 25 Feb 2015 07:25:01 -0800 (PST) Received: from nikita-hp-elitebook-750-g1 (broadband-37-110-139-150.nationalcablenetworks.ru. [37.110.139.150]) by mx.google.com with ESMTPSA id x1sm8552545lby.26.2015.02.25.07.24.59 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 07:25:00 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <7ef509ef10bb345c792f9d259c7a3fbb@mail.gmail.com> Date: Wed, 25 Feb 2015 18:23:49 +0400 Cc: "Dmitry Stogov" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <7ef509ef10bb345c792f9d259c7a3fbb@mail.gmail.com> User-Agent: Opera Mail/12.16 (Linux) Subject: Re: [PHP-DEV] Coercive Scalar Type Hints RFC From: inefedor@gmail.com ("Niktia Nefedov") On Wed, 25 Feb 2015 17:54:21 +0400, Dmitry Stogov wrote: >The object on the call-site should remain to be an object (if it's not > passed by reference), however the called function will receive a string. > It works in PHP-5 and PHP-7. Nothing should be changed. >$ sapi/cli/php -r 'class X {function __toString(){return "abc";}} $x=new > X; var_dump(strlen($x)); var_dump($x);' > int(3) > object(X)#1 (0) { > } >However, declare(strict_types=1) will break this. see > https://github.com/ircmaxell/php-src/compare/scalar_type_hints_v5#diff-ef5bf53d1412b50f85d125ca4fe84741R1182 >Thanks. Dmitry. Dmitry, I was talking about passing an object to a function, expecting a reference of a string: 'class X { function __toString() { return spl_object_hash($this); } } $x = new X; function foo(string &$x){} foo($x); var_dump($x);' Now what would this produce in Coercive STH is still an open question I guess as there is no implementation yet.