Cloudflare-WordPress icon indicating copy to clipboard operation
Cloudflare-WordPress copied to clipboard

Fix PHP Deprecated messages

Open PHP8Coder opened this issue 1 year ago • 5 comments

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the plugin and it is still present.

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

PHP8Coder avatar Oct 22 '23 14:10 PHP8Coder

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

knofte avatar Nov 29 '23 19:11 knofte

Please

gosixl avatar Jan 08 '24 03:01 gosixl

Same

juhojama avatar Jan 17 '24 08:01 juhojama

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.

github-actions[bot] avatar Jul 16 '24 01:07 github-actions[bot]

bump

knofte avatar Jul 16 '24 08:07 knofte