So after I understood that the issue was just in vscode, I found that is a know issue of Intelephense due the fact that in older php versions, constants could not be declared in php traits
https://github.com/bmewburn/vscode-intelephense/issues/2024
the solution is to suppress the message using /** @disregard P1012 */ on top like this
MyTrait.php
<?php
namespace App;
class MyTrait {
public function myTraitMethod() {
/** @disregard P1012 */
return self::MY_CONST;
}
}