It is generally recommended to explicitly declare the visibility for methods.
Adding explicit visibility (private, protected, or public) is generally
recommend to communicate to other developers how, and from where this method
is intended to be used.
Loading history...
14
$fields = parent::getCMSFields();
15
16
$fields->addFieldToTab( 'Root.Content.Image', new ImageField( 'MainImage' ) );
PSR1 recommends that each class should be in its own file to aid autoloaders.
Having each class in a dedicated file usually plays nice with PSR autoloaders
and is therefore a well established practice. If you use other autoloaders, you
might not want to follow this rule.
It is not recommended to use PHP's closing tag ?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended
as you might accidentally add whitespace after the closing tag which would then
be output by PHP. This can cause severe problems, for example headers cannot be
sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and
it also has no negative effects whatsoever.
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.