johnbillion / query-monitor

The developer tools panel for WordPress
https://querymonitor.com
GNU General Public License v2.0
1.59k stars 208 forks source link

Go on a spacewalk 👨‍🚀 #877

Closed szepeviktor closed 1 month ago

szepeviktor commented 1 month ago

@johnbillion This intro is a gift for you 🎁 https://starwarsintrocreator.kassellabs.io/#!/EO2E7oVWMbEJ5wC8fXSj

These tags would be read in https://github.com/johnbillion/query-monitor/blob/2b58634b37b8e7de52d8363c741053f42b7c8079/classes/QueryMonitor.php#L48

$collectors = array_filter(
    get_declared_classes(),
    static function (string $class): bool {
        return str_starts_with($class, 'QM_Collector_');
    }
);
// Run ReflectionClass::getDocComment on $collectors
// Parse @qm-collector tag
// Run add_filter

Similar to https://github.com/szepeviktor/SentencePress/blob/412fef6c8d6fed04cfb429cec11f866df4237f11/src/HookAnnotation.php#L43-L53

What do you think?

johnbillion commented 1 month ago

I'm a fan of declarative coding but this is a bit too far from the WordPress way. I've got a list of 100 things that are higher priority too! :D

szepeviktor commented 1 month ago

Somehow my brain associates "the WordPress way" with people who write scripts ... This a Symfony-like PR. In PHP 8 we could use #[Attribute].