Re: [PHP-DEV] scalar type-casting

2017-04-09 Thread Yasuo Ohgaki
Hi Rasmus, Although DbC is not what you need, but DbC could solve your issue more efficiently. i.e. Faster execution, not shorter code. https://wiki.php.net/rfc/dbc2 With DbC, caller has responsibility to pass correct parameters. On Sun, Apr 9, 2017 at 6:30 PM, Rasmus Schultz

Re: [PHP-DEV] scalar type-casting

2017-04-09 Thread Rasmus Schultz
> If the caller sees only the signature, then the function can do *literally anything* to their passed by reference variable. The caller is giving full control and "ownership" of that variable, and shouldn't make any assumptions about what it will look like when it comes back. Understood, only

Re: [PHP-DEV] How to get technical documentation on the Zend Engine

2017-04-09 Thread Yannick Komotir
Hi Nug, That is well known as PHP *Internals*. There is various ressources that can help on that : - The Official guides : http://www.php.net/manual/en/internals2.php and https://wiki.php.net/ - PHP internal developers collaborative initiative : http://www.phpinternalsbook.com/ - Nikita Popov's

Re: [PHP-DEV] scalar type-casting

2017-04-09 Thread Rowan Collins
On 9 April 2017 10:30:02 BST, Rasmus Schultz wrote: >Example: > >class Foo { public function __toString() { return "foo"; } } >function append_to(string &$str) { $str .= "_bar"; } >$foo = new Foo(); >append_to($foo); >var_dump($foo); // string(7) "foo_bar" > >In this example,

[PHP-DEV] scalar type-casting

2017-04-09 Thread Rasmus Schultz
Since PHP 7.0, I've started using scalar type-hints a lot, and it got me thinking about scalar type-casting. After poking through existing RFC's, it turns out, I was going to propose precisely the thing that Anthony Ferrara proposed in 2012: https://wiki.php.net/rfc/object_cast_to_types In the