Revert "[TASK] Let GeneralUtility::makeInstance() throw exception on unknown class" 10/54010/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 8 Sep 2017 10:14:36 +0000 (12:14 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 8 Sep 2017 12:10:31 +0000 (14:10 +0200)
This reverts commit 4bc4fb0273cb1b2cbdb025558b5c3ae9d76b0394.

The patch turned a PHP \Error into \Exception, which adds no value,
but can be misleading.

Change-Id: I6cc32da6c0620cb0d717c930d10fa4338d6cefac
Releases: master, 8.7
Resolves: #82131
Reverts: #82131
Reviewed-on: https://review.typo3.org/54004
Reviewed-on: https://review.typo3.org/54010
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index 0b2a540..e11f354 100644 (file)
@@ -3897,9 +3897,6 @@ class GeneralUtility
         ) {
             return array_shift(self::$nonSingletonInstances[$finalClassName]);
         }
-        if (!class_exists($finalClassName)) {
-            throw new \InvalidArgumentException('Class "' . $className . '" not found', 1503060454);
-        }
         // Create new instance and call constructor with parameters
         $instance = new $finalClassName(...$constructorArguments);
         // Register new singleton instance
index ae91720..08ad677 100644 (file)
@@ -4003,31 +4003,6 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function makeInstanceWithUnknownClassThrowsException()
-    {
-        $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionCode(1503060454);
-
-        GeneralUtility::makeInstance('UnknownClass' . time());
-    }
-
-    /**
-     * @test
-     */
-    public function makeInstanceWithUnknownClassImplementationThrowsException()
-    {
-        $this->expectException(\InvalidArgumentException::class);
-        $this->expectExceptionCode(1503060454);
-
-        GeneralUtilityFixture::resetFinalClassNameCache();
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => 'UnknownClass' . time()];
-
-        GeneralUtility::makeInstance(OriginalClassFixture::class);
-    }
-
-    /**
-     * @test
-     */
     public function makeInstanceWithBeginningSlashInClassNameThrowsException()
     {
         $this->expectException(\InvalidArgumentException::class);