I have a bug in my application which I do not understand at all. I made a minimal example which reproduces the issue:
<?php
class MyClass {
const ITEMS_PER_STACK = 30;
public function test(): int {
global $ITEMS_PER_STACK;
return $ITEMS_PER_STACK;
}
}
$a = new MyClass();
echo($a->test());
Expected behavior is an output of 30 while in reality if throws a null exception because the global variable cannot be accessed. Can someone explain it to me why this happens and how to fix this? Would be much appreciated, thanks.
self::ITEMS_PER_STACK