diff --git a/composer.json b/composer.json index 72195dc09..ea9fd0860 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "cweagans/composer-patches": "^1.7", "deepdiver/zipstreamer": "^2.0.3", "deepdiver1975/tarstreamer": "^2.1.0", - "doctrine/dbal": "^3.10.2", + "doctrine/dbal": "^3.10.4", "egulias/email-validator": "^4.0.4", "fusonic/opengraph": "^3.0.0", "giggsey/libphonenumber-for-php-lite": "^9.0.9", diff --git a/composer.lock b/composer.lock index 9c4603403..71cc3ddae 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c7b82134d47c4e489009244fbac4ae4d", + "content-hash": "ccac2d93769d160abe1b2e4502a5f6f0", "packages": [ { "name": "aws/aws-crt-php", @@ -434,16 +434,16 @@ }, { "name": "doctrine/dbal", - "version": "3.10.2", + "version": "3.10.4", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "c6c16cf787eaba3112203dfcd715fa2059c62282" + "reference": "63a46cb5aa6f60991186cc98c1d1b50c09311868" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/c6c16cf787eaba3112203dfcd715fa2059c62282", - "reference": "c6c16cf787eaba3112203dfcd715fa2059c62282", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/63a46cb5aa6f60991186cc98c1d1b50c09311868", + "reference": "63a46cb5aa6f60991186cc98c1d1b50c09311868", "shasum": "" }, "require": { @@ -459,16 +459,16 @@ }, "require-dev": { "doctrine/cache": "^1.11|^2.0", - "doctrine/coding-standard": "13.0.1", + "doctrine/coding-standard": "14.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "2.1.22", + "phpstan/phpstan": "2.1.30", "phpstan/phpstan-strict-rules": "^2", - "phpunit/phpunit": "9.6.23", - "slevomat/coding-standard": "8.16.2", - "squizlabs/php_codesniffer": "3.13.1", - "symfony/cache": "^5.4|^6.0|^7.0", - "symfony/console": "^4.4|^5.4|^6.0|^7.0" + "phpunit/phpunit": "9.6.29", + "slevomat/coding-standard": "8.24.0", + "squizlabs/php_codesniffer": "4.0.0", + "symfony/cache": "^5.4|^6.0|^7.0|^8.0", + "symfony/console": "^4.4|^5.4|^6.0|^7.0|^8.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -528,7 +528,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.10.2" + "source": "https://github.com/doctrine/dbal/tree/3.10.4" }, "funding": [ { @@ -544,7 +544,7 @@ "type": "tidelift" } ], - "time": "2025-09-04T23:51:27+00:00" + "time": "2025-11-29T10:46:08+00:00" }, { "name": "doctrine/deprecations", @@ -596,30 +596,29 @@ }, { "name": "doctrine/event-manager", - "version": "1.2.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520" + "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/b680156fa328f1dfd874fd48c7026c41570b9c6e", + "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e", "shasum": "" }, "require": { - "doctrine/deprecations": "^0.5.3 || ^1", - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "conflict": { "doctrine/common": "<2.9" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "~1.4.10 || ^1.8.8", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.24" + "doctrine/coding-standard": "^12", + "phpstan/phpstan": "^1.8.8", + "phpunit/phpunit": "^10.5", + "vimeo/psalm": "^5.24" }, "type": "library", "autoload": { @@ -668,7 +667,7 @@ ], "support": { "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/1.2.0" + "source": "https://github.com/doctrine/event-manager/tree/2.0.1" }, "funding": [ { @@ -684,7 +683,7 @@ "type": "tidelift" } ], - "time": "2022-10-12T20:51:15+00:00" + "time": "2024-05-22T20:47:39+00:00" }, { "name": "doctrine/lexer", diff --git a/composer/installed.json b/composer/installed.json index cdde6aa1f..9d0ff8405 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -449,17 +449,17 @@ }, { "name": "doctrine/dbal", - "version": "3.10.2", - "version_normalized": "3.10.2.0", + "version": "3.10.4", + "version_normalized": "3.10.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "c6c16cf787eaba3112203dfcd715fa2059c62282" + "reference": "63a46cb5aa6f60991186cc98c1d1b50c09311868" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/c6c16cf787eaba3112203dfcd715fa2059c62282", - "reference": "c6c16cf787eaba3112203dfcd715fa2059c62282", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/63a46cb5aa6f60991186cc98c1d1b50c09311868", + "reference": "63a46cb5aa6f60991186cc98c1d1b50c09311868", "shasum": "" }, "require": { @@ -475,21 +475,21 @@ }, "require-dev": { "doctrine/cache": "^1.11|^2.0", - "doctrine/coding-standard": "13.0.1", + "doctrine/coding-standard": "14.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "2.1.22", + "phpstan/phpstan": "2.1.30", "phpstan/phpstan-strict-rules": "^2", - "phpunit/phpunit": "9.6.23", - "slevomat/coding-standard": "8.16.2", - "squizlabs/php_codesniffer": "3.13.1", - "symfony/cache": "^5.4|^6.0|^7.0", - "symfony/console": "^4.4|^5.4|^6.0|^7.0" + "phpunit/phpunit": "9.6.29", + "slevomat/coding-standard": "8.24.0", + "squizlabs/php_codesniffer": "4.0.0", + "symfony/cache": "^5.4|^6.0|^7.0|^8.0", + "symfony/console": "^4.4|^5.4|^6.0|^7.0|^8.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." }, - "time": "2025-09-04T23:51:27+00:00", + "time": "2025-11-29T10:46:08+00:00", "bin": [ "bin/doctrine-dbal" ], @@ -546,7 +546,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.10.2" + "source": "https://github.com/doctrine/dbal/tree/3.10.4" }, "funding": [ { @@ -617,33 +617,32 @@ }, { "name": "doctrine/event-manager", - "version": "1.2.0", - "version_normalized": "1.2.0.0", + "version": "2.0.1", + "version_normalized": "2.0.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520" + "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520", - "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/b680156fa328f1dfd874fd48c7026c41570b9c6e", + "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e", "shasum": "" }, "require": { - "doctrine/deprecations": "^0.5.3 || ^1", - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "conflict": { "doctrine/common": "<2.9" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "~1.4.10 || ^1.8.8", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.24" + "doctrine/coding-standard": "^12", + "phpstan/phpstan": "^1.8.8", + "phpunit/phpunit": "^10.5", + "vimeo/psalm": "^5.24" }, - "time": "2022-10-12T20:51:15+00:00", + "time": "2024-05-22T20:47:39+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -692,7 +691,7 @@ ], "support": { "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/1.2.0" + "source": "https://github.com/doctrine/event-manager/tree/2.0.1" }, "funding": [ { diff --git a/composer/installed.php b/composer/installed.php index ebacbc383..a6c1af166 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -74,9 +74,9 @@ 'dev_requirement' => false, ), 'doctrine/dbal' => array( - 'pretty_version' => '3.10.2', - 'version' => '3.10.2.0', - 'reference' => 'c6c16cf787eaba3112203dfcd715fa2059c62282', + 'pretty_version' => '3.10.4', + 'version' => '3.10.4.0', + 'reference' => '63a46cb5aa6f60991186cc98c1d1b50c09311868', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/dbal', 'aliases' => array(), @@ -92,9 +92,9 @@ 'dev_requirement' => false, ), 'doctrine/event-manager' => array( - 'pretty_version' => '1.2.0', - 'version' => '1.2.0.0', - 'reference' => '95aa4cb529f1e96576f3fda9f5705ada4056a520', + 'pretty_version' => '2.0.1', + 'version' => '2.0.1.0', + 'reference' => 'b680156fa328f1dfd874fd48c7026c41570b9c6e', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/event-manager', 'aliases' => array(), diff --git a/doctrine/dbal/src/Driver/AbstractDB2Driver.php b/doctrine/dbal/src/Driver/AbstractDB2Driver.php index 81d84328c..682ed7a19 100644 --- a/doctrine/dbal/src/Driver/AbstractDB2Driver.php +++ b/doctrine/dbal/src/Driver/AbstractDB2Driver.php @@ -18,7 +18,7 @@ use function version_compare; /** - * Abstract base implementation of the {@see Driver} interface for IBM DB2 based drivers. + * Abstract base implementation of the {@see Driver} interface for Db2 based drivers. */ abstract class AbstractDB2Driver implements VersionAwarePlatformDriver { @@ -66,17 +66,17 @@ public function createDatabasePlatformForVersion($version) Deprecation::trigger( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5156', - 'IBM DB2 < 11.1 support is deprecated and will be removed in DBAL 4.' - . ' Consider upgrading to IBM DB2 11.1 or later.', + 'Db2 < 11.1 support is deprecated and will be removed in DBAL 4.' + . ' Consider upgrading to Db2 11.1 or later.', ); return $this->getDatabasePlatform(); } /** - * Detects IBM DB2 server version + * Detects Db2 server version * - * @param string $versionString Version string as returned by IBM DB2 server, i.e. 'DB2/LINUXX8664 11.5.8.0' + * @param string $versionString Version string as returned by Db2 server, i.e. 'DB2/LINUXX8664 11.5.8.0' * * @throws DBALException */ diff --git a/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php b/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php index 124a6f6db..1840b8a3a 100644 --- a/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php +++ b/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php @@ -11,7 +11,7 @@ use function strpos; /** - * IBM DB2 DSN + * Db2 DSN */ final class DataSourceName { diff --git a/doctrine/dbal/src/Driver/IBMDB2/Statement.php b/doctrine/dbal/src/Driver/IBMDB2/Statement.php index 699e236d7..be5831fba 100644 --- a/doctrine/dbal/src/Driver/IBMDB2/Statement.php +++ b/doctrine/dbal/src/Driver/IBMDB2/Statement.php @@ -174,7 +174,8 @@ private function bindLobs(): array foreach ($this->lobs as $param => $value) { if (is_resource($value)) { $handle = $handles[] = $this->createTemporaryFile(); - $path = stream_get_meta_data($handle)['uri']; + $path = stream_get_meta_data($handle)['uri'] ?? null; + assert($path !== null); $this->copyStreamToStream($value, $handle); diff --git a/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php b/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php index f5755932b..731a6aa94 100644 --- a/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php +++ b/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php @@ -9,6 +9,8 @@ use mysqli_sql_exception; use ReflectionProperty; +use const PHP_VERSION_ID; + /** @internal */ final class ConnectionError extends AbstractException { @@ -20,7 +22,9 @@ public static function new(mysqli $connection): self public static function upcast(mysqli_sql_exception $exception): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); } diff --git a/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php b/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php index 051f141fd..414bf3d06 100644 --- a/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php +++ b/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php @@ -11,6 +11,8 @@ use function assert; +use const PHP_VERSION_ID; + /** @internal */ final class ConnectionFailed extends AbstractException { @@ -25,7 +27,9 @@ public static function new(mysqli $connection): self public static function upcast(mysqli_sql_exception $exception): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); } diff --git a/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php b/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php index 71a5bc60b..21c78b6fa 100644 --- a/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php +++ b/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php @@ -11,6 +11,8 @@ use function sprintf; +use const PHP_VERSION_ID; + /** @internal */ final class InvalidCharset extends AbstractException { @@ -26,7 +28,9 @@ public static function fromCharset(mysqli $connection, string $charset): self public static function upcast(mysqli_sql_exception $exception, string $charset): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } return new self( sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()), diff --git a/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php b/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php index 716e2cd24..d099d254a 100644 --- a/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php +++ b/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php @@ -9,6 +9,8 @@ use mysqli_stmt; use ReflectionProperty; +use const PHP_VERSION_ID; + /** @internal */ final class StatementError extends AbstractException { @@ -20,7 +22,9 @@ public static function new(mysqli_stmt $statement): self public static function upcast(mysqli_sql_exception $exception): self { $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); - $p->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception); } diff --git a/doctrine/dbal/src/Driver/PDO/PDOConnect.php b/doctrine/dbal/src/Driver/PDO/PDOConnect.php index 346c6cd59..43bb3c93b 100644 --- a/doctrine/dbal/src/Driver/PDO/PDOConnect.php +++ b/doctrine/dbal/src/Driver/PDO/PDOConnect.php @@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Driver\PDO; use PDO; +use SensitiveParameter; use const PHP_VERSION_ID; @@ -13,8 +14,10 @@ trait PDOConnect { /** @param array $options */ private function doConnect( + #[SensitiveParameter] string $dsn, string $username, + #[SensitiveParameter] string $password, array $options ): PDO { diff --git a/doctrine/dbal/src/Platforms/DB2111Platform.php b/doctrine/dbal/src/Platforms/DB2111Platform.php index 40ab42f6e..c1087151f 100644 --- a/doctrine/dbal/src/Platforms/DB2111Platform.php +++ b/doctrine/dbal/src/Platforms/DB2111Platform.php @@ -7,9 +7,9 @@ use function sprintf; /** - * Provides the behavior, features and SQL dialect of the IBM DB2 11.1 (11.1 GA) database platform. + * Provides the behavior, features and SQL dialect of the Db2 11.1 (11.1 GA) database platform. * - * @deprecated This class will be merged with {@see DB2Platform} in 4.0 because support for IBM DB2 + * @deprecated This class will be merged with {@see DB2Platform} in 4.0 because support for Db2 * releases prior to 11.1 will be dropped. * * @see https://www.ibm.com/docs/en/db2/11.1?topic=database-whats-new-db2-version-111-ga diff --git a/doctrine/dbal/src/Platforms/DB2Platform.php b/doctrine/dbal/src/Platforms/DB2Platform.php index 69234f410..18d19bb26 100644 --- a/doctrine/dbal/src/Platforms/DB2Platform.php +++ b/doctrine/dbal/src/Platforms/DB2Platform.php @@ -26,7 +26,7 @@ use function strpos; /** - * Provides the behavior, features and SQL dialect of the IBM DB2 database platform of the oldest supported version. + * Provides the behavior, features and SQL dialect of the Db2 database platform of the oldest supported version. */ class DB2Platform extends AbstractPlatform { @@ -104,7 +104,7 @@ public function getBinaryDefaultLength() */ public function getVarcharTypeDeclarationSQL(array $column) { - // for IBM DB2, the CHAR max length is less than VARCHAR default length + // for Db2, the CHAR max length is less than VARCHAR default length if (! isset($column['length']) && ! empty($column['fixed'])) { $column['length'] = $this->getCharMaxLength(); } @@ -175,7 +175,7 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed/*, $lengt Deprecation::trigger( 'doctrine/dbal', 'https://github.com/doctrine/dbal/issues/3263', - 'Relying on the default string column length on IBM DB2 is deprecated' + 'Relying on the default string column length on Db2 is deprecated' . ', specify the length explicitly.', ); } @@ -193,8 +193,8 @@ protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed/*, $length Deprecation::trigger( 'doctrine/dbal', 'https://github.com/doctrine/dbal/issues/3263', - 'Relying on the default binary column length on IBM DB2 is deprecated' - . ', specify the length explicitly.', + 'Relying on the default binary column length on Db2 is deprecated' + . ', specify the length explicitly.', ); } @@ -1004,9 +1004,9 @@ public function getDummySelectSQL() /** * {@inheritDoc} * - * DB2 supports savepoints, but they work semantically different than on other vendor platforms. + * Db2 supports savepoints, but they work semantically different than on other vendor platforms. * - * TODO: We have to investigate how to get DB2 up and running with savepoints. + * TODO: We have to investigate how to get Db2 up and running with savepoints. */ public function supportsSavepoints() { diff --git a/doctrine/dbal/src/Platforms/Keywords/DB2Keywords.php b/doctrine/dbal/src/Platforms/Keywords/DB2Keywords.php index d5dbbd734..9e3ab367d 100644 --- a/doctrine/dbal/src/Platforms/Keywords/DB2Keywords.php +++ b/doctrine/dbal/src/Platforms/Keywords/DB2Keywords.php @@ -5,7 +5,7 @@ use Doctrine\Deprecations\Deprecation; /** - * DB2 Keywords. + * Db2 Keywords. */ class DB2Keywords extends KeywordList { diff --git a/doctrine/dbal/src/Schema/DB2SchemaManager.php b/doctrine/dbal/src/Schema/DB2SchemaManager.php index a07136fec..8f6e55f92 100644 --- a/doctrine/dbal/src/Schema/DB2SchemaManager.php +++ b/doctrine/dbal/src/Schema/DB2SchemaManager.php @@ -21,7 +21,7 @@ use const CASE_LOWER; /** - * IBM Db2 Schema Manager. + * Db2 Schema Manager. * * @extends AbstractSchemaManager */ diff --git a/doctrine/dbal/src/Schema/Visitor/DropSchemaSqlCollector.php b/doctrine/dbal/src/Schema/Visitor/DropSchemaSqlCollector.php index ddec6b4ae..d746b2aee 100644 --- a/doctrine/dbal/src/Schema/Visitor/DropSchemaSqlCollector.php +++ b/doctrine/dbal/src/Schema/Visitor/DropSchemaSqlCollector.php @@ -42,7 +42,7 @@ public function __construct(AbstractPlatform $platform) */ public function acceptTable(Table $table) { - $this->tables->attach($table); + $this->tables->offsetSet($table); } /** @@ -54,7 +54,7 @@ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkCons throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint); } - $this->constraints->attach($fkConstraint, $localTable); + $this->constraints->offsetSet($fkConstraint, $localTable); } /** @@ -62,7 +62,7 @@ public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkCons */ public function acceptSequence(Sequence $sequence) { - $this->sequences->attach($sequence); + $this->sequences->offsetSet($sequence); } /** @return void */ diff --git a/doctrine/event-manager/src/EventArgs.php b/doctrine/event-manager/src/EventArgs.php index 4795ba6be..eea3d8a0a 100644 --- a/doctrine/event-manager/src/EventArgs.php +++ b/doctrine/event-manager/src/EventArgs.php @@ -15,10 +15,8 @@ class EventArgs { /** * Single instance of EventArgs. - * - * @var EventArgs|null */ - private static $_emptyEventArgsInstance; + private static EventArgs|null $emptyEventArgsInstance = null; /** * Gets the single, empty and immutable EventArgs instance. @@ -31,15 +29,9 @@ class EventArgs * * @link https://msdn.microsoft.com/en-us/library/system.eventargs.aspx * @see EventManager::dispatchEvent - * - * @return EventArgs */ - public static function getEmptyInstance() + public static function getEmptyInstance(): EventArgs { - if (! self::$_emptyEventArgsInstance) { - self::$_emptyEventArgsInstance = new EventArgs(); - } - - return self::$_emptyEventArgsInstance; + return self::$emptyEventArgsInstance ??= new EventArgs(); } } diff --git a/doctrine/event-manager/src/EventManager.php b/doctrine/event-manager/src/EventManager.php index 6d841be27..86f5e4536 100644 --- a/doctrine/event-manager/src/EventManager.php +++ b/doctrine/event-manager/src/EventManager.php @@ -1,8 +1,8 @@ */ - private $listeners = []; + private array $listeners = []; /** * Dispatches an event to all registered listeners. @@ -28,16 +28,14 @@ class EventManager * the name of the method that is invoked on listeners. * @param EventArgs|null $eventArgs The event arguments to pass to the event handlers/listeners. * If not supplied, the single empty EventArgs instance is used. - * - * @return void */ - public function dispatchEvent($eventName, ?EventArgs $eventArgs = null) + public function dispatchEvent(string $eventName, EventArgs|null $eventArgs = null): void { if (! isset($this->listeners[$eventName])) { return; } - $eventArgs = $eventArgs ?? EventArgs::getEmptyInstance(); + $eventArgs ??= EventArgs::getEmptyInstance(); foreach ($this->listeners[$eventName] as $listener) { $listener->$eventName($eventArgs); @@ -47,24 +45,12 @@ public function dispatchEvent($eventName, ?EventArgs $eventArgs = null) /** * Gets the listeners of a specific event. * - * @param string|null $event The name of the event. + * @param string $event The name of the event. * - * @return object[]|array The event listeners for the specified event, or all event listeners. - * @psalm-return ($event is null ? array : object[]) + * @return object[] */ - public function getListeners($event = null) + public function getListeners(string $event): array { - if ($event === null) { - Deprecation::trigger( - 'doctrine/event-manager', - 'https://github.com/doctrine/event-manager/pull/50', - 'Calling %s without an event name is deprecated. Call getAllListeners() instead.', - __METHOD__ - ); - - return $this->getAllListeners(); - } - return $this->listeners[$event] ?? []; } @@ -80,12 +66,8 @@ public function getAllListeners(): array /** * Checks whether an event has any registered listeners. - * - * @param string $event - * - * @return bool TRUE if the specified event has any listeners, FALSE otherwise. */ - public function hasListeners($event) + public function hasListeners(string $event): bool { return ! empty($this->listeners[$event]); } @@ -95,10 +77,8 @@ public function hasListeners($event) * * @param string|string[] $events The event(s) to listen on. * @param object $listener The listener object. - * - * @return void */ - public function addEventListener($events, $listener) + public function addEventListener(string|array $events, object $listener): void { // Picks the hash code related to that listener $hash = spl_object_hash($listener); @@ -114,11 +94,8 @@ public function addEventListener($events, $listener) * Removes an event listener from the specified events. * * @param string|string[] $events - * @param object $listener - * - * @return void */ - public function removeEventListener($events, $listener) + public function removeEventListener(string|array $events, object $listener): void { // Picks the hash code related to that listener $hash = spl_object_hash($listener); @@ -129,27 +106,23 @@ public function removeEventListener($events, $listener) } /** - * Adds an EventSubscriber. The subscriber is asked for all the events it is - * interested in and added as a listener for these events. + * Adds an EventSubscriber. * - * @param EventSubscriber $subscriber The subscriber. - * - * @return void + * The subscriber is asked for all the events it is interested in and added + * as a listener for these events. */ - public function addEventSubscriber(EventSubscriber $subscriber) + public function addEventSubscriber(EventSubscriber $subscriber): void { $this->addEventListener($subscriber->getSubscribedEvents(), $subscriber); } /** - * Removes an EventSubscriber. The subscriber is asked for all the events it is - * interested in and removed as a listener for these events. - * - * @param EventSubscriber $subscriber The subscriber. + * Removes an EventSubscriber. * - * @return void + * The subscriber is asked for all the events it is interested in and removed + * as a listener for these events. */ - public function removeEventSubscriber(EventSubscriber $subscriber) + public function removeEventSubscriber(EventSubscriber $subscriber): void { $this->removeEventListener($subscriber->getSubscribedEvents(), $subscriber); }