diff --git a/typo3/sysext/form/Classes/Domain/Model/FormElements/AbstractFormElement.php b/typo3/sysext/form/Classes/Domain/Model/FormElements/AbstractFormElement.php index 7820f830b069..c68db7d8e199 100644 --- a/typo3/sysext/form/Classes/Domain/Model/FormElements/AbstractFormElement.php +++ b/typo3/sysext/form/Classes/Domain/Model/FormElements/AbstractFormElement.php @@ -147,7 +147,7 @@ public function isRequired(): bool */ public function setProperty(string $key, $value) { - if (is_array($value) && is_array($this->properties[$key])) { + if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) { ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value); } else { $this->properties[$key] = $value; diff --git a/typo3/sysext/form/Classes/Domain/Model/FormElements/Section.php b/typo3/sysext/form/Classes/Domain/Model/FormElements/Section.php index 5c237b93d6ad..cb2484dea605 100644 --- a/typo3/sysext/form/Classes/Domain/Model/FormElements/Section.php +++ b/typo3/sysext/form/Classes/Domain/Model/FormElements/Section.php @@ -117,7 +117,7 @@ public function getProperties(): array */ public function setProperty(string $key, $value) { - if (is_array($value) && is_array($this->properties[$key])) { + if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) { ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value); } else { $this->properties[$key] = $value; diff --git a/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php b/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php index 29711ea676a8..9170bdd38fcc 100644 --- a/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php +++ b/typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php @@ -13,15 +13,10 @@ */ class AbstractFormElementTest extends UnitTestCase { - /** - * Subject is not notice free, disable E_NOTICES - */ - protected static $suppressNotices = true; - /** * @test */ - public function newInstanceHasNoProperties() + public function newInstanceHasNoProperties(): void { /** @var AbstractFormElement $subject */ $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']); @@ -32,7 +27,7 @@ public function newInstanceHasNoProperties() /** * @test */ - public function setSimpleProperties() + public function setSimpleProperties(): void { /** @var AbstractFormElement $subject */ $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']); @@ -51,7 +46,7 @@ public function setSimpleProperties() /** * @test */ - public function overrideProperties() + public function overrideProperties(): void { /** @var AbstractFormElement $subject */ $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']); @@ -60,7 +55,7 @@ public function overrideProperties() $subject->setProperty('foo', 'buz'); $properties = $subject->getProperties(); - $this->assertEquals(1, count($properties)); + $this->assertEquals(1, \count($properties)); $this->assertTrue(array_key_exists('foo', $properties)); $this->assertEquals('buz', $properties['foo']); } @@ -68,7 +63,7 @@ public function overrideProperties() /** * @test */ - public function setArrayProperties() + public function setArrayProperties(): void { /** @var AbstractFormElement $subject */ $subject = $this->getMockForAbstractClass(AbstractFormElement::class, ['an_id', 'a_type']); @@ -80,7 +75,7 @@ public function setArrayProperties() $this->assertTrue(array_key_exists('foo', $properties)); //check arrays details - $this->assertTrue(is_array($properties['foo'])); + $this->assertTrue(\is_array($properties['foo'])); $this->assertCount(2, $properties['foo']); $this->assertTrue(array_key_exists('bar', $properties['foo'])); $this->assertEquals('baz', $properties['foo']['bar']); @@ -89,7 +84,7 @@ public function setArrayProperties() /** * @test */ - public function constructThrowsExceptionWhenIdentifierIsEmpty() + public function constructThrowsExceptionWhenIdentifierIsEmpty(): void { $this->expectException(IdentifierNotValidException::class); $this->expectExceptionCode(1477082502); @@ -108,7 +103,7 @@ public function constructThrowsExceptionWhenIdentifierIsEmpty() /** * @test */ - public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString() + public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString(): void { $mock = $this->getAccessibleMockForAbstractClass( AbstractFormElement::class, @@ -125,7 +120,7 @@ public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString() /** * @test */ - public function initializeFormElementExpectedCallInitializeFormObjectHooks() + public function initializeFormElementExpectedCallInitializeFormObjectHooks(): void { /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock */ $abstractFormElementMock = $this->getAccessibleMockForAbstractClass( @@ -155,10 +150,10 @@ public function initializeFormElementExpectedCallInitializeFormObjectHooks() ->method('initializeFormElement') ->with($abstractFormElementMock); - GeneralUtility::addInstance(get_class($secondMock), $secondMock); + GeneralUtility::addInstance(\get_class($secondMock), $secondMock); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] = [ - get_class($secondMock) + \get_class($secondMock) ]; $abstractFormElementMock->initializeFormElement(); @@ -167,7 +162,7 @@ public function initializeFormElementExpectedCallInitializeFormObjectHooks() /** * @test */ - public function getUniqueIdentifierExpectedUnique() + public function getUniqueIdentifierExpectedUnique(): void { /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock1 */ $abstractFormElementMock1 = $this->getAccessibleMockForAbstractClass( diff --git a/typo3/sysext/form/Tests/Unit/Domain/FormElements/SectionTest.php b/typo3/sysext/form/Tests/Unit/Domain/FormElements/SectionTest.php index 629676f57878..fd48763fba00 100644 --- a/typo3/sysext/form/Tests/Unit/Domain/FormElements/SectionTest.php +++ b/typo3/sysext/form/Tests/Unit/Domain/FormElements/SectionTest.php @@ -1,20 +1,17 @@ assertNotNull($this->sectionInstance); $this->assertCount(0, $this->sectionInstance->getProperties()); @@ -45,7 +42,7 @@ public function newInstanceHasNoProperties() /** * @test */ - public function setSimpleProperties() + public function setSimpleProperties(): void { $this->sectionInstance->setProperty('foo', 'bar'); $this->sectionInstance->setProperty('buz', 'qax'); @@ -61,13 +58,13 @@ public function setSimpleProperties() /** * @test */ - public function overrideProperties() + public function overrideProperties(): void { $this->sectionInstance->setProperty('foo', 'bar'); $this->sectionInstance->setProperty('foo', 'buz'); $properties = $this->sectionInstance->getProperties(); - $this->assertEquals(1, count($properties)); + $this->assertEquals(1, \count($properties)); $this->assertTrue(array_key_exists('foo', $properties)); $this->assertEquals('buz', $properties['foo']); } @@ -75,7 +72,7 @@ public function overrideProperties() /** * @test */ - public function setArrayProperties() + public function setArrayProperties(): void { $this->sectionInstance->setProperty('foo', ['bar' => 'baz', 'bla' => 'blubb']); $properties = $this->sectionInstance->getProperties(); @@ -84,7 +81,7 @@ public function setArrayProperties() $this->assertTrue(array_key_exists('foo', $properties)); //check arrays details - $this->assertTrue(is_array($properties['foo'])); + $this->assertTrue(\is_array($properties['foo'])); $this->assertCount(2, $properties['foo']); $this->assertTrue(array_key_exists('bar', $properties['foo'])); $this->assertEquals('baz', $properties['foo']['bar']);