When I take game.php from the reversi tutorial and view it in an IDE (I'm using VS Code), I see lots of examples of the following:
$board = self::getBoard();
which get underlined as a warning with the text "Non static method 'getBoard' should not be called statically."
It is only a warning, the code all still works. If I change the code to
$board = $this->getBoard();
the warning goes away, presumably as I am now no longer calling it statically.
Would you regard this as poor code?
If so, what would you generally do instead (static method? call as "$this->xxx")?
If I changed all of the references from self:: to $this, would it make any difference/would anything break for this game on bga?
I'm coming from a Java background, where I'm used to this sort of thing being impossible/a compiler error. I'm new to php, and trying to establish some sort of an idea as to the php coding standards/conventions.
$board = self::getBoard();
which get underlined as a warning with the text "Non static method 'getBoard' should not be called statically."
It is only a warning, the code all still works. If I change the code to
$board = $this->getBoard();
the warning goes away, presumably as I am now no longer calling it statically.
Would you regard this as poor code?
If so, what would you generally do instead (static method? call as "$this->xxx")?
If I changed all of the references from self:: to $this, would it make any difference/would anything break for this game on bga?
I'm coming from a Java background, where I'm used to this sort of thing being impossible/a compiler error. I'm new to php, and trying to establish some sort of an idea as to the php coding standards/conventions.