Re: [PHP] context when calling non static method of class in a static way

2011-05-23 Thread Simon Hilz
ah i forgot e_all doesnt include e_strict. with error_reporting(-1 / E_ALL | E_STRICT) i see the errors. so i think i am right that the use of that special behavior of php is not a good idea. thank you guys! Am 23.05.2011 00:32, schrieb Richard Quadling: On 22 May 2011 22:44, Simon Hilz wrote

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Richard Quadling
On 22 May 2011 22:44, Simon Hilz wrote: > i cant reproduce that error. which php version do you use? > i've coded an example for a "behavior"-pattern: > Try with ... call TankUpBehavior::tankUp (100) Strict Standards: Non-static method TankUpBehavior::tankUp() should not be called statically, as

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Simon Hilz
i cant reproduce that error. which php version do you use? i've coded an example for a "behavior"-pattern: = error_reporting(E_ALL & E_STRICT); class Car { private $fuel = 0; private $drivenDistance = 0; private $consumption =

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Peter Lind
class A { public function b() { echo get_class($this); } static function c() { echo get_class($this); } } class B { public function test(){ A::b(); A::c(); } } $b = new B; $b->test(); Generates: Strict Standards: Non-static method A::b() sho

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Simon Hilz
ourse I can call a method from it. Sorry Richard L. Buskirk -Original Message- From: Simon Hilz [mailto:simon.h...@gmx.de] Sent: Sunday, May 22, 2011 11:56 AM To: php-general@lists.php.net Subject: Re: [PHP] context when calling non static method of class in a static way Richard, yes!

RE: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread admin
] Sent: Sunday, May 22, 2011 11:56 AM To: php-general@lists.php.net Subject: Re: [PHP] context when calling non static method of class in a static way Richard, yes! at least my example works. i didn't test it any further; i doubt it is intended that way. Simon Hilz Am 22.05.2011 16:42, schri

RE: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread admin
. Buskirk -Original Message- From: Simon Hilz [mailto:simon.h...@gmx.de] Sent: Sunday, May 22, 2011 11:56 AM To: php-general@lists.php.net Subject: Re: [PHP] context when calling non static method of class in a static way Richard, yes! at least my example works. i didn't test it any fu

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Simon Hilz
Mike, yes i know the difference. I actually discovered that by accident when i've forgot to write the static keyword. my code lead to an exception. i wondered about the details of that exception and came to the solution that the behavior as decribed exists. in my opinion one could really use

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Simon Hilz
ssage- From: Simon Hilz [mailto:simon.h...@gmx.de] Sent: Sunday, May 22, 2011 10:18 AM To: php-general@lists.php.net Subject: [PHP] context when calling non static method of class in a static way hi, lets assume the following classes: class Foo{ public function bar() {

RE: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread admin
Simon, So without extending foo you can run bar in another class? Richard L. Buskirk -Original Message- From: Simon Hilz [mailto:simon.h...@gmx.de] Sent: Sunday, May 22, 2011 10:18 AM To: php-general@lists.php.net Subject: [PHP] context when calling non static method of class

Re: [PHP] context when calling non static method of class in a static way

2011-05-22 Thread Mike Mackintosh
Simon, You may want to be careful with the way you declare your class methods. Example: public function bar() != static function bar(), even if you use pnysudsfksdljfasdjfsd (::) See the example below. class Foo{ static function barStatic() { echo get_class($this); }

[PHP] context when calling non static method of class in a static way

2011-05-22 Thread Simon Hilz
hi, lets assume the following classes: class Foo{ public function bar() { echo get_class($this); } } class Foobar{ public function callBarStatic() { Foo::bar(); } } the following code results in the output "Foobar": $obj = new Foobar(); $obj