In a recent RFC that's been proposed and is now up for voting, the suggestion has been made to drop the var
keyword in PHP 7.1 and completely remove it in PHP 8 (made a bit redundant buy the public
keyword in classes). Evert Pot, however, disagrees and suggests dropping public instead.
A PHP RFC vote has started to deprecate the var keyword in PHP 7.1 and remove it in PHP 8. At the time of writing, there 23 who say it should be removed, and 18 who say it should not. [...] I’d like to offer a different opinion: I think people should be using var instead of public. I realize that this is as controversial as tabs vs. spaces (as in: it doesn’t really matter but conjures heated discussions), but hear me out!
He goes through an example on one of his own projects, showing how he's mostly removed the public
level of exposure from his development (using final and statics instead). He then suggests three common thoughts he sees people having being in favor of dropping var
versus public
:
- #1: Everyone doing the same thing is good
- #2: It’s ugly!
- #3: The public keyword is useful to convey intent
He also points to one place where he does see the need for a public
but also suggests that in that case var
would do juts fine too.