Hi

2015-03-09 15:11 GMT+01:00 Shawn McCool <sh...@heybigname.com>:
> I guess that if I thought that PHP would change its scoping, I would have
> tried for that.

Well take this code into consideration:
<?php
 class A {
   protected $b;

   function c($b) {
    $b = $b; // does not work
   }

   function d($d) {
    $b = $d; // works
   }
}
?>

A::c() will fail because the parameter $b conflicts with the property
A::$b, but example works because the parameter is now named $d, and
therefore making $b available for assignment (should probably
internally be implemented as a reference to $this->b), but only on
demand (JIT) to avoid extra memory consumption.

This approach may seem quirky at first, but it doesn't add any new
syntax but some magic behind the scenes. Although I personally am not
a huge fan of magic variables like that, it is possible.



-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to