From 5cdb4ec29f479dc67e63c022a07799a47b22f686 Mon Sep 17 00:00:00 2001 From: Daniel Degasperi Date: Fri, 20 Feb 2026 07:52:10 +0100 Subject: [PATCH 1/6] Fix PHP 8.4 nullable type deprecation --- ChangeLog | 10 ++++++++++ src/handlers/save_handler.php | 2 +- src/object/persistent_object_definition.php | 2 +- src/object/persistent_object_id_property.php | 2 +- src/session_decorators/identity.php | 2 +- src/structs/identity.php | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ce2b25..4045df6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1.8.2 - Thursday 20 February 2026 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentSaveHandler::saveInternal(). +- Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentObjectIdProperty::__construct(). +- Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentObjectDefinition::__construct(). +- Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentSessionIdentityDecorator::__construct(). +- Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentIdentity::__construct(). + + 1.8.1 - Friday 26 March 2021 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/handlers/save_handler.php b/src/handlers/save_handler.php index 4173edc..6e27f55 100644 --- a/src/handlers/save_handler.php +++ b/src/handlers/save_handler.php @@ -295,7 +295,7 @@ public function updateFromQuery( ezcQueryUpdate $query ) private function saveInternal( $object, $doPersistenceCheck = true, - ezcPersistentIdentifierGenerator $idGenerator = null + ?ezcPersistentIdentifierGenerator $idGenerator = null ) { $class = get_class( $object ); diff --git a/src/object/persistent_object_definition.php b/src/object/persistent_object_definition.php index 5bd1cb8..769f5d7 100644 --- a/src/object/persistent_object_definition.php +++ b/src/object/persistent_object_definition.php @@ -82,7 +82,7 @@ public function __construct( $table = '', $class = '', array $properties = array(), array $relations = array(), - ezcPersistentObjectIdProperty $idProperty = null ) + ?ezcPersistentObjectIdProperty $idProperty = null ) { $this->table = $table; $this->class = $class; diff --git a/src/object/persistent_object_id_property.php b/src/object/persistent_object_id_property.php index 73defc1..de945a1 100644 --- a/src/object/persistent_object_id_property.php +++ b/src/object/persistent_object_id_property.php @@ -93,7 +93,7 @@ public function __construct( $columnName = null, $propertyName = null, $visibility = null, - ezcPersistentGeneratorDefinition $generator = null, + ?ezcPersistentGeneratorDefinition $generator = null, $propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT, $databaseType = PDO::PARAM_STR ) diff --git a/src/session_decorators/identity.php b/src/session_decorators/identity.php index 0cc1072..4cb1e1d 100644 --- a/src/session_decorators/identity.php +++ b/src/session_decorators/identity.php @@ -127,7 +127,7 @@ class ezcPersistentSessionIdentityDecorator implements ezcPersistentSessionFound * @param ezcPersistentIdentityMap $identityMap * @param ezcPersistentSessionIdentityDecoratorOptions $options */ - public function __construct( ezcPersistentSession $session, ezcPersistentIdentityMap $identityMap, ezcPersistentSessionIdentityDecoratorOptions $options = null ) + public function __construct( ezcPersistentSession $session, ezcPersistentIdentityMap $identityMap, ?ezcPersistentSessionIdentityDecoratorOptions $options = null ) { $this->session = $session; $this->properties['identityMap'] = $identityMap; diff --git a/src/structs/identity.php b/src/structs/identity.php index 14aa3ab..20c2d54 100644 --- a/src/structs/identity.php +++ b/src/structs/identity.php @@ -122,7 +122,7 @@ public function __construct( $object = null, array $relatedObjects = array(), array $namedRelatedObjectSets = array(), - SplObjectStorage $references = null + ?SplObjectStorage $references = null ) { $this->object = $object; From 0c1d0bdd918c9e691cebb29784a9f63631f52838 Mon Sep 17 00:00:00 2001 From: Daniel Degasperi Date: Fri, 20 Feb 2026 15:35:04 +0100 Subject: [PATCH 2/6] Fix PHP 8.1 return types on ArrayObject subclasses --- ChangeLog | 3 +++ src/object/persistent_object_columns.php | 18 +++++++++--------- src/object/persistent_object_properties.php | 18 +++++++++--------- src/object/persistent_object_relations.php | 18 +++++++++--------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4045df6..5ae6bcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ - Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentObjectDefinition::__construct(). - Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentSessionIdentityDecorator::__construct(). - Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentIdentity::__construct(). +- Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectRelations::offsetSet(), exchangeArray(), setFlags() and append(). +- Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectProperties::offsetSet(), exchangeArray(), setFlags() and append(). +- Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectColumns::offsetSet(), exchangeArray(), setFlags() and append(). 1.8.1 - Friday 26 March 2021 diff --git a/src/object/persistent_object_columns.php b/src/object/persistent_object_columns.php index 4b4de0b..0c36905 100644 --- a/src/object/persistent_object_columns.php +++ b/src/object/persistent_object_columns.php @@ -60,7 +60,7 @@ public function __construct() * @param ezcPersistentObjectProperty $value * @return void */ - public function offsetSet( $offset, $value ) + public function offsetSet( $offset, $value ): void { if ( ( $value instanceof ezcPersistentObjectProperty ) === false && ( $value instanceof ezcPersistentObjectIdProperty ) === false ) { @@ -78,9 +78,9 @@ public function offsetSet( $offset, $value ) * Performs additional value checks on the array. * * @param array(ezcPersistentObjectProperty) $array New relations array. - * @return void + * @return array the old array. */ - public function exchangeArray( $array ) + public function exchangeArray( $array ): array { foreach ( $array as $offset => $value ) { @@ -93,7 +93,7 @@ public function exchangeArray( $array ) throw new ezcBaseValueException( 'offset', $offset, 'string, length > 0' ); } } - parent::exchangeArray( $array ); + return parent::exchangeArray( $array ); } /** @@ -103,7 +103,7 @@ public function exchangeArray( $array ) * @param int $flags Must be 0. * @return void */ - public function setFlags( $flags ) + public function setFlags( $flags ): void { if ( $flags !== 0 ) { @@ -112,12 +112,12 @@ public function setFlags( $flags ) } /** - * Appending is not supported. - * - * @param mixed $value + * Appending is not supported. + * + * @param mixed $value * @return void */ - public function append( $value ) + public function append( $value ): void { throw new Exception( 'Operation append is not supported by this object.' ); } diff --git a/src/object/persistent_object_properties.php b/src/object/persistent_object_properties.php index b89076f..4f65b03 100644 --- a/src/object/persistent_object_properties.php +++ b/src/object/persistent_object_properties.php @@ -60,7 +60,7 @@ public function __construct() * @param ezcPersistentObjectProperty $value * @return void */ - public function offsetSet( $offset, $value ) + public function offsetSet( $offset, $value ): void { if ( ( $value instanceof ezcPersistentObjectProperty ) === false ) { @@ -78,9 +78,9 @@ public function offsetSet( $offset, $value ) * Performs additional value checks on the array. * * @param array(ezcPersistentObjectProperty) $array New properties array. - * @return void + * @return array the old array. */ - public function exchangeArray( $array ) + public function exchangeArray( $array ): array { foreach ( $array as $offset => $value ) { @@ -93,7 +93,7 @@ public function exchangeArray( $array ) throw new ezcBaseValueException( 'offset', $offset, 'string, length > 0' ); } } - parent::exchangeArray( $array ); + return parent::exchangeArray( $array ); } /** @@ -103,7 +103,7 @@ public function exchangeArray( $array ) * @param int $flags Must be 0. * @return void */ - public function setFlags( $flags ) + public function setFlags( $flags ): void { if ( $flags !== 0 ) { @@ -112,12 +112,12 @@ public function setFlags( $flags ) } /** - * Appending is not supported. - * - * @param mixed $value + * Appending is not supported. + * + * @param mixed $value * @return void */ - public function append( $value ) + public function append( $value ): void { throw new Exception( 'Operation append is not supported by this object.' ); } diff --git a/src/object/persistent_object_relations.php b/src/object/persistent_object_relations.php index 1dbac42..1fdfdde 100644 --- a/src/object/persistent_object_relations.php +++ b/src/object/persistent_object_relations.php @@ -60,7 +60,7 @@ public function __construct() * @param ezcPersistentRelation $value * @return void */ - public function offsetSet( $offset, $value ) + public function offsetSet( $offset, $value ): void { if ( !( $value instanceof ezcPersistentRelation ) && !( $value instanceof ezcPersistentRelationCollection ) ) { @@ -78,9 +78,9 @@ public function offsetSet( $offset, $value ) * Performs additional value checks on the array. * * @param array(ezcPersistentRelation) $array New relations array. - * @return void + * @return array the old array. */ - public function exchangeArray( $array ) + public function exchangeArray( $array ): array { foreach ( $array as $offset => $value ) { @@ -93,7 +93,7 @@ public function exchangeArray( $array ) throw new ezcBaseValueException( 'offset', $offset, 'string, length > 0' ); } } - parent::exchangeArray( $array ); + return parent::exchangeArray( $array ); } /** @@ -103,7 +103,7 @@ public function exchangeArray( $array ) * @param int $flags Must be 0. * @return void */ - public function setFlags( $flags ) + public function setFlags( $flags ): void { if ( $flags !== 0 ) { @@ -112,12 +112,12 @@ public function setFlags( $flags ) } /** - * Appending is not supported. - * - * @param mixed $value + * Appending is not supported. + * + * @param mixed $value * @return void */ - public function append( $value ) + public function append( $value ): void { throw new Exception( 'Operation append is not supported by this object.' ); } From 1f3a7c0e0cb5374521ba48a58d89b612e439863b Mon Sep 17 00:00:00 2001 From: Daniel Degasperi Date: Fri, 20 Feb 2026 15:41:32 +0100 Subject: [PATCH 3/6] Add void return types to test setUp/tearDown --- ChangeLog | 1 + tests/basic_identity_map_test.php | 4 ++-- tests/database_type_test.php | 4 ++-- tests/find_iterator_test.php | 4 ++-- tests/find_query_test.php | 4 ++-- tests/instance_delayed_init_test.php | 2 +- tests/keyword_test.php | 4 ++-- tests/managers/cache_manager_test.php | 2 +- tests/managers/multi_manager_test.php | 2 +- tests/manual_generator_test.php | 4 ++-- tests/native_generator_test.php | 4 ++-- tests/object/columns_test.php | 4 ++-- tests/object/definition_test.php | 4 ++-- tests/object/id_property_test.php | 4 ++-- tests/object/properties_test.php | 4 ++-- tests/object/property_test.php | 4 ++-- tests/object/relations_test.php | 4 ++-- tests/persistent_session/casesensitive_test.php | 4 ++-- tests/persistent_session/instance_test.php | 2 +- tests/persistent_session/test_case.php | 4 ++-- tests/persistent_session_identity_decorator/instance_test.php | 2 +- .../relation_object_extractor_test.php | 4 ++-- .../relation_prefetch_test.php | 2 +- tests/persistent_session_identity_decorator/relation_test.php | 4 ++-- tests/persistent_session_identity_decorator/test_case.php | 2 +- tests/relations/many_to_many_relation_test.php | 4 ++-- tests/relations/many_to_one_relation_test.php | 4 ++-- tests/relations/multi_relation_test.php | 4 ++-- tests/relations/one_to_many_relation_test.php | 4 ++-- tests/relations/one_to_one_relation_test.php | 4 ++-- tests/string_identifier_test.php | 4 ++-- 31 files changed, 54 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ae6bcf..0edc313 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectRelations::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectProperties::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectColumns::offsetSet(), exchangeArray(), setFlags() and append(). +- Fixed: PHP 8.1 deprecation of missing return types in PHPUnit setUp() and tearDown() methods across all test classes. 1.8.1 - Friday 26 March 2021 diff --git a/tests/basic_identity_map_test.php b/tests/basic_identity_map_test.php index bdc113d..2e56404 100644 --- a/tests/basic_identity_map_test.php +++ b/tests/basic_identity_map_test.php @@ -44,14 +44,14 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( __CLASS__ ); } - public function setUp() + public function setUp(): void { $this->definitionManager = new ezcPersistentCodeManager( dirname( __FILE__ ) . '/data' ); } - public function tearDown() + public function tearDown(): void { } diff --git a/tests/database_type_test.php b/tests/database_type_test.php index 73911a9..8e53fcc 100644 --- a/tests/database_type_test.php +++ b/tests/database_type_test.php @@ -43,7 +43,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( __CLASS__ ); } - public function setup() + public function setUp(): void { try { @@ -61,7 +61,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { // DatabaseTypeTestObject::cleanup(); } diff --git a/tests/find_iterator_test.php b/tests/find_iterator_test.php index 42dd8c9..9e094f7 100644 --- a/tests/find_iterator_test.php +++ b/tests/find_iterator_test.php @@ -39,7 +39,7 @@ class ezcPersistentFindIteratorTest extends ezcTestCase private $manager; private $session; - protected function setUp() + protected function setUp(): void { try { @@ -56,7 +56,7 @@ protected function setUp() $this->session = new ezcPersistentSession( $this->db, $this->manager ); } - protected function tearDown() + protected function tearDown(): void { PersistentTestObject::cleanup(); } diff --git a/tests/find_query_test.php b/tests/find_query_test.php index 48f78c8..30cf24c 100644 --- a/tests/find_query_test.php +++ b/tests/find_query_test.php @@ -39,7 +39,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( __CLASS__ ); } - public function setUp() + public function setUp(): void { try { @@ -51,7 +51,7 @@ public function setUp() } } - public function tearDown() + public function tearDown(): void { unset( $this->db ); } diff --git a/tests/instance_delayed_init_test.php b/tests/instance_delayed_init_test.php index 8d77edb..54533cc 100644 --- a/tests/instance_delayed_init_test.php +++ b/tests/instance_delayed_init_test.php @@ -37,7 +37,7 @@ class ezcPersistentObjectInstanceDelayedInitTest extends ezcTestCase { private $default; - public function setUp() + public function setUp(): void { try { diff --git a/tests/keyword_test.php b/tests/keyword_test.php index fc09855..854cb83 100644 --- a/tests/keyword_test.php +++ b/tests/keyword_test.php @@ -42,7 +42,7 @@ class ezcPersistentKeywordTest extends ezcTestCase private $session = null; private $hasTables = false; - protected function setUp() + protected function setUp(): void { try { @@ -59,7 +59,7 @@ protected function setUp() new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/keywordtest" ) ); } - protected function tearDown() + protected function tearDown(): void { Table::cleanup(); } diff --git a/tests/managers/cache_manager_test.php b/tests/managers/cache_manager_test.php index 754a9e6..dc5ee03 100644 --- a/tests/managers/cache_manager_test.php +++ b/tests/managers/cache_manager_test.php @@ -35,7 +35,7 @@ class ezcPersistentCacheManagerTest extends ezcTestCase { private $manager = null; - protected function setUp() + protected function setUp(): void { $this->manager = new ezcPersistentCacheManager( new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/" ) ); } diff --git a/tests/managers/multi_manager_test.php b/tests/managers/multi_manager_test.php index 3e0704e..9e03983 100644 --- a/tests/managers/multi_manager_test.php +++ b/tests/managers/multi_manager_test.php @@ -35,7 +35,7 @@ class ezcPersistentMultiManagerTest extends ezcTestCase { private $manager = null; - protected function setUp() + protected function setUp(): void { $managers = array(); $managers[] = new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/" ); diff --git a/tests/manual_generator_test.php b/tests/manual_generator_test.php index cdfa87e..9e9a48f 100644 --- a/tests/manual_generator_test.php +++ b/tests/manual_generator_test.php @@ -39,7 +39,7 @@ class ezcPersistentManualGeneratorTest extends ezcTestCase private $session = null; private $hasTables = false; - protected function setUp() + protected function setUp(): void { try { @@ -57,7 +57,7 @@ protected function setUp() new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/" ) ); } - protected function tearDown() + protected function tearDown(): void { ManualGeneratorTest::cleanup(); } diff --git a/tests/native_generator_test.php b/tests/native_generator_test.php index a93c504..9f3695a 100644 --- a/tests/native_generator_test.php +++ b/tests/native_generator_test.php @@ -39,7 +39,7 @@ class ezcPersistentNativeGeneratorTest extends ezcTestCase private $session = null; private $hasTables = false; - protected function setUp() + protected function setUp(): void { try { @@ -62,7 +62,7 @@ protected function setUp() new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/" ) ); } - protected function tearDown() + protected function tearDown(): void { PersistentTestObject::cleanup(); } diff --git a/tests/object/columns_test.php b/tests/object/columns_test.php index 13b361d..10a5c5a 100644 --- a/tests/object/columns_test.php +++ b/tests/object/columns_test.php @@ -33,11 +33,11 @@ */ class ezcPersistentObjectColumnsTest extends ezcTestCase { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/object/definition_test.php b/tests/object/definition_test.php index 91dd6ad..68f281e 100644 --- a/tests/object/definition_test.php +++ b/tests/object/definition_test.php @@ -33,11 +33,11 @@ */ class ezcPersistentObjectDefinitionTest extends ezcTestCase { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/object/id_property_test.php b/tests/object/id_property_test.php index d0446dd..dce6f43 100644 --- a/tests/object/id_property_test.php +++ b/tests/object/id_property_test.php @@ -33,11 +33,11 @@ */ class ezcPersistentObjectIdPropertyTest extends ezcTestCase { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/object/properties_test.php b/tests/object/properties_test.php index 81ada8a..6f7b49c 100644 --- a/tests/object/properties_test.php +++ b/tests/object/properties_test.php @@ -33,11 +33,11 @@ */ class ezcPersistentObjectPropertiesTest extends ezcTestCase { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/object/property_test.php b/tests/object/property_test.php index 2fef8f9..823b613 100644 --- a/tests/object/property_test.php +++ b/tests/object/property_test.php @@ -33,11 +33,11 @@ */ class ezcPersistentObjectPropertyTest extends ezcTestCase { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/object/relations_test.php b/tests/object/relations_test.php index 090446e..0b3794b 100644 --- a/tests/object/relations_test.php +++ b/tests/object/relations_test.php @@ -33,11 +33,11 @@ */ class ezcPersistentObjectRelationsTest extends ezcTestCase { - protected function setUp() + protected function setUp(): void { } - protected function tearDown() + protected function tearDown(): void { } diff --git a/tests/persistent_session/casesensitive_test.php b/tests/persistent_session/casesensitive_test.php index f38f327..7e32a9e 100644 --- a/tests/persistent_session/casesensitive_test.php +++ b/tests/persistent_session/casesensitive_test.php @@ -37,7 +37,7 @@ class ezcPersistentSessionCasesensitiveTest extends ezcTestCase { protected $session = null; - protected function setUp() + protected function setUp(): void { try { @@ -134,7 +134,7 @@ public function testSave() $this->assertEquals( 'Finland has Nokia!', $object2->text ); } - protected function tearDown() + protected function tearDown(): void { PersistentTestObjectCasesensitive::cleanup(); } diff --git a/tests/persistent_session/instance_test.php b/tests/persistent_session/instance_test.php index f013c9c..55f85b3 100644 --- a/tests/persistent_session/instance_test.php +++ b/tests/persistent_session/instance_test.php @@ -35,7 +35,7 @@ class ezcPersistentSessionInstanceTest extends ezcTestCase { private $default; - protected function setUp() + protected function setUp(): void { try { diff --git a/tests/persistent_session/test_case.php b/tests/persistent_session/test_case.php index 5ebfca7..163ba20 100644 --- a/tests/persistent_session/test_case.php +++ b/tests/persistent_session/test_case.php @@ -48,7 +48,7 @@ class ezcPersistentSessionTest extends ezcTestCase protected $session = null; protected $hasTables = false; - protected function setUp() + protected function setUp(): void { try { @@ -69,7 +69,7 @@ protected function setUp() ); } - protected function tearDown() + protected function tearDown(): void { PersistentTestObject::cleanup(); } diff --git a/tests/persistent_session_identity_decorator/instance_test.php b/tests/persistent_session_identity_decorator/instance_test.php index 73b4a72..cdb3a7f 100644 --- a/tests/persistent_session_identity_decorator/instance_test.php +++ b/tests/persistent_session_identity_decorator/instance_test.php @@ -35,7 +35,7 @@ class ezcPersistentSessionIdentityDecoratorInstanceTest extends ezcTestCase { private $default; - protected function setUp() + protected function setUp(): void { try { diff --git a/tests/persistent_session_identity_decorator/relation_object_extractor_test.php b/tests/persistent_session_identity_decorator/relation_object_extractor_test.php index bac52de..e2229a3 100644 --- a/tests/persistent_session_identity_decorator/relation_object_extractor_test.php +++ b/tests/persistent_session_identity_decorator/relation_object_extractor_test.php @@ -48,7 +48,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( __CLASS__ ); } - public function setup() + public function setUp(): void { parent::setup(); @@ -72,7 +72,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { RelationTestEmployer::cleanup( $this->db ); } diff --git a/tests/persistent_session_identity_decorator/relation_prefetch_test.php b/tests/persistent_session_identity_decorator/relation_prefetch_test.php index c6abbef..c238e88 100644 --- a/tests/persistent_session_identity_decorator/relation_prefetch_test.php +++ b/tests/persistent_session_identity_decorator/relation_prefetch_test.php @@ -44,7 +44,7 @@ class ezcPersistentSessionIdentityDecoratorRelationPrefetchTest extends ezcTestC protected $db; - public function setup() + public function setUp(): void { $this->defManager = new ezcPersistentCodeManager( dirname( __FILE__ ) . '/../data/' diff --git a/tests/persistent_session_identity_decorator/relation_test.php b/tests/persistent_session_identity_decorator/relation_test.php index 815ddbe..fcad164 100644 --- a/tests/persistent_session_identity_decorator/relation_test.php +++ b/tests/persistent_session_identity_decorator/relation_test.php @@ -48,7 +48,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( __CLASS__ ); } - public function setup() + public function setUp(): void { try { @@ -76,7 +76,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { RelationTestEmployer::cleanup(); } diff --git a/tests/persistent_session_identity_decorator/test_case.php b/tests/persistent_session_identity_decorator/test_case.php index 29e428c..81abafa 100644 --- a/tests/persistent_session_identity_decorator/test_case.php +++ b/tests/persistent_session_identity_decorator/test_case.php @@ -39,7 +39,7 @@ class ezcPersistentSessionIdentityDecoratorTest extends ezcPersistentSessionTest protected $idSession; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/relations/many_to_many_relation_test.php b/tests/relations/many_to_many_relation_test.php index 1ecb041..ca9d215 100644 --- a/tests/relations/many_to_many_relation_test.php +++ b/tests/relations/many_to_many_relation_test.php @@ -45,7 +45,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( "ezcPersistentManyToManyRelationTest" ); } - public function setup() + public function setUp(): void { try { @@ -63,7 +63,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { RelationTestPerson::cleanup(); } diff --git a/tests/relations/many_to_one_relation_test.php b/tests/relations/many_to_one_relation_test.php index 6fab140..929c3bf 100644 --- a/tests/relations/many_to_one_relation_test.php +++ b/tests/relations/many_to_one_relation_test.php @@ -44,7 +44,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( "ezcPersistentManyToOneRelationTest" ); } - public function setup() + public function setUp(): void { try { @@ -62,7 +62,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { RelationTestEmployer::cleanup(); } diff --git a/tests/relations/multi_relation_test.php b/tests/relations/multi_relation_test.php index 2648215..fbc89d7 100644 --- a/tests/relations/multi_relation_test.php +++ b/tests/relations/multi_relation_test.php @@ -43,7 +43,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( __CLASS__ ); } - public function setup() + public function setUp(): void { try { @@ -61,7 +61,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { MultiRelationTestPerson::cleanup(); } diff --git a/tests/relations/one_to_many_relation_test.php b/tests/relations/one_to_many_relation_test.php index bf5ade1..26e748e 100644 --- a/tests/relations/one_to_many_relation_test.php +++ b/tests/relations/one_to_many_relation_test.php @@ -46,7 +46,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( "ezcPersistentOneToManyRelationTest" ); } - public function setup() + public function setUp(): void { try { @@ -64,7 +64,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { RelationTestEmployer::cleanup(); } diff --git a/tests/relations/one_to_one_relation_test.php b/tests/relations/one_to_one_relation_test.php index 0903fe6..b92a025 100644 --- a/tests/relations/one_to_one_relation_test.php +++ b/tests/relations/one_to_one_relation_test.php @@ -45,7 +45,7 @@ public static function suite() return new \PHPUnit\Framework\TestSuite( "ezcPersistentOneToOneRelationTest" ); } - public function setup() + public function setUp(): void { try { @@ -63,7 +63,7 @@ public function setup() ); } - public function teardown() + public function tearDown(): void { RelationTestBirthday::cleanup(); } diff --git a/tests/string_identifier_test.php b/tests/string_identifier_test.php index 4ab21b4..966a0d0 100644 --- a/tests/string_identifier_test.php +++ b/tests/string_identifier_test.php @@ -38,7 +38,7 @@ class ezcPersistentStringIdentifierTest extends ezcTestCase { private $session = null; - protected function setUp() + protected function setUp(): void { try { @@ -55,7 +55,7 @@ protected function setUp() new ezcPersistentCodeManager( dirname( __FILE__ ) . "/data/string_identifier" ) ); } - protected function tearDown() + protected function tearDown(): void { MainTable::cleanup(); } From e1778d26504d71fc7e8c1531b8dcf5e13054c7fe Mon Sep 17 00:00:00 2001 From: Daniel Degasperi Date: Fri, 20 Feb 2026 15:51:00 +0100 Subject: [PATCH 4/6] Fix deprecated PHPUnit API usage in tests --- ChangeLog | 3 ++ tests/database_type_test.php | 8 ++-- tests/find_query_test.php | 12 ++--- .../relation_query_creator_test.php | 27 +++++++---- .../relation_test.php | 48 +++++++------------ 5 files changed, 46 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0edc313..1455fbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectProperties::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectColumns::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in PHPUnit setUp() and tearDown() methods across all test classes. +- Fixed: PHPUnit deprecation of getMock() replaced with getMockBuilder() in test classes. +- Fixed: PHPUnit deprecation of readAttribute() replaced with a custom readPrivateAttribute() helper using Reflection. +- Fixed: PHPUnit strict type assertion corrections (string to int) in ezcPersistentDatabaseTypeTest. 1.8.1 - Friday 26 March 2021 diff --git a/tests/database_type_test.php b/tests/database_type_test.php index 8e53fcc..5b0f305 100644 --- a/tests/database_type_test.php +++ b/tests/database_type_test.php @@ -75,11 +75,11 @@ public function testLoadCorrectMysqlSqlite() $obj = $this->session->load( 'DatabaseTypeTestObject', 1 ); $this->assertSame( - '1', + 1, $obj->id ); $this->assertSame( - '23', + 23, $obj->int ); $this->assertSame( @@ -380,11 +380,11 @@ public function testFindCorrectMysqlSqlite() $obj = $objs[1]; $this->assertSame( - '1', + 1, $obj->id ); $this->assertSame( - '23', + 23, $obj->int ); $this->assertSame( diff --git a/tests/find_query_test.php b/tests/find_query_test.php index 30cf24c..f2a1fb8 100644 --- a/tests/find_query_test.php +++ b/tests/find_query_test.php @@ -217,14 +217,10 @@ public function testIssetPropertiesFailure() public function testDelegateSuccess() { - $q = $this->getMock( - 'ezcQuerySelect', - array( 'reset', 'alias', 'select' ), - array(), - '', - false, - false - ); + $q = $this->getMockBuilder( 'ezcQuerySelect' ) + ->disableOriginalConstructor() + ->onlyMethods( array( 'reset', 'alias', 'select' ) ) + ->getMock(); $q->expects( $this->once() ) ->method( 'reset' ) ->will( $this->returnValue( 23 ) ); diff --git a/tests/persistent_session_identity_decorator/relation_query_creator_test.php b/tests/persistent_session_identity_decorator/relation_query_creator_test.php index d03cef9..0d49dfc 100644 --- a/tests/persistent_session_identity_decorator/relation_query_creator_test.php +++ b/tests/persistent_session_identity_decorator/relation_query_creator_test.php @@ -135,18 +135,29 @@ public function testCreateMultiLevelMultiRelationFindQuery() protected function assertAliasesEqual( $expected, $actual ) { $this->assertEquals( - $this->readAttribute( - $expected->query, - 'aliases' - ), - $this->readAttribute( - $actual->query, - 'aliases' - ), + $this->readPrivateAttribute( $expected->query, 'aliases' ), + $this->readPrivateAttribute( $actual->query, 'aliases' ), 'Query aliases did not match.' ); } + protected function readPrivateAttribute( $object, $attribute ) + { + $class = new ReflectionClass( $object ); + while ( $class !== false ) + { + if ( $class->hasProperty( $attribute ) ) + { + $prop = $class->getProperty( $attribute ); + return $prop->getValue( $object ); + } + $class = $class->getParentClass(); + } + throw new ReflectionException( + 'Property ' . get_class( $object ) . '::$' . $attribute . ' does not exist' + ); + } + protected function getLoadQueryDummy( $q ) { $q->where( diff --git a/tests/persistent_session_identity_decorator/relation_test.php b/tests/persistent_session_identity_decorator/relation_test.php index fcad164..598f34a 100644 --- a/tests/persistent_session_identity_decorator/relation_test.php +++ b/tests/persistent_session_identity_decorator/relation_test.php @@ -656,27 +656,19 @@ public function testIsRelatedStored() $relObject = new RelationTestAddress(); $relObject->id = 42; - $idMap = $this->getMock( - 'ezcPersistentBasicIdentityMap', - array( 'getRelatedObjects' ), - array(), - '', - false, - false - ); + $idMap = $this->getMockBuilder( 'ezcPersistentBasicIdentityMap' ) + ->disableOriginalConstructor() + ->onlyMethods( array( 'getRelatedObjects' ) ) + ->getMock(); $idMap->expects( $this->once() ) ->method( 'getRelatedObjects' ) ->with( $srcObject, 'RelationTestAddress', null ) ->will( $this->returnValue( array( 42 => $relObject ) ) ); - $session = $this->getMock( - 'ezcPersistentSession', - array( 'isRelated' ), - array(), - '', - false, - false - ); + $session = $this->getMockBuilder( 'ezcPersistentSession' ) + ->disableOriginalConstructor() + ->onlyMethods( array( 'isRelated' ) ) + ->getMock(); $session->expects( $this->never() ) ->method( 'isRelated' ); @@ -696,27 +688,19 @@ public function testIsRelatedNotStored() $relObject = new RelationTestAddress(); $relObject->id = 42; - $idMap = $this->getMock( - 'ezcPersistentBasicIdentityMap', - array( 'getRelatedObjects' ), - array(), - '', - false, - false - ); + $idMap = $this->getMockBuilder( 'ezcPersistentBasicIdentityMap' ) + ->disableOriginalConstructor() + ->onlyMethods( array( 'getRelatedObjects' ) ) + ->getMock(); $idMap->expects( $this->once() ) ->method( 'getRelatedObjects' ) ->with( $srcObject, 'RelationTestAddress', null ) ->will( $this->returnValue( null ) ); - $session = $this->getMock( - 'ezcPersistentSession', - array( 'isRelated' ), - array(), - '', - false, - false - ); + $session = $this->getMockBuilder( 'ezcPersistentSession' ) + ->disableOriginalConstructor() + ->onlyMethods( array( 'isRelated' ) ) + ->getMock(); $session->expects( $this->once() ) ->method( 'isRelated' ) ->with( $srcObject, $relObject ) From f1bbe2dce425eb023315b418b8c32101862ea217 Mon Sep 17 00:00:00 2001 From: Daniel Degasperi Date: Fri, 20 Feb 2026 21:02:57 +0100 Subject: [PATCH 5/6] Fix PHP 8.1 return type covariance on Iterator and ArrayObject subclasses --- ChangeLog | 3 +++ src/find_iterator.php | 11 ++++++----- src/object/relation_collection.php | 10 +++++----- src/session_decorators/identity/find_iterator.php | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1455fbb..0d05ea7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ - Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentObjectDefinition::__construct(). - Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentSessionIdentityDecorator::__construct(). - Fixed: PHP 8.4 deprecation of implicit nullable parameter types in ezcPersistentIdentity::__construct(). +- Fixed: PHP 8.1 deprecation of non-covariant return types in ezcPersistentFindIterator::rewind(), current(), key(), next() and valid(). +- Fixed: PHP 8.1 deprecation of non-covariant return types in ezcPersistentIdentityFindIterator::next(). +- Fixed: PHP 8.1 deprecation of non-covariant return types in ezcPersistentRelationCollection::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectRelations::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectProperties::offsetSet(), exchangeArray(), setFlags() and append(). - Fixed: PHP 8.1 deprecation of missing return types in ezcPersistentObjectColumns::offsetSet(), exchangeArray(), setFlags() and append(). diff --git a/src/find_iterator.php b/src/find_iterator.php index 0ab6842..5f46e6d 100644 --- a/src/find_iterator.php +++ b/src/find_iterator.php @@ -101,7 +101,7 @@ public function __construct( PDOStatement $stmt, ezcPersistentObjectDefinition $ * * @return void */ - public function rewind() + public function rewind(): void { if ( $this->object === null ) { @@ -116,7 +116,7 @@ public function rewind() * * @return object */ - public function current() + public function current(): mixed { return $this->object; } @@ -129,7 +129,7 @@ public function current() * * @return null */ - public function key() + public function key(): mixed { return null; } @@ -143,6 +143,7 @@ public function key() * * @return object */ + #[\ReturnTypeWillChange] public function next() { $row = false; @@ -153,7 +154,7 @@ public function next() catch ( PDOException $e ) // MySQL 5.0 throws this if the statement is not executed. { $this->object = null; - return; + return null; } // SQLite returns empty array on faulty statement! @@ -193,7 +194,7 @@ private function checkDef() * * @return bool */ - public function valid() + public function valid(): bool { return $this->object !== null ? true : false; } diff --git a/src/object/relation_collection.php b/src/object/relation_collection.php index ed0675f..5acd5d8 100644 --- a/src/object/relation_collection.php +++ b/src/object/relation_collection.php @@ -60,7 +60,7 @@ public function __construct() * @param ezcPersistentRelation $value * @return void */ - public function offsetSet( $offset, $value ) + public function offsetSet( $offset, $value ): void { if ( ( $value instanceof ezcPersistentRelation ) === false ) { @@ -80,7 +80,7 @@ public function offsetSet( $offset, $value ) * @param array(ezcPersistentRelation) $array New relations array. * @return void */ - public function exchangeArray( $array ) + public function exchangeArray( $array ): array { foreach ( $array as $offset => $value ) { @@ -93,7 +93,7 @@ public function exchangeArray( $array ) throw new ezcBaseValueException( 'offset', $offset, 'string, length > 0' ); } } - parent::exchangeArray( $array ); + return parent::exchangeArray( $array ); } /** @@ -103,7 +103,7 @@ public function exchangeArray( $array ) * @param int $flags Must be 0. * @return void */ - public function setFlags( $flags ) + public function setFlags( $flags ): void { if ( $flags !== 0 ) { @@ -117,7 +117,7 @@ public function setFlags( $flags ) * @param mixed $value * @return void */ - public function append( $value ) + public function append( $value ): void { throw new Exception( 'Operation append is not supported by this object.' ); } diff --git a/src/session_decorators/identity/find_iterator.php b/src/session_decorators/identity/find_iterator.php index fd6bd1f..2fd584d 100644 --- a/src/session_decorators/identity/find_iterator.php +++ b/src/session_decorators/identity/find_iterator.php @@ -110,6 +110,7 @@ public function __construct( * * @return object */ + #[\ReturnTypeWillChange] public function next() { $object = parent::next(); From 6c942e40f2d99a8ead814448aaeeb93325a500f6 Mon Sep 17 00:00:00 2001 From: Daniel Degasperi Date: Fri, 20 Feb 2026 21:06:47 +0100 Subject: [PATCH 6/6] Add GitHub Actions CI workflows --- .github/workflows/ci.yml | 14 ++++++++++++++ .github/workflows/coding-standard.yml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coding-standard.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8fd75b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,14 @@ +name: CI + +on: + # Run on all pushes to master and on all pull requests. + push: + branches: + master + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + test: + uses: "zetacomponents/.github/.github/workflows/ci.yml@master" diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml new file mode 100644 index 0000000..a79757b --- /dev/null +++ b/.github/workflows/coding-standard.yml @@ -0,0 +1,14 @@ +name: Coding Standard + +on: + # Run on all pushes and on all pull requests. + push: + branches: + master + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + test: + uses: "zetacomponents/.github/.github/workflows/coding-standard.yml@master"