diff --git a/CHANGELOG.md b/CHANGELOG.md index cbb642e..9dacf99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Latest ------ ## Changes +* [#156](https://github.com/cleverage/ui-process-bundle/issues/156) `LogRecord::contextIsEmpty()` (deprecated since v3.1, use `hasContextInfo()`) triggers a deprecation at runtime with `trigger_deprecation()` (`symfony/deprecation-contracts`, now required). Add tests. * [#154](https://github.com/cleverage/ui-process-bundle/issues/154) Add a `.gitattributes`: the development files (`.docker/`, `.github/`, `tests/`, quality tools and PHPUnit configurations, `Makefile`) are no longer part of the archive installed by Composer (`dist`), remove the unused `package.json` (Webpack Encore leftover of the Symfony skeleton: no `webpack.config.js`, no `assets/`). * [#149](https://github.com/cleverage/ui-process-bundle/issues/149) Clean up composer.json: remove the unused `symfony/dotenv`, `symfony/runtime`, `ext-ctype` and `ext-iconv` requirements (applications relying on the bundle to install `symfony/dotenv` / `symfony/runtime` must require them, as the Symfony skeleton does); replace `doctrine/common` by `doctrine/collections` (only `ArrayCollection` is used); require `twig/twig`, `symfony/twig-bundle`, `psr/log`, `doctrine/persistence`, `doctrine/migrations` and `symfony/event-dispatcher-contracts`, used directly but only installed transitively; add `twig/extra-bundle` and `symfony/property-access` (used by the tests) to the dev requirements. * [#150](https://github.com/cleverage/ui-process-bundle/issues/150) Require `symfony/monolog-bundle` and `monolog/monolog`, used directly by the bundle (log handlers, `monolog` configuration prepended, `monolog.logger` tags) but only installed through `cleverage/process-bundle`, which may stop requiring MonologBundle (cleverage/process-bundle#269). diff --git a/composer.json b/composer.json index 80d83b9..570028c 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,7 @@ "symfony/config": "^6.4 || ^7.4 || ^8", "symfony/console": "^6.4 || ^7.4 || ^8", "symfony/dependency-injection": "^6.4 || ^7.4 || ^8", + "symfony/deprecation-contracts": "^2.5 || ^3", "symfony/doctrine-messenger": "^6.4 || ^7.4 || ^8", "symfony/event-dispatcher": "^6.4 || ^7.4 || ^8", "symfony/event-dispatcher-contracts": "^3", diff --git a/src/Entity/LogRecord.php b/src/Entity/LogRecord.php index a5df596..0efd67b 100644 --- a/src/Entity/LogRecord.php +++ b/src/Entity/LogRecord.php @@ -74,6 +74,8 @@ public function hasContextInfo(): bool */ public function contextIsEmpty(): bool { + trigger_deprecation('cleverage/ui-process-bundle', '3.1', 'The "%s()" method is deprecated, use "hasContextInfo()" instead.', __METHOD__); + return $this->hasContextInfo(); } diff --git a/tests/Entity/LogRecordTest.php b/tests/Entity/LogRecordTest.php index fb06144..c60f76d 100644 --- a/tests/Entity/LogRecordTest.php +++ b/tests/Entity/LogRecordTest.php @@ -41,9 +41,22 @@ public function testContextIsReadableByThePropertyAccessor(): void public function testDeprecatedContextIsEmptyIsUnchanged(): void { - // Misnamed: returns true when the context is NOT empty - self::assertTrue($this->createLogRecord(['file' => 'a.txt'])->contextIsEmpty()); - self::assertFalse($this->createLogRecord([])->contextIsEmpty()); + $deprecations = []; + set_error_handler(static function (int $errno, string $errstr) use (&$deprecations): bool { + $deprecations[] = $errstr; + + return true; + }, \E_USER_DEPRECATED); + try { + // Misnamed: returns true when the context is NOT empty + self::assertTrue($this->createLogRecord(['file' => 'a.txt'])->contextIsEmpty()); + self::assertFalse($this->createLogRecord([])->contextIsEmpty()); + } finally { + restore_error_handler(); + } + + $expected = 'Since cleverage/ui-process-bundle 3.1: The "CleverAge\\UiProcessBundle\\Entity\\LogRecord::contextIsEmpty()" method is deprecated, use "hasContextInfo()" instead.'; + self::assertSame([$expected, $expected], $deprecations); } public function testAccessors(): void