cloudflare / Cloudflare-WordPress

A Cloudflare plugin for WordPress
https://www.cloudflare.com/wordpress/
BSD 3-Clause "New" or "Revised" License
216 stars 83 forks source link

Fix PHP Deprecated messages #526

Open PHP8Coder opened 1 year ago

PHP8Coder commented 1 year ago

Confirmation

WordPress version

6.3.2

Cloudflare-WordPress version

4.12.2

PHP version

8.2.11

Expected result

No messages

Actual result

PHP Deprecated: Creation of dynamic property CF\WordPress\Proxy::$pluginAPI is deprecated in ***/wp-content/plugins/cloudflare/src/WordPress/Proxy.php on line 31

PHP Deprecated: Creation of dynamic property CF\WordPress\DataStore::$logger is deprecated in ***/wp-content/plugins/cloudflare/src/WordPress/DataStore.php on line 23

Steps to reproduce

Activate Debug logging

Additional factoids

How to fix:

class DataStore {
    public $logger;
    // ... rest of the class
}

namespace CF\WordPress;

use CF\Integration\DefaultLogger;
use CF\Integration\DataStoreInterface;
use CF\API\Plugin;
use Symfony\Polyfill\Tests\Intl\Idn;

class DataStore implements DataStoreInterface
{
    const API_KEY = 'cloudflare_api_key';
    const EMAIL = 'cloudflare_api_email';
    const CACHED_DOMAIN_NAME = 'cloudflare_cached_domain_name';

    protected $wordPressWrapper;
    protected $logger;  // <-- Add this line here

    /**
     * @param DefaultLogger $logger
     */
    public function __construct(DefaultLogger $logger)
    {
        $this->logger = $logger;
        $this->wordPressWrapper = new WordPressWrapper();
    }

    // ... rest of the class
}

namespace CF\WordPress;

use CF\API;
use CF\API\Plugin;
use CF\Integration\IntegrationInterface;
use CF\Router\RequestRouter;

class Proxy
{
    protected $config;
    protected $dataStore;
    protected $logger;
    protected $wordpressAPI;
    protected $wordpressClientAPI;
    protected $wordpressIntegration;
    protected $requestRouter;
    protected $pluginAPI;  // <-- Add this line here

    /**
     * @param IntegrationInterface $integration
     */
    public function __construct(IntegrationInterface $integration)
    {
        // ... rest of the constructor
    }

    // ... rest of the class
}

References

No response

knofte commented 1 year ago

@PHP8Coder protected $logger; or public though? Or either would be a safe one? (asking because I don't know)

gosixl commented 11 months ago

Please

juhojama commented 10 months ago

Same

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

knofte commented 4 months ago

bump