Re: About the magic function __call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My information was incomplete: I'm running php 5.1.2 (a requirement from the
customer).
I found this http://bugs.php.net/bug.php?id=42937

I "coded" this without testing, using only the idea. Thanks!

Thanks for the help Nathan!


2008/8/27 Nathan Nobbe <quickshiftin@xxxxxxxxx>

> On Wed, Aug 27, 2008 at 1:49 PM, Nathan Nobbe <quickshiftin@xxxxxxxxx>wrote:
>
>> On Wed, Aug 27, 2008 at 1:35 PM, Paulo Sousa <paulo.sousa.filho@xxxxxxxxx
>> > wrote:
>>  ...
>>
>
> this *should* work,
>
> here is a test, tests/classes/__call_005.phpt, you can take the part
> beneath the --FILE-- section and see if it blows up on your system or not.
> right now, im getting errors on a php5.2.5 system, and its working as
> expected on a php5.2.6 system.
>
> --TEST--
> When __call() is invoked via ::, ensure private implementation of __call()
> in superclass is accessed without error.
> --FILE--
> <?php
> class A {
>     private function __call($strMethod, $arrArgs) {
>         echo "In " . __METHOD__ . "($strMethod, array(" .
> implode(',',$arrArgs) . "))\n";
>         var_dump($this);
>     }
> }
>
> class B extends A {
>     function test() {
>         A::test1(1,'a');
>         B::test2(1,'a');
>         self::test3(1,'a');
>         parent::test4(1,'a');
>     }
> }
>
> $b = new B();
> $b->test();
> ?>
> --EXPECTF--
> In A::__call(test1, array(1,a))
> object(B)#1 (0) {
> }
> In A::__call(test2, array(1,a))
> object(B)#1 (0) {
> }
> In A::__call(test3, array(1,a))
> object(B)#1 (0) {
> }
> In A::__call(test4, array(1,a))
> object(B)#1 (0) {
> }
>
> also, i found in the code you posted, you are missing a 'function' in front
> of doWhatever (cause a parse error, which is why i mention it); w/ the
> following modification to your code, its running fine on a php 5.2.6 system,
> and choking on 5.2.5;
>
>       function __call($function, $args){
>                 var_dump($function);
>                 var_dump($args);
>                   $this->doWhatever();
>                   }
>
>                    private function doWhatever() {
>                     }
>
> nathan@devel ~/unpack/php-5.2.6RC3/tests/classes $ php testOtherStuff.php
> string(5) "drive"
> array(1) {
>   [0]=>
>   string(7) "testing"
> }
>
> -nathan
>
> (sorry for the long-winded post)
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux