On Wed, Mar 29, 2023, at 4:28 PM, Mark Baker wrote: > Another benefit of this approach would be to allow the inclusion of > multiple enums, in the same way that we can include multiple traits. > > > enum HttpErrors { > > case HTTP_STATUS_400; > > case HTTP_STATUS_401; > > … > > } > > enum DatabaseErrors { > > case RECORD_NOT_FOUND; > case DATABASE_NOT_AVAILABLE; > > … > > } > > > > enum ApiErrors { > > use HttpErrors, DatabaseErrors; > > > > case JsonParserError; > > case GraphQLParserError; > > }
All that said, we could get the same functionality with fewer questions if we just finally got around to introducing type definitions. type ApiError = DatabaseError|HttpError; function handleErrors(ApiError $error) {...} That would obviate the need for a lot of workarounds. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php