Files that define symbols such as classes and variables may be included into many files. Simply performing that inclusion should have no effect on
those files other than declaring new symbols. For instance, a file containing a class definition should not also contain side-effects such as
print
statements that will be evaluated automatically on inclusion. Logic should be segregated into symbol-only files and
side-effect-only files. The type of operation which is not allowed in a symbol-definition file includes but is not limited to:
- generating output
- modifying
ini
settings
- emitting errors or exceptions
- modifying global or static variables
- reading/writing files
Noncompliant code example
<?php
print "Include worked!";
class foo {
// ...
}
Compliant solution
<?php
class foo {
public function log() {
print "Include worked!";
}
}