DevinVinson / WordPress-Plugin-Boilerplate

[WordPress] A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.
http://wppb.io
7.62k stars 2.25k forks source link

Public, protected, private sequence #563

Open smileBeda opened 3 years ago

smileBeda commented 3 years ago

As far I see, most of the commonly accepted order of public, protected, private in PHP is:

public $public = 'Public';
protected $protected = 'Protected';
private $private = 'Private';

Or

public function MyPublic() { }
protected function MyProtected() { }
private function MyPrivate() { }

(see also https://www.php.net/manual/en/language.oop5.visibility.php)

However WPPB does this exactly the other way around. Let's look at https://github.com/DevinVinson/WordPress-Plugin-Boilerplate/blob/master/plugin-name/includes/class-plugin-name.php for example. It first declares public constructor, then it declares private and protected methods, then the public ones.

Why this discrepancy from mainstream?