From 220a54d55cf1ba4b60738daac486de5e9aeb6406 Mon Sep 17 00:00:00 2001 From: balexey88 Date: Fri, 9 Jan 2026 18:46:44 +0200 Subject: [PATCH 1/2] Release 4.4.0 --- .github/workflows/publish-release.yml | 148 +- .github/workflows/security-scan.yml | 2 +- changelog.txt | 8 + changes.md | 8 + composer.lock | 18 +- lib/Google/CHANGELOG.md | 14 + lib/Google/CODE_OF_CONDUCT.md | 43 - lib/Google/UPGRADING.md | 377 ----- lib/Google/composer.json | 10 +- lib/Google/composer.lock | 1374 ++++++++++++----- .../src/AuthHandler/Guzzle6AuthHandler.php | 18 +- lib/Google/src/Client.php | 12 +- lib/Google/src/Task/Composer.php | 54 +- lib/Google/vendor/autoload.php | 7 +- lib/Google/vendor/brick/math/CHANGELOG.md | 51 + lib/Google/vendor/brick/math/composer.json | 13 +- .../vendor/brick/math/psalm-baseline.xml | 70 + .../vendor/brick/math/src/BigDecimal.php | 111 +- .../vendor/brick/math/src/BigInteger.php | 63 +- .../vendor/brick/math/src/BigNumber.php | 243 +-- .../vendor/brick/math/src/BigRational.php | 59 +- .../math/src/Exception/MathException.php | 2 +- .../src/Exception/NumberFormatException.php | 10 +- .../brick/math/src/Internal/Calculator.php | 44 +- .../Internal/Calculator/BcMathCalculator.php | 20 +- .../src/Internal/Calculator/GmpCalculator.php | 17 + .../Internal/Calculator/NativeCalculator.php | 53 +- .../vendor/brick/math/src/RoundingMode.php | 31 +- .../vendor/composer/InstalledVersions.php | 45 +- .../vendor/composer/autoload_classmap.php | 2 - lib/Google/vendor/composer/autoload_files.php | 1 - lib/Google/vendor/composer/autoload_psr4.php | 1 - lib/Google/vendor/composer/autoload_real.php | 10 +- .../vendor/composer/autoload_static.php | 113 +- lib/Google/vendor/composer/installed.json | 435 +++--- lib/Google/vendor/composer/installed.php | 107 +- lib/Google/vendor/composer/platform_check.php | 9 +- .../google/apiclient-services/composer.json | 2 +- .../google/apiclient-services/src/Storage.php | 8 + .../AdvanceRelocateBucketOperationRequest.php | 18 +- .../src/Storage/AnywhereCache.php | 78 +- .../src/Storage/AnywhereCaches.php | 20 +- .../apiclient-services/src/Storage/Bucket.php | 251 ++- .../src/Storage/BucketAccessControl.php | 78 +- .../BucketAccessControlProjectTeam.php | 12 +- .../src/Storage/BucketAccessControls.php | 12 +- .../src/Storage/BucketAutoclass.php | 32 +- .../src/Storage/BucketBilling.php | 6 +- .../src/Storage/BucketCors.php | 34 +- .../Storage/BucketCustomPlacementConfig.php | 6 +- .../src/Storage/BucketEncryption.php | 71 +- ...omerManagedEncryptionEnforcementConfig.php | 85 + ...merSuppliedEncryptionEnforcementConfig.php | 86 ++ ...ogleManagedEncryptionEnforcementConfig.php | 84 + .../Storage/BucketHierarchicalNamespace.php | 6 +- .../src/Storage/BucketIamConfiguration.php | 20 +- ...BucketIamConfigurationBucketPolicyOnly.php | 18 +- ...mConfigurationUniformBucketLevelAccess.php | 18 +- .../src/Storage/BucketIpFilter.php | 45 +- .../BucketIpFilterPublicNetworkSource.php | 8 +- .../BucketIpFilterVpcNetworkSources.php | 16 +- .../src/Storage/BucketLifecycle.php | 5 +- .../src/Storage/BucketLifecycleRule.php | 8 +- .../src/Storage/BucketLifecycleRuleAction.php | 16 +- .../Storage/BucketLifecycleRuleCondition.php | 126 +- .../src/Storage/BucketLogging.php | 12 +- .../src/Storage/BucketObjectRetention.php | 6 +- .../src/Storage/BucketOwner.php | 12 +- .../src/Storage/BucketRetentionPolicy.php | 26 +- .../src/Storage/BucketSoftDeletePolicy.php | 18 +- .../src/Storage/BucketStorageLayout.php | 34 +- ...cketStorageLayoutCustomPlacementConfig.php | 6 +- ...cketStorageLayoutHierarchicalNamespace.php | 6 +- .../src/Storage/BucketVersioning.php | 6 +- .../src/Storage/BucketWebsite.php | 22 +- .../src/Storage/Buckets.php | 46 +- .../src/Storage/BulkRestoreObjectsRequest.php | 92 +- .../src/Storage/Channel.php | 68 +- .../src/Storage/ComposeRequest.php | 36 +- .../Storage/ComposeRequestSourceObjects.php | 18 +- ...equestSourceObjectsObjectPreconditions.php | 10 +- .../apiclient-services/src/Storage/Expr.php | 34 +- .../apiclient-services/src/Storage/Folder.php | 55 +- .../src/Storage/FolderPendingRenameInfo.php | 6 +- .../src/Storage/Folders.php | 20 +- ...oogleLongrunningListOperationsResponse.php | 20 +- .../Storage/GoogleLongrunningOperation.php | 66 +- .../src/Storage/GoogleRpcStatus.php | 20 +- .../src/Storage/HmacKey.php | 16 +- .../src/Storage/HmacKeyMetadata.php | 62 +- .../src/Storage/HmacKeysMetadata.php | 20 +- .../src/Storage/ManagedFolder.php | 54 +- .../src/Storage/ManagedFolders.php | 20 +- .../src/Storage/Notification.php | 64 +- .../src/Storage/Notifications.php | 12 +- .../src/Storage/ObjectAccessControl.php | 90 +- .../ObjectAccessControlProjectTeam.php | 12 +- .../src/Storage/ObjectAccessControls.php | 12 +- .../Storage/ObjectCustomContextPayload.php | 92 ++ .../src/Storage/Objects.php | 28 +- .../apiclient-services/src/Storage/Policy.php | 43 +- .../src/Storage/PolicyBindings.php | 90 +- .../src/Storage/RelocateBucketRequest.php | 17 +- ...equestDestinationCustomPlacementConfig.php | 6 +- .../src/Storage/Resource/Buckets.php | 2 + .../src/Storage/Resource/Objects.php | 3 + .../src/Storage/RewriteResponse.php | 43 +- .../src/Storage/ServiceAccount.php | 14 +- .../src/Storage/StorageObject.php | 327 +++- .../src/Storage/StorageObjectContexts.php | 44 + .../StorageObjectCustomerEncryption.php | 12 +- .../src/Storage/StorageObjectOwner.php | 12 +- .../src/Storage/StorageObjectRetention.php | 14 +- .../Storage/TestIamPermissionsResponse.php | 48 +- lib/Google/vendor/google/auth/README.md | 14 +- lib/Google/vendor/google/auth/VERSION | 2 +- lib/Google/vendor/google/auth/autoload.php | 34 - lib/Google/vendor/google/auth/composer.json | 13 +- .../src/Cache/FileSystemCacheItemPool.php | 6 +- .../vendor/google/auth/src/Cache/Item.php | 175 --- .../auth/src/Cache/SysVCacheItemPool.php | 150 +- .../ExternalAccountCredentials.php | 9 + .../ImpersonatedServiceAccountCredentials.php | 25 +- .../google/auth/src/CredentialsLoader.php | 44 +- .../google/auth/src/Logging/LoggingTrait.php | 1 + lib/Google/vendor/google/cloud-core/VERSION | 2 +- .../vendor/google/cloud-core/composer.json | 11 +- .../google/cloud-core/src/ApiHelperTrait.php | 27 +- .../src/Batch/OpisClosureSerializer.php | 1 + .../src/Batch/OpisClosureSerializerV4.php | 52 + .../src/Batch/SerializableClientTrait.php | 3 + .../google/cloud-core/src/CallTrait.php | 40 - .../google/cloud-core/src/ClientTrait.php | 14 +- .../vendor/google/cloud-core/src/Iam/Iam.php | 2 +- .../LongRunningClientConnection.php | 123 ++ .../src/LongRunning/LongRunningOperation.php | 10 +- .../cloud-core/src/OptionsValidator.php | 109 ++ .../Report/CloudRunJobMetadataProvider.php | 2 +- .../CloudRunServiceMetadataProvider.php | 2 +- .../google/cloud-core/src/RequestHandler.php | 15 +- .../cloud-core/src/RequestWrapperTrait.php | 4 +- .../google/cloud-core/src/RestTrait.php | 2 + .../google/cloud-core/src/ServiceBuilder.php | 10 +- .../Reflection/ReflectionHandlerFactory.php | 6 +- .../Reflection/ReflectionHandlerV5.php | 190 --- .../Reflection/ReflectionHandlerV6.php | 142 +- .../src/Testing/Snippet/Parser/Snippet.php | 13 + .../src/Testing/Snippet/SnippetTestCase.php | 78 + .../google/cloud-core/src/TimeTrait.php | 14 +- .../google/cloud-core/src/Timestamp.php | 14 +- .../google/cloud-storage/.gitattributes | 3 + .../vendor/google/cloud-storage/VERSION | 2 +- .../vendor/google/cloud-storage/composer.json | 2 +- .../google/cloud-storage/src/Bucket.php | 102 +- .../cloud-storage/src/BucketIterator.php | 50 + .../cloud-storage/src/Connection/Rest.php | 57 +- .../src/Connection/RetryTrait.php | 4 +- .../ServiceDefinition/storage-v1.json | 12 + .../cloud-storage/src/SigningHelper.php | 8 +- .../cloud-storage/src/StorageClient.php | 109 +- .../cloud-storage/src/StorageObject.php | 150 +- .../vendor/google/common-protos/VERSION | 2 +- .../vendor/google/common-protos/composer.json | 6 +- lib/Google/vendor/google/gax/CHANGELOG.md | 53 + lib/Google/vendor/google/gax/README.md | 2 +- lib/Google/vendor/google/gax/VERSION | 2 +- lib/Google/vendor/google/gax/composer.json | 10 +- .../vendor/google/gax/src/ApiException.php | 11 +- .../google/gax/src/ClientOptionsTrait.php | 21 +- .../google/gax/src/GapicClientTrait.php | 50 +- .../CredentialsWrapperMiddleware.php | 2 + .../src/Middleware/FixedHeaderMiddleware.php | 2 + .../src/Middleware/OperationsMiddleware.php | 2 + .../Middleware/OptionsFilterMiddleware.php | 2 + .../gax/src/Middleware/PagedMiddleware.php | 2 + .../Middleware/ResponseMetadataMiddleware.php | 2 + .../gax/src/Middleware/RetryMiddleware.php | 2 + .../Middleware/TransportCallMiddleware.php | 60 + .../google/gax/src/OperationResponse.php | 33 +- .../google/gax/src/Options/CallOptions.php | 24 +- .../google/gax/src/Options/ClientOptions.php | 132 +- .../gax/src/Options/OptionsInterface.php | 38 + .../google/gax/src/Options/OptionsTrait.php | 7 +- .../gax/src/Options/TransportOptions.php | 29 +- .../GrpcFallbackTransportOptions.php | 24 +- .../TransportOptions/GrpcTransportOptions.php | 33 +- .../TransportOptions/RestTransportOptions.php | 27 +- .../vendor/google/gax/src/ServerStream.php | 4 +- .../google/gax/src/Testing/GeneratedTest.php | 2 +- .../gax/src/Testing/MockGrpcTransport.php | 5 +- .../gax/src/Testing/MockRequestBody.php | 6 +- .../google/gax/src/Testing/MockResponse.php | 6 +- .../gax/src/Transport/GrpcTransport.php | 17 +- .../grpc-gcp/.github/release-please.yml | 3 + .../grpc-gcp/.github/workflows/tests.yml | 30 + lib/Google/vendor/google/grpc-gcp/.gitmodules | 3 + .../vendor/google/protobuf/composer.json | 5 +- .../src/GPBMetadata/Google/Protobuf/Api.php | 2 +- .../Google/Protobuf/Internal/Descriptor.php | 1 + .../protobuf/src/Google/Protobuf/Api.php | 38 + .../protobuf/src/Google/Protobuf/Enum.php | 4 + .../src/Google/Protobuf/EnumValue.php | 4 + .../protobuf/src/Google/Protobuf/Field.php | 4 + .../src/Google/Protobuf/Internal/Edition.php | 7 + .../Google/Protobuf/Internal/FieldOptions.php | 21 +- .../Protobuf/Internal/GPBDecodeException.php | 2 +- .../Protobuf/Internal/RepeatedField.php | 2 +- .../protobuf/src/Google/Protobuf/Method.php | 74 +- .../protobuf/src/Google/Protobuf/Option.php | 3 + .../src/Google/Protobuf/Timestamp.php | 52 +- .../protobuf/src/Google/Protobuf/Type.php | 4 + .../vendor/monolog/monolog/CHANGELOG.md | 169 ++ lib/Google/vendor/monolog/monolog/README.md | 36 +- lib/Google/vendor/monolog/monolog/UPGRADE.md | 72 - .../vendor/monolog/monolog/composer.json | 33 +- .../Monolog/Attribute/AsMonologProcessor.php | 24 +- .../Monolog/Attribute/WithMonologChannel.php | 29 + .../monolog/src/Monolog/DateTimeImmutable.php | 37 +- .../monolog/src/Monolog/ErrorHandler.php | 152 +- .../Monolog/Formatter/ChromePHPFormatter.php | 56 +- .../Monolog/Formatter/ElasticaFormatter.php | 19 +- .../Formatter/ElasticsearchFormatter.php | 15 +- .../Monolog/Formatter/FlowdockFormatter.php | 38 +- .../Monolog/Formatter/FluentdFormatter.php | 25 +- .../Monolog/Formatter/FormatterInterface.php | 18 +- .../Formatter/GelfMessageFormatter.php | 125 +- .../Formatter/GoogleCloudLoggingFormatter.php | 16 +- .../src/Monolog/Formatter/HtmlFormatter.php | 56 +- .../src/Monolog/Formatter/JsonFormatter.php | 124 +- .../src/Monolog/Formatter/LineFormatter.php | 153 +- .../src/Monolog/Formatter/LogglyFormatter.php | 14 +- .../Monolog/Formatter/LogmaticFormatter.php | 32 +- .../Monolog/Formatter/LogstashFormatter.php | 49 +- .../Monolog/Formatter/MongoDBFormatter.php | 53 +- .../Monolog/Formatter/NormalizerFormatter.php | 151 +- .../src/Monolog/Formatter/ScalarFormatter.php | 20 +- .../src/Monolog/Formatter/SyslogFormatter.php | 65 + .../Monolog/Formatter/WildfireFormatter.php | 92 +- .../src/Monolog/Handler/AbstractHandler.php | 52 +- .../Handler/AbstractProcessingHandler.php | 27 +- .../Monolog/Handler/AbstractSyslogHandler.php | 79 +- .../src/Monolog/Handler/AmqpHandler.php | 89 +- .../Monolog/Handler/BrowserConsoleHandler.php | 92 +- .../src/Monolog/Handler/BufferHandler.php | 57 +- .../src/Monolog/Handler/ChromePHPHandler.php | 58 +- .../src/Monolog/Handler/CouchDBHandler.php | 38 +- .../src/Monolog/Handler/CubeHandler.php | 64 +- .../monolog/src/Monolog/Handler/Curl/Util.php | 25 +- .../Monolog/Handler/DeduplicationHandler.php | 106 +- .../Handler/DoctrineCouchDBHandler.php | 14 +- .../src/Monolog/Handler/DynamoDbHandler.php | 50 +- .../src/Monolog/Handler/ElasticaHandler.php | 42 +- .../Monolog/Handler/ElasticsearchHandler.php | 63 +- .../src/Monolog/Handler/ErrorLogHandler.php | 31 +- .../Monolog/Handler/FallbackGroupHandler.php | 19 +- .../src/Monolog/Handler/FilterHandler.php | 116 +- .../ActivationStrategyInterface.php | 8 +- .../ChannelLevelActivationStrategy.php | 42 +- .../ErrorLevelActivationStrategy.php | 20 +- .../Monolog/Handler/FingersCrossedHandler.php | 120 +- .../src/Monolog/Handler/FirePHPHandler.php | 24 +- .../src/Monolog/Handler/FleepHookHandler.php | 29 +- .../src/Monolog/Handler/FlowdockHandler.php | 32 +- .../Handler/FormattableHandlerInterface.php | 5 +- .../Handler/FormattableHandlerTrait.php | 11 +- .../src/Monolog/Handler/GelfHandler.php | 15 +- .../src/Monolog/Handler/GroupHandler.php | 34 +- .../monolog/src/Monolog/Handler/Handler.php | 17 +- .../src/Monolog/Handler/HandlerInterface.php | 27 +- .../src/Monolog/Handler/HandlerWrapper.php | 30 +- .../src/Monolog/Handler/IFTTTHandler.php | 23 +- .../src/Monolog/Handler/InsightOpsHandler.php | 24 +- .../src/Monolog/Handler/LogEntriesHandler.php | 24 +- .../src/Monolog/Handler/LogglyHandler.php | 64 +- .../src/Monolog/Handler/LogmaticHandler.php | 48 +- .../src/Monolog/Handler/MailHandler.php | 28 +- .../src/Monolog/Handler/MandrillHandler.php | 22 +- .../src/Monolog/Handler/MongoDBHandler.php | 33 +- .../Monolog/Handler/NativeMailerHandler.php | 53 +- .../src/Monolog/Handler/NewRelicHandler.php | 99 +- .../src/Monolog/Handler/NoopHandler.php | 10 +- .../src/Monolog/Handler/NullHandler.php | 30 +- .../src/Monolog/Handler/OverflowHandler.php | 48 +- .../src/Monolog/Handler/PHPConsoleHandler.php | 144 +- .../src/Monolog/Handler/ProcessHandler.php | 40 +- .../Handler/ProcessableHandlerInterface.php | 7 +- .../Handler/ProcessableHandlerTrait.php | 21 +- .../src/Monolog/Handler/PsrHandler.php | 41 +- .../src/Monolog/Handler/PushoverHandler.php | 136 +- .../src/Monolog/Handler/RedisHandler.php | 53 +- .../Monolog/Handler/RedisPubSubHandler.php | 32 +- .../src/Monolog/Handler/RollbarHandler.php | 75 +- .../Monolog/Handler/RotatingFileHandler.php | 122 +- .../src/Monolog/Handler/SamplingHandler.php | 59 +- .../src/Monolog/Handler/SendGridHandler.php | 101 +- .../src/Monolog/Handler/Slack/SlackRecord.php | 172 +-- .../src/Monolog/Handler/SlackHandler.php | 57 +- .../Monolog/Handler/SlackWebhookHandler.php | 34 +- .../src/Monolog/Handler/SocketHandler.php | 104 +- .../src/Monolog/Handler/SqsHandler.php | 21 +- .../src/Monolog/Handler/StreamHandler.php | 130 +- .../Monolog/Handler/SwiftMailerHandler.php | 115 -- .../Monolog/Handler/SymfonyMailerHandler.php | 32 +- .../src/Monolog/Handler/SyslogHandler.php | 25 +- .../Monolog/Handler/SyslogUdp/UdpSocket.php | 35 +- .../src/Monolog/Handler/SyslogUdpHandler.php | 52 +- .../Monolog/Handler/TelegramBotHandler.php | 135 +- .../src/Monolog/Handler/TestHandler.php | 194 +-- .../Handler/WebRequestRecognizerTrait.php | 1 - .../Handler/WhatFailureGroupHandler.php | 27 +- .../Monolog/Handler/ZendMonitorHandler.php | 77 +- .../JsonSerializableDateTimeImmutable.php | 48 + .../monolog/monolog/src/Monolog/Level.php | 209 +++ .../monolog/monolog/src/Monolog/LogRecord.php | 115 +- .../monolog/monolog/src/Monolog/Logger.php | 367 +++-- .../Processor/ClosureContextProcessor.php | 51 + .../src/Monolog/Processor/GitProcessor.php | 28 +- .../Monolog/Processor/HostnameProcessor.php | 11 +- .../Processor/IntrospectionProcessor.php | 59 +- .../Processor/LoadAverageProcessor.php | 66 + .../Processor/MemoryPeakUsageProcessor.php | 8 +- .../src/Monolog/Processor/MemoryProcessor.php | 5 +- .../Processor/MemoryUsageProcessor.php | 8 +- .../Monolog/Processor/MercurialProcessor.php | 35 +- .../Monolog/Processor/ProcessIdProcessor.php | 8 +- .../Monolog/Processor/ProcessorInterface.php | 11 +- .../Processor/PsrLogMessageProcessor.php | 37 +- .../src/Monolog/Processor/TagProcessor.php | 16 +- .../src/Monolog/Processor/UidProcessor.php | 22 +- .../src/Monolog/Processor/WebProcessor.php | 30 +- .../monolog/monolog/src/Monolog/Registry.php | 11 +- .../src/Monolog/ResettableInterface.php | 5 +- .../monolog/src/Monolog/SignalHandler.php | 41 +- .../src/Monolog/Test/MonologTestCase.php | 71 + .../monolog/src/Monolog/Test/TestCase.php | 66 +- .../monolog/monolog/src/Monolog/Utils.php | 101 +- .../paragonie/random_compat/build-phar.sh | 5 + .../vendor/phpseclib/phpseclib/BACKERS.md | 3 +- .../vendor/phpseclib/phpseclib/README.md | 4 +- .../vendor/phpseclib/phpseclib/SECURITY.md | 13 + .../phpseclib/Crypt/RSA/Formats/Keys/PSS.php | 2 +- .../phpseclib/phpseclib/File/ASN1.php | 5 +- .../Math/BigInteger/Engines/BCMath.php | 2 +- .../phpseclib/phpseclib/phpseclib/Net/SCP.php | 303 ++++ .../phpseclib/phpseclib/Net/SFTP.php | 1 - .../phpseclib/phpseclib/Net/SSH2.php | 24 +- .../psr/cache/src/CacheItemInterface.php | 12 +- .../psr/cache/src/CacheItemPoolInterface.php | 22 +- lib/Google/vendor/ramsey/collection/README.md | 11 - .../vendor/ramsey/collection/composer.json | 52 +- .../collection/conventional-commits.json | 22 - .../ramsey/collection/src/AbstractArray.php | 57 +- .../collection/src/AbstractCollection.php | 242 +-- .../ramsey/collection/src/AbstractSet.php | 19 +- .../ramsey/collection/src/ArrayInterface.php | 4 +- .../ramsey/collection/src/Collection.php | 21 +- .../collection/src/CollectionInterface.php | 111 +- .../collection/src/DoubleEndedQueue.php | 127 +- .../src/DoubleEndedQueueInterface.php | 36 +- ...rException.php => CollectionException.php} | 7 +- .../Exception/CollectionMismatchException.php | 2 +- .../Exception/InvalidArgumentException.php | 4 +- ...eption.php => InvalidPropertyOrMethod.php} | 6 +- .../src/Exception/NoSuchElementException.php | 2 +- .../src/Exception/OutOfBoundsException.php | 4 +- .../UnsupportedOperationException.php | 2 +- .../ramsey/collection/src/Map/AbstractMap.php | 108 +- .../collection/src/Map/AbstractTypedMap.php | 17 +- .../src/Map/AssociativeArrayMap.php | 3 +- .../collection/src/Map/MapInterface.php | 57 +- .../collection/src/Map/NamedParameterMap.php | 21 +- .../ramsey/collection/src/Map/TypedMap.php | 36 +- .../collection/src/Map/TypedMapInterface.php | 3 +- .../vendor/ramsey/collection/src/Queue.php | 97 +- .../ramsey/collection/src/QueueInterface.php | 18 +- .../vendor/ramsey/collection/src/Set.php | 16 +- .../vendor/ramsey/collection/src/Sort.php | 31 + .../ramsey/collection/src/Tool/TypeTrait.php | 49 +- .../src/Tool/ValueExtractorTrait.php | 77 +- .../src/Tool/ValueToStringTrait.php | 18 +- lib/Google/vendor/ramsey/uuid/composer.json | 2 +- .../src/Converter/Time/PhpTimeConverter.php | 2 +- .../rize/uri-template/.php-cs-fixer.dist.php | 19 + lib/Google/vendor/rize/uri-template/README.md | 10 +- .../vendor/rize/uri-template/composer.json | 11 +- .../vendor/rize/uri-template/phpstan.neon | 5 + .../vendor/rize/uri-template/phpunit.xml | 22 + .../uri-template/src/Rize/UriTemplate.php | 69 +- .../src/Rize/UriTemplate/Node/Abstraction.php | 44 +- .../src/Rize/UriTemplate/Node/Expression.php | 97 +- .../src/Rize/UriTemplate/Node/Literal.php | 10 +- .../src/Rize/UriTemplate/Node/Variable.php | 26 +- .../Rize/UriTemplate/Operator/Abstraction.php | 345 ++--- .../src/Rize/UriTemplate/Operator/Named.php | 109 +- .../src/Rize/UriTemplate/Operator/UnNamed.php | 24 +- .../src/Rize/UriTemplate/Parser.php | 77 +- .../src/Rize/UriTemplate/UriTemplate.php | 6 +- .../tests/Rize/Uri/Node/ParserTest.php | 93 ++ .../tests/Rize/UriTemplateTest.php | 253 +++ .../uri-template/tests/fixtures/README.md | 90 ++ .../tests/fixtures/extended-tests.json | 118 ++ .../uri-template/tests/fixtures/json2xml.xslt | 201 +++ .../tests/fixtures/negative-tests.json | 57 + .../fixtures/spec-examples-by-section.json | 439 ++++++ .../tests/fixtures/spec-examples.json | 218 +++ .../tests/fixtures/transform-json-tests.xslt | 51 + .../symfony/deprecation-contracts/LICENSE | 2 +- .../symfony/deprecation-contracts/README.md | 2 +- .../deprecation-contracts/composer.json | 4 +- .../vendor/symfony/polyfill-php81/LICENSE | 19 - .../vendor/symfony/polyfill-php81/Php81.php | 37 - .../vendor/symfony/polyfill-php81/README.md | 18 - .../Resources/stubs/CURLStringFile.php | 51 - .../Resources/stubs/ReturnTypeWillChange.php | 20 - .../symfony/polyfill-php81/bootstrap.php | 28 - .../symfony/polyfill-php81/composer.json | 33 - lib/meta-box-tabs/CHANGELOG.md | 141 ++ lib/meta-box-tabs/meta-box-tabs.php | 8 +- lib/meta-box-tabs/tabs.js | 47 +- readme.txt | 14 +- vendor/autoload.php | 5 +- vendor/composer/InstalledVersions.php | 45 +- vendor/composer/autoload_classmap.php | 108 -- vendor/composer/autoload_static.php | 120 +- vendor/composer/installed.json | 16 +- vendor/composer/installed.php | 16 +- vendor/composer/platform_check.php | 5 +- vendor/udx/lib-wp-bootstrap/changes.md | 4 + .../lib/classes/class-bootstrap-theme.php | 2 +- vendor/wpmetabox/meta-box/css/style.css | 4 +- vendor/wpmetabox/meta-box/inc/clone.php | 12 +- vendor/wpmetabox/meta-box/inc/core.php | 13 +- .../wpmetabox/meta-box/inc/field-registry.php | 2 +- vendor/wpmetabox/meta-box/inc/field.php | 8 +- .../meta-box/inc/fields/autocomplete.php | 1 + .../meta-box/inc/fields/checkbox.php | 2 +- .../wpmetabox/meta-box/inc/fields/choice.php | 2 +- vendor/wpmetabox/meta-box/inc/fields/date.php | 2 +- .../meta-box/inc/fields/datetime.php | 2 +- .../wpmetabox/meta-box/inc/fields/divider.php | 4 +- .../meta-box/inc/fields/fieldset-text.php | 2 +- vendor/wpmetabox/meta-box/inc/fields/file.php | 11 +- .../wpmetabox/meta-box/inc/fields/heading.php | 4 +- vendor/wpmetabox/meta-box/inc/fields/icon.php | 7 +- .../meta-box/inc/fields/image-select.php | 5 +- .../wpmetabox/meta-box/inc/fields/input.php | 8 +- .../meta-box/inc/fields/key-value.php | 4 +- vendor/wpmetabox/meta-box/inc/fields/map.php | 21 +- .../wpmetabox/meta-box/inc/fields/media.php | 2 +- .../meta-box/inc/fields/object-choice.php | 4 +- vendor/wpmetabox/meta-box/inc/fields/osm.php | 23 +- vendor/wpmetabox/meta-box/inc/fields/post.php | 17 +- .../wpmetabox/meta-box/inc/fields/sidebar.php | 2 +- .../meta-box/inc/fields/text-list.php | 2 +- vendor/wpmetabox/meta-box/inc/fields/time.php | 2 +- vendor/wpmetabox/meta-box/inc/fields/user.php | 13 +- .../wpmetabox/meta-box/inc/helpers/field.php | 4 +- .../wpmetabox/meta-box/inc/helpers/string.php | 2 +- vendor/wpmetabox/meta-box/inc/loader.php | 15 +- .../meta-box/inc/meta-box-registry.php | 2 +- vendor/wpmetabox/meta-box/inc/meta-box.php | 22 +- vendor/wpmetabox/meta-box/inc/request.php | 2 +- vendor/wpmetabox/meta-box/inc/sanitizer.php | 1 + vendor/wpmetabox/meta-box/inc/shortcode.php | 8 +- .../meta-box/inc/walkers/input-list.php | 1 + .../meta-box/inc/walkers/select-tree.php | 3 +- .../wpmetabox/meta-box/inc/walkers/select.php | 1 + vendor/wpmetabox/meta-box/js/clone.js | 39 +- vendor/wpmetabox/meta-box/meta-box.php | 2 +- vendor/wpmetabox/meta-box/readme.txt | 27 +- .../src/Dashboard/assets/css/dashboard.css | 2 +- .../src/Dashboard/assets/css/dashboard.scss | 95 ++ .../meta-box/src/Dashboard/assets/img/hot.svg | 9 + .../meta-box/src/Dashboard/content.php | 79 +- .../meta-box/src/Integrations/Block.php | 2 +- .../wpml.php => src/Integrations/WPML.php} | 53 +- .../meta-box/src/Updater/Checker.php | 5 +- .../meta-box/src/Updater/Notification.php | 2 +- .../wpmetabox/meta-box/src/Updater/Option.php | 6 +- .../meta-box/vendor/composer/installed.php | 12 +- wp-stateless-media.php | 2 +- 481 files changed, 13824 insertions(+), 7959 deletions(-) delete mode 100644 lib/Google/CODE_OF_CONDUCT.md delete mode 100644 lib/Google/UPGRADING.md create mode 100644 lib/Google/vendor/brick/math/psalm-baseline.xml create mode 100644 lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerManagedEncryptionEnforcementConfig.php create mode 100644 lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig.php create mode 100644 lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionGoogleManagedEncryptionEnforcementConfig.php create mode 100644 lib/Google/vendor/google/apiclient-services/src/Storage/ObjectCustomContextPayload.php create mode 100644 lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectContexts.php delete mode 100644 lib/Google/vendor/google/auth/autoload.php delete mode 100644 lib/Google/vendor/google/auth/src/Cache/Item.php create mode 100644 lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializerV4.php delete mode 100644 lib/Google/vendor/google/cloud-core/src/CallTrait.php create mode 100644 lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningClientConnection.php create mode 100644 lib/Google/vendor/google/cloud-core/src/OptionsValidator.php delete mode 100644 lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV5.php create mode 100644 lib/Google/vendor/google/cloud-storage/.gitattributes create mode 100644 lib/Google/vendor/google/cloud-storage/src/BucketIterator.php create mode 100644 lib/Google/vendor/google/gax/src/Middleware/TransportCallMiddleware.php create mode 100644 lib/Google/vendor/google/gax/src/Options/OptionsInterface.php create mode 100644 lib/Google/vendor/google/grpc-gcp/.github/release-please.yml create mode 100644 lib/Google/vendor/google/grpc-gcp/.github/workflows/tests.yml create mode 100644 lib/Google/vendor/google/grpc-gcp/.gitmodules delete mode 100644 lib/Google/vendor/monolog/monolog/UPGRADE.md create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/WithMonologChannel.php create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/SyslogFormatter.php delete mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/JsonSerializableDateTimeImmutable.php create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Level.php create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ClosureContextProcessor.php create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Processor/LoadAverageProcessor.php create mode 100644 lib/Google/vendor/monolog/monolog/src/Monolog/Test/MonologTestCase.php create mode 100755 lib/Google/vendor/paragonie/random_compat/build-phar.sh create mode 100644 lib/Google/vendor/phpseclib/phpseclib/SECURITY.md create mode 100644 lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php delete mode 100644 lib/Google/vendor/ramsey/collection/conventional-commits.json rename lib/Google/vendor/ramsey/collection/src/Exception/{InvalidSortOrderException.php => CollectionException.php} (70%) rename lib/Google/vendor/ramsey/collection/src/Exception/{ValueExtractionException.php => InvalidPropertyOrMethod.php} (62%) create mode 100644 lib/Google/vendor/ramsey/collection/src/Sort.php create mode 100644 lib/Google/vendor/rize/uri-template/.php-cs-fixer.dist.php create mode 100644 lib/Google/vendor/rize/uri-template/phpstan.neon create mode 100644 lib/Google/vendor/rize/uri-template/phpunit.xml create mode 100644 lib/Google/vendor/rize/uri-template/tests/Rize/Uri/Node/ParserTest.php create mode 100644 lib/Google/vendor/rize/uri-template/tests/Rize/UriTemplateTest.php create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/README.md create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/extended-tests.json create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/json2xml.xslt create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/negative-tests.json create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples-by-section.json create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples.json create mode 100644 lib/Google/vendor/rize/uri-template/tests/fixtures/transform-json-tests.xslt delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/LICENSE delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/Php81.php delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/README.md delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/bootstrap.php delete mode 100644 lib/Google/vendor/symfony/polyfill-php81/composer.json create mode 100644 lib/meta-box-tabs/CHANGELOG.md create mode 100644 vendor/wpmetabox/meta-box/src/Dashboard/assets/img/hot.svg rename vendor/wpmetabox/meta-box/{inc/wpml.php => src/Integrations/WPML.php} (69%) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 9ff0505c1..bee8f0e2f 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -4,9 +4,12 @@ run-name: Publish Release on: workflow_dispatch: inputs: - release: - description: 'Release version (e.g. 1.2.3)' + tag: + description: 'Release tag (e.g. 1.2.3a)' required: true + version: + description: 'Release version (e.g. 1.2.3), default: latest' + required: false prerelease: description: 'Pre-release version (e.g. RC1, beta, etc...)' required: false @@ -14,139 +17,10 @@ on: permissions: contents: write -env: - TAG: ${{ github.event.inputs.release }} - PRETAG: ${{ github.event.inputs.prerelease }} - BRANCH: temp-release-${{ github.event.inputs.release }} - jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Prepare vars - id: vars - uses: actions/github-script@v7 - with: - script: | - const full_tag = [ - process.env.TAG, - process.env.PRETAG - ].filter(Boolean).join('-'); - const branch = `temp-release-${full_tag}`; - const is_prerelease = !!process.env.PRETAG; - - core.setOutput('full_tag', full_tag ); - core.setOutput('branch', branch ); - core.setOutput('is_prerelease', is_prerelease ); - - # 'ref' and 'repository' are required, otherwise repo could appear in detached head state - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - repository: ${{ github.repository }} - - - name: Parse Changelog Entries - uses: actions/github-script@v7 - id: changelog - with: - script: | - const { open } = require('fs/promises'); - - const version = process.env.TAG; - const delimiter = '#### '; - const file = await open('./changes.md'); - - let description = []; - let found = false; - - for await (let line of file.readLines()) { - line = line.trim(); - - if ( line.startsWith(`${delimiter}${version}`) ) { - found = true; - continue; - } - - if (!found) continue; - if ( line.startsWith(delimiter) ) break; - - description.push(line); - } - - if ( !description.length ) core.setFailed(`Release ${version} not found in the changelog!`); - - core.setOutput('description', description.join('\n') ); - - - # cleanup files that are not needed for the release - # but keep the .git folder, because we need it for the next step - - name: Cleanup files - run: | - rm -f composer.lock || true - rm -rf tests || true - rm -rf vendor/bin || true - rm -rf vendor/composer/installers || true - find ./ -name '.git*' -not -path './.git' -type f -delete || true - find ./ -name '.git*' -not -path './.git' -type d -exec rm -rf {} \; || true - find ./vendor -name .svn -exec rm -rf {} \; || true - - # cleanup files, specific to Google API PHP library - - name: Cleanup files for Google API library - run: | - rm -f lib/Google/phpstan.neon.dist || true - rm -f lib/Google/vendor/paragonie/random_compat/build-phar.sh || true - find ./lib/Google/ -name '.repo-metadata.json' -type f -delete || true - find ./lib/Google/vendor -name .svn -exec rm -rf '{}' \; || true - - # commit changes to temporary release branch and create a new tag - - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - message: Cleanup files for release - new_branch: ${{ steps.vars.outputs.branch }} - tag: ${{ steps.vars.outputs.full_tag }} - - # generate SBOM that will be attached to a release as an artifact - - name: Create SBOM - id: sbom - uses: anchore/sbom-action@v0 - with: - path: . - output-file: sbom.spdx.json - format: spdx-json - - # create a draft release with the version changelog as a description - - name: Create Draft Release - id: draft_release - uses: softprops/action-gh-release@v2 - with: - name: "Release ${{ steps.vars.outputs.full_tag }}" - body: "${{ steps.changelog.outputs.description }}" - tag_name: ${{ steps.vars.outputs.full_tag }} - draft: true - prerelease: ${{ steps.vars.outputs.is_prerelease }} - - # attach SBOM to release - - name: Upload SBOM to release - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.draft_release.outputs.upload_url }} - asset_path: ./sbom.spdx.json - asset_name: sbom.spdx.json - asset_content_type: application/json - - # publish release using an ID from the 'draft_release' step - - name: Publish Release - uses: eregon/publish-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - release_id: ${{ steps.draft_release.outputs.id }} - - # delete temporary release branch - - name: Delete temporary release branch - run: | - git push origin --delete ${{ steps.vars.outputs.branch }} + release: + uses: udx/reusable-workflows/.github/workflows/wp-gh-release-ops.yml@master + with: + tag: ${{ github.event.inputs.tag }} + version: ${{ github.event.inputs.version }} + prerelease: ${{ github.event.inputs.prerelease }} diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index c4dafb1cd..44a52ea1b 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Run Security Check id: test diff --git a/changelog.txt b/changelog.txt index 61e1c9566..c17f49bad 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,12 @@ == Changelog == += 4.4.0 = +* NEW - plugin requires PHP 8.1+. +* ENHANCEMENT - updated `firebase/php-jwt` library from 6.11.1 to 7.0.2. +* ENHANCEMENT - Updated Client library for Google APIs from 2.18.3 to 2.18.4. +* ENHANCEMENT - updated `wpmetabox/meta-box` library from 5.10.15 to 5.10.19. +* ENHANCEMENT - updated `Meta Box Tabs` library from 1.1.18 to 1.2.0. +* FIX - `udx/lib-wp-bootstrap` package correctly loads text domain to prevent PHP notices. + = 4.3.0 = * ENHANCEMENT - update dependencies for Google APIs Client Library. * COMPATIBILITY - Simple Local Avatars Compatibility replaced with [WP-Stateless - Simple Local Avatars Addon](https://wordpress.org/plugins/wp-stateless-simple-local-avatars-addon/). diff --git a/changes.md b/changes.md index 4860233af..1018865a9 100644 --- a/changes.md +++ b/changes.md @@ -1,3 +1,11 @@ +#### 4.4.0 +* NEW - plugin requires PHP 8.1+. +* ENHANCEMENT - updated `firebase/php-jwt` library from 6.11.1 to 7.0.2. +* ENHANCEMENT - Updated Client library for Google APIs from 2.18.3 to 2.18.4. +* ENHANCEMENT - updated `wpmetabox/meta-box` library from 5.10.15 to 5.10.19. +* ENHANCEMENT - updated `Meta Box Tabs` library from 1.1.18 to 1.2.0. +* FIX - `udx/lib-wp-bootstrap` package correctly loads text domain to prevent PHP notices. + #### 4.3.0 * ENHANCEMENT - update dependencies for Google APIs Client Library. * COMPATIBILITY - Simple Local Avatars Compatibility replaced with [WP-Stateless - Simple Local Avatars Addon](https://wordpress.org/plugins/wp-stateless-simple-local-avatars-addon/). diff --git a/composer.lock b/composer.lock index 8d1b09bc0..7e3a1cd83 100644 --- a/composer.lock +++ b/composer.lock @@ -307,15 +307,15 @@ }, { "name": "udx/lib-wp-bootstrap", - "version": "1.3.3", + "version": "1.3.4", "source": { "type": "git", "url": "git@github.com:udx/lib-wp-bootstrap", - "reference": "1.3.3" + "reference": "1.3.4" }, "dist": { "type": "zip", - "url": "https://github.com/udx/lib-wp-bootstrap/archive/1.3.3.zip" + "url": "https://github.com/udx/lib-wp-bootstrap/archive/1.3.4.zip" }, "require": { "php": ">=5.3" @@ -340,15 +340,15 @@ }, { "name": "wpackagist-plugin/meta-box", - "version": "5.10.15", + "version": "5.10.19", "source": { "type": "svn", "url": "https://plugins.svn.wordpress.org/meta-box/", - "reference": "tags/5.10.15" + "reference": "tags/5.10.19" }, "dist": { "type": "zip", - "url": "https://downloads.wordpress.org/plugin/meta-box.5.10.15.zip" + "url": "https://downloads.wordpress.org/plugin/meta-box.5.10.19.zip" }, "require": { "composer/installers": "^1.0 || ^2.0" @@ -1567,12 +1567,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">=7.4" }, - "platform-dev": [], - "plugin-api-version": "2.6.0" + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/lib/Google/CHANGELOG.md b/lib/Google/CHANGELOG.md index 00f046fb5..a0418c111 100644 --- a/lib/Google/CHANGELOG.md +++ b/lib/Google/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [2.18.4](https://github.com/googleapis/google-api-php-client/compare/v2.18.3...v2.18.4) (2025-09-29) + + +### Bug Fixes + +* Ensure credentials can be of type FetchAuthTokenInterface ([#2684](https://github.com/googleapis/google-api-php-client/issues/2684)) ([ed70802](https://github.com/googleapis/google-api-php-client/commit/ed70802cc4886ef1f513a2c0b56a8a972db5e7ab)) + +## [2.18.3](https://github.com/googleapis/google-api-php-client/compare/v2.18.2...v2.18.3) (2025-04-08) + + +### Bug Fixes + +* Convert Finder lazy iterator to array before deletion ([#2663](https://github.com/googleapis/google-api-php-client/issues/2663)) ([c699405](https://github.com/googleapis/google-api-php-client/commit/c6994051af1568359c97d267d9ef34ccbda31387)) + ## [2.18.2](https://github.com/googleapis/google-api-php-client/compare/v2.18.1...v2.18.2) (2024-12-16) diff --git a/lib/Google/CODE_OF_CONDUCT.md b/lib/Google/CODE_OF_CONDUCT.md deleted file mode 100644 index 46b2a08ea..000000000 --- a/lib/Google/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,43 +0,0 @@ -# Contributor Code of Conduct - -As contributors and maintainers of this project, -and in the interest of fostering an open and welcoming community, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. - -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, -such as physical or electronic -addresses, without explicit permission -* Other unethical or unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct. -By adopting this Code of Conduct, -project maintainers commit themselves to fairly and consistently -applying these principles to every aspect of managing this project. -Project maintainers who do not follow or enforce the Code of Conduct -may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, -available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) diff --git a/lib/Google/UPGRADING.md b/lib/Google/UPGRADING.md deleted file mode 100644 index ef939e943..000000000 --- a/lib/Google/UPGRADING.md +++ /dev/null @@ -1,377 +0,0 @@ -Google API Client Upgrade Guide -=============================== - -2.x to 2.10.0 -------------- - -### Namespaces - -The Google API Client for PHP now uses namespaces for all classes. Code using -the legacy classnames will continue to work, but it is advised to upgrade to the -underspaced names, as the legacy classnames will be deprecated some time in the -future. - -**Before** - -```php -$client = new Google_Client(); -$service = new Google_Service_Books($client); -``` - -**After** -```php -$client = new Google\Client(); -$service = new Google\Service\Books($client); -``` - -### Service class constructors - -Service class constructors now accept an optional `Google\Client|array` parameter -as their first argument, rather than requiring an instance of `Google\Client`. - -**Before** - -```php -$client = new Google_Client(); -$client->setApplicationName("Client_Library_Examples"); -$client->setDeveloperKey("YOUR_APP_KEY"); - -$service = new Google_Service_Books($client); -``` - -**After** - -```php -$service = new Google\Service\Books([ - 'application_name' => "Client_Library_Examples", - 'developer_key' => "YOUR_APP_KEY", -]); -``` - -1.0 to 2.0 ----------- - -The Google API Client for PHP has undergone major internal changes in `2.0`. Please read through -the list below in order to upgrade to the latest version: - -## Installation now uses `Composer` - -**Before** - -The project was cloned in your project and you would run the autoloader from wherever: - -```php -// the autoload file was included -require_once 'google-api-php-client/src/Google/autoload.php'; // or wherever autoload.php is located -// OR classes were added one-by-one -require_once 'Google/Client.php'; -require_once 'Google/Service/YouTube.php'; -``` - -**After** - -This library now uses [composer](https://getcomposer.org) (We suggest installing -composer [globally](http://symfony.com/doc/current/cookbook/composer.html)). Add this library by -running the following in the root of your project: - -``` -$ composer require google/apiclient:~2.0 -``` - -This will install this library and generate an autoload file in `vendor/autoload.php` in the root -of your project. You can now include this library with the following code: - -```php -require_once 'vendor/autoload.php'; -``` - -## Access Tokens are passed around as arrays instead of JSON strings - -**Before** - -```php -$accessToken = $client->getAccessToken(); -print_r($accessToken); -// would output: -// string(153) "{"access_token":"ya29.FAKsaByOPoddfzvKRo_LBpWWCpVTiAm4BjsvBwxtN7IgSNoUfcErBk_VPl4iAiE1ntb_","token_type":"Bearer","expires_in":3593,"created":1445548590}" -file_put_contents($credentialsPath, $accessToken); -``` - -**After** - -```php -$accessToken = $client->getAccessToken(); -print_r($accessToken); -// will output: -// array(4) { -// ["access_token"]=> -// string(73) "ya29.FAKsaByOPoddfzvKRo_LBpWWCpVTiAm4BjsvBwxtN7IgSNoUfcErBk_VPl4iAiE1ntb_" -// ["token_type"]=> -// string(6) "Bearer" -// ["expires_in"]=> -// int(3593) -// ["created"]=> -// int(1445548590) -// } -file_put_contents($credentialsPath, json_encode($accessToken)); -``` - -## ID Token data is returned as an array - -**Before** - -```php -$ticket = $client->verifyIdToken($idToken); -$data = $ticket->getAttributes(); -$userId = $data['payload']['sub']; -``` - -**After** - -```php -$userData = $client->verifyIdToken($idToken); -$userId = $userData['sub']; -``` - -## `Google_Auth_AssertionCredentials` has been removed - -For service accounts, we now use `setAuthConfig` or `useApplicationDefaultCredentials` - -**Before** - -```php -$client_email = '1234567890-a1b2c3d4e5f6g7h8i@developer.gserviceaccount.com'; -$private_key = file_get_contents('MyProject.p12'); -$scopes = array('https://www.googleapis.com/auth/sqlservice.admin'); -$credentials = new Google_Auth_AssertionCredentials( - $client_email, - $scopes, - $private_key -); -``` - -**After** - -```php -$client->setAuthConfig('/path/to/service-account.json'); - -// OR use environment variables (recommended) - -putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json'); -$client->useApplicationDefaultCredentials(); -``` - -> Note: P12s are deprecated in favor of service account JSON, which can be generated in the -> Credentials section of Google Developer Console. - -In order to impersonate a user, call `setSubject` when your service account -credentials are being used. - -**Before** - -```php -$user_to_impersonate = 'user@example.org'; -$credentials = new Google_Auth_AssertionCredentials( - $client_email, - $scopes, - $private_key, - 'notasecret', // Default P12 password - 'http://oauth.net/grant_type/jwt/1.0/bearer', // Default grant type - $user_to_impersonate, -); -``` - -**After** - -```php -$user_to_impersonate = 'user@example.org'; -$client->setSubject($user_to_impersonate); -``` - -Additionally, `Google_Client::loadServiceAccountJson` has been removed in favor -of `Google_Client::setAuthConfig`: - -**Before** - -```php -$scopes = [ Google_Service_Books::BOOKS ]; -$client->loadServiceAccountJson('/path/to/service-account.json', $scopes); -``` - -**After** - -```php -$scopes = [ Google_Service_Books::BOOKS ]; -$client->setAuthConfig('/path/to/service-account.json'); -$client->setScopes($scopes); -``` - -## `Google_Auth_AppIdentity` has been removed - -For App Engine authentication, we now use the underlying [`google/auth`][Google Auth] and -call `useApplicationDefaultCredentials`: - -**Before** - -```php -$client->setAuth(new Google_Auth_AppIdentity($client)); -$client->getAuth() - ->authenticateForScope('https://www.googleapis.com/auth/sqlservice.admin') -``` - -**After** - -```php -$client->useApplicationDefaultCredentials(); -$client->addScope('https://www.googleapis.com/auth/sqlservice.admin'); -``` - -This will detect when the App Engine environment is present, and use the appropriate credentials. - -## `Google_Auth_Abstract` classes have been removed - -[`google/auth`][Google Auth] is now used for authentication. As a result, all -`Google_Auth`-related functionality has been removed. The methods that were a part of -`Google_Auth_Abstract` have been moved into the `Google_Client` object. - -**Before** - -```php -$request = new Google_Http_Request(); -$client->getAuth()->sign($request); -``` - -**After** - -```php -// create an authorized HTTP client -$httpClient = $client->authorize(); - -// OR add authorization to an existing client -$httpClient = new GuzzleHttp\Client(); -$httpClient = $client->authorize($httpClient); -``` - -**Before** - -```php -$request = new Google_Http_Request(); -$response = $client->getAuth()->authenticatedRequest($request); -``` - -**After** - -```php -$httpClient = $client->authorize(); -$request = new GuzzleHttp\Psr7\Request('POST', $url); -$response = $httpClient->send($request); -``` - -> NOTE: `$request` can be any class implementing -> `Psr\Http\Message\RequestInterface` - -In addition, other methods that were callable on `Google_Auth_OAuth2` are now called -on the `Google_Client` object: - -**Before** - -```php -$client->getAuth()->refreshToken($token); -$client->getAuth()->refreshTokenWithAssertion(); -$client->getAuth()->revokeToken($token); -$client->getAuth()->isAccessTokenExpired(); -``` - -**After** - -```php -$client->refreshToken($token); -$client->refreshTokenWithAssertion(); -$client->revokeToken($token); -$client->isAccessTokenExpired(); -``` - -## PHP 5.6 is now the minimum supported PHP version - -This was previously `PHP 5.2`. If you still need to use PHP 5.2, please continue to use -the [v1-master](https://github.com/google/google-api-php-client/tree/v1-master) branch. - -## Guzzle and PSR-7 are used for HTTP Requests - -The HTTP library Guzzle is used for all HTTP Requests. By default, [`Guzzle 6`][Guzzle 6] -is used, but this library is also compatible with [`Guzzle 5`][Guzzle 5]. As a result, -all `Google_IO`-related functionality and `Google_Http`-related functionality has been -changed or removed. - -1. Removed `Google_Http_Request` -1. Removed `Google_IO_Abstract`, `Google_IO_Exception`, `Google_IO_Curl`, and `Google_IO_Stream` -1. Removed methods `Google_Client::getIo` and `Google_Client::setIo` -1. Refactored `Google_Http_Batch` and `Google_Http_MediaFileUpload` for Guzzle -1. Added `Google_Client::getHttpClient` and `Google_Client::setHttpClient` for getting and -setting the Guzzle `GuzzleHttp\ClientInterface` object. - -> NOTE: `PSR-7`-compatible libraries can now be used with this library. - -## Other Changes - - - [`PSR 3`][PSR 3] `LoggerInterface` is now supported, and [Monolog][Monolog] is used for all - logging. As a result, all `Google_Logger`-related functionality has been removed: - 1. Removed `Google_Logger_Abstract`, `Google_Logger_Exception`, `Google_Logger_File`, - `Google_Logger_Null`, and `Google_Logger_Psr` - 1. `Google_Client::setLogger` now requires `Psr\Log\LoggerInterface` - - [`firebase/jwt`][Firebase JWT] is now used for all JWT signing and verifying. As a result, the - following classes have been changed or removed: - 1. Removed `Google_Signer_P12` - 1. Removed `Google_Verifier_Pem` - 1. Removed `Google_Auth_LoginTicket` (see below) - - The following classes and methods have been removed in favor of [`google/auth`][Google Auth]: - 1. Removed methods `Google_Client::getAuth` and `Google_Client::setAuth` - 1. Removed `Google_Auth_Abstract` - - `Google_Auth_Abstract::sign` and `Google_Auth_Abstract::authenticatedRequest` have been - replaced by `Google_Client::authorize`. See the above examples for more details. - 1. Removed `Google_Auth_AppIdentity`. This is now supported in [`google/auth`][Google Auth AppIdentity] - and is used automatically when `Google_Client::useApplicationDefaultCredentials` is called. - 1. Removed `Google_Auth_AssertionCredentials`. Use `Google_Client::setAuthConfig` instead. - 1. Removed `Google_Auth_ComputeEngine`. This is now supported in - [`google/auth`][Google Auth GCE], and is used automatically when - `Google_Client::useApplicationDefaultCredentials` is called. - 1. Removed `Google_Auth_Exception` - 1. Removed `Google_Auth_LoginTicket`. Calls to `Google_Client::verifyIdToken` now returns - the payload of the ID Token as an array if the verification is successful. - 1. Removed `Google_Auth_OAuth2`. This functionality is now supported in [`google/auth`][Google Auth OAuth2] and wrapped in `Google_Client`. These changes will only affect applications calling `Google_Client::getAuth`, - as the methods on `Google_Client` have not changed. - 1. Removed `Google_Auth_Simple`. This is now supported in [`google/auth`][Google Auth Simple] - and is used automatically when `Google_Client::setDeveloperKey` is called. - - `Google_Client::sign` has been replaced by `Google_Client::authorize`. This function - now takes a `GuzzleHttp\ClientInterface` object and uses the following decision tree for - authentication: - 1. Uses Application Default Credentials when - `Google_Client::useApplicationDefaultCredentials` is called - - Looks for `GOOGLE_APPLICATION_CREDENTIALS` environment variable if set - - Looks in `~/.config/gcloud/application_default_credentials.json` - - Otherwise, uses `GCECredentials` - 1. Uses API Key if set (see `Client::setDeveloperKey`) - 1. Uses Access Token if set (call `Client::setAccessToken`) - 1. Automatically refreshes access tokens if one is set and the access token is expired - - Removed `Google_Config` - - Removed `Google_Utils` - - [`PSR-6`][PSR 6] cache is used for all caching. As a result: - 1. Removed `Google_Cache_Abstract` - 1. Classes `Google_Cache_Apc`, `Google_Cache_File`, `Google_Cache_Memcache`, and - `Google_Cache_Null` now implement `Google\Auth\CacheInterface`. - 1. Google Auth provides simple [caching utilities][Google Auth Cache] which - are used by default unless you provide alternatives. - - Removed `$boundary` constructor argument for `Google_Http_MediaFileUpload` - -[PSR 3]: https://www.php-fig.org/psr/psr-3/ -[PSR 6]: https://www.php-fig.org/psr/psr-6/ -[Guzzle 5]: https://github.com/guzzle/guzzle -[Guzzle 6]: http://docs.guzzlephp.org/en/latest/psr7.html -[Monolog]: https://github.com/Seldaek/monolog -[Google Auth]: https://github.com/google/google-auth-library-php -[Google Auth Cache]: https://github.com/googleapis/google-auth-library-php/tree/master/src/Cache -[Google Auth GCE]: https://github.com/google/google-auth-library-php/blob/master/src/GCECredentials.php -[Google Auth OAuth2]: https://github.com/google/google-auth-library-php/blob/master/src/OAuth2.php -[Google Auth Simple]: https://github.com/google/google-auth-library-php/blob/master/src/Simple.php -[Google Auth AppIdentity]: https://github.com/google/google-auth-library-php/blob/master/src/AppIdentityCredentials.php -[Firebase JWT]: https://github.com/firebase/php-jwt diff --git a/lib/Google/composer.json b/lib/Google/composer.json index b0deec34b..a645edaa7 100644 --- a/lib/Google/composer.json +++ b/lib/Google/composer.json @@ -6,7 +6,7 @@ "homepage": "http://developers.google.com/api-client-library/php", "license": "Apache-2.0", "require": { - "php": "^8.0", + "php": "^8.1", "google/auth": "^1.37", "google/apiclient-services": "~0.350", "firebase/php-jwt": "^6.0", @@ -14,17 +14,19 @@ "phpseclib/phpseclib": "^3.0.36", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.6", - "google/cloud-storage": "^1.48", + "google/cloud-storage": "^1.49", "google/cloud-core": "^1.60" }, "require-dev": { "squizlabs/php_codesniffer": "^3.8", "symfony/dom-crawler": "~2.1", "symfony/css-selector": "~2.1", + "cache/filesystem-adapter": "^1.1", "phpcompatibility/php-compatibility": "^9.2", - "composer/composer": "^1.10.23 || ^2.0.0", + "composer/composer": "^2.9.3", "phpspec/prophecy-phpunit": "^2.1", - "phpunit/phpunit": "^9.6" + "phpunit/phpunit": "^9.6", + "symfony/process": "^6.4" }, "suggest": { "cache/filesystem-adapter": "For caching certs and tokens (using Google\\Client::setCache)" diff --git a/lib/Google/composer.lock b/lib/Google/composer.lock index 09b329a8d..8e0cfe63c 100644 --- a/lib/Google/composer.lock +++ b/lib/Google/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f0f061a411d8b9b8125adb30e23805b4", + "content-hash": "69cac2b4d18946f91140bb96e685666f", "packages": [ { "name": "brick/math", - "version": "0.11.0", + "version": "0.13.1", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" + "reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "url": "https://api.github.com/repos/brick/math/zipball/fc7ed316430118cc7836bf45faff18d5dfc8de04", + "reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "5.0.0" + "phpunit/phpunit": "^10.1", + "vimeo/psalm": "6.8.8" }, "type": "library", "autoload": { @@ -46,12 +46,17 @@ "arithmetic", "bigdecimal", "bignum", + "bignumber", "brick", - "math" + "decimal", + "integer", + "math", + "mathematics", + "rational" ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.11.0" + "source": "https://github.com/brick/math/tree/0.13.1" }, "funding": [ { @@ -59,7 +64,7 @@ "type": "github" } ], - "time": "2023-01-15T23:15:59+00:00" + "time": "2025-03-29T13:50:30+00:00" }, { "name": "firebase/php-jwt", @@ -126,20 +131,20 @@ }, { "name": "google/apiclient-services", - "version": "v0.411.0", + "version": "v0.427.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "3d616fcefdb8e6c598b2d007d4155fe516b91abd" + "reference": "cc74cd104a1ed1cf545480c52f13831e6eb0efe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/3d616fcefdb8e6c598b2d007d4155fe516b91abd", - "reference": "3d616fcefdb8e6c598b2d007d4155fe516b91abd", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/cc74cd104a1ed1cf545480c52f13831e6eb0efe2", + "reference": "cc74cd104a1ed1cf545480c52f13831e6eb0efe2", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6" @@ -164,43 +169,44 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.411.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.427.0" }, - "time": "2025-09-05T20:24:02+00:00" + "time": "2025-12-24T01:04:22+00:00" }, { "name": "google/auth", - "version": "v1.47.1", + "version": "v1.50.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "d7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7" + "reference": "e1c26a718198e16d8a3c69b1cae136b73f959b0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/d7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7", - "reference": "d7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/e1c26a718198e16d8a3c69b1cae136b73f959b0f", + "reference": "e1c26a718198e16d8a3c69b1cae136b73f959b0f", "shasum": "" }, "require": { - "firebase/php-jwt": "^6.0", + "firebase/php-jwt": "^6.0||^7.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", - "php": "^8.0", + "php": "^8.1", "psr/cache": "^2.0||^3.0", "psr/http-message": "^1.1||^2.0", "psr/log": "^3.0" }, "require-dev": { "guzzlehttp/promises": "^2.0", - "kelvinmo/simplejwt": "0.7.1", + "kelvinmo/simplejwt": "^1.1.0", "phpseclib/phpseclib": "^3.0.35", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "sebastian/comparator": ">=1.2.3", - "squizlabs/php_codesniffer": "^3.5", + "squizlabs/php_codesniffer": "^4.0", + "symfony/filesystem": "^6.3||^7.3", "symfony/process": "^6.0||^7.0", - "webmozart/assert": "^1.11" + "webmozart/assert": "^1.11||^2.0" }, "suggest": { "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." @@ -225,40 +231,41 @@ "support": { "docs": "https://cloud.google.com/php/docs/reference/auth/latest", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.47.1" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.50.0" }, - "time": "2025-07-09T15:26:02+00:00" + "time": "2026-01-08T21:33:57+00:00" }, { "name": "google/cloud-core", - "version": "v1.64.0", + "version": "v1.69.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-cloud-php-core.git", - "reference": "f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85" + "reference": "a35bcf9d79f7007eaaf325e00011d08f40494fb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85", - "reference": "f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/a35bcf9d79f7007eaaf325e00011d08f40494fb1", + "reference": "a35bcf9d79f7007eaaf325e00011d08f40494fb1", "shasum": "" }, "require": { "google/auth": "^1.34", - "google/gax": "^1.36.0", + "google/gax": "^1.38.0", "guzzlehttp/guzzle": "^6.5.8||^7.4.4", "guzzlehttp/promises": "^1.4||^2.0", "guzzlehttp/psr7": "^2.6", "monolog/monolog": "^2.9||^3.0", - "php": "^8.0", + "php": "^8.1", "psr/http-message": "^1.0||^2.0", "rize/uri-template": "~0.3||~0.4" }, "require-dev": { "erusev/parsedown": "^1.6", "google/cloud-common-protos": "~0.5", - "opis/closure": "^3", - "phpdocumentor/reflection": "^5.3.3||^6.0", + "nikic/php-parser": "^5.6", + "opis/closure": "^3.7|^4.0", + "phpdocumentor/reflection": "^6.0", "phpdocumentor/reflection-docblock": "^5.3", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.0", @@ -291,27 +298,27 @@ ], "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", "support": { - "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.64.0" + "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.69.0" }, - "time": "2025-07-16T21:36:08+00:00" + "time": "2025-12-06T04:51:04+00:00" }, { "name": "google/cloud-storage", - "version": "v1.48.1", + "version": "v1.49.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-cloud-php-storage.git", - "reference": "509b095c3ea44db92c9e62a94b5773563c831821" + "reference": "30aefa19ce5af165cef8bb39c224cfa865461541" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-cloud-php-storage/zipball/509b095c3ea44db92c9e62a94b5773563c831821", - "reference": "509b095c3ea44db92c9e62a94b5773563c831821", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-storage/zipball/30aefa19ce5af165cef8bb39c224cfa865461541", + "reference": "30aefa19ce5af165cef8bb39c224cfa865461541", "shasum": "" }, "require": { "google/cloud-core": "^1.57", - "php": "^8.0", + "php": "^8.1", "ramsey/uuid": "^4.2.3" }, "require-dev": { @@ -348,27 +355,27 @@ ], "description": "Cloud Storage Client for PHP", "support": { - "source": "https://github.com/googleapis/google-cloud-php-storage/tree/v1.48.1" + "source": "https://github.com/googleapis/google-cloud-php-storage/tree/v1.49.0" }, - "time": "2025-05-20T19:49:54+00:00" + "time": "2025-12-06T04:51:04+00:00" }, { "name": "google/common-protos", - "version": "4.12.1", + "version": "4.12.4", "source": { "type": "git", "url": "https://github.com/googleapis/common-protos-php.git", - "reference": "70c4eb1abab5484a23c17a43b0d455259f5d8c1b" + "reference": "0127156899af0df2681bd42024c60bd5360d64e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/common-protos-php/zipball/70c4eb1abab5484a23c17a43b0d455259f5d8c1b", - "reference": "70c4eb1abab5484a23c17a43b0d455259f5d8c1b", + "url": "https://api.github.com/repos/googleapis/common-protos-php/zipball/0127156899af0df2681bd42024c60bd5360d64e3", + "reference": "0127156899af0df2681bd42024c60bd5360d64e3", "shasum": "" }, "require": { - "google/protobuf": "^v3.25.3||^4.26.1", - "php": "^8.0" + "google/protobuf": "^4.31", + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6" @@ -407,44 +414,44 @@ "google" ], "support": { - "source": "https://github.com/googleapis/common-protos-php/tree/v4.12.1" + "source": "https://github.com/googleapis/common-protos-php/tree/v4.12.4" }, - "time": "2025-05-20T19:49:54+00:00" + "time": "2025-09-20T01:29:44+00:00" }, { "name": "google/gax", - "version": "v1.36.1", + "version": "v1.40.0", "source": { "type": "git", "url": "https://github.com/googleapis/gax-php.git", - "reference": "afdac3bc38a3b17d70668115d7b1a97289ac4d72" + "reference": "1d3834d60b3f0794427c64d2b27d7c627fbba92c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/gax-php/zipball/afdac3bc38a3b17d70668115d7b1a97289ac4d72", - "reference": "afdac3bc38a3b17d70668115d7b1a97289ac4d72", + "url": "https://api.github.com/repos/googleapis/gax-php/zipball/1d3834d60b3f0794427c64d2b27d7c627fbba92c", + "reference": "1d3834d60b3f0794427c64d2b27d7c627fbba92c", "shasum": "" }, "require": { - "google/auth": "^1.45", + "google/auth": "^1.49", "google/common-protos": "^4.4", "google/grpc-gcp": "^0.4", "google/longrunning": "~0.4", - "google/protobuf": "^v3.25.3||^4.26.1", + "google/protobuf": "^4.31", "grpc/grpc": "^1.13", "guzzlehttp/promises": "^2.0", "guzzlehttp/psr7": "^2.0", - "php": "^8.0", + "php": "^8.1", "ramsey/uuid": "^4.0" }, "conflict": { - "ext-protobuf": "<3.7.0" + "ext-protobuf": "<4.31.0" }, "require-dev": { "phpspec/prophecy-phpunit": "^2.1", "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^9.6", - "squizlabs/php_codesniffer": "3.*" + "squizlabs/php_codesniffer": "4.*" }, "type": "library", "autoload": { @@ -464,9 +471,9 @@ ], "support": { "issues": "https://github.com/googleapis/gax-php/issues", - "source": "https://github.com/googleapis/gax-php/tree/v1.36.1" + "source": "https://github.com/googleapis/gax-php/tree/v1.40.0" }, - "time": "2025-05-20T19:50:43+00:00" + "time": "2025-12-04T18:45:15+00:00" }, { "name": "google/grpc-gcp", @@ -559,23 +566,23 @@ }, { "name": "google/protobuf", - "version": "v4.31.1", + "version": "v4.33.2", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "2b028ce8876254e2acbeceea7d9b573faad41864" + "reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/2b028ce8876254e2acbeceea7d9b573faad41864", - "reference": "2b028ce8876254e2acbeceea7d9b573faad41864", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318", + "reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318", "shasum": "" }, "require": { - "php": ">=7.0.0" + "php": ">=8.1.0" }, "require-dev": { - "phpunit/phpunit": ">=5.0.0" + "phpunit/phpunit": ">=5.0.0 <8.5.27" }, "suggest": { "ext-bcmath": "Need to support JSON deserialization" @@ -597,9 +604,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.31.1" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.2" }, - "time": "2025-05-28T18:52:35+00:00" + "time": "2025-12-05T22:12:22+00:00" }, { "name": "grpc/grpc", @@ -972,42 +979,43 @@ }, { "name": "monolog/monolog", - "version": "2.10.0", + "version": "3.10.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "5cf826f2991858b54d5c3809bee745560a1042a7" + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5cf826f2991858b54d5c3809bee745560a1042a7", - "reference": "5cf826f2991858b54d5c3809bee745560a1042a7", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/b321dd6749f0bf7189444158a3ce785cc16d69b0", + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0", "shasum": "" }, "require": { - "php": ">=7.2", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" }, "provide": { - "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + "psr/log-implementation": "3.0.0" }, "require-dev": { - "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "aws/aws-sdk-php": "^3.0", "doctrine/couchdb": "~1.0@dev", "elasticsearch/elasticsearch": "^7 || ^8", "ext-json": "*", - "graylog2/gelf-php": "^1.4.2 || ^2@dev", - "guzzlehttp/guzzle": "^7.4", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", + "mongodb/mongodb": "^1.8 || ^2.0", "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpspec/prophecy": "^1.15", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.5.38 || ^9.6.19", - "predis/predis": "^1.1 || ^2.0", - "rollbar/rollbar": "^1.3 || ^2 || ^3", - "ruflin/elastica": "^7", - "swiftmailer/swiftmailer": "^5.3|^6.0", + "php-console/php-console": "^3.1.8", + "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "^10.5.17 || ^11.0.7", + "predis/predis": "^1.1 || ^2", + "rollbar/rollbar": "^4.0", + "ruflin/elastica": "^7 || ^8", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" }, @@ -1030,7 +1038,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -1058,7 +1066,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.10.0" + "source": "https://github.com/Seldaek/monolog/tree/3.10.0" }, "funding": [ { @@ -1070,7 +1078,7 @@ "type": "tidelift" } ], - "time": "2024-11-12T12:43:37+00:00" + "time": "2026-01-02T08:56:05+00:00" }, { "name": "paragonie/constant_time_encoding", @@ -1193,16 +1201,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.47", + "version": "3.0.48", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d" + "reference": "64065a5679c50acb886e82c07aa139b0f757bb89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/9d6ca36a6c2dd434765b1071b2644a1c683b385d", - "reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/64065a5679c50acb886e82c07aa139b0f757bb89", + "reference": "64065a5679c50acb886e82c07aa139b0f757bb89", "shasum": "" }, "require": { @@ -1283,7 +1291,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.47" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.48" }, "funding": [ { @@ -1299,20 +1307,20 @@ "type": "tidelift" } ], - "time": "2025-10-06T01:07:24+00:00" + "time": "2025-12-15T11:51:42+00:00" }, { "name": "psr/cache", - "version": "3.0.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + "reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "url": "https://api.github.com/repos/php-fig/cache/zipball/213f9dbc5b9bfbc4f8db86d2838dc968752ce13b", + "reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b", "shasum": "" }, "require": { @@ -1346,9 +1354,9 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" + "source": "https://github.com/php-fig/cache/tree/2.0.0" }, - "time": "2021-02-03T23:26:27+00:00" + "time": "2021-02-03T23:23:37+00:00" }, { "name": "psr/http-client", @@ -1606,43 +1614,39 @@ }, { "name": "ramsey/collection", - "version": "1.3.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4" + "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4", - "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4", + "url": "https://api.github.com/repos/ramsey/collection/zipball/344572933ad0181accbf4ba763e85a0306a8c5e2", + "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0", - "symfony/polyfill-php81": "^1.23" + "php": "^8.1" }, "require-dev": { "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.28.3", - "fakerphp/faker": "^1.21", + "ergebnis/composer-normalize": "^2.45", + "fakerphp/faker": "^1.24", "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^1.0", - "mockery/mockery": "^1.5", + "jangregor/phpstan-prophecy": "^2.1", + "mockery/mockery": "^1.6", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcsstandards/phpcsutils": "^1.0.0-rc1", - "phpspec/prophecy-phpunit": "^2.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5", - "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18.4", - "ramsey/coding-standard": "^2.0.3", - "ramsey/conventional-commits": "^1.3", - "vimeo/psalm": "^5.4" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpspec/prophecy-phpunit": "^2.3", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5", + "ramsey/coding-standard": "^2.3", + "ramsey/conventional-commits": "^1.6", + "roave/security-advisories": "dev-latest" }, "type": "library", "extra": { @@ -1680,36 +1684,26 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/1.3.0" + "source": "https://github.com/ramsey/collection/tree/2.1.1" }, - "funding": [ - { - "url": "https://github.com/ramsey", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", - "type": "tidelift" - } - ], - "time": "2022-12-27T19:12:24+00:00" + "time": "2025-03-22T05:38:12+00:00" }, { "name": "ramsey/uuid", - "version": "4.9.1", + "version": "4.9.2", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440" + "reference": "8429c78ca35a09f27565311b98101e2826affde0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/81f941f6f729b1e3ceea61d9d014f8b6c6800440", - "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/8429c78ca35a09f27565311b98101e2826affde0", + "reference": "8429c78ca35a09f27565311b98101e2826affde0", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", + "brick/math": "^0.8.16 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" }, @@ -1768,29 +1762,31 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.9.1" + "source": "https://github.com/ramsey/uuid/tree/4.9.2" }, - "time": "2025-09-04T20:59:21+00:00" + "time": "2025-12-14T04:43:48+00:00" }, { "name": "rize/uri-template", - "version": "0.3.8", + "version": "0.4.1", "source": { "type": "git", "url": "https://github.com/rize/UriTemplate.git", - "reference": "34a5b96d0b65a5dddb7d20f09b6527a43faede24" + "reference": "abb53c8b73a5b6c24e11f49036ab842f560cad33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rize/UriTemplate/zipball/34a5b96d0b65a5dddb7d20f09b6527a43faede24", - "reference": "34a5b96d0b65a5dddb7d20f09b6527a43faede24", + "url": "https://api.github.com/repos/rize/UriTemplate/zipball/abb53c8b73a5b6c24e11f49036ab842f560cad33", + "reference": "abb53c8b73a5b6c24e11f49036ab842f560cad33", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "~4.8.36" + "friendsofphp/php-cs-fixer": "^3.63", + "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "~10.0" }, "type": "library", "autoload": { @@ -1816,7 +1812,7 @@ ], "support": { "issues": "https://github.com/rize/UriTemplate/issues", - "source": "https://github.com/rize/UriTemplate/tree/0.3.8" + "source": "https://github.com/rize/UriTemplate/tree/0.4.1" }, "funding": [ { @@ -1832,24 +1828,24 @@ "type": "open_collective" } ], - "time": "2024-08-30T07:09:40+00:00" + "time": "2025-12-02T15:19:04+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.0.2", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "type": "library", "extra": { @@ -1858,7 +1854,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -1883,7 +1879,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -1899,42 +1895,45 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" - }, + "time": "2024-09-25T14:21:43+00:00" + } + ], + "packages-dev": [ { - "name": "symfony/polyfill-php81", - "version": "v1.33.0", + "name": "cache/adapter-common", + "version": "1.3.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + "url": "https://github.com/php-cache/adapter-common.git", + "reference": "8788309be72aa7be69b88cdc0687549c74a7d479" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "url": "https://api.github.com/repos/php-cache/adapter-common/zipball/8788309be72aa7be69b88cdc0687549c74a7d479", + "reference": "8788309be72aa7be69b88cdc0687549c74a7d479", "shasum": "" }, "require": { - "php": ">=7.2" + "cache/tag-interop": "^1.0", + "php": ">=7.4", + "psr/cache": "^1.0 || ^2.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "cache/integration-tests": "^0.17", + "phpunit/phpunit": "^7.5.20 || ^9.5.10" }, "type": "library", "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" + "branch-alias": { + "dev-master": "1.1-dev" } }, "autoload": { - "files": [ - "bootstrap.php" - ], "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] + "Cache\\Adapter\\Common\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1942,59 +1941,171 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Aaron Scherer", + "email": "aequasi@gmail.com", + "homepage": "https://github.com/aequasi" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/nyholm" } ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", + "description": "Common classes for PSR-6 adapters", + "homepage": "http://www.php-cache.com/en/latest/", "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" + "cache", + "psr-6", + "tag" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" + "source": "https://github.com/php-cache/adapter-common/tree/1.3.0" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" + "time": "2022-01-15T15:47:19+00:00" + }, + { + "name": "cache/filesystem-adapter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-cache/filesystem-adapter.git", + "reference": "f1faaae40aaa696ef899cef6f6888aedb90b419b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-cache/filesystem-adapter/zipball/f1faaae40aaa696ef899cef6f6888aedb90b419b", + "reference": "f1faaae40aaa696ef899cef6f6888aedb90b419b", + "shasum": "" + }, + "require": { + "cache/adapter-common": "^1.0", + "league/flysystem": "^1.0", + "php": ">=7.4", + "psr/cache": "^1.0 || ^2.0", + "psr/simple-cache": "^1.0" + }, + "provide": { + "psr/cache-implementation": "^1.0", + "psr/simple-cache-implementation": "^1.0" + }, + "require-dev": { + "cache/integration-tests": "^0.17", + "phpunit/phpunit": "^7.5.20 || ^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Cache\\Adapter\\Filesystem\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/fabpot", - "type": "github" + "name": "Aaron Scherer", + "email": "aequasi@gmail.com", + "homepage": "https://github.com/aequasi" }, { - "url": "https://github.com/nicolas-grekas", - "type": "github" + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/nyholm" + } + ], + "description": "A PSR-6 cache implementation using filesystem. This implementation supports tags", + "homepage": "http://www.php-cache.com/en/latest/", + "keywords": [ + "cache", + "filesystem", + "psr-6", + "tag" + ], + "support": { + "source": "https://github.com/php-cache/filesystem-adapter/tree/1.2.0" + }, + "time": "2022-01-15T15:47:19+00:00" + }, + { + "name": "cache/tag-interop", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-cache/tag-interop.git", + "reference": "b062b1d735357da50edf8387f7a8696f3027d328" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-cache/tag-interop/zipball/b062b1d735357da50edf8387f7a8696f3027d328", + "reference": "b062b1d735357da50edf8387f7a8696f3027d328", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0 || ^8.0", + "psr/cache": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Cache\\TagInterop\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/nyholm" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "name": "Nicolas Grekas", + "email": "p@tchwork.com", + "homepage": "https://github.com/nicolas-grekas" } ], - "time": "2024-09-09T11:45:10+00:00" - } - ], - "packages-dev": [ + "description": "Framework interoperable interfaces for tags", + "homepage": "https://www.php-cache.com/en/latest/", + "keywords": [ + "cache", + "psr", + "psr6", + "tag" + ], + "support": { + "issues": "https://github.com/php-cache/tag-interop/issues", + "source": "https://github.com/php-cache/tag-interop/tree/1.1.0" + }, + "time": "2021-12-31T10:03:23+00:00" + }, { "name": "composer/ca-bundle", - "version": "1.5.9", + "version": "1.5.10", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "1905981ee626e6f852448b7aaa978f8666c5bc54" + "reference": "961a5e4056dd2e4a2eedcac7576075947c28bf63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/1905981ee626e6f852448b7aaa978f8666c5bc54", - "reference": "1905981ee626e6f852448b7aaa978f8666c5bc54", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/961a5e4056dd2e4a2eedcac7576075947c28bf63", + "reference": "961a5e4056dd2e4a2eedcac7576075947c28bf63", "shasum": "" }, "require": { @@ -2041,7 +2152,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.5.9" + "source": "https://github.com/composer/ca-bundle/tree/1.5.10" }, "funding": [ { @@ -2053,26 +2164,26 @@ "type": "github" } ], - "time": "2025-11-06T11:46:17+00:00" + "time": "2025-12-08T15:06:51+00:00" }, { "name": "composer/class-map-generator", - "version": "1.6.2", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/composer/class-map-generator.git", - "reference": "ba9f089655d4cdd64e762a6044f411ccdaec0076" + "reference": "8f5fa3cc214230e71f54924bd0197a3bcc705eb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/ba9f089655d4cdd64e762a6044f411ccdaec0076", - "reference": "ba9f089655d4cdd64e762a6044f411ccdaec0076", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/8f5fa3cc214230e71f54924bd0197a3bcc705eb1", + "reference": "8f5fa3cc214230e71f54924bd0197a3bcc705eb1", "shasum": "" }, "require": { "composer/pcre": "^2.1 || ^3.1", "php": "^7.2 || ^8.0", - "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7 || ^8" }, "require-dev": { "phpstan/phpstan": "^1.12 || ^2", @@ -2080,7 +2191,7 @@ "phpstan/phpstan-phpunit": "^1 || ^2", "phpstan/phpstan-strict-rules": "^1.1 || ^2", "phpunit/phpunit": "^8", - "symfony/filesystem": "^5.4 || ^6" + "symfony/filesystem": "^5.4 || ^6 || ^7 || ^8" }, "type": "library", "extra": { @@ -2110,7 +2221,7 @@ ], "support": { "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.6.2" + "source": "https://github.com/composer/class-map-generator/tree/1.7.1" }, "funding": [ { @@ -2122,57 +2233,60 @@ "type": "github" } ], - "time": "2025-08-20T18:52:43+00:00" + "time": "2025-12-29T13:15:25+00:00" }, { "name": "composer/composer", - "version": "2.7.7", + "version": "2.9.3", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "291942978f39435cf904d33739f98d7d4eca7b23" + "reference": "fb3bee27676fd852a8a11ebbb1de19b4dada5aba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/291942978f39435cf904d33739f98d7d4eca7b23", - "reference": "291942978f39435cf904d33739f98d7d4eca7b23", + "url": "https://api.github.com/repos/composer/composer/zipball/fb3bee27676fd852a8a11ebbb1de19b4dada5aba", + "reference": "fb3bee27676fd852a8a11ebbb1de19b4dada5aba", "shasum": "" }, "require": { - "composer/ca-bundle": "^1.0", - "composer/class-map-generator": "^1.3.3", + "composer/ca-bundle": "^1.5", + "composer/class-map-generator": "^1.4.0", "composer/metadata-minifier": "^1.0", - "composer/pcre": "^2.1 || ^3.1", + "composer/pcre": "^2.3 || ^3.3", "composer/semver": "^3.3", "composer/spdx-licenses": "^1.5.7", "composer/xdebug-handler": "^2.0.2 || ^3.0.3", - "justinrainbow/json-schema": "^5.2.11", + "ext-json": "*", + "justinrainbow/json-schema": "^6.5.1", "php": "^7.2.5 || ^8.0", "psr/log": "^1.0 || ^2.0 || ^3.0", - "react/promise": "^2.8 || ^3", + "react/promise": "^3.3", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.2", "seld/signal-handler": "^2.0", - "symfony/console": "^5.4.11 || ^6.0.11 || ^7", - "symfony/filesystem": "^5.4 || ^6.0 || ^7", - "symfony/finder": "^5.4 || ^6.0 || ^7", + "symfony/console": "^5.4.47 || ^6.4.25 || ^7.1.10 || ^8.0", + "symfony/filesystem": "^5.4.45 || ^6.4.24 || ^7.1.10 || ^8.0", + "symfony/finder": "^5.4.45 || ^6.4.24 || ^7.1.10 || ^8.0", "symfony/polyfill-php73": "^1.24", "symfony/polyfill-php80": "^1.24", "symfony/polyfill-php81": "^1.24", - "symfony/process": "^5.4 || ^6.0 || ^7" + "symfony/polyfill-php84": "^1.30", + "symfony/process": "^5.4.47 || ^6.4.25 || ^7.1.10 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^1.11.0", + "phpstan/phpstan": "^1.11.8", "phpstan/phpstan-deprecation-rules": "^1.2.0", "phpstan/phpstan-phpunit": "^1.4.0", "phpstan/phpstan-strict-rules": "^1.6.0", "phpstan/phpstan-symfony": "^1.4.0", - "symfony/phpunit-bridge": "^6.4.1 || ^7.0.1" + "symfony/phpunit-bridge": "^6.4.25 || ^7.3.3 || ^8.0" }, "suggest": { - "ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages", - "ext-zip": "Enabling the zip extension allows you to unzip archives", - "ext-zlib": "Allow gzip compression of HTTP requests" + "ext-curl": "Provides HTTP support (will fallback to PHP streams if missing)", + "ext-openssl": "Enables access to repositories and packages over HTTPS", + "ext-zip": "Allows direct extraction of ZIP archives (unzip/7z binaries will be used instead if available)", + "ext-zlib": "Enables gzip for HTTP requests" }, "bin": [ "bin/composer" @@ -2185,7 +2299,7 @@ ] }, "branch-alias": { - "dev-main": "2.7-dev" + "dev-main": "2.9-dev" } }, "autoload": { @@ -2220,7 +2334,7 @@ "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/composer/issues", "security": "https://github.com/composer/composer/security/policy", - "source": "https://github.com/composer/composer/tree/2.7.7" + "source": "https://github.com/composer/composer/tree/2.9.3" }, "funding": [ { @@ -2230,13 +2344,9 @@ { "url": "https://github.com/composer", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" } ], - "time": "2024-06-10T20:11:12+00:00" + "time": "2025-12-30T12:40:17+00:00" }, { "name": "composer/metadata-minifier", @@ -2659,30 +2769,30 @@ }, { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -2709,7 +2819,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -2725,72 +2835,305 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "justinrainbow/json-schema", - "version": "5.3.0", + "version": "6.6.4", "source": { "type": "git", "url": "https://github.com/jsonrainbow/json-schema.git", - "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8" + "reference": "2eeb75d21cf73211335888e7f5e6fd7440723ec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", - "reference": "feb2ca6dd1cebdaf1ed60a4c8de2e53ce11c4fd8", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/2eeb75d21cf73211335888e7f5e6fd7440723ec7", + "reference": "2eeb75d21cf73211335888e7f5e6fd7440723ec7", "shasum": "" }, "require": { - "php": ">=7.1" + "ext-json": "*", + "marc-mabe/php-enum": "^4.4", + "php": "^7.2 || ^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", - "json-schema/json-schema-test-suite": "1.2.0", - "phpunit/phpunit": "^4.8.35" + "friendsofphp/php-cs-fixer": "3.3.0", + "json-schema/json-schema-test-suite": "^23.2", + "marc-mabe/php-enum-phpstan": "^2.0", + "phpspec/prophecy": "^1.19", + "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "^8.5" }, "bin": [ "bin/validate-json" ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/jsonrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/6.6.4" + }, + "time": "2025-12-19T15:01:32+00:00" + }, + { + "name": "league/flysystem", + "version": "1.1.10", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3239285c825c152bcc315fe0e87d6b55f5972ed1", + "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "league/mime-type-detection": "^1.3", + "php": "^7.2.5 || ^8.0" + }, + "conflict": { + "league/flysystem-sftp": "<1.0.6" + }, + "require-dev": { + "phpspec/prophecy": "^1.11.1", + "phpunit/phpunit": "^8.5.8" + }, + "suggest": { + "ext-ftp": "Allows you to use FTP server storage", + "ext-openssl": "Allows you to use FTPS server storage", + "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", + "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", + "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Filesystem abstraction: Many filesystems, one API.", + "keywords": [ + "Cloud Files", + "WebDAV", + "abstraction", + "aws", + "cloud", + "copy.com", + "dropbox", + "file systems", + "files", + "filesystem", + "filesystems", + "ftp", + "rackspace", + "remote", + "s3", + "sftp", + "storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem/issues", + "source": "https://github.com/thephpleague/flysystem/tree/1.1.10" + }, + "funding": [ + { + "url": "https://offset.earth/frankdejonge", + "type": "other" + } + ], + "time": "2022-10-04T09:16:37+00:00" + }, + { + "name": "league/mime-type-detection", + "version": "1.16.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/mime-type-detection.git", + "reference": "2d6702ff215bf922936ccc1ad31007edc76451b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/2d6702ff215bf922936ccc1ad31007edc76451b9", + "reference": "2d6702ff215bf922936ccc1ad31007edc76451b9", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.2", + "phpstan/phpstan": "^0.12.68", + "phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\MimeTypeDetection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Mime-type detection for Flysystem", + "support": { + "issues": "https://github.com/thephpleague/mime-type-detection/issues", + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.16.0" + }, + "funding": [ + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2024-09-21T08:32:55+00:00" + }, + { + "name": "marc-mabe/php-enum", + "version": "v4.7.2", + "source": { + "type": "git", + "url": "https://github.com/marc-mabe/php-enum.git", + "reference": "bb426fcdd65c60fb3638ef741e8782508fda7eef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/marc-mabe/php-enum/zipball/bb426fcdd65c60fb3638ef741e8782508fda7eef", + "reference": "bb426fcdd65c60fb3638ef741e8782508fda7eef", + "shasum": "" + }, + "require": { + "ext-reflection": "*", + "php": "^7.1 | ^8.0" + }, + "require-dev": { + "phpbench/phpbench": "^0.16.10 || ^1.0.4", + "phpstan/phpstan": "^1.3.1", + "phpunit/phpunit": "^7.5.20 | ^8.5.22 | ^9.5.11", + "vimeo/psalm": "^4.17.0 | ^5.26.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-3.x": "3.2-dev", + "dev-master": "4.7-dev" + } + }, "autoload": { "psr-4": { - "JsonSchema\\": "src/JsonSchema/" - } + "MabeEnum\\": "src/" + }, + "classmap": [ + "stubs/Stringable.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Bruno Prieto Reis", - "email": "bruno.p.reis@gmail.com" - }, - { - "name": "Justin Rainbow", - "email": "justin.rainbow@gmail.com" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - }, - { - "name": "Robert Schönthal", - "email": "seroscho@googlemail.com" + "name": "Marc Bennewitz", + "email": "dev@mabe.berlin", + "homepage": "https://mabe.berlin/", + "role": "Lead" } ], - "description": "A library to validate a json schema.", - "homepage": "https://github.com/justinrainbow/json-schema", + "description": "Simple and fast implementation of enumerations with native PHP", + "homepage": "https://github.com/marc-mabe/php-enum", "keywords": [ - "json", - "schema" + "enum", + "enum-map", + "enum-set", + "enumeration", + "enumerator", + "enummap", + "enumset", + "map", + "set", + "type", + "type-hint", + "typehint" ], "support": { - "issues": "https://github.com/jsonrainbow/json-schema/issues", - "source": "https://github.com/jsonrainbow/json-schema/tree/5.3.0" + "issues": "https://github.com/marc-mabe/php-enum/issues", + "source": "https://github.com/marc-mabe/php-enum/tree/v4.7.2" }, - "time": "2024-07-06T21:00:26+00:00" + "time": "2025-09-14T11:18:39+00:00" }, { "name": "myclabs/deep-copy", @@ -2854,16 +3197,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.6.2", + "version": "v5.7.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "3a454ca033b9e06b63282ce19562e892747449bb" + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb", - "reference": "3a454ca033b9e06b63282ce19562e892747449bb", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82", "shasum": "" }, "require": { @@ -2906,9 +3249,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0" }, - "time": "2025-10-21T19:32:17+00:00" + "time": "2025-12-06T11:56:16+00:00" }, { "name": "phar-io/manifest", @@ -3145,16 +3488,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.3", + "version": "5.6.6", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94f8051919d1b0369a6bcc7931d679a511c03fe9" + "reference": "5cee1d3dfc2d2aa6599834520911d246f656bcb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94f8051919d1b0369a6bcc7931d679a511c03fe9", - "reference": "94f8051919d1b0369a6bcc7931d679a511c03fe9", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/5cee1d3dfc2d2aa6599834520911d246f656bcb8", + "reference": "5cee1d3dfc2d2aa6599834520911d246f656bcb8", "shasum": "" }, "require": { @@ -3164,7 +3507,7 @@ "phpdocumentor/reflection-common": "^2.2", "phpdocumentor/type-resolver": "^1.7", "phpstan/phpdoc-parser": "^1.7|^2.0", - "webmozart/assert": "^1.9.1" + "webmozart/assert": "^1.9.1 || ^2" }, "require-dev": { "mockery/mockery": "~1.3.5 || ~1.6.0", @@ -3203,22 +3546,22 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.3" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.6" }, - "time": "2025-08-01T19:43:32+00:00" + "time": "2025-12-22T21:13:58+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.10.0", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" + "reference": "92a98ada2b93d9b201a613cb5a33584dde25f195" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/92a98ada2b93d9b201a613cb5a33584dde25f195", + "reference": "92a98ada2b93d9b201a613cb5a33584dde25f195", "shasum": "" }, "require": { @@ -3261,9 +3604,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.12.0" }, - "time": "2024-11-09T15:12:26+00:00" + "time": "2025-11-21T15:09:14+00:00" }, { "name": "phpspec/prophecy", @@ -3758,16 +4101,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.29", + "version": "9.6.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9ecfec57835a5581bc888ea7e13b51eb55ab9dd3" + "reference": "945d0b7f346a084ce5549e95289962972c4272e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ecfec57835a5581bc888ea7e13b51eb55ab9dd3", - "reference": "9ecfec57835a5581bc888ea7e13b51eb55ab9dd3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/945d0b7f346a084ce5549e95289962972c4272e5", + "reference": "945d0b7f346a084ce5549e95289962972c4272e5", "shasum": "" }, "require": { @@ -3841,7 +4184,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.29" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.31" }, "funding": [ { @@ -3865,7 +4208,7 @@ "type": "tidelift" } ], - "time": "2025-09-24T06:29:11+00:00" + "time": "2025-12-06T07:45:52+00:00" }, { "name": "psr/container", @@ -3920,6 +4263,57 @@ }, "time": "2021-11-05T16:47:00+00:00" }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/master" + }, + "time": "2017-10-23T01:57:42+00:00" + }, { "name": "react/promise", "version": "v3.3.0", @@ -5258,23 +5652,24 @@ }, { "name": "symfony/console", - "version": "v6.0.19", + "version": "v6.4.31", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c3ebc83d031b71c39da318ca8b7a07ecc67507ed" + "reference": "f9f8a889f54c264f9abac3fc0f7a371ffca51997" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c3ebc83d031b71c39da318ca8b7a07ecc67507ed", - "reference": "c3ebc83d031b71c39da318ca8b7a07ecc67507ed", + "url": "https://api.github.com/repos/symfony/console/zipball/f9f8a889f54c264f9abac3fc0f7a371ffca51997", + "reference": "f9f8a889f54c264f9abac3fc0f7a371ffca51997", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.4|^6.0" + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^5.4|^6.0|^7.0" }, "conflict": { "symfony/dependency-injection": "<5.4", @@ -5288,18 +5683,16 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/lock": "^5.4|^6.0", - "symfony/process": "^5.4|^6.0", - "symfony/var-dumper": "^5.4|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5328,12 +5721,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.19" + "source": "https://github.com/symfony/console/tree/v6.4.31" }, "funding": [ { @@ -5344,12 +5737,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2023-01-01T08:36:10+00:00" + "time": "2025-12-22T08:30:34+00:00" }, { "name": "symfony/css-selector", @@ -5469,23 +5866,26 @@ }, { "name": "symfony/filesystem", - "version": "v6.0.19", + "version": "v6.4.30", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "3d49eec03fda1f0fc19b7349fbbe55ebc1004214" + "reference": "441c6b69f7222aadae7cbf5df588496d5ee37789" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/3d49eec03fda1f0fc19b7349fbbe55ebc1004214", - "reference": "3d49eec03fda1f0fc19b7349fbbe55ebc1004214", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/441c6b69f7222aadae7cbf5df588496d5ee37789", + "reference": "441c6b69f7222aadae7cbf5df588496d5ee37789", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.8" }, + "require-dev": { + "symfony/process": "^5.4|^6.4|^7.0" + }, "type": "library", "autoload": { "psr-4": { @@ -5512,7 +5912,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.0.19" + "source": "https://github.com/symfony/filesystem/tree/v6.4.30" }, "funding": [ { @@ -5523,29 +5923,36 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2023-01-20T17:44:14+00:00" + "time": "2025-11-26T14:43:45+00:00" }, { "name": "symfony/finder", - "version": "v6.0.19", + "version": "v6.4.31", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "5cc9cac6586fc0c28cd173780ca696e419fefa11" + "reference": "5547f2e1f0ca8e2e7abe490156b62da778cfbe2b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/5cc9cac6586fc0c28cd173780ca696e419fefa11", - "reference": "5cc9cac6586fc0c28cd173780ca696e419fefa11", + "url": "https://api.github.com/repos/symfony/finder/zipball/5547f2e1f0ca8e2e7abe490156b62da778cfbe2b", + "reference": "5547f2e1f0ca8e2e7abe490156b62da778cfbe2b", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" + }, + "require-dev": { + "symfony/filesystem": "^6.0|^7.0" }, "type": "library", "autoload": { @@ -5573,7 +5980,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.0.19" + "source": "https://github.com/symfony/finder/tree/v6.4.31" }, "funding": [ { @@ -5584,12 +5991,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2023-01-20T17:44:14+00:00" + "time": "2025-12-11T14:52:17+00:00" }, { "name": "symfony/polyfill-ctype", @@ -6090,22 +6501,182 @@ ], "time": "2025-01-02T08:10:11+00:00" }, + { + "name": "symfony/polyfill-php81", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php84", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-24T13:30:11+00:00" + }, { "name": "symfony/process", - "version": "v6.0.19", + "version": "v6.4.31", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "2114fd60f26a296cc403a7939ab91478475a33d4" + "reference": "8541b7308fca001320e90bca8a73a28aa5604a6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/2114fd60f26a296cc403a7939ab91478475a33d4", - "reference": "2114fd60f26a296cc403a7939ab91478475a33d4", + "url": "https://api.github.com/repos/symfony/process/zipball/8541b7308fca001320e90bca8a73a28aa5604a6e", + "reference": "8541b7308fca001320e90bca8a73a28aa5604a6e", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "type": "library", "autoload": { @@ -6133,7 +6704,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.0.19" + "source": "https://github.com/symfony/process/tree/v6.4.31" }, "funding": [ { @@ -6144,37 +6715,39 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2023-01-01T08:36:10+00:00" + "time": "2025-12-15T19:26:35+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.0.2", + "version": "v3.6.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66" + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d78d39c1599bd1188b8e26bb341da52c3c6d8a66", - "reference": "d78d39c1599bd1188b8e26bb341da52c3c6d8a66", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43", + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43", "shasum": "" }, "require": { - "php": ">=8.0.2", - "psr/container": "^2.0" + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "type": "library", "extra": { "thanks": { @@ -6182,13 +6755,16 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.6-dev" } }, "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -6215,7 +6791,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.6.1" }, "funding": [ { @@ -6226,42 +6802,46 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2022-05-30T19:17:58+00:00" + "time": "2025-07-15T11:30:57+00:00" }, { "name": "symfony/string", - "version": "v6.0.19", + "version": "v6.4.30", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "d9e72497367c23e08bf94176d2be45b00a9d232a" + "reference": "50590a057841fa6bf69d12eceffce3465b9e32cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/d9e72497367c23e08bf94176d2be45b00a9d232a", - "reference": "d9e72497367c23e08bf94176d2be45b00a9d232a", + "url": "https://api.github.com/repos/symfony/string/zipball/50590a057841fa6bf69d12eceffce3465b9e32cb", + "reference": "50590a057841fa6bf69d12eceffce3465b9e32cb", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": "<2.0" + "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/translation-contracts": "^2.0|^3.0", - "symfony/var-exporter": "^5.4|^6.0" + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -6300,7 +6880,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.19" + "source": "https://github.com/symfony/string/tree/v6.4.30" }, "funding": [ { @@ -6311,25 +6891,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2023-01-01T08:36:10+00:00" + "time": "2025-11-21T18:03:05+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.3", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", "shasum": "" }, "require": { @@ -6358,7 +6942,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + "source": "https://github.com/theseer/tokenizer/tree/1.3.1" }, "funding": [ { @@ -6366,7 +6950,7 @@ "type": "github" } ], - "time": "2024-03-03T12:36:25+00:00" + "time": "2025-11-17T20:03:58+00:00" }, { "name": "webmozart/assert", @@ -6429,12 +7013,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.0" + "php": "^8.1" }, - "platform-dev": [], - "plugin-api-version": "2.6.0" + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/lib/Google/src/AuthHandler/Guzzle6AuthHandler.php b/lib/Google/src/AuthHandler/Guzzle6AuthHandler.php index 352cf915c..05fe1b2b9 100644 --- a/lib/Google/src/AuthHandler/Guzzle6AuthHandler.php +++ b/lib/Google/src/AuthHandler/Guzzle6AuthHandler.php @@ -2,8 +2,8 @@ namespace Google\AuthHandler; -use Google\Auth\CredentialsLoader; use Google\Auth\FetchAuthTokenCache; +use Google\Auth\FetchAuthTokenInterface; use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Auth\Middleware\AuthTokenMiddleware; use Google\Auth\Middleware\ScopedAccessTokenMiddleware; @@ -28,7 +28,7 @@ public function __construct(?CacheItemPoolInterface $cache = null, array $cacheC public function attachCredentials( ClientInterface $http, - CredentialsLoader $credentials, + FetchAuthTokenInterface $credentials, ?callable $tokenCallback = null ) { // use the provided cache @@ -40,13 +40,21 @@ public function attachCredentials( ); } - return $this->attachCredentialsCache($http, $credentials, $tokenCallback); + return $this->attachToHttp($http, $credentials, $tokenCallback); } public function attachCredentialsCache( ClientInterface $http, FetchAuthTokenCache $credentials, ?callable $tokenCallback = null + ) { + return $this->attachToHttp($http, $credentials, $tokenCallback); + } + + private function attachToHttp( + ClientInterface $http, + FetchAuthTokenInterface $credentials, + ?callable $tokenCallback = null ) { // if we end up needing to make an HTTP request to retrieve credentials, we // can use our existing one, but we need to throw exceptions so the error @@ -63,9 +71,7 @@ public function attachCredentialsCache( $config['handler']->remove('google_auth'); $config['handler']->push($middleware, 'google_auth'); $config['auth'] = 'google_auth'; - $http = new Client($config); - - return $http; + return new Client($config); } public function attachToken(ClientInterface $http, array $token, array $scopes) diff --git a/lib/Google/src/Client.php b/lib/Google/src/Client.php index edfb1f83e..33147925f 100644 --- a/lib/Google/src/Client.php +++ b/lib/Google/src/Client.php @@ -27,6 +27,7 @@ use Google\Auth\Credentials\UserRefreshCredentials; use Google\Auth\CredentialsLoader; use Google\Auth\FetchAuthTokenCache; +use Google\Auth\FetchAuthTokenInterface; use Google\Auth\GetUniverseDomainInterface; use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Auth\OAuth2; @@ -90,7 +91,7 @@ class Client private $logger; /** - * @var ?CredentialsLoader $credentials + * @var ?FetchAuthTokenInterface $credentials */ private $credentials; @@ -118,10 +119,10 @@ class Client * Your Google Cloud client ID found in https://developers.google.com/console * @type string $client_secret * Your Google Cloud client secret found in https://developers.google.com/console - * @type string|array|CredentialsLoader $credentials + * @type string|array|FetchAuthTokenInterface $credentials * Can be a path to JSON credentials or an array representing those * credentials (@see Google\Client::setAuthConfig), or an instance of - * {@see CredentialsLoader}. + * {@see FetchAuthTokenInterface}. * @type string|array $scopes * {@see Google\Client::setScopes} * @type string $quota_project @@ -213,7 +214,7 @@ public function __construct(array $config = []) ], $config); if (!is_null($this->config['credentials'])) { - if ($this->config['credentials'] instanceof CredentialsLoader) { + if ($this->config['credentials'] instanceof FetchAuthTokenInterface) { $this->credentials = $this->config['credentials']; } else { $this->setAuthConfig($this->config['credentials']); @@ -460,7 +461,8 @@ public function authorize(?ClientInterface $http = null) $authHandler = $this->getAuthHandler(); // These conditionals represent the decision tree for authentication - // 1. Check if a Google\Auth\CredentialsLoader instance has been supplied via the "credentials" option + // 1. Check if an instance of Google\Auth\FetchAuthTokenInterface has + // been supplied via the "credentials" option // 2. Check for Application Default Credentials // 3a. Check for an Access Token // 3b. If access token exists but is expired, try to refresh it diff --git a/lib/Google/src/Task/Composer.php b/lib/Google/src/Task/Composer.php index fcad6bd13..fff4de22d 100644 --- a/lib/Google/src/Task/Composer.php +++ b/lib/Google/src/Task/Composer.php @@ -34,35 +34,37 @@ public static function cleanup( ) { $composer = $event->getComposer(); $extra = $composer->getPackage()->getExtra(); - $servicesToKeep = isset($extra['google/apiclient-services']) - ? $extra['google/apiclient-services'] - : []; - if ($servicesToKeep) { - $vendorDir = $composer->getConfig()->get('vendor-dir'); + $servicesToKeep = $extra['google/apiclient-services'] ?? []; + if (empty($servicesToKeep)) { + return; + } + $vendorDir = $composer->getConfig()->get('vendor-dir'); + $serviceDir = sprintf( + '%s/google/apiclient-services/src/Google/Service', + $vendorDir + ); + if (!is_dir($serviceDir)) { + // path for google/apiclient-services >= 0.200.0 $serviceDir = sprintf( - '%s/google/apiclient-services/src/Google/Service', + '%s/google/apiclient-services/src', $vendorDir ); - if (!is_dir($serviceDir)) { - // path for google/apiclient-services >= 0.200.0 - $serviceDir = sprintf( - '%s/google/apiclient-services/src', - $vendorDir - ); - } - self::verifyServicesToKeep($serviceDir, $servicesToKeep); - $finder = self::getServicesToRemove($serviceDir, $servicesToKeep); - $filesystem = $filesystem ?: new Filesystem(); - if (0 !== $count = count($finder)) { - $event->getIO()->write( - sprintf('Removing %s google services', $count) - ); - foreach ($finder as $file) { - $realpath = $file->getRealPath(); - $filesystem->remove($realpath); - $filesystem->remove($realpath . '.php'); - } - } + } + self::verifyServicesToKeep($serviceDir, $servicesToKeep); + $finder = self::getServicesToRemove($serviceDir, $servicesToKeep); + $filesystem = $filesystem ?: new Filesystem(); + $servicesToRemoveCount = $finder->count(); + if (0 === $servicesToRemoveCount) { + return; + } + $event->getIO()->write( + sprintf('Removing %d google services', $servicesToRemoveCount) + ); + $pathsToRemove = iterator_to_array($finder); + foreach ($pathsToRemove as $pathToRemove) { + $realpath = $pathToRemove->getRealPath(); + $filesystem->remove($realpath); + $filesystem->remove($realpath . '.php'); } } diff --git a/lib/Google/vendor/autoload.php b/lib/Google/vendor/autoload.php index 599daf634..5230015b2 100644 --- a/lib/Google/vendor/autoload.php +++ b/lib/Google/vendor/autoload.php @@ -14,12 +14,9 @@ echo $err; } } - trigger_error( - $err, - E_USER_ERROR - ); + throw new RuntimeException($err); } require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitbd131085cfdbf47b26d7ae00fe412ae4::getLoader(); +return ComposerAutoloaderInit7d51b2283bec19db67d0861b0c8ead2c::getLoader(); diff --git a/lib/Google/vendor/brick/math/CHANGELOG.md b/lib/Google/vendor/brick/math/CHANGELOG.md index 17cea8d9f..a07ba88a7 100644 --- a/lib/Google/vendor/brick/math/CHANGELOG.md +++ b/lib/Google/vendor/brick/math/CHANGELOG.md @@ -2,6 +2,57 @@ All notable changes to this project will be documented in this file. +## [0.13.1](https://github.com/brick/math/releases/tag/0.13.1) - 2025-03-29 + +✨ **Improvements** + +- `__toString()` methods of `BigInteger` and `BigDecimal` are now type-hinted as returning `numeric-string` instead of `string` (#90 by @vudaltsov) + +## [0.13.0](https://github.com/brick/math/releases/tag/0.13.0) - 2025-03-03 + +💥 **Breaking changes** + +- `BigDecimal::ofUnscaledValue()` no longer throws an exception if the scale is negative +- `MathException` now extends `RuntimeException` instead of `Exception`; this reverts the change introduced in version `0.11.0` (#82) + +✨ **New features** + +- `BigDecimal::ofUnscaledValue()` allows a negative scale (and converts the values to create a zero scale number) + +## [0.12.3](https://github.com/brick/math/releases/tag/0.12.3) - 2025-02-28 + +✨ **New features** + +- `BigDecimal::getPrecision()` Returns the number of significant digits in a decimal number + +## [0.12.2](https://github.com/brick/math/releases/tag/0.12.2) - 2025-02-26 + +⚡️ **Performance improvements** + +- Division in `NativeCalculator` is now faster for small divisors, thanks to [@Izumi-kun](https://github.com/Izumi-kun) in [#87](https://github.com/brick/math/pull/87). + +👌 **Improvements** + +- Add missing `RoundingNecessaryException` to the `@throws` annotation of `BigNumber::of()` + +## [0.12.1](https://github.com/brick/math/releases/tag/0.12.1) - 2023-11-29 + +⚡️ **Performance improvements** + +- `BigNumber::of()` is now faster, thanks to [@SebastienDug](https://github.com/SebastienDug) in [#77](https://github.com/brick/math/pull/77). + +## [0.12.0](https://github.com/brick/math/releases/tag/0.12.0) - 2023-11-26 + +💥 **Breaking changes** + +- Minimum PHP version is now 8.1 +- `RoundingMode` is now an `enum`; if you're type-hinting rounding modes, you need to type-hint against `RoundingMode` instead of `int` now +- `BigNumber` classes do not implement the `Serializable` interface anymore (they use the [new custom object serialization mechanism](https://wiki.php.net/rfc/custom_object_serialization)) +- The following breaking changes only affect you if you're creating your own `BigNumber` subclasses: + - the return type of `BigNumber::of()` is now `static` + - `BigNumber` has a new abstract method `from()` + - all `public` and `protected` functions of `BigNumber` are now `final` + ## [0.11.0](https://github.com/brick/math/releases/tag/0.11.0) - 2023-01-16 💥 **Breaking changes** diff --git a/lib/Google/vendor/brick/math/composer.json b/lib/Google/vendor/brick/math/composer.json index ed817bdd0..f400aa447 100644 --- a/lib/Google/vendor/brick/math/composer.json +++ b/lib/Google/vendor/brick/math/composer.json @@ -5,21 +5,26 @@ "keywords": [ "Brick", "Math", + "Mathematics", "Arbitrary-precision", "Arithmetic", "BigInteger", "BigDecimal", "BigRational", - "Bignum" + "BigNumber", + "Bignum", + "Decimal", + "Rational", + "Integer" ], "license": "MIT", "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^10.1", "php-coveralls/php-coveralls": "^2.2", - "vimeo/psalm": "5.0.0" + "vimeo/psalm": "6.8.8" }, "autoload": { "psr-4": { diff --git a/lib/Google/vendor/brick/math/psalm-baseline.xml b/lib/Google/vendor/brick/math/psalm-baseline.xml new file mode 100644 index 000000000..112adf451 --- /dev/null +++ b/lib/Google/vendor/brick/math/psalm-baseline.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/Google/vendor/brick/math/src/BigDecimal.php b/lib/Google/vendor/brick/math/src/BigDecimal.php index 02fc65612..0932fd642 100644 --- a/lib/Google/vendor/brick/math/src/BigDecimal.php +++ b/lib/Google/vendor/brick/math/src/BigDecimal.php @@ -8,6 +8,7 @@ use Brick\Math\Exception\MathException; use Brick\Math\Exception\NegativeNumberException; use Brick\Math\Internal\Calculator; +use Override; /** * Immutable, arbitrary-precision signed decimal numbers. @@ -23,14 +24,14 @@ final class BigDecimal extends BigNumber * No leading zero must be present. * No leading minus sign must be present if the value is 0. */ - private string $value; + private readonly string $value; /** * The scale (number of digits after the decimal point) of this decimal number. * * This must be zero or more. */ - private int $scale; + private readonly int $scale; /** * Protected constructor. Use a factory method to obtain an instance. @@ -45,15 +46,12 @@ protected function __construct(string $value, int $scale = 0) } /** - * Creates a BigDecimal of the given value. - * - * @throws MathException If the value cannot be converted to a BigDecimal. - * * @psalm-pure */ - public static function of(BigNumber|int|float|string $value) : BigDecimal + #[Override] + protected static function from(BigNumber $number): static { - return parent::of($value)->toBigDecimal(); + return $number->toBigDecimal(); } /** @@ -62,19 +60,23 @@ public static function of(BigNumber|int|float|string $value) : BigDecimal * Example: `(12345, 3)` will result in the BigDecimal `12.345`. * * @param BigNumber|int|float|string $value The unscaled value. Must be convertible to a BigInteger. - * @param int $scale The scale of the number, positive or zero. - * - * @throws \InvalidArgumentException If the scale is negative. + * @param int $scale The scale of the number. If negative, the scale will be set to zero + * and the unscaled value will be adjusted accordingly. * * @psalm-pure */ public static function ofUnscaledValue(BigNumber|int|float|string $value, int $scale = 0) : BigDecimal { + $value = (string) BigInteger::of($value); + if ($scale < 0) { - throw new \InvalidArgumentException('The scale cannot be negative.'); + if ($value !== '0') { + $value .= \str_repeat('0', -$scale); + } + $scale = 0; } - return new BigDecimal((string) BigInteger::of($value), $scale); + return new BigDecimal($value, $scale); } /** @@ -223,12 +225,12 @@ public function multipliedBy(BigNumber|int|float|string $that) : BigDecimal * * @param BigNumber|int|float|string $that The divisor. * @param int|null $scale The desired scale, or null to use the scale of this number. - * @param int $roundingMode An optional rounding mode. + * @param RoundingMode $roundingMode An optional rounding mode, defaults to UNNECESSARY. * * @throws \InvalidArgumentException If the scale or rounding mode is invalid. * @throws MathException If the number is invalid, is zero, or rounding was necessary. */ - public function dividedBy(BigNumber|int|float|string $that, ?int $scale = null, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + public function dividedBy(BigNumber|int|float|string $that, ?int $scale = null, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal { $that = BigDecimal::of($that); @@ -324,7 +326,7 @@ public function power(int $exponent) : BigDecimal } /** - * Returns the quotient of the division of this number by this given one. + * Returns the quotient of the division of this number by the given one. * * The quotient has a scale of `0`. * @@ -349,7 +351,7 @@ public function quotient(BigNumber|int|float|string $that) : BigDecimal } /** - * Returns the remainder of the division of this number by this given one. + * Returns the remainder of the division of this number by the given one. * * The remainder has a scale of `max($this->scale, $that->scale)`. * @@ -384,6 +386,8 @@ public function remainder(BigNumber|int|float|string $that) : BigDecimal * * @return BigDecimal[] An array containing the quotient and the remainder. * + * @psalm-return array{BigDecimal, BigDecimal} + * * @throws MathException If the divisor is not a valid decimal number, or is zero. */ public function quotientAndRemainder(BigNumber|int|float|string $that) : array @@ -537,6 +541,7 @@ public function negated() : BigDecimal return new BigDecimal(Calculator::get()->neg($this->value), $this->scale); } + #[Override] public function compareTo(BigNumber|int|float|string $that) : int { $that = BigNumber::of($that); @@ -554,6 +559,7 @@ public function compareTo(BigNumber|int|float|string $that) : int return - $that->compareTo($this); } + #[Override] public function getSign() : int { return ($this->value === '0') ? 0 : (($this->value[0] === '-') ? -1 : 1); @@ -569,6 +575,33 @@ public function getScale() : int return $this->scale; } + /** + * Returns the number of significant digits in the number. + * + * This is the number of digits to both sides of the decimal point, stripped of leading zeros. + * The sign has no impact on the result. + * + * Examples: + * 0 => 0 + * 0.0 => 0 + * 123 => 3 + * 123.456 => 6 + * 0.00123 => 3 + * 0.0012300 => 5 + */ + public function getPrecision(): int + { + $value = $this->value; + + if ($value === '0') { + return 0; + } + + $length = \strlen($value); + + return ($value[0] === '-') ? $length - 1 : $length; + } + /** * Returns a string representing the integral part of this decimal number. * @@ -611,6 +644,7 @@ public function hasNonZeroFractionalPart() : bool return $this->getFractionalPart() !== \str_repeat('0', $this->scale); } + #[Override] public function toBigInteger() : BigInteger { $zeroScaleDecimal = $this->scale === 0 ? $this : $this->dividedBy(1, 0); @@ -618,11 +652,13 @@ public function toBigInteger() : BigInteger return self::newBigInteger($zeroScaleDecimal->value); } + #[Override] public function toBigDecimal() : BigDecimal { return $this; } + #[Override] public function toBigRational() : BigRational { $numerator = self::newBigInteger($this->value); @@ -631,7 +667,8 @@ public function toBigRational() : BigRational return self::newBigRational($numerator, $denominator, false); } - public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + #[Override] + public function toScale(int $scale, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal { if ($scale === $this->scale) { return $this; @@ -640,24 +677,32 @@ public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSAR return $this->dividedBy(BigDecimal::one(), $scale, $roundingMode); } + #[Override] public function toInt() : int { return $this->toBigInteger()->toInt(); } + #[Override] public function toFloat() : float { return (float) (string) $this; } + /** + * @return numeric-string + */ + #[Override] public function __toString() : string { if ($this->scale === 0) { + /** @var numeric-string */ return $this->value; } $value = $this->getUnscaledValueWithLeadingZeros(); + /** @var numeric-string */ return \substr($value, 0, -$this->scale) . '.' . \substr($value, -$this->scale); } @@ -693,36 +738,6 @@ public function __unserialize(array $data): void $this->scale = $data['scale']; } - /** - * This method is required by interface Serializable and SHOULD NOT be accessed directly. - * - * @internal - */ - public function serialize() : string - { - return $this->value . ':' . $this->scale; - } - - /** - * This method is only here to implement interface Serializable and cannot be accessed directly. - * - * @internal - * @psalm-suppress RedundantPropertyInitializationCheck - * - * @throws \LogicException - */ - public function unserialize($value) : void - { - if (isset($this->value)) { - throw new \LogicException('unserialize() is an internal function, it must not be called directly.'); - } - - [$value, $scale] = \explode(':', $value); - - $this->value = $value; - $this->scale = (int) $scale; - } - /** * Puts the internal values of the given decimal numbers on the same scale. * diff --git a/lib/Google/vendor/brick/math/src/BigInteger.php b/lib/Google/vendor/brick/math/src/BigInteger.php index 435679331..6ede65e3a 100644 --- a/lib/Google/vendor/brick/math/src/BigInteger.php +++ b/lib/Google/vendor/brick/math/src/BigInteger.php @@ -10,6 +10,7 @@ use Brick\Math\Exception\NegativeNumberException; use Brick\Math\Exception\NumberFormatException; use Brick\Math\Internal\Calculator; +use Override; /** * An arbitrary-size integer. @@ -27,7 +28,7 @@ final class BigInteger extends BigNumber * No leading zeros must be present. * No leading minus sign must be present if the number is zero. */ - private string $value; + private readonly string $value; /** * Protected constructor. Use a factory method to obtain an instance. @@ -40,15 +41,12 @@ protected function __construct(string $value) } /** - * Creates a BigInteger of the given value. - * - * @throws MathException If the value cannot be converted to a BigInteger. - * * @psalm-pure */ - public static function of(BigNumber|int|float|string $value) : BigInteger + #[Override] + protected static function from(BigNumber $number): static { - return parent::of($value)->toBigInteger(); + return $number->toBigInteger(); } /** @@ -225,9 +223,10 @@ public static function randomBits(int $numBits, ?callable $randomBytesGenerator } if ($randomBytesGenerator === null) { - $randomBytesGenerator = 'random_bytes'; + $randomBytesGenerator = random_bytes(...); } + /** @var int<1, max> $byteLength */ $byteLength = \intdiv($numBits - 1, 8) + 1; $extraBits = ($byteLength * 8 - $numBits); @@ -429,12 +428,12 @@ public function multipliedBy(BigNumber|int|float|string $that) : BigInteger * Returns the result of the division of this number by the given one. * * @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger. - * @param int $roundingMode An optional rounding mode. + * @param RoundingMode $roundingMode An optional rounding mode, defaults to UNNECESSARY. * * @throws MathException If the divisor is not a valid number, is not convertible to a BigInteger, is zero, * or RoundingMode::UNNECESSARY is used and the remainder is not zero. */ - public function dividedBy(BigNumber|int|float|string $that, int $roundingMode = RoundingMode::UNNECESSARY) : BigInteger + public function dividedBy(BigNumber|int|float|string $that, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigInteger { $that = BigInteger::of($that); @@ -534,6 +533,8 @@ public function remainder(BigNumber|int|float|string $that) : BigInteger * * @return BigInteger[] An array containing the quotient and the remainder. * + * @psalm-return array{BigInteger, BigInteger} + * * @throws DivisionByZeroException If the divisor is zero. */ public function quotientAndRemainder(BigNumber|int|float|string $that) : array @@ -857,6 +858,7 @@ public function testBit(int $n) : bool return $this->shiftedRight($n)->isOdd(); } + #[Override] public function compareTo(BigNumber|int|float|string $that) : int { $that = BigNumber::of($that); @@ -868,31 +870,37 @@ public function compareTo(BigNumber|int|float|string $that) : int return - $that->compareTo($this); } + #[Override] public function getSign() : int { return ($this->value === '0') ? 0 : (($this->value[0] === '-') ? -1 : 1); } + #[Override] public function toBigInteger() : BigInteger { return $this; } + #[Override] public function toBigDecimal() : BigDecimal { return self::newBigDecimal($this->value); } + #[Override] public function toBigRational() : BigRational { return self::newBigRational($this, BigInteger::one(), false); } - public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + #[Override] + public function toScale(int $scale, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal { return $this->toBigDecimal()->toScale($scale, $roundingMode); } + #[Override] public function toInt() : int { $intValue = (int) $this->value; @@ -904,6 +912,7 @@ public function toInt() : int return $intValue; } + #[Override] public function toFloat() : float { return (float) $this->value; @@ -1014,8 +1023,13 @@ public function toBytes(bool $signed = true) : string return \hex2bin($hex); } + /** + * @return numeric-string + */ + #[Override] public function __toString() : string { + /** @var numeric-string */ return $this->value; } @@ -1049,31 +1063,4 @@ public function __unserialize(array $data): void $this->value = $data['value']; } - - /** - * This method is required by interface Serializable and SHOULD NOT be accessed directly. - * - * @internal - */ - public function serialize() : string - { - return $this->value; - } - - /** - * This method is only here to implement interface Serializable and cannot be accessed directly. - * - * @internal - * @psalm-suppress RedundantPropertyInitializationCheck - * - * @throws \LogicException - */ - public function unserialize($value) : void - { - if (isset($this->value)) { - throw new \LogicException('unserialize() is an internal function, it must not be called directly.'); - } - - $this->value = $value; - } } diff --git a/lib/Google/vendor/brick/math/src/BigNumber.php b/lib/Google/vendor/brick/math/src/BigNumber.php index 80146d207..5dabd314b 100644 --- a/lib/Google/vendor/brick/math/src/BigNumber.php +++ b/lib/Google/vendor/brick/math/src/BigNumber.php @@ -8,32 +8,36 @@ use Brick\Math\Exception\MathException; use Brick\Math\Exception\NumberFormatException; use Brick\Math\Exception\RoundingNecessaryException; +use Override; /** * Common interface for arbitrary-precision rational numbers. * * @psalm-immutable */ -abstract class BigNumber implements \Serializable, \JsonSerializable +abstract class BigNumber implements \JsonSerializable { /** - * The regular expression used to parse integer, decimal and rational numbers. + * The regular expression used to parse integer or decimal numbers. */ - private const PARSE_REGEXP = + private const PARSE_REGEXP_NUMERICAL = '/^' . '(?[\-\+])?' . - '(?:' . - '(?:' . - '(?[0-9]+)?' . - '(?\.)?' . - '(?[0-9]+)?' . - '(?:[eE](?[\-\+]?[0-9]+))?' . - ')|(?:' . - '(?[0-9]+)' . - '\/?' . - '(?[0-9]+)' . - ')' . - ')' . + '(?[0-9]+)?' . + '(?\.)?' . + '(?[0-9]+)?' . + '(?:[eE](?[\-\+]?[0-9]+))?' . + '$/'; + + /** + * The regular expression used to parse rational numbers. + */ + private const PARSE_REGEXP_RATIONAL = + '/^' . + '(?[\-\+])?' . + '(?[0-9]+)' . + '\/?' . + '(?[0-9]+)' . '$/'; /** @@ -48,12 +52,33 @@ abstract class BigNumber implements \Serializable, \JsonSerializable * - strings containing a `.` character or using an exponential notation are returned as BigDecimal * - strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger * - * @throws NumberFormatException If the format of the number is not valid. + * @throws NumberFormatException If the format of the number is not valid. + * @throws DivisionByZeroException If the value represents a rational number with a denominator of zero. + * @throws RoundingNecessaryException If the value cannot be converted to an instance of the subclass without rounding. + * + * @psalm-pure + */ + final public static function of(BigNumber|int|float|string $value) : static + { + $value = self::_of($value); + + if (static::class === BigNumber::class) { + // https://github.com/vimeo/psalm/issues/10309 + assert($value instanceof static); + + return $value; + } + + return static::from($value); + } + + /** + * @throws NumberFormatException If the format of the number is not valid. * @throws DivisionByZeroException If the value represents a rational number with a denominator of zero. * * @psalm-pure */ - public static function of(BigNumber|int|float|string $value) : BigNumber + private static function _of(BigNumber|int|float|string $value) : BigNumber { if ($value instanceof BigNumber) { return $value; @@ -63,34 +88,25 @@ public static function of(BigNumber|int|float|string $value) : BigNumber return new BigInteger((string) $value); } - $value = \is_float($value) ? self::floatToString($value) : $value; - - $throw = static function() use ($value) : void { - throw new NumberFormatException(\sprintf( - 'The given value "%s" does not represent a valid number.', - $value - )); - }; - - if (\preg_match(self::PARSE_REGEXP, $value, $matches) !== 1) { - $throw(); + if (is_float($value)) { + $value = (string) $value; } - $getMatch = static fn(string $value): ?string => (($matches[$value] ?? '') !== '') ? $matches[$value] : null; + if (str_contains($value, '/')) { + // Rational number + if (\preg_match(self::PARSE_REGEXP_RATIONAL, $value, $matches, PREG_UNMATCHED_AS_NULL) !== 1) { + throw NumberFormatException::invalidFormat($value); + } - $sign = $getMatch('sign'); - $numerator = $getMatch('numerator'); - $denominator = $getMatch('denominator'); + $sign = $matches['sign']; + $numerator = $matches['numerator']; + $denominator = $matches['denominator']; - if ($numerator !== null) { + assert($numerator !== null); assert($denominator !== null); - if ($sign !== null) { - $numerator = $sign . $numerator; - } - - $numerator = self::cleanUp($numerator); - $denominator = self::cleanUp($denominator); + $numerator = self::cleanUp($sign, $numerator); + $denominator = self::cleanUp(null, $denominator); if ($denominator === '0') { throw DivisionByZeroException::denominatorMustNotBeZero(); @@ -101,67 +117,62 @@ public static function of(BigNumber|int|float|string $value) : BigNumber new BigInteger($denominator), false ); - } + } else { + // Integer or decimal number + if (\preg_match(self::PARSE_REGEXP_NUMERICAL, $value, $matches, PREG_UNMATCHED_AS_NULL) !== 1) { + throw NumberFormatException::invalidFormat($value); + } - $point = $getMatch('point'); - $integral = $getMatch('integral'); - $fractional = $getMatch('fractional'); - $exponent = $getMatch('exponent'); + $sign = $matches['sign']; + $point = $matches['point']; + $integral = $matches['integral']; + $fractional = $matches['fractional']; + $exponent = $matches['exponent']; - if ($integral === null && $fractional === null) { - $throw(); - } + if ($integral === null && $fractional === null) { + throw NumberFormatException::invalidFormat($value); + } - if ($integral === null) { - $integral = '0'; - } + if ($integral === null) { + $integral = '0'; + } - if ($point !== null || $exponent !== null) { - $fractional = ($fractional ?? ''); - $exponent = ($exponent !== null) ? (int) $exponent : 0; + if ($point !== null || $exponent !== null) { + $fractional = ($fractional ?? ''); + $exponent = ($exponent !== null) ? (int)$exponent : 0; - if ($exponent === PHP_INT_MIN || $exponent === PHP_INT_MAX) { - throw new NumberFormatException('Exponent too large.'); - } + if ($exponent === PHP_INT_MIN || $exponent === PHP_INT_MAX) { + throw new NumberFormatException('Exponent too large.'); + } - $unscaledValue = self::cleanUp(($sign ?? ''). $integral . $fractional); + $unscaledValue = self::cleanUp($sign, $integral . $fractional); - $scale = \strlen($fractional) - $exponent; + $scale = \strlen($fractional) - $exponent; - if ($scale < 0) { - if ($unscaledValue !== '0') { - $unscaledValue .= \str_repeat('0', - $scale); + if ($scale < 0) { + if ($unscaledValue !== '0') { + $unscaledValue .= \str_repeat('0', -$scale); + } + $scale = 0; } - $scale = 0; - } - return new BigDecimal($unscaledValue, $scale); - } + return new BigDecimal($unscaledValue, $scale); + } - $integral = self::cleanUp(($sign ?? '') . $integral); + $integral = self::cleanUp($sign, $integral); - return new BigInteger($integral); + return new BigInteger($integral); + } } /** - * Safely converts float to string, avoiding locale-dependent issues. + * Overridden by subclasses to convert a BigNumber to an instance of the subclass. * - * @see https://github.com/brick/math/pull/20 + * @throws RoundingNecessaryException If the value cannot be converted. * * @psalm-pure - * @psalm-suppress ImpureFunctionCall */ - private static function floatToString(float $float) : string - { - $currentLocale = \setlocale(LC_NUMERIC, '0'); - \setlocale(LC_NUMERIC, 'C'); - - $result = (string) $float; - - \setlocale(LC_NUMERIC, $currentLocale); - - return $result; - } + abstract protected static function from(BigNumber $number): static; /** * Proxy method to access BigInteger's protected constructor from sibling classes. @@ -169,7 +180,7 @@ private static function floatToString(float $float) : string * @internal * @psalm-pure */ - protected function newBigInteger(string $value) : BigInteger + final protected function newBigInteger(string $value) : BigInteger { return new BigInteger($value); } @@ -180,7 +191,7 @@ protected function newBigInteger(string $value) : BigInteger * @internal * @psalm-pure */ - protected function newBigDecimal(string $value, int $scale = 0) : BigDecimal + final protected function newBigDecimal(string $value, int $scale = 0) : BigDecimal { return new BigDecimal($value, $scale); } @@ -191,7 +202,7 @@ protected function newBigDecimal(string $value, int $scale = 0) : BigDecimal * @internal * @psalm-pure */ - protected function newBigRational(BigInteger $numerator, BigInteger $denominator, bool $checkDenominator) : BigRational + final protected function newBigRational(BigInteger $numerator, BigInteger $denominator, bool $checkDenominator) : BigRational { return new BigRational($numerator, $denominator, $checkDenominator); } @@ -205,11 +216,9 @@ protected function newBigRational(BigInteger $numerator, BigInteger $denominator * @throws \InvalidArgumentException If no values are given. * @throws MathException If an argument is not valid. * - * @psalm-suppress LessSpecificReturnStatement - * @psalm-suppress MoreSpecificReturnType * @psalm-pure */ - public static function min(BigNumber|int|float|string ...$values) : static + final public static function min(BigNumber|int|float|string ...$values) : static { $min = null; @@ -237,11 +246,9 @@ public static function min(BigNumber|int|float|string ...$values) : static * @throws \InvalidArgumentException If no values are given. * @throws MathException If an argument is not valid. * - * @psalm-suppress LessSpecificReturnStatement - * @psalm-suppress MoreSpecificReturnType * @psalm-pure */ - public static function max(BigNumber|int|float|string ...$values) : static + final public static function max(BigNumber|int|float|string ...$values) : static { $max = null; @@ -271,7 +278,7 @@ public static function max(BigNumber|int|float|string ...$values) : static * * @psalm-pure */ - public static function sum(BigNumber|int|float|string ...$values) : static + final public static function sum(BigNumber|int|float|string ...$values) : static { /** @var static|null $sum */ $sum = null; @@ -323,37 +330,28 @@ private static function add(BigNumber $a, BigNumber $b) : BigNumber } /** - * Removes optional leading zeros and + sign from the given number. + * Removes optional leading zeros and applies sign. * - * @param string $number The number, validated as a non-empty string of digits with optional leading sign. + * @param string|null $sign The sign, '+' or '-', optional. Null is allowed for convenience and treated as '+'. + * @param string $number The number, validated as a non-empty string of digits. * * @psalm-pure */ - private static function cleanUp(string $number) : string + private static function cleanUp(string|null $sign, string $number) : string { - $firstChar = $number[0]; - - if ($firstChar === '+' || $firstChar === '-') { - $number = \substr($number, 1); - } - $number = \ltrim($number, '0'); if ($number === '') { return '0'; } - if ($firstChar === '-') { - return '-' . $number; - } - - return $number; + return $sign === '-' ? '-' . $number : $number; } /** * Checks if this number is equal to the given one. */ - public function isEqualTo(BigNumber|int|float|string $that) : bool + final public function isEqualTo(BigNumber|int|float|string $that) : bool { return $this->compareTo($that) === 0; } @@ -361,7 +359,7 @@ public function isEqualTo(BigNumber|int|float|string $that) : bool /** * Checks if this number is strictly lower than the given one. */ - public function isLessThan(BigNumber|int|float|string $that) : bool + final public function isLessThan(BigNumber|int|float|string $that) : bool { return $this->compareTo($that) < 0; } @@ -369,7 +367,7 @@ public function isLessThan(BigNumber|int|float|string $that) : bool /** * Checks if this number is lower than or equal to the given one. */ - public function isLessThanOrEqualTo(BigNumber|int|float|string $that) : bool + final public function isLessThanOrEqualTo(BigNumber|int|float|string $that) : bool { return $this->compareTo($that) <= 0; } @@ -377,7 +375,7 @@ public function isLessThanOrEqualTo(BigNumber|int|float|string $that) : bool /** * Checks if this number is strictly greater than the given one. */ - public function isGreaterThan(BigNumber|int|float|string $that) : bool + final public function isGreaterThan(BigNumber|int|float|string $that) : bool { return $this->compareTo($that) > 0; } @@ -385,7 +383,7 @@ public function isGreaterThan(BigNumber|int|float|string $that) : bool /** * Checks if this number is greater than or equal to the given one. */ - public function isGreaterThanOrEqualTo(BigNumber|int|float|string $that) : bool + final public function isGreaterThanOrEqualTo(BigNumber|int|float|string $that) : bool { return $this->compareTo($that) >= 0; } @@ -393,7 +391,7 @@ public function isGreaterThanOrEqualTo(BigNumber|int|float|string $that) : bool /** * Checks if this number equals zero. */ - public function isZero() : bool + final public function isZero() : bool { return $this->getSign() === 0; } @@ -401,7 +399,7 @@ public function isZero() : bool /** * Checks if this number is strictly negative. */ - public function isNegative() : bool + final public function isNegative() : bool { return $this->getSign() < 0; } @@ -409,7 +407,7 @@ public function isNegative() : bool /** * Checks if this number is negative or zero. */ - public function isNegativeOrZero() : bool + final public function isNegativeOrZero() : bool { return $this->getSign() <= 0; } @@ -417,7 +415,7 @@ public function isNegativeOrZero() : bool /** * Checks if this number is strictly positive. */ - public function isPositive() : bool + final public function isPositive() : bool { return $this->getSign() > 0; } @@ -425,7 +423,7 @@ public function isPositive() : bool /** * Checks if this number is positive or zero. */ - public function isPositiveOrZero() : bool + final public function isPositiveOrZero() : bool { return $this->getSign() >= 0; } @@ -433,6 +431,8 @@ public function isPositiveOrZero() : bool /** * Returns the sign of this number. * + * @psalm-return -1|0|1 + * * @return int -1 if the number is negative, 0 if zero, 1 if positive. */ abstract public function getSign() : int; @@ -440,7 +440,9 @@ abstract public function getSign() : int; /** * Compares this number to the given one. * - * @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`. + * @psalm-return -1|0|1 + * + * @return int -1 if `$this` is lower than, 0 if equal to, 1 if greater than `$that`. * * @throws MathException If the number is not valid. */ @@ -468,13 +470,13 @@ abstract public function toBigRational() : BigRational; /** * Converts this number to a BigDecimal with the given scale, using rounding if necessary. * - * @param int $scale The scale of the resulting `BigDecimal`. - * @param int $roundingMode A `RoundingMode` constant. + * @param int $scale The scale of the resulting `BigDecimal`. + * @param RoundingMode $roundingMode An optional rounding mode, defaults to UNNECESSARY. * * @throws RoundingNecessaryException If this number cannot be converted to the given scale without rounding. * This only applies when RoundingMode::UNNECESSARY is used. */ - abstract public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal; + abstract public function toScale(int $scale, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal; /** * Returns the exact value of this number as a native integer. @@ -505,7 +507,8 @@ abstract public function toFloat() : float; */ abstract public function __toString() : string; - public function jsonSerialize() : string + #[Override] + final public function jsonSerialize() : string { return $this->__toString(); } diff --git a/lib/Google/vendor/brick/math/src/BigRational.php b/lib/Google/vendor/brick/math/src/BigRational.php index 31f2904fa..fc36e5573 100644 --- a/lib/Google/vendor/brick/math/src/BigRational.php +++ b/lib/Google/vendor/brick/math/src/BigRational.php @@ -8,6 +8,7 @@ use Brick\Math\Exception\MathException; use Brick\Math\Exception\NumberFormatException; use Brick\Math\Exception\RoundingNecessaryException; +use Override; /** * An arbitrarily large rational number. @@ -21,12 +22,12 @@ final class BigRational extends BigNumber /** * The numerator. */ - private BigInteger $numerator; + private readonly BigInteger $numerator; /** * The denominator. Always strictly positive. */ - private BigInteger $denominator; + private readonly BigInteger $denominator; /** * Protected constructor. Use a factory method to obtain an instance. @@ -55,15 +56,12 @@ protected function __construct(BigInteger $numerator, BigInteger $denominator, b } /** - * Creates a BigRational of the given value. - * - * @throws MathException If the value cannot be converted to a BigRational. - * * @psalm-pure */ - public static function of(BigNumber|int|float|string $value) : BigRational + #[Override] + protected static function from(BigNumber $number): static { - return parent::of($value)->toBigRational(); + return $number->toBigRational(); } /** @@ -181,6 +179,8 @@ public function remainder() : BigInteger * Returns the quotient and remainder of the division of the numerator by the denominator. * * @return BigInteger[] + * + * @psalm-return array{BigInteger, BigInteger} */ public function quotientAndRemainder() : array { @@ -322,16 +322,19 @@ public function simplified() : BigRational return new BigRational($numerator, $denominator, false); } + #[Override] public function compareTo(BigNumber|int|float|string $that) : int { return $this->minus($that)->getSign(); } + #[Override] public function getSign() : int { return $this->numerator->getSign(); } + #[Override] public function toBigInteger() : BigInteger { $simplified = $this->simplified(); @@ -343,32 +346,38 @@ public function toBigInteger() : BigInteger return $simplified->numerator; } + #[Override] public function toBigDecimal() : BigDecimal { return $this->numerator->toBigDecimal()->exactlyDividedBy($this->denominator); } + #[Override] public function toBigRational() : BigRational { return $this; } - public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal + #[Override] + public function toScale(int $scale, RoundingMode $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal { return $this->numerator->toBigDecimal()->dividedBy($this->denominator, $scale, $roundingMode); } + #[Override] public function toInt() : int { return $this->toBigInteger()->toInt(); } + #[Override] public function toFloat() : float { $simplified = $this->simplified(); return $simplified->numerator->toFloat() / $simplified->denominator->toFloat(); } + #[Override] public function __toString() : string { $numerator = (string) $this->numerator; @@ -378,7 +387,7 @@ public function __toString() : string return $numerator; } - return $this->numerator . '/' . $this->denominator; + return $numerator . '/' . $denominator; } /** @@ -412,34 +421,4 @@ public function __unserialize(array $data): void $this->numerator = $data['numerator']; $this->denominator = $data['denominator']; } - - /** - * This method is required by interface Serializable and SHOULD NOT be accessed directly. - * - * @internal - */ - public function serialize() : string - { - return $this->numerator . '/' . $this->denominator; - } - - /** - * This method is only here to implement interface Serializable and cannot be accessed directly. - * - * @internal - * @psalm-suppress RedundantPropertyInitializationCheck - * - * @throws \LogicException - */ - public function unserialize($value) : void - { - if (isset($this->numerator)) { - throw new \LogicException('unserialize() is an internal function, it must not be called directly.'); - } - - [$numerator, $denominator] = \explode('/', $value); - - $this->numerator = BigInteger::of($numerator); - $this->denominator = BigInteger::of($denominator); - } } diff --git a/lib/Google/vendor/brick/math/src/Exception/MathException.php b/lib/Google/vendor/brick/math/src/Exception/MathException.php index 46e9c3fe4..8facd9c62 100644 --- a/lib/Google/vendor/brick/math/src/Exception/MathException.php +++ b/lib/Google/vendor/brick/math/src/Exception/MathException.php @@ -7,6 +7,6 @@ /** * Base class for all math exceptions. */ -class MathException extends \Exception +class MathException extends \RuntimeException { } diff --git a/lib/Google/vendor/brick/math/src/Exception/NumberFormatException.php b/lib/Google/vendor/brick/math/src/Exception/NumberFormatException.php index d9cf6ff5f..119cadbb4 100644 --- a/lib/Google/vendor/brick/math/src/Exception/NumberFormatException.php +++ b/lib/Google/vendor/brick/math/src/Exception/NumberFormatException.php @@ -9,6 +9,14 @@ */ class NumberFormatException extends MathException { + public static function invalidFormat(string $value) : self + { + return new self(\sprintf( + 'The given value "%s" does not represent a valid number.', + $value, + )); + } + /** * @param string $char The failing character. * @@ -28,6 +36,6 @@ public static function charNotInAlphabet(string $char) : self $char = '"' . $char . '"'; } - return new self(sprintf('Char %s is not a valid character in the given alphabet.', $char)); + return new self(\sprintf('Char %s is not a valid character in the given alphabet.', $char)); } } diff --git a/lib/Google/vendor/brick/math/src/Internal/Calculator.php b/lib/Google/vendor/brick/math/src/Internal/Calculator.php index b8cecda96..44dd66924 100644 --- a/lib/Google/vendor/brick/math/src/Internal/Calculator.php +++ b/lib/Google/vendor/brick/math/src/Internal/Calculator.php @@ -25,7 +25,7 @@ abstract class Calculator /** * The maximum exponent value allowed for the pow() method. */ - public const MAX_POWER = 1000000; + public const MAX_POWER = 1_000_000; /** * The alphabet for converting from and to base 2 to 36, lowercase. @@ -128,7 +128,9 @@ final public function neg(string $n) : string /** * Compares two numbers. * - * @return int [-1, 0, 1] If the first number is less than, equal to, or greater than the second number. + * @psalm-return -1|0|1 + * + * @return int -1 if the first number is less than, 0 if equal to, 1 if greater than the second number. */ final public function cmp(string $a, string $b) : int { @@ -428,16 +430,16 @@ final public function toArbitraryBase(string $number, string $alphabet, int $bas * * Rounding is performed when the remainder of the division is not zero. * - * @param string $a The dividend. - * @param string $b The divisor, must not be zero. - * @param int $roundingMode The rounding mode. + * @param string $a The dividend. + * @param string $b The divisor, must not be zero. + * @param RoundingMode $roundingMode The rounding mode. * * @throws \InvalidArgumentException If the rounding mode is invalid. * @throws RoundingNecessaryException If RoundingMode::UNNECESSARY is provided but rounding is necessary. * * @psalm-suppress ImpureFunctionCall */ - final public function divRound(string $a, string $b, int $roundingMode) : string + final public function divRound(string $a, string $b, RoundingMode $roundingMode) : string { [$quotient, $remainder] = $this->divQR($a, $b); @@ -571,27 +573,17 @@ private function bitwise(string $operator, string $a, string $b) : string $bBin = $this->twosComplement($bBin); } - switch ($operator) { - case 'and': - $value = $aBin & $bBin; - $negative = ($aNeg and $bNeg); - break; - - case 'or': - $value = $aBin | $bBin; - $negative = ($aNeg or $bNeg); - break; - - case 'xor': - $value = $aBin ^ $bBin; - $negative = ($aNeg xor $bNeg); - break; + $value = match ($operator) { + 'and' => $aBin & $bBin, + 'or' => $aBin | $bBin, + 'xor' => $aBin ^ $bBin, + }; - // @codeCoverageIgnoreStart - default: - throw new \InvalidArgumentException('Invalid bitwise operator.'); - // @codeCoverageIgnoreEnd - } + $negative = match ($operator) { + 'and' => $aNeg and $bNeg, + 'or' => $aNeg or $bNeg, + 'xor' => $aNeg xor $bNeg, + }; if ($negative) { $value = $this->twosComplement($value); diff --git a/lib/Google/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php b/lib/Google/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php index 5457a3c98..93a27ff81 100644 --- a/lib/Google/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php +++ b/lib/Google/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php @@ -5,6 +5,7 @@ namespace Brick\Math\Internal\Calculator; use Brick\Math\Internal\Calculator; +use Override; /** * Calculator implementation built around the bcmath library. @@ -15,59 +16,58 @@ */ class BcMathCalculator extends Calculator { + #[Override] public function add(string $a, string $b) : string { return \bcadd($a, $b, 0); } + #[Override] public function sub(string $a, string $b) : string { return \bcsub($a, $b, 0); } + #[Override] public function mul(string $a, string $b) : string { return \bcmul($a, $b, 0); } + #[Override] public function divQ(string $a, string $b) : string { return \bcdiv($a, $b, 0); } - /** - * @psalm-suppress InvalidNullableReturnType - * @psalm-suppress NullableReturnStatement - */ + #[Override] public function divR(string $a, string $b) : string { return \bcmod($a, $b, 0); } + #[Override] public function divQR(string $a, string $b) : array { $q = \bcdiv($a, $b, 0); $r = \bcmod($a, $b, 0); - assert($r !== null); - return [$q, $r]; } + #[Override] public function pow(string $a, int $e) : string { return \bcpow($a, (string) $e, 0); } + #[Override] public function modPow(string $base, string $exp, string $mod) : string { return \bcpowmod($base, $exp, $mod, 0); } - /** - * @psalm-suppress InvalidNullableReturnType - * @psalm-suppress NullableReturnStatement - */ + #[Override] public function sqrt(string $n) : string { return \bcsqrt($n, 0); diff --git a/lib/Google/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php b/lib/Google/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php index 42d4c6927..0e44deeb3 100644 --- a/lib/Google/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php +++ b/lib/Google/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php @@ -5,6 +5,7 @@ namespace Brick\Math\Internal\Calculator; use Brick\Math\Internal\Calculator; +use Override; /** * Calculator implementation built around the GMP library. @@ -15,31 +16,37 @@ */ class GmpCalculator extends Calculator { + #[Override] public function add(string $a, string $b) : string { return \gmp_strval(\gmp_add($a, $b)); } + #[Override] public function sub(string $a, string $b) : string { return \gmp_strval(\gmp_sub($a, $b)); } + #[Override] public function mul(string $a, string $b) : string { return \gmp_strval(\gmp_mul($a, $b)); } + #[Override] public function divQ(string $a, string $b) : string { return \gmp_strval(\gmp_div_q($a, $b)); } + #[Override] public function divR(string $a, string $b) : string { return \gmp_strval(\gmp_div_r($a, $b)); } + #[Override] public function divQR(string $a, string $b) : array { [$q, $r] = \gmp_div_qr($a, $b); @@ -50,11 +57,13 @@ public function divQR(string $a, string $b) : array ]; } + #[Override] public function pow(string $a, int $e) : string { return \gmp_strval(\gmp_pow($a, $e)); } + #[Override] public function modInverse(string $x, string $m) : ?string { $result = \gmp_invert($x, $m); @@ -66,41 +75,49 @@ public function modInverse(string $x, string $m) : ?string return \gmp_strval($result); } + #[Override] public function modPow(string $base, string $exp, string $mod) : string { return \gmp_strval(\gmp_powm($base, $exp, $mod)); } + #[Override] public function gcd(string $a, string $b) : string { return \gmp_strval(\gmp_gcd($a, $b)); } + #[Override] public function fromBase(string $number, int $base) : string { return \gmp_strval(\gmp_init($number, $base)); } + #[Override] public function toBase(string $number, int $base) : string { return \gmp_strval($number, $base); } + #[Override] public function and(string $a, string $b) : string { return \gmp_strval(\gmp_and($a, $b)); } + #[Override] public function or(string $a, string $b) : string { return \gmp_strval(\gmp_or($a, $b)); } + #[Override] public function xor(string $a, string $b) : string { return \gmp_strval(\gmp_xor($a, $b)); } + #[Override] public function sqrt(string $n) : string { return \gmp_strval(\gmp_sqrt($n)); diff --git a/lib/Google/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php b/lib/Google/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php index 7c679d24d..f71c55bed 100644 --- a/lib/Google/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php +++ b/lib/Google/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php @@ -5,6 +5,7 @@ namespace Brick\Math\Internal\Calculator; use Brick\Math\Internal\Calculator; +use Override; /** * Calculator implementation using only native PHP code. @@ -23,27 +24,21 @@ class NativeCalculator extends Calculator * Example: 32-bit: max number 1,999,999,999 (9 digits + carry) * 64-bit: max number 1,999,999,999,999,999,999 (18 digits + carry) */ - private int $maxDigits; + private readonly int $maxDigits; /** * @codeCoverageIgnore */ public function __construct() { - switch (PHP_INT_SIZE) { - case 4: - $this->maxDigits = 9; - break; - - case 8: - $this->maxDigits = 18; - break; - - default: - throw new \RuntimeException('The platform is not 32-bit or 64-bit as expected.'); - } + $this->maxDigits = match (PHP_INT_SIZE) { + 4 => 9, + 8 => 18, + default => throw new \RuntimeException('The platform is not 32-bit or 64-bit as expected.') + }; } + #[Override] public function add(string $a, string $b) : string { /** @@ -75,11 +70,13 @@ public function add(string $a, string $b) : string return $result; } + #[Override] public function sub(string $a, string $b) : string { return $this->add($a, $this->neg($b)); } + #[Override] public function mul(string $a, string $b) : string { /** @@ -123,16 +120,19 @@ public function mul(string $a, string $b) : string return $result; } + #[Override] public function divQ(string $a, string $b) : string { return $this->divQR($a, $b)[0]; } + #[Override] public function divR(string $a, string $b): string { return $this->divQR($a, $b)[1]; } + #[Override] public function divQR(string $a, string $b) : array { if ($a === '0') { @@ -161,10 +161,8 @@ public function divQR(string $a, string $b) : array if (is_int($nb)) { // the only division that may overflow is PHP_INT_MIN / -1, // which cannot happen here as we've already handled a divisor of -1 above. + $q = intdiv($na, $nb); $r = $na % $nb; - $q = ($na - $r) / $nb; - - assert(is_int($q)); return [ (string) $q, @@ -188,6 +186,7 @@ public function divQR(string $a, string $b) : array return [$q, $r]; } + #[Override] public function pow(string $a, int $e) : string { if ($e === 0) { @@ -216,6 +215,7 @@ public function pow(string $a, int $e) : string /** * Algorithm from: https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/ */ + #[Override] public function modPow(string $base, string $exp, string $mod) : string { // special case: the algorithm below fails with 0 power 0 mod 1 (returns 1 instead of 0) @@ -250,6 +250,7 @@ public function modPow(string $base, string $exp, string $mod) : string /** * Adapted from https://cp-algorithms.com/num_methods/roots_newton.html */ + #[Override] public function sqrt(string $n) : string { if ($n === '0') { @@ -497,6 +498,22 @@ private function doDiv(string $a, string $b) : array $r = $a; // remainder $z = $y; // focus length, always $y or $y+1 + /** @psalm-var numeric-string $b */ + $nb = $b * 1; // cast to number + // performance optimization in cases where the remainder will never cause int overflow + if (is_int(($nb - 1) * 10 + 9)) { + $r = (int) \substr($a, 0, $z - 1); + + for ($i = $z - 1; $i < $x; $i++) { + $n = $r * 10 + (int) $a[$i]; + /** @psalm-var int $nb */ + $q .= \intdiv($n, $nb); + $r = $n % $nb; + } + + return [\ltrim($q, '0') ?: '0', (string) $r]; + } + for (;;) { $focus = \substr($a, 0, $z); @@ -536,7 +553,7 @@ private function doDiv(string $a, string $b) : array /** * Compares two non-signed large numbers. * - * @return int [-1, 0, 1] + * @psalm-return -1|0|1 */ private function doCmp(string $a, string $b) : int { @@ -549,7 +566,7 @@ private function doCmp(string $a, string $b) : int return $cmp; } - return \strcmp($a, $b) <=> 0; // enforce [-1, 0, 1] + return \strcmp($a, $b) <=> 0; // enforce -1|0|1 } /** diff --git a/lib/Google/vendor/brick/math/src/RoundingMode.php b/lib/Google/vendor/brick/math/src/RoundingMode.php index 06936d8db..e8ee6a8b4 100644 --- a/lib/Google/vendor/brick/math/src/RoundingMode.php +++ b/lib/Google/vendor/brick/math/src/RoundingMode.php @@ -13,24 +13,15 @@ * regardless the digits' contribution to the value of the number. In other words, considered * as a numerical value, the discarded fraction could have an absolute value greater than one. */ -final class RoundingMode +enum RoundingMode { - /** - * Private constructor. This class is not instantiable. - * - * @codeCoverageIgnore - */ - private function __construct() - { - } - /** * Asserts that the requested operation has an exact result, hence no rounding is necessary. * * If this rounding mode is specified on an operation that yields a result that * cannot be represented at the requested scale, a RoundingNecessaryException is thrown. */ - public const UNNECESSARY = 0; + case UNNECESSARY; /** * Rounds away from zero. @@ -38,7 +29,7 @@ private function __construct() * Always increments the digit prior to a nonzero discarded fraction. * Note that this rounding mode never decreases the magnitude of the calculated value. */ - public const UP = 1; + case UP; /** * Rounds towards zero. @@ -46,7 +37,7 @@ private function __construct() * Never increments the digit prior to a discarded fraction (i.e., truncates). * Note that this rounding mode never increases the magnitude of the calculated value. */ - public const DOWN = 2; + case DOWN; /** * Rounds towards positive infinity. @@ -54,7 +45,7 @@ private function __construct() * If the result is positive, behaves as for UP; if negative, behaves as for DOWN. * Note that this rounding mode never decreases the calculated value. */ - public const CEILING = 3; + case CEILING; /** * Rounds towards negative infinity. @@ -62,7 +53,7 @@ private function __construct() * If the result is positive, behave as for DOWN; if negative, behave as for UP. * Note that this rounding mode never increases the calculated value. */ - public const FLOOR = 4; + case FLOOR; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round up. @@ -70,28 +61,28 @@ private function __construct() * Behaves as for UP if the discarded fraction is >= 0.5; otherwise, behaves as for DOWN. * Note that this is the rounding mode commonly taught at school. */ - public const HALF_UP = 5; + case HALF_UP; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. * * Behaves as for UP if the discarded fraction is > 0.5; otherwise, behaves as for DOWN. */ - public const HALF_DOWN = 6; + case HALF_DOWN; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards positive infinity. * * If the result is positive, behaves as for HALF_UP; if negative, behaves as for HALF_DOWN. */ - public const HALF_CEILING = 7; + case HALF_CEILING; /** * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards negative infinity. * * If the result is positive, behaves as for HALF_DOWN; if negative, behaves as for HALF_UP. */ - public const HALF_FLOOR = 8; + case HALF_FLOOR; /** * Rounds towards the "nearest neighbor" unless both neighbors are equidistant, in which case rounds towards the even neighbor. @@ -103,5 +94,5 @@ private function __construct() * cumulative error when applied repeatedly over a sequence of calculations. * It is sometimes known as "Banker's rounding", and is chiefly used in the USA. */ - public const HALF_EVEN = 9; + case HALF_EVEN; } diff --git a/lib/Google/vendor/composer/InstalledVersions.php b/lib/Google/vendor/composer/InstalledVersions.php index 51e734a77..2052022fd 100644 --- a/lib/Google/vendor/composer/InstalledVersions.php +++ b/lib/Google/vendor/composer/InstalledVersions.php @@ -26,12 +26,23 @@ */ class InstalledVersions { + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + /** * @var mixed[]|null * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; + /** + * @var bool + */ + private static $installedIsLocalDir; + /** * @var bool|null */ @@ -309,6 +320,24 @@ public static function reload($data) { self::$installed = $data; self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; } /** @@ -322,19 +351,27 @@ private static function getInstalled() } $installed = array(); + $copiedLocalDir = false; if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ $required = require $vendorDir.'/composer/installed.php'; - $installed[] = self::$installedByVendor[$vendorDir] = $required; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; } } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } } } @@ -350,7 +387,7 @@ private static function getInstalled() } } - if (self::$installed !== array()) { + if (self::$installed !== array() && !$copiedLocalDir) { $installed[] = self::$installed; } diff --git a/lib/Google/vendor/composer/autoload_classmap.php b/lib/Google/vendor/composer/autoload_classmap.php index c80dde643..375ca28e3 100644 --- a/lib/Google/vendor/composer/autoload_classmap.php +++ b/lib/Google/vendor/composer/autoload_classmap.php @@ -6,7 +6,6 @@ $baseDir = dirname($vendorDir); return array( - 'CURLStringFile' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 'GPBMetadata\\GrpcGcp' => $vendorDir . '/google/grpc-gcp/src/generated/GPBMetadata/GrpcGcp.php', 'Google_AccessToken_Revoke' => $baseDir . '/src/aliases.php', @@ -34,5 +33,4 @@ 'Grpc\\Gcp\\ApiConfig' => $vendorDir . '/google/grpc-gcp/src/generated/Grpc/Gcp/ApiConfig.php', 'Grpc\\Gcp\\ChannelPoolConfig' => $vendorDir . '/google/grpc-gcp/src/generated/Grpc/Gcp/ChannelPoolConfig.php', 'Grpc\\Gcp\\MethodConfig' => $vendorDir . '/google/grpc-gcp/src/generated/Grpc/Gcp/MethodConfig.php', - 'ReturnTypeWillChange' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php', ); diff --git a/lib/Google/vendor/composer/autoload_files.php b/lib/Google/vendor/composer/autoload_files.php index 1b96f7179..78726fc7a 100644 --- a/lib/Google/vendor/composer/autoload_files.php +++ b/lib/Google/vendor/composer/autoload_files.php @@ -9,7 +9,6 @@ '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', - '23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php', 'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php', '1f87db08236948d07391152dccb70f04' => $vendorDir . '/google/apiclient-services/autoload.php', 'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php', diff --git a/lib/Google/vendor/composer/autoload_psr4.php b/lib/Google/vendor/composer/autoload_psr4.php index 941b62a92..d18917026 100644 --- a/lib/Google/vendor/composer/autoload_psr4.php +++ b/lib/Google/vendor/composer/autoload_psr4.php @@ -7,7 +7,6 @@ return array( 'phpseclib3\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), - 'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'), 'Rize\\' => array($vendorDir . '/rize/uri-template/src/Rize'), 'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'), 'Ramsey\\Collection\\' => array($vendorDir . '/ramsey/collection/src'), diff --git a/lib/Google/vendor/composer/autoload_real.php b/lib/Google/vendor/composer/autoload_real.php index 9659486a6..7dfe40e5b 100644 --- a/lib/Google/vendor/composer/autoload_real.php +++ b/lib/Google/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitbd131085cfdbf47b26d7ae00fe412ae4 +class ComposerAutoloaderInit7d51b2283bec19db67d0861b0c8ead2c { private static $loader; @@ -24,16 +24,16 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInitbd131085cfdbf47b26d7ae00fe412ae4', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit7d51b2283bec19db67d0861b0c8ead2c', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitbd131085cfdbf47b26d7ae00fe412ae4', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit7d51b2283bec19db67d0861b0c8ead2c', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit7d51b2283bec19db67d0861b0c8ead2c::getInitializer($loader)); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit7d51b2283bec19db67d0861b0c8ead2c::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/lib/Google/vendor/composer/autoload_static.php b/lib/Google/vendor/composer/autoload_static.php index a87ff2e68..4912f401e 100644 --- a/lib/Google/vendor/composer/autoload_static.php +++ b/lib/Google/vendor/composer/autoload_static.php @@ -4,13 +4,12 @@ namespace Composer\Autoload; -class ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4 +class ComposerStaticInit7d51b2283bec19db67d0861b0c8ead2c { public static $files = array ( '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', - '23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php', 'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php', '1f87db08236948d07391152dccb70f04' => __DIR__ . '/..' . '/google/apiclient-services/autoload.php', 'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php', @@ -18,21 +17,17 @@ class ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4 ); public static $prefixLengthsPsr4 = array ( - 'p' => + 'p' => array ( 'phpseclib3\\' => 11, ), - 'S' => - array ( - 'Symfony\\Polyfill\\Php81\\' => 23, - ), - 'R' => + 'R' => array ( 'Rize\\' => 5, 'Ramsey\\Uuid\\' => 12, 'Ramsey\\Collection\\' => 18, ), - 'P' => + 'P' => array ( 'Psr\\Log\\' => 8, 'Psr\\Http\\Message\\' => 17, @@ -40,11 +35,11 @@ class ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4 'Psr\\Cache\\' => 10, 'ParagonIE\\ConstantTime\\' => 23, ), - 'M' => + 'M' => array ( 'Monolog\\' => 8, ), - 'G' => + 'G' => array ( 'GuzzleHttp\\Psr7\\' => 16, 'GuzzleHttp\\Promise\\' => 19, @@ -75,186 +70,181 @@ class ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4 'GPBMetadata\\Google\\Api\\' => 23, 'GPBMetadata\\ApiCore\\' => 20, ), - 'F' => + 'F' => array ( 'Firebase\\JWT\\' => 13, ), - 'B' => + 'B' => array ( 'Brick\\Math\\' => 11, ), ); public static $prefixDirsPsr4 = array ( - 'phpseclib3\\' => + 'phpseclib3\\' => array ( 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib', ), - 'Symfony\\Polyfill\\Php81\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-php81', - ), - 'Rize\\' => + 'Rize\\' => array ( 0 => __DIR__ . '/..' . '/rize/uri-template/src/Rize', ), - 'Ramsey\\Uuid\\' => + 'Ramsey\\Uuid\\' => array ( 0 => __DIR__ . '/..' . '/ramsey/uuid/src', ), - 'Ramsey\\Collection\\' => + 'Ramsey\\Collection\\' => array ( 0 => __DIR__ . '/..' . '/ramsey/collection/src', ), - 'Psr\\Log\\' => + 'Psr\\Log\\' => array ( 0 => __DIR__ . '/..' . '/psr/log/src', ), - 'Psr\\Http\\Message\\' => + 'Psr\\Http\\Message\\' => array ( 0 => __DIR__ . '/..' . '/psr/http-factory/src', 1 => __DIR__ . '/..' . '/psr/http-message/src', ), - 'Psr\\Http\\Client\\' => + 'Psr\\Http\\Client\\' => array ( 0 => __DIR__ . '/..' . '/psr/http-client/src', ), - 'Psr\\Cache\\' => + 'Psr\\Cache\\' => array ( 0 => __DIR__ . '/..' . '/psr/cache/src', ), - 'ParagonIE\\ConstantTime\\' => + 'ParagonIE\\ConstantTime\\' => array ( 0 => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src', ), - 'Monolog\\' => + 'Monolog\\' => array ( 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog', ), - 'GuzzleHttp\\Psr7\\' => + 'GuzzleHttp\\Psr7\\' => array ( 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', ), - 'GuzzleHttp\\Promise\\' => + 'GuzzleHttp\\Promise\\' => array ( 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', ), - 'GuzzleHttp\\' => + 'GuzzleHttp\\' => array ( 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', ), - 'Grpc\\Gcp\\' => + 'Grpc\\Gcp\\' => array ( 0 => __DIR__ . '/..' . '/google/grpc-gcp/src', ), - 'Grpc\\' => + 'Grpc\\' => array ( 0 => __DIR__ . '/..' . '/grpc/grpc/src/lib', ), - 'Google\\Type\\' => + 'Google\\Type\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/src/Type', ), - 'Google\\Service\\' => + 'Google\\Service\\' => array ( 0 => __DIR__ . '/..' . '/google/apiclient-services/src', ), - 'Google\\Rpc\\' => + 'Google\\Rpc\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/src/Rpc', ), - 'Google\\Protobuf\\' => + 'Google\\Protobuf\\' => array ( 0 => __DIR__ . '/..' . '/google/protobuf/src/Google/Protobuf', ), - 'Google\\LongRunning\\' => + 'Google\\LongRunning\\' => array ( 0 => __DIR__ . '/..' . '/google/longrunning/src/LongRunning', ), - 'Google\\Iam\\' => + 'Google\\Iam\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/src/Iam', ), - 'Google\\Cloud\\Storage\\' => + 'Google\\Cloud\\Storage\\' => array ( 0 => __DIR__ . '/..' . '/google/cloud-storage/src', ), - 'Google\\Cloud\\Core\\' => + 'Google\\Cloud\\Core\\' => array ( 0 => __DIR__ . '/..' . '/google/cloud-core/src', ), - 'Google\\Cloud\\' => + 'Google\\Cloud\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/src/Cloud', ), - 'Google\\Auth\\' => + 'Google\\Auth\\' => array ( 0 => __DIR__ . '/..' . '/google/auth/src', ), - 'Google\\Api\\' => + 'Google\\Api\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/src/Api', ), - 'Google\\ApiCore\\LongRunning\\' => + 'Google\\ApiCore\\LongRunning\\' => array ( 0 => __DIR__ . '/..' . '/google/longrunning/src/ApiCore/LongRunning', ), - 'Google\\ApiCore\\' => + 'Google\\ApiCore\\' => array ( 0 => __DIR__ . '/..' . '/google/gax/src', ), - 'Google\\' => + 'Google\\' => array ( 0 => __DIR__ . '/../..' . '/src', ), - 'GPBMetadata\\Google\\Type\\' => + 'GPBMetadata\\Google\\Type\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/metadata/Type', ), - 'GPBMetadata\\Google\\Rpc\\' => + 'GPBMetadata\\Google\\Rpc\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/metadata/Rpc', ), - 'GPBMetadata\\Google\\Protobuf\\' => + 'GPBMetadata\\Google\\Protobuf\\' => array ( 0 => __DIR__ . '/..' . '/google/protobuf/src/GPBMetadata/Google/Protobuf', ), - 'GPBMetadata\\Google\\Longrunning\\' => + 'GPBMetadata\\Google\\Longrunning\\' => array ( 0 => __DIR__ . '/..' . '/google/longrunning/metadata/Longrunning', ), - 'GPBMetadata\\Google\\Logging\\' => + 'GPBMetadata\\Google\\Logging\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/metadata/Logging', ), - 'GPBMetadata\\Google\\Iam\\' => + 'GPBMetadata\\Google\\Iam\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/metadata/Iam', ), - 'GPBMetadata\\Google\\Cloud\\' => + 'GPBMetadata\\Google\\Cloud\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/metadata/Cloud', ), - 'GPBMetadata\\Google\\Api\\' => + 'GPBMetadata\\Google\\Api\\' => array ( 0 => __DIR__ . '/..' . '/google/common-protos/metadata/Api', ), - 'GPBMetadata\\ApiCore\\' => + 'GPBMetadata\\ApiCore\\' => array ( 0 => __DIR__ . '/..' . '/google/gax/metadata/ApiCore', ), - 'Firebase\\JWT\\' => + 'Firebase\\JWT\\' => array ( 0 => __DIR__ . '/..' . '/firebase/php-jwt/src', ), - 'Brick\\Math\\' => + 'Brick\\Math\\' => array ( 0 => __DIR__ . '/..' . '/brick/math/src', ), ); public static $classMap = array ( - 'CURLStringFile' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 'GPBMetadata\\GrpcGcp' => __DIR__ . '/..' . '/google/grpc-gcp/src/generated/GPBMetadata/GrpcGcp.php', 'Google_AccessToken_Revoke' => __DIR__ . '/../..' . '/src/aliases.php', @@ -282,15 +272,14 @@ class ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4 'Grpc\\Gcp\\ApiConfig' => __DIR__ . '/..' . '/google/grpc-gcp/src/generated/Grpc/Gcp/ApiConfig.php', 'Grpc\\Gcp\\ChannelPoolConfig' => __DIR__ . '/..' . '/google/grpc-gcp/src/generated/Grpc/Gcp/ChannelPoolConfig.php', 'Grpc\\Gcp\\MethodConfig' => __DIR__ . '/..' . '/google/grpc-gcp/src/generated/Grpc/Gcp/MethodConfig.php', - 'ReturnTypeWillChange' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php', ); public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitbd131085cfdbf47b26d7ae00fe412ae4::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit7d51b2283bec19db67d0861b0c8ead2c::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit7d51b2283bec19db67d0861b0c8ead2c::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit7d51b2283bec19db67d0861b0c8ead2c::$classMap; }, null, ClassLoader::class); } diff --git a/lib/Google/vendor/composer/installed.json b/lib/Google/vendor/composer/installed.json index 0e245f20e..246ed0dd7 100644 --- a/lib/Google/vendor/composer/installed.json +++ b/lib/Google/vendor/composer/installed.json @@ -2,28 +2,28 @@ "packages": [ { "name": "brick/math", - "version": "0.11.0", - "version_normalized": "0.11.0.0", + "version": "0.13.1", + "version_normalized": "0.13.1.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" + "reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", - "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", + "url": "https://api.github.com/repos/brick/math/zipball/fc7ed316430118cc7836bf45faff18d5dfc8de04", + "reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "5.0.0" + "phpunit/phpunit": "^10.1", + "vimeo/psalm": "6.8.8" }, - "time": "2023-01-15T23:15:59+00:00", + "time": "2025-03-29T13:50:30+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -43,12 +43,17 @@ "arithmetic", "bigdecimal", "bignum", + "bignumber", "brick", - "math" + "decimal", + "integer", + "math", + "mathematics", + "rational" ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.11.0" + "source": "https://github.com/brick/math/tree/0.13.1" }, "funding": [ { @@ -126,26 +131,26 @@ }, { "name": "google/apiclient-services", - "version": "v0.411.0", - "version_normalized": "0.411.0.0", + "version": "v0.427.0", + "version_normalized": "0.427.0.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "3d616fcefdb8e6c598b2d007d4155fe516b91abd" + "reference": "cc74cd104a1ed1cf545480c52f13831e6eb0efe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/3d616fcefdb8e6c598b2d007d4155fe516b91abd", - "reference": "3d616fcefdb8e6c598b2d007d4155fe516b91abd", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/cc74cd104a1ed1cf545480c52f13831e6eb0efe2", + "reference": "cc74cd104a1ed1cf545480c52f13831e6eb0efe2", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6" }, - "time": "2025-09-05T20:24:02+00:00", + "time": "2025-12-24T01:04:22+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -167,49 +172,50 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.411.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.427.0" }, "install-path": "../google/apiclient-services" }, { "name": "google/auth", - "version": "v1.47.1", - "version_normalized": "1.47.1.0", + "version": "v1.50.0", + "version_normalized": "1.50.0.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "d7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7" + "reference": "e1c26a718198e16d8a3c69b1cae136b73f959b0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/d7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7", - "reference": "d7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/e1c26a718198e16d8a3c69b1cae136b73f959b0f", + "reference": "e1c26a718198e16d8a3c69b1cae136b73f959b0f", "shasum": "" }, "require": { - "firebase/php-jwt": "^6.0", + "firebase/php-jwt": "^6.0||^7.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", - "php": "^8.0", + "php": "^8.1", "psr/cache": "^2.0||^3.0", "psr/http-message": "^1.1||^2.0", "psr/log": "^3.0" }, "require-dev": { "guzzlehttp/promises": "^2.0", - "kelvinmo/simplejwt": "0.7.1", + "kelvinmo/simplejwt": "^1.1.0", "phpseclib/phpseclib": "^3.0.35", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "sebastian/comparator": ">=1.2.3", - "squizlabs/php_codesniffer": "^3.5", + "squizlabs/php_codesniffer": "^4.0", + "symfony/filesystem": "^6.3||^7.3", "symfony/process": "^6.0||^7.0", - "webmozart/assert": "^1.11" + "webmozart/assert": "^1.11||^2.0" }, "suggest": { "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." }, - "time": "2025-07-09T15:26:02+00:00", + "time": "2026-01-08T21:33:57+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -231,41 +237,42 @@ "support": { "docs": "https://cloud.google.com/php/docs/reference/auth/latest", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.47.1" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.50.0" }, "install-path": "../google/auth" }, { "name": "google/cloud-core", - "version": "v1.64.0", - "version_normalized": "1.64.0.0", + "version": "v1.69.0", + "version_normalized": "1.69.0.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-cloud-php-core.git", - "reference": "f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85" + "reference": "a35bcf9d79f7007eaaf325e00011d08f40494fb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85", - "reference": "f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/a35bcf9d79f7007eaaf325e00011d08f40494fb1", + "reference": "a35bcf9d79f7007eaaf325e00011d08f40494fb1", "shasum": "" }, "require": { "google/auth": "^1.34", - "google/gax": "^1.36.0", + "google/gax": "^1.38.0", "guzzlehttp/guzzle": "^6.5.8||^7.4.4", "guzzlehttp/promises": "^1.4||^2.0", "guzzlehttp/psr7": "^2.6", "monolog/monolog": "^2.9||^3.0", - "php": "^8.0", + "php": "^8.1", "psr/http-message": "^1.0||^2.0", "rize/uri-template": "~0.3||~0.4" }, "require-dev": { "erusev/parsedown": "^1.6", "google/cloud-common-protos": "~0.5", - "opis/closure": "^3", - "phpdocumentor/reflection": "^5.3.3||^6.0", + "nikic/php-parser": "^5.6", + "opis/closure": "^3.7|^4.0", + "phpdocumentor/reflection": "^6.0", "phpdocumentor/reflection-docblock": "^5.3", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.0", @@ -275,7 +282,7 @@ "opis/closure": "May be used to serialize closures to process jobs in the batch daemon. Please require version ^3.", "symfony/lock": "Required for the Spanner cached based session pool. Please require the following commit: 3.3.x-dev#1ba6ac9" }, - "time": "2025-07-16T21:36:08+00:00", + "time": "2025-12-06T04:51:04+00:00", "bin": [ "bin/google-cloud-batch" ], @@ -300,28 +307,28 @@ ], "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", "support": { - "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.64.0" + "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.69.0" }, "install-path": "../google/cloud-core" }, { "name": "google/cloud-storage", - "version": "v1.48.1", - "version_normalized": "1.48.1.0", + "version": "v1.49.0", + "version_normalized": "1.49.0.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-cloud-php-storage.git", - "reference": "509b095c3ea44db92c9e62a94b5773563c831821" + "reference": "30aefa19ce5af165cef8bb39c224cfa865461541" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-cloud-php-storage/zipball/509b095c3ea44db92c9e62a94b5773563c831821", - "reference": "509b095c3ea44db92c9e62a94b5773563c831821", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-storage/zipball/30aefa19ce5af165cef8bb39c224cfa865461541", + "reference": "30aefa19ce5af165cef8bb39c224cfa865461541", "shasum": "" }, "require": { "google/cloud-core": "^1.57", - "php": "^8.0", + "php": "^8.1", "ramsey/uuid": "^4.2.3" }, "require-dev": { @@ -338,7 +345,7 @@ "google/cloud-pubsub": "May be used to register a topic to receive bucket notifications.", "phpseclib/phpseclib": "May be used in place of OpenSSL for creating signed Cloud Storage URLs. Please require version ^2." }, - "time": "2025-05-20T19:49:54+00:00", + "time": "2025-12-06T04:51:04+00:00", "type": "library", "extra": { "component": { @@ -360,33 +367,33 @@ ], "description": "Cloud Storage Client for PHP", "support": { - "source": "https://github.com/googleapis/google-cloud-php-storage/tree/v1.48.1" + "source": "https://github.com/googleapis/google-cloud-php-storage/tree/v1.49.0" }, "install-path": "../google/cloud-storage" }, { "name": "google/common-protos", - "version": "4.12.1", - "version_normalized": "4.12.1.0", + "version": "4.12.4", + "version_normalized": "4.12.4.0", "source": { "type": "git", "url": "https://github.com/googleapis/common-protos-php.git", - "reference": "70c4eb1abab5484a23c17a43b0d455259f5d8c1b" + "reference": "0127156899af0df2681bd42024c60bd5360d64e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/common-protos-php/zipball/70c4eb1abab5484a23c17a43b0d455259f5d8c1b", - "reference": "70c4eb1abab5484a23c17a43b0d455259f5d8c1b", + "url": "https://api.github.com/repos/googleapis/common-protos-php/zipball/0127156899af0df2681bd42024c60bd5360d64e3", + "reference": "0127156899af0df2681bd42024c60bd5360d64e3", "shasum": "" }, "require": { - "google/protobuf": "^v3.25.3||^4.26.1", - "php": "^8.0" + "google/protobuf": "^4.31", + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6" }, - "time": "2025-05-20T19:49:54+00:00", + "time": "2025-09-20T01:29:44+00:00", "type": "library", "extra": { "component": { @@ -422,47 +429,47 @@ "google" ], "support": { - "source": "https://github.com/googleapis/common-protos-php/tree/v4.12.1" + "source": "https://github.com/googleapis/common-protos-php/tree/v4.12.4" }, "install-path": "../google/common-protos" }, { "name": "google/gax", - "version": "v1.36.1", - "version_normalized": "1.36.1.0", + "version": "v1.40.0", + "version_normalized": "1.40.0.0", "source": { "type": "git", "url": "https://github.com/googleapis/gax-php.git", - "reference": "afdac3bc38a3b17d70668115d7b1a97289ac4d72" + "reference": "1d3834d60b3f0794427c64d2b27d7c627fbba92c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/gax-php/zipball/afdac3bc38a3b17d70668115d7b1a97289ac4d72", - "reference": "afdac3bc38a3b17d70668115d7b1a97289ac4d72", + "url": "https://api.github.com/repos/googleapis/gax-php/zipball/1d3834d60b3f0794427c64d2b27d7c627fbba92c", + "reference": "1d3834d60b3f0794427c64d2b27d7c627fbba92c", "shasum": "" }, "require": { - "google/auth": "^1.45", + "google/auth": "^1.49", "google/common-protos": "^4.4", "google/grpc-gcp": "^0.4", "google/longrunning": "~0.4", - "google/protobuf": "^v3.25.3||^4.26.1", + "google/protobuf": "^4.31", "grpc/grpc": "^1.13", "guzzlehttp/promises": "^2.0", "guzzlehttp/psr7": "^2.0", - "php": "^8.0", + "php": "^8.1", "ramsey/uuid": "^4.0" }, "conflict": { - "ext-protobuf": "<3.7.0" + "ext-protobuf": "<4.31.0" }, "require-dev": { "phpspec/prophecy-phpunit": "^2.1", "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^9.6", - "squizlabs/php_codesniffer": "3.*" + "squizlabs/php_codesniffer": "4.*" }, - "time": "2025-05-20T19:50:43+00:00", + "time": "2025-12-04T18:45:15+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -482,7 +489,7 @@ ], "support": { "issues": "https://github.com/googleapis/gax-php/issues", - "source": "https://github.com/googleapis/gax-php/tree/v1.36.1" + "source": "https://github.com/googleapis/gax-php/tree/v1.40.0" }, "install-path": "../google/gax" }, @@ -583,29 +590,29 @@ }, { "name": "google/protobuf", - "version": "v4.31.1", - "version_normalized": "4.31.1.0", + "version": "v4.33.2", + "version_normalized": "4.33.2.0", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "2b028ce8876254e2acbeceea7d9b573faad41864" + "reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/2b028ce8876254e2acbeceea7d9b573faad41864", - "reference": "2b028ce8876254e2acbeceea7d9b573faad41864", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318", + "reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318", "shasum": "" }, "require": { - "php": ">=7.0.0" + "php": ">=8.1.0" }, "require-dev": { - "phpunit/phpunit": ">=5.0.0" + "phpunit/phpunit": ">=5.0.0 <8.5.27" }, "suggest": { "ext-bcmath": "Need to support JSON deserialization" }, - "time": "2025-05-28T18:52:35+00:00", + "time": "2025-12-05T22:12:22+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -624,7 +631,7 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.31.1" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.2" }, "install-path": "../google/protobuf" }, @@ -1011,43 +1018,44 @@ }, { "name": "monolog/monolog", - "version": "2.10.0", - "version_normalized": "2.10.0.0", + "version": "3.10.0", + "version_normalized": "3.10.0.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "5cf826f2991858b54d5c3809bee745560a1042a7" + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5cf826f2991858b54d5c3809bee745560a1042a7", - "reference": "5cf826f2991858b54d5c3809bee745560a1042a7", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/b321dd6749f0bf7189444158a3ce785cc16d69b0", + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0", "shasum": "" }, "require": { - "php": ">=7.2", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" }, "provide": { - "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + "psr/log-implementation": "3.0.0" }, "require-dev": { - "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "aws/aws-sdk-php": "^3.0", "doctrine/couchdb": "~1.0@dev", "elasticsearch/elasticsearch": "^7 || ^8", "ext-json": "*", - "graylog2/gelf-php": "^1.4.2 || ^2@dev", - "guzzlehttp/guzzle": "^7.4", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", + "mongodb/mongodb": "^1.8 || ^2.0", "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpspec/prophecy": "^1.15", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.5.38 || ^9.6.19", - "predis/predis": "^1.1 || ^2.0", - "rollbar/rollbar": "^1.3 || ^2 || ^3", - "ruflin/elastica": "^7", - "swiftmailer/swiftmailer": "^5.3|^6.0", + "php-console/php-console": "^3.1.8", + "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "^10.5.17 || ^11.0.7", + "predis/predis": "^1.1 || ^2", + "rollbar/rollbar": "^4.0", + "ruflin/elastica": "^7 || ^8", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" }, @@ -1067,11 +1075,11 @@ "rollbar/rollbar": "Allow sending log messages to Rollbar", "ruflin/elastica": "Allow sending log messages to an Elastic Search server" }, - "time": "2024-11-12T12:43:37+00:00", + "time": "2026-01-02T08:56:05+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "installation-source": "dist", @@ -1100,7 +1108,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.10.0" + "source": "https://github.com/Seldaek/monolog/tree/3.10.0" }, "funding": [ { @@ -1241,17 +1249,17 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.47", - "version_normalized": "3.0.47.0", + "version": "3.0.48", + "version_normalized": "3.0.48.0", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d" + "reference": "64065a5679c50acb886e82c07aa139b0f757bb89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/9d6ca36a6c2dd434765b1071b2644a1c683b385d", - "reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/64065a5679c50acb886e82c07aa139b0f757bb89", + "reference": "64065a5679c50acb886e82c07aa139b0f757bb89", "shasum": "" }, "require": { @@ -1269,7 +1277,7 @@ "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." }, - "time": "2025-10-06T01:07:24+00:00", + "time": "2025-12-15T11:51:42+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1334,7 +1342,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.47" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.48" }, "funding": [ { @@ -1354,23 +1362,23 @@ }, { "name": "psr/cache", - "version": "3.0.0", - "version_normalized": "3.0.0.0", + "version": "2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + "reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "url": "https://api.github.com/repos/php-fig/cache/zipball/213f9dbc5b9bfbc4f8db86d2838dc968752ce13b", + "reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b", "shasum": "" }, "require": { "php": ">=8.0.0" }, - "time": "2021-02-03T23:26:27+00:00", + "time": "2021-02-03T23:23:37+00:00", "type": "library", "extra": { "branch-alias": { @@ -1400,7 +1408,7 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" + "source": "https://github.com/php-fig/cache/tree/2.0.0" }, "install-path": "../psr/cache" }, @@ -1675,46 +1683,42 @@ }, { "name": "ramsey/collection", - "version": "1.3.0", - "version_normalized": "1.3.0.0", + "version": "2.1.1", + "version_normalized": "2.1.1.0", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4" + "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4", - "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4", + "url": "https://api.github.com/repos/ramsey/collection/zipball/344572933ad0181accbf4ba763e85a0306a8c5e2", + "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0", - "symfony/polyfill-php81": "^1.23" + "php": "^8.1" }, "require-dev": { "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.28.3", - "fakerphp/faker": "^1.21", + "ergebnis/composer-normalize": "^2.45", + "fakerphp/faker": "^1.24", "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^1.0", - "mockery/mockery": "^1.5", + "jangregor/phpstan-prophecy": "^2.1", + "mockery/mockery": "^1.6", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcsstandards/phpcsutils": "^1.0.0-rc1", - "phpspec/prophecy-phpunit": "^2.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5", - "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18.4", - "ramsey/coding-standard": "^2.0.3", - "ramsey/conventional-commits": "^1.3", - "vimeo/psalm": "^5.4" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpspec/prophecy-phpunit": "^2.3", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5", + "ramsey/coding-standard": "^2.3", + "ramsey/conventional-commits": "^1.6", + "roave/security-advisories": "dev-latest" }, - "time": "2022-12-27T19:12:24+00:00", + "time": "2025-03-22T05:38:12+00:00", "type": "library", "extra": { "captainhook": { @@ -1752,37 +1756,27 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/1.3.0" + "source": "https://github.com/ramsey/collection/tree/2.1.1" }, - "funding": [ - { - "url": "https://github.com/ramsey", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", - "type": "tidelift" - } - ], "install-path": "../ramsey/collection" }, { "name": "ramsey/uuid", - "version": "4.9.1", - "version_normalized": "4.9.1.0", + "version": "4.9.2", + "version_normalized": "4.9.2.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440" + "reference": "8429c78ca35a09f27565311b98101e2826affde0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/81f941f6f729b1e3ceea61d9d014f8b6c6800440", - "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/8429c78ca35a09f27565311b98101e2826affde0", + "reference": "8429c78ca35a09f27565311b98101e2826affde0", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", + "brick/math": "^0.8.16 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" }, @@ -1815,7 +1809,7 @@ "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." }, - "time": "2025-09-04T20:59:21+00:00", + "time": "2025-12-14T04:43:48+00:00", "type": "library", "extra": { "captainhook": { @@ -1843,32 +1837,34 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.9.1" + "source": "https://github.com/ramsey/uuid/tree/4.9.2" }, "install-path": "../ramsey/uuid" }, { "name": "rize/uri-template", - "version": "0.3.8", - "version_normalized": "0.3.8.0", + "version": "0.4.1", + "version_normalized": "0.4.1.0", "source": { "type": "git", "url": "https://github.com/rize/UriTemplate.git", - "reference": "34a5b96d0b65a5dddb7d20f09b6527a43faede24" + "reference": "abb53c8b73a5b6c24e11f49036ab842f560cad33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rize/UriTemplate/zipball/34a5b96d0b65a5dddb7d20f09b6527a43faede24", - "reference": "34a5b96d0b65a5dddb7d20f09b6527a43faede24", + "url": "https://api.github.com/repos/rize/UriTemplate/zipball/abb53c8b73a5b6c24e11f49036ab842f560cad33", + "reference": "abb53c8b73a5b6c24e11f49036ab842f560cad33", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "~4.8.36" + "friendsofphp/php-cs-fixer": "^3.63", + "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "~10.0" }, - "time": "2024-08-30T07:09:40+00:00", + "time": "2025-12-02T15:19:04+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1894,7 +1890,7 @@ ], "support": { "issues": "https://github.com/rize/UriTemplate/issues", - "source": "https://github.com/rize/UriTemplate/tree/0.3.8" + "source": "https://github.com/rize/UriTemplate/tree/0.4.1" }, "funding": [ { @@ -1914,23 +1910,23 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.0.2", - "version_normalized": "3.0.2.0", + "version": "v3.6.0", + "version_normalized": "3.6.0.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, - "time": "2022-01-02T09:55:41+00:00", + "time": "2024-09-25T14:21:43+00:00", "type": "library", "extra": { "thanks": { @@ -1938,7 +1934,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.6-dev" } }, "installation-source": "dist", @@ -1964,7 +1960,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -1981,89 +1977,6 @@ } ], "install-path": "../symfony/deprecation-contracts" - }, - { - "name": "symfony/polyfill-php81", - "version": "v1.33.0", - "version_normalized": "1.33.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-php81" } ], "dev": false, diff --git a/lib/Google/vendor/composer/installed.php b/lib/Google/vendor/composer/installed.php index f369de233..2bbaf0401 100644 --- a/lib/Google/vendor/composer/installed.php +++ b/lib/Google/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'google/apiclient', 'pretty_version' => 'dev-latest', 'version' => 'dev-latest', - 'reference' => '5531500eab1459100600be9f30c5795acddde4c6', + 'reference' => 'b101c6a4d352f985df1f531078959f218d9b1f1a', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -11,9 +11,9 @@ ), 'versions' => array( 'brick/math' => array( - 'pretty_version' => '0.11.0', - 'version' => '0.11.0.0', - 'reference' => '0ad82ce168c82ba30d1c01ec86116ab52f589478', + 'pretty_version' => '0.13.1', + 'version' => '0.13.1.0', + 'reference' => 'fc7ed316430118cc7836bf45faff18d5dfc8de04', 'type' => 'library', 'install_path' => __DIR__ . '/../brick/math', 'aliases' => array(), @@ -31,61 +31,61 @@ 'google/apiclient' => array( 'pretty_version' => 'dev-latest', 'version' => 'dev-latest', - 'reference' => '5531500eab1459100600be9f30c5795acddde4c6', + 'reference' => 'b101c6a4d352f985df1f531078959f218d9b1f1a', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'google/apiclient-services' => array( - 'pretty_version' => 'v0.411.0', - 'version' => '0.411.0.0', - 'reference' => '3d616fcefdb8e6c598b2d007d4155fe516b91abd', + 'pretty_version' => 'v0.427.0', + 'version' => '0.427.0.0', + 'reference' => 'cc74cd104a1ed1cf545480c52f13831e6eb0efe2', 'type' => 'library', 'install_path' => __DIR__ . '/../google/apiclient-services', 'aliases' => array(), 'dev_requirement' => false, ), 'google/auth' => array( - 'pretty_version' => 'v1.47.1', - 'version' => '1.47.1.0', - 'reference' => 'd7a0a215ec42ca0c8cb40e9ae0c5960aa9a024b7', + 'pretty_version' => 'v1.50.0', + 'version' => '1.50.0.0', + 'reference' => 'e1c26a718198e16d8a3c69b1cae136b73f959b0f', 'type' => 'library', 'install_path' => __DIR__ . '/../google/auth', 'aliases' => array(), 'dev_requirement' => false, ), 'google/cloud-core' => array( - 'pretty_version' => 'v1.64.0', - 'version' => '1.64.0.0', - 'reference' => 'f0cc1e5d7626b1b3d9407b2af2368acc7ccf0d85', + 'pretty_version' => 'v1.69.0', + 'version' => '1.69.0.0', + 'reference' => 'a35bcf9d79f7007eaaf325e00011d08f40494fb1', 'type' => 'library', 'install_path' => __DIR__ . '/../google/cloud-core', 'aliases' => array(), 'dev_requirement' => false, ), 'google/cloud-storage' => array( - 'pretty_version' => 'v1.48.1', - 'version' => '1.48.1.0', - 'reference' => '509b095c3ea44db92c9e62a94b5773563c831821', + 'pretty_version' => 'v1.49.0', + 'version' => '1.49.0.0', + 'reference' => '30aefa19ce5af165cef8bb39c224cfa865461541', 'type' => 'library', 'install_path' => __DIR__ . '/../google/cloud-storage', 'aliases' => array(), 'dev_requirement' => false, ), 'google/common-protos' => array( - 'pretty_version' => '4.12.1', - 'version' => '4.12.1.0', - 'reference' => '70c4eb1abab5484a23c17a43b0d455259f5d8c1b', + 'pretty_version' => '4.12.4', + 'version' => '4.12.4.0', + 'reference' => '0127156899af0df2681bd42024c60bd5360d64e3', 'type' => 'library', 'install_path' => __DIR__ . '/../google/common-protos', 'aliases' => array(), 'dev_requirement' => false, ), 'google/gax' => array( - 'pretty_version' => 'v1.36.1', - 'version' => '1.36.1.0', - 'reference' => 'afdac3bc38a3b17d70668115d7b1a97289ac4d72', + 'pretty_version' => 'v1.40.0', + 'version' => '1.40.0.0', + 'reference' => '1d3834d60b3f0794427c64d2b27d7c627fbba92c', 'type' => 'library', 'install_path' => __DIR__ . '/../google/gax', 'aliases' => array(), @@ -110,9 +110,9 @@ 'dev_requirement' => false, ), 'google/protobuf' => array( - 'pretty_version' => 'v4.31.1', - 'version' => '4.31.1.0', - 'reference' => '2b028ce8876254e2acbeceea7d9b573faad41864', + 'pretty_version' => 'v4.33.2', + 'version' => '4.33.2.0', + 'reference' => 'fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318', 'type' => 'library', 'install_path' => __DIR__ . '/../google/protobuf', 'aliases' => array(), @@ -155,9 +155,9 @@ 'dev_requirement' => false, ), 'monolog/monolog' => array( - 'pretty_version' => '2.10.0', - 'version' => '2.10.0.0', - 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', + 'pretty_version' => '3.10.0', + 'version' => '3.10.0.0', + 'reference' => 'b321dd6749f0bf7189444158a3ce785cc16d69b0', 'type' => 'library', 'install_path' => __DIR__ . '/../monolog/monolog', 'aliases' => array(), @@ -182,18 +182,18 @@ 'dev_requirement' => false, ), 'phpseclib/phpseclib' => array( - 'pretty_version' => '3.0.47', - 'version' => '3.0.47.0', - 'reference' => '9d6ca36a6c2dd434765b1071b2644a1c683b385d', + 'pretty_version' => '3.0.48', + 'version' => '3.0.48.0', + 'reference' => '64065a5679c50acb886e82c07aa139b0f757bb89', 'type' => 'library', 'install_path' => __DIR__ . '/../phpseclib/phpseclib', 'aliases' => array(), 'dev_requirement' => false, ), 'psr/cache' => array( - 'pretty_version' => '3.0.0', - 'version' => '3.0.0.0', - 'reference' => 'aa5030cfa5405eccfdcb1083ce040c2cb8d253bf', + 'pretty_version' => '2.0.0', + 'version' => '2.0.0.0', + 'reference' => '213f9dbc5b9bfbc4f8db86d2838dc968752ce13b', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/cache', 'aliases' => array(), @@ -256,7 +256,7 @@ 'psr/log-implementation' => array( 'dev_requirement' => false, 'provided' => array( - 0 => '1.0.0 || 2.0.0 || 3.0.0', + 0 => '3.0.0', ), ), 'ralouphie/getallheaders' => array( @@ -269,18 +269,18 @@ 'dev_requirement' => false, ), 'ramsey/collection' => array( - 'pretty_version' => '1.3.0', - 'version' => '1.3.0.0', - 'reference' => 'ad7475d1c9e70b190ecffc58f2d989416af339b4', + 'pretty_version' => '2.1.1', + 'version' => '2.1.1.0', + 'reference' => '344572933ad0181accbf4ba763e85a0306a8c5e2', 'type' => 'library', 'install_path' => __DIR__ . '/../ramsey/collection', 'aliases' => array(), 'dev_requirement' => false, ), 'ramsey/uuid' => array( - 'pretty_version' => '4.9.1', - 'version' => '4.9.1.0', - 'reference' => '81f941f6f729b1e3ceea61d9d014f8b6c6800440', + 'pretty_version' => '4.9.2', + 'version' => '4.9.2.0', + 'reference' => '8429c78ca35a09f27565311b98101e2826affde0', 'type' => 'library', 'install_path' => __DIR__ . '/../ramsey/uuid', 'aliases' => array(), @@ -289,35 +289,26 @@ 'rhumsaa/uuid' => array( 'dev_requirement' => false, 'replaced' => array( - 0 => '4.9.1', + 0 => '4.9.2', ), ), 'rize/uri-template' => array( - 'pretty_version' => '0.3.8', - 'version' => '0.3.8.0', - 'reference' => '34a5b96d0b65a5dddb7d20f09b6527a43faede24', + 'pretty_version' => '0.4.1', + 'version' => '0.4.1.0', + 'reference' => 'abb53c8b73a5b6c24e11f49036ab842f560cad33', 'type' => 'library', 'install_path' => __DIR__ . '/../rize/uri-template', 'aliases' => array(), 'dev_requirement' => false, ), 'symfony/deprecation-contracts' => array( - 'pretty_version' => 'v3.0.2', - 'version' => '3.0.2.0', - 'reference' => '26954b3d62a6c5fd0ea8a2a00c0353a14978d05c', + 'pretty_version' => 'v3.6.0', + 'version' => '3.6.0.0', + 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => false, ), - 'symfony/polyfill-php81' => array( - 'pretty_version' => 'v1.33.0', - 'version' => '1.33.0.0', - 'reference' => '4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-php81', - 'aliases' => array(), - 'dev_requirement' => false, - ), ), ); diff --git a/lib/Google/vendor/composer/platform_check.php b/lib/Google/vendor/composer/platform_check.php index b168ddd5d..2beb14918 100644 --- a/lib/Google/vendor/composer/platform_check.php +++ b/lib/Google/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 80002)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.2". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { @@ -19,8 +19,7 @@ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; } } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR + throw new \RuntimeException( + 'Composer detected issues in your platform: ' . implode(' ', $issues) ); } diff --git a/lib/Google/vendor/google/apiclient-services/composer.json b/lib/Google/vendor/google/apiclient-services/composer.json index 586694df8..8712550ac 100644 --- a/lib/Google/vendor/google/apiclient-services/composer.json +++ b/lib/Google/vendor/google/apiclient-services/composer.json @@ -6,7 +6,7 @@ "homepage": "http://developers.google.com/api-client-library/php", "license": "Apache-2.0", "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6" diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage.php b/lib/Google/vendor/google/apiclient-services/src/Storage.php index c76eab34c..4fb7501ec 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage.php @@ -458,6 +458,10 @@ public function __construct($clientOrConfig = [], $rootUrl = null) 'location' => 'query', 'type' => 'string', ], + 'returnPartialSuccess' => [ + 'location' => 'query', + 'type' => 'boolean', + ], 'softDeleted' => [ 'location' => 'query', 'type' => 'boolean', @@ -1604,6 +1608,10 @@ public function __construct($clientOrConfig = [], $rootUrl = null) 'location' => 'query', 'type' => 'string', ], + 'filter' => [ + 'location' => 'query', + 'type' => 'string', + ], 'includeFoldersAsPrefixes' => [ 'location' => 'query', 'type' => 'boolean', diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/AdvanceRelocateBucketOperationRequest.php b/lib/Google/vendor/google/apiclient-services/src/Storage/AdvanceRelocateBucketOperationRequest.php index ce4bcfae2..931dca579 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/AdvanceRelocateBucketOperationRequest.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/AdvanceRelocateBucketOperationRequest.php @@ -20,16 +20,26 @@ class AdvanceRelocateBucketOperationRequest extends \Google\Model { /** + * Specifies the time when the relocation will revert to the sync stage if the + * relocation hasn't succeeded. + * * @var string */ public $expireTime; /** + * Specifies the duration after which the relocation will revert to the sync + * stage if the relocation hasn't succeeded. Optional, if not supplied, a + * default value of 12h will be used. + * * @var string */ public $ttl; /** - * @param string + * Specifies the time when the relocation will revert to the sync stage if the + * relocation hasn't succeeded. + * + * @param string $expireTime */ public function setExpireTime($expireTime) { @@ -43,7 +53,11 @@ public function getExpireTime() return $this->expireTime; } /** - * @param string + * Specifies the duration after which the relocation will revert to the sync + * stage if the relocation hasn't succeeded. Optional, if not supplied, a + * default value of 12h will be used. + * + * @param string $ttl */ public function setTtl($ttl) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCache.php b/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCache.php index a80f1c9c5..fc709148b 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCache.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCache.php @@ -20,56 +20,85 @@ class AnywhereCache extends \Google\Model { /** + * The cache-level entry admission policy. + * * @var string */ public $admissionPolicy; /** + * The ID of the Anywhere cache instance. + * * @var string */ public $anywhereCacheId; /** + * The name of the bucket containing this cache instance. + * * @var string */ public $bucket; /** + * The creation time of the cache instance in RFC 3339 format. + * * @var string */ public $createTime; /** + * The ID of the resource, including the project number, bucket name and + * anywhere cache ID. + * * @var string */ public $id; /** + * The kind of item this is. For Anywhere Cache, this is always + * storage#anywhereCache. + * * @var string */ public $kind; /** + * True if the cache instance has an active Update long-running operation. + * * @var bool */ public $pendingUpdate; /** + * The link to this cache instance. + * * @var string */ public $selfLink; /** + * The current state of the cache instance. + * * @var string */ public $state; /** + * The TTL of all cache entries in whole seconds. e.g., "7200s". + * * @var string */ public $ttl; /** + * The modification time of the cache instance metadata in RFC 3339 format. + * * @var string */ public $updateTime; /** + * The zone in which the cache instance is running. For example, us- + * central1-a. + * * @var string */ public $zone; /** - * @param string + * The cache-level entry admission policy. + * + * @param string $admissionPolicy */ public function setAdmissionPolicy($admissionPolicy) { @@ -83,7 +112,9 @@ public function getAdmissionPolicy() return $this->admissionPolicy; } /** - * @param string + * The ID of the Anywhere cache instance. + * + * @param string $anywhereCacheId */ public function setAnywhereCacheId($anywhereCacheId) { @@ -97,7 +128,9 @@ public function getAnywhereCacheId() return $this->anywhereCacheId; } /** - * @param string + * The name of the bucket containing this cache instance. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -111,7 +144,9 @@ public function getBucket() return $this->bucket; } /** - * @param string + * The creation time of the cache instance in RFC 3339 format. + * + * @param string $createTime */ public function setCreateTime($createTime) { @@ -125,7 +160,10 @@ public function getCreateTime() return $this->createTime; } /** - * @param string + * The ID of the resource, including the project number, bucket name and + * anywhere cache ID. + * + * @param string $id */ public function setId($id) { @@ -139,7 +177,10 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For Anywhere Cache, this is always + * storage#anywhereCache. + * + * @param string $kind */ public function setKind($kind) { @@ -153,7 +194,9 @@ public function getKind() return $this->kind; } /** - * @param bool + * True if the cache instance has an active Update long-running operation. + * + * @param bool $pendingUpdate */ public function setPendingUpdate($pendingUpdate) { @@ -167,7 +210,9 @@ public function getPendingUpdate() return $this->pendingUpdate; } /** - * @param string + * The link to this cache instance. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -181,7 +226,9 @@ public function getSelfLink() return $this->selfLink; } /** - * @param string + * The current state of the cache instance. + * + * @param string $state */ public function setState($state) { @@ -195,7 +242,9 @@ public function getState() return $this->state; } /** - * @param string + * The TTL of all cache entries in whole seconds. e.g., "7200s". + * + * @param string $ttl */ public function setTtl($ttl) { @@ -209,7 +258,9 @@ public function getTtl() return $this->ttl; } /** - * @param string + * The modification time of the cache instance metadata in RFC 3339 format. + * + * @param string $updateTime */ public function setUpdateTime($updateTime) { @@ -223,7 +274,10 @@ public function getUpdateTime() return $this->updateTime; } /** - * @param string + * The zone in which the cache instance is running. For example, us- + * central1-a. + * + * @param string $zone */ public function setZone($zone) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCaches.php b/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCaches.php index 14874aea2..2c85c7078 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCaches.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/AnywhereCaches.php @@ -23,16 +23,24 @@ class AnywhereCaches extends \Google\Collection protected $itemsType = AnywhereCache::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of Anywhere Caches, this is always + * storage#anywhereCaches. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; /** - * @param AnywhereCache[] + * The list of items. + * + * @param AnywhereCache[] $items */ public function setItems($items) { @@ -46,7 +54,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of Anywhere Caches, this is always + * storage#anywhereCaches. + * + * @param string $kind */ public function setKind($kind) { @@ -60,7 +71,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Bucket.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Bucket.php index 374eeee79..3d5cdca5e 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Bucket.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Bucket.php @@ -31,6 +31,19 @@ class Bucket extends \Google\Collection protected $customPlacementConfigType = BucketCustomPlacementConfig::class; protected $customPlacementConfigDataType = ''; /** + * The default value for event-based hold on newly created objects in this + * bucket. Event-based hold is a way to retain objects indefinitely until an + * event occurs, signified by the hold's release. After being released, such + * objects will be subject to bucket-level retention (if any). One sample use + * case of this flag is for banks to hold loan documents for at least 3 years + * after loan is paid in full. Here, bucket-level retention is 3 years and the + * event is loan being paid in full. In this example, these objects will be + * held intact for any number of years until the event has occurred (event- + * based hold on the object is released) and then 3 more years after that. + * That means retention duration of the objects begins from the moment event- + * based hold transitioned from true to false. Objects under event-based hold + * cannot be deleted, overwritten or archived until the hold is removed. + * * @var bool */ public $defaultEventBasedHold; @@ -39,14 +52,20 @@ class Bucket extends \Google\Collection protected $encryptionType = BucketEncryption::class; protected $encryptionDataType = ''; /** + * HTTP 1.1 Entity tag for the bucket. + * * @var string */ public $etag; /** + * The generation of this bucket. + * * @var string */ public $generation; /** + * The hard delete time of the bucket in RFC 3339 format. + * * @var string */ public $hardDeleteTime; @@ -55,36 +74,53 @@ class Bucket extends \Google\Collection protected $iamConfigurationType = BucketIamConfiguration::class; protected $iamConfigurationDataType = ''; /** + * The ID of the bucket. For buckets, the id and name properties are the same. + * * @var string */ public $id; protected $ipFilterType = BucketIpFilter::class; protected $ipFilterDataType = ''; /** + * The kind of item this is. For buckets, this is always storage#bucket. + * * @var string */ public $kind; /** + * User-provided labels, in key/value pairs. + * * @var string[] */ public $labels; protected $lifecycleType = BucketLifecycle::class; protected $lifecycleDataType = ''; /** + * The location of the bucket. Object data for objects in the bucket resides + * in physical storage within this region. Defaults to US. See the + * [Developer's Guide](https://cloud.google.com/storage/docs/locations) for + * the authoritative list. + * * @var string */ public $location; /** + * The type of the bucket location. + * * @var string */ public $locationType; protected $loggingType = BucketLogging::class; protected $loggingDataType = ''; /** + * The metadata generation of this bucket. + * * @var string */ public $metageneration; /** + * The name of the bucket. + * * @var string */ public $name; @@ -93,42 +129,67 @@ class Bucket extends \Google\Collection protected $ownerType = BucketOwner::class; protected $ownerDataType = ''; /** + * The project number of the project the bucket belongs to. + * * @var string */ public $projectNumber; protected $retentionPolicyType = BucketRetentionPolicy::class; protected $retentionPolicyDataType = ''; /** + * The Recovery Point Objective (RPO) of this bucket. Set to ASYNC_TURBO to + * turn on Turbo Replication on a bucket. + * * @var string */ public $rpo; /** + * Reserved for future use. + * * @var bool */ public $satisfiesPZI; /** + * Reserved for future use. + * * @var bool */ public $satisfiesPZS; /** + * The URI of this bucket. + * * @var string */ public $selfLink; protected $softDeletePolicyType = BucketSoftDeletePolicy::class; protected $softDeletePolicyDataType = ''; /** + * The soft delete time of the bucket in RFC 3339 format. + * * @var string */ public $softDeleteTime; /** + * The bucket's default storage class, used whenever no storageClass is + * specified for a newly-created object. This defines how objects in the + * bucket are stored and determines the SLA and the cost of storage. Values + * include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, ARCHIVE, + * and DURABLE_REDUCED_AVAILABILITY. If this value is not specified when the + * bucket is created, it will default to STANDARD. For more information, see + * [Storage Classes](https://cloud.google.com/storage/docs/storage-classes). + * * @var string */ public $storageClass; /** + * The creation time of the bucket in RFC 3339 format. + * * @var string */ public $timeCreated; /** + * The modification time of the bucket in RFC 3339 format. + * * @var string */ public $updated; @@ -138,7 +199,9 @@ class Bucket extends \Google\Collection protected $websiteDataType = ''; /** - * @param BucketAccessControl[] + * Access controls on the bucket. + * + * @param BucketAccessControl[] $acl */ public function setAcl($acl) { @@ -152,7 +215,9 @@ public function getAcl() return $this->acl; } /** - * @param BucketAutoclass + * The bucket's Autoclass configuration. + * + * @param BucketAutoclass $autoclass */ public function setAutoclass(BucketAutoclass $autoclass) { @@ -166,7 +231,9 @@ public function getAutoclass() return $this->autoclass; } /** - * @param BucketBilling + * The bucket's billing configuration. + * + * @param BucketBilling $billing */ public function setBilling(BucketBilling $billing) { @@ -180,7 +247,9 @@ public function getBilling() return $this->billing; } /** - * @param BucketCors[] + * The bucket's Cross-Origin Resource Sharing (CORS) configuration. + * + * @param BucketCors[] $cors */ public function setCors($cors) { @@ -194,7 +263,9 @@ public function getCors() return $this->cors; } /** - * @param BucketCustomPlacementConfig + * The bucket's custom placement configuration for Custom Dual Regions. + * + * @param BucketCustomPlacementConfig $customPlacementConfig */ public function setCustomPlacementConfig(BucketCustomPlacementConfig $customPlacementConfig) { @@ -208,7 +279,20 @@ public function getCustomPlacementConfig() return $this->customPlacementConfig; } /** - * @param bool + * The default value for event-based hold on newly created objects in this + * bucket. Event-based hold is a way to retain objects indefinitely until an + * event occurs, signified by the hold's release. After being released, such + * objects will be subject to bucket-level retention (if any). One sample use + * case of this flag is for banks to hold loan documents for at least 3 years + * after loan is paid in full. Here, bucket-level retention is 3 years and the + * event is loan being paid in full. In this example, these objects will be + * held intact for any number of years until the event has occurred (event- + * based hold on the object is released) and then 3 more years after that. + * That means retention duration of the objects begins from the moment event- + * based hold transitioned from true to false. Objects under event-based hold + * cannot be deleted, overwritten or archived until the hold is removed. + * + * @param bool $defaultEventBasedHold */ public function setDefaultEventBasedHold($defaultEventBasedHold) { @@ -222,7 +306,9 @@ public function getDefaultEventBasedHold() return $this->defaultEventBasedHold; } /** - * @param ObjectAccessControl[] + * Default access controls to apply to new objects when no ACL is provided. + * + * @param ObjectAccessControl[] $defaultObjectAcl */ public function setDefaultObjectAcl($defaultObjectAcl) { @@ -236,7 +322,9 @@ public function getDefaultObjectAcl() return $this->defaultObjectAcl; } /** - * @param BucketEncryption + * Encryption configuration for a bucket. + * + * @param BucketEncryption $encryption */ public function setEncryption(BucketEncryption $encryption) { @@ -250,7 +338,9 @@ public function getEncryption() return $this->encryption; } /** - * @param string + * HTTP 1.1 Entity tag for the bucket. + * + * @param string $etag */ public function setEtag($etag) { @@ -264,7 +354,9 @@ public function getEtag() return $this->etag; } /** - * @param string + * The generation of this bucket. + * + * @param string $generation */ public function setGeneration($generation) { @@ -278,7 +370,9 @@ public function getGeneration() return $this->generation; } /** - * @param string + * The hard delete time of the bucket in RFC 3339 format. + * + * @param string $hardDeleteTime */ public function setHardDeleteTime($hardDeleteTime) { @@ -292,7 +386,9 @@ public function getHardDeleteTime() return $this->hardDeleteTime; } /** - * @param BucketHierarchicalNamespace + * The bucket's hierarchical namespace configuration. + * + * @param BucketHierarchicalNamespace $hierarchicalNamespace */ public function setHierarchicalNamespace(BucketHierarchicalNamespace $hierarchicalNamespace) { @@ -306,7 +402,9 @@ public function getHierarchicalNamespace() return $this->hierarchicalNamespace; } /** - * @param BucketIamConfiguration + * The bucket's IAM configuration. + * + * @param BucketIamConfiguration $iamConfiguration */ public function setIamConfiguration(BucketIamConfiguration $iamConfiguration) { @@ -320,7 +418,9 @@ public function getIamConfiguration() return $this->iamConfiguration; } /** - * @param string + * The ID of the bucket. For buckets, the id and name properties are the same. + * + * @param string $id */ public function setId($id) { @@ -334,7 +434,11 @@ public function getId() return $this->id; } /** - * @param BucketIpFilter + * The bucket's IP filter configuration. Specifies the network sources that + * are allowed to access the operations on the bucket, as well as its + * underlying objects. Only enforced when the mode is set to 'Enabled'. + * + * @param BucketIpFilter $ipFilter */ public function setIpFilter(BucketIpFilter $ipFilter) { @@ -348,7 +452,9 @@ public function getIpFilter() return $this->ipFilter; } /** - * @param string + * The kind of item this is. For buckets, this is always storage#bucket. + * + * @param string $kind */ public function setKind($kind) { @@ -362,7 +468,9 @@ public function getKind() return $this->kind; } /** - * @param string[] + * User-provided labels, in key/value pairs. + * + * @param string[] $labels */ public function setLabels($labels) { @@ -376,7 +484,11 @@ public function getLabels() return $this->labels; } /** - * @param BucketLifecycle + * The bucket's lifecycle configuration. See [Lifecycle + * Management](https://cloud.google.com/storage/docs/lifecycle) for more + * information. + * + * @param BucketLifecycle $lifecycle */ public function setLifecycle(BucketLifecycle $lifecycle) { @@ -390,7 +502,12 @@ public function getLifecycle() return $this->lifecycle; } /** - * @param string + * The location of the bucket. Object data for objects in the bucket resides + * in physical storage within this region. Defaults to US. See the + * [Developer's Guide](https://cloud.google.com/storage/docs/locations) for + * the authoritative list. + * + * @param string $location */ public function setLocation($location) { @@ -404,7 +521,9 @@ public function getLocation() return $this->location; } /** - * @param string + * The type of the bucket location. + * + * @param string $locationType */ public function setLocationType($locationType) { @@ -418,7 +537,10 @@ public function getLocationType() return $this->locationType; } /** - * @param BucketLogging + * The bucket's logging configuration, which defines the destination bucket + * and optional name prefix for the current bucket's logs. + * + * @param BucketLogging $logging */ public function setLogging(BucketLogging $logging) { @@ -432,7 +554,9 @@ public function getLogging() return $this->logging; } /** - * @param string + * The metadata generation of this bucket. + * + * @param string $metageneration */ public function setMetageneration($metageneration) { @@ -446,7 +570,9 @@ public function getMetageneration() return $this->metageneration; } /** - * @param string + * The name of the bucket. + * + * @param string $name */ public function setName($name) { @@ -460,7 +586,9 @@ public function getName() return $this->name; } /** - * @param BucketObjectRetention + * The bucket's object retention config. + * + * @param BucketObjectRetention $objectRetention */ public function setObjectRetention(BucketObjectRetention $objectRetention) { @@ -474,7 +602,9 @@ public function getObjectRetention() return $this->objectRetention; } /** - * @param BucketOwner + * The owner of the bucket. This is always the project team's owner group. + * + * @param BucketOwner $owner */ public function setOwner(BucketOwner $owner) { @@ -488,7 +618,9 @@ public function getOwner() return $this->owner; } /** - * @param string + * The project number of the project the bucket belongs to. + * + * @param string $projectNumber */ public function setProjectNumber($projectNumber) { @@ -502,7 +634,17 @@ public function getProjectNumber() return $this->projectNumber; } /** - * @param BucketRetentionPolicy + * The bucket's retention policy. The retention policy enforces a minimum + * retention time for all objects contained in the bucket, based on their + * creation time. Any attempt to overwrite or delete objects younger than the + * retention period will result in a PERMISSION_DENIED error. An unlocked + * retention policy can be modified or removed from the bucket via a + * storage.buckets.update operation. A locked retention policy cannot be + * removed or shortened in duration for the lifetime of the bucket. Attempting + * to remove or decrease period of a locked retention policy will result in a + * PERMISSION_DENIED error. + * + * @param BucketRetentionPolicy $retentionPolicy */ public function setRetentionPolicy(BucketRetentionPolicy $retentionPolicy) { @@ -516,7 +658,10 @@ public function getRetentionPolicy() return $this->retentionPolicy; } /** - * @param string + * The Recovery Point Objective (RPO) of this bucket. Set to ASYNC_TURBO to + * turn on Turbo Replication on a bucket. + * + * @param string $rpo */ public function setRpo($rpo) { @@ -530,7 +675,9 @@ public function getRpo() return $this->rpo; } /** - * @param bool + * Reserved for future use. + * + * @param bool $satisfiesPZI */ public function setSatisfiesPZI($satisfiesPZI) { @@ -544,7 +691,9 @@ public function getSatisfiesPZI() return $this->satisfiesPZI; } /** - * @param bool + * Reserved for future use. + * + * @param bool $satisfiesPZS */ public function setSatisfiesPZS($satisfiesPZS) { @@ -558,7 +707,9 @@ public function getSatisfiesPZS() return $this->satisfiesPZS; } /** - * @param string + * The URI of this bucket. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -572,7 +723,10 @@ public function getSelfLink() return $this->selfLink; } /** - * @param BucketSoftDeletePolicy + * The bucket's soft delete policy, which defines the period of time that + * soft-deleted objects will be retained, and cannot be permanently deleted. + * + * @param BucketSoftDeletePolicy $softDeletePolicy */ public function setSoftDeletePolicy(BucketSoftDeletePolicy $softDeletePolicy) { @@ -586,7 +740,9 @@ public function getSoftDeletePolicy() return $this->softDeletePolicy; } /** - * @param string + * The soft delete time of the bucket in RFC 3339 format. + * + * @param string $softDeleteTime */ public function setSoftDeleteTime($softDeleteTime) { @@ -600,7 +756,15 @@ public function getSoftDeleteTime() return $this->softDeleteTime; } /** - * @param string + * The bucket's default storage class, used whenever no storageClass is + * specified for a newly-created object. This defines how objects in the + * bucket are stored and determines the SLA and the cost of storage. Values + * include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, ARCHIVE, + * and DURABLE_REDUCED_AVAILABILITY. If this value is not specified when the + * bucket is created, it will default to STANDARD. For more information, see + * [Storage Classes](https://cloud.google.com/storage/docs/storage-classes). + * + * @param string $storageClass */ public function setStorageClass($storageClass) { @@ -614,7 +778,9 @@ public function getStorageClass() return $this->storageClass; } /** - * @param string + * The creation time of the bucket in RFC 3339 format. + * + * @param string $timeCreated */ public function setTimeCreated($timeCreated) { @@ -628,7 +794,9 @@ public function getTimeCreated() return $this->timeCreated; } /** - * @param string + * The modification time of the bucket in RFC 3339 format. + * + * @param string $updated */ public function setUpdated($updated) { @@ -642,7 +810,9 @@ public function getUpdated() return $this->updated; } /** - * @param BucketVersioning + * The bucket's versioning configuration. + * + * @param BucketVersioning $versioning */ public function setVersioning(BucketVersioning $versioning) { @@ -656,7 +826,12 @@ public function getVersioning() return $this->versioning; } /** - * @param BucketWebsite + * The bucket's website configuration, controlling how the service behaves + * when accessing bucket contents as a web site. See the [Static Website + * Examples](https://cloud.google.com/storage/docs/static-website) for more + * information. + * + * @param BucketWebsite $website */ public function setWebsite(BucketWebsite $website) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControl.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControl.php index 1da9d4aa6..b7e1d8920 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControl.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControl.php @@ -20,50 +20,79 @@ class BucketAccessControl extends \Google\Model { /** + * The name of the bucket. + * * @var string */ public $bucket; /** + * The domain associated with the entity, if any. + * * @var string */ public $domain; /** + * The email address associated with the entity, if any. + * * @var string */ public $email; /** + * The entity holding the permission, in one of the following forms: - user- + * userId - user-email - group-groupId - group-email - domain-domain - + * project-team-projectId - allUsers - allAuthenticatedUsers Examples: - + * The user liz@example.com would be user-liz@example.com. - The group + * example@googlegroups.com would be group-example@googlegroups.com. - To + * refer to all members of the Google Apps for Business domain example.com, + * the entity would be domain-example.com. + * * @var string */ public $entity; /** + * The ID for the entity, if any. + * * @var string */ public $entityId; /** + * HTTP 1.1 Entity tag for the access-control entry. + * * @var string */ public $etag; /** + * The ID of the access-control entry. + * * @var string */ public $id; /** + * The kind of item this is. For bucket access control entries, this is always + * storage#bucketAccessControl. + * * @var string */ public $kind; protected $projectTeamType = BucketAccessControlProjectTeam::class; protected $projectTeamDataType = ''; /** + * The access permission for the entity. + * * @var string */ public $role; /** + * The link to this access-control entry. + * * @var string */ public $selfLink; /** - * @param string + * The name of the bucket. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -77,7 +106,9 @@ public function getBucket() return $this->bucket; } /** - * @param string + * The domain associated with the entity, if any. + * + * @param string $domain */ public function setDomain($domain) { @@ -91,7 +122,9 @@ public function getDomain() return $this->domain; } /** - * @param string + * The email address associated with the entity, if any. + * + * @param string $email */ public function setEmail($email) { @@ -105,7 +138,15 @@ public function getEmail() return $this->email; } /** - * @param string + * The entity holding the permission, in one of the following forms: - user- + * userId - user-email - group-groupId - group-email - domain-domain - + * project-team-projectId - allUsers - allAuthenticatedUsers Examples: - + * The user liz@example.com would be user-liz@example.com. - The group + * example@googlegroups.com would be group-example@googlegroups.com. - To + * refer to all members of the Google Apps for Business domain example.com, + * the entity would be domain-example.com. + * + * @param string $entity */ public function setEntity($entity) { @@ -119,7 +160,9 @@ public function getEntity() return $this->entity; } /** - * @param string + * The ID for the entity, if any. + * + * @param string $entityId */ public function setEntityId($entityId) { @@ -133,7 +176,9 @@ public function getEntityId() return $this->entityId; } /** - * @param string + * HTTP 1.1 Entity tag for the access-control entry. + * + * @param string $etag */ public function setEtag($etag) { @@ -147,7 +192,9 @@ public function getEtag() return $this->etag; } /** - * @param string + * The ID of the access-control entry. + * + * @param string $id */ public function setId($id) { @@ -161,7 +208,10 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For bucket access control entries, this is always + * storage#bucketAccessControl. + * + * @param string $kind */ public function setKind($kind) { @@ -175,7 +225,9 @@ public function getKind() return $this->kind; } /** - * @param BucketAccessControlProjectTeam + * The project team associated with the entity, if any. + * + * @param BucketAccessControlProjectTeam $projectTeam */ public function setProjectTeam(BucketAccessControlProjectTeam $projectTeam) { @@ -189,7 +241,9 @@ public function getProjectTeam() return $this->projectTeam; } /** - * @param string + * The access permission for the entity. + * + * @param string $role */ public function setRole($role) { @@ -203,7 +257,9 @@ public function getRole() return $this->role; } /** - * @param string + * The link to this access-control entry. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControlProjectTeam.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControlProjectTeam.php index b6b42768f..e818ad587 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControlProjectTeam.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControlProjectTeam.php @@ -20,16 +20,22 @@ class BucketAccessControlProjectTeam extends \Google\Model { /** + * The project number. + * * @var string */ public $projectNumber; /** + * The team. + * * @var string */ public $team; /** - * @param string + * The project number. + * + * @param string $projectNumber */ public function setProjectNumber($projectNumber) { @@ -43,7 +49,9 @@ public function getProjectNumber() return $this->projectNumber; } /** - * @param string + * The team. + * + * @param string $team */ public function setTeam($team) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControls.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControls.php index d33617607..487b9e4f6 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControls.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAccessControls.php @@ -23,12 +23,17 @@ class BucketAccessControls extends \Google\Collection protected $itemsType = BucketAccessControl::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of bucket access control entries, this + * is always storage#bucketAccessControls. + * * @var string */ public $kind; /** - * @param BucketAccessControl[] + * The list of items. + * + * @param BucketAccessControl[] $items */ public function setItems($items) { @@ -42,7 +47,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of bucket access control entries, this + * is always storage#bucketAccessControls. + * + * @param string $kind */ public function setKind($kind) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAutoclass.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAutoclass.php index 956676ae8..a03136095 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAutoclass.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketAutoclass.php @@ -20,24 +20,38 @@ class BucketAutoclass extends \Google\Model { /** + * Whether or not Autoclass is enabled on this bucket + * * @var bool */ public $enabled; /** + * The storage class that objects in the bucket eventually transition to if + * they are not read for a certain length of time. Valid values are NEARLINE + * and ARCHIVE. + * * @var string */ public $terminalStorageClass; /** + * A date and time in RFC 3339 format representing the time of the most recent + * update to "terminalStorageClass". + * * @var string */ public $terminalStorageClassUpdateTime; /** + * A date and time in RFC 3339 format representing the instant at which + * "enabled" was last toggled. + * * @var string */ public $toggleTime; /** - * @param bool + * Whether or not Autoclass is enabled on this bucket + * + * @param bool $enabled */ public function setEnabled($enabled) { @@ -51,7 +65,11 @@ public function getEnabled() return $this->enabled; } /** - * @param string + * The storage class that objects in the bucket eventually transition to if + * they are not read for a certain length of time. Valid values are NEARLINE + * and ARCHIVE. + * + * @param string $terminalStorageClass */ public function setTerminalStorageClass($terminalStorageClass) { @@ -65,7 +83,10 @@ public function getTerminalStorageClass() return $this->terminalStorageClass; } /** - * @param string + * A date and time in RFC 3339 format representing the time of the most recent + * update to "terminalStorageClass". + * + * @param string $terminalStorageClassUpdateTime */ public function setTerminalStorageClassUpdateTime($terminalStorageClassUpdateTime) { @@ -79,7 +100,10 @@ public function getTerminalStorageClassUpdateTime() return $this->terminalStorageClassUpdateTime; } /** - * @param string + * A date and time in RFC 3339 format representing the instant at which + * "enabled" was last toggled. + * + * @param string $toggleTime */ public function setToggleTime($toggleTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketBilling.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketBilling.php index b2b3bb810..6f1dacd24 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketBilling.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketBilling.php @@ -20,12 +20,16 @@ class BucketBilling extends \Google\Model { /** + * When set to true, Requester Pays is enabled for this bucket. + * * @var bool */ public $requesterPays; /** - * @param bool + * When set to true, Requester Pays is enabled for this bucket. + * + * @param bool $requesterPays */ public function setRequesterPays($requesterPays) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCors.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCors.php index 5ba463da1..b377d1d27 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCors.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCors.php @@ -21,24 +21,40 @@ class BucketCors extends \Google\Collection { protected $collection_key = 'responseHeader'; /** + * The value, in seconds, to return in the Access-Control-Max-Age header used + * in preflight responses. + * * @var int */ public $maxAgeSeconds; /** + * The list of HTTP methods on which to include CORS response headers, (GET, + * OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and + * means "any method". + * * @var string[] */ public $method; /** + * The list of Origins eligible to receive CORS response headers. Note: "*" is + * permitted in the list of origins, and means "any Origin". + * * @var string[] */ public $origin; /** + * The list of HTTP headers other than the simple response headers to give + * permission for the user-agent to share across domains. + * * @var string[] */ public $responseHeader; /** - * @param int + * The value, in seconds, to return in the Access-Control-Max-Age header used + * in preflight responses. + * + * @param int $maxAgeSeconds */ public function setMaxAgeSeconds($maxAgeSeconds) { @@ -52,7 +68,11 @@ public function getMaxAgeSeconds() return $this->maxAgeSeconds; } /** - * @param string[] + * The list of HTTP methods on which to include CORS response headers, (GET, + * OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and + * means "any method". + * + * @param string[] $method */ public function setMethod($method) { @@ -66,7 +86,10 @@ public function getMethod() return $this->method; } /** - * @param string[] + * The list of Origins eligible to receive CORS response headers. Note: "*" is + * permitted in the list of origins, and means "any Origin". + * + * @param string[] $origin */ public function setOrigin($origin) { @@ -80,7 +103,10 @@ public function getOrigin() return $this->origin; } /** - * @param string[] + * The list of HTTP headers other than the simple response headers to give + * permission for the user-agent to share across domains. + * + * @param string[] $responseHeader */ public function setResponseHeader($responseHeader) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCustomPlacementConfig.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCustomPlacementConfig.php index 9637d4a9b..003852113 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCustomPlacementConfig.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketCustomPlacementConfig.php @@ -21,12 +21,16 @@ class BucketCustomPlacementConfig extends \Google\Collection { protected $collection_key = 'dataLocations'; /** + * The list of regional locations in which data is placed. + * * @var string[] */ public $dataLocations; /** - * @param string[] + * The list of regional locations in which data is placed. + * + * @param string[] $dataLocations */ public function setDataLocations($dataLocations) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryption.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryption.php index c44a60f8b..9c86dfb0d 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryption.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryption.php @@ -19,13 +19,63 @@ class BucketEncryption extends \Google\Model { + protected $customerManagedEncryptionEnforcementConfigType = BucketEncryptionCustomerManagedEncryptionEnforcementConfig::class; + protected $customerManagedEncryptionEnforcementConfigDataType = ''; + protected $customerSuppliedEncryptionEnforcementConfigType = BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig::class; + protected $customerSuppliedEncryptionEnforcementConfigDataType = ''; /** + * A Cloud KMS key that will be used to encrypt objects inserted into this + * bucket, if no encryption method is specified. + * * @var string */ public $defaultKmsKeyName; + protected $googleManagedEncryptionEnforcementConfigType = BucketEncryptionGoogleManagedEncryptionEnforcementConfig::class; + protected $googleManagedEncryptionEnforcementConfigDataType = ''; /** - * @param string + * If set, the new objects created in this bucket must comply with this + * enforcement config. Changing this has no effect on existing objects; it + * applies to new objects only. If omitted, the new objects are allowed to be + * encrypted with Customer Managed Encryption type by default. + * + * @param BucketEncryptionCustomerManagedEncryptionEnforcementConfig $customerManagedEncryptionEnforcementConfig + */ + public function setCustomerManagedEncryptionEnforcementConfig(BucketEncryptionCustomerManagedEncryptionEnforcementConfig $customerManagedEncryptionEnforcementConfig) + { + $this->customerManagedEncryptionEnforcementConfig = $customerManagedEncryptionEnforcementConfig; + } + /** + * @return BucketEncryptionCustomerManagedEncryptionEnforcementConfig + */ + public function getCustomerManagedEncryptionEnforcementConfig() + { + return $this->customerManagedEncryptionEnforcementConfig; + } + /** + * If set, the new objects created in this bucket must comply with this + * enforcement config. Changing this has no effect on existing objects; it + * applies to new objects only. If omitted, the new objects are allowed to be + * encrypted with Customer Supplied Encryption type by default. + * + * @param BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig $customerSuppliedEncryptionEnforcementConfig + */ + public function setCustomerSuppliedEncryptionEnforcementConfig(BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig $customerSuppliedEncryptionEnforcementConfig) + { + $this->customerSuppliedEncryptionEnforcementConfig = $customerSuppliedEncryptionEnforcementConfig; + } + /** + * @return BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig + */ + public function getCustomerSuppliedEncryptionEnforcementConfig() + { + return $this->customerSuppliedEncryptionEnforcementConfig; + } + /** + * A Cloud KMS key that will be used to encrypt objects inserted into this + * bucket, if no encryption method is specified. + * + * @param string $defaultKmsKeyName */ public function setDefaultKmsKeyName($defaultKmsKeyName) { @@ -38,6 +88,25 @@ public function getDefaultKmsKeyName() { return $this->defaultKmsKeyName; } + /** + * If set, the new objects created in this bucket must comply with this + * enforcement config. Changing this has no effect on existing objects; it + * applies to new objects only. If omitted, the new objects are allowed to be + * encrypted with Google Managed Encryption type by default. + * + * @param BucketEncryptionGoogleManagedEncryptionEnforcementConfig $googleManagedEncryptionEnforcementConfig + */ + public function setGoogleManagedEncryptionEnforcementConfig(BucketEncryptionGoogleManagedEncryptionEnforcementConfig $googleManagedEncryptionEnforcementConfig) + { + $this->googleManagedEncryptionEnforcementConfig = $googleManagedEncryptionEnforcementConfig; + } + /** + * @return BucketEncryptionGoogleManagedEncryptionEnforcementConfig + */ + public function getGoogleManagedEncryptionEnforcementConfig() + { + return $this->googleManagedEncryptionEnforcementConfig; + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerManagedEncryptionEnforcementConfig.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerManagedEncryptionEnforcementConfig.php new file mode 100644 index 000000000..f848c5a11 --- /dev/null +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerManagedEncryptionEnforcementConfig.php @@ -0,0 +1,85 @@ +effectiveTime = $effectiveTime; + } + /** + * @return string + */ + public function getEffectiveTime() + { + return $this->effectiveTime; + } + /** + * Restriction mode for Customer-Managed Encryption Keys. Defaults to + * NotRestricted. + * + * Accepted values: NotRestricted, FullyRestricted + * + * @param self::RESTRICTION_MODE_* $restrictionMode + */ + public function setRestrictionMode($restrictionMode) + { + $this->restrictionMode = $restrictionMode; + } + /** + * @return self::RESTRICTION_MODE_* + */ + public function getRestrictionMode() + { + return $this->restrictionMode; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(BucketEncryptionCustomerManagedEncryptionEnforcementConfig::class, 'Google_Service_Storage_BucketEncryptionCustomerManagedEncryptionEnforcementConfig'); diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig.php new file mode 100644 index 000000000..49eeeb327 --- /dev/null +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig.php @@ -0,0 +1,86 @@ +effectiveTime = $effectiveTime; + } + /** + * @return string + */ + public function getEffectiveTime() + { + return $this->effectiveTime; + } + /** + * Restriction mode for Customer-Supplied Encryption Keys. Defaults to + * NotRestricted. + * + * Accepted values: NotRestricted, FullyRestricted + * + * @param self::RESTRICTION_MODE_* $restrictionMode + */ + public function setRestrictionMode($restrictionMode) + { + $this->restrictionMode = $restrictionMode; + } + /** + * @return self::RESTRICTION_MODE_* + */ + public function getRestrictionMode() + { + return $this->restrictionMode; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig::class, 'Google_Service_Storage_BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig'); diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionGoogleManagedEncryptionEnforcementConfig.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionGoogleManagedEncryptionEnforcementConfig.php new file mode 100644 index 000000000..6aaebbca7 --- /dev/null +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketEncryptionGoogleManagedEncryptionEnforcementConfig.php @@ -0,0 +1,84 @@ +effectiveTime = $effectiveTime; + } + /** + * @return string + */ + public function getEffectiveTime() + { + return $this->effectiveTime; + } + /** + * Restriction mode for Google-Managed Encryption Keys. Defaults to + * NotRestricted. + * + * Accepted values: NotRestricted, FullyRestricted + * + * @param self::RESTRICTION_MODE_* $restrictionMode + */ + public function setRestrictionMode($restrictionMode) + { + $this->restrictionMode = $restrictionMode; + } + /** + * @return self::RESTRICTION_MODE_* + */ + public function getRestrictionMode() + { + return $this->restrictionMode; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(BucketEncryptionGoogleManagedEncryptionEnforcementConfig::class, 'Google_Service_Storage_BucketEncryptionGoogleManagedEncryptionEnforcementConfig'); diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketHierarchicalNamespace.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketHierarchicalNamespace.php index efcd78d23..26eb0913c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketHierarchicalNamespace.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketHierarchicalNamespace.php @@ -20,12 +20,16 @@ class BucketHierarchicalNamespace extends \Google\Model { /** + * When set to true, hierarchical namespace is enabled for this bucket. + * * @var bool */ public $enabled; /** - * @param bool + * When set to true, hierarchical namespace is enabled for this bucket. + * + * @param bool $enabled */ public function setEnabled($enabled) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfiguration.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfiguration.php index 734ea4815..1d713dd13 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfiguration.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfiguration.php @@ -22,6 +22,9 @@ class BucketIamConfiguration extends \Google\Model protected $bucketPolicyOnlyType = BucketIamConfigurationBucketPolicyOnly::class; protected $bucketPolicyOnlyDataType = ''; /** + * The bucket's Public Access Prevention configuration. Currently, 'inherited' + * and 'enforced' are supported. + * * @var string */ public $publicAccessPrevention; @@ -29,7 +32,13 @@ class BucketIamConfiguration extends \Google\Model protected $uniformBucketLevelAccessDataType = ''; /** - * @param BucketIamConfigurationBucketPolicyOnly + * The bucket's uniform bucket-level access configuration. The feature was + * formerly known as Bucket Policy Only. For backward compatibility, this + * field will be populated with identical information as the + * uniformBucketLevelAccess field. We recommend using the + * uniformBucketLevelAccess field to enable and disable the feature. + * + * @param BucketIamConfigurationBucketPolicyOnly $bucketPolicyOnly */ public function setBucketPolicyOnly(BucketIamConfigurationBucketPolicyOnly $bucketPolicyOnly) { @@ -43,7 +52,10 @@ public function getBucketPolicyOnly() return $this->bucketPolicyOnly; } /** - * @param string + * The bucket's Public Access Prevention configuration. Currently, 'inherited' + * and 'enforced' are supported. + * + * @param string $publicAccessPrevention */ public function setPublicAccessPrevention($publicAccessPrevention) { @@ -57,7 +69,9 @@ public function getPublicAccessPrevention() return $this->publicAccessPrevention; } /** - * @param BucketIamConfigurationUniformBucketLevelAccess + * The bucket's uniform bucket-level access configuration. + * + * @param BucketIamConfigurationUniformBucketLevelAccess $uniformBucketLevelAccess */ public function setUniformBucketLevelAccess(BucketIamConfigurationUniformBucketLevelAccess $uniformBucketLevelAccess) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationBucketPolicyOnly.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationBucketPolicyOnly.php index f271f1bb8..b89ebc717 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationBucketPolicyOnly.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationBucketPolicyOnly.php @@ -20,16 +20,25 @@ class BucketIamConfigurationBucketPolicyOnly extends \Google\Model { /** + * If set, access is controlled only by bucket-level or above IAM policies. + * * @var bool */ public $enabled; /** + * The deadline for changing iamConfiguration.bucketPolicyOnly.enabled from + * true to false in RFC 3339 format. iamConfiguration.bucketPolicyOnly.enabled + * may be changed from true to false until the locked time, after which the + * field is immutable. + * * @var string */ public $lockedTime; /** - * @param bool + * If set, access is controlled only by bucket-level or above IAM policies. + * + * @param bool $enabled */ public function setEnabled($enabled) { @@ -43,7 +52,12 @@ public function getEnabled() return $this->enabled; } /** - * @param string + * The deadline for changing iamConfiguration.bucketPolicyOnly.enabled from + * true to false in RFC 3339 format. iamConfiguration.bucketPolicyOnly.enabled + * may be changed from true to false until the locked time, after which the + * field is immutable. + * + * @param string $lockedTime */ public function setLockedTime($lockedTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationUniformBucketLevelAccess.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationUniformBucketLevelAccess.php index e4715bd62..cccd711ea 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationUniformBucketLevelAccess.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIamConfigurationUniformBucketLevelAccess.php @@ -20,16 +20,25 @@ class BucketIamConfigurationUniformBucketLevelAccess extends \Google\Model { /** + * If set, access is controlled only by bucket-level or above IAM policies. + * * @var bool */ public $enabled; /** + * The deadline for changing iamConfiguration.uniformBucketLevelAccess.enabled + * from true to false in RFC 3339 format. + * iamConfiguration.uniformBucketLevelAccess.enabled may be changed from true + * to false until the locked time, after which the field is immutable. + * * @var string */ public $lockedTime; /** - * @param bool + * If set, access is controlled only by bucket-level or above IAM policies. + * + * @param bool $enabled */ public function setEnabled($enabled) { @@ -43,7 +52,12 @@ public function getEnabled() return $this->enabled; } /** - * @param string + * The deadline for changing iamConfiguration.uniformBucketLevelAccess.enabled + * from true to false in RFC 3339 format. + * iamConfiguration.uniformBucketLevelAccess.enabled may be changed from true + * to false until the locked time, after which the field is immutable. + * + * @param string $lockedTime */ public function setLockedTime($lockedTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilter.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilter.php index a38d42393..3cf28e024 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilter.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilter.php @@ -21,10 +21,21 @@ class BucketIpFilter extends \Google\Collection { protected $collection_key = 'vpcNetworkSources'; /** + * Whether to allow all service agents to access the bucket regardless of the + * IP filter configuration. + * + * @var bool + */ + public $allowAllServiceAgentAccess; + /** + * Whether to allow cross-org VPCs in the bucket's IP filter configuration. + * * @var bool */ public $allowCrossOrgVpcs; /** + * The mode of the IP filter. Valid values are 'Enabled' and 'Disabled'. + * * @var string */ public $mode; @@ -34,7 +45,26 @@ class BucketIpFilter extends \Google\Collection protected $vpcNetworkSourcesDataType = 'array'; /** - * @param bool + * Whether to allow all service agents to access the bucket regardless of the + * IP filter configuration. + * + * @param bool $allowAllServiceAgentAccess + */ + public function setAllowAllServiceAgentAccess($allowAllServiceAgentAccess) + { + $this->allowAllServiceAgentAccess = $allowAllServiceAgentAccess; + } + /** + * @return bool + */ + public function getAllowAllServiceAgentAccess() + { + return $this->allowAllServiceAgentAccess; + } + /** + * Whether to allow cross-org VPCs in the bucket's IP filter configuration. + * + * @param bool $allowCrossOrgVpcs */ public function setAllowCrossOrgVpcs($allowCrossOrgVpcs) { @@ -48,7 +78,9 @@ public function getAllowCrossOrgVpcs() return $this->allowCrossOrgVpcs; } /** - * @param string + * The mode of the IP filter. Valid values are 'Enabled' and 'Disabled'. + * + * @param string $mode */ public function setMode($mode) { @@ -62,7 +94,9 @@ public function getMode() return $this->mode; } /** - * @param BucketIpFilterPublicNetworkSource + * The public network source of the bucket's IP filter. + * + * @param BucketIpFilterPublicNetworkSource $publicNetworkSource */ public function setPublicNetworkSource(BucketIpFilterPublicNetworkSource $publicNetworkSource) { @@ -76,7 +110,10 @@ public function getPublicNetworkSource() return $this->publicNetworkSource; } /** - * @param BucketIpFilterVpcNetworkSources[] + * The list of [VPC network](https://cloud.google.com/vpc/docs/vpc) sources of + * the bucket's IP filter. + * + * @param BucketIpFilterVpcNetworkSources[] $vpcNetworkSources */ public function setVpcNetworkSources($vpcNetworkSources) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterPublicNetworkSource.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterPublicNetworkSource.php index f217d816d..99a1444dd 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterPublicNetworkSource.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterPublicNetworkSource.php @@ -21,12 +21,18 @@ class BucketIpFilterPublicNetworkSource extends \Google\Collection { protected $collection_key = 'allowedIpCidrRanges'; /** + * The list of public IPv4, IPv6 cidr ranges that are allowed to access the + * bucket. + * * @var string[] */ public $allowedIpCidrRanges; /** - * @param string[] + * The list of public IPv4, IPv6 cidr ranges that are allowed to access the + * bucket. + * + * @param string[] $allowedIpCidrRanges */ public function setAllowedIpCidrRanges($allowedIpCidrRanges) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterVpcNetworkSources.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterVpcNetworkSources.php index 6521e666d..3eebc9fc5 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterVpcNetworkSources.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketIpFilterVpcNetworkSources.php @@ -21,16 +21,25 @@ class BucketIpFilterVpcNetworkSources extends \Google\Collection { protected $collection_key = 'allowedIpCidrRanges'; /** + * The list of IPv4, IPv6 cidr ranges subnetworks that are allowed to access + * the bucket. + * * @var string[] */ public $allowedIpCidrRanges; /** + * Name of the network. Format: + * projects/{PROJECT_ID}/global/networks/{NETWORK_NAME} + * * @var string */ public $network; /** - * @param string[] + * The list of IPv4, IPv6 cidr ranges subnetworks that are allowed to access + * the bucket. + * + * @param string[] $allowedIpCidrRanges */ public function setAllowedIpCidrRanges($allowedIpCidrRanges) { @@ -44,7 +53,10 @@ public function getAllowedIpCidrRanges() return $this->allowedIpCidrRanges; } /** - * @param string + * Name of the network. Format: + * projects/{PROJECT_ID}/global/networks/{NETWORK_NAME} + * + * @param string $network */ public function setNetwork($network) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycle.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycle.php index 0f1a2f08a..9b5bff578 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycle.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycle.php @@ -24,7 +24,10 @@ class BucketLifecycle extends \Google\Collection protected $ruleDataType = 'array'; /** - * @param BucketLifecycleRule[] + * A lifecycle management rule, which is made of an action to take and the + * condition(s) under which the action will be taken. + * + * @param BucketLifecycleRule[] $rule */ public function setRule($rule) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRule.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRule.php index 4c677dfa6..97831e434 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRule.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRule.php @@ -25,7 +25,9 @@ class BucketLifecycleRule extends \Google\Model protected $conditionDataType = ''; /** - * @param BucketLifecycleRuleAction + * The action to take. + * + * @param BucketLifecycleRuleAction $action */ public function setAction(BucketLifecycleRuleAction $action) { @@ -39,7 +41,9 @@ public function getAction() return $this->action; } /** - * @param BucketLifecycleRuleCondition + * The condition(s) under which the action will be taken. + * + * @param BucketLifecycleRuleCondition $condition */ public function setCondition(BucketLifecycleRuleCondition $condition) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleAction.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleAction.php index 8aa5da040..6e633ee23 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleAction.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleAction.php @@ -20,16 +20,25 @@ class BucketLifecycleRuleAction extends \Google\Model { /** + * Target storage class. Required iff the type of the action is + * SetStorageClass. + * * @var string */ public $storageClass; /** + * Type of the action. Currently, only Delete, SetStorageClass, and + * AbortIncompleteMultipartUpload are supported. + * * @var string */ public $type; /** - * @param string + * Target storage class. Required iff the type of the action is + * SetStorageClass. + * + * @param string $storageClass */ public function setStorageClass($storageClass) { @@ -43,7 +52,10 @@ public function getStorageClass() return $this->storageClass; } /** - * @param string + * Type of the action. Currently, only Delete, SetStorageClass, and + * AbortIncompleteMultipartUpload are supported. + * + * @param string $type */ public function setType($type) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleCondition.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleCondition.php index a71a8acd7..1c3c6c699 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleCondition.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLifecycleRuleCondition.php @@ -21,56 +21,110 @@ class BucketLifecycleRuleCondition extends \Google\Collection { protected $collection_key = 'matchesSuffix'; /** + * Age of an object (in days). This condition is satisfied when an object + * reaches the specified age. + * * @var int */ public $age; /** + * A date in RFC 3339 format with only the date part (for instance, + * "2013-01-15"). This condition is satisfied when an object is created before + * midnight of the specified date in UTC. + * * @var string */ public $createdBefore; /** + * A date in RFC 3339 format with only the date part (for instance, + * "2013-01-15"). This condition is satisfied when the custom time on an + * object is before this date in UTC. + * * @var string */ public $customTimeBefore; /** + * Number of days elapsed since the user-specified timestamp set on an object. + * The condition is satisfied if the days elapsed is at least this number. If + * no custom timestamp is specified on an object, the condition does not + * apply. + * * @var int */ public $daysSinceCustomTime; /** + * Number of days elapsed since the noncurrent timestamp of an object. The + * condition is satisfied if the days elapsed is at least this number. This + * condition is relevant only for versioned objects. The value of the field + * must be a nonnegative integer. If it's zero, the object version will become + * eligible for Lifecycle action as soon as it becomes noncurrent. + * * @var int */ public $daysSinceNoncurrentTime; /** + * Relevant only for versioned objects. If the value is true, this condition + * matches live objects; if the value is false, it matches archived objects. + * * @var bool */ public $isLive; /** + * A regular expression that satisfies the RE2 syntax. This condition is + * satisfied when the name of the object matches the RE2 pattern. Note: This + * feature is currently in the "Early Access" launch stage and is only + * available to a whitelisted set of users; that means that this feature may + * be changed in backward-incompatible ways and that it is not guaranteed to + * be released. + * * @var string */ public $matchesPattern; /** + * List of object name prefixes. This condition will be satisfied when at + * least one of the prefixes exactly matches the beginning of the object name. + * * @var string[] */ public $matchesPrefix; /** + * Objects having any of the storage classes specified by this condition will + * be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, + * ARCHIVE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. + * * @var string[] */ public $matchesStorageClass; /** + * List of object name suffixes. This condition will be satisfied when at + * least one of the suffixes exactly matches the end of the object name. + * * @var string[] */ public $matchesSuffix; /** + * A date in RFC 3339 format with only the date part (for instance, + * "2013-01-15"). This condition is satisfied when the noncurrent time on an + * object is before this date in UTC. This condition is relevant only for + * versioned objects. + * * @var string */ public $noncurrentTimeBefore; /** + * Relevant only for versioned objects. If the value is N, this condition is + * satisfied when there are at least N versions (including the live version) + * newer than this version of the object. + * * @var int */ public $numNewerVersions; /** - * @param int + * Age of an object (in days). This condition is satisfied when an object + * reaches the specified age. + * + * @param int $age */ public function setAge($age) { @@ -84,7 +138,11 @@ public function getAge() return $this->age; } /** - * @param string + * A date in RFC 3339 format with only the date part (for instance, + * "2013-01-15"). This condition is satisfied when an object is created before + * midnight of the specified date in UTC. + * + * @param string $createdBefore */ public function setCreatedBefore($createdBefore) { @@ -98,7 +156,11 @@ public function getCreatedBefore() return $this->createdBefore; } /** - * @param string + * A date in RFC 3339 format with only the date part (for instance, + * "2013-01-15"). This condition is satisfied when the custom time on an + * object is before this date in UTC. + * + * @param string $customTimeBefore */ public function setCustomTimeBefore($customTimeBefore) { @@ -112,7 +174,12 @@ public function getCustomTimeBefore() return $this->customTimeBefore; } /** - * @param int + * Number of days elapsed since the user-specified timestamp set on an object. + * The condition is satisfied if the days elapsed is at least this number. If + * no custom timestamp is specified on an object, the condition does not + * apply. + * + * @param int $daysSinceCustomTime */ public function setDaysSinceCustomTime($daysSinceCustomTime) { @@ -126,7 +193,13 @@ public function getDaysSinceCustomTime() return $this->daysSinceCustomTime; } /** - * @param int + * Number of days elapsed since the noncurrent timestamp of an object. The + * condition is satisfied if the days elapsed is at least this number. This + * condition is relevant only for versioned objects. The value of the field + * must be a nonnegative integer. If it's zero, the object version will become + * eligible for Lifecycle action as soon as it becomes noncurrent. + * + * @param int $daysSinceNoncurrentTime */ public function setDaysSinceNoncurrentTime($daysSinceNoncurrentTime) { @@ -140,7 +213,10 @@ public function getDaysSinceNoncurrentTime() return $this->daysSinceNoncurrentTime; } /** - * @param bool + * Relevant only for versioned objects. If the value is true, this condition + * matches live objects; if the value is false, it matches archived objects. + * + * @param bool $isLive */ public function setIsLive($isLive) { @@ -154,7 +230,14 @@ public function getIsLive() return $this->isLive; } /** - * @param string + * A regular expression that satisfies the RE2 syntax. This condition is + * satisfied when the name of the object matches the RE2 pattern. Note: This + * feature is currently in the "Early Access" launch stage and is only + * available to a whitelisted set of users; that means that this feature may + * be changed in backward-incompatible ways and that it is not guaranteed to + * be released. + * + * @param string $matchesPattern */ public function setMatchesPattern($matchesPattern) { @@ -168,7 +251,10 @@ public function getMatchesPattern() return $this->matchesPattern; } /** - * @param string[] + * List of object name prefixes. This condition will be satisfied when at + * least one of the prefixes exactly matches the beginning of the object name. + * + * @param string[] $matchesPrefix */ public function setMatchesPrefix($matchesPrefix) { @@ -182,7 +268,11 @@ public function getMatchesPrefix() return $this->matchesPrefix; } /** - * @param string[] + * Objects having any of the storage classes specified by this condition will + * be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, + * ARCHIVE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. + * + * @param string[] $matchesStorageClass */ public function setMatchesStorageClass($matchesStorageClass) { @@ -196,7 +286,10 @@ public function getMatchesStorageClass() return $this->matchesStorageClass; } /** - * @param string[] + * List of object name suffixes. This condition will be satisfied when at + * least one of the suffixes exactly matches the end of the object name. + * + * @param string[] $matchesSuffix */ public function setMatchesSuffix($matchesSuffix) { @@ -210,7 +303,12 @@ public function getMatchesSuffix() return $this->matchesSuffix; } /** - * @param string + * A date in RFC 3339 format with only the date part (for instance, + * "2013-01-15"). This condition is satisfied when the noncurrent time on an + * object is before this date in UTC. This condition is relevant only for + * versioned objects. + * + * @param string $noncurrentTimeBefore */ public function setNoncurrentTimeBefore($noncurrentTimeBefore) { @@ -224,7 +322,11 @@ public function getNoncurrentTimeBefore() return $this->noncurrentTimeBefore; } /** - * @param int + * Relevant only for versioned objects. If the value is N, this condition is + * satisfied when there are at least N versions (including the live version) + * newer than this version of the object. + * + * @param int $numNewerVersions */ public function setNumNewerVersions($numNewerVersions) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLogging.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLogging.php index b61b425f0..1d95e3cbd 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLogging.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketLogging.php @@ -20,16 +20,22 @@ class BucketLogging extends \Google\Model { /** + * The destination bucket where the current bucket's logs should be placed. + * * @var string */ public $logBucket; /** + * A prefix for log object names. + * * @var string */ public $logObjectPrefix; /** - * @param string + * The destination bucket where the current bucket's logs should be placed. + * + * @param string $logBucket */ public function setLogBucket($logBucket) { @@ -43,7 +49,9 @@ public function getLogBucket() return $this->logBucket; } /** - * @param string + * A prefix for log object names. + * + * @param string $logObjectPrefix */ public function setLogObjectPrefix($logObjectPrefix) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketObjectRetention.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketObjectRetention.php index 5d4a29d9e..1319b8bf8 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketObjectRetention.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketObjectRetention.php @@ -20,12 +20,16 @@ class BucketObjectRetention extends \Google\Model { /** + * The bucket's object retention mode. Can be Enabled. + * * @var string */ public $mode; /** - * @param string + * The bucket's object retention mode. Can be Enabled. + * + * @param string $mode */ public function setMode($mode) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketOwner.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketOwner.php index 6cd328963..b78bbe717 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketOwner.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketOwner.php @@ -20,16 +20,22 @@ class BucketOwner extends \Google\Model { /** + * The entity, in the form project-owner-projectId. + * * @var string */ public $entity; /** + * The ID for the entity. + * * @var string */ public $entityId; /** - * @param string + * The entity, in the form project-owner-projectId. + * + * @param string $entity */ public function setEntity($entity) { @@ -43,7 +49,9 @@ public function getEntity() return $this->entity; } /** - * @param string + * The ID for the entity. + * + * @param string $entityId */ public function setEntityId($entityId) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketRetentionPolicy.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketRetentionPolicy.php index bf16bdf0b..108c8fe7f 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketRetentionPolicy.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketRetentionPolicy.php @@ -20,20 +20,33 @@ class BucketRetentionPolicy extends \Google\Model { /** + * Server-determined value that indicates the time from which policy was + * enforced and effective. This value is in RFC 3339 format. + * * @var string */ public $effectiveTime; /** + * Once locked, an object retention policy cannot be modified. + * * @var bool */ public $isLocked; /** + * The duration in seconds that objects need to be retained. Retention + * duration must be greater than zero and less than 100 years. Note that + * enforcement of retention periods less than a day is not guaranteed. Such + * periods should only be used for testing purposes. + * * @var string */ public $retentionPeriod; /** - * @param string + * Server-determined value that indicates the time from which policy was + * enforced and effective. This value is in RFC 3339 format. + * + * @param string $effectiveTime */ public function setEffectiveTime($effectiveTime) { @@ -47,7 +60,9 @@ public function getEffectiveTime() return $this->effectiveTime; } /** - * @param bool + * Once locked, an object retention policy cannot be modified. + * + * @param bool $isLocked */ public function setIsLocked($isLocked) { @@ -61,7 +76,12 @@ public function getIsLocked() return $this->isLocked; } /** - * @param string + * The duration in seconds that objects need to be retained. Retention + * duration must be greater than zero and less than 100 years. Note that + * enforcement of retention periods less than a day is not guaranteed. Such + * periods should only be used for testing purposes. + * + * @param string $retentionPeriod */ public function setRetentionPeriod($retentionPeriod) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketSoftDeletePolicy.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketSoftDeletePolicy.php index 5c28f9b26..69a0a3b4b 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketSoftDeletePolicy.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketSoftDeletePolicy.php @@ -20,16 +20,27 @@ class BucketSoftDeletePolicy extends \Google\Model { /** + * Server-determined value that indicates the time from which the policy, or + * one with a greater retention, was effective. This value is in RFC 3339 + * format. + * * @var string */ public $effectiveTime; /** + * The duration in seconds that soft-deleted objects in the bucket will be + * retained and cannot be permanently deleted. + * * @var string */ public $retentionDurationSeconds; /** - * @param string + * Server-determined value that indicates the time from which the policy, or + * one with a greater retention, was effective. This value is in RFC 3339 + * format. + * + * @param string $effectiveTime */ public function setEffectiveTime($effectiveTime) { @@ -43,7 +54,10 @@ public function getEffectiveTime() return $this->effectiveTime; } /** - * @param string + * The duration in seconds that soft-deleted objects in the bucket will be + * retained and cannot be permanently deleted. + * + * @param string $retentionDurationSeconds */ public function setRetentionDurationSeconds($retentionDurationSeconds) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayout.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayout.php index a8036e51a..9a60555b8 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayout.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayout.php @@ -20,6 +20,8 @@ class BucketStorageLayout extends \Google\Model { /** + * The name of the bucket. + * * @var string */ public $bucket; @@ -28,20 +30,29 @@ class BucketStorageLayout extends \Google\Model protected $hierarchicalNamespaceType = BucketStorageLayoutHierarchicalNamespace::class; protected $hierarchicalNamespaceDataType = ''; /** + * The kind of item this is. For storage layout, this is always + * storage#storageLayout. + * * @var string */ public $kind; /** + * The location of the bucket. + * * @var string */ public $location; /** + * The type of the bucket location. + * * @var string */ public $locationType; /** - * @param string + * The name of the bucket. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -55,7 +66,9 @@ public function getBucket() return $this->bucket; } /** - * @param BucketStorageLayoutCustomPlacementConfig + * The bucket's custom placement configuration for Custom Dual Regions. + * + * @param BucketStorageLayoutCustomPlacementConfig $customPlacementConfig */ public function setCustomPlacementConfig(BucketStorageLayoutCustomPlacementConfig $customPlacementConfig) { @@ -69,7 +82,9 @@ public function getCustomPlacementConfig() return $this->customPlacementConfig; } /** - * @param BucketStorageLayoutHierarchicalNamespace + * The bucket's hierarchical namespace configuration. + * + * @param BucketStorageLayoutHierarchicalNamespace $hierarchicalNamespace */ public function setHierarchicalNamespace(BucketStorageLayoutHierarchicalNamespace $hierarchicalNamespace) { @@ -83,7 +98,10 @@ public function getHierarchicalNamespace() return $this->hierarchicalNamespace; } /** - * @param string + * The kind of item this is. For storage layout, this is always + * storage#storageLayout. + * + * @param string $kind */ public function setKind($kind) { @@ -97,7 +115,9 @@ public function getKind() return $this->kind; } /** - * @param string + * The location of the bucket. + * + * @param string $location */ public function setLocation($location) { @@ -111,7 +131,9 @@ public function getLocation() return $this->location; } /** - * @param string + * The type of the bucket location. + * + * @param string $locationType */ public function setLocationType($locationType) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutCustomPlacementConfig.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutCustomPlacementConfig.php index 57ae92bfa..e6bc86209 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutCustomPlacementConfig.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutCustomPlacementConfig.php @@ -21,12 +21,16 @@ class BucketStorageLayoutCustomPlacementConfig extends \Google\Collection { protected $collection_key = 'dataLocations'; /** + * The list of regional locations in which data is placed. + * * @var string[] */ public $dataLocations; /** - * @param string[] + * The list of regional locations in which data is placed. + * + * @param string[] $dataLocations */ public function setDataLocations($dataLocations) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutHierarchicalNamespace.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutHierarchicalNamespace.php index 8e6bc3f35..57e21f890 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutHierarchicalNamespace.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketStorageLayoutHierarchicalNamespace.php @@ -20,12 +20,16 @@ class BucketStorageLayoutHierarchicalNamespace extends \Google\Model { /** + * When set to true, hierarchical namespace is enabled for this bucket. + * * @var bool */ public $enabled; /** - * @param bool + * When set to true, hierarchical namespace is enabled for this bucket. + * + * @param bool $enabled */ public function setEnabled($enabled) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketVersioning.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketVersioning.php index 978e01102..3b2c3e037 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketVersioning.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketVersioning.php @@ -20,12 +20,16 @@ class BucketVersioning extends \Google\Model { /** + * While set to true, versioning is fully enabled for this bucket. + * * @var bool */ public $enabled; /** - * @param bool + * While set to true, versioning is fully enabled for this bucket. + * + * @param bool $enabled */ public function setEnabled($enabled) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketWebsite.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketWebsite.php index 7957ed1c7..ed49c902c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BucketWebsite.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BucketWebsite.php @@ -20,16 +20,30 @@ class BucketWebsite extends \Google\Model { /** + * If the requested object path is missing, the service will ensure the path + * has a trailing '/', append this suffix, and attempt to retrieve the + * resulting object. This allows the creation of index.html objects to + * represent directory pages. + * * @var string */ public $mainPageSuffix; /** + * If the requested object path is missing, and any mainPageSuffix object is + * missing, if applicable, the service will return the named object from this + * bucket as the content for a 404 Not Found result. + * * @var string */ public $notFoundPage; /** - * @param string + * If the requested object path is missing, the service will ensure the path + * has a trailing '/', append this suffix, and attempt to retrieve the + * resulting object. This allows the creation of index.html objects to + * represent directory pages. + * + * @param string $mainPageSuffix */ public function setMainPageSuffix($mainPageSuffix) { @@ -43,7 +57,11 @@ public function getMainPageSuffix() return $this->mainPageSuffix; } /** - * @param string + * If the requested object path is missing, and any mainPageSuffix object is + * missing, if applicable, the service will return the named object from this + * bucket as the content for a 404 Not Found result. + * + * @param string $notFoundPage */ public function setNotFoundPage($notFoundPage) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Buckets.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Buckets.php index c0e9d0f99..d2b5c4d7c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Buckets.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Buckets.php @@ -19,20 +19,35 @@ class Buckets extends \Google\Collection { - protected $collection_key = 'items'; + protected $collection_key = 'unreachable'; protected $itemsType = Bucket::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of buckets, this is always + * storage#buckets. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; + /** + * The list of bucket resource names that could not be reached during the + * listing operation. + * + * @var string[] + */ + public $unreachable; /** - * @param Bucket[] + * The list of items. + * + * @param Bucket[] $items */ public function setItems($items) { @@ -46,7 +61,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of buckets, this is always + * storage#buckets. + * + * @param string $kind */ public function setKind($kind) { @@ -60,7 +78,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { @@ -73,6 +94,23 @@ public function getNextPageToken() { return $this->nextPageToken; } + /** + * The list of bucket resource names that could not be reached during the + * listing operation. + * + * @param string[] $unreachable + */ + public function setUnreachable($unreachable) + { + $this->unreachable = $unreachable; + } + /** + * @return string[] + */ + public function getUnreachable() + { + return $this->unreachable; + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/BulkRestoreObjectsRequest.php b/lib/Google/vendor/google/apiclient-services/src/Storage/BulkRestoreObjectsRequest.php index d7feda6f0..92031ec04 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/BulkRestoreObjectsRequest.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/BulkRestoreObjectsRequest.php @@ -21,28 +21,67 @@ class BulkRestoreObjectsRequest extends \Google\Collection { protected $collection_key = 'matchGlobs'; /** + * If false (default), the restore will not overwrite live objects with the + * same name at the destination. This means some deleted objects may be + * skipped. If true, live objects will be overwritten resulting in a + * noncurrent object (if versioning is enabled). If versioning is not enabled, + * overwriting the object will result in a soft-deleted object. In either + * case, if a noncurrent object already exists with the same name, a live + * version can be written without issue. + * * @var bool */ public $allowOverwrite; /** + * If true, copies the source object's ACL; otherwise, uses the bucket's + * default object ACL. The default is false. + * * @var bool */ public $copySourceAcl; /** + * Restores only the objects that were created after this time. + * + * @var string + */ + public $createdAfterTime; + /** + * Restores only the objects that were created before this time. + * + * @var string + */ + public $createdBeforeTime; + /** + * Restores only the objects matching any of the specified glob(s). If this + * parameter is not specified, all objects will be restored within the + * specified time range. + * * @var string[] */ public $matchGlobs; /** + * Restores only the objects that were soft-deleted after this time. + * * @var string */ public $softDeletedAfterTime; /** + * Restores only the objects that were soft-deleted before this time. + * * @var string */ public $softDeletedBeforeTime; /** - * @param bool + * If false (default), the restore will not overwrite live objects with the + * same name at the destination. This means some deleted objects may be + * skipped. If true, live objects will be overwritten resulting in a + * noncurrent object (if versioning is enabled). If versioning is not enabled, + * overwriting the object will result in a soft-deleted object. In either + * case, if a noncurrent object already exists with the same name, a live + * version can be written without issue. + * + * @param bool $allowOverwrite */ public function setAllowOverwrite($allowOverwrite) { @@ -56,7 +95,10 @@ public function getAllowOverwrite() return $this->allowOverwrite; } /** - * @param bool + * If true, copies the source object's ACL; otherwise, uses the bucket's + * default object ACL. The default is false. + * + * @param bool $copySourceAcl */ public function setCopySourceAcl($copySourceAcl) { @@ -70,7 +112,43 @@ public function getCopySourceAcl() return $this->copySourceAcl; } /** - * @param string[] + * Restores only the objects that were created after this time. + * + * @param string $createdAfterTime + */ + public function setCreatedAfterTime($createdAfterTime) + { + $this->createdAfterTime = $createdAfterTime; + } + /** + * @return string + */ + public function getCreatedAfterTime() + { + return $this->createdAfterTime; + } + /** + * Restores only the objects that were created before this time. + * + * @param string $createdBeforeTime + */ + public function setCreatedBeforeTime($createdBeforeTime) + { + $this->createdBeforeTime = $createdBeforeTime; + } + /** + * @return string + */ + public function getCreatedBeforeTime() + { + return $this->createdBeforeTime; + } + /** + * Restores only the objects matching any of the specified glob(s). If this + * parameter is not specified, all objects will be restored within the + * specified time range. + * + * @param string[] $matchGlobs */ public function setMatchGlobs($matchGlobs) { @@ -84,7 +162,9 @@ public function getMatchGlobs() return $this->matchGlobs; } /** - * @param string + * Restores only the objects that were soft-deleted after this time. + * + * @param string $softDeletedAfterTime */ public function setSoftDeletedAfterTime($softDeletedAfterTime) { @@ -98,7 +178,9 @@ public function getSoftDeletedAfterTime() return $this->softDeletedAfterTime; } /** - * @param string + * Restores only the objects that were soft-deleted before this time. + * + * @param string $softDeletedBeforeTime */ public function setSoftDeletedBeforeTime($softDeletedBeforeTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Channel.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Channel.php index e4b538c80..e98557b57 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Channel.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Channel.php @@ -20,48 +20,74 @@ class Channel extends \Google\Model { /** + * The address where notifications are delivered for this channel. + * * @var string */ public $address; /** + * Date and time of notification channel expiration, expressed as a Unix + * timestamp, in milliseconds. Optional. + * * @var string */ public $expiration; /** + * A UUID or similar unique string that identifies this channel. + * * @var string */ public $id; /** + * Identifies this as a notification channel used to watch for changes to a + * resource, which is "api#channel". + * * @var string */ public $kind; /** + * Additional parameters controlling delivery channel behavior. Optional. + * * @var string[] */ public $params; /** + * A Boolean value to indicate whether payload is wanted. Optional. + * * @var bool */ public $payload; /** + * An opaque ID that identifies the resource being watched on this channel. + * Stable across different API versions. + * * @var string */ public $resourceId; /** + * A version-specific identifier for the watched resource. + * * @var string */ public $resourceUri; /** + * An arbitrary string delivered to the target address with each notification + * delivered over this channel. Optional. + * * @var string */ public $token; /** + * The type of delivery mechanism used for this channel. + * * @var string */ public $type; /** - * @param string + * The address where notifications are delivered for this channel. + * + * @param string $address */ public function setAddress($address) { @@ -75,7 +101,10 @@ public function getAddress() return $this->address; } /** - * @param string + * Date and time of notification channel expiration, expressed as a Unix + * timestamp, in milliseconds. Optional. + * + * @param string $expiration */ public function setExpiration($expiration) { @@ -89,7 +118,9 @@ public function getExpiration() return $this->expiration; } /** - * @param string + * A UUID or similar unique string that identifies this channel. + * + * @param string $id */ public function setId($id) { @@ -103,7 +134,10 @@ public function getId() return $this->id; } /** - * @param string + * Identifies this as a notification channel used to watch for changes to a + * resource, which is "api#channel". + * + * @param string $kind */ public function setKind($kind) { @@ -117,7 +151,9 @@ public function getKind() return $this->kind; } /** - * @param string[] + * Additional parameters controlling delivery channel behavior. Optional. + * + * @param string[] $params */ public function setParams($params) { @@ -131,7 +167,9 @@ public function getParams() return $this->params; } /** - * @param bool + * A Boolean value to indicate whether payload is wanted. Optional. + * + * @param bool $payload */ public function setPayload($payload) { @@ -145,7 +183,10 @@ public function getPayload() return $this->payload; } /** - * @param string + * An opaque ID that identifies the resource being watched on this channel. + * Stable across different API versions. + * + * @param string $resourceId */ public function setResourceId($resourceId) { @@ -159,7 +200,9 @@ public function getResourceId() return $this->resourceId; } /** - * @param string + * A version-specific identifier for the watched resource. + * + * @param string $resourceUri */ public function setResourceUri($resourceUri) { @@ -173,7 +216,10 @@ public function getResourceUri() return $this->resourceUri; } /** - * @param string + * An arbitrary string delivered to the target address with each notification + * delivered over this channel. Optional. + * + * @param string $token */ public function setToken($token) { @@ -187,7 +233,9 @@ public function getToken() return $this->token; } /** - * @param string + * The type of delivery mechanism used for this channel. + * + * @param string $type */ public function setType($type) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequest.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequest.php index 174719c99..663a96d2c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequest.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequest.php @@ -20,9 +20,17 @@ class ComposeRequest extends \Google\Collection { protected $collection_key = 'sourceObjects'; + /** + * If true, the source objects will be deleted. + * + * @var bool + */ + public $deleteSourceObjects; protected $destinationType = StorageObject::class; protected $destinationDataType = ''; /** + * The kind of item this is. + * * @var string */ public $kind; @@ -30,7 +38,25 @@ class ComposeRequest extends \Google\Collection protected $sourceObjectsDataType = 'array'; /** - * @param StorageObject + * If true, the source objects will be deleted. + * + * @param bool $deleteSourceObjects + */ + public function setDeleteSourceObjects($deleteSourceObjects) + { + $this->deleteSourceObjects = $deleteSourceObjects; + } + /** + * @return bool + */ + public function getDeleteSourceObjects() + { + return $this->deleteSourceObjects; + } + /** + * Properties of the resulting object. + * + * @param StorageObject $destination */ public function setDestination(StorageObject $destination) { @@ -44,7 +70,9 @@ public function getDestination() return $this->destination; } /** - * @param string + * The kind of item this is. + * + * @param string $kind */ public function setKind($kind) { @@ -58,7 +86,9 @@ public function getKind() return $this->kind; } /** - * @param ComposeRequestSourceObjects[] + * The list of source objects that will be concatenated into a single object. + * + * @param ComposeRequestSourceObjects[] $sourceObjects */ public function setSourceObjects($sourceObjects) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjects.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjects.php index 4ed52405f..da5b9b951 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjects.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjects.php @@ -20,10 +20,15 @@ class ComposeRequestSourceObjects extends \Google\Model { /** + * The generation of this object to use as the source. + * * @var string */ public $generation; /** + * The source object's name. All source objects must reside in the same + * bucket. + * * @var string */ public $name; @@ -31,7 +36,9 @@ class ComposeRequestSourceObjects extends \Google\Model protected $objectPreconditionsDataType = ''; /** - * @param string + * The generation of this object to use as the source. + * + * @param string $generation */ public function setGeneration($generation) { @@ -45,7 +52,10 @@ public function getGeneration() return $this->generation; } /** - * @param string + * The source object's name. All source objects must reside in the same + * bucket. + * + * @param string $name */ public function setName($name) { @@ -59,7 +69,9 @@ public function getName() return $this->name; } /** - * @param ComposeRequestSourceObjectsObjectPreconditions + * Conditions that must be met for this operation to execute. + * + * @param ComposeRequestSourceObjectsObjectPreconditions $objectPreconditions */ public function setObjectPreconditions(ComposeRequestSourceObjectsObjectPreconditions $objectPreconditions) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjectsObjectPreconditions.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjectsObjectPreconditions.php index e5ec2b825..f7644d3e0 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjectsObjectPreconditions.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ComposeRequestSourceObjectsObjectPreconditions.php @@ -20,12 +20,20 @@ class ComposeRequestSourceObjectsObjectPreconditions extends \Google\Model { /** + * Only perform the composition if the generation of the source object that + * would be used matches this value. If this value and a generation are both + * specified, they must be the same value or the call will fail. + * * @var string */ public $ifGenerationMatch; /** - * @param string + * Only perform the composition if the generation of the source object that + * would be used matches this value. If this value and a generation are both + * specified, they must be the same value or the call will fail. + * + * @param string $ifGenerationMatch */ public function setIfGenerationMatch($ifGenerationMatch) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Expr.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Expr.php index 2ed23b476..c8804488c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Expr.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Expr.php @@ -20,24 +20,40 @@ class Expr extends \Google\Model { /** + * An optional description of the expression. This is a longer text which + * describes the expression, e.g. when hovered over it in a UI. + * * @var string */ public $description; /** + * Textual representation of an expression in Common Expression Language + * syntax. The application context of the containing message determines which + * well-known feature set of CEL is supported. + * * @var string */ public $expression; /** + * An optional string indicating the location of the expression for error + * reporting, e.g. a file name and a position in the file. + * * @var string */ public $location; /** + * An optional title for the expression, i.e. a short string describing its + * purpose. This can be used e.g. in UIs which allow to enter the expression. + * * @var string */ public $title; /** - * @param string + * An optional description of the expression. This is a longer text which + * describes the expression, e.g. when hovered over it in a UI. + * + * @param string $description */ public function setDescription($description) { @@ -51,7 +67,11 @@ public function getDescription() return $this->description; } /** - * @param string + * Textual representation of an expression in Common Expression Language + * syntax. The application context of the containing message determines which + * well-known feature set of CEL is supported. + * + * @param string $expression */ public function setExpression($expression) { @@ -65,7 +85,10 @@ public function getExpression() return $this->expression; } /** - * @param string + * An optional string indicating the location of the expression for error + * reporting, e.g. a file name and a position in the file. + * + * @param string $location */ public function setLocation($location) { @@ -79,7 +102,10 @@ public function getLocation() return $this->location; } /** - * @param string + * An optional title for the expression, i.e. a short string describing its + * purpose. This can be used e.g. in UIs which allow to enter the expression. + * + * @param string $title */ public function setTitle($title) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Folder.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Folder.php index 11a41f3ac..7ca710698 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Folder.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Folder.php @@ -20,42 +20,61 @@ class Folder extends \Google\Model { /** + * The name of the bucket containing this folder. + * * @var string */ public $bucket; /** + * The creation time of the folder in RFC 3339 format. + * * @var string */ public $createTime; /** + * The ID of the folder, including the bucket name, folder name. + * * @var string */ public $id; /** + * The kind of item this is. For folders, this is always storage#folder. + * * @var string */ public $kind; /** + * The version of the metadata for this folder. Used for preconditions and for + * detecting changes in metadata. + * * @var string */ public $metageneration; /** + * The name of the folder. Required if not specified by URL parameter. + * * @var string */ public $name; protected $pendingRenameInfoType = FolderPendingRenameInfo::class; protected $pendingRenameInfoDataType = ''; /** + * The link to this folder. + * * @var string */ public $selfLink; /** + * The modification time of the folder metadata in RFC 3339 format. + * * @var string */ public $updateTime; /** - * @param string + * The name of the bucket containing this folder. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -69,7 +88,9 @@ public function getBucket() return $this->bucket; } /** - * @param string + * The creation time of the folder in RFC 3339 format. + * + * @param string $createTime */ public function setCreateTime($createTime) { @@ -83,7 +104,9 @@ public function getCreateTime() return $this->createTime; } /** - * @param string + * The ID of the folder, including the bucket name, folder name. + * + * @param string $id */ public function setId($id) { @@ -97,7 +120,9 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For folders, this is always storage#folder. + * + * @param string $kind */ public function setKind($kind) { @@ -111,7 +136,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The version of the metadata for this folder. Used for preconditions and for + * detecting changes in metadata. + * + * @param string $metageneration */ public function setMetageneration($metageneration) { @@ -125,7 +153,9 @@ public function getMetageneration() return $this->metageneration; } /** - * @param string + * The name of the folder. Required if not specified by URL parameter. + * + * @param string $name */ public function setName($name) { @@ -139,7 +169,10 @@ public function getName() return $this->name; } /** - * @param FolderPendingRenameInfo + * Only present if the folder is part of an ongoing rename folder operation. + * Contains information which can be used to query the operation status. + * + * @param FolderPendingRenameInfo $pendingRenameInfo */ public function setPendingRenameInfo(FolderPendingRenameInfo $pendingRenameInfo) { @@ -153,7 +186,9 @@ public function getPendingRenameInfo() return $this->pendingRenameInfo; } /** - * @param string + * The link to this folder. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -167,7 +202,9 @@ public function getSelfLink() return $this->selfLink; } /** - * @param string + * The modification time of the folder metadata in RFC 3339 format. + * + * @param string $updateTime */ public function setUpdateTime($updateTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/FolderPendingRenameInfo.php b/lib/Google/vendor/google/apiclient-services/src/Storage/FolderPendingRenameInfo.php index 186f07a5d..fcebf296c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/FolderPendingRenameInfo.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/FolderPendingRenameInfo.php @@ -20,12 +20,16 @@ class FolderPendingRenameInfo extends \Google\Model { /** + * The ID of the rename folder operation. + * * @var string */ public $operationId; /** - * @param string + * The ID of the rename folder operation. + * + * @param string $operationId */ public function setOperationId($operationId) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Folders.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Folders.php index 9aae966c3..ea3d1b7b5 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Folders.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Folders.php @@ -23,16 +23,24 @@ class Folders extends \Google\Collection protected $itemsType = Folder::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of folders, this is always + * storage#folders. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; /** - * @param Folder[] + * The list of items. + * + * @param Folder[] $items */ public function setItems($items) { @@ -46,7 +54,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of folders, this is always + * storage#folders. + * + * @param string $kind */ public function setKind($kind) { @@ -60,7 +71,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningListOperationsResponse.php b/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningListOperationsResponse.php index 0024c0108..67c018e44 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningListOperationsResponse.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningListOperationsResponse.php @@ -21,10 +21,16 @@ class GoogleLongrunningListOperationsResponse extends \Google\Collection { protected $collection_key = 'operations'; /** + * The kind of item this is. For lists of operations, this is always + * storage#operations. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; @@ -32,7 +38,10 @@ class GoogleLongrunningListOperationsResponse extends \Google\Collection protected $operationsDataType = 'array'; /** - * @param string + * The kind of item this is. For lists of operations, this is always + * storage#operations. + * + * @param string $kind */ public function setKind($kind) { @@ -46,7 +55,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { @@ -60,7 +72,9 @@ public function getNextPageToken() return $this->nextPageToken; } /** - * @param GoogleLongrunningOperation[] + * A list of operations that matches the specified filter in the request. + * + * @param GoogleLongrunningOperation[] $operations */ public function setOperations($operations) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningOperation.php b/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningOperation.php index 97ea2fdb7..511688720 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningOperation.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleLongrunningOperation.php @@ -20,34 +20,63 @@ class GoogleLongrunningOperation extends \Google\Model { /** + * If the value is "false", it means the operation is still in progress. If + * "true", the operation is completed, and either "error" or "response" is + * available. + * * @var bool */ public $done; protected $errorType = GoogleRpcStatus::class; protected $errorDataType = ''; /** + * The kind of item this is. For operations, this is always storage#operation. + * * @var string */ public $kind; /** + * Service-specific metadata associated with the operation. It typically + * contains progress information and common metadata such as create time. Some + * services might not provide such metadata. Any method that returns a long- + * running operation should document the metadata type, if any. + * * @var array[] */ public $metadata; /** + * The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the "name" + * should be a resource name ending with "operations/{operationId}". + * * @var string */ public $name; /** + * The normal response of the operation in case of success. If the original + * method returns no data on success, such as "Delete", the response is + * google.protobuf.Empty. If the original method is standard + * Get/Create/Update, the response should be the resource. For other methods, + * the response should have the type "XxxResponse", where "Xxx" is the + * original method name. For example, if the original method name is + * "TakeSnapshot()", the inferred response type is "TakeSnapshotResponse". + * * @var array[] */ public $response; /** + * The link to this long running operation. + * * @var string */ public $selfLink; /** - * @param bool + * If the value is "false", it means the operation is still in progress. If + * "true", the operation is completed, and either "error" or "response" is + * available. + * + * @param bool $done */ public function setDone($done) { @@ -61,7 +90,9 @@ public function getDone() return $this->done; } /** - * @param GoogleRpcStatus + * The error result of the operation in case of failure or cancellation. + * + * @param GoogleRpcStatus $error */ public function setError(GoogleRpcStatus $error) { @@ -75,7 +106,9 @@ public function getError() return $this->error; } /** - * @param string + * The kind of item this is. For operations, this is always storage#operation. + * + * @param string $kind */ public function setKind($kind) { @@ -89,7 +122,12 @@ public function getKind() return $this->kind; } /** - * @param array[] + * Service-specific metadata associated with the operation. It typically + * contains progress information and common metadata such as create time. Some + * services might not provide such metadata. Any method that returns a long- + * running operation should document the metadata type, if any. + * + * @param array[] $metadata */ public function setMetadata($metadata) { @@ -103,7 +141,11 @@ public function getMetadata() return $this->metadata; } /** - * @param string + * The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the "name" + * should be a resource name ending with "operations/{operationId}". + * + * @param string $name */ public function setName($name) { @@ -117,7 +159,15 @@ public function getName() return $this->name; } /** - * @param array[] + * The normal response of the operation in case of success. If the original + * method returns no data on success, such as "Delete", the response is + * google.protobuf.Empty. If the original method is standard + * Get/Create/Update, the response should be the resource. For other methods, + * the response should have the type "XxxResponse", where "Xxx" is the + * original method name. For example, if the original method name is + * "TakeSnapshot()", the inferred response type is "TakeSnapshotResponse". + * + * @param array[] $response */ public function setResponse($response) { @@ -131,7 +181,9 @@ public function getResponse() return $this->response; } /** - * @param string + * The link to this long running operation. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleRpcStatus.php b/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleRpcStatus.php index 4a9bf3f05..50de176b5 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleRpcStatus.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/GoogleRpcStatus.php @@ -21,20 +21,29 @@ class GoogleRpcStatus extends \Google\Collection { protected $collection_key = 'details'; /** + * The status code, which should be an enum value of google.rpc.Code. + * * @var int */ public $code; /** + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + * * @var array[] */ public $details; /** + * A developer-facing error message, which should be in English. + * * @var string */ public $message; /** - * @param int + * The status code, which should be an enum value of google.rpc.Code. + * + * @param int $code */ public function setCode($code) { @@ -48,7 +57,10 @@ public function getCode() return $this->code; } /** - * @param array[] + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. + * + * @param array[] $details */ public function setDetails($details) { @@ -62,7 +74,9 @@ public function getDetails() return $this->details; } /** - * @param string + * A developer-facing error message, which should be in English. + * + * @param string $message */ public function setMessage($message) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKey.php b/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKey.php index ba17777b3..6761ca8f5 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKey.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKey.php @@ -20,18 +20,24 @@ class HmacKey extends \Google\Model { /** + * The kind of item this is. For HMAC keys, this is always storage#hmacKey. + * * @var string */ public $kind; protected $metadataType = HmacKeyMetadata::class; protected $metadataDataType = ''; /** + * HMAC secret key material. + * * @var string */ public $secret; /** - * @param string + * The kind of item this is. For HMAC keys, this is always storage#hmacKey. + * + * @param string $kind */ public function setKind($kind) { @@ -45,7 +51,9 @@ public function getKind() return $this->kind; } /** - * @param HmacKeyMetadata + * Key metadata. + * + * @param HmacKeyMetadata $metadata */ public function setMetadata(HmacKeyMetadata $metadata) { @@ -59,7 +67,9 @@ public function getMetadata() return $this->metadata; } /** - * @param string + * HMAC secret key material. + * + * @param string $secret */ public function setSecret($secret) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeyMetadata.php b/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeyMetadata.php index 432ec9cb7..fc8b7d60d 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeyMetadata.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeyMetadata.php @@ -20,48 +20,71 @@ class HmacKeyMetadata extends \Google\Model { /** + * The ID of the HMAC Key. + * * @var string */ public $accessId; /** + * HTTP 1.1 Entity tag for the HMAC key. + * * @var string */ public $etag; /** + * The ID of the HMAC key, including the Project ID and the Access ID. + * * @var string */ public $id; /** + * The kind of item this is. For HMAC Key metadata, this is always + * storage#hmacKeyMetadata. + * * @var string */ public $kind; /** + * Project ID owning the service account to which the key authenticates. + * * @var string */ public $projectId; /** + * The link to this resource. + * * @var string */ public $selfLink; /** + * The email address of the key's associated service account. + * * @var string */ public $serviceAccountEmail; /** + * The state of the key. Can be one of ACTIVE, INACTIVE, or DELETED. + * * @var string */ public $state; /** + * The creation time of the HMAC key in RFC 3339 format. + * * @var string */ public $timeCreated; /** + * The last modification time of the HMAC key metadata in RFC 3339 format. + * * @var string */ public $updated; /** - * @param string + * The ID of the HMAC Key. + * + * @param string $accessId */ public function setAccessId($accessId) { @@ -75,7 +98,9 @@ public function getAccessId() return $this->accessId; } /** - * @param string + * HTTP 1.1 Entity tag for the HMAC key. + * + * @param string $etag */ public function setEtag($etag) { @@ -89,7 +114,9 @@ public function getEtag() return $this->etag; } /** - * @param string + * The ID of the HMAC key, including the Project ID and the Access ID. + * + * @param string $id */ public function setId($id) { @@ -103,7 +130,10 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For HMAC Key metadata, this is always + * storage#hmacKeyMetadata. + * + * @param string $kind */ public function setKind($kind) { @@ -117,7 +147,9 @@ public function getKind() return $this->kind; } /** - * @param string + * Project ID owning the service account to which the key authenticates. + * + * @param string $projectId */ public function setProjectId($projectId) { @@ -131,7 +163,9 @@ public function getProjectId() return $this->projectId; } /** - * @param string + * The link to this resource. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -145,7 +179,9 @@ public function getSelfLink() return $this->selfLink; } /** - * @param string + * The email address of the key's associated service account. + * + * @param string $serviceAccountEmail */ public function setServiceAccountEmail($serviceAccountEmail) { @@ -159,7 +195,9 @@ public function getServiceAccountEmail() return $this->serviceAccountEmail; } /** - * @param string + * The state of the key. Can be one of ACTIVE, INACTIVE, or DELETED. + * + * @param string $state */ public function setState($state) { @@ -173,7 +211,9 @@ public function getState() return $this->state; } /** - * @param string + * The creation time of the HMAC key in RFC 3339 format. + * + * @param string $timeCreated */ public function setTimeCreated($timeCreated) { @@ -187,7 +227,9 @@ public function getTimeCreated() return $this->timeCreated; } /** - * @param string + * The last modification time of the HMAC key metadata in RFC 3339 format. + * + * @param string $updated */ public function setUpdated($updated) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeysMetadata.php b/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeysMetadata.php index 7f51b5df5..88257f6ec 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeysMetadata.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/HmacKeysMetadata.php @@ -23,16 +23,24 @@ class HmacKeysMetadata extends \Google\Collection protected $itemsType = HmacKeyMetadata::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of hmacKeys, this is always + * storage#hmacKeysMetadata. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; /** - * @param HmacKeyMetadata[] + * The list of items. + * + * @param HmacKeyMetadata[] $items */ public function setItems($items) { @@ -46,7 +54,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of hmacKeys, this is always + * storage#hmacKeysMetadata. + * + * @param string $kind */ public function setKind($kind) { @@ -60,7 +71,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolder.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolder.php index cca7d25fa..b248a87e5 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolder.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolder.php @@ -20,40 +20,61 @@ class ManagedFolder extends \Google\Model { /** + * The name of the bucket containing this managed folder. + * * @var string */ public $bucket; /** + * The creation time of the managed folder in RFC 3339 format. + * * @var string */ public $createTime; /** + * The ID of the managed folder, including the bucket name and managed folder + * name. + * * @var string */ public $id; /** + * The kind of item this is. For managed folders, this is always + * storage#managedFolder. + * * @var string */ public $kind; /** + * The version of the metadata for this managed folder. Used for preconditions + * and for detecting changes in metadata. + * * @var string */ public $metageneration; /** + * The name of the managed folder. Required if not specified by URL parameter. + * * @var string */ public $name; /** + * The link to this managed folder. + * * @var string */ public $selfLink; /** + * The last update time of the managed folder metadata in RFC 3339 format. + * * @var string */ public $updateTime; /** - * @param string + * The name of the bucket containing this managed folder. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -67,7 +88,9 @@ public function getBucket() return $this->bucket; } /** - * @param string + * The creation time of the managed folder in RFC 3339 format. + * + * @param string $createTime */ public function setCreateTime($createTime) { @@ -81,7 +104,10 @@ public function getCreateTime() return $this->createTime; } /** - * @param string + * The ID of the managed folder, including the bucket name and managed folder + * name. + * + * @param string $id */ public function setId($id) { @@ -95,7 +121,10 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For managed folders, this is always + * storage#managedFolder. + * + * @param string $kind */ public function setKind($kind) { @@ -109,7 +138,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The version of the metadata for this managed folder. Used for preconditions + * and for detecting changes in metadata. + * + * @param string $metageneration */ public function setMetageneration($metageneration) { @@ -123,7 +155,9 @@ public function getMetageneration() return $this->metageneration; } /** - * @param string + * The name of the managed folder. Required if not specified by URL parameter. + * + * @param string $name */ public function setName($name) { @@ -137,7 +171,9 @@ public function getName() return $this->name; } /** - * @param string + * The link to this managed folder. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -151,7 +187,9 @@ public function getSelfLink() return $this->selfLink; } /** - * @param string + * The last update time of the managed folder metadata in RFC 3339 format. + * + * @param string $updateTime */ public function setUpdateTime($updateTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolders.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolders.php index 582c4fe93..d0217ccde 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolders.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ManagedFolders.php @@ -23,16 +23,24 @@ class ManagedFolders extends \Google\Collection protected $itemsType = ManagedFolder::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of managed folders, this is always + * storage#managedFolders. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; /** - * @param ManagedFolder[] + * The list of items. + * + * @param ManagedFolder[] $items */ public function setItems($items) { @@ -46,7 +54,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of managed folders, this is always + * storage#managedFolders. + * + * @param string $kind */ public function setKind($kind) { @@ -60,7 +71,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Notification.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Notification.php index 947f4afa1..ce289e14f 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Notification.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Notification.php @@ -27,44 +27,70 @@ class Notification extends \Google\Collection "payloadFormat" => "payload_format", ]; /** + * An optional list of additional attributes to attach to each Cloud PubSub + * message published for this notification subscription. + * * @var string[] */ public $customAttributes; /** + * HTTP 1.1 Entity tag for this subscription notification. + * * @var string */ public $etag; /** + * If present, only send notifications about listed event types. If empty, + * sent notifications for all event types. + * * @var string[] */ public $eventTypes; /** + * The ID of the notification. + * * @var string */ public $id; /** + * The kind of item this is. For notifications, this is always + * storage#notification. + * * @var string */ public $kind; /** + * If present, only apply this notification configuration to object names that + * begin with this prefix. + * * @var string */ public $objectNamePrefix; /** + * The desired content of the Payload. + * * @var string */ public $payloadFormat; /** + * The canonical URL of this notification. + * * @var string */ public $selfLink; /** + * The Cloud PubSub topic to which this subscription publishes. Formatted as: + * '//pubsub.googleapis.com/projects/{project-identifier}/topics/{my-topic}' + * * @var string */ public $topic; /** - * @param string[] + * An optional list of additional attributes to attach to each Cloud PubSub + * message published for this notification subscription. + * + * @param string[] $customAttributes */ public function setCustomAttributes($customAttributes) { @@ -78,7 +104,9 @@ public function getCustomAttributes() return $this->customAttributes; } /** - * @param string + * HTTP 1.1 Entity tag for this subscription notification. + * + * @param string $etag */ public function setEtag($etag) { @@ -92,7 +120,10 @@ public function getEtag() return $this->etag; } /** - * @param string[] + * If present, only send notifications about listed event types. If empty, + * sent notifications for all event types. + * + * @param string[] $eventTypes */ public function setEventTypes($eventTypes) { @@ -106,7 +137,9 @@ public function getEventTypes() return $this->eventTypes; } /** - * @param string + * The ID of the notification. + * + * @param string $id */ public function setId($id) { @@ -120,7 +153,10 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For notifications, this is always + * storage#notification. + * + * @param string $kind */ public function setKind($kind) { @@ -134,7 +170,10 @@ public function getKind() return $this->kind; } /** - * @param string + * If present, only apply this notification configuration to object names that + * begin with this prefix. + * + * @param string $objectNamePrefix */ public function setObjectNamePrefix($objectNamePrefix) { @@ -148,7 +187,9 @@ public function getObjectNamePrefix() return $this->objectNamePrefix; } /** - * @param string + * The desired content of the Payload. + * + * @param string $payloadFormat */ public function setPayloadFormat($payloadFormat) { @@ -162,7 +203,9 @@ public function getPayloadFormat() return $this->payloadFormat; } /** - * @param string + * The canonical URL of this notification. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -176,7 +219,10 @@ public function getSelfLink() return $this->selfLink; } /** - * @param string + * The Cloud PubSub topic to which this subscription publishes. Formatted as: + * '//pubsub.googleapis.com/projects/{project-identifier}/topics/{my-topic}' + * + * @param string $topic */ public function setTopic($topic) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Notifications.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Notifications.php index c97459dac..91efa8e07 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Notifications.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Notifications.php @@ -23,12 +23,17 @@ class Notifications extends \Google\Collection protected $itemsType = Notification::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of notifications, this is always + * storage#notifications. + * * @var string */ public $kind; /** - * @param Notification[] + * The list of items. + * + * @param Notification[] $items */ public function setItems($items) { @@ -42,7 +47,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of notifications, this is always + * storage#notifications. + * + * @param string $kind */ public function setKind($kind) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControl.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControl.php index 56ea5b724..16afbda94 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControl.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControl.php @@ -20,58 +20,91 @@ class ObjectAccessControl extends \Google\Model { /** + * The name of the bucket. + * * @var string */ public $bucket; /** + * The domain associated with the entity, if any. + * * @var string */ public $domain; /** + * The email address associated with the entity, if any. + * * @var string */ public $email; /** + * The entity holding the permission, in one of the following forms: - user- + * userId - user-email - group-groupId - group-email - domain-domain - + * project-team-projectId - allUsers - allAuthenticatedUsers Examples: - + * The user liz@example.com would be user-liz@example.com. - The group + * example@googlegroups.com would be group-example@googlegroups.com. - To + * refer to all members of the Google Apps for Business domain example.com, + * the entity would be domain-example.com. + * * @var string */ public $entity; /** + * The ID for the entity, if any. + * * @var string */ public $entityId; /** + * HTTP 1.1 Entity tag for the access-control entry. + * * @var string */ public $etag; /** + * The content generation of the object, if applied to an object. + * * @var string */ public $generation; /** + * The ID of the access-control entry. + * * @var string */ public $id; /** + * The kind of item this is. For object access control entries, this is always + * storage#objectAccessControl. + * * @var string */ public $kind; /** + * The name of the object, if applied to an object. + * * @var string */ public $object; protected $projectTeamType = ObjectAccessControlProjectTeam::class; protected $projectTeamDataType = ''; /** + * The access permission for the entity. + * * @var string */ public $role; /** + * The link to this access-control entry. + * * @var string */ public $selfLink; /** - * @param string + * The name of the bucket. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -85,7 +118,9 @@ public function getBucket() return $this->bucket; } /** - * @param string + * The domain associated with the entity, if any. + * + * @param string $domain */ public function setDomain($domain) { @@ -99,7 +134,9 @@ public function getDomain() return $this->domain; } /** - * @param string + * The email address associated with the entity, if any. + * + * @param string $email */ public function setEmail($email) { @@ -113,7 +150,15 @@ public function getEmail() return $this->email; } /** - * @param string + * The entity holding the permission, in one of the following forms: - user- + * userId - user-email - group-groupId - group-email - domain-domain - + * project-team-projectId - allUsers - allAuthenticatedUsers Examples: - + * The user liz@example.com would be user-liz@example.com. - The group + * example@googlegroups.com would be group-example@googlegroups.com. - To + * refer to all members of the Google Apps for Business domain example.com, + * the entity would be domain-example.com. + * + * @param string $entity */ public function setEntity($entity) { @@ -127,7 +172,9 @@ public function getEntity() return $this->entity; } /** - * @param string + * The ID for the entity, if any. + * + * @param string $entityId */ public function setEntityId($entityId) { @@ -141,7 +188,9 @@ public function getEntityId() return $this->entityId; } /** - * @param string + * HTTP 1.1 Entity tag for the access-control entry. + * + * @param string $etag */ public function setEtag($etag) { @@ -155,7 +204,9 @@ public function getEtag() return $this->etag; } /** - * @param string + * The content generation of the object, if applied to an object. + * + * @param string $generation */ public function setGeneration($generation) { @@ -169,7 +220,9 @@ public function getGeneration() return $this->generation; } /** - * @param string + * The ID of the access-control entry. + * + * @param string $id */ public function setId($id) { @@ -183,7 +236,10 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For object access control entries, this is always + * storage#objectAccessControl. + * + * @param string $kind */ public function setKind($kind) { @@ -197,7 +253,9 @@ public function getKind() return $this->kind; } /** - * @param string + * The name of the object, if applied to an object. + * + * @param string $object */ public function setObject($object) { @@ -211,7 +269,9 @@ public function getObject() return $this->object; } /** - * @param ObjectAccessControlProjectTeam + * The project team associated with the entity, if any. + * + * @param ObjectAccessControlProjectTeam $projectTeam */ public function setProjectTeam(ObjectAccessControlProjectTeam $projectTeam) { @@ -225,7 +285,9 @@ public function getProjectTeam() return $this->projectTeam; } /** - * @param string + * The access permission for the entity. + * + * @param string $role */ public function setRole($role) { @@ -239,7 +301,9 @@ public function getRole() return $this->role; } /** - * @param string + * The link to this access-control entry. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControlProjectTeam.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControlProjectTeam.php index 3c758e8d2..11f6dfcf5 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControlProjectTeam.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControlProjectTeam.php @@ -20,16 +20,22 @@ class ObjectAccessControlProjectTeam extends \Google\Model { /** + * The project number. + * * @var string */ public $projectNumber; /** + * The team. + * * @var string */ public $team; /** - * @param string + * The project number. + * + * @param string $projectNumber */ public function setProjectNumber($projectNumber) { @@ -43,7 +49,9 @@ public function getProjectNumber() return $this->projectNumber; } /** - * @param string + * The team. + * + * @param string $team */ public function setTeam($team) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControls.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControls.php index 18339b2ed..bc9bd9a3b 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControls.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectAccessControls.php @@ -23,12 +23,17 @@ class ObjectAccessControls extends \Google\Collection protected $itemsType = ObjectAccessControl::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of object access control entries, this + * is always storage#objectAccessControls. + * * @var string */ public $kind; /** - * @param ObjectAccessControl[] + * The list of items. + * + * @param ObjectAccessControl[] $items */ public function setItems($items) { @@ -42,7 +47,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of object access control entries, this + * is always storage#objectAccessControls. + * + * @param string $kind */ public function setKind($kind) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectCustomContextPayload.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectCustomContextPayload.php new file mode 100644 index 000000000..fceaa0e50 --- /dev/null +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ObjectCustomContextPayload.php @@ -0,0 +1,92 @@ +createTime = $createTime; + } + /** + * @return string + */ + public function getCreateTime() + { + return $this->createTime; + } + /** + * The time at which the object context was last updated in RFC 3339 format. + * + * @param string $updateTime + */ + public function setUpdateTime($updateTime) + { + $this->updateTime = $updateTime; + } + /** + * @return string + */ + public function getUpdateTime() + { + return $this->updateTime; + } + /** + * The value of the object context. + * + * @param string $value + */ + public function setValue($value) + { + $this->value = $value; + } + /** + * @return string + */ + public function getValue() + { + return $this->value; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ObjectCustomContextPayload::class, 'Google_Service_Storage_ObjectCustomContextPayload'); diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Objects.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Objects.php index 8cf793556..df9caa03b 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Objects.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Objects.php @@ -23,20 +23,31 @@ class Objects extends \Google\Collection protected $itemsType = StorageObject::class; protected $itemsDataType = 'array'; /** + * The kind of item this is. For lists of objects, this is always + * storage#objects. + * * @var string */ public $kind; /** + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * * @var string */ public $nextPageToken; /** + * The list of prefixes of objects matching-but-not-listed up to and including + * the requested delimiter. + * * @var string[] */ public $prefixes; /** - * @param StorageObject[] + * The list of items. + * + * @param StorageObject[] $items */ public function setItems($items) { @@ -50,7 +61,10 @@ public function getItems() return $this->items; } /** - * @param string + * The kind of item this is. For lists of objects, this is always + * storage#objects. + * + * @param string $kind */ public function setKind($kind) { @@ -64,7 +78,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The continuation token, used to page through large result sets. Provide + * this value in a subsequent request to return the next page of results. + * + * @param string $nextPageToken */ public function setNextPageToken($nextPageToken) { @@ -78,7 +95,10 @@ public function getNextPageToken() return $this->nextPageToken; } /** - * @param string[] + * The list of prefixes of objects matching-but-not-listed up to and including + * the requested delimiter. + * + * @param string[] $prefixes */ public function setPrefixes($prefixes) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Policy.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Policy.php index 81cd3fc7c..95b903e36 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Policy.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Policy.php @@ -23,24 +23,42 @@ class Policy extends \Google\Collection protected $bindingsType = PolicyBindings::class; protected $bindingsDataType = 'array'; /** + * HTTP 1.1 Entity tag for the policy. + * * @var string */ public $etag; /** + * The kind of item this is. For policies, this is always storage#policy. This + * field is ignored on input. + * * @var string */ public $kind; /** + * The ID of the resource to which this policy belongs. Will be of the form + * projects/_/buckets/bucket for buckets, + * projects/_/buckets/bucket/objects/object for objects, and + * projects/_/buckets/bucket/managedFolders/managedFolder. A specific + * generation may be specified by appending #generationNumber to the end of + * the object name, e.g. projects/_/buckets/my-bucket/objects/data.txt#17. The + * current generation can be denoted with #0. This field is ignored on input. + * * @var string */ public $resourceId; /** + * The IAM policy format version. + * * @var int */ public $version; /** - * @param PolicyBindings[] + * An association between a role, which comes with a set of permissions, and + * members who may assume that role. + * + * @param PolicyBindings[] $bindings */ public function setBindings($bindings) { @@ -54,7 +72,9 @@ public function getBindings() return $this->bindings; } /** - * @param string + * HTTP 1.1 Entity tag for the policy. + * + * @param string $etag */ public function setEtag($etag) { @@ -68,7 +88,10 @@ public function getEtag() return $this->etag; } /** - * @param string + * The kind of item this is. For policies, this is always storage#policy. This + * field is ignored on input. + * + * @param string $kind */ public function setKind($kind) { @@ -82,7 +105,15 @@ public function getKind() return $this->kind; } /** - * @param string + * The ID of the resource to which this policy belongs. Will be of the form + * projects/_/buckets/bucket for buckets, + * projects/_/buckets/bucket/objects/object for objects, and + * projects/_/buckets/bucket/managedFolders/managedFolder. A specific + * generation may be specified by appending #generationNumber to the end of + * the object name, e.g. projects/_/buckets/my-bucket/objects/data.txt#17. The + * current generation can be denoted with #0. This field is ignored on input. + * + * @param string $resourceId */ public function setResourceId($resourceId) { @@ -96,7 +127,9 @@ public function getResourceId() return $this->resourceId; } /** - * @param int + * The IAM policy format version. + * + * @param int $version */ public function setVersion($version) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/PolicyBindings.php b/lib/Google/vendor/google/apiclient-services/src/Storage/PolicyBindings.php index 3ec9e32bd..956cda807 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/PolicyBindings.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/PolicyBindings.php @@ -23,16 +23,60 @@ class PolicyBindings extends \Google\Collection protected $conditionType = Expr::class; protected $conditionDataType = ''; /** + * A collection of identifiers for members who may assume the provided role. + * Recognized identifiers are as follows: - allUsers - A special identifier + * that represents anyone on the internet; with or without a Google account. + * - allAuthenticatedUsers - A special identifier that represents anyone who + * is authenticated with a Google account or a service account. - + * user:emailid - An email address that represents a specific account. For + * example, user:alice@gmail.com or user:joe@example.com. - + * serviceAccount:emailid - An email address that represents a service + * account. For example, serviceAccount:my-other- + * app@appspot.gserviceaccount.com . - group:emailid - An email address that + * represents a Google group. For example, group:admins@example.com. - + * domain:domain - A Google Apps domain name that represents all the users of + * that domain. For example, domain:google.com or domain:example.com. - + * projectOwner:projectid - Owners of the given project. For example, + * projectOwner:my-example-project - projectEditor:projectid - Editors of + * the given project. For example, projectEditor:my-example-project - + * projectViewer:projectid - Viewers of the given project. For example, + * projectViewer:my-example-project + * * @var string[] */ public $members; /** + * The role to which members belong. Two types of roles are supported: new IAM + * roles, which grant permissions that do not map directly to those provided + * by ACLs, and legacy IAM roles, which do map directly to ACL permissions. + * All roles are of the format roles/storage.specificRole. The new IAM roles + * are: - roles/storage.admin - Full control of Google Cloud Storage + * resources. - roles/storage.objectViewer - Read-Only access to Google + * Cloud Storage objects. - roles/storage.objectCreator - Access to create + * objects in Google Cloud Storage. - roles/storage.objectAdmin - Full + * control of Google Cloud Storage objects. The legacy IAM roles are: - + * roles/storage.legacyObjectReader - Read-only access to objects without + * listing. Equivalent to an ACL entry on an object with the READER role. - + * roles/storage.legacyObjectOwner - Read/write access to existing objects + * without listing. Equivalent to an ACL entry on an object with the OWNER + * role. - roles/storage.legacyBucketReader - Read access to buckets with + * object listing. Equivalent to an ACL entry on a bucket with the READER + * role. - roles/storage.legacyBucketWriter - Read access to buckets with + * object listing/creation/deletion. Equivalent to an ACL entry on a bucket + * with the WRITER role. - roles/storage.legacyBucketOwner - Read and write + * access to existing buckets with object listing/creation/deletion. + * Equivalent to an ACL entry on a bucket with the OWNER role. + * * @var string */ public $role; /** - * @param Expr + * The condition that is associated with this binding. NOTE: an unsatisfied + * condition will not allow user access via current binding. Different + * bindings, including their conditions, are examined independently. + * + * @param Expr $condition */ public function setCondition(Expr $condition) { @@ -46,7 +90,26 @@ public function getCondition() return $this->condition; } /** - * @param string[] + * A collection of identifiers for members who may assume the provided role. + * Recognized identifiers are as follows: - allUsers - A special identifier + * that represents anyone on the internet; with or without a Google account. + * - allAuthenticatedUsers - A special identifier that represents anyone who + * is authenticated with a Google account or a service account. - + * user:emailid - An email address that represents a specific account. For + * example, user:alice@gmail.com or user:joe@example.com. - + * serviceAccount:emailid - An email address that represents a service + * account. For example, serviceAccount:my-other- + * app@appspot.gserviceaccount.com . - group:emailid - An email address that + * represents a Google group. For example, group:admins@example.com. - + * domain:domain - A Google Apps domain name that represents all the users of + * that domain. For example, domain:google.com or domain:example.com. - + * projectOwner:projectid - Owners of the given project. For example, + * projectOwner:my-example-project - projectEditor:projectid - Editors of + * the given project. For example, projectEditor:my-example-project - + * projectViewer:projectid - Viewers of the given project. For example, + * projectViewer:my-example-project + * + * @param string[] $members */ public function setMembers($members) { @@ -60,7 +123,28 @@ public function getMembers() return $this->members; } /** - * @param string + * The role to which members belong. Two types of roles are supported: new IAM + * roles, which grant permissions that do not map directly to those provided + * by ACLs, and legacy IAM roles, which do map directly to ACL permissions. + * All roles are of the format roles/storage.specificRole. The new IAM roles + * are: - roles/storage.admin - Full control of Google Cloud Storage + * resources. - roles/storage.objectViewer - Read-Only access to Google + * Cloud Storage objects. - roles/storage.objectCreator - Access to create + * objects in Google Cloud Storage. - roles/storage.objectAdmin - Full + * control of Google Cloud Storage objects. The legacy IAM roles are: - + * roles/storage.legacyObjectReader - Read-only access to objects without + * listing. Equivalent to an ACL entry on an object with the READER role. - + * roles/storage.legacyObjectOwner - Read/write access to existing objects + * without listing. Equivalent to an ACL entry on an object with the OWNER + * role. - roles/storage.legacyBucketReader - Read access to buckets with + * object listing. Equivalent to an ACL entry on a bucket with the READER + * role. - roles/storage.legacyBucketWriter - Read access to buckets with + * object listing/creation/deletion. Equivalent to an ACL entry on a bucket + * with the WRITER role. - roles/storage.legacyBucketOwner - Read and write + * access to existing buckets with object listing/creation/deletion. + * Equivalent to an ACL entry on a bucket with the OWNER role. + * + * @param string $role */ public function setRole($role) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequest.php b/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequest.php index 257afce4d..06e3b07e3 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequest.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequest.php @@ -22,16 +22,23 @@ class RelocateBucketRequest extends \Google\Model protected $destinationCustomPlacementConfigType = RelocateBucketRequestDestinationCustomPlacementConfig::class; protected $destinationCustomPlacementConfigDataType = ''; /** + * The new location the bucket will be relocated to. + * * @var string */ public $destinationLocation; /** + * If true, validate the operation, but do not actually relocate the bucket. + * * @var bool */ public $validateOnly; /** - * @param RelocateBucketRequestDestinationCustomPlacementConfig + * The bucket's new custom placement configuration if relocating to a Custom + * Dual Region. + * + * @param RelocateBucketRequestDestinationCustomPlacementConfig $destinationCustomPlacementConfig */ public function setDestinationCustomPlacementConfig(RelocateBucketRequestDestinationCustomPlacementConfig $destinationCustomPlacementConfig) { @@ -45,7 +52,9 @@ public function getDestinationCustomPlacementConfig() return $this->destinationCustomPlacementConfig; } /** - * @param string + * The new location the bucket will be relocated to. + * + * @param string $destinationLocation */ public function setDestinationLocation($destinationLocation) { @@ -59,7 +68,9 @@ public function getDestinationLocation() return $this->destinationLocation; } /** - * @param bool + * If true, validate the operation, but do not actually relocate the bucket. + * + * @param bool $validateOnly */ public function setValidateOnly($validateOnly) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequestDestinationCustomPlacementConfig.php b/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequestDestinationCustomPlacementConfig.php index a68be2988..8f7220476 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequestDestinationCustomPlacementConfig.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/RelocateBucketRequestDestinationCustomPlacementConfig.php @@ -21,12 +21,16 @@ class RelocateBucketRequestDestinationCustomPlacementConfig extends \Google\Coll { protected $collection_key = 'dataLocations'; /** + * The list of regional locations in which data is placed. + * * @var string[] */ public $dataLocations; /** - * @param string[] + * The list of regional locations in which data is placed. + * + * @param string[] $dataLocations */ public function setDataLocations($dataLocations) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Buckets.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Buckets.php index 3816df7c5..ab960a20c 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Buckets.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Buckets.php @@ -165,6 +165,8 @@ public function insert($project, Bucket $postBody, $optParams = []) * @opt_param string prefix Filter results to buckets whose names begin with * this prefix. * @opt_param string projection Set of properties to return. Defaults to noAcl. + * @opt_param bool returnPartialSuccess If true, return a list of bucket + * resource names for buckets that are in unreachable locations. * @opt_param bool softDeleted If true, only soft-deleted bucket versions will * be returned. The default is false. For more information, see [Soft * Delete](https://cloud.google.com/storage/docs/soft-delete). diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Objects.php b/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Objects.php index 056135e53..2168ec552 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Objects.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/Resource/Objects.php @@ -316,6 +316,9 @@ public function insert($bucket, StorageObject $postBody, $optParams = []) * lexicographically before endOffset. If startOffset is also set, the objects * listed will have names between startOffset (inclusive) and endOffset * (exclusive). + * @opt_param string filter Filter the returned objects. Currently only + * supported for the contexts field. If delimiter is set, the returned prefixes + * are exempt from this filter. * @opt_param bool includeFoldersAsPrefixes Only applicable if delimiter is set * to '/'. If true, will also include folders and managed folders (besides * objects) in the returned prefixes. diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/RewriteResponse.php b/lib/Google/vendor/google/apiclient-services/src/Storage/RewriteResponse.php index 8582e7700..07c17272d 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/RewriteResponse.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/RewriteResponse.php @@ -20,30 +20,47 @@ class RewriteResponse extends \Google\Model { /** + * true if the copy is finished; otherwise, false if the copy is in progress. + * This property is always present in the response. + * * @var bool */ public $done; /** + * The kind of item this is. + * * @var string */ public $kind; /** + * The total size of the object being copied in bytes. This property is always + * present in the response. + * * @var string */ public $objectSize; protected $resourceType = StorageObject::class; protected $resourceDataType = ''; /** + * A token to use in subsequent requests to continue copying data. This token + * is present in the response only when there is more data to copy. + * * @var string */ public $rewriteToken; /** + * The total bytes written so far, which can be used to provide a waiting user + * with a progress indicator. This property is always present in the response. + * * @var string */ public $totalBytesRewritten; /** - * @param bool + * true if the copy is finished; otherwise, false if the copy is in progress. + * This property is always present in the response. + * + * @param bool $done */ public function setDone($done) { @@ -57,7 +74,9 @@ public function getDone() return $this->done; } /** - * @param string + * The kind of item this is. + * + * @param string $kind */ public function setKind($kind) { @@ -71,7 +90,10 @@ public function getKind() return $this->kind; } /** - * @param string + * The total size of the object being copied in bytes. This property is always + * present in the response. + * + * @param string $objectSize */ public function setObjectSize($objectSize) { @@ -85,7 +107,10 @@ public function getObjectSize() return $this->objectSize; } /** - * @param StorageObject + * A resource containing the metadata for the copied-to object. This property + * is present in the response only when copying completes. + * + * @param StorageObject $resource */ public function setResource(StorageObject $resource) { @@ -99,7 +124,10 @@ public function getResource() return $this->resource; } /** - * @param string + * A token to use in subsequent requests to continue copying data. This token + * is present in the response only when there is more data to copy. + * + * @param string $rewriteToken */ public function setRewriteToken($rewriteToken) { @@ -113,7 +141,10 @@ public function getRewriteToken() return $this->rewriteToken; } /** - * @param string + * The total bytes written so far, which can be used to provide a waiting user + * with a progress indicator. This property is always present in the response. + * + * @param string $totalBytesRewritten */ public function setTotalBytesRewritten($totalBytesRewritten) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/ServiceAccount.php b/lib/Google/vendor/google/apiclient-services/src/Storage/ServiceAccount.php index d65e5c5c0..360c7dfea 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/ServiceAccount.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/ServiceAccount.php @@ -23,16 +23,23 @@ class ServiceAccount extends \Google\Model "emailAddress" => "email_address", ]; /** + * The ID of the notification. + * * @var string */ public $emailAddress; /** + * The kind of item this is. For notifications, this is always + * storage#notification. + * * @var string */ public $kind; /** - * @param string + * The ID of the notification. + * + * @param string $emailAddress */ public function setEmailAddress($emailAddress) { @@ -46,7 +53,10 @@ public function getEmailAddress() return $this->emailAddress; } /** - * @param string + * The kind of item this is. For notifications, this is always + * storage#notification. + * + * @param string $kind */ public function setKind($kind) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObject.php b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObject.php index 8f4b75b0d..910d4d5b4 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObject.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObject.php @@ -23,146 +23,261 @@ class StorageObject extends \Google\Collection protected $aclType = ObjectAccessControl::class; protected $aclDataType = 'array'; /** + * The name of the bucket containing this object. + * * @var string */ public $bucket; /** + * Cache-Control directive for the object data. If omitted, and the object is + * accessible to all anonymous users, the default will be public, max- + * age=3600. + * * @var string */ public $cacheControl; /** + * Number of underlying components that make up this object. Components are + * accumulated by compose operations. + * * @var int */ public $componentCount; /** + * Content-Disposition of the object data. + * * @var string */ public $contentDisposition; /** + * Content-Encoding of the object data. + * * @var string */ public $contentEncoding; /** + * Content-Language of the object data. + * * @var string */ public $contentLanguage; /** + * Content-Type of the object data. If an object is stored without a Content- + * Type, it is served as application/octet-stream. + * * @var string */ public $contentType; - /** + protected $contextsType = StorageObjectContexts::class; + protected $contextsDataType = ''; + /** + * CRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 + * in big-endian byte order. For more information about using the CRC32c + * checksum, see [Data Validation and Change + * Detection](https://cloud.google.com/storage/docs/data-validation). + * * @var string */ public $crc32c; /** + * A timestamp in RFC 3339 format specified by the user for an object. + * * @var string */ public $customTime; protected $customerEncryptionType = StorageObjectCustomerEncryption::class; protected $customerEncryptionDataType = ''; /** + * HTTP 1.1 Entity tag for the object. + * * @var string */ public $etag; /** + * Whether an object is under event-based hold. Event-based hold is a way to + * retain objects until an event occurs, which is signified by the hold's + * release (i.e. this value is set to false). After being released (set to + * false), such objects will be subject to bucket-level retention (if any). + * One sample use case of this flag is for banks to hold loan documents for at + * least 3 years after loan is paid in full. Here, bucket-level retention is 3 + * years and the event is the loan being paid in full. In this example, these + * objects will be held intact for any number of years until the event has + * occurred (event-based hold on the object is released) and then 3 more years + * after that. That means retention duration of the objects begins from the + * moment event-based hold transitioned from true to false. + * * @var bool */ public $eventBasedHold; /** + * The content generation of this object. Used for object versioning. + * * @var string */ public $generation; /** + * This is the time (in the future) when the soft-deleted object will no + * longer be restorable. It is equal to the soft delete time plus the current + * soft delete retention duration of the bucket. + * * @var string */ public $hardDeleteTime; /** + * The ID of the object, including the bucket name, object name, and + * generation number. + * * @var string */ public $id; /** + * The kind of item this is. For objects, this is always storage#object. + * * @var string */ public $kind; /** + * Not currently supported. Specifying the parameter causes the request to + * fail with status code 400 - Bad Request. + * * @var string */ public $kmsKeyName; /** + * MD5 hash of the data; encoded using base64. For more information about + * using the MD5 hash, see [Data Validation and Change + * Detection](https://cloud.google.com/storage/docs/data-validation). + * * @var string */ public $md5Hash; /** + * Media download link. + * * @var string */ public $mediaLink; /** + * User-provided metadata, in key/value pairs. + * * @var string[] */ public $metadata; /** + * The version of the metadata for this object at this generation. Used for + * preconditions and for detecting changes in metadata. A metageneration + * number is only meaningful in the context of a particular generation of a + * particular object. + * * @var string */ public $metageneration; /** + * The name of the object. Required if not specified by URL parameter. + * * @var string */ public $name; protected $ownerType = StorageObjectOwner::class; protected $ownerDataType = ''; /** + * Restore token used to differentiate deleted objects with the same name and + * generation. This field is only returned for deleted objects in hierarchical + * namespace buckets. + * * @var string */ public $restoreToken; protected $retentionType = StorageObjectRetention::class; protected $retentionDataType = ''; /** + * A server-determined value that specifies the earliest time that the + * object's retention period expires. This value is in RFC 3339 format. Note + * 1: This field is not provided for objects with an active event-based hold, + * since retention expiration is unknown until the hold is removed. Note 2: + * This value can be provided even when temporary hold is set (so that the + * user can reason about policy without having to first unset the temporary + * hold). + * * @var string */ public $retentionExpirationTime; /** + * The link to this object. + * * @var string */ public $selfLink; /** + * Content-Length of the data in bytes. + * * @var string */ public $size; /** + * The time at which the object became soft-deleted in RFC 3339 format. + * * @var string */ public $softDeleteTime; /** + * Storage class of the object. + * * @var string */ public $storageClass; /** + * Whether an object is under temporary hold. While this flag is set to true, + * the object is protected against deletion and overwrites. A common use case + * of this flag is regulatory investigations where objects need to be retained + * while the investigation is ongoing. Note that unlike event-based hold, + * temporary hold does not impact retention expiration time of an object. + * * @var bool */ public $temporaryHold; /** + * The creation time of the object in RFC 3339 format. + * * @var string */ public $timeCreated; /** + * The time at which the object became noncurrent in RFC 3339 format. Will be + * returned if and only if this version of the object has been deleted. + * * @var string */ public $timeDeleted; /** + * The time when the object was finalized. + * * @var string */ public $timeFinalized; /** + * The time at which the object's storage class was last changed. When the + * object is initially created, it will be set to timeCreated. + * * @var string */ public $timeStorageClassUpdated; /** + * The modification time of the object metadata in RFC 3339 format. Set + * initially to object creation time and then updated whenever any metadata of + * the object changes. This includes changes made by a requester, such as + * modifying custom metadata, as well as changes made by Cloud Storage on + * behalf of a requester, such as changing the storage class based on an + * Object Lifecycle Configuration. + * * @var string */ public $updated; /** - * @param ObjectAccessControl[] + * Access controls on the object. + * + * @param ObjectAccessControl[] $acl */ public function setAcl($acl) { @@ -176,7 +291,9 @@ public function getAcl() return $this->acl; } /** - * @param string + * The name of the bucket containing this object. + * + * @param string $bucket */ public function setBucket($bucket) { @@ -190,7 +307,11 @@ public function getBucket() return $this->bucket; } /** - * @param string + * Cache-Control directive for the object data. If omitted, and the object is + * accessible to all anonymous users, the default will be public, max- + * age=3600. + * + * @param string $cacheControl */ public function setCacheControl($cacheControl) { @@ -204,7 +325,10 @@ public function getCacheControl() return $this->cacheControl; } /** - * @param int + * Number of underlying components that make up this object. Components are + * accumulated by compose operations. + * + * @param int $componentCount */ public function setComponentCount($componentCount) { @@ -218,7 +342,9 @@ public function getComponentCount() return $this->componentCount; } /** - * @param string + * Content-Disposition of the object data. + * + * @param string $contentDisposition */ public function setContentDisposition($contentDisposition) { @@ -232,7 +358,9 @@ public function getContentDisposition() return $this->contentDisposition; } /** - * @param string + * Content-Encoding of the object data. + * + * @param string $contentEncoding */ public function setContentEncoding($contentEncoding) { @@ -246,7 +374,9 @@ public function getContentEncoding() return $this->contentEncoding; } /** - * @param string + * Content-Language of the object data. + * + * @param string $contentLanguage */ public function setContentLanguage($contentLanguage) { @@ -260,7 +390,10 @@ public function getContentLanguage() return $this->contentLanguage; } /** - * @param string + * Content-Type of the object data. If an object is stored without a Content- + * Type, it is served as application/octet-stream. + * + * @param string $contentType */ public function setContentType($contentType) { @@ -274,7 +407,30 @@ public function getContentType() return $this->contentType; } /** - * @param string + * User-defined or system-defined object contexts. Each object context is a + * key-payload pair, where the key provides the identification and the payload + * holds the associated value and additional metadata. + * + * @param StorageObjectContexts $contexts + */ + public function setContexts(StorageObjectContexts $contexts) + { + $this->contexts = $contexts; + } + /** + * @return StorageObjectContexts + */ + public function getContexts() + { + return $this->contexts; + } + /** + * CRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 + * in big-endian byte order. For more information about using the CRC32c + * checksum, see [Data Validation and Change + * Detection](https://cloud.google.com/storage/docs/data-validation). + * + * @param string $crc32c */ public function setCrc32c($crc32c) { @@ -288,7 +444,9 @@ public function getCrc32c() return $this->crc32c; } /** - * @param string + * A timestamp in RFC 3339 format specified by the user for an object. + * + * @param string $customTime */ public function setCustomTime($customTime) { @@ -302,7 +460,10 @@ public function getCustomTime() return $this->customTime; } /** - * @param StorageObjectCustomerEncryption + * Metadata of customer-supplied encryption key, if the object is encrypted by + * such a key. + * + * @param StorageObjectCustomerEncryption $customerEncryption */ public function setCustomerEncryption(StorageObjectCustomerEncryption $customerEncryption) { @@ -316,7 +477,9 @@ public function getCustomerEncryption() return $this->customerEncryption; } /** - * @param string + * HTTP 1.1 Entity tag for the object. + * + * @param string $etag */ public function setEtag($etag) { @@ -330,7 +493,19 @@ public function getEtag() return $this->etag; } /** - * @param bool + * Whether an object is under event-based hold. Event-based hold is a way to + * retain objects until an event occurs, which is signified by the hold's + * release (i.e. this value is set to false). After being released (set to + * false), such objects will be subject to bucket-level retention (if any). + * One sample use case of this flag is for banks to hold loan documents for at + * least 3 years after loan is paid in full. Here, bucket-level retention is 3 + * years and the event is the loan being paid in full. In this example, these + * objects will be held intact for any number of years until the event has + * occurred (event-based hold on the object is released) and then 3 more years + * after that. That means retention duration of the objects begins from the + * moment event-based hold transitioned from true to false. + * + * @param bool $eventBasedHold */ public function setEventBasedHold($eventBasedHold) { @@ -344,7 +519,9 @@ public function getEventBasedHold() return $this->eventBasedHold; } /** - * @param string + * The content generation of this object. Used for object versioning. + * + * @param string $generation */ public function setGeneration($generation) { @@ -358,7 +535,11 @@ public function getGeneration() return $this->generation; } /** - * @param string + * This is the time (in the future) when the soft-deleted object will no + * longer be restorable. It is equal to the soft delete time plus the current + * soft delete retention duration of the bucket. + * + * @param string $hardDeleteTime */ public function setHardDeleteTime($hardDeleteTime) { @@ -372,7 +553,10 @@ public function getHardDeleteTime() return $this->hardDeleteTime; } /** - * @param string + * The ID of the object, including the bucket name, object name, and + * generation number. + * + * @param string $id */ public function setId($id) { @@ -386,7 +570,9 @@ public function getId() return $this->id; } /** - * @param string + * The kind of item this is. For objects, this is always storage#object. + * + * @param string $kind */ public function setKind($kind) { @@ -400,7 +586,10 @@ public function getKind() return $this->kind; } /** - * @param string + * Not currently supported. Specifying the parameter causes the request to + * fail with status code 400 - Bad Request. + * + * @param string $kmsKeyName */ public function setKmsKeyName($kmsKeyName) { @@ -414,7 +603,11 @@ public function getKmsKeyName() return $this->kmsKeyName; } /** - * @param string + * MD5 hash of the data; encoded using base64. For more information about + * using the MD5 hash, see [Data Validation and Change + * Detection](https://cloud.google.com/storage/docs/data-validation). + * + * @param string $md5Hash */ public function setMd5Hash($md5Hash) { @@ -428,7 +621,9 @@ public function getMd5Hash() return $this->md5Hash; } /** - * @param string + * Media download link. + * + * @param string $mediaLink */ public function setMediaLink($mediaLink) { @@ -442,7 +637,9 @@ public function getMediaLink() return $this->mediaLink; } /** - * @param string[] + * User-provided metadata, in key/value pairs. + * + * @param string[] $metadata */ public function setMetadata($metadata) { @@ -456,7 +653,12 @@ public function getMetadata() return $this->metadata; } /** - * @param string + * The version of the metadata for this object at this generation. Used for + * preconditions and for detecting changes in metadata. A metageneration + * number is only meaningful in the context of a particular generation of a + * particular object. + * + * @param string $metageneration */ public function setMetageneration($metageneration) { @@ -470,7 +672,9 @@ public function getMetageneration() return $this->metageneration; } /** - * @param string + * The name of the object. Required if not specified by URL parameter. + * + * @param string $name */ public function setName($name) { @@ -484,7 +688,9 @@ public function getName() return $this->name; } /** - * @param StorageObjectOwner + * The owner of the object. This will always be the uploader of the object. + * + * @param StorageObjectOwner $owner */ public function setOwner(StorageObjectOwner $owner) { @@ -498,7 +704,11 @@ public function getOwner() return $this->owner; } /** - * @param string + * Restore token used to differentiate deleted objects with the same name and + * generation. This field is only returned for deleted objects in hierarchical + * namespace buckets. + * + * @param string $restoreToken */ public function setRestoreToken($restoreToken) { @@ -512,7 +722,9 @@ public function getRestoreToken() return $this->restoreToken; } /** - * @param StorageObjectRetention + * A collection of object level retention parameters. + * + * @param StorageObjectRetention $retention */ public function setRetention(StorageObjectRetention $retention) { @@ -526,7 +738,15 @@ public function getRetention() return $this->retention; } /** - * @param string + * A server-determined value that specifies the earliest time that the + * object's retention period expires. This value is in RFC 3339 format. Note + * 1: This field is not provided for objects with an active event-based hold, + * since retention expiration is unknown until the hold is removed. Note 2: + * This value can be provided even when temporary hold is set (so that the + * user can reason about policy without having to first unset the temporary + * hold). + * + * @param string $retentionExpirationTime */ public function setRetentionExpirationTime($retentionExpirationTime) { @@ -540,7 +760,9 @@ public function getRetentionExpirationTime() return $this->retentionExpirationTime; } /** - * @param string + * The link to this object. + * + * @param string $selfLink */ public function setSelfLink($selfLink) { @@ -554,7 +776,9 @@ public function getSelfLink() return $this->selfLink; } /** - * @param string + * Content-Length of the data in bytes. + * + * @param string $size */ public function setSize($size) { @@ -568,7 +792,9 @@ public function getSize() return $this->size; } /** - * @param string + * The time at which the object became soft-deleted in RFC 3339 format. + * + * @param string $softDeleteTime */ public function setSoftDeleteTime($softDeleteTime) { @@ -582,7 +808,9 @@ public function getSoftDeleteTime() return $this->softDeleteTime; } /** - * @param string + * Storage class of the object. + * + * @param string $storageClass */ public function setStorageClass($storageClass) { @@ -596,7 +824,13 @@ public function getStorageClass() return $this->storageClass; } /** - * @param bool + * Whether an object is under temporary hold. While this flag is set to true, + * the object is protected against deletion and overwrites. A common use case + * of this flag is regulatory investigations where objects need to be retained + * while the investigation is ongoing. Note that unlike event-based hold, + * temporary hold does not impact retention expiration time of an object. + * + * @param bool $temporaryHold */ public function setTemporaryHold($temporaryHold) { @@ -610,7 +844,9 @@ public function getTemporaryHold() return $this->temporaryHold; } /** - * @param string + * The creation time of the object in RFC 3339 format. + * + * @param string $timeCreated */ public function setTimeCreated($timeCreated) { @@ -624,7 +860,10 @@ public function getTimeCreated() return $this->timeCreated; } /** - * @param string + * The time at which the object became noncurrent in RFC 3339 format. Will be + * returned if and only if this version of the object has been deleted. + * + * @param string $timeDeleted */ public function setTimeDeleted($timeDeleted) { @@ -638,7 +877,9 @@ public function getTimeDeleted() return $this->timeDeleted; } /** - * @param string + * The time when the object was finalized. + * + * @param string $timeFinalized */ public function setTimeFinalized($timeFinalized) { @@ -652,7 +893,10 @@ public function getTimeFinalized() return $this->timeFinalized; } /** - * @param string + * The time at which the object's storage class was last changed. When the + * object is initially created, it will be set to timeCreated. + * + * @param string $timeStorageClassUpdated */ public function setTimeStorageClassUpdated($timeStorageClassUpdated) { @@ -666,7 +910,14 @@ public function getTimeStorageClassUpdated() return $this->timeStorageClassUpdated; } /** - * @param string + * The modification time of the object metadata in RFC 3339 format. Set + * initially to object creation time and then updated whenever any metadata of + * the object changes. This includes changes made by a requester, such as + * modifying custom metadata, as well as changes made by Cloud Storage on + * behalf of a requester, such as changing the storage class based on an + * Object Lifecycle Configuration. + * + * @param string $updated */ public function setUpdated($updated) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectContexts.php b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectContexts.php new file mode 100644 index 000000000..a6eab3c24 --- /dev/null +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectContexts.php @@ -0,0 +1,44 @@ +custom = $custom; + } + /** + * @return ObjectCustomContextPayload[] + */ + public function getCustom() + { + return $this->custom; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(StorageObjectContexts::class, 'Google_Service_Storage_StorageObjectContexts'); diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectCustomerEncryption.php b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectCustomerEncryption.php index b0c434f9e..9a21edbb3 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectCustomerEncryption.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectCustomerEncryption.php @@ -20,16 +20,22 @@ class StorageObjectCustomerEncryption extends \Google\Model { /** + * The encryption algorithm. + * * @var string */ public $encryptionAlgorithm; /** + * SHA256 hash value of the encryption key. + * * @var string */ public $keySha256; /** - * @param string + * The encryption algorithm. + * + * @param string $encryptionAlgorithm */ public function setEncryptionAlgorithm($encryptionAlgorithm) { @@ -43,7 +49,9 @@ public function getEncryptionAlgorithm() return $this->encryptionAlgorithm; } /** - * @param string + * SHA256 hash value of the encryption key. + * + * @param string $keySha256 */ public function setKeySha256($keySha256) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectOwner.php b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectOwner.php index 43979ff03..3eafc7a83 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectOwner.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectOwner.php @@ -20,16 +20,22 @@ class StorageObjectOwner extends \Google\Model { /** + * The entity, in the form user-userId. + * * @var string */ public $entity; /** + * The ID for the entity. + * * @var string */ public $entityId; /** - * @param string + * The entity, in the form user-userId. + * + * @param string $entity */ public function setEntity($entity) { @@ -43,7 +49,9 @@ public function getEntity() return $this->entity; } /** - * @param string + * The ID for the entity. + * + * @param string $entityId */ public function setEntityId($entityId) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectRetention.php b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectRetention.php index d871f9afa..80d8e27b6 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectRetention.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/StorageObjectRetention.php @@ -20,16 +20,23 @@ class StorageObjectRetention extends \Google\Model { /** + * The bucket's object retention mode, can only be Unlocked or Locked. + * * @var string */ public $mode; /** + * A time in RFC 3339 format until which object retention protects this + * object. + * * @var string */ public $retainUntilTime; /** - * @param string + * The bucket's object retention mode, can only be Unlocked or Locked. + * + * @param string $mode */ public function setMode($mode) { @@ -43,7 +50,10 @@ public function getMode() return $this->mode; } /** - * @param string + * A time in RFC 3339 format until which object retention protects this + * object. + * + * @param string $retainUntilTime */ public function setRetainUntilTime($retainUntilTime) { diff --git a/lib/Google/vendor/google/apiclient-services/src/Storage/TestIamPermissionsResponse.php b/lib/Google/vendor/google/apiclient-services/src/Storage/TestIamPermissionsResponse.php index 18310b1ad..023ba2a35 100644 --- a/lib/Google/vendor/google/apiclient-services/src/Storage/TestIamPermissionsResponse.php +++ b/lib/Google/vendor/google/apiclient-services/src/Storage/TestIamPermissionsResponse.php @@ -21,16 +21,40 @@ class TestIamPermissionsResponse extends \Google\Collection { protected $collection_key = 'permissions'; /** + * The kind of item this is. + * * @var string */ public $kind; /** + * The permissions held by the caller. Permissions are always of the format + * storage.resource.capability, where resource is one of buckets, objects, or + * managedFolders. The supported permissions are as follows: - + * storage.buckets.delete - Delete bucket. - storage.buckets.get - Read + * bucket metadata. - storage.buckets.getIamPolicy - Read bucket IAM policy. + * - storage.buckets.create - Create bucket. - storage.buckets.list - List + * buckets. - storage.buckets.setIamPolicy - Update bucket IAM policy. - + * storage.buckets.update - Update bucket metadata. - storage.objects.delete + * - Delete object. - storage.objects.get - Read object data and metadata. + * - storage.objects.getIamPolicy - Read object IAM policy. - + * storage.objects.create - Create object. - storage.objects.list - List + * objects. - storage.objects.setIamPolicy - Update object IAM policy. - + * storage.objects.update - Update object metadata. - + * storage.managedFolders.delete - Delete managed folder. - + * storage.managedFolders.get - Read managed folder metadata. - + * storage.managedFolders.getIamPolicy - Read managed folder IAM policy. - + * storage.managedFolders.create - Create managed folder. - + * storage.managedFolders.list - List managed folders. - + * storage.managedFolders.setIamPolicy - Update managed folder IAM policy. + * * @var string[] */ public $permissions; /** - * @param string + * The kind of item this is. + * + * @param string $kind */ public function setKind($kind) { @@ -44,7 +68,27 @@ public function getKind() return $this->kind; } /** - * @param string[] + * The permissions held by the caller. Permissions are always of the format + * storage.resource.capability, where resource is one of buckets, objects, or + * managedFolders. The supported permissions are as follows: - + * storage.buckets.delete - Delete bucket. - storage.buckets.get - Read + * bucket metadata. - storage.buckets.getIamPolicy - Read bucket IAM policy. + * - storage.buckets.create - Create bucket. - storage.buckets.list - List + * buckets. - storage.buckets.setIamPolicy - Update bucket IAM policy. - + * storage.buckets.update - Update bucket metadata. - storage.objects.delete + * - Delete object. - storage.objects.get - Read object data and metadata. + * - storage.objects.getIamPolicy - Read object IAM policy. - + * storage.objects.create - Create object. - storage.objects.list - List + * objects. - storage.objects.setIamPolicy - Update object IAM policy. - + * storage.objects.update - Update object metadata. - + * storage.managedFolders.delete - Delete managed folder. - + * storage.managedFolders.get - Read managed folder metadata. - + * storage.managedFolders.getIamPolicy - Read managed folder IAM policy. - + * storage.managedFolders.create - Create managed folder. - + * storage.managedFolders.list - List managed folders. - + * storage.managedFolders.setIamPolicy - Update managed folder IAM policy. + * + * @param string[] $permissions */ public function setPermissions($permissions) { diff --git a/lib/Google/vendor/google/auth/README.md b/lib/Google/vendor/google/auth/README.md index 3331aebf5..a8d77d692 100644 --- a/lib/Google/vendor/google/auth/README.md +++ b/lib/Google/vendor/google/auth/README.md @@ -171,11 +171,19 @@ $jsonKey = ['key' => 'value']; // define the scopes for your API call $scopes = ['https://www.googleapis.com/auth/drive.readonly']; -// Load credentials -$creds = CredentialsLoader::makeCredentials($scopes, $jsonKey); +// Load credentials from JSON containing service account credentials. +$creds = new ServiceAccountCredentials($scopes, $jsonKey), + +// For other credentials types, create those classes explicitly using the +// "type" field in the JSON key, for example: +$creds = match ($jsonKey['type']) { + 'service_account' => new ServiceAccountCredentials($scope, $jsonKey), + 'authorized_user' => new UserRefreshCredentials($scope, $jsonKey), + default => throw new InvalidArgumentException('This application only supports service account and user account credentials'), +}; // optional caching -// $creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache); +$creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache); // create middleware $middleware = new AuthTokenMiddleware($creds); diff --git a/lib/Google/vendor/google/auth/VERSION b/lib/Google/vendor/google/auth/VERSION index f805cd6ed..5a5c7211d 100644 --- a/lib/Google/vendor/google/auth/VERSION +++ b/lib/Google/vendor/google/auth/VERSION @@ -1 +1 @@ -1.47.1 +1.50.0 diff --git a/lib/Google/vendor/google/auth/autoload.php b/lib/Google/vendor/google/auth/autoload.php deleted file mode 100644 index 1e13827f5..000000000 --- a/lib/Google/vendor/google/auth/autoload.php +++ /dev/null @@ -1,34 +0,0 @@ - 3) { - // Maximum class file path depth in this project is 3. - $classPath = array_slice($classPath, 0, 3); - } - $filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php'; - if (file_exists($filePath)) { - require_once $filePath; - } -} - -spl_autoload_register('oauth2client_php_autoload'); diff --git a/lib/Google/vendor/google/auth/composer.json b/lib/Google/vendor/google/auth/composer.json index 6dddd9a29..84c82d37e 100644 --- a/lib/Google/vendor/google/auth/composer.json +++ b/lib/Google/vendor/google/auth/composer.json @@ -9,8 +9,8 @@ "docs": "https://cloud.google.com/php/docs/reference/auth/latest" }, "require": { - "php": "^8.0", - "firebase/php-jwt": "^6.0", + "php": "^8.1", + "firebase/php-jwt": "^6.0||^7.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", "psr/http-message": "^1.1||^2.0", @@ -19,14 +19,15 @@ }, "require-dev": { "guzzlehttp/promises": "^2.0", - "squizlabs/php_codesniffer": "^3.5", + "squizlabs/php_codesniffer": "^4.0", "phpunit/phpunit": "^9.6", "phpspec/prophecy-phpunit": "^2.1", "sebastian/comparator": ">=1.2.3", "phpseclib/phpseclib": "^3.0.35", - "kelvinmo/simplejwt": "0.7.1", - "webmozart/assert": "^1.11", - "symfony/process": "^6.0||^7.0" + "kelvinmo/simplejwt": "^1.1.0", + "webmozart/assert": "^1.11||^2.0", + "symfony/process": "^6.0||^7.0", + "symfony/filesystem": "^6.3||^7.3" }, "suggest": { "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." diff --git a/lib/Google/vendor/google/auth/src/Cache/FileSystemCacheItemPool.php b/lib/Google/vendor/google/auth/src/Cache/FileSystemCacheItemPool.php index ee0651a4e..fb8a045b2 100644 --- a/lib/Google/vendor/google/auth/src/Cache/FileSystemCacheItemPool.php +++ b/lib/Google/vendor/google/auth/src/Cache/FileSystemCacheItemPool.php @@ -46,7 +46,9 @@ public function __construct(string $path) return; } - if (!mkdir($this->cachePath)) { + // Suppress the error for when the directory already exists because of a + // race condition + if (!@mkdir($this->cachePath, 0777, true) && !is_dir($this->cachePath)) { throw new ErrorException("Cache folder couldn't be created."); } } @@ -111,7 +113,7 @@ public function save(CacheItemInterface $item): bool $itemPath = $this->cacheFilePath($item->getKey()); $serializedItem = serialize($item->get()); - $result = file_put_contents($itemPath, $serializedItem); + $result = file_put_contents($itemPath, $serializedItem, LOCK_EX); // 0 bytes write is considered a successful operation if ($result === false) { diff --git a/lib/Google/vendor/google/auth/src/Cache/Item.php b/lib/Google/vendor/google/auth/src/Cache/Item.php deleted file mode 100644 index ff85afa71..000000000 --- a/lib/Google/vendor/google/auth/src/Cache/Item.php +++ /dev/null @@ -1,175 +0,0 @@ -key = $key; - } - - /** - * {@inheritdoc} - */ - public function getKey() - { - return $this->key; - } - - /** - * {@inheritdoc} - */ - public function get() - { - return $this->isHit() ? $this->value : null; - } - - /** - * {@inheritdoc} - */ - public function isHit() - { - if (!$this->isHit) { - return false; - } - - if ($this->expiration === null) { - return true; - } - - return $this->currentTime()->getTimestamp() < $this->expiration->getTimestamp(); - } - - /** - * {@inheritdoc} - */ - public function set($value) - { - $this->isHit = true; - $this->value = $value; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function expiresAt($expiration) - { - if ($this->isValidExpiration($expiration)) { - $this->expiration = $expiration; - - return $this; - } - - $error = sprintf( - 'Argument 1 passed to %s::expiresAt() must implement interface DateTimeInterface, %s given', - get_class($this), - gettype($expiration) - ); - - throw new TypeError($error); - } - - /** - * {@inheritdoc} - */ - public function expiresAfter($time) - { - if (is_int($time)) { - $this->expiration = $this->currentTime()->add(new \DateInterval("PT{$time}S")); - } elseif ($time instanceof \DateInterval) { - $this->expiration = $this->currentTime()->add($time); - } elseif ($time === null) { - $this->expiration = $time; - } else { - $message = 'Argument 1 passed to %s::expiresAfter() must be an ' . - 'instance of DateInterval or of the type integer, %s given'; - $error = sprintf($message, get_class($this), gettype($time)); - - throw new TypeError($error); - } - - return $this; - } - - /** - * Determines if an expiration is valid based on the rules defined by PSR6. - * - * @param mixed $expiration - * @return bool - */ - private function isValidExpiration($expiration) - { - if ($expiration === null) { - return true; - } - - if ($expiration instanceof DateTimeInterface) { - return true; - } - - return false; - } - - /** - * @return DateTime - */ - protected function currentTime() - { - return new DateTime('now', new DateTimeZone('UTC')); - } -} diff --git a/lib/Google/vendor/google/auth/src/Cache/SysVCacheItemPool.php b/lib/Google/vendor/google/auth/src/Cache/SysVCacheItemPool.php index 7821d6b09..3b0a2488b 100644 --- a/lib/Google/vendor/google/auth/src/Cache/SysVCacheItemPool.php +++ b/lib/Google/vendor/google/auth/src/Cache/SysVCacheItemPool.php @@ -18,6 +18,8 @@ use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; +use SysvSemaphore; +use SysvSharedMemory; /** * SystemV shared memory based CacheItemPool implementation. @@ -32,6 +34,8 @@ class SysVCacheItemPool implements CacheItemPoolInterface const DEFAULT_PROJ = 'A'; + const DEFAULT_SEM_PROJ = 'B'; + const DEFAULT_MEMSIZE = 10000; const DEFAULT_PERM = 0600; @@ -61,6 +65,18 @@ class SysVCacheItemPool implements CacheItemPoolInterface */ private $hasLoadedItems = false; + /** + * @var SysvSemaphore|false + */ + private SysvSemaphore|false $semId = false; + + /** + * Maintain the process which is currently holding the semaphore to prevent deadlock. + * + * @var int|null + */ + private ?int $lockOwnerPid = null; + /** * Create a SystemV shared memory based CacheItemPool. * @@ -70,13 +86,16 @@ class SysVCacheItemPool implements CacheItemPoolInterface * @type int $variableKey The variable key for getting the data from the shared memory. **Defaults to** 1. * @type string $proj The project identifier for ftok. This needs to be a one character string. * **Defaults to** 'A'. + * @type string $semProj The project identifier for ftok to provide to `sem_get`. This needs to be a one + * character string. + * **Defaults to** 'B'. * @type int $memsize The memory size in bytes for shm_attach. **Defaults to** 10000. * @type int $perm The permission for shm_attach. **Defaults to** 0600. * } */ public function __construct($options = []) { - if (! extension_loaded('sysvshm')) { + if (!extension_loaded('sysvshm')) { throw new \RuntimeException( 'sysvshm extension is required to use this ItemPool' ); @@ -84,12 +103,20 @@ public function __construct($options = []) $this->options = $options + [ 'variableKey' => self::VAR_KEY, 'proj' => self::DEFAULT_PROJ, + 'semProj' => self::DEFAULT_SEM_PROJ, 'memsize' => self::DEFAULT_MEMSIZE, 'perm' => self::DEFAULT_PERM ]; $this->items = []; $this->deferredItems = []; $this->sysvKey = ftok(__FILE__, $this->options['proj']); + + // gracefully handle when `sysvsem` isn't loaded + // @TODO(v2): throw an exception when the extension isn't loaded + if (extension_loaded('sysvsem')) { + $semKey = ftok(__FILE__, $this->options['semProj']); + $this->semId = sem_get($semKey, 1, $this->options['perm'], true); + } } /** @@ -132,9 +159,17 @@ public function hasItem($key): bool */ public function clear(): bool { + if (!$this->acquireLock()) { + return false; + } + $this->items = []; $this->deferredItems = []; - return $this->saveCurrentItems(); + $ret = $this->saveCurrentItems(); + + $this->resetShm(); + $this->releaseLock(); + return $ret; } /** @@ -150,6 +185,10 @@ public function deleteItem($key): bool */ public function deleteItems(array $keys): bool { + if (!$this->acquireLock()) { + return false; + } + if (!$this->hasLoadedItems) { $this->loadItems(); } @@ -157,7 +196,11 @@ public function deleteItems(array $keys): bool foreach ($keys as $key) { unset($this->items[$key]); } - return $this->saveCurrentItems(); + $ret = $this->saveCurrentItems(); + + $this->resetShm(); + $this->releaseLock(); + return $ret; } /** @@ -165,12 +208,18 @@ public function deleteItems(array $keys): bool */ public function save(CacheItemInterface $item): bool { + if (!$this->acquireLock()) { + return false; + } + if (!$this->hasLoadedItems) { $this->loadItems(); } $this->items[$item->getKey()] = $item; - return $this->saveCurrentItems(); + $ret = $this->saveCurrentItems(); + $this->releaseLock(); + return $ret; } /** @@ -187,12 +236,18 @@ public function saveDeferred(CacheItemInterface $item): bool */ public function commit(): bool { + if (!$this->acquireLock()) { + return false; + } + foreach ($this->deferredItems as $item) { if ($this->save($item) === false) { + $this->releaseLock(); return false; } } $this->deferredItems = []; + $this->releaseLock(); return true; } @@ -203,20 +258,21 @@ public function commit(): bool */ private function saveCurrentItems() { - $shmid = shm_attach( - $this->sysvKey, - $this->options['memsize'], - $this->options['perm'] - ); - if ($shmid !== false) { - $ret = shm_put_var( + if (!$this->acquireLock()) { + return false; + } + + if (false !== $shmid = $this->attachShm()) { + $success = shm_put_var( $shmid, $this->options['variableKey'], $this->items ); shm_detach($shmid); - return $ret; + $this->releaseLock(); + return $success; } + $this->releaseLock(); return false; } @@ -227,22 +283,70 @@ private function saveCurrentItems() */ private function loadItems() { - $shmid = shm_attach( - $this->sysvKey, - $this->options['memsize'], - $this->options['perm'] - ); - if ($shmid !== false) { + if (!$this->acquireLock()) { + return false; + } + + if (false !== $shmid = $this->attachShm()) { $data = @shm_get_var($shmid, $this->options['variableKey']); - if (!empty($data)) { - $this->items = $data; - } else { - $this->items = []; - } + $this->items = $data ?: []; shm_detach($shmid); $this->hasLoadedItems = true; + $this->releaseLock(); + return true; + } + $this->releaseLock(); + return false; + } + + private function acquireLock(): bool + { + if ($this->semId === false) { + // if `sysvsem` isn't loaded, or if `sem_get` fails, return true + // this ensures BC with previous versions of the auth library. + // @TODO consider better handling when `sem_get` fails. + return true; + } + + $currentPid = getmypid(); + if ($this->lockOwnerPid === $currentPid) { + // We already have the lock + return true; + } + + if (sem_acquire($this->semId)) { + $this->lockOwnerPid = (int) $currentPid; return true; } return false; } + + private function releaseLock(): bool + { + if ($this->semId === false || $this->lockOwnerPid !== getmypid()) { + return true; + } + + $this->lockOwnerPid = null; + return sem_release($this->semId); + } + + private function resetShm(): void + { + // Remove the shared memory segment and semaphore when clearing the cache + $shmid = @shm_attach($this->sysvKey); + if ($shmid !== false) { + @shm_remove($shmid); + @shm_detach($shmid); + } + } + + private function attachShm(): SysvSharedMemory|false + { + return shm_attach( + $this->sysvKey, + $this->options['memsize'], + $this->options['perm'] + ); + } } diff --git a/lib/Google/vendor/google/auth/src/Credentials/ExternalAccountCredentials.php b/lib/Google/vendor/google/auth/src/Credentials/ExternalAccountCredentials.php index c0306ee80..afaf1ee3f 100644 --- a/lib/Google/vendor/google/auth/src/Credentials/ExternalAccountCredentials.php +++ b/lib/Google/vendor/google/auth/src/Credentials/ExternalAccountCredentials.php @@ -35,6 +35,15 @@ use GuzzleHttp\Psr7\Request; use InvalidArgumentException; +/** + * **IMPORTANT**: + * This class does not validate the credential configuration. A security + * risk occurs when a credential configuration configured with malicious urls + * is used. + * When the credential configuration is accepted from an + * untrusted source, you should validate it before creating this class. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + */ class ExternalAccountCredentials implements FetchAuthTokenInterface, UpdateMetadataInterface, diff --git a/lib/Google/vendor/google/auth/src/Credentials/ImpersonatedServiceAccountCredentials.php b/lib/Google/vendor/google/auth/src/Credentials/ImpersonatedServiceAccountCredentials.php index 8842cd17c..f4a339b2b 100644 --- a/lib/Google/vendor/google/auth/src/Credentials/ImpersonatedServiceAccountCredentials.php +++ b/lib/Google/vendor/google/auth/src/Credentials/ImpersonatedServiceAccountCredentials.php @@ -30,6 +30,15 @@ use InvalidArgumentException; use LogicException; +/** + * **IMPORTANT**: + * This class does not validate the credential configuration. A security + * risk occurs when a credential configuration configured with malicious urls + * is used. + * When the credential configuration is accepted from an + * untrusted source, you should validate it before creating this class. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + */ class ImpersonatedServiceAccountCredentials extends CredentialsLoader implements SignBlobInterface, GetUniverseDomainInterface @@ -78,11 +87,14 @@ class ImpersonatedServiceAccountCredentials extends CredentialsLoader implements * @type string[] $delegates The delegates to impersonate * } * @param string|null $targetAudience The audience to request an ID token. + * @param string|string[]|null $defaultScope The scopes to be used if no "scopes" field exists + * in the `$jsonKey`. */ public function __construct( string|array|null $scope, string|array $jsonKey, - private ?string $targetAudience = null + private ?string $targetAudience = null, + string|array|null $defaultScope = null, ) { if (is_string($jsonKey)) { if (!file_exists($jsonKey)) { @@ -101,6 +113,9 @@ public function __construct( if (!array_key_exists('source_credentials', $jsonKey)) { throw new LogicException('json key is missing the source_credentials field'); } + + $jsonKeyScope = $jsonKey['scopes'] ?? null; + $scope = $scope ?: $jsonKeyScope ?: $defaultScope; if ($scope && $targetAudience) { throw new InvalidArgumentException( 'Scope and targetAudience cannot both be supplied' @@ -118,7 +133,13 @@ public function __construct( // an ID token, the narrowest scope we can request is `iam`. $scope = self::IAM_SCOPE; } - $jsonKey['source_credentials'] = CredentialsLoader::makeCredentials($scope, $jsonKey['source_credentials']); + $jsonKey['source_credentials'] = match ($jsonKey['source_credentials']['type'] ?? null) { + // Do not pass $defaultScope to ServiceAccountCredentials + 'service_account' => new ServiceAccountCredentials($scope, $jsonKey['source_credentials']), + 'authorized_user' => new UserRefreshCredentials($scope, $jsonKey['source_credentials']), + 'external_account' => new ExternalAccountCredentials($scope, $jsonKey['source_credentials']), + default => throw new \InvalidArgumentException('invalid value in the type field'), + }; } $this->targetScope = $scope ?? []; diff --git a/lib/Google/vendor/google/auth/src/CredentialsLoader.php b/lib/Google/vendor/google/auth/src/CredentialsLoader.php index 9fc07416d..118f3a902 100644 --- a/lib/Google/vendor/google/auth/src/CredentialsLoader.php +++ b/lib/Google/vendor/google/auth/src/CredentialsLoader.php @@ -120,19 +120,38 @@ public static function fromWellKnownFile() /** * Create a new Credentials instance. * - * **Important**: If you accept a credential configuration (credential JSON/File/Stream) from an - * external source for authentication to Google Cloud Platform, you must validate it before - * providing it to any Google API or library. Providing an unvalidated credential configuration to - * Google APIs can compromise the security of your systems and data. For more information - * {@see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} + * @deprecated This method is being deprecated because of a potential security risk. * - * @param string|string[] $scope the scope of the access request, expressed - * either as an Array or as a space-delimited String. - * @param array $jsonKey the JSON credentials. - * @param string|string[] $defaultScope The default scope to use if no - * user-defined scopes exist, expressed either as an Array or as a - * space-delimited string. + * This method does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. * + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to use a credential-type-specific + * method. + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. Please follow the recommendation + * for that method. For example, if you want to load only service accounts, + * you can create the {@see ServiceAccountCredentials} explicitly: + * + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $creds = new ServiceAccountCredentials($scopes, $json); + * ``` + * + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * + * @param string|string[] $scope + * @param array $jsonKey + * @param string|string[] $defaultScope * @return ServiceAccountCredentials|UserRefreshCredentials|ImpersonatedServiceAccountCredentials|ExternalAccountCredentials */ public static function makeCredentials( @@ -155,8 +174,7 @@ public static function makeCredentials( } if ($jsonKey['type'] == 'impersonated_service_account') { - $anyScope = $scope ?: $defaultScope; - return new ImpersonatedServiceAccountCredentials($anyScope, $jsonKey); + return new ImpersonatedServiceAccountCredentials($scope, $jsonKey, null, $defaultScope); } if ($jsonKey['type'] == 'external_account') { diff --git a/lib/Google/vendor/google/auth/src/Logging/LoggingTrait.php b/lib/Google/vendor/google/auth/src/Logging/LoggingTrait.php index 2441a9bd7..0b8330d78 100644 --- a/lib/Google/vendor/google/auth/src/Logging/LoggingTrait.php +++ b/lib/Google/vendor/google/auth/src/Logging/LoggingTrait.php @@ -36,6 +36,7 @@ private function logRequest(RpcLogEvent $event): void 'severity' => strtoupper(LogLevel::DEBUG), 'processId' => $event->processId ?? null, 'requestId' => $event->requestId ?? null, + 'rpcName' => $event->rpcName ?? null, ]; $debugEvent = array_filter($debugEvent, fn ($value) => !is_null($value)); diff --git a/lib/Google/vendor/google/cloud-core/VERSION b/lib/Google/vendor/google/cloud-core/VERSION index 940573042..493498565 100644 --- a/lib/Google/vendor/google/cloud-core/VERSION +++ b/lib/Google/vendor/google/cloud-core/VERSION @@ -1 +1 @@ -1.64.0 +1.69.0 diff --git a/lib/Google/vendor/google/cloud-core/composer.json b/lib/Google/vendor/google/cloud-core/composer.json index dcbd57598..8c52588af 100644 --- a/lib/Google/vendor/google/cloud-core/composer.json +++ b/lib/Google/vendor/google/cloud-core/composer.json @@ -4,7 +4,7 @@ "license": "Apache-2.0", "minimum-stability": "stable", "require": { - "php": "^8.0", + "php": "^8.1", "rize/uri-template": "~0.3||~0.4", "google/auth": "^1.34", "guzzlehttp/guzzle": "^6.5.8||^7.4.4", @@ -12,17 +12,18 @@ "guzzlehttp/psr7": "^2.6", "monolog/monolog": "^2.9||^3.0", "psr/http-message": "^1.0||^2.0", - "google/gax": "^1.36.0" + "google/gax": "^1.38.0" }, "require-dev": { "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", "squizlabs/php_codesniffer": "2.*", - "phpdocumentor/reflection": "^5.3.3||^6.0", + "phpdocumentor/reflection": "^6.0", "phpdocumentor/reflection-docblock": "^5.3", "erusev/parsedown": "^1.6", - "opis/closure": "^3", - "google/cloud-common-protos": "~0.5" + "opis/closure": "^3.7|^4.0", + "google/cloud-common-protos": "~0.5", + "nikic/php-parser": "^5.6" }, "suggest": { "opis/closure": "May be used to serialize closures to process jobs in the batch daemon. Please require version ^3.", diff --git a/lib/Google/vendor/google/cloud-core/src/ApiHelperTrait.php b/lib/Google/vendor/google/cloud-core/src/ApiHelperTrait.php index 245b7e962..5ef652d06 100644 --- a/lib/Google/vendor/google/cloud-core/src/ApiHelperTrait.php +++ b/lib/Google/vendor/google/cloud-core/src/ApiHelperTrait.php @@ -19,7 +19,9 @@ use Google\ApiCore\ArrayTrait; use Google\ApiCore\Options\CallOptions; +use Google\Protobuf\Internal\Message; use Google\Protobuf\NullValue; +use LogicException; /** * @internal @@ -30,6 +32,8 @@ trait ApiHelperTrait use ArrayTrait; use TimeTrait; + private OptionsValidator $optionsValidator; + /** * Format a struct for the API. * @@ -240,6 +244,9 @@ protected function constructGapic($gapicName, array $config) */ private function convertDataToProtos(array $input, array $map): array { + if (!isset($this->serializer)) { + throw new \LogicException('Serializer must be set to use this function'); + } foreach ($map as $key => $className) { if (isset($input[$key])) { $input[$key] = $this->serializer->decodeMessage(new $className(), $input[$key]); @@ -260,8 +267,24 @@ private function splitOptionalArgs(array $input, array $extraAllowedKeys = []): $callOptionFields = array_keys((new CallOptions([]))->toArray()); $keys = array_merge($callOptionFields, $extraAllowedKeys); - $optionalArgs = $this->pluckArray($keys, $input); + $callOptions = $this->pluckArray($keys, $input); - return [$input, $optionalArgs]; + return [$input, $callOptions]; + } + + /** + * Helper method used to validate optons based on the supplied $optionTypes + * $optionTypes can be an array of string keys, a protobuf Message classname, or a + * the CallOptions classname. Parameters are split and returned in the order + * that the options types are provided. + * + * @throws LogicException + */ + private function validateOptions(array $options, array|Message|string ...$optionTypes): array + { + if (!isset($this->optionsValidator)) { + $this->optionsValidator = new OptionsValidator(); + } + return $this->optionsValidator->validateOptions($options, ...$optionTypes); } } diff --git a/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializer.php b/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializer.php index ce0e07574..3302a909e 100644 --- a/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializer.php +++ b/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializer.php @@ -23,6 +23,7 @@ * A closure serializer utilizing * [Opis Closure Library](https://github.com/opis/closure). * + * @deprecated use OpisClosureSerializerV4 * @experimental The experimental flag means that while we believe this method * or class is ready for use, it may change before release in backwards- * incompatible ways. Please use with caution, and test thoroughly when diff --git a/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializerV4.php b/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializerV4.php new file mode 100644 index 000000000..ac016bc20 --- /dev/null +++ b/lib/Google/vendor/google/cloud-core/src/Batch/OpisClosureSerializerV4.php @@ -0,0 +1,52 @@ +info()[$name])) { - trigger_error(sprintf( - 'Call to undefined method %s::%s', - __CLASS__, - $name - ), E_USER_ERROR); - } - - return $this->info()[$name]; - } -} diff --git a/lib/Google/vendor/google/cloud-core/src/ClientTrait.php b/lib/Google/vendor/google/cloud-core/src/ClientTrait.php index 2bd86cc1c..1f6e5cd5f 100644 --- a/lib/Google/vendor/google/cloud-core/src/ClientTrait.php +++ b/lib/Google/vendor/google/cloud-core/src/ClientTrait.php @@ -19,6 +19,8 @@ use Google\Auth\Credentials\GCECredentials; use Google\Auth\CredentialsLoader; +use Google\Auth\FetchAuthTokenInterface; +use Google\Auth\ProjectIdProviderInterface; use Google\Cloud\Core\Compute\Metadata; use Google\Cloud\Core\Exception\GoogleException; @@ -93,7 +95,12 @@ private function getGrpcInstallationMessage() */ private function configureAuthentication(array $config) { - $config['keyFile'] = $this->getKeyFile($config); + $credentialsFetcher = $config['credentialsFetcher'] ?? null; + + if (!($credentialsFetcher instanceof FetchAuthTokenInterface)) { + $config['keyFile'] = $this->getKeyFile($config); + } + $this->projectId = $this->detectProjectId($config); return $config; @@ -170,6 +177,7 @@ private function getKeyFile(array $config = []) private function detectProjectId(array $config) { $config += [ + 'credentialsFetcher' => null, 'httpHandler' => null, 'projectId' => null, 'projectIdRequired' => false, @@ -186,6 +194,10 @@ private function detectProjectId(array $config) return 'emulator-project'; } + if ($config['credentialsFetcher'] instanceof ProjectIdProviderInterface) { + return $config['credentialsFetcher']->getProjectId(); + } + if (isset($config['keyFile'])) { if (isset($config['keyFile']['project_id'])) { return $config['keyFile']['project_id']; diff --git a/lib/Google/vendor/google/cloud-core/src/Iam/Iam.php b/lib/Google/vendor/google/cloud-core/src/Iam/Iam.php index 3d530d8a3..cd351934d 100644 --- a/lib/Google/vendor/google/cloud-core/src/Iam/Iam.php +++ b/lib/Google/vendor/google/cloud-core/src/Iam/Iam.php @@ -34,7 +34,7 @@ * * use Google\Cloud\Spanner\SpannerClient; * - * $spanner = new SpannerClient(); + * $spanner = new SpannerClient(['projectId' => 'my-project']); * $instance = $spanner->instance('my-new-instance'); * * $iam = $instance->iam(); diff --git a/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningClientConnection.php b/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningClientConnection.php new file mode 100644 index 000000000..037a5d1ff --- /dev/null +++ b/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningClientConnection.php @@ -0,0 +1,123 @@ +gapicClient->resumeOperation($args['name']); + + return $this->operationResponseToArray($operationResponse); + } + + /** + * @param array $args + * @return array + */ + public function cancel(array $args): array + { + $operationResponse = $this->gapicClient->resumeOperation( + $args['name'], + $args['method'] ?? null + ); + $operationResponse->cancel(); + + return $this->operationResponseToArray($operationResponse); + } + + /** + * @param array $args + * @return array + */ + public function delete(array $args): array + { + $operationResponse = $this->gapicClient->resumeOperation( + $args['name'], + $args['method'] ?? null + ); + $operationResponse->cancel(); + + return $this->operationResponseToArray($operationResponse); + } + + /** + * @param array $args + * @return array + */ + public function operations(array $args): array + { + $request = ListOperationsRequest::build($args['name'], $args['filter'] ?? null); + $response = $this->gapicClient->getOperationsClient()->listOperations($request); + + return $this->handleResponse($response); + } + + private function operationResponseToArray(OperationResponse $operationResponse): array + { + $response = $this->handleResponse($operationResponse->getLastProtoResponse()); + $metaType = $response['metadata']['typeUrl']; + + // unpack result Any type + $result = $operationResponse->getResult(); + if ($result instanceof Any) { + // For some reason we aren't doing this in GAX OperationResponse (but we should) + $result = $result->unpack(); + } + $response['response'] = $this->handleResponse($result); + + // unpack error Any type + $response['error'] = $this->handleResponse($operationResponse->getError()); + + $metadata = $operationResponse->getMetadata(); + if ($metadata instanceof Any) { + // For some reason we aren't doing this in GAX OperationResponse (but we should) + $metadata = $metadata->unpack(); + } + $response['metadata'] = $this->handleResponse($metadata); + + // Used in LongRunningOperation to invoke callables + $response['metadata'] += ['typeUrl' => $metaType]; + + return $response; + } +} diff --git a/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningOperation.php b/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningOperation.php index d0decd596..64c898f06 100644 --- a/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningOperation.php +++ b/lib/Google/vendor/google/cloud-core/src/LongRunning/LongRunningOperation.php @@ -19,6 +19,7 @@ /** * Represent and interact with a Long Running Operation. + * @template T */ class LongRunningOperation { @@ -180,7 +181,7 @@ public function state(array $options = []) * ``` * * @param array $options [optional] Configuration options. - * @return mixed|null + * @return T|mixed|null */ public function result(array $options = []) { @@ -252,12 +253,11 @@ public function reload(array $options = []) $this->result = null; $this->error = null; - if (isset($res['done']) && $res['done']) { + + if ($res['done'] ?? false && isset($res['metadata']['typeUrl'])) { $type = $res['metadata']['typeUrl']; $this->result = $this->executeDoneCallback($type, $res['response']); - $this->error = (isset($res['error'])) - ? $res['error'] - : null; + $this->error = $res['error'] ?? null; } return $this->info = $res; diff --git a/lib/Google/vendor/google/cloud-core/src/OptionsValidator.php b/lib/Google/vendor/google/cloud-core/src/OptionsValidator.php new file mode 100644 index 000000000..cb82ad4bb --- /dev/null +++ b/lib/Google/vendor/google/cloud-core/src/OptionsValidator.php @@ -0,0 +1,109 @@ +vaidateOptions( + * $options, + * ['customOp1', 'customOp2'], + * new CommitRequest(), + * CallOptions::class, + * ); + * ``` + * + * @param array $options + * @param array|Message|string ...$optionTypes + * @return array + * @throws LogicException when a value exists which is not supported by any of the `$optionTypes`. + */ + public function validateOptions(array $options, array|Message|string ...$optionTypes): array + { + $splitOptions = []; + foreach ($optionTypes as $optionType) { + if (is_array($optionType)) { + $splitOptions[] = $this->pluckArray($optionType, $options); + } elseif ($optionType === CallOptions::class) { + $callOptionKeys = array_keys((new CallOptions([]))->toArray()); + $splitOptions[] = $this->pluckArray($callOptionKeys, $options); + } elseif ($optionType instanceof Message) { + $messageKeys = array_map( + fn ($method) => lcfirst(substr($method, 3)), + array_filter( + get_class_methods($optionType), + fn ($m) => 0 === strpos($m, 'get') + ) + ); + $messageOptions = $this->pluckArray($messageKeys, $options); + if ($this->serializer) { + $optionType = $this->serializer->decodeMessage($optionType, $messageOptions); + } else { + $optionType->mergeFromJsonString(json_encode($messageOptions, JSON_FORCE_OBJECT)); + } + $splitOptions[] = $optionType; + } elseif (is_string($optionType)) { + $splitOptions[] = $this->pluck($optionType, $options, false); + } else { + throw new LogicException(sprintf('Invalid option type: %s', $optionType)); + } + } + + if (!empty($options)) { + throw new LogicException( + 'Unexpected option(s) provided: ' . implode(', ', array_keys($options)) + ); + } + + return $splitOptions; + } +} diff --git a/lib/Google/vendor/google/cloud-core/src/Report/CloudRunJobMetadataProvider.php b/lib/Google/vendor/google/cloud-core/src/Report/CloudRunJobMetadataProvider.php index fe8d94ef4..234aefb46 100644 --- a/lib/Google/vendor/google/cloud-core/src/Report/CloudRunJobMetadataProvider.php +++ b/lib/Google/vendor/google/cloud-core/src/Report/CloudRunJobMetadataProvider.php @@ -80,7 +80,7 @@ public function __construct(array $env, ?Metadata $metadata = null) : null; $this->metadata = $metadata ?? new Metadata(); - $this->region = \basename($this->metadata->get('instance/region')); + $this->region = \basename($this->metadata->get('instance/region') ?? ''); $this->instanceId = $this->metadata->get('instance/id'); } diff --git a/lib/Google/vendor/google/cloud-core/src/Report/CloudRunServiceMetadataProvider.php b/lib/Google/vendor/google/cloud-core/src/Report/CloudRunServiceMetadataProvider.php index ece4061fd..66bc824c4 100644 --- a/lib/Google/vendor/google/cloud-core/src/Report/CloudRunServiceMetadataProvider.php +++ b/lib/Google/vendor/google/cloud-core/src/Report/CloudRunServiceMetadataProvider.php @@ -73,7 +73,7 @@ public function __construct(array $env, ?Metadata $metadata = null) : null; $this->metadata = $metadata ?? new Metadata(); - $this->region = \basename($this->metadata->get('instance/region')); + $this->region = \basename($this->metadata->get('instance/region') ?? ''); $this->instanceId = $this->metadata->get('instance/id'); } diff --git a/lib/Google/vendor/google/cloud-core/src/RequestHandler.php b/lib/Google/vendor/google/cloud-core/src/RequestHandler.php index f650b942b..ca4dbee34 100644 --- a/lib/Google/vendor/google/cloud-core/src/RequestHandler.php +++ b/lib/Google/vendor/google/cloud-core/src/RequestHandler.php @@ -42,16 +42,16 @@ class RequestHandler */ private Serializer $serializer; - private array $clients; + private array $clients = []; /** * @param Serializer $serializer - * @param array $clientClasses + * @param array $clients * @param array $clientConfig */ public function __construct( Serializer $serializer, - array $clientClasses, + array $clients, array $clientConfig = [] ) { //@codeCoverageIgnoreStart @@ -75,9 +75,12 @@ public function __construct( //@codeCoverageIgnoreEnd // Initialize the client classes and store them in memory - $this->clients = []; - foreach ($clientClasses as $className) { - $this->clients[$className] = new $className($clientConfig); + foreach ($clients as $client) { + if (is_object($client)) { + $this->clients[get_class($client)] = $client; + } else { + $this->clients[$client] = new $client($clientConfig); + } } } diff --git a/lib/Google/vendor/google/cloud-core/src/RequestWrapperTrait.php b/lib/Google/vendor/google/cloud-core/src/RequestWrapperTrait.php index 17cf45287..c2ffc9727 100644 --- a/lib/Google/vendor/google/cloud-core/src/RequestWrapperTrait.php +++ b/lib/Google/vendor/google/cloud-core/src/RequestWrapperTrait.php @@ -84,9 +84,7 @@ trait RequestWrapperTrait * @type array $authCacheOptions Cache configuration options. * @type FetchAuthTokenInterface $credentialsFetcher A credentials * fetcher instance. - * @type array $keyFile The contents of the service account credentials - * .json file retrieved from the Google Developer's Console. - * Ex: `json_decode(file_get_contents($path), true)`. + * @type array $keyFile [DEPRECATED] use `credentialsFetcher` option. * @type float $requestTimeout Seconds to wait before timing out the * request. **Defaults to** `0` with REST and `60` with gRPC. * @type int $retries Number of retries for a failed request. diff --git a/lib/Google/vendor/google/cloud-core/src/RestTrait.php b/lib/Google/vendor/google/cloud-core/src/RestTrait.php index 20b61cc00..207781c14 100644 --- a/lib/Google/vendor/google/cloud-core/src/RestTrait.php +++ b/lib/Google/vendor/google/cloud-core/src/RestTrait.php @@ -95,6 +95,8 @@ public function send($resource, $method, array $options = [], $whitelisted = fal 'requestTimeout', 'restRetryFunction', 'restRetryListener', + 'restDelayFunction', + 'restCalcDelayFunction', ], $options); try { diff --git a/lib/Google/vendor/google/cloud-core/src/ServiceBuilder.php b/lib/Google/vendor/google/cloud-core/src/ServiceBuilder.php index 2de759b76..6add2cf30 100644 --- a/lib/Google/vendor/google/cloud-core/src/ServiceBuilder.php +++ b/lib/Google/vendor/google/cloud-core/src/ServiceBuilder.php @@ -88,12 +88,8 @@ class ServiceBuilder * requests specifically for authentication. * @type callable $httpHandler A handler used to deliver Psr7 requests. * Only valid for requests sent over REST. - * @type array $keyFile The contents of the service account credentials - * .json file retrieved from the Google Developer's Console. - * Ex: `json_decode(file_get_contents($path), true)`. - * @type string $keyFilePath The full path to your service account - * credentials .json file retrieved from the Google Developers - * Console. + * @type array $keyFile [DEPRECATED] + * @type string $keyFilePath [DEPRECATED] * @type int $retries Number of retries for a failed request. * **Defaults to** `3`. * @type array $scopes Scopes to be used for the request. @@ -261,7 +257,7 @@ public function pubsub(array $config = []) * * Example: * ``` - * $spanner = $cloud->spanner(); + * $spanner = $cloud->spanner(['projectId' => 'my-project']); * ``` * * @param array $config [optional] { diff --git a/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerFactory.php b/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerFactory.php index 7adc137e2..e11392c3a 100644 --- a/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerFactory.php +++ b/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerFactory.php @@ -26,12 +26,10 @@ class ReflectionHandlerFactory { /** - * @return ReflectionHandlerV5 + * @return ReflectionHandlerV6 */ public static function create() { - return class_exists(Argument::class) - ? new ReflectionHandlerV5() - : new ReflectionHandlerV6(); + return new ReflectionHandlerV6(); } } diff --git a/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV5.php b/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV5.php deleted file mode 100644 index ea4e2b001..000000000 --- a/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV5.php +++ /dev/null @@ -1,190 +0,0 @@ -descriptionFactory = $this->createDescriptionFactory(); - $this->docBlockFactory = $this->createDocBlockFactory($this->descriptionFactory); - } - - /** - * @param string $class - * @return DocBlock - */ - public function createDocBlock($classOrMethod) - { - return $this->docBlockFactory->create($classOrMethod); - } - - /** - * @param DocBlock $docBlock - * @return string - */ - public function getDocBlockText(DocBlock $docBlock) - { - $description = $this->descriptionFactory->create( - $docBlock->getSummary() . "\n\n" . $docBlock->getDescription(), - $docBlock->getContext() - ); - return $description->render(); - } - - /** - * @param array $files - * @return string[] - */ - public function classes(array $files) - { - $projectFactory = $this->createProjectFactory(); - $localFiles = []; - foreach ($files as $file) { - $localFiles[] = new LocalFile($file); - } - $project = $projectFactory->create('My Project', $localFiles); - $classes = []; - foreach ($files as $file) { - $classesInFile = $project->getFiles()[$file]->getClasses(); - foreach ($classesInFile as $class) { - $classes[] = (string) $class->getFqsen(); - } - } - return $classes; - } - - /** - * Split this into a separate method because ReflectionHandler V6 looks - * different - */ - protected function createParser() - { - 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()); - $nodesFactory = new NodesFactory($parser, $nodeTraverser); - - $docblockFactory = $this->createDocBlockFactory($this->createDescriptionFactory()); - - $methodStrategy = new Factory\Method($docblockFactory); - - $strategies = new ProjectFactoryStrategies( - [ - new Factory\Namespace_(), - new Factory\Class_($docblockFactory), - new Factory\Enum_($docblockFactory), - new Factory\EnumCase($docblockFactory, new PrettyPrinter()), - new Factory\Define($docblockFactory, new PrettyPrinter()), - new Factory\GlobalConstant($docblockFactory, new PrettyPrinter()), - new Factory\ClassConstant($docblockFactory, new PrettyPrinter()), - new Factory\File($docblockFactory, $nodesFactory), - new Factory\Function_($docblockFactory), - new Factory\Interface_($docblockFactory), - $methodStrategy, - new Factory\Property($docblockFactory, new PrettyPrinter()), - new Factory\Trait_($docblockFactory), - new Factory\IfStatement(), - new TraitUse(), - ] + $this->getAdditionalStrategies() - ); - - $strategies->addStrategy( - new Factory\ConstructorPromotion($methodStrategy, $docblockFactory, new PrettyPrinter()), - 1100 - ); - $strategies->addStrategy(new Noop(), -PHP_INT_MAX); - - return new ProjectFactory($strategies); - } - - /** - * @return DescriptionFactory - */ - public function createDescriptionFactory() - { - $fqsenResolver = new FqsenResolver(); - $tagFactory = new StandardTagFactory($fqsenResolver); - $descriptionFactory = new CoreDescriptionFactory($tagFactory); - - $tagFactory->addService($descriptionFactory, DescriptionFactory::class); - $tagFactory->addService(new TypeResolver($fqsenResolver)); - - return $descriptionFactory; - } - - /** - * @return DocBlockFactory - */ - private function createDocBlockFactory($descriptionFactory) - { - $tagFactory = $descriptionFactory->getTagFactory(); - return new DocBlockFactory($descriptionFactory, $tagFactory); - } -} diff --git a/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV6.php b/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV6.php index b04a9efe0..07200de67 100644 --- a/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV6.php +++ b/lib/Google/vendor/google/cloud-core/src/Testing/Reflection/ReflectionHandlerV6.php @@ -1,6 +1,6 @@ descriptionFactory = $this->createDescriptionFactory(); + $this->docBlockFactory = $this->createDocBlockFactory($this->descriptionFactory); + } + + /** + * @param string $class + * @return DocBlock + */ + public function createDocBlock($classOrMethod) + { + return $this->docBlockFactory->create($classOrMethod); + } + + /** + * @param DocBlock $docBlock + * @return string + */ + public function getDocBlockText(DocBlock $docBlock) + { + $description = $this->descriptionFactory->create( + $docBlock->getSummary() . "\n\n" . $docBlock->getDescription(), + $docBlock->getContext() + ); + return $description->render(); + } + /** - * @see ReflectionHandlerV5 + * @param array $files + * @return string[] */ - protected function createParser() + public function classes(array $files) + { + $projectFactory = $this->createProjectFactory(); + $localFiles = []; + foreach ($files as $file) { + $localFiles[] = new LocalFile($file); + } + $project = $projectFactory->create('My Project', $localFiles); + $classes = []; + foreach ($files as $file) { + $classesInFile = $project->getFiles()[$file]->getClasses(); + foreach ($classesInFile as $class) { + $classes[] = (string) $class->getFqsen(); + } + } + return $classes; + } + + /** + * @return ProjectFactory + */ + public function createProjectFactory() { $phpVersion = PhpVersion::fromString('8.1'); // PHP 8.1.0 - return (new ParserFactory())->createForVersion($phpVersion); + $parser = (new ParserFactory())->createForVersion($phpVersion); + $nodeTraverser = new NodeTraverser(); + $nodeTraverser->addVisitor(new NameResolver()); + $nodeTraverser->addVisitor(new ElementNameResolver()); + $nodesFactory = new NodesFactory($parser, $nodeTraverser); + + $docblockFactory = $this->createDocBlockFactory($this->createDescriptionFactory()); + + $methodStrategy = new Factory\Method($docblockFactory); + + $strategies = new ProjectFactoryStrategies( + [ + new Factory\Namespace_(), + new Factory\Class_($docblockFactory), + new Factory\Enum_($docblockFactory), + new Factory\EnumCase($docblockFactory, new PrettyPrinter()), + new Factory\Define($docblockFactory, new PrettyPrinter()), + new Factory\GlobalConstant($docblockFactory, new PrettyPrinter()), + new Factory\ClassConstant($docblockFactory, new PrettyPrinter()), + new Factory\File($docblockFactory, $nodesFactory), + new Factory\Function_($docblockFactory), + new Factory\Interface_($docblockFactory), + $methodStrategy, + new Factory\Property($docblockFactory, new PrettyPrinter()), + new Factory\Trait_($docblockFactory), + new Factory\IfStatement(), + new TraitUse(), + ] + ); + + $strategies->addStrategy( + new Factory\ConstructorPromotion($methodStrategy, $docblockFactory, new PrettyPrinter()), + 1100 + ); + $strategies->addStrategy(new Noop(), -PHP_INT_MAX); + + return new ProjectFactory($strategies); + } + + /** + * @return DescriptionFactory + */ + public function createDescriptionFactory() + { + $fqsenResolver = new FqsenResolver(); + $tagFactory = new StandardTagFactory($fqsenResolver); + $descriptionFactory = new CoreDescriptionFactory($tagFactory); + + $tagFactory->addService($descriptionFactory, DescriptionFactory::class); + $tagFactory->addService(new TypeResolver($fqsenResolver)); + + return $descriptionFactory; } /** - * @see ReflectionHandlerV5 + * @return DocBlockFactory */ - protected function getAdditionalStrategies() + private function createDocBlockFactory($descriptionFactory) { - return []; + $tagFactory = $descriptionFactory->getTagFactory(); + return new DocBlockFactory($descriptionFactory, $tagFactory); } } diff --git a/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/Parser/Snippet.php b/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/Parser/Snippet.php index 400aa6469..bb95616b8 100644 --- a/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/Parser/Snippet.php +++ b/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/Parser/Snippet.php @@ -189,6 +189,19 @@ public function addLocal($name, $value) $this->locals[$name] = $value; } + /** + * Add a local variables to make available in the snippet execution scope. + * + * @param array $locals + * @return void + */ + public function addLocals(array $locals) + { + foreach ($locals as $name => $value) { + $this->addLocal($name, $value); + } + } + /** * Add a `use` statement for a class. * diff --git a/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/SnippetTestCase.php b/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/SnippetTestCase.php index bda2a0303..3ed8de6d0 100644 --- a/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/SnippetTestCase.php +++ b/lib/Google/vendor/google/cloud-core/src/Testing/Snippet/SnippetTestCase.php @@ -32,6 +32,8 @@ */ class SnippetTestCase extends TestCase { + const PROJECT = 'my-awesome-project'; + use CheckForClassTrait; private static $coverage; @@ -125,4 +127,80 @@ public static function snippetFromMethod($class, $method, $indexOrName = 0) return clone $snippet; } + + /** + * Retrieve a snippet from a markdown file. + * + * @param string $fileName The path to the file + * @param string $header The markdown header the snippet is under + * @param int $index The index of the snippet + * @return Snippet + * + * @experimental + * @internal + */ + public static function snippetFromMarkdown(string $fileName, string $header = '', int $index = 0) + { + // Normalize line endings to \n to make regex handling consistent across platforms + $markdown = str_replace( + ["\r\n", "\r"], + "\n", + file_get_contents($fileName) + ); + + // select by header + if ($header) { + $pattern = '/^#+\s*' . preg_quote($header, '/') . '\s*\n([\s\S]*?)(?=^#+.*$|\Z)/m'; + if (!preg_match($pattern, $markdown, $matches)) { + throw new \Exception('Heeader "' . $header . '" not found in markdown file ' . basename($fileName)); + } + $markdown = trim($matches[1]); + } + + /** + * Regex Explanation: + * * (?m) : Enable multi-line mode (^ matches start of line). + * ^ : Start of a line. + * (\s*) : Group 1: Capture indentation. + * (`{3,}|~{3,}) : Group 2: Capture the fence (3+ backticks or tildes). + * [ \t]* : Consume optional spaces. + * (.*?) : Group 3: Capture the language (and/or extra info) non-greedily. + * \n : End of the opening line. + * ([\s\S]*?) : Group 4: Content (non-greedy). + * \n : Newline before closing fence. + * \1 : Match exact indentation from Group 1. + * \2 : Match exact fence from Group 2. + * \s* : Consume any trailing whitespace/newlines on the closing line. + */ + $pattern = '/^(?m)(\s*)(`{3,}|~{3,})[ \t]*(.*?)\n([\s\S]*?)\1\2\s*$/m'; + $snippets = []; + if (!preg_match_all($pattern, $markdown, $matches, PREG_SET_ORDER)) { + throw new \Exception('No snippets found in markdown file ' . basename($fileName)); + } + foreach ($matches as $i => $match) { + // Group 3 is the language info string. Trim it to remove extra spaces. + $language = isset($match[3]) ? trim($match[3]) : ''; + + // Fallback to 'text' if empty + if ($language === '') { + $language = 'text'; + } + + // Group 4 is the actual code content + $code = $match[4]; + + $snippets[] = new Snippet($fileName . '-' . $i, [ + 'content' => $code, + 'file' => $fileName, + 'index' => $i, + 'name' => strtolower($language), + ]); + } + + if (!isset($snippets[$index])) { + throw new \Exception('No snippet found in markdown file ' . basename($fileName) . ' at index ' . $index); + } + + return clone $snippets[$index]; + } } diff --git a/lib/Google/vendor/google/cloud-core/src/TimeTrait.php b/lib/Google/vendor/google/cloud-core/src/TimeTrait.php index ab10cf269..2cd926516 100644 --- a/lib/Google/vendor/google/cloud-core/src/TimeTrait.php +++ b/lib/Google/vendor/google/cloud-core/src/TimeTrait.php @@ -79,12 +79,12 @@ private function formatTimeAsString(\DateTimeInterface $dateTime, $ns) $dateTime = $dateTime->setTimeZone(new \DateTimeZone('UTC')); if ($ns === null) { return $dateTime->format(Timestamp::FORMAT); - } else { - return sprintf( - $dateTime->format(Timestamp::FORMAT_INTERPOLATE), - $this->convertNanoSecondsToFraction($ns) - ); } + + return sprintf( + $dateTime->format(Timestamp::FORMAT_INTERPOLATE), + $this->convertNanoSecondsToFraction($ns) + ); } /** @@ -95,10 +95,10 @@ private function formatTimeAsString(\DateTimeInterface $dateTime, $ns) * $dateTime will be used instead. * @return array */ - private function formatTimeAsArray(\DateTimeInterface $dateTime, $ns) + private function formatTimeAsArray(\DateTimeInterface $dateTime, $ns = null) { if ($ns === null) { - $ns = $dateTime->format('u'); + $ns = $this->convertFractionToNanoSeconds($dateTime->format('u')); } return [ 'seconds' => (int) $dateTime->format('U'), diff --git a/lib/Google/vendor/google/cloud-core/src/Timestamp.php b/lib/Google/vendor/google/cloud-core/src/Timestamp.php index 2ab3eeb36..b8988e640 100644 --- a/lib/Google/vendor/google/cloud-core/src/Timestamp.php +++ b/lib/Google/vendor/google/cloud-core/src/Timestamp.php @@ -17,6 +17,8 @@ namespace Google\Cloud\Core; +use DateTimeInterface; + /** * Represents a Timestamp value. * @@ -85,9 +87,9 @@ public function __construct(\DateTimeInterface $value, $nanoSeconds = null) * $dateTime = $timestamp->get(); * ``` * - * @return \DateTimeInterface + * @return DateTimeInterface */ - public function get() + public function get(): DateTimeInterface { return $this->value; } @@ -102,7 +104,7 @@ public function get() * * @return int */ - public function nanoSeconds() + public function nanoSeconds(): int { return $this->nanoSeconds === null ? (int) $this->value->format('u') * 1000 @@ -119,7 +121,7 @@ public function nanoSeconds() * * @return string */ - public function formatAsString() + public function formatAsString(): string { return $this->formatTimeAsString( $this->value, @@ -143,7 +145,7 @@ public function __toString() * * @return array */ - public function formatForApi() + public function formatForApi(): array { return $this->formatTimeAsArray($this->value, $this->nanoSeconds()); } @@ -155,7 +157,7 @@ public function formatForApi() * @access private */ #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): string { return $this->formatAsString(); } diff --git a/lib/Google/vendor/google/cloud-storage/.gitattributes b/lib/Google/vendor/google/cloud-storage/.gitattributes new file mode 100644 index 000000000..d43b60862 --- /dev/null +++ b/lib/Google/vendor/google/cloud-storage/.gitattributes @@ -0,0 +1,3 @@ +/*.xml.dist export-ignore +/tests export-ignore +/.github export-ignore diff --git a/lib/Google/vendor/google/cloud-storage/VERSION b/lib/Google/vendor/google/cloud-storage/VERSION index 5525f03fa..7f3a46a84 100644 --- a/lib/Google/vendor/google/cloud-storage/VERSION +++ b/lib/Google/vendor/google/cloud-storage/VERSION @@ -1 +1 @@ -1.48.1 +1.49.0 diff --git a/lib/Google/vendor/google/cloud-storage/composer.json b/lib/Google/vendor/google/cloud-storage/composer.json index d0000cd74..a784163d5 100644 --- a/lib/Google/vendor/google/cloud-storage/composer.json +++ b/lib/Google/vendor/google/cloud-storage/composer.json @@ -4,7 +4,7 @@ "license": "Apache-2.0", "minimum-stability": "stable", "require": { - "php": "^8.0", + "php": "^8.1", "google/cloud-core": "^1.57", "ramsey/uuid": "^4.2.3" }, diff --git a/lib/Google/vendor/google/cloud-storage/src/Bucket.php b/lib/Google/vendor/google/cloud-storage/src/Bucket.php index 6abec40c8..4f6b30024 100644 --- a/lib/Google/vendor/google/cloud-storage/src/Bucket.php +++ b/lib/Google/vendor/google/cloud-storage/src/Bucket.php @@ -1519,14 +1519,50 @@ public function lockRetentionPolicy(array $options = []) * space, and line breaks will be replaced by an empty string. * V2 Signed URLs may not provide `x-goog-encryption-key` or * `x-goog-encryption-key-sha256` headers. - * @type array $keyFile Keyfile data to use in place of the keyfile with - * which the client was constructed. If `$options.keyFilePath` is - * set, this option is ignored. - * @type string $keyFilePath A path to a valid keyfile to use in place - * of the keyfile with which the client was constructed. - * @type string|array $scopes One or more authentication scopes to be - * used with a key file. This option is ignored unless - * `$options.keyFile` or `$options.keyFilePath` is set. + * @type FetchAuthTokenInterface $credentialsFetcher A credentials + * fetcher instance. + * @type array $keyFile [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * @type string $keyFilePath [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials * @type array $queryParams Additional query parameters to be included * as part of the signed URL query string. For allowed values, * see [Reference Headers](https://cloud.google.com/storage/docs/xml-api/reference-headers#query). @@ -1613,12 +1649,50 @@ public function signedUrl($expires, array $options = []) * `x-ignore` prefix), given as key/value pairs. * @type bool $forceOpenssl If true, OpenSSL will be used regardless of * whether phpseclib is available. **Defaults to** `false`. - * @type array $keyFile Keyfile data to use in place of the keyfile with - * which the client was constructed. If `$options.keyFilePath` is - * set, this option is ignored. - * @type string $keyFilePath A path to a valid Keyfile to use in place - * of the keyfile with which the client was constructed. - * @type string $scheme Either `http` or `https`. Only used if a custom + * @type FetchAuthTokenInterface $credentialsFetcher A credentials + * fetcher instance. + * @type array $keyFile [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * @type string $keyFilePath [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials * hostname is provided via `$options.bucketBoundHostname`. If a * custom bucketBoundHostname is provided, **defaults to** `http`. * In all other cases, **defaults to** `https`. diff --git a/lib/Google/vendor/google/cloud-storage/src/BucketIterator.php b/lib/Google/vendor/google/cloud-storage/src/BucketIterator.php new file mode 100644 index 000000000..3f1164ced --- /dev/null +++ b/lib/Google/vendor/google/cloud-storage/src/BucketIterator.php @@ -0,0 +1,50 @@ + + */ + public function unreachable() + { + return $this->unreachable->getArrayCopy(); + } +} diff --git a/lib/Google/vendor/google/cloud-storage/src/Connection/Rest.php b/lib/Google/vendor/google/cloud-storage/src/Connection/Rest.php index 928087478..4766c0ac2 100644 --- a/lib/Google/vendor/google/cloud-storage/src/Connection/Rest.php +++ b/lib/Google/vendor/google/cloud-storage/src/Connection/Rest.php @@ -100,6 +100,26 @@ class Rest implements ConnectionInterface */ private $restRetryFunction; + /** + * @var string|null + */ + private ?string $retryStrategy; + + /** + * @var callable|null + */ + private $restDelayFunction; + + /** + * @var callable|null + */ + private $restCalcDelayFunction; + + /** + * @var callable|null + */ + private $restRetryListener; + /** * @param array $config */ @@ -128,6 +148,10 @@ public function __construct(array $config = []) $this->projectId = $this->pluck('projectId', $config, false); $this->restRetryFunction = (isset($config['restRetryFunction'])) ? $config['restRetryFunction'] : null; + $this->retryStrategy = $config['retryStrategy'] ?? null; + $this->restDelayFunction = $config['restDelayFunction'] ?? null; + $this->restCalcDelayFunction = $config['restCalcDelayFunction'] ?? null; + $this->restRetryListener = $config['restRetryListener'] ?? null; } /** @@ -308,11 +332,13 @@ public function downloadObject(array $args = []) $resultStream = Utils::streamFor(null); $transcodedObj = false; + $args['retryStrategy'] ??= $this->retryStrategy; + list($request, $requestOptions) = $this->buildDownloadObjectParams($args); $invocationId = Uuid::uuid4()->toString(); $requestOptions['retryHeaders'] = self::getRetryHeaders($invocationId, 1); - $requestOptions['restRetryFunction'] = $this->getRestRetryFunction('objects', 'get', $requestOptions); + $requestOptions['restRetryFunction'] = $this->getRestRetryFunction('objects', 'get', $args); // We try to deduce if the object is a transcoded object when we receive the headers. $requestOptions['restOptions']['on_headers'] = function ($response) use (&$transcodedObj) { $header = $response->getHeader(self::TRANSCODED_OBJ_HEADER_KEY); @@ -461,6 +487,8 @@ private function resolveUploadOptions(array $args) 'userProject' => null, ]; + $args['retryStrategy'] ??= $this->retryStrategy; + $args['data'] = Utils::streamFor($args['data']); if ($args['resumable'] === null) { @@ -520,7 +548,7 @@ private function resolveUploadOptions(array $args) } /** - * @param array $args + * @param array $args */ public function getBucketIamPolicy(array $args) { @@ -528,7 +556,7 @@ public function getBucketIamPolicy(array $args) } /** - * @param array $args + * @param array $args */ public function setBucketIamPolicy(array $args) { @@ -536,7 +564,7 @@ public function setBucketIamPolicy(array $args) } /** - * @param array $args + * @param array $args */ public function testBucketIamPermissions(array $args) { @@ -677,7 +705,7 @@ private function buildDownloadObjectParams(array $args) } /** - * Choose a upload validation method based on user input and platform + * Choose an upload validation method based on user input and platform * requirements. * * @param array $args @@ -748,8 +776,8 @@ protected function crc32cExtensionLoaded() /** * Check if hash() supports crc32c. * - * @deprecated * @return bool + * @deprecated */ protected function supportsBuiltinCrc32c() { @@ -774,12 +802,20 @@ public function send($resource, $method, array $options = [], $whitelisted = fal 'objectAccessControls' => 'object_acl' ]; $retryResource = isset($retryMap[$resource]) ? $retryMap[$resource] : $resource; + $options['restRetryFunction'] = $this->restRetryFunction ?? $this->getRestRetryFunction( $retryResource, $method, $options ); + $options += array_filter([ + 'retryStrategy' => $this->retryStrategy, + 'restDelayFunction' => $this->restDelayFunction, + 'restCalcDelayFunction' => $this->restCalcDelayFunction, + 'restRetryListener' => $this->restRetryListener, + ]); + $options = $this->addRetryHeaderLogic($options); return $this->traitSend($resource, $method, $options); @@ -796,19 +832,26 @@ private function addRetryHeaderLogic(array $args) $invocationId = Uuid::uuid4()->toString(); $args['retryHeaders'] = self::getRetryHeaders($invocationId, 1); + $userListener = $args['restRetryListener'] ?? null; + // Adding callback logic to update headers while retrying $args['restRetryListener'] = function ( \Exception $e, $retryAttempt, &$arguments ) use ( - $invocationId + $invocationId, + $userListener ) { $arguments[0] = $this->modifyRequestForRetry( $arguments[0], $retryAttempt, $invocationId ); + + if ($userListener) { + $userListener($e, $retryAttempt, $arguments); + } }; return $args; diff --git a/lib/Google/vendor/google/cloud-storage/src/Connection/RetryTrait.php b/lib/Google/vendor/google/cloud-storage/src/Connection/RetryTrait.php index 4899e7e46..83a5dac47 100644 --- a/lib/Google/vendor/google/cloud-storage/src/Connection/RetryTrait.php +++ b/lib/Google/vendor/google/cloud-storage/src/Connection/RetryTrait.php @@ -31,7 +31,7 @@ trait RetryTrait * @var array */ private static $httpRetryCodes = [ - 0, // connetion-refused OR connection-reset gives status code of 0 + 0, // connection-refused OR connection-reset gives status code of 0 200, // partial download cases 408, 429, @@ -192,7 +192,7 @@ private function isPreConditionSupplied($methodName, array $args) * @param bool $isIdempotent * @param bool $preconditionNeeded * @param bool $preconditionSupplied - * @param int|null $maxRetries The maximum number of retries allowd. + * @param int|null $maxRetries The maximum number of retries allowed. * Null for no limit. * @return bool */ diff --git a/lib/Google/vendor/google/cloud-storage/src/Connection/ServiceDefinition/storage-v1.json b/lib/Google/vendor/google/cloud-storage/src/Connection/ServiceDefinition/storage-v1.json index 431263d70..52aa9050a 100644 --- a/lib/Google/vendor/google/cloud-storage/src/Connection/ServiceDefinition/storage-v1.json +++ b/lib/Google/vendor/google/cloud-storage/src/Connection/ServiceDefinition/storage-v1.json @@ -745,6 +745,13 @@ "$ref": "Bucket" } }, + "unreachable": { + "type": "array", + "description": "The list of bucket resource names that could not be reached during the listing operation.", + "items": { + "type": "string" + } + }, "kind": { "type": "string", "description": "The kind of item this is. For lists of buckets, this is always storage#buckets.", @@ -2528,6 +2535,11 @@ "type": "boolean", "description": "If set to true, only soft-deleted bucket versions are listed as distinct results in order of bucket name and generation number. The default value is false.", "location": "query" + }, + "returnPartialSuccess": { + "type": "boolean", + "description": "If true, returns a partial list of buckets. The `unreachable` field will contain buckets that were not reachable.", + "location": "query" } }, "parameterOrder": [ diff --git a/lib/Google/vendor/google/cloud-storage/src/SigningHelper.php b/lib/Google/vendor/google/cloud-storage/src/SigningHelper.php index 41acfbaf9..8e1d47781 100644 --- a/lib/Google/vendor/google/cloud-storage/src/SigningHelper.php +++ b/lib/Google/vendor/google/cloud-storage/src/SigningHelper.php @@ -198,7 +198,7 @@ public function v2Sign(ConnectionInterface $connection, $expires, $resource, $ge // urlencode parameter values foreach ($params as &$value) { - $value = rawurlencode($value); + $value = rawurlencode($value ?? ''); } $params = $this->addCommonParams($generation, $params, $options); @@ -346,7 +346,7 @@ public function v4Sign(ConnectionInterface $connection, $expires, $resource, $ge fn () => $credentials->signBlob($stringToSign, [ 'forceOpenssl' => $options['forceOpenssl'] ]) - ))); + ) ?? '')); // Construct the modified resource name. If a custom hostname is provided, // this will remove the bucket name from the resource. @@ -628,6 +628,7 @@ private function normalizeOptions(array $options) 'headers' => [], 'keyFile' => null, 'keyFilePath' => null, + 'credentialsFetcher' => null, 'method' => 'GET', 'queryParams' => [], 'responseDisposition' => null, @@ -822,6 +823,8 @@ private function getSigningCredentials(ConnectionInterface $connection, array $o $scopes = $options['scopes'] ?? $rw->scopes(); $credentials = CredentialsLoader::makeCredentials($scopes, $keyFile); + } elseif (isset($options['credentialsFetcher'])) { + $credentials = $options['credentialsFetcher']; } else { $credentials = $rw->getCredentialsFetcher(); } @@ -838,6 +841,7 @@ private function getSigningCredentials(ConnectionInterface $connection, array $o unset( $options['keyFilePath'], $options['keyFile'], + $options['credentialsFetcher'], $options['scopes'] ); diff --git a/lib/Google/vendor/google/cloud-storage/src/StorageClient.php b/lib/Google/vendor/google/cloud-storage/src/StorageClient.php index 23355325c..f8e1d19bc 100644 --- a/lib/Google/vendor/google/cloud-storage/src/StorageClient.php +++ b/lib/Google/vendor/google/cloud-storage/src/StorageClient.php @@ -47,7 +47,7 @@ class StorageClient use ArrayTrait; use ClientTrait; - const VERSION = '1.48.1'; + const VERSION = '1.49.0'; const FULL_CONTROL_SCOPE = 'https://www.googleapis.com/auth/devstorage.full_control'; const READ_ONLY_SCOPE = 'https://www.googleapis.com/auth/devstorage.read_only'; @@ -97,16 +97,71 @@ class StorageClient * fetcher instance. * @type callable $httpHandler A handler used to deliver Psr7 requests. * Only valid for requests sent over REST. - * @type array $keyFile The contents of the service account credentials - * .json file retrieved from the Google Developer's Console. - * Ex: `json_decode(file_get_contents($path), true)`. - * @type string $keyFilePath The full path to your service account - * credentials .json file retrieved from the Google Developers - * Console. + * @type array $keyFile [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * $creds = new StorageClient(['credentialsFetcher' => $creds]); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * @type string $keyFilePath [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * $creds = new StorageClient(['credentialsFetcher' => $creds]); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials * @type float $requestTimeout Seconds to wait before timing out the * request. **Defaults to** `0` with REST and `60` with gRPC. * @type int $retries Number of retries for a failed request. * **Defaults to** `3`. + * @type string $retryStrategy Retry strategy to signify that we never + * want to retry an operation even if the error is retryable. + * **Defaults to** `StorageClient::RETRY_IDEMPOTENT`. + * @type callable $restDelayFunction Executes a delay, defaults to + * utilizing `usleep`. Function signature should match: + * `function (int $delay) : void`. + * @type callable $restCalcDelayFunction Sets the conditions for + * determining how long to wait between attempts to retry. Function + * signature should match: `function (int $attempt) : int`. + * @type callable $restRetryFunction Sets the conditions for whether or + * not a request should attempt to retry. Function signature should + * match: `function (\Exception $ex) : bool`. + * @type callable $restRetryListener Runs after the restRetryFunction. + * This might be used to simply consume the exception and + * $arguments b/w retries. This returns the new $arguments thus + * allowing modification on demand for $arguments. For ex: + * changing the headers in b/w retries. * @type array $scopes Scopes to be used for the request. * @type string $quotaProject Specifies a user project to bill for * access charges associated with the request. @@ -218,24 +273,37 @@ public function bucket($name, $userProject = false, array $options = []) * If false, `$options.userProject` will be used ONLY for the * listBuckets operation. If `$options.userProject` is not set, * this option has no effect. **Defaults to** `true`. + * @type bool $returnPartialSuccess If true, the returned iterator will contain an + * `unreachable` property with a list of buckets that were not retrieved. + * **Note:** If set to false (default) and unreachable buckets are found, + * the operation will throw an exception. + * * } - * @return ItemIterator + * @return BucketIterator * @throws GoogleException When a project ID has not been detected. */ public function buckets(array $options = []) { $this->requireProjectId(); - $resultLimit = $this->pluck('resultLimit', $options, false); - $bucketUserProject = $this->pluck('bucketUserProject', $options, false); - $bucketUserProject = !is_null($bucketUserProject) - ? $bucketUserProject - : true; - $userProject = (isset($options['userProject']) && $bucketUserProject) - ? $options['userProject'] - : null; - - return new ItemIterator( + $bucketUserProject = $this->pluck('bucketUserProject', $options, null) ?? true; + $userProject = $bucketUserProject ? ($options['userProject'] ?? null) : null; + + $unreachable = new \ArrayObject(); + + $apiCall = [$this->connection, 'listBuckets']; + $callDelegate = function (array $args) use ($apiCall, $unreachable) { + $response = call_user_func($apiCall, $args); + if (isset($response['unreachable']) && is_array($response['unreachable'])) { + $current = $unreachable->getArrayCopy(); + $updated = array_unique(array_merge($current, $response['unreachable'])); + $unreachable->exchangeArray($updated); + } + return $response; + }; + + // Return the new BucketIterator with the wrapped unreachable bucket + return new BucketIterator( new PageIterator( function (array $bucket) use ($userProject) { return new Bucket( @@ -244,10 +312,11 @@ function (array $bucket) use ($userProject) { $bucket + ['requesterProjectId' => $userProject] ); }, - [$this->connection, 'listBuckets'], + $callDelegate, $options + ['project' => $this->projectId], ['resultLimit' => $resultLimit] - ) + ), + $unreachable ); } diff --git a/lib/Google/vendor/google/cloud-storage/src/StorageObject.php b/lib/Google/vendor/google/cloud-storage/src/StorageObject.php index 5aa126002..dd11ac358 100644 --- a/lib/Google/vendor/google/cloud-storage/src/StorageObject.php +++ b/lib/Google/vendor/google/cloud-storage/src/StorageObject.php @@ -478,7 +478,7 @@ public function rewrite($destination, array $options = []) } /** - * Move an object within a bucket with HNS enabled. + * Move an object within a bucket. * * This method copies data using multiple requests so large objects can be * copied with a normal length timeout per request rather than one very long @@ -925,11 +925,50 @@ public function downloadAsStreamAsync(array $options = []) * space, and line breaks will be replaced by an empty string. * V2 Signed URLs may not provide `x-goog-encryption-key` or * `x-goog-encryption-key-sha256` headers. - * @type array $keyFile Keyfile data to use in place of the keyfile with - * which the client was constructed. If `$options.keyFilePath` is - * set, this option is ignored. - * @type string $keyFilePath A path to a valid Keyfile to use in place - * of the keyfile with which the client was constructed. + * @type FetchAuthTokenInterface $credentialsFetcher A credentials + * fetcher instance. + * @type array $keyFile [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * @type string $keyFilePath [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials * @type string $method One of `GET`, `PUT` or `DELETE`. * **Defaults to** `GET`. * @type string $responseDisposition The @@ -1043,11 +1082,50 @@ public function signedUrl($expires, array $options = []) * space, and line breaks will be replaced by an empty string. * V2 Signed URLs may not provide `x-goog-encryption-key` or * `x-goog-encryption-key-sha256` headers. - * @type array $keyFile Keyfile data to use in place of the keyfile with - * which the client was constructed. If `$options.keyFilePath` is - * set, this option is ignored. - * @type string $keyFilePath A path to a valid Keyfile to use in place - * of the keyfile with which the client was constructed. + * @type FetchAuthTokenInterface $credentialsFetcher A credentials + * fetcher instance. + * @type array $keyFile [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * @type string $keyFilePath [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials * @type string $responseDisposition The * [`response-content-disposition`](http://www.iana.org/assignments/cont-disp/cont-disp.xhtml) * parameter of the signed url. @@ -1142,12 +1220,50 @@ public function signedUploadUrl($expires, array $options = []) * space, and line breaks will be replaced by an empty string. * V2 Signed URLs may not provide `x-goog-encryption-key` or * `x-goog-encryption-key-sha256` headers. - * @type array $keyFile Keyfile data to use in place of the keyfile with - * which the client was constructed. If `$options.keyFilePath` is - * set, this option is ignored. - * @type string $keyFilePath A path to a valid Keyfile to use in place - * of the keyfile with which the client was constructed. - * @type string $origin Value of CORS header + * @type FetchAuthTokenInterface $credentialsFetcher A credentials + * fetcher instance. + * @type array $keyFile [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials + * @type string $keyFilePath [DEPRECATED] + * This option is being deprecated because of a potential security risk. + * This option does not validate the credential configuration. The security + * risk occurs when a credential configuration is accepted from a source + * that is not under your control and used without validation on your side. + * If you know that you will be loading credential configurations of a + * specific type, it is recommended to create the credentials directly and + * configure them using the `credentialsFetcher` option instead. + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * $credentialsFetcher = new ServiceAccountCredentials($scopes, $json); + * ``` + * This will ensure that an unexpected credential type with potential for + * malicious intent is not loaded unintentionally. You might still have to do + * validation for certain credential types. + * If you are loading your credential configuration from an untrusted source and have + * not mitigated the risks (e.g. by validating the configuration yourself), make + * these changes as soon as possible to prevent security risks to your environment. + * Regardless of the method used, it is always your responsibility to validate + * configurations received from external sources. + * @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials * "Access-Control-Allow-Origin". **Defaults to** `"*"`. * @type string|array $scopes One or more authentication scopes to be * used with a key file. This option is ignored unless diff --git a/lib/Google/vendor/google/common-protos/VERSION b/lib/Google/vendor/google/common-protos/VERSION index 53cf85e17..23297c30e 100644 --- a/lib/Google/vendor/google/common-protos/VERSION +++ b/lib/Google/vendor/google/common-protos/VERSION @@ -1 +1 @@ -4.12.1 +4.12.4 diff --git a/lib/Google/vendor/google/common-protos/composer.json b/lib/Google/vendor/google/common-protos/composer.json index 7af87dcf4..a69cf2598 100644 --- a/lib/Google/vendor/google/common-protos/composer.json +++ b/lib/Google/vendor/google/common-protos/composer.json @@ -2,15 +2,15 @@ "name": "google/common-protos", "type": "library", "description": "Google API Common Protos for PHP", - "version": "4.12.1", + "version": "4.12.4", "keywords": [ "google" ], "homepage": "https://github.com/googleapis/common-protos-php", "license": "Apache-2.0", "require": { - "php": "^8.0", - "google/protobuf": "^v3.25.3||^4.26.1" + "php": "^8.1", + "google/protobuf": "^4.31" }, "require-dev": { "phpunit/phpunit": "^9.6" diff --git a/lib/Google/vendor/google/gax/CHANGELOG.md b/lib/Google/vendor/google/gax/CHANGELOG.md index 32f7fe85c..b62325b88 100644 --- a/lib/Google/vendor/google/gax/CHANGELOG.md +++ b/lib/Google/vendor/google/gax/CHANGELOG.md @@ -1,5 +1,58 @@ # Changelog +## [1.40.0](https://github.com/googleapis/gax-php/compare/v1.39.0...v1.40.0) (2025-12-04) + + +### Features + +* Add TransportCallMiddleware ([#640](https://github.com/googleapis/gax-php/issues/640)) ([a0f9d37](https://github.com/googleapis/gax-php/commit/a0f9d3740d62f6a776ac701631aa734046ceeb77)) + +## [1.39.0](https://github.com/googleapis/gax-php/compare/v1.38.2...v1.39.0) (2025-12-02) + + +### Features + +* Add GapicClientTrait::prependMiddleware ([#638](https://github.com/googleapis/gax-php/issues/638)) ([d46c06d](https://github.com/googleapis/gax-php/commit/d46c06d3bb551d9f7848bceebcfd78f80ec7890f)) + +## [1.38.2](https://github.com/googleapis/gax-php/compare/v1.38.1...v1.38.2) (2025-11-14) + + +### Bug Fixes + +* Don't override ApiException::__toString ([#388](https://github.com/googleapis/gax-php/issues/388)) ([db7cd2e](https://github.com/googleapis/gax-php/commit/db7cd2e55219463aa0f7d0bcc989f35d008d174b)) + +## [1.38.1](https://github.com/googleapis/gax-php/compare/v1.38.0...v1.38.1) (2025-11-06) + + +### Bug Fixes + +* Add return type to `offsetGet` ([#633](https://github.com/googleapis/gax-php/issues/633)) ([b77c12d](https://github.com/googleapis/gax-php/commit/b77c12dc959e8434fcd1f7f08cedaa84cdfb00a4)) + +## [1.38.0](https://github.com/googleapis/gax-php/compare/v1.37.0...v1.38.0) (2025-09-17) + + +### Features + +* Add the rpcName to the BIDI stream opening request ([#630](https://github.com/googleapis/gax-php/issues/630)) ([9c61d8f](https://github.com/googleapis/gax-php/commit/9c61d8f2bd09731d5f22c22eb81895eaf4db2031)) +* Make options classes fluid ([#618](https://github.com/googleapis/gax-php/issues/618)) ([427b46e](https://github.com/googleapis/gax-php/commit/427b46e91b3881fd0da361b5b351c6dda47e640a)) + + +### Bug Fixes + +* Update protobuf RepeatedField to new namespace ([#624](https://github.com/googleapis/gax-php/issues/624)) ([3558cc4](https://github.com/googleapis/gax-php/commit/3558cc49139861fa411c77b33f457467ec8daa97)) + +## [1.37.0](https://github.com/googleapis/gax-php/compare/v1.36.1...v1.37.0) (2025-09-10) + + +### Features + +* Support client options in ClientOptionsTrait::buildClientOptions ([#621](https://github.com/googleapis/gax-php/issues/621)) ([68e2336](https://github.com/googleapis/gax-php/commit/68e23369657b1740fffe480f96d9d7b04e3e38c2)) + + +### Bug Fixes + +* Ensure compute request build parameters have the operation ID last ([#625](https://github.com/googleapis/gax-php/issues/625)) ([f90ab28](https://github.com/googleapis/gax-php/commit/f90ab28cea6bbbd00f2a652a6d77babb69b2ada8)) + ## [1.36.1](https://github.com/googleapis/gax-php/compare/v1.36.0...v1.36.1) (2025-05-20) diff --git a/lib/Google/vendor/google/gax/README.md b/lib/Google/vendor/google/gax/README.md index 5a5875b70..6a6c01760 100644 --- a/lib/Google/vendor/google/gax/README.md +++ b/lib/Google/vendor/google/gax/README.md @@ -17,7 +17,7 @@ more convenient and idiomatic API surface to callers. ## PHP Versions -gax-php currently requires PHP 8.0 or higher. +gax-php currently requires PHP 8.1 or higher. ## Contributing diff --git a/lib/Google/vendor/google/gax/VERSION b/lib/Google/vendor/google/gax/VERSION index f107550c2..32b7211cb 100644 --- a/lib/Google/vendor/google/gax/VERSION +++ b/lib/Google/vendor/google/gax/VERSION @@ -1 +1 @@ -1.36.1 +1.40.0 diff --git a/lib/Google/vendor/google/gax/composer.json b/lib/Google/vendor/google/gax/composer.json index 06152f6ed..55ee44b42 100644 --- a/lib/Google/vendor/google/gax/composer.json +++ b/lib/Google/vendor/google/gax/composer.json @@ -6,11 +6,11 @@ "homepage": "https://github.com/googleapis/gax-php", "license": "BSD-3-Clause", "require": { - "php": "^8.0", - "google/auth": "^1.45", + "php": "^8.1", + "google/auth": "^1.49", "google/grpc-gcp": "^0.4", "grpc/grpc": "^1.13", - "google/protobuf": "^v3.25.3||^4.26.1", + "google/protobuf": "^4.31", "guzzlehttp/promises": "^2.0", "guzzlehttp/psr7": "^2.0", "google/common-protos": "^4.4", @@ -19,12 +19,12 @@ }, "require-dev": { "phpunit/phpunit": "^9.6", - "squizlabs/php_codesniffer": "3.*", + "squizlabs/php_codesniffer": "4.*", "phpspec/prophecy-phpunit": "^2.1", "phpstan/phpstan": "^2.0" }, "conflict": { - "ext-protobuf": "<3.7.0" + "ext-protobuf": "<4.31.0" }, "autoload": { "psr-4": { diff --git a/lib/Google/vendor/google/gax/src/ApiException.php b/lib/Google/vendor/google/gax/src/ApiException.php index b66fff873..74a42672b 100644 --- a/lib/Google/vendor/google/gax/src/ApiException.php +++ b/lib/Google/vendor/google/gax/src/ApiException.php @@ -32,7 +32,7 @@ namespace Google\ApiCore; use Exception; -use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\RepeatedField; use Google\Rpc\Status; use GuzzleHttp\Exception\RequestException; use stdClass; @@ -333,13 +333,4 @@ public function getMetadata() { return $this->metadata; } - - /** - * String representation of ApiException - * @return string - */ - public function __toString() - { - return __CLASS__ . ": $this->message\n"; - } } diff --git a/lib/Google/vendor/google/gax/src/ClientOptionsTrait.php b/lib/Google/vendor/google/gax/src/ClientOptionsTrait.php index 62ea0ec36..5def36e9e 100644 --- a/lib/Google/vendor/google/gax/src/ClientOptionsTrait.php +++ b/lib/Google/vendor/google/gax/src/ClientOptionsTrait.php @@ -32,6 +32,7 @@ namespace Google\ApiCore; +use Google\ApiCore\Options\ClientOptions; use Google\Auth\ApplicationDefaultCredentials; use Google\Auth\CredentialsLoader; use Google\Auth\FetchAuthTokenInterface; @@ -84,8 +85,26 @@ private static function getClientDefaults() return []; } - private function buildClientOptions(array $options) + /** + * Resolve client options based on the client's default + * ({@see ClientOptionsTrait::getClientDefault}) and the default for all + * Google APIs. + * + * 1. Set default client option values + * 2. Set default logger (and log user-supplied configuration options) + * 3. Set default transport configuration + * 4. Call "modifyClientOptions" (for backwards compatibility) + * 5. Use "defaultScopes" when custom endpoint is supplied + * 6. Load mTLS from the environment if configured + * 7. Resolve endpoint based on universe domain template when possible + * 8. Load sysvshm grpc config when possible + */ + private function buildClientOptions(array|ClientOptions $options) { + if ($options instanceof ClientOptions) { + $options = $options->toArray(); + } + // Build $defaultOptions starting from top level // variables, then going into deeper nesting, so that // we will not encounter missing keys diff --git a/lib/Google/vendor/google/gax/src/GapicClientTrait.php b/lib/Google/vendor/google/gax/src/GapicClientTrait.php index 3ebee5807..fe84a9aab 100644 --- a/lib/Google/vendor/google/gax/src/GapicClientTrait.php +++ b/lib/Google/vendor/google/gax/src/GapicClientTrait.php @@ -40,6 +40,7 @@ use Google\ApiCore\Middleware\PagedMiddleware; use Google\ApiCore\Middleware\RequestAutoPopulationMiddleware; use Google\ApiCore\Middleware\RetryMiddleware; +use Google\ApiCore\Middleware\TransportCallMiddleware; use Google\ApiCore\Options\CallOptions; use Google\ApiCore\Options\ClientOptions; use Google\ApiCore\Options\TransportOptions; @@ -72,6 +73,8 @@ trait GapicClientTrait private string $serviceName = ''; private array $agentHeader = []; private array $descriptors = []; + /** @var array $prependMiddlewareCallables */ + private array $prependMiddlewareCallables = []; /** @var array $middlewareCallables */ private array $middlewareCallables = []; private array $transportCallMethods = [ @@ -118,6 +121,42 @@ public function addMiddleware(callable $middlewareCallable): void $this->middlewareCallables[] = $middlewareCallable; } + /** + * Prepend a middleware to the call stack by providing a callable which will be + * invoked at the end of each call, and will return an instance of + * {@see MiddlewareInterface} when invoked. + * + * The callable must have the following method signature: + * + * callable(MiddlewareInterface): MiddlewareInterface + * + * An implementation may look something like this: + * ``` + * $client->prependMiddleware(function (MiddlewareInterface $handler) { + * return new class ($handler) implements MiddlewareInterface { + * public function __construct(private MiddlewareInterface $handler) { + * } + * + * public function __invoke(Call $call, array $options) { + * // modify call and options (pre-request) + * $response = ($this->handler)($call, $options); + * // modify the response (post-request) + * return $response; + * } + * }; + * }); + * ``` + * + * @param callable $middlewareCallable A callable which returns an instance + * of {@see MiddlewareInterface} when invoked with a + * MiddlewareInterface instance as its first argument. + * @return void + */ + public function prependMiddleware(callable $middlewareCallable): void + { + $this->prependMiddlewareCallables[] = $middlewareCallable; + } + /** * Initiates an orderly shutdown in which preexisting calls continue but new * calls are immediately cancelled. @@ -659,10 +698,13 @@ private function createCallStack(array $callConstructionOptions) ]; } - $callStack = function (Call $call, array $options) { - $startCallMethod = $this->transportCallMethods[$call->getCallType()]; - return $this->transport->$startCallMethod($call, $options); - }; + $callStack = new TransportCallMiddleware($this->transport, $this->transportCallMethods); + + foreach ($this->prependMiddlewareCallables as $fn) { + /** @var MiddlewareInterface $callStack */ + $callStack = $fn($callStack); + } + $callStack = new CredentialsWrapperMiddleware($callStack, $this->credentialsWrapper); $callStack = new FixedHeaderMiddleware($callStack, $fixedHeaders, true); $callStack = new RetryMiddleware($callStack, $callConstructionOptions['retrySettings']); diff --git a/lib/Google/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php index 7d890980a..086df0ef0 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php @@ -37,6 +37,8 @@ /** * Middleware which adds a CredentialsWrapper object to the call options. +* +* @internal */ class CredentialsWrapperMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/FixedHeaderMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/FixedHeaderMiddleware.php index 43fbb508f..f3204b548 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/FixedHeaderMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/FixedHeaderMiddleware.php @@ -36,6 +36,8 @@ /** * Middleware to add fixed headers to an API call. + * + * @internal */ class FixedHeaderMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/OperationsMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/OperationsMiddleware.php index 2da3ed3cf..e7f9baca6 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/OperationsMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/OperationsMiddleware.php @@ -37,6 +37,8 @@ /** * Middleware which wraps the response in an OperationResponse object. + * + * @internal */ class OperationsMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/OptionsFilterMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/OptionsFilterMiddleware.php index bcc405292..d5027fe4b 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/OptionsFilterMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/OptionsFilterMiddleware.php @@ -36,6 +36,8 @@ /** * Middleware which filters the $options array. +* +* @internal */ class OptionsFilterMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/PagedMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/PagedMiddleware.php index e5187638f..b396281e9 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/PagedMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/PagedMiddleware.php @@ -39,6 +39,8 @@ /** * Middleware which wraps the response in an PagedListResponses object. +* +* @internal */ class PagedMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/ResponseMetadataMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/ResponseMetadataMiddleware.php index c8f16087d..c9dbdef21 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/ResponseMetadataMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/ResponseMetadataMiddleware.php @@ -37,6 +37,8 @@ /** * Middleware which transforms $response into [$response, $metadata] + * + * @internal */ class ResponseMetadataMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/RetryMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/RetryMiddleware.php index 4e8f6e79d..a86e120d6 100644 --- a/lib/Google/vendor/google/gax/src/Middleware/RetryMiddleware.php +++ b/lib/Google/vendor/google/gax/src/Middleware/RetryMiddleware.php @@ -39,6 +39,8 @@ /** * Middleware that adds retry functionality. + * + * @internal */ class RetryMiddleware implements MiddlewareInterface { diff --git a/lib/Google/vendor/google/gax/src/Middleware/TransportCallMiddleware.php b/lib/Google/vendor/google/gax/src/Middleware/TransportCallMiddleware.php new file mode 100644 index 000000000..7854cefaa --- /dev/null +++ b/lib/Google/vendor/google/gax/src/Middleware/TransportCallMiddleware.php @@ -0,0 +1,60 @@ +transportCallMethods[$call->getCallType()]; + return $this->transport->$startCallMethod($call, $options); + } +} diff --git a/lib/Google/vendor/google/gax/src/OperationResponse.php b/lib/Google/vendor/google/gax/src/OperationResponse.php index 198f165d8..8e58c810e 100644 --- a/lib/Google/vendor/google/gax/src/OperationResponse.php +++ b/lib/Google/vendor/google/gax/src/OperationResponse.php @@ -56,6 +56,8 @@ * more control is required, it is possible to make calls against the * Operations API directly instead of via the OperationResponse object * using an Operations Client instance. + * + * @template T = mixed */ class OperationResponse { @@ -280,9 +282,10 @@ public function reload() } /** - * Return the result of the operation. If operationSucceeded() is false, return null. + * Return the result of the operation. If operationSucceeded() is false, + * return null. * - * @return mixed|null The result of the operation, or null if operationSucceeded() is false + * @return T|null */ public function getResult() { @@ -473,16 +476,28 @@ public function getMetadata() */ private function operationsCall(string $method, ?string $requestClass) { - $args = array_merge([$this->getName()], array_values($this->additionalArgs)); - if ($requestClass) { - if (!method_exists($requestClass, 'build')) { - throw new LogicException('Request class must support the static build method'); + // V1 GAPIC clients have an empty $requestClass + if (empty($requestClass)) { + if ($this->additionalArgs) { + return $this->operationsClient->$method( + $this->getName(), + ...array_values($this->additionalArgs) + ); } - $request = call_user_func_array($requestClass . '::build', $args); - $args = [$request]; + return $this->operationsClient->$method($this->getName()); } - return call_user_func_array([$this->operationsClient, $method], $args); + if (!method_exists($requestClass, 'build')) { + throw new LogicException('Request class must support the static build method'); + } + // In V2 of Compute, the Request "build" methods contain the operation ID last instead + // of first. Compute is the only API which uses $additionalArgs, so switching the order + // will not break anything. + $request = $requestClass::build(...array_merge( + array_values($this->additionalArgs), + [$this->getName()] + )); + return $this->operationsClient->$method($request); } private function canHaveResult() diff --git a/lib/Google/vendor/google/gax/src/Options/CallOptions.php b/lib/Google/vendor/google/gax/src/Options/CallOptions.php index 2256f4389..bae69ddd0 100644 --- a/lib/Google/vendor/google/gax/src/Options/CallOptions.php +++ b/lib/Google/vendor/google/gax/src/Options/CallOptions.php @@ -44,7 +44,7 @@ * {@see \Google\ApiCore\Transport\TransportInterface::startClientStreamingCall()}, and * {@see \Google\ApiCore\Transport\TransportInterface::startServerStreamingCall()}. */ -class CallOptions implements ArrayAccess +class CallOptions implements ArrayAccess, OptionsInterface { use OptionsTrait; @@ -93,17 +93,21 @@ private function fromArray(array $arr): void /** * @param array $headers */ - public function setHeaders(array $headers) + public function setHeaders(array $headers): self { $this->headers = $headers; + + return $this; } /** * @param int|null $timeoutMillis */ - public function setTimeoutMillis(?int $timeoutMillis) + public function setTimeoutMillis(?int $timeoutMillis): self { $this->timeoutMillis = $timeoutMillis; + + return $this; } /** @@ -125,24 +129,32 @@ public function setTimeoutMillis(?int $timeoutMillis) * See {@link https://docs.guzzlephp.org/en/stable/request-options.html}. * } */ - public function setTransportOptions(array $transportOptions) + public function setTransportOptions(array $transportOptions): self { $this->transportOptions = $transportOptions; + + return $this; } /** * @deprecated use CallOptions::setTransportOptions */ - public function setTransportSpecificOptions(array $transportSpecificOptions) + public function setTransportSpecificOptions(array $transportSpecificOptions): self { $this->setTransportOptions($transportSpecificOptions); + + return $this; } /** * @param RetrySettings|array|null $retrySettings + * + * @return $this */ - public function setRetrySettings($retrySettings) + public function setRetrySettings($retrySettings): self { $this->retrySettings = $retrySettings; + + return $this; } } diff --git a/lib/Google/vendor/google/gax/src/Options/ClientOptions.php b/lib/Google/vendor/google/gax/src/Options/ClientOptions.php index ae52db06a..b9677fe20 100644 --- a/lib/Google/vendor/google/gax/src/Options/ClientOptions.php +++ b/lib/Google/vendor/google/gax/src/Options/ClientOptions.php @@ -59,7 +59,7 @@ * Note: It's possible to pass an associative array to the API clients as well, * as ClientOptions will still be used internally for validation. */ -class ClientOptions implements ArrayAccess +class ClientOptions implements ArrayAccess, OptionsInterface { use OptionsTrait; @@ -112,19 +112,21 @@ class ClientOptions implements ArrayAccess * path to a JSON file, or a PHP array containing the decoded JSON data. * By default this settings points to the default client config file, which is provided * in the resources folder. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * The credentials to be used by the client to authorize API calls. This option - * accepts either a path to a credentials file, or a decoded credentials file as a - * PHP array. - * *Advanced usage*: In addition, this option can also accept a pre-constructed - * \Google\Auth\FetchAuthTokenInterface object or \Google\ApiCore\CredentialsWrapper - * object. Note that when one of these objects are provided, any settings in - * $authConfig will be ignored. - * *Important*: If you accept a credential configuration (credential JSON/File/Stream) - * from an external source for authentication to Google Cloud Platform, you must - * validate it before providing it to any Google API or library. Providing an - * unvalidated credential configuration to Google APIs can compromise the security of - * your systems and data. For more information + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed \Google\Auth\FetchAuthTokenInterface + * object or \Google\ApiCore\CredentialsWrapper object. Note that when one of these objects + * are provided, any settings in $authConfig will be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded credentials + * file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential + * configuration to Google APIs can compromise the security of your systems and data. It is now + * recommended to create the credentials explicitly: + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\ApiCore\Options\ClientOptions; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new ClientOptions(['credentials' => $creds]); + * ``` + * For more information * {@see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} * @type array $credentialsConfig * Options used to configure credentials, including auth token caching, for the client. @@ -202,25 +204,35 @@ private function fromArray(array $arr): void /** * @param ?string $apiEndpoint + * + * @return $this */ - public function setApiEndpoint(?string $apiEndpoint): void + public function setApiEndpoint(?string $apiEndpoint): self { $this->apiEndpoint = $apiEndpoint; + + return $this; } /** * @param bool $disableRetries + * + * @return $this */ - public function setDisableRetries(bool $disableRetries): void + public function setDisableRetries(bool $disableRetries): self { $this->disableRetries = $disableRetries; + + return $this; } /** * @param string|array $clientConfig + * + * @return $this * @throws InvalidArgumentException */ - public function setClientConfig($clientConfig): void + public function setClientConfig($clientConfig): self { if (is_string($clientConfig)) { $this->clientConfig = json_decode(file_get_contents($clientConfig), true); @@ -229,123 +241,181 @@ public function setClientConfig($clientConfig): void } else { throw new InvalidArgumentException('Invalid client config'); } + + return $this; } /** * @param string|array|FetchAuthTokenInterface|CredentialsWrapper|null $credentials + * + * @return $this */ - public function setCredentials($credentials): void + public function setCredentials($credentials): self { $this->credentials = $credentials; + + return $this; } /** * @param array $credentialsConfig + * + * @return $this */ - public function setCredentialsConfig(array $credentialsConfig): void + public function setCredentialsConfig(array $credentialsConfig): self { $this->credentialsConfig = $credentialsConfig; + + return $this; } /** * @param string|TransportInterface|null $transport + * + * @return $this */ - public function setTransport($transport): void + public function setTransport($transport): self { $this->transport = $transport; + + return $this; } /** * @param TransportOptions $transportConfig + * + * @return $this */ - public function setTransportConfig(TransportOptions $transportConfig): void + public function setTransportConfig(TransportOptions $transportConfig): self { $this->transportConfig = $transportConfig; + + return $this; } /** * @param ?string $versionFile + * + * @return $this */ - public function setVersionFile(?string $versionFile): void + public function setVersionFile(?string $versionFile): self { $this->versionFile = $versionFile; + + return $this; } /** * @param ?string $descriptorsConfigPath + * + * @return $this */ - private function setDescriptorsConfigPath(?string $descriptorsConfigPath) + private function setDescriptorsConfigPath(?string $descriptorsConfigPath): self { if (!is_null($descriptorsConfigPath)) { self::validateFileExists($descriptorsConfigPath); } $this->descriptorsConfigPath = $descriptorsConfigPath; + + return $this; } /** * @param ?string $serviceName + * + * @return $this */ - public function setServiceName(?string $serviceName): void + public function setServiceName(?string $serviceName): self { $this->serviceName = $serviceName; + + return $this; } /** * @param ?string $libName + * + * @return $this */ - public function setLibName(?string $libName): void + public function setLibName(?string $libName): self { $this->libName = $libName; + + return $this; } /** * @param ?string $libVersion + * + * @return $this */ - public function setLibVersion(?string $libVersion): void + public function setLibVersion(?string $libVersion): self { $this->libVersion = $libVersion; + + return $this; } /** * @param ?string $gapicVersion + * + * @return $this */ - public function setGapicVersion(?string $gapicVersion): void + public function setGapicVersion(?string $gapicVersion): self { $this->gapicVersion = $gapicVersion; + + return $this; } /** * @param ?callable $clientCertSource + * + * @return $this */ - public function setClientCertSource(?callable $clientCertSource) + public function setClientCertSource(?callable $clientCertSource): self { if (!is_null($clientCertSource)) { $clientCertSource = Closure::fromCallable($clientCertSource); } $this->clientCertSource = $clientCertSource; + + return $this; } /** * @param string $universeDomain + * + * @return $this */ - public function setUniverseDomain(?string $universeDomain) + public function setUniverseDomain(?string $universeDomain): self { $this->universeDomain = $universeDomain; + + return $this; } /** * @param string $apiKey + * + * @return $this */ - public function setApiKey(?string $apiKey) + public function setApiKey(?string $apiKey): self { $this->apiKey = $apiKey; + + return $this; } /** * @param null|false|LoggerInterface $logger + * + * @return $this */ - public function setLogger(null|false|LoggerInterface $logger) + public function setLogger(null|false|LoggerInterface $logger): self { $this->logger = $logger; + + return $this; } } diff --git a/lib/Google/vendor/google/gax/src/Options/OptionsInterface.php b/lib/Google/vendor/google/gax/src/Options/OptionsInterface.php new file mode 100644 index 000000000..684d27e65 --- /dev/null +++ b/lib/Google/vendor/google/gax/src/Options/OptionsInterface.php @@ -0,0 +1,38 @@ +$offset); } + /** + * @return mixed + */ #[\ReturnTypeWillChange] public function offsetGet($offset) { @@ -83,7 +86,9 @@ public function toArray(): array { $arr = []; foreach (get_object_vars($this) as $key => $value) { - $arr[$key] = $value; + $arr[$key] = $value instanceof OptionsInterface + ? $value->toArray() + : $value; } return $arr; } diff --git a/lib/Google/vendor/google/gax/src/Options/TransportOptions.php b/lib/Google/vendor/google/gax/src/Options/TransportOptions.php index 8a1f006d5..3334d6f6c 100644 --- a/lib/Google/vendor/google/gax/src/Options/TransportOptions.php +++ b/lib/Google/vendor/google/gax/src/Options/TransportOptions.php @@ -37,7 +37,7 @@ use Google\ApiCore\Options\TransportOptions\GrpcTransportOptions; use Google\ApiCore\Options\TransportOptions\RestTransportOptions; -class TransportOptions implements ArrayAccess +class TransportOptions implements ArrayAccess, OptionsInterface { use OptionsTrait; @@ -73,18 +73,39 @@ private function fromArray(array $arr): void $this->setRest(new RestTransportOptions($arr['rest'] ?? [])); } - public function setGrpc(GrpcTransportOptions $grpc): void + /** + * @param GrpcTransportOptions $grpc + * + * @return $this + */ + public function setGrpc(GrpcTransportOptions $grpc): self { $this->grpc = $grpc; + + return $this; } - public function setGrpcFallback(GrpcFallbackTransportOptions $grpcFallback): void + /** + * @param GrpcFallbackTransportOptions $grpcFallback + * + * @return $this + */ + public function setGrpcFallback(GrpcFallbackTransportOptions $grpcFallback): self { $this->grpcFallback = $grpcFallback; + + return $this; } - public function setRest(RestTransportOptions $rest): void + /** + * @param RestTransportOptions $rest + * + * @return $this + */ + public function setRest(RestTransportOptions $rest): self { $this->rest = $rest; + + return $this; } } diff --git a/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcFallbackTransportOptions.php b/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcFallbackTransportOptions.php index 285a9803d..9f94b235e 100644 --- a/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcFallbackTransportOptions.php +++ b/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcFallbackTransportOptions.php @@ -34,6 +34,7 @@ use ArrayAccess; use Closure; +use Google\ApiCore\Options\OptionsInterface; use Google\ApiCore\Options\OptionsTrait; use Psr\Log\LoggerInterface; @@ -41,7 +42,7 @@ * The GrpcFallbackTransportOptions class provides typing to the associative array of options used * to configure {@see \Google\ApiCore\Transport\GrpcFallbackTransport}. */ -class GrpcFallbackTransportOptions implements ArrayAccess +class GrpcFallbackTransportOptions implements ArrayAccess, OptionsInterface { use OptionsTrait; @@ -80,30 +81,45 @@ private function fromArray(array $arr): void $this->setLogger($arr['logger'] ?? null); } - public function setHttpHandler(?callable $httpHandler) + /** + * @param ?callable $httpHandler + * + * @return $this + */ + public function setHttpHandler(?callable $httpHandler): self { if (!is_null($httpHandler)) { $httpHandler = Closure::fromCallable($httpHandler); } $this->httpHandler = $httpHandler; + + return $this; } /** * @param ?callable $clientCertSource + * + * @return $this */ - public function setClientCertSource(?callable $clientCertSource) + public function setClientCertSource(?callable $clientCertSource): self { if (!is_null($clientCertSource)) { $clientCertSource = Closure::fromCallable($clientCertSource); } $this->clientCertSource = $clientCertSource; + + return $this; } /** * @param null|false|LoggerInterface $logger + * + * @return $this */ - public function setLogger(null|false|LoggerInterface $logger) + public function setLogger(null|false|LoggerInterface $logger): self { $this->logger = $logger; + + return $this; } } diff --git a/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcTransportOptions.php b/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcTransportOptions.php index 65fdda5fe..051b57bbe 100644 --- a/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcTransportOptions.php +++ b/lib/Google/vendor/google/gax/src/Options/TransportOptions/GrpcTransportOptions.php @@ -34,6 +34,7 @@ use ArrayAccess; use Closure; +use Google\ApiCore\Options\OptionsInterface; use Google\ApiCore\Options\OptionsTrait; use Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface; use Grpc\Channel; @@ -44,7 +45,7 @@ * The GrpcTransportOptions class provides typing to the associative array of options used to * configure {@see \Google\ApiCore\Transport\GrpcTransport}. */ -class GrpcTransportOptions implements ArrayAccess +class GrpcTransportOptions implements ArrayAccess, OptionsInterface { use OptionsTrait; @@ -101,44 +102,64 @@ private function fromArray(array $arr): void /** * @param array $stubOpts + * + * @return $this */ - public function setStubOpts(array $stubOpts) + public function setStubOpts(array $stubOpts): self { $this->stubOpts = $stubOpts; + + return $this; } /** * @param ?Channel $channel + * + * @return $this */ - public function setChannel(?Channel $channel) + public function setChannel(?Channel $channel): self { $this->channel = $channel; + + return $this; } /** * @param Interceptor[]|UnaryInterceptorInterface[] $interceptors + * + * @return $this */ - public function setInterceptors(array $interceptors) + public function setInterceptors(array $interceptors): self { $this->interceptors = $interceptors; + + return $this; } /** * @param ?callable $clientCertSource + * + * @return $this */ - public function setClientCertSource(?callable $clientCertSource) + public function setClientCertSource(?callable $clientCertSource): self { if (!is_null($clientCertSource)) { $clientCertSource = Closure::fromCallable($clientCertSource); } $this->clientCertSource = $clientCertSource; + + return $this; } /** * @param null|false|LoggerInterface $logger + * + * @return $this */ - public function setLogger(null|false|LoggerInterface $logger) + public function setLogger(null|false|LoggerInterface $logger): self { $this->logger = $logger; + + return $this; } } diff --git a/lib/Google/vendor/google/gax/src/Options/TransportOptions/RestTransportOptions.php b/lib/Google/vendor/google/gax/src/Options/TransportOptions/RestTransportOptions.php index 0f0fd3a92..ea55e2e97 100644 --- a/lib/Google/vendor/google/gax/src/Options/TransportOptions/RestTransportOptions.php +++ b/lib/Google/vendor/google/gax/src/Options/TransportOptions/RestTransportOptions.php @@ -34,6 +34,7 @@ use ArrayAccess; use Closure; +use Google\ApiCore\Options\OptionsInterface; use Google\ApiCore\Options\OptionsTrait; use Psr\Log\LoggerInterface; @@ -41,7 +42,7 @@ * The RestTransportOptions class provides typing to the associative array of options used to * configure {@see \Google\ApiCore\Transport\RestTransport}. */ -class RestTransportOptions implements ArrayAccess +class RestTransportOptions implements ArrayAccess, OptionsInterface { use OptionsTrait; @@ -87,39 +88,55 @@ private function fromArray(array $arr): void /** * @param ?callable $httpHandler + * + * @return $this */ - public function setHttpHandler(?callable $httpHandler) + public function setHttpHandler(?callable $httpHandler): self { if (!is_null($httpHandler)) { $httpHandler = Closure::fromCallable($httpHandler); } $this->httpHandler = $httpHandler; + + return $this; } /** * @param ?callable $clientCertSource + * + * @return $this */ - public function setClientCertSource(?callable $clientCertSource) + public function setClientCertSource(?callable $clientCertSource): self { if (!is_null($clientCertSource)) { $clientCertSource = Closure::fromCallable($clientCertSource); } $this->clientCertSource = $clientCertSource; + + return $this; } /** * @param ?string $restClientConfigPath + * + * @return $this */ - public function setRestClientConfigPath(?string $restClientConfigPath) + public function setRestClientConfigPath(?string $restClientConfigPath): self { $this->restClientConfigPath = $restClientConfigPath; + + return $this; } /** * @param null|false|LoggerInterface $logger + * + * @return $this */ - public function setLogger(null|false|LoggerInterface $logger) + public function setLogger(null|false|LoggerInterface $logger): self { $this->logger = $logger; + + return $this; } } diff --git a/lib/Google/vendor/google/gax/src/ServerStream.php b/lib/Google/vendor/google/gax/src/ServerStream.php index 548b6b48c..3257e6550 100644 --- a/lib/Google/vendor/google/gax/src/ServerStream.php +++ b/lib/Google/vendor/google/gax/src/ServerStream.php @@ -39,6 +39,8 @@ /** * ServerStream is the response object from a server streaming API call. + * + * @template T = mixed */ class ServerStream { @@ -72,7 +74,7 @@ public function __construct( * completes. Throws an ApiException if the streaming call failed. * * @throws ApiException - * @return \Generator|mixed + * @return \Generator|mixed */ public function readAll() { diff --git a/lib/Google/vendor/google/gax/src/Testing/GeneratedTest.php b/lib/Google/vendor/google/gax/src/Testing/GeneratedTest.php index 329bff09a..f8d4c1af4 100644 --- a/lib/Google/vendor/google/gax/src/Testing/GeneratedTest.php +++ b/lib/Google/vendor/google/gax/src/Testing/GeneratedTest.php @@ -34,7 +34,7 @@ use Google\ApiCore\Serializer; use Google\Protobuf\DescriptorPool; use Google\Protobuf\Internal\Message; -use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\RepeatedField; use PHPUnit\Framework\TestCase; /** diff --git a/lib/Google/vendor/google/gax/src/Testing/MockGrpcTransport.php b/lib/Google/vendor/google/gax/src/Testing/MockGrpcTransport.php index 6e5c4fa59..d6af2fe4f 100644 --- a/lib/Google/vendor/google/gax/src/Testing/MockGrpcTransport.php +++ b/lib/Google/vendor/google/gax/src/Testing/MockGrpcTransport.php @@ -34,6 +34,7 @@ use Google\ApiCore\Transport\GrpcTransport; use Grpc\ChannelCredentials; +use Psr\Log\LoggerInterface; /** * @internal @@ -46,11 +47,11 @@ class MockGrpcTransport extends GrpcTransport /** * @param mixed $mockCall */ - public function __construct($mockCall = null) + public function __construct($mockCall = null, ?LoggerInterface $logger = null) { $this->mockCall = $mockCall; $opts = ['credentials' => ChannelCredentials::createSsl()]; - parent::__construct('', $opts); + parent::__construct('', $opts, logger: $logger); } /** diff --git a/lib/Google/vendor/google/gax/src/Testing/MockRequestBody.php b/lib/Google/vendor/google/gax/src/Testing/MockRequestBody.php index 08a823305..7d877d809 100644 --- a/lib/Google/vendor/google/gax/src/Testing/MockRequestBody.php +++ b/lib/Google/vendor/google/gax/src/Testing/MockRequestBody.php @@ -75,7 +75,7 @@ class MockRequestBody extends \Google\Protobuf\Internal\Message * * @type string $name * @type int|string $number - * @type string[]|\Google\Protobuf\Internal\RepeatedField $repeated_field + * @type string[]|\Google\Protobuf\RepeatedField $repeated_field * @type \Google\ApiCore\Testing\MockRequestBody $nested_message * @type \Google\Protobuf\BytesValue $bytes_value * @type \Google\Protobuf\Duration $duration_value @@ -143,7 +143,7 @@ public function setNumber($var) /** * Generated from protobuf field repeated string repeated_field = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return \Google\Protobuf\RepeatedField */ public function getRepeatedField() { @@ -152,7 +152,7 @@ public function getRepeatedField() /** * Generated from protobuf field repeated string repeated_field = 3; - * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @param string[]|\Google\Protobuf\RepeatedField $var * @return $this */ public function setRepeatedField($var) diff --git a/lib/Google/vendor/google/gax/src/Testing/MockResponse.php b/lib/Google/vendor/google/gax/src/Testing/MockResponse.php index cbe7ba659..6d93ad96c 100644 --- a/lib/Google/vendor/google/gax/src/Testing/MockResponse.php +++ b/lib/Google/vendor/google/gax/src/Testing/MockResponse.php @@ -42,7 +42,7 @@ class MockResponse extends \Google\Protobuf\Internal\Message * * @type string $name * @type int|string $number - * @type string[]|\Google\Protobuf\Internal\RepeatedField $resources_list + * @type string[]|\Google\Protobuf\RepeatedField $resources_list * @type string $next_page_token * @type array|\Google\Protobuf\Internal\MapField $resources_map * } @@ -99,7 +99,7 @@ public function setNumber($var) /** * Generated from protobuf field repeated string resources_list = 3; - * @return \Google\Protobuf\Internal\RepeatedField + * @return \Google\Protobuf\RepeatedField */ public function getResourcesList() { @@ -108,7 +108,7 @@ public function getResourcesList() /** * Generated from protobuf field repeated string resources_list = 3; - * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @param string[]|\Google\Protobuf\RepeatedField $var * @return $this */ public function setResourcesList($var) diff --git a/lib/Google/vendor/google/gax/src/Transport/GrpcTransport.php b/lib/Google/vendor/google/gax/src/Transport/GrpcTransport.php index ebcbc07b2..5fd03a6fe 100644 --- a/lib/Google/vendor/google/gax/src/Transport/GrpcTransport.php +++ b/lib/Google/vendor/google/gax/src/Transport/GrpcTransport.php @@ -178,7 +178,7 @@ public function startBidiStreamingCall(Call $call, array $options) { $this->verifyUniverseDomain($options); - return new BidiStream( + $bidiStream = new BidiStream( $this->_bidiRequest( '/' . $call->getMethod(), [$call->getDecodeType(), 'decode'], @@ -188,6 +188,21 @@ public function startBidiStreamingCall(Call $call, array $options) $call->getDescriptor(), $this->logger ); + + if ($this->logger) { + $requestEvent = new RpcLogEvent(); + + $requestEvent->headers = $options['headers'] ?? []; + $requestEvent->retryAttempt = $options['retryAttempt'] ?? null; + $requestEvent->serviceName = $options['serviceName'] ?? null; + $requestEvent->rpcName = $call->getMethod(); + $requestEvent->processId = (int) getmypid(); + $requestEvent->requestId = crc32((string) spl_object_id($bidiStream) . getmypid()); + + $this->logRequest($requestEvent); + } + + return $bidiStream; } /** diff --git a/lib/Google/vendor/google/grpc-gcp/.github/release-please.yml b/lib/Google/vendor/google/grpc-gcp/.github/release-please.yml new file mode 100644 index 000000000..ddc69395d --- /dev/null +++ b/lib/Google/vendor/google/grpc-gcp/.github/release-please.yml @@ -0,0 +1,3 @@ +releaseType: simple +handleGHRelease: true +primaryBranch: main diff --git a/lib/Google/vendor/google/grpc-gcp/.github/workflows/tests.yml b/lib/Google/vendor/google/grpc-gcp/.github/workflows/tests.yml new file mode 100644 index 000000000..fe47b44c0 --- /dev/null +++ b/lib/Google/vendor/google/grpc-gcp/.github/workflows/tests.yml @@ -0,0 +1,30 @@ +name: Test Suite +on: + push: + branches: + - master + pull_request: +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ] + name: "PHP ${{ matrix.php }} Unit Test" + steps: + - uses: actions/checkout@v2 + - uses: codecov/codecov-action@v1 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: pecl + extensions: grpc-1.49.0 + - name: Install composer dependencies + uses: nick-invision/retry@v1 + with: + timeout_minutes: 10 + max_attempts: 3 + command: composer install + - name: Run PHPUnit + run: vendor/bin/phpunit -v diff --git a/lib/Google/vendor/google/grpc-gcp/.gitmodules b/lib/Google/vendor/google/grpc-gcp/.gitmodules new file mode 100644 index 000000000..6c20e7b68 --- /dev/null +++ b/lib/Google/vendor/google/grpc-gcp/.gitmodules @@ -0,0 +1,3 @@ +[submodule "third_party/googleapis"] + path = third_party/googleapis + url = https://github.com/googleapis/googleapis.git diff --git a/lib/Google/vendor/google/protobuf/composer.json b/lib/Google/vendor/google/protobuf/composer.json index 70af0a033..534647221 100644 --- a/lib/Google/vendor/google/protobuf/composer.json +++ b/lib/Google/vendor/google/protobuf/composer.json @@ -6,10 +6,10 @@ "homepage": "https://developers.google.com/protocol-buffers/", "license": "BSD-3-Clause", "require": { - "php": ">=7.0.0" + "php": ">=8.1.0" }, "require-dev": { - "phpunit/phpunit": ">=5.0.0" + "phpunit/phpunit": ">=5.0.0 <8.5.27" }, "suggest": { "ext-bcmath": "Need to support JSON deserialization" @@ -21,3 +21,4 @@ } } } + diff --git a/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Api.php b/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Api.php index 4485d3d0b..83e2748e4 100644 --- a/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Api.php +++ b/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Api.php @@ -18,7 +18,7 @@ public static function initOnce() { \GPBMetadata\Google\Protobuf\SourceContext::initOnce(); \GPBMetadata\Google\Protobuf\Type::initOnce(); $pool->internalAddGeneratedFile( - "\x0A\xC9\x05\x0A\x19google/protobuf/api.proto\x12\x0Fgoogle.protobuf\x1A\x1Agoogle/protobuf/type.proto\"\x81\x02\x0A\x03Api\x12\x0C\x0A\x04name\x18\x01 \x01(\x09\x12(\x0A\x07methods\x18\x02 \x03(\x0B2\x17.google.protobuf.Method\x12(\x0A\x07options\x18\x03 \x03(\x0B2\x17.google.protobuf.Option\x12\x0F\x0A\x07version\x18\x04 \x01(\x09\x126\x0A\x0Esource_context\x18\x05 \x01(\x0B2\x1E.google.protobuf.SourceContext\x12&\x0A\x06mixins\x18\x06 \x03(\x0B2\x16.google.protobuf.Mixin\x12'\x0A\x06syntax\x18\x07 \x01(\x0E2\x17.google.protobuf.Syntax\"\xD5\x01\x0A\x06Method\x12\x0C\x0A\x04name\x18\x01 \x01(\x09\x12\x18\x0A\x10request_type_url\x18\x02 \x01(\x09\x12\x19\x0A\x11request_streaming\x18\x03 \x01(\x08\x12\x19\x0A\x11response_type_url\x18\x04 \x01(\x09\x12\x1A\x0A\x12response_streaming\x18\x05 \x01(\x08\x12(\x0A\x07options\x18\x06 \x03(\x0B2\x17.google.protobuf.Option\x12'\x0A\x06syntax\x18\x07 \x01(\x0E2\x17.google.protobuf.Syntax\"#\x0A\x05Mixin\x12\x0C\x0A\x04name\x18\x01 \x01(\x09\x12\x0C\x0A\x04root\x18\x02 \x01(\x09Bv\x0A\x13com.google.protobufB\x08ApiProtoP\x01Z,google.golang.org/protobuf/types/known/apipb\xA2\x02\x03GPB\xAA\x02\x1EGoogle.Protobuf.WellKnownTypesb\x06proto3" + "\x0A\xF3\x05\x0A\x19google/protobuf/api.proto\x12\x0Fgoogle.protobuf\x1A\x1Agoogle/protobuf/type.proto\"\x92\x02\x0A\x03Api\x12\x0C\x0A\x04name\x18\x01 \x01(\x09\x12(\x0A\x07methods\x18\x02 \x03(\x0B2\x17.google.protobuf.Method\x12(\x0A\x07options\x18\x03 \x03(\x0B2\x17.google.protobuf.Option\x12\x0F\x0A\x07version\x18\x04 \x01(\x09\x126\x0A\x0Esource_context\x18\x05 \x01(\x0B2\x1E.google.protobuf.SourceContext\x12&\x0A\x06mixins\x18\x06 \x03(\x0B2\x16.google.protobuf.Mixin\x12'\x0A\x06syntax\x18\x07 \x01(\x0E2\x17.google.protobuf.Syntax\x12\x0F\x0A\x07edition\x18\x08 \x01(\x09\"\xEE\x01\x0A\x06Method\x12\x0C\x0A\x04name\x18\x01 \x01(\x09\x12\x18\x0A\x10request_type_url\x18\x02 \x01(\x09\x12\x19\x0A\x11request_streaming\x18\x03 \x01(\x08\x12\x19\x0A\x11response_type_url\x18\x04 \x01(\x09\x12\x1A\x0A\x12response_streaming\x18\x05 \x01(\x08\x12(\x0A\x07options\x18\x06 \x03(\x0B2\x17.google.protobuf.Option\x12+\x0A\x06syntax\x18\x07 \x01(\x0E2\x17.google.protobuf.SyntaxB\x02\x18\x01\x12\x13\x0A\x07edition\x18\x08 \x01(\x09B\x02\x18\x01\"#\x0A\x05Mixin\x12\x0C\x0A\x04name\x18\x01 \x01(\x09\x12\x0C\x0A\x04root\x18\x02 \x01(\x09Bv\x0A\x13com.google.protobufB\x08ApiProtoP\x01Z,google.golang.org/protobuf/types/known/apipb\xA2\x02\x03GPB\xAA\x02\x1EGoogle.Protobuf.WellKnownTypesb\x06proto3" , true); static::$is_initialized = true; diff --git a/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php b/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php index 84486a90b..9a80d8b16 100644 --- a/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php +++ b/lib/Google/vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php @@ -431,6 +431,7 @@ public static function initOnce() { ->value("EDITION_PROTO3", 999) ->value("EDITION_2023", 1000) ->value("EDITION_2024", 1001) + ->value("EDITION_UNSTABLE", 9999) ->value("EDITION_1_TEST_ONLY", 1) ->value("EDITION_2_TEST_ONLY", 2) ->value("EDITION_99997_TEST_ONLY", 99997) diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Api.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Api.php index 341c56984..a44c858dc 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Api.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Api.php @@ -18,6 +18,10 @@ * sometimes simply referred to as "APIs" in other contexts, such as the name of * this message itself. See https://cloud.google.com/apis/design/glossary for * detailed terminology. + * New usages of this message as an alternative to ServiceDescriptorProto are + * strongly discouraged. This message does not reliability preserve all + * information necessary to model the schema and preserve semantics. Instead + * make use of FileDescriptorSet which preserves the necessary information. * * Generated from protobuf message google.protobuf.Api */ @@ -83,6 +87,12 @@ class Api extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.protobuf.Syntax syntax = 7; */ protected $syntax = 0; + /** + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * + * Generated from protobuf field string edition = 8; + */ + protected $edition = ''; /** * Constructor. @@ -122,6 +132,8 @@ class Api extends \Google\Protobuf\Internal\Message * Included interfaces. See [Mixin][]. * @type int $syntax * The source syntax of the service. + * @type string $edition + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. * } */ public function __construct($data = NULL) { @@ -357,5 +369,31 @@ public function setSyntax($var) return $this; } + /** + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * + * Generated from protobuf field string edition = 8; + * @return string + */ + public function getEdition() + { + return $this->edition; + } + + /** + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * + * Generated from protobuf field string edition = 8; + * @param string $var + * @return $this + */ + public function setEdition($var) + { + GPBUtil::checkString($var, True); + $this->edition = $var; + + return $this; + } + } diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Enum.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Enum.php index 296b0a019..ea3be4056 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Enum.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Enum.php @@ -11,6 +11,10 @@ /** * Enum type definition. + * New usages of this message as an alternative to EnumDescriptorProto are + * strongly discouraged. This message does not reliability preserve all + * information necessary to model the schema and preserve semantics. Instead + * make use of FileDescriptorSet which preserves the necessary information. * * Generated from protobuf message google.protobuf.Enum */ diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/EnumValue.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/EnumValue.php index a782640b8..f9dfece17 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/EnumValue.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/EnumValue.php @@ -11,6 +11,10 @@ /** * Enum value definition. + * New usages of this message as an alternative to EnumValueDescriptorProto are + * strongly discouraged. This message does not reliability preserve all + * information necessary to model the schema and preserve semantics. Instead + * make use of FileDescriptorSet which preserves the necessary information. * * Generated from protobuf message google.protobuf.EnumValue */ diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Field.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Field.php index 405a2c0ad..727453027 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Field.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Field.php @@ -11,6 +11,10 @@ /** * A single field of a message type. + * New usages of this message as an alternative to FieldDescriptorProto are + * strongly discouraged. This message does not reliability preserve all + * information necessary to model the schema and preserve semantics. Instead + * make use of FileDescriptorSet which preserves the necessary information. * * Generated from protobuf message google.protobuf.Field */ diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/Edition.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/Edition.php index 7493ee1b8..a4df1fbc2 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/Edition.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/Edition.php @@ -52,6 +52,12 @@ class Edition * Generated from protobuf enum EDITION_2024 = 1001; */ const EDITION_2024 = 1001; + /** + * A placeholder edition for developing and testing unscheduled features. + * + * Generated from protobuf enum EDITION_UNSTABLE = 9999; + */ + const EDITION_UNSTABLE = 9999; /** * Placeholder editions for testing feature resolution. These should not be * used or relied on outside of tests. @@ -91,6 +97,7 @@ class Edition self::EDITION_PROTO3 => 'EDITION_PROTO3', self::EDITION_2023 => 'EDITION_2023', self::EDITION_2024 => 'EDITION_2024', + self::EDITION_UNSTABLE => 'EDITION_UNSTABLE', self::EDITION_1_TEST_ONLY => 'EDITION_1_TEST_ONLY', self::EDITION_2_TEST_ONLY => 'EDITION_2_TEST_ONLY', self::EDITION_99997_TEST_ONLY => 'EDITION_99997_TEST_ONLY', diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/FieldOptions.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/FieldOptions.php index 0e6bff555..5442e5182 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/FieldOptions.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/FieldOptions.php @@ -97,9 +97,11 @@ class FieldOptions extends \Google\Protobuf\Internal\Message */ protected $deprecated = null; /** + * DEPRECATED. DO NOT USE! * For Google-internal migration only. Do not use. * - * Generated from protobuf field optional bool weak = 10 [default = false]; + * Generated from protobuf field optional bool weak = 10 [default = false, deprecated = true]; + * @deprecated */ protected $weak = null; /** @@ -204,6 +206,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * for accessors, or it will be completely ignored; in the very least, this * is a formalization for deprecating fields. * @type bool $weak + * DEPRECATED. DO NOT USE! * For Google-internal migration only. Do not use. * @type bool $debug_redact * Indicate that the field value should not be printed out when using debug @@ -531,35 +534,47 @@ public function setDeprecated($var) } /** + * DEPRECATED. DO NOT USE! * For Google-internal migration only. Do not use. * - * Generated from protobuf field optional bool weak = 10 [default = false]; + * Generated from protobuf field optional bool weak = 10 [default = false, deprecated = true]; * @return bool + * @deprecated */ public function getWeak() { + if (isset($this->weak)) { + @trigger_error('weak is deprecated.', E_USER_DEPRECATED); + } return isset($this->weak) ? $this->weak : false; } public function hasWeak() { + if (isset($this->weak)) { + @trigger_error('weak is deprecated.', E_USER_DEPRECATED); + } return isset($this->weak); } public function clearWeak() { + @trigger_error('weak is deprecated.', E_USER_DEPRECATED); unset($this->weak); } /** + * DEPRECATED. DO NOT USE! * For Google-internal migration only. Do not use. * - * Generated from protobuf field optional bool weak = 10 [default = false]; + * Generated from protobuf field optional bool weak = 10 [default = false, deprecated = true]; * @param bool $var * @return $this + * @deprecated */ public function setWeak($var) { + @trigger_error('weak is deprecated.', E_USER_DEPRECATED); GPBUtil::checkBool($var); $this->weak = $var; diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBDecodeException.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBDecodeException.php index 6a143a2a0..7104109fa 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBDecodeException.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBDecodeException.php @@ -14,7 +14,7 @@ class GPBDecodeException extends \Exception public function __construct( $message, $code = 0, - \Exception $previous = null) + ?\Exception $previous = null) { parent::__construct( "Error occurred during parsing: " . $message, diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/RepeatedField.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/RepeatedField.php index cd6ef02cb..face4fc67 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/RepeatedField.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Internal/RepeatedField.php @@ -7,7 +7,7 @@ * This class is deprecated. Use Google\Protobuf\RepeatedField instead. * @deprecated */ - class RepeatedField {} + class RepeatedField extends \Google\Protobuf\RepeatedField {} } class_exists(\Google\Protobuf\RepeatedField::class); @trigger_error('Google\Protobuf\Internal\RepeatedField is deprecated and will be removed in the next major release. Use Google\Protobuf\RepeatedField instead', E_USER_DEPRECATED); diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Method.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Method.php index 5e55a764c..6eb9c358c 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Method.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Method.php @@ -11,6 +11,10 @@ /** * Method represents a method of an API interface. + * New usages of this message as an alternative to MethodDescriptorProto are + * strongly discouraged. This message does not reliability preserve all + * information necessary to model the schema and preserve semantics. Instead + * make use of FileDescriptorSet which preserves the necessary information. * * Generated from protobuf message google.protobuf.Method */ @@ -54,10 +58,22 @@ class Method extends \Google\Protobuf\Internal\Message private $options; /** * The source syntax of this method. + * This field should be ignored, instead the syntax should be inherited from + * Api. This is similar to Field and EnumValue. * - * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * Generated from protobuf field .google.protobuf.Syntax syntax = 7 [deprecated = true]; + * @deprecated */ protected $syntax = 0; + /** + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * This field should be ignored, instead the edition should be inherited from + * Api. This is similar to Field and EnumValue. + * + * Generated from protobuf field string edition = 8 [deprecated = true]; + * @deprecated + */ + protected $edition = ''; /** * Constructor. @@ -79,6 +95,12 @@ class Method extends \Google\Protobuf\Internal\Message * Any metadata attached to the method. * @type int $syntax * The source syntax of this method. + * This field should be ignored, instead the syntax should be inherited from + * Api. This is similar to Field and EnumValue. + * @type string $edition + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * This field should be ignored, instead the edition should be inherited from + * Api. This is similar to Field and EnumValue. * } */ public function __construct($data = NULL) { @@ -244,29 +266,75 @@ public function setOptions($var) /** * The source syntax of this method. + * This field should be ignored, instead the syntax should be inherited from + * Api. This is similar to Field and EnumValue. * - * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * Generated from protobuf field .google.protobuf.Syntax syntax = 7 [deprecated = true]; * @return int + * @deprecated */ public function getSyntax() { + if ($this->syntax !== 0) { + @trigger_error('syntax is deprecated.', E_USER_DEPRECATED); + } return $this->syntax; } /** * The source syntax of this method. + * This field should be ignored, instead the syntax should be inherited from + * Api. This is similar to Field and EnumValue. * - * Generated from protobuf field .google.protobuf.Syntax syntax = 7; + * Generated from protobuf field .google.protobuf.Syntax syntax = 7 [deprecated = true]; * @param int $var * @return $this + * @deprecated */ public function setSyntax($var) { + @trigger_error('syntax is deprecated.', E_USER_DEPRECATED); GPBUtil::checkEnum($var, \Google\Protobuf\Syntax::class); $this->syntax = $var; return $this; } + /** + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * This field should be ignored, instead the edition should be inherited from + * Api. This is similar to Field and EnumValue. + * + * Generated from protobuf field string edition = 8 [deprecated = true]; + * @return string + * @deprecated + */ + public function getEdition() + { + if ($this->edition !== '') { + @trigger_error('edition is deprecated.', E_USER_DEPRECATED); + } + return $this->edition; + } + + /** + * The source edition string, only valid when syntax is SYNTAX_EDITIONS. + * This field should be ignored, instead the edition should be inherited from + * Api. This is similar to Field and EnumValue. + * + * Generated from protobuf field string edition = 8 [deprecated = true]; + * @param string $var + * @return $this + * @deprecated + */ + public function setEdition($var) + { + @trigger_error('edition is deprecated.', E_USER_DEPRECATED); + GPBUtil::checkString($var, True); + $this->edition = $var; + + return $this; + } + } diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Option.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Option.php index 7674fda83..4dc52ca23 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Option.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Option.php @@ -12,6 +12,9 @@ /** * A protocol buffer option, which can be attached to a message, field, * enumeration, etc. + * New usages of this message as an alternative to FileOptions, MessageOptions, + * FieldOptions, EnumOptions, EnumValueOptions, ServiceOptions, or MethodOptions + * are strongly discouraged. * * Generated from protobuf message google.protobuf.Option */ diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Timestamp.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Timestamp.php index 54d675cb2..bd23d8076 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Timestamp.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Timestamp.php @@ -82,17 +82,18 @@ class Timestamp extends \Google\Protobuf\Internal\TimestampBase { /** - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. + * Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must + * be between -315576000000 and 315576000000 inclusive (which corresponds to + * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). * * Generated from protobuf field int64 seconds = 1; */ protected $seconds = 0; /** - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 + * Non-negative fractions of a second at nanosecond resolution. This field is + * the nanosecond portion of the duration, not an alternative to seconds. + * Negative second values with fractions must still have non-negative nanos + * values that count forward in time. Must be between 0 and 999,999,999 * inclusive. * * Generated from protobuf field int32 nanos = 2; @@ -106,13 +107,14 @@ class Timestamp extends \Google\Protobuf\Internal\TimestampBase * Optional. Data for populating the Message object. * * @type int|string $seconds - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. + * Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must + * be between -315576000000 and 315576000000 inclusive (which corresponds to + * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). * @type int $nanos - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 + * Non-negative fractions of a second at nanosecond resolution. This field is + * the nanosecond portion of the duration, not an alternative to seconds. + * Negative second values with fractions must still have non-negative nanos + * values that count forward in time. Must be between 0 and 999,999,999 * inclusive. * } */ @@ -122,9 +124,9 @@ public function __construct($data = NULL) { } /** - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. + * Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must + * be between -315576000000 and 315576000000 inclusive (which corresponds to + * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). * * Generated from protobuf field int64 seconds = 1; * @return int|string @@ -135,9 +137,9 @@ public function getSeconds() } /** - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. + * Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must + * be between -315576000000 and 315576000000 inclusive (which corresponds to + * 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). * * Generated from protobuf field int64 seconds = 1; * @param int|string $var @@ -152,9 +154,10 @@ public function setSeconds($var) } /** - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 + * Non-negative fractions of a second at nanosecond resolution. This field is + * the nanosecond portion of the duration, not an alternative to seconds. + * Negative second values with fractions must still have non-negative nanos + * values that count forward in time. Must be between 0 and 999,999,999 * inclusive. * * Generated from protobuf field int32 nanos = 2; @@ -166,9 +169,10 @@ public function getNanos() } /** - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 + * Non-negative fractions of a second at nanosecond resolution. This field is + * the nanosecond portion of the duration, not an alternative to seconds. + * Negative second values with fractions must still have non-negative nanos + * values that count forward in time. Must be between 0 and 999,999,999 * inclusive. * * Generated from protobuf field int32 nanos = 2; diff --git a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Type.php b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Type.php index c274909ab..ef37e778a 100644 --- a/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Type.php +++ b/lib/Google/vendor/google/protobuf/src/Google/Protobuf/Type.php @@ -11,6 +11,10 @@ /** * A protocol buffer message type. + * New usages of this message as an alternative to DescriptorProto are strongly + * discouraged. This message does not reliability preserve all information + * necessary to model the schema and preserve semantics. Instead make use of + * FileDescriptorSet which preserves the necessary information. * * Generated from protobuf message google.protobuf.Type */ diff --git a/lib/Google/vendor/monolog/monolog/CHANGELOG.md b/lib/Google/vendor/monolog/monolog/CHANGELOG.md index 122d85cde..2c89f9d18 100644 --- a/lib/Google/vendor/monolog/monolog/CHANGELOG.md +++ b/lib/Google/vendor/monolog/monolog/CHANGELOG.md @@ -1,3 +1,172 @@ +### 3.10.0 (2026-01-02) + + * Added automatic directory cleanup in RotatingFileHandler (#2000) + * Added timezone-aware file rotation to RotatingFileHandler (#1982) + * Added support for mongodb/mongodb 2.0+ (#1998) + * Added NoDiscard attribute to TestHandler methods to ensure the result is used (#2013) + * Fixed JsonFormatter crashing if __toString throws while normalizing data (#1968) + * Fixed PHP 8.5 deprecation warnings (#1997, #2009) + * Fixed DeduplicatingHandler collecting duplicate logs if the file cannot be locked (2e97231) + * Fixed GelfMessageFormatter to use integers instead of bool for gelf 1.1 support (#1973) + * Fixed empty stack traces being output anyway (#1979) + * Fixed StreamHandler not reopening the file if the inode changed (#1963) + * Fixed TelegramBotHandler sending empty messages (#1992) + * Fixed file paths in stack traces containing backslashes on windows, always using / now to unify logs (#1980) + * Fixed RotatingFileHandler unlink errors not being suppressed correctly (#1999) + +### 3.9.0 (2025-03-24) + + * BC Warning: Fixed SendGridHandler to use the V3 API as V2 is now shut down, but this requires a new API key (#1952) + * Deprecated Monolog\Test\TestCase in favor of Monolog\Test\MonologTestCase (#1953) + * Added extension point for NativeMailerHandler::mail (#1948) + * Added setHandler method to BufferHandler to modify the nested handler at runtime (#1946) + * Fixed date format in ElasticsearchFormatter to use +00:00 vs +0000 tz identifiers (#1942) + * Fixed GelfMessageFormatter handling numeric context/extra keys (#1932) + +### 3.8.1 (2024-12-05) + + * Deprecated Monolog\DateTimeImmutable in favor of Monolog\JsonSerializableDateTimeImmutable (#1928) + * Fixed gelf keys not being valid when context/extra data keys have spaces in them (#1927) + * Fixed empty lines appearing in the stack traces when a custom formatter returned null (#1925) + +### 3.8.0 (2024-11-12) + + * Added `$fileOpenMode` param to `StreamHandler` to define a custom fopen mode to open the log file (#1913) + * Fixed PHP 8.4 deprecation notices (#1903) + * Added ability to extend/override `IntrospectionProcessor` (#1899) + * Added `$timeout` param to `ProcessHandler` to configure the stream_select() timeout to avoid blocking too long (default is 1.0 sec) (#1916) + * Fixed JsonFormatter batch handling to normalize records individually to make sure they look the same as if they were handled one by one (#1906) + * Fixed `StreamHandler` handling of write failures so that it now closes/reopens the stream and retries the write once before failing (#1882) + * Fixed `StreamHandler` error handler causing issues if a stream handler triggers an error (#1866) + * Fixed `StreamHandler::reset` not closing the stream, so that it would fail to write in some cases with long running processes (#1862) + * Fixed `RotatingFileHandler` issue where rotation does not happen in some long running processes (#1905) + * Fixed `JsonFormatter` handling of incomplete classes (#1834) + * Fixed `RotatingFileHandler` bug where rotation could sometimes not happen correctly (#1905) + +### 3.7.0 (2024-06-28) + + * Added `NormalizerFormatter->setBasePath(...)` (and `JsonFormatter` by extension) that allows removing the project's path from the stack trace output (47e301d3e) + * Fixed JsonFormatter handling of incomplete classes (#1834) + * Fixed private error handlers causing problems with custom StreamHandler implementations (#1866) + +### 3.6.0 (2024-04-12) + + * Added `LineFormatter->setBasePath(...)` that allows removing the project's path from the stack trace output (#1873) + * Added `$includeExtra` option in `PsrHandler` to also use extra data to replace placeholder values in the message (#1852) + * Added ability to customize what is a duplicated message by extending the `DeduplicationHandler` (#1879) + * Added handling for using `GelfMessageFormatter` together with the `AmqpHandler` (#1869) + * Added ability to extend `GoogleCloudLoggingFormatter` (#1859) + * Fixed `__toString` failures in context data crashing the normalization process (#1868) + * Fixed PHP 8.4 deprecation warnings (#1874) + +### 3.5.0 (2023-10-27) + + * Added ability to indent stack traces in LineFormatter via e.g. `indentStacktraces(' ')` (#1835) + * Added ability to configure a max level name length in LineFormatter via e.g. `setMaxLevelNameLength(3)` (#1850) + * Added support for indexed arrays (i.e. `[]` and not `{}` arrays once json serialized) containing inline linebreaks in LineFormatter (#1818) + * Added `WithMonologChannel` attribute for integrators to use to configure autowiring (#1847) + * Fixed log record `extra` data leaking between handlers that have handler-specific processors set (#1819) + * Fixed LogglyHandler issue with record level filtering (#1841) + * Fixed display_errors parsing in ErrorHandler which did not support string values (#1804) + * Fixed bug where the previous error handler would not be restored in some cases where StreamHandler fails (#1815) + * Fixed normalization error when normalizing incomplete classes (#1833) + +### 3.4.0 (2023-06-21) + + * Added `LoadAverageProcessor` to track one of the 1, 5 or 15min load averages (#1803) + * Added support for priority to the `AsMonologProcessor` attribute (#1797) + * Added `TelegramBotHandler` `topic`/`message_thread_id` support (#1802) + * Fixed `FingersCrossedHandler` passthruLevel checking (#1801) + * Fixed support of yearly and monthly rotation log file to rotate only once a month/year (#1805) + * Fixed `TestHandler` method docs (#1794) + * Fixed handling of falsey `display_errors` string values (#1804) + +### 3.3.1 (2023-02-06) + + * Fixed Logger not being serializable anymore (#1792) + +### 3.3.0 (2023-02-06) + + * Deprecated FlowdockHandler & Formatter as the flowdock service was shutdown (#1748) + * Added `ClosureContextProcessor` to allow delaying the creation of context data by setting a Closure in context which is called when the log record is used (#1745) + * Added an ElasticsearchHandler option to set the `op_type` to `create` instead of the default `index` (#1766) + * Added support for enum context values in PsrLogMessageProcessor (#1773) + * Added graylog2/gelf-php 2.x support (#1747) + * Improved `BrowserConsoleHandler` logging to use more appropriate methods than just console.log in the browser (#1739) + * Fixed GitProcessor not filtering correctly based on Level (#1749) + * Fixed `WhatFailureGroupHandler` not catching errors happening inside `close()` (#1791) + * Fixed datetime field in `GoogleCloudLoggingFormatter` (#1758) + * Fixed infinite loop detection within Fibers (#1753) + * Fixed `AmqpHandler->setExtraAttributes` not working with buffering handler wrappers (#1781) + +### 3.2.0 (2022-07-24) + + * Deprecated `CubeHandler` and `PHPConsoleHandler` as both projects are abandoned and those should not be used anymore (#1734) + * Marked `Logger` `@final` as it should not be extended, prefer composition or talk to us if you are missing something + * Added RFC 5424 level (`7` to `0`) support to `Logger::log` and `Logger::addRecord` to increase interoperability (#1723) + * Added `SyslogFormatter` to output syslog-like files which can be consumed by tools like [lnav](https://lnav.org/) (#1689) + * Added support for `__toString` for objects which are not json serializable in `JsonFormatter` (#1733) + * Added `GoogleCloudLoggingFormatter` (#1719) + * Added support for Predis 2.x (#1732) + * Added `AmqpHandler->setExtraAttributes` to allow configuring attributes when using an AMQPExchange (#1724) + * Fixed serialization/unserialization of handlers to make sure private properties are included (#1727) + * Fixed allowInlineLineBreaks in LineFormatter causing issues with windows paths containing `\n` or `\r` sequences (#1720) + * Fixed max normalization depth not being taken into account when formatting exceptions with a deep chain of previous exceptions (#1726) + * Fixed PHP 8.2 deprecation warnings (#1722) + * Fixed rare race condition or filesystem issue where StreamHandler is unable to create the directory the log should go into yet it exists already (#1678) + +### 3.1.0 (2022-06-09) + + * Added `$datetime` parameter to `Logger::addRecord` as low level API to allow logging into the past or future (#1682) + * Added `Logger::useLoggingLoopDetection` to allow disabling cyclic logging detection in concurrent frameworks (#1681) + * Fixed handling of fatal errors if callPrevious is disabled in ErrorHandler (#1670) + * Fixed interop issue by removing the need for a return type in ProcessorInterface (#1680) + * Marked the reusable `Monolog\Test\TestCase` class as `@internal` to make sure PHPStorm does not show it above PHPUnit, you may still use it to test your own handlers/etc though (#1677) + * Fixed RotatingFileHandler issue when the date format contained slashes (#1671) + +### 3.0.0 (2022-05-10) + +Changes from RC1 + +- The `Monolog\LevelName` enum does not exist anymore, use `Monolog\Level->getName()` instead. + +### 3.0.0-RC1 (2022-05-08) + +This is mostly a cleanup release offering stronger type guarantees for integrators with the +array->object/enum changes, but there is no big new feature for end users. + +See [UPGRADE notes](UPGRADE.md#300) for details on all breaking changes especially if you are extending/implementing Monolog classes/interfaces. + +Noteworthy BC Breaks: + +- The minimum supported PHP version is now `8.1.0`. +- Log records have been converted from an array to a [`Monolog\LogRecord` object](src/Monolog/LogRecord.php) + with public (and mostly readonly) properties. e.g. instead of doing + `$record['context']` use `$record->context`. + In formatters or handlers if you rather need an array to work with you can use `$record->toArray()` + to get back a Monolog 1/2 style record array. This will contain the enum values instead of enum cases + in the `level` and `level_name` keys to be more backwards compatible and use simpler data types. +- `FormatterInterface`, `HandlerInterface`, `ProcessorInterface`, etc. changed to contain `LogRecord $record` + instead of `array $record` parameter types. If you want to support multiple Monolog versions this should + be possible by type-hinting nothing, or `array|LogRecord` if you support PHP 8.0+. You can then code + against the $record using Monolog 2 style as LogRecord implements ArrayAccess for BC. + The interfaces do not require a `LogRecord` return type even where it would be applicable, but if you only + support Monolog 3 in integration code I would recommend you use `LogRecord` return types wherever fitting + to ensure forward compatibility as it may be added in Monolog 4. +- Log levels are now enums [`Monolog\Level`](src/Monolog/Level.php) and [`Monolog\LevelName`](src/Monolog/LevelName.php) +- Removed deprecated SwiftMailerHandler, migrate to SymfonyMailerHandler instead. +- `ResettableInterface::reset()` now requires a void return type. +- All properties have had types added, which may require you to do so as well if you extended + a Monolog class and declared the same property. + +New deprecations: + +- `Logger::DEBUG`, `Logger::ERROR`, etc. are now deprecated in favor of the `Monolog\Level` enum. + e.g. instead of `Logger::WARNING` use `Level::Warning` if you need to pass the enum case + to Monolog or one of its handlers, or `Level::Warning->value` if you need the integer + value equal to what `Logger::WARNING` was giving you. +- `Logger::getLevelName()` is now deprecated. + ### 2.10.0 (2024-11-12) * Added `$fileOpenMode` to `StreamHandler` to define a custom fopen mode to open the log file (#1913) diff --git a/lib/Google/vendor/monolog/monolog/README.md b/lib/Google/vendor/monolog/monolog/README.md index bfcae0c00..0564f96f0 100644 --- a/lib/Google/vendor/monolog/monolog/README.md +++ b/lib/Google/vendor/monolog/monolog/README.md @@ -1,8 +1,12 @@ +

Monolog

+ # Monolog - Logging for PHP [![Continuous Integration](https://github.com/Seldaek/monolog/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/Seldaek/monolog/actions) [![Total Downloads](https://img.shields.io/packagist/dt/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog) [![Latest Stable Version](https://img.shields.io/packagist/v/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog) +>**Note** This is the **documentation for Monolog 3.x**, if you are using older releases +>see the documentation for [Monolog 2.x](https://github.com/Seldaek/monolog/blob/2.x/README.md) or [Monolog 1.x](https://github.com/Seldaek/monolog/blob/1.x/README.md) Monolog sends your logs to files, sockets, inboxes, databases and various web services. See the complete list of handlers below. Special handlers @@ -15,12 +19,28 @@ make sure you can always use another compatible logger at a later time. As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels. Internally Monolog still uses its own level scheme since it predates PSR-3. + + ## Installation Install the latest version with ```bash -$ composer require monolog/monolog +composer require monolog/monolog ``` ## Basic Usage @@ -28,12 +48,13 @@ $ composer require monolog/monolog ```php pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); +$log->pushHandler(new StreamHandler('path/to/your.log', Level::Warning)); // add records to the log $log->warning('Foo'); @@ -50,7 +71,7 @@ $log->error('Bar'); ## Support Monolog Financially -Get supported Monolog and help fund the project with the [Tidelift Subscription](https://tidelift.com/subscription/pkg/packagist-monolog-monolog?utm_source=packagist-monolog-monolog&utm_medium=referral&utm_campaign=enterprise) or via [GitHub sponsorship](https://github.com/sponsors/Seldaek). +Get supported Monolog and help fund the project with the [Tidelift Subscription](https://tidelift.com/subscription/pkg/packagist-monolog-monolog?utm_source=packagist-monolog-monolog&utm_medium=referral&utm_campaign=enterprise) or via [GitHub sponsorship](https://github.com/sponsors/Seldaek). Tidelift delivers commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. @@ -64,11 +85,13 @@ can also add your own there if you publish one. ### Requirements -- Monolog `^2.0` works with PHP 7.2 or above, use Monolog `^1.25` for PHP 5.3+ support. +- Monolog `^3.0` works with PHP 8.1 or above. +- Monolog `^2.5` works with PHP 7.2 or above. +- Monolog `^1.25` works with PHP 5.3 up to 8.1, but is not very maintained anymore and will not receive PHP support fixes anymore. ### Support -Monolog 1.x support is somewhat limited at this point and only important fixes will be done. You should migrate to Monolog 2 where possible to benefit from all the latest features and fixes. +Monolog 1.x support is somewhat limited at this point and only important fixes will be done. You should migrate to Monolog 2 or 3 where possible to benefit from all the latest features and fixes. ### Submitting bugs and feature requests @@ -83,7 +106,6 @@ Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/mono - [Lumen](http://lumen.laravel.com/) comes out of the box with Monolog. - [PPI](https://github.com/ppi/framework) comes out of the box with Monolog. - [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin. -- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer. - [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog. - [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog. - [Nette Framework](http://nette.org/en/) is usable with Monolog via the [contributte/monolog](https://github.com/contributte/monolog) or [orisai/nette-monolog](https://github.com/orisai/nette-monolog) extensions. @@ -96,6 +118,8 @@ Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/mono - [Drupal](https://www.drupal.org/) is usable with Monolog via the [monolog](https://www.drupal.org/project/monolog) module. - [Aimeos ecommerce framework](https://aimeos.org/) is usable with Monolog via the [ai-monolog](https://github.com/aimeos/ai-monolog) extension. - [Magento](https://magento.com/) comes out of the box with Monolog. +- [Spiral Framework](https://spiral.dev) comes out of the box with Monolog bridge. +- [WebFramework](https://web-framework.com/) comes out of the box with Monolog. ### Author diff --git a/lib/Google/vendor/monolog/monolog/UPGRADE.md b/lib/Google/vendor/monolog/monolog/UPGRADE.md deleted file mode 100644 index 84e15e6b7..000000000 --- a/lib/Google/vendor/monolog/monolog/UPGRADE.md +++ /dev/null @@ -1,72 +0,0 @@ -### 2.0.0 - -- `Monolog\Logger::API` can be used to distinguish between a Monolog `1` and `2` - install of Monolog when writing integration code. - -- Removed non-PSR-3 methods to add records, all the `add*` (e.g. `addWarning`) - methods as well as `emerg`, `crit`, `err` and `warn`. - -- DateTime are now formatted with a timezone and microseconds (unless disabled). - Various formatters and log output might be affected, which may mess with log parsing - in some cases. - -- The `datetime` in every record array is now a DateTimeImmutable, not that you - should have been modifying these anyway. - -- The timezone is now set per Logger instance and not statically, either - via ->setTimezone or passed in the constructor. Calls to Logger::setTimezone - should be converted. - -- `HandlerInterface` has been split off and two new interfaces now exist for - more granular controls: `ProcessableHandlerInterface` and - `FormattableHandlerInterface`. Handlers not extending `AbstractHandler` - should make sure to implement the relevant interfaces. - -- `HandlerInterface` now requires the `close` method to be implemented. This - only impacts you if you implement the interface yourself, but you can extend - the new `Monolog\Handler\Handler` base class too. - -- There is no more default handler configured on empty Logger instances, if - you were relying on that you will not get any output anymore, make sure to - configure the handler you need. - -#### LogglyFormatter - -- The records' `datetime` is not sent anymore. Only `timestamp` is sent to Loggly. - -#### AmqpHandler - -- Log levels are not shortened to 4 characters anymore. e.g. a warning record - will be sent using the `warning.channel` routing key instead of `warn.channel` - as in 1.x. -- The exchange name does not default to 'log' anymore, and it is completely ignored - now for the AMQP extension users. Only PHPAmqpLib uses it if provided. - -#### RotatingFileHandler - -- The file name format must now contain `{date}` and the date format must be set - to one of the predefined FILE_PER_* constants to avoid issues with file rotation. - See `setFilenameFormat`. - -#### LogstashFormatter - -- Removed Logstash V0 support -- Context/extra prefix has been removed in favor of letting users configure the exact key being sent -- Context/extra data are now sent as an object instead of single keys - -#### HipChatHandler - -- Removed deprecated HipChat handler, migrate to Slack and use SlackWebhookHandler or SlackHandler instead - -#### SlackbotHandler - -- Removed deprecated SlackbotHandler handler, use SlackWebhookHandler or SlackHandler instead - -#### RavenHandler - -- Removed deprecated RavenHandler handler, use sentry/sentry 2.x and their Sentry\Monolog\Handler instead - -#### ElasticSearchHandler - -- As support for the official Elasticsearch library was added, the former ElasticSearchHandler has been - renamed to ElasticaHandler and the new one added as ElasticsearchHandler. diff --git a/lib/Google/vendor/monolog/monolog/composer.json b/lib/Google/vendor/monolog/monolog/composer.json index a1f08a22d..b0fb2d7a5 100644 --- a/lib/Google/vendor/monolog/monolog/composer.json +++ b/lib/Google/vendor/monolog/monolog/composer.json @@ -13,26 +13,27 @@ } ], "require": { - "php": ">=7.2", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" }, "require-dev": { "ext-json": "*", - "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "aws/aws-sdk-php": "^3.0", "doctrine/couchdb": "~1.0@dev", "elasticsearch/elasticsearch": "^7 || ^8", - "graylog2/gelf-php": "^1.4.2 || ^2@dev", - "guzzlehttp/guzzle": "^7.4", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", + "mongodb/mongodb": "^1.8 || ^2.0", "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpspec/prophecy": "^1.15", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.5.38 || ^9.6.19", - "predis/predis": "^1.1 || ^2.0", - "rollbar/rollbar": "^1.3 || ^2 || ^3", - "ruflin/elastica": "^7", - "swiftmailer/swiftmailer": "^5.3|^6.0", + "php-console/php-console": "^3.1.8", + "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "^10.5.17 || ^11.0.7", + "predis/predis": "^1.1 || ^2", + "rollbar/rollbar": "^4.0", + "ruflin/elastica": "^7 || ^8", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" }, @@ -59,11 +60,11 @@ "psr-4": {"Monolog\\": "tests/Monolog"} }, "provide": { - "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + "psr/log-implementation": "3.0.0" }, "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "scripts": { @@ -75,7 +76,7 @@ "sort-packages": true, "platform-check": false, "allow-plugins": { - "composer/package-versions-deprecated": true + "php-http/discovery": false } } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php index 188bbb0d8..c519e0537 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php @@ -13,34 +13,26 @@ /** * A reusable attribute to help configure a class or a method as a processor. - * + * * Using it offers no guarantee: it needs to be leveraged by a Monolog third-party consumer. - * + * * Using it with the Monolog library only has no effect at all: processors should still be turned into a callable if * needed and manually pushed to the loggers and to the processable handlers. */ #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class AsMonologProcessor { - /** @var string|null */ - public $channel = null; - /** @var string|null */ - public $handler = null; - /** @var string|null */ - public $method = null; - /** * @param string|null $channel The logging channel the processor should be pushed to. * @param string|null $handler The handler the processor should be pushed to. * @param string|null $method The method that processes the records (if the attribute is used at the class level). + * @param int|null $priority The priority of the processor so the order can be determined. */ public function __construct( - ?string $channel = null, - ?string $handler = null, - ?string $method = null + public readonly ?string $channel = null, + public readonly ?string $handler = null, + public readonly ?string $method = null, + public readonly ?int $priority = null ) { - $this->channel = $channel; - $this->handler = $handler; - $this->method = $method; } -} +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/WithMonologChannel.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/WithMonologChannel.php new file mode 100644 index 000000000..862e05b33 --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Attribute/WithMonologChannel.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Attribute; + +/** + * A reusable attribute to help configure a class as expecting a given logger channel. + * + * Using it offers no guarantee: it needs to be leveraged by a Monolog third-party consumer. + * + * Using it with the Monolog library only has no effect at all: wiring the logger instance into + * other classes is not managed by Monolog. + */ +#[\Attribute(\Attribute::TARGET_CLASS)] +final class WithMonologChannel +{ + public function __construct( + public readonly string $channel + ) { + } +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php b/lib/Google/vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php index 789f9bfc4..3cb7086d7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php @@ -11,41 +11,14 @@ namespace Monolog; -use DateTimeZone; +class_alias(JsonSerializableDateTimeImmutable::class, 'Monolog\DateTimeImmutable'); -/** - * Overrides default json encoding of date time objects - * - * @author Menno Holtkamp - * @author Jordi Boggiano - */ -class DateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable -{ +// @phpstan-ignore-next-line +if (false) { /** - * @var bool + * @deprecated Use \Monolog\JsonSerializableDateTimeImmutable instead. */ - private $useMicroseconds; - - public function __construct(bool $useMicroseconds, ?DateTimeZone $timezone = null) - { - $this->useMicroseconds = $useMicroseconds; - - // if you like to use a custom time to pass to Logger::addRecord directly, - // call modify() or setTimestamp() on this instance to change the date after creating it - parent::__construct('now', $timezone); - } - - public function jsonSerialize(): string - { - if ($this->useMicroseconds) { - return $this->format('Y-m-d\TH:i:s.uP'); - } - - return $this->format('Y-m-d\TH:i:sP'); - } - - public function __toString(): string + class DateTimeImmutable extends JsonSerializableDateTimeImmutable { - return $this->jsonSerialize(); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/ErrorHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/ErrorHandler.php index 1406d34e8..805f2dfd9 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/ErrorHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/ErrorHandler.php @@ -11,6 +11,7 @@ namespace Monolog; +use Closure; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -25,35 +26,33 @@ */ class ErrorHandler { - /** @var LoggerInterface */ - private $logger; + private Closure|null $previousExceptionHandler = null; - /** @var ?callable */ - private $previousExceptionHandler = null; /** @var array an array of class name to LogLevel::* constant mapping */ - private $uncaughtExceptionLevelMap = []; + private array $uncaughtExceptionLevelMap = []; + + /** @var Closure|true|null */ + private Closure|bool|null $previousErrorHandler = null; - /** @var callable|true|null */ - private $previousErrorHandler = null; /** @var array an array of E_* constant to LogLevel::* constant mapping */ - private $errorLevelMap = []; - /** @var bool */ - private $handleOnlyReportedErrors = true; - - /** @var bool */ - private $hasFatalErrorHandler = false; - /** @var LogLevel::* */ - private $fatalLevel = LogLevel::ALERT; - /** @var ?string */ - private $reservedMemory = null; + private array $errorLevelMap = []; + + private bool $handleOnlyReportedErrors = true; + + private bool $hasFatalErrorHandler = false; + + private string $fatalLevel = LogLevel::ALERT; + + private string|null $reservedMemory = null; + /** @var ?array{type: int, message: string, file: string, line: int, trace: mixed} */ - private $lastFatalData = null; - /** @var int[] */ - private static $fatalErrors = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR]; + private array|null $lastFatalData = null; - public function __construct(LoggerInterface $logger) - { - $this->logger = $logger; + private const FATAL_ERRORS = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR]; + + public function __construct( + private LoggerInterface $logger + ) { } /** @@ -61,11 +60,10 @@ public function __construct(LoggerInterface $logger) * * By default it will handle errors, exceptions and fatal errors * - * @param LoggerInterface $logger * @param array|false $errorLevelMap an array of E_* constant to LogLevel::* constant mapping, or false to disable error handling * @param array|false $exceptionLevelMap an array of class name to LogLevel::* constant mapping, or false to disable exception handling * @param LogLevel::*|null|false $fatalLevel a LogLevel::* constant, null to use the default LogLevel::ALERT or false to disable fatal error handling - * @return ErrorHandler + * @return static */ public static function register(LoggerInterface $logger, $errorLevelMap = [], $exceptionLevelMap = [], $fatalLevel = null): self { @@ -99,8 +97,8 @@ public function registerExceptionHandler(array $levelMap = [], bool $callPreviou $this->uncaughtExceptionLevelMap[$class] = $level; } } - if ($callPrevious && $prev) { - $this->previousExceptionHandler = $prev; + if ($callPrevious && null !== $prev) { + $this->previousExceptionHandler = $prev(...); } return $this; @@ -112,10 +110,10 @@ public function registerExceptionHandler(array $levelMap = [], bool $callPreviou */ public function registerErrorHandler(array $levelMap = [], bool $callPrevious = true, int $errorTypes = -1, bool $handleOnlyReportedErrors = true): self { - $prev = set_error_handler([$this, 'handleError'], $errorTypes); + $prev = set_error_handler($this->handleError(...), $errorTypes); $this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap); if ($callPrevious) { - $this->previousErrorHandler = $prev ?: true; + $this->previousErrorHandler = $prev !== null ? $prev(...) : true; } else { $this->previousErrorHandler = null; } @@ -126,12 +124,13 @@ public function registerErrorHandler(array $levelMap = [], bool $callPrevious = } /** - * @param LogLevel::*|null $level a LogLevel::* constant, null to use the default LogLevel::ALERT - * @param int $reservedMemorySize Amount of KBs to reserve in memory so that it can be freed when handling fatal errors giving Monolog some room in memory to get its job done + * @param LogLevel::*|null $level a LogLevel::* constant, null to use the default LogLevel::ALERT + * @param int $reservedMemorySize Amount of KBs to reserve in memory so that it can be freed when handling fatal errors giving Monolog some room in memory to get its job done + * @return $this */ public function registerFatalHandler($level = null, int $reservedMemorySize = 20): self { - register_shutdown_function([$this, 'handleFatalError']); + register_shutdown_function($this->handleFatalError(...)); $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize); $this->fatalLevel = null === $level ? LogLevel::ALERT : $level; @@ -168,17 +167,14 @@ protected function defaultErrorLevelMap(): array E_USER_ERROR => LogLevel::ERROR, E_USER_WARNING => LogLevel::WARNING, E_USER_NOTICE => LogLevel::NOTICE, - E_STRICT => LogLevel::NOTICE, + 2048 => LogLevel::NOTICE, // E_STRICT E_RECOVERABLE_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::NOTICE, E_USER_DEPRECATED => LogLevel::NOTICE, ]; } - /** - * @phpstan-return never - */ - private function handleException(\Throwable $e): void + private function handleException(\Throwable $e): never { $level = LogLevel::ERROR; foreach ($this->uncaughtExceptionLevelMap as $class => $candidate) { @@ -194,30 +190,25 @@ private function handleException(\Throwable $e): void ['exception' => $e] ); - if ($this->previousExceptionHandler) { + if (null !== $this->previousExceptionHandler) { ($this->previousExceptionHandler)($e); } - if (!headers_sent() && in_array(strtolower((string) ini_get('display_errors')), ['0', '', 'false', 'off', 'none', 'no'], true)) { + if (!headers_sent() && \in_array(strtolower((string) \ini_get('display_errors')), ['0', '', 'false', 'off', 'none', 'no'], true)) { http_response_code(500); } exit(255); } - /** - * @private - * - * @param mixed[] $context - */ - public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool + private function handleError(int $code, string $message, string $file = '', int $line = 0): bool { - if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) { + if ($this->handleOnlyReportedErrors && 0 === (error_reporting() & $code)) { return false; } // fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries - if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { + if (!$this->hasFatalErrorHandler || !\in_array($code, self::FATAL_ERRORS, true)) { $level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL; $this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]); } else { @@ -228,8 +219,9 @@ public function handleError(int $code, string $message, string $file = '', int $ if ($this->previousErrorHandler === true) { return false; - } elseif ($this->previousErrorHandler) { - return (bool) ($this->previousErrorHandler)($code, $message, $file, $line, $context); + } + if ($this->previousErrorHandler instanceof Closure) { + return (bool) ($this->previousErrorHandler)($code, $message, $file, $line); } return true; @@ -242,13 +234,12 @@ public function handleFatalError(): void { $this->reservedMemory = ''; - if (is_array($this->lastFatalData)) { + if (\is_array($this->lastFatalData)) { $lastError = $this->lastFatalData; } else { $lastError = error_get_last(); } - - if ($lastError && in_array($lastError['type'], self::$fatalErrors, true)) { + if (\is_array($lastError) && \in_array($lastError['type'], self::FATAL_ERRORS, true)) { $trace = $lastError['trace'] ?? null; $this->logger->log( $this->fatalLevel, @@ -264,44 +255,25 @@ public function handleFatalError(): void } } - /** - * @param int $code - */ - private static function codeToString($code): string + private static function codeToString(int $code): string { - switch ($code) { - case E_ERROR: - return 'E_ERROR'; - case E_WARNING: - return 'E_WARNING'; - case E_PARSE: - return 'E_PARSE'; - case E_NOTICE: - return 'E_NOTICE'; - case E_CORE_ERROR: - return 'E_CORE_ERROR'; - case E_CORE_WARNING: - return 'E_CORE_WARNING'; - case E_COMPILE_ERROR: - return 'E_COMPILE_ERROR'; - case E_COMPILE_WARNING: - return 'E_COMPILE_WARNING'; - case E_USER_ERROR: - return 'E_USER_ERROR'; - case E_USER_WARNING: - return 'E_USER_WARNING'; - case E_USER_NOTICE: - return 'E_USER_NOTICE'; - case E_STRICT: - return 'E_STRICT'; - case E_RECOVERABLE_ERROR: - return 'E_RECOVERABLE_ERROR'; - case E_DEPRECATED: - return 'E_DEPRECATED'; - case E_USER_DEPRECATED: - return 'E_USER_DEPRECATED'; - } - - return 'Unknown PHP error'; + return match ($code) { + E_ERROR => 'E_ERROR', + E_WARNING => 'E_WARNING', + E_PARSE => 'E_PARSE', + E_NOTICE => 'E_NOTICE', + E_CORE_ERROR => 'E_CORE_ERROR', + E_CORE_WARNING => 'E_CORE_WARNING', + E_COMPILE_ERROR => 'E_COMPILE_ERROR', + E_COMPILE_WARNING => 'E_COMPILE_WARNING', + E_USER_ERROR => 'E_USER_ERROR', + E_USER_WARNING => 'E_USER_WARNING', + E_USER_NOTICE => 'E_USER_NOTICE', + 2048 => 'E_STRICT', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + E_DEPRECATED => 'E_DEPRECATED', + E_USER_DEPRECATED => 'E_USER_DEPRECATED', + default => 'Unknown PHP error', + }; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php index aa1884b9c..beb5106af 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php @@ -11,7 +11,8 @@ namespace Monolog\Formatter; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Formats a log message according to the ChromePHP array format @@ -23,52 +24,55 @@ class ChromePHPFormatter implements FormatterInterface /** * Translates Monolog log levels to Wildfire levels. * - * @var array + * @return 'log'|'info'|'warn'|'error' */ - private $logLevels = [ - Logger::DEBUG => 'log', - Logger::INFO => 'info', - Logger::NOTICE => 'info', - Logger::WARNING => 'warn', - Logger::ERROR => 'error', - Logger::CRITICAL => 'error', - Logger::ALERT => 'error', - Logger::EMERGENCY => 'error', - ]; + private function toWildfireLevel(Level $level): string + { + return match ($level) { + Level::Debug => 'log', + Level::Info => 'info', + Level::Notice => 'info', + Level::Warning => 'warn', + Level::Error => 'error', + Level::Critical => 'error', + Level::Alert => 'error', + Level::Emergency => 'error', + }; + } /** - * {@inheritDoc} + * @inheritDoc */ - public function format(array $record) + public function format(LogRecord $record) { // Retrieve the line and file if set and remove them from the formatted extra $backtrace = 'unknown'; - if (isset($record['extra']['file'], $record['extra']['line'])) { - $backtrace = $record['extra']['file'].' : '.$record['extra']['line']; - unset($record['extra']['file'], $record['extra']['line']); + if (isset($record->extra['file'], $record->extra['line'])) { + $backtrace = $record->extra['file'].' : '.$record->extra['line']; + unset($record->extra['file'], $record->extra['line']); } - $message = ['message' => $record['message']]; - if ($record['context']) { - $message['context'] = $record['context']; + $message = ['message' => $record->message]; + if (\count($record->context) > 0) { + $message['context'] = $record->context; } - if ($record['extra']) { - $message['extra'] = $record['extra']; + if (\count($record->extra) > 0) { + $message['extra'] = $record->extra; } - if (count($message) === 1) { + if (\count($message) === 1) { $message = reset($message); } return [ - $record['channel'], + $record->channel, $message, $backtrace, - $this->logLevels[$record['level']], + $this->toWildfireLevel($record->level), ]; } /** - * {@inheritDoc} + * @inheritDoc */ public function formatBatch(array $records) { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php index 6c8a9ab5e..a0fa4a9e1 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php @@ -12,25 +12,24 @@ namespace Monolog\Formatter; use Elastica\Document; +use Monolog\LogRecord; /** * Format a log message into an Elastica Document * * @author Jelle Vink - * - * @phpstan-import-type Record from \Monolog\Logger */ class ElasticaFormatter extends NormalizerFormatter { /** * @var string Elastic search index name */ - protected $index; + protected string $index; /** - * @var ?string Elastic search document type + * @var string|null Elastic search document type */ - protected $type; + protected string|null $type; /** * @param string $index Elastic Search index name @@ -46,9 +45,9 @@ public function __construct(string $index, ?string $type) } /** - * {@inheritDoc} + * @inheritDoc */ - public function format(array $record) + public function format(LogRecord $record) { $record = parent::format($record); @@ -72,16 +71,12 @@ public function getType(): string /** * Convert a log message into an Elastica Document * - * @phpstan-param Record $record + * @param mixed[] $record */ protected function getDocument(array $record): Document { $document = new Document(); $document->setData($record); - if (method_exists($document, 'setType')) { - /** @phpstan-ignore-next-line */ - $document->setType($this->type); - } $document->setIndex($this->index); return $document; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticsearchFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticsearchFormatter.php index b792b819c..6326cf5d7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticsearchFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ElasticsearchFormatter.php @@ -12,6 +12,7 @@ namespace Monolog\Formatter; use DateTimeInterface; +use Monolog\LogRecord; /** * Format a log message into an Elasticsearch record @@ -23,12 +24,12 @@ class ElasticsearchFormatter extends NormalizerFormatter /** * @var string Elasticsearch index name */ - protected $index; + protected string $index; /** * @var string Elasticsearch record type */ - protected $type; + protected string $type; /** * @param string $index Elasticsearch index name @@ -37,16 +38,16 @@ class ElasticsearchFormatter extends NormalizerFormatter public function __construct(string $index, string $type) { // Elasticsearch requires an ISO 8601 format date with optional millisecond precision. - parent::__construct(DateTimeInterface::ISO8601); + parent::__construct(DateTimeInterface::ATOM); $this->index = $index; $this->type = $type; } /** - * {@inheritDoc} + * @inheritDoc */ - public function format(array $record) + public function format(LogRecord $record) { $record = parent::format($record); @@ -55,8 +56,6 @@ public function format(array $record) /** * Getter index - * - * @return string */ public function getIndex(): string { @@ -65,8 +64,6 @@ public function getIndex(): string /** * Getter type - * - * @return string */ public function getType(): string { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php index 867ae586b..cc805c892 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php @@ -11,6 +11,8 @@ namespace Monolog\Formatter; +use Monolog\LogRecord; + /** * formats the record to be used in the FlowdockHandler * @@ -19,15 +21,9 @@ */ class FlowdockFormatter implements FormatterInterface { - /** - * @var string - */ - private $source; + private string $source; - /** - * @var string - */ - private $sourceEmail; + private string $sourceEmail; public function __construct(string $source, string $sourceEmail) { @@ -36,43 +32,41 @@ public function __construct(string $source, string $sourceEmail) } /** - * {@inheritDoc} + * @inheritDoc * * @return mixed[] */ - public function format(array $record): array + public function format(LogRecord $record): array { $tags = [ '#logs', - '#' . strtolower($record['level_name']), - '#' . $record['channel'], + '#' . $record->level->toPsrLogLevel(), + '#' . $record->channel, ]; - foreach ($record['extra'] as $value) { + foreach ($record->extra as $value) { $tags[] = '#' . $value; } $subject = sprintf( 'in %s: %s - %s', $this->source, - $record['level_name'], - $this->getShortMessage($record['message']) + $record->level->getName(), + $this->getShortMessage($record->message) ); - $record['flowdock'] = [ + return [ 'source' => $this->source, 'from_address' => $this->sourceEmail, 'subject' => $subject, - 'content' => $record['message'], + 'content' => $record->message, 'tags' => $tags, 'project' => $this->source, ]; - - return $record; } /** - * {@inheritDoc} + * @inheritDoc * * @return mixed[][] */ @@ -92,7 +86,7 @@ public function getShortMessage(string $message): string static $hasMbString; if (null === $hasMbString) { - $hasMbString = function_exists('mb_strlen'); + $hasMbString = \function_exists('mb_strlen'); } $maxLength = 45; @@ -102,7 +96,7 @@ public function getShortMessage(string $message): string $message = mb_substr($message, 0, $maxLength - 4, 'UTF-8') . ' ...'; } } else { - if (strlen($message) > $maxLength) { + if (\strlen($message) > $maxLength) { $message = substr($message, 0, $maxLength - 4) . ' ...'; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php index 29b14d30d..5f7811735 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php @@ -12,6 +12,7 @@ namespace Monolog\Formatter; use Monolog\Utils; +use Monolog\LogRecord; /** * Class FluentdFormatter @@ -39,14 +40,10 @@ class FluentdFormatter implements FormatterInterface /** * @var bool $levelTag should message level be a part of the fluentd tag */ - protected $levelTag = false; + protected bool $levelTag = false; public function __construct(bool $levelTag = false) { - if (!function_exists('json_encode')) { - throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter'); - } - $this->levelTag = $levelTag; } @@ -55,25 +52,25 @@ public function isUsingLevelsInTag(): bool return $this->levelTag; } - public function format(array $record): string + public function format(LogRecord $record): string { - $tag = $record['channel']; + $tag = $record->channel; if ($this->levelTag) { - $tag .= '.' . strtolower($record['level_name']); + $tag .= '.' . $record->level->toPsrLogLevel(); } $message = [ - 'message' => $record['message'], - 'context' => $record['context'], - 'extra' => $record['extra'], + 'message' => $record->message, + 'context' => $record->context, + 'extra' => $record->extra, ]; if (!$this->levelTag) { - $message['level'] = $record['level']; - $message['level_name'] = $record['level_name']; + $message['level'] = $record->level->value; + $message['level_name'] = $record->level->getName(); } - return Utils::jsonEncode([$tag, $record['datetime']->getTimestamp(), $message]); + return Utils::jsonEncode([$tag, $record->datetime->getTimestamp(), $message]); } public function formatBatch(array $records): string diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php index 19617ec5f..3413a4b05 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php @@ -11,32 +11,28 @@ namespace Monolog\Formatter; +use Monolog\LogRecord; + /** * Interface for formatters * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger */ interface FormatterInterface { /** * Formats a log record. * - * @param array $record A record to format - * @return mixed The formatted record - * - * @phpstan-param Record $record + * @param LogRecord $record A record to format + * @return mixed The formatted record */ - public function format(array $record); + public function format(LogRecord $record); /** * Formats a set of log records. * - * @param array $records A set of records to format - * @return mixed The formatted set of records - * - * @phpstan-param Record[] $records + * @param array $records A set of records to format + * @return mixed The formatted set of records */ public function formatBatch(array $records); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php index 3b3e1e7f6..bf8ed2411 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php @@ -11,17 +11,16 @@ namespace Monolog\Formatter; -use Monolog\Logger; +use Monolog\Level; use Gelf\Message; use Monolog\Utils; +use Monolog\LogRecord; /** * Serializes a log message to GELF * @see http://docs.graylog.org/en/latest/pages/gelf.html * * @author Matt Lehner - * - * @phpstan-import-type Level from \Monolog\Logger */ class GelfMessageFormatter extends NormalizerFormatter { @@ -30,46 +29,43 @@ class GelfMessageFormatter extends NormalizerFormatter /** * @var string the name of the system for the Gelf log message */ - protected $systemName; + protected string $systemName; /** * @var string a prefix for 'extra' fields from the Monolog record (optional) */ - protected $extraPrefix; + protected string $extraPrefix; /** * @var string a prefix for 'context' fields from the Monolog record (optional) */ - protected $contextPrefix; + protected string $contextPrefix; /** * @var int max length per field */ - protected $maxLength; + protected int $maxLength; /** - * @var int + * Translates Monolog log levels to Graylog2 log priorities. */ - private $gelfVersion = 2; + private function getGraylog2Priority(Level $level): int + { + return match ($level) { + Level::Debug => 7, + Level::Info => 6, + Level::Notice => 5, + Level::Warning => 4, + Level::Error => 3, + Level::Critical => 2, + Level::Alert => 1, + Level::Emergency => 0, + }; + } /** - * Translates Monolog log levels to Graylog2 log priorities. - * - * @var array - * - * @phpstan-var array + * @throws \RuntimeException */ - private $logLevels = [ - Logger::DEBUG => 7, - Logger::INFO => 6, - Logger::NOTICE => 5, - Logger::WARNING => 4, - Logger::ERROR => 3, - Logger::CRITICAL => 2, - Logger::ALERT => 1, - Logger::EMERGENCY => 0, - ]; - public function __construct(?string $systemName = null, ?string $extraPrefix = null, string $contextPrefix = 'ctxt_', ?int $maxLength = null) { if (!class_exists(Message::class)) { @@ -78,69 +74,51 @@ public function __construct(?string $systemName = null, ?string $extraPrefix = n parent::__construct('U.u'); - $this->systemName = (is_null($systemName) || $systemName === '') ? (string) gethostname() : $systemName; + $this->systemName = (null === $systemName || $systemName === '') ? (string) gethostname() : $systemName; - $this->extraPrefix = is_null($extraPrefix) ? '' : $extraPrefix; + $this->extraPrefix = null === $extraPrefix ? '' : $extraPrefix; $this->contextPrefix = $contextPrefix; - $this->maxLength = is_null($maxLength) ? self::DEFAULT_MAX_LENGTH : $maxLength; - - if (method_exists(Message::class, 'setFacility')) { - $this->gelfVersion = 1; - } + $this->maxLength = null === $maxLength ? self::DEFAULT_MAX_LENGTH : $maxLength; } /** - * {@inheritDoc} + * @inheritDoc */ - public function format(array $record): Message + public function format(LogRecord $record): Message { $context = $extra = []; - if (isset($record['context'])) { - /** @var mixed[] $context */ - $context = parent::normalize($record['context']); - } - if (isset($record['extra'])) { - /** @var mixed[] $extra */ - $extra = parent::normalize($record['extra']); + if (isset($record->context)) { + /** @var array|bool|float|int|string|null> $context */ + $context = parent::normalize($record->context); } - - if (!isset($record['datetime'], $record['message'], $record['level'])) { - throw new \InvalidArgumentException('The record should at least contain datetime, message and level keys, '.var_export($record, true).' given'); + if (isset($record->extra)) { + /** @var array|bool|float|int|string|null> $extra */ + $extra = parent::normalize($record->extra); } $message = new Message(); $message - ->setTimestamp($record['datetime']) - ->setShortMessage((string) $record['message']) + ->setTimestamp($record->datetime) + ->setShortMessage($record->message) ->setHost($this->systemName) - ->setLevel($this->logLevels[$record['level']]); + ->setLevel($this->getGraylog2Priority($record->level)); // message length + system name length + 200 for padding / metadata - $len = 200 + strlen((string) $record['message']) + strlen($this->systemName); + $len = 200 + \strlen($record->message) + \strlen($this->systemName); if ($len > $this->maxLength) { - $message->setShortMessage(Utils::substr($record['message'], 0, $this->maxLength)); + $message->setShortMessage(Utils::substr($record->message, 0, $this->maxLength)); } - if ($this->gelfVersion === 1) { - if (isset($record['channel'])) { - $message->setFacility($record['channel']); - } - if (isset($extra['line'])) { - $message->setLine($extra['line']); - unset($extra['line']); - } - if (isset($extra['file'])) { - $message->setFile($extra['file']); - unset($extra['file']); - } - } else { - $message->setAdditional('facility', $record['channel']); + if (isset($record->channel)) { + $message->setAdditional('facility', $record->channel); } foreach ($extra as $key => $val) { - $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); - $len = strlen($this->extraPrefix . $key . $val); + $key = (string) preg_replace('#[^\w.-]#', '-', (string) $key); + $val = \is_bool($val) ? ($val ? 1 : 0) : $val; + $val = \is_scalar($val) || null === $val ? $val : $this->toJson($val); + $len = \strlen($this->extraPrefix . $key . $val); if ($len > $this->maxLength) { $message->setAdditional($this->extraPrefix . $key, Utils::substr((string) $val, 0, $this->maxLength)); @@ -150,8 +128,10 @@ public function format(array $record): Message } foreach ($context as $key => $val) { - $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); - $len = strlen($this->contextPrefix . $key . $val); + $key = (string) preg_replace('#[^\w.-]#', '-', (string) $key); + $val = \is_bool($val) ? ($val ? 1 : 0) : $val; + $val = \is_scalar($val) || null === $val ? $val : $this->toJson($val); + $len = \strlen($this->contextPrefix . $key . $val); if ($len > $this->maxLength) { $message->setAdditional($this->contextPrefix . $key, Utils::substr((string) $val, 0, $this->maxLength)); @@ -160,13 +140,10 @@ public function format(array $record): Message $message->setAdditional($this->contextPrefix . $key, $val); } - if ($this->gelfVersion === 1) { - /** @phpstan-ignore-next-line */ - if (null === $message->getFile() && isset($context['exception']['file'])) { - if (preg_match("/^(.+):([0-9]+)$/", $context['exception']['file'], $matches)) { - $message->setFile($matches[1]); - $message->setLine($matches[2]); - } + if (!$message->hasAdditional('file') && isset($context['exception']['file'])) { + if (1 === preg_match("/^(.+):([0-9]+)$/", $context['exception']['file'], $matches)) { + $message->setAdditional('file', $matches[1]); + $message->setAdditional('line', $matches[2]); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GoogleCloudLoggingFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GoogleCloudLoggingFormatter.php index ca52ebf4e..c97b9122c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GoogleCloudLoggingFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/GoogleCloudLoggingFormatter.php @@ -22,19 +22,19 @@ * * @author Luís Cobucci */ -final class GoogleCloudLoggingFormatter extends JsonFormatter +class GoogleCloudLoggingFormatter extends JsonFormatter { - /** {@inheritdoc} **/ - public function format(array $record): string + protected function normalizeRecord(LogRecord $record): array { + $normalized = parent::normalizeRecord($record); + // Re-key level for GCP logging - $record['severity'] = $record['level_name']; - $record['time'] = $record['datetime']->format(DateTimeInterface::RFC3339_EXTENDED); + $normalized['severity'] = $normalized['level_name']; + $normalized['time'] = $record->datetime->format(DateTimeInterface::RFC3339_EXTENDED); // Remove keys that are not used by GCP - unset($record['level'], $record['level_name'], $record['datetime']); + unset($normalized['level'], $normalized['level_name'], $normalized['datetime']); - return parent::format($record); + return $normalized; } } - diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php index 10a4311cb..09cbea9b6 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php @@ -11,8 +11,9 @@ namespace Monolog\Formatter; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * Formats incoming records into an HTML table @@ -25,19 +26,20 @@ class HtmlFormatter extends NormalizerFormatter { /** * Translates Monolog log levels to html color priorities. - * - * @var array */ - protected $logLevels = [ - Logger::DEBUG => '#CCCCCC', - Logger::INFO => '#28A745', - Logger::NOTICE => '#17A2B8', - Logger::WARNING => '#FFC107', - Logger::ERROR => '#FD7E14', - Logger::CRITICAL => '#DC3545', - Logger::ALERT => '#821722', - Logger::EMERGENCY => '#000000', - ]; + protected function getLevelColor(Level $level): string + { + return match ($level) { + Level::Debug => '#CCCCCC', + Level::Info => '#28A745', + Level::Notice => '#17A2B8', + Level::Warning => '#FFC107', + Level::Error => '#FD7E14', + Level::Critical => '#DC3545', + Level::Alert => '#821722', + Level::Emergency => '#000000', + }; + } /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format @@ -67,15 +69,13 @@ protected function addRow(string $th, string $td = ' ', bool $escapeTd = true): /** * Create a HTML h1 tag * - * @param string $title Text to be in the h1 - * @param int $level Error level - * @return string + * @param string $title Text to be in the h1 */ - protected function addTitle(string $title, int $level): string + protected function addTitle(string $title, Level $level): string { $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); - return '

'.$title.'

'; + return '

'.$title.'

'; } /** @@ -83,25 +83,25 @@ protected function addTitle(string $title, int $level): string * * @return string The formatted record */ - public function format(array $record): string + public function format(LogRecord $record): string { - $output = $this->addTitle($record['level_name'], $record['level']); + $output = $this->addTitle($record->level->getName(), $record->level); $output .= ''; - $output .= $this->addRow('Message', (string) $record['message']); - $output .= $this->addRow('Time', $this->formatDate($record['datetime'])); - $output .= $this->addRow('Channel', $record['channel']); - if ($record['context']) { + $output .= $this->addRow('Message', $record->message); + $output .= $this->addRow('Time', $this->formatDate($record->datetime)); + $output .= $this->addRow('Channel', $record->channel); + if (\count($record->context) > 0) { $embeddedTable = '
'; - foreach ($record['context'] as $key => $value) { + foreach ($record->context as $key => $value) { $embeddedTable .= $this->addRow((string) $key, $this->convertToString($value)); } $embeddedTable .= '
'; $output .= $this->addRow('Context', $embeddedTable, false); } - if ($record['extra']) { + if (\count($record->extra) > 0) { $embeddedTable = ''; - foreach ($record['extra'] as $key => $value) { + foreach ($record->extra as $key => $value) { $embeddedTable .= $this->addRow((string) $key, $this->convertToString($value)); } $embeddedTable .= '
'; @@ -131,7 +131,7 @@ public function formatBatch(array $records): string */ protected function convertToString($data): string { - if (null === $data || is_scalar($data)) { + if (null === $data || \is_scalar($data)) { return (string) $data; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php index 753e6852c..fa11d0ef0 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php @@ -11,7 +11,9 @@ namespace Monolog\Formatter; +use Stringable; use Throwable; +use Monolog\LogRecord; /** * Encodes whatever record data is passed to it as json @@ -19,8 +21,6 @@ * This can be useful to log to databases or remote APIs * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger */ class JsonFormatter extends NormalizerFormatter { @@ -28,13 +28,13 @@ class JsonFormatter extends NormalizerFormatter public const BATCH_MODE_NEWLINES = 2; /** @var self::BATCH_MODE_* */ - protected $batchMode; - /** @var bool */ - protected $appendNewline; - /** @var bool */ - protected $ignoreEmptyContextAndExtra; - /** @var bool */ - protected $includeStacktraces = false; + protected int $batchMode; + + protected bool $appendNewline; + + protected bool $ignoreEmptyContextAndExtra; + + protected bool $includeStacktraces = false; /** * @param self::BATCH_MODE_* $batchMode @@ -70,47 +70,28 @@ public function isAppendingNewlines(): bool } /** - * {@inheritDoc} + * @inheritDoc */ - public function format(array $record): string + public function format(LogRecord $record): string { - $normalized = $this->normalize($record); - - if (isset($normalized['context']) && $normalized['context'] === []) { - if ($this->ignoreEmptyContextAndExtra) { - unset($normalized['context']); - } else { - $normalized['context'] = new \stdClass; - } - } - if (isset($normalized['extra']) && $normalized['extra'] === []) { - if ($this->ignoreEmptyContextAndExtra) { - unset($normalized['extra']); - } else { - $normalized['extra'] = new \stdClass; - } - } + $normalized = $this->normalizeRecord($record); return $this->toJson($normalized, true) . ($this->appendNewline ? "\n" : ''); } /** - * {@inheritDoc} + * @inheritDoc */ public function formatBatch(array $records): string { - switch ($this->batchMode) { - case static::BATCH_MODE_NEWLINES: - return $this->formatBatchNewlines($records); - - case static::BATCH_MODE_JSON: - default: - return $this->formatBatchJson($records); - } + return match ($this->batchMode) { + static::BATCH_MODE_NEWLINES => $this->formatBatchNewlines($records), + default => $this->formatBatchJson($records), + }; } /** - * @return self + * @return $this */ public function includeStacktraces(bool $include = true): self { @@ -119,56 +100,77 @@ public function includeStacktraces(bool $include = true): self return $this; } + /** + * @return array|bool|float|int|\stdClass|string|null> + */ + protected function normalizeRecord(LogRecord $record): array + { + $normalized = parent::normalizeRecord($record); + + if (isset($normalized['context']) && $normalized['context'] === []) { + if ($this->ignoreEmptyContextAndExtra) { + unset($normalized['context']); + } else { + $normalized['context'] = new \stdClass; + } + } + if (isset($normalized['extra']) && $normalized['extra'] === []) { + if ($this->ignoreEmptyContextAndExtra) { + unset($normalized['extra']); + } else { + $normalized['extra'] = new \stdClass; + } + } + + return $normalized; + } + /** * Return a JSON-encoded array of records. * - * @phpstan-param Record[] $records + * @phpstan-param LogRecord[] $records */ protected function formatBatchJson(array $records): string { - return $this->toJson($this->normalize($records), true); + $formatted = array_map(fn (LogRecord $record) => $this->normalizeRecord($record), $records); + + return $this->toJson($formatted, true); } /** * Use new lines to separate records instead of a * JSON-encoded array. * - * @phpstan-param Record[] $records + * @phpstan-param LogRecord[] $records */ protected function formatBatchNewlines(array $records): string { - $instance = $this; - $oldNewline = $this->appendNewline; $this->appendNewline = false; - array_walk($records, function (&$value, $key) use ($instance) { - $value = $instance->format($value); - }); + $formatted = array_map(fn (LogRecord $record) => $this->format($record), $records); $this->appendNewline = $oldNewline; - return implode("\n", $records); + return implode("\n", $formatted); } /** * Normalizes given $data. * - * @param mixed $data - * - * @return mixed + * @return null|scalar|array|object */ - protected function normalize($data, int $depth = 0) + protected function normalize(mixed $data, int $depth = 0): mixed { if ($depth > $this->maxNormalizeDepth) { return 'Over '.$this->maxNormalizeDepth.' levels deep, aborting normalization'; } - if (is_array($data)) { + if (\is_array($data)) { $normalized = []; $count = 1; foreach ($data as $key => $value) { if ($count++ > $this->maxNormalizeItemCount) { - $normalized['...'] = 'Over '.$this->maxNormalizeItemCount.' items ('.count($data).' total), aborting normalization'; + $normalized['...'] = 'Over '.$this->maxNormalizeItemCount.' items ('.\count($data).' total), aborting normalization'; break; } @@ -178,7 +180,7 @@ protected function normalize($data, int $depth = 0) return $normalized; } - if (is_object($data)) { + if (\is_object($data)) { if ($data instanceof \DateTimeInterface) { return $this->formatDate($data); } @@ -192,18 +194,22 @@ protected function normalize($data, int $depth = 0) return $data; } - if (\get_class($data) === '__PHP_Incomplete_Class') { - return new \ArrayObject($data); + if ($data instanceof Stringable) { + try { + return $data->__toString(); + } catch (Throwable) { + return $data::class; + } } - if (method_exists($data, '__toString')) { - return $data->__toString(); + if (\get_class($data) === '__PHP_Incomplete_Class') { + return new \ArrayObject($data); } return $data; } - if (is_resource($data)) { + if (\is_resource($data)) { return parent::normalize($data); } @@ -214,7 +220,7 @@ protected function normalize($data, int $depth = 0) * Normalizes given exception with or without its own stack trace based on * `includeStacktraces` property. * - * {@inheritDoc} + * @return array>> */ protected function normalizeException(Throwable $e, int $depth = 0): array { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php index e6e789833..d44e7aef0 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php @@ -11,7 +11,9 @@ namespace Monolog\Formatter; +use Closure; use Monolog\Utils; +use Monolog\LogRecord; /** * Formats incoming records into a one-line string @@ -25,22 +27,19 @@ class LineFormatter extends NormalizerFormatter { public const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; - /** @var string */ - protected $format; - /** @var bool */ - protected $allowInlineLineBreaks; - /** @var bool */ - protected $ignoreEmptyContextAndExtra; - /** @var bool */ - protected $includeStacktraces; - /** @var ?callable */ - protected $stacktracesParser; + protected string $format; + protected bool $allowInlineLineBreaks; + protected bool $ignoreEmptyContextAndExtra; + protected bool $includeStacktraces; + protected ?int $maxLevelNameLength = null; + protected string $indentStacktraces = ''; + protected Closure|null $stacktracesParser = null; + protected string $basePath = ''; /** - * @param string|null $format The format of the message - * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format - * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries - * @param bool $ignoreEmptyContextAndExtra + * @param string|null $format The format of the message + * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format + * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries */ public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false) { @@ -51,7 +50,25 @@ public function __construct(?string $format = null, ?string $dateFormat = null, parent::__construct($dateFormat); } - public function includeStacktraces(bool $include = true, ?callable $parser = null): self + /** + * Setting a base path will hide the base path from exception and stack trace file names to shorten them + * @return $this + */ + public function setBasePath(string $path = ''): self + { + if ($path !== '') { + $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + } + + $this->basePath = $path; + + return $this; + } + + /** + * @return $this + */ + public function includeStacktraces(bool $include = true, ?Closure $parser = null): self { $this->includeStacktraces = $include; if ($this->includeStacktraces) { @@ -62,6 +79,22 @@ public function includeStacktraces(bool $include = true, ?callable $parser = nul return $this; } + /** + * Indent stack traces to separate them a bit from the main log record messages + * + * @param string $indent The string used to indent, for example " " + * @return $this + */ + public function indentStacktraces(string $indent): self + { + $this->indentStacktraces = $indent; + + return $this; + } + + /** + * @return $this + */ public function allowInlineLineBreaks(bool $allow = true): self { $this->allowInlineLineBreaks = $allow; @@ -69,6 +102,9 @@ public function allowInlineLineBreaks(bool $allow = true): self return $this; } + /** + * @return $this + */ public function ignoreEmptyContextAndExtra(bool $ignore = true): self { $this->ignoreEmptyContextAndExtra = $ignore; @@ -77,14 +113,30 @@ public function ignoreEmptyContextAndExtra(bool $ignore = true): self } /** - * {@inheritDoc} + * Allows cutting the level name to get fixed-length levels like INF for INFO, ERR for ERROR if you set this to 3 for example + * + * @param int|null $maxLevelNameLength Maximum characters for the level name. Set null for infinite length (default) + * @return $this + */ + public function setMaxLevelNameLength(?int $maxLevelNameLength = null): self + { + $this->maxLevelNameLength = $maxLevelNameLength; + + return $this; + } + + /** + * @inheritDoc */ - public function format(array $record): string + public function format(LogRecord $record): string { $vars = parent::format($record); - $output = $this->format; + if ($this->maxLevelNameLength !== null) { + $vars['level_name'] = substr($vars['level_name'], 0, $this->maxLevelNameLength); + } + $output = $this->format; foreach ($vars['extra'] as $var => $val) { if (false !== strpos($output, '%extra.'.$var.'%')) { $output = str_replace('%extra.'.$var.'%', $this->stringify($val), $output); @@ -100,12 +152,12 @@ public function format(array $record): string } if ($this->ignoreEmptyContextAndExtra) { - if (empty($vars['context'])) { + if (\count($vars['context']) === 0) { unset($vars['context']); $output = str_replace('%context%', '', $output); } - if (empty($vars['extra'])) { + if (\count($vars['extra']) === 0) { unset($vars['extra']); $output = str_replace('%extra%', '', $output); } @@ -122,7 +174,8 @@ public function format(array $record): string $output = preg_replace('/%(?:extra|context)\..+?%/', '', $output); if (null === $output) { $pcreErrorCode = preg_last_error(); - throw new \RuntimeException('Failed to run preg_replace: ' . $pcreErrorCode . ' / ' . Utils::pcreLastErrorMessage($pcreErrorCode)); + + throw new \RuntimeException('Failed to run preg_replace: ' . $pcreErrorCode . ' / ' . preg_last_error_msg()); } } @@ -151,16 +204,15 @@ protected function normalizeException(\Throwable $e, int $depth = 0): string { $str = $this->formatException($e); - if ($previous = $e->getPrevious()) { - do { - $depth++; - if ($depth > $this->maxNormalizeDepth) { - $str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization'; - break; - } - - $str .= "\n[previous exception] " . $this->formatException($previous); - } while ($previous = $previous->getPrevious()); + $previous = $e->getPrevious(); + while ($previous instanceof \Throwable) { + $depth++; + if ($depth > $this->maxNormalizeDepth) { + $str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization'; + break; + } + $str .= "\n[previous exception] " . $this->formatException($previous); + $previous = $previous->getPrevious(); } return $str; @@ -171,11 +223,11 @@ protected function normalizeException(\Throwable $e, int $depth = 0): string */ protected function convertToString($data): string { - if (null === $data || is_bool($data)) { + if (null === $data || \is_bool($data)) { return var_export($data, true); } - if (is_scalar($data)) { + if (\is_scalar($data)) { return (string) $data; } @@ -185,11 +237,12 @@ protected function convertToString($data): string protected function replaceNewlines(string $str): string { if ($this->allowInlineLineBreaks) { - if (0 === strpos($str, '{')) { + if (0 === strpos($str, '{') || 0 === strpos($str, '[')) { $str = preg_replace('/(?detail)) { - if (is_string($e->detail)) { + if (\is_string($e->detail)) { $str .= ' detail: ' . $e->detail; - } elseif (is_object($e->detail) || is_array($e->detail)) { + } elseif (\is_object($e->detail) || \is_array($e->detail)) { $str .= ' detail: ' . $this->toJson($e->detail, true); } } } - $str .= '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . ')'; + + $file = $e->getFile(); + if ($this->basePath !== '') { + $file = preg_replace('{^'.preg_quote($this->basePath).'}', '', $file); + } + + $str .= '): ' . $e->getMessage() . ' at ' . strtr((string) $file, DIRECTORY_SEPARATOR, '/') . ':' . $e->getLine() . ')'; if ($this->includeStacktraces) { $str .= $this->stacktracesParser($e); @@ -232,15 +291,27 @@ private function stacktracesParser(\Throwable $e): string { $trace = $e->getTraceAsString(); - if ($this->stacktracesParser) { + if ($this->basePath !== '') { + $trace = preg_replace('{^(#\d+ )' . preg_quote($this->basePath) . '}m', '$1', $trace) ?? $trace; + } + + if ($this->stacktracesParser !== null) { $trace = $this->stacktracesParserCustom($trace); } - return "\n[stacktrace]\n" . $trace . "\n"; + if ($this->indentStacktraces !== '') { + $trace = str_replace("\n", "\n{$this->indentStacktraces}", $trace); + } + + if (trim($trace) === '') { + return ''; + } + + return "\n{$this->indentStacktraces}[stacktrace]\n{$this->indentStacktraces}" . strtr($trace, DIRECTORY_SEPARATOR, '/') . "\n"; } private function stacktracesParserCustom(string $trace): string { - return implode("\n", array_filter(array_map($this->stacktracesParser, explode("\n", $trace)))); + return implode("\n", array_filter(array_map($this->stacktracesParser, explode("\n", $trace)), fn ($line) => is_string($line) && trim($line) !== '')); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php index 29841aa38..5f0b6a453 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php @@ -11,6 +11,8 @@ namespace Monolog\Formatter; +use Monolog\LogRecord; + /** * Encodes message information into JSON in a format compatible with Loggly. * @@ -33,13 +35,13 @@ public function __construct(int $batchMode = self::BATCH_MODE_NEWLINES, bool $ap * @see https://www.loggly.com/docs/automated-parsing/#json * @see \Monolog\Formatter\JsonFormatter::format() */ - public function format(array $record): string + protected function normalizeRecord(LogRecord $record): array { - if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTimeInterface)) { - $record["timestamp"] = $record["datetime"]->format("Y-m-d\TH:i:s.uO"); - unset($record["datetime"]); - } + $recordData = parent::normalizeRecord($record); + + $recordData["timestamp"] = $record->datetime->format("Y-m-d\TH:i:s.uO"); + unset($recordData["datetime"]); - return parent::format($record); + return $recordData; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogmaticFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogmaticFormatter.php index b0451aba7..9e44c19f4 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogmaticFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogmaticFormatter.php @@ -11,6 +11,8 @@ namespace Monolog\Formatter; +use Monolog\LogRecord; + /** * Encodes message information into JSON in a format compatible with Logmatic. * @@ -20,16 +22,13 @@ class LogmaticFormatter extends JsonFormatter { protected const MARKERS = ["sourcecode", "php"]; - /** - * @var string - */ - protected $hostname = ''; + protected string $hostname = ''; + + protected string $appName = ''; /** - * @var string + * @return $this */ - protected $appname = ''; - public function setHostname(string $hostname): self { $this->hostname = $hostname; @@ -37,9 +36,12 @@ public function setHostname(string $hostname): self return $this; } - public function setAppname(string $appname): self + /** + * @return $this + */ + public function setAppName(string $appName): self { - $this->appname = $appname; + $this->appName = $appName; return $this; } @@ -50,17 +52,19 @@ public function setAppname(string $appname): self * @see http://doc.logmatic.io/docs/basics-to-send-data * @see \Monolog\Formatter\JsonFormatter::format() */ - public function format(array $record): string + public function normalizeRecord(LogRecord $record): array { - if (!empty($this->hostname)) { + $record = parent::normalizeRecord($record); + + if ($this->hostname !== '') { $record["hostname"] = $this->hostname; } - if (!empty($this->appname)) { - $record["appname"] = $this->appname; + if ($this->appName !== '') { + $record["appname"] = $this->appName; } $record["@marker"] = static::MARKERS; - return parent::format($record); + return $record; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php index f8de0d333..d0e8749e3 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php @@ -11,6 +11,8 @@ namespace Monolog\Formatter; +use Monolog\LogRecord; + /** * Serializes a log message to Logstash Event Format * @@ -24,22 +26,22 @@ class LogstashFormatter extends NormalizerFormatter /** * @var string the name of the system for the Logstash log message, used to fill the @source field */ - protected $systemName; + protected string $systemName; /** * @var string an application name for the Logstash log message, used to fill the @type field */ - protected $applicationName; + protected string $applicationName; /** * @var string the key for 'extra' fields from the Monolog record */ - protected $extraKey; + protected string $extraKey; /** * @var string the key for 'context' fields from the Monolog record */ - protected $contextKey; + protected string $contextKey; /** * @param string $applicationName The application that sends the data, used as the "type" field of logstash @@ -59,41 +61,38 @@ public function __construct(string $applicationName, ?string $systemName = null, } /** - * {@inheritDoc} + * @inheritDoc */ - public function format(array $record): string + public function format(LogRecord $record): string { - $record = parent::format($record); + $recordData = parent::format($record); - if (empty($record['datetime'])) { - $record['datetime'] = gmdate('c'); - } $message = [ - '@timestamp' => $record['datetime'], + '@timestamp' => $recordData['datetime'], '@version' => 1, 'host' => $this->systemName, ]; - if (isset($record['message'])) { - $message['message'] = $record['message']; + if (isset($recordData['message'])) { + $message['message'] = $recordData['message']; } - if (isset($record['channel'])) { - $message['type'] = $record['channel']; - $message['channel'] = $record['channel']; + if (isset($recordData['channel'])) { + $message['type'] = $recordData['channel']; + $message['channel'] = $recordData['channel']; } - if (isset($record['level_name'])) { - $message['level'] = $record['level_name']; + if (isset($recordData['level_name'])) { + $message['level'] = $recordData['level_name']; } - if (isset($record['level'])) { - $message['monolog_level'] = $record['level']; + if (isset($recordData['level'])) { + $message['monolog_level'] = $recordData['level']; } - if ($this->applicationName) { + if ('' !== $this->applicationName) { $message['type'] = $this->applicationName; } - if (!empty($record['extra'])) { - $message[$this->extraKey] = $record['extra']; + if (\count($recordData['extra']) > 0) { + $message[$this->extraKey] = $recordData['extra']; } - if (!empty($record['context'])) { - $message[$this->contextKey] = $record['context']; + if (\count($recordData['context']) > 0) { + $message[$this->contextKey] = $recordData['context']; } return $this->toJson($message) . "\n"; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php index fca69a899..64ecef2a4 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php @@ -14,6 +14,7 @@ use MongoDB\BSON\Type; use MongoDB\BSON\UTCDateTime; use Monolog\Utils; +use Monolog\LogRecord; /** * Formats a record for use with the MongoDBHandler. @@ -22,40 +23,34 @@ */ class MongoDBFormatter implements FormatterInterface { - /** @var bool */ - private $exceptionTraceAsString; - /** @var int */ - private $maxNestingLevel; - /** @var bool */ - private $isLegacyMongoExt; + private bool $exceptionTraceAsString; + private int $maxNestingLevel; /** - * @param int $maxNestingLevel 0 means infinite nesting, the $record itself is level 1, $record['context'] is 2 + * @param int $maxNestingLevel 0 means infinite nesting, the $record itself is level 1, $record->context is 2 * @param bool $exceptionTraceAsString set to false to log exception traces as a sub documents instead of strings */ public function __construct(int $maxNestingLevel = 3, bool $exceptionTraceAsString = true) { $this->maxNestingLevel = max($maxNestingLevel, 0); $this->exceptionTraceAsString = $exceptionTraceAsString; - - $this->isLegacyMongoExt = extension_loaded('mongodb') && version_compare((string) phpversion('mongodb'), '1.1.9', '<='); } /** - * {@inheritDoc} + * @inheritDoc * * @return mixed[] */ - public function format(array $record): array + public function format(LogRecord $record): array { /** @var mixed[] $res */ - $res = $this->formatArray($record); + $res = $this->formatArray($record->toArray()); return $res; } /** - * {@inheritDoc} + * @inheritDoc * * @return array */ @@ -84,9 +79,9 @@ protected function formatArray(array $array, int $nestingLevel = 0) $array[$name] = $this->formatDate($value, $nestingLevel + 1); } elseif ($value instanceof \Throwable) { $array[$name] = $this->formatException($value, $nestingLevel + 1); - } elseif (is_array($value)) { + } elseif (\is_array($value)) { $array[$name] = $this->formatArray($value, $nestingLevel + 1); - } elseif (is_object($value) && !$value instanceof Type) { + } elseif (\is_object($value) && !$value instanceof Type) { $array[$name] = $this->formatObject($value, $nestingLevel + 1); } } @@ -128,35 +123,7 @@ protected function formatException(\Throwable $exception, int $nestingLevel) } protected function formatDate(\DateTimeInterface $value, int $nestingLevel): UTCDateTime - { - if ($this->isLegacyMongoExt) { - return $this->legacyGetMongoDbDateTime($value); - } - - return $this->getMongoDbDateTime($value); - } - - private function getMongoDbDateTime(\DateTimeInterface $value): UTCDateTime { return new UTCDateTime((int) floor(((float) $value->format('U.u')) * 1000)); } - - /** - * This is needed to support MongoDB Driver v1.19 and below - * - * See https://github.com/mongodb/mongo-php-driver/issues/426 - * - * It can probably be removed in 2.1 or later once MongoDB's 1.2 is released and widely adopted - */ - private function legacyGetMongoDbDateTime(\DateTimeInterface $value): UTCDateTime - { - $milliseconds = floor(((float) $value->format('U.u')) * 1000); - - $milliseconds = (PHP_INT_SIZE == 8) //64-bit OS? - ? (int) $milliseconds - : (string) $milliseconds; - - // @phpstan-ignore-next-line - return new UTCDateTime($milliseconds); - } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php index f926a842f..60da29cf7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php @@ -11,9 +11,10 @@ namespace Monolog\Formatter; -use Monolog\DateTimeImmutable; +use Monolog\JsonSerializableDateTimeImmutable; use Monolog\Utils; use Throwable; +use Monolog\LogRecord; /** * Normalizes incoming records to remove objects/resources so it's easier to dump to various targets @@ -24,15 +25,13 @@ class NormalizerFormatter implements FormatterInterface { public const SIMPLE_DATE = "Y-m-d\TH:i:sP"; - /** @var string */ - protected $dateFormat; - /** @var int */ - protected $maxNormalizeDepth = 9; - /** @var int */ - protected $maxNormalizeItemCount = 1000; + protected string $dateFormat; + protected int $maxNormalizeDepth = 9; + protected int $maxNormalizeItemCount = 1000; - /** @var int */ - private $jsonEncodeOptions = Utils::DEFAULT_JSON_FLAGS; + private int $jsonEncodeOptions = Utils::DEFAULT_JSON_FLAGS; + + protected string $basePath = ''; /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format @@ -40,23 +39,28 @@ class NormalizerFormatter implements FormatterInterface public function __construct(?string $dateFormat = null) { $this->dateFormat = null === $dateFormat ? static::SIMPLE_DATE : $dateFormat; - if (!function_exists('json_encode')) { - throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter'); - } } /** - * {@inheritDoc} + * @inheritDoc + */ + public function format(LogRecord $record) + { + return $this->normalizeRecord($record); + } + + /** + * Normalize an arbitrary value to a scalar|array|null * - * @param mixed[] $record + * @return null|scalar|array */ - public function format(array $record) + public function normalizeValue(mixed $data): mixed { - return $this->normalize($record); + return $this->normalize($data); } /** - * {@inheritDoc} + * @inheritDoc */ public function formatBatch(array $records) { @@ -72,6 +76,9 @@ public function getDateFormat(): string return $this->dateFormat; } + /** + * @return $this + */ public function setDateFormat(string $dateFormat): self { $this->dateFormat = $dateFormat; @@ -87,6 +94,9 @@ public function getMaxNormalizeDepth(): int return $this->maxNormalizeDepth; } + /** + * @return $this + */ public function setMaxNormalizeDepth(int $maxNormalizeDepth): self { $this->maxNormalizeDepth = $maxNormalizeDepth; @@ -102,6 +112,9 @@ public function getMaxNormalizeItemCount(): int return $this->maxNormalizeItemCount; } + /** + * @return $this + */ public function setMaxNormalizeItemCount(int $maxNormalizeItemCount): self { $this->maxNormalizeItemCount = $maxNormalizeItemCount; @@ -111,6 +124,8 @@ public function setMaxNormalizeItemCount(int $maxNormalizeItemCount): self /** * Enables `json_encode` pretty print. + * + * @return $this */ public function setJsonPrettyPrint(bool $enable): self { @@ -124,17 +139,47 @@ public function setJsonPrettyPrint(bool $enable): self } /** - * @param mixed $data - * @return null|scalar|array + * Setting a base path will hide the base path from exception and stack trace file names to shorten them + * @return $this */ - protected function normalize($data, int $depth = 0) + public function setBasePath(string $path = ''): self + { + if ($path !== '') { + $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + } + + $this->basePath = $path; + + return $this; + } + + /** + * Provided as extension point + * + * Because normalize is called with sub-values of context data etc, normalizeRecord can be + * extended when data needs to be appended on the record array but not to other normalized data. + * + * @return array + */ + protected function normalizeRecord(LogRecord $record): array + { + /** @var array $normalized */ + $normalized = $this->normalize($record->toArray()); + + return $normalized; + } + + /** + * @return null|scalar|array + */ + protected function normalize(mixed $data, int $depth = 0): mixed { if ($depth > $this->maxNormalizeDepth) { return 'Over ' . $this->maxNormalizeDepth . ' levels deep, aborting normalization'; } - if (null === $data || is_scalar($data)) { - if (is_float($data)) { + if (null === $data || \is_scalar($data)) { + if (\is_float($data)) { if (is_infinite($data)) { return ($data > 0 ? '' : '-') . 'INF'; } @@ -146,13 +191,13 @@ protected function normalize($data, int $depth = 0) return $data; } - if (is_array($data)) { + if (\is_array($data)) { $normalized = []; $count = 1; foreach ($data as $key => $value) { if ($count++ > $this->maxNormalizeItemCount) { - $normalized['...'] = 'Over ' . $this->maxNormalizeItemCount . ' items ('.count($data).' total), aborting normalization'; + $normalized['...'] = 'Over ' . $this->maxNormalizeItemCount . ' items ('.\count($data).' total), aborting normalization'; break; } @@ -166,38 +211,44 @@ protected function normalize($data, int $depth = 0) return $this->formatDate($data); } - if (is_object($data)) { + if (\is_object($data)) { if ($data instanceof Throwable) { return $this->normalizeException($data, $depth); } if ($data instanceof \JsonSerializable) { - /** @var null|scalar|array $value */ + /** @var null|scalar|array $value */ $value = $data->jsonSerialize(); } elseif (\get_class($data) === '__PHP_Incomplete_Class') { $accessor = new \ArrayObject($data); $value = (string) $accessor['__PHP_Incomplete_Class_Name']; } elseif (method_exists($data, '__toString')) { - /** @var string $value */ - $value = $data->__toString(); + try { + /** @var string $value */ + $value = $data->__toString(); + } catch (\Throwable) { + // if the toString method is failing, use the default behavior + /** @var null|scalar|array $value */ + $value = json_decode($this->toJson($data, true), true); + } } else { // the rest is normalized by json encoding and decoding it - /** @var null|scalar|array $value */ + /** @var null|scalar|array $value */ $value = json_decode($this->toJson($data, true), true); } return [Utils::getClass($data) => $value]; } - if (is_resource($data)) { + if (\is_resource($data)) { return sprintf('[resource(%s)]', get_resource_type($data)); } - return '[unknown('.gettype($data).')]'; + return '[unknown('.\gettype($data).')]'; } /** - * @return mixed[] + * @return array>> */ protected function normalizeException(Throwable $e, int $depth = 0) { @@ -209,11 +260,16 @@ protected function normalizeException(Throwable $e, int $depth = 0) return (array) $e->jsonSerialize(); } + $file = $e->getFile(); + if ($this->basePath !== '') { + $file = preg_replace('{^'.preg_quote($this->basePath).'}', '', $file); + } + $data = [ 'class' => Utils::getClass($e), 'message' => $e->getMessage(), 'code' => (int) $e->getCode(), - 'file' => $e->getFile().':'.$e->getLine(), + 'file' => $file.':'.$e->getLine(), ]; if ($e instanceof \SoapFault) { @@ -226,9 +282,9 @@ protected function normalizeException(Throwable $e, int $depth = 0) } if (isset($e->detail)) { - if (is_string($e->detail)) { + if (\is_string($e->detail)) { $data['detail'] = $e->detail; - } elseif (is_object($e->detail) || is_array($e->detail)) { + } elseif (\is_object($e->detail) || \is_array($e->detail)) { $data['detail'] = $this->toJson($e->detail, true); } } @@ -236,12 +292,16 @@ protected function normalizeException(Throwable $e, int $depth = 0) $trace = $e->getTrace(); foreach ($trace as $frame) { - if (isset($frame['file'])) { - $data['trace'][] = $frame['file'].':'.$frame['line']; + if (isset($frame['file'], $frame['line'])) { + $file = $frame['file']; + if ($this->basePath !== '') { + $file = preg_replace('{^'.preg_quote($this->basePath).'}', '', $file); + } + $data['trace'][] = $file.':'.$frame['line']; } } - if ($previous = $e->getPrevious()) { + if (($previous = $e->getPrevious()) instanceof \Throwable) { $data['previous'] = $this->normalizeException($previous, $depth + 1); } @@ -260,20 +320,20 @@ protected function toJson($data, bool $ignoreErrors = false): string return Utils::jsonEncode($data, $this->jsonEncodeOptions, $ignoreErrors); } - /** - * @return string - */ - protected function formatDate(\DateTimeInterface $date) + protected function formatDate(\DateTimeInterface $date): string { - // in case the date format isn't custom then we defer to the custom DateTimeImmutable + // in case the date format isn't custom then we defer to the custom JsonSerializableDateTimeImmutable // formatting logic, which will pick the right format based on whether useMicroseconds is on - if ($this->dateFormat === self::SIMPLE_DATE && $date instanceof DateTimeImmutable) { + if ($this->dateFormat === self::SIMPLE_DATE && $date instanceof JsonSerializableDateTimeImmutable) { return (string) $date; } return $date->format($this->dateFormat); } + /** + * @return $this + */ public function addJsonEncodeOption(int $option): self { $this->jsonEncodeOptions |= $option; @@ -281,6 +341,9 @@ public function addJsonEncodeOption(int $option): self return $this; } + /** + * @return $this + */ public function removeJsonEncodeOption(int $option): self { $this->jsonEncodeOptions &= ~$option; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php index 187bc550d..ec73a0ec4 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php @@ -11,8 +11,10 @@ namespace Monolog\Formatter; +use Monolog\LogRecord; + /** - * Formats data into an associative array of scalar values. + * Formats data into an associative array of scalar (+ null) values. * Objects and arrays will be JSON encoded. * * @author Andrew Lawson @@ -20,29 +22,25 @@ class ScalarFormatter extends NormalizerFormatter { /** - * {@inheritDoc} + * @inheritDoc * * @phpstan-return array $record */ - public function format(array $record): array + public function format(LogRecord $record): array { $result = []; - foreach ($record as $key => $value) { - $result[$key] = $this->normalizeValue($value); + foreach ($record->toArray() as $key => $value) { + $result[$key] = $this->toScalar($value); } return $result; } - /** - * @param mixed $value - * @return scalar|null - */ - protected function normalizeValue($value) + protected function toScalar(mixed $value): string|int|float|bool|null { $normalized = $this->normalize($value); - if (is_array($normalized)) { + if (\is_array($normalized)) { return $this->toJson($normalized, true); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/SyslogFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/SyslogFormatter.php new file mode 100644 index 000000000..ccaddf77a --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/SyslogFormatter.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Level; +use Monolog\LogRecord; + +/** + * Serializes a log message according to RFC 5424 + * + * @author Dalibor Karlović + * @author Renat Gabdullin + */ +class SyslogFormatter extends LineFormatter +{ + private const SYSLOG_FACILITY_USER = 1; + private const FORMAT = "<%extra.priority%>1 %datetime% %extra.hostname% %extra.app-name% %extra.procid% %channel% %extra.structured-data% %level_name%: %message% %context% %extra%\n"; + private const NILVALUE = '-'; + + private string $hostname; + private int $procid; + + public function __construct(private string $applicationName = self::NILVALUE) + { + parent::__construct(self::FORMAT, 'Y-m-d\TH:i:s.uP', true, true); + $this->hostname = (string) gethostname(); + $this->procid = (int) getmypid(); + } + + public function format(LogRecord $record): string + { + $record->extra = $this->formatExtra($record); + + return parent::format($record); + } + + /** + * @return array + */ + private function formatExtra(LogRecord $record): array + { + $extra = $record->extra; + $extra['app-name'] = $this->applicationName; + $extra['hostname'] = $this->hostname; + $extra['procid'] = $this->procid; + $extra['priority'] = self::calculatePriority($record->level); + $extra['structured-data'] = self::NILVALUE; + + return $extra; + } + + private static function calculatePriority(Level $level): int + { + return (self::SYSLOG_FACILITY_USER * 8) + $level->toRFC5424Level(); + } +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php index 6539b3473..4acfb9291 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php @@ -11,7 +11,8 @@ namespace Monolog\Formatter; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Serializes a log message according to Wildfire's header requirements @@ -19,27 +20,9 @@ * @author Eric Clemmons (@ericclemmons) * @author Christophe Coevoet * @author Kirill chEbba Chebunin - * - * @phpstan-import-type Level from \Monolog\Logger */ class WildfireFormatter extends NormalizerFormatter { - /** - * Translates Monolog log levels to Wildfire levels. - * - * @var array - */ - private $logLevels = [ - Logger::DEBUG => 'LOG', - Logger::INFO => 'INFO', - Logger::NOTICE => 'INFO', - Logger::WARNING => 'WARN', - Logger::ERROR => 'ERROR', - Logger::CRITICAL => 'ERROR', - Logger::ALERT => 'ERROR', - Logger::EMERGENCY => 'ERROR', - ]; - /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format */ @@ -52,46 +35,61 @@ public function __construct(?string $dateFormat = null) } /** - * {@inheritDoc} + * Translates Monolog log levels to Wildfire levels. * - * @return string + * @return 'LOG'|'INFO'|'WARN'|'ERROR' + */ + private function toWildfireLevel(Level $level): string + { + return match ($level) { + Level::Debug => 'LOG', + Level::Info => 'INFO', + Level::Notice => 'INFO', + Level::Warning => 'WARN', + Level::Error => 'ERROR', + Level::Critical => 'ERROR', + Level::Alert => 'ERROR', + Level::Emergency => 'ERROR', + }; + } + + /** + * @inheritDoc */ - public function format(array $record): string + public function format(LogRecord $record): string { // Retrieve the line and file if set and remove them from the formatted extra $file = $line = ''; - if (isset($record['extra']['file'])) { - $file = $record['extra']['file']; - unset($record['extra']['file']); + if (isset($record->extra['file'])) { + $file = $record->extra['file']; + unset($record->extra['file']); } - if (isset($record['extra']['line'])) { - $line = $record['extra']['line']; - unset($record['extra']['line']); + if (isset($record->extra['line'])) { + $line = $record->extra['line']; + unset($record->extra['line']); } - /** @var mixed[] $record */ - $record = $this->normalize($record); - $message = ['message' => $record['message']]; + $message = ['message' => $record->message]; $handleError = false; - if ($record['context']) { - $message['context'] = $record['context']; + if (\count($record->context) > 0) { + $message['context'] = $this->normalize($record->context); $handleError = true; } - if ($record['extra']) { - $message['extra'] = $record['extra']; + if (\count($record->extra) > 0) { + $message['extra'] = $this->normalize($record->extra); $handleError = true; } - if (count($message) === 1) { + if (\count($message) === 1) { $message = reset($message); } - if (isset($record['context']['table'])) { + if (is_array($message) && isset($message['context']) && \is_array($message['context']) && isset($message['context']['table'])) { $type = 'TABLE'; - $label = $record['channel'] .': '. $record['message']; - $message = $record['context']['table']; + $label = $record->channel .': '. $record->message; + $message = $message['context']['table']; } else { - $type = $this->logLevels[$record['level']]; - $label = $record['channel']; + $type = $this->toWildfireLevel($record->level); + $label = $record->channel; } // Create JSON object describing the appearance of the message in the console @@ -108,13 +106,13 @@ public function format(array $record): string // The message itself is a serialization of the above JSON object + it's length return sprintf( '%d|%s|', - strlen($json), + \strlen($json), $json ); } /** - * {@inheritDoc} + * @inheritDoc * * @phpstan-return never */ @@ -124,13 +122,13 @@ public function formatBatch(array $records) } /** - * {@inheritDoc} + * @inheritDoc * - * @return null|scalar|array|object + * @return null|scalar|array|object */ - protected function normalize($data, int $depth = 0) + protected function normalize(mixed $data, int $depth = 0): mixed { - if (is_object($data) && !$data instanceof \DateTimeInterface) { + if (\is_object($data) && !$data instanceof \DateTimeInterface) { return $data; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php index a5cdaa71f..61d45d58b 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php @@ -11,55 +11,51 @@ namespace Monolog\Handler; +use Monolog\Level; use Monolog\Logger; use Monolog\ResettableInterface; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Base Handler class providing basic level/bubble support * * @author Jordi Boggiano - * - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ abstract class AbstractHandler extends Handler implements ResettableInterface { - /** - * @var int - * @phpstan-var Level - */ - protected $level = Logger::DEBUG; - /** @var bool */ - protected $bubble = true; + protected Level $level = Level::Debug; + protected bool $bubble = true; /** - * @param int|string $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param int|string|Level|LogLevel::* $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function __construct($level = Logger::DEBUG, bool $bubble = true) + public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true) { $this->setLevel($level); $this->bubble = $bubble; } /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { - return $record['level'] >= $this->level; + return $record->level->value >= $this->level->value; } /** * Sets minimum logging level at which this handler will be triggered. * - * @param Level|LevelName|LogLevel::* $level Level or level name - * @return self + * @param Level|LogLevel::* $level Level or level name + * @return $this + * + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function setLevel($level): self + public function setLevel(int|string|Level $level): self { $this->level = Logger::toMonologLevel($level); @@ -68,12 +64,8 @@ public function setLevel($level): self /** * Gets minimum logging level at which this handler will be triggered. - * - * @return int - * - * @phpstan-return Level */ - public function getLevel(): int + public function getLevel(): Level { return $this->level; } @@ -81,9 +73,9 @@ public function getLevel(): int /** * Sets the bubbling behavior. * - * @param bool $bubble true means that this handler allows bubbling. - * false means that bubbling is not permitted. - * @return self + * @param bool $bubble true means that this handler allows bubbling. + * false means that bubbling is not permitted. + * @return $this */ public function setBubble(bool $bubble): self { @@ -104,9 +96,9 @@ public function getBubble(): bool } /** - * {@inheritDoc} + * @inheritDoc */ - public function reset() + public function reset(): void { } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php index 77e533fca..de13a76be 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php @@ -11,6 +11,8 @@ namespace Monolog\Handler; +use Monolog\LogRecord; + /** * Base Handler class providing the Handler structure, including processors and formatters * @@ -18,11 +20,6 @@ * * @author Jordi Boggiano * @author Christophe Coevoet - * - * @phpstan-import-type LevelName from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-type FormattedRecord array{message: string, context: mixed[], level: Level, level_name: LevelName, channel: string, datetime: \DateTimeImmutable, extra: mixed[], formatted: mixed} */ abstract class AbstractProcessingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface { @@ -30,20 +27,19 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc use FormattableHandlerTrait; /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if (!$this->isHandling($record)) { return false; } - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } - $record['formatted'] = $this->getFormatter()->format($record); + $record->formatted = $this->getFormatter()->format($record); $this->write($record); @@ -51,16 +47,11 @@ public function handle(array $record): bool } /** - * Writes the record down to the log of the implementing handler - * - * @phpstan-param FormattedRecord $record + * Writes the (already formatted) record down to the log of the implementing handler */ - abstract protected function write(array $record): void; + abstract protected function write(LogRecord $record): void; - /** - * @return void - */ - public function reset() + public function reset(): void { parent::reset(); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php index 5e5ad1c1f..4a7031706 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php @@ -11,70 +11,59 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; /** * Common syslog functionality - * - * @phpstan-import-type Level from \Monolog\Logger */ abstract class AbstractSyslogHandler extends AbstractProcessingHandler { - /** @var int */ - protected $facility; + protected int $facility; /** - * Translates Monolog log levels to syslog log priorities. - * @var array - * @phpstan-var array + * List of valid log facility names. + * @var array */ - protected $logLevels = [ - Logger::DEBUG => LOG_DEBUG, - Logger::INFO => LOG_INFO, - Logger::NOTICE => LOG_NOTICE, - Logger::WARNING => LOG_WARNING, - Logger::ERROR => LOG_ERR, - Logger::CRITICAL => LOG_CRIT, - Logger::ALERT => LOG_ALERT, - Logger::EMERGENCY => LOG_EMERG, + protected array $facilities = [ + 'auth' => \LOG_AUTH, + 'authpriv' => \LOG_AUTHPRIV, + 'cron' => \LOG_CRON, + 'daemon' => \LOG_DAEMON, + 'kern' => \LOG_KERN, + 'lpr' => \LOG_LPR, + 'mail' => \LOG_MAIL, + 'news' => \LOG_NEWS, + 'syslog' => \LOG_SYSLOG, + 'user' => \LOG_USER, + 'uucp' => \LOG_UUCP, ]; /** - * List of valid log facility names. - * @var array + * Translates Monolog log levels to syslog log priorities. */ - protected $facilities = [ - 'auth' => LOG_AUTH, - 'authpriv' => LOG_AUTHPRIV, - 'cron' => LOG_CRON, - 'daemon' => LOG_DAEMON, - 'kern' => LOG_KERN, - 'lpr' => LOG_LPR, - 'mail' => LOG_MAIL, - 'news' => LOG_NEWS, - 'syslog' => LOG_SYSLOG, - 'user' => LOG_USER, - 'uucp' => LOG_UUCP, - ]; + protected function toSyslogPriority(Level $level): int + { + return $level->toRFC5424Level(); + } /** * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant */ - public function __construct($facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(string|int $facility = \LOG_USER, int|string|Level $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->facilities['local0'] = LOG_LOCAL0; - $this->facilities['local1'] = LOG_LOCAL1; - $this->facilities['local2'] = LOG_LOCAL2; - $this->facilities['local3'] = LOG_LOCAL3; - $this->facilities['local4'] = LOG_LOCAL4; - $this->facilities['local5'] = LOG_LOCAL5; - $this->facilities['local6'] = LOG_LOCAL6; - $this->facilities['local7'] = LOG_LOCAL7; + if (!\defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->facilities['local0'] = \LOG_LOCAL0; + $this->facilities['local1'] = \LOG_LOCAL1; + $this->facilities['local2'] = \LOG_LOCAL2; + $this->facilities['local3'] = \LOG_LOCAL3; + $this->facilities['local4'] = \LOG_LOCAL4; + $this->facilities['local5'] = \LOG_LOCAL5; + $this->facilities['local6'] = \LOG_LOCAL6; + $this->facilities['local7'] = \LOG_LOCAL7; } else { $this->facilities['local0'] = 128; // LOG_LOCAL0 $this->facilities['local1'] = 136; // LOG_LOCAL1 @@ -87,9 +76,9 @@ public function __construct($facility = LOG_USER, $level = Logger::DEBUG, bool $ } // convert textual description of facility to syslog constant - if (is_string($facility) && array_key_exists(strtolower($facility), $this->facilities)) { + if (\is_string($facility) && \array_key_exists(strtolower($facility), $this->facilities)) { $facility = $this->facilities[strtolower($facility)]; - } elseif (!in_array($facility, array_values($this->facilities), true)) { + } elseif (!\in_array($facility, array_values($this->facilities), true)) { throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given'); } @@ -97,7 +86,7 @@ public function __construct($facility = LOG_USER, $level = Logger::DEBUG, bool $ } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php index 994872ce8..119f33947 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php @@ -11,24 +11,39 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Gelf\Message as GelfMessage; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\JsonFormatter; use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Channel\AMQPChannel; use AMQPExchange; +use Monolog\LogRecord; -/** - * @phpstan-import-type Record from \Monolog\Logger - */ class AmqpHandler extends AbstractProcessingHandler { + protected AMQPExchange|AMQPChannel $exchange; + + /** @var array */ + private array $extraAttributes = []; + + protected string $exchangeName; + /** - * @var AMQPExchange|AMQPChannel $exchange + * @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use + * @param string|null $exchangeName Optional exchange name, for AMQPChannel (PhpAmqpLib) only */ - protected $exchange; - /** @var array */ - private $extraAttributes = []; + public function __construct(AMQPExchange|AMQPChannel $exchange, ?string $exchangeName = null, int|string|Level $level = Level::Debug, bool $bubble = true) + { + if ($exchange instanceof AMQPChannel) { + $this->exchangeName = (string) $exchangeName; + } elseif ($exchangeName !== null) { + @trigger_error('The $exchangeName parameter can only be passed when using PhpAmqpLib, if using an AMQPExchange instance configure it beforehand', E_USER_DEPRECATED); + } + $this->exchange = $exchange; + + parent::__construct($level, $bubble); + } /** * @return array @@ -41,55 +56,37 @@ public function getExtraAttributes(): array /** * Configure extra attributes to pass to the AMQPExchange (if you are using the amqp extension) * - * @param array $extraAttributes One of content_type, content_encoding, + * @param array $extraAttributes One of content_type, content_encoding, * message_id, user_id, app_id, delivery_mode, * priority, timestamp, expiration, type * or reply_to, headers. - * @return AmqpHandler + * @return $this */ public function setExtraAttributes(array $extraAttributes): self { $this->extraAttributes = $extraAttributes; - return $this; - } - /** - * @var string - */ - protected $exchangeName; - - /** - * @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use - * @param string|null $exchangeName Optional exchange name, for AMQPChannel (PhpAmqpLib) only - */ - public function __construct($exchange, ?string $exchangeName = null, $level = Logger::DEBUG, bool $bubble = true) - { - if ($exchange instanceof AMQPChannel) { - $this->exchangeName = (string) $exchangeName; - } elseif (!$exchange instanceof AMQPExchange) { - throw new \InvalidArgumentException('PhpAmqpLib\Channel\AMQPChannel or AMQPExchange instance required'); - } elseif ($exchangeName) { - @trigger_error('The $exchangeName parameter can only be passed when using PhpAmqpLib, if using an AMQPExchange instance configure it beforehand', E_USER_DEPRECATED); - } - $this->exchange = $exchange; - - parent::__construct($level, $bubble); + return $this; } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $data = $record["formatted"]; + $data = $record->formatted; $routingKey = $this->getRoutingKey($record); + if($data instanceof GelfMessage) { + $data = json_encode($data->toArray()); + } + if ($this->exchange instanceof AMQPExchange) { $attributes = [ 'delivery_mode' => 2, 'content_type' => 'application/json', ]; - if ($this->extraAttributes) { + if (\count($this->extraAttributes) > 0) { $attributes = array_merge($attributes, $this->extraAttributes); } $this->exchange->publish( @@ -108,7 +105,7 @@ protected function write(array $record): void } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -123,10 +120,13 @@ public function handleBatch(array $records): void continue; } - /** @var Record $record */ $record = $this->processRecord($record); $data = $this->getFormatter()->format($record); + if($data instanceof GelfMessage) { + $data = json_encode($data->toArray()); + } + $this->exchange->batch_basic_publish( $this->createAmqpMessage($data), $this->exchangeName, @@ -139,12 +139,10 @@ public function handleBatch(array $records): void /** * Gets the routing key for the AMQP exchange - * - * @phpstan-param Record $record */ - protected function getRoutingKey(array $record): string + protected function getRoutingKey(LogRecord $record): string { - $routingKey = sprintf('%s.%s', $record['level_name'], $record['channel']); + $routingKey = sprintf('%s.%s', $record->level->name, $record->channel); return strtolower($routingKey); } @@ -155,14 +153,15 @@ private function createAmqpMessage(string $data): AMQPMessage 'delivery_mode' => 2, 'content_type' => 'application/json', ]; - if ($this->extraAttributes) { + if (\count($this->extraAttributes) > 0) { $attributes = array_merge($attributes, $this->extraAttributes); } + return new AMQPMessage($data, $attributes); } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php index 95bbfed42..788d7d068 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php @@ -14,35 +14,30 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; use Monolog\Utils; -use Monolog\Logger; +use Monolog\LogRecord; +use Monolog\Level; -use function count; use function headers_list; use function stripos; -use function trigger_error; - -use const E_USER_DEPRECATED; /** * Handler sending logs to browser's javascript console with no browser extension required * * @author Olivier Poitrey - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class BrowserConsoleHandler extends AbstractProcessingHandler { - /** @var bool */ - protected static $initialized = false; - /** @var FormattedRecord[] */ - protected static $records = []; + protected static bool $initialized = false; + + /** @var LogRecord[] */ + protected static array $records = []; protected const FORMAT_HTML = 'html'; protected const FORMAT_JS = 'js'; protected const FORMAT_UNKNOWN = 'unknown'; /** - * {@inheritDoc} + * @inheritDoc * * Formatted output may contain some formatting markers to be transferred to `console.log` using the %c format. * @@ -56,9 +51,9 @@ protected function getDefaultFormatter(): FormatterInterface } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { // Accumulate records static::$records[] = $record; @@ -81,11 +76,11 @@ public static function send(): void return; } - if (count(static::$records)) { + if (\count(static::$records) > 0) { if ($format === self::FORMAT_HTML) { - static::writeOutput(''); - } elseif ($format === self::FORMAT_JS) { - static::writeOutput(static::generateScript()); + static::writeOutput(''); + } else { // js format + static::writeOutput(self::generateScript()); } static::resetStatic(); } @@ -96,7 +91,7 @@ public function close(): void self::resetStatic(); } - public function reset() + public function reset(): void { parent::reset(); @@ -174,18 +169,18 @@ private static function generateScript(): string { $script = []; foreach (static::$records as $record) { - $context = static::dump('Context', $record['context']); - $extra = static::dump('Extra', $record['extra']); + $context = self::dump('Context', $record->context); + $extra = self::dump('Extra', $record->extra); - if (empty($context) && empty($extra)) { - $script[] = static::call_array(static::getConsoleMethodForLevel($record['level']), static::handleStyles($record['formatted'])); + if (\count($context) === 0 && \count($extra) === 0) { + $script[] = self::call_array(self::getConsoleMethodForLevel($record->level), self::handleStyles($record->formatted)); } else { $script = array_merge( $script, - [static::call_array('groupCollapsed', static::handleStyles($record['formatted']))], + [self::call_array('groupCollapsed', self::handleStyles($record->formatted))], $context, $extra, - [static::call('groupEnd')] + [self::call('groupEnd')] ); } } @@ -193,18 +188,14 @@ private static function generateScript(): string return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);"; } - private static function getConsoleMethodForLevel(int $level): string + private static function getConsoleMethodForLevel(Level $level): string { - return [ - Logger::DEBUG => 'debug', - Logger::INFO => 'info', - Logger::NOTICE => 'info', - Logger::WARNING => 'warn', - Logger::ERROR => 'error', - Logger::CRITICAL => 'error', - Logger::ALERT => 'error', - Logger::EMERGENCY => 'error', - ][$level] ?? 'log'; + return match ($level) { + Level::Debug => 'debug', + Level::Info, Level::Notice => 'info', + Level::Warning => 'warn', + Level::Error, Level::Critical, Level::Alert, Level::Emergency => 'error', + }; } /** @@ -218,14 +209,14 @@ private static function handleStyles(string $formatted): array foreach (array_reverse($matches) as $match) { $args[] = '"font-weight: normal"'; - $args[] = static::quote(static::handleCustomStyles($match[2][0], $match[1][0])); + $args[] = self::quote(self::handleCustomStyles($match[2][0], $match[1][0])); $pos = $match[0][1]; - $format = Utils::substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . Utils::substr($format, $pos + strlen($match[0][0])); + $format = Utils::substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . Utils::substr($format, $pos + \strlen($match[0][0])); } - $args[] = static::quote('font-weight: normal'); - $args[] = static::quote($format); + $args[] = self::quote('font-weight: normal'); + $args[] = self::quote($format); return array_reverse($args); } @@ -239,7 +230,7 @@ private static function handleCustomStyles(string $style, string $string): strin if (trim($m[1]) === 'autolabel') { // Format the string as a label with consistent auto assigned background color if (!isset($labels[$string])) { - $labels[$string] = $colors[count($labels) % count($colors)]; + $labels[$string] = $colors[\count($labels) % \count($colors)]; } $color = $labels[$string]; @@ -251,7 +242,8 @@ private static function handleCustomStyles(string $style, string $string): strin if (null === $style) { $pcreErrorCode = preg_last_error(); - throw new \RuntimeException('Failed to run preg_replace_callback: ' . $pcreErrorCode . ' / ' . Utils::pcreLastErrorMessage($pcreErrorCode)); + + throw new \RuntimeException('Failed to run preg_replace_callback: ' . $pcreErrorCode . ' / ' . preg_last_error_msg()); } return $style; @@ -264,17 +256,17 @@ private static function handleCustomStyles(string $style, string $string): strin private static function dump(string $title, array $dict): array { $script = []; - $dict = array_filter($dict); - if (empty($dict)) { + $dict = array_filter($dict, fn ($value) => $value !== null); + if (\count($dict) === 0) { return $script; } - $script[] = static::call('log', static::quote('%c%s'), static::quote('font-weight: bold'), static::quote($title)); + $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title)); foreach ($dict as $key => $value) { $value = json_encode($value); - if (empty($value)) { - $value = static::quote(''); + if (false === $value) { + $value = self::quote(''); } - $script[] = static::call('log', static::quote('%s: %o'), static::quote((string) $key), $value); + $script[] = self::call('log', self::quote('%s: %o'), self::quote((string) $key), $value); } return $script; @@ -291,11 +283,11 @@ private static function quote(string $arg): string private static function call(...$args): string { $method = array_shift($args); - if (!is_string($method)) { + if (!\is_string($method)) { throw new \UnexpectedValueException('Expected the first arg to be a string, got: '.var_export($method, true)); } - return static::call_array($method, $args); + return self::call_array($method, $args); } /** diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php index fcce5d630..c799b6b9c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php @@ -11,9 +11,10 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\ResettableInterface; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Buffers all records until closing the handler and then pass them as batch. @@ -22,32 +23,30 @@ * sending one per log message. * * @author Christophe Coevoet - * - * @phpstan-import-type Record from \Monolog\Logger */ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface { use ProcessableHandlerTrait; - /** @var HandlerInterface */ - protected $handler; - /** @var int */ - protected $bufferSize = 0; - /** @var int */ - protected $bufferLimit; - /** @var bool */ - protected $flushOnOverflow; - /** @var Record[] */ - protected $buffer = []; - /** @var bool */ - protected $initialized = false; + protected HandlerInterface $handler; + + protected int $bufferSize = 0; + + protected int $bufferLimit; + + protected bool $flushOnOverflow; + + /** @var LogRecord[] */ + protected array $buffer = []; + + protected bool $initialized = false; /** * @param HandlerInterface $handler Handler. * @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. * @param bool $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded */ - public function __construct(HandlerInterface $handler, int $bufferLimit = 0, $level = Logger::DEBUG, bool $bubble = true, bool $flushOnOverflow = false) + public function __construct(HandlerInterface $handler, int $bufferLimit = 0, int|string|Level $level = Level::Debug, bool $bubble = true, bool $flushOnOverflow = false) { parent::__construct($level, $bubble); $this->handler = $handler; @@ -56,11 +55,11 @@ public function __construct(HandlerInterface $handler, int $bufferLimit = 0, $le } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - if ($record['level'] < $this->level) { + if ($record->level->isLowerThan($this->level)) { return false; } @@ -79,8 +78,7 @@ public function handle(array $record): bool } } - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } @@ -108,7 +106,7 @@ public function __destruct() } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -126,7 +124,7 @@ public function clear(): void $this->buffer = []; } - public function reset() + public function reset(): void { $this->flush(); @@ -140,7 +138,7 @@ public function reset() } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -150,11 +148,11 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface return $this; } - throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($this->handler).' does not support formatters.'); } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { @@ -162,6 +160,11 @@ public function getFormatter(): FormatterInterface return $this->handler->getFormatter(); } - throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($this->handler).' does not support formatters.'); + } + + public function setHandler(HandlerInterface $handler): void + { + $this->handler = $handler; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php index 234ecf614..6598e822c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php @@ -13,8 +13,10 @@ use Monolog\Formatter\ChromePHPFormatter; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; +use Monolog\JsonSerializableDateTimeImmutable; /** * Handler sending logs to the ChromePHP extension (http://www.chromephp.com/) @@ -22,8 +24,6 @@ * This also works out of the box with Firefox 43+ * * @author Christophe Coevoet - * - * @phpstan-import-type Record from \Monolog\Logger */ class ChromePHPHandler extends AbstractProcessingHandler { @@ -44,38 +44,31 @@ class ChromePHPHandler extends AbstractProcessingHandler */ protected const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|HeadlessChrome|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}'; - /** @var bool */ - protected static $initialized = false; + protected static bool $initialized = false; /** * Tracks whether we sent too much data * * Chrome limits the headers to 4KB, so when we sent 3KB we stop sending - * - * @var bool */ - protected static $overflowed = false; + protected static bool $overflowed = false; /** @var mixed[] */ - protected static $json = [ + protected static array $json = [ 'version' => self::VERSION, 'columns' => ['label', 'log', 'backtrace', 'type'], 'rows' => [], ]; - /** @var bool */ - protected static $sendHeaders = true; + protected static bool $sendHeaders = true; - public function __construct($level = Logger::DEBUG, bool $bubble = true) + public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); - if (!function_exists('json_encode')) { - throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s ChromePHPHandler'); - } } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -86,15 +79,15 @@ public function handleBatch(array $records): void $messages = []; foreach ($records as $record) { - if ($record['level'] < $this->level) { + if ($record->level < $this->level) { continue; } - /** @var Record $message */ + $message = $this->processRecord($record); $messages[] = $message; } - if (!empty($messages)) { + if (\count($messages) > 0) { $messages = $this->getFormatter()->formatBatch($messages); self::$json['rows'] = array_merge(self::$json['rows'], $messages); $this->send(); @@ -102,7 +95,7 @@ public function handleBatch(array $records): void } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { @@ -115,13 +108,13 @@ protected function getDefaultFormatter(): FormatterInterface * @see sendHeader() * @see send() */ - protected function write(array $record): void + protected function write(LogRecord $record): void { if (!$this->isWebRequest()) { return; } - self::$json['rows'][] = $record['formatted']; + self::$json['rows'][] = $record->formatted; $this->send(); } @@ -150,19 +143,16 @@ protected function send(): void $json = Utils::jsonEncode(self::$json, Utils::DEFAULT_JSON_FLAGS & ~JSON_UNESCAPED_UNICODE, true); $data = base64_encode($json); - if (strlen($data) > 3 * 1024) { + if (\strlen($data) > 3 * 1024) { self::$overflowed = true; - $record = [ - 'message' => 'Incomplete logs, chrome header size limit reached', - 'context' => [], - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'monolog', - 'datetime' => new \DateTimeImmutable(), - 'extra' => [], - ]; - self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record); + $record = new LogRecord( + message: 'Incomplete logs, chrome header size limit reached', + level: Level::Warning, + channel: 'monolog', + datetime: new JsonSerializableDateTimeImmutable(true), + ); + self::$json['rows'][\count(self::$json['rows']) - 1] = $this->getFormatter()->format($record); $json = Utils::jsonEncode(self::$json, Utils::DEFAULT_JSON_FLAGS & ~JSON_UNESCAPED_UNICODE, true); $data = base64_encode($json); } @@ -187,7 +177,7 @@ protected function sendHeader(string $header, string $content): void */ protected function headersAccepted(): bool { - if (empty($_SERVER['HTTP_USER_AGENT'])) { + if (!isset($_SERVER['HTTP_USER_AGENT'])) { return false; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php index 526576132..8d9c10e76 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php @@ -13,22 +13,42 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\JsonFormatter; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * CouchDB handler * * @author Markus Bachmann + * @phpstan-type Options array{ + * host: string, + * port: int, + * dbname: string, + * username: string|null, + * password: string|null + * } + * @phpstan-type InputOptions array{ + * host?: string, + * port?: int, + * dbname?: string, + * username?: string|null, + * password?: string|null + * } */ class CouchDBHandler extends AbstractProcessingHandler { - /** @var mixed[] */ - private $options; + /** + * @var mixed[] + * @phpstan-var Options + */ + private array $options; /** * @param mixed[] $options + * + * @phpstan-param InputOptions $options */ - public function __construct(array $options = [], $level = Logger::DEBUG, bool $bubble = true) + public function __construct(array $options = [], int|string|Level $level = Level::Debug, bool $bubble = true) { $this->options = array_merge([ 'host' => 'localhost', @@ -42,12 +62,12 @@ public function __construct(array $options = [], $level = Logger::DEBUG, bool $b } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { $basicAuth = null; - if ($this->options['username']) { + if (null !== $this->options['username'] && null !== $this->options['password']) { $basicAuth = sprintf('%s:%s@', $this->options['username'], $this->options['password']); } @@ -55,7 +75,7 @@ protected function write(array $record): void $context = stream_context_create([ 'http' => [ 'method' => 'POST', - 'content' => $record['formatted'], + 'content' => $record->formatted, 'ignore_errors' => true, 'max_redirects' => 0, 'header' => 'Content-type: application/json', @@ -68,7 +88,7 @@ protected function write(array $record): void } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php index 3535a4fcd..f9ebedece 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php @@ -11,8 +11,9 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * Logs to Cube. @@ -23,18 +24,13 @@ */ class CubeHandler extends AbstractProcessingHandler { - /** @var resource|\Socket|null */ - private $udpConnection = null; - /** @var resource|\CurlHandle|null */ - private $httpConnection = null; - /** @var string */ - private $scheme; - /** @var string */ - private $host; - /** @var int */ - private $port; + private ?\Socket $udpConnection = null; + private ?\CurlHandle $httpConnection = null; + private string $scheme; + private string $host; + private int $port; /** @var string[] */ - private $acceptedSchemes = ['http', 'udp']; + private array $acceptedSchemes = ['http', 'udp']; /** * Create a Cube handler @@ -43,7 +39,7 @@ class CubeHandler extends AbstractProcessingHandler * A valid url must consist of three parts : protocol://host:port * Only valid protocols used by Cube are http and udp */ - public function __construct(string $url, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(string $url, int|string|Level $level = Level::Debug, bool $bubble = true) { $urlInfo = parse_url($url); @@ -51,7 +47,7 @@ public function __construct(string $url, $level = Logger::DEBUG, bool $bubble = throw new \UnexpectedValueException('URL "'.$url.'" is not valid'); } - if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) { + if (!\in_array($urlInfo['scheme'], $this->acceptedSchemes, true)) { throw new \UnexpectedValueException( 'Invalid protocol (' . $urlInfo['scheme'] . ').' . ' Valid options are ' . implode(', ', $this->acceptedSchemes) @@ -60,7 +56,7 @@ public function __construct(string $url, $level = Logger::DEBUG, bool $bubble = $this->scheme = $urlInfo['scheme']; $this->host = $urlInfo['host']; - $this->port = (int) $urlInfo['port']; + $this->port = $urlInfo['port']; parent::__construct($level, $bubble); } @@ -73,7 +69,7 @@ public function __construct(string $url, $level = Logger::DEBUG, bool $bubble = */ protected function connectUdp(): void { - if (!extension_loaded('sockets')) { + if (!\extension_loaded('sockets')) { throw new MissingExtensionException('The sockets extension is required to use udp URLs with the CubeHandler'); } @@ -96,7 +92,7 @@ protected function connectUdp(): void */ protected function connectHttp(): void { - if (!extension_loaded('curl')) { + if (!\extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is required to use http URLs with the CubeHandler'); } @@ -111,24 +107,24 @@ protected function connectHttp(): void } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $date = $record['datetime']; + $date = $record->datetime; $data = ['time' => $date->format('Y-m-d\TH:i:s.uO')]; - unset($record['datetime']); + $context = $record->context; - if (isset($record['context']['type'])) { - $data['type'] = $record['context']['type']; - unset($record['context']['type']); + if (isset($context['type'])) { + $data['type'] = $context['type']; + unset($context['type']); } else { - $data['type'] = $record['channel']; + $data['type'] = $record->channel; } - $data['data'] = $record['context']; - $data['data']['level'] = $record['level']; + $data['data'] = $context; + $data['data']['level'] = $record->level; if ($this->scheme === 'http') { $this->writeHttp(Utils::jsonEncode($data)); @@ -139,16 +135,20 @@ protected function write(array $record): void private function writeUdp(string $data): void { - if (!$this->udpConnection) { + if (null === $this->udpConnection) { $this->connectUdp(); } - socket_send($this->udpConnection, $data, strlen($data), 0); + if (null === $this->udpConnection) { + throw new \LogicException('No UDP socket could be opened'); + } + + socket_send($this->udpConnection, $data, \strlen($data), 0); } private function writeHttp(string $data): void { - if (!$this->httpConnection) { + if (null === $this->httpConnection) { $this->connectHttp(); } @@ -159,9 +159,9 @@ private function writeHttp(string $data): void curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']'); curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', - 'Content-Length: ' . strlen('['.$data.']'), + 'Content-Length: ' . \strlen('['.$data.']'), ]); - Curl\Util::execute($this->httpConnection, 5, false); + Curl\Util::execute($this->httpConnection, 5); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php index 7213e8ee2..2ef58877d 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php @@ -21,7 +21,7 @@ final class Util { /** @var array */ - private static $retriableErrorCodes = [ + private static array $retriableErrorCodes = [ CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_HTTP_NOT_FOUND, @@ -34,38 +34,27 @@ final class Util /** * Executes a CURL request with optional retries and exception on failure * - * @param resource|CurlHandle $ch curl handler - * @param int $retries - * @param bool $closeAfterDone - * @return bool|string @see curl_exec + * @param CurlHandle $ch curl handler + * @return bool|string @see curl_exec */ - public static function execute($ch, int $retries = 5, bool $closeAfterDone = true) + public static function execute(CurlHandle $ch, int $retries = 5): bool|string { - while ($retries--) { + while ($retries > 0) { + $retries--; $curlResponse = curl_exec($ch); if ($curlResponse === false) { $curlErrno = curl_errno($ch); - if (false === in_array($curlErrno, self::$retriableErrorCodes, true) || !$retries) { + if (false === \in_array($curlErrno, self::$retriableErrorCodes, true) || $retries === 0) { $curlError = curl_error($ch); - if ($closeAfterDone) { - curl_close($ch); - } - throw new \RuntimeException(sprintf('Curl error (code %d): %s', $curlErrno, $curlError)); } - continue; } - if ($closeAfterDone) { - curl_close($ch); - } - return $curlResponse; } - return false; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php index 9b85ae7ed..2b1d0b867 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php @@ -11,8 +11,10 @@ namespace Monolog\Handler; +use Monolog\Level; use Monolog\Logger; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Simple handler wrapper that deduplicates log records across multiple requests @@ -33,45 +35,28 @@ * same way. * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger */ class DeduplicationHandler extends BufferHandler { - /** - * @var string - */ - protected $deduplicationStore; + protected string $deduplicationStore; - /** - * @var Level - */ - protected $deduplicationLevel; + protected Level $deduplicationLevel; - /** - * @var int - */ - protected $time; + protected int $time; + protected bool $gc = false; /** - * @var bool - */ - private $gc = false; - - /** - * @param HandlerInterface $handler Handler. - * @param string $deduplicationStore The file/path where the deduplication log should be kept - * @param string|int $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes - * @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param HandlerInterface $handler Handler. + * @param string|null $deduplicationStore The file/path where the deduplication log should be kept + * @param int|string|Level|LogLevel::* $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes + * @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * - * @phpstan-param Level|LevelName|LogLevel::* $deduplicationLevel + * @phpstan-param value-of|value-of|Level|LogLevel::* $deduplicationLevel */ - public function __construct(HandlerInterface $handler, ?string $deduplicationStore = null, $deduplicationLevel = Logger::ERROR, int $time = 60, bool $bubble = true) + public function __construct(HandlerInterface $handler, ?string $deduplicationStore = null, int|string|Level $deduplicationLevel = Level::Error, int $time = 60, bool $bubble = true) { - parent::__construct($handler, 0, Logger::DEBUG, $bubble, false); + parent::__construct($handler, 0, Level::Debug, $bubble, false); $this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore; $this->deduplicationLevel = Logger::toMonologLevel($deduplicationLevel); @@ -84,13 +69,24 @@ public function flush(): void return; } + $store = null; + + if (file_exists($this->deduplicationStore)) { + $store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + } + $passthru = null; foreach ($this->buffer as $record) { - if ($record['level'] >= $this->deduplicationLevel) { - $passthru = $passthru || !$this->isDuplicate($record); + if ($record->level->value >= $this->deduplicationLevel->value) { + $passthru = $passthru === true || !\is_array($store) || !$this->isDuplicate($store, $record); if ($passthru) { - $this->appendRecord($record); + $line = $this->buildDeduplicationStoreEntry($record); + file_put_contents($this->deduplicationStore, $line . "\n", FILE_APPEND); + if (!\is_array($store)) { + $store = []; + } + $store[] = $line; } } } @@ -108,27 +104,19 @@ public function flush(): void } /** - * @phpstan-param Record $record + * If there is a store entry older than e.g. a day, this method should set `$this->gc` to `true` to trigger garbage collection. + * @param string[] $store The deduplication store */ - private function isDuplicate(array $record): bool + protected function isDuplicate(array $store, LogRecord $record): bool { - if (!file_exists($this->deduplicationStore)) { - return false; - } - - $store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - if (!is_array($store)) { - return false; - } - + $timestampValidity = $record->datetime->getTimestamp() - $this->time; + $expectedMessage = preg_replace('{[\r\n].*}', '', $record->message); $yesterday = time() - 86400; - $timestampValidity = $record['datetime']->getTimestamp() - $this->time; - $expectedMessage = preg_replace('{[\r\n].*}', '', $record['message']); - for ($i = count($store) - 1; $i >= 0; $i--) { + for ($i = \count($store) - 1; $i >= 0; $i--) { list($timestamp, $level, $message) = explode(':', $store[$i], 3); - if ($level === $record['level_name'] && $message === $expectedMessage && $timestamp > $timestampValidity) { + if ($level === $record->level->getName() && $message === $expectedMessage && $timestamp > $timestampValidity) { return true; } @@ -140,6 +128,14 @@ private function isDuplicate(array $record): bool return false; } + /** + * @return string The given record serialized as a single line of text + */ + protected function buildDeduplicationStoreEntry(LogRecord $record): string + { + return $record->datetime->getTimestamp() . ':' . $record->level->getName() . ':' . preg_replace('{[\r\n].*}', '', $record->message); + } + private function collectLogs(): void { if (!file_exists($this->deduplicationStore)) { @@ -148,18 +144,20 @@ private function collectLogs(): void $handle = fopen($this->deduplicationStore, 'rw+'); - if (!$handle) { + if (false === $handle) { throw new \RuntimeException('Failed to open file for reading and writing: ' . $this->deduplicationStore); } - flock($handle, LOCK_EX); + if (false === flock($handle, LOCK_EX)) { + return; + } $validLogs = []; $timestampValidity = time() - $this->time; while (!feof($handle)) { $log = fgets($handle); - if ($log && substr($log, 0, 10) >= $timestampValidity) { + if (\is_string($log) && '' !== $log && substr($log, 0, 10) >= $timestampValidity) { $validLogs[] = $log; } } @@ -175,12 +173,4 @@ private function collectLogs(): void $this->gc = false; } - - /** - * @phpstan-param Record $record - */ - private function appendRecord(array $record): void - { - file_put_contents($this->deduplicationStore, $record['datetime']->getTimestamp() . ':' . $record['level_name'] . ':' . preg_replace('{[\r\n].*}', '', $record['message']) . "\n", FILE_APPEND); - } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php index ebd52c3a0..eab9f1089 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php @@ -11,10 +11,11 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\NormalizerFormatter; use Monolog\Formatter\FormatterInterface; use Doctrine\CouchDB\CouchDBClient; +use Monolog\LogRecord; /** * CouchDB handler for Doctrine CouchDB ODM @@ -23,21 +24,20 @@ */ class DoctrineCouchDBHandler extends AbstractProcessingHandler { - /** @var CouchDBClient */ - private $client; + private CouchDBClient $client; - public function __construct(CouchDBClient $client, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(CouchDBClient $client, int|string|Level $level = Level::Debug, bool $bubble = true) { $this->client = $client; parent::__construct($level, $bubble); } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->client->postDocument($record['formatted']); + $this->client->postDocument($record->formatted); } protected function getDefaultFormatter(): FormatterInterface diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php index 21840bf60..f1c5a9590 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php @@ -16,7 +16,8 @@ use Monolog\Formatter\FormatterInterface; use Aws\DynamoDb\Marshaler; use Monolog\Formatter\ScalarFormatter; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Amazon DynamoDB handler (http://aws.amazon.com/dynamodb/) @@ -28,35 +29,15 @@ class DynamoDbHandler extends AbstractProcessingHandler { public const DATE_FORMAT = 'Y-m-d\TH:i:s.uO'; - /** - * @var DynamoDbClient - */ - protected $client; + protected DynamoDbClient $client; - /** - * @var string - */ - protected $table; + protected string $table; - /** - * @var int - */ - protected $version; - - /** - * @var Marshaler - */ - protected $marshaler; + protected Marshaler $marshaler; - public function __construct(DynamoDbClient $client, string $table, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(DynamoDbClient $client, string $table, int|string|Level $level = Level::Debug, bool $bubble = true) { - /** @phpstan-ignore-next-line */ - if (defined('Aws\Sdk::VERSION') && version_compare(Sdk::VERSION, '3.0', '>=')) { - $this->version = 3; - $this->marshaler = new Marshaler; - } else { - $this->version = 2; - } + $this->marshaler = new Marshaler; $this->client = $client; $this->table = $table; @@ -65,17 +46,12 @@ public function __construct(DynamoDbClient $client, string $table, $level = Logg } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $filtered = $this->filterEmptyFields($record['formatted']); - if ($this->version === 3) { - $formatted = $this->marshaler->marshalItem($filtered); - } else { - /** @phpstan-ignore-next-line */ - $formatted = $this->client->formatAttributes($filtered); - } + $filtered = $this->filterEmptyFields($record->formatted); + $formatted = $this->marshaler->marshalItem($filtered); $this->client->putItem([ 'TableName' => $this->table, @@ -90,12 +66,12 @@ protected function write(array $record): void protected function filterEmptyFields(array $record): array { return array_filter($record, function ($value) { - return !empty($value) || false === $value || 0 === $value; + return [] !== $value; }); } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticaHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticaHandler.php index fc92ca42d..4a184b393 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticaHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticaHandler.php @@ -11,12 +11,14 @@ namespace Monolog\Handler; +use Elastic\Transport\Exception\TransportException; use Elastica\Document; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\ElasticaFormatter; -use Monolog\Logger; +use Monolog\Level; use Elastica\Client; use Elastica\Exception\ExceptionInterface; +use Monolog\LogRecord; /** * Elastic Search handler @@ -33,24 +35,34 @@ * $log->pushHandler($handler); * * @author Jelle Vink + * @phpstan-type Options array{ + * index: string, + * type: string, + * ignore_error: bool + * } + * @phpstan-type InputOptions array{ + * index?: string, + * type?: string, + * ignore_error?: bool + * } */ class ElasticaHandler extends AbstractProcessingHandler { - /** - * @var Client - */ - protected $client; + protected Client $client; /** * @var mixed[] Handler config options + * @phpstan-var Options */ - protected $options = []; + protected array $options; /** * @param Client $client Elastica Client object * @param mixed[] $options Handler configuration + * + * @phpstan-param InputOptions $options */ - public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true) + public function __construct(Client $client, array $options = [], int|string|Level $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); $this->client = $client; @@ -65,15 +77,15 @@ public function __construct(Client $client, array $options = [], $level = Logger } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->bulkSend([$record['formatted']]); + $this->bulkSend([$record->formatted]); } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -86,6 +98,8 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface /** * @return mixed[] + * + * @phpstan-return Options */ public function getOptions(): array { @@ -93,7 +107,7 @@ public function getOptions(): array } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { @@ -101,7 +115,7 @@ protected function getDefaultFormatter(): FormatterInterface } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -120,7 +134,7 @@ protected function bulkSend(array $documents): void { try { $this->client->addDocuments($documents); - } catch (ExceptionInterface $e) { + } catch (ExceptionInterface | TransportException $e) { if (!$this->options['ignore_error']) { throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticsearchHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticsearchHandler.php index 264b380d7..6fd705de4 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticsearchHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ElasticsearchHandler.php @@ -14,12 +14,13 @@ use Elastic\Elasticsearch\Response\Elasticsearch; use Throwable; use RuntimeException; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\ElasticsearchFormatter; use InvalidArgumentException; use Elasticsearch\Common\Exceptions\RuntimeException as ElasticsearchRuntimeException; use Elasticsearch\Client; +use Monolog\LogRecord; use Elastic\Elasticsearch\Exception\InvalidArgumentException as ElasticInvalidArgumentException; use Elastic\Elasticsearch\Client as Client8; @@ -43,18 +44,28 @@ * $log->pushHandler($handler); * * @author Avtandil Kikabidze + * @phpstan-type Options array{ + * index: string, + * type: string, + * ignore_error: bool, + * op_type: 'index'|'create' + * } + * @phpstan-type InputOptions array{ + * index?: string, + * type?: string, + * ignore_error?: bool, + * op_type?: 'index'|'create' + * } */ class ElasticsearchHandler extends AbstractProcessingHandler { - /** - * @var Client|Client8 - */ - protected $client; + protected Client|Client8 $client; /** * @var mixed[] Handler config options + * @phpstan-var Options */ - protected $options = []; + protected array $options; /** * @var bool @@ -64,13 +75,11 @@ class ElasticsearchHandler extends AbstractProcessingHandler /** * @param Client|Client8 $client Elasticsearch Client object * @param mixed[] $options Handler configuration + * + * @phpstan-param InputOptions $options */ - public function __construct($client, array $options = [], $level = Logger::DEBUG, bool $bubble = true) + public function __construct(Client|Client8 $client, array $options = [], int|string|Level $level = Level::Debug, bool $bubble = true) { - if (!$client instanceof Client && !$client instanceof Client8) { - throw new \TypeError('Elasticsearch\Client or Elastic\Elasticsearch\Client instance required'); - } - parent::__construct($level, $bubble); $this->client = $client; $this->options = array_merge( @@ -78,6 +87,7 @@ public function __construct($client, array $options = [], $level = Logger::DEBUG 'index' => 'monolog', // Elastic index name 'type' => '_doc', // Elastic document type 'ignore_error' => false, // Suppress Elasticsearch exceptions + 'op_type' => 'index', // Elastic op_type (index or create) (https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#docs-index-api-op_type) ], $options ); @@ -92,15 +102,15 @@ public function __construct($client, array $options = [], $level = Logger::DEBUG } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->bulkSend([$record['formatted']]); + $this->bulkSend([$record->formatted]); } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -115,6 +125,8 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface * Getter options * * @return mixed[] + * + * @phpstan-return Options */ public function getOptions(): array { @@ -122,7 +134,7 @@ public function getOptions(): array } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { @@ -130,7 +142,7 @@ protected function getDefaultFormatter(): FormatterInterface } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -141,7 +153,7 @@ public function handleBatch(array $records): void /** * Use Elasticsearch bulk API to send list of documents * - * @param array[] $records Records + _index/_type keys + * @param array> $records Records + _index/_type keys * @throws \RuntimeException */ protected function bulkSend(array $records): void @@ -153,7 +165,7 @@ protected function bulkSend(array $records): void foreach ($records as $record) { $params['body'][] = [ - 'index' => $this->needsType ? [ + $this->options['op_type'] => $this->needsType ? [ '_index' => $record['_index'], '_type' => $record['_type'], ] : [ @@ -187,7 +199,6 @@ protected function bulkSend(array $records): void */ protected function createExceptionFromResponses($responses): Throwable { - // @phpstan-ignore offsetAccess.nonOffsetAccessible foreach ($responses['items'] ?? [] as $item) { if (isset($item['index']['error'])) { return $this->createExceptionFromError($item['index']['error']); @@ -198,7 +209,11 @@ protected function createExceptionFromResponses($responses): Throwable return new ElasticInvalidArgumentException('Elasticsearch failed to index one or more records.'); } - return new ElasticsearchRuntimeException('Elasticsearch failed to index one or more records.'); + if (class_exists(ElasticsearchRuntimeException::class)) { + return new ElasticsearchRuntimeException('Elasticsearch failed to index one or more records.'); + } + + throw new \LogicException('Unsupported elastic search client version'); } /** @@ -214,6 +229,10 @@ protected function createExceptionFromError(array $error): Throwable return new ElasticInvalidArgumentException($error['type'] . ': ' . $error['reason'], 0, $previous); } - return new ElasticsearchRuntimeException($error['type'] . ': ' . $error['reason'], 0, $previous); + if (class_exists(ElasticsearchRuntimeException::class)) { + return new ElasticsearchRuntimeException($error['type'].': '.$error['reason'], 0, $previous); + } + + throw new \LogicException('Unsupported elastic search client version'); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php index f2e22036b..cd28ff6ac 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php @@ -13,8 +13,9 @@ use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * Stores to PHP error_log() handler. @@ -26,20 +27,21 @@ class ErrorLogHandler extends AbstractProcessingHandler public const OPERATING_SYSTEM = 0; public const SAPI = 4; - /** @var int */ - protected $messageType; - /** @var bool */ - protected $expandNewlines; + /** @var 0|4 */ + protected int $messageType; + protected bool $expandNewlines; /** - * @param int $messageType Says where the error should go. + * @param 0|4 $messageType Says where the error should go. * @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries + * + * @throws \InvalidArgumentException If an unsupported message type is set */ - public function __construct(int $messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, bool $bubble = true, bool $expandNewlines = false) + public function __construct(int $messageType = self::OPERATING_SYSTEM, int|string|Level $level = Level::Debug, bool $bubble = true, bool $expandNewlines = false) { parent::__construct($level, $bubble); - if (false === in_array($messageType, self::getAvailableTypes(), true)) { + if (false === \in_array($messageType, self::getAvailableTypes(), true)) { $message = sprintf('The given message type "%s" is not supported', print_r($messageType, true)); throw new \InvalidArgumentException($message); @@ -61,7 +63,7 @@ public static function getAvailableTypes(): array } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { @@ -69,20 +71,21 @@ protected function getDefaultFormatter(): FormatterInterface } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { if (!$this->expandNewlines) { - error_log((string) $record['formatted'], $this->messageType); + error_log((string) $record->formatted, $this->messageType); return; } - $lines = preg_split('{[\r\n]+}', (string) $record['formatted']); + $lines = preg_split('{[\r\n]+}', (string) $record->formatted); if ($lines === false) { $pcreErrorCode = preg_last_error(); - throw new \RuntimeException('Failed to preg_split formatted string: ' . $pcreErrorCode . ' / '. Utils::pcreLastErrorMessage($pcreErrorCode)); + + throw new \RuntimeException('Failed to preg_split formatted string: ' . $pcreErrorCode . ' / '. preg_last_error_msg()); } foreach ($lines as $line) { error_log($line, $this->messageType); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FallbackGroupHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FallbackGroupHandler.php index d4e234ce0..58318bee7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FallbackGroupHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FallbackGroupHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Throwable; +use Monolog\LogRecord; /** * Forwards records to at most one handler @@ -19,23 +20,20 @@ * If a handler fails, the exception is suppressed and the record is forwarded to the next handler. * * As soon as one handler handles a record successfully, the handling stops there. - * - * @phpstan-import-type Record from \Monolog\Logger */ class FallbackGroupHandler extends GroupHandler { /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } foreach ($this->handlers as $handler) { try { - $handler->handle($record); + $handler->handle(clone $record); break; } catch (Throwable $e) { // What throwable? @@ -46,22 +44,21 @@ public function handle(array $record): bool } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { - if ($this->processors) { + if (\count($this->processors) > 0) { $processed = []; foreach ($records as $record) { $processed[] = $this->processRecord($record); } - /** @var Record[] $records */ $records = $processed; } foreach ($this->handlers as $handler) { try { - $handler->handleBatch($records); + $handler->handleBatch(array_map(fn ($record) => clone $record, $records)); break; } catch (Throwable $e) { // What throwable? diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php index 5e43e1dc2..6653fa15a 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php @@ -11,10 +11,13 @@ namespace Monolog\Handler; +use Closure; +use Monolog\Level; use Monolog\Logger; use Monolog\ResettableInterface; use Monolog\Formatter\FormatterInterface; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Simple handler wrapper that filters records based on a list of levels @@ -23,110 +26,100 @@ * * @author Hennadiy Verkh * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class FilterHandler extends Handler implements ProcessableHandlerInterface, ResettableInterface, FormattableHandlerInterface { use ProcessableHandlerTrait; /** - * Handler or factory callable($record, $this) + * Handler or factory Closure($record, $this) * - * @var callable|HandlerInterface - * @phpstan-var callable(?Record, HandlerInterface): HandlerInterface|HandlerInterface + * @phpstan-var (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface */ - protected $handler; + protected Closure|HandlerInterface $handler; /** * Minimum level for logs that are passed to handler * - * @var int[] - * @phpstan-var array + * @var bool[] Map of Level value => true + * @phpstan-var array, true> */ - protected $acceptedLevels; + protected array $acceptedLevels; /** * Whether the messages that are handled can bubble up the stack or not - * - * @var bool */ - protected $bubble; + protected bool $bubble; /** - * @psalm-param HandlerInterface|callable(?Record, HandlerInterface): HandlerInterface $handler + * @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler * - * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $filterHandler). - * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided - * @param int|string $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $filterHandler). + * @param int|string|Level|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided + * @param int|string|Level|LogLevel::* $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * - * @phpstan-param Level|LevelName|LogLevel::*|array $minLevelOrList - * @phpstan-param Level|LevelName|LogLevel::* $maxLevel + * @phpstan-param value-of|value-of|Level|LogLevel::*|array|value-of|Level|LogLevel::*> $minLevelOrList + * @phpstan-param value-of|value-of|Level|LogLevel::* $maxLevel */ - public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, bool $bubble = true) + public function __construct(Closure|HandlerInterface $handler, int|string|Level|array $minLevelOrList = Level::Debug, int|string|Level $maxLevel = Level::Emergency, bool $bubble = true) { $this->handler = $handler; $this->bubble = $bubble; $this->setAcceptedLevels($minLevelOrList, $maxLevel); - - if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) { - throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); - } } /** - * @phpstan-return array + * @phpstan-return list List of levels */ public function getAcceptedLevels(): array { - return array_flip($this->acceptedLevels); + return array_map(fn (int $level) => Level::from($level), array_keys($this->acceptedLevels)); } /** - * @param int|string|array $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided - * @param int|string $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array + * @param int|string|Level|LogLevel::*|array $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided + * @param int|string|Level|LogLevel::* $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array + * @return $this * - * @phpstan-param Level|LevelName|LogLevel::*|array $minLevelOrList - * @phpstan-param Level|LevelName|LogLevel::* $maxLevel + * @phpstan-param value-of|value-of|Level|LogLevel::*|array|value-of|Level|LogLevel::*> $minLevelOrList + * @phpstan-param value-of|value-of|Level|LogLevel::* $maxLevel */ - public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY): self + public function setAcceptedLevels(int|string|Level|array $minLevelOrList = Level::Debug, int|string|Level $maxLevel = Level::Emergency): self { - if (is_array($minLevelOrList)) { - $acceptedLevels = array_map('Monolog\Logger::toMonologLevel', $minLevelOrList); + if (\is_array($minLevelOrList)) { + $acceptedLevels = array_map(Logger::toMonologLevel(...), $minLevelOrList); } else { $minLevelOrList = Logger::toMonologLevel($minLevelOrList); $maxLevel = Logger::toMonologLevel($maxLevel); - $acceptedLevels = array_values(array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) { - return $level >= $minLevelOrList && $level <= $maxLevel; - })); + $acceptedLevels = array_values(array_filter(Level::cases(), fn (Level $level) => $level->value >= $minLevelOrList->value && $level->value <= $maxLevel->value)); + } + $this->acceptedLevels = []; + foreach ($acceptedLevels as $level) { + $this->acceptedLevels[$level->value] = true; } - $this->acceptedLevels = array_flip($acceptedLevels); return $this; } /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { - return isset($this->acceptedLevels[$record['level']]); + return isset($this->acceptedLevels[$record->level->value]); } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if (!$this->isHandling($record)) { return false; } - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } @@ -136,7 +129,7 @@ public function handle(array $record): bool } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -147,34 +140,31 @@ public function handleBatch(array $records): void } } - if (count($filtered) > 0) { - $this->getHandler($filtered[count($filtered) - 1])->handleBatch($filtered); + if (\count($filtered) > 0) { + $this->getHandler($filtered[\count($filtered) - 1])->handleBatch($filtered); } } /** * Return the nested handler * - * If the handler was provided as a factory callable, this will trigger the handler's instantiation. - * - * @return HandlerInterface - * - * @phpstan-param Record $record + * If the handler was provided as a factory, this will trigger the handler's instantiation. */ - public function getHandler(?array $record = null) + public function getHandler(LogRecord|null $record = null): HandlerInterface { if (!$this->handler instanceof HandlerInterface) { - $this->handler = ($this->handler)($record, $this); - if (!$this->handler instanceof HandlerInterface) { - throw new \RuntimeException("The factory callable should return a HandlerInterface"); + $handler = ($this->handler)($record, $this); + if (!$handler instanceof HandlerInterface) { + throw new \RuntimeException("The factory Closure should return a HandlerInterface"); } + $this->handler = $handler; } return $this->handler; } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -185,11 +175,11 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface return $this; } - throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($handler).' does not support formatters.'); } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { @@ -198,10 +188,10 @@ public function getFormatter(): FormatterInterface return $handler->getFormatter(); } - throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($handler).' does not support formatters.'); } - public function reset() + public function reset(): void { $this->resetProcessors(); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php index 0aa5607b1..e8a1b0b0d 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php @@ -11,19 +11,17 @@ namespace Monolog\Handler\FingersCrossed; +use Monolog\LogRecord; + /** * Interface for activation strategies for the FingersCrossedHandler. * * @author Johannes M. Schmitt - * - * @phpstan-import-type Record from \Monolog\Logger */ interface ActivationStrategyInterface { /** * Returns whether the given record activates the handler. - * - * @phpstan-param Record $record */ - public function isHandlerActivated(array $record): bool; + public function isHandlerActivated(LogRecord $record): bool; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php index 7b9abb582..383e19af9 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php @@ -11,8 +11,10 @@ namespace Monolog\Handler\FingersCrossed; +use Monolog\Level; use Monolog\Logger; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Channel and Error level based monolog activation strategy. Allows to trigger activation @@ -23,55 +25,45 @@ * * * $activationStrategy = new ChannelLevelActivationStrategy( - * Logger::CRITICAL, + * Level::Critical, * array( - * 'request' => Logger::ALERT, - * 'sensitive' => Logger::ERROR, + * 'request' => Level::Alert, + * 'sensitive' => Level::Error, * ) * ); * $handler = new FingersCrossedHandler(new StreamHandler('php://stderr'), $activationStrategy); * * * @author Mike Meessen - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class ChannelLevelActivationStrategy implements ActivationStrategyInterface { - /** - * @var Level - */ - private $defaultActionLevel; + private Level $defaultActionLevel; /** * @var array */ - private $channelToActionLevel; + private array $channelToActionLevel; /** - * @param int|string $defaultActionLevel The default action level to be used if the record's category doesn't match any - * @param array $channelToActionLevel An array that maps channel names to action levels. + * @param int|string|Level|LogLevel::* $defaultActionLevel The default action level to be used if the record's category doesn't match any + * @param array $channelToActionLevel An array that maps channel names to action levels. * - * @phpstan-param array $channelToActionLevel - * @phpstan-param Level|LevelName|LogLevel::* $defaultActionLevel + * @phpstan-param value-of|value-of|Level|LogLevel::* $defaultActionLevel + * @phpstan-param array|value-of|Level|LogLevel::*> $channelToActionLevel */ - public function __construct($defaultActionLevel, array $channelToActionLevel = []) + public function __construct(int|string|Level $defaultActionLevel, array $channelToActionLevel = []) { $this->defaultActionLevel = Logger::toMonologLevel($defaultActionLevel); - $this->channelToActionLevel = array_map('Monolog\Logger::toMonologLevel', $channelToActionLevel); + $this->channelToActionLevel = array_map(Logger::toMonologLevel(...), $channelToActionLevel); } - /** - * @phpstan-param Record $record - */ - public function isHandlerActivated(array $record): bool + public function isHandlerActivated(LogRecord $record): bool { - if (isset($this->channelToActionLevel[$record['channel']])) { - return $record['level'] >= $this->channelToActionLevel[$record['channel']]; + if (isset($this->channelToActionLevel[$record->channel])) { + return $record->level->value >= $this->channelToActionLevel[$record->channel]->value; } - return $record['level'] >= $this->defaultActionLevel; + return $record->level->value >= $this->defaultActionLevel->value; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php index 5ec88eab6..c3ca2967a 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php @@ -11,6 +11,8 @@ namespace Monolog\Handler\FingersCrossed; +use Monolog\Level; +use Monolog\LogRecord; use Monolog\Logger; use Psr\Log\LogLevel; @@ -18,29 +20,23 @@ * Error level based activation strategy. * * @author Johannes M. Schmitt - * - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class ErrorLevelActivationStrategy implements ActivationStrategyInterface { - /** - * @var Level - */ - private $actionLevel; + private Level $actionLevel; /** - * @param int|string $actionLevel Level or name or value + * @param int|string|Level $actionLevel Level or name or value * - * @phpstan-param Level|LevelName|LogLevel::* $actionLevel + * @phpstan-param value-of|value-of|Level|LogLevel::* $actionLevel */ - public function __construct($actionLevel) + public function __construct(int|string|Level $actionLevel) { $this->actionLevel = Logger::toMonologLevel($actionLevel); } - public function isHandlerActivated(array $record): bool + public function isHandlerActivated(LogRecord $record): bool { - return $record['level'] >= $this->actionLevel; + return $record->level->value >= $this->actionLevel->value; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php index dfcb3af28..1ce64e845 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php @@ -11,12 +11,15 @@ namespace Monolog\Handler; +use Closure; use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use Monolog\Handler\FingersCrossed\ActivationStrategyInterface; +use Monolog\Level; use Monolog\Logger; use Monolog\ResettableInterface; use Monolog\Formatter\FormatterInterface; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Buffers all records until a certain level is reached @@ -33,55 +36,50 @@ * Monolog\Handler\FingersCrossed\ namespace. * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterface, ResettableInterface, FormattableHandlerInterface { use ProcessableHandlerTrait; /** - * @var callable|HandlerInterface - * @phpstan-var callable(?Record, HandlerInterface): HandlerInterface|HandlerInterface - */ - protected $handler; - /** @var ActivationStrategyInterface */ - protected $activationStrategy; - /** @var bool */ - protected $buffering = true; - /** @var int */ - protected $bufferSize; - /** @var Record[] */ - protected $buffer = []; - /** @var bool */ - protected $stopBuffering; - /** - * @var ?int - * @phpstan-var ?Level + * Handler or factory Closure($record, $this) + * + * @phpstan-var (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface */ - protected $passthruLevel; - /** @var bool */ - protected $bubble; + protected Closure|HandlerInterface $handler; + + protected ActivationStrategyInterface $activationStrategy; + + protected bool $buffering = true; + + protected int $bufferSize; + + /** @var LogRecord[] */ + protected array $buffer = []; + + protected bool $stopBuffering; + + protected Level|null $passthruLevel = null; + + protected bool $bubble; /** - * @psalm-param HandlerInterface|callable(?Record, HandlerInterface): HandlerInterface $handler + * @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler * - * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $fingersCrossedHandler). - * @param int|string|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action, or a level name/value at which the handler is activated - * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true) - * @param int|string $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered + * @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $fingersCrossedHandler). + * @param int|string|Level|LogLevel::*|null $activationStrategy Strategy which determines when this handler takes action, or a level name/value at which the handler is activated + * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true) + * @param int|string|Level|LogLevel::*|null $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered * - * @phpstan-param Level|LevelName|LogLevel::* $passthruLevel - * @phpstan-param Level|LevelName|LogLevel::*|ActivationStrategyInterface $activationStrategy + * @phpstan-param value-of|value-of|Level|LogLevel::*|ActivationStrategyInterface|null $activationStrategy + * @phpstan-param value-of|value-of|Level|LogLevel::*|null $passthruLevel */ - public function __construct($handler, $activationStrategy = null, int $bufferSize = 0, bool $bubble = true, bool $stopBuffering = true, $passthruLevel = null) + public function __construct(Closure|HandlerInterface $handler, int|string|Level|ActivationStrategyInterface|null $activationStrategy = null, int $bufferSize = 0, bool $bubble = true, bool $stopBuffering = true, int|string|Level|null $passthruLevel = null) { if (null === $activationStrategy) { - $activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING); + $activationStrategy = new ErrorLevelActivationStrategy(Level::Warning); } // convert simple int activationStrategy to an object @@ -98,16 +96,12 @@ public function __construct($handler, $activationStrategy = null, int $bufferSiz if ($passthruLevel !== null) { $this->passthruLevel = Logger::toMonologLevel($passthruLevel); } - - if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) { - throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); - } } /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { return true; } @@ -126,18 +120,17 @@ public function activate(): void } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } if ($this->buffering) { $this->buffer[] = $record; - if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { + if ($this->bufferSize > 0 && \count($this->buffer) > $this->bufferSize) { array_shift($this->buffer); } if ($this->activationStrategy->isHandlerActivated($record)) { @@ -151,7 +144,7 @@ public function handle(array $record): bool } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -160,7 +153,7 @@ public function close(): void $this->getHandler()->close(); } - public function reset() + public function reset(): void { $this->flushBuffer(); @@ -188,11 +181,11 @@ public function clear(): void private function flushBuffer(): void { if (null !== $this->passthruLevel) { - $level = $this->passthruLevel; - $this->buffer = array_filter($this->buffer, function ($record) use ($level) { - return $record['level'] >= $level; + $passthruLevel = $this->passthruLevel; + $this->buffer = array_filter($this->buffer, static function ($record) use ($passthruLevel) { + return $passthruLevel->includes($record->level); }); - if (count($this->buffer) > 0) { + if (\count($this->buffer) > 0) { $this->getHandler(end($this->buffer))->handleBatch($this->buffer); } } @@ -204,26 +197,23 @@ private function flushBuffer(): void /** * Return the nested handler * - * If the handler was provided as a factory callable, this will trigger the handler's instantiation. - * - * @return HandlerInterface - * - * @phpstan-param Record $record + * If the handler was provided as a factory, this will trigger the handler's instantiation. */ - public function getHandler(?array $record = null) + public function getHandler(LogRecord|null $record = null): HandlerInterface { if (!$this->handler instanceof HandlerInterface) { - $this->handler = ($this->handler)($record, $this); - if (!$this->handler instanceof HandlerInterface) { - throw new \RuntimeException("The factory callable should return a HandlerInterface"); + $handler = ($this->handler)($record, $this); + if (!$handler instanceof HandlerInterface) { + throw new \RuntimeException("The factory Closure should return a HandlerInterface"); } + $this->handler = $handler; } return $this->handler; } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -234,11 +224,11 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface return $this; } - throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($handler).' does not support formatters.'); } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { @@ -247,6 +237,6 @@ public function getFormatter(): FormatterInterface return $handler->getFormatter(); } - throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($handler).' does not support formatters.'); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php index 72718de63..6b9e5103a 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php @@ -13,13 +13,12 @@ use Monolog\Formatter\WildfireFormatter; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol. * * @author Eric Clemmons (@ericclemmons) - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class FirePHPHandler extends AbstractProcessingHandler { @@ -47,18 +46,15 @@ class FirePHPHandler extends AbstractProcessingHandler /** * Whether or not Wildfire vendor-specific headers have been generated & sent yet - * @var bool */ - protected static $initialized = false; + protected static bool $initialized = false; /** * Shared static message index between potentially multiple handlers - * @var int */ - protected static $messageIndex = 1; + protected static int $messageIndex = 1; - /** @var bool */ - protected static $sendHeaders = true; + protected static bool $sendHeaders = true; /** * Base header creation function used by init headers & record headers @@ -85,21 +81,19 @@ protected function createHeader(array $meta, string $message): array * @phpstan-return non-empty-array * * @see createHeader() - * - * @phpstan-param FormattedRecord $record */ - protected function createRecordHeader(array $record): array + protected function createRecordHeader(LogRecord $record): array { // Wildfire is extensible to support multiple protocols & plugins in a single request, // but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake. return $this->createHeader( [1, 1, 1, self::$messageIndex++], - $record['formatted'] + $record->formatted ); } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { @@ -140,7 +134,7 @@ protected function sendHeader(string $header, string $content): void * @see sendHeader() * @see sendInitHeaders() */ - protected function write(array $record): void + protected function write(LogRecord $record): void { if (!self::$sendHeaders || !$this->isWebRequest()) { return; @@ -171,7 +165,7 @@ protected function write(array $record): void */ protected function headersAccepted(): bool { - if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])) { + if (isset($_SERVER['HTTP_USER_AGENT']) && 1 === preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])) { return true; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php index 85c95b9d7..46ebfc0b7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php @@ -13,7 +13,8 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Sends logs to Fleep.io using Webhook integrations @@ -22,8 +23,6 @@ * * @see https://fleep.io/integrations/webhooks/ Fleep Webhooks Documentation * @author Ando Roots - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class FleepHookHandler extends SocketHandler { @@ -34,7 +33,7 @@ class FleepHookHandler extends SocketHandler /** * @var string Webhook token (specifies the conversation where logs are sent) */ - protected $token; + protected string $token; /** * Construct a new Fleep.io Handler. @@ -42,12 +41,12 @@ class FleepHookHandler extends SocketHandler * For instructions on how to create a new web hook in your conversations * see https://fleep.io/integrations/webhooks/ * - * @param string $token Webhook token - * @throws MissingExtensionException + * @param string $token Webhook token + * @throws MissingExtensionException if OpenSSL is missing */ public function __construct( string $token, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, bool $persistent = false, float $timeout = 0.0, @@ -55,7 +54,7 @@ public function __construct( ?float $connectionTimeout = null, ?int $chunkSize = null ) { - if (!extension_loaded('openssl')) { + if (!\extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FleepHookHandler'); } @@ -89,16 +88,16 @@ protected function getDefaultFormatter(): FormatterInterface /** * Handles a log record */ - public function write(array $record): void + public function write(LogRecord $record): void { parent::write($record); $this->closeSocket(); } /** - * {@inheritDoc} + * @inheritDoc */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { $content = $this->buildContent($record); @@ -113,7 +112,7 @@ private function buildHeader(string $content): string $header = "POST " . static::FLEEP_HOOK_URI . $this->token . " HTTP/1.1\r\n"; $header .= "Host: " . static::FLEEP_HOST . "\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "Content-Length: " . \strlen($content) . "\r\n"; $header .= "\r\n"; return $header; @@ -121,13 +120,11 @@ private function buildHeader(string $content): string /** * Builds the body of API call - * - * @phpstan-param FormattedRecord $record */ - private function buildContent(array $record): string + private function buildContent(LogRecord $record): string { $dataArray = [ - 'message' => $record['formatted'], + 'message' => $record->formatted, ]; return http_build_query($dataArray); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php index 5715d5800..27c6c1533 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php @@ -11,10 +11,11 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; use Monolog\Formatter\FlowdockFormatter; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Sends notifications through the Flowdock push API @@ -26,23 +27,18 @@ * * @author Dominik Liebler * @see https://www.flowdock.com/api/push - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler * @deprecated Since 2.9.0 and 3.3.0, Flowdock was shutdown we will thus drop this handler in Monolog 4 */ class FlowdockHandler extends SocketHandler { - /** - * @var string - */ - protected $apiToken; + protected string $apiToken; /** * @throws MissingExtensionException if OpenSSL is missing */ public function __construct( string $apiToken, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, bool $persistent = false, float $timeout = 0.0, @@ -50,7 +46,7 @@ public function __construct( ?float $connectionTimeout = null, ?int $chunkSize = null ) { - if (!extension_loaded('openssl')) { + if (!\extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler'); } @@ -68,7 +64,7 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -88,9 +84,9 @@ protected function getDefaultFormatter(): FormatterInterface } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { parent::write($record); @@ -98,9 +94,9 @@ protected function write(array $record): void } /** - * {@inheritDoc} + * @inheritDoc */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { $content = $this->buildContent($record); @@ -109,12 +105,10 @@ protected function generateDataStream(array $record): string /** * Builds the body of API call - * - * @phpstan-param FormattedRecord $record */ - private function buildContent(array $record): string + private function buildContent(LogRecord $record): string { - return Utils::jsonEncode($record['formatted']['flowdock']); + return Utils::jsonEncode($record->formatted); } /** @@ -125,7 +119,7 @@ private function buildHeader(string $content): string $header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n"; $header .= "Host: api.flowdock.com\r\n"; $header .= "Content-Type: application/json\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "Content-Length: " . \strlen($content) . "\r\n"; $header .= "\r\n"; return $header; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php index fc1693cd0..72da59e1c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php @@ -23,15 +23,12 @@ interface FormattableHandlerInterface /** * Sets the formatter. * - * @param FormatterInterface $formatter - * @return HandlerInterface self + * @return HandlerInterface self */ public function setFormatter(FormatterInterface $formatter): HandlerInterface; /** * Gets the formatter. - * - * @return FormatterInterface */ public function getFormatter(): FormatterInterface; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php index b60bdce0e..c044e0786 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php @@ -21,13 +21,10 @@ */ trait FormattableHandlerTrait { - /** - * @var ?FormatterInterface - */ - protected $formatter; + protected FormatterInterface|null $formatter = null; /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -37,11 +34,11 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { - if (!$this->formatter) { + if (null === $this->formatter) { $this->formatter = $this->getDefaultFormatter(); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php index 4ff26c4cd..ba5bb975d 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php @@ -12,9 +12,10 @@ namespace Monolog\Handler; use Gelf\PublisherInterface; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\GelfMessageFormatter; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Handler to send messages to a Graylog2 (http://www.graylog2.org) server @@ -27,12 +28,12 @@ class GelfHandler extends AbstractProcessingHandler /** * @var PublisherInterface the publisher object that sends the message to the server */ - protected $publisher; + protected PublisherInterface $publisher; /** * @param PublisherInterface $publisher a gelf publisher object */ - public function __construct(PublisherInterface $publisher, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(PublisherInterface $publisher, int|string|Level $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); @@ -40,15 +41,15 @@ public function __construct(PublisherInterface $publisher, $level = Logger::DEBU } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->publisher->publish($record['formatted']); + $this->publisher->publish($record->formatted); } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php index 3c9dc4b3b..0423dc346 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php @@ -13,26 +13,26 @@ use Monolog\Formatter\FormatterInterface; use Monolog\ResettableInterface; +use Monolog\LogRecord; /** * Forwards records to multiple handlers * * @author Lenar Lõhmus - * - * @phpstan-import-type Record from \Monolog\Logger */ class GroupHandler extends Handler implements ProcessableHandlerInterface, ResettableInterface { use ProcessableHandlerTrait; /** @var HandlerInterface[] */ - protected $handlers; - /** @var bool */ - protected $bubble; + protected array $handlers; + protected bool $bubble; /** * @param HandlerInterface[] $handlers Array of Handlers. * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * + * @throws \InvalidArgumentException if an unsupported handler is set */ public function __construct(array $handlers, bool $bubble = true) { @@ -47,9 +47,9 @@ public function __construct(array $handlers, bool $bubble = true) } /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { foreach ($this->handlers as $handler) { if ($handler->isHandling($record)) { @@ -61,42 +61,40 @@ public function isHandling(array $record): bool } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } foreach ($this->handlers as $handler) { - $handler->handle($record); + $handler->handle(clone $record); } return false === $this->bubble; } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { - if ($this->processors) { + if (\count($this->processors) > 0) { $processed = []; foreach ($records as $record) { $processed[] = $this->processRecord($record); } - /** @var Record[] $records */ $records = $processed; } foreach ($this->handlers as $handler) { - $handler->handleBatch($records); + $handler->handleBatch(array_map(fn ($record) => clone $record, $records)); } } - public function reset() + public function reset(): void { $this->resetProcessors(); @@ -117,7 +115,7 @@ public function close(): void } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Handler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Handler.php index 34b4935dd..8a4e7ab10 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Handler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Handler.php @@ -19,7 +19,7 @@ abstract class Handler implements HandlerInterface { /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -29,7 +29,7 @@ public function handleBatch(array $records): void } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -44,19 +44,10 @@ public function __destruct() } } - public function __sleep() + public function __serialize(): array { $this->close(); - $reflClass = new \ReflectionClass($this); - - $keys = []; - foreach ($reflClass->getProperties() as $reflProp) { - if (!$reflProp->isStatic()) { - $keys[] = $reflProp->getName(); - } - } - - return $keys; + return (array) $this; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php index affcc51fc..93306d961 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php @@ -11,13 +11,12 @@ namespace Monolog\Handler; +use Monolog\LogRecord; + /** * Interface that all Monolog Handlers must implement * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger */ interface HandlerInterface { @@ -30,13 +29,9 @@ interface HandlerInterface * is no guarantee that handle() will not be called, and isHandling() might not be called * for a given record. * - * @param array $record Partial log record containing only a level key - * - * @return bool - * - * @phpstan-param array{level: Level} $record + * @param LogRecord $record Partial log record having only a level initialized */ - public function isHandling(array $record): bool; + public function isHandling(LogRecord $record): bool; /** * Handles a record. @@ -48,20 +43,16 @@ public function isHandling(array $record): bool; * Unless the bubbling is interrupted (by returning true), the Logger class will keep on * calling further handlers in the stack with a given log record. * - * @param array $record The record to handle - * @return bool true means that this handler handled the record, and that bubbling is not permitted. - * false means the record was either not processed or that this handler allows bubbling. - * - * @phpstan-param Record $record + * @param LogRecord $record The record to handle + * @return bool true means that this handler handled the record, and that bubbling is not permitted. + * false means the record was either not processed or that this handler allows bubbling. */ - public function handle(array $record): bool; + public function handle(LogRecord $record): bool; /** * Handles a set of records at once. * - * @param array $records The records to handle (an array of record arrays) - * - * @phpstan-param Record[] $records + * @param array $records The records to handle */ public function handleBatch(array $records): void; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php index d4351b9f9..541ec2541 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php @@ -13,6 +13,7 @@ use Monolog\ResettableInterface; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * This simple wrapper class can be used to extend handlers functionality. @@ -21,7 +22,7 @@ * * Inherit from this class and override handle() like this: * - * public function handle(array $record) + * public function handle(LogRecord $record) * { * if ($record meets certain conditions) { * return false; @@ -33,10 +34,7 @@ */ class HandlerWrapper implements HandlerInterface, ProcessableHandlerInterface, FormattableHandlerInterface, ResettableInterface { - /** - * @var HandlerInterface - */ - protected $handler; + protected HandlerInterface $handler; public function __construct(HandlerInterface $handler) { @@ -44,23 +42,23 @@ public function __construct(HandlerInterface $handler) } /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { return $this->handler->isHandling($record); } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { return $this->handler->handle($record); } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { @@ -68,7 +66,7 @@ public function handleBatch(array $records): void } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -76,7 +74,7 @@ public function close(): void } /** - * {@inheritDoc} + * @inheritDoc */ public function pushProcessor(callable $callback): HandlerInterface { @@ -90,7 +88,7 @@ public function pushProcessor(callable $callback): HandlerInterface } /** - * {@inheritDoc} + * @inheritDoc */ public function popProcessor(): callable { @@ -102,7 +100,7 @@ public function popProcessor(): callable } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -116,7 +114,7 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { @@ -127,7 +125,7 @@ public function getFormatter(): FormatterInterface throw new \LogicException('The wrapped handler does not implement ' . FormattableHandlerInterface::class); } - public function reset() + public function reset(): void { if ($this->handler instanceof ResettableInterface) { $this->handler->reset(); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php index 000ccea40..b9c7ba84b 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php @@ -11,8 +11,9 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * IFTTTHandler uses cURL to trigger IFTTT Maker actions @@ -27,18 +28,18 @@ */ class IFTTTHandler extends AbstractProcessingHandler { - /** @var string */ - private $eventName; - /** @var string */ - private $secretKey; + private string $eventName; + private string $secretKey; /** * @param string $eventName The name of the IFTTT Maker event that should be triggered * @param string $secretKey A valid IFTTT secret key + * + * @throws MissingExtensionException If the curl extension is missing */ - public function __construct(string $eventName, string $secretKey, $level = Logger::ERROR, bool $bubble = true) + public function __construct(string $eventName, string $secretKey, int|string|Level $level = Level::Error, bool $bubble = true) { - if (!extension_loaded('curl')) { + if (!\extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the IFTTTHandler'); } @@ -49,14 +50,14 @@ public function __construct(string $eventName, string $secretKey, $level = Logge } /** - * {@inheritDoc} + * @inheritDoc */ - public function write(array $record): void + public function write(LogRecord $record): void { $postData = [ - "value1" => $record["channel"], + "value1" => $record->channel, "value2" => $record["level_name"], - "value3" => $record["message"], + "value3" => $record->message, ]; $postString = Utils::jsonEncode($postData); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php index 71f64a267..4b558bd65 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php @@ -11,7 +11,8 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Inspired on LogEntriesHandler. @@ -21,15 +22,12 @@ */ class InsightOpsHandler extends SocketHandler { - /** - * @var string - */ - protected $logToken; + protected string $logToken; /** - * @param string $token Log token supplied by InsightOps - * @param string $region Region where InsightOps account is hosted. Could be 'us' or 'eu'. - * @param bool $useSSL Whether or not SSL encryption should be used + * @param string $token Log token supplied by InsightOps + * @param string $region Region where InsightOps account is hosted. Could be 'us' or 'eu'. + * @param bool $useSSL Whether or not SSL encryption should be used * * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing */ @@ -37,7 +35,7 @@ public function __construct( string $token, string $region = 'us', bool $useSSL = true, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, bool $persistent = false, float $timeout = 0.0, @@ -45,7 +43,7 @@ public function __construct( ?float $connectionTimeout = null, ?int $chunkSize = null ) { - if ($useSSL && !extension_loaded('openssl')) { + if ($useSSL && !\extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for InsightOpsHandler'); } @@ -67,10 +65,10 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { - return $this->logToken . ' ' . $record['formatted']; + return $this->logToken . ' ' . $record->formatted; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php index 25fcd1594..8c12898e2 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php @@ -11,29 +11,27 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * @author Robert Kaufmann III */ class LogEntriesHandler extends SocketHandler { - /** - * @var string - */ - protected $logToken; + protected string $logToken; /** - * @param string $token Log token supplied by LogEntries - * @param bool $useSSL Whether or not SSL encryption should be used. - * @param string $host Custom hostname to send the data to if needed + * @param string $token Log token supplied by LogEntries + * @param bool $useSSL Whether or not SSL encryption should be used. + * @param string $host Custom hostname to send the data to if needed * * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing */ public function __construct( string $token, bool $useSSL = true, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, string $host = 'data.logentries.com', bool $persistent = false, @@ -42,7 +40,7 @@ public function __construct( ?float $connectionTimeout = null, ?int $chunkSize = null ) { - if ($useSSL && !extension_loaded('openssl')) { + if ($useSSL && !\extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler'); } @@ -61,10 +59,10 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { - return $this->logToken . ' ' . $record['formatted']; + return $this->logToken . ' ' . $record->formatted; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php index 6d13db375..c1ccc0ed3 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php @@ -11,11 +11,11 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LogglyFormatter; -use function array_key_exists; use CurlHandle; +use Monolog\LogRecord; /** * Sends errors to Loggly. @@ -33,24 +33,23 @@ class LogglyHandler extends AbstractProcessingHandler /** * Caches the curl handlers for every given endpoint. * - * @var resource[]|CurlHandle[] + * @var CurlHandle[] */ - protected $curlHandlers = []; + protected array $curlHandlers = []; - /** @var string */ - protected $token; + protected string $token; /** @var string[] */ - protected $tag = []; + protected array $tag = []; /** * @param string $token API token supplied by Loggly * * @throws MissingExtensionException If the curl extension is missing */ - public function __construct(string $token, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(string $token, int|string|Level $level = Level::Debug, bool $bubble = true) { - if (!extension_loaded('curl')) { + if (!\extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the LogglyHandler'); } @@ -61,14 +60,10 @@ public function __construct(string $token, $level = Logger::DEBUG, bool $bubble /** * Loads and returns the shared curl handler for the given endpoint. - * - * @param string $endpoint - * - * @return resource|CurlHandle */ - protected function getCurlHandler(string $endpoint) + protected function getCurlHandler(string $endpoint): CurlHandle { - if (!array_key_exists($endpoint, $this->curlHandlers)) { + if (!\array_key_exists($endpoint, $this->curlHandlers)) { $this->curlHandlers[$endpoint] = $this->loadCurlHandle($endpoint); } @@ -77,12 +72,8 @@ protected function getCurlHandler(string $endpoint) /** * Starts a fresh curl session for the given endpoint and returns its handler. - * - * @param string $endpoint - * - * @return resource|CurlHandle */ - private function loadCurlHandle(string $endpoint) + private function loadCurlHandle(string $endpoint): CurlHandle { $url = sprintf("https://%s/%s/%s/", static::HOST, $endpoint, $this->token); @@ -96,32 +87,37 @@ private function loadCurlHandle(string $endpoint) } /** - * @param string[]|string $tag + * @param string[]|string $tag + * @return $this */ - public function setTag($tag): self + public function setTag(string|array $tag): self { - $tag = !empty($tag) ? $tag : []; - $this->tag = is_array($tag) ? $tag : [$tag]; + if ('' === $tag || [] === $tag) { + $this->tag = []; + } else { + $this->tag = \is_array($tag) ? $tag : [$tag]; + } return $this; } /** - * @param string[]|string $tag + * @param string[]|string $tag + * @return $this */ - public function addTag($tag): self + public function addTag(string|array $tag): self { - if (!empty($tag)) { - $tag = is_array($tag) ? $tag : [$tag]; + if ('' !== $tag) { + $tag = \is_array($tag) ? $tag : [$tag]; $this->tag = array_unique(array_merge($this->tag, $tag)); } return $this; } - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->send($record["formatted"], static::ENDPOINT_SINGLE); + $this->send($record->formatted, static::ENDPOINT_SINGLE); } public function handleBatch(array $records): void @@ -129,10 +125,10 @@ public function handleBatch(array $records): void $level = $this->level; $records = array_filter($records, function ($record) use ($level) { - return ($record['level'] >= $level); + return ($record->level->value >= $level->value); }); - if ($records) { + if (\count($records) > 0) { $this->send($this->getFormatter()->formatBatch($records), static::ENDPOINT_BATCH); } } @@ -143,14 +139,14 @@ protected function send(string $data, string $endpoint): void $headers = ['Content-Type: application/json']; - if (!empty($this->tag)) { + if (\count($this->tag) > 0) { $headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tag); } curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - Curl\Util::execute($ch, 5, false); + Curl\Util::execute($ch, 5); } protected function getDefaultFormatter(): FormatterInterface diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php index 859a46906..6aa1b31bf 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php @@ -11,44 +11,36 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LogmaticFormatter; +use Monolog\LogRecord; /** * @author Julien Breux */ class LogmaticHandler extends SocketHandler { - /** - * @var string - */ - private $logToken; + private string $logToken; - /** - * @var string - */ - private $hostname; + private string $hostname; - /** - * @var string - */ - private $appname; + private string $appName; /** - * @param string $token Log token supplied by Logmatic. - * @param string $hostname Host name supplied by Logmatic. - * @param string $appname Application name supplied by Logmatic. - * @param bool $useSSL Whether or not SSL encryption should be used. + * @param string $token Log token supplied by Logmatic. + * @param string $hostname Host name supplied by Logmatic. + * @param string $appName Application name supplied by Logmatic. + * @param bool $useSSL Whether or not SSL encryption should be used. * * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing */ public function __construct( string $token, string $hostname = '', - string $appname = '', + string $appName = '', bool $useSSL = true, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, bool $persistent = false, float $timeout = 0.0, @@ -56,7 +48,7 @@ public function __construct( ?float $connectionTimeout = null, ?int $chunkSize = null ) { - if ($useSSL && !extension_loaded('openssl')) { + if ($useSSL && !\extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP extension is required to use SSL encrypted connection for LogmaticHandler'); } @@ -76,29 +68,29 @@ public function __construct( $this->logToken = $token; $this->hostname = $hostname; - $this->appname = $appname; + $this->appName = $appName; } /** - * {@inheritDoc} + * @inheritDoc */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { - return $this->logToken . ' ' . $record['formatted']; + return $this->logToken . ' ' . $record->formatted; } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { $formatter = new LogmaticFormatter(); - if (!empty($this->hostname)) { + if ($this->hostname !== '') { $formatter->setHostname($this->hostname); } - if (!empty($this->appname)) { - $formatter->setAppname($this->appname); + if ($this->appName !== '') { + $formatter->setAppName($this->appName); } return $formatter; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php index 97f343202..b6c822772 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php @@ -13,33 +13,32 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\HtmlFormatter; +use Monolog\LogRecord; /** * Base class for all mail handlers * * @author Gyula Sallai - * - * @phpstan-import-type Record from \Monolog\Logger */ abstract class MailHandler extends AbstractProcessingHandler { /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { $messages = []; foreach ($records as $record) { - if ($record['level'] < $this->level) { + if ($record->level->isLowerThan($this->level)) { continue; } - /** @var Record $message */ + $message = $this->processRecord($record); $messages[] = $message; } - if (!empty($messages)) { + if (\count($messages) > 0) { $this->send((string) $this->getFormatter()->formatBatch($messages), $messages); } } @@ -50,27 +49,26 @@ public function handleBatch(array $records): void * @param string $content formatted email body to be sent * @param array $records the array of log records that formed this content * - * @phpstan-param Record[] $records + * @phpstan-param non-empty-array $records */ abstract protected function send(string $content, array $records): void; /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->send((string) $record['formatted'], [$record]); + $this->send((string) $record->formatted, [$record]); } /** - * @phpstan-param non-empty-array $records - * @phpstan-return Record + * @phpstan-param non-empty-array $records */ - protected function getHighestRecord(array $records): array + protected function getHighestRecord(array $records): LogRecord { $highestRecord = null; foreach ($records as $record) { - if ($highestRecord === null || $highestRecord['level'] < $record['level']) { + if ($highestRecord === null || $record->level->isHigherThan($highestRecord->level)) { $highestRecord = $record; } } @@ -85,8 +83,6 @@ protected function isHtmlBody(string $body): bool /** * Gets the default formatter. - * - * @return FormatterInterface */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php index 3003500ec..477ac345a 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php @@ -11,7 +11,7 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Swift; use Swift_Message; @@ -22,22 +22,22 @@ */ class MandrillHandler extends MailHandler { - /** @var Swift_Message */ - protected $message; - /** @var string */ - protected $apiKey; + protected Swift_Message $message; + protected string $apiKey; /** - * @psalm-param Swift_Message|callable(): Swift_Message $message + * @phpstan-param (Swift_Message|callable(): Swift_Message) $message * * @param string $apiKey A valid Mandrill API key * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced + * + * @throws \InvalidArgumentException if not a Swift Message is set */ - public function __construct(string $apiKey, $message, $level = Logger::ERROR, bool $bubble = true) + public function __construct(string $apiKey, callable|Swift_Message $message, int|string|Level $level = Level::Error, bool $bubble = true) { parent::__construct($level, $bubble); - if (!$message instanceof Swift_Message && is_callable($message)) { + if (!$message instanceof Swift_Message) { $message = $message(); } if (!$message instanceof Swift_Message) { @@ -48,7 +48,7 @@ public function __construct(string $apiKey, $message, $level = Logger::ERROR, bo } /** - * {@inheritDoc} + * @inheritDoc */ protected function send(string $content, array $records): void { @@ -70,8 +70,8 @@ protected function send(string $content, array $records): void $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json'); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'key' => $this->apiKey, 'raw_message' => (string) $message, diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php index 306309119..3a1c085b7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php @@ -11,12 +11,14 @@ namespace Monolog\Handler; +use MongoDB\Client; +use MongoDB\Collection; use MongoDB\Driver\BulkWrite; use MongoDB\Driver\Manager; -use MongoDB\Client; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\MongoDBFormatter; +use Monolog\LogRecord; /** * Logs to a MongoDB database. @@ -33,12 +35,11 @@ */ class MongoDBHandler extends AbstractProcessingHandler { - /** @var \MongoDB\Collection */ - private $collection; - /** @var Client|Manager */ - private $manager; - /** @var string */ - private $namespace; + private Collection $collection; + + private Client|Manager $manager; + + private string|null $namespace = null; /** * Constructor. @@ -47,14 +48,10 @@ class MongoDBHandler extends AbstractProcessingHandler * @param string $database Database name * @param string $collection Collection name */ - public function __construct($mongodb, string $database, string $collection, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(Client|Manager $mongodb, string $database, string $collection, int|string|Level $level = Level::Debug, bool $bubble = true) { - if (!($mongodb instanceof Client || $mongodb instanceof Manager)) { - throw new \InvalidArgumentException('MongoDB\Client or MongoDB\Driver\Manager instance required'); - } - if ($mongodb instanceof Client) { - $this->collection = $mongodb->selectCollection($database, $collection); + $this->collection = method_exists($mongodb, 'getCollection') ? $mongodb->getCollection($database, $collection) : $mongodb->selectCollection($database, $collection); } else { $this->manager = $mongodb; $this->namespace = $database . '.' . $collection; @@ -63,21 +60,21 @@ public function __construct($mongodb, string $database, string $collection, $lev parent::__construct($level, $bubble); } - protected function write(array $record): void + protected function write(LogRecord $record): void { if (isset($this->collection)) { - $this->collection->insertOne($record['formatted']); + $this->collection->insertOne($record->formatted); } if (isset($this->manager, $this->namespace)) { $bulk = new BulkWrite; - $bulk->insert($record["formatted"]); + $bulk->insert($record->formatted); $this->manager->executeBulkWrite($this->namespace, $bulk); } } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php index 0c0a3bdb1..a5d1a9771 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php @@ -11,7 +11,7 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\LineFormatter; /** @@ -26,43 +26,39 @@ class NativeMailerHandler extends MailHandler * The email addresses to which the message will be sent * @var string[] */ - protected $to; + protected array $to; /** * The subject of the email - * @var string */ - protected $subject; + protected string $subject; /** * Optional headers for the message * @var string[] */ - protected $headers = []; + protected array $headers = []; /** * Optional parameters for the message * @var string[] */ - protected $parameters = []; + protected array $parameters = []; /** * The wordwrap length for the message - * @var int */ - protected $maxColumnWidth; + protected int $maxColumnWidth; /** * The Content-type for the message - * @var string|null */ - protected $contentType; + protected string|null $contentType = null; /** * The encoding for the message - * @var string */ - protected $encoding = 'utf-8'; + protected string $encoding = 'utf-8'; /** * @param string|string[] $to The receiver of the mail @@ -70,7 +66,7 @@ class NativeMailerHandler extends MailHandler * @param string $from The sender of the mail * @param int $maxColumnWidth The maximum column width that the message lines will have */ - public function __construct($to, string $subject, string $from, $level = Logger::ERROR, bool $bubble = true, int $maxColumnWidth = 70) + public function __construct(string|array $to, string $subject, string $from, int|string|Level $level = Level::Error, bool $bubble = true, int $maxColumnWidth = 70) { parent::__construct($level, $bubble); $this->to = (array) $to; @@ -82,7 +78,8 @@ public function __construct($to, string $subject, string $from, $level = Logger: /** * Add headers to the message * - * @param string|string[] $headers Custom added headers + * @param string|string[] $headers Custom added headers + * @return $this */ public function addHeader($headers): self { @@ -99,7 +96,8 @@ public function addHeader($headers): self /** * Add parameters to the message * - * @param string|string[] $parameters Custom added parameters + * @param string|string[] $parameters Custom added parameters + * @return $this */ public function addParameter($parameters): self { @@ -109,11 +107,11 @@ public function addParameter($parameters): self } /** - * {@inheritDoc} + * @inheritDoc */ protected function send(string $content, array $records): void { - $contentType = $this->getContentType() ?: ($this->isHtmlBody($content) ? 'text/html' : 'text/plain'); + $contentType = $this->getContentType() ?? ($this->isHtmlBody($content) ? 'text/html' : 'text/plain'); if ($contentType !== 'text/html') { $content = wordwrap($content, $this->maxColumnWidth); @@ -125,15 +123,12 @@ protected function send(string $content, array $records): void $headers .= 'MIME-Version: 1.0' . "\r\n"; } - $subject = $this->subject; - if ($records) { - $subjectFormatter = new LineFormatter($this->subject); - $subject = $subjectFormatter->format($this->getHighestRecord($records)); - } + $subjectFormatter = new LineFormatter($this->subject); + $subject = $subjectFormatter->format($this->getHighestRecord($records)); $parameters = implode(' ', $this->parameters); foreach ($this->to as $to) { - mail($to, $subject, $content, $headers, $parameters); + $this->mail($to, $subject, $content, $headers, $parameters); } } @@ -148,7 +143,8 @@ public function getEncoding(): string } /** - * @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML messages. + * @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML messages. + * @return $this */ public function setContentType(string $contentType): self { @@ -161,6 +157,9 @@ public function setContentType(string $contentType): self return $this; } + /** + * @return $this + */ public function setEncoding(string $encoding): self { if (strpos($encoding, "\n") !== false || strpos($encoding, "\r") !== false) { @@ -171,4 +170,10 @@ public function setEncoding(string $encoding): self return $this; } + + + protected function mail(string $to, string $subject, string $content, string $headers, string $parameters): void + { + mail($to, $subject, $content, $headers, $parameters); + } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php index 114d749eb..4f28dd4a5 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php @@ -11,16 +11,17 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; use Monolog\Formatter\NormalizerFormatter; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Class to record a log on a NewRelic application. * Enabling New Relic High Security mode may prevent capture of useful information. * - * This handler requires a NormalizerFormatter to function and expects an array in $record['formatted'] + * This handler requires a NormalizerFormatter to function and expects an array in $record->formatted * * @see https://docs.newrelic.com/docs/agents/php-agent * @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security @@ -28,76 +29,59 @@ class NewRelicHandler extends AbstractProcessingHandler { /** - * Name of the New Relic application that will receive logs from this handler. - * - * @var ?string - */ - protected $appName; - - /** - * Name of the current transaction - * - * @var ?string - */ - protected $transactionName; - - /** - * Some context and extra data is passed into the handler as arrays of values. Do we send them as is - * (useful if we are using the API), or explode them for display on the NewRelic RPM website? - * - * @var bool - */ - protected $explodeArrays; - - /** - * {@inheritDoc} - * - * @param string|null $appName - * @param bool $explodeArrays - * @param string|null $transactionName + * @inheritDoc */ public function __construct( - $level = Logger::ERROR, + int|string|Level $level = Level::Error, bool $bubble = true, - ?string $appName = null, - bool $explodeArrays = false, - ?string $transactionName = null + + /** + * Name of the New Relic application that will receive logs from this handler. + */ + protected string|null $appName = null, + + /** + * Some context and extra data is passed into the handler as arrays of values. Do we send them as is + * (useful if we are using the API), or explode them for display on the NewRelic RPM website? + */ + protected bool $explodeArrays = false, + + /** + * Name of the current transaction + */ + protected string|null $transactionName = null ) { parent::__construct($level, $bubble); - - $this->appName = $appName; - $this->explodeArrays = $explodeArrays; - $this->transactionName = $transactionName; } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { if (!$this->isNewRelicEnabled()) { throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler'); } - if ($appName = $this->getAppName($record['context'])) { + if (null !== ($appName = $this->getAppName($record->context))) { $this->setNewRelicAppName($appName); } - if ($transactionName = $this->getTransactionName($record['context'])) { + if (null !== ($transactionName = $this->getTransactionName($record->context))) { $this->setNewRelicTransactionName($transactionName); - unset($record['formatted']['context']['transaction_name']); + unset($record->formatted['context']['transaction_name']); } - if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Throwable) { - newrelic_notice_error($record['message'], $record['context']['exception']); - unset($record['formatted']['context']['exception']); + if (isset($record->context['exception']) && $record->context['exception'] instanceof \Throwable) { + newrelic_notice_error($record->message, $record->context['exception']); + unset($record->formatted['context']['exception']); } else { - newrelic_notice_error($record['message']); + newrelic_notice_error($record->message); } - if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) { - foreach ($record['formatted']['context'] as $key => $parameter) { - if (is_array($parameter) && $this->explodeArrays) { + if (isset($record->formatted['context']) && \is_array($record->formatted['context'])) { + foreach ($record->formatted['context'] as $key => $parameter) { + if (\is_array($parameter) && $this->explodeArrays) { foreach ($parameter as $paramKey => $paramValue) { $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue); } @@ -107,9 +91,9 @@ protected function write(array $record): void } } - if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) { - foreach ($record['formatted']['extra'] as $key => $parameter) { - if (is_array($parameter) && $this->explodeArrays) { + if (isset($record->formatted['extra']) && \is_array($record->formatted['extra'])) { + foreach ($record->formatted['extra'] as $key => $parameter) { + if (\is_array($parameter) && $this->explodeArrays) { foreach ($parameter as $paramKey => $paramValue) { $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue); } @@ -122,12 +106,10 @@ protected function write(array $record): void /** * Checks whether the NewRelic extension is enabled in the system. - * - * @return bool */ protected function isNewRelicEnabled(): bool { - return extension_loaded('newrelic'); + return \extension_loaded('newrelic'); } /** @@ -177,12 +159,11 @@ protected function setNewRelicTransactionName(string $transactionName): void } /** - * @param string $key - * @param mixed $value + * @param mixed $value */ protected function setNewRelicParameter(string $key, $value): void { - if (null === $value || is_scalar($value)) { + if (null === $value || \is_scalar($value)) { newrelic_add_custom_parameter($key, $value); } else { newrelic_add_custom_parameter($key, Utils::jsonEncode($value, null, true)); @@ -190,7 +171,7 @@ protected function setNewRelicParameter(string $key, $value): void } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NoopHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NoopHandler.php index 1ddf0beb9..d9fea180c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NoopHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NoopHandler.php @@ -11,6 +11,8 @@ namespace Monolog\Handler; +use Monolog\LogRecord; + /** * No-op * @@ -23,17 +25,17 @@ class NoopHandler extends Handler { /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { return true; } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { return false; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php index e75ee0c6e..1aa84e4f8 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php @@ -11,8 +11,10 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Psr\Log\LogLevel; +use Monolog\Logger; +use Monolog\LogRecord; /** * Blackhole @@ -21,40 +23,34 @@ * to put on top of an existing stack to override it temporarily. * * @author Jordi Boggiano - * - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class NullHandler extends Handler { - /** - * @var int - */ - private $level; + private Level $level; /** - * @param string|int $level The minimum logging level at which this handler will be triggered + * @param string|int|Level $level The minimum logging level at which this handler will be triggered * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function __construct($level = Logger::DEBUG) + public function __construct(string|int|Level $level = Level::Debug) { $this->level = Logger::toMonologLevel($level); } /** - * {@inheritDoc} + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { - return $record['level'] >= $this->level; + return $record->level->value >= $this->level->value; } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - return $record['level'] >= $this->level; + return $record->level->value >= $this->level->value; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/OverflowHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/OverflowHandler.php index 22068c9a3..adc0eb1f0 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/OverflowHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/OverflowHandler.php @@ -11,8 +11,9 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Handler to only pass log messages when a certain threshold of number of messages is reached. @@ -27,7 +28,7 @@ * $handler = new SomeHandler(...) * * // Pass all warnings to the handler when more than 10 & all error messages when more then 5 - * $overflow = new OverflowHandler($handler, [Logger::WARNING => 10, Logger::ERROR => 5]); + * $overflow = new OverflowHandler($handler, [Level::Warning->value => 10, Level::Error->value => 5]); * * $log->pushHandler($overflow); *``` @@ -36,36 +37,25 @@ */ class OverflowHandler extends AbstractHandler implements FormattableHandlerInterface { - /** @var HandlerInterface */ - private $handler; - - /** @var int[] */ - private $thresholdMap = [ - Logger::DEBUG => 0, - Logger::INFO => 0, - Logger::NOTICE => 0, - Logger::WARNING => 0, - Logger::ERROR => 0, - Logger::CRITICAL => 0, - Logger::ALERT => 0, - Logger::EMERGENCY => 0, - ]; + private HandlerInterface $handler; + + /** @var array */ + private array $thresholdMap = []; /** * Buffer of all messages passed to the handler before the threshold was reached * * @var mixed[][] */ - private $buffer = []; + private array $buffer = []; /** - * @param HandlerInterface $handler - * @param int[] $thresholdMap Dictionary of logger level => threshold + * @param array $thresholdMap Dictionary of log level value => threshold */ public function __construct( HandlerInterface $handler, array $thresholdMap = [], - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true ) { $this->handler = $handler; @@ -85,15 +75,15 @@ public function __construct( * Unless the bubbling is interrupted (by returning true), the Logger class will keep on * calling further handlers in the stack with a given log record. * - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - if ($record['level'] < $this->level) { + if ($record->level->isLowerThan($this->level)) { return false; } - $level = $record['level']; + $level = $record->level->value; if (!isset($this->thresholdMap[$level])) { $this->thresholdMap[$level] = 0; @@ -107,7 +97,7 @@ public function handle(array $record): bool return false === $this->bubble; } - if ($this->thresholdMap[$level] == 0) { + if ($this->thresholdMap[$level] === 0) { // This current message is breaking the threshold. Flush the buffer and continue handling the current record foreach ($this->buffer[$level] ?? [] as $buffered) { $this->handler->handle($buffered); @@ -122,7 +112,7 @@ public function handle(array $record): bool } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -132,11 +122,11 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface return $this; } - throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($this->handler).' does not support formatters.'); } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { @@ -144,6 +134,6 @@ public function getFormatter(): FormatterInterface return $this->handler->getFormatter(); } - throw new \UnexpectedValueException('The nested handler of type '.get_class($this->handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($this->handler).' does not support formatters.'); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php index 23a1d1178..b37266d59 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php @@ -13,11 +13,13 @@ use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; use PhpConsole\Connector; use PhpConsole\Handler as VendorPhpConsoleHandler; use PhpConsole\Helper; +use Monolog\LogRecord; +use PhpConsole\Storage; /** * Monolog handler for Google Chrome extension "PHP Console" @@ -37,14 +39,59 @@ * PC::debug($_SERVER); // PHP Console debugger for any type of vars * * @author Sergey Barbushin https://www.linkedin.com/in/barbushin + * @phpstan-type Options array{ + * enabled: bool, + * classesPartialsTraceIgnore: string[], + * debugTagsKeysInContext: array, + * useOwnErrorsHandler: bool, + * useOwnExceptionsHandler: bool, + * sourcesBasePath: string|null, + * registerHelper: bool, + * serverEncoding: string|null, + * headersLimit: int|null, + * password: string|null, + * enableSslOnlyMode: bool, + * ipMasks: string[], + * enableEvalListener: bool, + * dumperDetectCallbacks: bool, + * dumperLevelLimit: int, + * dumperItemsCountLimit: int, + * dumperItemSizeLimit: int, + * dumperDumpSizeLimit: int, + * detectDumpTraceAndSource: bool, + * dataStorage: Storage|null + * } + * @phpstan-type InputOptions array{ + * enabled?: bool, + * classesPartialsTraceIgnore?: string[], + * debugTagsKeysInContext?: array, + * useOwnErrorsHandler?: bool, + * useOwnExceptionsHandler?: bool, + * sourcesBasePath?: string|null, + * registerHelper?: bool, + * serverEncoding?: string|null, + * headersLimit?: int|null, + * password?: string|null, + * enableSslOnlyMode?: bool, + * ipMasks?: string[], + * enableEvalListener?: bool, + * dumperDetectCallbacks?: bool, + * dumperLevelLimit?: int, + * dumperItemsCountLimit?: int, + * dumperItemSizeLimit?: int, + * dumperDumpSizeLimit?: int, + * detectDumpTraceAndSource?: bool, + * dataStorage?: Storage|null + * } * - * @phpstan-import-type Record from \Monolog\Logger * @deprecated Since 2.8.0 and 3.2.0, PHPConsole is abandoned and thus we will drop this handler in Monolog 4 */ class PHPConsoleHandler extends AbstractProcessingHandler { - /** @var array */ - private $options = [ + /** + * @phpstan-var Options + */ + private array $options = [ 'enabled' => true, // bool Is PHP Console server enabled 'classesPartialsTraceIgnore' => ['Monolog\\'], // array Hide calls of classes started with... 'debugTagsKeysInContext' => [0, 'tag'], // bool Is PHP Console server enabled @@ -64,18 +111,18 @@ class PHPConsoleHandler extends AbstractProcessingHandler 'dumperItemSizeLimit' => 5000, // int Maximum length of any string or dumped array item 'dumperDumpSizeLimit' => 500000, // int Maximum approximate size of dumped vars result formatted in JSON 'detectDumpTraceAndSource' => false, // bool Autodetect and append trace data to debug - 'dataStorage' => null, // \PhpConsole\Storage|null Fixes problem with custom $_SESSION handler(see http://goo.gl/Ne8juJ) + 'dataStorage' => null, // \PhpConsole\Storage|null Fixes problem with custom $_SESSION handler (see https://github.com/barbushin/php-console#troubleshooting-with-_session-handler-overridden-in-some-frameworks) ]; - /** @var Connector */ - private $connector; + private Connector $connector; /** * @param array $options See \Monolog\Handler\PHPConsoleHandler::$options for more details * @param Connector|null $connector Instance of \PhpConsole\Connector class (optional) * @throws \RuntimeException + * @phpstan-param InputOptions $options */ - public function __construct(array $options = [], ?Connector $connector = null, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(array $options = [], ?Connector $connector = null, int|string|Level $level = Level::Debug, bool $bubble = true) { if (!class_exists('PhpConsole\Connector')) { throw new \RuntimeException('PHP Console library not found. See https://github.com/barbushin/php-console#installation'); @@ -86,14 +133,16 @@ public function __construct(array $options = [], ?Connector $connector = null, $ } /** - * @param array $options - * + * @param array $options * @return array + * + * @phpstan-param InputOptions $options + * @phpstan-return Options */ private function initOptions(array $options): array { $wrongOptions = array_diff(array_keys($options), array_keys($this->options)); - if ($wrongOptions) { + if (\count($wrongOptions) > 0) { throw new \RuntimeException('Unknown options: ' . implode(', ', $wrongOptions)); } @@ -102,8 +151,8 @@ private function initOptions(array $options): array private function initConnector(?Connector $connector = null): Connector { - if (!$connector) { - if ($this->options['dataStorage']) { + if (null === $connector) { + if ($this->options['dataStorage'] instanceof Storage) { Connector::setPostponeStorage($this->options['dataStorage']); } $connector = Connector::getInstance(); @@ -120,22 +169,22 @@ private function initConnector(?Connector $connector = null): Connector $handler->setHandleExceptions($this->options['useOwnExceptionsHandler']); $handler->start(); } - if ($this->options['sourcesBasePath']) { + if (null !== $this->options['sourcesBasePath']) { $connector->setSourcesBasePath($this->options['sourcesBasePath']); } - if ($this->options['serverEncoding']) { + if (null !== $this->options['serverEncoding']) { $connector->setServerEncoding($this->options['serverEncoding']); } - if ($this->options['password']) { + if (null !== $this->options['password']) { $connector->setPassword($this->options['password']); } if ($this->options['enableSslOnlyMode']) { $connector->enableSslOnlyMode(); } - if ($this->options['ipMasks']) { + if (\count($this->options['ipMasks']) > 0) { $connector->setAllowedIpMasks($this->options['ipMasks']); } - if ($this->options['headersLimit']) { + if (null !== $this->options['headersLimit'] && $this->options['headersLimit'] > 0) { $connector->setHeadersLimit($this->options['headersLimit']); } if ($this->options['detectDumpTraceAndSource']) { @@ -168,7 +217,7 @@ public function getOptions(): array return $this->options; } - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if ($this->options['enabled'] && $this->connector->isActiveClient()) { return parent::handle($record); @@ -180,48 +229,39 @@ public function handle(array $record): bool /** * Writes the record down to the log of the implementing handler */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - if ($record['level'] < Logger::NOTICE) { + if ($record->level->isLowerThan(Level::Notice)) { $this->handleDebugRecord($record); - } elseif (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Throwable) { + } elseif (isset($record->context['exception']) && $record->context['exception'] instanceof \Throwable) { $this->handleExceptionRecord($record); } else { $this->handleErrorRecord($record); } } - /** - * @phpstan-param Record $record - */ - private function handleDebugRecord(array $record): void + private function handleDebugRecord(LogRecord $record): void { - $tags = $this->getRecordTags($record); - $message = $record['message']; - if ($record['context']) { - $message .= ' ' . Utils::jsonEncode($this->connector->getDumper()->dump(array_filter($record['context'])), null, true); + [$tags, $filteredContext] = $this->getRecordTags($record); + $message = $record->message; + if (\count($filteredContext) > 0) { + $message .= ' ' . Utils::jsonEncode($this->connector->getDumper()->dump(array_filter($filteredContext)), null, true); } $this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options['classesPartialsTraceIgnore']); } - /** - * @phpstan-param Record $record - */ - private function handleExceptionRecord(array $record): void + private function handleExceptionRecord(LogRecord $record): void { - $this->connector->getErrorsDispatcher()->dispatchException($record['context']['exception']); + $this->connector->getErrorsDispatcher()->dispatchException($record->context['exception']); } - /** - * @phpstan-param Record $record - */ - private function handleErrorRecord(array $record): void + private function handleErrorRecord(LogRecord $record): void { - $context = $record['context']; + $context = $record->context; $this->connector->getErrorsDispatcher()->dispatchError( $context['code'] ?? null, - $context['message'] ?? $record['message'], + $context['message'] ?? $record->message, $context['file'] ?? null, $context['line'] ?? null, $this->options['classesPartialsTraceIgnore'] @@ -229,32 +269,32 @@ private function handleErrorRecord(array $record): void } /** - * @phpstan-param Record $record - * @return string + * @return array{string, mixed[]} */ - private function getRecordTags(array &$record) + private function getRecordTags(LogRecord $record): array { $tags = null; - if (!empty($record['context'])) { - $context = & $record['context']; + $filteredContext = []; + if ($record->context !== []) { + $filteredContext = $record->context; foreach ($this->options['debugTagsKeysInContext'] as $key) { - if (!empty($context[$key])) { - $tags = $context[$key]; + if (isset($filteredContext[$key])) { + $tags = $filteredContext[$key]; if ($key === 0) { - array_shift($context); + array_shift($filteredContext); } else { - unset($context[$key]); + unset($filteredContext[$key]); } break; } } } - return $tags ?: strtolower($record['level_name']); + return [$tags ?? $record->level->toPsrLogLevel(), $filteredContext]; } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessHandler.php index 8a8cf1be6..2855a9f7c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessHandler.php @@ -11,7 +11,8 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Stores to STDIN of any process, specified by a command. @@ -33,23 +34,19 @@ class ProcessHandler extends AbstractProcessingHandler */ private $process; - /** - * @var string - */ - private $command; + private string $command; - /** - * @var string|null - */ - private $cwd; + private ?string $cwd; /** * @var resource[] */ - private $pipes = []; + private array $pipes = []; + + private float $timeout; /** - * @var array + * @var array> */ protected const DESCRIPTOR_SPEC = [ 0 => ['pipe', 'r'], // STDIN is a pipe that the child will read from @@ -61,9 +58,10 @@ class ProcessHandler extends AbstractProcessingHandler * @param string $command Command for the process to start. Absolute paths are recommended, * especially if you do not use the $cwd parameter. * @param string|null $cwd "Current working directory" (CWD) for the process to be executed in. + * @param float $timeout The maximum timeout (in seconds) for the stream_select() function. * @throws \InvalidArgumentException */ - public function __construct(string $command, $level = Logger::DEBUG, bool $bubble = true, ?string $cwd = null) + public function __construct(string $command, int|string|Level $level = Level::Debug, bool $bubble = true, ?string $cwd = null, float $timeout = 1.0) { if ($command === '') { throw new \InvalidArgumentException('The command argument must be a non-empty string.'); @@ -76,6 +74,7 @@ public function __construct(string $command, $level = Logger::DEBUG, bool $bubbl $this->command = $command; $this->cwd = $cwd; + $this->timeout = $timeout; } /** @@ -83,14 +82,14 @@ public function __construct(string $command, $level = Logger::DEBUG, bool $bubbl * * @throws \UnexpectedValueException */ - protected function write(array $record): void + protected function write(LogRecord $record): void { $this->ensureProcessIsStarted(); - $this->writeProcessInput($record['formatted']); + $this->writeProcessInput($record->formatted); $errors = $this->readProcessErrors(); - if (empty($errors) === false) { + if ($errors !== '') { throw new \UnexpectedValueException(sprintf('Errors while writing to process: %s', $errors)); } } @@ -101,7 +100,7 @@ protected function write(array $record): void */ private function ensureProcessIsStarted(): void { - if (is_resource($this->process) === false) { + if (\is_resource($this->process) === false) { $this->startProcess(); $this->handleStartupErrors(); @@ -134,7 +133,7 @@ private function handleStartupErrors(): void $errors = $this->readProcessErrors(); - if (is_resource($this->process) === false || empty($errors) === false) { + if (\is_resource($this->process) === false || $errors !== '') { throw new \UnexpectedValueException( sprintf('The process "%s" could not be opened: ' . $errors, $this->command) ); @@ -151,7 +150,8 @@ protected function selectErrorStream() $empty = []; $errorPipes = [$this->pipes[2]]; - return stream_select($errorPipes, $empty, $empty, 1); + $seconds = (int) $this->timeout; + return stream_select($errorPipes, $empty, $empty, $seconds, (int) (($this->timeout - $seconds) * 1000000)); } /** @@ -176,11 +176,11 @@ protected function writeProcessInput(string $string): void } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { - if (is_resource($this->process)) { + if (\is_resource($this->process)) { foreach ($this->pipes as $pipe) { fclose($pipe); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php index 3adec7a4d..9fb290faa 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php @@ -12,20 +12,19 @@ namespace Monolog\Handler; use Monolog\Processor\ProcessorInterface; +use Monolog\LogRecord; /** * Interface to describe loggers that have processors * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger */ interface ProcessableHandlerInterface { /** * Adds a processor in the stack. * - * @psalm-param ProcessorInterface|callable(Record): Record $callback + * @phpstan-param ProcessorInterface|(callable(LogRecord): LogRecord) $callback * * @param ProcessorInterface|callable $callback * @return HandlerInterface self @@ -35,7 +34,7 @@ public function pushProcessor(callable $callback): HandlerInterface; /** * Removes the processor on top of the stack and returns it. * - * @psalm-return ProcessorInterface|callable(Record): Record $callback + * @phpstan-return ProcessorInterface|(callable(LogRecord): LogRecord) $callback * * @throws \LogicException In case the processor stack is empty * @return callable|ProcessorInterface diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php index 9ef6e301c..74eeddddc 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php @@ -13,24 +13,23 @@ use Monolog\ResettableInterface; use Monolog\Processor\ProcessorInterface; +use Monolog\LogRecord; /** * Helper trait for implementing ProcessableInterface * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger */ trait ProcessableHandlerTrait { /** * @var callable[] - * @phpstan-var array + * @phpstan-var array<(callable(LogRecord): LogRecord)|ProcessorInterface> */ - protected $processors = []; + protected array $processors = []; /** - * {@inheritDoc} + * @inheritDoc */ public function pushProcessor(callable $callback): HandlerInterface { @@ -40,24 +39,18 @@ public function pushProcessor(callable $callback): HandlerInterface } /** - * {@inheritDoc} + * @inheritDoc */ public function popProcessor(): callable { - if (!$this->processors) { + if (\count($this->processors) === 0) { throw new \LogicException('You tried to pop from an empty processor stack.'); } return array_shift($this->processors); } - /** - * Processes a record. - * - * @phpstan-param Record $record - * @phpstan-return Record - */ - protected function processRecord(array $record): array + protected function processRecord(LogRecord $record): LogRecord { foreach ($this->processors as $processor) { $record = $processor($record); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php index 36e19cccf..100e8e4a6 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php @@ -11,9 +11,10 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Psr\Log\LoggerInterface; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Proxies log messages to an existing PSR-3 compliant logger. @@ -28,49 +29,47 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface { /** * PSR-3 compliant logger - * - * @var LoggerInterface */ - protected $logger; + protected LoggerInterface $logger; - /** - * @var FormatterInterface|null - */ - protected $formatter; + protected FormatterInterface|null $formatter = null; + private bool $includeExtra; /** * @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied */ - public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(LoggerInterface $logger, int|string|Level $level = Level::Debug, bool $bubble = true, bool $includeExtra = false) { parent::__construct($level, $bubble); $this->logger = $logger; + $this->includeExtra = $includeExtra; } /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if (!$this->isHandling($record)) { return false; } - if ($this->formatter) { - $formatted = $this->formatter->format($record); - $this->logger->log(strtolower($record['level_name']), (string) $formatted, $record['context']); - } else { - $this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']); - } + $message = $this->formatter !== null + ? (string) $this->formatter->format($record) + : $record->message; + + $context = $this->includeExtra + ? [...$record->extra, ...$record->context] + : $record->context; + + $this->logger->log($record->level->toPsrLogLevel(), $message, $context); return false === $this->bubble; } /** * Sets the formatter. - * - * @param FormatterInterface $formatter */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -81,12 +80,10 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface /** * Gets the formatter. - * - * @return FormatterInterface */ public function getFormatter(): FormatterInterface { - if (!$this->formatter) { + if ($this->formatter === null) { throw new \LogicException('No formatter has been set and this handler does not have a default formatter'); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php index fed2303d7..b2a78955a 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php @@ -11,48 +11,45 @@ namespace Monolog\Handler; +use Monolog\Level; use Monolog\Logger; use Monolog\Utils; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Sends notifications through the pushover api to mobile phones * * @author Sebastian Göttschkes * @see https://www.pushover.net/api - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class PushoverHandler extends SocketHandler { - /** @var string */ - private $token; + private string $token; + /** @var array */ - private $users; - /** @var string */ - private $title; - /** @var string|int|null */ - private $user = null; - /** @var int */ - private $retry; - /** @var int */ - private $expire; - - /** @var int */ - private $highPriorityLevel; - /** @var int */ - private $emergencyLevel; - /** @var bool */ - private $useFormattedMessage = false; + private array $users; + + private string $title; + + private string|int|null $user = null; + + private int $retry; + + private int $expire; + + private Level $highPriorityLevel; + + private Level $emergencyLevel; + + private bool $useFormattedMessage = false; /** * All parameters that can be sent to Pushover * @see https://pushover.net/api * @var array */ - private $parameterNames = [ + private array $parameterNames = [ 'token' => true, 'user' => true, 'message' => true, @@ -73,40 +70,42 @@ class PushoverHandler extends SocketHandler * @see https://pushover.net/api#sounds * @var string[] */ - private $sounds = [ + private array $sounds = [ 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', 'persistent', 'echo', 'updown', 'none', ]; /** - * @param string $token Pushover api token - * @param string|array $users Pushover user id or array of ids the message will be sent to - * @param string|null $title Title sent to the Pushover API - * @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not - * the pushover.net app owner. OpenSSL is required for this option. - * @param string|int $highPriorityLevel The minimum logging level at which this handler will start - * sending "high priority" requests to the Pushover API - * @param string|int $emergencyLevel The minimum logging level at which this handler will start - * sending "emergency" requests to the Pushover API - * @param int $retry The retry parameter specifies how often (in seconds) the Pushover servers will - * send the same notification to the user. - * @param int $expire The expire parameter specifies how many seconds your notification will continue - * to be retried for (every retry seconds). + * @param string $token Pushover api token + * @param string|array $users Pushover user id or array of ids the message will be sent to + * @param string|null $title Title sent to the Pushover API + * @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not + * the pushover.net app owner. OpenSSL is required for this option. + * @param int $retry The retry parameter specifies how often (in seconds) the Pushover servers will + * send the same notification to the user. + * @param int $expire The expire parameter specifies how many seconds your notification will continue + * to be retried for (every retry seconds). + * + * @param int|string|Level|LogLevel::* $highPriorityLevel The minimum logging level at which this handler will start + * sending "high priority" requests to the Pushover API + * @param int|string|Level|LogLevel::* $emergencyLevel The minimum logging level at which this handler will start + * sending "emergency" requests to the Pushover API + * * * @phpstan-param string|array $users - * @phpstan-param Level|LevelName|LogLevel::* $highPriorityLevel - * @phpstan-param Level|LevelName|LogLevel::* $emergencyLevel + * @phpstan-param value-of|value-of|Level|LogLevel::* $highPriorityLevel + * @phpstan-param value-of|value-of|Level|LogLevel::* $emergencyLevel */ public function __construct( string $token, $users, ?string $title = null, - $level = Logger::CRITICAL, + int|string|Level $level = Level::Critical, bool $bubble = true, bool $useSSL = true, - $highPriorityLevel = Logger::CRITICAL, - $emergencyLevel = Logger::EMERGENCY, + int|string|Level $highPriorityLevel = Level::Critical, + int|string|Level $emergencyLevel = Level::Emergency, int $retry = 30, int $expire = 25200, bool $persistent = false, @@ -129,32 +128,29 @@ public function __construct( $this->token = $token; $this->users = (array) $users; - $this->title = $title ?: (string) gethostname(); + $this->title = $title ?? (string) gethostname(); $this->highPriorityLevel = Logger::toMonologLevel($highPriorityLevel); $this->emergencyLevel = Logger::toMonologLevel($emergencyLevel); $this->retry = $retry; $this->expire = $expire; } - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { $content = $this->buildContent($record); return $this->buildHeader($content) . $content; } - /** - * @phpstan-param FormattedRecord $record - */ - private function buildContent(array $record): string + private function buildContent(LogRecord $record): string { // Pushover has a limit of 512 characters on title and message combined. - $maxMessageLength = 512 - strlen($this->title); + $maxMessageLength = 512 - \strlen($this->title); - $message = ($this->useFormattedMessage) ? $record['formatted'] : $record['message']; + $message = ($this->useFormattedMessage) ? $record->formatted : $record->message; $message = Utils::substr($message, 0, $maxMessageLength); - $timestamp = $record['datetime']->getTimestamp(); + $timestamp = $record->datetime->getTimestamp(); $dataArray = [ 'token' => $this->token, @@ -164,23 +160,23 @@ private function buildContent(array $record): string 'timestamp' => $timestamp, ]; - if (isset($record['level']) && $record['level'] >= $this->emergencyLevel) { + if ($record->level->value >= $this->emergencyLevel->value) { $dataArray['priority'] = 2; $dataArray['retry'] = $this->retry; $dataArray['expire'] = $this->expire; - } elseif (isset($record['level']) && $record['level'] >= $this->highPriorityLevel) { + } elseif ($record->level->value >= $this->highPriorityLevel->value) { $dataArray['priority'] = 1; } // First determine the available parameters - $context = array_intersect_key($record['context'], $this->parameterNames); - $extra = array_intersect_key($record['extra'], $this->parameterNames); + $context = array_intersect_key($record->context, $this->parameterNames); + $extra = array_intersect_key($record->extra, $this->parameterNames); // Least important info should be merged with subsequent info $dataArray = array_merge($extra, $context, $dataArray); // Only pass sounds that are supported by the API - if (isset($dataArray['sound']) && !in_array($dataArray['sound'], $this->sounds)) { + if (isset($dataArray['sound']) && !\in_array($dataArray['sound'], $this->sounds, true)) { unset($dataArray['sound']); } @@ -192,13 +188,13 @@ private function buildHeader(string $content): string $header = "POST /1/messages.json HTTP/1.1\r\n"; $header .= "Host: api.pushover.net\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "Content-Length: " . \strlen($content) . "\r\n"; $header .= "\r\n"; return $header; } - protected function write(array $record): void + protected function write(LogRecord $record): void { foreach ($this->users as $user) { $this->user = $user; @@ -211,35 +207,39 @@ protected function write(array $record): void } /** - * @param int|string $value + * @param int|string|Level|LogLevel::* $level + * @return $this * - * @phpstan-param Level|LevelName|LogLevel::* $value + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function setHighPriorityLevel($value): self + public function setHighPriorityLevel(int|string|Level $level): self { - $this->highPriorityLevel = Logger::toMonologLevel($value); + $this->highPriorityLevel = Logger::toMonologLevel($level); return $this; } /** - * @param int|string $value + * @param int|string|Level|LogLevel::* $level + * @return $this * - * @phpstan-param Level|LevelName|LogLevel::* $value + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function setEmergencyLevel($value): self + public function setEmergencyLevel(int|string|Level $level): self { - $this->emergencyLevel = Logger::toMonologLevel($value); + $this->emergencyLevel = Logger::toMonologLevel($level); return $this; } /** * Use the formatted message? + * + * @return $this */ - public function useFormattedMessage(bool $value): self + public function useFormattedMessage(bool $useFormattedMessage): self { - $this->useFormattedMessage = $value; + $this->useFormattedMessage = $useFormattedMessage; return $this; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php index 91d16eaf6..c40d97c61 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php @@ -13,7 +13,10 @@ use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; +use Predis\Client as Predis; +use Redis; /** * Logs to a Redis key using rpush @@ -21,33 +24,25 @@ * usage example: * * $log = new Logger('application'); - * $redis = new RedisHandler(new Predis\Client("tcp://localhost:6379"), "logs", "prod"); + * $redis = new RedisHandler(new Predis\Client("tcp://localhost:6379"), "logs"); * $log->pushHandler($redis); * * @author Thomas Tourlourat - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class RedisHandler extends AbstractProcessingHandler { - /** @var \Predis\Client<\Predis\Client>|\Redis */ - private $redisClient; - /** @var string */ - private $redisKey; - /** @var int */ - protected $capSize; + /** @var Predis|Redis */ + private Predis|Redis $redisClient; + private string $redisKey; + protected int $capSize; /** - * @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance - * @param string $key The key name to push records to - * @param int $capSize Number of entries to limit list size to, 0 = unlimited + * @param Predis|Redis $redis The redis instance + * @param string $key The key name to push records to + * @param int $capSize Number of entries to limit list size to, 0 = unlimited */ - public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true, int $capSize = 0) + public function __construct(Predis|Redis $redis, string $key, int|string|Level $level = Level::Debug, bool $bubble = true, int $capSize = 0) { - if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) { - throw new \InvalidArgumentException('Predis\Client or Redis instance required'); - } - $this->redisClient = $redis; $this->redisKey = $key; $this->capSize = $capSize; @@ -56,43 +51,41 @@ public function __construct($redis, string $key, $level = Logger::DEBUG, bool $b } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - if ($this->capSize) { + if ($this->capSize > 0) { $this->writeCapped($record); } else { - $this->redisClient->rpush($this->redisKey, $record["formatted"]); + $this->redisClient->rpush($this->redisKey, $record->formatted); } } /** * Write and cap the collection * Writes the record to the redis list and caps its - * - * @phpstan-param FormattedRecord $record */ - protected function writeCapped(array $record): void + protected function writeCapped(LogRecord $record): void { - if ($this->redisClient instanceof \Redis) { - $mode = defined('\Redis::MULTI') ? \Redis::MULTI : 1; + if ($this->redisClient instanceof Redis) { + $mode = \defined('Redis::MULTI') ? Redis::MULTI : 1; $this->redisClient->multi($mode) - ->rpush($this->redisKey, $record["formatted"]) + ->rPush($this->redisKey, $record->formatted) ->ltrim($this->redisKey, -$this->capSize, -1) ->exec(); } else { $redisKey = $this->redisKey; $capSize = $this->capSize; $this->redisClient->transaction(function ($tx) use ($record, $redisKey, $capSize) { - $tx->rpush($redisKey, $record["formatted"]); + $tx->rpush($redisKey, $record->formatted); $tx->ltrim($redisKey, -$capSize, -1); }); } } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisPubSubHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisPubSubHandler.php index 7789309c1..fa8e9e9ff 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisPubSubHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RedisPubSubHandler.php @@ -13,7 +13,10 @@ use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; +use Predis\Client as Predis; +use Redis; /** * Sends the message to a Redis Pub/Sub channel using PUBLISH @@ -21,28 +24,23 @@ * usage example: * * $log = new Logger('application'); - * $redis = new RedisPubSubHandler(new Predis\Client("tcp://localhost:6379"), "logs", Logger::WARNING); + * $redis = new RedisPubSubHandler(new Predis\Client("tcp://localhost:6379"), "logs", Level::Warning); * $log->pushHandler($redis); * * @author Gaëtan Faugère */ class RedisPubSubHandler extends AbstractProcessingHandler { - /** @var \Predis\Client<\Predis\Client>|\Redis */ - private $redisClient; - /** @var string */ - private $channelKey; + /** @var Predis|Redis */ + private Predis|Redis $redisClient; + private string $channelKey; /** - * @param \Predis\Client<\Predis\Client>|\Redis $redis The redis instance - * @param string $key The channel key to publish records to + * @param Predis|Redis $redis The redis instance + * @param string $key The channel key to publish records to */ - public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(Predis|Redis $redis, string $key, int|string|Level $level = Level::Debug, bool $bubble = true) { - if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) { - throw new \InvalidArgumentException('Predis\Client or Redis instance required'); - } - $this->redisClient = $redis; $this->channelKey = $key; @@ -50,15 +48,15 @@ public function __construct($redis, string $key, $level = Logger::DEBUG, bool $b } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->redisClient->publish($this->channelKey, $record["formatted"]); + $this->redisClient->publish($this->channelKey, $record->formatted); } /** - * {@inheritDoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php index adcc9395a..6b9943265 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php @@ -11,9 +11,10 @@ namespace Monolog\Handler; +use Monolog\Level; use Rollbar\RollbarLogger; use Throwable; -use Monolog\Logger; +use Monolog\LogRecord; /** * Sends errors to Rollbar @@ -33,37 +34,19 @@ */ class RollbarHandler extends AbstractProcessingHandler { - /** - * @var RollbarLogger - */ - protected $rollbarLogger; - - /** @var string[] */ - protected $levelMap = [ - Logger::DEBUG => 'debug', - Logger::INFO => 'info', - Logger::NOTICE => 'info', - Logger::WARNING => 'warning', - Logger::ERROR => 'error', - Logger::CRITICAL => 'critical', - Logger::ALERT => 'critical', - Logger::EMERGENCY => 'critical', - ]; + protected RollbarLogger $rollbarLogger; /** * Records whether any log records have been added since the last flush of the rollbar notifier - * - * @var bool */ - private $hasRecords = false; + private bool $hasRecords = false; - /** @var bool */ - protected $initialized = false; + protected bool $initialized = false; /** * @param RollbarLogger $rollbarLogger RollbarLogger object constructed with valid token */ - public function __construct(RollbarLogger $rollbarLogger, $level = Logger::ERROR, bool $bubble = true) + public function __construct(RollbarLogger $rollbarLogger, int|string|Level $level = Level::Error, bool $bubble = true) { $this->rollbarLogger = $rollbarLogger; @@ -71,22 +54,41 @@ public function __construct(RollbarLogger $rollbarLogger, $level = Logger::ERROR } /** - * {@inheritDoc} + * Translates Monolog log levels to Rollbar levels. + * + * @return 'debug'|'info'|'warning'|'error'|'critical' + */ + protected function toRollbarLevel(Level $level): string + { + return match ($level) { + Level::Debug => 'debug', + Level::Info => 'info', + Level::Notice => 'info', + Level::Warning => 'warning', + Level::Error => 'error', + Level::Critical => 'critical', + Level::Alert => 'critical', + Level::Emergency => 'critical', + }; + } + + /** + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { if (!$this->initialized) { // __destructor() doesn't get called on Fatal errors - register_shutdown_function(array($this, 'close')); + register_shutdown_function([$this, 'close']); $this->initialized = true; } - $context = $record['context']; - $context = array_merge($context, $record['extra'], [ - 'level' => $this->levelMap[$record['level']], - 'monolog_level' => $record['level_name'], - 'channel' => $record['channel'], - 'datetime' => $record['datetime']->format('U'), + $context = $record->context; + $context = array_merge($context, $record->extra, [ + 'level' => $this->toRollbarLevel($record->level), + 'monolog_level' => $record->level->getName(), + 'channel' => $record->channel, + 'datetime' => $record->datetime->format('U'), ]); if (isset($context['exception']) && $context['exception'] instanceof Throwable) { @@ -94,10 +96,9 @@ protected function write(array $record): void unset($context['exception']); $toLog = $exception; } else { - $toLog = $record['message']; + $toLog = $record->message; } - // @phpstan-ignore-next-line $this->rollbarLogger->log($context['level'], $toLog, $context); $this->hasRecords = true; @@ -112,7 +113,7 @@ public function flush(): void } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -120,9 +121,9 @@ public function close(): void } /** - * {@inheritDoc} + * @inheritDoc */ - public function reset() + public function reset(): void { $this->flush(); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php index 2d0c1a72d..401c10895 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php @@ -11,9 +11,11 @@ namespace Monolog\Handler; +use DateTimeZone; use InvalidArgumentException; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * Stores logs to files that are rotated every day and a limited number of files are kept. @@ -30,38 +32,32 @@ class RotatingFileHandler extends StreamHandler public const FILE_PER_MONTH = 'Y-m'; public const FILE_PER_YEAR = 'Y'; - /** @var string */ - protected $filename; - /** @var int */ - protected $maxFiles; - /** @var bool */ - protected $mustRotate; - /** @var \DateTimeImmutable */ - protected $nextRotation; - /** @var string */ - protected $filenameFormat; - /** @var string */ - protected $dateFormat; + protected string $filename; + protected int $maxFiles; + protected bool|null $mustRotate = null; + protected \DateTimeImmutable $nextRotation; + protected string $filenameFormat; + protected string $dateFormat; + protected DateTimeZone|null $timezone = null; /** - * @param string $filename - * @param int $maxFiles The maximal amount of files to keep (0 means unlimited) - * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) - * @param bool $useLocking Try to lock log file before doing any writes + * @param int $maxFiles The maximal amount of files to keep (0 means unlimited) + * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) + * @param bool $useLocking Try to lock log file before doing any writes */ - public function __construct(string $filename, int $maxFiles = 0, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) + public function __construct(string $filename, int $maxFiles = 0, int|string|Level $level = Level::Debug, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false, string $dateFormat = self::FILE_PER_DAY, string $filenameFormat = '{filename}-{date}', DateTimeZone|null $timezone = null) { $this->filename = Utils::canonicalizePath($filename); $this->maxFiles = $maxFiles; - $this->nextRotation = new \DateTimeImmutable('tomorrow'); - $this->filenameFormat = '{filename}-{date}'; - $this->dateFormat = static::FILE_PER_DAY; + $this->setFilenameFormat($filenameFormat, $dateFormat); + $this->nextRotation = $this->getNextRotation(); + $this->timezone = $timezone; parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission, $useLocking); } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -73,34 +69,25 @@ public function close(): void } /** - * {@inheritDoc} + * @inheritDoc */ - public function reset() + public function reset(): void { parent::reset(); - - if (true === $this->mustRotate) { - $this->rotate(); - } } + /** + * @return $this + */ public function setFilenameFormat(string $filenameFormat, string $dateFormat): self { - if (!preg_match('{^[Yy](([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) { - throw new InvalidArgumentException( - 'Invalid date format - format must be one of '. - 'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m") '. - 'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the '. - 'date formats using slashes, underscores and/or dots instead of dashes.' - ); - } + $this->setDateFormat($dateFormat); if (substr_count($filenameFormat, '{date}') === 0) { throw new InvalidArgumentException( 'Invalid filename format - format must contain at least `{date}`, because otherwise rotating is impossible.' ); } $this->filenameFormat = $filenameFormat; - $this->dateFormat = $dateFormat; $this->url = $this->getTimedFilename(); $this->close(); @@ -108,9 +95,9 @@ public function setFilenameFormat(string $filenameFormat, string $dateFormat): s } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { // on the first record written, if the log is new, we rotate (once per day) after the log has been written so that the new file exists if (null === $this->mustRotate) { @@ -118,14 +105,14 @@ protected function write(array $record): void } // if the next rotation is expired, then we rotate immediately - if ($this->nextRotation <= $record['datetime']) { + if ($this->nextRotation <= $record->datetime) { $this->mustRotate = true; $this->close(); // triggers rotation } parent::write($record); - if ($this->mustRotate) { + if (true === $this->mustRotate) { $this->close(); // triggers rotation } } @@ -137,7 +124,7 @@ protected function rotate(): void { // update filename $this->url = $this->getTimedFilename(); - $this->nextRotation = new \DateTimeImmutable('tomorrow'); + $this->nextRotation = $this->getNextRotation(); $this->mustRotate = false; @@ -152,7 +139,7 @@ protected function rotate(): void return; } - if ($this->maxFiles >= count($logFiles)) { + if ($this->maxFiles >= \count($logFiles)) { // no files to remove return; } @@ -162,14 +149,27 @@ protected function rotate(): void return strcmp($b, $a); }); - foreach (array_slice($logFiles, $this->maxFiles) as $file) { + $basePath = dirname($this->filename); + + foreach (\array_slice($logFiles, $this->maxFiles) as $file) { if (is_writable($file)) { // suppress errors here as unlink() might fail if two processes // are cleaning up/rotating at the same time set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool { - return false; + return true; }); unlink($file); + + $dir = dirname($file); + while ($dir !== $basePath) { + $entries = scandir($dir); + if ($entries === false || \count(array_diff($entries, ['.', '..'])) > 0) { + break; + } + + rmdir($dir); + $dir = dirname($dir); + } restore_error_handler(); } } @@ -180,8 +180,8 @@ protected function getTimedFilename(): string $fileInfo = pathinfo($this->filename); $timedFilename = str_replace( ['{filename}', '{date}'], - [$fileInfo['filename'], date($this->dateFormat)], - $fileInfo['dirname'] . '/' . $this->filenameFormat + [$fileInfo['filename'], (new \DateTimeImmutable(timezone: $this->timezone))->format($this->dateFormat)], + ($fileInfo['dirname'] ?? '') . '/' . $this->filenameFormat ); if (isset($fileInfo['extension'])) { @@ -199,9 +199,9 @@ protected function getGlobPattern(): string [$fileInfo['filename'], str_replace( ['Y', 'y', 'm', 'd'], ['[0-9][0-9][0-9][0-9]', '[0-9][0-9]', '[0-9][0-9]', '[0-9][0-9]'], - $this->dateFormat) - ], - $fileInfo['dirname'] . '/' . $this->filenameFormat + $this->dateFormat + )], + ($fileInfo['dirname'] ?? '') . '/' . $this->filenameFormat ); if (isset($fileInfo['extension'])) { $glob .= '.'.$fileInfo['extension']; @@ -209,4 +209,26 @@ protected function getGlobPattern(): string return $glob; } + + protected function setDateFormat(string $dateFormat): void + { + if (0 === preg_match('{^[Yy](([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) { + throw new InvalidArgumentException( + 'Invalid date format - format must be one of '. + 'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m") '. + 'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the '. + 'date formats using slashes, underscores and/or dots instead of dashes.' + ); + } + $this->dateFormat = $dateFormat; + } + + protected function getNextRotation(): \DateTimeImmutable + { + return match (str_replace(['/','_','.'], '-', $this->dateFormat)) { + self::FILE_PER_MONTH => (new \DateTimeImmutable('first day of next month'))->setTime(0, 0, 0), + self::FILE_PER_YEAR => (new \DateTimeImmutable('first day of January next year'))->setTime(0, 0, 0), + default => (new \DateTimeImmutable('tomorrow'))->setTime(0, 0, 0), + }; + } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php index 25cce07f9..1b10580f2 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php @@ -11,7 +11,9 @@ namespace Monolog\Handler; +use Closure; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Sampling handler @@ -26,52 +28,42 @@ * * @author Bryan Davis * @author Kunal Mehta - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger */ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInterface, FormattableHandlerInterface { use ProcessableHandlerTrait; /** - * @var HandlerInterface|callable - * @phpstan-var HandlerInterface|callable(Record|array{level: Level}|null, HandlerInterface): HandlerInterface + * Handler or factory Closure($record, $this) + * + * @phpstan-var (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface */ - protected $handler; + protected Closure|HandlerInterface $handler; - /** - * @var int $factor - */ - protected $factor; + protected int $factor; /** - * @psalm-param HandlerInterface|callable(Record|array{level: Level}|null, HandlerInterface): HandlerInterface $handler + * @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler * - * @param callable|HandlerInterface $handler Handler or factory callable($record|null, $samplingHandler). - * @param int $factor Sample factor (e.g. 10 means every ~10th record is sampled) + * @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $samplingHandler). + * @param int $factor Sample factor (e.g. 10 means every ~10th record is sampled) */ - public function __construct($handler, int $factor) + public function __construct(Closure|HandlerInterface $handler, int $factor) { parent::__construct(); $this->handler = $handler; $this->factor = $factor; - - if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) { - throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); - } } - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { return $this->getHandler($record)->isHandling($record); } - public function handle(array $record): bool + public function handle(LogRecord $record): bool { if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) { - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } @@ -84,26 +76,23 @@ public function handle(array $record): bool /** * Return the nested handler * - * If the handler was provided as a factory callable, this will trigger the handler's instantiation. - * - * @phpstan-param Record|array{level: Level}|null $record - * - * @return HandlerInterface + * If the handler was provided as a factory, this will trigger the handler's instantiation. */ - public function getHandler(?array $record = null) + public function getHandler(LogRecord|null $record = null): HandlerInterface { if (!$this->handler instanceof HandlerInterface) { - $this->handler = ($this->handler)($record, $this); - if (!$this->handler instanceof HandlerInterface) { - throw new \RuntimeException("The factory callable should return a HandlerInterface"); + $handler = ($this->handler)($record, $this); + if (!$handler instanceof HandlerInterface) { + throw new \RuntimeException("The factory Closure should return a HandlerInterface"); } + $this->handler = $handler; } return $this->handler; } /** - * {@inheritDoc} + * @inheritDoc */ public function setFormatter(FormatterInterface $formatter): HandlerInterface { @@ -114,11 +103,11 @@ public function setFormatter(FormatterInterface $formatter): HandlerInterface return $this; } - throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($handler).' does not support formatters.'); } /** - * {@inheritDoc} + * @inheritDoc */ public function getFormatter(): FormatterInterface { @@ -127,6 +116,6 @@ public function getFormatter(): FormatterInterface return $handler->getFormatter(); } - throw new \UnexpectedValueException('The nested handler of type '.get_class($handler).' does not support formatters.'); + throw new \UnexpectedValueException('The nested handler of type '.\get_class($handler).' does not support formatters.'); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php index 1280ee703..5847a585c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php @@ -11,10 +11,11 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; +use Monolog\Utils; /** - * SendGridrHandler uses the SendGrid API v2 function to send Log emails, more information in https://sendgrid.com/docs/API_Reference/Web_API/mail.html + * SendGridHandler uses the SendGrid API v3 function to send Log emails, more information in https://www.twilio.com/docs/sendgrid/for-developers/sending-email/api-getting-started * * @author Ricardo Fontanelli */ @@ -22,81 +23,73 @@ class SendGridHandler extends MailHandler { /** * The SendGrid API User - * @var string + * @deprecated this is not used anymore as of SendGrid API v3 */ - protected $apiUser; - - /** - * The SendGrid API Key - * @var string - */ - protected $apiKey; - - /** - * The email addresses to which the message will be sent - * @var string - */ - protected $from; - + protected string $apiUser; /** * The email addresses to which the message will be sent * @var string[] */ - protected $to; - - /** - * The subject of the email - * @var string - */ - protected $subject; + protected array $to; /** - * @param string $apiUser The SendGrid API User - * @param string $apiKey The SendGrid API Key - * @param string $from The sender of the email - * @param string|string[] $to The recipients of the email - * @param string $subject The subject of the mail + * @param string|null $apiUser Unused user as of SendGrid API v3, you can pass null or any string + * @param list|string $to + * @param non-empty-string $apiHost Allows you to use another endpoint (e.g. api.eu.sendgrid.com) + * @throws MissingExtensionException If the curl extension is missing */ - public function __construct(string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Logger::ERROR, bool $bubble = true) - { - if (!extension_loaded('curl')) { + public function __construct( + string|null $apiUser, + protected string $apiKey, + protected string $from, + array|string $to, + protected string $subject, + int|string|Level $level = Level::Error, + bool $bubble = true, + /** @var non-empty-string */ + private readonly string $apiHost = 'api.sendgrid.com', + ) { + if (!\extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the SendGridHandler'); } - parent::__construct($level, $bubble); - $this->apiUser = $apiUser; - $this->apiKey = $apiKey; - $this->from = $from; $this->to = (array) $to; - $this->subject = $subject; + // @phpstan-ignore property.deprecated + $this->apiUser = $apiUser ?? ''; + parent::__construct($level, $bubble); } - /** - * {@inheritDoc} - */ protected function send(string $content, array $records): void { - $message = []; - $message['api_user'] = $this->apiUser; - $message['api_key'] = $this->apiKey; - $message['from'] = $this->from; + $body = []; + $body['personalizations'] = []; + $body['from']['email'] = $this->from; foreach ($this->to as $recipient) { - $message['to[]'] = $recipient; + $body['personalizations'][]['to'][]['email'] = $recipient; } - $message['subject'] = $this->subject; - $message['date'] = date('r'); + $body['subject'] = $this->subject; if ($this->isHtmlBody($content)) { - $message['html'] = $content; + $body['content'][] = [ + 'type' => 'text/html', + 'value' => $content, + ]; } else { - $message['text'] = $content; + $body['content'][] = [ + 'type' => 'text/plain', + 'value' => $content, + ]; } - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, 'https://api.sendgrid.com/api/mail.send.json'); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($message)); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json', + 'Authorization: Bearer '.$this->apiKey, + ]); + curl_setopt($ch, CURLOPT_URL, 'https://'.$this->apiHost.'/v3/mail/send'); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, Utils::jsonEncode($body)); + Curl\Util::execute($ch, 2); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php index 9ae100371..0e46c2d2f 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php @@ -11,10 +11,11 @@ namespace Monolog\Handler\Slack; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; use Monolog\Formatter\NormalizerFormatter; use Monolog\Formatter\FormatterInterface; +use Monolog\LogRecord; /** * Slack record utility helping to log to Slack webhooks or API. @@ -23,9 +24,6 @@ * @author Haralan Dobrev * @see https://api.slack.com/incoming-webhooks * @see https://api.slack.com/docs/message-attachments - * - * @phpstan-import-type FormattedRecord from \Monolog\Handler\AbstractProcessingHandler - * @phpstan-import-type Record from \Monolog\Logger */ class SlackRecord { @@ -39,55 +37,43 @@ class SlackRecord /** * Slack channel (encoded ID or name) - * @var string|null */ - private $channel; + private string|null $channel; /** * Name of a bot - * @var string|null */ - private $username; + private string|null $username; /** * User icon e.g. 'ghost', 'http://example.com/user.png' - * @var string|null */ - private $userIcon; + private string|null $userIcon; /** * Whether the message should be added to Slack as attachment (plain text otherwise) - * @var bool */ - private $useAttachment; + private bool $useAttachment; /** * Whether the the context/extra messages added to Slack as attachments are in a short style - * @var bool */ - private $useShortAttachment; + private bool $useShortAttachment; /** * Whether the attachment should include context and extra data - * @var bool */ - private $includeContextAndExtra; + private bool $includeContextAndExtra; /** * Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'] * @var string[] */ - private $excludeFields; + private array $excludeFields; - /** - * @var ?FormatterInterface - */ - private $formatter; + private FormatterInterface|null $formatter; - /** - * @var NormalizerFormatter - */ - private $normalizerFormatter; + private NormalizerFormatter $normalizerFormatter; /** * @param string[] $excludeFields @@ -99,8 +85,8 @@ public function __construct( ?string $userIcon = null, bool $useShortAttachment = false, bool $includeContextAndExtra = false, - array $excludeFields = array(), - ?FormatterInterface $formatter = null + array $excludeFields = [], + FormatterInterface|null $formatter = null ) { $this ->setChannel($channel) @@ -121,77 +107,76 @@ public function __construct( * Returns required data in format that Slack * is expecting. * - * @phpstan-param FormattedRecord $record * @phpstan-return mixed[] */ - public function getSlackData(array $record): array + public function getSlackData(LogRecord $record): array { - $dataArray = array(); - $record = $this->removeExcludedFields($record); + $dataArray = []; - if ($this->username) { + if ($this->username !== null) { $dataArray['username'] = $this->username; } - if ($this->channel) { + if ($this->channel !== null) { $dataArray['channel'] = $this->channel; } - if ($this->formatter && !$this->useAttachment) { - /** @phpstan-ignore-next-line */ + if ($this->formatter !== null && !$this->useAttachment) { $message = $this->formatter->format($record); } else { - $message = $record['message']; + $message = $record->message; } + $recordData = $this->removeExcludedFields($record); + if ($this->useAttachment) { - $attachment = array( - 'fallback' => $message, - 'text' => $message, - 'color' => $this->getAttachmentColor($record['level']), - 'fields' => array(), - 'mrkdwn_in' => array('fields'), - 'ts' => $record['datetime']->getTimestamp(), + $attachment = [ + 'fallback' => $message, + 'text' => $message, + 'color' => $this->getAttachmentColor($record->level), + 'fields' => [], + 'mrkdwn_in' => ['fields'], + 'ts' => $recordData['datetime']->getTimestamp(), 'footer' => $this->username, 'footer_icon' => $this->userIcon, - ); + ]; if ($this->useShortAttachment) { - $attachment['title'] = $record['level_name']; + $attachment['title'] = $recordData['level_name']; } else { $attachment['title'] = 'Message'; - $attachment['fields'][] = $this->generateAttachmentField('Level', $record['level_name']); + $attachment['fields'][] = $this->generateAttachmentField('Level', $recordData['level_name']); } if ($this->includeContextAndExtra) { - foreach (array('extra', 'context') as $key) { - if (empty($record[$key])) { + foreach (['extra', 'context'] as $key) { + if (!isset($recordData[$key]) || \count($recordData[$key]) === 0) { continue; } if ($this->useShortAttachment) { $attachment['fields'][] = $this->generateAttachmentField( - (string) $key, - $record[$key] + $key, + $recordData[$key] ); } else { // Add all extra fields as individual fields in attachment $attachment['fields'] = array_merge( $attachment['fields'], - $this->generateAttachmentFields($record[$key]) + $this->generateAttachmentFields($recordData[$key]) ); } } } - $dataArray['attachments'] = array($attachment); + $dataArray['attachments'] = [$attachment]; } else { $dataArray['text'] = $message; } - if ($this->userIcon) { - if (filter_var($this->userIcon, FILTER_VALIDATE_URL)) { - $dataArray['icon_url'] = $this->userIcon; + if ($this->userIcon !== null) { + if (false !== ($iconUrl = filter_var($this->userIcon, FILTER_VALIDATE_URL))) { + $dataArray['icon_url'] = $iconUrl; } else { $dataArray['icon_emoji'] = ":{$this->userIcon}:"; } @@ -204,18 +189,14 @@ public function getSlackData(array $record): array * Returns a Slack message attachment color associated with * provided level. */ - public function getAttachmentColor(int $level): string + public function getAttachmentColor(Level $level): string { - switch (true) { - case $level >= Logger::ERROR: - return static::COLOR_DANGER; - case $level >= Logger::WARNING: - return static::COLOR_WARNING; - case $level >= Logger::INFO: - return static::COLOR_GOOD; - default: - return static::COLOR_DEFAULT; - } + return match ($level) { + Level::Error, Level::Critical, Level::Alert, Level::Emergency => static::COLOR_DANGER, + Level::Warning => static::COLOR_WARNING, + Level::Info, Level::Notice => static::COLOR_GOOD, + Level::Debug => static::COLOR_DEFAULT + }; } /** @@ -225,13 +206,13 @@ public function getAttachmentColor(int $level): string */ public function stringify(array $fields): string { - /** @var Record $fields */ - $normalized = $this->normalizerFormatter->format($fields); + /** @var array|bool|float|int|string|null> $normalized */ + $normalized = $this->normalizerFormatter->normalizeValue($fields); - $hasSecondDimension = count(array_filter($normalized, 'is_array')); - $hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric')); + $hasSecondDimension = \count(array_filter($normalized, 'is_array')) > 0; + $hasOnlyNonNumericKeys = \count(array_filter(array_keys($normalized), 'is_numeric')) === 0; - return $hasSecondDimension || $hasNonNumericKeys + return $hasSecondDimension || $hasOnlyNonNumericKeys ? Utils::jsonEncode($normalized, JSON_PRETTY_PRINT|Utils::DEFAULT_JSON_FLAGS) : Utils::jsonEncode($normalized, Utils::DEFAULT_JSON_FLAGS); } @@ -239,9 +220,8 @@ public function stringify(array $fields): string /** * Channel used by the bot when posting * - * @param ?string $channel - * - * @return static + * @param ?string $channel + * @return $this */ public function setChannel(?string $channel = null): self { @@ -253,9 +233,8 @@ public function setChannel(?string $channel = null): self /** * Username used by the bot when posting * - * @param ?string $username - * - * @return static + * @param ?string $username + * @return $this */ public function setUsername(?string $username = null): self { @@ -264,6 +243,9 @@ public function setUsername(?string $username = null): self return $this; } + /** + * @return $this + */ public function useAttachment(bool $useAttachment = true): self { $this->useAttachment = $useAttachment; @@ -271,6 +253,9 @@ public function useAttachment(bool $useAttachment = true): self return $this; } + /** + * @return $this + */ public function setUserIcon(?string $userIcon = null): self { $this->userIcon = $userIcon; @@ -282,6 +267,9 @@ public function setUserIcon(?string $userIcon = null): self return $this; } + /** + * @return $this + */ public function useShortAttachment(bool $useShortAttachment = false): self { $this->useShortAttachment = $useShortAttachment; @@ -289,6 +277,9 @@ public function useShortAttachment(bool $useShortAttachment = false): self return $this; } + /** + * @return $this + */ public function includeContextAndExtra(bool $includeContextAndExtra = false): self { $this->includeContextAndExtra = $includeContextAndExtra; @@ -301,7 +292,8 @@ public function includeContextAndExtra(bool $includeContextAndExtra = false): se } /** - * @param string[] $excludeFields + * @param string[] $excludeFields + * @return $this */ public function excludeFields(array $excludeFields = []): self { @@ -310,6 +302,9 @@ public function excludeFields(array $excludeFields = []): self return $this; } + /** + * @return $this + */ public function setFormatter(?FormatterInterface $formatter = null): self { $this->formatter = $formatter; @@ -326,15 +321,15 @@ public function setFormatter(?FormatterInterface $formatter = null): self */ private function generateAttachmentField(string $title, $value): array { - $value = is_array($value) + $value = \is_array($value) ? sprintf('```%s```', substr($this->stringify($value), 0, 1990)) : $value; - return array( + return [ 'title' => ucfirst($title), 'value' => $value, 'short' => false, - ); + ]; } /** @@ -346,10 +341,10 @@ private function generateAttachmentField(string $title, $value): array */ private function generateAttachmentFields(array $data): array { - /** @var Record $data */ - $normalized = $this->normalizerFormatter->format($data); + /** @var array|string> $normalized */ + $normalized = $this->normalizerFormatter->normalizeValue($data); - $fields = array(); + $fields = []; foreach ($normalized as $key => $value) { $fields[] = $this->generateAttachmentField((string) $key, $value); } @@ -360,15 +355,14 @@ private function generateAttachmentFields(array $data): array /** * Get a copy of record with fields excluded according to $this->excludeFields * - * @phpstan-param FormattedRecord $record - * * @return mixed[] */ - private function removeExcludedFields(array $record): array + private function removeExcludedFields(LogRecord $record): array { + $recordData = $record->toArray(); foreach ($this->excludeFields as $field) { $keys = explode('.', $field); - $node = &$record; + $node = &$recordData; $lastKey = end($keys); foreach ($keys as $key) { if (!isset($node[$key])) { @@ -382,6 +376,6 @@ private function removeExcludedFields(array $record): array } } - return $record; + return $recordData; } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php index a648513e0..2a34dda2d 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php @@ -12,31 +12,28 @@ namespace Monolog\Handler; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; use Monolog\Handler\Slack\SlackRecord; +use Monolog\LogRecord; /** * Sends notifications through Slack API * * @author Greg Kedzierski * @see https://api.slack.com/ - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class SlackHandler extends SocketHandler { /** * Slack API token - * @var string */ - private $token; + private string $token; /** * Instance of the SlackRecord util class preparing data for Slack API. - * @var SlackRecord */ - private $slackRecord; + private SlackRecord $slackRecord; /** * @param string $token Slack API token @@ -55,18 +52,18 @@ public function __construct( ?string $username = null, bool $useAttachment = true, ?string $iconEmoji = null, - $level = Logger::CRITICAL, + $level = Level::Critical, bool $bubble = true, bool $useShortAttachment = false, bool $includeContextAndExtra = false, - array $excludeFields = array(), + array $excludeFields = [], bool $persistent = false, float $timeout = 0.0, float $writingTimeout = 10.0, ?float $connectionTimeout = null, ?int $chunkSize = null ) { - if (!extension_loaded('openssl')) { + if (!\extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler'); } @@ -105,9 +102,9 @@ public function getToken(): string } /** - * {@inheritDoc} + * @inheritDoc */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { $content = $this->buildContent($record); @@ -116,10 +113,8 @@ protected function generateDataStream(array $record): string /** * Builds the body of API call - * - * @phpstan-param FormattedRecord $record */ - private function buildContent(array $record): string + private function buildContent(LogRecord $record): string { $dataArray = $this->prepareContentData($record); @@ -127,15 +122,14 @@ private function buildContent(array $record): string } /** - * @phpstan-param FormattedRecord $record * @return string[] */ - protected function prepareContentData(array $record): array + protected function prepareContentData(LogRecord $record): array { $dataArray = $this->slackRecord->getSlackData($record); $dataArray['token'] = $this->token; - if (!empty($dataArray['attachments'])) { + if (isset($dataArray['attachments']) && \is_array($dataArray['attachments']) && \count($dataArray['attachments']) > 0) { $dataArray['attachments'] = Utils::jsonEncode($dataArray['attachments']); } @@ -150,16 +144,16 @@ private function buildHeader(string $content): string $header = "POST /api/chat.postMessage HTTP/1.1\r\n"; $header .= "Host: slack.com\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "Content-Length: " . \strlen($content) . "\r\n"; $header .= "\r\n"; return $header; } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { parent::write($record); $this->finalizeWrite(); @@ -174,7 +168,7 @@ protected function write(array $record): void protected function finalizeWrite(): void { $res = $this->getResource(); - if (is_resource($res)) { + if (\is_resource($res)) { @fread($res, 2048); } $this->closeSocket(); @@ -198,6 +192,8 @@ public function getFormatter(): FormatterInterface /** * Channel used by the bot when posting + * + * @return $this */ public function setChannel(string $channel): self { @@ -208,6 +204,8 @@ public function setChannel(string $channel): self /** * Username used by the bot when posting + * + * @return $this */ public function setUsername(string $username): self { @@ -216,6 +214,9 @@ public function setUsername(string $username): self return $this; } + /** + * @return $this + */ public function useAttachment(bool $useAttachment): self { $this->slackRecord->useAttachment($useAttachment); @@ -223,6 +224,9 @@ public function useAttachment(bool $useAttachment): self return $this; } + /** + * @return $this + */ public function setIconEmoji(string $iconEmoji): self { $this->slackRecord->setUserIcon($iconEmoji); @@ -230,6 +234,9 @@ public function setIconEmoji(string $iconEmoji): self return $this; } + /** + * @return $this + */ public function useShortAttachment(bool $useShortAttachment): self { $this->slackRecord->useShortAttachment($useShortAttachment); @@ -237,6 +244,9 @@ public function useShortAttachment(bool $useShortAttachment): self return $this; } + /** + * @return $this + */ public function includeContextAndExtra(bool $includeContextAndExtra): self { $this->slackRecord->includeContextAndExtra($includeContextAndExtra); @@ -245,7 +255,8 @@ public function includeContextAndExtra(bool $includeContextAndExtra): self } /** - * @param string[] $excludeFields + * @param string[] $excludeFields + * @return $this */ public function excludeFields(array $excludeFields): self { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php index 8ae3c7882..f265d80c9 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php @@ -12,9 +12,10 @@ namespace Monolog\Handler; use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; use Monolog\Handler\Slack\SlackRecord; +use Monolog\LogRecord; /** * Sends notifications through Slack Webhooks @@ -26,18 +27,18 @@ class SlackWebhookHandler extends AbstractProcessingHandler { /** * Slack Webhook token - * @var string + * + * @var non-empty-string */ - private $webhookUrl; + private string $webhookUrl; /** * Instance of the SlackRecord util class preparing data for Slack API. - * @var SlackRecord */ - private $slackRecord; + private SlackRecord $slackRecord; /** - * @param string $webhookUrl Slack Webhook URL + * @param non-empty-string $webhookUrl Slack Webhook URL * @param string|null $channel Slack channel (encoded ID or name) * @param string|null $username Name of a bot * @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise) @@ -45,6 +46,8 @@ class SlackWebhookHandler extends AbstractProcessingHandler * @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style * @param bool $includeContextAndExtra Whether the attachment should include context and extra data * @param string[] $excludeFields Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'] + * + * @throws MissingExtensionException If the curl extension is missing */ public function __construct( string $webhookUrl, @@ -54,11 +57,11 @@ public function __construct( ?string $iconEmoji = null, bool $useShortAttachment = false, bool $includeContextAndExtra = false, - $level = Logger::CRITICAL, + $level = Level::Critical, bool $bubble = true, - array $excludeFields = array() + array $excludeFields = [] ) { - if (!extension_loaded('curl')) { + if (!\extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the SlackWebhookHandler'); } @@ -88,24 +91,21 @@ public function getWebhookUrl(): string } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { $postData = $this->slackRecord->getSlackData($record); $postString = Utils::jsonEncode($postData); $ch = curl_init(); - $options = array( + $options = [ CURLOPT_URL => $this->webhookUrl, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, - CURLOPT_HTTPHEADER => array('Content-type: application/json'), + CURLOPT_HTTPHEADER => ['Content-type: application/json'], CURLOPT_POSTFIELDS => $postString, - ); - if (defined('CURLOPT_SAFE_UPLOAD')) { - $options[CURLOPT_SAFE_UPLOAD] = true; - } + ]; curl_setopt_array($ch, $options); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php index 21701afa2..36d46bf9d 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php @@ -11,41 +11,29 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Stores to any socket - uses fsockopen() or pfsockopen(). * * @author Pablo de Leon Belloc * @see http://php.net/manual/en/function.fsockopen.php - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class SocketHandler extends AbstractProcessingHandler { - /** @var string */ - private $connectionString; - /** @var float */ - private $connectionTimeout; + private string $connectionString; + private float $connectionTimeout; /** @var resource|null */ private $resource; - /** @var float */ - private $timeout; - /** @var float */ - private $writingTimeout; - /** @var ?int */ - private $lastSentBytes = null; - /** @var ?int */ - private $chunkSize; - /** @var bool */ - private $persistent; - /** @var ?int */ - private $errno = null; - /** @var ?string */ - private $errstr = null; - /** @var ?float */ - private $lastWritingAt = null; + private float $timeout; + private float $writingTimeout; + private int|null $lastSentBytes = null; + private int|null $chunkSize; + private bool $persistent; + private int|null $errno = null; + private string|null $errstr = null; + private float|null $lastWritingAt = null; /** * @param string $connectionString Socket connection string @@ -56,11 +44,11 @@ class SocketHandler extends AbstractProcessingHandler * established * @param int|null $chunkSize Sets the chunk size. Only has effect during connection in the writing cycle * - * @throws \InvalidArgumentException If an invalid timeout value (less than 0) is passed. + * @throws \InvalidArgumentException If an invalid timeout value (less than 0) is passed. */ public function __construct( string $connectionString, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, bool $persistent = false, float $timeout = 0.0, @@ -75,7 +63,7 @@ public function __construct( $this->validateTimeout($connectionTimeout); } - $this->connectionTimeout = $connectionTimeout ?? (float) ini_get('default_socket_timeout'); + $this->connectionTimeout = $connectionTimeout ?? (float) \ini_get('default_socket_timeout'); $this->persistent = $persistent; $this->validateTimeout($timeout); $this->timeout = $timeout; @@ -87,12 +75,12 @@ public function __construct( /** * Connect (if necessary) and write to the socket * - * {@inheritDoc} + * @inheritDoc * * @throws \UnexpectedValueException * @throws \RuntimeException */ - protected function write(array $record): void + protected function write(LogRecord $record): void { $this->connectIfNotConnected(); $data = $this->generateDataStream($record); @@ -114,7 +102,7 @@ public function close(): void */ public function closeSocket(): void { - if (is_resource($this->resource)) { + if (\is_resource($this->resource)) { fclose($this->resource); $this->resource = null; } @@ -122,6 +110,8 @@ public function closeSocket(): void /** * Set socket connection to be persistent. It only has effect before the connection is initiated. + * + * @return $this */ public function setPersistent(bool $persistent): self { @@ -134,6 +124,7 @@ public function setPersistent(bool $persistent): self * Set connection timeout. Only has effect before we connect. * * @see http://php.net/manual/en/function.fsockopen.php + * @return $this */ public function setConnectionTimeout(float $seconds): self { @@ -147,6 +138,7 @@ public function setConnectionTimeout(float $seconds): self * Set write timeout. Only has effect before we connect. * * @see http://php.net/manual/en/function.stream-set-timeout.php + * @return $this */ public function setTimeout(float $seconds): self { @@ -159,7 +151,8 @@ public function setTimeout(float $seconds): self /** * Set writing timeout. Only has effect during connection in the writing cycle. * - * @param float $seconds 0 for no timeout + * @param float $seconds 0 for no timeout + * @return $this */ public function setWritingTimeout(float $seconds): self { @@ -171,6 +164,8 @@ public function setWritingTimeout(float $seconds): self /** * Set chunk size. Only has effect during connection in the writing cycle. + * + * @return $this */ public function setChunkSize(int $bytes): self { @@ -213,8 +208,6 @@ public function getTimeout(): float /** * Get current local writing timeout - * - * @return float */ public function getWritingTimeout(): float { @@ -236,7 +229,7 @@ public function getChunkSize(): ?int */ public function isConnected(): bool { - return is_resource($this->resource) + return \is_resource($this->resource) && !feof($this->resource); // on TCP - other party can close connection. } @@ -264,15 +257,13 @@ protected function fsockopen() * Wrapper to allow mocking * * @see http://php.net/manual/en/function.stream-set-timeout.php - * - * @return bool */ - protected function streamSetTimeout() + protected function streamSetTimeout(): bool { $seconds = floor($this->timeout); $microseconds = round(($this->timeout - $seconds) * 1e6); - if (!is_resource($this->resource)) { + if (!\is_resource($this->resource)) { throw new \LogicException('streamSetTimeout called but $this->resource is not a resource'); } @@ -284,11 +275,11 @@ protected function streamSetTimeout() * * @see http://php.net/manual/en/function.stream-set-chunk-size.php * - * @return int|bool + * @return int|false */ - protected function streamSetChunkSize() + protected function streamSetChunkSize(): int|bool { - if (!is_resource($this->resource)) { + if (!\is_resource($this->resource)) { throw new \LogicException('streamSetChunkSize called but $this->resource is not a resource'); } @@ -302,11 +293,11 @@ protected function streamSetChunkSize() /** * Wrapper to allow mocking * - * @return int|bool + * @return int|false */ - protected function fwrite(string $data) + protected function fwrite(string $data): int|bool { - if (!is_resource($this->resource)) { + if (!\is_resource($this->resource)) { throw new \LogicException('fwrite called but $this->resource is not a resource'); } @@ -318,9 +309,9 @@ protected function fwrite(string $data) * * @return mixed[]|bool */ - protected function streamGetMetadata() + protected function streamGetMetadata(): array|bool { - if (!is_resource($this->resource)) { + if (!\is_resource($this->resource)) { throw new \LogicException('streamGetMetadata called but $this->resource is not a resource'); } @@ -342,12 +333,9 @@ private function connectIfNotConnected(): void $this->connect(); } - /** - * @phpstan-param FormattedRecord $record - */ - protected function generateDataStream(array $record): string + protected function generateDataStream(LogRecord $record): string { - return (string) $record['formatted']; + return (string) $record->formatted; } /** @@ -372,7 +360,7 @@ private function createSocketResource(): void } else { $resource = $this->fsockopen(); } - if (is_bool($resource)) { + if (\is_bool($resource)) { throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)"); } $this->resource = $resource; @@ -387,18 +375,18 @@ private function setSocketTimeout(): void private function setStreamChunkSize(): void { - if ($this->chunkSize && !$this->streamSetChunkSize()) { + if (null !== $this->chunkSize && false === $this->streamSetChunkSize()) { throw new \UnexpectedValueException("Failed setting chunk size with stream_set_chunk_size()"); } } private function writeToSocket(string $data): void { - $length = strlen($data); + $length = \strlen($data); $sent = 0; $this->lastSentBytes = $sent; while ($this->isConnected() && $sent < $length) { - if (0 == $sent) { + if (0 === $sent) { $chunk = $this->fwrite($data); } else { $chunk = $this->fwrite(substr($data, $sent)); @@ -408,7 +396,7 @@ private function writeToSocket(string $data): void } $sent += $chunk; $socketInfo = $this->streamGetMetadata(); - if (is_array($socketInfo) && $socketInfo['timed_out']) { + if (\is_array($socketInfo) && (bool) $socketInfo['timed_out']) { throw new \RuntimeException("Write timed-out"); } @@ -424,7 +412,7 @@ private function writeToSocket(string $data): void private function writingIsTimedOut(int $sent): bool { // convert to ms - if (0.0 == $this->writingTimeout) { + if (0.0 === $this->writingTimeout) { return false; } @@ -437,7 +425,7 @@ private function writingIsTimedOut(int $sent): bool usleep(100); } - if ((microtime(true) - $this->lastWritingAt) >= $this->writingTimeout) { + if ((microtime(true) - (float) $this->lastWritingAt) >= $this->writingTimeout) { $this->closeSocket(); return true; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php index dcf282b45..1d28b65d4 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php @@ -12,8 +12,9 @@ namespace Monolog\Handler; use Aws\Sqs\SqsClient; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * Writes to any sqs queue. @@ -27,12 +28,10 @@ class SqsHandler extends AbstractProcessingHandler /** 100 KB in bytes - head message size for new error log */ protected const HEAD_MESSAGE_SIZE = 102400; - /** @var SqsClient */ - private $client; - /** @var string */ - private $queueUrl; + private SqsClient $client; + private string $queueUrl; - public function __construct(SqsClient $sqsClient, string $queueUrl, $level = Logger::DEBUG, bool $bubble = true) + public function __construct(SqsClient $sqsClient, string $queueUrl, int|string|Level $level = Level::Debug, bool $bubble = true) { parent::__construct($level, $bubble); @@ -41,16 +40,16 @@ public function __construct(SqsClient $sqsClient, string $queueUrl, $level = Log } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - if (!isset($record['formatted']) || 'string' !== gettype($record['formatted'])) { + if (!isset($record->formatted) || 'string' !== \gettype($record->formatted)) { throw new \InvalidArgumentException('SqsHandler accepts only formatted records as a string' . Utils::getRecordMessageForException($record)); } - $messageBody = $record['formatted']; - if (strlen($messageBody) >= static::MAX_MESSAGE_SIZE) { + $messageBody = $record->formatted; + if (\strlen($messageBody) >= static::MAX_MESSAGE_SIZE) { $messageBody = Utils::substr($messageBody, 0, static::HEAD_MESSAGE_SIZE); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php index 218d43847..c8a648c43 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php @@ -11,8 +11,9 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** * Stores to any stream resource @@ -20,33 +21,24 @@ * Can be used to store into php://stderr, remote and local files, etc. * * @author Jordi Boggiano - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class StreamHandler extends AbstractProcessingHandler { - /** @const int */ protected const MAX_CHUNK_SIZE = 2147483647; - /** @const int 10MB */ + /** 10MB */ protected const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024; - /** @var int */ - protected $streamChunkSize; + protected int $streamChunkSize; /** @var resource|null */ protected $stream; - /** @var ?string */ - protected $url = null; - /** @var ?string */ - private $errorMessage = null; - /** @var ?int */ - protected $filePermission; - /** @var bool */ - protected $useLocking; - /** @var string */ - protected $fileOpenMode; + protected string|null $url = null; + private string|null $errorMessage = null; + protected int|null $filePermission; + protected bool $useLocking; + protected string $fileOpenMode; /** @var true|null */ - private $dirCreated = null; - /** @var bool */ - private $retrying = false; + private bool|null $dirCreated = null; + private bool $retrying = false; + private int|null $inodeUrl = null; /** * @param resource|string $stream If a missing path can't be created, an UnexpectedValueException will be thrown on first write @@ -56,11 +48,11 @@ class StreamHandler extends AbstractProcessingHandler * * @throws \InvalidArgumentException If stream is not a resource or string */ - public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false, $fileOpenMode = 'a') + public function __construct($stream, int|string|Level $level = Level::Debug, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false, string $fileOpenMode = 'a') { parent::__construct($level, $bubble); - if (($phpMemoryLimit = Utils::expandIniShorthandBytes(ini_get('memory_limit'))) !== false) { + if (($phpMemoryLimit = Utils::expandIniShorthandBytes(\ini_get('memory_limit'))) !== false) { if ($phpMemoryLimit > 0) { // use max 10% of allowed memory for the chunk size, and at least 100KB $this->streamChunkSize = min(static::MAX_CHUNK_SIZE, max((int) ($phpMemoryLimit / 10), 100 * 1024)); @@ -73,11 +65,11 @@ public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE; } - if (is_resource($stream)) { + if (\is_resource($stream)) { $this->stream = $stream; stream_set_chunk_size($this->stream, $this->streamChunkSize); - } elseif (is_string($stream)) { + } elseif (\is_string($stream)) { $this->url = Utils::canonicalizePath($stream); } else { throw new \InvalidArgumentException('A stream must either be a resource or a string.'); @@ -89,11 +81,25 @@ public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true } /** - * {@inheritDoc} + * @inheritDoc + */ + public function reset(): void + { + parent::reset(); + + // auto-close on reset to make sure we periodically close the file in long running processes + // as long as they correctly call reset() between jobs + if ($this->url !== null && $this->url !== 'php://memory') { + $this->close(); + } + } + + /** + * @inheritDoc */ public function close(): void { - if ($this->url && is_resource($this->stream)) { + if (null !== $this->url && \is_resource($this->stream)) { fclose($this->stream); } $this->stream = null; @@ -112,37 +118,38 @@ public function getStream() /** * Return the stream URL if it was configured with a URL and not an active resource - * - * @return string|null */ public function getUrl(): ?string { return $this->url; } - /** - * @return int - */ public function getStreamChunkSize(): int { return $this->streamChunkSize; } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - if (!is_resource($this->stream)) { + if ($this->hasUrlInodeWasChanged()) { + $this->close(); + $this->write($record); + + return; + } + + if (!\is_resource($this->stream)) { $url = $this->url; if (null === $url || '' === $url) { throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().' . Utils::getRecordMessageForException($record)); } $this->createDir($url); $this->errorMessage = null; - set_error_handler(function (...$args) { - return $this->customErrorHandler(...$args); - }); + set_error_handler($this->customErrorHandler(...)); + try { $stream = fopen($url, $this->fileOpenMode); if ($this->filePermission !== null) { @@ -151,29 +158,24 @@ protected function write(array $record): void } finally { restore_error_handler(); } - if (!is_resource($stream)) { + if (!\is_resource($stream)) { $this->stream = null; throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url) . Utils::getRecordMessageForException($record)); } stream_set_chunk_size($stream, $this->streamChunkSize); $this->stream = $stream; + $this->inodeUrl = $this->getInodeFromUrl(); } $stream = $this->stream; - if (!is_resource($stream)) { - throw new \LogicException('No stream was opened yet' . Utils::getRecordMessageForException($record)); - } - if ($this->useLocking) { // ignoring errors here, there's not much we can do about them flock($stream, LOCK_EX); } $this->errorMessage = null; - set_error_handler(function (...$args) { - return $this->customErrorHandler(...$args); - }); + set_error_handler($this->customErrorHandler(...)); try { $this->streamWrite($stream, $record); } finally { @@ -202,15 +204,15 @@ protected function write(array $record): void /** * Write to stream * @param resource $stream - * @param array $record - * - * @phpstan-param FormattedRecord $record */ - protected function streamWrite($stream, array $record): void + protected function streamWrite($stream, LogRecord $record): void { - fwrite($stream, (string) $record['formatted']); + fwrite($stream, (string) $record->formatted); } + /** + * @return true + */ private function customErrorHandler(int $code, string $msg): bool { $this->errorMessage = preg_replace('{^(fopen|mkdir|fwrite)\(.*?\): }', '', $msg); @@ -222,11 +224,11 @@ private function getDirFromStream(string $stream): ?string { $pos = strpos($stream, '://'); if ($pos === false) { - return dirname($stream); + return \dirname($stream); } if ('file://' === substr($stream, 0, 7)) { - return dirname(substr($stream, 7)); + return \dirname(substr($stream, 7)); } return null; @@ -235,7 +237,7 @@ private function getDirFromStream(string $stream): ?string private function createDir(string $url): void { // Do not try to create dir if it has already been tried. - if ($this->dirCreated) { + if (true === $this->dirCreated) { return; } @@ -253,4 +255,26 @@ private function createDir(string $url): void } $this->dirCreated = true; } + + private function getInodeFromUrl(): ?int + { + if ($this->url === null || str_starts_with($this->url, 'php://')) { + return null; + } + + $inode = @fileinode($this->url); + + return $inode === false ? null : $inode; + } + + private function hasUrlInodeWasChanged(): bool + { + if ($this->inodeUrl === null || $this->retrying || $this->inodeUrl === $this->getInodeFromUrl()) { + return false; + } + + $this->retrying = true; + + return true; + } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php deleted file mode 100644 index fae925141..000000000 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Utils; -use Monolog\Formatter\FormatterInterface; -use Monolog\Formatter\LineFormatter; -use Swift_Message; -use Swift; - -/** - * SwiftMailerHandler uses Swift_Mailer to send the emails - * - * @author Gyula Sallai - * - * @phpstan-import-type Record from \Monolog\Logger - * @deprecated Since Monolog 2.6. Use SymfonyMailerHandler instead. - */ -class SwiftMailerHandler extends MailHandler -{ - /** @var \Swift_Mailer */ - protected $mailer; - /** @var Swift_Message|callable(string, Record[]): Swift_Message */ - private $messageTemplate; - - /** - * @psalm-param Swift_Message|callable(string, Record[]): Swift_Message $message - * - * @param \Swift_Mailer $mailer The mailer to use - * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced - */ - public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, bool $bubble = true) - { - parent::__construct($level, $bubble); - - @trigger_error('The SwiftMailerHandler is deprecated since Monolog 2.6. Use SymfonyMailerHandler instead.', E_USER_DEPRECATED); - - $this->mailer = $mailer; - $this->messageTemplate = $message; - } - - /** - * {@inheritDoc} - */ - protected function send(string $content, array $records): void - { - $this->mailer->send($this->buildMessage($content, $records)); - } - - /** - * Gets the formatter for the Swift_Message subject. - * - * @param string|null $format The format of the subject - */ - protected function getSubjectFormatter(?string $format): FormatterInterface - { - return new LineFormatter($format); - } - - /** - * Creates instance of Swift_Message to be sent - * - * @param string $content formatted email body to be sent - * @param array $records Log records that formed the content - * @return Swift_Message - * - * @phpstan-param Record[] $records - */ - protected function buildMessage(string $content, array $records): Swift_Message - { - $message = null; - if ($this->messageTemplate instanceof Swift_Message) { - $message = clone $this->messageTemplate; - $message->generateId(); - } elseif (is_callable($this->messageTemplate)) { - $message = ($this->messageTemplate)($content, $records); - } - - if (!$message instanceof Swift_Message) { - $record = reset($records); - throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it' . ($record ? Utils::getRecordMessageForException($record) : '')); - } - - if ($records) { - $subjectFormatter = $this->getSubjectFormatter($message->getSubject()); - $message->setSubject($subjectFormatter->format($this->getHighestRecord($records))); - } - - $mime = 'text/plain'; - if ($this->isHtmlBody($content)) { - $mime = 'text/html'; - } - - $message->setBody($content, $mime); - /** @phpstan-ignore-next-line */ - if (version_compare(Swift::VERSION, '6.0.0', '>=')) { - $message->setDate(new \DateTimeImmutable()); - } else { - /** @phpstan-ignore-next-line */ - $message->setDate(time()); - } - - return $message; - } -} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php index 130e6f1f3..33aa4fd7b 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php @@ -11,7 +11,9 @@ namespace Monolog\Handler; -use Monolog\Logger; +use Closure; +use Monolog\Level; +use Monolog\LogRecord; use Monolog\Utils; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; @@ -23,23 +25,20 @@ * SymfonyMailerHandler uses Symfony's Mailer component to send the emails * * @author Jordi Boggiano - * - * @phpstan-import-type Record from \Monolog\Logger */ class SymfonyMailerHandler extends MailHandler { - /** @var MailerInterface|TransportInterface */ - protected $mailer; - /** @var Email|callable(string, Record[]): Email */ - private $emailTemplate; + protected MailerInterface|TransportInterface $mailer; + /** @var Email|Closure(string, LogRecord[]): Email */ + private Email|Closure $emailTemplate; /** - * @psalm-param Email|callable(string, Record[]): Email $email + * @phpstan-param Email|Closure(string, LogRecord[]): Email $email * * @param MailerInterface|TransportInterface $mailer The mailer to use - * @param callable|Email $email An email template, the subject/body will be replaced + * @param Closure|Email $email An email template, the subject/body will be replaced */ - public function __construct($mailer, $email, $level = Logger::ERROR, bool $bubble = true) + public function __construct($mailer, Email|Closure $email, int|string|Level $level = Level::Error, bool $bubble = true) { parent::__construct($level, $bubble); @@ -68,26 +67,25 @@ protected function getSubjectFormatter(?string $format): FormatterInterface /** * Creates instance of Email to be sent * - * @param string $content formatted email body to be sent - * @param array $records Log records that formed the content - * - * @phpstan-param Record[] $records + * @param string $content formatted email body to be sent + * @param LogRecord[] $records Log records that formed the content */ protected function buildMessage(string $content, array $records): Email { $message = null; if ($this->emailTemplate instanceof Email) { $message = clone $this->emailTemplate; - } elseif (is_callable($this->emailTemplate)) { + } elseif (\is_callable($this->emailTemplate)) { $message = ($this->emailTemplate)($content, $records); } if (!$message instanceof Email) { $record = reset($records); - throw new \InvalidArgumentException('Could not resolve message as instance of Email or a callable returning it' . ($record ? Utils::getRecordMessageForException($record) : '')); + + throw new \InvalidArgumentException('Could not resolve message as instance of Email or a callable returning it' . ($record instanceof LogRecord ? Utils::getRecordMessageForException($record) : '')); } - if ($records) { + if (\count($records) > 0) { $subjectFormatter = $this->getSubjectFormatter($message->getSubject()); $message->subject($subjectFormatter->format($this->getHighestRecord($records))); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php index 1d543b7ec..f3d7674c2 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php @@ -11,8 +11,8 @@ namespace Monolog\Handler; -use Monolog\Logger; -use Monolog\Utils; +use Monolog\Level; +use Monolog\LogRecord; /** * Logs to syslog service. @@ -29,17 +29,14 @@ */ class SyslogHandler extends AbstractSyslogHandler { - /** @var string */ - protected $ident; - /** @var int */ - protected $logopts; + protected string $ident; + protected int $logopts; /** - * @param string $ident * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID */ - public function __construct(string $ident, $facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true, int $logopts = LOG_PID) + public function __construct(string $ident, string|int $facility = LOG_USER, int|string|Level $level = Level::Debug, bool $bubble = true, int $logopts = LOG_PID) { parent::__construct($facility, $level, $bubble); @@ -48,7 +45,7 @@ public function __construct(string $ident, $facility = LOG_USER, $level = Logger } /** - * {@inheritDoc} + * @inheritDoc */ public function close(): void { @@ -56,13 +53,11 @@ public function close(): void } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - if (!openlog($this->ident, $this->logopts, $this->facility)) { - throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"' . Utils::getRecordMessageForException($record)); - } - syslog($this->logLevels[$record['level']], (string) $record['formatted']); + openlog($this->ident, $this->logopts, $this->facility); + syslog($this->toSyslogPriority($record->level), (string) $record->formatted); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php index dbd8ef69d..3ff0bce5f 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php @@ -18,12 +18,9 @@ class UdpSocket { protected const DATAGRAM_MAX_LENGTH = 65023; - /** @var string */ - protected $ip; - /** @var int */ - protected $port; - /** @var resource|Socket|null */ - protected $socket = null; + protected string $ip; + protected int $port; + protected ?Socket $socket = null; public function __construct(string $ip, int $port = 514) { @@ -31,28 +28,20 @@ public function __construct(string $ip, int $port = 514) $this->port = $port; } - /** - * @param string $line - * @param string $header - * @return void - */ - public function write($line, $header = "") + public function write(string $line, string $header = ""): void { $this->send($this->assembleMessage($line, $header)); } public function close(): void { - if (is_resource($this->socket) || $this->socket instanceof Socket) { + if ($this->socket instanceof Socket) { socket_close($this->socket); $this->socket = null; } } - /** - * @return resource|Socket - */ - protected function getSocket() + protected function getSocket(): Socket { if (null !== $this->socket) { return $this->socket; @@ -66,22 +55,22 @@ protected function getSocket() $protocol = IPPROTO_IP; } - $this->socket = socket_create($domain, SOCK_DGRAM, $protocol) ?: null; - if (null === $this->socket) { - throw new \RuntimeException('The UdpSocket to '.$this->ip.':'.$this->port.' could not be opened via socket_create'); + $socket = socket_create($domain, SOCK_DGRAM, $protocol); + if ($socket instanceof Socket) { + return $this->socket = $socket; } - return $this->socket; + throw new \RuntimeException('The UdpSocket to '.$this->ip.':'.$this->port.' could not be opened via socket_create'); } protected function send(string $chunk): void { - socket_sendto($this->getSocket(), $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port); + socket_sendto($this->getSocket(), $chunk, \strlen($chunk), $flags = 0, $this->ip, $this->port); } protected function assembleMessage(string $line, string $header): string { - $chunkSize = static::DATAGRAM_MAX_LENGTH - strlen($header); + $chunkSize = static::DATAGRAM_MAX_LENGTH - \strlen($header); return $header . Utils::substr($line, 0, $chunkSize); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php index deaa19f80..b5e467417 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php @@ -12,8 +12,9 @@ namespace Monolog\Handler; use DateTimeInterface; -use Monolog\Logger; use Monolog\Handler\SyslogUdp\UdpSocket; +use Monolog\Level; +use Monolog\LogRecord; use Monolog\Utils; /** @@ -29,33 +30,31 @@ class SyslogUdpHandler extends AbstractSyslogHandler const RFC5424e = 2; /** @var array */ - private $dateFormats = array( + private array $dateFormats = [ self::RFC3164 => 'M d H:i:s', self::RFC5424 => \DateTime::RFC3339, self::RFC5424e => \DateTime::RFC3339_EXTENDED, - ); + ]; - /** @var UdpSocket */ - protected $socket; - /** @var string */ - protected $ident; + protected UdpSocket $socket; + protected string $ident; /** @var self::RFC* */ - protected $rfc; + protected int $rfc; /** - * @param string $host Either IP/hostname or a path to a unix socket (port must be 0 then) - * @param int $port Port number, or 0 if $host is a unix socket - * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param string $ident Program name or tag for each log message. - * @param int $rfc RFC to format the message for. - * @throws MissingExtensionException + * @param string $host Either IP/hostname or a path to a unix socket (port must be 0 then) + * @param int $port Port number, or 0 if $host is a unix socket + * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param string $ident Program name or tag for each log message. + * @param int $rfc RFC to format the message for. + * @throws MissingExtensionException when there is no socket extension * * @phpstan-param self::RFC* $rfc */ - public function __construct(string $host, int $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424) + public function __construct(string $host, int $port = 514, string|int $facility = LOG_USER, int|string|Level $level = Level::Debug, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424) { - if (!extension_loaded('sockets')) { + if (!\extension_loaded('sockets')) { throw new MissingExtensionException('The sockets extension is required to use the SyslogUdpHandler'); } @@ -67,11 +66,11 @@ public function __construct(string $host, int $port = 514, $facility = LOG_USER, $this->socket = new UdpSocket($host, $port); } - protected function write(array $record): void + protected function write(LogRecord $record): void { - $lines = $this->splitMessageIntoLines($record['formatted']); + $lines = $this->splitMessageIntoLines($record->formatted); - $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']], $record['datetime']); + $header = $this->makeCommonSyslogHeader($this->toSyslogPriority($record->level), $record->datetime); foreach ($lines as $line) { $this->socket->write($line, $header); @@ -89,14 +88,15 @@ public function close(): void */ private function splitMessageIntoLines($message): array { - if (is_array($message)) { + if (\is_array($message)) { $message = implode("\n", $message); } $lines = preg_split('/$\R?^/m', (string) $message, -1, PREG_SPLIT_NO_EMPTY); if (false === $lines) { $pcreErrorCode = preg_last_error(); - throw new \RuntimeException('Could not preg_split: ' . $pcreErrorCode . ' / ' . Utils::pcreLastErrorMessage($pcreErrorCode)); + + throw new \RuntimeException('Could not preg_split: ' . $pcreErrorCode . ' / ' . preg_last_error_msg()); } return $lines; @@ -109,11 +109,13 @@ protected function makeCommonSyslogHeader(int $severity, DateTimeInterface $date { $priority = $severity + $this->facility; - if (!$pid = getmypid()) { + $pid = getmypid(); + if (false === $pid) { $pid = '-'; } - if (!$hostname = gethostname()) { + $hostname = gethostname(); + if (false === $hostname) { $hostname = '-'; } @@ -140,6 +142,8 @@ protected function makeCommonSyslogHeader(int $severity, DateTimeInterface $date /** * Inject your own socket, mainly used for testing + * + * @return $this */ public function setSocket(UdpSocket $socket): self { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php index a6223b795..e6b23bc48 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php @@ -12,24 +12,27 @@ namespace Monolog\Handler; use RuntimeException; -use Monolog\Logger; +use Monolog\Level; use Monolog\Utils; +use Monolog\LogRecord; /** - * Handler send logs to Telegram using Telegram Bot API. + * Handler sends logs to Telegram using Telegram Bot API. * * How to use: - * 1) Create telegram bot with https://telegram.me/BotFather - * 2) Create a telegram channel where logs will be recorded. - * 3) Add created bot from step 1 to the created channel from step 2. + * 1) Create a Telegram bot with https://telegram.me/BotFather; + * 2) Create a Telegram channel or a group where logs will be recorded; + * 3) Add the created bot from step 1 to the created channel/group from step 2. * - * Use telegram bot API key from step 1 and channel name with '@' prefix from step 2 to create instance of TelegramBotHandler + * In order to create an instance of TelegramBotHandler use + * 1. The Telegram bot API key from step 1 + * 2. The channel name with the `@` prefix if you created a public channel (e.g. `@my_public_channel`), + * or the channel ID with the `-100` prefix if you created a private channel (e.g. `-1001234567890`), + * or the group ID from step 2 (e.g. `-1234567890`). * * @link https://core.telegram.org/bots/api * * @author Mazur Alexandr - * - * @phpstan-import-type Record from \Monolog\Logger */ class TelegramBotHandler extends AbstractProcessingHandler { @@ -52,70 +55,70 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * Telegram bot access token provided by BotFather. * Create telegram bot with https://telegram.me/BotFather and use access token from it. - * @var string */ - private $apiKey; + private string $apiKey; /** * Telegram channel name. * Since to start with '@' symbol as prefix. - * @var string */ - private $channel; + private string $channel; /** * The kind of formatting that is used for the message. * See available options at https://core.telegram.org/bots/api#formatting-options * or in AVAILABLE_PARSE_MODES - * @var ?string */ - private $parseMode; + private string|null $parseMode; /** * Disables link previews for links in the message. - * @var ?bool */ - private $disableWebPagePreview; + private bool|null $disableWebPagePreview; /** * Sends the message silently. Users will receive a notification with no sound. - * @var ?bool */ - private $disableNotification; + private bool|null $disableNotification; /** * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages. * False - truncates a message that is too long. - * @var bool */ - private $splitLongMessages; + private bool $splitLongMessages; /** * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests). - * @var bool */ - private $delayBetweenMessages; + private bool $delayBetweenMessages; + + /** + * Telegram message thread id, unique identifier for the target message thread (topic) of the forum; for forum supergroups only + * See how to get the `message_thread_id` https://stackoverflow.com/a/75178418 + */ + private int|null $topic; /** - * @param string $apiKey Telegram bot access token provided by BotFather - * @param string $channel Telegram channel name - * @param bool $splitLongMessages Split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages - * @param bool $delayBetweenMessages Adds delay between sending a split message according to Telegram API - * @throws MissingExtensionException + * @param string $apiKey Telegram bot access token provided by BotFather + * @param string $channel Telegram channel name + * @param bool $splitLongMessages Split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages + * @param bool $delayBetweenMessages Adds delay between sending a split message according to Telegram API + * @param int $topic Telegram message thread id, unique identifier for the target message thread (topic) of the forum + * @throws MissingExtensionException If the curl extension is missing */ public function __construct( string $apiKey, string $channel, - $level = Logger::DEBUG, + $level = Level::Debug, bool $bubble = true, ?string $parseMode = null, ?bool $disableWebPagePreview = null, ?bool $disableNotification = null, bool $splitLongMessages = false, - bool $delayBetweenMessages = false - ) - { - if (!extension_loaded('curl')) { + bool $delayBetweenMessages = false, + ?int $topic = null + ) { + if (!\extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the TelegramBotHandler'); } @@ -128,11 +131,15 @@ public function __construct( $this->disableNotification($disableNotification); $this->splitLongMessages($splitLongMessages); $this->delayBetweenMessages($delayBetweenMessages); + $this->setTopic($topic); } - public function setParseMode(?string $parseMode = null): self + /** + * @return $this + */ + public function setParseMode(string|null $parseMode = null): self { - if ($parseMode !== null && !in_array($parseMode, self::AVAILABLE_PARSE_MODES)) { + if ($parseMode !== null && !\in_array($parseMode, self::AVAILABLE_PARSE_MODES, true)) { throw new \InvalidArgumentException('Unknown parseMode, use one of these: ' . implode(', ', self::AVAILABLE_PARSE_MODES) . '.'); } @@ -141,14 +148,20 @@ public function setParseMode(?string $parseMode = null): self return $this; } - public function disableWebPagePreview(?bool $disableWebPagePreview = null): self + /** + * @return $this + */ + public function disableWebPagePreview(bool|null $disableWebPagePreview = null): self { $this->disableWebPagePreview = $disableWebPagePreview; return $this; } - public function disableNotification(?bool $disableNotification = null): self + /** + * @return $this + */ + public function disableNotification(bool|null $disableNotification = null): self { $this->disableNotification = $disableNotification; @@ -158,7 +171,7 @@ public function disableNotification(?bool $disableNotification = null): self /** * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages. * False - truncates a message that is too long. - * @param bool $splitLongMessages + * * @return $this */ public function splitLongMessages(bool $splitLongMessages = false): self @@ -170,7 +183,7 @@ public function splitLongMessages(bool $splitLongMessages = false): self /** * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests). - * @param bool $delayBetweenMessages + * * @return $this */ public function delayBetweenMessages(bool $delayBetweenMessages = false): self @@ -181,11 +194,20 @@ public function delayBetweenMessages(bool $delayBetweenMessages = false): self } /** - * {@inheritDoc} + * @return $this + */ + public function setTopic(?int $topic = null): self + { + $this->topic = $topic; + + return $this; + } + + /** + * @inheritDoc */ public function handleBatch(array $records): void { - /** @var Record[] $messages */ $messages = []; foreach ($records as $record) { @@ -193,30 +215,28 @@ public function handleBatch(array $records): void continue; } - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } $messages[] = $record; } - if (!empty($messages)) { - $this->send((string)$this->getFormatter()->formatBatch($messages)); + if (\count($messages) > 0) { + $this->send((string) $this->getFormatter()->formatBatch($messages)); } } /** * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->send($record['formatted']); + $this->send($record->formatted); } /** * Send request to @link https://api.telegram.org/bot on SendMessage action. - * @param string $message */ protected function send(string $message): void { @@ -233,21 +253,29 @@ protected function send(string $message): void protected function sendCurl(string $message): void { + if ('' === trim($message)) { + return; + } + $ch = curl_init(); $url = self::BOT_API . $this->apiKey . '/SendMessage'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ + $params = [ 'text' => $message, 'chat_id' => $this->channel, 'parse_mode' => $this->parseMode, 'disable_web_page_preview' => $this->disableWebPagePreview, 'disable_notification' => $this->disableNotification, - ])); + ]; + if ($this->topic !== null) { + $params['message_thread_id'] = $this->topic; + } + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); $result = Curl\Util::execute($ch); - if (!is_string($result)) { + if (!\is_string($result)) { throw new RuntimeException('Telegram API error. Description: No response'); } $result = json_decode($result, true); @@ -259,14 +287,13 @@ protected function sendCurl(string $message): void /** * Handle a message that is too long: truncates or splits into several - * @param string $message * @return string[] */ private function handleMessageLength(string $message): array { - $truncatedMarker = ' (...truncated)'; - if (!$this->splitLongMessages && strlen($message) > self::MAX_MESSAGE_LENGTH) { - return [Utils::substr($message, 0, self::MAX_MESSAGE_LENGTH - strlen($truncatedMarker)) . $truncatedMarker]; + $truncatedMarker = ' (…truncated)'; + if (!$this->splitLongMessages && \strlen($message) > self::MAX_MESSAGE_LENGTH) { + return [Utils::substr($message, 0, self::MAX_MESSAGE_LENGTH - \strlen($truncatedMarker)) . $truncatedMarker]; } return str_split($message, self::MAX_MESSAGE_LENGTH); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php index 0986da270..cb95e79c0 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php @@ -11,8 +11,11 @@ namespace Monolog\Handler; +use Monolog\Level; use Monolog\Logger; use Psr\Log\LogLevel; +use Monolog\LogRecord; +use NoDiscard; /** * Used for testing purposes. @@ -21,14 +24,14 @@ * * @author Jordi Boggiano * - * @method bool hasEmergency($record) - * @method bool hasAlert($record) - * @method bool hasCritical($record) - * @method bool hasError($record) - * @method bool hasWarning($record) - * @method bool hasNotice($record) - * @method bool hasInfo($record) - * @method bool hasDebug($record) + * @method bool hasEmergency(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasAlert(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasCritical(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasError(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasWarning(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasNotice(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasInfo(array{message: string, context?: mixed[]}|string $recordAssertions) + * @method bool hasDebug(array{message: string, context?: mixed[]}|string $recordAssertions) * * @method bool hasEmergencyRecords() * @method bool hasAlertRecords() @@ -39,111 +42,96 @@ * @method bool hasInfoRecords() * @method bool hasDebugRecords() * - * @method bool hasEmergencyThatContains($message) - * @method bool hasAlertThatContains($message) - * @method bool hasCriticalThatContains($message) - * @method bool hasErrorThatContains($message) - * @method bool hasWarningThatContains($message) - * @method bool hasNoticeThatContains($message) - * @method bool hasInfoThatContains($message) - * @method bool hasDebugThatContains($message) + * @method bool hasEmergencyThatContains(string $message) + * @method bool hasAlertThatContains(string $message) + * @method bool hasCriticalThatContains(string $message) + * @method bool hasErrorThatContains(string $message) + * @method bool hasWarningThatContains(string $message) + * @method bool hasNoticeThatContains(string $message) + * @method bool hasInfoThatContains(string $message) + * @method bool hasDebugThatContains(string $message) * - * @method bool hasEmergencyThatMatches($message) - * @method bool hasAlertThatMatches($message) - * @method bool hasCriticalThatMatches($message) - * @method bool hasErrorThatMatches($message) - * @method bool hasWarningThatMatches($message) - * @method bool hasNoticeThatMatches($message) - * @method bool hasInfoThatMatches($message) - * @method bool hasDebugThatMatches($message) + * @method bool hasEmergencyThatMatches(string $regex) + * @method bool hasAlertThatMatches(string $regex) + * @method bool hasCriticalThatMatches(string $regex) + * @method bool hasErrorThatMatches(string $regex) + * @method bool hasWarningThatMatches(string $regex) + * @method bool hasNoticeThatMatches(string $regex) + * @method bool hasInfoThatMatches(string $regex) + * @method bool hasDebugThatMatches(string $regex) * - * @method bool hasEmergencyThatPasses($message) - * @method bool hasAlertThatPasses($message) - * @method bool hasCriticalThatPasses($message) - * @method bool hasErrorThatPasses($message) - * @method bool hasWarningThatPasses($message) - * @method bool hasNoticeThatPasses($message) - * @method bool hasInfoThatPasses($message) - * @method bool hasDebugThatPasses($message) - * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger + * @method bool hasEmergencyThatPasses(callable $predicate) + * @method bool hasAlertThatPasses(callable $predicate) + * @method bool hasCriticalThatPasses(callable $predicate) + * @method bool hasErrorThatPasses(callable $predicate) + * @method bool hasWarningThatPasses(callable $predicate) + * @method bool hasNoticeThatPasses(callable $predicate) + * @method bool hasInfoThatPasses(callable $predicate) + * @method bool hasDebugThatPasses(callable $predicate) */ class TestHandler extends AbstractProcessingHandler { - /** @var Record[] */ - protected $records = []; - /** @var array */ - protected $recordsByLevel = []; - /** @var bool */ - private $skipReset = false; + /** @var LogRecord[] */ + protected array $records = []; + /** @phpstan-var array, LogRecord[]> */ + protected array $recordsByLevel = []; + private bool $skipReset = false; /** - * @return array - * - * @phpstan-return Record[] + * @return array */ - public function getRecords() + #[NoDiscard] + public function getRecords(): array { return $this->records; } - /** - * @return void - */ - public function clear() + public function clear(): void { $this->records = []; $this->recordsByLevel = []; } - /** - * @return void - */ - public function reset() + public function reset(): void { if (!$this->skipReset) { $this->clear(); } } - /** - * @return void - */ - public function setSkipReset(bool $skipReset) + public function setSkipReset(bool $skipReset): void { $this->skipReset = $skipReset; } /** - * @param string|int $level Logging level value or name + * @param int|string|Level|LogLevel::* $level Logging level value or name * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function hasRecords($level): bool + #[NoDiscard] + public function hasRecords(int|string|Level $level): bool { - return isset($this->recordsByLevel[Logger::toMonologLevel($level)]); + return isset($this->recordsByLevel[Logger::toMonologLevel($level)->value]); } /** - * @param string|array $record Either a message string or an array containing message and optionally context keys that will be checked against all records - * @param string|int $level Logging level value or name + * @param string|array $recordAssertions Either a message string or an array containing message and optionally context keys that will be checked against all records * - * @phpstan-param array{message: string, context?: mixed[]}|string $record - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param array{message: string, context?: mixed[]}|string $recordAssertions */ - public function hasRecord($record, $level): bool + #[NoDiscard] + public function hasRecord(string|array $recordAssertions, Level $level): bool { - if (is_string($record)) { - $record = array('message' => $record); + if (\is_string($recordAssertions)) { + $recordAssertions = ['message' => $recordAssertions]; } - return $this->hasRecordThatPasses(function ($rec) use ($record) { - if ($rec['message'] !== $record['message']) { + return $this->hasRecordThatPasses(function (LogRecord $rec) use ($recordAssertions) { + if ($rec->message !== $recordAssertions['message']) { return false; } - if (isset($record['context']) && $rec['context'] !== $record['context']) { + if (isset($recordAssertions['context']) && $rec->context !== $recordAssertions['context']) { return false; } @@ -151,47 +139,32 @@ public function hasRecord($record, $level): bool }, $level); } - /** - * @param string|int $level Logging level value or name - * - * @phpstan-param Level|LevelName|LogLevel::* $level - */ - public function hasRecordThatContains(string $message, $level): bool + #[NoDiscard] + public function hasRecordThatContains(string $message, Level $level): bool { - return $this->hasRecordThatPasses(function ($rec) use ($message) { - return strpos($rec['message'], $message) !== false; - }, $level); + return $this->hasRecordThatPasses(fn (LogRecord $rec) => str_contains($rec->message, $message), $level); } - /** - * @param string|int $level Logging level value or name - * - * @phpstan-param Level|LevelName|LogLevel::* $level - */ - public function hasRecordThatMatches(string $regex, $level): bool + #[NoDiscard] + public function hasRecordThatMatches(string $regex, Level $level): bool { - return $this->hasRecordThatPasses(function (array $rec) use ($regex): bool { - return preg_match($regex, $rec['message']) > 0; - }, $level); + return $this->hasRecordThatPasses(fn (LogRecord $rec) => preg_match($regex, $rec->message) > 0, $level); } /** - * @param string|int $level Logging level value or name - * @return bool - * - * @psalm-param callable(Record, int): mixed $predicate - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param callable(LogRecord, int): mixed $predicate */ - public function hasRecordThatPasses(callable $predicate, $level) + #[NoDiscard] + public function hasRecordThatPasses(callable $predicate, Level $level): bool { $level = Logger::toMonologLevel($level); - if (!isset($this->recordsByLevel[$level])) { + if (!isset($this->recordsByLevel[$level->value])) { return false; } - foreach ($this->recordsByLevel[$level] as $i => $rec) { - if ($predicate($rec, $i)) { + foreach ($this->recordsByLevel[$level->value] as $i => $rec) { + if ((bool) $predicate($rec, $i)) { return true; } } @@ -200,32 +173,31 @@ public function hasRecordThatPasses(callable $predicate, $level) } /** - * {@inheritDoc} + * @inheritDoc */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - $this->recordsByLevel[$record['level']][] = $record; + $this->recordsByLevel[$record->level->value][] = $record; $this->records[] = $record; } /** - * @param string $method - * @param mixed[] $args - * @return bool + * @param mixed[] $args */ - public function __call($method, $args) + #[NoDiscard] + public function __call(string $method, array $args): bool { - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { + if ((bool) preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches)) { $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; - $level = constant('Monolog\Logger::' . strtoupper($matches[2])); + $level = \constant(Level::class.'::' . $matches[2]); $callback = [$this, $genericMethod]; - if (is_callable($callback)) { + if (\is_callable($callback)) { $args[] = $level; - return call_user_func_array($callback, $args); + return \call_user_func_array($callback, $args); } } - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); + throw new \BadMethodCallException('Call to undefined method ' . \get_class($this) . '::' . $method . '()'); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WebRequestRecognizerTrait.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WebRequestRecognizerTrait.php index c81835288..9c12c3d56 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WebRequestRecognizerTrait.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WebRequestRecognizerTrait.php @@ -15,7 +15,6 @@ trait WebRequestRecognizerTrait { /** * Checks if PHP's serving a web request - * @return bool */ protected function isWebRequest(): bool { diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php index b6d3d3b19..932fa70e7 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php @@ -11,30 +11,30 @@ namespace Monolog\Handler; +use Monolog\LogRecord; +use Throwable; + /** * Forwards records to multiple handlers suppressing failures of each handler * and continuing through to give every handler a chance to succeed. * * @author Craig D'Amelio - * - * @phpstan-import-type Record from \Monolog\Logger */ class WhatFailureGroupHandler extends GroupHandler { /** - * {@inheritDoc} + * @inheritDoc */ - public function handle(array $record): bool + public function handle(LogRecord $record): bool { - if ($this->processors) { - /** @var Record $record */ + if (\count($this->processors) > 0) { $record = $this->processRecord($record); } foreach ($this->handlers as $handler) { try { - $handler->handle($record); - } catch (\Throwable $e) { + $handler->handle(clone $record); + } catch (Throwable) { // What failure? } } @@ -43,23 +43,22 @@ public function handle(array $record): bool } /** - * {@inheritDoc} + * @inheritDoc */ public function handleBatch(array $records): void { - if ($this->processors) { - $processed = array(); + if (\count($this->processors) > 0) { + $processed = []; foreach ($records as $record) { $processed[] = $this->processRecord($record); } - /** @var Record[] $records */ $records = $processed; } foreach ($this->handlers as $handler) { try { - $handler->handleBatch($records); - } catch (\Throwable $e) { + $handler->handleBatch(array_map(fn ($record) => clone $record, $records)); + } catch (Throwable) { // What failure? } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php index ddd46d8c5..8841f2f14 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php @@ -13,70 +13,67 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\NormalizerFormatter; -use Monolog\Logger; +use Monolog\Level; +use Monolog\LogRecord; /** * Handler sending logs to Zend Monitor * * @author Christian Bergau * @author Jason Davis - * - * @phpstan-import-type FormattedRecord from AbstractProcessingHandler */ class ZendMonitorHandler extends AbstractProcessingHandler { - /** - * Monolog level / ZendMonitor Custom Event priority map - * - * @var array - */ - protected $levelMap = []; - /** * @throws MissingExtensionException */ - public function __construct($level = Logger::DEBUG, bool $bubble = true) + public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true) { - if (!function_exists('zend_monitor_custom_event')) { + if (!\function_exists('zend_monitor_custom_event')) { throw new MissingExtensionException( 'You must have Zend Server installed with Zend Monitor enabled in order to use this handler' ); } - //zend monitor constants are not defined if zend monitor is not enabled. - $this->levelMap = [ - Logger::DEBUG => \ZEND_MONITOR_EVENT_SEVERITY_INFO, - Logger::INFO => \ZEND_MONITOR_EVENT_SEVERITY_INFO, - Logger::NOTICE => \ZEND_MONITOR_EVENT_SEVERITY_INFO, - Logger::WARNING => \ZEND_MONITOR_EVENT_SEVERITY_WARNING, - Logger::ERROR => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, - Logger::CRITICAL => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, - Logger::ALERT => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, - Logger::EMERGENCY => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, - ]; + parent::__construct($level, $bubble); } /** - * {@inheritDoc} + * Translates Monolog log levels to ZendMonitor levels. */ - protected function write(array $record): void + protected function toZendMonitorLevel(Level $level): int + { + return match ($level) { + Level::Debug => \ZEND_MONITOR_EVENT_SEVERITY_INFO, + Level::Info => \ZEND_MONITOR_EVENT_SEVERITY_INFO, + Level::Notice => \ZEND_MONITOR_EVENT_SEVERITY_INFO, + Level::Warning => \ZEND_MONITOR_EVENT_SEVERITY_WARNING, + Level::Error => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, + Level::Critical => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, + Level::Alert => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, + Level::Emergency => \ZEND_MONITOR_EVENT_SEVERITY_ERROR, + }; + } + + /** + * @inheritDoc + */ + protected function write(LogRecord $record): void { $this->writeZendMonitorCustomEvent( - Logger::getLevelName($record['level']), - $record['message'], - $record['formatted'], - $this->levelMap[$record['level']] + $record->level->getName(), + $record->message, + $record->formatted, + $this->toZendMonitorLevel($record->level) ); } /** * Write to Zend Monitor Events - * @param string $type Text displayed in "Class Name (custom)" field - * @param string $message Text displayed in "Error String" - * @param array $formatted Displayed in Custom Variables tab - * @param int $severity Set the event severity level (-1,0,1) - * - * @phpstan-param FormattedRecord $formatted + * @param string $type Text displayed in "Class Name (custom)" field + * @param string $message Text displayed in "Error String" + * @param array $formatted Displayed in Custom Variables tab + * @param int $severity Set the event severity level (-1,0,1) */ protected function writeZendMonitorCustomEvent(string $type, string $message, array $formatted, int $severity): void { @@ -84,18 +81,10 @@ protected function writeZendMonitorCustomEvent(string $type, string $message, ar } /** - * {@inheritDoc} + * @inheritDoc */ public function getDefaultFormatter(): FormatterInterface { return new NormalizerFormatter(); } - - /** - * @return array - */ - public function getLevelMap(): array - { - return $this->levelMap; - } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/JsonSerializableDateTimeImmutable.php b/lib/Google/vendor/monolog/monolog/src/Monolog/JsonSerializableDateTimeImmutable.php new file mode 100644 index 000000000..de2cc5e96 --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/JsonSerializableDateTimeImmutable.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use DateTimeZone; + +/** + * Overrides default json encoding of date time objects + * + * @author Menno Holtkamp + * @author Jordi Boggiano + */ +class JsonSerializableDateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable +{ + private bool $useMicroseconds; + + public function __construct(bool $useMicroseconds, ?DateTimeZone $timezone = null) + { + $this->useMicroseconds = $useMicroseconds; + + // if you like to use a custom time to pass to Logger::addRecord directly, + // call modify() or setTimestamp() on this instance to change the date after creating it + parent::__construct('now', $timezone); + } + + public function jsonSerialize(): string + { + if ($this->useMicroseconds) { + return $this->format('Y-m-d\TH:i:s.uP'); + } + + return $this->format('Y-m-d\TH:i:sP'); + } + + public function __toString(): string + { + return $this->jsonSerialize(); + } +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Level.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Level.php new file mode 100644 index 000000000..38a74fb8f --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Level.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Psr\Log\LogLevel; + +/** + * Represents the log levels + * + * Monolog supports the logging levels described by RFC 5424 {@see https://datatracker.ietf.org/doc/html/rfc5424} + * but due to BC the severity values used internally are not 0-7. + * + * To get the level name/value out of a Level there are several options: + * + * - Use ->getName() to get the standard Monolog name which is full uppercased (e.g. "DEBUG") + * - Use ->toPsrLogLevel() to get the standard PSR-3 name which is full lowercased (e.g. "debug") + * - Use ->toRFC5424Level() to get the standard RFC 5424 value (e.g. 7 for debug, 0 for emergency) + * - Use ->name to get the enum case's name which is capitalized (e.g. "Debug") + * + * To get the internal value for filtering, if the includes/isLowerThan/isHigherThan methods are + * not enough, you can use ->value to get the enum case's integer value. + */ +enum Level: int +{ + /** + * Detailed debug information + */ + case Debug = 100; + + /** + * Interesting events + * + * Examples: User logs in, SQL logs. + */ + case Info = 200; + + /** + * Uncommon events + */ + case Notice = 250; + + /** + * Exceptional occurrences that are not errors + * + * Examples: Use of deprecated APIs, poor use of an API, + * undesirable things that are not necessarily wrong. + */ + case Warning = 300; + + /** + * Runtime errors + */ + case Error = 400; + + /** + * Critical conditions + * + * Example: Application component unavailable, unexpected exception. + */ + case Critical = 500; + + /** + * Action must be taken immediately + * + * Example: Entire website down, database unavailable, etc. + * This should trigger the SMS alerts and wake you up. + */ + case Alert = 550; + + /** + * Urgent alert. + */ + case Emergency = 600; + + /** + * @param value-of|LogLevel::*|'Debug'|'Info'|'Notice'|'Warning'|'Error'|'Critical'|'Alert'|'Emergency' $name + * @return static + */ + public static function fromName(string $name): self + { + return match (strtolower($name)) { + 'debug' => self::Debug, + 'info' => self::Info, + 'notice' => self::Notice, + 'warning' => self::Warning, + 'error' => self::Error, + 'critical' => self::Critical, + 'alert' => self::Alert, + 'emergency' => self::Emergency, + }; + } + + /** + * @param value-of $value + * @return static + */ + public static function fromValue(int $value): self + { + return self::from($value); + } + + /** + * Returns true if the passed $level is higher or equal to $this + */ + public function includes(Level $level): bool + { + return $this->value <= $level->value; + } + + public function isHigherThan(Level $level): bool + { + return $this->value > $level->value; + } + + public function isLowerThan(Level $level): bool + { + return $this->value < $level->value; + } + + /** + * Returns the monolog standardized all-capitals name of the level + * + * Use this instead of $level->name which returns the enum case name (e.g. Debug vs DEBUG if you use getName()) + * + * @return value-of + */ + public function getName(): string + { + return match ($this) { + self::Debug => 'DEBUG', + self::Info => 'INFO', + self::Notice => 'NOTICE', + self::Warning => 'WARNING', + self::Error => 'ERROR', + self::Critical => 'CRITICAL', + self::Alert => 'ALERT', + self::Emergency => 'EMERGENCY', + }; + } + + /** + * Returns the PSR-3 level matching this instance + * + * @phpstan-return \Psr\Log\LogLevel::* + */ + public function toPsrLogLevel(): string + { + return match ($this) { + self::Debug => LogLevel::DEBUG, + self::Info => LogLevel::INFO, + self::Notice => LogLevel::NOTICE, + self::Warning => LogLevel::WARNING, + self::Error => LogLevel::ERROR, + self::Critical => LogLevel::CRITICAL, + self::Alert => LogLevel::ALERT, + self::Emergency => LogLevel::EMERGENCY, + }; + } + + /** + * Returns the RFC 5424 level matching this instance + * + * @phpstan-return int<0, 7> + */ + public function toRFC5424Level(): int + { + return match ($this) { + self::Debug => 7, + self::Info => 6, + self::Notice => 5, + self::Warning => 4, + self::Error => 3, + self::Critical => 2, + self::Alert => 1, + self::Emergency => 0, + }; + } + + public const VALUES = [ + 100, + 200, + 250, + 300, + 400, + 500, + 550, + 600, + ]; + + public const NAMES = [ + 'DEBUG', + 'INFO', + 'NOTICE', + 'WARNING', + 'ERROR', + 'CRITICAL', + 'ALERT', + 'EMERGENCY', + ]; +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/LogRecord.php b/lib/Google/vendor/monolog/monolog/src/Monolog/LogRecord.php index 702807d71..14c82f304 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/LogRecord.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/LogRecord.php @@ -14,21 +14,114 @@ use ArrayAccess; /** - * Monolog log record interface for forward compatibility with Monolog 3.0 - * - * This is just present in Monolog 2.4+ to allow interoperable code to be written against - * both versions by type-hinting arguments as `array|\Monolog\LogRecord $record` - * - * Do not rely on this interface for other purposes, and do not implement it. + * Monolog log record * * @author Jordi Boggiano - * @template-extends \ArrayAccess<'message'|'level'|'context'|'level_name'|'channel'|'datetime'|'extra'|'formatted', mixed> - * @phpstan-import-type Record from Logger + * @template-implements ArrayAccess<'message'|'level'|'context'|'level_name'|'channel'|'datetime'|'extra'|'formatted', int|string|\DateTimeImmutable|array> */ -interface LogRecord extends \ArrayAccess +class LogRecord implements ArrayAccess { + private const MODIFIABLE_FIELDS = [ + 'extra' => true, + 'formatted' => true, + ]; + + public function __construct( + public readonly \DateTimeImmutable $datetime, + public readonly string $channel, + public readonly Level $level, + public readonly string $message, + /** @var array */ + public readonly array $context = [], + /** @var array */ + public array $extra = [], + public mixed $formatted = null, + ) { + } + + public function offsetSet(mixed $offset, mixed $value): void + { + if ($offset === 'extra') { + if (!\is_array($value)) { + throw new \InvalidArgumentException('extra must be an array'); + } + + $this->extra = $value; + + return; + } + + if ($offset === 'formatted') { + $this->formatted = $value; + + return; + } + + throw new \LogicException('Unsupported operation: setting '.$offset); + } + + public function offsetExists(mixed $offset): bool + { + if ($offset === 'level_name') { + return true; + } + + return isset($this->{$offset}); + } + + public function offsetUnset(mixed $offset): void + { + throw new \LogicException('Unsupported operation'); + } + + public function &offsetGet(mixed $offset): mixed + { + // handle special cases for the level enum + if ($offset === 'level_name') { + // avoid returning readonly props by ref as this is illegal + $copy = $this->level->getName(); + + return $copy; + } + if ($offset === 'level') { + // avoid returning readonly props by ref as this is illegal + $copy = $this->level->value; + + return $copy; + } + + if (isset(self::MODIFIABLE_FIELDS[$offset])) { + return $this->{$offset}; + } + + // avoid returning readonly props by ref as this is illegal + $copy = $this->{$offset}; + + return $copy; + } + /** - * @phpstan-return Record + * @phpstan-return array{message: string, context: mixed[], level: value-of, level_name: value-of, channel: string, datetime: \DateTimeImmutable, extra: mixed[]} */ - public function toArray(): array; + public function toArray(): array + { + return [ + 'message' => $this->message, + 'context' => $this->context, + 'level' => $this->level->value, + 'level_name' => $this->level->getName(), + 'channel' => $this->channel, + 'datetime' => $this->datetime, + 'extra' => $this->extra, + ]; + } + + public function with(mixed ...$args): self + { + foreach (['message', 'context', 'level', 'channel', 'datetime', 'extra'] as $prop) { + $args[$prop] ??= $this->{$prop}; + } + + return new self(...$args); + } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Logger.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Logger.php index bf65d3c53..e545c4487 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Logger.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Logger.php @@ -11,13 +11,17 @@ namespace Monolog; +use Closure; use DateTimeZone; +use Fiber; use Monolog\Handler\HandlerInterface; +use Monolog\Processor\ProcessorInterface; use Psr\Log\LoggerInterface; use Psr\Log\InvalidArgumentException; use Psr\Log\LogLevel; use Throwable; use Stringable; +use WeakMap; /** * Monolog log channel @@ -26,15 +30,14 @@ * and uses them to store records that are added to it. * * @author Jordi Boggiano - * - * @phpstan-type Level Logger::DEBUG|Logger::INFO|Logger::NOTICE|Logger::WARNING|Logger::ERROR|Logger::CRITICAL|Logger::ALERT|Logger::EMERGENCY - * @phpstan-type LevelName 'DEBUG'|'INFO'|'NOTICE'|'WARNING'|'ERROR'|'CRITICAL'|'ALERT'|'EMERGENCY' - * @phpstan-type Record array{message: string, context: mixed[], level: Level, level_name: LevelName, channel: string, datetime: \DateTimeImmutable, extra: mixed[]} + * @final */ class Logger implements LoggerInterface, ResettableInterface { /** * Detailed debug information + * + * @deprecated Use \Monolog\Level::Debug */ public const DEBUG = 100; @@ -42,11 +45,15 @@ class Logger implements LoggerInterface, ResettableInterface * Interesting events * * Examples: User logs in, SQL logs. + * + * @deprecated Use \Monolog\Level::Info */ public const INFO = 200; /** * Uncommon events + * + * @deprecated Use \Monolog\Level::Notice */ public const NOTICE = 250; @@ -55,11 +62,15 @@ class Logger implements LoggerInterface, ResettableInterface * * Examples: Use of deprecated APIs, poor use of an API, * undesirable things that are not necessarily wrong. + * + * @deprecated Use \Monolog\Level::Warning */ public const WARNING = 300; /** * Runtime errors + * + * @deprecated Use \Monolog\Level::Error */ public const ERROR = 400; @@ -67,6 +78,8 @@ class Logger implements LoggerInterface, ResettableInterface * Critical conditions * * Example: Application component unavailable, unexpected exception. + * + * @deprecated Use \Monolog\Level::Critical */ public const CRITICAL = 500; @@ -75,11 +88,15 @@ class Logger implements LoggerInterface, ResettableInterface * * Example: Entire website down, database unavailable, etc. * This should trigger the SMS alerts and wake you up. + * + * @deprecated Use \Monolog\Level::Alert */ public const ALERT = 550; /** * Urgent alert. + * + * @deprecated Use \Monolog\Level::Emergency */ public const EMERGENCY = 600; @@ -88,28 +105,8 @@ class Logger implements LoggerInterface, ResettableInterface * * This is only bumped when API breaks are done and should * follow the major version of the library - * - * @var int - */ - public const API = 2; - - /** - * This is a static variable and not a constant to serve as an extension point for custom levels - * - * @var array $levels Logging levels with the levels as key - * - * @phpstan-var array $levels Logging levels with the levels as key */ - protected static $levels = [ - self::DEBUG => 'DEBUG', - self::INFO => 'INFO', - self::NOTICE => 'NOTICE', - self::WARNING => 'WARNING', - self::ERROR => 'ERROR', - self::CRITICAL => 'CRITICAL', - self::ALERT => 'ALERT', - self::EMERGENCY => 'EMERGENCY', - ]; + public const API = 3; /** * Mapping between levels numbers defined in RFC 5424 and Monolog ones @@ -117,90 +114,71 @@ class Logger implements LoggerInterface, ResettableInterface * @phpstan-var array $rfc_5424_levels */ private const RFC_5424_LEVELS = [ - 7 => self::DEBUG, - 6 => self::INFO, - 5 => self::NOTICE, - 4 => self::WARNING, - 3 => self::ERROR, - 2 => self::CRITICAL, - 1 => self::ALERT, - 0 => self::EMERGENCY, + 7 => Level::Debug, + 6 => Level::Info, + 5 => Level::Notice, + 4 => Level::Warning, + 3 => Level::Error, + 2 => Level::Critical, + 1 => Level::Alert, + 0 => Level::Emergency, ]; - /** - * @var string - */ - protected $name; + protected string $name; /** * The handler stack * - * @var HandlerInterface[] + * @var list */ - protected $handlers; + protected array $handlers; /** * Processors that will process all log records * * To process records of a single handler instead, add the processor on that specific handler * - * @var callable[] + * @var array<(callable(LogRecord): LogRecord)|ProcessorInterface> */ - protected $processors; + protected array $processors; - /** - * @var bool - */ - protected $microsecondTimestamps = true; + protected bool $microsecondTimestamps = true; - /** - * @var DateTimeZone - */ - protected $timezone; + protected DateTimeZone $timezone; - /** - * @var callable|null - */ - protected $exceptionHandler; + protected Closure|null $exceptionHandler = null; /** - * @var int Keeps track of depth to prevent infinite logging loops + * Keeps track of depth to prevent infinite logging loops */ - private $logDepth = 0; + private int $logDepth = 0; /** - * @var \WeakMap<\Fiber, int> Keeps track of depth inside fibers to prevent infinite logging loops + * @var WeakMap, int> Keeps track of depth inside fibers to prevent infinite logging loops */ - private $fiberLogDepth; + private WeakMap $fiberLogDepth; /** - * @var bool Whether to detect infinite logging loops - * + * Whether to detect infinite logging loops * This can be disabled via {@see useLoggingLoopDetection} if you have async handlers that do not play well with this */ - private $detectCycles = true; + private bool $detectCycles = true; /** - * @psalm-param array $processors - * * @param string $name The logging channel, a simple descriptive name that is attached to all log records - * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. + * @param list $handlers Optional stack of handlers, the first one in the array is called first, etc. * @param callable[] $processors Optional array of processors * @param DateTimeZone|null $timezone Optional timezone, if not provided date_default_timezone_get() will be used + * + * @phpstan-param array<(callable(LogRecord): LogRecord)|ProcessorInterface> $processors */ - public function __construct(string $name, array $handlers = [], array $processors = [], ?DateTimeZone $timezone = null) + public function __construct(string $name, array $handlers = [], array $processors = [], DateTimeZone|null $timezone = null) { $this->name = $name; $this->setHandlers($handlers); $this->processors = $processors; - $this->timezone = $timezone ?: new DateTimeZone(date_default_timezone_get() ?: 'UTC'); - - if (\PHP_VERSION_ID >= 80100) { - // Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412 - /** @var \WeakMap<\Fiber, int> $fiberLogDepth */ - $fiberLogDepth = new \WeakMap(); - $this->fiberLogDepth = $fiberLogDepth; - } + $this->timezone = $timezone ?? new DateTimeZone(date_default_timezone_get()); + $this->fiberLogDepth = new \WeakMap(); } public function getName(): string @@ -210,6 +188,8 @@ public function getName(): string /** * Return a new cloned instance with the name changed + * + * @return static */ public function withName(string $name): self { @@ -221,6 +201,8 @@ public function withName(string $name): self /** * Pushes a handler on to the stack. + * + * @return $this */ public function pushHandler(HandlerInterface $handler): self { @@ -236,7 +218,7 @@ public function pushHandler(HandlerInterface $handler): self */ public function popHandler(): HandlerInterface { - if (!$this->handlers) { + if (0 === \count($this->handlers)) { throw new \LogicException('You tried to pop from an empty handler stack.'); } @@ -248,7 +230,8 @@ public function popHandler(): HandlerInterface * * If a map is passed, keys will be ignored. * - * @param HandlerInterface[] $handlers + * @param list $handlers + * @return $this */ public function setHandlers(array $handlers): self { @@ -261,7 +244,7 @@ public function setHandlers(array $handlers): self } /** - * @return HandlerInterface[] + * @return list */ public function getHandlers(): array { @@ -270,8 +253,11 @@ public function getHandlers(): array /** * Adds a processor on to the stack. + * + * @phpstan-param ProcessorInterface|(callable(LogRecord): LogRecord) $callback + * @return $this */ - public function pushProcessor(callable $callback): self + public function pushProcessor(ProcessorInterface|callable $callback): self { array_unshift($this->processors, $callback); @@ -281,12 +267,12 @@ public function pushProcessor(callable $callback): self /** * Removes the processor on top of the stack and returns it. * + * @phpstan-return ProcessorInterface|(callable(LogRecord): LogRecord) * @throws \LogicException If empty processor stack - * @return callable */ public function popProcessor(): callable { - if (!$this->processors) { + if (0 === \count($this->processors)) { throw new \LogicException('You tried to pop from an empty processor stack.'); } @@ -295,6 +281,7 @@ public function popProcessor(): callable /** * @return callable[] + * @phpstan-return array */ public function getProcessors(): array { @@ -310,7 +297,8 @@ public function getProcessors(): array * by default. This function lets you disable them though in case you want * to suppress microseconds from the output. * - * @param bool $micro True to use microtime() to create timestamps + * @param bool $micro True to use microtime() to create timestamps + * @return $this */ public function useMicrosecondTimestamps(bool $micro): self { @@ -319,6 +307,9 @@ public function useMicrosecondTimestamps(bool $micro): self return $this; } + /** + * @return $this + */ public function useLoggingLoopDetection(bool $detectCycles): self { $this->detectCycles = $detectCycles; @@ -329,25 +320,24 @@ public function useLoggingLoopDetection(bool $detectCycles): self /** * Adds a log record. * - * @param int $level The logging level (a Monolog or RFC 5424 level) - * @param string $message The log message - * @param mixed[] $context The log context - * @param DateTimeImmutable $datetime Optional log date to log into the past or future - * @return bool Whether the record has been processed + * @param int $level The logging level (a Monolog or RFC 5424 level) + * @param string $message The log message + * @param mixed[] $context The log context + * @param JsonSerializableDateTimeImmutable|null $datetime Optional log date to log into the past or future * - * @phpstan-param Level $level + * @return bool Whether the record has been processed + * + * @phpstan-param value-of|Level $level */ - public function addRecord(int $level, string $message, array $context = [], ?DateTimeImmutable $datetime = null): bool + public function addRecord(int|Level $level, string $message, array $context = [], JsonSerializableDateTimeImmutable|null $datetime = null): bool { - if (isset(self::RFC_5424_LEVELS[$level])) { + if (\is_int($level) && isset(self::RFC_5424_LEVELS[$level])) { $level = self::RFC_5424_LEVELS[$level]; } if ($this->detectCycles) { - if (\PHP_VERSION_ID >= 80100 && $fiber = \Fiber::getCurrent()) { - // @phpstan-ignore offsetAssign.dimType - $this->fiberLogDepth[$fiber] = $this->fiberLogDepth[$fiber] ?? 0; - $logDepth = ++$this->fiberLogDepth[$fiber]; + if (null !== ($fiber = Fiber::getCurrent())) { + $logDepth = $this->fiberLogDepth[$fiber] = ($this->fiberLogDepth[$fiber] ?? 0) + 1; } else { $logDepth = ++$this->logDepth; } @@ -357,37 +347,37 @@ public function addRecord(int $level, string $message, array $context = [], ?Dat if ($logDepth === 3) { $this->warning('A possible infinite logging loop was detected and aborted. It appears some of your handler code is triggering logging, see the previous log record for a hint as to what may be the cause.'); + return false; } elseif ($logDepth >= 5) { // log depth 4 is let through, so we can log the warning above return false; } try { - $record = null; + $recordInitialized = \count($this->processors) === 0; + + $record = new LogRecord( + datetime: $datetime ?? new JsonSerializableDateTimeImmutable($this->microsecondTimestamps, $this->timezone), + channel: $this->name, + level: self::toMonologLevel($level), + message: $message, + context: $context, + extra: [], + ); + $handled = false; foreach ($this->handlers as $handler) { - if (null === $record) { - // skip creating the record as long as no handler is going to handle it - if (!$handler->isHandling(['level' => $level])) { + if (false === $recordInitialized) { + // skip initializing the record as long as no handler is going to handle it + if (!$handler->isHandling($record)) { continue; } - $levelName = static::getLevelName($level); - - $record = [ - 'message' => $message, - 'context' => $context, - 'level' => $level, - 'level_name' => $levelName, - 'channel' => $this->name, - 'datetime' => $datetime ?? new DateTimeImmutable($this->microsecondTimestamps, $this->timezone), - 'extra' => [], - ]; - try { foreach ($this->processors as $processor) { $record = $processor($record); } + $recordInitialized = true; } catch (Throwable $e) { $this->handleException($e, $record); @@ -395,9 +385,10 @@ public function addRecord(int $level, string $message, array $context = [], ?Dat } } - // once the record exists, send it to all handlers as long as the bubbling chain is not interrupted + // once the record is initialized, send it to all handlers as long as the bubbling chain is not interrupted try { - if (true === $handler->handle($record)) { + $handled = true; + if (true === $handler->handle(clone $record)) { break; } } catch (Throwable $e) { @@ -406,6 +397,8 @@ public function addRecord(int $level, string $message, array $context = [], ?Dat return true; } } + + return $handled; } finally { if ($this->detectCycles) { if (isset($fiber)) { @@ -415,8 +408,6 @@ public function addRecord(int $level, string $message, array $context = [], ?Dat } } } - - return null !== $record; } /** @@ -462,77 +453,77 @@ public function reset(): void } /** - * Gets all supported logging levels. + * Gets the name of the logging level as a string. * - * @return array Assoc array with human-readable level names => level codes. - * @phpstan-return array - */ - public static function getLevels(): array - { - return array_flip(static::$levels); - } - - /** - * Gets the name of the logging level. + * This still returns a string instead of a Level for BC, but new code should not rely on this method. * * @throws \Psr\Log\InvalidArgumentException If level is not defined * - * @phpstan-param Level $level - * @phpstan-return LevelName + * @phpstan-param value-of|Level $level + * @phpstan-return value-of + * + * @deprecated Since 3.0, use {@see toMonologLevel} or {@see \Monolog\Level->getName()} instead */ - public static function getLevelName(int $level): string + public static function getLevelName(int|Level $level): string { - if (!isset(static::$levels[$level])) { - throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels))); - } - - return static::$levels[$level]; + return self::toMonologLevel($level)->getName(); } /** * Converts PSR-3 levels to Monolog ones if necessary * - * @param string|int $level Level number (monolog) or name (PSR-3) + * @param int|string|Level|LogLevel::* $level Level number (monolog) or name (PSR-3) * @throws \Psr\Log\InvalidArgumentException If level is not defined * - * @phpstan-param Level|LevelName|LogLevel::* $level - * @phpstan-return Level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public static function toMonologLevel($level): int + public static function toMonologLevel(string|int|Level $level): Level { - if (is_string($level)) { + if ($level instanceof Level) { + return $level; + } + + if (\is_string($level)) { if (is_numeric($level)) { - /** @phpstan-ignore-next-line */ - return intval($level); + $levelEnum = Level::tryFrom((int) $level); + if ($levelEnum === null) { + throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', Level::NAMES + Level::VALUES)); + } + + return $levelEnum; } - // Contains chars of all log levels and avoids using strtoupper() which may have + // Contains first char of all log levels and avoids using strtoupper() which may have // strange results depending on locale (for example, "i" will become "İ" in Turkish locale) - $upper = strtr($level, 'abcdefgilmnortuwy', 'ABCDEFGILMNORTUWY'); - if (defined(__CLASS__.'::'.$upper)) { - return constant(__CLASS__ . '::' . $upper); + $upper = strtr(substr($level, 0, 1), 'dinweca', 'DINWECA') . strtolower(substr($level, 1)); + if (\defined(Level::class.'::'.$upper)) { + return \constant(Level::class . '::' . $upper); } - throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels) + static::$levels)); + throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', Level::NAMES + Level::VALUES)); } - if (!is_int($level)) { - throw new InvalidArgumentException('Level "'.var_export($level, true).'" is not defined, use one of: '.implode(', ', array_keys(static::$levels) + static::$levels)); + $levelEnum = Level::tryFrom($level); + if ($levelEnum === null) { + throw new InvalidArgumentException('Level "'.var_export($level, true).'" is not defined, use one of: '.implode(', ', Level::NAMES + Level::VALUES)); } - return $level; + return $levelEnum; } /** * Checks whether the Logger has a handler that listens on the given level * - * @phpstan-param Level $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function isHandling(int $level): bool + public function isHandling(int|string|Level $level): bool { - $record = [ - 'level' => $level, - ]; + $record = new LogRecord( + datetime: new JsonSerializableDateTimeImmutable($this->microsecondTimestamps, $this->timezone), + channel: $this->name, + message: '', + level: self::toMonologLevel($level), + ); foreach ($this->handlers as $handler) { if ($handler->isHandling($record)) { @@ -546,16 +537,18 @@ public function isHandling(int $level): bool /** * Set a custom exception handler that will be called if adding a new record fails * - * The callable will receive an exception object and the record that failed to be logged + * The Closure will receive an exception object and the record that failed to be logged + * + * @return $this */ - public function setExceptionHandler(?callable $callback): self + public function setExceptionHandler(Closure|null $callback): self { $this->exceptionHandler = $callback; return $this; } - public function getExceptionHandler(): ?callable + public function getExceptionHandler(): Closure|null { return $this->exceptionHandler; } @@ -569,19 +562,21 @@ public function getExceptionHandler(): ?callable * @param string|Stringable $message The log message * @param mixed[] $context The log context * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param Level|LogLevel::* $level */ - public function log($level, $message, array $context = []): void + public function log($level, string|\Stringable $message, array $context = []): void { - if (!is_int($level) && !is_string($level)) { - throw new \InvalidArgumentException('$level is expected to be a string or int'); - } + if (!$level instanceof Level) { + if (!\is_string($level) && !\is_int($level)) { + throw new \InvalidArgumentException('$level is expected to be a string, int or '.Level::class.' instance'); + } - if (isset(self::RFC_5424_LEVELS[$level])) { - $level = self::RFC_5424_LEVELS[$level]; - } + if (isset(self::RFC_5424_LEVELS[$level])) { + $level = self::RFC_5424_LEVELS[$level]; + } - $level = static::toMonologLevel($level); + $level = static::toMonologLevel($level); + } $this->addRecord($level, (string) $message, $context); } @@ -594,9 +589,9 @@ public function log($level, $message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function debug($message, array $context = []): void + public function debug(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::DEBUG, (string) $message, $context); + $this->addRecord(Level::Debug, (string) $message, $context); } /** @@ -607,9 +602,9 @@ public function debug($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function info($message, array $context = []): void + public function info(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::INFO, (string) $message, $context); + $this->addRecord(Level::Info, (string) $message, $context); } /** @@ -620,9 +615,9 @@ public function info($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function notice($message, array $context = []): void + public function notice(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::NOTICE, (string) $message, $context); + $this->addRecord(Level::Notice, (string) $message, $context); } /** @@ -633,9 +628,9 @@ public function notice($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function warning($message, array $context = []): void + public function warning(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::WARNING, (string) $message, $context); + $this->addRecord(Level::Warning, (string) $message, $context); } /** @@ -646,9 +641,9 @@ public function warning($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function error($message, array $context = []): void + public function error(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::ERROR, (string) $message, $context); + $this->addRecord(Level::Error, (string) $message, $context); } /** @@ -659,9 +654,9 @@ public function error($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function critical($message, array $context = []): void + public function critical(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::CRITICAL, (string) $message, $context); + $this->addRecord(Level::Critical, (string) $message, $context); } /** @@ -672,9 +667,9 @@ public function critical($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function alert($message, array $context = []): void + public function alert(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::ALERT, (string) $message, $context); + $this->addRecord(Level::Alert, (string) $message, $context); } /** @@ -685,13 +680,15 @@ public function alert($message, array $context = []): void * @param string|Stringable $message The log message * @param mixed[] $context The log context */ - public function emergency($message, array $context = []): void + public function emergency(string|\Stringable $message, array $context = []): void { - $this->addRecord(static::EMERGENCY, (string) $message, $context); + $this->addRecord(Level::Emergency, (string) $message, $context); } /** * Sets the timezone to be used for the timestamp of log records. + * + * @return $this */ public function setTimezone(DateTimeZone $tz): self { @@ -711,13 +708,10 @@ public function getTimezone(): DateTimeZone /** * Delegates exception management to the custom exception handler, * or throws the exception if no custom handler is set. - * - * @param array $record - * @phpstan-param Record $record */ - protected function handleException(Throwable $e, array $record): void + protected function handleException(Throwable $e, LogRecord $record): void { - if (!$this->exceptionHandler) { + if (null === $this->exceptionHandler) { throw $e; } @@ -752,11 +746,6 @@ public function __unserialize(array $data): void } } - if (\PHP_VERSION_ID >= 80100) { - // Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412 - /** @var \WeakMap<\Fiber, int> $fiberLogDepth */ - $fiberLogDepth = new \WeakMap(); - $this->fiberLogDepth = $fiberLogDepth; - } + $this->fiberLogDepth = new \WeakMap(); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ClosureContextProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ClosureContextProcessor.php new file mode 100644 index 000000000..514b35478 --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ClosureContextProcessor.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\LogRecord; + +/** + * Generates a context from a Closure if the Closure is the only value + * in the context + * + * It helps reduce the performance impact of debug logs if they do + * need to create lots of context information. If this processor is added + * on the correct handler the context data will only be generated + * when the logs are actually logged to that handler, which is useful when + * using FingersCrossedHandler or other filtering handlers to conditionally + * log records. + */ +class ClosureContextProcessor implements ProcessorInterface +{ + public function __invoke(LogRecord $record): LogRecord + { + $context = $record->context; + if (isset($context[0]) && 1 === \count($context) && $context[0] instanceof \Closure) { + try { + $context = $context[0](); + } catch (\Throwable $e) { + $context = [ + 'error_on_context_generation' => $e->getMessage(), + 'exception' => $e, + ]; + } + + if (!\is_array($context)) { + $context = [$context]; + } + + $record = $record->with(context: $context); + } + + return $record; + } +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php index 8166bdca2..6b25505de 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php @@ -11,46 +11,44 @@ namespace Monolog\Processor; +use Monolog\Level; use Monolog\Logger; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Injects Git branch and Git commit SHA in all records * * @author Nick Otter * @author Jordi Boggiano - * - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class GitProcessor implements ProcessorInterface { - /** @var int */ - private $level; + private Level $level; /** @var array{branch: string, commit: string}|array|null */ private static $cache = null; /** - * @param string|int $level The minimum logging level at which this Processor will be triggered + * @param int|string|Level|LogLevel::* $level The minimum logging level at which this Processor will be triggered * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function __construct($level = Logger::DEBUG) + public function __construct(int|string|Level $level = Level::Debug) { $this->level = Logger::toMonologLevel($level); } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { // return if the level is not high enough - if ($record['level'] < $this->level) { + if ($record->level->isLowerThan($this->level)) { return $record; } - $record['extra']['git'] = self::getGitInfo(); + $record->extra['git'] = self::getGitInfo(); return $record; } @@ -60,12 +58,12 @@ public function __invoke(array $record): array */ private static function getGitInfo(): array { - if (self::$cache) { + if (self::$cache !== null) { return self::$cache; } - $branches = `git branch -v --no-abbrev`; - if ($branches && preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) { + $branches = shell_exec('git branch -v --no-abbrev'); + if (\is_string($branches) && 1 === preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) { return self::$cache = [ 'branch' => $matches[1], 'commit' => $matches[2], diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/HostnameProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/HostnameProcessor.php index 91fda7d6d..cba6e0963 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/HostnameProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/HostnameProcessor.php @@ -11,13 +11,14 @@ namespace Monolog\Processor; +use Monolog\LogRecord; + /** * Injects value of gethostname in all records */ class HostnameProcessor implements ProcessorInterface { - /** @var string */ - private static $host; + private static string $host; public function __construct() { @@ -25,11 +26,11 @@ public function __construct() } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { - $record['extra']['hostname'] = self::$host; + $record->extra['hostname'] = self::$host; return $record; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php index a32e76b21..b942dc055 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php @@ -11,8 +11,10 @@ namespace Monolog\Processor; +use Monolog\Level; use Monolog\Logger; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Injects line/file:class/function where the log message came from @@ -24,44 +26,45 @@ * triggered the FingersCrossedHandler. * * @author Jordi Boggiano - * - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class IntrospectionProcessor implements ProcessorInterface { - /** @var int */ - private $level; - /** @var string[] */ - private $skipClassesPartials; - /** @var int */ - private $skipStackFramesCount; + protected Level $level; + /** @var string[] */ - private $skipFunctions = [ + protected array $skipClassesPartials; + + protected int $skipStackFramesCount; + + protected const SKIP_FUNCTIONS = [ 'call_user_func', 'call_user_func_array', ]; + protected const SKIP_CLASSES = [ + 'Monolog\\', + ]; + /** - * @param string|int $level The minimum logging level at which this Processor will be triggered - * @param string[] $skipClassesPartials + * @param string|int|Level $level The minimum logging level at which this Processor will be triggered + * @param string[] $skipClassesPartials * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function __construct($level = Logger::DEBUG, array $skipClassesPartials = [], int $skipStackFramesCount = 0) + public function __construct(int|string|Level $level = Level::Debug, array $skipClassesPartials = [], int $skipStackFramesCount = 0) { $this->level = Logger::toMonologLevel($level); - $this->skipClassesPartials = array_merge(['Monolog\\'], $skipClassesPartials); + $this->skipClassesPartials = array_merge(static::SKIP_CLASSES, $skipClassesPartials); $this->skipStackFramesCount = $skipStackFramesCount; } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { // return if the level is not high enough - if ($record['level'] < $this->level) { + if ($record->level->isLowerThan($this->level)) { return $record; } @@ -83,7 +86,7 @@ public function __invoke(array $record): array continue 2; } } - } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) { + } elseif (\in_array($trace[$i]['function'], self::SKIP_FUNCTIONS, true)) { $i++; continue; @@ -95,14 +98,14 @@ public function __invoke(array $record): array $i += $this->skipStackFramesCount; // we should have the call source now - $record['extra'] = array_merge( - $record['extra'], + $record->extra = array_merge( + $record->extra, [ - 'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null, - 'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null, - 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, - 'callType' => isset($trace[$i]['type']) ? $trace[$i]['type'] : null, - 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, + 'file' => $trace[$i - 1]['file'] ?? null, + 'line' => $trace[$i - 1]['line'] ?? null, + 'class' => $trace[$i]['class'] ?? null, + 'callType' => $trace[$i]['type'] ?? null, + 'function' => $trace[$i]['function'] ?? null, ] ); @@ -110,7 +113,7 @@ public function __invoke(array $record): array } /** - * @param array[] $trace + * @param array $trace */ private function isTraceClassOrSkippedFunction(array $trace, int $index): bool { @@ -118,6 +121,6 @@ private function isTraceClassOrSkippedFunction(array $trace, int $index): bool return false; } - return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions); + return isset($trace[$index]['class']) || \in_array($trace[$index]['function'], self::SKIP_FUNCTIONS, true); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/LoadAverageProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/LoadAverageProcessor.php new file mode 100644 index 000000000..762ed9142 --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/LoadAverageProcessor.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\LogRecord; + +/** + * Injects sys_getloadavg in all records @see https://www.php.net/manual/en/function.sys-getloadavg.php + * + * @author Johan Vlaar + */ +class LoadAverageProcessor implements ProcessorInterface +{ + public const LOAD_1_MINUTE = 0; + public const LOAD_5_MINUTE = 1; + public const LOAD_15_MINUTE = 2; + + private const AVAILABLE_LOAD = [ + self::LOAD_1_MINUTE, + self::LOAD_5_MINUTE, + self::LOAD_15_MINUTE, + ]; + + /** + * @var int + */ + protected $avgSystemLoad; + + /** + * @param self::LOAD_* $avgSystemLoad + */ + public function __construct(int $avgSystemLoad = self::LOAD_1_MINUTE) + { + if (!\in_array($avgSystemLoad, self::AVAILABLE_LOAD, true)) { + throw new \InvalidArgumentException(sprintf('Invalid average system load: `%s`', $avgSystemLoad)); + } + $this->avgSystemLoad = $avgSystemLoad; + } + + /** + * {@inheritDoc} + */ + public function __invoke(LogRecord $record): LogRecord + { + if (!\function_exists('sys_getloadavg')) { + return $record; + } + $usage = sys_getloadavg(); + if (false === $usage) { + return $record; + } + + $record->extra['load_average'] = $usage[$this->avgSystemLoad]; + + return $record; + } +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php index 37c756fcb..adc32c65d 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php @@ -11,6 +11,8 @@ namespace Monolog\Processor; +use Monolog\LogRecord; + /** * Injects memory_get_peak_usage in all records * @@ -20,9 +22,9 @@ class MemoryPeakUsageProcessor extends MemoryProcessor { /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { $usage = memory_get_peak_usage($this->realUsage); @@ -30,7 +32,7 @@ public function __invoke(array $record): array $usage = $this->formatBytes($usage); } - $record['extra']['memory_peak_usage'] = $usage; + $record->extra['memory_peak_usage'] = $usage; return $record; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php index 227deb7c8..f808e51b4 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php @@ -21,12 +21,12 @@ abstract class MemoryProcessor implements ProcessorInterface /** * @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported. */ - protected $realUsage; + protected bool $realUsage; /** * @var bool If true, then format memory size to human readable string (MB, KB, B depending on size) */ - protected $useFormatting; + protected bool $useFormatting; /** * @param bool $realUsage Set this to true to get the real size of memory allocated from system. @@ -41,7 +41,6 @@ public function __construct(bool $realUsage = true, bool $useFormatting = true) /** * Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is * - * @param int $bytes * @return string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as int */ protected function formatBytes(int $bytes) diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php index e141921e9..a814b1df3 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php @@ -11,6 +11,8 @@ namespace Monolog\Processor; +use Monolog\LogRecord; + /** * Injects memory_get_usage in all records * @@ -20,9 +22,9 @@ class MemoryUsageProcessor extends MemoryProcessor { /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { $usage = memory_get_usage($this->realUsage); @@ -30,7 +32,7 @@ public function __invoke(array $record): array $usage = $this->formatBytes($usage); } - $record['extra']['memory_usage'] = $usage; + $record->extra['memory_usage'] = $usage; return $record; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php index d4a628f55..3076a3d8c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php @@ -11,45 +11,43 @@ namespace Monolog\Processor; +use Monolog\Level; use Monolog\Logger; use Psr\Log\LogLevel; +use Monolog\LogRecord; /** * Injects Hg branch and Hg revision number in all records * * @author Jonathan A. Schweder - * - * @phpstan-import-type LevelName from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger */ class MercurialProcessor implements ProcessorInterface { - /** @var Level */ - private $level; + private Level $level; /** @var array{branch: string, revision: string}|array|null */ private static $cache = null; /** - * @param int|string $level The minimum logging level at which this Processor will be triggered + * @param int|string|Level $level The minimum logging level at which this Processor will be triggered * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function __construct($level = Logger::DEBUG) + public function __construct(int|string|Level $level = Level::Debug) { $this->level = Logger::toMonologLevel($level); } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { // return if the level is not high enough - if ($record['level'] < $this->level) { + if ($record->level->isLowerThan($this->level)) { return $record; } - $record['extra']['hg'] = self::getMercurialInfo(); + $record->extra['hg'] = self::getMercurialInfo(); return $record; } @@ -59,18 +57,23 @@ public function __invoke(array $record): array */ private static function getMercurialInfo(): array { - if (self::$cache) { + if (self::$cache !== null) { return self::$cache; } - $result = explode(' ', trim(`hg id -nb`)); - - if (count($result) >= 3) { + $result = explode(' ', trim((string) shell_exec('hg id -nb'))); + if (\count($result) >= 3) { return self::$cache = [ 'branch' => $result[1], 'revision' => $result[2], ]; } + if (\count($result) === 2) { + return self::$cache = [ + 'branch' => $result[1], + 'revision' => $result[0], + ]; + } return self::$cache = []; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php index 3b939a951..bb9a52243 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php @@ -11,6 +11,8 @@ namespace Monolog\Processor; +use Monolog\LogRecord; + /** * Adds value of getmypid into records * @@ -19,11 +21,11 @@ class ProcessIdProcessor implements ProcessorInterface { /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { - $record['extra']['process_id'] = getmypid(); + $record->extra['process_id'] = getmypid(); return $record; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php index 5defb7eb4..ebe41fc20 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php @@ -11,20 +11,17 @@ namespace Monolog\Processor; +use Monolog\LogRecord; + /** * An optional interface to allow labelling Monolog processors. * * @author Nicolas Grekas - * - * @phpstan-import-type Record from \Monolog\Logger */ interface ProcessorInterface { /** - * @return array The processed record - * - * @phpstan-param Record $record - * @phpstan-return Record + * @return LogRecord The processed record */ - public function __invoke(array $record); + public function __invoke(LogRecord $record); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php index e7c12176a..291361d2f 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php @@ -12,6 +12,7 @@ namespace Monolog\Processor; use Monolog\Utils; +use Monolog\LogRecord; /** * Processes a record's message according to PSR-3 rules @@ -24,11 +25,9 @@ class PsrLogMessageProcessor implements ProcessorInterface { public const SIMPLE_DATE = "Y-m-d\TH:i:s.uP"; - /** @var string|null */ - private $dateFormat; + private ?string $dateFormat; - /** @var bool */ - private $removeUsedContextFields; + private bool $removeUsedContextFields; /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format @@ -41,48 +40,48 @@ public function __construct(?string $dateFormat = null, bool $removeUsedContextF } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { - if (false === strpos($record['message'], '{')) { + if (false === strpos($record->message, '{')) { return $record; } $replacements = []; - foreach ($record['context'] as $key => $val) { + $context = $record->context; + + foreach ($context as $key => $val) { $placeholder = '{' . $key . '}'; - if (strpos($record['message'], $placeholder) === false) { + if (strpos($record->message, $placeholder) === false) { continue; } - if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) { + if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, "__toString"))) { $replacements[$placeholder] = $val; } elseif ($val instanceof \DateTimeInterface) { - if (!$this->dateFormat && $val instanceof \Monolog\DateTimeImmutable) { + if (null === $this->dateFormat && $val instanceof \Monolog\JsonSerializableDateTimeImmutable) { // handle monolog dates using __toString if no specific dateFormat was asked for // so that it follows the useMicroseconds flag $replacements[$placeholder] = (string) $val; } else { - $replacements[$placeholder] = $val->format($this->dateFormat ?: static::SIMPLE_DATE); + $replacements[$placeholder] = $val->format($this->dateFormat ?? static::SIMPLE_DATE); } } elseif ($val instanceof \UnitEnum) { $replacements[$placeholder] = $val instanceof \BackedEnum ? $val->value : $val->name; - } elseif (is_object($val)) { + } elseif (\is_object($val)) { $replacements[$placeholder] = '[object '.Utils::getClass($val).']'; - } elseif (is_array($val)) { + } elseif (\is_array($val)) { $replacements[$placeholder] = 'array'.Utils::jsonEncode($val, null, true); } else { - $replacements[$placeholder] = '['.gettype($val).']'; + $replacements[$placeholder] = '['.\gettype($val).']'; } if ($this->removeUsedContextFields) { - unset($record['context'][$key]); + unset($context[$key]); } } - $record['message'] = strtr($record['message'], $replacements); - - return $record; + return $record->with(message: strtr($record->message, $replacements), context: $context); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php index 80f18747a..f4e41ce20 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php @@ -11,6 +11,8 @@ namespace Monolog\Processor; +use Monolog\LogRecord; + /** * Adds a tags array into record * @@ -19,7 +21,7 @@ class TagProcessor implements ProcessorInterface { /** @var string[] */ - private $tags; + private array $tags; /** * @param string[] $tags @@ -30,7 +32,8 @@ public function __construct(array $tags = []) } /** - * @param string[] $tags + * @param string[] $tags + * @return $this */ public function addTags(array $tags = []): self { @@ -40,7 +43,8 @@ public function addTags(array $tags = []): self } /** - * @param string[] $tags + * @param string[] $tags + * @return $this */ public function setTags(array $tags = []): self { @@ -50,11 +54,11 @@ public function setTags(array $tags = []): self } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { - $record['extra']['tags'] = $this->tags; + $record->extra['tags'] = $this->tags; return $record; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php index a27b74dbf..261e65389 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php @@ -12,6 +12,7 @@ namespace Monolog\Processor; use Monolog\ResettableInterface; +use Monolog\LogRecord; /** * Adds a unique identifier into records @@ -20,9 +21,12 @@ */ class UidProcessor implements ProcessorInterface, ResettableInterface { - /** @var string */ - private $uid; + /** @var non-empty-string */ + private string $uid; + /** + * @param int<1, 32> $length + */ public function __construct(int $length = 7) { if ($length > 32 || $length < 1) { @@ -33,11 +37,11 @@ public function __construct(int $length = 7) } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { - $record['extra']['uid'] = $this->uid; + $record->extra['uid'] = $this->uid; return $record; } @@ -47,11 +51,15 @@ public function getUid(): string return $this->uid; } - public function reset() + public function reset(): void { - $this->uid = $this->generateUid(strlen($this->uid)); + $this->uid = $this->generateUid(\strlen($this->uid)); } + /** + * @param positive-int $length + * @return non-empty-string + */ private function generateUid(int $length): string { return substr(bin2hex(random_bytes((int) ceil($length / 2))), 0, $length); diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php index 887f4d396..b78385e0c 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php @@ -11,6 +11,9 @@ namespace Monolog\Processor; +use ArrayAccess; +use Monolog\LogRecord; + /** * Injects url/method and remote IP of the current web request in all records * @@ -19,9 +22,9 @@ class WebProcessor implements ProcessorInterface { /** - * @var array|\ArrayAccess + * @var array|ArrayAccess */ - protected $serverData; + protected array|ArrayAccess $serverData; /** * Default fields @@ -30,7 +33,7 @@ class WebProcessor implements ProcessorInterface * * @var array */ - protected $extraFields = [ + protected array $extraFields = [ 'url' => 'REQUEST_URI', 'ip' => 'REMOTE_ADDR', 'http_method' => 'REQUEST_METHOD', @@ -40,17 +43,15 @@ class WebProcessor implements ProcessorInterface ]; /** - * @param array|\ArrayAccess|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data - * @param array|array|null $extraFields Field names and the related key inside $serverData to be added (or just a list of field names to use the default configured $serverData mapping). If not provided it defaults to: [url, ip, http_method, server, referrer] + unique_id if present in server data + * @param array|ArrayAccess|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data + * @param array|array|null $extraFields Field names and the related key inside $serverData to be added (or just a list of field names to use the default configured $serverData mapping). If not provided it defaults to: [url, ip, http_method, server, referrer] + unique_id if present in server data */ - public function __construct($serverData = null, ?array $extraFields = null) + public function __construct(array|ArrayAccess|null $serverData = null, array|null $extraFields = null) { if (null === $serverData) { $this->serverData = &$_SERVER; - } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) { - $this->serverData = $serverData; } else { - throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.'); + $this->serverData = $serverData; } $defaultEnabled = ['url', 'ip', 'http_method', 'server', 'referrer']; @@ -64,7 +65,7 @@ public function __construct($serverData = null, ?array $extraFields = null) } if (isset($extraFields[0])) { foreach (array_keys($this->extraFields) as $fieldName) { - if (!in_array($fieldName, $extraFields)) { + if (!\in_array($fieldName, $extraFields, true)) { unset($this->extraFields[$fieldName]); } } @@ -74,9 +75,9 @@ public function __construct($serverData = null, ?array $extraFields = null) } /** - * {@inheritDoc} + * @inheritDoc */ - public function __invoke(array $record): array + public function __invoke(LogRecord $record): LogRecord { // skip processing if for some reason request data // is not present (CLI or wonky SAPIs) @@ -84,11 +85,14 @@ public function __invoke(array $record): array return $record; } - $record['extra'] = $this->appendExtraFields($record['extra']); + $record->extra = $this->appendExtraFields($record->extra); return $record; } + /** + * @return $this + */ public function addExtraField(string $extraName, string $serverName): self { $this->extraFields[$extraName] = $serverName; diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Registry.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Registry.php index ae94ae6cc..2ef2edceb 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Registry.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Registry.php @@ -42,7 +42,7 @@ class Registry * * @var Logger[] */ - private static $loggers = []; + private static array $loggers = []; /** * Adds new logging channel to the registry @@ -51,11 +51,10 @@ class Registry * @param string|null $name Name of the logging channel ($logger->getName() by default) * @param bool $overwrite Overwrite instance in the registry if the given name already exists? * @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists - * @return void */ - public static function addLogger(Logger $logger, ?string $name = null, bool $overwrite = false) + public static function addLogger(Logger $logger, ?string $name = null, bool $overwrite = false): void { - $name = $name ?: $logger->getName(); + $name = $name ?? $logger->getName(); if (isset(self::$loggers[$name]) && !$overwrite) { throw new InvalidArgumentException('Logger with the given name already exists'); @@ -110,7 +109,7 @@ public static function clear(): void * @param string $name Name of the requested Logger instance * @throws \InvalidArgumentException If named Logger instance is not in the registry */ - public static function getInstance($name): Logger + public static function getInstance(string $name): Logger { if (!isset(self::$loggers[$name])) { throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name)); @@ -127,7 +126,7 @@ public static function getInstance($name): Logger * @throws \InvalidArgumentException If named Logger instance is not in the registry * @return Logger Requested instance of Logger */ - public static function __callStatic($name, $arguments) + public static function __callStatic(string $name, array $arguments): Logger { return self::getInstance($name); } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/ResettableInterface.php b/lib/Google/vendor/monolog/monolog/src/Monolog/ResettableInterface.php index 2c5fd7851..4983a6b35 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/ResettableInterface.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/ResettableInterface.php @@ -27,8 +27,5 @@ */ interface ResettableInterface { - /** - * @return void - */ - public function reset(); + public function reset(): void; } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/SignalHandler.php b/lib/Google/vendor/monolog/monolog/src/Monolog/SignalHandler.php index d730eea3a..b6a69fca0 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/SignalHandler.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/SignalHandler.php @@ -19,21 +19,17 @@ * Monolog POSIX signal handler * * @author Robert Gust-Bardon - * - * @phpstan-import-type Level from \Monolog\Logger - * @phpstan-import-type LevelName from \Monolog\Logger */ class SignalHandler { - /** @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; /** @var array SIG_DFL, SIG_IGN or previous callable */ - private $previousSignalHandler = []; - /** @var array */ - private $signalLevelMap = []; + private array $previousSignalHandler = []; + /** @var array */ + private array $signalLevelMap = []; /** @var array */ - private $signalRestartSyscalls = []; + private array $signalRestartSyscalls = []; public function __construct(LoggerInterface $logger) { @@ -41,21 +37,18 @@ public function __construct(LoggerInterface $logger) } /** - * @param int|string $level Level or level name - * @param bool $callPrevious - * @param bool $restartSyscalls - * @param bool|null $async + * @param int|string|Level $level Level or level name * @return $this * - * @phpstan-param Level|LevelName|LogLevel::* $level + * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ - public function registerSignalHandler(int $signo, $level = LogLevel::CRITICAL, bool $callPrevious = true, bool $restartSyscalls = true, ?bool $async = true): self + public function registerSignalHandler(int $signo, int|string|Level $level = LogLevel::CRITICAL, bool $callPrevious = true, bool $restartSyscalls = true, ?bool $async = true): self { - if (!extension_loaded('pcntl') || !function_exists('pcntl_signal')) { + if (!\extension_loaded('pcntl') || !\function_exists('pcntl_signal')) { return $this; } - $level = Logger::toMonologLevel($level); + $level = Logger::toMonologLevel($level)->toPsrLogLevel(); if ($callPrevious) { $handler = pcntl_signal_get_handler($signo); @@ -80,13 +73,13 @@ public function registerSignalHandler(int $signo, $level = LogLevel::CRITICAL, b */ public function handleSignal(int $signo, $siginfo = null): void { + /** @var array $signals */ static $signals = []; - if (!$signals && extension_loaded('pcntl')) { + if (\count($signals) === 0 && \extension_loaded('pcntl')) { $pcntl = new ReflectionExtension('pcntl'); - // HHVM 3.24.2 returns an empty array. - foreach ($pcntl->getConstants() ?: get_defined_constants(true)['Core'] as $name => $value) { - if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && is_int($value)) { + foreach ($pcntl->getConstants() as $name => $value) { + if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && \is_int($value)) { $signals[$value] = $name; } } @@ -102,8 +95,8 @@ public function handleSignal(int $signo, $siginfo = null): void } if ($this->previousSignalHandler[$signo] === SIG_DFL) { - if (extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_sigprocmask') && function_exists('pcntl_signal_dispatch') - && extension_loaded('posix') && function_exists('posix_getpid') && function_exists('posix_kill') + if (\extension_loaded('pcntl') && \function_exists('pcntl_signal') && \function_exists('pcntl_sigprocmask') && \function_exists('pcntl_signal_dispatch') + && \extension_loaded('posix') && \function_exists('posix_getpid') && \function_exists('posix_kill') ) { $restartSyscalls = $this->signalRestartSyscalls[$signo] ?? true; pcntl_signal($signo, SIG_DFL, $restartSyscalls); @@ -113,7 +106,7 @@ public function handleSignal(int $signo, $siginfo = null): void pcntl_sigprocmask(SIG_SETMASK, $oldset); pcntl_signal($signo, [$this, 'handleSignal'], $restartSyscalls); } - } elseif (is_callable($this->previousSignalHandler[$signo])) { + } elseif (\is_callable($this->previousSignalHandler[$signo])) { $this->previousSignalHandler[$signo]($signo, $siginfo); } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Test/MonologTestCase.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Test/MonologTestCase.php new file mode 100644 index 000000000..34c7724ea --- /dev/null +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Test/MonologTestCase.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Test; + +use Monolog\Level; +use Monolog\Logger; +use Monolog\LogRecord; +use Monolog\JsonSerializableDateTimeImmutable; +use Monolog\Formatter\FormatterInterface; +use Psr\Log\LogLevel; + +/** + * Lets you easily generate log records and a dummy formatter for testing purposes + * + * @author Jordi Boggiano + */ +class MonologTestCase extends \PHPUnit\Framework\TestCase +{ + /** + * @param array $context + * @param array $extra + * + * @phpstan-param value-of|value-of|Level|LogLevel::* $level + */ + protected function getRecord(int|string|Level $level = Level::Warning, string|\Stringable $message = 'test', array $context = [], string $channel = 'test', \DateTimeImmutable $datetime = new JsonSerializableDateTimeImmutable(true), array $extra = []): LogRecord + { + return new LogRecord( + message: (string) $message, + context: $context, + level: Logger::toMonologLevel($level), + channel: $channel, + datetime: $datetime, + extra: $extra, + ); + } + + /** + * @phpstan-return list + */ + protected function getMultipleRecords(): array + { + return [ + $this->getRecord(Level::Debug, 'debug message 1'), + $this->getRecord(Level::Debug, 'debug message 2'), + $this->getRecord(Level::Info, 'information'), + $this->getRecord(Level::Warning, 'warning'), + $this->getRecord(Level::Error, 'error'), + ]; + } + + protected function getIdentityFormatter(): FormatterInterface + { + $formatter = $this->createMock(FormatterInterface::class); + $formatter->expects(self::any()) + ->method('format') + ->willReturnCallback(function ($record) { + return $record->message; + }); + + return $formatter; + } +} diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Test/TestCase.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Test/TestCase.php index bc0b425ea..bf40b31fc 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Test/TestCase.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Test/TestCase.php @@ -11,75 +11,13 @@ namespace Monolog\Test; -use Monolog\Logger; -use Monolog\DateTimeImmutable; -use Monolog\Formatter\FormatterInterface; - /** * Lets you easily generate log records and a dummy formatter for testing purposes * * @author Jordi Boggiano * - * @phpstan-import-type Record from \Monolog\Logger - * @phpstan-import-type Level from \Monolog\Logger - * - * @internal feel free to reuse this to test your own handlers, this is marked internal to avoid issues with PHPStorm https://github.com/Seldaek/monolog/issues/1677 + * @deprecated use MonologTestCase instead. */ -class TestCase extends \PHPUnit\Framework\TestCase +class TestCase extends MonologTestCase { - public function tearDown(): void - { - parent::tearDown(); - - if (isset($this->handler)) { - unset($this->handler); - } - } - - /** - * @param mixed[] $context - * - * @return array Record - * - * @phpstan-param Level $level - * @phpstan-return Record - */ - protected function getRecord(int $level = Logger::WARNING, string $message = 'test', array $context = []): array - { - return [ - 'message' => (string) $message, - 'context' => $context, - 'level' => $level, - 'level_name' => Logger::getLevelName($level), - 'channel' => 'test', - 'datetime' => new DateTimeImmutable(true), - 'extra' => [], - ]; - } - - /** - * @phpstan-return Record[] - */ - protected function getMultipleRecords(): array - { - return [ - $this->getRecord(Logger::DEBUG, 'debug message 1'), - $this->getRecord(Logger::DEBUG, 'debug message 2'), - $this->getRecord(Logger::INFO, 'information'), - $this->getRecord(Logger::WARNING, 'warning'), - $this->getRecord(Logger::ERROR, 'error'), - ]; - } - - protected function getIdentityFormatter(): FormatterInterface - { - $formatter = $this->createMock(FormatterInterface::class); - $formatter->expects($this->any()) - ->method('format') - ->will($this->returnCallback(function ($record) { - return $record['message']; - })); - - return $formatter; - } } diff --git a/lib/Google/vendor/monolog/monolog/src/Monolog/Utils.php b/lib/Google/vendor/monolog/monolog/src/Monolog/Utils.php index d4ff4c040..153801553 100644 --- a/lib/Google/vendor/monolog/monolog/src/Monolog/Utils.php +++ b/lib/Google/vendor/monolog/monolog/src/Monolog/Utils.php @@ -19,12 +19,12 @@ public static function getClass(object $object): string { $class = \get_class($object); - if (false === ($pos = \strpos($class, "@anonymous\0"))) { + if (false === ($pos = strpos($class, "@anonymous\0"))) { return $class; } - if (false === ($parent = \get_parent_class($class))) { - return \substr($class, 0, $pos + 10); + if (false === ($parent = get_parent_class($class))) { + return substr($class, 0, $pos + 10); } return $parent . '@anonymous'; @@ -32,11 +32,11 @@ public static function getClass(object $object): string public static function substr(string $string, int $start, ?int $length = null): string { - if (extension_loaded('mbstring')) { + if (\extension_loaded('mbstring')) { return mb_strcut($string, $start, $length); } - return substr($string, $start, (null === $length) ? strlen($string) : $length); + return substr($string, $start, (null === $length) ? \strlen($string) : $length); } /** @@ -119,10 +119,10 @@ public static function handleJsonError(int $code, $data, ?int $encodeFlags = nul self::throwEncodeError($code, $data); } - if (is_string($data)) { + if (\is_string($data)) { self::detectAndCleanUtf8($data); - } elseif (is_array($data)) { - array_walk_recursive($data, array('Monolog\Utils', 'detectAndCleanUtf8')); + } elseif (\is_array($data)) { + array_walk_recursive($data, ['Monolog\Utils', 'detectAndCleanUtf8']); } else { self::throwEncodeError($code, $data); } @@ -140,52 +140,22 @@ public static function handleJsonError(int $code, $data, ?int $encodeFlags = nul return $json; } - /** - * @internal - */ - public static function pcreLastErrorMessage(int $code): string - { - if (PHP_VERSION_ID >= 80000) { - return preg_last_error_msg(); - } - - $constants = (get_defined_constants(true))['pcre']; - $constants = array_filter($constants, function ($key) { - return substr($key, -6) == '_ERROR'; - }, ARRAY_FILTER_USE_KEY); - - $constants = array_flip($constants); - - return $constants[$code] ?? 'UNDEFINED_ERROR'; - } - /** * Throws an exception according to a given code with a customized message * * @param int $code return code of json_last_error function * @param mixed $data data that was meant to be encoded * @throws \RuntimeException - * - * @return never */ - private static function throwEncodeError(int $code, $data): void + private static function throwEncodeError(int $code, $data): never { - switch ($code) { - case JSON_ERROR_DEPTH: - $msg = 'Maximum stack depth exceeded'; - break; - case JSON_ERROR_STATE_MISMATCH: - $msg = 'Underflow or the modes mismatch'; - break; - case JSON_ERROR_CTRL_CHAR: - $msg = 'Unexpected control character found'; - break; - case JSON_ERROR_UTF8: - $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded'; - break; - default: - $msg = 'Unknown error'; - } + $msg = match ($code) { + JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', + JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', + JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', + JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', + default => 'Unknown error', + }; throw new \RuntimeException('JSON encoding failed: '.$msg.'. Encoding: '.var_export($data, true)); } @@ -207,17 +177,20 @@ private static function throwEncodeError(int $code, $data): void */ private static function detectAndCleanUtf8(&$data): void { - if (is_string($data) && !preg_match('//u', $data)) { + if (\is_string($data) && preg_match('//u', $data) !== 1) { $data = preg_replace_callback( '/[\x80-\xFF]+/', - function ($m) { - return function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]); + function (array $m): string { + return \function_exists('mb_convert_encoding') + ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') + : (\function_exists('utf8_encode') ? utf8_encode($m[0]) : ''); }, $data ); - if (!is_string($data)) { + if (!\is_string($data)) { $pcreErrorCode = preg_last_error(); - throw new \RuntimeException('Failed to preg_replace_callback: ' . $pcreErrorCode . ' / ' . self::pcreLastErrorMessage($pcreErrorCode)); + + throw new \RuntimeException('Failed to preg_replace_callback: ' . $pcreErrorCode . ' / ' . preg_last_error_msg()); } $data = str_replace( ['¤', '¦', '¨', '´', '¸', '¼', '½', '¾'], @@ -230,12 +203,12 @@ function ($m) { /** * Converts a string with a valid 'memory_limit' format, to bytes. * - * @param string|false $val - * @return int|false Returns an integer representing bytes. Returns FALSE in case of error. + * @param string|false $val + * @return int|false Returns an integer representing bytes. Returns FALSE in case of error. */ public static function expandIniShorthandBytes($val) { - if (!is_string($val)) { + if (!\is_string($val)) { return false; } @@ -244,7 +217,7 @@ public static function expandIniShorthandBytes($val) return (int) $val; } - if (!preg_match('/^\s*(?\d+)(?:\.\d+)?\s*(?[gmk]?)\s*$/i', $val, $match)) { + if (!(bool) preg_match('/^\s*(?\d+)(?:\.\d+)?\s*(?[gmk]?)\s*$/i', $val, $match)) { return false; } @@ -252,8 +225,10 @@ public static function expandIniShorthandBytes($val) switch (strtolower($match['unit'])) { case 'g': $val *= 1024; + // no break case 'm': $val *= 1024; + // no break case 'k': $val *= 1024; } @@ -261,24 +236,22 @@ public static function expandIniShorthandBytes($val) return $val; } - /** - * @param array $record - */ - public static function getRecordMessageForException(array $record): string + public static function getRecordMessageForException(LogRecord $record): string { $context = ''; $extra = ''; + try { - if ($record['context']) { - $context = "\nContext: " . json_encode($record['context']); + if (\count($record->context) > 0) { + $context = "\nContext: " . json_encode($record->context, JSON_THROW_ON_ERROR); } - if ($record['extra']) { - $extra = "\nExtra: " . json_encode($record['extra']); + if (\count($record->extra) > 0) { + $extra = "\nExtra: " . json_encode($record->extra, JSON_THROW_ON_ERROR); } } catch (\Throwable $e) { // noop } - return "\nThe exception occurred while attempting to log: " . $record['message'] . $context . $extra; + return "\nThe exception occurred while attempting to log: " . $record->message . $context . $extra; } } diff --git a/lib/Google/vendor/paragonie/random_compat/build-phar.sh b/lib/Google/vendor/paragonie/random_compat/build-phar.sh new file mode 100755 index 000000000..b4a5ba31c --- /dev/null +++ b/lib/Google/vendor/paragonie/random_compat/build-phar.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +basedir=$( dirname $( readlink -f ${BASH_SOURCE[0]} ) ) + +php -dphar.readonly=0 "$basedir/other/build_phar.php" $* \ No newline at end of file diff --git a/lib/Google/vendor/phpseclib/phpseclib/BACKERS.md b/lib/Google/vendor/phpseclib/phpseclib/BACKERS.md index cafcf60a2..d9406b287 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/BACKERS.md +++ b/lib/Google/vendor/phpseclib/phpseclib/BACKERS.md @@ -16,4 +16,5 @@ phpseclib ongoing development is made possible by [Tidelift](https://tidelift.co - [istiak-tridip](https://github.com/istiak-tridip) - [Anna Filina](https://github.com/afilina) - [blakemckeeby](https://github.com/blakemckeeby) -- [ssddanbrown](https://github.com/ssddanbrown) \ No newline at end of file +- [ssddanbrown](https://github.com/ssddanbrown) +- Stefan Beck \ No newline at end of file diff --git a/lib/Google/vendor/phpseclib/phpseclib/README.md b/lib/Google/vendor/phpseclib/phpseclib/README.md index c26edd49b..416e56ba6 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/README.md +++ b/lib/Google/vendor/phpseclib/phpseclib/README.md @@ -51,7 +51,7 @@ SSH-2, SFTP, X.509, an arbitrary-precision integer arithmetic library, Ed25519 / * PHP4 compatible * Composer compatible (PSR-0 autoloading) * Install using Composer: `composer require phpseclib/phpseclib:~1.0` -* [Download 1.0.24 as ZIP](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.24.zip/download) +* [Download 1.0.25 as ZIP](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.25.zip/download) ## Security contact information @@ -75,6 +75,8 @@ Need Support? ## Additional Thanks - Allan Simon +- [Anna Filina](https://afilina.com/) +- delovelady - [ChargeOver](https://chargeover.com/) - diff --git a/lib/Google/vendor/phpseclib/phpseclib/SECURITY.md b/lib/Google/vendor/phpseclib/phpseclib/SECURITY.md new file mode 100644 index 000000000..f8368b669 --- /dev/null +++ b/lib/Google/vendor/phpseclib/phpseclib/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +| Version | Supported | +| ------- | ------------------ | +| 1.0.x | :white_check_mark: | +| 2.0.x | :white_check_mark: | +| 3.0.x | :white_check_mark: | + +## Reporting a Vulnerability + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. \ No newline at end of file diff --git a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php index bf51bcf76..ee9b992ed 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php +++ b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php @@ -141,7 +141,7 @@ public static function load($key, $password = '') $result['hash'] = str_replace('id-', '', $params['hashAlgorithm']['algorithm']); $result['MGFHash'] = str_replace('id-', '', $params['maskGenAlgorithm']['parameters']['algorithm']); if (isset($params['saltLength'])) { - $result['saltLength'] = (int) $params['saltLength']->toString(); + $result['saltLength'] = (int) "$params[saltLength]"; } if (isset($key['meta'])) { diff --git a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php index 685a7cde0..a5e0c4ba9 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php +++ b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php @@ -789,7 +789,10 @@ public static function asn1map(array $decoded, $mapping, $special = []) case self::TYPE_ENUMERATED: $temp = $decoded['content']; if (isset($mapping['implicit'])) { - $temp = new BigInteger($decoded['content'], -256); + $temp = new BigInteger($temp, -256); + } + if (!$temp instanceof BigInteger) { + return false; } if (isset($mapping['mapping'])) { $temp = $temp->toString(); diff --git a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php index 7b6283002..5fd78ecca 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php +++ b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php @@ -154,7 +154,7 @@ public function toBytes($twos_compliment = false) while (bccomp($current, '0', 0) > 0) { $temp = self::BCMOD_THREE_PARAMS ? bcmod($current, '16777216', 0) : bcmod($current, '16777216'); - $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value; + $value = chr($temp >> 16) . chr(($temp >> 8) & 0xFF) . chr($temp & 0xFF) . $value; $current = bcdiv($current, '16777216', 0); } diff --git a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php new file mode 100644 index 000000000..ae5c8ec08 --- /dev/null +++ b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php @@ -0,0 +1,303 @@ + + * login('username', 'password')) { + * exit('Login Failed'); + * } + * + * echo $scp->exec('pwd') . "\r\n"; + * $scp->put('filename.ext', 'hello, world!'); + * echo $scp->exec('ls -latr'); + * ?> + * + * + * @author Jim Wigginton + * @copyright 2009 Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +namespace phpseclib3\Net; + +use phpseclib3\Common\Functions\Strings; +use phpseclib3\Exception\FileNotFoundException; + +/** + * Pure-PHP implementations of SCP. + * + * @author Jim Wigginton + */ +class SCP extends SSH2 +{ + /** + * Reads data from a local file. + * + * @see \phpseclib3\Net\SCP::put() + */ + const SOURCE_LOCAL_FILE = 1; + /** + * Reads data from a string. + * + * @see \phpseclib3\Net\SCP::put() + */ + // this value isn't really used anymore but i'm keeping it reserved for historical reasons + const SOURCE_STRING = 2; + /** + * SCP.php doesn't support SOURCE_CALLBACK because, with that one, we don't know the size, in advance + */ + //const SOURCE_CALLBACK = 16; + + /** + * Error information + * + * @see self::getSCPErrors() + * @see self::getLastSCPError() + * @var array + */ + private $scp_errors = []; + + /** + * Uploads a file to the SCP server. + * + * By default, \phpseclib\Net\SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. + * So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SCP::get(), you will get a file, twelve bytes + * long, containing 'filename.ext' as its contents. + * + * Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will + * contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how + * large $remote_file will be, as well. + * + * Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take + * care of that, yourself. + * + * @param string $remote_file + * @param string $data + * @param int $mode + * @param callable $callback + * @return bool + * @access public + */ + public function put($remote_file, $data, $mode = self::SOURCE_STRING, $callback = null) + { + if (!($this->bitmap & self::MASK_LOGIN)) { + return false; + } + + if (empty($remote_file)) { + // remote file cannot be blank + return false; + } + + if (!$this->exec('scp -t ' . escapeshellarg($remote_file), false)) { // -t = to + return false; + } + + $temp = $this->get_channel_packet(self::CHANNEL_EXEC, true); + if ($temp !== chr(0)) { + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + + $packet_size = $this->packet_size_client_to_server[self::CHANNEL_EXEC] - 4; + + $remote_file = basename($remote_file); + + $dataCallback = false; + switch (true) { + case is_resource($data): + $mode = $mode & ~self::SOURCE_LOCAL_FILE; + $info = stream_get_meta_data($data); + if (isset($info['wrapper_type']) && $info['wrapper_type'] == 'PHP' && $info['stream_type'] == 'Input') { + $fp = fopen('php://memory', 'w+'); + stream_copy_to_stream($data, $fp); + rewind($fp); + } else { + $fp = $data; + } + break; + case $mode & self::SOURCE_LOCAL_FILE: + if (!is_file($data)) { + throw new FileNotFoundException("$data is not a valid file"); + } + $fp = @fopen($data, 'rb'); + if (!$fp) { + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + } + + if (isset($fp)) { + $stat = fstat($fp); + $size = !empty($stat) ? $stat['size'] : 0; + } else { + $size = strlen($data); + } + + $sent = 0; + $size = $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size; + + $temp = 'C0644 ' . $size . ' ' . $remote_file . "\n"; + $this->send_channel_packet(self::CHANNEL_EXEC, $temp); + + $temp = $this->get_channel_packet(self::CHANNEL_EXEC, true); + if ($temp !== chr(0)) { + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + + $sent = 0; + while ($sent < $size) { + $temp = $mode & self::SOURCE_STRING ? substr($data, $sent, $packet_size) : fread($fp, $packet_size); + $this->send_channel_packet(self::CHANNEL_EXEC, $temp); + $sent += strlen($temp); + + if (is_callable($callback)) { + call_user_func($callback, $sent); + } + } + $this->close_channel(self::CHANNEL_EXEC, true); + + if ($mode != self::SOURCE_STRING) { + fclose($fp); + } + + return true; + } + + /** + * Downloads a file from the SCP server. + * + * Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if + * the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the + * operation + * + * @param string $remote_file + * @param string $local_file + * @return mixed + * @access public + */ + public function get($remote_file, $local_file = null, $progressCallback = null) + { + if (!($this->bitmap & self::MASK_LOGIN)) { + return false; + } + + if (!$this->exec('scp -f ' . escapeshellarg($remote_file), false)) { // -f = from + return false; + } + + $this->send_channel_packet(self::CHANNEL_EXEC, chr(0)); + + $info = $this->get_channel_packet(self::CHANNEL_EXEC, true); + // per https://goteleport.com/blog/scp-familiar-simple-insecure-slow/ non-zero responses mean there are errors + if ($info[0] === chr(1) || $info[0] == chr(2)) { + $type = $info[0] === chr(1) ? 'warning' : 'error'; + $this->scp_errors[] = "$type: " . substr($info, 1); + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + + $this->send_channel_packet(self::CHANNEL_EXEC, chr(0)); + + if (!preg_match('#(?[^ ]+) (?\d+) (?.+)#', rtrim($info), $info)) { + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + + $fclose_check = false; + if (is_resource($local_file)) { + $fp = $local_file; + } elseif (!is_null($local_file)) { + $fp = @fopen($local_file, 'wb'); + if (!$fp) { + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + $fclose_check = true; + } else { + $content = ''; + } + + $size = 0; + while (true) { + $data = $this->get_channel_packet(self::CHANNEL_EXEC, true); + // Terminate the loop in case the server repeatedly sends an empty response + if ($data === false) { + $this->close_channel(self::CHANNEL_EXEC, true); + // no data received from server + return false; + } + // SCP usually seems to split stuff out into 16k chunks + $length = strlen($data); + $size += $length; + $end = $size > $info['size']; + if ($end) { + $diff = $size - $info['size']; + $offset = $length - $diff; + if ($data[$offset] === chr(0)) { + $data = substr($data, 0, -$diff); + } else { + $type = $data[$offset] === chr(1) ? 'warning' : 'error'; + $this->scp_errors[] = "$type: " . substr($data, 1); + $this->close_channel(self::CHANNEL_EXEC, true); + return false; + } + } + + if (is_null($local_file)) { + $content .= $data; + } else { + fputs($fp, $data); + } + + if (is_callable($progressCallback)) { + call_user_func($progressCallback, $size); + } + + if ($end) { + break; + } + } + + $this->close_channel(self::CHANNEL_EXEC, true); + + if ($fclose_check) { + fclose($fp); + } + + // if $content isn't set that means a file was written to + return isset($content) ? $content : true; + } + + /** + * Returns all errors on the SCP layer + * + * @return array + */ + public function getSCPErrors() + { + return $this->scp_errors; + } + + /** + * Returns the last error on the SCP layer + * + * @return string + */ + public function getLastSCPError() + { + return count($this->scp_errors) ? $this->scp_errors[count($this->scp_errors) - 1] : ''; + } +} diff --git a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php index 9d385ad75..59de3c9eb 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php +++ b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php @@ -3462,7 +3462,6 @@ public function getSFTPLog() return $this->packet_type_log; } } - /** * Returns all errors on the SFTP layer * diff --git a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php index 1c8a0e265..ffe3ce060 100644 --- a/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php +++ b/lib/Google/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php @@ -679,7 +679,7 @@ class SSH2 * @see self::send_channel_packet() * @var array */ - private $packet_size_client_to_server = []; + protected $packet_size_client_to_server = []; /** * Message Number Log @@ -2941,6 +2941,9 @@ public function exec($command, $callback = null) $this->channel_id_last_interactive = self::CHANNEL_EXEC; return true; } + if ($callback === false) { + return true; + } $output = ''; while (true) { @@ -3997,9 +4000,11 @@ private function filter($payload) break; case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 Strings::shift($payload, 1); - list($request_name) = Strings::unpackSSH2('s', $payload); + list($request_name, $want_reply) = Strings::unpackSSH2('sb', $payload); $this->errors[] = "SSH_MSG_GLOBAL_REQUEST: $request_name"; - $this->send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE)); + if ($want_reply) { + $this->send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE)); + } $payload = $this->get_binary_packet(); break; case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1 @@ -4236,7 +4241,6 @@ protected function get_channel_packet($client_channel, $skip_extended = false) if (strlen($error_message)) { $this->errors[count($this->errors) - 1] .= "\r\n$error_message"; } - if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_CLOSE) { if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) { $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$channel])); @@ -4245,7 +4249,6 @@ protected function get_channel_packet($client_channel, $skip_extended = false) $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_CLOSE; } - continue 3; case 'exit-status': list(, $this->exit_status) = Strings::unpackSSH2('CN', $response); @@ -4255,8 +4258,13 @@ protected function get_channel_packet($client_channel, $skip_extended = false) continue 3; default: - // "Some systems may not implement signals, in which case they SHOULD ignore this message." - // -- http://tools.ietf.org/html/rfc4254#section-6.9 + list($want_reply) = Strings::unpackSSH2('b', $response); + if ($want_reply) { + // "If the request is not recognized or is not supported for the channel, + // SSH_MSG_CHANNEL_FAILURE is returned." + // -- https://datatracker.ietf.org/doc/html/rfc4254#page-10 + $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_FAILURE, $this->server_channels[$channel])); + } continue 3; } } @@ -4714,7 +4722,7 @@ protected function send_channel_packet($client_channel, $data) * @param bool $want_reply * @return void */ - private function close_channel($client_channel) + protected function close_channel($client_channel) { // see http://tools.ietf.org/html/rfc4254#section-5.3 diff --git a/lib/Google/vendor/psr/cache/src/CacheItemInterface.php b/lib/Google/vendor/psr/cache/src/CacheItemInterface.php index 2b2e4bb88..893315e6e 100644 --- a/lib/Google/vendor/psr/cache/src/CacheItemInterface.php +++ b/lib/Google/vendor/psr/cache/src/CacheItemInterface.php @@ -32,7 +32,7 @@ interface CacheItemInterface * @return string * The key string for this cache item. */ - public function getKey(): string; + public function getKey(); /** * Retrieves the value of the item from the cache associated with this object's key. @@ -46,7 +46,7 @@ public function getKey(): string; * @return mixed * The value corresponding to this cache item's key, or null if not found. */ - public function get(): mixed; + public function get(); /** * Confirms if the cache item lookup resulted in a cache hit. @@ -57,7 +57,7 @@ public function get(): mixed; * @return bool * True if the request resulted in a cache hit. False otherwise. */ - public function isHit(): bool; + public function isHit(); /** * Sets the value represented by this cache item. @@ -72,7 +72,7 @@ public function isHit(): bool; * @return static * The invoked object. */ - public function set(mixed $value): static; + public function set(mixed $value); /** * Sets the expiration time for this cache item. @@ -86,7 +86,7 @@ public function set(mixed $value): static; * @return static * The called object. */ - public function expiresAt(?\DateTimeInterface $expiration): static; + public function expiresAt(?\DateTimeInterface $expiration); /** * Sets the expiration time for this cache item. @@ -101,5 +101,5 @@ public function expiresAt(?\DateTimeInterface $expiration): static; * @return static * The called object. */ - public function expiresAfter(int|\DateInterval|null $time): static; + public function expiresAfter(int|\DateInterval|null $time); } diff --git a/lib/Google/vendor/psr/cache/src/CacheItemPoolInterface.php b/lib/Google/vendor/psr/cache/src/CacheItemPoolInterface.php index 4b3017c75..9ff99da6b 100644 --- a/lib/Google/vendor/psr/cache/src/CacheItemPoolInterface.php +++ b/lib/Google/vendor/psr/cache/src/CacheItemPoolInterface.php @@ -29,7 +29,7 @@ interface CacheItemPoolInterface * @return CacheItemInterface * The corresponding Cache Item. */ - public function getItem(string $key): CacheItemInterface; + public function getItem(string $key); /** * Returns a traversable set of cache items. @@ -41,13 +41,13 @@ public function getItem(string $key): CacheItemInterface; * If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException * MUST be thrown. * - * @return iterable - * An iterable collection of Cache Items keyed by the cache keys of + * @return array|\Traversable + * A traversable collection of Cache Items keyed by the cache keys of * each item. A Cache item will be returned for each key, even if that * key is not found. However, if no keys are specified then an empty * traversable MUST be returned instead. */ - public function getItems(array $keys = []): iterable; + public function getItems(array $keys = []); /** * Confirms if the cache contains specified cache item. @@ -66,7 +66,7 @@ public function getItems(array $keys = []): iterable; * @return bool * True if item exists in the cache, false otherwise. */ - public function hasItem(string $key): bool; + public function hasItem(string $key); /** * Deletes all items in the pool. @@ -74,7 +74,7 @@ public function hasItem(string $key): bool; * @return bool * True if the pool was successfully cleared. False if there was an error. */ - public function clear(): bool; + public function clear(); /** * Removes the item from the pool. @@ -89,7 +89,7 @@ public function clear(): bool; * @return bool * True if the item was successfully removed. False if there was an error. */ - public function deleteItem(string $key): bool; + public function deleteItem(string $key); /** * Removes multiple items from the pool. @@ -104,7 +104,7 @@ public function deleteItem(string $key): bool; * @return bool * True if the items were successfully removed. False if there was an error. */ - public function deleteItems(array $keys): bool; + public function deleteItems(array $keys); /** * Persists a cache item immediately. @@ -115,7 +115,7 @@ public function deleteItems(array $keys): bool; * @return bool * True if the item was successfully persisted. False if there was an error. */ - public function save(CacheItemInterface $item): bool; + public function save(CacheItemInterface $item); /** * Sets a cache item to be persisted later. @@ -126,7 +126,7 @@ public function save(CacheItemInterface $item): bool; * @return bool * False if the item could not be queued or if a commit was attempted and failed. True otherwise. */ - public function saveDeferred(CacheItemInterface $item): bool; + public function saveDeferred(CacheItemInterface $item); /** * Persists any deferred cache items. @@ -134,5 +134,5 @@ public function saveDeferred(CacheItemInterface $item): bool; * @return bool * True if all not-yet-saved items were successfully saved or there were none. False otherwise. */ - public function commit(): bool; + public function commit(); } diff --git a/lib/Google/vendor/ramsey/collection/README.md b/lib/Google/vendor/ramsey/collection/README.md index c77ffcb18..aacf940b3 100644 --- a/lib/Google/vendor/ramsey/collection/README.md +++ b/lib/Google/vendor/ramsey/collection/README.md @@ -11,7 +11,6 @@ Read License Build Status Codecov Code Coverage - Psalm Type Coverage

## About @@ -49,16 +48,6 @@ contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read [SECURITY.md][] for instructions on submitting a vulnerability report. -## ramsey/collection for Enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of ramsey/collection and thousands of other packages are working -with Tidelift to deliver commercial support and maintenance for the open source -packages you use to build your applications. Save time, reduce risk, and improve -code health, while paying the maintainers of the exact packages you use. -[Learn more.](https://tidelift.com/subscription/pkg/packagist-ramsey-collection?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - ## Copyright and License The ramsey/collection library is copyright © [Ben Ramsey](https://benramsey.com) diff --git a/lib/Google/vendor/ramsey/collection/composer.json b/lib/Google/vendor/ramsey/collection/composer.json index f09106a15..42fc22b95 100644 --- a/lib/Google/vendor/ramsey/collection/composer.json +++ b/lib/Google/vendor/ramsey/collection/composer.json @@ -19,32 +19,27 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "symfony/polyfill-php81": "^1.23" + "php": "^8.1" }, "require-dev": { "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.28.3", - "fakerphp/faker": "^1.21", + "ergebnis/composer-normalize": "^2.45", + "fakerphp/faker": "^1.24", "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^1.0", - "mockery/mockery": "^1.5", + "jangregor/phpstan-prophecy": "^2.1", + "mockery/mockery": "^1.6", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcsstandards/phpcsutils": "^1.0.0-rc1", - "phpspec/prophecy-phpunit": "^2.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5", - "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18.4", - "ramsey/coding-standard": "^2.0.3", - "ramsey/conventional-commits": "^1.3", - "vimeo/psalm": "^5.4" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpspec/prophecy-phpunit": "^2.3", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5", + "ramsey/coding-standard": "^2.3", + "ramsey/conventional-commits": "^1.6", + "roave/security-advisories": "dev-latest" }, - "minimum-stability": "RC", "prefer-stable": true, "autoload": { "psr-4": { @@ -53,19 +48,15 @@ }, "autoload-dev": { "psr-4": { - "Ramsey\\Collection\\Test\\": "tests/", - "Ramsey\\Test\\Generics\\": "tests/generics/" - }, - "files": [ - "vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php" - ] + "Ramsey\\Collection\\Test\\": "tests/" + } }, "config": { "allow-plugins": { + "captainhook/plugin-composer": true, "dealerdirect/phpcodesniffer-composer-installer": true, "ergebnis/composer-normalize": true, - "phpstan/extension-installer": true, - "captainhook/plugin-composer": true + "phpstan/extension-installer": true }, "sort-packages": true }, @@ -79,11 +70,9 @@ }, "scripts": { "dev:analyze": [ - "@dev:analyze:phpstan", - "@dev:analyze:psalm" + "@dev:analyze:phpstan" ], "dev:analyze:phpstan": "phpstan analyse --ansi --memory-limit=1G", - "dev:analyze:psalm": "psalm", "dev:build:clean": "git clean -fX build/", "dev:lint": [ "@dev:lint:syntax", @@ -105,7 +94,6 @@ "scripts-descriptions": { "dev:analyze": "Runs all static analysis checks.", "dev:analyze:phpstan": "Runs the PHPStan static analyzer.", - "dev:analyze:psalm": "Runs the Psalm static analyzer.", "dev:build:clean": "Cleans the build/ directory.", "dev:lint": "Runs all linting checks.", "dev:lint:fix": "Auto-fixes coding standards issues, if possible.", diff --git a/lib/Google/vendor/ramsey/collection/conventional-commits.json b/lib/Google/vendor/ramsey/collection/conventional-commits.json deleted file mode 100644 index 5fe21d2fa..000000000 --- a/lib/Google/vendor/ramsey/collection/conventional-commits.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "typeCase": "kebab", - "types": [ - "chore", - "ci", - "docs", - "feat", - "fix", - "refactor", - "security", - "style", - "test" - ], - "scopeCase": "kebab", - "scopeRequired": false, - "scopes": [], - "descriptionCase": null, - "descriptionEndMark": "", - "bodyRequired": false, - "bodyWrapWidth": 72, - "requiredFooters": [] -} diff --git a/lib/Google/vendor/ramsey/collection/src/AbstractArray.php b/lib/Google/vendor/ramsey/collection/src/AbstractArray.php index 9b39dd0cb..6d6b6d66b 100644 --- a/lib/Google/vendor/ramsey/collection/src/AbstractArray.php +++ b/lib/Google/vendor/ramsey/collection/src/AbstractArray.php @@ -18,8 +18,6 @@ use Traversable; use function count; -use function serialize; -use function unserialize; /** * This class provides a basic implementation of `ArrayInterface`, to minimize @@ -44,7 +42,7 @@ abstract class AbstractArray implements ArrayInterface */ public function __construct(array $data = []) { - // Invoke offsetSet() for each value added; in this way, sub-classes + // Invoke offsetSet() for each value added; in this way, subclasses // may provide additional logic about values added to the array object. foreach ($data as $key => $value) { $this[$key] = $value; @@ -70,7 +68,7 @@ public function getIterator(): Traversable * * @param array-key $offset The offset to check. */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return isset($this->data[$offset]); } @@ -82,13 +80,12 @@ public function offsetExists($offset): bool * * @param array-key $offset The offset for which a value should be returned. * - * @return T|null the value stored at the offset, or null if the offset + * @return T the value stored at the offset, or null if the offset * does not exist. */ - #[\ReturnTypeWillChange] // phpcs:ignore - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { - return $this->data[$offset] ?? null; + return $this->data[$offset]; } /** @@ -96,12 +93,11 @@ public function offsetGet($offset) * * @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet() * - * @param array-key|null $offset The offset to set. If `null`, the value may be - * set at a numerically-indexed offset. + * @param array-key | null $offset The offset to set. If `null`, the value + * may be set at a numerically-indexed offset. * @param T $value The value to set at the given offset. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { if ($offset === null) { $this->data[] = $value; @@ -117,25 +113,11 @@ public function offsetSet($offset, $value): void * * @param array-key $offset The offset to remove from the array. */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { unset($this->data[$offset]); } - /** - * Returns a serialized string representation of this array object. - * - * @deprecated The Serializable interface will go away in PHP 9. - * - * @link http://php.net/manual/en/serializable.serialize.php Serializable::serialize() - * - * @return string a PHP serialized string. - */ - public function serialize(): string - { - return serialize($this->data); - } - /** * Returns data suitable for PHP serialization. * @@ -149,25 +131,6 @@ public function __serialize(): array return $this->data; } - /** - * Converts a serialized string representation into an instance object. - * - * @deprecated The Serializable interface will go away in PHP 9. - * - * @link http://php.net/manual/en/serializable.unserialize.php Serializable::unserialize() - * - * @param string $serialized A PHP serialized string to unserialize. - * - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - */ - public function unserialize($serialized): void - { - /** @var array $data */ - $data = unserialize($serialized, ['allowed_classes' => false]); - - $this->data = $data; - } - /** * Adds unserialized data to the object. * @@ -203,6 +166,6 @@ public function toArray(): array public function isEmpty(): bool { - return count($this->data) === 0; + return $this->data === []; } } diff --git a/lib/Google/vendor/ramsey/collection/src/AbstractCollection.php b/lib/Google/vendor/ramsey/collection/src/AbstractCollection.php index 38ef7144c..2f006b90f 100644 --- a/lib/Google/vendor/ramsey/collection/src/AbstractCollection.php +++ b/lib/Google/vendor/ramsey/collection/src/AbstractCollection.php @@ -17,27 +17,27 @@ use Closure; use Ramsey\Collection\Exception\CollectionMismatchException; use Ramsey\Collection\Exception\InvalidArgumentException; -use Ramsey\Collection\Exception\InvalidSortOrderException; -use Ramsey\Collection\Exception\OutOfBoundsException; +use Ramsey\Collection\Exception\InvalidPropertyOrMethod; +use Ramsey\Collection\Exception\NoSuchElementException; +use Ramsey\Collection\Exception\UnsupportedOperationException; use Ramsey\Collection\Tool\TypeTrait; use Ramsey\Collection\Tool\ValueExtractorTrait; use Ramsey\Collection\Tool\ValueToStringTrait; use function array_filter; +use function array_key_first; +use function array_key_last; use function array_map; use function array_merge; +use function array_reduce; use function array_search; use function array_udiff; use function array_uintersect; -use function current; -use function end; use function in_array; use function is_int; use function is_object; -use function reset; use function spl_object_id; use function sprintf; -use function unserialize; use function usort; /** @@ -55,27 +55,24 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt use ValueExtractorTrait; /** - * @inheritDoc + * @throws InvalidArgumentException if $element is of the wrong type. */ - public function add($element): bool + public function add(mixed $element): bool { $this[] = $element; return true; } - /** - * @inheritDoc - */ - public function contains($element, bool $strict = true): bool + public function contains(mixed $element, bool $strict = true): bool { return in_array($element, $this->data, $strict); } /** - * @inheritDoc + * @throws InvalidArgumentException if $element is of the wrong type. */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { if ($this->checkType($this->getType(), $value) === false) { throw new InvalidArgumentException( @@ -91,10 +88,7 @@ public function offsetSet($offset, $value): void } } - /** - * @inheritDoc - */ - public function remove($element): bool + public function remove(mixed $element): bool { if (($position = array_search($element, $this->data, true)) !== false) { unset($this[$position]); @@ -106,6 +100,11 @@ public function remove($element): bool } /** + * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist + * on the elements in this collection. + * @throws UnsupportedOperationException if unable to call column() on this + * collection. + * * @inheritDoc */ public function column(string $propertyOrMethod): array @@ -113,77 +112,74 @@ public function column(string $propertyOrMethod): array $temp = []; foreach ($this->data as $item) { - /** @var mixed $value */ - $value = $this->extractValue($item, $propertyOrMethod); - - /** @psalm-suppress MixedAssignment */ - $temp[] = $value; + $temp[] = $this->extractValue($item, $propertyOrMethod); } return $temp; } /** - * @inheritDoc + * @return T + * + * @throws NoSuchElementException if this collection is empty. */ - public function first() + public function first(): mixed { - if ($this->isEmpty()) { - throw new OutOfBoundsException('Can\'t determine first item. Collection is empty'); - } - - reset($this->data); + $firstIndex = array_key_first($this->data); - /** @var T $first */ - $first = current($this->data); + if ($firstIndex === null) { + throw new NoSuchElementException('Can\'t determine first item. Collection is empty'); + } - return $first; + return $this->data[$firstIndex]; } /** - * @inheritDoc + * @return T + * + * @throws NoSuchElementException if this collection is empty. */ - public function last() + public function last(): mixed { - if ($this->isEmpty()) { - throw new OutOfBoundsException('Can\'t determine last item. Collection is empty'); - } + $lastIndex = array_key_last($this->data); - /** @var T $item */ - $item = end($this->data); - reset($this->data); + if ($lastIndex === null) { + throw new NoSuchElementException('Can\'t determine last item. Collection is empty'); + } - return $item; + return $this->data[$lastIndex]; } - public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): CollectionInterface + /** + * @return CollectionInterface + * + * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist + * on the elements in this collection. + * @throws UnsupportedOperationException if unable to call sort() on this + * collection. + */ + public function sort(?string $propertyOrMethod = null, Sort $order = Sort::Ascending): CollectionInterface { - if (!in_array($order, [self::SORT_ASC, self::SORT_DESC], true)) { - throw new InvalidSortOrderException('Invalid sort order given: ' . $order); - } - $collection = clone $this; usort( $collection->data, - /** - * @param T $a - * @param T $b - */ - function ($a, $b) use ($propertyOrMethod, $order): int { - /** @var mixed $aValue */ + function (mixed $a, mixed $b) use ($propertyOrMethod, $order): int { $aValue = $this->extractValue($a, $propertyOrMethod); - - /** @var mixed $bValue */ $bValue = $this->extractValue($b, $propertyOrMethod); - return ($aValue <=> $bValue) * ($order === self::SORT_DESC ? -1 : 1); + return ($aValue <=> $bValue) * ($order === Sort::Descending ? -1 : 1); }, ); return $collection; } + /** + * @param callable(T): bool $callback A callable to use for filtering elements. + * + * @return CollectionInterface + */ public function filter(callable $callback): CollectionInterface { $collection = clone $this; @@ -193,23 +189,56 @@ public function filter(callable $callback): CollectionInterface } /** - * {@inheritdoc} + * @return CollectionInterface + * + * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist + * on the elements in this collection. + * @throws UnsupportedOperationException if unable to call where() on this + * collection. */ - public function where(string $propertyOrMethod, $value): CollectionInterface + public function where(?string $propertyOrMethod, mixed $value): CollectionInterface { - return $this->filter(function ($item) use ($propertyOrMethod, $value) { - /** @var mixed $accessorValue */ - $accessorValue = $this->extractValue($item, $propertyOrMethod); - - return $accessorValue === $value; - }); + return $this->filter( + fn (mixed $item): bool => $this->extractValue($item, $propertyOrMethod) === $value, + ); } + /** + * @param callable(T): TCallbackReturn $callback A callable to apply to each + * item of the collection. + * + * @return CollectionInterface + * + * @template TCallbackReturn + */ public function map(callable $callback): CollectionInterface { return new Collection('mixed', array_map($callback, $this->data)); } + /** + * @param callable(TCarry, T): TCarry $callback A callable to apply to each + * item of the collection to reduce it to a single value. + * @param TCarry $initial This is the initial value provided to the callback. + * + * @return TCarry + * + * @template TCarry + */ + public function reduce(callable $callback, mixed $initial): mixed + { + return array_reduce($this->data, $callback, $initial); + } + + /** + * @param CollectionInterface $other The collection to check for divergent + * items. + * + * @return CollectionInterface + * + * @throws CollectionMismatchException if the compared collections are of + * differing types. + */ public function diff(CollectionInterface $other): CollectionInterface { $this->compareCollectionTypes($other); @@ -217,28 +246,40 @@ public function diff(CollectionInterface $other): CollectionInterface $diffAtoB = array_udiff($this->data, $other->toArray(), $this->getComparator()); $diffBtoA = array_udiff($other->toArray(), $this->data, $this->getComparator()); - /** @var array $diff */ - $diff = array_merge($diffAtoB, $diffBtoA); - $collection = clone $this; - $collection->data = $diff; + $collection->data = array_merge($diffAtoB, $diffBtoA); return $collection; } + /** + * @param CollectionInterface $other The collection to check for + * intersecting items. + * + * @return CollectionInterface + * + * @throws CollectionMismatchException if the compared collections are of + * differing types. + */ public function intersect(CollectionInterface $other): CollectionInterface { $this->compareCollectionTypes($other); - /** @var array $intersect */ - $intersect = array_uintersect($this->data, $other->toArray(), $this->getComparator()); - $collection = clone $this; - $collection->data = $intersect; + $collection->data = array_uintersect($this->data, $other->toArray(), $this->getComparator()); return $collection; } + /** + * @param CollectionInterface ...$collections The collections to merge. + * + * @return CollectionInterface + * + * @throws CollectionMismatchException if unable to merge any of the given + * collections or items within the given collections due to type + * mismatch errors. + */ public function merge(CollectionInterface ...$collections): CollectionInterface { $mergedCollection = clone $this; @@ -274,19 +315,10 @@ public function merge(CollectionInterface ...$collections): CollectionInterface return $mergedCollection; } - /** - * @inheritDoc - */ - public function unserialize($serialized): void - { - /** @var array $data */ - $data = unserialize($serialized, ['allowed_classes' => [$this->getType()]]); - - $this->data = $data; - } - /** * @param CollectionInterface $other + * + * @throws CollectionMismatchException */ private function compareCollectionTypes(CollectionInterface $other): void { @@ -303,23 +335,19 @@ private function compareCollectionTypes(CollectionInterface $other): void private function getComparator(): Closure { - return /** - * @param T $a - * @param T $b - */ - function ($a, $b): int { - // If the two values are object, we convert them to unique scalars. - // If the collection contains mixed values (unlikely) where some are objects - // and some are not, we leave them as they are. - // The comparator should still work and the result of $a < $b should - // be consistent but unpredictable since not documented. - if (is_object($a) && is_object($b)) { - $a = spl_object_id($a); - $b = spl_object_id($b); - } + return function (mixed $a, mixed $b): int { + // If the two values are object, we convert them to unique scalars. + // If the collection contains mixed values (unlikely) where some are objects + // and some are not, we leave them as they are. + // The comparator should still work and the result of $a < $b should + // be consistent but unpredictable since not documented. + if (is_object($a) && is_object($b)) { + $a = spl_object_id($a); + $b = spl_object_id($b); + } - return $a === $b ? 0 : ($a < $b ? 1 : -1); - }; + return $a === $b ? 0 : ($a < $b ? 1 : -1); + }; } /** @@ -327,15 +355,11 @@ function ($a, $b): int { */ private function getUniformType(CollectionInterface $collection): string { - switch ($collection->getType()) { - case 'integer': - return 'int'; - case 'boolean': - return 'bool'; - case 'double': - return 'float'; - default: - return $collection->getType(); - } + return match ($collection->getType()) { + 'integer' => 'int', + 'boolean' => 'bool', + 'double' => 'float', + default => $collection->getType(), + }; } } diff --git a/lib/Google/vendor/ramsey/collection/src/AbstractSet.php b/lib/Google/vendor/ramsey/collection/src/AbstractSet.php index 1126ccb0a..63f833156 100644 --- a/lib/Google/vendor/ramsey/collection/src/AbstractSet.php +++ b/lib/Google/vendor/ramsey/collection/src/AbstractSet.php @@ -24,22 +24,23 @@ */ abstract class AbstractSet extends AbstractCollection { - /** - * @inheritDoc - */ - public function add($element): bool + public function add(mixed $element): bool { if ($this->contains($element)) { return false; } - return parent::add($element); + // Call offsetSet() on the parent instead of add(), since calling + // parent::add() will invoke $this->offsetSet(), which will call + // $this->contains() a second time. This can cause performance issues + // with extremely large collections. For more information, see + // https://github.com/ramsey/collection/issues/68. + parent::offsetSet(null, $element); + + return true; } - /** - * @inheritDoc - */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { if ($this->contains($value)) { return; diff --git a/lib/Google/vendor/ramsey/collection/src/ArrayInterface.php b/lib/Google/vendor/ramsey/collection/src/ArrayInterface.php index 27af6102b..bc7f6f424 100644 --- a/lib/Google/vendor/ramsey/collection/src/ArrayInterface.php +++ b/lib/Google/vendor/ramsey/collection/src/ArrayInterface.php @@ -17,7 +17,6 @@ use ArrayAccess; use Countable; use IteratorAggregate; -use Serializable; /** * `ArrayInterface` provides traversable array functionality to data types. @@ -29,8 +28,7 @@ interface ArrayInterface extends ArrayAccess, Countable, - IteratorAggregate, - Serializable + IteratorAggregate { /** * Removes all items from this array. diff --git a/lib/Google/vendor/ramsey/collection/src/Collection.php b/lib/Google/vendor/ramsey/collection/src/Collection.php index 532b971b6..3b0f7689d 100644 --- a/lib/Google/vendor/ramsey/collection/src/Collection.php +++ b/lib/Google/vendor/ramsey/collection/src/Collection.php @@ -24,7 +24,7 @@ * * Example usage: * - * ``` php + * ``` * $collection = new \Ramsey\Collection\Collection('My\\Foo'); * $collection->add(new \My\Foo()); * $collection->add(new \My\Foo()); @@ -37,7 +37,7 @@ * It is preferable to subclass `AbstractCollection` to create your own typed * collections. For example: * - * ``` php + * ``` * namespace My\Foo; * * class FooCollection extends \Ramsey\Collection\AbstractCollection @@ -51,7 +51,7 @@ * * And then use it similarly to the earlier example: * - * ``` php + * ``` * $fooCollection = new \My\Foo\FooCollection(); * $fooCollection->add(new \My\Foo()); * $fooCollection->add(new \My\Foo()); @@ -64,7 +64,7 @@ * The benefit with this approach is that you may do type-checking on the * collection object: * - * ``` php + * ``` * if ($collection instanceof \My\Foo\FooCollection) { * // the collection is a collection of My\Foo objects * } @@ -75,25 +75,16 @@ */ class Collection extends AbstractCollection { - /** - * The type of elements stored in this collection. - * - * A collection's type is immutable once it is set. For this reason, this - * property is set private. - */ - private string $collectionType; - /** * Constructs a collection object of the specified type, optionally with the * specified data. * - * @param string $collectionType The type (FQCN) associated with this + * @param string $collectionType The type or class name associated with this * collection. * @param array $data The initial items to store in the collection. */ - public function __construct(string $collectionType, array $data = []) + public function __construct(private readonly string $collectionType, array $data = []) { - $this->collectionType = $collectionType; parent::__construct($data); } diff --git a/lib/Google/vendor/ramsey/collection/src/CollectionInterface.php b/lib/Google/vendor/ramsey/collection/src/CollectionInterface.php index 9f86a2837..3ffbb1669 100644 --- a/lib/Google/vendor/ramsey/collection/src/CollectionInterface.php +++ b/lib/Google/vendor/ramsey/collection/src/CollectionInterface.php @@ -14,8 +14,14 @@ namespace Ramsey\Collection; +use Ramsey\Collection\Exception\CollectionMismatchException; +use Ramsey\Collection\Exception\InvalidArgumentException; +use Ramsey\Collection\Exception\InvalidPropertyOrMethod; +use Ramsey\Collection\Exception\NoSuchElementException; +use Ramsey\Collection\Exception\UnsupportedOperationException; + /** - * A collection represents a group of objects, known as its elements. + * A collection represents a group of values, known as its elements. * * Some collections allow duplicate elements and others do not. Some are ordered * and others unordered. @@ -25,16 +31,6 @@ */ interface CollectionInterface extends ArrayInterface { - /** - * Ascending sort type. - */ - public const SORT_ASC = 'asc'; - - /** - * Descending sort type. - */ - public const SORT_DESC = 'desc'; - /** * Ensures that this collection contains the specified element (optional * operation). @@ -58,9 +54,11 @@ interface CollectionInterface extends ArrayInterface * @param T $element The element to add to the collection. * * @return bool `true` if this collection changed as a result of the call. + * + * @throws InvalidArgumentException if the collection refuses to add the + * $element for any reason other than that it already contains the element. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function add($element): bool; + public function add(mixed $element): bool; /** * Returns `true` if this collection contains the specified element. @@ -68,8 +66,7 @@ public function add($element): bool; * @param T $element The element to check whether the collection contains. * @param bool $strict Whether to perform a strict type check on the value. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function contains($element, bool $strict = true): bool; + public function contains(mixed $element, bool $strict = true): bool; /** * Returns the type associated with this collection. @@ -84,15 +81,20 @@ public function getType(): string; * * @return bool `true` if an element was removed as a result of this call. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function remove($element): bool; + public function remove(mixed $element): bool; /** - * Returns the values from the given property or method. + * Returns the values from the given property, method, or array key. * - * @param string $propertyOrMethod The property or method name to filter by. + * @param string $propertyOrMethod The name of the property, method, or + * array key to evaluate and return. * * @return list + * + * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist + * on the elements in this collection. + * @throws UnsupportedOperationException if unable to call column() on this + * collection. */ public function column(string $propertyOrMethod): array; @@ -100,29 +102,41 @@ public function column(string $propertyOrMethod): array; * Returns the first item of the collection. * * @return T + * + * @throws NoSuchElementException if this collection is empty. */ - public function first(); + public function first(): mixed; /** * Returns the last item of the collection. * * @return T + * + * @throws NoSuchElementException if this collection is empty. */ - public function last(); + public function last(): mixed; /** - * Sort the collection by a property or method with the given sort order. + * Sort the collection by a property, method, or array key with the given + * sort order. + * + * If $propertyOrMethod is `null`, this will sort by comparing each element. * * This will always leave the original collection untouched and will return * a new one. * - * @param string $propertyOrMethod The property or method to sort by. - * @param string $order The sort order for the resulting collection (one of - * this interface's `SORT_*` constants). + * @param string | null $propertyOrMethod The property, method, or array key + * to sort by. + * @param Sort $order The sort order for the resulting collection. * * @return CollectionInterface + * + * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist + * on the elements in this collection. + * @throws UnsupportedOperationException if unable to call sort() on this + * collection. */ - public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): self; + public function sort(?string $propertyOrMethod = null, Sort $order = Sort::Ascending): self; /** * Filter out items of the collection which don't match the criteria of @@ -134,25 +148,31 @@ public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): * See the {@link http://php.net/manual/en/function.array-filter.php PHP array_filter() documentation} * for examples of how the `$callback` parameter works. * - * @param callable(T):bool $callback A callable to use for filtering elements. + * @param callable(T): bool $callback A callable to use for filtering elements. * * @return CollectionInterface */ public function filter(callable $callback): self; /** - * Create a new collection where items match the criteria of given callback. + * Create a new collection where the result of the given property, method, + * or array key of each item in the collection equals the given value. * * This will always leave the original collection untouched and will return * a new one. * - * @param string $propertyOrMethod The property or method to evaluate. + * @param string | null $propertyOrMethod The property, method, or array key + * to evaluate. If `null`, the element itself is compared to $value. * @param mixed $value The value to match. * * @return CollectionInterface + * + * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist + * on the elements in this collection. + * @throws UnsupportedOperationException if unable to call where() on this + * collection. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function where(string $propertyOrMethod, $value): self; + public function where(?string $propertyOrMethod, mixed $value): self; /** * Apply a given callback method on each item of the collection. @@ -164,7 +184,7 @@ public function where(string $propertyOrMethod, $value): self; * See the {@link http://php.net/manual/en/function.array-map.php PHP array_map() documentation} * for examples of how the `$callback` parameter works. * - * @param callable(T):TCallbackReturn $callback A callable to apply to each + * @param callable(T): TCallbackReturn $callback A callable to apply to each * item of the collection. * * @return CollectionInterface @@ -173,6 +193,23 @@ public function where(string $propertyOrMethod, $value): self; */ public function map(callable $callback): self; + /** + * Apply a given callback method on each item of the collection + * to reduce it to a single value. + * + * See the {@link http://php.net/manual/en/function.array-reduce.php PHP array_reduce() documentation} + * for examples of how the `$callback` and `$initial` parameters work. + * + * @param callable(TCarry, T): TCarry $callback A callable to apply to each + * item of the collection to reduce it to a single value. + * @param TCarry $initial This is the initial value provided to the callback. + * + * @return TCarry + * + * @template TCarry + */ + public function reduce(callable $callback, mixed $initial): mixed; + /** * Create a new collection with divergent items between current and given * collection. @@ -181,6 +218,9 @@ public function map(callable $callback): self; * items. * * @return CollectionInterface + * + * @throws CollectionMismatchException if the compared collections are of + * differing types. */ public function diff(CollectionInterface $other): self; @@ -192,6 +232,9 @@ public function diff(CollectionInterface $other): self; * intersecting items. * * @return CollectionInterface + * + * @throws CollectionMismatchException if the compared collections are of + * differing types. */ public function intersect(CollectionInterface $other): self; @@ -201,6 +244,10 @@ public function intersect(CollectionInterface $other): self; * @param CollectionInterface ...$collections The collections to merge. * * @return CollectionInterface + * + * @throws CollectionMismatchException if unable to merge any of the given + * collections or items within the given collections due to type + * mismatch errors. */ public function merge(CollectionInterface ...$collections): self; } diff --git a/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueue.php b/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueue.php index 4d1f71ea4..62947a24f 100644 --- a/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueue.php +++ b/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueue.php @@ -17,6 +17,10 @@ use Ramsey\Collection\Exception\InvalidArgumentException; use Ramsey\Collection\Exception\NoSuchElementException; +use function array_key_last; +use function array_pop; +use function array_unshift; + /** * This class provides a basic implementation of `DoubleEndedQueueInterface`, to * minimize the effort required to implement this interface. @@ -28,33 +32,21 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface { /** - * Index of the last element in the queue. - */ - private int $tail = -1; - - /** - * @inheritDoc + * Constructs a double-ended queue (dequeue) object of the specified type, + * optionally with the specified data. + * + * @param string $queueType The type or class name associated with this dequeue. + * @param array $data The initial items to store in the dequeue. */ - public function offsetSet($offset, $value): void + public function __construct(private readonly string $queueType, array $data = []) { - if ($this->checkType($this->getType(), $value) === false) { - throw new InvalidArgumentException( - 'Value must be of type ' . $this->getType() . '; value is ' - . $this->toolValueToString($value), - ); - } - - $this->tail++; - - $this->data[$this->tail] = $value; + parent::__construct($this->queueType, $data); } /** * @throws InvalidArgumentException if $element is of the wrong type - * - * @inheritDoc */ - public function addFirst($element): bool + public function addFirst(mixed $element): bool { if ($this->checkType($this->getType(), $element) === false) { throw new InvalidArgumentException( @@ -63,125 +55,112 @@ public function addFirst($element): bool ); } - $this->index--; - - $this->data[$this->index] = $element; + array_unshift($this->data, $element); return true; } /** - * @inheritDoc + * @throws InvalidArgumentException if $element is of the wrong type */ - public function addLast($element): bool + public function addLast(mixed $element): bool { return $this->add($element); } - /** - * @inheritDoc - */ - public function offerFirst($element): bool + public function offerFirst(mixed $element): bool { try { return $this->addFirst($element); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { return false; } } - /** - * @inheritDoc - */ - public function offerLast($element): bool + public function offerLast(mixed $element): bool { return $this->offer($element); } /** - * @inheritDoc + * @return T the first element in this queue. + * + * @throws NoSuchElementException if the queue is empty */ - public function removeFirst() + public function removeFirst(): mixed { return $this->remove(); } /** - * @inheritDoc + * @return T the last element in this queue. + * + * @throws NoSuchElementException if this queue is empty. */ - public function removeLast() + public function removeLast(): mixed { - $tail = $this->pollLast(); - - if ($tail === null) { - throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); - } - - return $tail; + return $this->pollLast() ?? throw new NoSuchElementException( + 'Can\'t return element from Queue. Queue is empty.', + ); } /** - * @inheritDoc + * @return T | null the head of this queue, or `null` if this queue is empty. */ - public function pollFirst() + public function pollFirst(): mixed { return $this->poll(); } /** - * @inheritDoc + * @return T | null the tail of this queue, or `null` if this queue is empty. */ - public function pollLast() + public function pollLast(): mixed { - if ($this->count() === 0) { - return null; - } - - $tail = $this[$this->tail]; - - unset($this[$this->tail]); - $this->tail--; - - return $tail; + return array_pop($this->data); } /** - * @inheritDoc + * @return T the head of this queue. + * + * @throws NoSuchElementException if this queue is empty. */ - public function firstElement() + public function firstElement(): mixed { return $this->element(); } /** - * @inheritDoc + * @return T the tail of this queue. + * + * @throws NoSuchElementException if this queue is empty. */ - public function lastElement() + public function lastElement(): mixed { - if ($this->count() === 0) { - throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); - } - - return $this->data[$this->tail]; + return $this->peekLast() ?? throw new NoSuchElementException( + 'Can\'t return element from Queue. Queue is empty.', + ); } /** - * @inheritDoc + * @return T | null the head of this queue, or `null` if this queue is empty. */ - public function peekFirst() + public function peekFirst(): mixed { return $this->peek(); } /** - * @inheritDoc + * @return T | null the tail of this queue, or `null` if this queue is empty. */ - public function peekLast() + public function peekLast(): mixed { - if ($this->count() === 0) { + $lastIndex = array_key_last($this->data); + + if ($lastIndex === null) { return null; } - return $this->data[$this->tail]; + return $this->data[$lastIndex]; } } diff --git a/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php b/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php index 3fa4ecab8..15cc0e97b 100644 --- a/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php +++ b/lib/Google/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php @@ -181,8 +181,7 @@ interface DoubleEndedQueueInterface extends QueueInterface * Implementations should use a more-specific exception that extends * `\RuntimeException`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function addFirst($element): bool; + public function addFirst(mixed $element): bool; /** * Inserts the specified element at the end of this queue if it is possible @@ -202,8 +201,7 @@ public function addFirst($element): bool; * Implementations should use a more-specific exception that extends * `\RuntimeException`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function addLast($element): bool; + public function addLast(mixed $element): bool; /** * Inserts the specified element at the front of this queue if it is @@ -217,8 +215,7 @@ public function addLast($element): bool; * * @return bool `true` if the element was added to this queue, else `false`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function offerFirst($element): bool; + public function offerFirst(mixed $element): bool; /** * Inserts the specified element at the end of this queue if it is possible @@ -232,8 +229,7 @@ public function offerFirst($element): bool; * * @return bool `true` if the element was added to this queue, else `false`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function offerLast($element): bool; + public function offerLast(mixed $element): bool; /** * Retrieves and removes the head of this queue. @@ -245,7 +241,7 @@ public function offerLast($element): bool; * * @throws NoSuchElementException if this queue is empty. */ - public function removeFirst(); + public function removeFirst(): mixed; /** * Retrieves and removes the tail of this queue. @@ -257,23 +253,23 @@ public function removeFirst(); * * @throws NoSuchElementException if this queue is empty. */ - public function removeLast(); + public function removeLast(): mixed; /** * Retrieves and removes the head of this queue, or returns `null` if this * queue is empty. * - * @return T|null the head of this queue, or `null` if this queue is empty. + * @return T | null the head of this queue, or `null` if this queue is empty. */ - public function pollFirst(); + public function pollFirst(): mixed; /** * Retrieves and removes the tail of this queue, or returns `null` if this * queue is empty. * - * @return T|null the tail of this queue, or `null` if this queue is empty. + * @return T | null the tail of this queue, or `null` if this queue is empty. */ - public function pollLast(); + public function pollLast(): mixed; /** * Retrieves, but does not remove, the head of this queue. @@ -285,7 +281,7 @@ public function pollLast(); * * @throws NoSuchElementException if this queue is empty. */ - public function firstElement(); + public function firstElement(): mixed; /** * Retrieves, but does not remove, the tail of this queue. @@ -297,21 +293,21 @@ public function firstElement(); * * @throws NoSuchElementException if this queue is empty. */ - public function lastElement(); + public function lastElement(): mixed; /** * Retrieves, but does not remove, the head of this queue, or returns `null` * if this queue is empty. * - * @return T|null the head of this queue, or `null` if this queue is empty. + * @return T | null the head of this queue, or `null` if this queue is empty. */ - public function peekFirst(); + public function peekFirst(): mixed; /** * Retrieves, but does not remove, the tail of this queue, or returns `null` * if this queue is empty. * - * @return T|null the tail of this queue, or `null` if this queue is empty. + * @return T | null the tail of this queue, or `null` if this queue is empty. */ - public function peekLast(); + public function peekLast(): mixed; } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php b/lib/Google/vendor/ramsey/collection/src/Exception/CollectionException.php similarity index 70% rename from lib/Google/vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php rename to lib/Google/vendor/ramsey/collection/src/Exception/CollectionException.php index 4491429c7..4aa92bed8 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/CollectionException.php @@ -14,11 +14,8 @@ namespace Ramsey\Collection\Exception; -use RuntimeException; +use Throwable; -/** - * Thrown when attempting to use a sort order that is not recognized. - */ -class InvalidSortOrderException extends RuntimeException +interface CollectionException extends Throwable { } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php b/lib/Google/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php index 7058bcf6e..42f5be2df 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php @@ -19,6 +19,6 @@ /** * Thrown when attempting to operate on collections of differing types. */ -class CollectionMismatchException extends RuntimeException +class CollectionMismatchException extends RuntimeException implements CollectionException { } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php b/lib/Google/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php index dcc3eac60..7b41b4a7c 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php @@ -14,9 +14,11 @@ namespace Ramsey\Collection\Exception; +use InvalidArgumentException as PhpInvalidArgumentException; + /** * Thrown to indicate an argument is not of the expected type. */ -class InvalidArgumentException extends \InvalidArgumentException +class InvalidArgumentException extends PhpInvalidArgumentException implements CollectionException { } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/ValueExtractionException.php b/lib/Google/vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php similarity index 62% rename from lib/Google/vendor/ramsey/collection/src/Exception/ValueExtractionException.php rename to lib/Google/vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php index 32f2a175f..a53be14aa 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/ValueExtractionException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php @@ -17,8 +17,10 @@ use RuntimeException; /** - * Thrown when attempting to extract a value for a method or property that does not exist. + * Thrown when attempting to evaluate a property, method, or array key + * that doesn't exist on an element or cannot otherwise be evaluated in the + * current context. */ -class ValueExtractionException extends RuntimeException +class InvalidPropertyOrMethod extends RuntimeException implements CollectionException { } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/NoSuchElementException.php b/lib/Google/vendor/ramsey/collection/src/Exception/NoSuchElementException.php index cabcb9d88..cd98f0c0f 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/NoSuchElementException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/NoSuchElementException.php @@ -19,6 +19,6 @@ /** * Thrown when attempting to access an element that does not exist. */ -class NoSuchElementException extends RuntimeException +class NoSuchElementException extends RuntimeException implements CollectionException { } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php b/lib/Google/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php index 4e9d16fa3..c75294e53 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php @@ -14,9 +14,11 @@ namespace Ramsey\Collection\Exception; +use OutOfBoundsException as PhpOutOfBoundsException; + /** * Thrown when attempting to access an element out of the range of the collection. */ -class OutOfBoundsException extends \OutOfBoundsException +class OutOfBoundsException extends PhpOutOfBoundsException implements CollectionException { } diff --git a/lib/Google/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php b/lib/Google/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php index 9b6228971..d074f45fd 100644 --- a/lib/Google/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php +++ b/lib/Google/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php @@ -19,6 +19,6 @@ /** * Thrown to indicate that the requested operation is not supported. */ -class UnsupportedOperationException extends RuntimeException +class UnsupportedOperationException extends RuntimeException implements CollectionException { } diff --git a/lib/Google/vendor/ramsey/collection/src/Map/AbstractMap.php b/lib/Google/vendor/ramsey/collection/src/Map/AbstractMap.php index 378807289..92f23e605 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/AbstractMap.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/AbstractMap.php @@ -16,6 +16,7 @@ use Ramsey\Collection\AbstractArray; use Ramsey\Collection\Exception\InvalidArgumentException; +use Traversable; use function array_key_exists; use function array_keys; @@ -26,16 +27,36 @@ * This class provides a basic implementation of `MapInterface`, to minimize the * effort required to implement this interface. * + * @template K of array-key * @template T * @extends AbstractArray - * @implements MapInterface + * @implements MapInterface */ abstract class AbstractMap extends AbstractArray implements MapInterface { /** + * @param array $data The initial items to add to this map. + */ + public function __construct(array $data = []) + { + parent::__construct($data); + } + + /** + * @return Traversable + */ + public function getIterator(): Traversable + { + return parent::getIterator(); + } + + /** + * @param K $offset The offset to set + * @param T $value The value to set at the given offset. + * * @inheritDoc */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { if ($offset === null) { throw new InvalidArgumentException( @@ -47,18 +68,12 @@ public function offsetSet($offset, $value): void $this->data[$offset] = $value; } - /** - * @inheritDoc - */ - public function containsKey($key): bool + public function containsKey(int | string $key): bool { return array_key_exists($key, $this->data); } - /** - * @inheritDoc - */ - public function containsValue($value): bool + public function containsValue(mixed $value): bool { return in_array($value, $this->data, true); } @@ -68,25 +83,29 @@ public function containsValue($value): bool */ public function keys(): array { + /** @var list */ return array_keys($this->data); } /** - * @inheritDoc + * @param K $key The key to return from the map. + * @param T | null $defaultValue The default value to use if `$key` is not found. + * + * @return T | null the value or `null` if the key could not be found. */ - public function get($key, $defaultValue = null) + public function get(int | string $key, mixed $defaultValue = null): mixed { - if (!$this->containsKey($key)) { - return $defaultValue; - } - - return $this[$key]; + return $this[$key] ?? $defaultValue; } /** - * @inheritDoc + * @param K $key The key to put or replace in the map. + * @param T $value The value to store at `$key`. + * + * @return T | null the previous value associated with key, or `null` if + * there was no mapping for `$key`. */ - public function put($key, $value) + public function put(int | string $key, mixed $value): mixed { $previousValue = $this->get($key); $this[$key] = $value; @@ -95,9 +114,13 @@ public function put($key, $value) } /** - * @inheritDoc + * @param K $key The key to put in the map. + * @param T $value The value to store at `$key`. + * + * @return T | null the previous value associated with key, or `null` if + * there was no mapping for `$key`. */ - public function putIfAbsent($key, $value) + public function putIfAbsent(int | string $key, mixed $value): mixed { $currentValue = $this->get($key); @@ -109,9 +132,12 @@ public function putIfAbsent($key, $value) } /** - * @inheritDoc + * @param K $key The key to remove from the map. + * + * @return T | null the previous value associated with key, or `null` if + * there was no mapping for `$key`. */ - public function remove($key) + public function remove(int | string $key): mixed { $previousValue = $this->get($key); unset($this[$key]); @@ -119,10 +145,7 @@ public function remove($key) return $previousValue; } - /** - * @inheritDoc - */ - public function removeIf($key, $value): bool + public function removeIf(int | string $key, mixed $value): bool { if ($this->get($key) === $value) { unset($this[$key]); @@ -134,9 +157,13 @@ public function removeIf($key, $value): bool } /** - * @inheritDoc + * @param K $key The key to replace. + * @param T $value The value to set at `$key`. + * + * @return T | null the previous value associated with key, or `null` if + * there was no mapping for `$key`. */ - public function replace($key, $value) + public function replace(int | string $key, mixed $value): mixed { $currentValue = $this->get($key); @@ -147,10 +174,7 @@ public function replace($key, $value) return $currentValue; } - /** - * @inheritDoc - */ - public function replaceIf($key, $oldValue, $newValue): bool + public function replaceIf(int | string $key, mixed $oldValue, mixed $newValue): bool { if ($this->get($key) === $oldValue) { $this[$key] = $newValue; @@ -160,4 +184,22 @@ public function replaceIf($key, $oldValue, $newValue): bool return false; } + + /** + * @return array + */ + public function __serialize(): array + { + /** @var array */ + return parent::__serialize(); + } + + /** + * @return array + */ + public function toArray(): array + { + /** @var array */ + return parent::toArray(); + } } diff --git a/lib/Google/vendor/ramsey/collection/src/Map/AbstractTypedMap.php b/lib/Google/vendor/ramsey/collection/src/Map/AbstractTypedMap.php index 486dc2e29..8b6cc0484 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/AbstractTypedMap.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/AbstractTypedMap.php @@ -18,16 +18,14 @@ use Ramsey\Collection\Tool\TypeTrait; use Ramsey\Collection\Tool\ValueToStringTrait; -use function var_export; - /** * This class provides a basic implementation of `TypedMapInterface`, to * minimize the effort required to implement this interface. * * @template K of array-key * @template T - * @extends AbstractMap - * @implements TypedMapInterface + * @extends AbstractMap + * @implements TypedMapInterface */ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface { @@ -35,20 +33,13 @@ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface use ValueToStringTrait; /** - * @param K|null $offset + * @param K $offset * @param T $value * * @inheritDoc */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { - if ($offset === null) { - throw new InvalidArgumentException( - 'Map elements are key/value pairs; a key must be provided for ' - . 'value ' . var_export($value, true), - ); - } - if ($this->checkType($this->getKeyType(), $offset) === false) { throw new InvalidArgumentException( 'Key must be of type ' . $this->getKeyType() . '; key is ' diff --git a/lib/Google/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php b/lib/Google/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php index 79a314d96..34e4e853b 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php @@ -17,8 +17,7 @@ /** * `AssociativeArrayMap` represents a standard associative array object. * - * @template T - * @extends AbstractMap + * @extends AbstractMap */ class AssociativeArrayMap extends AbstractMap { diff --git a/lib/Google/vendor/ramsey/collection/src/Map/MapInterface.php b/lib/Google/vendor/ramsey/collection/src/Map/MapInterface.php index 6ed0b2967..22ba1bdd1 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/MapInterface.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/MapInterface.php @@ -21,6 +21,7 @@ * * A map cannot contain duplicate keys; each key can map to at most one value. * + * @template K of array-key * @template T * @extends ArrayInterface */ @@ -29,9 +30,9 @@ interface MapInterface extends ArrayInterface /** * Returns `true` if this map contains a mapping for the specified key. * - * @param array-key $key The key to check in the map. + * @param K $key The key to check in the map. */ - public function containsKey($key): bool; + public function containsKey(int | string $key): bool; /** * Returns `true` if this map maps one or more keys to the specified value. @@ -40,13 +41,12 @@ public function containsKey($key): bool; * * @param T $value The value to check in the map. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function containsValue($value): bool; + public function containsValue(mixed $value): bool; /** * Return an array of the keys contained in this map. * - * @return list + * @return list */ public function keys(): array; @@ -55,13 +55,12 @@ public function keys(): array; * map contains no mapping for the key, or (optionally) `$defaultValue` if * this map contains no mapping for the key. * - * @param array-key $key The key to return from the map. - * @param T|null $defaultValue The default value to use if `$key` is not found. + * @param K $key The key to return from the map. + * @param T | null $defaultValue The default value to use if `$key` is not found. * - * @return T|null the value or `null` if the key could not be found. + * @return T | null the value or `null` if the key could not be found. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function get($key, $defaultValue = null); + public function get(int | string $key, mixed $defaultValue = null): mixed; /** * Associates the specified value with the specified key in this map. @@ -69,14 +68,13 @@ public function get($key, $defaultValue = null); * If the map previously contained a mapping for the key, the old value is * replaced by the specified value. * - * @param array-key $key The key to put or replace in the map. + * @param K $key The key to put or replace in the map. * @param T $value The value to store at `$key`. * - * @return T|null the previous value associated with key, or `null` if + * @return T | null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function put($key, $value); + public function put(int | string $key, mixed $value): mixed; /** * Associates the specified value with the specified key in this map only if @@ -85,25 +83,23 @@ public function put($key, $value); * If there is already a value associated with `$key`, this returns that * value without replacing it. * - * @param array-key $key The key to put in the map. + * @param K $key The key to put in the map. * @param T $value The value to store at `$key`. * - * @return T|null the previous value associated with key, or `null` if + * @return T | null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function putIfAbsent($key, $value); + public function putIfAbsent(int | string $key, mixed $value): mixed; /** * Removes the mapping for a key from this map if it is present. * - * @param array-key $key The key to remove from the map. + * @param K $key The key to remove from the map. * - * @return T|null the previous value associated with key, or `null` if + * @return T | null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function remove($key); + public function remove(int | string $key): mixed; /** * Removes the entry for the specified key only if it is currently mapped to @@ -111,26 +107,24 @@ public function remove($key); * * This performs a strict type check on the value. * - * @param array-key $key The key to remove from the map. + * @param K $key The key to remove from the map. * @param T $value The value to match. * * @return bool true if the value was removed. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function removeIf($key, $value): bool; + public function removeIf(int | string $key, mixed $value): bool; /** * Replaces the entry for the specified key only if it is currently mapped * to some value. * - * @param array-key $key The key to replace. + * @param K $key The key to replace. * @param T $value The value to set at `$key`. * - * @return T|null the previous value associated with key, or `null` if + * @return T | null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function replace($key, $value); + public function replace(int | string $key, mixed $value): mixed; /** * Replaces the entry for the specified key only if currently mapped to the @@ -138,12 +132,11 @@ public function replace($key, $value); * * This performs a strict type check on the value. * - * @param array-key $key The key to remove from the map. + * @param K $key The key to remove from the map. * @param T $oldValue The value to match. * @param T $newValue The value to use as a replacement. * * @return bool true if the value was replaced. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function replaceIf($key, $oldValue, $newValue): bool; + public function replaceIf(int | string $key, mixed $oldValue, mixed $newValue): bool; } diff --git a/lib/Google/vendor/ramsey/collection/src/Map/NamedParameterMap.php b/lib/Google/vendor/ramsey/collection/src/Map/NamedParameterMap.php index 6e391e970..f948e476c 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/NamedParameterMap.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/NamedParameterMap.php @@ -21,13 +21,12 @@ use function array_combine; use function array_key_exists; use function is_int; -use function var_export; /** * `NamedParameterMap` represents a mapping of values to a set of named keys * that may optionally be typed * - * @extends AbstractMap + * @extends AbstractMap */ class NamedParameterMap extends AbstractMap { @@ -39,13 +38,13 @@ class NamedParameterMap extends AbstractMap * * @var array */ - protected array $namedParameters; + private readonly array $namedParameters; /** * Constructs a new `NamedParameterMap`. * * @param array $namedParameters The named parameters defined for this map. - * @param array $data An initial set of data to set on this map. + * @param array $data An initial set of data to set on this map. */ public function __construct(array $namedParameters, array $data = []) { @@ -63,22 +62,12 @@ public function getNamedParameters(): array return $this->namedParameters; } - /** - * @inheritDoc - */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { - if ($offset === null) { - throw new InvalidArgumentException( - 'Map elements are key/value pairs; a key must be provided for ' - . 'value ' . var_export($value, true), - ); - } - if (!array_key_exists($offset, $this->namedParameters)) { throw new InvalidArgumentException( 'Attempting to set value for unconfigured parameter \'' - . $offset . '\'', + . $this->toolValueToString($offset) . '\'', ); } diff --git a/lib/Google/vendor/ramsey/collection/src/Map/TypedMap.php b/lib/Google/vendor/ramsey/collection/src/Map/TypedMap.php index 77ef8d314..4a090c812 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/TypedMap.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/TypedMap.php @@ -14,8 +14,6 @@ namespace Ramsey\Collection\Map; -use Ramsey\Collection\Tool\TypeTrait; - /** * A `TypedMap` represents a map of elements where key and value are typed. * @@ -31,7 +29,7 @@ * * Example usage: * - * ```php + * ``` * $map = new TypedMap('string', Foo::class); * $map['x'] = new Foo(); * foreach ($map as $key => $value) { @@ -53,7 +51,7 @@ * It is preferable to subclass `AbstractTypedMap` to create your own typed map * implementation: * - * ```php + * ``` * class FooTypedMap extends AbstractTypedMap * { * public function getKeyType() @@ -70,7 +68,7 @@ * * … but you also may use the `TypedMap` class: * - * ```php + * ``` * class FooTypedMap extends TypedMap * { * public function __constructor(array $data = []) @@ -86,24 +84,6 @@ */ class TypedMap extends AbstractTypedMap { - use TypeTrait; - - /** - * The data type of keys stored in this collection. - * - * A map key's type is immutable once it is set. For this reason, this - * property is set private. - */ - private string $keyType; - - /** - * The data type of values stored in this collection. - * - * A map value's type is immutable once it is set. For this reason, this - * property is set private. - */ - private string $valueType; - /** * Constructs a map object of the specified key and value types, * optionally with the specified data. @@ -112,11 +92,11 @@ class TypedMap extends AbstractTypedMap * @param string $valueType The data type of the map's values. * @param array $data The initial data to set for this map. */ - public function __construct(string $keyType, string $valueType, array $data = []) - { - $this->keyType = $keyType; - $this->valueType = $valueType; - + public function __construct( + private readonly string $keyType, + private readonly string $valueType, + array $data = [], + ) { parent::__construct($data); } diff --git a/lib/Google/vendor/ramsey/collection/src/Map/TypedMapInterface.php b/lib/Google/vendor/ramsey/collection/src/Map/TypedMapInterface.php index 0308109cc..5a44f0647 100644 --- a/lib/Google/vendor/ramsey/collection/src/Map/TypedMapInterface.php +++ b/lib/Google/vendor/ramsey/collection/src/Map/TypedMapInterface.php @@ -18,8 +18,9 @@ * A `TypedMapInterface` represents a map of elements where key and value are * typed. * + * @template K of array-key * @template T - * @extends MapInterface + * @extends MapInterface */ interface TypedMapInterface extends MapInterface { diff --git a/lib/Google/vendor/ramsey/collection/src/Queue.php b/lib/Google/vendor/ramsey/collection/src/Queue.php index bc8c24e1c..0f5b33740 100644 --- a/lib/Google/vendor/ramsey/collection/src/Queue.php +++ b/lib/Google/vendor/ramsey/collection/src/Queue.php @@ -19,6 +19,8 @@ use Ramsey\Collection\Tool\TypeTrait; use Ramsey\Collection\Tool\ValueToStringTrait; +use function array_key_first; + /** * This class provides a basic implementation of `QueueInterface`, to minimize * the effort required to implement this interface. @@ -32,29 +34,15 @@ class Queue extends AbstractArray implements QueueInterface use TypeTrait; use ValueToStringTrait; - /** - * The type of elements stored in this queue. - * - * A queue's type is immutable once it is set. For this reason, this - * property is set private. - */ - private string $queueType; - - /** - * The index of the head of the queue. - */ - protected int $index = 0; - /** * Constructs a queue object of the specified type, optionally with the * specified data. * - * @param string $queueType The type (FQCN) associated with this queue. - * @param array $data The initial items to store in the collection. + * @param string $queueType The type or class name associated with this queue. + * @param array $data The initial items to store in the queue. */ - public function __construct(string $queueType, array $data = []) + public function __construct(private readonly string $queueType, array $data = []) { - $this->queueType = $queueType; parent::__construct($data); } @@ -65,9 +53,9 @@ public function __construct(string $queueType, array $data = []) * serves only to fulfill the `ArrayAccess` interface requirements. It is * invoked by other operations when adding values to the queue. * - * @throws InvalidArgumentException if $value is of the wrong type + * @throws InvalidArgumentException if $value is of the wrong type. */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { if ($this->checkType($this->getType(), $value) === false) { throw new InvalidArgumentException( @@ -80,11 +68,9 @@ public function offsetSet($offset, $value): void } /** - * @throws InvalidArgumentException if $value is of the wrong type - * - * @inheritDoc + * @throws InvalidArgumentException if $value is of the wrong type. */ - public function add($element): bool + public function add(mixed $element): bool { $this[] = $element; @@ -92,74 +78,67 @@ public function add($element): bool } /** - * @inheritDoc + * @return T + * + * @throws NoSuchElementException if this queue is empty. */ - public function element() + public function element(): mixed { - $element = $this->peek(); - - if ($element === null) { - throw new NoSuchElementException( - 'Can\'t return element from Queue. Queue is empty.', - ); - } - - return $element; + return $this->peek() ?? throw new NoSuchElementException( + 'Can\'t return element from Queue. Queue is empty.', + ); } - /** - * @inheritDoc - */ - public function offer($element): bool + public function offer(mixed $element): bool { try { return $this->add($element); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { return false; } } /** - * @inheritDoc + * @return T | null */ - public function peek() + public function peek(): mixed { - if ($this->count() === 0) { + $index = array_key_first($this->data); + + if ($index === null) { return null; } - return $this[$this->index]; + return $this[$index]; } /** - * @inheritDoc + * @return T | null */ - public function poll() + public function poll(): mixed { - if ($this->count() === 0) { + $index = array_key_first($this->data); + + if ($index === null) { return null; } - $head = $this[$this->index]; - - unset($this[$this->index]); - $this->index++; + $head = $this[$index]; + unset($this[$index]); return $head; } /** - * @inheritDoc + * @return T + * + * @throws NoSuchElementException if this queue is empty. */ - public function remove() + public function remove(): mixed { - $head = $this->poll(); - - if ($head === null) { - throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); - } - - return $head; + return $this->poll() ?? throw new NoSuchElementException( + 'Can\'t return element from Queue. Queue is empty.', + ); } public function getType(): string diff --git a/lib/Google/vendor/ramsey/collection/src/QueueInterface.php b/lib/Google/vendor/ramsey/collection/src/QueueInterface.php index 4f91487fa..f29ce43ab 100644 --- a/lib/Google/vendor/ramsey/collection/src/QueueInterface.php +++ b/lib/Google/vendor/ramsey/collection/src/QueueInterface.php @@ -129,8 +129,7 @@ interface QueueInterface extends ArrayInterface * Implementations should use a more-specific exception that extends * `\RuntimeException`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function add($element): bool; + public function add(mixed $element): bool; /** * Retrieves, but does not remove, the head of this queue. @@ -144,7 +143,7 @@ public function add($element): bool; * * @throws NoSuchElementException if this queue is empty. */ - public function element(); + public function element(): mixed; /** * Inserts the specified element into this queue if it is possible to do so @@ -160,8 +159,7 @@ public function element(); * * @return bool `true` if the element was added to this queue, else `false`. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - public function offer($element): bool; + public function offer(mixed $element): bool; /** * Retrieves, but does not remove, the head of this queue, or returns `null` @@ -169,9 +167,9 @@ public function offer($element): bool; * * @see self::element() * - * @return T|null the head of this queue, or `null` if this queue is empty. + * @return T | null the head of this queue, or `null` if this queue is empty. */ - public function peek(); + public function peek(): mixed; /** * Retrieves and removes the head of this queue, or returns `null` @@ -179,9 +177,9 @@ public function peek(); * * @see self::remove() * - * @return T|null the head of this queue, or `null` if this queue is empty. + * @return T | null the head of this queue, or `null` if this queue is empty. */ - public function poll(); + public function poll(): mixed; /** * Retrieves and removes the head of this queue. @@ -195,7 +193,7 @@ public function poll(); * * @throws NoSuchElementException if this queue is empty. */ - public function remove(); + public function remove(): mixed; /** * Returns the type associated with this queue. diff --git a/lib/Google/vendor/ramsey/collection/src/Set.php b/lib/Google/vendor/ramsey/collection/src/Set.php index c1d37ccca..d60f2487a 100644 --- a/lib/Google/vendor/ramsey/collection/src/Set.php +++ b/lib/Google/vendor/ramsey/collection/src/Set.php @@ -24,11 +24,11 @@ * * Example usage: * - * ``` php + * ``` * $foo = new \My\Foo(); * $set = new Set(\My\Foo::class); * - * $set->add($foo); // returns TRUE, the element don't exists + * $set->add($foo); // returns TRUE, the element doesn't exist * $set->add($foo); // returns FALSE, the element already exists * * $bar = new \My\Foo(); @@ -40,23 +40,15 @@ */ class Set extends AbstractSet { - /** - * The type of elements stored in this set - * - * A set's type is immutable. For this reason, this property is private. - */ - private string $setType; - /** * Constructs a set object of the specified type, optionally with the * specified data. * - * @param string $setType The type (FQCN) associated with this set. + * @param string $setType The type or class name associated with this set. * @param array $data The initial items to store in the set. */ - public function __construct(string $setType, array $data = []) + public function __construct(private readonly string $setType, array $data = []) { - $this->setType = $setType; parent::__construct($data); } diff --git a/lib/Google/vendor/ramsey/collection/src/Sort.php b/lib/Google/vendor/ramsey/collection/src/Sort.php new file mode 100644 index 000000000..0c3c19213 --- /dev/null +++ b/lib/Google/vendor/ramsey/collection/src/Sort.php @@ -0,0 +1,31 @@ + + * @license http://opensource.org/licenses/MIT MIT + */ + +declare(strict_types=1); + +namespace Ramsey\Collection; + +/** + * Collection sorting + */ +enum Sort: string +{ + /** + * Sort items in a collection in ascending order. + */ + case Ascending = 'asc'; + + /** + * Sort items in a collection in descending order. + */ + case Descending = 'desc'; +} diff --git a/lib/Google/vendor/ramsey/collection/src/Tool/TypeTrait.php b/lib/Google/vendor/ramsey/collection/src/Tool/TypeTrait.php index 728d44b65..ac51b7f10 100644 --- a/lib/Google/vendor/ramsey/collection/src/Tool/TypeTrait.php +++ b/lib/Google/vendor/ramsey/collection/src/Tool/TypeTrait.php @@ -36,39 +36,22 @@ trait TypeTrait * @param string $type The type to check the value against. * @param mixed $value The value to check. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - protected function checkType(string $type, $value): bool + protected function checkType(string $type, mixed $value): bool { - switch ($type) { - case 'array': - return is_array($value); - case 'bool': - case 'boolean': - return is_bool($value); - case 'callable': - return is_callable($value); - case 'float': - case 'double': - return is_float($value); - case 'int': - case 'integer': - return is_int($value); - case 'null': - return $value === null; - case 'numeric': - return is_numeric($value); - case 'object': - return is_object($value); - case 'resource': - return is_resource($value); - case 'scalar': - return is_scalar($value); - case 'string': - return is_string($value); - case 'mixed': - return true; - default: - return $value instanceof $type; - } + return match ($type) { + 'array' => is_array($value), + 'bool', 'boolean' => is_bool($value), + 'callable' => is_callable($value), + 'float', 'double' => is_float($value), + 'int', 'integer' => is_int($value), + 'null' => $value === null, + 'numeric' => is_numeric($value), + 'object' => is_object($value), + 'resource' => is_resource($value), + 'scalar' => is_scalar($value), + 'string' => is_string($value), + 'mixed' => true, + default => $value instanceof $type, + }; } } diff --git a/lib/Google/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php b/lib/Google/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php index e10824283..bbe27b441 100644 --- a/lib/Google/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php +++ b/lib/Google/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php @@ -14,9 +14,11 @@ namespace Ramsey\Collection\Tool; -use Ramsey\Collection\Exception\ValueExtractionException; +use Ramsey\Collection\Exception\InvalidPropertyOrMethod; +use Ramsey\Collection\Exception\UnsupportedOperationException; +use ReflectionProperty; -use function get_class; +use function is_array; use function is_object; use function method_exists; use function property_exists; @@ -28,34 +30,71 @@ trait ValueExtractorTrait { /** - * Extracts the value of the given property or method from the object. + * Returns the type associated with this collection. + */ + abstract public function getType(): string; + + /** + * Extracts the value of the given property, method, or array key from the + * element. + * + * If `$propertyOrMethod` is `null`, we return the element as-is. * - * @param mixed $object The object to extract the value from. - * @param string $propertyOrMethod The property or method for which the + * @param mixed $element The element to extract the value from. + * @param string | null $propertyOrMethod The property or method for which the * value should be extracted. * - * @return mixed the value extracted from the specified property or method. + * @return mixed the value extracted from the specified property, method, + * or array key, or the element itself. * - * @throws ValueExtractionException if the method or property is not defined. + * @throws InvalidPropertyOrMethod + * @throws UnsupportedOperationException */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - protected function extractValue($object, string $propertyOrMethod) + protected function extractValue(mixed $element, ?string $propertyOrMethod): mixed { - if (!is_object($object)) { - throw new ValueExtractionException('Unable to extract a value from a non-object'); + if ($propertyOrMethod === null) { + return $element; + } + + if (!is_object($element) && !is_array($element)) { + throw new UnsupportedOperationException(sprintf( + 'The collection type "%s" does not support the $propertyOrMethod parameter', + $this->getType(), + )); + } + + if (is_array($element)) { + return $element[$propertyOrMethod] ?? throw new InvalidPropertyOrMethod(sprintf( + 'Key or index "%s" not found in collection elements', + $propertyOrMethod, + )); + } + + if (property_exists($element, $propertyOrMethod) && method_exists($element, $propertyOrMethod)) { + $reflectionProperty = new ReflectionProperty($element, $propertyOrMethod); + if ($reflectionProperty->isPublic()) { + return $element->$propertyOrMethod; + } + + return $element->{$propertyOrMethod}(); + } + + if (property_exists($element, $propertyOrMethod)) { + return $element->$propertyOrMethod; } - if (property_exists($object, $propertyOrMethod)) { - return $object->$propertyOrMethod; + if (method_exists($element, $propertyOrMethod)) { + return $element->{$propertyOrMethod}(); } - if (method_exists($object, $propertyOrMethod)) { - return $object->{$propertyOrMethod}(); + if (isset($element->$propertyOrMethod)) { + return $element->$propertyOrMethod; } - throw new ValueExtractionException( - // phpcs:ignore SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall - sprintf('Method or property "%s" not defined in %s', $propertyOrMethod, get_class($object)), - ); + throw new InvalidPropertyOrMethod(sprintf( + 'Method or property "%s" not defined in %s', + $propertyOrMethod, + $element::class, + )); } } diff --git a/lib/Google/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php b/lib/Google/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php index cacefc8b6..40c780325 100644 --- a/lib/Google/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php +++ b/lib/Google/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php @@ -16,7 +16,7 @@ use DateTimeInterface; -use function get_class; +use function assert; use function get_resource_type; use function is_array; use function is_bool; @@ -24,7 +24,6 @@ use function is_object; use function is_resource; use function is_scalar; -use function var_export; /** * Provides functionality to express a value as string @@ -46,8 +45,7 @@ trait ValueToStringTrait * * @param mixed $value the value to return as a string. */ - // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint - protected function toolValueToString($value): string + protected function toolValueToString(mixed $value): string { // null if ($value === null) { @@ -74,16 +72,13 @@ protected function toolValueToString($value): string return '(' . get_resource_type($value) . ' resource #' . (int) $value . ')'; } - // If we don't know what it is, use var_export(). - if (!is_object($value)) { - return '(' . var_export($value, true) . ')'; - } - // From here, $value should be an object. + assert(is_object($value)); // __toString() is implemented if (is_callable([$value, '__toString'])) { - return (string) $value->__toString(); + /** @var string */ + return $value->__toString(); } // object of type \DateTime @@ -92,7 +87,6 @@ protected function toolValueToString($value): string } // unknown type - // phpcs:ignore SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall - return '(' . get_class($value) . ' Object)'; + return '(' . $value::class . ' Object)'; } } diff --git a/lib/Google/vendor/ramsey/uuid/composer.json b/lib/Google/vendor/ramsey/uuid/composer.json index b34d9b108..178019f42 100644 --- a/lib/Google/vendor/ramsey/uuid/composer.json +++ b/lib/Google/vendor/ramsey/uuid/composer.json @@ -10,7 +10,7 @@ ], "require": { "php": "^8.0", - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", + "brick/math": "^0.8.16 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", "ramsey/collection": "^1.2 || ^2.0" }, "require-dev": { diff --git a/lib/Google/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php b/lib/Google/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php index 67dbf8871..371a66b43 100644 --- a/lib/Google/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php +++ b/lib/Google/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php @@ -110,7 +110,7 @@ public function convertTime(Hexadecimal $uuidTimestamp): Time // Convert the 100-nanosecond intervals into seconds and microseconds. $splitTime = $this->splitTime( - ((int) $timestamp->toString() - self::GREGORIAN_TO_UNIX_INTERVALS) / self::SECOND_INTERVALS, + ($timestamp->toString() - self::GREGORIAN_TO_UNIX_INTERVALS) / self::SECOND_INTERVALS, ); if (count($splitTime) === 0) { diff --git a/lib/Google/vendor/rize/uri-template/.php-cs-fixer.dist.php b/lib/Google/vendor/rize/uri-template/.php-cs-fixer.dist.php new file mode 100644 index 000000000..cb2af3860 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/.php-cs-fixer.dist.php @@ -0,0 +1,19 @@ +setParallelConfig(ParallelConfigFactory::detect()) + ->setRiskyAllowed(true) + ->setUsingCache(false) + ->setRules([ + '@PER-CS2.0' => true, + ]) + ->setFinder( + (new Finder()) + ->in([__DIR__ . '/src', __DIR__ . '/tests']) + ); \ No newline at end of file diff --git a/lib/Google/vendor/rize/uri-template/README.md b/lib/Google/vendor/rize/uri-template/README.md index 52f52fefc..f2293df83 100644 --- a/lib/Google/vendor/rize/uri-template/README.md +++ b/lib/Google/vendor/rize/uri-template/README.md @@ -2,10 +2,13 @@ This is a URI Template implementation in PHP based on [RFC 6570 URI Template](http://tools.ietf.org/html/rfc6570). In addition to URI expansion, it also supports URI extraction (used by [Google Cloud Core](https://github.com/googleapis/google-cloud-php-core) and [Google Cloud Client Library](https://github.com/googleapis/google-cloud-php)). -![CI](https://github.com/rize/UriTemplate/workflows/CI/badge.svg) [![Total Downloads](https://poser.pugx.org/rize/uri-template/downloads.png)](https://packagist.org/packages/rize/uri-template) -[![Financial Contributors on Open Collective](https://opencollective.com/rize-uri-template/all/badge.svg?label=financial+contributors)](https://opencollective.com/rize-uri-template) +![CI](https://github.com/rize/UriTemplate/workflows/CI/badge.svg) [![Total Downloads](https://poser.pugx.org/rize/uri-template/downloads)](https://packagist.org/packages/rize/uri-template) [![Latest Stable Version](https://poser.pugx.org/rize/uri-template/v)](https://packagist.org/packages/rize/uri-template) [![PHP Version Require](https://poser.pugx.org/rize/uri-template/require/php)](https://packagist.org/packages/rize/uri-template) -* [Node.js/Javascript](https://github.com/rezigned/uri-template.js) URI Template +> [!NOTE] +> +> Due to the deprecation of implictly nullable parameter types in [PHP 8.4](https://wiki.php.net/rfc/deprecate-implicitly-nullable-types), we must introduce breaking change by adding explicit nullable types (`?T`) which requires PHP 7.1+. +> +> As a result, version [0.4.0](https://github.com/rize/UriTemplate/releases/tag/0.4.0) and later will no longer support PHP versions below 8.1. ## Usage @@ -217,6 +220,7 @@ Using `composer` * **0.2.5** Add strict mode support for `extract` method * **0.3.0** Improve code quality + RFC3986 support for `extract` method by @Maks3w * **0.3.1** Improve `extract` method to parse two or more adjacent variables separated by dot by @corleonis +* **0.4.0** Fixes the deprecation of implicitly nullable parameter types introduced in PHP 8.4. This version requires PHP 8.1 or later. ## Contributors diff --git a/lib/Google/vendor/rize/uri-template/composer.json b/lib/Google/vendor/rize/uri-template/composer.json index cec985a48..0dbfd2ead 100644 --- a/lib/Google/vendor/rize/uri-template/composer.json +++ b/lib/Google/vendor/rize/uri-template/composer.json @@ -11,10 +11,12 @@ } ], "require": { - "php": ">=5.3.0" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "~4.8.36" + "phpunit/phpunit": "~10.0", + "phpstan/phpstan": "^1.12", + "friendsofphp/php-cs-fixer": "^3.63" }, "autoload": { "psr-4": { @@ -22,6 +24,9 @@ } }, "scripts": { - "test": "vendor/bin/phpunit test/" + "test": "vendor/bin/phpunit", + "cs": "vendor/bin/php-cs-fixer fix --dry-run", + "cs-fix": "vendor/bin/php-cs-fixer fix", + "phpstan": "vendor/bin/phpstan" } } diff --git a/lib/Google/vendor/rize/uri-template/phpstan.neon b/lib/Google/vendor/rize/uri-template/phpstan.neon new file mode 100644 index 000000000..a76a83296 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 5 + paths: + - src + - tests \ No newline at end of file diff --git a/lib/Google/vendor/rize/uri-template/phpunit.xml b/lib/Google/vendor/rize/uri-template/phpunit.xml new file mode 100644 index 000000000..530f84f33 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/phpunit.xml @@ -0,0 +1,22 @@ + + + + + tests + + + + + + src + + + diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate.php index 330f39b80..51a841ddc 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate.php @@ -5,47 +5,38 @@ use Rize\UriTemplate\Parser; /** - * URI Template + * URI Template. */ class UriTemplate { - /** - * @var Parser - */ - protected $parser, - $parsed = array(), - $base_uri, - $params = array(); - - public function __construct($base_uri = '', $params = array(), Parser $parser = null) + protected Parser $parser; + protected array $parsed = []; + + public function __construct(protected string $base_uri = '', protected array $params = [], ?Parser $parser = null) { - $this->base_uri = $base_uri; - $this->params = $params; - $this->parser = $parser ?: $this->createNodeParser(); + $this->parser = $parser ?: $this->createNodeParser(); } /** - * Expands URI Template + * Expands URI Template. * - * @param string $uri URI Template - * @param array $params URI Template's parameters - * @return string + * @param mixed $params */ - public function expand($uri, $params = array()) + public function expand(string $uri, $params = []): string { $params += $this->params; - $uri = $this->base_uri.$uri; - $result = array(); + $uri = $this->base_uri . $uri; + $result = []; // quick check - if (($start = strpos($uri, '{')) === false) { + if (!str_contains($uri, '{')) { return $uri; } $parser = $this->parser; $nodes = $parser->parse($uri); - foreach($nodes as $node) { + foreach ($nodes as $node) { $result[] = $node->expand($parser, $params); } @@ -53,48 +44,48 @@ public function expand($uri, $params = array()) } /** - * Extracts variables from URI + * Extracts variables from URI. * - * @param string $template - * @param string $uri - * @param bool $strict This will perform a full match * @return null|array params or null if not match and $strict is true */ - public function extract($template, $uri, $strict = false) + public function extract(string $template, string $uri, bool $strict = false): ?array { - $params = array(); + $params = []; $nodes = $this->parser->parse($template); - # PHP 8.1.0RC4-dev still throws deprecation warning for `strlen`. - # $uri = (string) $uri; - - foreach($nodes as $node) { + // PHP 8.1.0RC4-dev still throws deprecation warning for `strlen`. + // $uri = (string) $uri; + foreach ($nodes as $node) { // if strict is given, and there's no remaining uri just return null - if ($strict && !strlen((string) $uri)) { + if ($strict && (string) $uri === '') { return null; } - // uri'll be truncated from the start when a match is found + // URI will be truncated from the start when a match is found $match = $node->match($this->parser, $uri, $params, $strict); - list($uri, $params) = $match; + if ($match === null) { + return null; + } + + [$uri, $params] = $match; } // if there's remaining $uri, matching is failed - if ($strict && strlen((string) $uri)) { + if ($strict && (string) $uri !== '') { return null; } return $params; } - public function getParser() + public function getParser(): Parser { return $this->parser; } - protected function createNodeParser() + protected function createNodeParser(): Parser { static $parser; @@ -102,6 +93,6 @@ protected function createNodeParser() return $parser; } - return $parser = new Parser; + return $parser = new Parser(); } } diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Abstraction.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Abstraction.php index 3f2e3501e..7332df5c4 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Abstraction.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Abstraction.php @@ -5,61 +5,45 @@ use Rize\UriTemplate\Parser; /** - * Base class for all Nodes + * Base class for all Nodes. */ abstract class Abstraction { - /** - * @var string - */ - private $token; - - public function __construct($token) - { - $this->token = $token; - } + public function __construct(private readonly string $token) {} /** * Expands URI template * - * @param Parser $parser - * @param array $params - * @return null|string + * @param array $params */ - public function expand(Parser $parser, array $params = array()) + public function expand(Parser $parser, array $params = []): ?string { return $this->token; } /** - * Matches given URI against current node + * Matches given URI against current node. + * + * @param array $params * - * @param Parser $parser - * @param string $uri - * @param array $params - * @param bool $strict - * @return null|array `uri and params` or `null` if not match and $strict is true + * @return null|array{0: string, 1: array} `uri and params` or `null` if not match and $strict is true */ - public function match(Parser $parser, $uri, $params = array(), $strict = false) + public function match(Parser $parser, string $uri, array $params = [], bool $strict = false): ?array { // match literal string from start to end - $length = strlen($this->token); - if (substr($uri, 0, $length) === $this->token) { - $uri = substr($uri, $length); + if (str_starts_with($uri, $this->token)) { + $uri = substr($uri, strlen($this->token)); } // when there's no match, just return null if strict mode is given - else if ($strict) { + elseif ($strict) { return null; } - return array($uri, $params); + return [$uri, $params]; } - /** - * @return string - */ - public function getToken() + public function getToken(): string { return $this->token; } diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Expression.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Expression.php index 892ccc695..a31fa24c2 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Expression.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Expression.php @@ -2,83 +2,53 @@ namespace Rize\UriTemplate\Node; -use Rize\UriTemplate\Parser; use Rize\UriTemplate\Operator; +use Rize\UriTemplate\Parser; -/** - * Description - */ class Expression extends Abstraction { /** - * @var Operator\Abstraction - */ - private $operator; - - /** - * @var array + * @param string $forwardLookupSeparator */ - private $variables = array(); - - /** - * Whether to do a forward lookup for a given separator - * @var string + public function __construct(string $token, private readonly Operator\Abstraction $operator, private readonly ?array $variables = null, /** + * Whether to do a forward lookup for a given separator. */ - private $forwardLookupSeparator; - - public function __construct($token, Operator\Abstraction $operator, array $variables = null, $forwardLookupSeparator = null) + private $forwardLookupSeparator = null) { parent::__construct($token); - $this->operator = $operator; - $this->variables = $variables; - $this->forwardLookupSeparator = $forwardLookupSeparator; } - /** - * @return Operator\Abstraction - */ - public function getOperator() + public function getOperator(): Operator\Abstraction { return $this->operator; } - /** - * @return array - */ - public function getVariables() + public function getVariables(): ?array { return $this->variables; } - /** - * @return string - */ - public function getForwardLookupSeparator() + public function getForwardLookupSeparator(): string { return $this->forwardLookupSeparator; } - /** - * @param string $forwardLookupSeparator - */ - public function setForwardLookupSeparator($forwardLookupSeparator) + public function setForwardLookupSeparator(string $forwardLookupSeparator): void { $this->forwardLookupSeparator = $forwardLookupSeparator; } - /** - * @param Parser $parser - * @param array $params - * @return null|string - */ - public function expand(Parser $parser, array $params = array()) + public function expand(Parser $parser, array $params = []): ?string { - $data = array(); - $op = $this->operator; + $data = []; + $op = $this->operator; - // check for variable modifiers - foreach($this->variables as $var) { + if ($this->variables === null) { + return $op->first; + } + // check for variable modifiers + foreach ($this->variables as $var) { $val = $op->expand($parser, $var, $params); // skip null value @@ -87,25 +57,21 @@ public function expand(Parser $parser, array $params = array()) } } - return $data ? $op->first.implode($op->sep, $data) : null; + return $data ? $op->first . implode($op->sep, $data) : null; } /** - * Matches given URI against current node + * Matches given URI against current node. * - * @param Parser $parser - * @param string $uri - * @param array $params - * @param bool $strict * @return null|array `uri and params` or `null` if not match and $strict is true */ - public function match(Parser $parser, $uri, $params = array(), $strict = false) + public function match(Parser $parser, string $uri, array $params = [], bool $strict = false): ?array { $op = $this->operator; // check expression operator first if ($op->id && isset($uri[0]) && $uri[0] !== $op->id) { - return array($uri, $params); + return [$uri, $params]; } // remove operator from input @@ -113,9 +79,8 @@ public function match(Parser $parser, $uri, $params = array(), $strict = false) $uri = substr($uri, 1); } - foreach($this->sortVariables($this->variables) as $var) { - /** @var \Rize\UriTemplate\Node\Variable $regex */ - $regex = '#'.$op->toRegex($parser, $var).'#'; + foreach ($this->sortVariables($this->variables) as $var) { + $regex = '#' . $op->toRegex($parser, $var) . '#'; $val = null; // do a forward lookup and get just the relevant part @@ -128,14 +93,13 @@ public function match(Parser $parser, $uri, $params = array(), $strict = false) } if (preg_match($regex, $preparedUri, $match)) { - // remove matched part from input - $preparedUri = preg_replace($regex, '', $preparedUri, $limit = 1); + $preparedUri = preg_replace($regex, '', $preparedUri, 1); $val = $op->extract($parser, $var, $match[0]); } // if strict is given, we quit immediately when there's no match - else if ($strict) { + elseif ($strict) { return null; } @@ -144,21 +108,16 @@ public function match(Parser $parser, $uri, $params = array(), $strict = false) $params[$var->getToken()] = $val; } - return array($uri, $params); + return [$uri, $params]; } /** * Sort variables before extracting data from uri. * We have to sort vars by non-explode to explode. - * - * @param array $vars - * @return array */ - protected function sortVariables(array $vars) + protected function sortVariables(array $vars): array { - usort($vars, function($a, $b) { - return $a->options['modifier'] >= $b->options['modifier'] ? 1 : -1; - }); + usort($vars, static fn($a, $b) => $a->options['modifier'] <=> $b->options['modifier']); return $vars; } diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Literal.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Literal.php index 1c54da129..bc939b6b0 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Literal.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Node/Literal.php @@ -1,11 +1,5 @@ - null, - 'value' => null, - ); + /** + * Variable name without modifier + * e.g. 'term:1' becomes 'term'. + */ + public string $name; + public array $options = ['modifier' => null, 'value' => null]; - public function __construct($token, array $options = array()) + public function __construct(string $token, array $options = []) { parent::__construct($token); $this->options = $options + $this->options; @@ -25,9 +19,9 @@ public function __construct($token, array $options = array()) // normalize var name e.g. from 'term:1' becomes 'term' $name = $token; if ($options['modifier'] === ':') { - $name = substr($name, 0, strpos($name, $options['modifier'])); + $name = strstr($name, $options['modifier'], true); } $this->name = $name; } -} \ No newline at end of file +} diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Abstraction.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Abstraction.php index 1b7633762..856bd1c8f 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Abstraction.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Abstraction.php @@ -14,7 +14,7 @@ * | named | false false false false true true true false | * | ifemp | "" "" "" "" "" "=" "=" "" | * | allow | U U+R U U U U U U+R | - * `------------------------------------------------------------------' + * `------------------------------------------------------------------'. * * named = false * | 1 | {/list} /red,green,blue | {$value}*(?:,{$value}+)* @@ -35,7 +35,7 @@ * * RESERVED * -------- - * RFC 1738 ":" | "/" | "?" | | "@" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "-" | "_" | "." | + * RFC 1738 ":" | "/" | "?" | | "@" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "-" | "_" | "." | * RFC 3986 ":" | "/" | "?" | "#" | "[" | "]" | "@" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" * RFC 6570 ":" | "/" | "?" | "#" | "[" | "]" | "@" | "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=" * @@ -47,108 +47,109 @@ abstract class Abstraction * start - Variable offset position, level-2 operators start at 1 * (exclude operator itself, e.g. {?query}) * first - If variables found, prepend this value to it - * named - Whether or not the expansion includes the variable or key name - * reserved - union of (unreserved / reserved / pct-encoded) + * named - Whether the expansion includes the variable or key name + * reserved - union of (unreserved / reserved / pct-encoded). */ - public $id, - $named, - $sep, - $empty, - $reserved, - $start, - $first; - - protected static $types = array( - '' => array( - 'sep' => ',', - 'named' => false, - 'empty' => '', - 'reserved' => false, - 'start' => 0, - 'first' => null, - ), - '+' => array( - 'sep' => ',', - 'named' => false, - 'empty' => '', - 'reserved' => true, - 'start' => 1, - 'first' => null, - ), - '.' => array( - 'sep' => '.', - 'named' => false, - 'empty' => '', - 'reserved' => false, - 'start' => 1, - 'first' => '.', - ), - '/' => array( - 'sep' => '/', - 'named' => false, - 'empty' => '', - 'reserved' => false, - 'start' => 1, - 'first' => '/', - ), - ';' => array( - 'sep' => ';', - 'named' => true, - 'empty' => '', - 'reserved' => false, - 'start' => 1, - 'first' => ';', - ), - '?' => array( - 'sep' => '&', - 'named' => true, - 'empty' => '=', - 'reserved' => false, - 'start' => 1, - 'first' => '?', - ), - '&' => array( - 'sep' => '&', - 'named' => true, - 'empty' => '=', - 'reserved' => false, - 'start' => 1, - 'first' => '&', - ), - '#' => array( - 'sep' => ',', - 'named' => false, - 'empty' => '', - 'reserved' => true, - 'start' => 1, - 'first' => '#', - ), - ), - $loaded = array(); - - /** - * gen-delims | sub-delims - */ - public static $reserved_chars = array( - '%3A' => ':', - '%2F' => '/', - '%3F' => '?', - '%23' => '#', - '%5B' => '[', - '%5D' => ']', - '%40' => '@', - '%21' => '!', - '%24' => '$', - '%26' => '&', - '%27' => "'", - '%28' => '(', - '%29' => ')', - '%2A' => '*', - '%2B' => '+', - '%2C' => ',', - '%3B' => ';', - '%3D' => '=', - ); + public $id; + public $named; + public $sep; + public $empty; + public $reserved; + public $start; + public $first; + + /** + * gen-delims | sub-delims. + */ + public static $reserved_chars = [ + '%3A' => ':', + '%2F' => '/', + '%3F' => '?', + '%23' => '#', + '%5B' => '[', + '%5D' => ']', + '%40' => '@', + '%21' => '!', + '%24' => '$', + '%26' => '&', + '%27' => "'", + '%28' => '(', + '%29' => ')', + '%2A' => '*', + '%2B' => '+', + '%2C' => ',', + '%3B' => ';', + '%3D' => '=', + ]; + + protected static $types = [ + '' => [ + 'sep' => ',', + 'named' => false, + 'empty' => '', + 'reserved' => false, + 'start' => 0, + 'first' => null, + ], + '+' => [ + 'sep' => ',', + 'named' => false, + 'empty' => '', + 'reserved' => true, + 'start' => 1, + 'first' => null, + ], + '.' => [ + 'sep' => '.', + 'named' => false, + 'empty' => '', + 'reserved' => false, + 'start' => 1, + 'first' => '.', + ], + '/' => [ + 'sep' => '/', + 'named' => false, + 'empty' => '', + 'reserved' => false, + 'start' => 1, + 'first' => '/', + ], + ';' => [ + 'sep' => ';', + 'named' => true, + 'empty' => '', + 'reserved' => false, + 'start' => 1, + 'first' => ';', + ], + '?' => [ + 'sep' => '&', + 'named' => true, + 'empty' => '=', + 'reserved' => false, + 'start' => 1, + 'first' => '?', + ], + '&' => [ + 'sep' => '&', + 'named' => true, + 'empty' => '=', + 'reserved' => false, + 'start' => 1, + 'first' => '&', + ], + '#' => [ + 'sep' => ',', + 'named' => false, + 'empty' => '', + 'reserved' => true, + 'start' => 1, + 'first' => '#', + ], + ]; + + protected static $loaded = []; /** * RFC 3986 Allowed path characters regex except the path delimiter '/'. @@ -166,29 +167,29 @@ abstract class Abstraction public function __construct($id, $named, $sep, $empty, $reserved, $start, $first) { - $this->id = $id; + $this->id = $id; $this->named = $named; - $this->sep = $sep; + $this->sep = $sep; $this->empty = $empty; $this->start = $start; $this->first = $first; $this->reserved = $reserved; } - abstract public function toRegex(Parser $parser, Node\Variable $var); + abstract public function toRegex(Parser $parser, Node\Variable $var): string; - public function expand(Parser $parser, Node\Variable $var, array $params = array()) + public function expand(Parser $parser, Node\Variable $var, array $params = []) { $options = $var->options; $name = $var->name; - $is_explode = in_array($options['modifier'], array('*', '%')); + $is_explode = in_array($options['modifier'], ['*', '%']); // skip null if (!isset($params[$name])) { return null; } - $val = $params[$name]; + $val = $params[$name]; // This algorithm is based on RFC6570 http://tools.ietf.org/html/rfc6570 // non-array, e.g. string @@ -197,38 +198,32 @@ public function expand(Parser $parser, Node\Variable $var, array $params = array } // non-explode ':' - else if (!$is_explode) { + if (!$is_explode) { return $this->expandNonExplode($parser, $var, $val); } // explode '*', '%' - else { - return $this->expandExplode($parser, $var, $val); - } + + return $this->expandExplode($parser, $var, $val); } public function expandString(Parser $parser, Node\Variable $var, $val) { - $val = (string)$val; + $val = (string) $val; $options = $var->options; $result = null; if ($options['modifier'] === ':') { - $val = substr($val, 0, (int)$options['value']); + $val = substr($val, 0, (int) $options['value']); } - return $result.$this->encode($parser, $var, $val); + return $result . $this->encode($parser, $var, $val); } /** - * Non explode modifier ':' - * - * @param Parser $parser - * @param Node\Variable $var - * @param array $val - * @return null|string + * Non explode modifier ':'. */ - public function expandNonExplode(Parser $parser, Node\Variable $var, array $val) + public function expandNonExplode(Parser $parser, Node\Variable $var, array $val): ?string { if (empty($val)) { return null; @@ -238,14 +233,9 @@ public function expandNonExplode(Parser $parser, Node\Variable $var, array $val) } /** - * Explode modifier '*', '%' - * - * @param Parser $parser - * @param Node\Variable $var - * @param array $val - * @return null|string + * Explode modifier '*', '%'. */ - public function expandExplode(Parser $parser, Node\Variable $var, array $val) + public function expandExplode(Parser $parser, Node\Variable $var, array $val): ?string { if (empty($val)) { return null; @@ -255,17 +245,13 @@ public function expandExplode(Parser $parser, Node\Variable $var, array $val) } /** - * Encodes variable according to spec (reserved or unreserved) - * - * @param Parser $parser - * @param Node\Variable $var - * @param mixed $values + * Encodes variable according to spec (reserved or unreserved). * * @return string encoded string */ - public function encode(Parser $parser, Node\Variable $var, $values) + public function encode(Parser $parser, Node\Variable $var, mixed $values) { - $values = (array)$values; + $values = (array) $values; $list = isset($values[0]); $reserved = $this->reserved; $maps = static::$reserved_chars; @@ -277,13 +263,12 @@ public function encode(Parser $parser, Node\Variable $var, $values) $assoc_sep = $sep = ','; } - array_walk($values, function(&$v, $k) use ($assoc_sep, $reserved, $list, $maps) { - + array_walk($values, function (&$v, $k) use ($assoc_sep, $reserved, $list, $maps): void { $encoded = rawurlencode($v); // assoc? encode key too if (!$list) { - $encoded = rawurlencode($k).$assoc_sep.$encoded; + $encoded = rawurlencode($k) . $assoc_sep . $encoded; } // rawurlencode is compliant with 'unreserved' set @@ -293,11 +278,10 @@ public function encode(Parser $parser, Node\Variable $var, $values) // decode chars in reserved set else { - $v = str_replace( array_keys($maps), $maps, - $encoded + $encoded, ); } }); @@ -306,71 +290,59 @@ public function encode(Parser $parser, Node\Variable $var, $values) } /** - * Decodes variable - * - * @param Parser $parser - * @param Node\Variable $var - * @param mixed $values + * Decodes variable. * * @return string decoded string */ - public function decode(Parser $parser, Node\Variable $var, $values) + public function decode(Parser $parser, Node\Variable $var, mixed $values) { $single = !is_array($values); - $values = (array)$values; + $values = (array) $values; - array_walk($values, function(&$v, $k) { + array_walk($values, function (&$v, $k): void { $v = rawurldecode($v); }); return $single ? reset($values) : $values; } - + /** - * Extracts value from variable - * - * @param Parser $parser - * @param Node\Variable $var - * @param string $data - * @return string + * Extracts value from variable. */ - public function extract(Parser $parser, Node\Variable $var, $data) + public function extract(Parser $parser, Node\Variable $var, string $data): array|string { - $value = $data; - $vals = array_filter(explode($this->sep, $data)); + $value = $data; + $vals = array_filter(explode($this->sep, $data)); $options = $var->options; switch ($options['modifier']) { - case '*': - $data = array(); - foreach($vals as $val) { - - if (strpos($val, '=') !== false) { - list($k, $v) = explode('=', $val); - $data[$k] = $v; - } - - else { - $data[] = $val; + $value = []; + foreach ($vals as $val) { + if (str_contains($val, '=')) { + [$k, $v] = explode('=', $val); + $value[$k] = $v; + } else { + $value[] = $val; } } break; + case ':': break; - default: - $data = strpos($data, $this->sep) !== false ? $vals : $value; + default: + $value = str_contains($value, (string) $this->sep) ? $vals : $value; } - return $this->decode($parser, $var, $data); + return $this->decode($parser, $var, $value); } public static function createById($id) { if (!isset(static::$types[$id])) { - throw new \Exception("Invalid operator [$id]"); + throw new \InvalidArgumentException("Invalid operator [{$id}]"); } if (isset(static::$loaded[$id])) { @@ -378,31 +350,24 @@ public static function createById($id) } $op = static::$types[$id]; - $class = __NAMESPACE__.'\\'.($op['named'] ? 'Named' : 'UnNamed'); + $class = __NAMESPACE__ . '\\' . ($op['named'] ? 'Named' : 'UnNamed'); return static::$loaded[$id] = new $class($id, $op['named'], $op['sep'], $op['empty'], $op['reserved'], $op['start'], $op['first']); } - public static function isValid($id) + public static function isValid($id): bool { return isset(static::$types[$id]); } /** - * Returns the correct regex given the variable location in the URI - * - * @return string + * Returns the correct regex given the variable location in the URI. */ - protected function getRegex() + protected function getRegex(): string { - switch ($this->id) { - case '?': - case '&': - case '#': - return self::$queryRegex; - case ';': - default: - return self::$pathRegex; - } + return match ($this->id) { + '?', '&', '#' => self::$queryRegex, + default => self::$pathRegex, + }; } } diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Named.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Named.php index 708710ce1..2c0a505de 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Named.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/Named.php @@ -10,49 +10,51 @@ * | 2 | {?list*} ?list=red&list=green&list=blue | {name}+=(?:{$value}+(?:{sep}{name}+={$value}*))* * | 3 | {?keys} ?keys=semi,%3B,dot,.,comma,%2C | (same as 1) * | 4 | {?keys*} ?semi=%3B&dot=.&comma=%2C | (same as 2) - * | 5 | {?list*} ?list[]=red&list[]=green&list[]=blue | {name[]}+=(?:{$value}+(?:{sep}{name[]}+={$value}*))* + * | 5 | {?list*} ?list[]=red&list[]=green&list[]=blue | {name[]}+=(?:{$value}+(?:{sep}{name[]}+={$value}*))*. */ class Named extends Abstraction { - public function toRegex(Parser $parser, Node\Variable $var) + public function toRegex(Parser $parser, Node\Variable $var): string { - $regex = null; $name = $var->name; $value = $this->getRegex(); $options = $var->options; if ($options['modifier']) { - switch($options['modifier']) { + switch ($options['modifier']) { case '*': // 2 | 4 $regex = "{$name}+=(?:{$value}+(?:{$this->sep}{$name}+={$value}*)*)" . "|{$value}+=(?:{$value}+(?:{$this->sep}{$value}+={$value}*)*)"; + break; + case ':': - $regex = "{$value}\{0,{$options['value']}\}"; + $regex = "{$value}\\{0,{$options['value']}\\}"; + break; case '%': // 5 - $name = $name.'+(?:%5B|\[)[^=]*='; + $name .= '+(?:%5B|\[)[^=]*='; $regex = "{$name}(?:{$value}+(?:{$this->sep}{$name}{$value}*)*)"; + break; + default: - throw new \Exception("Unknown modifier `{$options['modifier']}`"); + throw new \InvalidArgumentException("Unknown modifier `{$options['modifier']}`"); } - } - - else { + } else { // 1, 3 $regex = "{$name}=(?:{$value}+(?:,{$value}+)*)*"; } - return '(?:&)?'.$regex; + return '(?:&)?' . $regex; } - public function expandString(Parser $parser, Node\Variable $var, $val) + public function expandString(Parser $parser, Node\Variable $var, $val): string { - $val = (string)$val; + $val = (string) $val; $options = $var->options; $result = $this->encode($parser, $var, $var->name); @@ -61,61 +63,42 @@ public function expandString(Parser $parser, Node\Variable $var, $val) return $result . $this->empty; } - else { - $result .= '='; - } + $result .= '='; if ($options['modifier'] === ':') { - $val = mb_substr($val, 0, (int)$options['value']); + $val = mb_substr($val, 0, (int) $options['value']); } - return $result.$this->encode($parser, $var, $val); + return $result . $this->encode($parser, $var, $val); } - public function expandNonExplode(Parser $parser, Node\Variable $var, array $val) + public function expandNonExplode(Parser $parser, Node\Variable $var, array $val): ?string { if (empty($val)) { return null; } - $result = $this->encode($parser, $var, $var->name); - - if (empty($val)) { - return $result . $this->empty; - } + $result = $this->encode($parser, $var, $var->name); - else { - $result .= '='; - } + $result .= '='; - return $result.$this->encode($parser, $var, $val); + return $result . $this->encode($parser, $var, $val); } - public function expandExplode(Parser $parser, Node\Variable $var, array $val) + public function expandExplode(Parser $parser, Node\Variable $var, array $val): ?string { if (empty($val)) { return null; } - $result = $this->encode($parser, $var, $var->name); - - // RFC6570 doesn't specify how to handle empty list/assoc array - // for explode modifier - if (empty($val)) { - return $result . $this->empty; - } - - $list = isset($val[0]); - $data = array(); - foreach($val as $k => $v) { - + $list = isset($val[0]); + $data = []; + foreach ($val as $k => $v) { // if value is a list, use `varname` as keyname, otherwise use `key` name $key = $list ? $var->name : $k; if ($list) { $data[$key][] = $v; - } - - else { + } else { $data[$key] = $v; } } @@ -123,14 +106,14 @@ public function expandExplode(Parser $parser, Node\Variable $var, array $val) // if it's array modifier, we have to use variable name as index // e.g. if variable name is 'query' and value is ['limit' => 1] // then we convert it to ['query' => ['limit' => 1]] - if (!$list and $var->options['modifier'] === '%') { - $data = array($var->name => $data); + if (!$list && $var->options['modifier'] === '%') { + $data = [$var->name => $data]; } - return $this->encodeExplodeVars($parser, $var, $data); + return $this->encodeExplodeVars($var, $data); } - public function extract(Parser $parser, Node\Variable $var, $data) + public function extract(Parser $parser, Node\Variable $var, $data): array|string { // get rid of optional `&` at the beginning if ($data[0] === '&') { @@ -143,45 +126,47 @@ public function extract(Parser $parser, Node\Variable $var, $data) switch ($options['modifier']) { case '%': - parse_str($data, $query); + parse_str($value, $query); return $query[$var->name]; case '*': - $data = array(); + $value = []; - foreach($vals as $val) { - list($k, $v) = explode('=', $val); + foreach ($vals as $val) { + [$k, $v] = explode('=', $val); // 2 if ($k === $var->getToken()) { - $data[] = $v; + $value[] = $v; } // 4 else { - $data[$k] = $v; + $value[$k] = $v; } } break; + case ':': break; + default: // 1, 3 // remove key from value e.g. 'lang=en,th' becomes 'en,th' - $value = str_replace($var->getToken().'=', '', $value); - $data = explode(',', $value); + $value = str_replace($var->getToken() . '=', '', $value); + $value = explode(',', $value); - if (sizeof($data) === 1) { - $data = current($data); + if (count($value) === 1) { + $value = current($value); } } - return $this->decode($parser, $var, $data); + return $this->decode($parser, $var, $value); } - public function encodeExplodeVars(Parser $parser, Node\Variable $var, $data) + public function encodeExplodeVars(Node\Variable $var, $data): null|array|string { // http_build_query uses PHP_QUERY_RFC1738 encoding by default // i.e. spaces are encoded as '+' (plus signs) we need to convert @@ -198,7 +183,6 @@ public function encodeExplodeVars(Parser $parser, Node\Variable $var, $data) // `:`, `*` modifiers else { - // by default, http_build_query will convert array values to `a[]=1&a[]=2` // which is different from the spec. It should be `a=1&a=2` $query = preg_replace('#%5B\d+%5D#', '', $query); @@ -206,11 +190,10 @@ public function encodeExplodeVars(Parser $parser, Node\Variable $var, $data) // handle reserved charset if ($this->reserved) { - $query = str_replace( array_keys(static::$reserved_chars), static::$reserved_chars, - $query + $query, ); } diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/UnNamed.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/UnNamed.php index 14a49b299..d1e53dd8f 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/UnNamed.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Operator/UnNamed.php @@ -9,37 +9,39 @@ * | 1 | {/list} /red,green,blue | {$value}*(?:,{$value}+)* * | 2 | {/list*} /red/green/blue | {$value}+(?:{$sep}{$value}+)* * | 3 | {/keys} /semi,%3B,dot,.,comma,%2C | /(\w+,?)+ - * | 4 | {/keys*} /semi=%3B/dot=./comma=%2C | /(?:\w+=\w+/?)* + * | 4 | {/keys*} /semi=%3B/dot=./comma=%2C | /(?:\w+=\w+/?)*. */ class UnNamed extends Abstraction { - public function toRegex(Parser $parser, Node\Variable $var) + public function toRegex(Parser $parser, Node\Variable $var): string { - $regex = null; $value = $this->getRegex(); $options = $var->options; if ($options['modifier']) { - switch($options['modifier']) { + switch ($options['modifier']) { case '*': // 2 | 4 $regex = "{$value}+(?:{$this->sep}{$value}+)*"; + break; + case ':': - $regex = $value.'{0,'.$options['value'].'}'; + $regex = $value . '{0,' . $options['value'] . '}'; + break; + case '%': - throw new \Exception("% (array) modifier only works with Named type operators e.g. ;,?,&"); + throw new \InvalidArgumentException('% (array) modifier only works with Named type operators e.g. ;,?,&'); + default: - throw new \Exception("Unknown modifier `{$options['modifier']}`"); + throw new \InvalidArgumentException("Unknown modifier `{$options['modifier']}`"); } - } - - else { + } else { // 1, 3 $regex = "{$value}*(?:,{$value}+)*"; } return $regex; } -} \ No newline at end of file +} diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Parser.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Parser.php index 10ca382a2..efeb292ab 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Parser.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/Parser.php @@ -2,34 +2,33 @@ namespace Rize\UriTemplate; -use Rize\UriTemplate\Node; +use Rize\UriTemplate\Node\Abstraction; use Rize\UriTemplate\Node\Expression; -use Rize\UriTemplate\Operator; +use Rize\UriTemplate\Node\Variable; use Rize\UriTemplate\Operator\UnNamed; class Parser { - const REGEX_VARNAME = '(?:[A-z0-9_\.]|%[0-9a-fA-F]{2})'; + private const REGEX_VARNAME = '[A-z0-9.]|%[0-9a-fA-F]{2}'; /** - * Parses URI Template and returns nodes + * Parses URI Template and returns nodes. * - * @param string $template * @return Node\Abstraction[] */ - public function parse($template) + public function parse(string $template): array { - $parts = preg_split('#(\{[^\}]+\})#', $template, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - $nodes = array(); + $parts = preg_split('#(\{[^}]+})#', $template, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $nodes = []; - foreach($parts as $part) { + foreach ($parts as $part) { $node = $this->createNode($part); // if current node has dot separator that requires a forward lookup // for the previous node iff previous node's operator is UnNamed if ($node instanceof Expression && $node->getOperator()->id === '.') { - if (sizeof($nodes) > 0) { - $previousNode = $nodes[sizeof($nodes) - 1]; + if (count($nodes) > 0) { + $previousNode = $nodes[count($nodes) - 1]; if ($previousNode instanceof Expression && $previousNode->getOperator() instanceof UnNamed) { $previousNode->setForwardLookupSeparator($node->getOperator()->id); } @@ -42,11 +41,7 @@ public function parse($template) return $nodes; } - /** - * @param string $token - * @return Node\Abstraction - */ - protected function createNode($token) + protected function createNode(string $token): Abstraction { // literal string if ($token[0] !== '{') { @@ -59,21 +54,22 @@ protected function createNode($token) return $node; } - protected function parseExpression($expression) + protected function parseExpression(string $expression): Expression { $token = $expression; $prefix = $token[0]; // not a valid operator? if (!Operator\Abstraction::isValid($prefix)) { - // not valid chars? - if (!preg_match('#'.self::REGEX_VARNAME.'#', $token)) { - throw new \Exception("Invalid operator [$prefix] found at {$token}"); + if (!preg_match('#' . self::REGEX_VARNAME . '#', $token)) { + throw new \InvalidArgumentException("Invalid operator [{$prefix}] found at {$token}"); } // default operator - $prefix = null; + // + // PHP 8.5: using null as array offset is deprecated and we no longer rely on auto-casting null to ''. + $prefix = ''; } // remove operator prefix if exists e.g. '?' @@ -82,74 +78,71 @@ protected function parseExpression($expression) } // parse variables - $vars = array(); - foreach(explode(',', $token) as $var) { + $vars = []; + foreach (explode(',', $token) as $var) { $vars[] = $this->parseVariable($var); } return $this->createExpressionNode( $token, $this->createOperatorNode($prefix), - $vars + $vars, ); } - protected function parseVariable($var) + protected function parseVariable(string $var): Variable { $var = trim($var); $val = null; $modifier = null; // check for prefix (:) / explode (*) / array (%) modifier - if (strpos($var, ':') !== false) { + if (str_contains($var, ':')) { $modifier = ':'; - list($varname, $val) = explode(':', $var); + [$varname, $val] = explode(':', $var); // error checking if (!is_numeric($val)) { - throw new \Exception("Value for `:` modifier must be numeric value [$varname:$val]"); + throw new \InvalidArgumentException("Value for `:` modifier must be numeric value [{$varname}:{$val}]"); } } - switch($last = substr($var, -1)) { + switch ($last = substr($var, -1)) { case '*': case '%': - // there can be only 1 modifier per var if ($modifier) { - throw new \Exception("Multiple modifiers per variable are not allowed [$var]"); + throw new \InvalidArgumentException("Multiple modifiers per variable are not allowed [{$var}]"); } $modifier = $last; - $var = substr($var, 0, -1); + $var = substr($var, 0, -1); + break; } return $this->createVariableNode( $var, - array( - 'modifier' => $modifier, - 'value' => $val, - ) + ['modifier' => $modifier, 'value' => $val], ); } - protected function createVariableNode($token, $options = array()) + protected function createVariableNode($token, $options = []): Variable { - return new Node\Variable($token, $options); + return new Variable($token, $options); } - protected function createExpressionNode($token, Operator\Abstraction $operator = null, array $vars = array()) + protected function createExpressionNode($token, ?Operator\Abstraction $operator = null, array $vars = []): Expression { - return new Node\Expression($token, $operator, $vars); + return new Expression($token, $operator, $vars); } - protected function createLiteralNode($token) + protected function createLiteralNode(string $token): Node\Literal { return new Node\Literal($token); } - protected function createOperatorNode($token) + protected function createOperatorNode($token): Operator\Abstraction { return Operator\Abstraction::createById($token); } diff --git a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/UriTemplate.php b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/UriTemplate.php index 983d5b555..2170bfc80 100644 --- a/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/UriTemplate.php +++ b/lib/Google/vendor/rize/uri-template/src/Rize/UriTemplate/UriTemplate.php @@ -5,8 +5,6 @@ use Rize\UriTemplate as Template; /** - * Future compatibility + * Future compatibility. */ -class UriTemplate extends Template -{ -} +class UriTemplate extends Template {} diff --git a/lib/Google/vendor/rize/uri-template/tests/Rize/Uri/Node/ParserTest.php b/lib/Google/vendor/rize/uri-template/tests/Rize/Uri/Node/ParserTest.php new file mode 100644 index 000000000..203d2384e --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/Rize/Uri/Node/ParserTest.php @@ -0,0 +1,93 @@ + ':', 'value' => 1], + )], + ), new Node\Literal('/'), new Node\Expression( + 'term', + Operator\Abstraction::createById(''), + [new Node\Variable( + 'term', + ['modifier' => null, 'value' => null], + )], + ), new Node\Literal('/'), new Node\Expression( + 'test*', + Operator\Abstraction::createById(''), + [new Node\Variable( + 'test', + ['modifier' => '*', 'value' => null], + )], + ), new Node\Literal('/foo'), new Node\Expression( + 'query,number', + Operator\Abstraction::createById('?'), + [new Node\Variable( + 'query', + ['modifier' => null, 'value' => null], + ), new Node\Variable( + 'number', + ['modifier' => null, 'value' => null], + )], + )]; + + $service = $this->service(); + $actual = $service->parse($input); + + $this->assertEquals($expected, $actual); + } + + public function testParseTemplateWithLiteral() + { + // will pass + $uri = new UriTemplate('http://www.example.com/v1/company/', []); + $params = $uri->extract('/{countryCode}/{registrationNumber}/test{.format}', '/gb/0123456/test.json'); + static::assertEquals(['countryCode' => 'gb', 'registrationNumber' => '0123456', 'format' => 'json'], $params); + } + + #[Depends('testParseTemplateWithLiteral')] + public function testParseTemplateWithTwoVariablesAndDotBetween() + { + // will fail + $uri = new UriTemplate('http://www.example.com/v1/company/', []); + $params = $uri->extract('/{countryCode}/{registrationNumber}{.format}', '/gb/0123456.json'); + static::assertEquals(['countryCode' => 'gb', 'registrationNumber' => '0123456', 'format' => 'json'], $params); + } + + #[Depends('testParseTemplateWithLiteral')] + public function testParseTemplateWithTwoVariablesAndDotBetweenStrict() + { + // will fail + $uri = new UriTemplate('http://www.example.com/v1/company/', []); + $params = $uri->extract('/{countryCode}/{registrationNumber}{.format}', '/gb/0123456.json', true); + static::assertEquals(['countryCode' => 'gb', 'registrationNumber' => '0123456', 'format' => 'json'], $params); + } + + #[Depends('testParseTemplateWithLiteral')] + public function testParseTemplateWithThreeVariablesAndDotBetweenStrict() + { + // will fail + $uri = new UriTemplate('http://www.example.com/v1/company/', []); + $params = $uri->extract('/{countryCode}/{registrationNumber}{.namespace}{.format}', '/gb/0123456.company.json'); + static::assertEquals(['countryCode' => 'gb', 'registrationNumber' => '0123456', 'namespace' => 'company', 'format' => 'json'], $params); + } +} diff --git a/lib/Google/vendor/rize/uri-template/tests/Rize/UriTemplateTest.php b/lib/Google/vendor/rize/uri-template/tests/Rize/UriTemplateTest.php new file mode 100644 index 000000000..427f93f44 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/Rize/UriTemplateTest.php @@ -0,0 +1,253 @@ + ["one", "two", "three"], 'dom' => ["example", "com"], 'dub' => "me/too", 'hello' => "Hello World!", 'half' => "50%", 'var' => "value", 'who' => "fred", 'base' => "http://example.com/home/", 'path' => "/foo/bar", 'list' => ["red", "green", "blue"], 'keys' => ["semi" => ";", "dot" => ".", "comma" => ","], 'list_with_empty' => [''], 'keys_with_empty' => ['john' => ''], 'v' => "6", 'x' => "1024", 'y' => "768", 'empty' => "", 'empty_keys' => [], 'undef' => null]; + + return [ + ['http://example.com/~john', ['uri' => 'http://example.com/~{username}', 'params' => ['username' => 'john']]], + ['http://example.com/dictionary/d/dog', ['uri' => 'http://example.com/dictionary/{term:1}/{term}', 'params' => ['term' => 'dog'], 'extract' => ['term:1' => 'd', 'term' => 'dog']]], + # Form-style parameters expression + ['http://example.com/j/john/search?q=mycelium&q=3&lang=th,jp,en', ['uri' => 'http://example.com/{term:1}/{term}/search{?q*,lang}', 'params' => ['q' => ['mycelium', 3], 'lang' => ['th', 'jp', 'en'], 'term' => 'john']]], + ['http://www.example.com/john', ['uri' => 'http://www.example.com/{username}', 'params' => ['username' => 'john']]], + ['http://www.example.com/foo?query=mycelium&number=100', ['uri' => 'http://www.example.com/foo{?query,number}', 'params' => ['query' => 'mycelium', 'number' => 100]]], + # 'query' is undefined + ['http://www.example.com/foo?number=100', [ + 'uri' => 'http://www.example.com/foo{?query,number}', + 'params' => ['number' => 100], + # we can't extract undefined values + 'extract' => false, + ]], + # undefined variables + ['http://www.example.com/foo', ['uri' => 'http://www.example.com/foo{?query,number}', 'params' => [], 'extract' => ['query' => null, 'number' => null]]], + ['http://www.example.com/foo', ['uri' => 'http://www.example.com/foo{?number}', 'params' => [], 'extract' => ['number' => null]]], + ['one,two,three|one,two,three|/one,two,three|/one/two/three|;count=one,two,three|;count=one;count=two;count=three|?count=one,two,three|?count=one&count=two&count=three|&count=one&count=two&count=three', ['uri' => '{count}|{count*}|{/count}|{/count*}|{;count}|{;count*}|{?count}|{?count*}|{&count*}', 'params' => ['count' => ['one', 'two', 'three']]]], + ['http://www.host.com/path/to/a/file.x.y', ['uri' => 'http://{host}{/segments*}/{file}{.extensions*}', 'params' => ['host' => 'www.host.com', 'segments' => ['path', 'to', 'a'], 'file' => 'file', 'extensions' => ['x', 'y']], 'extract' => ['host' => 'www.host.com', 'segments' => ['path', 'to', 'a'], 'file' => 'file.x.y', 'extensions' => null]]], + # level 1 - Simple String Expansion: {var} + ['value|Hello%20World%21|50%25|OX|OX|1024,768|1024,Hello%20World%21,768|?1024,|?1024|?768|val|value|red,green,blue|semi,%3B,dot,.,comma,%2C|semi=%3B,dot=.,comma=%2C', ['uri' => '{var}|{hello}|{half}|O{empty}X|O{undef}X|{x,y}|{x,hello,y}|?{x,empty}|?{x,undef}|?{undef,y}|{var:3}|{var:30}|{list}|{keys}|{keys*}', 'params' => $params]], + # level 2 - Reserved Expansion: {+var} + ['value|Hello%20World!|50%25|http%3A%2F%2Fexample.com%2Fhome%2Findex|http://example.com/home/index|OX|OX|/foo/bar/here|here?ref=/foo/bar|up/foo/barvalue/here|1024,Hello%20World!,768|/foo/bar,1024/here|/foo/b/here|red,green,blue|red,green,blue|semi,;,dot,.,comma,,|semi=;,dot=.,comma=,', ['uri' => '{+var}|{+hello}|{+half}|{base}index|{+base}index|O{+empty}X|O{+undef}X|{+path}/here|here?ref={+path}|up{+path}{var}/here|{+x,hello,y}|{+path,x}/here|{+path:6}/here|{+list}|{+list*}|{+keys}|{+keys*}', 'params' => $params]], + # level 2 - Fragment Expansion: {#var} + ['#value|#Hello%20World!|#50%25|foo#|foo|#1024,Hello%20World!,768|#/foo/bar,1024/here|#/foo/b/here|#red,green,blue|#red,green,blue|#semi,;,dot,.,comma,,|#semi=;,dot=.,comma=,', ['uri' => '{#var}|{#hello}|{#half}|foo{#empty}|foo{#undef}|{#x,hello,y}|{#path,x}/here|{#path:6}/here|{#list}|{#list*}|{#keys}|{#keys*}', 'params' => $params]], + # Label Expansion with Dot-Prefix: {.var} + ['.fred|.fred.fred|.50%25.fred|www.example.com|X.value|X.|X|X.val|X.red,green,blue|X.red.green.blue|X.semi,%3B,dot,.,comma,%2C|X.semi=%3B.dot=..comma=%2C|X|X', ['uri' => '{.who}|{.who,who}|{.half,who}|www{.dom*}|X{.var}|X{.empty}|X{.undef}|X{.var:3}|X{.list}|X{.list*}|X{.keys}|X{.keys*}|X{.empty_keys}|X{.empty_keys*}', 'params' => $params]], + # Path Segment Expansion: {/var} + ['/fred|/fred/fred|/50%25/fred|/fred/me%2Ftoo|/value|/value/|/value|/value/1024/here|/v/value|/red,green,blue|/red/green/blue|/red/green/blue/%2Ffoo|/semi,%3B,dot,.,comma,%2C|/semi=%3B/dot=./comma=%2C', ['uri' => '{/who}|{/who,who}|{/half,who}|{/who,dub}|{/var}|{/var,empty}|{/var,undef}|{/var,x}/here|{/var:1,var}|{/list}|{/list*}|{/list*,path:4}|{/keys}|{/keys*}', 'params' => $params]], + # Path-Style Parameter Expansion: {;var} + [';who=fred|;half=50%25|;empty|;v=6;empty;who=fred|;v=6;who=fred|;x=1024;y=768|;x=1024;y=768;empty|;x=1024;y=768|;hello=Hello|;list=red,green,blue|;list=red;list=green;list=blue|;keys=semi,%3B,dot,.,comma,%2C|;semi=%3B;dot=.;comma=%2C', ['uri' => '{;who}|{;half}|{;empty}|{;v,empty,who}|{;v,bar,who}|{;x,y}|{;x,y,empty}|{;x,y,undef}|{;hello:5}|{;list}|{;list*}|{;keys}|{;keys*}', 'params' => $params]], + # Form-Style Query Expansion: {?var} + ['?who=fred|?half=50%25|?x=1024&y=768|?x=1024&y=768&empty=|?x=1024&y=768|?var=val|?list=red,green,blue|?list=red&list=green&list=blue|?keys=semi,%3B,dot,.,comma,%2C|?semi=%3B&dot=.&comma=%2C|?list_with_empty=|?john=', ['uri' => '{?who}|{?half}|{?x,y}|{?x,y,empty}|{?x,y,undef}|{?var:3}|{?list}|{?list*}|{?keys}|{?keys*}|{?list_with_empty*}|{?keys_with_empty*}', 'params' => $params]], + # Form-Style Query Continuation: {&var} + ['&who=fred|&half=50%25|?fixed=yes&x=1024|&x=1024&y=768&empty=|&x=1024&y=768|&var=val|&list=red,green,blue|&list=red&list=green&list=blue|&keys=semi,%3B,dot,.,comma,%2C|&semi=%3B&dot=.&comma=%2C', ['uri' => '{&who}|{&half}|?fixed=yes{&x}|{&x,y,empty}|{&x,y,undef}|{&var:3}|{&list}|{&list*}|{&keys}|{&keys*}', 'params' => $params]], + # Test empty values + ['|||', ['uri' => '{empty}|{empty*}|{?empty}|{?empty*}', 'params' => ['empty' => []]]], + ]; + } + + public static function dataExpandWithArrayModifier() + { + return [ + # List + [ + # '?choices[]=a&choices[]=b&choices[]=c', + '?choices%5B%5D=a&choices%5B%5D=b&choices%5B%5D=c', + ['uri' => '{?choices%}', 'params' => ['choices' => ['a', 'b', 'c']]], + ], + # Keys + [ + # '?choices[a]=1&choices[b]=2&choices[c][test]=3', + '?choices%5Ba%5D=1&choices%5Bb%5D=2&choices%5Bc%5D%5Btest%5D=3', + ['uri' => '{?choices%}', 'params' => ['choices' => ['a' => 1, 'b' => 2, 'c' => ['test' => 3]]]], + ], + # Mixed + [ + # '?list[]=a&list[]=b&keys[a]=1&keys[b]=2', + '?list%5B%5D=a&list%5B%5D=b&keys%5Ba%5D=1&keys%5Bb%5D=2', + ['uri' => '{?list%,keys%}', 'params' => ['list' => ['a', 'b'], 'keys' => ['a' => 1, 'b' => 2]]], + ], + ]; + } + + public static function dataBaseTemplate() + { + return [ + [ + 'http://google.com/api/1/users/1', + # base uri + ['uri' => '{+host}/api/{v}', 'params' => ['host' => 'http://google.com', 'v' => 1]], + # other uri + ['uri' => '/{resource}/{id}', 'params' => ['resource' => 'users', 'id' => 1]], + ], + # test override base params + [ + 'http://github.com/api/1/users/1', + # base uri + ['uri' => '{+host}/api/{v}', 'params' => ['host' => 'http://google.com', 'v' => 1]], + # other uri + ['uri' => '/{resource}/{id}', 'params' => ['host' => 'http://github.com', 'resource' => 'users', 'id' => 1]], + ], + ]; + } + + public static function dataExtraction() + { + return [['/no/{term:1}/random/foo{?query,list%,keys%}', '/no/j/random/foo?query=1,2,3&list%5B%5D=a&list%5B%5D=b&keys%5Ba%5D=1&keys%5Bb%5D=2&keys%5Bc%5D%5Btest%5D%5Btest%5D=1', ['term:1' => 'j', 'query' => [1, 2, 3], 'list' => ['a', 'b'], 'keys' => ['a' => 1, 'b' => 2, 'c' => ['test' => ['test' => 1]]]]], ['/no/{term:1}/random/{term}/{test*}/foo{?query,number}', '/no/j/random/john/a,b,c/foo?query=1,2,3&number=10', ['term:1' => 'j', 'term' => 'john', 'test' => ['a', 'b', 'c'], 'query' => [1, 2, 3], 'number' => 10]], ['/search/{term:1}/{term}/{?q*,limit}', '/search/j/john/?a=1&b=2&limit=10', ['term:1' => 'j', 'term' => 'john', 'q' => ['a' => 1, 'b' => 2], 'limit' => 10]], ['http://www.example.com/foo{?query,number}', 'http://www.example.com/foo?query=5', ['query' => 5, 'number' => null]], ['{count}|{count*}|{/count}|{/count*}|{;count}|{;count*}|{?count}|{?count*}|{&count*}', 'one,two,three|one,two,three|/one,two,three|/one/two/three|;count=one,two,three|;count=one;count=two;count=three|?count=one,two,three|?count=one&count=two&count=three|&count=one&count=two&count=three', ['count' => ['one', 'two', 'three']]], ['http://example.com/{term:1}/{term}/search{?q*,lang}', 'http://example.com/j/john/search?q=Hello%20World%21&q=3&lang=th,jp,en', ['q' => ['Hello World!', 3], 'lang' => ['th', 'jp', 'en'], 'term' => 'john', 'term:1' => 'j']], ['/foo/bar/{number}', '/foo/bar/0', ['number' => 0]], ['/some/{path}{?ref}', '/some/foo', ['path' => 'foo', 'ref' => null]]]; + } + + /** + * @dataProvider dataExpansion + */ + public function testExpansion($expected, $input) + { + $service = $this->service(); + $result = $service->expand($input['uri'], $input['params']); + + $this->assertEquals($expected, $result); + } + + /** + * @dataProvider dataExpandWithArrayModifier + */ + public function testExpandWithArrayModifier($expected, $input) + { + $service = $this->service(); + $result = $service->expand($input['uri'], $input['params']); + + $this->assertEquals($expected, $result); + } + + /** + * @dataProvider dataBaseTemplate + */ + public function testBaseTemplate($expected, $base, $other) + { + $service = $this->service($base['uri'], $base['params']); + $result = $service->expand($other['uri'], $other['params']); + + $this->assertEquals($expected, $result); + } + + /** + * @dataProvider dataExtraction + */ + public function testExtract($template, $uri, $expected) + { + $service = $this->service(); + $actual = $service->extract($template, $uri); + + $this->assertEquals($expected, $actual); + } + + public function testExpandFromFixture() + { + $dir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; + $files = ['spec-examples.json', 'spec-examples-by-section.json', 'extended-tests.json']; + $service = $this->service(); + + foreach ($files as $file) { + $content = json_decode(file_get_contents($dir . $file), $array = true); + + # iterate through each fixture + foreach ($content as $fixture) { + $vars = $fixture['variables']; + + # assert each test cases + foreach ($fixture['testcases'] as $case) { + [$uri, $expected] = $case; + + $actual = $service->expand($uri, $vars); + + if (is_array($expected)) { + $expected = current(array_filter($expected, fn($input) => $actual === $input)); + } + + $this->assertEquals($expected, $actual); + } + } + } + } + + public static function dataExtractStrictMode() + { + $dataTest = [['/search/{term:1}/{term}/{?q*,limit}', '/search/j/john/?a=1&b=2&limit=10', ['term:1' => 'j', 'term' => 'john', 'limit' => '10', 'q' => ['a' => '1', 'b' => '2']]], ['http://example.com/{term:1}/{term}/search{?q*,lang}', 'http://example.com/j/john/search?q=Hello%20World%21&q=3&lang=th,jp,en', ['term:1' => 'j', 'term' => 'john', 'lang' => ['th', 'jp', 'en'], 'q' => ['Hello World!', '3']]], ['/foo/bar/{number}', '/foo/bar/0', ['number' => 0]], ['/', '/', []]]; + + $rfc3986AllowedPathCharacters = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':', '@']; + + foreach ($rfc3986AllowedPathCharacters as $char) { + $title = "RFC3986 path character ($char)"; + $title = str_replace("'", 'single quote', $title); // PhpStorm workaround + if ($char === ',') { // , means array on RFC6570 + $params = ['term' => ['foo', 'baz']]; + } else { + $params = ['term' => "foo{$char}baz"]; + } + + $data = ['/search/{term}', "/search/foo{$char}baz", $params]; + + $dataTest[$title] = $data; + $data = ['/search/{;term}', "/search/;term=foo{$char}baz", $params]; + $dataTest['Named ' . $title] = $data; + } + + $rfc3986AllowedQueryCharacters = $rfc3986AllowedPathCharacters; + $rfc3986AllowedQueryCharacters[] = '/'; + $rfc3986AllowedQueryCharacters[] = '?'; + unset($rfc3986AllowedQueryCharacters[array_search('&', $rfc3986AllowedQueryCharacters, true)]); + + foreach ($rfc3986AllowedQueryCharacters as $char) { + $title = "RFC3986 query character ($char)"; + $title = str_replace("'", 'single quote', $title); // PhpStorm workaround + if ($char === ',') { // , means array on RFC6570 + $params = ['term' => ['foo', 'baz']]; + } else { + $params = ['term' => "foo{$char}baz"]; + } + + $data = ['/search/{?term}', "/search/?term=foo{$char}baz", $params]; + $dataTest['Named ' . $title] = $data; + } + + return $dataTest; + } + + public static function extractStrictModeNotMatchProvider() + { + return [['/', '/a'], ['/{test}', '/a/'], ['/search/{term:1}/{term}/{?q*,limit}', '/search/j/?a=1&b=2&limit=10'], ['http://www.example.com/foo{?query,number}', 'http://www.example.com/foo?query=5'], ['http://www.example.com/foo{?query,number}', 'http://www.example.com/foo'], ['http://example.com/{term:1}/{term}/search{?q*,lang}', 'http://example.com/j/john/search?q=']]; + } + + #[DataProvider('dataExtractStrictMode')] + public function testExtractStrictMode(string $template, string $uri, array $expectedParams) + { + $service = $this->service(); + $params = $service->extract($template, $uri, true); + + $this->assertTrue(isset($params)); + $this->assertEquals($expectedParams, $params); + } + + #[DataProvider('extractStrictModeNotMatchProvider')] + public function testExtractStrictModeNotMatch(string $template, string $uri) + { + $service = $this->service(); + $actual = $service->extract($template, $uri, true); + + $this->assertFalse(isset($actual)); + } +} diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/README.md b/lib/Google/vendor/rize/uri-template/tests/fixtures/README.md new file mode 100644 index 000000000..3eb519da6 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/README.md @@ -0,0 +1,90 @@ + +URI Template Tests +================== + +This is a set of tests for implementations of +[RFC6570](http://tools.ietf.org/html/rfc6570) - URI Template. It is designed +to be reused by any implementation, to improve interoperability and +implementation quality. + +If your project uses Git for version control, you can make uritemplate-tests into a [submodule](http://help.github.com/submodules/). + +Test Format +----------- + +Each test file is a [JSON](http://tools.ietf.org/html/RFC6627) document +containing an object whose properties are groups of related tests. +Alternatively, all tests are available in XML as well, with the XML files +being generated by transform-json-tests.xslt which uses json2xml.xslt as a +general-purpose JSON-to-XML parsing library. + +Each group, in turn, is an object with three children: + +* level - the level of the tests covered, as per the RFC (optional; if absent, + assume level 4). +* variables - an object representing the variables that are available to the + tests in the suite +* testcases - a list of testcases, where each case is a two-member list, the + first being the template, the second being the result of expanding the + template with the provided variables. + +Note that the result string can be a few different things: + +* string - if the second member is a string, the result of expansion is + expected to match it, character-for-character. +* list - if the second member is a list of strings, the result of expansion + is expected to match one of them; this allows for templates that can + expand into different, equally-acceptable URIs. +* false - if the second member is boolean false, expansion is expected to + fail (i.e., the template was invalid). + +For example: + + { + "Level 1 Examples" : + { + "level": 1, + "variables": { + "var" : "value", + "hello" : "Hello World!" + }, + "testcases" : [ + ["{var}", "value"], + ["{hello}", "Hello%20World%21"] + ] + } + } + + +Tests Included +-------------- + +The following test files are included: + +* spec-examples.json - The complete set of example templates from the RFC +* spec-examples-by-section.json - The examples, section by section +* extended-tests.json - more complex test cases +* negative-tests.json - invalid templates + +For all these test files, XML versions with the names *.xml can be +generated with the transform-json-tests.xslt XSLT stylesheet. The XSLT +contains the names of the above test files as a parameter, and can be +started with any XML as input (i.e., the XML input is ignored). + +License +------- + + Copyright 2011-2012 The Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/extended-tests.json b/lib/Google/vendor/rize/uri-template/tests/fixtures/extended-tests.json new file mode 100644 index 000000000..8ae8134cc --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/extended-tests.json @@ -0,0 +1,118 @@ +{ + "Additional Examples 1":{ + "level":4, + "variables":{ + "id" : "person", + "token" : "12345", + "fields" : ["id", "name", "picture"], + "format" : "json", + "q" : "URI Templates", + "page" : "5", + "lang" : "en", + "geocode" : ["37.76","-122.427"], + "first_name" : "John", + "last.name" : "Doe", + "Some%20Thing" : "foo", + "number" : 6, + "long" : 37.76, + "lat" : -122.427, + "group_id" : "12345", + "query" : "PREFIX dc: SELECT ?book ?who WHERE { ?book dc:creator ?who }", + "uri" : "http://example.org/?uri=http%3A%2F%2Fexample.org%2F", + "word" : "drücken", + "Stra%C3%9Fe" : "Grüner Weg", + "random" : "šö䟜ñꀣ¥‡ÑÒÓÔÕÖרÙÚàáâãäåæçÿ", + "assoc_special_chars" : + { "šö䟜ñꀣ¥‡ÑÒÓÔÕ" : "ÖרÙÚàáâãäåæçÿ" } + }, + "testcases":[ + + [ "{/id*}" , "/person" ], + [ "{/id*}{?fields,first_name,last.name,token}" , [ + "/person?fields=id,name,picture&first_name=John&last.name=Doe&token=12345", + "/person?fields=id,picture,name&first_name=John&last.name=Doe&token=12345", + "/person?fields=picture,name,id&first_name=John&last.name=Doe&token=12345", + "/person?fields=picture,id,name&first_name=John&last.name=Doe&token=12345", + "/person?fields=name,picture,id&first_name=John&last.name=Doe&token=12345", + "/person?fields=name,id,picture&first_name=John&last.name=Doe&token=12345"] + ], + ["/search.{format}{?q,geocode,lang,locale,page,result_type}", + [ "/search.json?q=URI%20Templates&geocode=37.76,-122.427&lang=en&page=5", + "/search.json?q=URI%20Templates&geocode=-122.427,37.76&lang=en&page=5"] + ], + ["/test{/Some%20Thing}", "/test/foo" ], + ["/set{?number}", "/set?number=6"], + ["/loc{?long,lat}" , "/loc?long=37.76&lat=-122.427"], + ["/base{/group_id,first_name}/pages{/page,lang}{?format,q}","/base/12345/John/pages/5/en?format=json&q=URI%20Templates"], + ["/sparql{?query}", "/sparql?query=PREFIX%20dc%3A%20%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%20SELECT%20%3Fbook%20%3Fwho%20WHERE%20%7B%20%3Fbook%20dc%3Acreator%20%3Fwho%20%7D"], + ["/go{?uri}", "/go?uri=http%3A%2F%2Fexample.org%2F%3Furi%3Dhttp%253A%252F%252Fexample.org%252F"], + ["/service{?word}", "/service?word=dr%C3%BCcken"], + ["/lookup{?Stra%C3%9Fe}", "/lookup?Stra%25C3%259Fe=Gr%C3%BCner%20Weg"], + ["{random}" , "%C5%A1%C3%B6%C3%A4%C5%B8%C5%93%C3%B1%C3%AA%E2%82%AC%C2%A3%C2%A5%E2%80%A1%C3%91%C3%92%C3%93%C3%94%C3%95%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%BF"], + ["{?assoc_special_chars*}", "?%C5%A1%C3%B6%C3%A4%C5%B8%C5%93%C3%B1%C3%AA%E2%82%AC%C2%A3%C2%A5%E2%80%A1%C3%91%C3%92%C3%93%C3%94%C3%95=%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%BF"] + ] + }, + "Additional Examples 2":{ + "level":4, + "variables":{ + "id" : ["person","albums"], + "token" : "12345", + "fields" : ["id", "name", "picture"], + "format" : "atom", + "q" : "URI Templates", + "page" : "10", + "start" : "5", + "lang" : "en", + "geocode" : ["37.76","-122.427"] + }, + "testcases":[ + + [ "{/id*}" , ["/person/albums","/albums/person"] ], + [ "{/id*}{?fields,token}" , [ + "/person/albums?fields=id,name,picture&token=12345", + "/person/albums?fields=id,picture,name&token=12345", + "/person/albums?fields=picture,name,id&token=12345", + "/person/albums?fields=picture,id,name&token=12345", + "/person/albums?fields=name,picture,id&token=12345", + "/person/albums?fields=name,id,picture&token=12345", + "/albums/person?fields=id,name,picture&token=12345", + "/albums/person?fields=id,picture,name&token=12345", + "/albums/person?fields=picture,name,id&token=12345", + "/albums/person?fields=picture,id,name&token=12345", + "/albums/person?fields=name,picture,id&token=12345", + "/albums/person?fields=name,id,picture&token=12345"] + ] + ] + }, + "Additional Examples 3: Empty Variables":{ + "variables" : { + "empty_list" : [], + "empty_assoc" : {} + }, + "testcases":[ + [ "{/empty_list}", [ "" ] ], + [ "{/empty_list*}", [ "" ] ], + [ "{?empty_list}", [ ""] ], + [ "{?empty_list*}", [ "" ] ], + [ "{?empty_assoc}", [ "" ] ], + [ "{?empty_assoc*}", [ "" ] ] + ] + }, + "Additional Examples 4: Numeric Keys":{ + "variables" : { + "42" : "The Answer to the Ultimate Question of Life, the Universe, and Everything", + "1337" : ["leet", "as","it", "can","be"], + "german" : { + "11": "elf", + "12": "zwölf" + } + }, + "testcases":[ + [ "{42}", "The%20Answer%20to%20the%20Ultimate%20Question%20of%20Life%2C%20the%20Universe%2C%20and%20Everything"], + [ "{?42}", "?42=The%20Answer%20to%20the%20Ultimate%20Question%20of%20Life%2C%20the%20Universe%2C%20and%20Everything"], + [ "{1337}", "leet,as,it,can,be"], + [ "{?1337*}", "?1337=leet&1337=as&1337=it&1337=can&1337=be"], + [ "{?german*}", [ "?11=elf&12=zw%C3%B6lf", "?12=zw%C3%B6lf&11=elf"] ] + ] + } +} diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/json2xml.xslt b/lib/Google/vendor/rize/uri-template/tests/fixtures/json2xml.xslt new file mode 100644 index 000000000..59b3548c0 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/json2xml.xslt @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \b + + + + + + + + + + + \v + + + + + \f + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/negative-tests.json b/lib/Google/vendor/rize/uri-template/tests/fixtures/negative-tests.json new file mode 100644 index 000000000..552a6bf07 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/negative-tests.json @@ -0,0 +1,57 @@ +{ + "Failure Tests":{ + "level":4, + "variables":{ + "id" : "thing", + "var" : "value", + "hello" : "Hello World!", + "with space" : "fail", + " leading_space" : "Hi!", + "trailing_space " : "Bye!", + "empty" : "", + "path" : "/foo/bar", + "x" : "1024", + "y" : "768", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "example" : "red", + "searchTerms" : "uri templates", + "~thing" : "some-user", + "default-graph-uri" : ["http://www.example/book/","http://www.example/papers/"], + "query" : "PREFIX dc: SELECT ?book ?who WHERE { ?book dc:creator ?who }" + + }, + "testcases":[ + [ "{/id*", false ], + [ "/id*}", false ], + [ "{/?id}", false ], + [ "{var:prefix}", false ], + [ "{hello:2*}", false ] , + [ "{??hello}", false ] , + [ "{!hello}", false ] , + [ "{with space}", false], + [ "{ leading_space}", false], + [ "{trailing_space }", false], + [ "{=path}", false ] , + [ "{$var}", false ], + [ "{|var*}", false ], + [ "{*keys?}", false ], + [ "{?empty=default,var}", false ], + [ "{var}{-prefix|/-/|var}" , false ], + [ "?q={searchTerms}&c={example:color?}" , false ], + [ "x{?empty|foo=none}" , false ], + [ "/h{#hello+}" , false ], + [ "/h#{hello+}" , false ], + [ "{keys:1}", false ], + [ "{+keys:1}", false ], + [ "{;keys:1*}", false ], + [ "?{-join|&|var,list}" , false ], + [ "/people/{~thing}", false], + [ "/{default-graph-uri}", false ], + [ "/sparql{?query,default-graph-uri}", false ], + [ "/sparql{?query){&default-graph-uri*}", false ], + [ "/resolution{?x, y}" , false ] + + ] + } +} \ No newline at end of file diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples-by-section.json b/lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples-by-section.json new file mode 100644 index 000000000..5aef18205 --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples-by-section.json @@ -0,0 +1,439 @@ +{ + "3.2.1 Variable Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{count}", "one,two,three"], + ["{count*}", "one,two,three"], + ["{/count}", "/one,two,three"], + ["{/count*}", "/one/two/three"], + ["{;count}", ";count=one,two,three"], + ["{;count*}", ";count=one;count=two;count=three"], + ["{?count}", "?count=one,two,three"], + ["{?count*}", "?count=one&count=two&count=three"], + ["{&count*}", "&count=one&count=two&count=three"] + ] + }, + "3.2.2 Simple String Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{var}", "value"], + ["{hello}", "Hello%20World%21"], + ["{half}", "50%25"], + ["O{empty}X", "OX"], + ["O{undef}X", "OX"], + ["{x,y}", "1024,768"], + ["{x,hello,y}", "1024,Hello%20World%21,768"], + ["?{x,empty}", "?1024,"], + ["?{x,undef}", "?1024"], + ["?{undef,y}", "?768"], + ["{var:3}", "val"], + ["{var:30}", "value"], + ["{list}", "red,green,blue"], + ["{list*}", "red,green,blue"], + ["{keys}", [ + "comma,%2C,dot,.,semi,%3B", + "comma,%2C,semi,%3B,dot,.", + "dot,.,comma,%2C,semi,%3B", + "dot,.,semi,%3B,comma,%2C", + "semi,%3B,comma,%2C,dot,.", + "semi,%3B,dot,.,comma,%2C" + ]], + ["{keys*}", [ + "comma=%2C,dot=.,semi=%3B", + "comma=%2C,semi=%3B,dot=.", + "dot=.,comma=%2C,semi=%3B", + "dot=.,semi=%3B,comma=%2C", + "semi=%3B,comma=%2C,dot=.", + "semi=%3B,dot=.,comma=%2C" + ]] + ] + }, + "3.2.3 Reserved Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{+var}", "value"], + ["{/var,empty}", "/value/"], + ["{/var,undef}", "/value"], + ["{+hello}", "Hello%20World!"], + ["{+half}", "50%25"], + ["{base}index", "http%3A%2F%2Fexample.com%2Fhome%2Findex"], + ["{+base}index", "http://example.com/home/index"], + ["O{+empty}X", "OX"], + ["O{+undef}X", "OX"], + ["{+path}/here", "/foo/bar/here"], + ["{+path:6}/here", "/foo/b/here"], + ["here?ref={+path}", "here?ref=/foo/bar"], + ["up{+path}{var}/here", "up/foo/barvalue/here"], + ["{+x,hello,y}", "1024,Hello%20World!,768"], + ["{+path,x}/here", "/foo/bar,1024/here"], + ["{+list}", "red,green,blue"], + ["{+list*}", "red,green,blue"], + ["{+keys}", [ + "comma,,,dot,.,semi,;", + "comma,,,semi,;,dot,.", + "dot,.,comma,,,semi,;", + "dot,.,semi,;,comma,,", + "semi,;,comma,,,dot,.", + "semi,;,dot,.,comma,," + ]], + ["{+keys*}", [ + "comma=,,dot=.,semi=;", + "comma=,,semi=;,dot=.", + "dot=.,comma=,,semi=;", + "dot=.,semi=;,comma=,", + "semi=;,comma=,,dot=.", + "semi=;,dot=.,comma=," + ]] + ] + }, + "3.2.4 Fragment Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{#var}", "#value"], + ["{#hello}", "#Hello%20World!"], + ["{#half}", "#50%25"], + ["foo{#empty}", "foo#"], + ["foo{#undef}", "foo"], + ["{#x,hello,y}", "#1024,Hello%20World!,768"], + ["{#path,x}/here", "#/foo/bar,1024/here"], + ["{#path:6}/here", "#/foo/b/here"], + ["{#list}", "#red,green,blue"], + ["{#list*}", "#red,green,blue"], + ["{#keys}", [ + "#comma,,,dot,.,semi,;", + "#comma,,,semi,;,dot,.", + "#dot,.,comma,,,semi,;", + "#dot,.,semi,;,comma,,", + "#semi,;,comma,,,dot,.", + "#semi,;,dot,.,comma,," + ]] + ] + }, + "3.2.5 Label Expansion with Dot-Prefix" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{.who}", ".fred"], + ["{.who,who}", ".fred.fred"], + ["{.half,who}", ".50%25.fred"], + ["www{.dom*}", "www.example.com"], + ["X{.var}", "X.value"], + ["X{.var:3}", "X.val"], + ["X{.empty}", "X."], + ["X{.undef}", "X"], + ["X{.list}", "X.red,green,blue"], + ["X{.list*}", "X.red.green.blue"], + ["{#keys}", [ + "#comma,,,dot,.,semi,;", + "#comma,,,semi,;,dot,.", + "#dot,.,comma,,,semi,;", + "#dot,.,semi,;,comma,,", + "#semi,;,comma,,,dot,.", + "#semi,;,dot,.,comma,," + ]], + ["{#keys*}", [ + "#comma=,,dot=.,semi=;", + "#comma=,,semi=;,dot=.", + "#dot=.,comma=,,semi=;", + "#dot=.,semi=;,comma=,", + "#semi=;,comma=,,dot=.", + "#semi=;,dot=.,comma=," + ]], + ["X{.empty_keys}", "X"], + ["X{.empty_keys*}", "X"] + ] + }, + "3.2.6 Path Segment Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{/who}", "/fred"], + ["{/who,who}", "/fred/fred"], + ["{/half,who}", "/50%25/fred"], + ["{/who,dub}", "/fred/me%2Ftoo"], + ["{/var}", "/value"], + ["{/var,empty}", "/value/"], + ["{/var,undef}", "/value"], + ["{/var,x}/here", "/value/1024/here"], + ["{/var:1,var}", "/v/value"], + ["{/list}", "/red,green,blue"], + ["{/list*}", "/red/green/blue"], + ["{/list*,path:4}", "/red/green/blue/%2Ffoo"], + ["{/keys}", [ + "/comma,%2C,dot,.,semi,%3B", + "/comma,%2C,semi,%3B,dot,.", + "/dot,.,comma,%2C,semi,%3B", + "/dot,.,semi,%3B,comma,%2C", + "/semi,%3B,comma,%2C,dot,.", + "/semi,%3B,dot,.,comma,%2C" + ]], + ["{/keys*}", [ + "/comma=%2C/dot=./semi=%3B", + "/comma=%2C/semi=%3B/dot=.", + "/dot=./comma=%2C/semi=%3B", + "/dot=./semi=%3B/comma=%2C", + "/semi=%3B/comma=%2C/dot=.", + "/semi=%3B/dot=./comma=%2C" + ]] + ] + }, + "3.2.7 Path-Style Parameter Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{;who}", ";who=fred"], + ["{;half}", ";half=50%25"], + ["{;empty}", ";empty"], + ["{;hello:5}", ";hello=Hello"], + ["{;v,empty,who}", ";v=6;empty;who=fred"], + ["{;v,bar,who}", ";v=6;who=fred"], + ["{;x,y}", ";x=1024;y=768"], + ["{;x,y,empty}", ";x=1024;y=768;empty"], + ["{;x,y,undef}", ";x=1024;y=768"], + ["{;list}", ";list=red,green,blue"], + ["{;list*}", ";list=red;list=green;list=blue"], + ["{;keys}", [ + ";keys=comma,%2C,dot,.,semi,%3B", + ";keys=comma,%2C,semi,%3B,dot,.", + ";keys=dot,.,comma,%2C,semi,%3B", + ";keys=dot,.,semi,%3B,comma,%2C", + ";keys=semi,%3B,comma,%2C,dot,.", + ";keys=semi,%3B,dot,.,comma,%2C" + ]], + ["{;keys*}", [ + ";comma=%2C;dot=.;semi=%3B", + ";comma=%2C;semi=%3B;dot=.", + ";dot=.;comma=%2C;semi=%3B", + ";dot=.;semi=%3B;comma=%2C", + ";semi=%3B;comma=%2C;dot=.", + ";semi=%3B;dot=.;comma=%2C" + ]] + ] + }, + "3.2.8 Form-Style Query Expansion" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{?who}", "?who=fred"], + ["{?half}", "?half=50%25"], + ["{?x,y}", "?x=1024&y=768"], + ["{?x,y,empty}", "?x=1024&y=768&empty="], + ["{?x,y,undef}", "?x=1024&y=768"], + ["{?var:3}", "?var=val"], + ["{?list}", "?list=red,green,blue"], + ["{?list*}", "?list=red&list=green&list=blue"], + ["{?keys}", [ + "?keys=comma,%2C,dot,.,semi,%3B", + "?keys=comma,%2C,semi,%3B,dot,.", + "?keys=dot,.,comma,%2C,semi,%3B", + "?keys=dot,.,semi,%3B,comma,%2C", + "?keys=semi,%3B,comma,%2C,dot,.", + "?keys=semi,%3B,dot,.,comma,%2C" + ]], + ["{?keys*}", [ + "?comma=%2C&dot=.&semi=%3B", + "?comma=%2C&semi=%3B&dot=.", + "?dot=.&comma=%2C&semi=%3B", + "?dot=.&semi=%3B&comma=%2C", + "?semi=%3B&comma=%2C&dot=.", + "?semi=%3B&dot=.&comma=%2C" + ]] + ] + }, + "3.2.9 Form-Style Query Continuation" : + { + "variables": { + "count" : ["one", "two", "three"], + "dom" : ["example", "com"], + "dub" : "me/too", + "hello" : "Hello World!", + "half" : "50%", + "var" : "value", + "who" : "fred", + "base" : "http://example.com/home/", + "path" : "/foo/bar", + "list" : ["red", "green", "blue"], + "keys" : { "semi" : ";", "dot" : ".", "comma" : ","}, + "v" : "6", + "x" : "1024", + "y" : "768", + "empty" : "", + "empty_keys" : [], + "undef" : null + }, + "testcases" : [ + ["{&who}", "&who=fred"], + ["{&half}", "&half=50%25"], + ["?fixed=yes{&x}", "?fixed=yes&x=1024"], + ["{&var:3}", "&var=val"], + ["{&x,y,empty}", "&x=1024&y=768&empty="], + ["{&x,y,undef}", "&x=1024&y=768"], + ["{&list}", "&list=red,green,blue"], + ["{&list*}", "&list=red&list=green&list=blue"], + ["{&keys}", [ + "&keys=comma,%2C,dot,.,semi,%3B", + "&keys=comma,%2C,semi,%3B,dot,.", + "&keys=dot,.,comma,%2C,semi,%3B", + "&keys=dot,.,semi,%3B,comma,%2C", + "&keys=semi,%3B,comma,%2C,dot,.", + "&keys=semi,%3B,dot,.,comma,%2C" + ]], + ["{&keys*}", [ + "&comma=%2C&dot=.&semi=%3B", + "&comma=%2C&semi=%3B&dot=.", + "&dot=.&comma=%2C&semi=%3B", + "&dot=.&semi=%3B&comma=%2C", + "&semi=%3B&comma=%2C&dot=.", + "&semi=%3B&dot=.&comma=%2C" + ]] + ] + } +} diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples.json b/lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples.json new file mode 100644 index 000000000..2e8e942da --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/spec-examples.json @@ -0,0 +1,218 @@ +{ + "Level 1 Examples" : + { + "level": 1, + "variables": { + "var" : "value", + "hello" : "Hello World!" + }, + "testcases" : [ + ["{var}", "value"], + ["{hello}", "Hello%20World%21"] + ] + }, + "Level 2 Examples" : + { + "level": 2, + "variables": { + "var" : "value", + "hello" : "Hello World!", + "path" : "/foo/bar" + }, + "testcases" : [ + ["{+var}", "value"], + ["{+hello}", "Hello%20World!"], + ["{+path}/here", "/foo/bar/here"], + ["here?ref={+path}", "here?ref=/foo/bar"] + ] + }, + "Level 3 Examples" : + { + "level": 3, + "variables": { + "var" : "value", + "hello" : "Hello World!", + "empty" : "", + "path" : "/foo/bar", + "x" : "1024", + "y" : "768" + }, + "testcases" : [ + ["map?{x,y}", "map?1024,768"], + ["{x,hello,y}", "1024,Hello%20World%21,768"], + ["{+x,hello,y}", "1024,Hello%20World!,768"], + ["{+path,x}/here", "/foo/bar,1024/here"], + ["{#x,hello,y}", "#1024,Hello%20World!,768"], + ["{#path,x}/here", "#/foo/bar,1024/here"], + ["X{.var}", "X.value"], + ["X{.x,y}", "X.1024.768"], + ["{/var}", "/value"], + ["{/var,x}/here", "/value/1024/here"], + ["{;x,y}", ";x=1024;y=768"], + ["{;x,y,empty}", ";x=1024;y=768;empty"], + ["{?x,y}", "?x=1024&y=768"], + ["{?x,y,empty}", "?x=1024&y=768&empty="], + ["?fixed=yes{&x}", "?fixed=yes&x=1024"], + ["{&x,y,empty}", "&x=1024&y=768&empty="] + ] + }, + "Level 4 Examples" : + { + "level": 4, + "variables": { + "var": "value", + "hello": "Hello World!", + "path": "/foo/bar", + "list": ["red", "green", "blue"], + "keys": {"semi": ";", "dot": ".", "comma":","} + }, + "testcases": [ + ["{var:3}", "val"], + ["{var:30}", "value"], + ["{list}", "red,green,blue"], + ["{list*}", "red,green,blue"], + ["{keys}", [ + "comma,%2C,dot,.,semi,%3B", + "comma,%2C,semi,%3B,dot,.", + "dot,.,comma,%2C,semi,%3B", + "dot,.,semi,%3B,comma,%2C", + "semi,%3B,comma,%2C,dot,.", + "semi,%3B,dot,.,comma,%2C" + ]], + ["{keys*}", [ + "comma=%2C,dot=.,semi=%3B", + "comma=%2C,semi=%3B,dot=.", + "dot=.,comma=%2C,semi=%3B", + "dot=.,semi=%3B,comma=%2C", + "semi=%3B,comma=%2C,dot=.", + "semi=%3B,dot=.,comma=%2C" + ]], + ["{+path:6}/here", "/foo/b/here"], + ["{+list}", "red,green,blue"], + ["{+list*}", "red,green,blue"], + ["{+keys}", [ + "comma,,,dot,.,semi,;", + "comma,,,semi,;,dot,.", + "dot,.,comma,,,semi,;", + "dot,.,semi,;,comma,,", + "semi,;,comma,,,dot,.", + "semi,;,dot,.,comma,," + ]], + ["{+keys*}", [ + "comma=,,dot=.,semi=;", + "comma=,,semi=;,dot=.", + "dot=.,comma=,,semi=;", + "dot=.,semi=;,comma=,", + "semi=;,comma=,,dot=.", + "semi=;,dot=.,comma=," + ]], + ["{#path:6}/here", "#/foo/b/here"], + ["{#list}", "#red,green,blue"], + ["{#list*}", "#red,green,blue"], + ["{#keys}", [ + "#comma,,,dot,.,semi,;", + "#comma,,,semi,;,dot,.", + "#dot,.,comma,,,semi,;", + "#dot,.,semi,;,comma,,", + "#semi,;,comma,,,dot,.", + "#semi,;,dot,.,comma,," + ]], + ["{#keys*}", [ + "#comma=,,dot=.,semi=;", + "#comma=,,semi=;,dot=.", + "#dot=.,comma=,,semi=;", + "#dot=.,semi=;,comma=,", + "#semi=;,comma=,,dot=.", + "#semi=;,dot=.,comma=," + ]], + ["X{.var:3}", "X.val"], + ["X{.list}", "X.red,green,blue"], + ["X{.list*}", "X.red.green.blue"], + ["X{.keys}", [ + "X.comma,%2C,dot,.,semi,%3B", + "X.comma,%2C,semi,%3B,dot,.", + "X.dot,.,comma,%2C,semi,%3B", + "X.dot,.,semi,%3B,comma,%2C", + "X.semi,%3B,comma,%2C,dot,.", + "X.semi,%3B,dot,.,comma,%2C" + ]], + ["{/var:1,var}", "/v/value"], + ["{/list}", "/red,green,blue"], + ["{/list*}", "/red/green/blue"], + ["{/list*,path:4}", "/red/green/blue/%2Ffoo"], + ["{/keys}", [ + "/comma,%2C,dot,.,semi,%3B", + "/comma,%2C,semi,%3B,dot,.", + "/dot,.,comma,%2C,semi,%3B", + "/dot,.,semi,%3B,comma,%2C", + "/semi,%3B,comma,%2C,dot,.", + "/semi,%3B,dot,.,comma,%2C" + ]], + ["{/keys*}", [ + "/comma=%2C/dot=./semi=%3B", + "/comma=%2C/semi=%3B/dot=.", + "/dot=./comma=%2C/semi=%3B", + "/dot=./semi=%3B/comma=%2C", + "/semi=%3B/comma=%2C/dot=.", + "/semi=%3B/dot=./comma=%2C" + ]], + ["{;hello:5}", ";hello=Hello"], + ["{;list}", ";list=red,green,blue"], + ["{;list*}", ";list=red;list=green;list=blue"], + ["{;keys}", [ + ";keys=comma,%2C,dot,.,semi,%3B", + ";keys=comma,%2C,semi,%3B,dot,.", + ";keys=dot,.,comma,%2C,semi,%3B", + ";keys=dot,.,semi,%3B,comma,%2C", + ";keys=semi,%3B,comma,%2C,dot,.", + ";keys=semi,%3B,dot,.,comma,%2C" + ]], + ["{;keys*}", [ + ";comma=%2C;dot=.;semi=%3B", + ";comma=%2C;semi=%3B;dot=.", + ";dot=.;comma=%2C;semi=%3B", + ";dot=.;semi=%3B;comma=%2C", + ";semi=%3B;comma=%2C;dot=.", + ";semi=%3B;dot=.;comma=%2C" + ]], + ["{?var:3}", "?var=val"], + ["{?list}", "?list=red,green,blue"], + ["{?list*}", "?list=red&list=green&list=blue"], + ["{?keys}", [ + "?keys=comma,%2C,dot,.,semi,%3B", + "?keys=comma,%2C,semi,%3B,dot,.", + "?keys=dot,.,comma,%2C,semi,%3B", + "?keys=dot,.,semi,%3B,comma,%2C", + "?keys=semi,%3B,comma,%2C,dot,.", + "?keys=semi,%3B,dot,.,comma,%2C" + ]], + ["{?keys*}", [ + "?comma=%2C&dot=.&semi=%3B", + "?comma=%2C&semi=%3B&dot=.", + "?dot=.&comma=%2C&semi=%3B", + "?dot=.&semi=%3B&comma=%2C", + "?semi=%3B&comma=%2C&dot=.", + "?semi=%3B&dot=.&comma=%2C" + ]], + ["{&var:3}", "&var=val"], + ["{&list}", "&list=red,green,blue"], + ["{&list*}", "&list=red&list=green&list=blue"], + ["{&keys}", [ + "&keys=comma,%2C,dot,.,semi,%3B", + "&keys=comma,%2C,semi,%3B,dot,.", + "&keys=dot,.,comma,%2C,semi,%3B", + "&keys=dot,.,semi,%3B,comma,%2C", + "&keys=semi,%3B,comma,%2C,dot,.", + "&keys=semi,%3B,dot,.,comma,%2C" + ]], + ["{&keys*}", [ + "&comma=%2C&dot=.&semi=%3B", + "&comma=%2C&semi=%3B&dot=.", + "&dot=.&comma=%2C&semi=%3B", + "&dot=.&semi=%3B&comma=%2C", + "&semi=%3B&comma=%2C&dot=.", + "&semi=%3B&dot=.&comma=%2C" + ]] + ] + } +} diff --git a/lib/Google/vendor/rize/uri-template/tests/fixtures/transform-json-tests.xslt b/lib/Google/vendor/rize/uri-template/tests/fixtures/transform-json-tests.xslt new file mode 100644 index 000000000..d956b6bdb --- /dev/null +++ b/lib/Google/vendor/rize/uri-template/tests/fixtures/transform-json-tests.xslt @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/Google/vendor/symfony/deprecation-contracts/LICENSE b/lib/Google/vendor/symfony/deprecation-contracts/LICENSE index 406242ff2..0ed3a2465 100644 --- a/lib/Google/vendor/symfony/deprecation-contracts/LICENSE +++ b/lib/Google/vendor/symfony/deprecation-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2022 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/Google/vendor/symfony/deprecation-contracts/README.md b/lib/Google/vendor/symfony/deprecation-contracts/README.md index 4957933a6..9814864c0 100644 --- a/lib/Google/vendor/symfony/deprecation-contracts/README.md +++ b/lib/Google/vendor/symfony/deprecation-contracts/README.md @@ -22,5 +22,5 @@ trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use This will generate the following message: `Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.` -While not necessarily recommended, the deprecation notices can be completely ignored by declaring an empty +While not recommended, the deprecation notices can be completely ignored by declaring an empty `function trigger_deprecation() {}` in your application. diff --git a/lib/Google/vendor/symfony/deprecation-contracts/composer.json b/lib/Google/vendor/symfony/deprecation-contracts/composer.json index 1c1b4ba0e..5533b5c3f 100644 --- a/lib/Google/vendor/symfony/deprecation-contracts/composer.json +++ b/lib/Google/vendor/symfony/deprecation-contracts/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "autoload": { "files": [ @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.6-dev" }, "thanks": { "name": "symfony/contracts", diff --git a/lib/Google/vendor/symfony/polyfill-php81/LICENSE b/lib/Google/vendor/symfony/polyfill-php81/LICENSE deleted file mode 100644 index 99c6bdf35..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2021-present Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/Google/vendor/symfony/polyfill-php81/Php81.php b/lib/Google/vendor/symfony/polyfill-php81/Php81.php deleted file mode 100644 index f0507b765..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/Php81.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php81; - -/** - * @author Nicolas Grekas - * - * @internal - */ -final class Php81 -{ - public static function array_is_list(array $array): bool - { - if ([] === $array || $array === array_values($array)) { - return true; - } - - $nextKey = -1; - - foreach ($array as $k => $v) { - if ($k !== ++$nextKey) { - return false; - } - } - - return true; - } -} diff --git a/lib/Google/vendor/symfony/polyfill-php81/README.md b/lib/Google/vendor/symfony/polyfill-php81/README.md deleted file mode 100644 index c07ef7820..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Symfony Polyfill / Php81 -======================== - -This component provides features added to PHP 8.1 core: - -- [`array_is_list`](https://php.net/array_is_list) -- [`enum_exists`](https://php.net/enum-exists) -- [`MYSQLI_REFRESH_REPLICA`](https://php.net/mysqli.constants#constantmysqli-refresh-replica) constant -- [`ReturnTypeWillChange`](https://wiki.php.net/rfc/internal_method_return_types) -- [`CURLStringFile`](https://php.net/CURLStringFile) (but only if PHP >= 7.4 is used) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php b/lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php deleted file mode 100644 index 5ff93fcaf..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (\PHP_VERSION_ID >= 70400 && extension_loaded('curl')) { - /** - * @property string $data - */ - class CURLStringFile extends CURLFile - { - private $data; - - public function __construct(string $data, string $postname, string $mime = 'application/octet-stream') - { - $this->data = $data; - parent::__construct('data://application/octet-stream;base64,'.base64_encode($data), $mime, $postname); - } - - public function __set(string $name, $value): void - { - if ('data' !== $name) { - $this->$name = $value; - - return; - } - - if (is_object($value) ? !method_exists($value, '__toString') : !is_scalar($value)) { - throw new TypeError('Cannot assign '.gettype($value).' to property CURLStringFile::$data of type string'); - } - - $this->name = 'data://application/octet-stream;base64,'.base64_encode($value); - } - - public function __isset(string $name): bool - { - return isset($this->$name); - } - - public function &__get(string $name) - { - return $this->$name; - } - } -} diff --git a/lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php b/lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php deleted file mode 100644 index cb7720a8d..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (\PHP_VERSION_ID < 80100) { - #[Attribute(Attribute::TARGET_METHOD)] - final class ReturnTypeWillChange - { - public function __construct() - { - } - } -} diff --git a/lib/Google/vendor/symfony/polyfill-php81/bootstrap.php b/lib/Google/vendor/symfony/polyfill-php81/bootstrap.php deleted file mode 100644 index 9f872e02f..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/bootstrap.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Php81 as p; - -if (\PHP_VERSION_ID >= 80100) { - return; -} - -if (defined('MYSQLI_REFRESH_SLAVE') && !defined('MYSQLI_REFRESH_REPLICA')) { - define('MYSQLI_REFRESH_REPLICA', 64); -} - -if (!function_exists('array_is_list')) { - function array_is_list(array $array): bool { return p\Php81::array_is_list($array); } -} - -if (!function_exists('enum_exists')) { - function enum_exists(string $enum, bool $autoload = true): bool { return $autoload && class_exists($enum) && false; } -} diff --git a/lib/Google/vendor/symfony/polyfill-php81/composer.json b/lib/Google/vendor/symfony/polyfill-php81/composer.json deleted file mode 100644 index 28b6408ea..000000000 --- a/lib/Google/vendor/symfony/polyfill-php81/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "symfony/polyfill-php81", - "type": "library", - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "keywords": ["polyfill", "shim", "compatibility", "portable"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=7.2" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Php81\\": "" }, - "files": [ "bootstrap.php" ], - "classmap": [ "Resources/stubs" ] - }, - "minimum-stability": "dev", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - } -} diff --git a/lib/meta-box-tabs/CHANGELOG.md b/lib/meta-box-tabs/CHANGELOG.md new file mode 100644 index 000000000..fa1656c03 --- /dev/null +++ b/lib/meta-box-tabs/CHANGELOG.md @@ -0,0 +1,141 @@ +### 1.2.1 - 2025-09-16 + +- Fix tabs not working with blocks. + +### 1.2.0 - 2025-02-04 + +Add an option `'tab_remember' => true` to set to remember the opening tab in the next page load. + +### 1.1.19 - 2024-12-16 + +Improve performance + +### 1.1.18 - 2024-08-19 + +Fix running PHP Codesniffer when installing & autoload the plugin's main file via Composer + +### 1.1.17 - 2023-09-18 + +Fix "hide_from_front" not working if fields are in a tab + +### 1.1.16 - 2023-07-18 + +Fix issue with tooltip left + +### 1.1.15 - 2023-03-08 + +Auto enqueue Font Awesome when it's used + +### 1.1.14 - 2023-01-16 + +Fix issue with tooltip left + +### 1.1.13 - 2022-06-30 + +- Fix wysiwyg options not working + +### 1.1.12 - 2022-05-05 + +- Fix validating fields in inactive tabs + +### 1.1.11 - 2022-03-14 + +- Fix not working with blocks + +### 1.1.10 - 2022-01-14 + +- Fix tabs overflow container when too many tabs +- Fix JS validation error when no tabs + +### 1.1.9 - 2021-10-25 + +- Improve styling + +### 1.1.8 - 2020-09-04 + +- Fix undefined `tab_default_value`. + +### 1.1.7 - 2020-07-06 + +- Fix clicking icons not switching tabs. + +### 1.1.6 - 2020-06-02 + +- Improve style for tabs + +### 1.1.5 - 2019-12-24 + +- Show error fields in hidden tabs when validating. + +### 1.1.4 - 2019-04-02 + +- Fixed `overflow` issue cut off the color picker. +- Fixed wrong spacing for fields in user profile, edit term and settings pages. + +### 1.1.3 - 2019-02-26 + +- Fixed CSS for textarea field in tabs-left style. +- Also optimized CSS for user profile, edit term and settings pages. + +### 1.1.2 - 2019-01-21 + +- Fixed styling in user profile, term edit and settings pages screen. + +### 1.1.1 + +- Improved the way to show Google maps/OSM in hidden tabs. + +### 1.1.0 + +- Added new setting `tab_default_active` to set the default active tab when page loads +- Fixed color field is cut off in tab panel with tabs on the left. + +### 1.0.4 + +- Fixed styles for mobile devices + +### 1.0.3 + +- Fix style for groups + +### 1.0.2 + +- Empty tabs now showing empty tab panel instead of showing existing fields from other tabs. + +### 1.0.1 + +- Improvement: Better padding for tab panel content with tabs on the left. + +### 1.0.0 + +- Improvement: Make the extension safe to be included in themes/plugins. + +### 0.1.7 + +- Improvement: Better compatibility with Conditional Logic + +### 0.1.5 + +- Fix: Incorrect style for file advanced fields with Meta Box 4.6 + +### 0.1.4 + +- Improvement: Add option to hide meta box wrapper around tabs + +### 0.1.3 + +- Fix: Google maps not fully loaded in hidden tab + +### 0.1.2 + +- New: Now works with [MB Group](https://metabox.io/plugins/meta-box-group/) extension +- New: Improve performance by loading in admin only + +### 0.1.1 + +- New: Add left tab style +- New: Allow to use icons in tabs. Support Dashicons by default but can use any icon. + +### 0.1 + +- First release \ No newline at end of file diff --git a/lib/meta-box-tabs/meta-box-tabs.php b/lib/meta-box-tabs/meta-box-tabs.php index 6f1abc4ad..9b8d79225 100644 --- a/lib/meta-box-tabs/meta-box-tabs.php +++ b/lib/meta-box-tabs/meta-box-tabs.php @@ -3,7 +3,7 @@ * Plugin Name: MB Tabs * Plugin URI: https://metabox.io/plugins/meta-box-tabs/ * Description: Create tabs for meta boxes easily. Support 3 WordPress-native tab styles. - * Version: 1.2.0 + * Version: 1.2.1 * Author: MetaBox.io * Author URI: https://metabox.io * License: GPL2+ @@ -76,7 +76,7 @@ public function enqueue( RW_Meta_Box $obj ) { $tab_data = [ 'label' => $tab_data ]; } $tab_data = wp_parse_args( $tab_data, [ - 'icon' => '', + 'icon' => '', 'label' => '', ] ); $strpos = [ 'fa', 'fas', 'fa-solid', 'fab', 'fa-brand', 'far', 'fa-regular' ]; @@ -151,7 +151,7 @@ public function show_nav( RW_Meta_Box $obj ) { $tab_data = [ 'label' => $tab_data ]; } $tab_data = wp_parse_args( $tab_data, [ - 'icon' => '', + 'icon' => '', 'label' => '', ] ); @@ -181,7 +181,7 @@ public function show_nav( RW_Meta_Box $obj ) { $icon, esc_html( $tab_data['label'] ) ); - $i++; + ++$i; } echo ''; diff --git a/lib/meta-box-tabs/tabs.js b/lib/meta-box-tabs/tabs.js index 69b0f099b..aa30e49c3 100644 --- a/lib/meta-box-tabs/tabs.js +++ b/lib/meta-box-tabs/tabs.js @@ -1,4 +1,4 @@ -(( window, document, $ ) => { +( ( window, document, $ ) => { // Store initialized tabs to avoid re-initializing them. const initializedTabs = new Set(); @@ -19,14 +19,14 @@ $panels.hide().filter( '.rwmb-tab-panel-' + tab ).show(); const tabsGroupId = $wrapper.data( 'tab-remember' ); - + // Save active tab to local storage. if ( tabsGroupId ) { rememberTab( tab, tabsGroupId ); } // Delay expensive tasks, make sure the panel is visible before initializing - if ( ! initializedTabs.has( tab ) ) { + if ( !initializedTabs.has( tab ) ) { setTimeout( () => { rwmb.$document.trigger( 'mb_init_editors' ); @@ -36,19 +36,24 @@ initializedTabs.add( tab ); }, 200 ); } - } + }; // Set active tab based on visible pane to better works with Meta Box Conditional Logic. function tweakForConditionalLogic() { - if ( $( '.rwmb-tab-active' ).is( 'visible' ) ) { - return; - } + const $tabGroups = $( '.rwmb-tabs' ); - // Find the active pane. - var activePane = $( '.rwmb-tab-panel[style*="block"]' ).index(); - if ( activePane >= 0 ) { - $( '.rwmb-tab-nav li' ).removeClass( 'rwmb-tab-active' ).eq( activePane ).addClass( 'rwmb-tab-active' ); - } + $tabGroups.each( function() { + const $tabs = $( this ); + if ( $tabs.find( '.rwmb-tab-active' ).is( ':visible' ) ) { + return; + } + + // Find the active pane. + const activePane = $tabs.find( '.rwmb-tab-panel[style*="block"]' ).index(); + if ( activePane >= 0 ) { + $tabs.find( '.rwmb-tab-nav li' ).removeClass( 'rwmb-tab-active' ).eq( activePane ).addClass( 'rwmb-tab-active' ); + } + } ); } function showValidateErrorFields() { @@ -63,31 +68,31 @@ } const rememberTab = ( panel, tabsGroupId ) => { - localStorage.setItem( `rwmb_active_tab:${tabsGroupId}`, panel ); - } + localStorage.setItem( `rwmb_active_tab:${ tabsGroupId }`, panel ); + }; const setActiveTabsFromLocalStorage = () => { const tabGroups = document.querySelectorAll( '.rwmb-tabs' ); - + tabGroups.forEach( tabs => { const tabsGroupId = tabs.dataset.tabRemember; - if ( ! tabsGroupId ) { + if ( !tabsGroupId ) { tabs.querySelector( '.rwmb-tab-active a' ).click(); return; } - const activeTab = localStorage.getItem( `rwmb_active_tab:${tabsGroupId}` ); - + const activeTab = localStorage.getItem( `rwmb_active_tab:${ tabsGroupId }` ); + if ( activeTab ) { - tabs.querySelector( `li[data-panel="${activeTab}"] a` ).click(); + tabs.querySelector( `li[data-panel="${ activeTab }"] a` ).click(); } else { tabs.querySelector( '.rwmb-tab-active a' ).click(); } } ); - } + }; - $( document ).on( 'mb_ready', function () { + $( document ).on( 'mb_ready', function() { switchTab(); tweakForConditionalLogic(); showValidateErrorFields(); diff --git a/readme.txt b/readme.txt index 6e4ebd446..3802dd8cb 100644 --- a/readme.txt +++ b/readme.txt @@ -3,10 +3,10 @@ Contributors: usability_dynamics, andypotanin, ideric, planvova, obolgun Donate link: https://udx.io Tags: google cloud, google cloud storage, cdn, uploads, backup License: GPLv2 or later -Requires PHP: 8.0 +Requires PHP: 8.1 Requires at least: 5.0 -Tested up to: 6.8 -Stable tag: 4.3.0 +Tested up to: 6.9 +Stable tag: 4.4.0 Upload and serve your WordPress media files from Google Cloud Storage. @@ -136,6 +136,14 @@ Before upgrading to WP-Stateless 3.2.0, please, make sure you use PHP 7.2 or abo Before upgrading to WP-Stateless 3.0, please, make sure you tested it on your development environment. == Changelog == += 4.4.0 = +* NEW - plugin requires PHP 8.1+. +* ENHANCEMENT - updated `firebase/php-jwt` library from 6.11.1 to 7.0.2. +* ENHANCEMENT - Updated Client library for Google APIs from 2.18.3 to 2.18.4. +* ENHANCEMENT - updated `wpmetabox/meta-box` library from 5.10.15 to 5.10.19. +* ENHANCEMENT - updated `Meta Box Tabs` library from 1.1.18 to 1.2.0. +* FIX - `udx/lib-wp-bootstrap` package correctly loads text domain to prevent PHP notices. + = 4.3.0 = * ENHANCEMENT - update dependencies for Google APIs Client Library. * COMPATIBILITY - Simple Local Avatars Compatibility replaced with [WP-Stateless - Simple Local Avatars Addon](https://wordpress.org/plugins/wp-stateless-simple-local-avatars-addon/). diff --git a/vendor/autoload.php b/vendor/autoload.php index 9ceacb360..3a5fd21ae 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -14,10 +14,7 @@ echo $err; } } - trigger_error( - $err, - E_USER_ERROR - ); + throw new RuntimeException($err); } require_once __DIR__ . '/composer/autoload_real.php'; diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 51e734a77..2052022fd 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -26,12 +26,23 @@ */ class InstalledVersions { + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + /** * @var mixed[]|null * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; + /** + * @var bool + */ + private static $installedIsLocalDir; + /** * @var bool|null */ @@ -309,6 +320,24 @@ public static function reload($data) { self::$installed = $data; self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; } /** @@ -322,19 +351,27 @@ private static function getInstalled() } $installed = array(); + $copiedLocalDir = false; if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ $required = require $vendorDir.'/composer/installed.php'; - $installed[] = self::$installedByVendor[$vendorDir] = $required; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; } } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } } } @@ -350,7 +387,7 @@ private static function getInstalled() } } - if (self::$installed !== array()) { + if (self::$installed !== array() && !$copiedLocalDir) { $installed[] = self::$installed; } diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 5cd38fca7..ff3b61db0 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,115 +6,7 @@ $baseDir = dirname($vendorDir); return array( - 'ChromePhp' => $vendorDir . '/ccampbell/chromephp/ChromePhp.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'Composer\\Installers\\AglInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AglInstaller.php', - 'Composer\\Installers\\AkauntingInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AkauntingInstaller.php', - 'Composer\\Installers\\AnnotateCmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php', - 'Composer\\Installers\\AsgardInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AsgardInstaller.php', - 'Composer\\Installers\\AttogramInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/AttogramInstaller.php', - 'Composer\\Installers\\BaseInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BaseInstaller.php', - 'Composer\\Installers\\BitrixInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BitrixInstaller.php', - 'Composer\\Installers\\BonefishInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BonefishInstaller.php', - 'Composer\\Installers\\BotbleInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/BotbleInstaller.php', - 'Composer\\Installers\\CakePHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php', - 'Composer\\Installers\\ChefInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ChefInstaller.php', - 'Composer\\Installers\\CiviCrmInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CiviCrmInstaller.php', - 'Composer\\Installers\\ClanCatsFrameworkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php', - 'Composer\\Installers\\CockpitInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CockpitInstaller.php', - 'Composer\\Installers\\CodeIgniterInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php', - 'Composer\\Installers\\Concrete5Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Concrete5Installer.php', - 'Composer\\Installers\\ConcreteCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ConcreteCMSInstaller.php', - 'Composer\\Installers\\CroogoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/CroogoInstaller.php', - 'Composer\\Installers\\DecibelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DecibelInstaller.php', - 'Composer\\Installers\\DframeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DframeInstaller.php', - 'Composer\\Installers\\DokuWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DokuWikiInstaller.php', - 'Composer\\Installers\\DolibarrInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DolibarrInstaller.php', - 'Composer\\Installers\\DrupalInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/DrupalInstaller.php', - 'Composer\\Installers\\ElggInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ElggInstaller.php', - 'Composer\\Installers\\EliasisInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/EliasisInstaller.php', - 'Composer\\Installers\\ExpressionEngineInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php', - 'Composer\\Installers\\EzPlatformInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/EzPlatformInstaller.php', - 'Composer\\Installers\\ForkCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ForkCMSInstaller.php', - 'Composer\\Installers\\FuelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelInstaller.php', - 'Composer\\Installers\\FuelphpInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php', - 'Composer\\Installers\\GravInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/GravInstaller.php', - 'Composer\\Installers\\HuradInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/HuradInstaller.php', - 'Composer\\Installers\\ImageCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ImageCMSInstaller.php', - 'Composer\\Installers\\Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Installer.php', - 'Composer\\Installers\\ItopInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ItopInstaller.php', - 'Composer\\Installers\\KanboardInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KanboardInstaller.php', - 'Composer\\Installers\\KnownInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KnownInstaller.php', - 'Composer\\Installers\\KodiCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KodiCMSInstaller.php', - 'Composer\\Installers\\KohanaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/KohanaInstaller.php', - 'Composer\\Installers\\LanManagementSystemInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php', - 'Composer\\Installers\\LaravelInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LaravelInstaller.php', - 'Composer\\Installers\\LavaLiteInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LavaLiteInstaller.php', - 'Composer\\Installers\\LithiumInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/LithiumInstaller.php', - 'Composer\\Installers\\MODULEWorkInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php', - 'Composer\\Installers\\MODXEvoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php', - 'Composer\\Installers\\MagentoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MagentoInstaller.php', - 'Composer\\Installers\\MajimaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MajimaInstaller.php', - 'Composer\\Installers\\MakoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MakoInstaller.php', - 'Composer\\Installers\\MantisBTInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MantisBTInstaller.php', - 'Composer\\Installers\\MatomoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MatomoInstaller.php', - 'Composer\\Installers\\MauticInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MauticInstaller.php', - 'Composer\\Installers\\MayaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MayaInstaller.php', - 'Composer\\Installers\\MediaWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php', - 'Composer\\Installers\\MiaoxingInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MiaoxingInstaller.php', - 'Composer\\Installers\\MicroweberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php', - 'Composer\\Installers\\ModxInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ModxInstaller.php', - 'Composer\\Installers\\MoodleInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/MoodleInstaller.php', - 'Composer\\Installers\\OctoberInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OctoberInstaller.php', - 'Composer\\Installers\\OntoWikiInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OntoWikiInstaller.php', - 'Composer\\Installers\\OsclassInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OsclassInstaller.php', - 'Composer\\Installers\\OxidInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/OxidInstaller.php', - 'Composer\\Installers\\PPIInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PPIInstaller.php', - 'Composer\\Installers\\PantheonInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PantheonInstaller.php', - 'Composer\\Installers\\PhiftyInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhiftyInstaller.php', - 'Composer\\Installers\\PhpBBInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php', - 'Composer\\Installers\\PiwikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PiwikInstaller.php', - 'Composer\\Installers\\PlentymarketsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php', - 'Composer\\Installers\\Plugin' => $vendorDir . '/composer/installers/src/Composer/Installers/Plugin.php', - 'Composer\\Installers\\PortoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PortoInstaller.php', - 'Composer\\Installers\\PrestashopInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php', - 'Composer\\Installers\\ProcessWireInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ProcessWireInstaller.php', - 'Composer\\Installers\\PuppetInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PuppetInstaller.php', - 'Composer\\Installers\\PxcmsInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/PxcmsInstaller.php', - 'Composer\\Installers\\RadPHPInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RadPHPInstaller.php', - 'Composer\\Installers\\ReIndexInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ReIndexInstaller.php', - 'Composer\\Installers\\Redaxo5Installer' => $vendorDir . '/composer/installers/src/Composer/Installers/Redaxo5Installer.php', - 'Composer\\Installers\\RedaxoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php', - 'Composer\\Installers\\RoundcubeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php', - 'Composer\\Installers\\SMFInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SMFInstaller.php', - 'Composer\\Installers\\ShopwareInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php', - 'Composer\\Installers\\SilverStripeInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php', - 'Composer\\Installers\\SiteDirectInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SiteDirectInstaller.php', - 'Composer\\Installers\\StarbugInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/StarbugInstaller.php', - 'Composer\\Installers\\SyDESInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SyDESInstaller.php', - 'Composer\\Installers\\SyliusInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/SyliusInstaller.php', - 'Composer\\Installers\\TaoInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TaoInstaller.php', - 'Composer\\Installers\\TastyIgniterInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TastyIgniterInstaller.php', - 'Composer\\Installers\\TheliaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TheliaInstaller.php', - 'Composer\\Installers\\TuskInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/TuskInstaller.php', - 'Composer\\Installers\\UserFrostingInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/UserFrostingInstaller.php', - 'Composer\\Installers\\VanillaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/VanillaInstaller.php', - 'Composer\\Installers\\VgmcpInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/VgmcpInstaller.php', - 'Composer\\Installers\\WHMCSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php', - 'Composer\\Installers\\WinterInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WinterInstaller.php', - 'Composer\\Installers\\WolfCMSInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php', - 'Composer\\Installers\\WordPressInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/WordPressInstaller.php', - 'Composer\\Installers\\YawikInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/YawikInstaller.php', - 'Composer\\Installers\\ZendInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZendInstaller.php', - 'Composer\\Installers\\ZikulaInstaller' => $vendorDir . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php', - 'Firebase\\JWT\\BeforeValidException' => $vendorDir . '/firebase/php-jwt/src/BeforeValidException.php', - 'Firebase\\JWT\\CachedKeySet' => $vendorDir . '/firebase/php-jwt/src/CachedKeySet.php', - 'Firebase\\JWT\\ExpiredException' => $vendorDir . '/firebase/php-jwt/src/ExpiredException.php', - 'Firebase\\JWT\\JWK' => $vendorDir . '/firebase/php-jwt/src/JWK.php', - 'Firebase\\JWT\\JWT' => $vendorDir . '/firebase/php-jwt/src/JWT.php', - 'Firebase\\JWT\\JWTExceptionWithPayloadInterface' => $vendorDir . '/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php', - 'Firebase\\JWT\\Key' => $vendorDir . '/firebase/php-jwt/src/Key.php', - 'Firebase\\JWT\\SignatureInvalidException' => $vendorDir . '/firebase/php-jwt/src/SignatureInvalidException.php', 'UDX\\Settings' => $baseDir . '/lib/includes/class-settings.php', 'UDX\\Utility' => $baseDir . '/lib/includes/class-utility.php', 'UsabilityDynamics\\UD_API\\API' => $vendorDir . '/udx/lib-ud-api-client/lib/classes/class-api.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3820710ef..787d767c3 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,31 +7,31 @@ class ComposerStaticInitc59d002476a452800baaf79c430753cb { public static $prefixLengthsPsr4 = array ( - 'F' => + 'F' => array ( 'Firebase\\JWT\\' => 13, ), - 'C' => + 'C' => array ( 'Composer\\Installers\\' => 20, ), ); public static $prefixDirsPsr4 = array ( - 'Firebase\\JWT\\' => + 'Firebase\\JWT\\' => array ( 0 => __DIR__ . '/..' . '/firebase/php-jwt/src', ), - 'Composer\\Installers\\' => + 'Composer\\Installers\\' => array ( 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', ), ); public static $prefixesPsr0 = array ( - 'C' => + 'C' => array ( - 'ChromePhp' => + 'ChromePhp' => array ( 0 => __DIR__ . '/..' . '/ccampbell/chromephp', ), @@ -39,115 +39,7 @@ class ComposerStaticInitc59d002476a452800baaf79c430753cb ); public static $classMap = array ( - 'ChromePhp' => __DIR__ . '/..' . '/ccampbell/chromephp/ChromePhp.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'Composer\\Installers\\AglInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AglInstaller.php', - 'Composer\\Installers\\AkauntingInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AkauntingInstaller.php', - 'Composer\\Installers\\AnnotateCmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php', - 'Composer\\Installers\\AsgardInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AsgardInstaller.php', - 'Composer\\Installers\\AttogramInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/AttogramInstaller.php', - 'Composer\\Installers\\BaseInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BaseInstaller.php', - 'Composer\\Installers\\BitrixInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BitrixInstaller.php', - 'Composer\\Installers\\BonefishInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BonefishInstaller.php', - 'Composer\\Installers\\BotbleInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/BotbleInstaller.php', - 'Composer\\Installers\\CakePHPInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CakePHPInstaller.php', - 'Composer\\Installers\\ChefInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ChefInstaller.php', - 'Composer\\Installers\\CiviCrmInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CiviCrmInstaller.php', - 'Composer\\Installers\\ClanCatsFrameworkInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php', - 'Composer\\Installers\\CockpitInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CockpitInstaller.php', - 'Composer\\Installers\\CodeIgniterInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php', - 'Composer\\Installers\\Concrete5Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Concrete5Installer.php', - 'Composer\\Installers\\ConcreteCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ConcreteCMSInstaller.php', - 'Composer\\Installers\\CroogoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/CroogoInstaller.php', - 'Composer\\Installers\\DecibelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DecibelInstaller.php', - 'Composer\\Installers\\DframeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DframeInstaller.php', - 'Composer\\Installers\\DokuWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DokuWikiInstaller.php', - 'Composer\\Installers\\DolibarrInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DolibarrInstaller.php', - 'Composer\\Installers\\DrupalInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/DrupalInstaller.php', - 'Composer\\Installers\\ElggInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ElggInstaller.php', - 'Composer\\Installers\\EliasisInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/EliasisInstaller.php', - 'Composer\\Installers\\ExpressionEngineInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php', - 'Composer\\Installers\\EzPlatformInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/EzPlatformInstaller.php', - 'Composer\\Installers\\ForkCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ForkCMSInstaller.php', - 'Composer\\Installers\\FuelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/FuelInstaller.php', - 'Composer\\Installers\\FuelphpInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/FuelphpInstaller.php', - 'Composer\\Installers\\GravInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/GravInstaller.php', - 'Composer\\Installers\\HuradInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/HuradInstaller.php', - 'Composer\\Installers\\ImageCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ImageCMSInstaller.php', - 'Composer\\Installers\\Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Installer.php', - 'Composer\\Installers\\ItopInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ItopInstaller.php', - 'Composer\\Installers\\KanboardInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KanboardInstaller.php', - 'Composer\\Installers\\KnownInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KnownInstaller.php', - 'Composer\\Installers\\KodiCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KodiCMSInstaller.php', - 'Composer\\Installers\\KohanaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/KohanaInstaller.php', - 'Composer\\Installers\\LanManagementSystemInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php', - 'Composer\\Installers\\LaravelInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LaravelInstaller.php', - 'Composer\\Installers\\LavaLiteInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LavaLiteInstaller.php', - 'Composer\\Installers\\LithiumInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/LithiumInstaller.php', - 'Composer\\Installers\\MODULEWorkInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php', - 'Composer\\Installers\\MODXEvoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MODXEvoInstaller.php', - 'Composer\\Installers\\MagentoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MagentoInstaller.php', - 'Composer\\Installers\\MajimaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MajimaInstaller.php', - 'Composer\\Installers\\MakoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MakoInstaller.php', - 'Composer\\Installers\\MantisBTInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MantisBTInstaller.php', - 'Composer\\Installers\\MatomoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MatomoInstaller.php', - 'Composer\\Installers\\MauticInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MauticInstaller.php', - 'Composer\\Installers\\MayaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MayaInstaller.php', - 'Composer\\Installers\\MediaWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MediaWikiInstaller.php', - 'Composer\\Installers\\MiaoxingInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MiaoxingInstaller.php', - 'Composer\\Installers\\MicroweberInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MicroweberInstaller.php', - 'Composer\\Installers\\ModxInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ModxInstaller.php', - 'Composer\\Installers\\MoodleInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/MoodleInstaller.php', - 'Composer\\Installers\\OctoberInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OctoberInstaller.php', - 'Composer\\Installers\\OntoWikiInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OntoWikiInstaller.php', - 'Composer\\Installers\\OsclassInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OsclassInstaller.php', - 'Composer\\Installers\\OxidInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/OxidInstaller.php', - 'Composer\\Installers\\PPIInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PPIInstaller.php', - 'Composer\\Installers\\PantheonInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PantheonInstaller.php', - 'Composer\\Installers\\PhiftyInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PhiftyInstaller.php', - 'Composer\\Installers\\PhpBBInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PhpBBInstaller.php', - 'Composer\\Installers\\PiwikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PiwikInstaller.php', - 'Composer\\Installers\\PlentymarketsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php', - 'Composer\\Installers\\Plugin' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Plugin.php', - 'Composer\\Installers\\PortoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PortoInstaller.php', - 'Composer\\Installers\\PrestashopInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PrestashopInstaller.php', - 'Composer\\Installers\\ProcessWireInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ProcessWireInstaller.php', - 'Composer\\Installers\\PuppetInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PuppetInstaller.php', - 'Composer\\Installers\\PxcmsInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/PxcmsInstaller.php', - 'Composer\\Installers\\RadPHPInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RadPHPInstaller.php', - 'Composer\\Installers\\ReIndexInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ReIndexInstaller.php', - 'Composer\\Installers\\Redaxo5Installer' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/Redaxo5Installer.php', - 'Composer\\Installers\\RedaxoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RedaxoInstaller.php', - 'Composer\\Installers\\RoundcubeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/RoundcubeInstaller.php', - 'Composer\\Installers\\SMFInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SMFInstaller.php', - 'Composer\\Installers\\ShopwareInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ShopwareInstaller.php', - 'Composer\\Installers\\SilverStripeInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SilverStripeInstaller.php', - 'Composer\\Installers\\SiteDirectInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SiteDirectInstaller.php', - 'Composer\\Installers\\StarbugInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/StarbugInstaller.php', - 'Composer\\Installers\\SyDESInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SyDESInstaller.php', - 'Composer\\Installers\\SyliusInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/SyliusInstaller.php', - 'Composer\\Installers\\TaoInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TaoInstaller.php', - 'Composer\\Installers\\TastyIgniterInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TastyIgniterInstaller.php', - 'Composer\\Installers\\TheliaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TheliaInstaller.php', - 'Composer\\Installers\\TuskInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/TuskInstaller.php', - 'Composer\\Installers\\UserFrostingInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/UserFrostingInstaller.php', - 'Composer\\Installers\\VanillaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/VanillaInstaller.php', - 'Composer\\Installers\\VgmcpInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/VgmcpInstaller.php', - 'Composer\\Installers\\WHMCSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WHMCSInstaller.php', - 'Composer\\Installers\\WinterInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WinterInstaller.php', - 'Composer\\Installers\\WolfCMSInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WolfCMSInstaller.php', - 'Composer\\Installers\\WordPressInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/WordPressInstaller.php', - 'Composer\\Installers\\YawikInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/YawikInstaller.php', - 'Composer\\Installers\\ZendInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZendInstaller.php', - 'Composer\\Installers\\ZikulaInstaller' => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers/ZikulaInstaller.php', - 'Firebase\\JWT\\BeforeValidException' => __DIR__ . '/..' . '/firebase/php-jwt/src/BeforeValidException.php', - 'Firebase\\JWT\\CachedKeySet' => __DIR__ . '/..' . '/firebase/php-jwt/src/CachedKeySet.php', - 'Firebase\\JWT\\ExpiredException' => __DIR__ . '/..' . '/firebase/php-jwt/src/ExpiredException.php', - 'Firebase\\JWT\\JWK' => __DIR__ . '/..' . '/firebase/php-jwt/src/JWK.php', - 'Firebase\\JWT\\JWT' => __DIR__ . '/..' . '/firebase/php-jwt/src/JWT.php', - 'Firebase\\JWT\\JWTExceptionWithPayloadInterface' => __DIR__ . '/..' . '/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php', - 'Firebase\\JWT\\Key' => __DIR__ . '/..' . '/firebase/php-jwt/src/Key.php', - 'Firebase\\JWT\\SignatureInvalidException' => __DIR__ . '/..' . '/firebase/php-jwt/src/SignatureInvalidException.php', 'UDX\\Settings' => __DIR__ . '/../..' . '/lib/includes/class-settings.php', 'UDX\\Utility' => __DIR__ . '/../..' . '/lib/includes/class-utility.php', 'UsabilityDynamics\\UD_API\\API' => __DIR__ . '/..' . '/udx/lib-ud-api-client/lib/classes/class-api.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index c474bc8e1..1b86af2b6 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -309,16 +309,16 @@ }, { "name": "udx/lib-wp-bootstrap", - "version": "1.3.3", - "version_normalized": "1.3.3.0", + "version": "1.3.4", + "version_normalized": "1.3.4.0", "source": { "type": "git", "url": "git@github.com:udx/lib-wp-bootstrap", - "reference": "1.3.3" + "reference": "1.3.4" }, "dist": { "type": "zip", - "url": "https://github.com/udx/lib-wp-bootstrap/archive/1.3.3.zip" + "url": "https://github.com/udx/lib-wp-bootstrap/archive/1.3.4.zip" }, "require": { "php": ">=5.3" @@ -345,16 +345,16 @@ }, { "name": "wpackagist-plugin/meta-box", - "version": "5.10.15", - "version_normalized": "5.10.15.0", + "version": "5.10.19", + "version_normalized": "5.10.19.0", "source": { "type": "svn", "url": "https://plugins.svn.wordpress.org/meta-box/", - "reference": "tags/5.10.15" + "reference": "tags/5.10.19" }, "dist": { "type": "zip", - "url": "https://downloads.wordpress.org/plugin/meta-box.5.10.15.zip" + "url": "https://downloads.wordpress.org/plugin/meta-box.5.10.19.zip" }, "require": { "composer/installers": "^1.0 || ^2.0" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 3a037f258..e418eea65 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'wpcloud/wp-stateless', 'pretty_version' => 'dev-latest', 'version' => 'dev-latest', - 'reference' => 'a217f19a168588b1f86671abb2f1ac8a6f99814c', + 'reference' => 'b101c6a4d352f985df1f531078959f218d9b1f1a', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -47,18 +47,18 @@ 'dev_requirement' => false, ), 'udx/lib-wp-bootstrap' => array( - 'pretty_version' => '1.3.3', - 'version' => '1.3.3.0', - 'reference' => '1.3.3', + 'pretty_version' => '1.3.4', + 'version' => '1.3.4.0', + 'reference' => '1.3.4', 'type' => 'library', 'install_path' => __DIR__ . '/../udx/lib-wp-bootstrap', 'aliases' => array(), 'dev_requirement' => false, ), 'wpackagist-plugin/meta-box' => array( - 'pretty_version' => '5.10.15', - 'version' => '5.10.15.0', - 'reference' => 'tags/5.10.15', + 'pretty_version' => '5.10.19', + 'version' => '5.10.19.0', + 'reference' => 'tags/5.10.19', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../wpmetabox/meta-box', 'aliases' => array(), @@ -67,7 +67,7 @@ 'wpcloud/wp-stateless' => array( 'pretty_version' => 'dev-latest', 'version' => 'dev-latest', - 'reference' => 'a217f19a168588b1f86671abb2f1ac8a6f99814c', + 'reference' => 'b101c6a4d352f985df1f531078959f218d9b1f1a', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index adfb472fb..a70ba47c6 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -19,8 +19,7 @@ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; } } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR + throw new \RuntimeException( + 'Composer detected issues in your platform: ' . implode(' ', $issues) ); } diff --git a/vendor/udx/lib-wp-bootstrap/changes.md b/vendor/udx/lib-wp-bootstrap/changes.md index 29e76ae36..3f3449dbb 100644 --- a/vendor/udx/lib-wp-bootstrap/changes.md +++ b/vendor/udx/lib-wp-bootstrap/changes.md @@ -1,3 +1,7 @@ +### 1.3.4 + +* Fix notice about translations loaded too soon + ### 1.3.3 * Require user to be logged in while dismissing Admin Panel notices. diff --git a/vendor/udx/lib-wp-bootstrap/lib/classes/class-bootstrap-theme.php b/vendor/udx/lib-wp-bootstrap/lib/classes/class-bootstrap-theme.php index 5594b0cba..5d69d7771 100644 --- a/vendor/udx/lib-wp-bootstrap/lib/classes/class-bootstrap-theme.php +++ b/vendor/udx/lib-wp-bootstrap/lib/classes/class-bootstrap-theme.php @@ -49,7 +49,7 @@ class Bootstrap_Theme extends Bootstrap { protected function __construct( $args ) { parent::__construct( $args ); //** Load text domain */ - add_action( 'after_setup_theme', array( $this, 'load_textdomain' ), 1 ); + add_action( 'init', array( $this, 'load_textdomain' ), 1 ); //** TGM Plugin activation. */ $this->check_plugins_requirements(); //** May be initialize Licenses Manager. */ diff --git a/vendor/wpmetabox/meta-box/css/style.css b/vendor/wpmetabox/meta-box/css/style.css index a78635b8a..f26f92bb7 100644 --- a/vendor/wpmetabox/meta-box/css/style.css +++ b/vendor/wpmetabox/meta-box/css/style.css @@ -1,8 +1,8 @@ /* Styles for 'normal' meta boxes -------------------------------------------------------------- */ -/* Clearfix for field */ -.rwmb-field { +/* Lower specificity so it field classes are applied */ +:where(.rwmb-field) { display: flex; } .rwmb-field:not(:last-of-type) { diff --git a/vendor/wpmetabox/meta-box/inc/clone.php b/vendor/wpmetabox/meta-box/inc/clone.php index 63f0dca6b..3948e8893 100644 --- a/vendor/wpmetabox/meta-box/inc/clone.php +++ b/vendor/wpmetabox/meta-box/inc/clone.php @@ -3,17 +3,17 @@ * The clone module, allowing users to clone (duplicate) fields. */ class RWMB_Clone { - public static function html( array $meta, array $field ) : string { + public static function html( array $meta, array $field ): string { $field_html = ''; $count = count( $meta ); foreach ( $meta as $index => $sub_meta ) { $sub_field = $field; $sub_field['field_name'] = $field['field_name'] . "[{$index}]"; - $attributes_id = $sub_field['attributes']['id'] ?? $sub_field['id']; + $attributes_id = $sub_field['attributes']['id'] ?? $sub_field['id']; if ( $index === 0 && $count > 1 ) { - $sub_field['attributes']['id'] = $attributes_id . "_rwmb_template"; + $sub_field['attributes']['id'] = $attributes_id . '_rwmb_template'; } if ( $index === 1 ) { @@ -46,7 +46,7 @@ public static function html( array $meta, array $field ) : string { $sort_icon = ""; } - $class .= $index === 0 ? ' rwmb-clone-template' : ''; + $class .= $index === 0 ? ' rwmb-clone-template' : ''; $input_html = "
" . $sort_icon; // Call separated methods for displaying each type of field. @@ -97,7 +97,7 @@ public static function value( $new, $old, $object_id, array $field ) { return $new; } - public static function add_clone_button( array $field ) : string { + public static function add_clone_button( array $field ): string { if ( ! $field['clone'] ) { return ''; } @@ -105,7 +105,7 @@ public static function add_clone_button( array $field ) : string { return '' . esc_html( $text ) . ''; } - public static function remove_clone_button( array $field ) : string { + public static function remove_clone_button( array $field ): string { $text = RWMB_Field::filter( 'remove_clone_button_text', '', $field ); return '' . $text . ''; } diff --git a/vendor/wpmetabox/meta-box/inc/core.php b/vendor/wpmetabox/meta-box/inc/core.php index 516e9573f..d02281353 100644 --- a/vendor/wpmetabox/meta-box/inc/core.php +++ b/vendor/wpmetabox/meta-box/inc/core.php @@ -9,8 +9,15 @@ public function init() { $this->add_context_hooks(); } - public function plugin_links( array $links ) : array { - $links[] = '' . esc_html__( 'Docs', 'meta-box' ) . ''; + public function plugin_links( array $links ): array { + $links[] = '' . esc_html__( 'Docs', 'meta-box' ) . ''; + + $utc_timezone = new DateTimeZone( 'UTC' ); + $now = new DateTime( 'now', $utc_timezone ); + $sale_end = new DateTime( '2025-12-02 00:00:00', $utc_timezone ); + if ( $now < $sale_end ) { + $links[] = '' . esc_html__( 'Black Friday Sale', 'meta-box' ) . ''; + } return $links; } @@ -46,7 +53,7 @@ public function fix_page_template( WP_Post $post ) { * Get registered meta boxes via a filter. * @deprecated No longer used. Keep for backward-compatibility with extensions. */ - public static function get_meta_boxes() : array { + public static function get_meta_boxes(): array { $meta_boxes = rwmb_get_registry( 'meta_box' )->all(); return wp_list_pluck( $meta_boxes, 'meta_box' ); } diff --git a/vendor/wpmetabox/meta-box/inc/field-registry.php b/vendor/wpmetabox/meta-box/inc/field-registry.php index f7030e594..1c838a92d 100644 --- a/vendor/wpmetabox/meta-box/inc/field-registry.php +++ b/vendor/wpmetabox/meta-box/inc/field-registry.php @@ -50,7 +50,7 @@ public function get( $id, $type, $object_type = 'post' ) { * * @return array List of fields. */ - public function get_by_object_type( string $object_type = 'post' ) : array { + public function get_by_object_type( string $object_type = 'post' ): array { return $this->data[ $object_type ] ?? []; } } diff --git a/vendor/wpmetabox/meta-box/inc/field.php b/vendor/wpmetabox/meta-box/inc/field.php index 0d2466c9a..cf9c1b9b2 100644 --- a/vendor/wpmetabox/meta-box/inc/field.php +++ b/vendor/wpmetabox/meta-box/inc/field.php @@ -577,11 +577,11 @@ protected static function get_std( array $field ) { $depth = 0; if ( $field['multiple'] ) { - $depth++; + ++$depth; } if ( $field['clone'] ) { - $depth++; + ++$depth; } return Arr::to_depth( $field['std'], $depth ); @@ -591,9 +591,9 @@ protected static function get_single_std( array $field ) { $depth = 0; if ( $field['multiple'] ) { - $depth++; + ++$depth; } - return Arr::to_depth( $field[ 'std' ], $depth ); + return Arr::to_depth( $field['std'], $depth ); } } diff --git a/vendor/wpmetabox/meta-box/inc/fields/autocomplete.php b/vendor/wpmetabox/meta-box/inc/fields/autocomplete.php index 6591994f0..d65bb03d3 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/autocomplete.php +++ b/vendor/wpmetabox/meta-box/inc/fields/autocomplete.php @@ -70,6 +70,7 @@ public static function html( $meta, $field ) { if ( is_array( $field['options'] ) ) { foreach ( $field['options'] as $value => $label ) { + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict if ( ! in_array( $value, $meta ) ) { continue; } diff --git a/vendor/wpmetabox/meta-box/inc/fields/checkbox.php b/vendor/wpmetabox/meta-box/inc/fields/checkbox.php index 0997aa750..3ebddba66 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/checkbox.php +++ b/vendor/wpmetabox/meta-box/inc/fields/checkbox.php @@ -25,7 +25,7 @@ public static function html( $meta, $field ) { return $output; } - protected static function input_description( array $field ) : string { + protected static function input_description( array $field ): string { return ''; } diff --git a/vendor/wpmetabox/meta-box/inc/fields/choice.php b/vendor/wpmetabox/meta-box/inc/fields/choice.php index affb313ed..4fca113eb 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/choice.php +++ b/vendor/wpmetabox/meta-box/inc/fields/choice.php @@ -37,7 +37,7 @@ public static function normalize( $field ) { return $field; } - public static function transform_options( $options ) : array { + public static function transform_options( $options ): array { $transformed = []; $options = (array) $options; foreach ( $options as $value => $label ) { diff --git a/vendor/wpmetabox/meta-box/inc/fields/date.php b/vendor/wpmetabox/meta-box/inc/fields/date.php index aae9820bc..e354b1465 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/date.php +++ b/vendor/wpmetabox/meta-box/inc/fields/date.php @@ -15,7 +15,7 @@ public static function admin_enqueue_scripts() { * Returns a date() compatible format string from the JavaScript format. * @link http://www.php.net/manual/en/function.date.php */ - protected static function get_php_format( array $js_options ) : string { + protected static function get_php_format( array $js_options ): string { return strtr( $js_options['dateFormat'], self::$date_formats ); } } diff --git a/vendor/wpmetabox/meta-box/inc/fields/datetime.php b/vendor/wpmetabox/meta-box/inc/fields/datetime.php index 8f10f569a..2be77efbb 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/datetime.php +++ b/vendor/wpmetabox/meta-box/inc/fields/datetime.php @@ -212,7 +212,7 @@ public static function from_save_format( $meta, array $field ): string { ] ); $format = $formats[ $field['save_format'] ]; - $date = DateTimeImmutable::createFromFormat( $format, $meta ); + $date = DateTimeImmutable::createFromFormat( $format, (string) $meta ); return false === $date ? (string) $meta : $date->format( $field['php_format'] ); } diff --git a/vendor/wpmetabox/meta-box/inc/fields/divider.php b/vendor/wpmetabox/meta-box/inc/fields/divider.php index e382099dc..3e6c71026 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/divider.php +++ b/vendor/wpmetabox/meta-box/inc/fields/divider.php @@ -10,12 +10,12 @@ public static function admin_enqueue_scripts() { wp_style_add_data( 'rwmb-divider', 'path', RWMB_CSS_DIR . 'divider.css' ); } - protected static function begin_html( array $field ) : string { + protected static function begin_html( array $field ): string { $attributes = empty( $field['id'] ) ? '' : " id='{$field['id']}'"; return ""; } - public static function end_html( array $field ) : string { + public static function end_html( array $field ): string { return ''; } } diff --git a/vendor/wpmetabox/meta-box/inc/fields/fieldset-text.php b/vendor/wpmetabox/meta-box/inc/fields/fieldset-text.php index 1aaa1472a..c133f07c4 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/fieldset-text.php +++ b/vendor/wpmetabox/meta-box/inc/fields/fieldset-text.php @@ -37,7 +37,7 @@ public static function html( $meta, $field ) { return $out; } - protected static function input_description( array $field ) : string { + protected static function input_description( array $field ): string { return ''; } diff --git a/vendor/wpmetabox/meta-box/inc/fields/file.php b/vendor/wpmetabox/meta-box/inc/fields/file.php index f3d3f9a42..8ff843a4c 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/file.php +++ b/vendor/wpmetabox/meta-box/inc/fields/file.php @@ -64,8 +64,9 @@ public static function ajax_delete_file() { /** * Recursively search needle in haystack */ - protected static function in_array_r( $needle, $haystack, $strict = false ) : bool { + protected static function in_array_r( $needle, $haystack, $strict = false ): bool { foreach ( $haystack as $item ) { + // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual if ( ( $strict ? $item === $needle : $item == $needle ) || ( is_array( $item ) && self::in_array_r( $needle, $item, $strict ) ) ) { return true; } @@ -213,7 +214,7 @@ protected static function file_html( $file, $index, $field ) { ); } - protected static function file_info_custom_dir( string $file, array $field ) : array { + protected static function file_info_custom_dir( string $file, array $field ): array { $path = wp_normalize_path( trailingslashit( $field['upload_dir'] ) . basename( $file ) ); $ext = pathinfo( $path, PATHINFO_EXTENSION ); $icon_url = wp_mime_type_icon( wp_ext2type( $ext ) ); @@ -249,7 +250,7 @@ public static function value( $new, $old, $post_id, $field ) { $new = array_filter( (array) $new ); $count = self::transform( $input ); - for ( $i = 0; $i < $count; $i ++ ) { + for ( $i = 0; $i < $count; $i++ ) { $attachment = self::handle_upload( "{$input}_{$i}", $post_id, $field ); if ( $attachment && ! is_wp_error( $attachment ) ) { $new[] = $attachment; @@ -457,7 +458,7 @@ public static function handle_upload_custom_dir( $file_id, $field ) { // @codingStandardsIgnoreEnd // Use a closure to filter upload directory. Requires PHP >= 5.3.0. - $filter_upload_dir = function( $uploads ) use ( $field ) { + $filter_upload_dir = function ( $uploads ) use ( $field ) { $uploads['path'] = $field['upload_dir']; $uploads['url'] = self::convert_path_to_url( $field['upload_dir'] ); $uploads['subdir'] = ''; @@ -485,7 +486,7 @@ public static function handle_upload_custom_dir( $file_id, $field ) { return empty( $file_info['url'] ) ? null : $file_info['url']; } - public static function convert_path_to_url( string $path ) : string { + public static function convert_path_to_url( string $path ): string { $path = wp_normalize_path( untrailingslashit( $path ) ); $root = wp_normalize_path( untrailingslashit( ABSPATH ) ); $relative_path = str_replace( $root, '', $path ); diff --git a/vendor/wpmetabox/meta-box/inc/fields/heading.php b/vendor/wpmetabox/meta-box/inc/fields/heading.php index ea7eb3a6a..d89cb1938 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/heading.php +++ b/vendor/wpmetabox/meta-box/inc/fields/heading.php @@ -10,12 +10,12 @@ public static function admin_enqueue_scripts() { wp_style_add_data( 'rwmb-heading', 'path', RWMB_CSS_DIR . 'heading.css' ); } - protected static function begin_html( array $field ) : string { + protected static function begin_html( array $field ): string { $attributes = empty( $field['id'] ) ? '' : " id='{$field['id']}'"; return sprintf( '%s', $attributes, $field['name'] ); } - protected static function end_html( array $field ) : string { + protected static function end_html( array $field ): string { return self::input_description( $field ); } } diff --git a/vendor/wpmetabox/meta-box/inc/fields/icon.php b/vendor/wpmetabox/meta-box/inc/fields/icon.php index ae455f5d0..15d9fcb75 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/icon.php +++ b/vendor/wpmetabox/meta-box/inc/fields/icon.php @@ -30,11 +30,12 @@ private static function enqueue_icon_font_style( array $field ): void { private static function get_icons( array $field ): array { // Get from cache to prevent reading large files. - $params = [ + $params = [ 'icon_file' => $field['icon_file'], 'icon_dir' => $field['icon_dir'], 'icon_css' => is_string( $field['icon_css'] ) ? $field['icon_css'] : '', ]; + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize $cache_key = md5( serialize( $params ) ) . '-icons'; $icons = wp_cache_get( $cache_key, self::CACHE_GROUP ); if ( false !== $icons ) { @@ -239,6 +240,7 @@ public static function normalize( $field ) { } // Font Awesome Pro. + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf if ( $field['icon_set'] === 'font-awesome-pro' ) { } elseif ( $field['icon_file'] || $field['icon_dir'] || $field['icon_css'] ) { @@ -274,7 +276,8 @@ public static function format_single_value( $field, $value, $args, $post_id ) { } $icons = self::get_icons( $field ); - $key = array_search( $value, array_column( $icons, 'value' ) ); + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict + $key = array_search( $value, array_column( $icons, 'value' ) ); if ( false === $key ) { return ''; } diff --git a/vendor/wpmetabox/meta-box/inc/fields/image-select.php b/vendor/wpmetabox/meta-box/inc/fields/image-select.php index 38f9d6b13..9b8712aac 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/image-select.php +++ b/vendor/wpmetabox/meta-box/inc/fields/image-select.php @@ -18,14 +18,15 @@ public static function admin_enqueue_scripts() { * @return string */ public static function html( $meta, $field ) { - $html = []; - $meta = (array) $meta; + $html = []; + $meta = (array) $meta; foreach ( $field['options'] as $value => $image ) { $attributes = self::get_attributes( $field, $value ); $html[] = sprintf( '', $image, self::render_attributes( $attributes ), + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict checked( in_array( $value, $meta ), true, false ) ); } diff --git a/vendor/wpmetabox/meta-box/inc/fields/input.php b/vendor/wpmetabox/meta-box/inc/fields/input.php index 2831d5b30..e94690060 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/input.php +++ b/vendor/wpmetabox/meta-box/inc/fields/input.php @@ -29,7 +29,7 @@ public static function html( $meta, $field ) { } $attributes = static::get_attributes( $field, $meta ); - $output .= sprintf( '%s', self::render_attributes( $attributes ), self::datalist( $field ) ); + $output .= sprintf( '%s', self::render_attributes( $attributes ), self::datalist( $field ) ); if ( $field['append'] ) { $output .= '' . $field['append'] . ''; @@ -50,7 +50,7 @@ public static function html( $meta, $field ) { */ public static function normalize( $field ) { $field = parent::normalize( $field ); - $field = wp_parse_args( $field, [ + $field = wp_parse_args( $field, [ 'autocomplete' => false, 'datalist' => false, 'readonly' => false, @@ -61,7 +61,7 @@ public static function normalize( $field ) { 'append' => '', ] ); if ( $field['datalist'] ) { - $field['datalist'] = wp_parse_args( $field['datalist'], [ + $field['datalist'] = wp_parse_args( $field['datalist'], [ 'id' => $field['id'] . '_list', 'options' => [], ] ); @@ -78,7 +78,7 @@ public static function normalize( $field ) { */ public static function get_attributes( $field, $value = null ) { $attributes = parent::get_attributes( $field, $value ); - $attributes = wp_parse_args( $attributes, [ + $attributes = wp_parse_args( $attributes, [ 'autocomplete' => $field['autocomplete'], 'list' => $field['datalist'] ? $field['datalist']['id'] : false, 'readonly' => $field['readonly'], diff --git a/vendor/wpmetabox/meta-box/inc/fields/key-value.php b/vendor/wpmetabox/meta-box/inc/fields/key-value.php index 542844a95..e91e1f04c 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/key-value.php +++ b/vendor/wpmetabox/meta-box/inc/fields/key-value.php @@ -34,11 +34,11 @@ public static function html( $meta, $field ) { return $html; } - protected static function begin_html( array $field ) : string { + protected static function begin_html( array $field ): string { return parent::begin_html( $field ) . parent::input_description( $field ); } - protected static function input_description( array $field ) : string { + protected static function input_description( array $field ): string { return ''; } diff --git a/vendor/wpmetabox/meta-box/inc/fields/map.php b/vendor/wpmetabox/meta-box/inc/fields/map.php index 8f52c0245..0f1eb313a 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/map.php +++ b/vendor/wpmetabox/meta-box/inc/fields/map.php @@ -105,7 +105,7 @@ public static function get_value( $field, $args = [], $post_id = null ) { $location = []; foreach ( $value as $clone ) { list( $latitude, $longitude, $zoom ) = explode( ',', $clone . ',,' ); - $location[] = compact( 'latitude', 'longitude', 'zoom' ); + $location[] = compact( 'latitude', 'longitude', 'zoom' ); } return $location; } @@ -116,13 +116,13 @@ public static function get_value( $field, $args = [], $post_id = null ) { /** * Format value before render map - * @param mixed $field - * @param mixed $value - * @param mixed $args - * @param mixed $post_id + * @param array $field Field settings. + * @param mixed $value Field value. + * @param mixed $args Additional arguments. + * @param mixed $post_id Post ID. * @return string */ - public static function format_single_value( $field, $value, $args, $post_id ): string { + public static function format_single_value( $field, $value, $args, $post_id ) { $args = wp_parse_args( $args, [ 'api_key' => $field['api_key'] ?? '', ] ); @@ -138,16 +138,17 @@ public static function format_single_value( $field, $value, $args, $post_id ): s * @return string */ public static function render_map( $location, $args = [] ) { - // For compatibility with previous version, or within groups. + // For compatibility with previous version, or within groups. if ( is_string( $location ) ) { list( $latitude, $longitude, $zoom ) = explode( ',', $location . ',,' ); } else { + // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract( $location ); } - if ( ! $latitude || ! $longitude ) { - return ''; - } + if ( ! $latitude || ! $longitude ) { + return ''; + } $args = wp_parse_args( $args, [ 'latitude' => $latitude, diff --git a/vendor/wpmetabox/meta-box/inc/fields/media.php b/vendor/wpmetabox/meta-box/inc/fields/media.php index 202a2ac8d..f6c5edbc0 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/media.php +++ b/vendor/wpmetabox/meta-box/inc/fields/media.php @@ -142,7 +142,7 @@ public static function get_attributes( $field, $value = null ) { return $attributes; } - protected static function get_mime_extensions() : array { + protected static function get_mime_extensions(): array { $mime_types = wp_get_mime_types(); $extensions = []; foreach ( $mime_types as $ext => $mime ) { diff --git a/vendor/wpmetabox/meta-box/inc/fields/object-choice.php b/vendor/wpmetabox/meta-box/inc/fields/object-choice.php index 7b8657047..c16165de3 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/object-choice.php +++ b/vendor/wpmetabox/meta-box/inc/fields/object-choice.php @@ -28,7 +28,7 @@ public static function show( array $field, bool $saved, $post_id = 0 ) { parent::show( $field, $saved, $post_id ); } - abstract public static function query( $meta, array $field ) : array; + abstract public static function query( $meta, array $field ): array; /** * Get field HTML. @@ -152,7 +152,7 @@ public static function admin_enqueue_scripts() { /** * Get correct rendering class for the field. */ - protected static function get_type_class( array $field ) : string { + protected static function get_type_class( array $field ): string { return RWMB_Helpers_Field::get_class( [ 'type' => $field['field_type'] ] ); } } diff --git a/vendor/wpmetabox/meta-box/inc/fields/osm.php b/vendor/wpmetabox/meta-box/inc/fields/osm.php index 57082fe15..11224b407 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/osm.php +++ b/vendor/wpmetabox/meta-box/inc/fields/osm.php @@ -12,7 +12,7 @@ public static function admin_enqueue_scripts() { wp_style_add_data( 'rwmb-osm', 'path', RWMB_CSS_DIR . 'osm.css' ); wp_enqueue_script( 'rwmb-osm', RWMB_JS_URL . 'osm.js', [ 'jquery', 'jquery-ui-autocomplete', 'leaflet' ], RWMB_VER, true ); - RWMB_Helpers_Field::localize_script_once( 'rwmb-osm', 'RWMB_Osm', [ + RWMB_Helpers_Field::localize_script_once( 'rwmb-osm', 'RWMB_Osm', [ 'no_results_string' => __( 'No results found', 'meta-box' ), ] ); } @@ -100,13 +100,13 @@ public static function get_value( $field, $args = [], $post_id = null ) { /** * Format value before render map - * @param mixed $field - * @param mixed $value - * @param mixed $args - * @param mixed $post_id - * @return string + * @param array $field Field settings. + * @param mixed $value Field value. + * @param mixed $args Additional arguments. + * @param mixed $post_id Post ID. + * @return string HTML. */ - public static function format_single_value( $field, $value, $args, $post_id ): string { + public static function format_single_value( $field, $value, $args, $post_id ) { return self::render_map( $value, $args ); } @@ -114,7 +114,7 @@ public static function format_single_value( $field, $value, $args, $post_id ): s * Render a map in the frontend. * * @param string|array $location The "latitude,longitude[,zoom]" location. - * @param array $args Additional arguments for the map. + * @param array $args Additional arguments for the map. * * @return string */ @@ -123,6 +123,7 @@ public static function render_map( $location, $args = [] ) { if ( is_string( $location ) ) { list( $latitude, $longitude, $zoom ) = explode( ',', $location . ',,' ); } else { + // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract( $location ); } @@ -130,7 +131,7 @@ public static function render_map( $location, $args = [] ) { return ''; } - $args = wp_parse_args( $args, [ + $args = wp_parse_args( $args, [ 'latitude' => $latitude, 'longitude' => $longitude, 'width' => '100%', @@ -151,7 +152,7 @@ public static function render_map( $location, $args = [] ) { * More Open Street Map options * @link https://leafletjs.com/reference-1.5.0.html#map-option */ - $args['js_options'] = wp_parse_args( $args['js_options'], [ + $args['js_options'] = wp_parse_args( $args['js_options'], [ // Default to 'zoom' level set in admin, but can be overwritten. 'zoom' => $args['zoom'], ] ); @@ -171,6 +172,6 @@ private static function enqueue_map_assets() { wp_enqueue_script( 'leaflet', RWMB_JS_URL . 'leaflet/leaflet.js', [], '1.9.4', true ); wp_enqueue_style( 'leaflet-gesture-handling', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.css', [ 'leaflet' ], '1.2.2' ); wp_style_add_data( 'leaflet-gesture-handling', 'path', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.css' ); - wp_enqueue_script( 'leaflet-gesture-handling', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.js', [ 'leaflet' ], '1.2.2' ); + wp_enqueue_script( 'leaflet-gesture-handling', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.js', [ 'leaflet' ], '1.2.2', true ); } } diff --git a/vendor/wpmetabox/meta-box/inc/fields/post.php b/vendor/wpmetabox/meta-box/inc/fields/post.php index 665cfebae..42a7d4d12 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/post.php +++ b/vendor/wpmetabox/meta-box/inc/fields/post.php @@ -118,9 +118,10 @@ public static function query( $meta, array $field ): array { // Get from cache to prevent same queries. $last_changed = wp_cache_get_last_changed( 'posts' ); - $key = md5( serialize( $args ) ); - $cache_key = "$key:$last_changed"; - $options = wp_cache_get( $cache_key, 'meta-box-post-field' ); + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize + $key = md5( serialize( $args ) ); + $cache_key = "$key:$last_changed"; + $options = wp_cache_get( $cache_key, 'meta-box-post-field' ); if ( false !== $options ) { return $options; @@ -136,7 +137,7 @@ public static function query( $meta, array $field ): array { if ( ! current_user_can( 'read_post', $post ) ) { continue; } - + $label = $post->post_title ? $post->post_title : __( '(No title)', 'meta-box' ); $label = self::filter( 'choice_label', $label, $field, $post ); $options[ $post->ID ] = [ @@ -212,6 +213,14 @@ public static function format_single_value( $field, $value, $args, $post_id ) { return ''; } + /** + * Allow developers to change the value of the post. Used for WPML integration. + * @var int|string $value The post ID. + * @var array $field The field parameters. + * @internal + */ + $value = apply_filters( '_rwmb_post_format_single_value', $value, $field ); + $link = $args['link'] ?? 'view'; $text = get_the_title( $value ); diff --git a/vendor/wpmetabox/meta-box/inc/fields/sidebar.php b/vendor/wpmetabox/meta-box/inc/fields/sidebar.php index 77a9672d7..3d2a8e041 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/sidebar.php +++ b/vendor/wpmetabox/meta-box/inc/fields/sidebar.php @@ -15,7 +15,7 @@ public static function normalize( $field ) { return $field; } - public static function query( $meta, array $field ) : array { + public static function query( $meta, array $field ): array { global $wp_registered_sidebars; $options = []; foreach ( $wp_registered_sidebars as $sidebar ) { diff --git a/vendor/wpmetabox/meta-box/inc/fields/text-list.php b/vendor/wpmetabox/meta-box/inc/fields/text-list.php index d8ef5de0e..267e8143b 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/text-list.php +++ b/vendor/wpmetabox/meta-box/inc/fields/text-list.php @@ -38,7 +38,7 @@ public static function html( $meta, $field ) { $label, self::render_attributes( $attributes ) ); - $count ++; + ++$count; } return implode( ' ', $html ); diff --git a/vendor/wpmetabox/meta-box/inc/fields/time.php b/vendor/wpmetabox/meta-box/inc/fields/time.php index 1ae8cc74a..c434fee49 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/time.php +++ b/vendor/wpmetabox/meta-box/inc/fields/time.php @@ -30,4 +30,4 @@ public static function normalize( $field ) { protected static function get_php_format( array $js_options ): string { return strtr( $js_options['timeFormat'], self::$time_formats ); } -} \ No newline at end of file +} diff --git a/vendor/wpmetabox/meta-box/inc/fields/user.php b/vendor/wpmetabox/meta-box/inc/fields/user.php index f440bbfec..10962dc80 100644 --- a/vendor/wpmetabox/meta-box/inc/fields/user.php +++ b/vendor/wpmetabox/meta-box/inc/fields/user.php @@ -17,7 +17,7 @@ public static function ajax_get_users() { $request = rwmb_request(); $field = $request->filter_post( 'field', FILTER_DEFAULT, FILTER_FORCE_ARRAY ); - + // Required for 'choice_label' filter. See self::filter(). $field['clone'] = false; $field['_original_id'] = $field['id']; @@ -97,12 +97,12 @@ public static function normalize( $field ) { public static function query( $meta, array $field ): array { $display_field = $field['display_field']; - $args = wp_parse_args( $field['query_args'], [ + $args = wp_parse_args( $field['query_args'], [ 'orderby' => $display_field, 'order' => 'asc', ] ); - $args['fields'] = [ + $args['fields'] = [ 'ID', 'user_login', 'user_nicename', @@ -122,9 +122,10 @@ public static function query( $meta, array $field ): array { // Get from cache to prevent same queries. $last_changed = wp_cache_get_last_changed( 'users' ); - $key = md5( serialize( $args ) ); - $cache_key = "$key:$last_changed"; - $options = wp_cache_get( $cache_key, 'meta-box-user-field' ); + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize + $key = md5( serialize( $args ) ); + $cache_key = "$key:$last_changed"; + $options = wp_cache_get( $cache_key, 'meta-box-user-field' ); if ( false !== $options ) { return $options; } diff --git a/vendor/wpmetabox/meta-box/inc/helpers/field.php b/vendor/wpmetabox/meta-box/inc/helpers/field.php index e6e705aa3..583decc28 100644 --- a/vendor/wpmetabox/meta-box/inc/helpers/field.php +++ b/vendor/wpmetabox/meta-box/inc/helpers/field.php @@ -19,14 +19,14 @@ public static function add_inline_script_once( string $handle, string $text ) { } } - public static function get_class( $field ) : string { + public static function get_class( $field ): string { $type = self::get_type( $field ); $class = 'RWMB_' . RWMB_Helpers_String::title_case( $type ) . '_Field'; $class = apply_filters( 'rwmb_field_class', $class, $type ); return class_exists( $class ) ? $class : 'RWMB_Input_Field'; } - private static function get_type( $field ) : string { + private static function get_type( $field ): string { $type = $field['type'] ?? 'text'; $map = array_merge( [ diff --git a/vendor/wpmetabox/meta-box/inc/helpers/string.php b/vendor/wpmetabox/meta-box/inc/helpers/string.php index fc90d50c5..84a592fed 100644 --- a/vendor/wpmetabox/meta-box/inc/helpers/string.php +++ b/vendor/wpmetabox/meta-box/inc/helpers/string.php @@ -3,7 +3,7 @@ * String helper functions. */ class RWMB_Helpers_String { - public static function title_case( string $text ) : string { + public static function title_case( string $text ): string { $text = str_replace( [ '-', '_' ], ' ', $text ); $text = ucwords( $text ); $text = str_replace( ' ', '_', $text ); diff --git a/vendor/wpmetabox/meta-box/inc/loader.php b/vendor/wpmetabox/meta-box/inc/loader.php index 2408bbd75..0cced892c 100644 --- a/vendor/wpmetabox/meta-box/inc/loader.php +++ b/vendor/wpmetabox/meta-box/inc/loader.php @@ -7,7 +7,7 @@ class RWMB_Loader { protected function constants() { // Script version, used to add version for scripts and styles. - define( 'RWMB_VER', '5.10.15' ); + define( 'RWMB_VER', '5.10.19' ); list( $path, $url ) = self::get_path( dirname( __DIR__ ) ); @@ -96,15 +96,11 @@ public function init() { $media_modal = new RWMB_Media_Modal(); $media_modal->init(); - // WPML Compatibility. - $wpml = new RWMB_WPML(); - $wpml->init(); - // Update. $update_option = null; $update_checker = null; if ( class_exists( '\MetaBox\Updater\Option' ) ) { - $update_option = new \MetaBox\Updater\Option(); + $update_option = new \MetaBox\Updater\Option(); $update_checker = new \MetaBox\Updater\Checker( $update_option ); $update_checker->init(); $update_settings = new \MetaBox\Updater\Settings( $update_checker, $update_option ); @@ -113,10 +109,13 @@ public function init() { $update_notification->init(); } + // WPML Compatibility. + new \MetaBox\Integrations\WPML(); + // Register categories for page builders. new \MetaBox\Integrations\Block(); - new \MetaBox\Integrations\Bricks; - new \MetaBox\Integrations\Elementor; + new \MetaBox\Integrations\Bricks(); + new \MetaBox\Integrations\Elementor(); new \MetaBox\Integrations\Oxygen(); if ( is_admin() ) { diff --git a/vendor/wpmetabox/meta-box/inc/meta-box-registry.php b/vendor/wpmetabox/meta-box/inc/meta-box-registry.php index 92ee5ee38..4699c25fc 100644 --- a/vendor/wpmetabox/meta-box/inc/meta-box-registry.php +++ b/vendor/wpmetabox/meta-box/inc/meta-box-registry.php @@ -34,7 +34,7 @@ public function get( $id ) { * * @param array $args Custom argument to get meta boxes by. */ - public function get_by( array $args ) : array { + public function get_by( array $args ): array { $meta_boxes = $this->data; foreach ( $meta_boxes as $index => $meta_box ) { foreach ( $args as $key => $value ) { diff --git a/vendor/wpmetabox/meta-box/inc/meta-box.php b/vendor/wpmetabox/meta-box/inc/meta-box.php index a7c54930b..ff87a9942 100644 --- a/vendor/wpmetabox/meta-box/inc/meta-box.php +++ b/vendor/wpmetabox/meta-box/inc/meta-box.php @@ -70,7 +70,7 @@ public function register_fields() { } } - public function is_shown() : bool { + public function is_shown(): bool { $show = apply_filters( 'rwmb_show', true, $this->meta_box ); return apply_filters( "rwmb_show_{$this->id}", $show, $this->meta_box ); } @@ -83,7 +83,7 @@ protected function global_hooks() { // Don't enqueue on frontend as front-end forms and blocks already call the enqueue() method. // TODO: Uncomment this when we have a way to enqueue assets for the block/site editor. // if ( is_admin() ) { - // add_action( 'enqueue_block_assets', [ $this, 'enqueue' ] ); + // add_action( 'enqueue_block_assets', [ $this, 'enqueue' ] ); // } // Add additional actions for fields. @@ -156,10 +156,10 @@ public function enqueue() { do_action( 'rwmb_enqueue_scripts', $this ); } - private function is_gutenberg_screen() : bool { + private function is_gutenberg_screen(): bool { $screen = get_current_screen(); - return in_array( $screen->base, [ 'site-editor', 'widgets' ] ); + return in_array( $screen->base, [ 'site-editor', 'widgets' ], true ); } /** @@ -181,7 +181,7 @@ public function add_meta_boxes() { } } - public function postbox_classes( array $classes ) : array { + public function postbox_classes( array $classes ): array { if ( $this->closed ) { $classes[] = 'closed'; } @@ -190,7 +190,7 @@ public function postbox_classes( array $classes ) : array { return $classes; } - public function hide( array $hidden, $screen ) : array { + public function hide( array $hidden, $screen ): array { if ( $this->is_edit_screen( $screen ) && $this->default_hidden ) { $hidden[] = $this->id; } @@ -242,8 +242,8 @@ protected function get_cleanup_fields( $fields, $prefix = '' ) { foreach ( $fields as $field ) { $field_id = $prefix . $field['id']; if ( ! empty( $field['fields'] ) ) { - $suffix = $field[ 'clone' ] ? '.*.' : '.'; - $names = array_merge( $names, $this->get_cleanup_fields( $field['fields'], $field_id . $suffix ) ); + $suffix = $field['clone'] ? '.*.' : '.'; + $names = array_merge( $names, $this->get_cleanup_fields( $field['fields'], $field_id . $suffix ) ); } if ( $field['clone'] ) { @@ -301,7 +301,7 @@ public function save_field( array $field ) { RWMB_Field::filter( 'after_save_field', null, $field, $new, $old, $this->object_id ); } - public function validate() : bool { + public function validate(): bool { $nonce = rwmb_request()->filter_post( "nonce_{$this->id}" ); return ! $this->saved @@ -336,7 +336,7 @@ public static function normalize( $meta_box ) { return $meta_box; } - public static function normalize_fields( array $fields, $storage = null ) : array { + public static function normalize_fields( array $fields, $storage = null ): array { foreach ( $fields as $k => $field ) { $field = RWMB_Field::call( 'normalize', $field ); @@ -410,7 +410,7 @@ public function set_object_id( $id = null ) { $this->object_id = $id; } - public function get_object_type() : string { + public function get_object_type(): string { return $this->object_type; } diff --git a/vendor/wpmetabox/meta-box/inc/request.php b/vendor/wpmetabox/meta-box/inc/request.php index f8bdd691f..0108ad292 100644 --- a/vendor/wpmetabox/meta-box/inc/request.php +++ b/vendor/wpmetabox/meta-box/inc/request.php @@ -42,7 +42,7 @@ public function cleanup( array $data ) { if ( empty( $cleanups ) || ! is_array( $cleanups ) ) { return $data; } - + // Decode the JSON string for each cleanup item foreach ( $cleanups as $cleanup ) { $cleanup = json_decode( stripslashes( $cleanup ) ); diff --git a/vendor/wpmetabox/meta-box/inc/sanitizer.php b/vendor/wpmetabox/meta-box/inc/sanitizer.php index 8c3c3421a..e72cd5b65 100644 --- a/vendor/wpmetabox/meta-box/inc/sanitizer.php +++ b/vendor/wpmetabox/meta-box/inc/sanitizer.php @@ -146,6 +146,7 @@ private function sanitize_choice( $value, $field ) { $options = RWMB_Choice_Field::transform_options( $field['options'] ); $options = wp_list_pluck( $options, 'value' ); $value = wp_unslash( $value ); + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict return is_array( $value ) ? array_intersect( $value, $options ) : ( in_array( $value, $options ) ? $value : '' ); } diff --git a/vendor/wpmetabox/meta-box/inc/shortcode.php b/vendor/wpmetabox/meta-box/inc/shortcode.php index 821e0226f..2990e8202 100644 --- a/vendor/wpmetabox/meta-box/inc/shortcode.php +++ b/vendor/wpmetabox/meta-box/inc/shortcode.php @@ -22,7 +22,7 @@ public function register_shortcode( $atts ) { $field_id = $atts['id']; $object_id = $atts['object_id']; - + unset( $atts['id'], $atts['object_id'] ); $value = $this->get_value( $field_id, $object_id, $atts ); @@ -39,11 +39,11 @@ public function register_shortcode( $atts ) { } private function get_value( $field_id, $object_id, $atts ) { - // If we pass object_id via shortcode, we need to make sure current user + // If we pass object_id via shortcode, we need to make sure current user // has permission to view the object - if ( ! is_null ( $object_id ) ) { + if ( ! is_null( $object_id ) ) { $has_object_permission = $this->check_object_permission( $object_id, $atts ); - + if ( ! $has_object_permission ) { return null; } diff --git a/vendor/wpmetabox/meta-box/inc/walkers/input-list.php b/vendor/wpmetabox/meta-box/inc/walkers/input-list.php index 6e7991c5a..44f557d56 100644 --- a/vendor/wpmetabox/meta-box/inc/walkers/input-list.php +++ b/vendor/wpmetabox/meta-box/inc/walkers/input-list.php @@ -42,6 +42,7 @@ public function start_el( &$output, $object, $depth = 0, $args = [], $current_ob $output .= sprintf( '', RWMB_Field::render_attributes( $attributes ), + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict checked( in_array( $object->value, $this->meta ), true, false ), $object->label ); diff --git a/vendor/wpmetabox/meta-box/inc/walkers/select-tree.php b/vendor/wpmetabox/meta-box/inc/walkers/select-tree.php index 6a8037dd2..13e821cb3 100644 --- a/vendor/wpmetabox/meta-box/inc/walkers/select-tree.php +++ b/vendor/wpmetabox/meta-box/inc/walkers/select-tree.php @@ -66,7 +66,7 @@ public function display_level( $options, $parent_id = 0, $active = false ) { $attributes = RWMB_Field::call( 'get_attributes', $field, $this->meta ); if ( $output_required ) { - unset( $attributes[ 'required' ] ); + unset( $attributes['required'] ); } if ( ! empty( $attributes['required'] ) ) { @@ -86,6 +86,7 @@ public function display_level( $options, $parent_id = 0, $active = false ) { foreach ( $children as $child ) { if ( isset( $options[ $child->value ] ) ) { + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict $output .= $this->display_level( $options, $child->value, in_array( $child->value, $this->meta ) && $active ); } } diff --git a/vendor/wpmetabox/meta-box/inc/walkers/select.php b/vendor/wpmetabox/meta-box/inc/walkers/select.php index 727877840..bb8d5f7f5 100644 --- a/vendor/wpmetabox/meta-box/inc/walkers/select.php +++ b/vendor/wpmetabox/meta-box/inc/walkers/select.php @@ -22,6 +22,7 @@ public function start_el( &$output, $object, $depth = 0, $args = [], $current_ob $output .= sprintf( '', esc_attr( $object->value ), + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict selected( in_array( $object->value, $this->meta ), true, false ), $indent, esc_html( $object->label ) diff --git a/vendor/wpmetabox/meta-box/js/clone.js b/vendor/wpmetabox/meta-box/js/clone.js index 52bc10672..e8313e999 100644 --- a/vendor/wpmetabox/meta-box/js/clone.js +++ b/vendor/wpmetabox/meta-box/js/clone.js @@ -14,7 +14,7 @@ // Name attribute var name = this.name; - if ( name && ! $field.closest( '.rwmb-group-clone' ).length ) { + if ( name && !$field.closest( '.rwmb-group-clone' ).length ) { $field.attr( 'name', cloneIndex.replace( index, name, '[', ']', false ) ); } @@ -60,7 +60,7 @@ var regex = new RegExp( cloneIndex.escapeRegex( before ) + '(\\d+)' + cloneIndex.escapeRegex( after ) + end ), newValue = before + index + after; - return regex.test( value ) ? value.replace( regex, newValue ) : (alternative ? value + newValue : value ); + return regex.test( value ) ? value.replace( regex, newValue ) : ( alternative ? value + newValue : value ); }, /** @@ -94,7 +94,7 @@ // Object holds all method related to fields' value when clone. var cloneValue = { - setDefault: function() { + setDefault: function () { var $field = $( this ); if ( true !== $field.data( 'clone-default' ) ) { @@ -107,25 +107,30 @@ if ( 'radio' === type ) { $field.prop( 'checked', $field.val() === defaultValue ); } else if ( $field.hasClass( 'rwmb-checkbox' ) || $field.hasClass( 'rwmb-switch' ) ) { - $field.prop( 'checked', !! defaultValue ); + $field.prop( 'checked', !!defaultValue ); } else if ( $field.hasClass( 'rwmb-checkbox_list' ) ) { var value = $field.val(); $field.prop( 'checked', Array.isArray( defaultValue ) ? -1 !== defaultValue.indexOf( value ) : value == defaultValue ); } else if ( $field.is( 'select' ) ) { $field.find( 'option[value="' + defaultValue + '"]' ).prop( 'selected', true ); - } else if ( ! $field.hasClass( 'rwmb-hidden' ) ) { + } else if ( !$field.hasClass( 'rwmb-hidden' ) ) { $field.val( defaultValue ); } }, - clear: function() { + clear: function () { const $field = $( this ), type = $field.attr( 'type' ); if ( 'radio' === type || 'checkbox' === type ) { $field.prop( 'checked', false ); } else if ( $field.is( 'select' ) ) { - $field.prop( 'selectedIndex', 0 ); - } else if ( ! $field.hasClass( 'rwmb-hidden' ) ) { + if ( $field.attr( 'multiple' ) ) { + $field.find( 'option' ).prop( 'selected', false ); + $field.val( null ).trigger( 'change' ); + } else { + $field.prop( 'selectedIndex', 0 ); + } + } else if ( !$field.hasClass( 'rwmb-hidden' ) ) { $field.val( '' ); } } @@ -146,20 +151,20 @@ $template.find( rwmb.inputSelectors ).each( function () { this.id = this.id.includes( '_rwmb_template' ) ? this.id : this.id + '_rwmb_template'; } ); - + // Clear fields' values. - var $inputs = $clone.find( rwmb.inputSelectors ); + var $inputs = $clone.find( rwmb.inputSelectors ); let count = $container.children( '.rwmb-clone' ).length; - + // The first clone should keep the default values. if ( count > 1 ) { $inputs.each( cloneValue.clear ); } - + $clone = $clone.removeClass( 'rwmb-clone-template' ); // Remove validation errors. $clone.find( 'p.rwmb-error' ).remove(); - + // Insert clone. $clone.insertAfter( $last ); count++; @@ -195,7 +200,7 @@ let offset = 1; // Add the first clone if data-clone-empty-start = false - const cloneEmptyStart = $container[0].dataset.cloneEmptyStart ?? 0; + const cloneEmptyStart = $container[ 0 ].dataset.cloneEmptyStart ?? 0; // If clone-empty-start is true, we need at least 1 item. if ( cloneEmptyStart == 1 ) { @@ -235,7 +240,7 @@ toggleRemoveButtons( $container ); toggleAddButton( $container ); - sortClones.apply( $container[0] ); + sortClones.apply( $container[ 0 ] ); } function removeClone( e ) { @@ -279,7 +284,7 @@ // Make the placeholder has the same height as dragged item ui.placeholder.height( ui.item.outerHeight() ); }, - stop: function( event, ui ) { + stop: function ( event, ui ) { ui.item.trigger( 'mb_init_editors' ); ui.item.find( rwmb.inputSelectors ).first().trigger( 'mb_change' ); } @@ -310,4 +315,4 @@ rwmb.sortClones = sortClones; rwmb.toggleRemoveButtons = toggleRemoveButtons; rwmb.toggleAddButton = toggleAddButton; -} )( jQuery, rwmb ); +}( jQuery, rwmb ) ); diff --git a/vendor/wpmetabox/meta-box/meta-box.php b/vendor/wpmetabox/meta-box/meta-box.php index a513cc268..cb59208c3 100644 --- a/vendor/wpmetabox/meta-box/meta-box.php +++ b/vendor/wpmetabox/meta-box/meta-box.php @@ -3,7 +3,7 @@ * Plugin Name: Meta Box * Plugin URI: https://metabox.io * Description: Create custom meta boxes and custom fields in WordPress. - * Version: 5.10.15 + * Version: 5.10.19 * Author: MetaBox.io * Author URI: https://metabox.io * License: GPL2+ diff --git a/vendor/wpmetabox/meta-box/readme.txt b/vendor/wpmetabox/meta-box/readme.txt index ffbf20fda..14c885205 100644 --- a/vendor/wpmetabox/meta-box/readme.txt +++ b/vendor/wpmetabox/meta-box/readme.txt @@ -4,8 +4,8 @@ Donate link: https://metabox.io/pricing/ Tags: custom fields, custom post types, post type, custom taxonomies, meta box Requires at least: 6.5 Requires PHP: 7.1 -Tested up to: 6.8.2 -Stable tag: 5.10.15 +Tested up to: 6.8.3 +Stable tag: 5.10.19 License: GPLv2 or later Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for your custom post types in WordPress. @@ -147,17 +147,34 @@ If you want to use Meta Box, please follow these steps: == Changelog == += 5.10.19 - 2025-11-24 = + +- Fix the `use` statement with non-compound name has no effect + += 5.10.18 - 2025-11-24 = + +- Fix deprecation message for `datetime` field + += 5.10.17 - 2025-11-07 = + +- WPML integration: fix error when filtering value for helper functions when no fields are found. + += 5.10.16 - 2025-11-05 = + +- WPML integration: filter helper functions to get the translated IDs for `post` field +- Fix cloning `post` field not clearing the value + = 5.10.15 - 2025-10-06 = -Add `marker_draggable` option for `map`/`osm` fields to disable changing the pin on the map. +- Add `marker_draggable` option for `map`/`osm` fields to disable changing the pin on the map. = 5.10.14 - 2025-09-15 = -Update dependencies +- Update dependencies = 5.10.13 - 2025-08-14 = -Fix `get_current_screen()` error for term meta +- Fix `get_current_screen()` error for term meta = 5.10.12 - 2025-08-13 = diff --git a/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.css b/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.css index 34fe9d5e6..7f2069ff9 100644 --- a/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.css +++ b/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.css @@ -1 +1 @@ -body.wp-admin{background:#f8fafc}div#wpcontent{padding-left:0}#wpwrap .notice{display:none}.mb-dashboard{--mb-color-accent: #00b1b3;--mb-color-link: var(--mb-color-accent);--mb-border: 1px solid #cbd5e1;font-size:14px;color:#334155}.mb-dashboard a{text-decoration:none;color:var(--mb-color-link)}.mb-dashboard a:hover{color:var(--mb-color-link);text-decoration:underline}.mb-dashboard a:focus,.mb-dashboard a:active{outline:none;box-shadow:none}.mb-dashboard p{font-size:14px}.mb-dashboard table{width:100%;border-collapse:collapse}.mb-dashboard tr{border-bottom:1px solid #e2e8f0}.mb-dashboard tr:hover{background:#f8fafc}.mb-dashboard th,.mb-dashboard td{padding-block:12px}.mb-dashboard__button{--mb-color-link: #fff;display:inline-block;background:var(--mb-color-accent);padding:16px;text-transform:uppercase;font-weight:700;font-size:16px;line-height:1;letter-spacing:.025em;white-space:nowrap;border-radius:4px;text-decoration:none}.mb-dashboard__button.mb-dashboard__button:hover{color:#fff;opacity:.9;text-decoration:none}.mb-dashboard__button:focus,.mb-dashboard__button:active{color:#fff}.mb-dashboard__hidden{display:none}.mb-dashboard__external{display:inline-flex;align-items:center;gap:4px}.mb-dashboard__external svg{width:1em;height:1em;fill:currentColor}.mb-dashboard__tooltip{position:relative}.mb-dashboard__tooltip:after{content:attr(data-tooltip);background-color:#0f172a;color:#fff;padding:4px 8px;border-radius:4px;white-space:nowrap;position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);visibility:hidden;opacity:0;transition:opacity .3s ease-in-out}.mb-dashboard__tooltip[data-position=top]:after{bottom:calc(100% + 8px);top:auto}.mb-dashboard__tooltip[data-position=bottom-right]:after{left:auto;transform:none;right:0}.mb-dashboard__tooltip:hover:after{visibility:visible;opacity:1}.mb-dashboard__body{display:flex;gap:48px;padding:48px;max-width:1280px;margin-inline:auto}.mb-dashboard__header{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:12px;background:#fff;border-bottom:1px solid #e2e8f0}.mb-dashboard__header__search{flex:1}.mb-dashboard__header__search__inner{position:relative;max-width:480px;margin-inline:auto}.mb-dashboard__header__search input[type=text]{width:100%;background:#f1f5f9;border-color:#e2e8f0;padding:2px 16px;margin:0}.mb-dashboard__header__search input[type=text]:focus,.mb-dashboard__header__search input[type=text]:hover{border-color:#cbd5e1;box-shadow:none}.mb-dashboard__header__search:has(.mb-dashboard__header__search-results:not([data-type=empty])) input{border-radius:4px 4px 0 0}.mb-dashboard__header__search-results{position:absolute;top:33px;left:0;right:0;background:#fff;z-index:9;border:var(--mb-border);border-radius:0 0 4px 4px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1)}.mb-dashboard__header__search-results a{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;color:inherit;padding:8px 16px;transition:all .2s ease-in-out}.mb-dashboard__header__search-results a:hover{color:inherit;text-decoration:none;background:#f1f5f9}.mb-dashboard__header__search-results a:last-child{border-radius:0 0 4px 4px}.mb-dashboard__header__search-results span{display:inline-block;padding:2px 8px;background:#e2e8f0;border:var(--mb-border);border-radius:4px;font-size:12px}.mb-dashboard__header__search-results[data-type=empty]{display:none}.mb-dashboard__header__search-results[data-type=text]{padding:16px}.mb-dashboard__header__icons{display:flex;align-items:center}.mb-dashboard__header__icons a{display:inline-flex;align-items:center;justify-content:center}.mb-dashboard__header__social{display:flex;align-items:center;gap:12px;border-right:var(--mb-border);padding-right:12px;margin-right:12px}.mb-dashboard__header__social svg{width:16px;height:16px;fill:#64748b;transition:all .2s ease-in-out}.mb-dashboard__header__social a{width:24px;height:24px}.mb-dashboard__header__social a:hover svg{fill:#334155}.mb-dashboard__header__links{display:flex;align-items:center;gap:12px}.mb-dashboard__header__links a{color:#64748b;width:36px;height:36px;border:var(--mb-border);border-radius:50%}.mb-dashboard__header__links a:hover{color:#334155;border-color:#94a3b8}.mb-dashboard__header__links svg{width:20px;height:20px}.mb-dashboard__header .mb-dashboard__logo svg{display:block;width:auto;height:46px}.mb-dashboard__main{flex:1;display:flex;flex-direction:column;gap:48px}.mb-dashboard__actions__title{font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:.025em;line-height:1;margin-bottom:16px}.mb-dashboard__actions__inner{display:grid;grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));gap:24px}.mb-dashboard__action{display:flex;gap:16px;align-items:center;border-radius:8px;border:1px solid var(--mb-color-accent);padding:24px;background:#fff;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);position:relative;top:0;transition:all .2s ease}.mb-dashboard__action svg{width:32px;height:32px;fill:var(--mb-color-accent)}.mb-dashboard__action__title{display:block;margin-bottom:4px;color:#0f172a;font-weight:600;font-size:16px}.mb-dashboard__action__description{color:#64748b}.mb-dashboard__action.mb-dashboard__action:hover{text-decoration:none;top:-8px}.mb-dashboard__intro__subtitle{font-size:16px}.mb-dashboard__intro__title{font-size:24px;color:#0f172a;font-weight:600;margin-top:12px}.mb-dashboard__intro__text{margin-top:24px;font-size:18px;line-height:1.6}.mb-dashboard__intro .mb-dashboard__button{margin-top:24px}.mb-dashboard__info{background:#fff;border-radius:8px;border:var(--mb-border)}.mb-dashboard__tabs{display:flex;gap:24px;border-bottom:var(--mb-border);font-size:14px;padding-inline:24px}.mb-dashboard__tab{display:block;padding-block:16px;border-bottom:3px solid rgba(0,0,0,0);font-weight:600;color:#0f172a;cursor:pointer}.mb-dashboard__tab--active{border-color:var(--mb-color-accent)}.mb-dashboard__tab__badge{background:var(--mb-color-accent);color:#fff;font-size:10px;display:inline-block;line-height:1;padding:4px;border-radius:2px;position:relative;top:-12px}.mb-dashboard__tab-pane{padding:24px}.mb-dashboard__tutorials__inner{display:grid;gap:16px;grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));margin-bottom:24px}.mb-dashboard__tutorial{display:flex;align-items:flex-start;gap:16px}.mb-dashboard__tutorial a{color:inherit}.mb-dashboard__tutorial__image{position:relative}.mb-dashboard__tutorial__image .tobii-zoom__icon{display:none}.mb-dashboard__tutorial__image:before{position:absolute;top:calc(50% - 9px);left:calc(50% - 16px);content:"";font-family:"dashicons";font-size:32px;color:red}.mb-dashboard__tutorial img{width:90px;height:auto;display:block;border-radius:8px}.mb-dashboard__tutorial .mb-dashboard__tutorial__title{font-size:16px;font-weight:600;color:#0f172a;margin-bottom:8px;display:block}.mb-dashboard__tutorial__description{font-size:12px;color:#64748b}.mb-dashboard__compare{container-type:inline-size}.mb-dashboard__compare__header{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;margin-block:24px}.mb-dashboard__compare__header p{margin-bottom:0}.mb-dashboard__compare__title{font-size:20px;font-weight:600;color:#0f172a}.mb-dashboard__compare tbody svg{width:20px;height:20px}.mb-dashboard__compare__footer{margin-top:48px;background:#f1f5f9;padding:48px;text-align:center;border-radius:8px}.mb-dashboard__compare__footer p{font-size:16px;margin-bottom:24px}.mb-dashboard__sidebar{flex-basis:360px;display:flex;flex-direction:column;gap:24px}.mb-dashboard__widget{border:var(--mb-border);border-radius:8px;background:#fff;padding:24px}.mb-dashboard__widget-title{font-weight:600;font-size:16px;color:#0f172a;margin-bottom:18px;margin-top:-4px}.mb-dashboard__widget-body>p:last-child{margin-bottom:0}.mb-dashboard__upgrade{border:none;background:linear-gradient(135deg, rgb(0, 182, 182) 0%, rgb(43, 68, 91) 100%);color:#fff;position:relative}.mb-dashboard__upgrade .mb-dashboard__widget-title{color:inherit}.mb-dashboard__upgrade ul{margin-bottom:24px}.mb-dashboard__upgrade li{display:flex;gap:4px;align-items:center}.mb-dashboard__upgrade svg{width:16px;height:16px;fill:#fff}.mb-dashboard__upgrade a{display:block;text-align:center}.mb-dashboard__upgrade img{position:absolute;top:-30px;right:-10px;width:60px;transform:rotate(-30deg)}.mb-dashboard__plugins .mb-dashboard__widget-body{display:flex;flex-direction:column;gap:16px}.mb-dashboard__plugin{display:flex;align-items:center;gap:8px;position:relative}.mb-dashboard__plugin img{width:32px;height:32px}.mb-dashboard__plugin__text{flex:1}.mb-dashboard__plugin .mb-dashboard__plugin__title{font-weight:600;color:#0f172a}.mb-dashboard__plugin__description{font-size:12px;color:#64748b}.mb-dashboard__plugin__status{font-size:12px;font-weight:600;display:inline-flex;align-items:center;gap:4px;position:absolute;right:0;top:-4px;padding:2px 6px;border-radius:4px;border:1px solid rgba(0,0,0,0)}.mb-dashboard__plugin__status:before{display:inline-block;content:"";width:6px;height:6px;border-radius:50%;background:currentColor}.mb-dashboard__plugin__status[data-action=install]{color:#64748b;border-color:currentColor;cursor:pointer}.mb-dashboard__plugin__status[data-action=activate]{color:#f59e0b;border-color:currentColor;cursor:pointer}.mb-dashboard__plugin__status[data-action=""]{color:var(--mb-color-accent)}.mb-dashboard__support{position:relative}.mb-dashboard__support__icon{position:absolute;top:0;right:0;width:48px;height:48px;fill:#f8fafc;z-index:0}.mb-dashboard__news-icon{position:relative}.mb-dashboard__news-icon:before{content:"";display:inline-block;width:10px;height:10px;position:absolute;top:0;right:0;background:#ef4444;border-radius:50%}.mb-dashboard__news{--mb-news-width: 360px;position:fixed;top:32px;right:calc(0px - var(--mb-news-width));width:var(--mb-news-width);bottom:0;background:#fff;transition:all .2s ease-in-out;overflow-x:auto;border-left:var(--mb-border)}.mb-dashboard__news--active{right:0}.mb-dashboard__news__header{padding:12px 24px;border-bottom:var(--mb-border);display:flex;align-items:center;justify-content:space-between;margin-bottom:24px}.mb-dashboard__news__heading{font-size:16px;font-weight:600;color:#0f172a}.mb-dashboard__news__close{width:32px;height:32px;padding:0;display:inline-flex;align-items:center;justify-content:center;border:none;background:none;cursor:pointer}.mb-dashboard__news__close svg{width:24px;height:24px}.mb-dashboard__news__date{font-size:10px;text-transform:uppercase;letter-spacing:.025em;font-weight:600;margin-bottom:8px;color:#94a3b8}.mb-dashboard__news .mb-dashboard__news__title{display:block;font-size:16px;font-weight:600;color:#0f172a;margin-bottom:16px}.mb-dashboard__news__content p{display:none}.mb-dashboard__news__item{padding-inline:24px}.mb-dashboard__news__item:not(:first-child){margin-top:24px;padding-top:24px;border-top:var(--mb-border)}@media(max-width: 1023px){.mb-dashboard__header__search{display:none}.mb-dashboard__body{flex-direction:column}}@media(max-width: 782px){.mb-dashboard__news{top:46px}}@media(max-width: 599px){.mb-dashboard__header__social{display:none}.mb-dashboard__body{padding:24px}}@container (max-width: 599px){.mb-dashboard__compare__header{flex-direction:column}} +body.wp-admin{background:#f8fafc}div#wpcontent{padding-left:0}#wpwrap .notice{display:none}.mb-dashboard{--mb-color-accent: #00b1b3;--mb-color-link: var(--mb-color-accent);--mb-border: 1px solid #cbd5e1;font-size:14px;color:#334155}.mb-dashboard a{text-decoration:none;color:var(--mb-color-link)}.mb-dashboard a:hover{color:var(--mb-color-link);text-decoration:underline}.mb-dashboard a:focus,.mb-dashboard a:active{outline:none;box-shadow:none}.mb-dashboard p{font-size:14px}.mb-dashboard table{width:100%;border-collapse:collapse}.mb-dashboard tr{border-bottom:1px solid #e2e8f0}.mb-dashboard tr:hover{background:#f8fafc}.mb-dashboard th,.mb-dashboard td{padding-block:12px}.mb-dashboard__button{--mb-color-link: #fff;display:inline-block;background:var(--mb-color-accent);padding:16px;text-transform:uppercase;font-weight:700;font-size:16px;line-height:1;letter-spacing:.025em;white-space:nowrap;border-radius:4px;text-decoration:none}.mb-dashboard__button.mb-dashboard__button:hover{color:#fff;opacity:.9;text-decoration:none}.mb-dashboard__button:focus,.mb-dashboard__button:active{color:#fff}.mb-dashboard__hidden{display:none}.mb-dashboard__external{display:inline-flex;align-items:center;gap:4px}.mb-dashboard__external svg{width:1em;height:1em;fill:currentColor}.mb-dashboard__tooltip{position:relative}.mb-dashboard__tooltip:after{content:attr(data-tooltip);background-color:#0f172a;color:#fff;padding:4px 8px;border-radius:4px;white-space:nowrap;position:absolute;top:calc(100% + 8px);left:50%;transform:translateX(-50%);visibility:hidden;opacity:0;transition:opacity .3s ease-in-out}.mb-dashboard__tooltip[data-position=top]:after{bottom:calc(100% + 8px);top:auto}.mb-dashboard__tooltip[data-position=bottom-right]:after{left:auto;transform:none;right:0}.mb-dashboard__tooltip:hover:after{visibility:visible;opacity:1}.mb-dashboard__body{display:flex;gap:48px;padding:48px;max-width:1280px;margin-inline:auto}.mb-dashboard__header{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:12px;background:#fff;border-bottom:1px solid #e2e8f0}.mb-dashboard__header__search{flex:1}.mb-dashboard__header__search__inner{position:relative;max-width:480px;margin-inline:auto}.mb-dashboard__header__search input[type=text]{width:100%;background:#f1f5f9;border-color:#e2e8f0;padding:2px 16px;margin:0}.mb-dashboard__header__search input[type=text]:focus,.mb-dashboard__header__search input[type=text]:hover{border-color:#cbd5e1;box-shadow:none}.mb-dashboard__header__search:has(.mb-dashboard__header__search-results:not([data-type=empty])) input{border-radius:4px 4px 0 0}.mb-dashboard__header__search-results{position:absolute;top:33px;left:0;right:0;background:#fff;z-index:9;border:var(--mb-border);border-radius:0 0 4px 4px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1)}.mb-dashboard__header__search-results a{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;color:inherit;padding:8px 16px;transition:all .2s ease-in-out}.mb-dashboard__header__search-results a:hover{color:inherit;text-decoration:none;background:#f1f5f9}.mb-dashboard__header__search-results a:last-child{border-radius:0 0 4px 4px}.mb-dashboard__header__search-results span{display:inline-block;padding:2px 8px;background:#e2e8f0;border:var(--mb-border);border-radius:4px;font-size:12px}.mb-dashboard__header__search-results[data-type=empty]{display:none}.mb-dashboard__header__search-results[data-type=text]{padding:16px}.mb-dashboard__header__icons{display:flex;align-items:center}.mb-dashboard__header__icons a{display:inline-flex;align-items:center;justify-content:center}.mb-dashboard__header__social{display:flex;align-items:center;gap:12px;border-right:var(--mb-border);padding-right:12px;margin-right:12px}.mb-dashboard__header__social svg{width:16px;height:16px;fill:#64748b;transition:all .2s ease-in-out}.mb-dashboard__header__social a{width:24px;height:24px}.mb-dashboard__header__social a:hover svg{fill:#334155}.mb-dashboard__header__links{display:flex;align-items:center;gap:12px}.mb-dashboard__header__links a{color:#64748b;width:36px;height:36px;border:var(--mb-border);border-radius:50%}.mb-dashboard__header__links a:hover{color:#334155;border-color:#94a3b8}.mb-dashboard__header__links svg{width:20px;height:20px}.mb-dashboard__header .mb-dashboard__logo svg{display:block;width:auto;height:46px}.mb-dashboard__main{flex:1;display:flex;flex-direction:column;gap:48px}.mb-dashboard__actions__title{font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:.025em;line-height:1;margin-bottom:16px}.mb-dashboard__actions__inner{display:grid;grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));gap:24px}.mb-dashboard__action{display:flex;gap:16px;align-items:center;border-radius:8px;border:1px solid var(--mb-color-accent);padding:24px;background:#fff;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);position:relative;top:0;transition:all .2s ease}.mb-dashboard__action svg{width:32px;height:32px;fill:var(--mb-color-accent)}.mb-dashboard__action__title{display:block;margin-bottom:4px;color:#0f172a;font-weight:600;font-size:16px}.mb-dashboard__action__description{color:#64748b}.mb-dashboard__action.mb-dashboard__action:hover{text-decoration:none;top:-8px}.mb-dashboard__intro__subtitle{font-size:16px}.mb-dashboard__intro__title{font-size:24px;color:#0f172a;font-weight:600;margin-top:12px}.mb-dashboard__intro__text{margin-top:24px;font-size:18px;line-height:1.6}.mb-dashboard__intro .mb-dashboard__button{margin-top:24px}.mb-dashboard__info{background:#fff;border-radius:8px;border:var(--mb-border)}.mb-dashboard__tabs{display:flex;gap:24px;border-bottom:var(--mb-border);font-size:14px;padding-inline:24px}.mb-dashboard__tab{display:block;padding-block:16px;border-bottom:3px solid rgba(0,0,0,0);font-weight:600;color:#0f172a;cursor:pointer}.mb-dashboard__tab--active{border-color:var(--mb-color-accent)}.mb-dashboard__tab__badge{background:var(--mb-color-accent);color:#fff;font-size:10px;display:inline-block;line-height:1;padding:4px;border-radius:2px;position:relative;top:-12px}.mb-dashboard__tab-pane{padding:24px}.mb-dashboard__tutorials__inner{display:grid;gap:16px;grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));margin-bottom:24px}.mb-dashboard__tutorial{display:flex;align-items:flex-start;gap:16px}.mb-dashboard__tutorial a{color:inherit}.mb-dashboard__tutorial__image{position:relative}.mb-dashboard__tutorial__image .tobii-zoom__icon{display:none}.mb-dashboard__tutorial__image:before{position:absolute;top:calc(50% - 9px);left:calc(50% - 16px);content:"";font-family:"dashicons";font-size:32px;color:red}.mb-dashboard__tutorial img{width:90px;height:auto;display:block;border-radius:8px}.mb-dashboard__tutorial .mb-dashboard__tutorial__title{font-size:16px;font-weight:600;color:#0f172a;margin-bottom:8px;display:block}.mb-dashboard__tutorial__description{font-size:12px;color:#64748b}.mb-dashboard__compare{container-type:inline-size}.mb-dashboard__compare__header{display:flex;align-items:flex-start;justify-content:space-between;gap:24px;margin-block:24px}.mb-dashboard__compare__header p{margin-bottom:0}.mb-dashboard__compare__title{font-size:20px;font-weight:600;color:#0f172a}.mb-dashboard__compare tbody svg{width:20px;height:20px}.mb-dashboard__compare__footer{margin-top:48px;background:#f1f5f9;padding:48px;text-align:center;border-radius:8px}.mb-dashboard__compare__footer p{font-size:16px;margin-bottom:24px}.mb-dashboard__sidebar{flex-basis:360px;display:flex;flex-direction:column;gap:24px}.mb-dashboard__widget{border:var(--mb-border);border-radius:8px;background:#fff;padding:24px}.mb-dashboard__widget-title{font-weight:600;font-size:16px;color:#0f172a;margin-bottom:18px;margin-top:-4px}.mb-dashboard__widget-body>p:last-child{margin-bottom:0}.mb-dashboard__upgrade{border:none;background:linear-gradient(135deg, rgb(0, 182, 182) 0%, rgb(43, 68, 91) 100%);color:#fff;position:relative}.mb-dashboard__upgrade .mb-dashboard__widget-title{color:inherit}.mb-dashboard__upgrade ul{margin-bottom:24px}.mb-dashboard__upgrade li{display:flex;gap:4px;align-items:center}.mb-dashboard__upgrade svg{width:16px;height:16px;fill:#fff}.mb-dashboard__upgrade a{display:block;text-align:center}.mb-dashboard__upgrade img{position:absolute;top:-30px;right:-10px;width:60px;transform:rotate(-30deg)}.mb-dashboard__plugins .mb-dashboard__widget-body{display:flex;flex-direction:column;gap:16px}.mb-dashboard__plugin{display:flex;align-items:center;gap:8px;position:relative}.mb-dashboard__plugin img{width:32px;height:32px}.mb-dashboard__plugin__text{flex:1}.mb-dashboard__plugin .mb-dashboard__plugin__title{font-weight:600;color:#0f172a}.mb-dashboard__plugin__description{font-size:12px;color:#64748b}.mb-dashboard__plugin__status{font-size:12px;font-weight:600;display:inline-flex;align-items:center;gap:4px;position:absolute;right:0;top:-4px;padding:2px 6px;border-radius:4px;border:1px solid rgba(0,0,0,0)}.mb-dashboard__plugin__status:before{display:inline-block;content:"";width:6px;height:6px;border-radius:50%;background:currentColor}.mb-dashboard__plugin__status[data-action=install]{color:#64748b;border-color:currentColor;cursor:pointer}.mb-dashboard__plugin__status[data-action=activate]{color:#f59e0b;border-color:currentColor;cursor:pointer}.mb-dashboard__plugin__status[data-action=""]{color:var(--mb-color-accent)}.mb-dashboard__support{position:relative}.mb-dashboard__support__icon{position:absolute;top:0;right:0;width:48px;height:48px;fill:#f8fafc;z-index:0}.mb-dashboard__news-icon{position:relative}.mb-dashboard__news-icon:before{content:"";display:inline-block;width:10px;height:10px;position:absolute;top:0;right:0;background:#ef4444;border-radius:50%}.mb-dashboard__news{--mb-news-width: 360px;position:fixed;top:32px;right:calc(0px - var(--mb-news-width));width:var(--mb-news-width);bottom:0;background:#fff;transition:all .2s ease-in-out;overflow-x:auto;border-left:var(--mb-border)}.mb-dashboard__news--active{right:0}.mb-dashboard__news__header{padding:12px 24px;border-bottom:var(--mb-border);display:flex;align-items:center;justify-content:space-between;margin-bottom:24px}.mb-dashboard__news__heading{font-size:16px;font-weight:600;color:#0f172a}.mb-dashboard__news__close{width:32px;height:32px;padding:0;display:inline-flex;align-items:center;justify-content:center;border:none;background:none;cursor:pointer}.mb-dashboard__news__close svg{width:24px;height:24px}.mb-dashboard__news__date{font-size:10px;text-transform:uppercase;letter-spacing:.025em;font-weight:600;margin-bottom:8px;color:#94a3b8}.mb-dashboard__news .mb-dashboard__news__title{display:block;font-size:16px;font-weight:600;color:#0f172a;margin-bottom:16px}.mb-dashboard__news__content p{display:none}.mb-dashboard__news__item{padding-inline:24px}.mb-dashboard__news__item:not(:first-child){margin-top:24px;padding-top:24px;border-top:var(--mb-border)}.mb-dashboard__sale .mb-dashboard__widget-title{margin:-25px -25px 0;background:var(--mb-color-accent);color:#fff;padding:16px 24px;border-radius:4px 4px 0 0;position:relative}.mb-dashboard__sale__badge{background:url(../img/hot.svg) no-repeat center center;background-size:64px 64px;font-weight:700;font-size:12px;text-transform:uppercase;display:inline-block;width:64px;height:64px;line-height:64px;text-align:center;position:absolute;top:-24px;color:#0f172a}.mb-dashboard__sale__button{--mb-color-link: #fff;display:block;margin-inline:auto;text-align:center;background:var(--mb-color-accent);padding:16px 24px;line-height:1;white-space:nowrap;border-radius:4px;text-decoration:none}.mb-dashboard__sale__button.mb-dashboard__sale__button:hover{opacity:.9;text-decoration:none}.mb-dashboard__sale__button:focus,.mb-dashboard__sale__button:active{color:#fff}.mb-dashboard__sale__button-text--large{font-size:16px;font-weight:700;letter-spacing:.025em;text-transform:uppercase;display:block;margin-bottom:4px}.mb-dashboard__sale__button-text--small{font-size:14px;display:block;color:#fff}.mb-dashboard__countdown{list-style:none;padding:0;margin-inline:0;margin-top:16px;display:flex;align-items:center;justify-content:center;gap:16px;text-align:center}.mb-dashboard__countdown li{border:1px solid var(--mb-color-accent);border-radius:4px;padding:12px 16px;margin:0}.mb-dashboard__countdown-number{font-size:24px;font-weight:600;margin-bottom:8px}@media(max-width: 1023px){.mb-dashboard__header__search{display:none}.mb-dashboard__body{flex-direction:column}}@media(max-width: 782px){.mb-dashboard__news{top:46px}}@media(max-width: 599px){.mb-dashboard__header__social{display:none}.mb-dashboard__body{padding:24px}}@container (max-width: 599px){.mb-dashboard__compare__header{flex-direction:column}} diff --git a/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.scss b/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.scss index 99321467d..a265cecf5 100644 --- a/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.scss +++ b/vendor/wpmetabox/meta-box/src/Dashboard/assets/css/dashboard.scss @@ -802,6 +802,101 @@ div#wpcontent { border-top: var(--mb-border); } } + + // Sale widget + &__sale { + .mb-dashboard__widget-title { + margin: -25px -25px 0; + background: var(--mb-color-accent); + color: #fff; + padding: 16px 24px; + border-radius: 4px 4px 0 0; + position: relative; + } + + &__badge { + background: url(../img/hot.svg) no-repeat center center; + background-size: 64px 64px; + font-weight: 700; + font-size: 12px; + text-transform: uppercase; + display: inline-block; + width: 64px; + height: 64px; + line-height: 64px; + text-align: center; + position: absolute; + top: -24px; + color: #0f172a; + } + + &__button { + --mb-color-link: #fff; + + display: block; + margin-inline: auto; + text-align: center; + + background: var(--mb-color-accent); + padding: 16px 24px; + line-height: 1; + + white-space: nowrap; + border-radius: 4px; + text-decoration: none; + + &.mb-dashboard__sale__button:hover { + opacity: .9; + text-decoration: none; + } + + &:focus, + &:active { + color: #fff; + } + + &-text--large { + font-size: 16px; + font-weight: 700; + letter-spacing: .025em; + text-transform: uppercase; + // color: rgb(251 191 36); + display: block; + margin-bottom: 4px; + } + + &-text--small { + font-size: 14px; + display: block; + color: #fff; + } + } + } + + &__countdown { + list-style: none; + padding: 0; + margin-inline: 0; + margin-top: 16px; + display: flex; + align-items: center; + justify-content: center; + gap: 16px; + text-align: center; + + li { + border: 1px solid var(--mb-color-accent); + border-radius: 4px; + padding: 12px 16px; + margin: 0; + } + + &-number { + font-size: 24px; + font-weight: 600; + margin-bottom: 8px; + } + } } @media (max-width:1023px) { diff --git a/vendor/wpmetabox/meta-box/src/Dashboard/assets/img/hot.svg b/vendor/wpmetabox/meta-box/src/Dashboard/assets/img/hot.svg new file mode 100644 index 000000000..db6037db9 --- /dev/null +++ b/vendor/wpmetabox/meta-box/src/Dashboard/assets/img/hot.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/vendor/wpmetabox/meta-box/src/Dashboard/content.php b/vendor/wpmetabox/meta-box/src/Dashboard/content.php index c26d96c93..defa5c99c 100644 --- a/vendor/wpmetabox/meta-box/src/Dashboard/content.php +++ b/vendor/wpmetabox/meta-box/src/Dashboard/content.php @@ -567,6 +567,79 @@ class="mb-dashboard__tutorial__image lightbox mb-dashboard__tooltip"