From 7ba0c6a6b415ab7f451446f0d67ca91edf93859b Mon Sep 17 00:00:00 2001 From: Christian Krzeminski Date: Wed, 3 Jul 2024 11:05:15 +0200 Subject: [PATCH] chore: code-style --- .code-quality/phpstan-baseline.neon | 4 ++++ Classes/System/Restler/Builder.php | 28 +++------------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.code-quality/phpstan-baseline.neon b/.code-quality/phpstan-baseline.neon index 56f33dc..085696e 100644 --- a/.code-quality/phpstan-baseline.neon +++ b/.code-quality/phpstan-baseline.neon @@ -48,3 +48,7 @@ parameters: message: "#^Interface (.*) has only single implementer. Consider using the class directly as there is no point in using the interface.$#" count: 1 path: ../Classes/System/Restler/ConfigurationInterface.php + - + message: "#^Unable to resolve the template type T in call to method static method (.*)$#" + count: 2 + path: ../Classes/System/Restler/Builder.php diff --git a/Classes/System/Restler/Builder.php b/Classes/System/Restler/Builder.php index c23b1bb..3d1ad0a 100644 --- a/Classes/System/Restler/Builder.php +++ b/Classes/System/Restler/Builder.php @@ -28,7 +28,6 @@ use Aoe\Restler\Configuration\ExtensionConfiguration; use Aoe\Restler\System\TYPO3\Cache; -use Error; use InvalidArgumentException; use Luracast\Restler\Defaults; use Luracast\Restler\Scope; @@ -37,7 +36,6 @@ use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; class Builder implements SingletonInterface { @@ -139,32 +137,12 @@ private function addApiClassesByGlobalArray(RestlerExtended $restler): void } /** - * use auto-loading for PHP-classes of restler-framework and Extbase/TYPO3 (use dependency-injection of Extbase) + * use autoload for PHP-classes of restler-framework and Extbase/TYPO3 (use dependency-injection of Extbase) */ private function setAutoLoading(): void { - // set auto-loading for Extbase/TYPO3-classes - Scope::$resolver = static function ($className) { - try { - return GeneralUtility::makeInstance($className); - } catch (Error $error) { - // @TODO TYPO3 v12: - // Using of ObjectManager will be removed in TYPO3v12. Currently, we must use the ObjectManager - // as a fallback because it can happen, that e.g. the REST-controllers (which 3rd-party-extensions - // provide), are not supporting the new dependency-injection (via symfony) of TYPO3! - - // Log deprecation-notice - $info = '%s should implement TYPO3\CMS\Core\SingletonInterface - otherwise the class can '; - $info .= 'not be created by GeneralUtility::makeInstance() in TYPO3v12 (error-code: %s)!'; - trigger_error( - sprintf($info, $className, (string) $error->getCode()), - E_USER_DEPRECATED - ); - - // use legacy ObjectManager to create the required object - return GeneralUtility::makeInstance(ObjectManager::class)->get($className); - } - }; + // set autoload for Extbase/TYPO3-classes + Scope::$resolver = static fn ($className): object => GeneralUtility::makeInstance($className); } /**