I have discovered a weird problem in my code regarding class constants. While it seems that the code does work correctly, I cannot figure out the reason of PHP Notice I am getting:
Use of undefined constant PAYMENT_ERROR - assumed 'PAYMENT_ERROR' in /src/Micro/Payments/Manager.php on line 146
The code in Manager.php function looks like this:
$code = Result::PAYMENT_ERROR;
return new Result($code, $errMsg); // <- line 146 - causes PHP Notice
What is strange to me, is that $code
variable is set correctly and does not trigger any notices. Only instantiating Result does.
The Result class is very simple:
class Result
{
// ... boilerplate code skipped ...
// constant is defined like this:
const PAYMENT_ERROR = 2;
public function __construct($code, array $messages)
{
$this->code = $code;
$this->messages = $messages;
}
// ... other functions skipped as they are not relevat ...
}
Is there a problem that I pass Result's constant to it's own constructor?