Sighhh... I've wanted to do this for a long time, but WordPress's coding standards don't make it easy since prefixed, lowercased, hyphenated file names don't actually match capitalized, underscored class names. š¤¦āāļø
While import use statements can already be used in WordPress Core, it is, for the moment, strongly discouraged.
Import use statements are most useful when combined with namespaces and a class autoloading implementation.
As neither of these are currently in place for WordPress Core and discussions about this are ongoing, holding off on adding import use statements to WordPress Core is the sensible choice for now.
I realize this is referring to WordPress Core which doesn't apply to plugins, but I enjoy using PHPCS to enforce the WordPress coding standards throughout all of my WordPress code. (Which I still need to implement CI/CD pipelines for...)
For backwards-compatibility, I could define an associative array to directly map PHP classnames to their file paths. Obviously, that's a manual maintenance requirement as new classes are added, so it is prone to mistake and isn't ideal. However, this would be the safest approach for backwards compatibility to avoid renaming classes and changing file paths.
Sighhh... I've wanted to do this for a long time, but WordPress's coding standards don't make it easy since prefixed, lowercased, hyphenated file names don't actually match capitalized, underscored class names. š¤¦āāļø
Also, WordPress's coding standards specifically note this:
I realize this is referring to WordPress Core which doesn't apply to plugins, but I enjoy using PHPCS to enforce the WordPress coding standards throughout all of my WordPress code. (Which I still need to implement CI/CD pipelines for...)
For backwards-compatibility, I could define an associative array to directly map PHP classnames to their file paths. Obviously, that's a manual maintenance requirement as new classes are added, so it is prone to mistake and isn't ideal. However, this would be the safest approach for backwards compatibility to avoid renaming classes and changing file paths.