diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..15bd17299 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "CI" diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 559e83399..d6d1396cf 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -12,6 +12,6 @@ on: jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.1.0" with: php-version: "7.4" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4b55228f3..ca371fd54 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -15,6 +15,8 @@ env: jobs: phpunit: name: "PHPUnit" - uses: "doctrine/.github/.github/workflows/continuous-integration.yml@1.1.1" + uses: "doctrine/.github/.github/workflows/continuous-integration.yml@5.1.0" with: - php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]' + php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]' + secrets: + CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index e7e127f4a..e193d87b6 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,7 +8,7 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.1.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9a911787d..a5f2b173f 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -12,6 +12,6 @@ on: jobs: static-analysis: name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.4.0" + uses: "doctrine/.github/.github/workflows/static-analysis.yml@5.1.0" with: php-version: "8.1" diff --git a/src/Proxy/ProxyGenerator.php b/src/Proxy/ProxyGenerator.php index ec6fb1004..9f35fd5a2 100644 --- a/src/Proxy/ProxyGenerator.php +++ b/src/Proxy/ProxyGenerator.php @@ -1282,7 +1282,6 @@ function (ReflectionType $intersectedType) use ($method, $parameter) { if ( $type->allowsNull() && ! in_array($name, ['mixed', 'null'], true) - && ($parameter === null || ! $parameter->isDefaultValueAvailable() || $parameter->getDefaultValue() !== null) ) { $name = '?' . $name; } diff --git a/tests/Common/Proxy/Php8UnionTypes.php b/tests/Common/Proxy/Php8UnionTypes.php index ab5c391c8..c95412746 100644 --- a/tests/Common/Proxy/Php8UnionTypes.php +++ b/tests/Common/Proxy/Php8UnionTypes.php @@ -12,10 +12,16 @@ class Php8UnionTypes public function setValue(stdClass|array $value) : bool|float { + return true; } public function setNullableValue(stdClass|array|null $value) : bool|float|null { + return true; } + public function setNullableValueDefaultNull(stdClass|array|null $value = null) : bool|float|null + { + return true; + } } diff --git a/tests/Common/Proxy/ProxyGeneratorTest.php b/tests/Common/Proxy/ProxyGeneratorTest.php index 59c1eb3ef..168b3254b 100644 --- a/tests/Common/Proxy/ProxyGeneratorTest.php +++ b/tests/Common/Proxy/ProxyGeneratorTest.php @@ -180,7 +180,7 @@ public function testClassWithScalarTypeHintsOnProxiedMethods() self::assertEquals(1, substr_count($classCode, 'function combinationOfTypeHintsAndNormal(\stdClass $a, \Countable $b, $c, int $d)')); self::assertEquals(1, substr_count($classCode, 'function typeHintsWithVariadic(int ...$foo)')); self::assertEquals(1, substr_count($classCode, 'function withDefaultValue(int $foo = 123)')); - self::assertEquals(1, substr_count($classCode, 'function withDefaultValueNull(int $foo = NULL)')); + self::assertEquals(1, substr_count($classCode, 'function withDefaultValueNull(?int $foo = NULL)')); } public function testClassWithReturnTypesOnProxiedMethods() @@ -220,8 +220,8 @@ public function testClassWithNullableTypeHintsOnProxiedMethods() self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintObject(?\stdClass $param)')); self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintSelf(?\\' . $className . ' $param)')); self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintWithDefault(?int $param = 123)')); - self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintWithDefaultNull(int $param = NULL)')); - self::assertEquals(1, substr_count($classCode, 'function notNullableTypeHintWithDefaultNull(int $param = NULL)')); + self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintWithDefaultNull(?int $param = NULL)')); + self::assertEquals(1, substr_count($classCode, 'function notNullableTypeHintWithDefaultNull(?int $param = NULL)')); } public function testClassWithNullableReturnTypesOnProxiedMethods() @@ -259,7 +259,7 @@ public function testClassWithNullableOptionalNonLastParameterOnProxiedMethods() } self::assertStringContainsString( - 'public function midSignatureNullableParameter(\stdClass $param = NULL, $secondParam)', + 'public function midSignatureNullableParameter(?\stdClass $param = NULL, $secondParam)', file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyNullableNonOptionalHintClass.php') ); @@ -287,7 +287,7 @@ public function testClassWithPhp71NullableOptionalNonLastParameterOnProxiedMetho } self::assertStringContainsString( - 'public function midSignatureNullableParameter(string $param = NULL, $secondParam)', + 'public function midSignatureNullableParameter(?string $param = NULL, $secondParam)', file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp71NullableDefaultedNonOptionalHintClass.php'), 'Signature allows nullable type, although explicit "?" marker isn\'t used in the proxy' ); @@ -460,6 +460,11 @@ public function testPhp8UnionTypes() 'setNullableValue(\stdClass|array|null $value): float|bool|null', file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8UnionTypes.php') ); + + self::assertStringContainsString( + 'setNullableValueDefaultNull(\stdClass|array|null $value = NULL): float|bool|null', + file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8UnionTypes.php') + ); } /**