Shijiang | 3 Aug 2010 13:09
Picon

[PHP-DEV] Confusing performance of the magic method __call

Hi,

In the following sample code, I expected that the magic method __call only works within the class Test.
But it seems that the access control keyword private lost its efficacy when working together with the magic
method __call.

<?php
class Test{
    private function __call($name,$params){   
        echo $name,"\n";
        echo $params[0];
    }   

    public function bar(){   
        $this->kakaka('afaafaf');
    }   
}
$foo=new Test;
$foo->bar('sfsfss');
$foo->nothing('works'); // this also works without any errors.
?>

IMHO, since the function __call is a method of a class, it should obey the visibility rules.

Cheers.
Ferenc Kovacs | 3 Aug 2010 13:14
Picon
Gravatar

Re: [PHP-DEV] Confusing performance of the magic method __call

2010/8/3 Shijiang <shijiang <at> staff.sina.com.cn>:
> Hi,
>
> In the following sample code, I expected that the magic method __call only works within the class Test.
> But it seems that the access control keyword private lost its efficacy when working together with the
magic method __call.
>
> <?php
> class Test{
>    private function __call($name,$params){
>        echo $name,"\n";
>        echo $params[0];
>    }
>
>    public function bar(){
>        $this->kakaka('afaafaf');
>    }
> }
> $foo=new Test;
> $foo->bar('sfsfss');
> $foo->nothing('works'); // this also works without any errors.
> ?>
>
> IMHO, since the function __call is a method of a class, it should obey the visibility rules.
>
> Cheers.
>

http://www.php.net/manual/en/migration53.incompatible.php

(Continue reading)

Victor Bolshov | 3 Aug 2010 13:15
Picon

Re: [PHP-DEV] Confusing performance of the magic method __call

Shijiang, did you notice the

--
Warning: The magic method __call() must have public visibility and cannot be
static in Command line code on line 1
--

???

2010/8/3 Shijiang <shijiang <at> staff.sina.com.cn>

> Hi,
>
> In the following sample code, I expected that the magic method __call only
> works within the class Test.
> But it seems that the access control keyword private lost its efficacy when
> working together with the magic method __call.
>
> <?php
> class Test{
>    private function __call($name,$params){
>        echo $name,"\n";
>        echo $params[0];
>    }
>
>    public function bar(){
>        $this->kakaka('afaafaf');
>    }
> }
> $foo=new Test;
(Continue reading)

Ferenc Kovacs | 3 Aug 2010 13:23
Picon
Gravatar

Re: [PHP-DEV] Confusing performance of the magic method __call

2010/8/3 Victor Bolshov <crocodile2u <at> gmail.com>:
> Shijiang, did you notice the
>
> --
> Warning: The magic method __call() must have public visibility and cannot be
> static in Command line code on line 1
> --
>
> ???
>
> 2010/8/3 Shijiang <shijiang <at> staff.sina.com.cn>
>
>> Hi,
>>
>> In the following sample code, I expected that the magic method __call only
>> works within the class Test.
>> But it seems that the access control keyword private lost its efficacy when
>> working together with the magic method __call.
>>
>> <?php
>> class Test{
>>    private function __call($name,$params){
>>        echo $name,"\n";
>>        echo $params[0];
>>    }
>>
>>    public function bar(){
>>        $this->kakaka('afaafaf');
>>    }
>> }
(Continue reading)

Victor Bolshov | 3 Aug 2010 13:54
Picon

Re: [PHP-DEV] Confusing performance of the magic method __call

Yes, sorry. I've been working with 5.3 for pretty long time so I found the
original letter a bit strange.

2010/8/3 Ferenc Kovacs <info <at> tyrael.hu>

> 2010/8/3 Victor Bolshov <crocodile2u <at> gmail.com>:
> > Shijiang, did you notice the
> >
> > --
> > Warning: The magic method __call() must have public visibility and cannot
> be
> > static in Command line code on line 1
> > --
> >
> > ???
> >
> > 2010/8/3 Shijiang <shijiang <at> staff.sina.com.cn>
> >
> >> Hi,
> >>
> >> In the following sample code, I expected that the magic method __call
> only
> >> works within the class Test.
> >> But it seems that the access control keyword private lost its efficacy
> when
> >> working together with the magic method __call.
> >>
> >> <?php
> >> class Test{
> >>    private function __call($name,$params){
(Continue reading)

高春辉 | 3 Aug 2010 14:11
Picon

[PHP-DEV] 答复: [PHP-DEV] full LFS support

nobody to care this change? :(

-----邮件原件-----
发件人: tyra3l <at> gmail.com [mailto:tyra3l <at> gmail.com] 代表 Ferenc Kovacs
发送时间: 2010年7月30日 22:14
收件人: PHP Internals
主题: [PHP-DEV] full LFS support

Hi.

I would like to know what is the current status of the LFS support for php.

http://bugs.php.net/bug.php?id=27792
http://bugs.php.net/bug.php?id=48886

As far as I can see, there are some patches floating around, but some of them doesn't work, some of them are incomplete.

As far as I can see, with the latest release(5.3.3) you can't stat or filesize a file where the size is >= 2GiB
on 32bit OS, and >= 4GiB on 64bit.
Is this true?
From the proposed patches, it seems that there arent that many LOC which needs to be adjusted to provide a
decent LFS support.
Are there any blocker objections or architectural problems, or we just lack specification or manpower to
fix this issue?
If this gets fixed, will this be included into the 5.3 branch, or this can only be added with the next major version?

Tyrael

--

-- 
PHP Internals - PHP Runtime Development Mailing List
(Continue reading)

Ferenc Kovacs | 3 Aug 2010 15:01
Picon
Gravatar

Re: [PHP-DEV] 答复: [PHP-DEV] full LFS support

Maybe this is just lost in the weekend's email swarm.
At least I hope this is the reason for the silence.

Tyrael

On Tue, Aug 3, 2010 at 2:11 PM, 高春辉 <gaochunhui <at> gmail.com> wrote:
> nobody to care this change? :(
>
> -----邮件原件-----
> 发件人: tyra3l <at> gmail.com [mailto:tyra3l <at> gmail.com] 代表 Ferenc Kovacs
> 发送时间: 2010年7月30日 22:14
> 收件人: PHP Internals
> 主题: [PHP-DEV] full LFS support
>
> Hi.
>
> I would like to know what is the current status of the LFS support for php.
>
> http://bugs.php.net/bug.php?id=27792
> http://bugs.php.net/bug.php?id=48886
>
> As far as I can see, there are some patches floating around, but some of them doesn't work, some of them are incomplete.
>
> As far as I can see, with the latest release(5.3.3) you can't stat or filesize a file where the size is >= 2GiB
on 32bit OS, and >= 4GiB on 64bit.
> Is this true?
> From the proposed patches, it seems that there arent that many LOC which needs to be adjusted to provide a
decent LFS support.
> Are there any blocker objections or architectural problems, or we just lack specification or manpower to
fix this issue?
(Continue reading)

Gustavo Lopes | 3 Aug 2010 20:12
Picon
Favicon
Gravatar

[PHP-DEV] Closures, rebinding and scopes

Hi

Even though one cannot bind a static closure to an instance, one can  
rebind its scope with the Closure::bind/Closure::bindTo:

class foo {
	static protected $field = "foo_field";
	static function getClosure() {
		return static function () {
			//causes a crash (fbc already freed) in call after rebinding,
			//so let's not use it
			//echo get_called_class(), "\n";
			echo static::$field, "\n";
		};
	}
}

class subFoo {
	static protected $field = "subfoo_field";
}

$c = foo::getClosure();
$c(); //foo_field
$c = $c->bindTo(new subFoo());
$c(); //subfoo_field

It doesn't make sense to require an instance in order to change the scope  
of a static closure, so perhaps better options would be:

1. Change Closure::bind/Closure::bindTo so that they accept a class name  
(Continue reading)

Shijiang | 4 Aug 2010 04:21
Picon

Re: [PHP-DEV] Confusing performance of the magic method __call

I was working with PHP 5.2.9 with error_report=E_ALL and display_errors=On and got no error at all.

Just now I tried it under PHP 5.3.0 and got the warning.

Sometimes although I declared the magic method __call(), I want to prevent it from being called outside the
class. 
Could someone be kindly enough to tell me why it must be  public?

Thanks.
  ----- Original Message ----- 
  From: Victor Bolshov 
  To: Shijiang 
  Cc: PHP internals 
  Sent: Tuesday, August 03, 2010 7:15 PM
  Subject: Re: [PHP-DEV] Confusing performance of the magic method __call


  Shijiang, did you notice the


  --
  Warning: The magic method __call() must have public visibility and cannot be static in Command line code on
line 1
  --


  ???


  2010/8/3 Shijiang <shijiang <at> staff.sina.com.cn>
(Continue reading)

Guillaume Rossolini | 4 Aug 2010 04:50
Picon

Re: [PHP-DEV] Confusing performance of the magic method __call

2010/8/4 Shijiang <shijiang <at> staff.sina.com.cn>

> I was working with PHP 5.2.9 with error_report=E_ALL and display_errors=On
> and got no error at all.
>
> Just now I tried it under PHP 5.3.0 and got the warning.
>
> Sometimes although I declared the magic method __call(), I want to prevent
> it from being called outside the class.
> Could someone be kindly enough to tell me why it must be  public?
>
> Thanks.
>
>
Hi,

To get the error messages mentioned above, you might want to try the
following error reporting level: E_ALL | E_STRICT
Please refer to the manual to understand why E_ALL does not actually mean
all error levels:
http://www.php.net/manual/en/function.error-reporting.php (below "Notes")

Also, your php.ini file for PHP 5.3 has details explaining why this version
includes E_STRICT (I am guessing you chose the "development" version).

As for your other question regarding why the magic method visibility works
as it does, the answer has been given in the following bug reports:
http://bugs.php.net/bug.php?id=40056
http://bugs.php.net/bug.php?id=44769

(Continue reading)


Gmane