BracketSpace / Notification

WordPress Notification plugin
https://docs.bracketspace.com/notification/
GNU General Public License v3.0
170 stars 30 forks source link

Write cutting edge code and release it to legacy platforms #319

Open szepeviktor opened 3 years ago

szepeviktor commented 3 years ago

Problem

We want to write PHP 7.4/8.0 code but users run PHP 5.6

Solution

Use Rector in the release process!

Alternatives you've considered

Sleep.

jakubmikita commented 3 years ago

Hmm, do you know any WP plugin which is using this?

It looks interesting!

szepeviktor commented 3 years ago

I'm not in the WordPress business, just playing with PHP technologies. Do you think it will somehow fail?

szepeviktor commented 3 years ago

https://github.com/rectorphp/rector/issues?q=WordPress 🖱️

<?php

use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::SETS, [
        SetList::DOWNGRADE_PHP74,
        SetList::DOWNGRADE_PHP73,
        SetList::DOWNGRADE_PHP72,
        SetList::DOWNGRADE_PHP71,
        SetList::DOWNGRADE_PHP70,
        SetList::DOWNGRADE_PHP56,
    ]);
};
jakubmikita commented 3 years ago

WordPress is very specific and bloated, looking at all the problems with ie with PHPUnit I wouldn't be surprised if it fail miserably. I will take a closer look at this package and its usage with WP though

szepeviktor commented 3 years ago

You can audit the changes. Tests must be written for PHPUnit running on PHP 5.6. -> https://github.com/rectorphp/rector/blob/master/packages/set/src/ValueObject/SetList.php#L399-L467

szepeviktor commented 3 years ago

Hmm, do you know any WP plugin which is using this?

Found one: https://github.com/leoloso/PoP/blob/master/rector-downgrade-code.php

szepeviktor commented 3 years ago

Another one: https://github.com/szepeviktor/phpstan-higher-order-collections/blob/master/rector.php

mircobabini commented 3 years ago

Hmm, do you know any WP plugin which is using this?

Found one: https://github.com/leoloso/PoP/blob/master/rector-downgrade-code.php Another one: https://github.com/szepeviktor/phpstan-higher-order-collections/blob/master/rector.php

These are not Wordpress plugins.

Also, seems like support of autoload and includes (WordPress beloved stuffs) is still a work in progress https://github.com/rectorphp/rector/issues/4330.

szepeviktor commented 3 years ago

I think using Composer autoloader (not the tool!) in a WordPress plugin is okay. Please see Yoast SEO for example. So Rector won't have to rectify that. Composer autoloader is PHP 5.3+ compatible.

szepeviktor commented 3 years ago

This is how I try to break away from WordPress legacy technologies. Theory https://github.com/szepeviktor/small-project/blob/master/MAIN-FILE-PARTS.md In practice https://github.com/meilisearch/meilisearch-wordpress/pull/20

jakubmikita commented 3 years ago

We're good with Composer itself because all its loaders are backward compatible. There are problems with a few things:

I'm looking into using the Rector within this project and I'd like to find out if all the packages processed by Imposter can be rectified to older PHP versions.

szepeviktor commented 3 years ago

Highly interesting topic 👀

Time traveling 101!

szepeviktor commented 3 years ago

Public testing with Rectorizer 🤖 https://github.com/szepeviktor/rectorize/actions/runs/588606017

jakubmikita commented 3 years ago

Wow, this truly seems to work!