diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 6e6514db9aff..64f557576029 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -12,7 +12,7 @@ jobs: strategy: matrix: platform: [ubuntu-latest, windows-latest] - php: [ "8.0", "8.1", "8.2", "8.3" ] + php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ] extensions: ["grpc-1.54.0"] type: ["Unit Test"] include: diff --git a/BigQuery/composer.json b/BigQuery/composer.json index c8cffbdffc10..726986dcbb3c 100644 --- a/BigQuery/composer.json +++ b/BigQuery/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "google/cloud-storage": "^1.3" diff --git a/BigQuery/tests/Unit/Connection/RestTest.php b/BigQuery/tests/Unit/Connection/RestTest.php index 7c7f31c785e7..f47edb96de0c 100644 --- a/BigQuery/tests/Unit/Connection/RestTest.php +++ b/BigQuery/tests/Unit/Connection/RestTest.php @@ -52,7 +52,7 @@ public function setUp(): void public function testApiEndpointForUniverseDomain( array $config, string $expectedEndpoint, - string $envUniverse = null + ?string $envUniverse = null ) { if ($envUniverse) { putenv('GOOGLE_CLOUD_UNIVERSE_DOMAIN=' . $envUniverse); diff --git a/Bigtable/composer.json b/Bigtable/composer.json index 6d49236e1b90..c15c68129d1d 100644 --- a/Bigtable/composer.json +++ b/Bigtable/composer.json @@ -11,7 +11,7 @@ "require-dev": { "phpunit/phpunit": "^9.0", "erusev/parsedown": "^1.6", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "phpspec/prophecy-phpunit": "^2.0", "dg/bypass-finals": "^1.7" diff --git a/Core/composer.json b/Core/composer.json index f84a2979e013..fc0026b2042b 100644 --- a/Core/composer.json +++ b/Core/composer.json @@ -18,7 +18,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "opis/closure": "^3", diff --git a/Core/src/AnonymousCredentials.php b/Core/src/AnonymousCredentials.php index 4322a15ba3c2..f8c2c9f19733 100644 --- a/Core/src/AnonymousCredentials.php +++ b/Core/src/AnonymousCredentials.php @@ -43,7 +43,7 @@ class AnonymousCredentials implements * @param callable $httpHandler * @return array */ - public function fetchAuthToken(callable $httpHandler = null) + public function fetchAuthToken(?callable $httpHandler = null) { return $this->token; } @@ -81,7 +81,7 @@ public function getLastReceivedToken() public function updateMetadata( $metadata, $authUri = null, - callable $httpHandler = null + ?callable $httpHandler = null ) { return $metadata; } diff --git a/Core/src/Batch/BatchRunner.php b/Core/src/Batch/BatchRunner.php index b2b55983e41b..0ee47ca57a7b 100644 --- a/Core/src/Batch/BatchRunner.php +++ b/Core/src/Batch/BatchRunner.php @@ -57,8 +57,8 @@ class BatchRunner * to use. **Defaults to** null. This is only for testing purpose. */ public function __construct( - ConfigStorageInterface $configStorage = null, - ProcessItemInterface $processor = null + ?ConfigStorageInterface $configStorage = null, + ?ProcessItemInterface $processor = null ) { if ($configStorage === null || $processor === null) { if ($this->isSysvIPCLoaded() && $this->isDaemonRunning()) { diff --git a/Core/src/Batch/Retry.php b/Core/src/Batch/Retry.php index 483c7eb3dac8..8f66863ec526 100644 --- a/Core/src/Batch/Retry.php +++ b/Core/src/Batch/Retry.php @@ -37,7 +37,7 @@ class Retry * * @param BatchRunner $runner [optional] **Defaults to** a new BatchRunner. */ - public function __construct(BatchRunner $runner = null) + public function __construct(?BatchRunner $runner = null) { $this->runner = $runner ?: new BatchRunner(); $this->initFailureFile(); diff --git a/Core/src/Compute/Metadata.php b/Core/src/Compute/Metadata.php index 0f34adb5ef0e..d1471c773e86 100644 --- a/Core/src/Compute/Metadata.php +++ b/Core/src/Compute/Metadata.php @@ -59,7 +59,7 @@ class Metadata /** * @param ReaderInterface $reader [optional] A metadata reader implementation. */ - public function __construct(ReaderInterface $reader = null) + public function __construct(?ReaderInterface $reader = null) { $this->reader = $reader ?: new HttpHandlerReader(); } diff --git a/Core/src/Compute/Metadata/Readers/HttpHandlerReader.php b/Core/src/Compute/Metadata/Readers/HttpHandlerReader.php index d1d7b1530490..a057b138c7e6 100644 --- a/Core/src/Compute/Metadata/Readers/HttpHandlerReader.php +++ b/Core/src/Compute/Metadata/Readers/HttpHandlerReader.php @@ -36,7 +36,7 @@ class HttpHandlerReader implements ReaderInterface * @param callable $httpHandler [optional] An HTTP Handler capable of * accepting PSR7 requests and returning PSR7 responses. */ - public function __construct(callable $httpHandler = null) + public function __construct(?callable $httpHandler = null) { $this->httpHandler = $httpHandler ?: HttpHandlerFactory::build(HttpClientCache::getHttpClient()); diff --git a/Core/src/Exception/ServiceException.php b/Core/src/Exception/ServiceException.php index b601eb677e36..0db353d6f308 100644 --- a/Core/src/Exception/ServiceException.php +++ b/Core/src/Exception/ServiceException.php @@ -65,7 +65,7 @@ class ServiceException extends GoogleException public function __construct( $message = null, $code = 0, - Exception $serviceException = null, + ?Exception $serviceException = null, array $metadata = [] ) { $this->serviceException = $serviceException; diff --git a/Core/src/ExponentialBackoff.php b/Core/src/ExponentialBackoff.php index e5a04131198f..58eea5ee7d79 100644 --- a/Core/src/ExponentialBackoff.php +++ b/Core/src/ExponentialBackoff.php @@ -64,8 +64,8 @@ class ExponentialBackoff */ public function __construct( $retries = null, - callable $retryFunction = null, - callable $retryListener = null + ?callable $retryFunction = null, + ?callable $retryListener = null ) { $this->retries = $retries !== null ? (int) $retries : 3; $this->retryFunction = $retryFunction; diff --git a/Core/src/GrpcTrait.php b/Core/src/GrpcTrait.php index bab9d6d325d2..2573c43192ea 100644 --- a/Core/src/GrpcTrait.php +++ b/Core/src/GrpcTrait.php @@ -98,8 +98,8 @@ public function send(callable $request, array $args, $whitelisted = false) */ private function getGaxConfig( $version, - callable $authHttpHandler = null, - string $universeDomain = null + ?callable $authHttpHandler = null, + ?string $universeDomain = null ) { $config = [ 'libName' => 'gccl', diff --git a/Core/src/RequestWrapper.php b/Core/src/RequestWrapper.php index eb8f7650284a..10e6ff729879 100644 --- a/Core/src/RequestWrapper.php +++ b/Core/src/RequestWrapper.php @@ -511,7 +511,7 @@ private function buildDefaultAsyncHandler() /** * Verify that the expected universe domain matches the universe domain from the credentials. */ - private function checkUniverseDomain(FetchAuthTokenInterface $credentialsFetcher = null) + private function checkUniverseDomain(?FetchAuthTokenInterface $credentialsFetcher = null) { if (false === $this->hasCheckedUniverse) { if ($this->universeDomain === '') { diff --git a/Core/src/RestTrait.php b/Core/src/RestTrait.php index 70966a8a0359..20b61cc00c21 100644 --- a/Core/src/RestTrait.php +++ b/Core/src/RestTrait.php @@ -122,7 +122,7 @@ public function send($resource, $method, array $options = [], $whitelisted = fal * @param string $apiEndpointTemplate * @return string */ - private function getApiEndpoint($default, array $config, string $apiEndpointTemplate = null) + private function getApiEndpoint($default, array $config, ?string $apiEndpointTemplate = null) { // If the $default parameter is provided, or the user has set an "apiEndoint" config option, // fall back to the previous behavior. diff --git a/Core/src/Retry.php b/Core/src/Retry.php index 67b6000b4540..6083b5857dde 100644 --- a/Core/src/Retry.php +++ b/Core/src/Retry.php @@ -54,7 +54,7 @@ class Retry public function __construct( $retries, callable $delayFunction, - callable $retryFunction = null + ?callable $retryFunction = null ) { $this->retries = $retries !== null ? (int) $retries : 3; $this->delayFunction = $delayFunction; diff --git a/Core/src/Testing/ArrayHasSameValuesToken.php b/Core/src/Testing/ArrayHasSameValuesToken.php index d6acbca9c198..213dd6ddedcc 100644 --- a/Core/src/Testing/ArrayHasSameValuesToken.php +++ b/Core/src/Testing/ArrayHasSameValuesToken.php @@ -25,7 +25,7 @@ class ArrayHasSameValuesToken implements TokenInterface * @experimental * @internal */ - public function __construct($value, StringUtil $util = null) + public function __construct($value, ?StringUtil $util = null) { $this->value = $value; $this->util = $util ?: new StringUtil(); diff --git a/Core/src/Testing/Reflection/ReflectionHandlerFactory.php b/Core/src/Testing/Reflection/ReflectionHandlerFactory.php index 6c4b7b427474..7adc137e2016 100644 --- a/Core/src/Testing/Reflection/ReflectionHandlerFactory.php +++ b/Core/src/Testing/Reflection/ReflectionHandlerFactory.php @@ -17,6 +17,8 @@ namespace Google\Cloud\Core\Testing\Reflection; +use phpDocumentor\Reflection\Php\Factory\Argument; + /** * Class for determining which verison of phpdocumentor/reflection is being used. * @internal @@ -28,6 +30,8 @@ class ReflectionHandlerFactory */ public static function create() { - return new ReflectionHandlerV5(); + return class_exists(Argument::class) + ? new ReflectionHandlerV5() + : new ReflectionHandlerV6(); } } diff --git a/Core/src/Testing/Reflection/ReflectionHandlerV5.php b/Core/src/Testing/Reflection/ReflectionHandlerV5.php index 9f61f3938281..ea4e2b001b5c 100644 --- a/Core/src/Testing/Reflection/ReflectionHandlerV5.php +++ b/Core/src/Testing/Reflection/ReflectionHandlerV5.php @@ -99,14 +99,33 @@ public function classes(array $files) } /** - * @return ProjectFactory + * Split this into a separate method because ReflectionHandler V6 looks + * different */ - public function createProjectFactory() + protected function createParser() { - $parser = (new ParserFactory())->create( + return (new ParserFactory())->create( ParserFactory::ONLY_PHP7, new Lexer\Emulative(['phpVersion' => Lexer\Emulative::PHP_8_0]) ); + } + + /** + * Split this into a separate method because V6 does not support it + */ + protected function getAdditionalStrategies() + { + return [ + new Factory\Argument(new PrettyPrinter()) // @phpstan-ignore-line + ]; + } + + /** + * @return ProjectFactory + */ + public function createProjectFactory() + { + $parser = $this->createParser(); $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor(new NameResolver()); $nodeTraverser->addVisitor(new ElementNameResolver()); @@ -119,7 +138,6 @@ public function createProjectFactory() $strategies = new ProjectFactoryStrategies( [ new Factory\Namespace_(), - new Factory\Argument(new PrettyPrinter()), new Factory\Class_($docblockFactory), new Factory\Enum_($docblockFactory), new Factory\EnumCase($docblockFactory, new PrettyPrinter()), @@ -134,7 +152,7 @@ public function createProjectFactory() new Factory\Trait_($docblockFactory), new Factory\IfStatement(), new TraitUse(), - ] + ] + $this->getAdditionalStrategies() ); $strategies->addStrategy( diff --git a/Core/src/Testing/Reflection/ReflectionHandlerV6.php b/Core/src/Testing/Reflection/ReflectionHandlerV6.php new file mode 100644 index 000000000000..b04a9efe0581 --- /dev/null +++ b/Core/src/Testing/Reflection/ReflectionHandlerV6.php @@ -0,0 +1,46 @@ +createForVersion($phpVersion); + } + + /** + * @see ReflectionHandlerV5 + */ + protected function getAdditionalStrategies() + { + return []; + } +} diff --git a/Core/src/Testing/System/DeletionQueue.php b/Core/src/Testing/System/DeletionQueue.php index f29bda287bbc..820d9f19441d 100644 --- a/Core/src/Testing/System/DeletionQueue.php +++ b/Core/src/Testing/System/DeletionQueue.php @@ -90,7 +90,7 @@ public function add($toDelete) * @experimental * @internal */ - public function process(callable $action = null) + public function process(?callable $action = null) { if ($action) { $action($this->queue); diff --git a/Core/src/ValidateTrait.php b/Core/src/ValidateTrait.php index f1582702fcff..1e9f913c0c93 100644 --- a/Core/src/ValidateTrait.php +++ b/Core/src/ValidateTrait.php @@ -37,7 +37,7 @@ trait ValidateTrait private function validateBatch( array $input, $type, - callable $additionalCheck = null + ?callable $additionalCheck = null ) { foreach ($input as $element) { if (!($element instanceof $type)) { diff --git a/Core/tests/Unit/GrpcTraitTest.php b/Core/tests/Unit/GrpcTraitTest.php index 4add5af99efa..8902368c9a21 100644 --- a/Core/tests/Unit/GrpcTraitTest.php +++ b/Core/tests/Unit/GrpcTraitTest.php @@ -203,7 +203,7 @@ function () { public function testUniverseDomainFromGaxConfig( ?string $universeDomain, string $expectedUniverseDomain, - string $envUniverse = null + ?string $envUniverse = null ) { if ($envUniverse) { putenv('GOOGLE_CLOUD_UNIVERSE_DOMAIN=' . $envUniverse); diff --git a/Core/tests/Unit/RequestWrapperTest.php b/Core/tests/Unit/RequestWrapperTest.php index 1ac68f1dad2a..84c8aaac1bc6 100644 --- a/Core/tests/Unit/RequestWrapperTest.php +++ b/Core/tests/Unit/RequestWrapperTest.php @@ -783,7 +783,7 @@ public function testFetchingCredentialAsAuthHeaderWithOverlappingHeaders() public function testCheckUniverseDomainFails( ?string $universeDomain, ?string $credentialsUniverse, - string $message = null + ?string $message = null ) { $this->expectException(GoogleException::class); $this->expectExceptionMessage($message ?: sprintf( diff --git a/Core/tests/Unit/ServiceBuilderTest.php b/Core/tests/Unit/ServiceBuilderTest.php index 3667628bb299..487fad4639f2 100644 --- a/Core/tests/Unit/ServiceBuilderTest.php +++ b/Core/tests/Unit/ServiceBuilderTest.php @@ -46,7 +46,7 @@ class ServiceBuilderTest extends TestCase /** * @dataProvider serviceProvider */ - public function testBuildsClients($serviceName, $expectedClient, array $args = [], callable $beforeCallable = null) + public function testBuildsClients($serviceName, $expectedClient, array $args = [], ?callable $beforeCallable = null) { $this->checkAndSkipTest([$expectedClient]); @@ -86,7 +86,7 @@ public function testKeyfilePathAuthPassthrough( $serviceName, $expectedClient, array $args = [], - callable $beforeCallable = null + ?callable $beforeCallable = null ) { $this->checkAndSkipTest([$expectedClient]); @@ -124,7 +124,7 @@ public function testKeyfileAuthPassthrough( $serviceName, $expectedClient, array $args = [], - callable $beforeCallable = null + ?callable $beforeCallable = null ) { $this->checkAndSkipTest([$expectedClient]); diff --git a/Core/tests/Unit/ServicesNotFoundTest.php b/Core/tests/Unit/ServicesNotFoundTest.php index c4201bf0f703..fc4c52d5ea0f 100644 --- a/Core/tests/Unit/ServicesNotFoundTest.php +++ b/Core/tests/Unit/ServicesNotFoundTest.php @@ -32,6 +32,11 @@ class ServicesNotFoundTest extends TestCase public static function setUpBeforeClass(): void { + if (version_compare(PHP_VERSION, '8.4', '>=')) { + // @TODO upgrade to using Laravel/closure instead + // @see https://github.com/opis/closure/pull/145 + self::markTestSkipped('This test is not compatible with PHP 8.4'); + } self::$cloud = new ServiceBuilder; foreach (spl_autoload_functions() as $function) { if ($function[0] instanceof ClassLoader) { diff --git a/Datastore/composer.json b/Datastore/composer.json index 0a7e29192c10..f38d33ca9cf3 100644 --- a/Datastore/composer.json +++ b/Datastore/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6" }, diff --git a/Datastore/src/EntityInterface.php b/Datastore/src/EntityInterface.php index fe501d4bbed7..a0e6ec5d70de 100644 --- a/Datastore/src/EntityInterface.php +++ b/Datastore/src/EntityInterface.php @@ -55,7 +55,7 @@ interface EntityInterface * created as the result of a service request. * } */ - public static function build(Key $key = null, array $entity = [], array $options = []); + public static function build(?Key $key = null, array $entity = [], array $options = []); /** * Defines embedded entity mappings. diff --git a/Datastore/src/EntityTrait.php b/Datastore/src/EntityTrait.php index d483d97e4017..f3c710537fb5 100644 --- a/Datastore/src/EntityTrait.php +++ b/Datastore/src/EntityTrait.php @@ -56,7 +56,7 @@ trait EntityTrait * created as the result of a service request. * } */ - public function __construct(Key $key = null, array $entity = [], array $options = []) + public function __construct(?Key $key = null, array $entity = [], array $options = []) { $this->key = $key; $this->entity = $entity; @@ -92,7 +92,7 @@ public function __construct(Key $key = null, array $entity = [], array $options * } * @throws \InvalidArgumentException */ - public static function build(Key $key = null, array $entity = [], array $options = []) + public static function build(?Key $key = null, array $entity = [], array $options = []) { return new static($key, $entity, $options); } diff --git a/Debugger/composer.json b/Debugger/composer.json index 2acfbd39ec09..09d06d96ed7b 100644 --- a/Debugger/composer.json +++ b/Debugger/composer.json @@ -15,7 +15,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "google/cloud-tools": "^0.15.0", diff --git a/Debugger/src/Breakpoint.php b/Debugger/src/Breakpoint.php index 447a5bd41446..17b4b5c515df 100644 --- a/Debugger/src/Breakpoint.php +++ b/Debugger/src/Breakpoint.php @@ -649,7 +649,7 @@ public function validate() * resolver that uses the current include path. * @return bool */ - public function resolveLocation(SourceLocationResolver $resolver = null) + public function resolveLocation(?SourceLocationResolver $resolver = null) { $resolver = $resolver ?: new SourceLocationResolver(); $this->resolvedLocation = $resolver->resolve($this->location); diff --git a/Debugger/src/Daemon.php b/Debugger/src/Daemon.php index edad96c8ec43..19ad51ea1967 100644 --- a/Debugger/src/Daemon.php +++ b/Debugger/src/Daemon.php @@ -173,7 +173,7 @@ public function __construct(array $options = []) * $daemon->run(); * ``` */ - public function run(DebuggerClient $client = null, $asDaemon = true) + public function run(?DebuggerClient $client = null, $asDaemon = true) { $client = $client ?: $this->defaultClient(); $extSourceContexts = $this->extSourceContext ? [$this->extSourceContext] : []; @@ -274,7 +274,7 @@ private function defaultClient() return new DebuggerClient($this->getUnwrappedClientConfig()); } - private function defaultLabels(MetadataProviderInterface $metadataProvider = null) + private function defaultLabels(?MetadataProviderInterface $metadataProvider = null) { $metadataProvider = $metadataProvider ?: MetadataProviderUtils::autoSelect($_SERVER); $labels = []; diff --git a/ErrorReporting/src/Bootstrap.php b/ErrorReporting/src/Bootstrap.php index 8f69bc13a5c3..1a94cac6b389 100644 --- a/ErrorReporting/src/Bootstrap.php +++ b/ErrorReporting/src/Bootstrap.php @@ -33,7 +33,7 @@ public static function prependFileLocation() * @return void * @codeCoverageIgnore */ - public static function init(PsrLogger $psrLogger = null) + public static function init(?PsrLogger $psrLogger = null) { self::$psrLogger = $psrLogger ?: (new LoggingClient()) ->psrLogger(self::DEFAULT_LOGNAME, [ @@ -79,9 +79,6 @@ public static function getErrorPrefix($level) case E_USER_NOTICE: $prefix = 'PHP Notice'; break; - case E_STRICT: - $prefix = 'PHP Debug'; - break; default: $prefix = 'PHP Notice'; } @@ -113,8 +110,6 @@ public static function getErrorLevelString($level) case E_NOTICE: case E_USER_NOTICE: return 'NOTICE'; - case E_STRICT: - return 'DEBUG'; default: return 'NOTICE'; } @@ -264,7 +259,7 @@ public static function shutdownHandler() * * @param array $trace The stack trace returned from Exception::getTrace() */ - private static function getFunctionNameForReport(array $trace = null) + private static function getFunctionNameForReport(?array $trace = null) { if (null === $trace) { return ''; diff --git a/ErrorReporting/tests/Unit/BootstrapTest.php b/ErrorReporting/tests/Unit/BootstrapTest.php index 4cd3b05d7239..3a49f79cb490 100644 --- a/ErrorReporting/tests/Unit/BootstrapTest.php +++ b/ErrorReporting/tests/Unit/BootstrapTest.php @@ -78,7 +78,6 @@ public function levelAndErrorPrefixProvider() [E_USER_WARNING, 'PHP Warning'], [E_NOTICE, 'PHP Notice'], [E_USER_NOTICE, 'PHP Notice'], - [E_STRICT, 'PHP Debug'], [PHP_INT_MAX, 'PHP Notice'], ]; } @@ -107,7 +106,6 @@ public function levelAndErrorLevelString() [E_USER_WARNING, 'WARNING'], [E_NOTICE, 'NOTICE'], [E_USER_NOTICE, 'NOTICE'], - [E_STRICT, 'DEBUG'], [PHP_INT_MAX, 'NOTICE'], ]; } diff --git a/Firestore/composer.json b/Firestore/composer.json index 7affa72d3681..8a4f7c8c1203 100644 --- a/Firestore/composer.json +++ b/Firestore/composer.json @@ -14,7 +14,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6" }, diff --git a/Firestore/tests/System/ValueMapperTest.php b/Firestore/tests/System/ValueMapperTest.php index 403ed7e5af2c..d633d7456cce 100644 --- a/Firestore/tests/System/ValueMapperTest.php +++ b/Firestore/tests/System/ValueMapperTest.php @@ -48,7 +48,7 @@ public static function setUpTestFixtures(): void /** * @dataProvider values */ - public function testValue($input, callable $expectation = null) + public function testValue($input, ?callable $expectation = null) { self::$document->update([ ['path' => self::FIELD, 'value' => $input] diff --git a/Firestore/tests/Unit/Connection/GrpcTest.php b/Firestore/tests/Unit/Connection/GrpcTest.php index a05499f7981b..0202ec87c489 100644 --- a/Firestore/tests/Unit/Connection/GrpcTest.php +++ b/Firestore/tests/Unit/Connection/GrpcTest.php @@ -410,7 +410,7 @@ private function header() ]; } - private function sendAndAssert($method, array $args, array $expectedArgs, Grpc $connection = null) + private function sendAndAssert($method, array $args, array $expectedArgs, ?Grpc $connection = null) { $connection = $connection ?: new Grpc([ 'projectId' => 'test', diff --git a/Firestore/tests/Unit/QueryTest.php b/Firestore/tests/Unit/QueryTest.php index 36ea6943f4f6..05272a339190 100644 --- a/Firestore/tests/Unit/QueryTest.php +++ b/Firestore/tests/Unit/QueryTest.php @@ -1567,7 +1567,7 @@ public function testBuildPositionAllDescendantsDocument() ], $this->collectionGroupQuery); } - private function runAndAssert(callable $filters, $assertion, Query $query = null) + private function runAndAssert(callable $filters, $assertion, ?Query $query = null) { if (is_array($assertion)) { $this->connection->runQuery( diff --git a/Language/composer.json b/Language/composer.json index 9cd84837ff16..1b4fca93818f 100644 --- a/Language/composer.json +++ b/Language/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "google/cloud-storage": "^1.3" diff --git a/Logging/composer.json b/Logging/composer.json index 4ffbbb86799d..8ae3790a22d5 100644 --- a/Logging/composer.json +++ b/Logging/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "fig/log-test": "^1.1", diff --git a/Logging/src/Logger.php b/Logging/src/Logger.php index e560740b2f8e..566c52daa42f 100644 --- a/Logging/src/Logger.php +++ b/Logging/src/Logger.php @@ -129,8 +129,8 @@ public function __construct( ConnectionInterface $connection, $name, $projectId, - array $resource = null, - array $labels = null + ?array $resource = null, + ?array $labels = null ) { $this->connection = $connection; $this->name = $name; @@ -491,7 +491,7 @@ private function handleTimestamp(array $options) * @param \DateTimeInterface $dt [optional] * @return string */ - private function createTimestamp(\DateTimeInterface $dt = null) + private function createTimestamp(?\DateTimeInterface $dt = null) { if (!$dt) { $dt = \DateTime::createFromFormat( diff --git a/Logging/tests/Unit/LoggerTest.php b/Logging/tests/Unit/LoggerTest.php index d51440f841b1..ee36ec22434f 100644 --- a/Logging/tests/Unit/LoggerTest.php +++ b/Logging/tests/Unit/LoggerTest.php @@ -323,7 +323,7 @@ public function testWritesEntries() $this->assertNull($logger->writeBatch([$entry1, $entry2])); } - private function getLogger($connection, array $resource = null, array $labels = null) + private function getLogger($connection, ?array $resource = null, ?array $labels = null) { $logger = new LoggerStub($connection->reveal(), $this->logName, $this->projectId, $resource, $labels); $logger->setTime($this->microtime); diff --git a/Logging/tests/Unit/PsrLoggerTest.php b/Logging/tests/Unit/PsrLoggerTest.php index 3d1e1127174a..7b0624cb361e 100644 --- a/Logging/tests/Unit/PsrLoggerTest.php +++ b/Logging/tests/Unit/PsrLoggerTest.php @@ -46,7 +46,7 @@ public function setUp(): void $this->connection = $this->prophesize(ConnectionInterface::class); } - public function getPsrLogger($connection, array $resource = null, array $labels = null, $messageKey = 'message') + public function getPsrLogger($connection, ?array $resource = null, ?array $labels = null, $messageKey = 'message') { $logger = new Logger($connection->reveal(), $this->logName, $this->projectId, $resource, $labels); return new PsrLogger($logger, $messageKey, ['metadataProvider' => new EmptyMetadataProvider()]); diff --git a/PubSub/composer.json b/PubSub/composer.json index 45d9e87c141a..9eb92eac1908 100644 --- a/PubSub/composer.json +++ b/PubSub/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "flix-tech/avro-php": "^5.0.0" diff --git a/Spanner/composer.json b/Spanner/composer.json index 6bd4c5577770..55da48c121f3 100644 --- a/Spanner/composer.json +++ b/Spanner/composer.json @@ -13,7 +13,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "google/cloud-pubsub": "^2.0" diff --git a/Spanner/src/BatchDmlResult.php b/Spanner/src/BatchDmlResult.php index f375d8ea6a0e..e5b0a2f45b78 100644 --- a/Spanner/src/BatchDmlResult.php +++ b/Spanner/src/BatchDmlResult.php @@ -67,7 +67,7 @@ class BatchDmlResult * @param array|null $errorStatement The statement (with params and types) * which triggered an error. */ - public function __construct(array $data, array $errorStatement = null) + public function __construct(array $data, ?array $errorStatement = null) { $this->data = $data; $this->errorStatement = $errorStatement; diff --git a/Spanner/src/Database.php b/Spanner/src/Database.php index 23e4317e0462..d0bff4802ae2 100644 --- a/Spanner/src/Database.php +++ b/Spanner/src/Database.php @@ -218,7 +218,7 @@ public function __construct( array $lroCallables, $projectId, $name, - SessionPoolInterface $sessionPool = null, + ?SessionPoolInterface $sessionPool = null, $returnInt64AsObject = false, array $info = [], $databaseRole = '' diff --git a/Spanner/src/InstanceConfiguration.php b/Spanner/src/InstanceConfiguration.php index e38162aad35f..65e81517ffdd 100644 --- a/Spanner/src/InstanceConfiguration.php +++ b/Spanner/src/InstanceConfiguration.php @@ -91,7 +91,7 @@ public function __construct( $projectId, $name, array $info = [], - LongRunningConnectionInterface $lroConnection = null + ?LongRunningConnectionInterface $lroConnection = null ) { $this->connection = $connection; $this->projectId = $projectId; diff --git a/Spanner/tests/System/PgQueryTest.php b/Spanner/tests/System/PgQueryTest.php index b45766cfa491..6e1a247a1da5 100644 --- a/Spanner/tests/System/PgQueryTest.php +++ b/Spanner/tests/System/PgQueryTest.php @@ -681,7 +681,7 @@ function (array $res) { /** * @dataProvider arrayTypesProvider */ - public function testBindArrayOfType($value, $result = null, $resultType = null, callable $filter = null) + public function testBindArrayOfType($value, $result = null, $resultType = null, ?callable $filter = null) { if (!$filter) { $filter = function ($val) { diff --git a/Spanner/tests/System/QueryTest.php b/Spanner/tests/System/QueryTest.php index 3e6f5a68c978..e478ef6aa4ae 100644 --- a/Spanner/tests/System/QueryTest.php +++ b/Spanner/tests/System/QueryTest.php @@ -379,7 +379,7 @@ public function testBindJsonParameterNull() * covers 55 * @dataProvider arrayTypes */ - public function testBindArrayOfType($value, $result = null, $resultType = null, callable $filter = null) + public function testBindArrayOfType($value, $result = null, $resultType = null, ?callable $filter = null) { if ($resultType == Numeric::class) { $this->skipEmulatorTests(); diff --git a/Spanner/tests/Unit/Session/CacheSessionPoolTest.php b/Spanner/tests/Unit/Session/CacheSessionPoolTest.php index 7a4fd47ee651..3461bf4a6d8a 100644 --- a/Spanner/tests/Unit/Session/CacheSessionPoolTest.php +++ b/Spanner/tests/Unit/Session/CacheSessionPoolTest.php @@ -927,7 +927,7 @@ private function getDatabase($shouldCreateFails = false, $willDeleteSessions = f return $database->reveal(); } - private function getCacheItemPool(array $cacheData = null) + private function getCacheItemPool(?array $cacheData = null) { $cacheItemPool = new MemoryCacheItemPool(); $cacheItem = $cacheItemPool->getItem( diff --git a/Speech/composer.json b/Speech/composer.json index f1952b1aeb55..5fe28b7069ab 100644 --- a/Speech/composer.json +++ b/Speech/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "google/cloud-storage": "^1.3" diff --git a/Storage/composer.json b/Storage/composer.json index 4c9900893a58..c2fe9d41c6f9 100644 --- a/Storage/composer.json +++ b/Storage/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "phpseclib/phpseclib": "^2.0||^3.0", diff --git a/Storage/src/WriteStream.php b/Storage/src/WriteStream.php index ba5d07fbc09b..3cb816b2690f 100644 --- a/Storage/src/WriteStream.php +++ b/Storage/src/WriteStream.php @@ -46,7 +46,7 @@ class WriteStream implements StreamInterface * upload data * } */ - public function __construct(AbstractUploader $uploader = null, $options = []) + public function __construct(?AbstractUploader $uploader = null, $options = []) { if ($uploader) { $this->setUploader($uploader); diff --git a/Storage/tests/System/StreamWrapper/StreamWrapperTestCase.php b/Storage/tests/System/StreamWrapper/StreamWrapperTestCase.php index cd15693a601f..82c4cb461802 100644 --- a/Storage/tests/System/StreamWrapper/StreamWrapperTestCase.php +++ b/Storage/tests/System/StreamWrapper/StreamWrapperTestCase.php @@ -42,7 +42,7 @@ public static function tearDownTestFixtures(): void self::$client->unregisterStreamWrapper(); } - protected static function generateUrl($file, Bucket $bucket = null) + protected static function generateUrl($file, ?Bucket $bucket = null) { $bucket = $bucket ?: self::$bucket; $bucketName = $bucket->name(); diff --git a/Storage/tests/Unit/BucketTest.php b/Storage/tests/Unit/BucketTest.php index 4f993ea66e73..5ac38e70763f 100644 --- a/Storage/tests/Unit/BucketTest.php +++ b/Storage/tests/Unit/BucketTest.php @@ -749,7 +749,7 @@ public function terminalStorageClass() } private function getBucketForSigning( - SignBlobInterface $credentials = null, + ?SignBlobInterface $credentials = null, $scopes = '' ) { if ($credentials === null) { diff --git a/Storage/tests/Unit/Connection/RestTest.php b/Storage/tests/Unit/Connection/RestTest.php index 0ca09d0eb473..7bcc731fdddd 100644 --- a/Storage/tests/Unit/Connection/RestTest.php +++ b/Storage/tests/Unit/Connection/RestTest.php @@ -67,7 +67,7 @@ public function setUp(): void public function testApiEndpointForUniverseDomain( array $config, string $expectedEndpoint, - string $envUniverse = null + ?string $envUniverse = null ) { if ($envUniverse) { putenv('GOOGLE_CLOUD_UNIVERSE_DOMAIN=' . $envUniverse); diff --git a/Storage/tests/Unit/SigningHelperTest.php b/Storage/tests/Unit/SigningHelperTest.php index ddc0aec54c18..af215676d279 100644 --- a/Storage/tests/Unit/SigningHelperTest.php +++ b/Storage/tests/Unit/SigningHelperTest.php @@ -497,7 +497,7 @@ public function urlMethods() /** * @dataProvider options */ - public function testNormalizeOptions(array $options, array $expected = null, $exception = null) + public function testNormalizeOptions(array $options, ?array $expected = null, $exception = null) { if ($exception) { $this->expectException($exception); diff --git a/Storage/tests/Unit/StorageObjectTest.php b/Storage/tests/Unit/StorageObjectTest.php index 787ff11f23e0..12c0e754b44c 100644 --- a/Storage/tests/Unit/StorageObjectTest.php +++ b/Storage/tests/Unit/StorageObjectTest.php @@ -977,7 +977,7 @@ public function urlVersion() } private function getStorageObjectForSigning( - SignBlobInterface $credentials = null, + ?SignBlobInterface $credentials = null, $scopes = '', $generation = null ) { diff --git a/Trace/composer.json b/Trace/composer.json index 79c5f1d9c3f3..e8cba230ab7a 100644 --- a/Trace/composer.json +++ b/Trace/composer.json @@ -13,7 +13,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6" }, diff --git a/Translate/composer.json b/Translate/composer.json index e0859bc5d0a7..e9adebb708cd 100644 --- a/Translate/composer.json +++ b/Translate/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6" }, diff --git a/Vision/composer.json b/Vision/composer.json index fcec8513f483..35bf4ca3a5cc 100644 --- a/Vision/composer.json +++ b/Vision/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3", + "phpdocumentor/reflection": "^5.3.3||^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", "google/cloud-storage": "^1.12" diff --git a/composer.json b/composer.json index a8c323ae6cf9..9677187cca0e 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ }, "require-dev": { "phpunit/phpunit": "^9.6", - "phpdocumentor/reflection": "^5.0", + "phpdocumentor/reflection": "^5.0||^6.0", "erusev/parsedown": "^1.6", "phpseclib/phpseclib": "^3.0", "google/cloud-tools": "^0.15.0", diff --git a/dev/src/Command/AddComponentCommand.php b/dev/src/Command/AddComponentCommand.php index 98dd8cdb941a..ce85171566f8 100644 --- a/dev/src/Command/AddComponentCommand.php +++ b/dev/src/Command/AddComponentCommand.php @@ -73,7 +73,7 @@ class AddComponentCommand extends Command * @param Client $httpClient specify the HTTP client, useful for tests. * @param RunProcess $runProcess Instance to execute Symfony Process commands, useful for tests. */ - public function __construct($rootPath, Client $httpClient = null, RunProcess $runProcess = null) + public function __construct($rootPath, ?Client $httpClient = null, ?RunProcess $runProcess = null) { $this->rootPath = realpath($rootPath); $this->httpClient = $httpClient ?: new Client(); diff --git a/dev/src/Command/ReleaseInfoCommand.php b/dev/src/Command/ReleaseInfoCommand.php index 01941c03522c..6a769f2adbd7 100644 --- a/dev/src/Command/ReleaseInfoCommand.php +++ b/dev/src/Command/ReleaseInfoCommand.php @@ -44,7 +44,7 @@ class ReleaseInfoCommand extends Command /** * @param Client $httpClient specify the HTTP client, useful for testing */ - public function __construct(Client $httpClient = null) + public function __construct(?Client $httpClient = null) { $this->httpClient = $httpClient ?: new Client(); parent::__construct(); diff --git a/dev/src/Component.php b/dev/src/Component.php index 734193da319c..cb12186a4565 100644 --- a/dev/src/Component.php +++ b/dev/src/Component.php @@ -40,7 +40,7 @@ class Component /** @var array */ private array $componentDependencies; - public function __construct(private string $name, string $path = null) + public function __construct(private string $name, ?string $path = null) { $this->path = $path ?: $this->getComponentPath($name); $this->validateComponentFiles(); diff --git a/dev/src/DocFx/Node/XrefTrait.php b/dev/src/DocFx/Node/XrefTrait.php index 100b317268c2..c91b49184566 100644 --- a/dev/src/DocFx/Node/XrefTrait.php +++ b/dev/src/DocFx/Node/XrefTrait.php @@ -156,7 +156,7 @@ function ($matches) { ); } - private function replaceUidWithLink(string $uid, string $name = null): string + private function replaceUidWithLink(string $uid, ?string $name = null): string { if (is_null($name)) { $name = ltrim($uid, '\\'); diff --git a/dev/src/GitHub.php b/dev/src/GitHub.php index 73de8f3c1a7d..e9d84a756661 100644 --- a/dev/src/GitHub.php +++ b/dev/src/GitHub.php @@ -17,6 +17,7 @@ namespace Google\Cloud\Dev; +use DateTime; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\Response; @@ -302,7 +303,7 @@ public function getTeams(string $repoName) * * @return array|null */ - public function getReleases($target, \DateTime $fromDate = null): ?array + public function getReleases($target, ?DateTime $fromDate = null): ?array { try { $res = $this->client->get(sprintf( diff --git a/dev/src/RunProcess.php b/dev/src/RunProcess.php index 6c879eb313e0..de4c82b12ef4 100644 --- a/dev/src/RunProcess.php +++ b/dev/src/RunProcess.php @@ -35,7 +35,7 @@ class RunProcess * @param string|null $cwd * @return string $shellOutput */ - public function execute(array $command, string $cwd = null): string + public function execute(array $command, ?string $cwd = null): string { $process = new Process($command, $cwd); $process->mustRun(); diff --git a/dev/tests/fixtures/component/Vision/composer.json b/dev/tests/fixtures/component/Vision/composer.json index 455134fb84fb..2aab8a4da14c 100644 --- a/dev/tests/fixtures/component/Vision/composer.json +++ b/dev/tests/fixtures/component/Vision/composer.json @@ -12,7 +12,7 @@ "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.0", + "phpdocumentor/reflection": "^5.0||^6.0", "erusev/parsedown": "^1.6", "google/cloud-storage": "^1.12" },