Define constants in those methods where you use, not globally
Author: abelardolgCreated Nov 6, 2022Updated Nov 6, 2022
// Bad
class MyClass { private const MY_CONSTANT = 5;
// public function myFunction(): void {
$myVar = self::MY_CONSTANT;
}
// Good idea? Let's check it out!
class MyClass {
public function myFunction(): void { $MY_CONSTANT = 5; $myVar = $MY_CONSTANT;
}
Source: piotrplenik/clean-code-php