/** * Should be in the format (all required): * static $SAMPLE_ERROR_KEY = array( * 'message' => 'sample error message', * 'httpcode' => '401', * 'code' => 1); // optional */ function __construct() { $rClass = new \ReflectionClass(get_called_class()); $rProperties = $rClass->getProperties(\ReflectionProperty::IS_STATIC); $defaultProps = $rClass->getDefaultProperties(); foreach ($rProperties as $rProperty) { $ignoreAnnotation = ReflectionHelper::getDocDirective($rProperty->getDocComment(), 'ignore'); if (!empty($ignoreAnnotation) || !is_array($defaultProps[$rProperty->getName()]) || empty($defaultProps[$rProperty->getName()])) { continue; } $propertyKeys = array_keys($defaultProps[$rProperty->getName()]); $key = $propertyKeys[0]; $errorResponseArray = $defaultProps[$rProperty->getName()][$key]; if (empty($errorResponseArray['message']) || empty($errorResponseArray['httpcode'])) { continue; } $this->errorResponses[$key] = ErrorResponse::FromArray($errorResponseArray); } }