diff --git a/.gitignore b/.gitignore index 19982ea..209d67e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ composer.lock -vendor \ No newline at end of file +vendor +.idea + +.phpunit.result.cache +.phpunit.cache + +.phpstan +.php-cs-fixer.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..50eee83 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,14 @@ +in(__DIR__.'/src') + ->in(__DIR__.'/test') + ->exclude('vendor'); + +$config = new PhpCsFixer\Config(); + +return $config->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setFinder($finder); diff --git a/.travis.yml b/.travis.yml index a04b9d5..8a53b0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,22 +13,22 @@ env: matrix: include: - - php: 7.2 + - php: 8.1 env: - DEPS=lowest - - php: 7.2 + - php: 8.1 env: - DEPS=latest - - php: 7.3 + - php: 8.2 env: - DEPS=lowest - - php: 7.3 + - php: 8.2 env: - DEPS=latest - - php: 7.4 + - php: 8.3 env: - DEPS=lowest - - php: 7.4 + - php: 8.3 env: - DEPS=latest @@ -49,4 +49,4 @@ after_script: - if [[ $TEST_COVERAGE == 'true' ]]; then vendor/bin/php-coveralls -v ; fi notifications: - email: false \ No newline at end of file + email: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e4ce528 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +## 2.0.0 +* [TASK][CRM-63243](https://jira.trans.eu/browse/CRM-63243) Adjust code for php ^8.1 diff --git a/composer.json b/composer.json index ea6e63d..a5eb5ef 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,25 @@ { "name": "rstgroup/object-builder", "description": "Dynamic build of object", + "version": "2.0.0", "license": "MIT", "keywords": [], + "authors": [ + { + "name": "Team ABW", + "email": "abw@rst.com.pl" + } + ], "require": { - "php": "^7.2", - "phpstan/phpdoc-parser": "^0.3.0 || ^0.4.0 || ^0.5.0", - "roave/better-reflection": "^3.0 || ^4.0" + "php": "^8.1", + "phpstan/phpdoc-parser": "^1.29.0", + "roave/better-reflection": "~6.25.0" }, "require-dev": { - "phpunit/phpunit": "^7.2" + "friendsofphp/php-cs-fixer": "^3.58", + "phpstan/phpstan": "^1.11", + "phpunit/phpunit": "^10.0.0", + "rector/rector": "^1.1" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..bd143ab --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 6 + tmpDir: .phpstan + paths: + - src + - test diff --git a/phpunit.xml b/phpunit.xml index 2db3447..9e559d4 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,29 +1,26 @@ - + - - - - test/unit/ - - - - - - src - - test - - - - - \ No newline at end of file + cacheDirectory=".phpunit.cache" + backupStaticProperties="false" +> + + + test/unit/ + + + + + src + + + test + + + diff --git a/rector.php b/rector.php new file mode 100755 index 0000000..3575543 --- /dev/null +++ b/rector.php @@ -0,0 +1,32 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/test', + ]); + + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_81, + ]); + + $rectorConfig->import(SetList::CODE_QUALITY); + $rectorConfig->import(SetList::TYPE_DECLARATION); + $rectorConfig->import(SetList::CODING_STYLE); + + $rectorConfig->sets([ + PHPUnitSetList::PHPUNIT_70, + PHPUnitSetList::PHPUNIT_80, + PHPUnitSetList::PHPUNIT_90, + PHPUnitSetList::PHPUNIT_100, + PHPUnitSetList::PHPUNIT_CODE_QUALITY, + ]); + +}; diff --git a/src/Builder.php b/src/Builder.php index fee1b06..996f754 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -1,8 +1,15 @@ -parameterNameStrategy = $parameterNameStrategy; } /** - * @param mixed[] $data * @throws BuilderException */ public function build(string $class, array $data): object @@ -34,18 +35,18 @@ public function build(string $class, array $data): object try { $classReflection = new ReflectionClass($class); - /** @var ReflectionMethod $constructorMethod */ + /** @var ReflectionMethod|null $constructor */ $constructor = $classReflection->getConstructor(); $parameters = iterator_to_array($this->collect($constructor, $data)); return new $class(...$parameters); - } catch (Throwable $exception) { - throw new BuilderException('Cant build object', 0, $exception); + } catch (Throwable $throwable) { + throw new BuilderException('Cant build object', 0, $throwable); } } - private function collect(ReflectionMethod $constructor, array $data): iterable + private function collect(ReflectionMethod $constructor, array $data): Iterator { foreach ($constructor->getParameters() as $parameter) { $name = $parameter->getName(); @@ -84,17 +85,19 @@ private function parameterDataIsInData(string $parameterName, array $data): bool } /** - * @param mixed $data - * @return mixed + * @throws BuilderException + * @throws ReflectionException */ - private function buildParameter(ReflectionParameter $parameter, $data, ReflectionMethod $constructor) + private function buildParameter(ReflectionParameter $parameter, mixed $data, ReflectionMethod $constructor): mixed { - $class = $parameter->getClass(); + $parameterType = $parameter->getType(); + + if ($parameterType instanceof ReflectionNamedType && !$parameterType->isBuiltin()) { + $parameterClass = new ReflectionClass($parameterType->getName()); - if (null !== $class) { - $name = $class->getName(); + $name = $parameterClass->getName(); /** @var ReflectionMethod $constructorMethod */ - $constructorMethod = $class->getConstructor(); + $constructorMethod = $parameterClass->getConstructor(); $parameters = []; if (null !== $constructorMethod) { @@ -104,7 +107,7 @@ private function buildParameter(ReflectionParameter $parameter, $data, Reflectio return new $name(...$parameters); } - if ($parameter->isArray()) { + if ($parameterType instanceof ReflectionNamedType && $parameterType->getName() === 'array') { $parser = new PhpDocParser(new TypeParser(), new ConstExprParser()); $node = $parser->parse(new TokenIterator((new Lexer())->tokenize($constructor->getDocComment()))); foreach ($node->getParamTagValues() as $node) { @@ -113,6 +116,7 @@ private function buildParameter(ReflectionParameter $parameter, $data, Reflectio if ($this->isScalar($typeName)) { continue; } + $list = []; $parser = (new BetterReflection())->phpParser(); @@ -122,7 +126,7 @@ private function buildParameter(ReflectionParameter $parameter, $data, Reflectio $uses = $this->getUseStmts($namespace); $namespaces = $this->getUsesNamespaces($uses); - foreach($data as $objectConstructorData) { + foreach ($data as $objectConstructorData) { $list[] = $this->build( $this->getFullClassName($typeName, $namespaces, $constructor->getDeclaringClass()), $objectConstructorData @@ -170,7 +174,7 @@ private function getUseStmts(Stmt\Namespace_ $node): array $uses = []; foreach ($node->stmts as $node) { if ($node instanceof Stmt\Use_) { - $uses[]= $node; + $uses[] = $node; } } @@ -197,7 +201,7 @@ private function getFullClassName(string $name, array $namespaces, ReflectionCla return $name; } - if (0 === count($namespaces)) { + if ([] === $namespaces) { return $class->getNamespaceName() . '\\' . $name; } diff --git a/src/BuilderException.php b/src/BuilderException.php index 5bee453..82042e2 100644 --- a/src/BuilderException.php +++ b/src/BuilderException.php @@ -1,4 +1,6 @@ -list1 = $list1; - $this->list2 = $list2; } } diff --git a/test/ListOfObjectsWithScalarTypedArrayConstructor.php b/test/ListOfObjectsWithScalarTypedArrayConstructor.php index ed7b41c..ef6da7c 100644 --- a/test/ListOfObjectsWithScalarTypedArrayConstructor.php +++ b/test/ListOfObjectsWithScalarTypedArrayConstructor.php @@ -1,19 +1,16 @@ -list1 = $list1; - $this->list2 = $list2; } } diff --git a/test/ListOfObjectsWithUseStmtConstructor.php b/test/ListOfObjectsWithUseStmtConstructor.php index 7fac801..60f2975 100644 --- a/test/ListOfObjectsWithUseStmtConstructor.php +++ b/test/ListOfObjectsWithUseStmtConstructor.php @@ -1,21 +1,24 @@ -list = $list; $this->object = new SomeObject(); } } diff --git a/test/ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor.php b/test/ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor.php index 1aeabf4..9aeeac1 100644 --- a/test/ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor.php +++ b/test/ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor.php @@ -1,16 +1,17 @@ -list = $list; } } diff --git a/test/ListOfObjectsWithoutUseStmtConstructor.php b/test/ListOfObjectsWithoutUseStmtConstructor.php index 38db6b5..ce51c72 100644 --- a/test/ListOfObjectsWithoutUseStmtConstructor.php +++ b/test/ListOfObjectsWithoutUseStmtConstructor.php @@ -1,16 +1,15 @@ -list = $list; } } diff --git a/test/Object/SomeObject.php b/test/Object/SomeObject.php index 59e8e8c..2b6390a 100644 --- a/test/Object/SomeObject.php +++ b/test/Object/SomeObject.php @@ -1,4 +1,6 @@ -someString = $someString; - $this->someInt = $someInt; - $this->someObject = $someObject; } } diff --git a/test/SimpleMixedConstructorWithDefaultValue.php b/test/SimpleMixedConstructorWithDefaultValue.php index d44b028..0ff92d6 100644 --- a/test/SimpleMixedConstructorWithDefaultValue.php +++ b/test/SimpleMixedConstructorWithDefaultValue.php @@ -1,20 +1,15 @@ -someString = $someString; - $this->someInt = $someInt; - $this->someObject = $someObject; } } diff --git a/test/SimpleNullableConstructor.php b/test/SimpleNullableConstructor.php index c9b4416..b146db6 100644 --- a/test/SimpleNullableConstructor.php +++ b/test/SimpleNullableConstructor.php @@ -1,17 +1,12 @@ -someInt = $someInt; - $this->someString1 = $someString1; - $this->someString2 = $someString2; } } diff --git a/test/SimpleScalarConstructor.php b/test/SimpleScalarConstructor.php index d0927c4..f41236a 100644 --- a/test/SimpleScalarConstructor.php +++ b/test/SimpleScalarConstructor.php @@ -1,15 +1,12 @@ -someString = $someString; - $this->someInt = $someInt; } } diff --git a/test/SomeAggregateRoot.php b/test/SomeAggregateRoot.php index ab48e11..1fdb0f7 100644 --- a/test/SomeAggregateRoot.php +++ b/test/SomeAggregateRoot.php @@ -1,23 +1,16 @@ -someString = $someString; - $this->simpleObject1 = $simpleObject1; - $this->simpleObject2 = $simpleObject2; - $this->someInt = $someInt; } } diff --git a/test/SomeObjectWithEmptyConstructor.php b/test/SomeObjectWithEmptyConstructor.php index 05795b1..6664196 100644 --- a/test/SomeObjectWithEmptyConstructor.php +++ b/test/SomeObjectWithEmptyConstructor.php @@ -1,8 +1,9 @@ -strategy = new Simple(); } - /** - * @test - * @dataProvider validStrings - */ - public function simpleStrategyReturnTrueForStringsWithoutUnderscoreMinusAndSpace(string $string) + #[DataProvider('validStrings')] + #[Test] + public function simpleStrategyReturnTrueForStringsWithoutUnderscoreMinusAndSpace(string $string): void { - $isFulfilled = static::$strategy->isFulfilled($string); + $isFulfilled = $this->strategy->isFulfilled($string); $this->assertTrue($isFulfilled); } - /** - * @test - * @dataProvider invalidStrings - */ - public function simpleStrategyReturnFalseForStringsWitUnderscoreOrMinusOrSpace(string $string) + #[DataProvider('invalidStrings')] + #[Test] + public function simpleStrategyReturnFalseForStringsWitUnderscoreOrMinusOrSpace(string $string): void { - $isFulfilled = static::$strategy->isFulfilled($string); + $isFulfilled = $this->strategy->isFulfilled($string); $this->assertFalse($isFulfilled); } - /** @test */ - public function simpleStrategyReturnGivenParameterWithoutModification() + #[Test] + public function simpleStrategyReturnGivenParameterWithoutModification(): void { - $string = static::$strategy->getName('simpleCamelCase'); + $string = $this->strategy->getName('simpleCamelCase'); $this->assertSame('simpleCamelCase', $string); } - /** @return string[][] */ - public function validStrings(): array + public static function validStrings(): Iterator { - return [ - 'simple string' => ['string'], - 'camelCase string' => ['validString'], - 'string with number' => ['valid1'], - 'camelCase with number' => ['validString123String'], - ]; + yield 'simple string' => ['string']; + yield 'camelCase string' => ['validString']; + yield 'string with number' => ['valid1']; + yield 'camelCase with number' => ['validString123String']; } - /** @return string[][] */ - public function invalidStrings(): array + public static function invalidStrings(): Iterator { - return [ - 'string with space' => ['string string'], - 'string with underscore' => ['string_string'], - 'string with minus' => ['string-string'], - ]; + yield 'string with space' => ['string string']; + yield 'string with underscore' => ['string_string']; + yield 'string with minus' => ['string-string']; } } diff --git a/test/unit/Builder/ParameterNameStrategy/SnakeCaseTest.php b/test/unit/Builder/ParameterNameStrategy/SnakeCaseTest.php index ac8ec64..c66cfd1 100644 --- a/test/unit/Builder/ParameterNameStrategy/SnakeCaseTest.php +++ b/test/unit/Builder/ParameterNameStrategy/SnakeCaseTest.php @@ -1,67 +1,60 @@ -strategy = new SnakeCase(); } - /** - * @test - * @dataProvider validStrings - */ - public function snakeCaseStrategyReturnTrueForStringsOnlyInSneakCaseFormat(string $string) + #[DataProvider('validStrings')] + #[Test] + public function snakeCaseStrategyReturnTrueForStringsOnlyInSneakCaseFormat(string $string): void { - $isFulfilled = static::$strategy->isFulfilled($string); + $isFulfilled = $this->strategy->isFulfilled($string); $this->assertTrue($isFulfilled); } - /** - * @test - * @dataProvider invalidStrings - */ - public function snakeCaseStrategyReturnFalseForStringsWitUnderscoreOrSpace(string $string) + #[DataProvider('invalidStrings')] + #[Test] + public function snakeCaseStrategyReturnFalseForStringsWitUnderscoreOrSpace(string $string): void { - $isFulfilled = static::$strategy->isFulfilled($string); + $isFulfilled = $this->strategy->isFulfilled($string); $this->assertFalse($isFulfilled); } - /** @test */ - public function snakeCaseStrategyReturnGivenParameterAsCamelCase() + #[Test] + public function snakeCaseStrategyReturnGivenParameterAsCamelCase(): void { - $string = static::$strategy->getName('simple_snake_case'); + $string = $this->strategy->getName('simple_snake_case'); $this->assertSame('simpleSnakeCase', $string); } - /** @return string[][] */ - public function validStrings(): array + public static function validStrings(): Iterator { - return [ - 'simple string' => ['string'], - 'sneak case string' => ['valid_string'], - 'sneak case string with number' => ['valid_string_1'], - ]; + yield 'simple string' => ['string']; + yield 'sneak case string' => ['valid_string']; + yield 'sneak case string with number' => ['valid_string_1']; } - /** @return string[][] */ - public function invalidStrings(): array + public static function invalidStrings(): Iterator { - return [ - 'string with space' => ['string string'], - 'string with minus' => ['string-string'], - ]; + yield 'string with space' => ['string string']; + yield 'string with minus' => ['string-string']; } } diff --git a/test/unit/Builder/ReflectionTest.php b/test/unit/Builder/ReflectionTest.php index 0b48bce..2619a29 100644 --- a/test/unit/Builder/ReflectionTest.php +++ b/test/unit/Builder/ReflectionTest.php @@ -1,7 +1,10 @@ -builder = new Reflection(new Simple()); } - /** @test */ - public function iCanBuildSimpleObjectWithScalarValuesInConstructor() + #[Test] + public function iCanBuildSimpleObjectWithScalarValuesInConstructor(): void { $data = [ 'someString' => 'some string', @@ -39,15 +41,15 @@ public function iCanBuildSimpleObjectWithScalarValuesInConstructor() $class = SimpleScalarConstructor::class; /** @var SimpleScalarConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(SimpleScalarConstructor::class, $object); $this->assertSame('some string', $object->someString); $this->assertSame(999, $object->someInt); } - /** @test */ - public function iCanBuildSimpleObjectWithScalarAndObjectValuesInConstructor() + #[Test] + public function iCanBuildSimpleObjectWithScalarAndObjectValuesInConstructor(): void { $data = [ 'someString' => 'some string', @@ -57,7 +59,7 @@ public function iCanBuildSimpleObjectWithScalarAndObjectValuesInConstructor() $class = SimpleMixedConstructor::class; /** @var SimpleMixedConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(SimpleMixedConstructor::class, $object); $this->assertSame('some string', $object->someString); @@ -65,8 +67,8 @@ public function iCanBuildSimpleObjectWithScalarAndObjectValuesInConstructor() $this->assertInstanceOf(SomeObjectWithEmptyConstructor::class, $object->someObject); } - /** @test */ - public function iCanBuildSimpleObjectWithDefaultValuesInConstructor() + #[Test] + public function iCanBuildSimpleObjectWithDefaultValuesInConstructor(): void { $data = [ 'someObject' => [], @@ -74,7 +76,7 @@ public function iCanBuildSimpleObjectWithDefaultValuesInConstructor() $class = SimpleMixedConstructorWithDefaultValue::class; /** @var SimpleMixedConstructorWithDefaultValue $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(SimpleMixedConstructorWithDefaultValue::class, $object); $this->assertSame('some string', $object->someString); @@ -82,8 +84,8 @@ public function iCanBuildSimpleObjectWithDefaultValuesInConstructor() $this->assertInstanceOf(SomeObjectWithEmptyConstructor::class, $object->someObject); } - /** @test */ - public function iCanBuildObjectWithObjectCollectionWithoutUseInConstructor() + #[Test] + public function iCanBuildObjectWithObjectCollectionWithoutUseInConstructor(): void { $data = [ 'list' => [ @@ -100,17 +102,15 @@ public function iCanBuildObjectWithObjectCollectionWithoutUseInConstructor() $class = ListOfObjectsWithoutUseStmtConstructor::class; /** @var ListOfObjectsWithoutUseStmtConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(ListOfObjectsWithoutUseStmtConstructor::class, $object); $this->assertCount(2, $object->list); - foreach($object->list as $element) { - $this->assertInstanceOf(SimpleScalarConstructor::class, $element); - } + $this->assertContainsOnlyInstancesOf(SimpleScalarConstructor::class, $object->list); } - /** @test */ - public function iCanBuildObjectWithObjectCollectionWithUseInConstructor() + #[Test] + public function iCanBuildObjectWithObjectCollectionWithUseInConstructor(): void { $data = [ 'list' => [ @@ -121,17 +121,15 @@ public function iCanBuildObjectWithObjectCollectionWithUseInConstructor() $class = ListOfObjectsWithUseStmtConstructor::class; /** @var ListOfObjectsWithUseStmtConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(ListOfObjectsWithUseStmtConstructor::class, $object); $this->assertCount(2, $object->list); - foreach($object->list as $element) { - $this->assertInstanceOf(SomeSecondObject::class, $element); - } + $this->assertContainsOnlyInstancesOf(SomeSecondObject::class, $object->list); } - /** @test */ - public function iCanBuildObjectWithObjectCollectionWithoutUseButWithFQNTypedArrayInConstructor() + #[Test] + public function iCanBuildObjectWithObjectCollectionWithoutUseButWithFQNTypedArrayInConstructor(): void { $data = [ 'list' => [ @@ -142,17 +140,15 @@ public function iCanBuildObjectWithObjectCollectionWithoutUseButWithFQNTypedArra $class = ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor::class; /** @var ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(ListOfObjectsWithoutUseButWithFQNTypedArrayConstructor::class, $object); $this->assertCount(2, $object->list); - foreach($object->list as $element) { - $this->assertInstanceOf(SomeObject::class, $element); - } + $this->assertContainsOnlyInstancesOf(SomeObject::class, $object->list); } - /** @test */ - public function iCanBuildObjectWithScalarCollectionTypedArrayInConstructor() + #[Test] + public function iCanBuildObjectWithScalarCollectionTypedArrayInConstructor(): void { $data = [ 'list1' => ['str', 'str'], @@ -161,21 +157,22 @@ public function iCanBuildObjectWithScalarCollectionTypedArrayInConstructor() $class = ListOfObjectsWithScalarTypedArrayConstructor::class; /** @var ListOfObjectsWithScalarTypedArrayConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(ListOfObjectsWithScalarTypedArrayConstructor::class, $object); $this->assertCount(2, $object->list1); $this->assertCount(2, $object->list2); - foreach($object->list1 as $element) { + foreach ($object->list1 as $element) { $this->assertSame('str', $element); } - foreach($object->list2 as $element) { + + foreach ($object->list2 as $element) { $this->assertSame('str', $element); } } - /** @test */ - public function iCanBuildObjectWithBothScalarAndObjectCollectionTypedArrayInConstructor() + #[Test] + public function iCanBuildObjectWithBothScalarAndObjectCollectionTypedArrayInConstructor(): void { $data = [ 'list1' => ['str', 'str'], @@ -193,21 +190,20 @@ public function iCanBuildObjectWithBothScalarAndObjectCollectionTypedArrayInCons $class = ListOfObjectsWithScalarTypedArrayAndObjectListConstructor::class; /** @var ListOfObjectsWithScalarTypedArrayAndObjectListConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(ListOfObjectsWithScalarTypedArrayAndObjectListConstructor::class, $object); $this->assertCount(2, $object->list1); $this->assertCount(2, $object->list2); - foreach($object->list1 as $element) { + foreach ($object->list1 as $element) { $this->assertSame('str', $element); } - foreach($object->list2 as $element) { - $this->assertInstanceOf(SimpleScalarConstructor::class, $element); - } + + $this->assertContainsOnlyInstancesOf(SimpleScalarConstructor::class, $object->list2); } - /** @test */ - public function iCanBuildAdvancedObjectHierarchy() + #[Test] + public function iCanBuildAdvancedObjectHierarchy(): void { $data = [ 'someString' => 'some string', @@ -225,7 +221,7 @@ public function iCanBuildAdvancedObjectHierarchy() $class = SomeAggregateRoot::class; /** @var SomeAggregateRoot $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(SomeAggregateRoot::class, $object); $this->assertSame('some string', $object->someString); @@ -236,8 +232,8 @@ public function iCanBuildAdvancedObjectHierarchy() $this->assertSame(2, $object->simpleObject2->someInt); } - /** @test */ - public function iCanBuildObjectWithNullableParameterWithoutDefaultValue() + #[Test] + public function iCanBuildObjectWithNullableParameterWithoutDefaultValue(): void { $data = [ 'someString1' => 'some string1', @@ -246,7 +242,7 @@ public function iCanBuildObjectWithNullableParameterWithoutDefaultValue() $class = SimpleNullableConstructor::class; /** @var SimpleNullableConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(SimpleNullableConstructor::class, $object); $this->assertSame('some string1', $object->someString1); @@ -254,8 +250,8 @@ public function iCanBuildObjectWithNullableParameterWithoutDefaultValue() $this->assertNull($object->someInt); } - /** @test */ - public function iCanBuildObjectWithNullableParameterWithHimValueValue() + #[Test] + public function iCanBuildObjectWithNullableParameterWithHimValueValue(): void { $data = [ 'someString1' => 'some string1', @@ -265,7 +261,7 @@ public function iCanBuildObjectWithNullableParameterWithHimValueValue() $class = SimpleNullableConstructor::class; /** @var SimpleNullableConstructor $object */ - $object = static::$builder->build($class, $data); + $object = $this->builder->build($class, $data); $this->assertInstanceOf(SimpleNullableConstructor::class, $object); $this->assertSame('some string1', $object->someString1);