List Info

Thread: Re: Comment on Web Services::Services_TinyURL




Re: Comment on Web Services::Services_TinyURL
user name
2007-09-11 11:32:40
Hi

On Tue, 11 Sep 2007 09:17:56 -0700, Joe Stump <joejoestump.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>> No notice, no E_STRICT. Seems to be fine. Hence,
Travis can extend the
>> class for unittests without making the code any
more complicated. 
>
> Since when does PHP5 allow you to call static methods
non-statically
> without throwing a notice? This is news to me.

It seems that a static function is always called static,
even with $test->staticMethod()...

Simple Test:
<?php
class Test
{
    public static function testMethod() {
        var_dump($this);
    }
}

$test = new Test();
$test->testMethod();

Test::testMethod();


outputs twice(!) a notice about the undefined variable $this
and null.

Sascha

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


Re: Comment on Web Services::Services_TinyURL
user name
2007-09-11 11:36:31
On 9/11/07, Sascha Grossenbacher <saschagrosbluewin.ch> wrote:
> Hi
>
> On Tue, 11 Sep 2007 09:17:56 -0700, Joe Stump
<joejoestump.net> wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> >> No notice, no E_STRICT. Seems to be fine.
Hence, Travis can extend the
> >> class for unittests without making the code
any more complicated. 
> >
> > Since when does PHP5 allow you to call static
methods non-statically
> > without throwing a notice? This is news to me.
>
> It seems that a static function is always called
static, even with $test->staticMethod()...
>
> Simple Test:
> <?php
> class Test
> {
>     public static function testMethod() {
>         var_dump($this);
>     }
> }
>
> $test = new Test();
> $test->testMethod();
>
> Test::testMethod();
>
>
> outputs twice(!) a notice about the undefined variable
$this and null.

Interesting, and good to know. Didn't think of that.

Travis: Would this still work for you though? 

Till

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )