ID:               40886
 User updated by:  andrea at 3site dot it
 Reported By:      andrea at 3site dot it
 Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Windows XP SP2
 PHP Version:      5.2.1
 New Comment:

That's what I think about this feature.
http://webreflection.blogspot.com/2007/03/php-5-developers-teach-us-what-does.html

If a method is static, it should be static ... with PHP 5 a static
method become an instance method (not static) ... what a feature!

The solution is to remove static keyword from my static methods, well
done!

I hope PHP 6 will not have this ambiguity, regards.


Previous Comments:
------------------------------------------------------------------------

[2007-03-22 14:51:05] [EMAIL PROTECTED]

this bug really shows how one person's bug is another person's 
feature. :)

the syntax $a->method() allows you to call a static method of the 
class that $a is an instantiated object of, something I find useful 
for objects that contain static methods in a parent/child 
inheritance hierarchy.  Using $a->method(), I don't need to do 
hackery to figure out which class "$a" is in order to call one of 
its static methods.  Consider the alternative:

<?php
call_user_func_array(get_class($a), 'method', $args);
?>

The above is the only alternative (save using reflection, which is 
even more verbose and inefficient) to:

<?php
$a->method($arg1, $arg1);
?>

Which syntax do you prefer?

The big difference between php 4 and php 5 is that a method declared 
as "static" does not have $this set.  You'll get a fatal error, in 
fact, if you try to use $this in a static method.

Why do you care so much about whether it's called with 
class::method() or $this->method()?  You can't have two methods with 
the same name, one static and one non-static, so there is no 
possibility of accidentally calling the wrong one.

If you are wanting absolutely "perfect" OO, there are plenty of 
other languages that will provide exactly the straightjacket and 
punishment you desire.  If you want to code efficient, easy to 
maintain, working programs, use PHP.

------------------------------------------------------------------------

[2007-03-22 12:28:44] andrea at 3site dot it

Derick, this is a bug (any Object Oriented logic).
There's something wrong in your static keyword implementation, at least
for methods that uses static keyword.

This my last call and this is my last example:

<?php
class ExampleClass {

        public  $StaticExample;

        public final function __construct(){
                // bye bye public *parameter*
                $this->StaticExample = create_function('$never', 'return 
"welcome
PHP5 ambiguity";');
        }
        
        public final static function StaticExample(){
                echo "StaticExample", "<br />";
        }
}

$test = new ExampleClass();
ExampleClass::StaticExample();
exit($test->StaticExample());
?>

What does static keyword mean for PHP 5 developers?
If this is an expected behaviour you should explain them in
documentation page.

Regards (I'll never open again this *bug*)

------------------------------------------------------------------------

[2007-03-22 12:18:16] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php



------------------------------------------------------------------------

[2007-03-22 12:15:28] [EMAIL PROTECTED]

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


------------------------------------------------------------------------

[2007-03-22 11:29:22] daniele_dll at yahoo dot it

Hi,

i was talking with andrea yesterday evening and he was explaining me
that stuff.

I don't know if it is an expected behaviour or not, but i'm sure that
somewhere there is a problem!

Infact, if it is an expected behaviour the static keyword loss it
meanings and, probably, slowdown the php page compilation/execution, but
if it is normal documentation should be fixed because it says a totally
different stuff.

However, to get back to the problem, the manual says, as should be:
"A member declared as static can not be accessed with an instantiated
class object"

Because is a non sense say that something is static and after let to
the code to call it as non static

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40886

-- 
Edit this bug report at http://bugs.php.net/?id=40886&edit=1

Reply via email to