Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait

Also fix and test for get_defined_constants(true)