I've the following code:
class A {
public function methodB()
{
// do something
return 1;
}
}
$a = A::methodB();
It should never work and it works on that machine! It does return 1. Really, I swear I'm not drunk.
Of course if I run it on my machine or on production server it won't work. Because you can't call non-static methods like static. Class should always be instantiated at first.
I was worried about it. Thought today when I set up a separate working machine for testing the project I got again the environment there this code works.
Things get worse - I have developers in team who still doesn't get clearly the diference between Static and Non-static methods. As result they have code what works fine on their machine but it fails on any others environments.
WHY is it working? I want such code to fail. It shouldn't work.
The configuration of machine where it works is following:
vagrant@vagrant-ubuntu-trusty-32:/var/www/apotheke$ php -v PHP 5.6.17-3+deb.sury.org~trusty+1 (cli) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
Really, I feel so stupid. Do I miss something?