From 358c21a5a55e7b396637a580742e237297c2e8b7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 15 Mar 2022 08:34:43 +0100 Subject: [PATCH] PHP 8.2 | Various tests: explicitly declare properties Dynamic (non-explicitly declared) property usage is expected to be deprecated as of PHP 8.2 and will become a fatal error in PHP 9.0. There are a number of ways to mitigate this: * If it's an accidental typo for a declared property: fix the typo. * For known properties: declare them on the class. * For unknown properties: add the magic `__get()`, `__set()` et al methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods build in. * For unknown _use of_ dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes. This commit addresses a number of issues in the "known property" category within the test suite. Refs: * https://wiki.php.net/rfc/deprecate_dynamic_properties --- tests/Mockery/Adapter/Phpunit/TestListenerTest.php | 5 +++++ tests/Mockery/AdhocTest.php | 2 ++ tests/Mockery/DefaultMatchersTest.php | 2 ++ tests/Mockery/ExpectationTest.php | 4 ++++ .../Generator/StringManipulation/Pass/ClassNamePassTest.php | 2 ++ .../Generator/StringManipulation/Pass/ClassPassTest.php | 2 ++ tests/Mockery/HamcrestExpectationTest.php | 2 ++ tests/Mockery/MockClassWithFinalWakeupTest.php | 2 ++ 8 files changed, 21 insertions(+) diff --git a/tests/Mockery/Adapter/Phpunit/TestListenerTest.php b/tests/Mockery/Adapter/Phpunit/TestListenerTest.php index 615f56523..c650d4588 100644 --- a/tests/Mockery/Adapter/Phpunit/TestListenerTest.php +++ b/tests/Mockery/Adapter/Phpunit/TestListenerTest.php @@ -28,6 +28,11 @@ class TestListenerTest extends MockeryTestCase { + protected $container; + protected $listener; + protected $testResult; + protected $test; + protected function mockeryTestSetUp() { // We intentionally test the static container here. That is what the diff --git a/tests/Mockery/AdhocTest.php b/tests/Mockery/AdhocTest.php index d679625e6..3e6b7eb54 100644 --- a/tests/Mockery/AdhocTest.php +++ b/tests/Mockery/AdhocTest.php @@ -26,6 +26,8 @@ */ class Mockery_AdhocTest extends MockeryTestCase { + protected $container; + public function mockeryTestSetUp() { $this->container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader()); diff --git a/tests/Mockery/DefaultMatchersTest.php b/tests/Mockery/DefaultMatchersTest.php index 9d5050905..162d7c444 100644 --- a/tests/Mockery/DefaultMatchersTest.php +++ b/tests/Mockery/DefaultMatchersTest.php @@ -50,6 +50,8 @@ public function __construct($value) class DefaultMatchersTest extends MockeryTestCase { + protected $mock; + public function mockeryTestSetUp() { parent::mockeryTestSetUp(); diff --git a/tests/Mockery/ExpectationTest.php b/tests/Mockery/ExpectationTest.php index 1430701a1..c688aec5f 100644 --- a/tests/Mockery/ExpectationTest.php +++ b/tests/Mockery/ExpectationTest.php @@ -28,6 +28,8 @@ class ExpectationTest extends MockeryTestCase { use RegExpCompatability; + protected $mock; + public function mockeryTestSetUp() { parent::mockeryTestSetUp(); @@ -2228,6 +2230,8 @@ public function baz() class Mockery_UseDemeter { + protected $demeter; + public function __construct($demeter) { $this->demeter = $demeter; diff --git a/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php b/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php index 55a9b33a1..29a8210d9 100644 --- a/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php +++ b/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php @@ -28,6 +28,8 @@ class ClassNamePassTest extends MockeryTestCase { const CODE = "namespace Mockery; class Mock {}"; + protected $pass; + public function mockeryTestSetUp() { $this->pass = new ClassNamePass(); diff --git a/tests/Mockery/Generator/StringManipulation/Pass/ClassPassTest.php b/tests/Mockery/Generator/StringManipulation/Pass/ClassPassTest.php index cc182be8f..31e6ce099 100644 --- a/tests/Mockery/Generator/StringManipulation/Pass/ClassPassTest.php +++ b/tests/Mockery/Generator/StringManipulation/Pass/ClassPassTest.php @@ -28,6 +28,8 @@ class ClassPassTest extends MockeryTestCase { const CODE = "class Mock implements MockInterface {}"; + protected $pass; + public function mockeryTestSetUp() { $this->pass = new ClassPass(); diff --git a/tests/Mockery/HamcrestExpectationTest.php b/tests/Mockery/HamcrestExpectationTest.php index e7f793d70..4d58e7da9 100644 --- a/tests/Mockery/HamcrestExpectationTest.php +++ b/tests/Mockery/HamcrestExpectationTest.php @@ -23,6 +23,8 @@ class HamcrestExpectationTest extends MockeryTestCase { + protected $mock; + public function mockeryTestSetUp() { parent::mockeryTestSetUp(); diff --git a/tests/Mockery/MockClassWithFinalWakeupTest.php b/tests/Mockery/MockClassWithFinalWakeupTest.php index b5bdbd868..fd6409221 100644 --- a/tests/Mockery/MockClassWithFinalWakeupTest.php +++ b/tests/Mockery/MockClassWithFinalWakeupTest.php @@ -25,6 +25,8 @@ class MockClassWithFinalWakeupTest extends MockeryTestCase { + protected $container; + protected function mockeryTestSetUp() { $this->container = new \Mockery\Container();