From 81ade70944d4c35d40099989730ce143e8e2f5ba Mon Sep 17 00:00:00 2001 From: gaofeng <1212121@qq.com> Date: Wed, 17 Jun 2026 09:23:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 12 + .example.env | 17 + .gitignore | 4 + .htaccess | 0 .travis.yml | 42 + LICENSE.txt | 32 + README.md | 77 + app/.htaccess | 1 + app/AppService.php | 22 + app/BaseController.php | 94 + app/ExceptionHandle.php | 58 + app/Request.php | 8 + app/common.php | 2 + app/event.php | 17 + app/lang/en-us.php | 1058 ++++++ app/lang/zh-cn.php | 911 ++++++ app/log/driver/Monolog.php | 81 + app/middleware.php | 11 + app/middleware/LogRecorder.php | 41 + app/miniapi/common.php | 413 +++ app/miniapi/controller/Auth.php | 134 + app/miniapi/controller/Base.php | 283 ++ app/miniapi/controller/Esta.php | 107 + app/miniapi/controller/Evus.php | 139 + app/miniapi/controller/Help.php | 57 + app/miniapi/controller/Index.php | 87 + app/miniapi/controller/News.php | 79 + app/miniapi/controller/Ocr.php | 68 + app/miniapi/controller/Order.php | 193 ++ app/miniapi/controller/Upload.php | 74 + .../service/Context/MiniAppContext.php | 66 + .../service/Legal/LegalDocumentService.php | 144 + .../service/Payment/MiniPayService.php | 65 + .../service/Payment/PaymentChannelService.php | 35 + .../service/Product/ProductService.php | 94 + app/provider.php | 9 + app/service.php | 9 + app/service/AwsUploadService.php | 126 + app/service/BaiduOcrService.php | 122 + app/service/CompressImgService.php | 185 ++ app/service/MiniProgramWechatService.php | 127 + app/service/OssService.php | 301 ++ app/service/OssUploadService.php | 203 ++ app/service/PassportOcrService.php | 233 ++ app/service/SwooleService.php | 63 + app/service/UploadService.php | 133 + composer.json | 53 + composer.lock | 1794 ++++++++++ config/app.php | 31 + config/cache.php | 29 + config/citic.php | 6 + config/console.php | 9 + config/cookie.php | 20 + config/database.php | 63 + config/filesystem.php | 47 + config/lang.php | 29 + config/log.php | 50 + config/middleware.php | 8 + config/mini_legal.php | 43 + config/mini_payment.php | 57 + config/mini_product.php | 49 + config/miniapp.php | 24 + config/ocr.php | 10 + config/oss.php | 13 + config/route.php | 51 + config/session.php | 19 + config/trace.php | 10 + config/view.php | 25 + extend/api/Httpcurl.php | 125 + extend/api/Verify.php | 337 ++ extend/api/Verify/bgs/1.jpg | Bin 0 -> 30428 bytes extend/api/Verify/bgs/2.jpg | Bin 0 -> 29677 bytes extend/api/Verify/bgs/3.jpg | Bin 0 -> 32109 bytes extend/api/Verify/bgs/4.jpg | Bin 0 -> 29081 bytes extend/api/Verify/bgs/5.jpg | Bin 0 -> 27940 bytes extend/api/Verify/bgs/6.jpg | Bin 0 -> 31381 bytes extend/api/Verify/bgs/7.jpg | Bin 0 -> 30234 bytes extend/api/Verify/bgs/8.jpg | Bin 0 -> 30188 bytes extend/api/Verify/ttfs/1.ttf | Bin 0 -> 57520 bytes extend/api/Verify/ttfs/2.ttf | Bin 0 -> 28328 bytes extend/api/Verify/ttfs/3.ttf | Bin 0 -> 39308 bytes extend/api/Verify/ttfs/4.ttf | Bin 0 -> 34852 bytes extend/api/Verify/ttfs/5.ttf | Bin 0 -> 32664 bytes extend/api/Verify/ttfs/6.ttf | Bin 0 -> 28036 bytes nginx.htaccess | 8 + public/.htaccess | 0 public/index.php | 25 + public/json/country.json | 978 ++++++ public/json/country_en.json | 978 ++++++ public/json/phone_prefix.json | 978 ++++++ public/json/phone_prefix_en.json | 979 ++++++ public/json/us.json | 234 ++ public/json/us_en.json | 234 ++ public/nginx.htaccess | 8 + public/robots.txt | 2 + public/router.php | 19 + route/app.php | 41 + think | 11 + thinkphp/lang/zh-cn.php | 136 + .../oss-v2/.github/workflows/main.yml | 37 + vendor/alibabacloud/oss-v2/.gitignore | 10 + vendor/alibabacloud/oss-v2/CHANGELOG.md | 72 + vendor/alibabacloud/oss-v2/DEVGUIDE-CN.md | 1767 ++++++++++ vendor/alibabacloud/oss-v2/DEVGUIDE.md | 0 vendor/alibabacloud/oss-v2/LICENSE | 201 ++ vendor/alibabacloud/oss-v2/README-CN.md | 146 + vendor/alibabacloud/oss-v2/README.md | 146 + vendor/alibabacloud/oss-v2/autoload.php | 11 + vendor/alibabacloud/oss-v2/composer.json | 30 + vendor/alibabacloud/oss-v2/index.php | 3 + vendor/alibabacloud/oss-v2/phpunit.xml | 46 + .../oss-v2/sample/AbortBucketWorm.php | 45 + .../oss-v2/sample/AbortMultipartUpload.php | 50 + .../oss-v2/sample/AppendObject.php | 54 + .../oss-v2/sample/AsyncProcessObject.php | 59 + .../oss-v2/sample/CleanRestoredObject.php | 49 + .../oss-v2/sample/CloseMetaQuery.php | 45 + .../oss-v2/sample/CompleteMultipartUpload.php | 125 + vendor/alibabacloud/oss-v2/sample/Copier.php | 120 + .../alibabacloud/oss-v2/sample/CopyObject.php | 57 + .../oss-v2/sample/CreateAccessPoint.php | 52 + .../CreateBucketDataRedundancyTransition.php | 47 + .../oss-v2/sample/CreateCnameToken.php | 51 + .../oss-v2/sample/DeleteAccessPoint.php | 48 + .../oss-v2/sample/DeleteBucket.php | 47 + .../oss-v2/sample/DeleteBucketCors.php | 47 + .../DeleteBucketDataRedundancyTransition.php | 47 + .../oss-v2/sample/DeleteBucketEncryption.php | 47 + .../oss-v2/sample/DeleteBucketInventory.php | 50 + .../oss-v2/sample/DeleteBucketLifecycle.php | 47 + .../oss-v2/sample/DeleteBucketLogging.php | 47 + .../oss-v2/sample/DeleteBucketOverwrite.php | 47 + .../oss-v2/sample/DeleteBucketPolicy.php | 47 + .../sample/DeleteBucketPublicAccessBlock.php | 46 + .../oss-v2/sample/DeleteBucketReplication.php | 51 + .../oss-v2/sample/DeleteBucketTags.php | 47 + .../oss-v2/sample/DeleteBucketWebsite.php | 47 + .../oss-v2/sample/DeleteCname.php | 50 + .../oss-v2/sample/DeleteMultipleObjects.php | 57 + .../oss-v2/sample/DeleteObject.php | 50 + .../oss-v2/sample/DeleteObjectTagging.php | 46 + .../oss-v2/sample/DeletePublicAccessBlock.php | 44 + .../oss-v2/sample/DeleteStyle.php | 49 + .../DeleteUserDefinedLogFieldsConfig.php | 46 + .../sample/DeletetAccessPointPolicy.php | 48 + .../oss-v2/sample/DescribeRegions.php | 46 + .../oss-v2/sample/DoMetaQuery.php | 80 + .../alibabacloud/oss-v2/sample/Downloader.php | 71 + .../oss-v2/sample/EncryptionClient.php | 172 + .../oss-v2/sample/ExtentBucketWorm.php | 47 + .../oss-v2/sample/GetAccessPoint.php | 49 + .../oss-v2/sample/GetAccessPointPolicy.php | 49 + .../oss-v2/sample/GetBucketAccessMonitor.php | 47 + .../oss-v2/sample/GetBucketAcl.php | 45 + .../sample/GetBucketArchiveDirectRead.php | 47 + .../oss-v2/sample/GetBucketCors.php | 48 + .../GetBucketDataRedundancyTransition.php | 48 + .../oss-v2/sample/GetBucketEncryption.php | 48 + .../oss-v2/sample/GetBucketHttpsConfig.php | 49 + .../oss-v2/sample/GetBucketInfo.php | 49 + .../oss-v2/sample/GetBucketInventory.php | 51 + .../oss-v2/sample/GetBucketLifecycle.php | 48 + .../oss-v2/sample/GetBucketLocation.php | 49 + .../oss-v2/sample/GetBucketLogging.php | 48 + .../oss-v2/sample/GetBucketOverwrite.php | 48 + .../oss-v2/sample/GetBucketPolicy.php | 48 + .../oss-v2/sample/GetBucketPolicyStatus.php | 48 + .../sample/GetBucketPublicAccessBlock.php | 47 + .../oss-v2/sample/GetBucketReferer.php | 47 + .../oss-v2/sample/GetBucketReplication.php | 48 + .../sample/GetBucketReplicationLocation.php | 48 + .../sample/GetBucketReplicationProgress.php | 50 + .../oss-v2/sample/GetBucketRequestPayment.php | 48 + .../oss-v2/sample/GetBucketResourceGroup.php | 47 + .../oss-v2/sample/GetBucketStat.php | 49 + .../oss-v2/sample/GetBucketTags.php | 48 + .../sample/GetBucketTransferAcceleration.php | 48 + .../oss-v2/sample/GetBucketVersioning.php | 45 + .../oss-v2/sample/GetBucketWebsite.php | 48 + .../oss-v2/sample/GetBucketWorm.php | 48 + .../oss-v2/sample/GetCnameToken.php | 47 + .../oss-v2/sample/GetMetaQueryStatus.php | 47 + .../alibabacloud/oss-v2/sample/GetObject.php | 51 + .../oss-v2/sample/GetObjectAcl.php | 47 + .../oss-v2/sample/GetObjectMeta.php | 51 + .../oss-v2/sample/GetObjectTagging.php | 47 + .../oss-v2/sample/GetPublicAccessBlock.php | 45 + .../alibabacloud/oss-v2/sample/GetStyle.php | 50 + .../alibabacloud/oss-v2/sample/GetSymlink.php | 47 + .../sample/GetUserDefinedLogFieldsConfig.php | 47 + .../alibabacloud/oss-v2/sample/HeadObject.php | 51 + .../oss-v2/sample/InitiateBucketWorm.php | 48 + .../oss-v2/sample/InitiateMultipartUpload.php | 50 + .../oss-v2/sample/InvokeOperation.php | 98 + .../oss-v2/sample/IsBucketExist.php | 45 + .../oss-v2/sample/IsObjectExist.php | 47 + .../oss-v2/sample/ListAccessPoint.php | 48 + .../ListBucketDataRedundancyTransition.php | 46 + .../oss-v2/sample/ListBucketInventory.php | 49 + .../oss-v2/sample/ListBuckets.php | 46 + .../oss-v2/sample/ListCloudBoxes.php | 47 + .../alibabacloud/oss-v2/sample/ListCname.php | 47 + .../oss-v2/sample/ListMultipartUploads.php | 51 + .../oss-v2/sample/ListObjectVersions.php | 50 + .../oss-v2/sample/ListObjects.php | 50 + .../oss-v2/sample/ListObjectsV2.php | 48 + .../alibabacloud/oss-v2/sample/ListParts.php | 55 + .../alibabacloud/oss-v2/sample/ListStyle.php | 49 + .../ListUserDataRedundancyTransition.php | 44 + .../oss-v2/sample/OpenMetaQuery.php | 57 + .../oss-v2/sample/OptionObject.php | 53 + .../alibabacloud/oss-v2/sample/PostObject.php | 156 + vendor/alibabacloud/oss-v2/sample/Presign.php | 102 + .../oss-v2/sample/ProcessObject.php | 56 + .../oss-v2/sample/PutAccessPointPolicy.php | 67 + .../alibabacloud/oss-v2/sample/PutBucket.php | 47 + .../oss-v2/sample/PutBucketAccessMonitor.php | 48 + .../oss-v2/sample/PutBucketAcl.php | 44 + .../sample/PutBucketArchiveDirectRead.php | 48 + .../oss-v2/sample/PutBucketCors.php | 54 + .../oss-v2/sample/PutBucketEncryption.php | 50 + .../oss-v2/sample/PutBucketHttpsConfig.php | 54 + .../oss-v2/sample/PutBucketInventory.php | 81 + .../oss-v2/sample/PutBucketLifecycle.php | 59 + .../oss-v2/sample/PutBucketLogging.php | 51 + .../oss-v2/sample/PutBucketOverwrite.php | 57 + .../oss-v2/sample/PutBucketPolicy.php | 59 + .../sample/PutBucketPublicAccessBlock.php | 48 + .../oss-v2/sample/PutBucketReferer.php | 51 + .../oss-v2/sample/PutBucketReplication.php | 64 + .../oss-v2/sample/PutBucketRequestPayment.php | 48 + .../oss-v2/sample/PutBucketResourceGroup.php | 48 + .../oss-v2/sample/PutBucketRtc.php | 57 + .../oss-v2/sample/PutBucketTags.php | 50 + .../sample/PutBucketTransferAcceleration.php | 48 + .../oss-v2/sample/PutBucketVersioning.php | 46 + .../oss-v2/sample/PutBucketWebsite.php | 55 + .../alibabacloud/oss-v2/sample/PutCname.php | 50 + .../alibabacloud/oss-v2/sample/PutObject.php | 52 + .../oss-v2/sample/PutObjectAcl.php | 46 + .../oss-v2/sample/PutObjectTagging.php | 53 + .../oss-v2/sample/PutPublicAccessBlock.php | 46 + .../alibabacloud/oss-v2/sample/PutStyle.php | 50 + .../alibabacloud/oss-v2/sample/PutSymlink.php | 49 + .../sample/PutUserDefinedLogFieldsConfig.php | 49 + .../oss-v2/sample/RestoreObject.php | 49 + .../oss-v2/sample/SealAppendObject.php | 51 + .../alibabacloud/oss-v2/sample/UploadPart.php | 107 + .../oss-v2/sample/UploadPartCopy.php | 60 + .../alibabacloud/oss-v2/sample/Uploader.php | 133 + .../src/Annotation/AnnotationInterface.php | 10 + .../oss-v2/src/Annotation/Functions.php | 85 + .../src/Annotation/RequiredProperty.php | 8 + .../oss-v2/src/Annotation/TagBody.php | 14 + .../oss-v2/src/Annotation/TagHeader.php | 14 + .../oss-v2/src/Annotation/TagProperty.php | 28 + .../oss-v2/src/Annotation/TagQuery.php | 14 + .../oss-v2/src/Annotation/XmlElement.php | 22 + .../oss-v2/src/Annotation/XmlRoot.php | 16 + vendor/alibabacloud/oss-v2/src/Client.php | 435 +++ .../oss-v2/src/ClientExtensionTrait.php | 202 ++ vendor/alibabacloud/oss-v2/src/ClientImpl.php | 752 +++++ vendor/alibabacloud/oss-v2/src/Config.php | 700 ++++ vendor/alibabacloud/oss-v2/src/Copier.php | 533 +++ .../AnonymousCredentialsProvider.php | 14 + .../oss-v2/src/Credentials/Credentials.php | 93 + .../src/Credentials/CredentialsProvider.php | 13 + .../Credentials/CredentialsProviderFunc.php | 26 + ...EnvironmentVariableCredentialsProvider.php | 20 + .../Credentials/StaticCredentialsProvider.php | 36 + .../alibabacloud/oss-v2/src/Crypto/AesCtr.php | 152 + .../oss-v2/src/Crypto/AesCtrCipher.php | 61 + .../oss-v2/src/Crypto/AesCtrCipherBuilder.php | 65 + .../oss-v2/src/Crypto/CipherData.php | 43 + .../oss-v2/src/Crypto/CipherInterface.php | 18 + .../src/Crypto/ContentCipherInterface.php | 21 + .../oss-v2/src/Crypto/Envelope.php | 43 + .../oss-v2/src/Crypto/LazyDecryptStream.php | 107 + .../src/Crypto/MasterCipherInterface.php | 45 + .../oss-v2/src/Crypto/MasterRsaCipher.php | 113 + .../oss-v2/src/Crypto/ReadDecryptStream.php | 56 + .../oss-v2/src/Crypto/ReadEncryptStream.php | 56 + vendor/alibabacloud/oss-v2/src/Defaults.php | 113 + .../alibabacloud/oss-v2/src/Deserializer.php | 325 ++ vendor/alibabacloud/oss-v2/src/Downloader.php | 422 +++ .../oss-v2/src/EncryptionClient.php | 750 +++++ .../oss-v2/src/Exception/CopyException.php | 41 + .../src/Exception/CredentialsException.php | 18 + .../Exception/DeserializationExecption.php | 16 + .../src/Exception/DownloadException.php | 32 + .../src/Exception/InconsistentExecption.php | 25 + .../src/Exception/OperationException.php | 22 + .../oss-v2/src/Exception/ParserException.php | 17 + .../src/Exception/SerializationExecption.php | 16 + .../oss-v2/src/Exception/ServiceException.php | 111 + .../src/Exception/StreamRewindException.php | 17 + .../oss-v2/src/Exception/UploadException.php | 41 + .../src/Models/AbortBucketWormRequest.php | 38 + .../src/Models/AbortBucketWormResult.php | 15 + .../Models/AbortMultipartUploadRequest.php | 63 + .../src/Models/AbortMultipartUploadResult.php | 16 + .../oss-v2/src/Models/AccessControlList.php | 36 + .../src/Models/AccessMonitorConfiguration.php | 36 + .../src/Models/AccessMonitorStatusType.php | 15 + .../oss-v2/src/Models/AccessPoint.php | 85 + .../src/Models/AccessPointEndpoints.php | 45 + .../Models/AccessPointVpcConfiguration.php | 35 + .../oss-v2/src/Models/AccessPoints.php | 35 + .../oss-v2/src/Models/AppendObjectRequest.php | 234 ++ .../oss-v2/src/Models/AppendObjectResult.php | 86 + .../ApplyServerSideEncryptionByDefault.php | 56 + .../Models/ArchiveDirectReadConfiguration.php | 35 + .../src/Models/AsyncProcessObjectRequest.php | 62 + .../src/Models/AsyncProcessObjectResult.php | 50 + .../alibabacloud/oss-v2/src/Models/Bucket.php | 106 + .../oss-v2/src/Models/BucketACLType.php | 30 + .../src/Models/BucketCnameConfiguration.php | 35 + .../Models/BucketDataRedundancyTransition.php | 106 + .../oss-v2/src/Models/BucketInfo.php | 189 ++ .../oss-v2/src/Models/BucketLoggingStatus.php | 36 + .../oss-v2/src/Models/BucketPolicy.php | 45 + .../BucketResourceGroupConfiguration.php | 35 + .../src/Models/BucketVersioningStatusType.php | 22 + .../oss-v2/src/Models/BucketWormStateType.php | 23 + .../oss-v2/src/Models/CORSConfiguration.php | 46 + .../oss-v2/src/Models/CORSRule.php | 76 + .../src/Models/CertificateConfiguration.php | 86 + .../oss-v2/src/Models/CipherSuite.php | 61 + .../src/Models/CleanRestoredObjectRequest.php | 61 + .../src/Models/CleanRestoredObjectResult.php | 15 + .../src/Models/CloseMetaQueryRequest.php | 38 + .../src/Models/CloseMetaQueryResult.php | 15 + .../oss-v2/src/Models/CloudBox.php | 74 + .../oss-v2/src/Models/CloudBoxes.php | 34 + .../alibabacloud/oss-v2/src/Models/Cname.php | 45 + .../oss-v2/src/Models/CnameCertificate.php | 95 + .../oss-v2/src/Models/CnameInfo.php | 65 + .../oss-v2/src/Models/CnameToken.php | 65 + .../oss-v2/src/Models/CommonPrefix.php | 35 + .../src/Models/CompleteBucketWormRequest.php | 49 + .../src/Models/CompleteBucketWormResult.php | 15 + .../src/Models/CompleteMultipartUpload.php | 36 + .../Models/CompleteMultipartUploadRequest.php | 128 + .../Models/CompleteMultipartUploadResult.php | 96 + .../oss-v2/src/Models/CopyObjectRequest.php | 291 ++ .../oss-v2/src/Models/CopyObjectResult.php | 96 + .../oss-v2/src/Models/CopyResult.php | 68 + .../oss-v2/src/Models/CreateAccessPoint.php | 46 + .../Models/CreateAccessPointConfiguration.php | 55 + .../src/Models/CreateAccessPointRequest.php | 49 + .../src/Models/CreateAccessPointResult.php | 33 + .../src/Models/CreateBucketConfiguration.php | 45 + ...eBucketDataRedundancyTransitionRequest.php | 49 + ...teBucketDataRedundancyTransitionResult.php | 33 + .../src/Models/CreateCnameTokenRequest.php | 49 + .../src/Models/CreateCnameTokenResult.php | 33 + .../oss-v2/src/Models/DataRedundancyType.php | 25 + .../alibabacloud/oss-v2/src/Models/Delete.php | 44 + .../Models/DeleteAccessPointPolicyRequest.php | 49 + .../Models/DeleteAccessPointPolicyResult.php | 15 + .../src/Models/DeleteAccessPointRequest.php | 49 + .../src/Models/DeleteAccessPointResult.php | 15 + .../src/Models/DeleteBucketCorsRequest.php | 38 + .../src/Models/DeleteBucketCorsResult.php | 15 + ...eBucketDataRedundancyTransitionRequest.php | 49 + ...teBucketDataRedundancyTransitionResult.php | 15 + .../Models/DeleteBucketEncryptionRequest.php | 38 + .../Models/DeleteBucketEncryptionResult.php | 15 + .../Models/DeleteBucketInventoryRequest.php | 49 + .../Models/DeleteBucketInventoryResult.php | 15 + .../Models/DeleteBucketLifecycleRequest.php | 38 + .../Models/DeleteBucketLifecycleResult.php | 15 + .../src/Models/DeleteBucketLoggingRequest.php | 38 + .../src/Models/DeleteBucketLoggingResult.php | 15 + .../DeleteBucketOverwriteConfigRequest.php | 38 + .../DeleteBucketOverwriteConfigResult.php | 15 + .../src/Models/DeleteBucketPolicyRequest.php | 38 + .../src/Models/DeleteBucketPolicyResult.php | 15 + .../DeleteBucketPublicAccessBlockRequest.php | 38 + .../DeleteBucketPublicAccessBlockResult.php | 15 + .../Models/DeleteBucketReplicationRequest.php | 49 + .../Models/DeleteBucketReplicationResult.php | 15 + .../oss-v2/src/Models/DeleteBucketRequest.php | 35 + .../oss-v2/src/Models/DeleteBucketResult.php | 16 + .../src/Models/DeleteBucketTagsRequest.php | 47 + .../src/Models/DeleteBucketTagsResult.php | 15 + .../src/Models/DeleteBucketWebsiteRequest.php | 38 + .../src/Models/DeleteBucketWebsiteResult.php | 15 + .../oss-v2/src/Models/DeleteCnameRequest.php | 49 + .../oss-v2/src/Models/DeleteCnameResult.php | 15 + .../src/Models/DeleteMarkerProperties.php | 75 + .../Models/DeleteMultipleObjectsRequest.php | 83 + .../Models/DeleteMultipleObjectsResult.php | 41 + .../oss-v2/src/Models/DeleteObject.php | 44 + .../oss-v2/src/Models/DeleteObjectRequest.php | 62 + .../oss-v2/src/Models/DeleteObjectResult.php | 41 + .../src/Models/DeleteObjectTaggingRequest.php | 62 + .../src/Models/DeleteObjectTaggingResult.php | 32 + .../Models/DeletePublicAccessBlockRequest.php | 25 + .../Models/DeletePublicAccessBlockResult.php | 15 + .../oss-v2/src/Models/DeleteStyleRequest.php | 49 + .../oss-v2/src/Models/DeleteStyleResult.php | 15 + ...eleteUserDefinedLogFieldsConfigRequest.php | 37 + ...DeleteUserDefinedLogFieldsConfigResult.php | 15 + .../oss-v2/src/Models/DeletedInfo.php | 65 + .../src/Models/DescribeRegionsRequest.php | 36 + .../src/Models/DescribeRegionsResult.php | 32 + .../oss-v2/src/Models/DoMetaQueryRequest.php | 59 + .../oss-v2/src/Models/DoMetaQueryResult.php | 54 + .../oss-v2/src/Models/DownloadResult.php | 29 + .../oss-v2/src/Models/EncodeType.php | 14 + .../src/Models/EncryptionMultipartContext.php | 55 + .../oss-v2/src/Models/ErrorDocument.php | 46 + .../src/Models/ExtendBucketWormRequest.php | 60 + .../src/Models/ExtendBucketWormResult.php | 15 + .../src/Models/ExtendWormConfiguration.php | 35 + .../oss-v2/src/Models/GetAccessPoint.php | 135 + .../Models/GetAccessPointPolicyRequest.php | 49 + .../src/Models/GetAccessPointPolicyResult.php | 30 + .../src/Models/GetAccessPointRequest.php | 49 + .../src/Models/GetAccessPointResult.php | 33 + .../Models/GetBucketAccessMonitorRequest.php | 38 + .../Models/GetBucketAccessMonitorResult.php | 33 + .../oss-v2/src/Models/GetBucketAclRequest.php | 35 + .../oss-v2/src/Models/GetBucketAclResult.php | 42 + .../GetBucketArchiveDirectReadRequest.php | 38 + .../GetBucketArchiveDirectReadResult.php | 34 + .../src/Models/GetBucketCorsRequest.php | 38 + .../oss-v2/src/Models/GetBucketCorsResult.php | 34 + ...tBucketDataRedundancyTransitionRequest.php | 49 + ...etBucketDataRedundancyTransitionResult.php | 33 + .../src/Models/GetBucketEncryptionRequest.php | 38 + .../src/Models/GetBucketEncryptionResult.php | 33 + .../Models/GetBucketHttpsConfigRequest.php | 38 + .../src/Models/GetBucketHttpsConfigResult.php | 33 + .../src/Models/GetBucketInfoRequest.php | 35 + .../oss-v2/src/Models/GetBucketInfoResult.php | 32 + .../src/Models/GetBucketInventoryRequest.php | 49 + .../src/Models/GetBucketInventoryResult.php | 33 + .../src/Models/GetBucketLifecycleRequest.php | 38 + .../src/Models/GetBucketLifecycleResult.php | 34 + .../src/Models/GetBucketLocationRequest.php | 35 + .../src/Models/GetBucketLocationResult.php | 32 + .../src/Models/GetBucketLoggingRequest.php | 38 + .../src/Models/GetBucketLoggingResult.php | 33 + .../GetBucketOverwriteConfigRequest.php | 38 + .../Models/GetBucketOverwriteConfigResult.php | 33 + .../src/Models/GetBucketPolicyRequest.php | 38 + .../src/Models/GetBucketPolicyResult.php | 30 + .../Models/GetBucketPolicyStatusRequest.php | 38 + .../Models/GetBucketPolicyStatusResult.php | 33 + .../GetBucketPublicAccessBlockRequest.php | 37 + .../GetBucketPublicAccessBlockResult.php | 34 + .../src/Models/GetBucketRefererRequest.php | 38 + .../src/Models/GetBucketRefererResult.php | 34 + .../GetBucketReplicationLocationRequest.php | 38 + .../GetBucketReplicationLocationResult.php | 33 + .../GetBucketReplicationProgressRequest.php | 49 + .../GetBucketReplicationProgressResult.php | 33 + .../Models/GetBucketReplicationRequest.php | 38 + .../src/Models/GetBucketReplicationResult.php | 33 + .../Models/GetBucketRequestPaymentRequest.php | 38 + .../Models/GetBucketRequestPaymentResult.php | 33 + .../Models/GetBucketResourceGroupRequest.php | 38 + .../Models/GetBucketResourceGroupResult.php | 33 + .../src/Models/GetBucketStatRequest.php | 35 + .../oss-v2/src/Models/GetBucketStatResult.php | 212 ++ .../src/Models/GetBucketTagsRequest.php | 38 + .../oss-v2/src/Models/GetBucketTagsResult.php | 33 + .../GetBucketTransferAccelerationRequest.php | 38 + .../GetBucketTransferAccelerationResult.php | 34 + .../src/Models/GetBucketVersioningRequest.php | 35 + .../src/Models/GetBucketVersioningResult.php | 32 + .../src/Models/GetBucketWebsiteRequest.php | 38 + .../src/Models/GetBucketWebsiteResult.php | 33 + .../src/Models/GetBucketWormRequest.php | 38 + .../oss-v2/src/Models/GetBucketWormResult.php | 33 + .../src/Models/GetCnameTokenRequest.php | 49 + .../oss-v2/src/Models/GetCnameTokenResult.php | 33 + .../src/Models/GetMetaQueryStatusRequest.php | 38 + .../src/Models/GetMetaQueryStatusResult.php | 33 + .../oss-v2/src/Models/GetObjectAclRequest.php | 62 + .../oss-v2/src/Models/GetObjectAclResult.php | 45 + .../src/Models/GetObjectMetaRequest.php | 62 + .../oss-v2/src/Models/GetObjectMetaResult.php | 76 + .../oss-v2/src/Models/GetObjectRequest.php | 208 ++ .../oss-v2/src/Models/GetObjectResult.php | 257 ++ .../src/Models/GetObjectTaggingRequest.php | 62 + .../src/Models/GetObjectTaggingResult.php | 34 + .../Models/GetPublicAccessBlockRequest.php | 28 + .../src/Models/GetPublicAccessBlockResult.php | 34 + .../oss-v2/src/Models/GetStyleRequest.php | 49 + .../oss-v2/src/Models/GetStyleResult.php | 33 + .../oss-v2/src/Models/GetSymlinkRequest.php | 62 + .../oss-v2/src/Models/GetSymlinkResult.php | 52 + .../GetUserDefinedLogFieldsConfigRequest.php | 38 + .../GetUserDefinedLogFieldsConfigResult.php | 33 + .../oss-v2/src/Models/HeadObjectRequest.php | 98 + .../oss-v2/src/Models/HeadObjectResult.php | 300 ++ .../HistoricalObjectReplicationType.php | 15 + .../oss-v2/src/Models/HttpsConfiguration.php | 44 + .../oss-v2/src/Models/IndexDocument.php | 56 + .../src/Models/InitiateBucketWormRequest.php | 49 + .../src/Models/InitiateBucketWormResult.php | 33 + .../Models/InitiateMultipartUploadRequest.php | 219 ++ .../Models/InitiateMultipartUploadResult.php | 68 + .../src/Models/InitiateWormConfiguration.php | 35 + .../src/Models/InventoryConfiguration.php | 95 + .../src/Models/InventoryDestination.php | 35 + .../oss-v2/src/Models/InventoryEncryption.php | 45 + .../oss-v2/src/Models/InventoryFilter.php | 85 + .../oss-v2/src/Models/InventoryFormatType.php | 14 + .../src/Models/InventoryFrequencyType.php | 15 + .../Models/InventoryOSSBucketDestination.php | 86 + .../src/Models/InventoryOptionalFieldType.php | 20 + .../oss-v2/src/Models/InventorySchedule.php | 36 + .../src/Models/LifecycleConfiguration.php | 36 + .../oss-v2/src/Models/LifecycleRule.php | 136 + .../LifecycleRuleAbortMultipartUpload.php | 46 + .../src/Models/LifecycleRuleExpiration.php | 56 + .../oss-v2/src/Models/LifecycleRuleFilter.php | 56 + .../oss-v2/src/Models/LifecycleRuleNot.php | 46 + .../src/Models/LifecycleRuleTransition.php | 87 + .../oss-v2/src/Models/ListAccessPoints.php | 75 + .../src/Models/ListAccessPointsRequest.php | 58 + .../src/Models/ListAccessPointsResult.php | 33 + .../ListBucketDataRedundancyTransition.php | 34 + ...tBucketDataRedundancyTransitionRequest.php | 37 + ...stBucketDataRedundancyTransitionResult.php | 33 + .../src/Models/ListBucketInventoryRequest.php | 48 + .../src/Models/ListBucketInventoryResult.php | 34 + .../oss-v2/src/Models/ListBucketsRequest.php | 94 + .../oss-v2/src/Models/ListBucketsResult.php | 85 + .../oss-v2/src/Models/ListCloudBoxes.php | 97 + .../src/Models/ListCloudBoxesRequest.php | 57 + .../src/Models/ListCloudBoxesResult.php | 33 + .../oss-v2/src/Models/ListCnameRequest.php | 38 + .../oss-v2/src/Models/ListCnameResult.php | 54 + .../ListInventoryConfigurationsResult.php | 55 + .../Models/ListMultipartUploadsRequest.php | 99 + .../src/Models/ListMultipartUploadsResult.php | 122 + .../src/Models/ListObjectVersionsRequest.php | 99 + .../src/Models/ListObjectVersionsResult.php | 141 + .../oss-v2/src/Models/ListObjectsRequest.php | 91 + .../oss-v2/src/Models/ListObjectsResult.php | 113 + .../src/Models/ListObjectsV2Request.php | 109 + .../oss-v2/src/Models/ListObjectsV2Result.php | 131 + .../oss-v2/src/Models/ListPartsRequest.php | 89 + .../oss-v2/src/Models/ListPartsResult.php | 115 + .../oss-v2/src/Models/ListStyleRequest.php | 38 + .../oss-v2/src/Models/ListStyleResult.php | 33 + ...istUserDataRedundancyTransitionRequest.php | 45 + ...ListUserDataRedundancyTransitionResult.php | 32 + .../src/Models/LocationRTCConstraint.php | 35 + .../src/Models/LocationTransferType.php | 44 + .../Models/LocationTransferTypeConstraint.php | 35 + .../oss-v2/src/Models/LoggingEnabled.php | 56 + .../oss-v2/src/Models/LoggingHeaderSet.php | 35 + .../oss-v2/src/Models/LoggingParamSet.php | 35 + .../oss-v2/src/Models/MetaQuery.php | 106 + .../oss-v2/src/Models/MetaQueryAddress.php | 95 + .../oss-v2/src/Models/MetaQueryAddresses.php | 34 + .../src/Models/MetaQueryAggregation.php | 65 + .../src/Models/MetaQueryAggregations.php | 34 + .../src/Models/MetaQueryAudioStream.php | 95 + .../src/Models/MetaQueryAudioStreams.php | 34 + .../oss-v2/src/Models/MetaQueryFile.php | 481 +++ .../oss-v2/src/Models/MetaQueryFiles.php | 34 + .../oss-v2/src/Models/MetaQueryGroup.php | 45 + .../oss-v2/src/Models/MetaQueryGroups.php | 35 + .../oss-v2/src/Models/MetaQueryMediaTypes.php | 35 + .../oss-v2/src/Models/MetaQueryOrderType.php | 15 + .../oss-v2/src/Models/MetaQueryOssTagging.php | 34 + .../src/Models/MetaQueryOssUserMeta.php | 34 + .../oss-v2/src/Models/MetaQueryStatus.php | 65 + .../oss-v2/src/Models/MetaQuerySubtitle.php | 65 + .../oss-v2/src/Models/MetaQuerySubtitles.php | 34 + .../oss-v2/src/Models/MetaQueryTagging.php | 45 + .../oss-v2/src/Models/MetaQueryUserMeta.php | 44 + .../src/Models/MetaQueryVideoStream.php | 145 + .../src/Models/MetaQueryVideoStreams.php | 34 + .../oss-v2/src/Models/MirrorAuth.php | 65 + .../oss-v2/src/Models/MirrorHeaderSet.php | 46 + .../oss-v2/src/Models/MirrorHeaders.php | 66 + .../src/Models/MirrorMultiAlternate.php | 65 + .../src/Models/MirrorMultiAlternates.php | 35 + .../oss-v2/src/Models/MirrorReturnHeaders.php | 35 + .../oss-v2/src/Models/MirrorTagging.php | 45 + .../oss-v2/src/Models/MirrorTaggings.php | 35 + .../Models/NoncurrentVersionExpiration.php | 36 + .../Models/NoncurrentVersionTransition.php | 77 + .../oss-v2/src/Models/ObjectACLType.php | 34 + .../oss-v2/src/Models/ObjectIdentifier.php | 45 + .../oss-v2/src/Models/ObjectProperties.php | 116 + .../src/Models/ObjectVersionProperties.php | 137 + .../src/Models/OpenMetaQueryRequest.php | 48 + .../oss-v2/src/Models/OpenMetaQueryResult.php | 15 + .../oss-v2/src/Models/OptionObjectRequest.php | 81 + .../oss-v2/src/Models/OptionObjectResult.php | 67 + .../oss-v2/src/Models/OptionalFields.php | 35 + .../src/Models/OverwriteConfiguration.php | 35 + .../oss-v2/src/Models/OverwritePrincipals.php | 35 + .../oss-v2/src/Models/OverwriteRule.php | 75 + .../alibabacloud/oss-v2/src/Models/Owner.php | 45 + .../alibabacloud/oss-v2/src/Models/Part.php | 77 + .../oss-v2/src/Models/PolicyStatus.php | 35 + .../oss-v2/src/Models/PresignResult.php | 56 + .../src/Models/ProcessObjectRequest.php | 62 + .../oss-v2/src/Models/ProcessObjectResult.php | 59 + .../Models/PublicAccessBlockConfiguration.php | 35 + .../Models/PutAccessPointPolicyRequest.php | 60 + .../src/Models/PutAccessPointPolicyResult.php | 15 + .../Models/PutBucketAccessMonitorRequest.php | 49 + .../Models/PutBucketAccessMonitorResult.php | 15 + .../oss-v2/src/Models/PutBucketAclRequest.php | 45 + .../oss-v2/src/Models/PutBucketAclResult.php | 16 + .../PutBucketArchiveDirectReadRequest.php | 49 + .../PutBucketArchiveDirectReadResult.php | 15 + .../src/Models/PutBucketCorsRequest.php | 49 + .../oss-v2/src/Models/PutBucketCorsResult.php | 15 + .../src/Models/PutBucketEncryptionRequest.php | 49 + .../src/Models/PutBucketEncryptionResult.php | 15 + .../Models/PutBucketHttpsConfigRequest.php | 49 + .../src/Models/PutBucketHttpsConfigResult.php | 15 + .../src/Models/PutBucketInventoryRequest.php | 60 + .../src/Models/PutBucketInventoryResult.php | 15 + .../src/Models/PutBucketLifecycleRequest.php | 59 + .../src/Models/PutBucketLifecycleResult.php | 15 + .../src/Models/PutBucketLoggingRequest.php | 49 + .../src/Models/PutBucketLoggingResult.php | 15 + .../PutBucketOverwriteConfigRequest.php | 49 + .../Models/PutBucketOverwriteConfigResult.php | 15 + .../src/Models/PutBucketPolicyRequest.php | 49 + .../src/Models/PutBucketPolicyResult.php | 15 + .../PutBucketPublicAccessBlockRequest.php | 49 + .../PutBucketPublicAccessBlockResult.php | 15 + .../src/Models/PutBucketRefererRequest.php | 49 + .../src/Models/PutBucketRefererResult.php | 15 + .../Models/PutBucketReplicationRequest.php | 49 + .../src/Models/PutBucketReplicationResult.php | 32 + .../oss-v2/src/Models/PutBucketRequest.php | 63 + .../Models/PutBucketRequestPaymentRequest.php | 49 + .../Models/PutBucketRequestPaymentResult.php | 15 + .../Models/PutBucketResourceGroupRequest.php | 49 + .../Models/PutBucketResourceGroupResult.php | 15 + .../oss-v2/src/Models/PutBucketResult.php | 16 + .../oss-v2/src/Models/PutBucketRtcRequest.php | 49 + .../oss-v2/src/Models/PutBucketRtcResult.php | 15 + .../src/Models/PutBucketTagsRequest.php | 49 + .../oss-v2/src/Models/PutBucketTagsResult.php | 15 + .../PutBucketTransferAccelerationRequest.php | 49 + .../PutBucketTransferAccelerationResult.php | 15 + .../src/Models/PutBucketVersioningRequest.php | 44 + .../src/Models/PutBucketVersioningResult.php | 16 + .../src/Models/PutBucketWebsiteRequest.php | 49 + .../src/Models/PutBucketWebsiteResult.php | 15 + .../oss-v2/src/Models/PutCnameRequest.php | 49 + .../oss-v2/src/Models/PutCnameResult.php | 15 + .../oss-v2/src/Models/PutObjectAclRequest.php | 74 + .../oss-v2/src/Models/PutObjectAclResult.php | 30 + .../oss-v2/src/Models/PutObjectRequest.php | 253 ++ .../oss-v2/src/Models/PutObjectResult.php | 69 + .../src/Models/PutObjectTaggingRequest.php | 71 + .../src/Models/PutObjectTaggingResult.php | 32 + .../Models/PutPublicAccessBlockRequest.php | 39 + .../src/Models/PutPublicAccessBlockResult.php | 15 + .../oss-v2/src/Models/PutStyleRequest.php | 70 + .../oss-v2/src/Models/PutStyleResult.php | 15 + .../oss-v2/src/Models/PutSymlinkRequest.php | 107 + .../oss-v2/src/Models/PutSymlinkResult.php | 32 + .../PutUserDefinedLogFieldsConfigRequest.php | 49 + .../PutUserDefinedLogFieldsConfigResult.php | 15 + .../oss-v2/src/Models/RefererBlacklist.php | 35 + .../src/Models/RefererConfiguration.php | 75 + .../oss-v2/src/Models/RefererList.php | 35 + .../oss-v2/src/Models/RegionInfo.php | 66 + .../src/Models/ReplicationConfiguration.php | 35 + .../src/Models/ReplicationDestination.php | 56 + .../ReplicationEncryptionConfiguration.php | 34 + .../oss-v2/src/Models/ReplicationLocation.php | 55 + .../src/Models/ReplicationPrefixSet.php | 35 + .../oss-v2/src/Models/ReplicationProgress.php | 35 + .../Models/ReplicationProgressInformation.php | 44 + .../src/Models/ReplicationProgressRule.php | 95 + .../oss-v2/src/Models/ReplicationRule.php | 126 + .../oss-v2/src/Models/ReplicationRules.php | 35 + .../ReplicationSourceSelectionCriteria.php | 35 + .../src/Models/ReplicationTimeControl.php | 35 + .../Models/RequestPaymentConfiguration.php | 35 + .../src/Models/RestoreObjectRequest.php | 71 + .../oss-v2/src/Models/RestoreObjectResult.php | 42 + .../oss-v2/src/Models/RestoreRequest.php | 43 + .../oss-v2/src/Models/ReturnHeader.php | 45 + .../oss-v2/src/Models/RoutingRule.php | 64 + .../src/Models/RoutingRuleCondition.php | 66 + .../src/Models/RoutingRuleIncludeHeader.php | 66 + .../src/Models/RoutingRuleLuaConfig.php | 35 + .../oss-v2/src/Models/RoutingRuleRedirect.php | 403 +++ .../oss-v2/src/Models/RoutingRules.php | 35 + .../oss-v2/src/Models/RtcConfiguration.php | 45 + .../alibabacloud/oss-v2/src/Models/SSEKMS.php | 35 + .../src/Models/SealAppendObjectRequest.php | 52 + .../src/Models/SealAppendObjectResult.php | 30 + .../src/Models/ServerSideEncryptionRule.php | 36 + .../Models/ServerSideEncryptionRuleInfo.php | 55 + .../src/Models/SseKmsEncryptedObjects.php | 36 + .../oss-v2/src/Models/StatusType.php | 16 + .../oss-v2/src/Models/StorageClassType.php | 43 + .../oss-v2/src/Models/StyleContent.php | 35 + .../oss-v2/src/Models/StyleInfo.php | 75 + .../oss-v2/src/Models/StyleList.php | 35 + vendor/alibabacloud/oss-v2/src/Models/TLS.php | 44 + vendor/alibabacloud/oss-v2/src/Models/Tag.php | 40 + .../alibabacloud/oss-v2/src/Models/TagSet.php | 36 + .../oss-v2/src/Models/Tagging.php | 35 + .../TransferAccelerationConfiguration.php | 35 + .../oss-v2/src/Models/TransferType.php | 16 + .../oss-v2/src/Models/TransferTypes.php | 35 + .../alibabacloud/oss-v2/src/Models/Upload.php | 56 + .../oss-v2/src/Models/UploadPart.php | 47 + .../src/Models/UploadPartCopyRequest.php | 152 + .../src/Models/UploadPartCopyResult.php | 51 + .../oss-v2/src/Models/UploadPartRequest.php | 193 ++ .../oss-v2/src/Models/UploadPartResult.php | 51 + .../oss-v2/src/Models/UploadResult.php | 74 + .../UserDefinedLogFieldsConfiguration.php | 46 + .../src/Models/VersioningConfiguration.php | 36 + .../src/Models/WebsiteConfiguration.php | 56 + .../oss-v2/src/Models/WormConfiguration.php | 77 + .../oss-v2/src/OperationInput.php | 180 + .../oss-v2/src/OperationOutput.php | 103 + .../src/Paginator/ListBucketsPaginator.php | 85 + .../ListMultipartUploadsPaginator.php | 89 + .../Paginator/ListObjectVersionsPaginator.php | 89 + .../src/Paginator/ListObjectsPaginator.php | 85 + .../src/Paginator/ListObjectsV2Paginator.php | 85 + .../src/Paginator/ListPartsPaginator.php | 85 + .../oss-v2/src/Paginator/Paginator.php | 40 + .../oss-v2/src/ProgressStream.php | 73 + .../src/Retry/BackoffDelayerInterface.php | 17 + .../oss-v2/src/Retry/ClientErrorRetryable.php | 41 + .../oss-v2/src/Retry/EqualJitterBackoff.php | 54 + .../src/Retry/ErrorRetryableInterface.php | 11 + .../oss-v2/src/Retry/FixedDelayBackoff.php | 38 + .../oss-v2/src/Retry/FullJitterBackoff.php | 51 + .../src/Retry/HTTPStatusCodeRetryable.php | 27 + .../oss-v2/src/Retry/NopRetryer.php | 23 + .../oss-v2/src/Retry/RetryerInterface.php | 15 + .../src/Retry/ServiceErrorCodeRetryable.php | 26 + .../oss-v2/src/Retry/StandardRetryer.php | 64 + .../oss-v2/src/RetryMiddleware.php | 138 + vendor/alibabacloud/oss-v2/src/Serializer.php | 265 ++ .../oss-v2/src/Signer/NopSigner.php | 13 + .../oss-v2/src/Signer/SignerInterface.php | 24 + .../oss-v2/src/Signer/SignerV1.php | 209 ++ .../oss-v2/src/Signer/SignerV4.php | 317 ++ .../oss-v2/src/Signer/SigningContext.php | 115 + .../oss-v2/src/SinkStreamWrapper.php | 91 + .../oss-v2/src/Transform/AccessPoint.php | 260 ++ .../src/Transform/BucketAccessMonitor.php | 83 + .../src/Transform/BucketArchiveDirectRead.php | 87 + .../oss-v2/src/Transform/BucketBasic.php | 958 ++++++ .../oss-v2/src/Transform/BucketCname.php | 195 ++ .../oss-v2/src/Transform/BucketCors.php | 155 + .../oss-v2/src/Transform/BucketEncryption.php | 120 + .../src/Transform/BucketHttpsConfig.php | 87 + .../oss-v2/src/Transform/BucketInventory.php | 156 + .../oss-v2/src/Transform/BucketLifecycle.php | 118 + .../oss-v2/src/Transform/BucketLogging.php | 217 ++ .../oss-v2/src/Transform/BucketMetaQuery.php | 159 + .../src/Transform/BucketOverwriteConfig.php | 120 + .../oss-v2/src/Transform/BucketPolicy.php | 155 + .../src/Transform/BucketPublicAccessBlock.php | 120 + .../Transform/BucketRedundancyTransition.php | 194 ++ .../oss-v2/src/Transform/BucketReferer.php | 87 + .../src/Transform/BucketReplication.php | 230 ++ .../src/Transform/BucketRequestPayment.php | 87 + .../src/Transform/BucketResourceGroup.php | 87 + .../oss-v2/src/Transform/BucketStyle.php | 156 + .../oss-v2/src/Transform/BucketTags.php | 120 + .../Transform/BucketTransferAcceleration.php | 87 + .../oss-v2/src/Transform/BucketWebsite.php | 118 + .../oss-v2/src/Transform/BucketWorm.php | 181 + .../oss-v2/src/Transform/CloudBoxes.php | 53 + .../oss-v2/src/Transform/Functions.php | 367 +++ .../oss-v2/src/Transform/ObjectBasic.php | 1690 ++++++++++ .../oss-v2/src/Transform/ObjectMultipart.php | 616 ++++ .../src/Transform/PublicAccessBlock.php | 117 + .../alibabacloud/oss-v2/src/Types/Model.php | 8 + .../oss-v2/src/Types/ModelTrait.php | 26 + .../oss-v2/src/Types/RequestModel.php | 34 + .../oss-v2/src/Types/ResultModel.php | 39 + vendor/alibabacloud/oss-v2/src/Uploader.php | 399 +++ vendor/alibabacloud/oss-v2/src/Utils.php | 409 +++ vendor/alibabacloud/oss-v2/src/Validation.php | 56 + vendor/alibabacloud/oss-v2/src/Version.php | 14 + .../oss-v2/tests/Data/enc-example.jpg | Bin 0 -> 21839 bytes .../oss-v2/tests/Data/example.jpg | Bin 0 -> 21839 bytes .../ClientAccessPointTest.php | 242 ++ .../ClientBucketAccessMonitorTest.php | 80 + .../ClientBucketArchiveDirectReadTest.php | 81 + .../ClientBucketBasicTest.php | 514 +++ .../ClientBucketCnameTest.php | 166 + .../IntegrationTests/ClientBucketCorsTest.php | 159 + ...ientBucketDataRedundancyTransitionTest.php | 147 + .../ClientBucketEncryptionTest.php | 109 + .../ClientBucketHttpsConfigTest.php | 116 + .../ClientBucketInventoryTest.php | 190 ++ .../ClientBucketLifecycleTest.php | 127 + .../ClientBucketLoggingTest.php | 188 ++ .../ClientBucketMetaQueryTest.php | 184 ++ .../ClientBucketOverwriteTest.php | 112 + .../ClientBucketPolicyTest.php | 136 + .../ClientBucketPublicAccessBlockTest.php | 90 + .../ClientBucketRefererTest.php | 83 + .../ClientBucketReplicationTest.php | 246 ++ .../ClientBucketRequestPaymentTest.php | 80 + .../ClientBucketResourceGroupTest.php | 78 + .../ClientBucketStyleTest.php | 128 + .../IntegrationTests/ClientBucketTagsTest.php | 109 + .../ClientBucketTransferAccelerationTest.php | 81 + .../ClientBucketWebsiteTest.php | 242 ++ .../IntegrationTests/ClientBucketWormTest.php | 183 ++ .../IntegrationTests/ClientExtensionTest.php | 1010 ++++++ .../ClientListCloudBoxesTest.php | 57 + .../tests/IntegrationTests/ClientMiscTest.php | 380 +++ .../ClientObjectBasicTest.php | 634 ++++ .../ClientObjectMultipartTest.php | 433 +++ .../IntegrationTests/ClientPaginatorTest.php | 774 +++++ .../IntegrationTests/ClientPresignerTest.php | 507 +++ .../ClientPublicAccessBlockTest.php | 88 + .../IntegrationTests/EncryptionClientTest.php | 1045 ++++++ .../IntegrationTests/TestIntegration.php | 402 +++ .../UnitTests/Annotation/AnnotationTest.php | 80 + .../UnitTests/Annotation/ModelObject.php | 39 + .../tests/UnitTests/Annotation/XmlObject.php | 39 + .../oss-v2/tests/UnitTests/ClientImplTest.php | 2282 +++++++++++++ .../UnitTests/Credentials/CredentialsTest.php | 84 + .../UnitTests/Crypto/AesCtrCipherTest.php | 218 ++ .../UnitTests/Crypto/MasterRsaCipherTest.php | 113 + .../tests/UnitTests/Crypto/enc-example.jpg | Bin 0 -> 21839 bytes .../oss-v2/tests/UnitTests/Crypto/example.jpg | Bin 0 -> 21839 bytes .../tests/UnitTests/DeserializerTest.php | 632 ++++ .../UnitTests/Exception/ExceptionTest.php | 15 + .../Fixtures/BaiscTypeLackAnnotationXml.php | 32 + .../UnitTests/Fixtures/BaiscTypeListXml.php | 36 + .../tests/UnitTests/Fixtures/BaiscTypeXml.php | 36 + .../UnitTests/Fixtures/DatetimeTypeXml.php | 36 + .../UnitTests/Fixtures/MixedTypeListXml.php | 30 + .../tests/UnitTests/Fixtures/MixedTypeXml.php | 38 + .../UnitTests/Fixtures/NoRewindStream.php | 23 + .../UnitTests/Fixtures/PutApiARequest.php | 44 + .../UnitTests/Fixtures/PutApiBRequest.php | 44 + .../UnitTests/Fixtures/PutApiBResult.php | 52 + .../UnitTests/Fixtures/PutApiRequest.php | 107 + .../tests/UnitTests/Fixtures/PutApiResult.php | 62 + .../UnitTests/Fixtures/RewindStatStream.php | 34 + .../UnitTests/Fixtures/RootConfiguration.php | 34 + .../UnitTests/Fixtures/SubConfiguration.php | 29 + .../tests/UnitTests/Retry/BackoffTest.php | 58 + .../UnitTests/Retry/ErrorRetryableTest.php | 72 + .../tests/UnitTests/Retry/RetryerTest.php | 76 + .../oss-v2/tests/UnitTests/SerializerTest.php | 722 ++++ .../tests/UnitTests/Signer/NopSignerTest.php | 18 + .../UnitTests/Signer/SignerContextTest.php | 26 + .../tests/UnitTests/Signer/SignerV1Test.php | 258 ++ .../tests/UnitTests/Signer/SignerV4Test.php | 618 ++++ .../UnitTests/Transform/AccessPointTest.php | 482 +++ .../Transform/BucketAccessMonitorTest.php | 115 + .../Transform/BucketArchiveDirectReadTest.php | 133 + .../UnitTests/Transform/BucketBasicTest.php | 2414 ++++++++++++++ .../UnitTests/Transform/BucketCnameTest.php | 377 +++ .../UnitTests/Transform/BucketCorsTest.php | 271 ++ .../Transform/BucketEncryptionTest.php | 232 ++ .../Transform/BucketHttpsConfigTest.php | 177 + .../Transform/BucketInventoryTest.php | 497 +++ .../Transform/BucketLifecycleTest.php | 538 +++ .../UnitTests/Transform/BucketLoggingTest.php | 354 ++ .../Transform/BucketMetaQueryTest.php | 639 ++++ .../Transform/BucketOverwriteConfigTest.php | 200 ++ .../UnitTests/Transform/BucketPolicyTest.php | 197 ++ .../Transform/BucketPublicAccessBlockTest.php | 155 + .../BucketRedundancyTransitionTest.php | 467 +++ .../UnitTests/Transform/BucketRefererTest.php | 200 ++ .../Transform/BucketReplicationTest.php | 428 +++ .../Transform/BucketRequestPaymentTest.php | 143 + .../Transform/BucketResourceGroupTest.php | 115 + .../UnitTests/Transform/BucketStyleTest.php | 274 ++ .../UnitTests/Transform/BucketTagsTest.php | 177 + .../BucketTransferAccelerationTest.php | 133 + .../UnitTests/Transform/BucketWebsiteTest.php | 590 ++++ .../UnitTests/Transform/BucketWormTest.php | 276 ++ .../UnitTests/Transform/CloudBoxesTest.php | 85 + .../UnitTests/Transform/FunctionsTest.php | 105 + .../UnitTests/Transform/ObjectBasicTest.php | 2903 +++++++++++++++++ .../Transform/ObjectMultipartTest.php | 1121 +++++++ .../Transform/PublicAccessBlockTest.php | 127 + .../oss-v2/tests/UnitTests/Types/ModelA.php | 30 + .../tests/UnitTests/Types/ModelPrivate.php | 41 + .../tests/UnitTests/Types/ModelTest.php | 112 + .../tests/UnitTests/Types/XmlModelA.php | 44 + .../oss-v2/tests/UnitTests/UtilsTest.php | 187 ++ .../oss-v2/tests/UnitTests/ValidationTest.php | 44 + vendor/autoload.php | 25 + vendor/bin/var-dump-server | 119 + vendor/bin/var-dump-server.bat | 5 + vendor/composer/ClassLoader.php | 579 ++++ vendor/composer/InstalledVersions.php | 359 ++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 10 + vendor/composer/autoload_files.php | 19 + vendor/composer/autoload_namespaces.php | 10 + vendor/composer/autoload_psr4.php | 30 + vendor/composer/autoload_real.php | 50 + vendor/composer/autoload_static.php | 182 ++ vendor/composer/installed.json | 1870 +++++++++++ vendor/composer/installed.php | 302 ++ vendor/composer/platform_check.php | 26 + vendor/guzzlehttp/guzzle/CHANGELOG.md | 1672 ++++++++++ vendor/guzzlehttp/guzzle/LICENSE | 27 + vendor/guzzlehttp/guzzle/README.md | 94 + vendor/guzzlehttp/guzzle/UPGRADING.md | 1253 +++++++ vendor/guzzlehttp/guzzle/composer.json | 131 + .../guzzlehttp/guzzle/src/BodySummarizer.php | 28 + .../guzzle/src/BodySummarizerInterface.php | 13 + vendor/guzzlehttp/guzzle/src/Client.php | 483 +++ .../guzzlehttp/guzzle/src/ClientInterface.php | 84 + vendor/guzzlehttp/guzzle/src/ClientTrait.php | 241 ++ .../guzzle/src/Cookie/CookieJar.php | 307 ++ .../guzzle/src/Cookie/CookieJarInterface.php | 80 + .../guzzle/src/Cookie/FileCookieJar.php | 101 + .../guzzle/src/Cookie/SessionCookieJar.php | 77 + .../guzzle/src/Cookie/SetCookie.php | 492 +++ .../src/Exception/BadResponseException.php | 39 + .../guzzle/src/Exception/ClientException.php | 10 + .../guzzle/src/Exception/ConnectException.php | 56 + .../guzzle/src/Exception/GuzzleException.php | 9 + .../Exception/InvalidArgumentException.php | 7 + .../guzzle/src/Exception/RequestException.php | 150 + .../guzzle/src/Exception/ServerException.php | 10 + .../Exception/TooManyRedirectsException.php | 7 + .../src/Exception/TransferException.php | 7 + .../guzzle/src/Handler/CurlFactory.php | 736 +++++ .../src/Handler/CurlFactoryInterface.php | 25 + .../guzzle/src/Handler/CurlHandler.php | 49 + .../guzzle/src/Handler/CurlMultiHandler.php | 284 ++ .../guzzle/src/Handler/EasyHandle.php | 112 + .../guzzle/src/Handler/HeaderProcessor.php | 42 + .../guzzle/src/Handler/MockHandler.php | 212 ++ .../guzzlehttp/guzzle/src/Handler/Proxy.php | 51 + .../guzzle/src/Handler/StreamHandler.php | 627 ++++ vendor/guzzlehttp/guzzle/src/HandlerStack.php | 275 ++ .../guzzle/src/MessageFormatter.php | 199 ++ .../guzzle/src/MessageFormatterInterface.php | 18 + vendor/guzzlehttp/guzzle/src/Middleware.php | 268 ++ vendor/guzzlehttp/guzzle/src/Pool.php | 125 + .../guzzle/src/PrepareBodyMiddleware.php | 105 + .../guzzle/src/RedirectMiddleware.php | 228 ++ .../guzzlehttp/guzzle/src/RequestOptions.php | 274 ++ .../guzzlehttp/guzzle/src/RetryMiddleware.php | 119 + .../guzzlehttp/guzzle/src/TransferStats.php | 133 + vendor/guzzlehttp/guzzle/src/Utils.php | 384 +++ vendor/guzzlehttp/guzzle/src/functions.php | 167 + .../guzzle/src/functions_include.php | 6 + vendor/guzzlehttp/promises/CHANGELOG.md | 180 + vendor/guzzlehttp/promises/LICENSE | 24 + vendor/guzzlehttp/promises/README.md | 559 ++++ vendor/guzzlehttp/promises/composer.json | 58 + .../promises/src/AggregateException.php | 19 + .../promises/src/CancellationException.php | 12 + vendor/guzzlehttp/promises/src/Coroutine.php | 162 + vendor/guzzlehttp/promises/src/Create.php | 79 + vendor/guzzlehttp/promises/src/Each.php | 81 + .../guzzlehttp/promises/src/EachPromise.php | 248 ++ .../promises/src/FulfilledPromise.php | 89 + vendor/guzzlehttp/promises/src/Is.php | 40 + vendor/guzzlehttp/promises/src/Promise.php | 281 ++ .../promises/src/PromiseInterface.php | 91 + .../promises/src/PromisorInterface.php | 16 + .../promises/src/RejectedPromise.php | 95 + .../promises/src/RejectionException.php | 49 + vendor/guzzlehttp/promises/src/TaskQueue.php | 71 + .../promises/src/TaskQueueInterface.php | 24 + vendor/guzzlehttp/promises/src/Utils.php | 261 ++ vendor/guzzlehttp/psr7/CHANGELOG.md | 475 +++ vendor/guzzlehttp/psr7/LICENSE | 26 + vendor/guzzlehttp/psr7/README.md | 887 +++++ vendor/guzzlehttp/psr7/composer.json | 93 + vendor/guzzlehttp/psr7/src/AppendStream.php | 248 ++ vendor/guzzlehttp/psr7/src/BufferStream.php | 147 + vendor/guzzlehttp/psr7/src/CachingStream.php | 153 + vendor/guzzlehttp/psr7/src/DroppingStream.php | 49 + .../src/Exception/MalformedUriException.php | 14 + vendor/guzzlehttp/psr7/src/FnStream.php | 180 + vendor/guzzlehttp/psr7/src/Header.php | 134 + vendor/guzzlehttp/psr7/src/HttpFactory.php | 94 + vendor/guzzlehttp/psr7/src/InflateStream.php | 37 + vendor/guzzlehttp/psr7/src/LazyOpenStream.php | 49 + vendor/guzzlehttp/psr7/src/LimitStream.php | 157 + vendor/guzzlehttp/psr7/src/Message.php | 246 ++ vendor/guzzlehttp/psr7/src/MessageTrait.php | 265 ++ vendor/guzzlehttp/psr7/src/MimeType.php | 1259 +++++++ .../guzzlehttp/psr7/src/MultipartStream.php | 165 + vendor/guzzlehttp/psr7/src/NoSeekStream.php | 28 + vendor/guzzlehttp/psr7/src/PumpStream.php | 179 + vendor/guzzlehttp/psr7/src/Query.php | 118 + vendor/guzzlehttp/psr7/src/Request.php | 159 + vendor/guzzlehttp/psr7/src/Response.php | 161 + vendor/guzzlehttp/psr7/src/Rfc7230.php | 23 + vendor/guzzlehttp/psr7/src/ServerRequest.php | 340 ++ vendor/guzzlehttp/psr7/src/Stream.php | 283 ++ .../psr7/src/StreamDecoratorTrait.php | 156 + vendor/guzzlehttp/psr7/src/StreamWrapper.php | 207 ++ vendor/guzzlehttp/psr7/src/UploadedFile.php | 211 ++ vendor/guzzlehttp/psr7/src/Uri.php | 743 +++++ vendor/guzzlehttp/psr7/src/UriComparator.php | 52 + vendor/guzzlehttp/psr7/src/UriNormalizer.php | 220 ++ vendor/guzzlehttp/psr7/src/UriResolver.php | 211 ++ vendor/guzzlehttp/psr7/src/Utils.php | 477 +++ .../FallbackMimeTypeDetector.php | 52 + vendor/league/flysystem-local/LICENSE | 19 + .../LocalFilesystemAdapter.php | 485 +++ vendor/league/flysystem-local/composer.json | 25 + vendor/league/flysystem/INFO.md | 2 + vendor/league/flysystem/LICENSE | 19 + vendor/league/flysystem/composer.json | 72 + vendor/league/flysystem/readme.md | 61 + .../src/CalculateChecksumFromStream.php | 30 + .../src/ChecksumAlgoIsNotSupported.php | 11 + .../league/flysystem/src/ChecksumProvider.php | 14 + vendor/league/flysystem/src/Config.php | 57 + .../flysystem/src/CorruptedPathDetected.php | 13 + .../league/flysystem/src/DecoratedAdapter.php | 97 + .../flysystem/src/DirectoryAttributes.php | 87 + .../league/flysystem/src/DirectoryListing.php | 93 + .../league/flysystem/src/FileAttributes.php | 100 + vendor/league/flysystem/src/Filesystem.php | 290 ++ .../flysystem/src/FilesystemAdapter.php | 115 + .../flysystem/src/FilesystemException.php | 11 + .../src/FilesystemOperationFailed.php | 25 + .../flysystem/src/FilesystemOperator.php | 9 + .../league/flysystem/src/FilesystemReader.php | 85 + .../league/flysystem/src/FilesystemWriter.php | 58 + .../flysystem/src/InvalidStreamProvided.php | 11 + .../src/InvalidVisibilityProvided.php | 20 + vendor/league/flysystem/src/MountManager.php | 434 +++ .../league/flysystem/src/PathNormalizer.php | 10 + vendor/league/flysystem/src/PathPrefixer.php | 50 + .../flysystem/src/PathTraversalDetected.php | 25 + .../flysystem/src/PortableVisibilityGuard.php | 19 + .../src/ProxyArrayAccessToProperties.php | 62 + .../src/ResolveIdenticalPathConflict.php | 11 + .../flysystem/src/StorageAttributes.php | 40 + .../flysystem/src/SymbolicLinkEncountered.php | 25 + .../src/UnableToCheckDirectoryExistence.php | 13 + .../flysystem/src/UnableToCheckExistence.php | 26 + .../src/UnableToCheckFileExistence.php | 13 + .../league/flysystem/src/UnableToCopyFile.php | 62 + .../flysystem/src/UnableToCreateDirectory.php | 50 + .../flysystem/src/UnableToDeleteDirectory.php | 48 + .../flysystem/src/UnableToDeleteFile.php | 45 + .../src/UnableToGeneratePublicUrl.php | 26 + .../src/UnableToGenerateTemporaryUrl.php | 26 + .../flysystem/src/UnableToListContents.php | 24 + .../flysystem/src/UnableToMountFilesystem.php | 32 + .../league/flysystem/src/UnableToMoveFile.php | 67 + .../flysystem/src/UnableToProvideChecksum.php | 16 + .../league/flysystem/src/UnableToReadFile.php | 45 + .../src/UnableToResolveFilesystemMount.php | 20 + .../src/UnableToRetrieveMetadata.php | 76 + .../flysystem/src/UnableToSetVisibility.php | 49 + .../flysystem/src/UnableToWriteFile.php | 45 + .../PortableVisibilityConverter.php | 79 + .../UnixVisibility/VisibilityConverter.php | 14 + .../src/UnreadableFileEncountered.php | 28 + .../ChainedPublicUrlGenerator.php | 30 + .../PrefixPublicUrlGenerator.php | 23 + .../src/UrlGeneration/PublicUrlGenerator.php | 16 + .../ShardedPrefixPublicUrlGenerator.php | 39 + .../UrlGeneration/TemporaryUrlGenerator.php | 16 + vendor/league/flysystem/src/Visibility.php | 11 + .../src/WhitespacePathNormalizer.php | 49 + .../league/mime-type-detection/CHANGELOG.md | 64 + vendor/league/mime-type-detection/LICENSE | 19 + .../league/mime-type-detection/composer.json | 34 + .../src/EmptyExtensionToMimeTypeMap.php | 13 + .../src/ExtensionLookup.php | 14 + .../src/ExtensionMimeTypeDetector.php | 56 + .../src/ExtensionToMimeTypeMap.php | 10 + .../src/FinfoMimeTypeDetector.php | 106 + .../src/GeneratedExtensionToMimeTypeMap.php | 2310 +++++++++++++ .../src/MimeTypeDetector.php | 19 + .../src/OverridingExtensionToMimeTypeMap.php | 30 + .../php-curl-class/CHANGELOG.md | 350 ++ vendor/php-curl-class/php-curl-class/LICENSE | 24 + .../php-curl-class/php-curl-class/README.md | 408 +++ .../php-curl-class/php-curl-class/SECURITY.md | 127 + .../php-curl-class/composer.json | 53 + .../php-curl-class/src/Curl/ArrayUtil.php | 159 + .../php-curl-class/src/Curl/BaseCurl.php | 422 +++ .../src/Curl/CaseInsensitiveArray.php | 211 ++ .../php-curl-class/src/Curl/Curl.php | 2275 +++++++++++++ .../php-curl-class/src/Curl/Decoder.php | 45 + .../php-curl-class/src/Curl/Encoder.php | 30 + .../php-curl-class/src/Curl/MultiCurl.php | 976 ++++++ .../php-curl-class/src/Curl/StringUtil.php | 65 + .../php-curl-class/src/Curl/Url.php | 253 ++ vendor/psr/container/LICENSE | 21 + vendor/psr/container/README.md | 13 + vendor/psr/container/composer.json | 27 + .../src/ContainerExceptionInterface.php | 12 + .../psr/container/src/ContainerInterface.php | 36 + .../src/NotFoundExceptionInterface.php | 10 + vendor/psr/http-client/CHANGELOG.md | 31 + vendor/psr/http-client/LICENSE | 19 + vendor/psr/http-client/README.md | 12 + vendor/psr/http-client/composer.json | 30 + .../src/ClientExceptionInterface.php | 10 + .../psr/http-client/src/ClientInterface.php | 20 + .../src/NetworkExceptionInterface.php | 24 + .../src/RequestExceptionInterface.php | 24 + vendor/psr/http-factory/LICENSE | 21 + vendor/psr/http-factory/README.md | 12 + vendor/psr/http-factory/composer.json | 38 + .../src/RequestFactoryInterface.php | 18 + .../src/ResponseFactoryInterface.php | 18 + .../src/ServerRequestFactoryInterface.php | 24 + .../src/StreamFactoryInterface.php | 45 + .../src/UploadedFileFactoryInterface.php | 34 + .../http-factory/src/UriFactoryInterface.php | 17 + vendor/psr/http-message/CHANGELOG.md | 36 + vendor/psr/http-message/LICENSE | 19 + vendor/psr/http-message/README.md | 16 + vendor/psr/http-message/composer.json | 26 + .../psr/http-message/docs/PSR7-Interfaces.md | 130 + vendor/psr/http-message/docs/PSR7-Usage.md | 159 + .../psr/http-message/src/MessageInterface.php | 189 ++ .../psr/http-message/src/RequestInterface.php | 131 + .../http-message/src/ResponseInterface.php | 70 + .../src/ServerRequestInterface.php | 263 ++ .../psr/http-message/src/StreamInterface.php | 160 + .../src/UploadedFileInterface.php | 125 + vendor/psr/http-message/src/UriInterface.php | 326 ++ vendor/psr/log/LICENSE | 19 + vendor/psr/log/README.md | 58 + vendor/psr/log/composer.json | 26 + vendor/psr/log/src/AbstractLogger.php | 15 + .../psr/log/src/InvalidArgumentException.php | 7 + vendor/psr/log/src/LogLevel.php | 18 + vendor/psr/log/src/LoggerAwareInterface.php | 14 + vendor/psr/log/src/LoggerAwareTrait.php | 22 + vendor/psr/log/src/LoggerInterface.php | 98 + vendor/psr/log/src/LoggerTrait.php | 98 + vendor/psr/log/src/NullLogger.php | 26 + vendor/psr/simple-cache/.editorconfig | 12 + vendor/psr/simple-cache/LICENSE.md | 21 + vendor/psr/simple-cache/README.md | 8 + vendor/psr/simple-cache/composer.json | 25 + .../psr/simple-cache/src/CacheException.php | 10 + .../psr/simple-cache/src/CacheInterface.php | 114 + .../src/InvalidArgumentException.php | 13 + vendor/ralouphie/getallheaders/LICENSE | 21 + vendor/ralouphie/getallheaders/README.md | 27 + vendor/ralouphie/getallheaders/composer.json | 26 + .../getallheaders/src/getallheaders.php | 46 + vendor/services.php | 7 + .../deprecation-contracts/CHANGELOG.md | 5 + vendor/symfony/deprecation-contracts/LICENSE | 19 + .../symfony/deprecation-contracts/README.md | 26 + .../deprecation-contracts/composer.json | 35 + .../deprecation-contracts/function.php | 27 + vendor/symfony/polyfill-mbstring/LICENSE | 19 + vendor/symfony/polyfill-mbstring/Mbstring.php | 1045 ++++++ vendor/symfony/polyfill-mbstring/README.md | 13 + .../Resources/unidata/caseFolding.php | 119 + .../Resources/unidata/lowerCase.php | 1397 ++++++++ .../Resources/unidata/titleCaseRegexp.php | 5 + .../Resources/unidata/upperCase.php | 1489 +++++++++ .../symfony/polyfill-mbstring/bootstrap.php | 172 + .../symfony/polyfill-mbstring/bootstrap80.php | 167 + .../symfony/polyfill-mbstring/composer.json | 39 + vendor/symfony/var-dumper/CHANGELOG.md | 116 + .../var-dumper/Caster/AddressInfoCaster.php | 82 + .../symfony/var-dumper/Caster/AmqpCaster.php | 214 ++ vendor/symfony/var-dumper/Caster/ArgsStub.php | 79 + vendor/symfony/var-dumper/Caster/Caster.php | 203 ++ .../symfony/var-dumper/Caster/ClassStub.php | 104 + .../symfony/var-dumper/Caster/ConstStub.php | 52 + .../symfony/var-dumper/Caster/CurlCaster.php | 31 + .../var-dumper/Caster/CutArrayStub.php | 30 + vendor/symfony/var-dumper/Caster/CutStub.php | 64 + .../symfony/var-dumper/Caster/DOMCaster.php | 318 ++ .../symfony/var-dumper/Caster/DateCaster.php | 129 + .../var-dumper/Caster/DoctrineCaster.php | 64 + vendor/symfony/var-dumper/Caster/DsCaster.php | 70 + .../symfony/var-dumper/Caster/DsPairStub.php | 28 + vendor/symfony/var-dumper/Caster/EnumStub.php | 29 + .../var-dumper/Caster/ExceptionCaster.php | 397 +++ .../symfony/var-dumper/Caster/FFICaster.php | 171 + .../symfony/var-dumper/Caster/FiberCaster.php | 43 + .../symfony/var-dumper/Caster/FrameStub.php | 28 + vendor/symfony/var-dumper/Caster/GdCaster.php | 30 + .../symfony/var-dumper/Caster/GmpCaster.php | 34 + .../var-dumper/Caster/ImagineCaster.php | 39 + vendor/symfony/var-dumper/Caster/ImgStub.php | 26 + .../symfony/var-dumper/Caster/IntlCaster.php | 174 + vendor/symfony/var-dumper/Caster/LinkStub.php | 105 + .../var-dumper/Caster/MemcachedCaster.php | 83 + .../var-dumper/Caster/MysqliCaster.php | 33 + .../var-dumper/Caster/OpenSSLCaster.php | 69 + .../symfony/var-dumper/Caster/PdoCaster.php | 124 + .../symfony/var-dumper/Caster/PgSqlCaster.php | 158 + .../var-dumper/Caster/ProxyManagerCaster.php | 35 + .../var-dumper/Caster/RdKafkaCaster.php | 188 ++ .../symfony/var-dumper/Caster/RedisCaster.php | 152 + .../var-dumper/Caster/ReflectionCaster.php | 448 +++ .../var-dumper/Caster/ResourceCaster.php | 92 + .../symfony/var-dumper/Caster/ScalarStub.php | 27 + .../var-dumper/Caster/SocketCaster.php | 64 + .../symfony/var-dumper/Caster/SplCaster.php | 258 ++ .../var-dumper/Caster/SqliteCaster.php | 32 + .../symfony/var-dumper/Caster/StubCaster.php | 94 + .../var-dumper/Caster/SymfonyCaster.php | 123 + .../symfony/var-dumper/Caster/TraceStub.php | 32 + .../var-dumper/Caster/UninitializedStub.php | 25 + .../symfony/var-dumper/Caster/UuidCaster.php | 32 + .../symfony/var-dumper/Caster/VirtualStub.php | 21 + .../var-dumper/Caster/XmlReaderCaster.php | 94 + .../var-dumper/Caster/XmlResourceCaster.php | 65 + .../var-dumper/Cloner/AbstractCloner.php | 413 +++ .../var-dumper/Cloner/ClonerInterface.php | 23 + vendor/symfony/var-dumper/Cloner/Cursor.php | 43 + vendor/symfony/var-dumper/Cloner/Data.php | 429 +++ .../var-dumper/Cloner/DumperInterface.php | 53 + .../var-dumper/Cloner/Internal/NoDefault.php | 25 + vendor/symfony/var-dumper/Cloner/Stub.php | 75 + .../symfony/var-dumper/Cloner/VarCloner.php | 218 ++ .../Command/Descriptor/CliDescriptor.php | 78 + .../Descriptor/DumpDescriptorInterface.php | 23 + .../Command/Descriptor/HtmlDescriptor.php | 118 + .../var-dumper/Command/ServerDumpCommand.php | 111 + .../var-dumper/Dumper/AbstractDumper.php | 201 ++ .../symfony/var-dumper/Dumper/CliDumper.php | 667 ++++ .../ContextProvider/CliContextProvider.php | 32 + .../ContextProviderInterface.php | 22 + .../RequestContextProvider.php | 50 + .../ContextProvider/SourceContextProvider.php | 121 + .../Dumper/ContextualizedDumper.php | 40 + .../var-dumper/Dumper/DataDumperInterface.php | 27 + .../symfony/var-dumper/Dumper/HtmlDumper.php | 980 ++++++ .../var-dumper/Dumper/ServerDumper.php | 53 + .../Exception/ThrowingCasterException.php | 26 + vendor/symfony/var-dumper/LICENSE | 19 + vendor/symfony/var-dumper/README.md | 15 + .../var-dumper/Resources/bin/var-dump-server | 67 + .../Resources/css/htmlDescriptor.css | 130 + .../var-dumper/Resources/functions/dump.php | 68 + .../var-dumper/Resources/js/htmlDescriptor.js | 10 + .../symfony/var-dumper/Server/Connection.php | 97 + .../symfony/var-dumper/Server/DumpServer.php | 109 + .../var-dumper/Test/VarDumperTestTrait.php | 87 + vendor/symfony/var-dumper/VarDumper.php | 118 + vendor/symfony/var-dumper/composer.json | 45 + .../.github/ISSUE_TEMPLATE/1-bug-report.yml | 67 + .../ISSUE_TEMPLATE/2-feature_request.md | 20 + .../.github/ISSUE_TEMPLATE/3-custom.md | 10 + .../.github/ISSUE_TEMPLATE/config.yml | 8 + .../framework/.github/workflows/build.yml | 48 + .../.github/workflows/php-cs-fixer.yml | 31 + vendor/topthink/framework/CONTRIBUTING.md | 119 + vendor/topthink/framework/LICENSE.txt | 32 + vendor/topthink/framework/README.md | 85 + vendor/topthink/framework/composer.json | 59 + vendor/topthink/framework/logo.png | Bin 0 -> 6995 bytes vendor/topthink/framework/phpunit.xml.dist | 27 + vendor/topthink/framework/src/helper.php | 677 ++++ vendor/topthink/framework/src/lang/zh-cn.php | 157 + vendor/topthink/framework/src/think/App.php | 651 ++++ vendor/topthink/framework/src/think/Cache.php | 200 ++ .../topthink/framework/src/think/Config.php | 209 ++ .../topthink/framework/src/think/Console.php | 787 +++++ .../topthink/framework/src/think/Cookie.php | 223 ++ vendor/topthink/framework/src/think/Db.php | 117 + vendor/topthink/framework/src/think/Env.php | 199 ++ vendor/topthink/framework/src/think/Event.php | 291 ++ .../framework/src/think/Exception.php | 59 + vendor/topthink/framework/src/think/File.php | 198 ++ vendor/topthink/framework/src/think/Http.php | 279 ++ vendor/topthink/framework/src/think/Lang.php | 273 ++ vendor/topthink/framework/src/think/Log.php | 249 ++ .../topthink/framework/src/think/Manager.php | 173 + .../framework/src/think/Middleware.php | 248 ++ .../topthink/framework/src/think/Pipeline.php | 106 + .../topthink/framework/src/think/Request.php | 2218 +++++++++++++ .../topthink/framework/src/think/Response.php | 425 +++ vendor/topthink/framework/src/think/Route.php | 885 +++++ .../topthink/framework/src/think/Service.php | 63 + .../topthink/framework/src/think/Session.php | 65 + vendor/topthink/framework/src/think/View.php | 187 ++ .../framework/src/think/cache/Driver.php | 385 +++ .../framework/src/think/cache/TagSet.php | 121 + .../framework/src/think/cache/driver/File.php | 308 ++ .../src/think/cache/driver/Memcache.php | 204 ++ .../src/think/cache/driver/Memcached.php | 215 ++ .../src/think/cache/driver/Redis.php | 254 ++ .../src/think/cache/driver/Wincache.php | 170 + .../framework/src/think/console/Command.php | 504 +++ .../framework/src/think/console/Input.php | 465 +++ .../framework/src/think/console/LICENSE | 19 + .../framework/src/think/console/Output.php | 231 ++ .../framework/src/think/console/Table.php | 300 ++ .../framework/src/think/console/bin/README.md | 1 + .../src/think/console/bin/hiddeninput.exe | Bin 0 -> 9216 bytes .../src/think/console/command/Clear.php | 85 + .../src/think/console/command/Help.php | 70 + .../src/think/console/command/Lists.php | 74 + .../src/think/console/command/Make.php | 99 + .../src/think/console/command/RouteList.php | 128 + .../src/think/console/command/RunServer.php | 72 + .../think/console/command/ServiceDiscover.php | 52 + .../think/console/command/VendorPublish.php | 69 + .../src/think/console/command/Version.php | 35 + .../think/console/command/make/Command.php | 54 + .../think/console/command/make/Controller.php | 55 + .../src/think/console/command/make/Event.php | 35 + .../think/console/command/make/Listener.php | 35 + .../think/console/command/make/Middleware.php | 36 + .../src/think/console/command/make/Model.php | 36 + .../think/console/command/make/Service.php | 36 + .../think/console/command/make/Subscribe.php | 35 + .../think/console/command/make/Validate.php | 38 + .../console/command/make/stubs/command.stub | 26 + .../command/make/stubs/controller.api.stub | 64 + .../command/make/stubs/controller.plain.stub | 9 + .../command/make/stubs/controller.stub | 85 + .../console/command/make/stubs/event.stub | 8 + .../console/command/make/stubs/listener.stub | 17 + .../command/make/stubs/middleware.stub | 19 + .../console/command/make/stubs/model.stub | 14 + .../console/command/make/stubs/service.stub | 27 + .../console/command/make/stubs/subscribe.stub | 8 + .../console/command/make/stubs/validate.stub | 25 + .../think/console/command/optimize/Route.php | 66 + .../think/console/command/optimize/Schema.php | 109 + .../src/think/console/input/Argument.php | 138 + .../src/think/console/input/Definition.php | 375 +++ .../src/think/console/input/Option.php | 221 ++ .../src/think/console/output/Ask.php | 336 ++ .../src/think/console/output/Descriptor.php | 323 ++ .../src/think/console/output/Formatter.php | 198 ++ .../src/think/console/output/Question.php | 211 ++ .../console/output/descriptor/Console.php | 153 + .../think/console/output/driver/Buffer.php | 52 + .../think/console/output/driver/Console.php | 369 +++ .../think/console/output/driver/Nothing.php | 33 + .../think/console/output/formatter/Stack.php | 116 + .../think/console/output/formatter/Style.php | 190 ++ .../think/console/output/question/Choice.php | 163 + .../console/output/question/Confirmation.php | 57 + .../think/contract/CacheHandlerInterface.php | 71 + .../think/contract/LogHandlerInterface.php | 28 + .../think/contract/ModelRelationInterface.php | 98 + .../contract/SessionHandlerInterface.php | 23 + .../contract/TemplateHandlerInterface.php | 56 + .../framework/src/think/event/AppInit.php | 20 + .../framework/src/think/event/HttpEnd.php | 20 + .../framework/src/think/event/HttpRun.php | 20 + .../framework/src/think/event/LogRecord.php | 29 + .../framework/src/think/event/LogWrite.php | 23 + .../framework/src/think/event/RouteLoaded.php | 20 + .../exception/ClassNotFoundException.php | 36 + .../src/think/exception/ErrorException.php | 57 + .../src/think/exception/FileException.php | 17 + .../framework/src/think/exception/Handle.php | 371 +++ .../src/think/exception/HttpException.php | 36 + .../think/exception/HttpResponseException.php | 31 + .../exception/InvalidArgumentException.php | 21 + .../think/exception/InvalidCacheException.php | 19 + .../exception/RouteNotFoundException.php | 26 + .../framework/src/think/facade/App.php | 59 + .../framework/src/think/facade/Cache.php | 48 + .../framework/src/think/facade/Config.php | 37 + .../framework/src/think/facade/Console.php | 56 + .../framework/src/think/facade/Cookie.php | 40 + .../framework/src/think/facade/Env.php | 44 + .../framework/src/think/facade/Event.php | 42 + .../framework/src/think/facade/Lang.php | 41 + .../framework/src/think/facade/Log.php | 58 + .../framework/src/think/facade/Middleware.php | 42 + .../framework/src/think/facade/Request.php | 134 + .../framework/src/think/facade/Route.php | 82 + .../framework/src/think/facade/Session.php | 45 + .../framework/src/think/facade/View.php | 42 + .../framework/src/think/file/UploadedFile.php | 129 + .../src/think/initializer/BootService.php | 26 + .../framework/src/think/initializer/Error.php | 120 + .../src/think/initializer/RegisterService.php | 48 + .../framework/src/think/log/Channel.php | 163 + .../framework/src/think/log/ChannelSet.php | 34 + .../framework/src/think/log/driver/File.php | 207 ++ .../framework/src/think/log/driver/Socket.php | 307 ++ .../src/think/middleware/AllowCrossDomain.php | 63 + .../think/middleware/CheckRequestCache.php | 183 ++ .../src/think/middleware/FormTokenCheck.php | 44 + .../src/think/middleware/LoadLangPack.php | 113 + .../src/think/middleware/SessionInit.php | 71 + .../framework/src/think/response/File.php | 161 + .../framework/src/think/response/Html.php | 34 + .../framework/src/think/response/Json.php | 61 + .../framework/src/think/response/Jsonp.php | 73 + .../framework/src/think/response/Redirect.php | 102 + .../framework/src/think/response/View.php | 150 + .../framework/src/think/response/Xml.php | 127 + .../framework/src/think/route/Dispatch.php | 348 ++ .../framework/src/think/route/Domain.php | 41 + .../framework/src/think/route/Resource.php | 263 ++ .../src/think/route/ResourceRegister.php | 72 + .../framework/src/think/route/Rule.php | 1036 ++++++ .../framework/src/think/route/RuleGroup.php | 732 +++++ .../framework/src/think/route/RuleItem.php | 328 ++ .../framework/src/think/route/RuleName.php | 212 ++ .../framework/src/think/route/Url.php | 478 +++ .../src/think/route/dispatch/Callback.php | 65 + .../src/think/route/dispatch/Controller.php | 115 + .../src/think/service/ModelService.php | 52 + .../src/think/service/PaginatorService.php | 52 + .../src/think/service/ValidateService.php | 31 + .../framework/src/think/session/Store.php | 325 ++ .../src/think/session/driver/Cache.php | 50 + .../src/think/session/driver/File.php | 248 ++ .../framework/src/think/view/driver/Php.php | 209 ++ .../framework/src/tpl/think_exception.tpl | 502 +++ vendor/topthink/framework/tests/AppTest.php | 207 ++ vendor/topthink/framework/tests/CacheTest.php | 154 + .../topthink/framework/tests/ConfigTest.php | 46 + vendor/topthink/framework/tests/DbTest.php | 49 + .../topthink/framework/tests/DispatchTest.php | 32 + vendor/topthink/framework/tests/EnvTest.php | 80 + vendor/topthink/framework/tests/EventTest.php | 134 + vendor/topthink/framework/tests/HttpTest.php | 153 + .../framework/tests/InteractsWithApp.php | 30 + vendor/topthink/framework/tests/LogTest.php | 132 + .../framework/tests/MiddlewareTest.php | 110 + vendor/topthink/framework/tests/RouteTest.php | 230 ++ .../topthink/framework/tests/SessionTest.php | 225 ++ .../topthink/framework/tests/UrlRouteTest.php | 60 + vendor/topthink/framework/tests/ViewTest.php | 122 + vendor/topthink/framework/tests/bootstrap.php | 3 + vendor/topthink/think-container/.travis.yml | 26 + vendor/topthink/think-container/LICENSE | 201 ++ vendor/topthink/think-container/README.md | 95 + vendor/topthink/think-container/composer.json | 26 + .../topthink/think-container/phpunit.xml.dist | 25 + .../think-container/src/Container.php | 564 ++++ .../topthink/think-container/src/Facade.php | 99 + .../src/exception/ClassNotFoundException.php | 36 + .../src/exception/FuncNotFoundException.php | 27 + .../think-container/tests/ContainerTest.php | 361 ++ .../think-container/tests/bootstrap.php | 3 + vendor/topthink/think-dumper/README.md | 35 + vendor/topthink/think-dumper/composer.json | 32 + vendor/topthink/think-dumper/phpunit.xml.dist | 25 + .../topthink/think-dumper/src/Connection.php | 82 + vendor/topthink/think-dumper/src/Dumper.php | 103 + .../think-dumper/src/ServerDumper.php | 31 + .../src/SourceContextProvider.php | 58 + vendor/topthink/think-dumper/src/helper.php | 8 + .../think-dumper/tests/DumperTest.php | 14 + .../topthink/think-dumper/tests/bootstrap.php | 13 + vendor/topthink/think-filesystem/README.md | 5 + .../topthink/think-filesystem/composer.json | 34 + .../think-filesystem/phpunit.xml.dist | 17 + .../think-filesystem/src/Filesystem.php | 89 + .../src/facade/Filesystem.php | 33 + .../src/filesystem/Driver.php | 130 + .../src/filesystem/driver/Local.php | 98 + .../think-filesystem/tests/FilesystemTest.php | 80 + .../think-filesystem/tests/bootstrap.php | 2 + .../topthink/think-filesystem/tests/test.txt | 1 + .../think-helper/.github/workflows/ci.yml | 36 + .../think-helper/.github/workflows/php.yml | 36 + vendor/topthink/think-helper/LICENSE | 201 ++ vendor/topthink/think-helper/README.md | 35 + vendor/topthink/think-helper/composer.json | 36 + vendor/topthink/think-helper/phpunit.xml.dist | 17 + .../topthink/think-helper/src/Collection.php | 678 ++++ .../think-helper/src/contract/Arrayable.php | 8 + .../think-helper/src/contract/Jsonable.php | 8 + vendor/topthink/think-helper/src/helper.php | 317 ++ .../topthink/think-helper/src/helper/Arr.php | 669 ++++ .../think-helper/src/helper/Macroable.php | 66 + .../topthink/think-helper/src/helper/Str.php | 234 ++ .../topthink/think-helper/tests/ArrTest.php | 372 +++ .../think-helper/tests/CollectionTest.php | 70 + .../think-helper/tests/IsAssocTest.php | 48 + .../think-helper/tests/MergeDeepTest.php | 69 + .../topthink/think-helper/tests/StrTest.php | 59 + .../topthink/think-helper/tests/TestCase.php | 13 + vendor/topthink/think-multi-app/LICENSE | 201 ++ vendor/topthink/think-multi-app/README.md | 14 + vendor/topthink/think-multi-app/composer.json | 28 + .../topthink/think-multi-app/src/MultiApp.php | 223 ++ .../topthink/think-multi-app/src/Service.php | 32 + vendor/topthink/think-multi-app/src/Url.php | 229 ++ .../think-multi-app/src/command/Build.php | 180 + .../think-multi-app/src/command/Clear.php | 66 + .../src/command/stubs/controller.stub | 12 + vendor/topthink/think-orm/.gitattributes | 3 + vendor/topthink/think-orm/LICENSE | 201 ++ vendor/topthink/think-orm/README.md | 43 + vendor/topthink/think-orm/composer.json | 47 + vendor/topthink/think-orm/src/DbManager.php | 400 +++ vendor/topthink/think-orm/src/Entity.php | 327 ++ vendor/topthink/think-orm/src/Model.php | 892 +++++ vendor/topthink/think-orm/src/Paginator.php | 568 ++++ .../topthink/think-orm/src/db/BaseBuilder.php | 971 ++++++ .../topthink/think-orm/src/db/BaseQuery.php | 1756 ++++++++++ vendor/topthink/think-orm/src/db/Builder.php | 839 +++++ .../topthink/think-orm/src/db/CacheItem.php | 220 ++ .../topthink/think-orm/src/db/Connection.php | 383 +++ .../think-orm/src/db/ConnectionInterface.php | 208 ++ vendor/topthink/think-orm/src/db/Express.php | 64 + vendor/topthink/think-orm/src/db/Fetch.php | 544 +++ vendor/topthink/think-orm/src/db/Mongo.php | 802 +++++ .../think-orm/src/db/PDOConnection.php | 2003 ++++++++++++ vendor/topthink/think-orm/src/db/Query.php | 648 ++++ vendor/topthink/think-orm/src/db/Raw.php | 54 + vendor/topthink/think-orm/src/db/Where.php | 175 + .../think-orm/src/db/builder/Mongo.php | 692 ++++ .../think-orm/src/db/builder/Mysql.php | 525 +++ .../think-orm/src/db/builder/Oracle.php | 134 + .../think-orm/src/db/builder/Pgsql.php | 123 + .../think-orm/src/db/builder/Sqlite.php | 118 + .../think-orm/src/db/builder/Sqlsrv.php | 194 ++ .../src/db/concern/AggregateQuery.php | 131 + .../src/db/concern/JoinAndViewQuery.php | 241 ++ .../src/db/concern/ModelRelationQuery.php | 729 +++++ .../think-orm/src/db/concern/ParamsBind.php | 149 + .../src/db/concern/ResultOperation.php | 266 ++ .../src/db/concern/TableFieldInfo.php | 107 + .../src/db/concern/TimeFieldQuery.php | 227 ++ .../think-orm/src/db/concern/Transaction.php | 131 + .../think-orm/src/db/concern/WhereQuery.php | 670 ++++ .../think-orm/src/db/connector/Mongo.php | 1214 +++++++ .../think-orm/src/db/connector/Mysql.php | 169 + .../think-orm/src/db/connector/Oracle.php | 125 + .../think-orm/src/db/connector/Pgsql.php | 113 + .../think-orm/src/db/connector/Sqlite.php | 97 + .../think-orm/src/db/connector/Sqlsrv.php | 131 + .../think-orm/src/db/connector/pgsql.sql | 117 + .../think-orm/src/db/connector/pgsql12.sql | 117 + .../src/db/exception/BindParamException.php | 35 + .../db/exception/DataNotFoundException.php | 44 + .../src/db/exception/DbEventException.php | 21 + .../src/db/exception/DbException.php | 45 + .../src/db/exception/DuplicateException.php | 21 + .../db/exception/InvalidArgumentException.php | 23 + .../src/db/exception/ModelEventException.php | 21 + .../db/exception/ModelNotFoundException.php | 44 + .../src/db/exception/PDOException.php | 45 + vendor/topthink/think-orm/src/facade/Db.php | 32 + vendor/topthink/think-orm/src/helper.php | 52 + .../think-orm/src/model/Collection.php | 284 ++ vendor/topthink/think-orm/src/model/Pivot.php | 77 + .../topthink/think-orm/src/model/Relation.php | 354 ++ vendor/topthink/think-orm/src/model/View.php | 744 +++++ .../topthink/think-orm/src/model/Virtual.php | 72 + .../think-orm/src/model/concern/Attribute.php | 719 ++++ .../src/model/concern/AutoWriteData.php | 138 + .../src/model/concern/Conversion.php | 208 ++ .../think-orm/src/model/concern/DbConnect.php | 202 ++ .../src/model/concern/ModelEvent.php | 85 + .../think-orm/src/model/concern/OptimLock.php | 87 + .../src/model/concern/RelationShip.php | 902 +++++ .../src/model/concern/SoftDelete.php | 219 ++ .../src/model/contract/EnumTransform.php | 10 + .../src/model/contract/FieldTypeTransform.php | 17 + .../src/model/contract/Modelable.php | 9 + .../think-orm/src/model/contract/Typeable.php | 17 + .../src/model/relation/BelongsTo.php | 350 ++ .../src/model/relation/BelongsToMany.php | 735 +++++ .../think-orm/src/model/relation/HasMany.php | 386 +++ .../src/model/relation/HasManyThrough.php | 391 +++ .../think-orm/src/model/relation/HasOne.php | 317 ++ .../src/model/relation/HasOneThrough.php | 164 + .../src/model/relation/MorphMany.php | 436 +++ .../think-orm/src/model/relation/MorphOne.php | 393 +++ .../think-orm/src/model/relation/MorphTo.php | 392 +++ .../src/model/relation/MorphToMany.php | 497 +++ .../think-orm/src/model/relation/OneToOne.php | 347 ++ .../think-orm/src/model/type/Date.php | 19 + .../think-orm/src/model/type/DateTime.php | 74 + .../think-orm/src/model/type/Json.php | 43 + .../src/paginator/driver/Bootstrap.php | 219 ++ vendor/topthink/think-orm/stubs/Exception.php | 59 + vendor/topthink/think-orm/stubs/Facade.php | 69 + .../topthink/think-orm/stubs/load_stubs.php | 9 + vendor/topthink/think-template/LICENSE | 201 ++ vendor/topthink/think-template/README.md | 70 + vendor/topthink/think-template/composer.json | 20 + vendor/topthink/think-template/phpunit.xml | 12 + .../topthink/think-template/src/Template.php | 1316 ++++++++ .../think-template/src/facade/Template.php | 83 + .../think-template/src/template/TagLib.php | 341 ++ .../src/template/contract/DriverInterface.php | 35 + .../src/template/driver/File.php | 84 + .../exception/TemplateNotFoundException.php | 33 + .../think-template/src/template/taglib/Cx.php | 715 ++++ .../think-template/tests/bootstrap.php | 3 + .../think-template/tests/tag/Demo.php | 46 + .../think-template/tests/template/extend.html | 2 + .../think-template/tests/template/fetch.html | 1 + .../tests/template/include.html | 1 + .../think-template/tests/template/layout.html | 1 + .../tests/think/TemplateTest.php | 247 ++ vendor/topthink/think-trace/LICENSE | 201 ++ vendor/topthink/think-trace/README.md | 15 + vendor/topthink/think-trace/composer.json | 31 + vendor/topthink/think-trace/src/Console.php | 173 + vendor/topthink/think-trace/src/Html.php | 126 + vendor/topthink/think-trace/src/Service.php | 21 + .../topthink/think-trace/src/TraceDebug.php | 109 + vendor/topthink/think-trace/src/config.php | 10 + .../think-trace/src/tpl/page_trace.tpl | 71 + vendor/topthink/think-validate/LICENSE | 201 ++ vendor/topthink/think-validate/README.md | 82 + vendor/topthink/think-validate/composer.json | 23 + .../topthink/think-validate/src/Validate.php | 2197 +++++++++++++ .../think-validate/src/contract/Enumable.php | 22 + .../src/exception/ValidateException.php | 45 + .../think-validate/src/facade/Validate.php | 80 + vendor/topthink/think-validate/src/helper.php | 67 + .../src/validate/ValidateRule.php | 187 ++ .../src/validate/ValidateRuleSet.php | 74 + vendor/topthink/think-view/LICENSE | 201 ++ vendor/topthink/think-view/README.md | 36 + vendor/topthink/think-view/composer.json | 20 + vendor/topthink/think-view/src/Think.php | 254 ++ 1638 files changed, 213697 insertions(+) create mode 100644 .env create mode 100644 .example.env create mode 100644 .gitignore create mode 100644 .htaccess create mode 100644 .travis.yml create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 app/.htaccess create mode 100644 app/AppService.php create mode 100644 app/BaseController.php create mode 100644 app/ExceptionHandle.php create mode 100644 app/Request.php create mode 100644 app/common.php create mode 100644 app/event.php create mode 100644 app/lang/en-us.php create mode 100644 app/lang/zh-cn.php create mode 100644 app/log/driver/Monolog.php create mode 100644 app/middleware.php create mode 100644 app/middleware/LogRecorder.php create mode 100644 app/miniapi/common.php create mode 100644 app/miniapi/controller/Auth.php create mode 100644 app/miniapi/controller/Base.php create mode 100644 app/miniapi/controller/Esta.php create mode 100644 app/miniapi/controller/Evus.php create mode 100644 app/miniapi/controller/Help.php create mode 100644 app/miniapi/controller/Index.php create mode 100644 app/miniapi/controller/News.php create mode 100644 app/miniapi/controller/Ocr.php create mode 100644 app/miniapi/controller/Order.php create mode 100644 app/miniapi/controller/Upload.php create mode 100644 app/miniapi/service/Context/MiniAppContext.php create mode 100644 app/miniapi/service/Legal/LegalDocumentService.php create mode 100644 app/miniapi/service/Payment/MiniPayService.php create mode 100644 app/miniapi/service/Payment/PaymentChannelService.php create mode 100644 app/miniapi/service/Product/ProductService.php create mode 100644 app/provider.php create mode 100644 app/service.php create mode 100644 app/service/AwsUploadService.php create mode 100644 app/service/BaiduOcrService.php create mode 100644 app/service/CompressImgService.php create mode 100644 app/service/MiniProgramWechatService.php create mode 100644 app/service/OssService.php create mode 100644 app/service/OssUploadService.php create mode 100644 app/service/PassportOcrService.php create mode 100644 app/service/SwooleService.php create mode 100644 app/service/UploadService.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 config/app.php create mode 100644 config/cache.php create mode 100644 config/citic.php create mode 100644 config/console.php create mode 100644 config/cookie.php create mode 100644 config/database.php create mode 100644 config/filesystem.php create mode 100644 config/lang.php create mode 100644 config/log.php create mode 100644 config/middleware.php create mode 100644 config/mini_legal.php create mode 100644 config/mini_payment.php create mode 100644 config/mini_product.php create mode 100644 config/miniapp.php create mode 100644 config/ocr.php create mode 100644 config/oss.php create mode 100644 config/route.php create mode 100644 config/session.php create mode 100644 config/trace.php create mode 100644 config/view.php create mode 100644 extend/api/Httpcurl.php create mode 100644 extend/api/Verify.php create mode 100644 extend/api/Verify/bgs/1.jpg create mode 100644 extend/api/Verify/bgs/2.jpg create mode 100644 extend/api/Verify/bgs/3.jpg create mode 100644 extend/api/Verify/bgs/4.jpg create mode 100644 extend/api/Verify/bgs/5.jpg create mode 100644 extend/api/Verify/bgs/6.jpg create mode 100644 extend/api/Verify/bgs/7.jpg create mode 100644 extend/api/Verify/bgs/8.jpg create mode 100644 extend/api/Verify/ttfs/1.ttf create mode 100644 extend/api/Verify/ttfs/2.ttf create mode 100644 extend/api/Verify/ttfs/3.ttf create mode 100644 extend/api/Verify/ttfs/4.ttf create mode 100644 extend/api/Verify/ttfs/5.ttf create mode 100644 extend/api/Verify/ttfs/6.ttf create mode 100644 nginx.htaccess create mode 100644 public/.htaccess create mode 100644 public/index.php create mode 100644 public/json/country.json create mode 100644 public/json/country_en.json create mode 100644 public/json/phone_prefix.json create mode 100644 public/json/phone_prefix_en.json create mode 100644 public/json/us.json create mode 100644 public/json/us_en.json create mode 100644 public/nginx.htaccess create mode 100644 public/robots.txt create mode 100644 public/router.php create mode 100644 route/app.php create mode 100644 think create mode 100644 thinkphp/lang/zh-cn.php create mode 100644 vendor/alibabacloud/oss-v2/.github/workflows/main.yml create mode 100644 vendor/alibabacloud/oss-v2/.gitignore create mode 100644 vendor/alibabacloud/oss-v2/CHANGELOG.md create mode 100644 vendor/alibabacloud/oss-v2/DEVGUIDE-CN.md create mode 100644 vendor/alibabacloud/oss-v2/DEVGUIDE.md create mode 100644 vendor/alibabacloud/oss-v2/LICENSE create mode 100644 vendor/alibabacloud/oss-v2/README-CN.md create mode 100644 vendor/alibabacloud/oss-v2/README.md create mode 100644 vendor/alibabacloud/oss-v2/autoload.php create mode 100644 vendor/alibabacloud/oss-v2/composer.json create mode 100644 vendor/alibabacloud/oss-v2/index.php create mode 100644 vendor/alibabacloud/oss-v2/phpunit.xml create mode 100644 vendor/alibabacloud/oss-v2/sample/AbortBucketWorm.php create mode 100644 vendor/alibabacloud/oss-v2/sample/AbortMultipartUpload.php create mode 100644 vendor/alibabacloud/oss-v2/sample/AppendObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/AsyncProcessObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CleanRestoredObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CloseMetaQuery.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CompleteMultipartUpload.php create mode 100644 vendor/alibabacloud/oss-v2/sample/Copier.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CopyObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CreateAccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CreateBucketDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/sample/CreateCnameToken.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteAccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucket.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketCors.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketEncryption.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketInventory.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketLifecycle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketLogging.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketOverwrite.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketPublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketReplication.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketTags.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteBucketWebsite.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteCname.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteMultipleObjects.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteObjectTagging.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeletePublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteStyle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeleteUserDefinedLogFieldsConfig.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DeletetAccessPointPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DescribeRegions.php create mode 100644 vendor/alibabacloud/oss-v2/sample/DoMetaQuery.php create mode 100644 vendor/alibabacloud/oss-v2/sample/Downloader.php create mode 100644 vendor/alibabacloud/oss-v2/sample/EncryptionClient.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ExtentBucketWorm.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetAccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetAccessPointPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketAccessMonitor.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketAcl.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketArchiveDirectRead.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketCors.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketEncryption.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketHttpsConfig.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketInfo.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketInventory.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketLifecycle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketLocation.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketLogging.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketOverwrite.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketPolicyStatus.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketPublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketReferer.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketReplication.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketReplicationLocation.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketReplicationProgress.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketRequestPayment.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketResourceGroup.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketStat.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketTags.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketTransferAcceleration.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketVersioning.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketWebsite.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetBucketWorm.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetCnameToken.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetMetaQueryStatus.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetObjectAcl.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetObjectMeta.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetObjectTagging.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetPublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetStyle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetSymlink.php create mode 100644 vendor/alibabacloud/oss-v2/sample/GetUserDefinedLogFieldsConfig.php create mode 100644 vendor/alibabacloud/oss-v2/sample/HeadObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/InitiateBucketWorm.php create mode 100644 vendor/alibabacloud/oss-v2/sample/InitiateMultipartUpload.php create mode 100644 vendor/alibabacloud/oss-v2/sample/InvokeOperation.php create mode 100644 vendor/alibabacloud/oss-v2/sample/IsBucketExist.php create mode 100644 vendor/alibabacloud/oss-v2/sample/IsObjectExist.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListAccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListBucketDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListBucketInventory.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListBuckets.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListCloudBoxes.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListCname.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListMultipartUploads.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListObjectVersions.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListObjects.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListObjectsV2.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListParts.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListStyle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ListUserDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/sample/OpenMetaQuery.php create mode 100644 vendor/alibabacloud/oss-v2/sample/OptionObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PostObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/Presign.php create mode 100644 vendor/alibabacloud/oss-v2/sample/ProcessObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutAccessPointPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucket.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketAccessMonitor.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketAcl.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketArchiveDirectRead.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketCors.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketEncryption.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketHttpsConfig.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketInventory.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketLifecycle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketLogging.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketOverwrite.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketPublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketReferer.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketReplication.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketRequestPayment.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketResourceGroup.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketRtc.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketTags.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketTransferAcceleration.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketVersioning.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutBucketWebsite.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutCname.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutObjectAcl.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutObjectTagging.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutPublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutStyle.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutSymlink.php create mode 100644 vendor/alibabacloud/oss-v2/sample/PutUserDefinedLogFieldsConfig.php create mode 100644 vendor/alibabacloud/oss-v2/sample/RestoreObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/SealAppendObject.php create mode 100644 vendor/alibabacloud/oss-v2/sample/UploadPart.php create mode 100644 vendor/alibabacloud/oss-v2/sample/UploadPartCopy.php create mode 100644 vendor/alibabacloud/oss-v2/sample/Uploader.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/AnnotationInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/Functions.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/RequiredProperty.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/TagBody.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/TagHeader.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/TagProperty.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/TagQuery.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/XmlElement.php create mode 100644 vendor/alibabacloud/oss-v2/src/Annotation/XmlRoot.php create mode 100644 vendor/alibabacloud/oss-v2/src/Client.php create mode 100644 vendor/alibabacloud/oss-v2/src/ClientExtensionTrait.php create mode 100644 vendor/alibabacloud/oss-v2/src/ClientImpl.php create mode 100644 vendor/alibabacloud/oss-v2/src/Config.php create mode 100644 vendor/alibabacloud/oss-v2/src/Copier.php create mode 100644 vendor/alibabacloud/oss-v2/src/Credentials/AnonymousCredentialsProvider.php create mode 100644 vendor/alibabacloud/oss-v2/src/Credentials/Credentials.php create mode 100644 vendor/alibabacloud/oss-v2/src/Credentials/CredentialsProvider.php create mode 100644 vendor/alibabacloud/oss-v2/src/Credentials/CredentialsProviderFunc.php create mode 100644 vendor/alibabacloud/oss-v2/src/Credentials/EnvironmentVariableCredentialsProvider.php create mode 100644 vendor/alibabacloud/oss-v2/src/Credentials/StaticCredentialsProvider.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/AesCtr.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipher.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipherBuilder.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/CipherData.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/CipherInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/ContentCipherInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/Envelope.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/LazyDecryptStream.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/MasterCipherInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/MasterRsaCipher.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/ReadDecryptStream.php create mode 100644 vendor/alibabacloud/oss-v2/src/Crypto/ReadEncryptStream.php create mode 100644 vendor/alibabacloud/oss-v2/src/Defaults.php create mode 100644 vendor/alibabacloud/oss-v2/src/Deserializer.php create mode 100644 vendor/alibabacloud/oss-v2/src/Downloader.php create mode 100644 vendor/alibabacloud/oss-v2/src/EncryptionClient.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/CopyException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/CredentialsException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/DeserializationExecption.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/DownloadException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/InconsistentExecption.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/OperationException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/ParserException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/SerializationExecption.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/ServiceException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/StreamRewindException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Exception/UploadException.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AbortMultipartUploadRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AbortMultipartUploadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessControlList.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessMonitorConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessMonitorStatusType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessPointEndpoints.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessPointVpcConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AccessPoints.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AppendObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AppendObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ApplyServerSideEncryptionByDefault.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ArchiveDirectReadConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Bucket.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketACLType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketCnameConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketInfo.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketLoggingStatus.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketResourceGroupConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketVersioningStatusType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/BucketWormStateType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CORSConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CORSRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CertificateConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CipherSuite.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CloseMetaQueryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CloseMetaQueryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CloudBox.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CloudBoxes.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Cname.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CnameCertificate.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CnameInfo.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CnameToken.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CommonPrefix.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUpload.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CopyObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CopyObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CopyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateAccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateBucketConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DataRedundancyType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Delete.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketCorsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketCorsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketDataRedundancyTransitionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketDataRedundancyTransitionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketEncryptionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketEncryptionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketInventoryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketInventoryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLifecycleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLifecycleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLoggingRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLoggingResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketOverwriteConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketOverwriteConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPolicyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPolicyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPublicAccessBlockRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPublicAccessBlockResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketReplicationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketReplicationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketTagsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketTagsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketWebsiteRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteBucketWebsiteResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteCnameRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteCnameResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteMarkerProperties.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteObject.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeletePublicAccessBlockRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeletePublicAccessBlockResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteStyleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteStyleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteUserDefinedLogFieldsConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeleteUserDefinedLogFieldsConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DeletedInfo.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/DownloadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/EncodeType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/EncryptionMultipartContext.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ErrorDocument.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ExtendWormConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetAccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetAccessPointRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetAccessPointResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketAclRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketAclResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketStatRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketStatResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketWormRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetBucketWormResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectAclRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectAclResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetPublicAccessBlockRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetPublicAccessBlockResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetStyleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetStyleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetSymlinkRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetSymlinkResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/HeadObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/HeadObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/HistoricalObjectReplicationType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/HttpsConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/IndexDocument.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InitiateWormConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryDestination.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryEncryption.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryFilter.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryFormatType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryFrequencyType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryOSSBucketDestination.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventoryOptionalFieldType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/InventorySchedule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleAbortMultipartUpload.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleExpiration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleFilter.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleNot.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleTransition.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListAccessPoints.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListBucketsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxes.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListCnameRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListCnameResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListInventoryConfigurationsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListObjectsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListObjectsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Request.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Result.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListPartsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListPartsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListStyleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListStyleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LocationRTCConstraint.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LocationTransferType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LocationTransferTypeConstraint.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LoggingEnabled.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LoggingHeaderSet.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/LoggingParamSet.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQuery.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddress.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddresses.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregation.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregations.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStream.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStreams.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryFile.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryFiles.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroup.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroups.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryMediaTypes.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryOrderType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryOssTagging.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryOssUserMeta.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryStatus.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitle.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitles.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryTagging.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryUserMeta.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStream.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStreams.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorAuth.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorHeaderSet.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorHeaders.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternate.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternates.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorReturnHeaders.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorTagging.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/MirrorTaggings.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionExpiration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionTransition.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ObjectACLType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ObjectIdentifier.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ObjectProperties.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ObjectVersionProperties.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OptionObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OptionObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OptionalFields.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OverwriteConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OverwritePrincipals.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/OverwriteRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Owner.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Part.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PolicyStatus.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PresignResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ProcessObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ProcessObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PublicAccessBlockConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketAccessMonitorRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketAccessMonitorResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketAclRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketAclResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketArchiveDirectReadRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketArchiveDirectReadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketCorsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketCorsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketEncryptionRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketEncryptionResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketHttpsConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketHttpsConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketInventoryRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketInventoryResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketLifecycleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketLifecycleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketLoggingRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketLoggingResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketOverwriteConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketOverwriteConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketPolicyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketPolicyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketPublicAccessBlockRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketPublicAccessBlockResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRefererRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRefererResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketReplicationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketReplicationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketResourceGroupRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketResourceGroupResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRtcRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketRtcResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketTagsRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketTagsResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketTransferAccelerationRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketTransferAccelerationResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketVersioningRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketVersioningResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketWebsiteRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutBucketWebsiteResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutCnameRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutCnameResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutObjectAclRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutObjectAclResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutStyleRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutStyleResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutSymlinkRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutSymlinkResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RefererBlacklist.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RefererConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RefererList.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RegionInfo.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationDestination.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationEncryptionConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationLocation.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationPrefixSet.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationProgress.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressInformation.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationRules.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationSourceSelectionCriteria.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReplicationTimeControl.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RequestPaymentConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RestoreObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RestoreObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RestoreRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ReturnHeader.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RoutingRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RoutingRuleCondition.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RoutingRuleIncludeHeader.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RoutingRuleLuaConfig.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RoutingRuleRedirect.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RoutingRules.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/RtcConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/SSEKMS.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRule.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRuleInfo.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/SseKmsEncryptedObjects.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/StatusType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/StorageClassType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/StyleContent.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/StyleInfo.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/StyleList.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/TLS.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Tag.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/TagSet.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Tagging.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/TransferAccelerationConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/TransferType.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/TransferTypes.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/Upload.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UploadPart.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UploadPartRequest.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UploadPartResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UploadResult.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/UserDefinedLogFieldsConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/VersioningConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/WebsiteConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Models/WormConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/src/OperationInput.php create mode 100644 vendor/alibabacloud/oss-v2/src/OperationOutput.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/ListBucketsPaginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/ListMultipartUploadsPaginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/ListObjectVersionsPaginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsPaginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsV2Paginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/ListPartsPaginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/Paginator/Paginator.php create mode 100644 vendor/alibabacloud/oss-v2/src/ProgressStream.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/BackoffDelayerInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/ClientErrorRetryable.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/EqualJitterBackoff.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/ErrorRetryableInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/FixedDelayBackoff.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/FullJitterBackoff.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/HTTPStatusCodeRetryable.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/NopRetryer.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/RetryerInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/ServiceErrorCodeRetryable.php create mode 100644 vendor/alibabacloud/oss-v2/src/Retry/StandardRetryer.php create mode 100644 vendor/alibabacloud/oss-v2/src/RetryMiddleware.php create mode 100644 vendor/alibabacloud/oss-v2/src/Serializer.php create mode 100644 vendor/alibabacloud/oss-v2/src/Signer/NopSigner.php create mode 100644 vendor/alibabacloud/oss-v2/src/Signer/SignerInterface.php create mode 100644 vendor/alibabacloud/oss-v2/src/Signer/SignerV1.php create mode 100644 vendor/alibabacloud/oss-v2/src/Signer/SignerV4.php create mode 100644 vendor/alibabacloud/oss-v2/src/Signer/SigningContext.php create mode 100644 vendor/alibabacloud/oss-v2/src/SinkStreamWrapper.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/AccessPoint.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketAccessMonitor.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketArchiveDirectRead.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketBasic.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketCname.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketCors.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketEncryption.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketHttpsConfig.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketInventory.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketLifecycle.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketLogging.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketMetaQuery.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketOverwriteConfig.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketPolicy.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketPublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketRedundancyTransition.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketReferer.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketReplication.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketRequestPayment.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketResourceGroup.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketStyle.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketTags.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketTransferAcceleration.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketWebsite.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/BucketWorm.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/CloudBoxes.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/Functions.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/ObjectBasic.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/ObjectMultipart.php create mode 100644 vendor/alibabacloud/oss-v2/src/Transform/PublicAccessBlock.php create mode 100644 vendor/alibabacloud/oss-v2/src/Types/Model.php create mode 100644 vendor/alibabacloud/oss-v2/src/Types/ModelTrait.php create mode 100644 vendor/alibabacloud/oss-v2/src/Types/RequestModel.php create mode 100644 vendor/alibabacloud/oss-v2/src/Types/ResultModel.php create mode 100644 vendor/alibabacloud/oss-v2/src/Uploader.php create mode 100644 vendor/alibabacloud/oss-v2/src/Utils.php create mode 100644 vendor/alibabacloud/oss-v2/src/Validation.php create mode 100644 vendor/alibabacloud/oss-v2/src/Version.php create mode 100644 vendor/alibabacloud/oss-v2/tests/Data/enc-example.jpg create mode 100644 vendor/alibabacloud/oss-v2/tests/Data/example.jpg create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientAccessPointTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketAccessMonitorTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketArchiveDirectReadTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketBasicTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCnameTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCorsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketDataRedundancyTransitionTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketEncryptionTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketHttpsConfigTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketInventoryTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLifecycleTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLoggingTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketMetaQueryTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketOverwriteTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPolicyTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPublicAccessBlockTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRefererTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketReplicationTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRequestPaymentTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketResourceGroupTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketStyleTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTagsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTransferAccelerationTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWebsiteTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWormTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientExtensionTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientListCloudBoxesTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientMiscTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectBasicTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectMultipartTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPaginatorTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPresignerTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPublicAccessBlockTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/EncryptionClientTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/IntegrationTests/TestIntegration.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/AnnotationTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/ModelObject.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/XmlObject.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/ClientImplTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Credentials/CredentialsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/AesCtrCipherTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/MasterRsaCipherTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/enc-example.jpg create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/example.jpg create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/DeserializerTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Exception/ExceptionTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeLackAnnotationXml.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeListXml.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeXml.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/DatetimeTypeXml.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeListXml.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeXml.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/NoRewindStream.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiARequest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBRequest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBResult.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiRequest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiResult.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RewindStatStream.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RootConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/SubConfiguration.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/BackoffTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/ErrorRetryableTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/RetryerTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/SerializerTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/NopSignerTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerContextTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV1Test.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV4Test.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/AccessPointTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketAccessMonitorTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketArchiveDirectReadTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketBasicTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCnameTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCorsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketEncryptionTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketHttpsConfigTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketInventoryTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLifecycleTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLoggingTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketMetaQueryTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketOverwriteConfigTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPolicyTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRedundancyTransitionTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRefererTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketReplicationTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRequestPaymentTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketResourceGroupTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketStyleTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTagsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTransferAccelerationTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWebsiteTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWormTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/CloudBoxesTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/FunctionsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectBasicTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectMultipartTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/PublicAccessBlockTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelA.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelPrivate.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/Types/XmlModelA.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/UtilsTest.php create mode 100644 vendor/alibabacloud/oss-v2/tests/UnitTests/ValidationTest.php create mode 100644 vendor/autoload.php create mode 100644 vendor/bin/var-dump-server create mode 100644 vendor/bin/var-dump-server.bat create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/InstalledVersions.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_files.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php create mode 100644 vendor/composer/installed.json create mode 100644 vendor/composer/installed.php create mode 100644 vendor/composer/platform_check.php create mode 100644 vendor/guzzlehttp/guzzle/CHANGELOG.md create mode 100644 vendor/guzzlehttp/guzzle/LICENSE create mode 100644 vendor/guzzlehttp/guzzle/README.md create mode 100644 vendor/guzzlehttp/guzzle/UPGRADING.md create mode 100644 vendor/guzzlehttp/guzzle/composer.json create mode 100644 vendor/guzzlehttp/guzzle/src/BodySummarizer.php create mode 100644 vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php create mode 100644 vendor/guzzlehttp/guzzle/src/Client.php create mode 100644 vendor/guzzlehttp/guzzle/src/ClientInterface.php create mode 100644 vendor/guzzlehttp/guzzle/src/ClientTrait.php create mode 100644 vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php create mode 100644 vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php create mode 100644 vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php create mode 100644 vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php create mode 100644 vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/ClientException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/RequestException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/ServerException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Exception/TransferException.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/Proxy.php create mode 100644 vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php create mode 100644 vendor/guzzlehttp/guzzle/src/HandlerStack.php create mode 100644 vendor/guzzlehttp/guzzle/src/MessageFormatter.php create mode 100644 vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php create mode 100644 vendor/guzzlehttp/guzzle/src/Middleware.php create mode 100644 vendor/guzzlehttp/guzzle/src/Pool.php create mode 100644 vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php create mode 100644 vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php create mode 100644 vendor/guzzlehttp/guzzle/src/RequestOptions.php create mode 100644 vendor/guzzlehttp/guzzle/src/RetryMiddleware.php create mode 100644 vendor/guzzlehttp/guzzle/src/TransferStats.php create mode 100644 vendor/guzzlehttp/guzzle/src/Utils.php create mode 100644 vendor/guzzlehttp/guzzle/src/functions.php create mode 100644 vendor/guzzlehttp/guzzle/src/functions_include.php create mode 100644 vendor/guzzlehttp/promises/CHANGELOG.md create mode 100644 vendor/guzzlehttp/promises/LICENSE create mode 100644 vendor/guzzlehttp/promises/README.md create mode 100644 vendor/guzzlehttp/promises/composer.json create mode 100644 vendor/guzzlehttp/promises/src/AggregateException.php create mode 100644 vendor/guzzlehttp/promises/src/CancellationException.php create mode 100644 vendor/guzzlehttp/promises/src/Coroutine.php create mode 100644 vendor/guzzlehttp/promises/src/Create.php create mode 100644 vendor/guzzlehttp/promises/src/Each.php create mode 100644 vendor/guzzlehttp/promises/src/EachPromise.php create mode 100644 vendor/guzzlehttp/promises/src/FulfilledPromise.php create mode 100644 vendor/guzzlehttp/promises/src/Is.php create mode 100644 vendor/guzzlehttp/promises/src/Promise.php create mode 100644 vendor/guzzlehttp/promises/src/PromiseInterface.php create mode 100644 vendor/guzzlehttp/promises/src/PromisorInterface.php create mode 100644 vendor/guzzlehttp/promises/src/RejectedPromise.php create mode 100644 vendor/guzzlehttp/promises/src/RejectionException.php create mode 100644 vendor/guzzlehttp/promises/src/TaskQueue.php create mode 100644 vendor/guzzlehttp/promises/src/TaskQueueInterface.php create mode 100644 vendor/guzzlehttp/promises/src/Utils.php create mode 100644 vendor/guzzlehttp/psr7/CHANGELOG.md create mode 100644 vendor/guzzlehttp/psr7/LICENSE create mode 100644 vendor/guzzlehttp/psr7/README.md create mode 100644 vendor/guzzlehttp/psr7/composer.json create mode 100644 vendor/guzzlehttp/psr7/src/AppendStream.php create mode 100644 vendor/guzzlehttp/psr7/src/BufferStream.php create mode 100644 vendor/guzzlehttp/psr7/src/CachingStream.php create mode 100644 vendor/guzzlehttp/psr7/src/DroppingStream.php create mode 100644 vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php create mode 100644 vendor/guzzlehttp/psr7/src/FnStream.php create mode 100644 vendor/guzzlehttp/psr7/src/Header.php create mode 100644 vendor/guzzlehttp/psr7/src/HttpFactory.php create mode 100644 vendor/guzzlehttp/psr7/src/InflateStream.php create mode 100644 vendor/guzzlehttp/psr7/src/LazyOpenStream.php create mode 100644 vendor/guzzlehttp/psr7/src/LimitStream.php create mode 100644 vendor/guzzlehttp/psr7/src/Message.php create mode 100644 vendor/guzzlehttp/psr7/src/MessageTrait.php create mode 100644 vendor/guzzlehttp/psr7/src/MimeType.php create mode 100644 vendor/guzzlehttp/psr7/src/MultipartStream.php create mode 100644 vendor/guzzlehttp/psr7/src/NoSeekStream.php create mode 100644 vendor/guzzlehttp/psr7/src/PumpStream.php create mode 100644 vendor/guzzlehttp/psr7/src/Query.php create mode 100644 vendor/guzzlehttp/psr7/src/Request.php create mode 100644 vendor/guzzlehttp/psr7/src/Response.php create mode 100644 vendor/guzzlehttp/psr7/src/Rfc7230.php create mode 100644 vendor/guzzlehttp/psr7/src/ServerRequest.php create mode 100644 vendor/guzzlehttp/psr7/src/Stream.php create mode 100644 vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php create mode 100644 vendor/guzzlehttp/psr7/src/StreamWrapper.php create mode 100644 vendor/guzzlehttp/psr7/src/UploadedFile.php create mode 100644 vendor/guzzlehttp/psr7/src/Uri.php create mode 100644 vendor/guzzlehttp/psr7/src/UriComparator.php create mode 100644 vendor/guzzlehttp/psr7/src/UriNormalizer.php create mode 100644 vendor/guzzlehttp/psr7/src/UriResolver.php create mode 100644 vendor/guzzlehttp/psr7/src/Utils.php create mode 100644 vendor/league/flysystem-local/FallbackMimeTypeDetector.php create mode 100644 vendor/league/flysystem-local/LICENSE create mode 100644 vendor/league/flysystem-local/LocalFilesystemAdapter.php create mode 100644 vendor/league/flysystem-local/composer.json create mode 100644 vendor/league/flysystem/INFO.md create mode 100644 vendor/league/flysystem/LICENSE create mode 100644 vendor/league/flysystem/composer.json create mode 100644 vendor/league/flysystem/readme.md create mode 100644 vendor/league/flysystem/src/CalculateChecksumFromStream.php create mode 100644 vendor/league/flysystem/src/ChecksumAlgoIsNotSupported.php create mode 100644 vendor/league/flysystem/src/ChecksumProvider.php create mode 100644 vendor/league/flysystem/src/Config.php create mode 100644 vendor/league/flysystem/src/CorruptedPathDetected.php create mode 100644 vendor/league/flysystem/src/DecoratedAdapter.php create mode 100644 vendor/league/flysystem/src/DirectoryAttributes.php create mode 100644 vendor/league/flysystem/src/DirectoryListing.php create mode 100644 vendor/league/flysystem/src/FileAttributes.php create mode 100644 vendor/league/flysystem/src/Filesystem.php create mode 100644 vendor/league/flysystem/src/FilesystemAdapter.php create mode 100644 vendor/league/flysystem/src/FilesystemException.php create mode 100644 vendor/league/flysystem/src/FilesystemOperationFailed.php create mode 100644 vendor/league/flysystem/src/FilesystemOperator.php create mode 100644 vendor/league/flysystem/src/FilesystemReader.php create mode 100644 vendor/league/flysystem/src/FilesystemWriter.php create mode 100644 vendor/league/flysystem/src/InvalidStreamProvided.php create mode 100644 vendor/league/flysystem/src/InvalidVisibilityProvided.php create mode 100644 vendor/league/flysystem/src/MountManager.php create mode 100644 vendor/league/flysystem/src/PathNormalizer.php create mode 100644 vendor/league/flysystem/src/PathPrefixer.php create mode 100644 vendor/league/flysystem/src/PathTraversalDetected.php create mode 100644 vendor/league/flysystem/src/PortableVisibilityGuard.php create mode 100644 vendor/league/flysystem/src/ProxyArrayAccessToProperties.php create mode 100644 vendor/league/flysystem/src/ResolveIdenticalPathConflict.php create mode 100644 vendor/league/flysystem/src/StorageAttributes.php create mode 100644 vendor/league/flysystem/src/SymbolicLinkEncountered.php create mode 100644 vendor/league/flysystem/src/UnableToCheckDirectoryExistence.php create mode 100644 vendor/league/flysystem/src/UnableToCheckExistence.php create mode 100644 vendor/league/flysystem/src/UnableToCheckFileExistence.php create mode 100644 vendor/league/flysystem/src/UnableToCopyFile.php create mode 100644 vendor/league/flysystem/src/UnableToCreateDirectory.php create mode 100644 vendor/league/flysystem/src/UnableToDeleteDirectory.php create mode 100644 vendor/league/flysystem/src/UnableToDeleteFile.php create mode 100644 vendor/league/flysystem/src/UnableToGeneratePublicUrl.php create mode 100644 vendor/league/flysystem/src/UnableToGenerateTemporaryUrl.php create mode 100644 vendor/league/flysystem/src/UnableToListContents.php create mode 100644 vendor/league/flysystem/src/UnableToMountFilesystem.php create mode 100644 vendor/league/flysystem/src/UnableToMoveFile.php create mode 100644 vendor/league/flysystem/src/UnableToProvideChecksum.php create mode 100644 vendor/league/flysystem/src/UnableToReadFile.php create mode 100644 vendor/league/flysystem/src/UnableToResolveFilesystemMount.php create mode 100644 vendor/league/flysystem/src/UnableToRetrieveMetadata.php create mode 100644 vendor/league/flysystem/src/UnableToSetVisibility.php create mode 100644 vendor/league/flysystem/src/UnableToWriteFile.php create mode 100644 vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php create mode 100644 vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php create mode 100644 vendor/league/flysystem/src/UnreadableFileEncountered.php create mode 100644 vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php create mode 100644 vendor/league/flysystem/src/UrlGeneration/PrefixPublicUrlGenerator.php create mode 100644 vendor/league/flysystem/src/UrlGeneration/PublicUrlGenerator.php create mode 100644 vendor/league/flysystem/src/UrlGeneration/ShardedPrefixPublicUrlGenerator.php create mode 100644 vendor/league/flysystem/src/UrlGeneration/TemporaryUrlGenerator.php create mode 100644 vendor/league/flysystem/src/Visibility.php create mode 100644 vendor/league/flysystem/src/WhitespacePathNormalizer.php create mode 100644 vendor/league/mime-type-detection/CHANGELOG.md create mode 100644 vendor/league/mime-type-detection/LICENSE create mode 100644 vendor/league/mime-type-detection/composer.json create mode 100644 vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php create mode 100644 vendor/league/mime-type-detection/src/ExtensionLookup.php create mode 100644 vendor/league/mime-type-detection/src/ExtensionMimeTypeDetector.php create mode 100644 vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php create mode 100644 vendor/league/mime-type-detection/src/FinfoMimeTypeDetector.php create mode 100644 vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php create mode 100644 vendor/league/mime-type-detection/src/MimeTypeDetector.php create mode 100644 vendor/league/mime-type-detection/src/OverridingExtensionToMimeTypeMap.php create mode 100644 vendor/php-curl-class/php-curl-class/CHANGELOG.md create mode 100644 vendor/php-curl-class/php-curl-class/LICENSE create mode 100644 vendor/php-curl-class/php-curl-class/README.md create mode 100644 vendor/php-curl-class/php-curl-class/SECURITY.md create mode 100644 vendor/php-curl-class/php-curl-class/composer.json create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/ArrayUtil.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/BaseCurl.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/CaseInsensitiveArray.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/Curl.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/Decoder.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/Encoder.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/MultiCurl.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/StringUtil.php create mode 100644 vendor/php-curl-class/php-curl-class/src/Curl/Url.php create mode 100644 vendor/psr/container/LICENSE create mode 100644 vendor/psr/container/README.md create mode 100644 vendor/psr/container/composer.json create mode 100644 vendor/psr/container/src/ContainerExceptionInterface.php create mode 100644 vendor/psr/container/src/ContainerInterface.php create mode 100644 vendor/psr/container/src/NotFoundExceptionInterface.php create mode 100644 vendor/psr/http-client/CHANGELOG.md create mode 100644 vendor/psr/http-client/LICENSE create mode 100644 vendor/psr/http-client/README.md create mode 100644 vendor/psr/http-client/composer.json create mode 100644 vendor/psr/http-client/src/ClientExceptionInterface.php create mode 100644 vendor/psr/http-client/src/ClientInterface.php create mode 100644 vendor/psr/http-client/src/NetworkExceptionInterface.php create mode 100644 vendor/psr/http-client/src/RequestExceptionInterface.php create mode 100644 vendor/psr/http-factory/LICENSE create mode 100644 vendor/psr/http-factory/README.md create mode 100644 vendor/psr/http-factory/composer.json create mode 100644 vendor/psr/http-factory/src/RequestFactoryInterface.php create mode 100644 vendor/psr/http-factory/src/ResponseFactoryInterface.php create mode 100644 vendor/psr/http-factory/src/ServerRequestFactoryInterface.php create mode 100644 vendor/psr/http-factory/src/StreamFactoryInterface.php create mode 100644 vendor/psr/http-factory/src/UploadedFileFactoryInterface.php create mode 100644 vendor/psr/http-factory/src/UriFactoryInterface.php create mode 100644 vendor/psr/http-message/CHANGELOG.md create mode 100644 vendor/psr/http-message/LICENSE create mode 100644 vendor/psr/http-message/README.md create mode 100644 vendor/psr/http-message/composer.json create mode 100644 vendor/psr/http-message/docs/PSR7-Interfaces.md create mode 100644 vendor/psr/http-message/docs/PSR7-Usage.md create mode 100644 vendor/psr/http-message/src/MessageInterface.php create mode 100644 vendor/psr/http-message/src/RequestInterface.php create mode 100644 vendor/psr/http-message/src/ResponseInterface.php create mode 100644 vendor/psr/http-message/src/ServerRequestInterface.php create mode 100644 vendor/psr/http-message/src/StreamInterface.php create mode 100644 vendor/psr/http-message/src/UploadedFileInterface.php create mode 100644 vendor/psr/http-message/src/UriInterface.php create mode 100644 vendor/psr/log/LICENSE create mode 100644 vendor/psr/log/README.md create mode 100644 vendor/psr/log/composer.json create mode 100644 vendor/psr/log/src/AbstractLogger.php create mode 100644 vendor/psr/log/src/InvalidArgumentException.php create mode 100644 vendor/psr/log/src/LogLevel.php create mode 100644 vendor/psr/log/src/LoggerAwareInterface.php create mode 100644 vendor/psr/log/src/LoggerAwareTrait.php create mode 100644 vendor/psr/log/src/LoggerInterface.php create mode 100644 vendor/psr/log/src/LoggerTrait.php create mode 100644 vendor/psr/log/src/NullLogger.php create mode 100644 vendor/psr/simple-cache/.editorconfig create mode 100644 vendor/psr/simple-cache/LICENSE.md create mode 100644 vendor/psr/simple-cache/README.md create mode 100644 vendor/psr/simple-cache/composer.json create mode 100644 vendor/psr/simple-cache/src/CacheException.php create mode 100644 vendor/psr/simple-cache/src/CacheInterface.php create mode 100644 vendor/psr/simple-cache/src/InvalidArgumentException.php create mode 100644 vendor/ralouphie/getallheaders/LICENSE create mode 100644 vendor/ralouphie/getallheaders/README.md create mode 100644 vendor/ralouphie/getallheaders/composer.json create mode 100644 vendor/ralouphie/getallheaders/src/getallheaders.php create mode 100644 vendor/services.php create mode 100644 vendor/symfony/deprecation-contracts/CHANGELOG.md create mode 100644 vendor/symfony/deprecation-contracts/LICENSE create mode 100644 vendor/symfony/deprecation-contracts/README.md create mode 100644 vendor/symfony/deprecation-contracts/composer.json create mode 100644 vendor/symfony/deprecation-contracts/function.php create mode 100644 vendor/symfony/polyfill-mbstring/LICENSE create mode 100644 vendor/symfony/polyfill-mbstring/Mbstring.php create mode 100644 vendor/symfony/polyfill-mbstring/README.md create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php create mode 100644 vendor/symfony/polyfill-mbstring/bootstrap.php create mode 100644 vendor/symfony/polyfill-mbstring/bootstrap80.php create mode 100644 vendor/symfony/polyfill-mbstring/composer.json create mode 100644 vendor/symfony/var-dumper/CHANGELOG.md create mode 100644 vendor/symfony/var-dumper/Caster/AddressInfoCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/AmqpCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ArgsStub.php create mode 100644 vendor/symfony/var-dumper/Caster/Caster.php create mode 100644 vendor/symfony/var-dumper/Caster/ClassStub.php create mode 100644 vendor/symfony/var-dumper/Caster/ConstStub.php create mode 100644 vendor/symfony/var-dumper/Caster/CurlCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/CutArrayStub.php create mode 100644 vendor/symfony/var-dumper/Caster/CutStub.php create mode 100644 vendor/symfony/var-dumper/Caster/DOMCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/DateCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/DoctrineCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/DsCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/DsPairStub.php create mode 100644 vendor/symfony/var-dumper/Caster/EnumStub.php create mode 100644 vendor/symfony/var-dumper/Caster/ExceptionCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/FFICaster.php create mode 100644 vendor/symfony/var-dumper/Caster/FiberCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/FrameStub.php create mode 100644 vendor/symfony/var-dumper/Caster/GdCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/GmpCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ImagineCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ImgStub.php create mode 100644 vendor/symfony/var-dumper/Caster/IntlCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/LinkStub.php create mode 100644 vendor/symfony/var-dumper/Caster/MemcachedCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/MysqliCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/OpenSSLCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/PdoCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/PgSqlCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/RdKafkaCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/RedisCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ReflectionCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ResourceCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/ScalarStub.php create mode 100644 vendor/symfony/var-dumper/Caster/SocketCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/SplCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/SqliteCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/StubCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/SymfonyCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/TraceStub.php create mode 100644 vendor/symfony/var-dumper/Caster/UninitializedStub.php create mode 100644 vendor/symfony/var-dumper/Caster/UuidCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/VirtualStub.php create mode 100644 vendor/symfony/var-dumper/Caster/XmlReaderCaster.php create mode 100644 vendor/symfony/var-dumper/Caster/XmlResourceCaster.php create mode 100644 vendor/symfony/var-dumper/Cloner/AbstractCloner.php create mode 100644 vendor/symfony/var-dumper/Cloner/ClonerInterface.php create mode 100644 vendor/symfony/var-dumper/Cloner/Cursor.php create mode 100644 vendor/symfony/var-dumper/Cloner/Data.php create mode 100644 vendor/symfony/var-dumper/Cloner/DumperInterface.php create mode 100644 vendor/symfony/var-dumper/Cloner/Internal/NoDefault.php create mode 100644 vendor/symfony/var-dumper/Cloner/Stub.php create mode 100644 vendor/symfony/var-dumper/Cloner/VarCloner.php create mode 100644 vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php create mode 100644 vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php create mode 100644 vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php create mode 100644 vendor/symfony/var-dumper/Command/ServerDumpCommand.php create mode 100644 vendor/symfony/var-dumper/Dumper/AbstractDumper.php create mode 100644 vendor/symfony/var-dumper/Dumper/CliDumper.php create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php create mode 100644 vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php create mode 100644 vendor/symfony/var-dumper/Dumper/DataDumperInterface.php create mode 100644 vendor/symfony/var-dumper/Dumper/HtmlDumper.php create mode 100644 vendor/symfony/var-dumper/Dumper/ServerDumper.php create mode 100644 vendor/symfony/var-dumper/Exception/ThrowingCasterException.php create mode 100644 vendor/symfony/var-dumper/LICENSE create mode 100644 vendor/symfony/var-dumper/README.md create mode 100644 vendor/symfony/var-dumper/Resources/bin/var-dump-server create mode 100644 vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css create mode 100644 vendor/symfony/var-dumper/Resources/functions/dump.php create mode 100644 vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js create mode 100644 vendor/symfony/var-dumper/Server/Connection.php create mode 100644 vendor/symfony/var-dumper/Server/DumpServer.php create mode 100644 vendor/symfony/var-dumper/Test/VarDumperTestTrait.php create mode 100644 vendor/symfony/var-dumper/VarDumper.php create mode 100644 vendor/symfony/var-dumper/composer.json create mode 100644 vendor/topthink/framework/.github/ISSUE_TEMPLATE/1-bug-report.yml create mode 100644 vendor/topthink/framework/.github/ISSUE_TEMPLATE/2-feature_request.md create mode 100644 vendor/topthink/framework/.github/ISSUE_TEMPLATE/3-custom.md create mode 100644 vendor/topthink/framework/.github/ISSUE_TEMPLATE/config.yml create mode 100644 vendor/topthink/framework/.github/workflows/build.yml create mode 100644 vendor/topthink/framework/.github/workflows/php-cs-fixer.yml create mode 100644 vendor/topthink/framework/CONTRIBUTING.md create mode 100644 vendor/topthink/framework/LICENSE.txt create mode 100644 vendor/topthink/framework/README.md create mode 100644 vendor/topthink/framework/composer.json create mode 100644 vendor/topthink/framework/logo.png create mode 100644 vendor/topthink/framework/phpunit.xml.dist create mode 100644 vendor/topthink/framework/src/helper.php create mode 100644 vendor/topthink/framework/src/lang/zh-cn.php create mode 100644 vendor/topthink/framework/src/think/App.php create mode 100644 vendor/topthink/framework/src/think/Cache.php create mode 100644 vendor/topthink/framework/src/think/Config.php create mode 100644 vendor/topthink/framework/src/think/Console.php create mode 100644 vendor/topthink/framework/src/think/Cookie.php create mode 100644 vendor/topthink/framework/src/think/Db.php create mode 100644 vendor/topthink/framework/src/think/Env.php create mode 100644 vendor/topthink/framework/src/think/Event.php create mode 100644 vendor/topthink/framework/src/think/Exception.php create mode 100644 vendor/topthink/framework/src/think/File.php create mode 100644 vendor/topthink/framework/src/think/Http.php create mode 100644 vendor/topthink/framework/src/think/Lang.php create mode 100644 vendor/topthink/framework/src/think/Log.php create mode 100644 vendor/topthink/framework/src/think/Manager.php create mode 100644 vendor/topthink/framework/src/think/Middleware.php create mode 100644 vendor/topthink/framework/src/think/Pipeline.php create mode 100644 vendor/topthink/framework/src/think/Request.php create mode 100644 vendor/topthink/framework/src/think/Response.php create mode 100644 vendor/topthink/framework/src/think/Route.php create mode 100644 vendor/topthink/framework/src/think/Service.php create mode 100644 vendor/topthink/framework/src/think/Session.php create mode 100644 vendor/topthink/framework/src/think/View.php create mode 100644 vendor/topthink/framework/src/think/cache/Driver.php create mode 100644 vendor/topthink/framework/src/think/cache/TagSet.php create mode 100644 vendor/topthink/framework/src/think/cache/driver/File.php create mode 100644 vendor/topthink/framework/src/think/cache/driver/Memcache.php create mode 100644 vendor/topthink/framework/src/think/cache/driver/Memcached.php create mode 100644 vendor/topthink/framework/src/think/cache/driver/Redis.php create mode 100644 vendor/topthink/framework/src/think/cache/driver/Wincache.php create mode 100644 vendor/topthink/framework/src/think/console/Command.php create mode 100644 vendor/topthink/framework/src/think/console/Input.php create mode 100644 vendor/topthink/framework/src/think/console/LICENSE create mode 100644 vendor/topthink/framework/src/think/console/Output.php create mode 100644 vendor/topthink/framework/src/think/console/Table.php create mode 100644 vendor/topthink/framework/src/think/console/bin/README.md create mode 100644 vendor/topthink/framework/src/think/console/bin/hiddeninput.exe create mode 100644 vendor/topthink/framework/src/think/console/command/Clear.php create mode 100644 vendor/topthink/framework/src/think/console/command/Help.php create mode 100644 vendor/topthink/framework/src/think/console/command/Lists.php create mode 100644 vendor/topthink/framework/src/think/console/command/Make.php create mode 100644 vendor/topthink/framework/src/think/console/command/RouteList.php create mode 100644 vendor/topthink/framework/src/think/console/command/RunServer.php create mode 100644 vendor/topthink/framework/src/think/console/command/ServiceDiscover.php create mode 100644 vendor/topthink/framework/src/think/console/command/VendorPublish.php create mode 100644 vendor/topthink/framework/src/think/console/command/Version.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Command.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Controller.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Event.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Listener.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Middleware.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Model.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Service.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Subscribe.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/Validate.php create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/command.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/controller.api.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/controller.plain.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/controller.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/event.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/listener.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/middleware.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/model.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/service.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/subscribe.stub create mode 100644 vendor/topthink/framework/src/think/console/command/make/stubs/validate.stub create mode 100644 vendor/topthink/framework/src/think/console/command/optimize/Route.php create mode 100644 vendor/topthink/framework/src/think/console/command/optimize/Schema.php create mode 100644 vendor/topthink/framework/src/think/console/input/Argument.php create mode 100644 vendor/topthink/framework/src/think/console/input/Definition.php create mode 100644 vendor/topthink/framework/src/think/console/input/Option.php create mode 100644 vendor/topthink/framework/src/think/console/output/Ask.php create mode 100644 vendor/topthink/framework/src/think/console/output/Descriptor.php create mode 100644 vendor/topthink/framework/src/think/console/output/Formatter.php create mode 100644 vendor/topthink/framework/src/think/console/output/Question.php create mode 100644 vendor/topthink/framework/src/think/console/output/descriptor/Console.php create mode 100644 vendor/topthink/framework/src/think/console/output/driver/Buffer.php create mode 100644 vendor/topthink/framework/src/think/console/output/driver/Console.php create mode 100644 vendor/topthink/framework/src/think/console/output/driver/Nothing.php create mode 100644 vendor/topthink/framework/src/think/console/output/formatter/Stack.php create mode 100644 vendor/topthink/framework/src/think/console/output/formatter/Style.php create mode 100644 vendor/topthink/framework/src/think/console/output/question/Choice.php create mode 100644 vendor/topthink/framework/src/think/console/output/question/Confirmation.php create mode 100644 vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php create mode 100644 vendor/topthink/framework/src/think/contract/LogHandlerInterface.php create mode 100644 vendor/topthink/framework/src/think/contract/ModelRelationInterface.php create mode 100644 vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php create mode 100644 vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php create mode 100644 vendor/topthink/framework/src/think/event/AppInit.php create mode 100644 vendor/topthink/framework/src/think/event/HttpEnd.php create mode 100644 vendor/topthink/framework/src/think/event/HttpRun.php create mode 100644 vendor/topthink/framework/src/think/event/LogRecord.php create mode 100644 vendor/topthink/framework/src/think/event/LogWrite.php create mode 100644 vendor/topthink/framework/src/think/event/RouteLoaded.php create mode 100644 vendor/topthink/framework/src/think/exception/ClassNotFoundException.php create mode 100644 vendor/topthink/framework/src/think/exception/ErrorException.php create mode 100644 vendor/topthink/framework/src/think/exception/FileException.php create mode 100644 vendor/topthink/framework/src/think/exception/Handle.php create mode 100644 vendor/topthink/framework/src/think/exception/HttpException.php create mode 100644 vendor/topthink/framework/src/think/exception/HttpResponseException.php create mode 100644 vendor/topthink/framework/src/think/exception/InvalidArgumentException.php create mode 100644 vendor/topthink/framework/src/think/exception/InvalidCacheException.php create mode 100644 vendor/topthink/framework/src/think/exception/RouteNotFoundException.php create mode 100644 vendor/topthink/framework/src/think/facade/App.php create mode 100644 vendor/topthink/framework/src/think/facade/Cache.php create mode 100644 vendor/topthink/framework/src/think/facade/Config.php create mode 100644 vendor/topthink/framework/src/think/facade/Console.php create mode 100644 vendor/topthink/framework/src/think/facade/Cookie.php create mode 100644 vendor/topthink/framework/src/think/facade/Env.php create mode 100644 vendor/topthink/framework/src/think/facade/Event.php create mode 100644 vendor/topthink/framework/src/think/facade/Lang.php create mode 100644 vendor/topthink/framework/src/think/facade/Log.php create mode 100644 vendor/topthink/framework/src/think/facade/Middleware.php create mode 100644 vendor/topthink/framework/src/think/facade/Request.php create mode 100644 vendor/topthink/framework/src/think/facade/Route.php create mode 100644 vendor/topthink/framework/src/think/facade/Session.php create mode 100644 vendor/topthink/framework/src/think/facade/View.php create mode 100644 vendor/topthink/framework/src/think/file/UploadedFile.php create mode 100644 vendor/topthink/framework/src/think/initializer/BootService.php create mode 100644 vendor/topthink/framework/src/think/initializer/Error.php create mode 100644 vendor/topthink/framework/src/think/initializer/RegisterService.php create mode 100644 vendor/topthink/framework/src/think/log/Channel.php create mode 100644 vendor/topthink/framework/src/think/log/ChannelSet.php create mode 100644 vendor/topthink/framework/src/think/log/driver/File.php create mode 100644 vendor/topthink/framework/src/think/log/driver/Socket.php create mode 100644 vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php create mode 100644 vendor/topthink/framework/src/think/middleware/CheckRequestCache.php create mode 100644 vendor/topthink/framework/src/think/middleware/FormTokenCheck.php create mode 100644 vendor/topthink/framework/src/think/middleware/LoadLangPack.php create mode 100644 vendor/topthink/framework/src/think/middleware/SessionInit.php create mode 100644 vendor/topthink/framework/src/think/response/File.php create mode 100644 vendor/topthink/framework/src/think/response/Html.php create mode 100644 vendor/topthink/framework/src/think/response/Json.php create mode 100644 vendor/topthink/framework/src/think/response/Jsonp.php create mode 100644 vendor/topthink/framework/src/think/response/Redirect.php create mode 100644 vendor/topthink/framework/src/think/response/View.php create mode 100644 vendor/topthink/framework/src/think/response/Xml.php create mode 100644 vendor/topthink/framework/src/think/route/Dispatch.php create mode 100644 vendor/topthink/framework/src/think/route/Domain.php create mode 100644 vendor/topthink/framework/src/think/route/Resource.php create mode 100644 vendor/topthink/framework/src/think/route/ResourceRegister.php create mode 100644 vendor/topthink/framework/src/think/route/Rule.php create mode 100644 vendor/topthink/framework/src/think/route/RuleGroup.php create mode 100644 vendor/topthink/framework/src/think/route/RuleItem.php create mode 100644 vendor/topthink/framework/src/think/route/RuleName.php create mode 100644 vendor/topthink/framework/src/think/route/Url.php create mode 100644 vendor/topthink/framework/src/think/route/dispatch/Callback.php create mode 100644 vendor/topthink/framework/src/think/route/dispatch/Controller.php create mode 100644 vendor/topthink/framework/src/think/service/ModelService.php create mode 100644 vendor/topthink/framework/src/think/service/PaginatorService.php create mode 100644 vendor/topthink/framework/src/think/service/ValidateService.php create mode 100644 vendor/topthink/framework/src/think/session/Store.php create mode 100644 vendor/topthink/framework/src/think/session/driver/Cache.php create mode 100644 vendor/topthink/framework/src/think/session/driver/File.php create mode 100644 vendor/topthink/framework/src/think/view/driver/Php.php create mode 100644 vendor/topthink/framework/src/tpl/think_exception.tpl create mode 100644 vendor/topthink/framework/tests/AppTest.php create mode 100644 vendor/topthink/framework/tests/CacheTest.php create mode 100644 vendor/topthink/framework/tests/ConfigTest.php create mode 100644 vendor/topthink/framework/tests/DbTest.php create mode 100644 vendor/topthink/framework/tests/DispatchTest.php create mode 100644 vendor/topthink/framework/tests/EnvTest.php create mode 100644 vendor/topthink/framework/tests/EventTest.php create mode 100644 vendor/topthink/framework/tests/HttpTest.php create mode 100644 vendor/topthink/framework/tests/InteractsWithApp.php create mode 100644 vendor/topthink/framework/tests/LogTest.php create mode 100644 vendor/topthink/framework/tests/MiddlewareTest.php create mode 100644 vendor/topthink/framework/tests/RouteTest.php create mode 100644 vendor/topthink/framework/tests/SessionTest.php create mode 100644 vendor/topthink/framework/tests/UrlRouteTest.php create mode 100644 vendor/topthink/framework/tests/ViewTest.php create mode 100644 vendor/topthink/framework/tests/bootstrap.php create mode 100644 vendor/topthink/think-container/.travis.yml create mode 100644 vendor/topthink/think-container/LICENSE create mode 100644 vendor/topthink/think-container/README.md create mode 100644 vendor/topthink/think-container/composer.json create mode 100644 vendor/topthink/think-container/phpunit.xml.dist create mode 100644 vendor/topthink/think-container/src/Container.php create mode 100644 vendor/topthink/think-container/src/Facade.php create mode 100644 vendor/topthink/think-container/src/exception/ClassNotFoundException.php create mode 100644 vendor/topthink/think-container/src/exception/FuncNotFoundException.php create mode 100644 vendor/topthink/think-container/tests/ContainerTest.php create mode 100644 vendor/topthink/think-container/tests/bootstrap.php create mode 100644 vendor/topthink/think-dumper/README.md create mode 100644 vendor/topthink/think-dumper/composer.json create mode 100644 vendor/topthink/think-dumper/phpunit.xml.dist create mode 100644 vendor/topthink/think-dumper/src/Connection.php create mode 100644 vendor/topthink/think-dumper/src/Dumper.php create mode 100644 vendor/topthink/think-dumper/src/ServerDumper.php create mode 100644 vendor/topthink/think-dumper/src/SourceContextProvider.php create mode 100644 vendor/topthink/think-dumper/src/helper.php create mode 100644 vendor/topthink/think-dumper/tests/DumperTest.php create mode 100644 vendor/topthink/think-dumper/tests/bootstrap.php create mode 100644 vendor/topthink/think-filesystem/README.md create mode 100644 vendor/topthink/think-filesystem/composer.json create mode 100644 vendor/topthink/think-filesystem/phpunit.xml.dist create mode 100644 vendor/topthink/think-filesystem/src/Filesystem.php create mode 100644 vendor/topthink/think-filesystem/src/facade/Filesystem.php create mode 100644 vendor/topthink/think-filesystem/src/filesystem/Driver.php create mode 100644 vendor/topthink/think-filesystem/src/filesystem/driver/Local.php create mode 100644 vendor/topthink/think-filesystem/tests/FilesystemTest.php create mode 100644 vendor/topthink/think-filesystem/tests/bootstrap.php create mode 100644 vendor/topthink/think-filesystem/tests/test.txt create mode 100644 vendor/topthink/think-helper/.github/workflows/ci.yml create mode 100644 vendor/topthink/think-helper/.github/workflows/php.yml create mode 100644 vendor/topthink/think-helper/LICENSE create mode 100644 vendor/topthink/think-helper/README.md create mode 100644 vendor/topthink/think-helper/composer.json create mode 100644 vendor/topthink/think-helper/phpunit.xml.dist create mode 100644 vendor/topthink/think-helper/src/Collection.php create mode 100644 vendor/topthink/think-helper/src/contract/Arrayable.php create mode 100644 vendor/topthink/think-helper/src/contract/Jsonable.php create mode 100644 vendor/topthink/think-helper/src/helper.php create mode 100644 vendor/topthink/think-helper/src/helper/Arr.php create mode 100644 vendor/topthink/think-helper/src/helper/Macroable.php create mode 100644 vendor/topthink/think-helper/src/helper/Str.php create mode 100644 vendor/topthink/think-helper/tests/ArrTest.php create mode 100644 vendor/topthink/think-helper/tests/CollectionTest.php create mode 100644 vendor/topthink/think-helper/tests/IsAssocTest.php create mode 100644 vendor/topthink/think-helper/tests/MergeDeepTest.php create mode 100644 vendor/topthink/think-helper/tests/StrTest.php create mode 100644 vendor/topthink/think-helper/tests/TestCase.php create mode 100644 vendor/topthink/think-multi-app/LICENSE create mode 100644 vendor/topthink/think-multi-app/README.md create mode 100644 vendor/topthink/think-multi-app/composer.json create mode 100644 vendor/topthink/think-multi-app/src/MultiApp.php create mode 100644 vendor/topthink/think-multi-app/src/Service.php create mode 100644 vendor/topthink/think-multi-app/src/Url.php create mode 100644 vendor/topthink/think-multi-app/src/command/Build.php create mode 100644 vendor/topthink/think-multi-app/src/command/Clear.php create mode 100644 vendor/topthink/think-multi-app/src/command/stubs/controller.stub create mode 100644 vendor/topthink/think-orm/.gitattributes create mode 100644 vendor/topthink/think-orm/LICENSE create mode 100644 vendor/topthink/think-orm/README.md create mode 100644 vendor/topthink/think-orm/composer.json create mode 100644 vendor/topthink/think-orm/src/DbManager.php create mode 100644 vendor/topthink/think-orm/src/Entity.php create mode 100644 vendor/topthink/think-orm/src/Model.php create mode 100644 vendor/topthink/think-orm/src/Paginator.php create mode 100644 vendor/topthink/think-orm/src/db/BaseBuilder.php create mode 100644 vendor/topthink/think-orm/src/db/BaseQuery.php create mode 100644 vendor/topthink/think-orm/src/db/Builder.php create mode 100644 vendor/topthink/think-orm/src/db/CacheItem.php create mode 100644 vendor/topthink/think-orm/src/db/Connection.php create mode 100644 vendor/topthink/think-orm/src/db/ConnectionInterface.php create mode 100644 vendor/topthink/think-orm/src/db/Express.php create mode 100644 vendor/topthink/think-orm/src/db/Fetch.php create mode 100644 vendor/topthink/think-orm/src/db/Mongo.php create mode 100644 vendor/topthink/think-orm/src/db/PDOConnection.php create mode 100644 vendor/topthink/think-orm/src/db/Query.php create mode 100644 vendor/topthink/think-orm/src/db/Raw.php create mode 100644 vendor/topthink/think-orm/src/db/Where.php create mode 100644 vendor/topthink/think-orm/src/db/builder/Mongo.php create mode 100644 vendor/topthink/think-orm/src/db/builder/Mysql.php create mode 100644 vendor/topthink/think-orm/src/db/builder/Oracle.php create mode 100644 vendor/topthink/think-orm/src/db/builder/Pgsql.php create mode 100644 vendor/topthink/think-orm/src/db/builder/Sqlite.php create mode 100644 vendor/topthink/think-orm/src/db/builder/Sqlsrv.php create mode 100644 vendor/topthink/think-orm/src/db/concern/AggregateQuery.php create mode 100644 vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php create mode 100644 vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php create mode 100644 vendor/topthink/think-orm/src/db/concern/ParamsBind.php create mode 100644 vendor/topthink/think-orm/src/db/concern/ResultOperation.php create mode 100644 vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php create mode 100644 vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php create mode 100644 vendor/topthink/think-orm/src/db/concern/Transaction.php create mode 100644 vendor/topthink/think-orm/src/db/concern/WhereQuery.php create mode 100644 vendor/topthink/think-orm/src/db/connector/Mongo.php create mode 100644 vendor/topthink/think-orm/src/db/connector/Mysql.php create mode 100644 vendor/topthink/think-orm/src/db/connector/Oracle.php create mode 100644 vendor/topthink/think-orm/src/db/connector/Pgsql.php create mode 100644 vendor/topthink/think-orm/src/db/connector/Sqlite.php create mode 100644 vendor/topthink/think-orm/src/db/connector/Sqlsrv.php create mode 100644 vendor/topthink/think-orm/src/db/connector/pgsql.sql create mode 100644 vendor/topthink/think-orm/src/db/connector/pgsql12.sql create mode 100644 vendor/topthink/think-orm/src/db/exception/BindParamException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/DbEventException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/DbException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/DuplicateException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/ModelEventException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/ModelNotFoundException.php create mode 100644 vendor/topthink/think-orm/src/db/exception/PDOException.php create mode 100644 vendor/topthink/think-orm/src/facade/Db.php create mode 100644 vendor/topthink/think-orm/src/helper.php create mode 100644 vendor/topthink/think-orm/src/model/Collection.php create mode 100644 vendor/topthink/think-orm/src/model/Pivot.php create mode 100644 vendor/topthink/think-orm/src/model/Relation.php create mode 100644 vendor/topthink/think-orm/src/model/View.php create mode 100644 vendor/topthink/think-orm/src/model/Virtual.php create mode 100644 vendor/topthink/think-orm/src/model/concern/Attribute.php create mode 100644 vendor/topthink/think-orm/src/model/concern/AutoWriteData.php create mode 100644 vendor/topthink/think-orm/src/model/concern/Conversion.php create mode 100644 vendor/topthink/think-orm/src/model/concern/DbConnect.php create mode 100644 vendor/topthink/think-orm/src/model/concern/ModelEvent.php create mode 100644 vendor/topthink/think-orm/src/model/concern/OptimLock.php create mode 100644 vendor/topthink/think-orm/src/model/concern/RelationShip.php create mode 100644 vendor/topthink/think-orm/src/model/concern/SoftDelete.php create mode 100644 vendor/topthink/think-orm/src/model/contract/EnumTransform.php create mode 100644 vendor/topthink/think-orm/src/model/contract/FieldTypeTransform.php create mode 100644 vendor/topthink/think-orm/src/model/contract/Modelable.php create mode 100644 vendor/topthink/think-orm/src/model/contract/Typeable.php create mode 100644 vendor/topthink/think-orm/src/model/relation/BelongsTo.php create mode 100644 vendor/topthink/think-orm/src/model/relation/BelongsToMany.php create mode 100644 vendor/topthink/think-orm/src/model/relation/HasMany.php create mode 100644 vendor/topthink/think-orm/src/model/relation/HasManyThrough.php create mode 100644 vendor/topthink/think-orm/src/model/relation/HasOne.php create mode 100644 vendor/topthink/think-orm/src/model/relation/HasOneThrough.php create mode 100644 vendor/topthink/think-orm/src/model/relation/MorphMany.php create mode 100644 vendor/topthink/think-orm/src/model/relation/MorphOne.php create mode 100644 vendor/topthink/think-orm/src/model/relation/MorphTo.php create mode 100644 vendor/topthink/think-orm/src/model/relation/MorphToMany.php create mode 100644 vendor/topthink/think-orm/src/model/relation/OneToOne.php create mode 100644 vendor/topthink/think-orm/src/model/type/Date.php create mode 100644 vendor/topthink/think-orm/src/model/type/DateTime.php create mode 100644 vendor/topthink/think-orm/src/model/type/Json.php create mode 100644 vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php create mode 100644 vendor/topthink/think-orm/stubs/Exception.php create mode 100644 vendor/topthink/think-orm/stubs/Facade.php create mode 100644 vendor/topthink/think-orm/stubs/load_stubs.php create mode 100644 vendor/topthink/think-template/LICENSE create mode 100644 vendor/topthink/think-template/README.md create mode 100644 vendor/topthink/think-template/composer.json create mode 100644 vendor/topthink/think-template/phpunit.xml create mode 100644 vendor/topthink/think-template/src/Template.php create mode 100644 vendor/topthink/think-template/src/facade/Template.php create mode 100644 vendor/topthink/think-template/src/template/TagLib.php create mode 100644 vendor/topthink/think-template/src/template/contract/DriverInterface.php create mode 100644 vendor/topthink/think-template/src/template/driver/File.php create mode 100644 vendor/topthink/think-template/src/template/exception/TemplateNotFoundException.php create mode 100644 vendor/topthink/think-template/src/template/taglib/Cx.php create mode 100644 vendor/topthink/think-template/tests/bootstrap.php create mode 100644 vendor/topthink/think-template/tests/tag/Demo.php create mode 100644 vendor/topthink/think-template/tests/template/extend.html create mode 100644 vendor/topthink/think-template/tests/template/fetch.html create mode 100644 vendor/topthink/think-template/tests/template/include.html create mode 100644 vendor/topthink/think-template/tests/template/layout.html create mode 100644 vendor/topthink/think-template/tests/think/TemplateTest.php create mode 100644 vendor/topthink/think-trace/LICENSE create mode 100644 vendor/topthink/think-trace/README.md create mode 100644 vendor/topthink/think-trace/composer.json create mode 100644 vendor/topthink/think-trace/src/Console.php create mode 100644 vendor/topthink/think-trace/src/Html.php create mode 100644 vendor/topthink/think-trace/src/Service.php create mode 100644 vendor/topthink/think-trace/src/TraceDebug.php create mode 100644 vendor/topthink/think-trace/src/config.php create mode 100644 vendor/topthink/think-trace/src/tpl/page_trace.tpl create mode 100644 vendor/topthink/think-validate/LICENSE create mode 100644 vendor/topthink/think-validate/README.md create mode 100644 vendor/topthink/think-validate/composer.json create mode 100644 vendor/topthink/think-validate/src/Validate.php create mode 100644 vendor/topthink/think-validate/src/contract/Enumable.php create mode 100644 vendor/topthink/think-validate/src/exception/ValidateException.php create mode 100644 vendor/topthink/think-validate/src/facade/Validate.php create mode 100644 vendor/topthink/think-validate/src/helper.php create mode 100644 vendor/topthink/think-validate/src/validate/ValidateRule.php create mode 100644 vendor/topthink/think-validate/src/validate/ValidateRuleSet.php create mode 100644 vendor/topthink/think-view/LICENSE create mode 100644 vendor/topthink/think-view/README.md create mode 100644 vendor/topthink/think-view/composer.json create mode 100644 vendor/topthink/think-view/src/Think.php diff --git a/.env b/.env new file mode 100644 index 0000000..e8d696f --- /dev/null +++ b/.env @@ -0,0 +1,12 @@ +APP_DEBUG = true +TCP_LOG_URL="121.40.192.142" +TCP_LOG_PORT=18001 +PROJECT_NAME="miniapi" +DEFAULT_LANG = zh-cn +SITE_DOMAIN = www.evus.cn +SITE_DOMAIN_BJ = www.evus.com.cn + +WECHAT_MINI_APPID = your_jinan_mini_appid +WECHAT_MINI_SECRET = your_jinan_mini_secret +WECHAT_MINI_APPID_BJ = wx72d43069c530ddb7 +WECHAT_MINI_SECRET_BJ = 1369ccf68a82005b3b6e94f5f95c6489 \ No newline at end of file diff --git a/.example.env b/.example.env new file mode 100644 index 0000000..d90c573 --- /dev/null +++ b/.example.env @@ -0,0 +1,17 @@ +APP_DEBUG = true +DB_TYPE = mysql +DB_HOST = 127.0.0.1 +DB_NAME = test +DB_USER = username +DB_PASS = password +DB_PORT = 3306 +DB_CHARSET = utf8 + +DEFAULT_LANG = zh-cn +SITE_DOMAIN = www.evus.cn +SITE_DOMAIN_BJ = www.evus.com.cn + +WECHAT_MINI_APPID = your_jinan_mini_appid +WECHAT_MINI_SECRET = your_jinan_mini_secret +WECHAT_MINI_APPID_BJ = your_beijing_mini_appid +WECHAT_MINI_SECRET_BJ = your_beijing_mini_secret diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d60af4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.idea +/doc +/runtime +/data diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36f7b6f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +sudo: false + +language: php + +branches: + only: + - stable + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + +install: + - composer install --no-dev --no-interaction --ignore-platform-reqs + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip . + - composer require --update-no-dev --no-interaction "topthink/think-image:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0" + - composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0" + - composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0" + - zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip . + +script: + - php think unit + +deploy: + provider: releases + api_key: + secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw= + file: + - ThinkPHP_Core.zip + - ThinkPHP_Full.zip + skip_cleanup: true + on: + tags: true diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..8d94897 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2025 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..05c7b83 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +![](https://www.thinkphp.cn/uploads/images/20230630/300c856765af4d8ae758c503185f8739.png) + +ThinkPHP 8 +=============== + +## 特性 + +* 基于PHP`8.0+`重构 +* 升级`PSR`依赖 +* 依赖`think-orm`3.0+版本 +* 全新的`think-dumper`服务,支持远程调试 +* 支持`6.0`/`6.1`无缝升级 + +> ThinkPHP8的运行环境要求PHP8.0+ + +现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习ThinkPHP的旅途中享受私人AI助理服务! + +![](https://www.topthink.com/uploads/assistant/20230630/4d1a3f0ad2958b49bb8189b7ef824cb0.png) + +ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。 + +## 文档 + +[完全开发手册](https://doc.thinkphp.cn) + + +## 赞助 + +全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及GIT仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障ThinkPHP的可持续发展。 + +[![](https://www.thinkphp.cn/sponsor/special.svg)](https://www.thinkphp.cn/sponsor/special) + +[![](https://www.thinkphp.cn/sponsor.svg)](https://www.thinkphp.cn/sponsor) + +## 安装 + +~~~ +composer create-project topthink/think tp +~~~ + +启动服务 + +~~~ +cd tp +php think run +~~~ + +然后就可以在浏览器中访问 + +~~~ +http://localhost:8000 +~~~ + +如果需要更新框架使用 +~~~ +composer update topthink/framework +~~~ + +## 命名规范 + +`ThinkPHP`遵循PSR-2命名规范和PSR-4自动加载规范。 + +## 参与开发 + +直接提交PR或者Issue即可 + +## 版权信息 + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 + +本项目包含的第三方源码和二进制文件之版权信息另行标注。 + +版权所有Copyright © 2006-2024 by ThinkPHP (http://thinkphp.cn) All rights reserved。 + +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +更多细节参阅 [LICENSE.txt](LICENSE.txt) diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/app/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/app/AppService.php b/app/AppService.php new file mode 100644 index 0000000..96556e8 --- /dev/null +++ b/app/AppService.php @@ -0,0 +1,22 @@ +app = $app; + $this->request = $this->app->request; + + // 控制器初始化 + $this->initialize(); + } + + // 初始化 + protected function initialize() + {} + + /** + * 验证数据 + * @access protected + * @param array $data 数据 + * @param string|array $validate 验证器名或者验证规则数组 + * @param array $message 提示信息 + * @param bool $batch 是否批量验证 + * @return array|string|true + * @throws ValidateException + */ + protected function validate(array $data, string|array $validate, array $message = [], bool $batch = false) + { + if (is_array($validate)) { + $v = new Validate(); + $v->rule($validate); + } else { + if (strpos($validate, '.')) { + // 支持场景 + [$validate, $scene] = explode('.', $validate); + } + $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); + $v = new $class(); + if (!empty($scene)) { + $v->scene($scene); + } + } + + $v->message($message); + + // 是否批量验证 + if ($batch || $this->batchValidate) { + $v->batch(true); + } + + return $v->failException(true)->check($data); + } + +} diff --git a/app/ExceptionHandle.php b/app/ExceptionHandle.php new file mode 100644 index 0000000..453d126 --- /dev/null +++ b/app/ExceptionHandle.php @@ -0,0 +1,58 @@ + [ + ], + + 'listen' => [ + 'AppInit' => [], + 'HttpRun' => [], + 'HttpEnd' => [], + 'LogLevel' => [], + 'LogWrite' => [], + ], + + 'subscribe' => [ + ], +]; diff --git a/app/lang/en-us.php b/app/lang/en-us.php new file mode 100644 index 0000000..b291133 --- /dev/null +++ b/app/lang/en-us.php @@ -0,0 +1,1058 @@ + [ + 'title' => 'EVUS Chinese Website_EVUS US Visa Registration_EVUS Registration Steps', + 'description' => 'EVUS,EVUS registration steps,EVUS system registration portal,what is EVUS,EVUS US visa registration,EVUS official website in Chinese', + 'keywords' => 'EVUS Chinese Website provides registration services for the new Electronic Visa Update System (EVUS). Offers EVUS official website queries, updates, EVUS system registration portal, EVUS registration steps and related information.', + 'footer_1' => 'Disclaimer: This website is a professionally registered and ICP-filed service platform dedicated to assisting individuals and businesses with travel authorization applications. Full refund for unsuccessful registrations (service fees non-refundable after approval). Disputes shall be arbitrated in the jurisdiction where our company is registered.', + 'footer_2' => 'ITS INTERNATIONAL TRAVEL SERVICE COMPANY Copyright © 2024-2025 All rights reservedben', + ], + 'menu_home' => 'HOME', + 'menu_apply' => 'ENROLL', + 'menu_search' => 'STATUS', + 'menu_us_apply' => 'VISA', + 'menu_esta_apply' => 'ESTA', + 'menu_help' => 'HELP', + 'menu_news' => 'NEWS', + 'menu_user' => 'ACCOUNT', + 'menu_company' => 'ABOUT', + 'user_my_order' => 'My Orders', + 'user_invoice' => 'Invoice', + 'user_multiple_invoice' => 'Combined Invoice', + 'user_logout' => 'Sign Out', + 'order_paid' => 'Paid', + 'order_unpaid' => 'Unpaid', + + 'index_title' => 'eVUS Registration Service in Chinese', + 'index_desc' => 'Click the registration button to complete the process easily', + 'index_button' => 'eVUS Registration', + 'index_step1' => 'Enter travel information', + 'index_step2' => '3-5 minutes entry', + 'index_step3' => 'Pay service fee', + 'index_step4' => 'Submit for review within 3-15 minutes', + 'index_step5' => 'Check registration status', + 'index_attention_tips' => 'Important Notice', + 'index_attention' => 'This is an independently operated commercial service platform featuring three core services: an intelligent form-filling system that streamlines the application process, precise OCR recognition for quick information extraction, and AI-powered multilingual translation. The website is registered, certified, and compliant with relevant authorities, providing professional paid services and is not affiliated with any government agency.', + 'index_price_1_1' => 'Express eVUS Registration', + 'index_price_1_2' => 'Precise OCR Recognition', + 'index_price_1_3' => 'Smart AI Translation', + 'index_price_1_4' => 'Submit within 6 hours', + 'index_price_2_1' => 'Professional eVUS Registration', + 'index_price_2_2' => 'Precise OCR Recognition', + 'index_price_2_3' => 'Smart AI Translation', + 'index_price_2_4' => 'Submit within 15 minutes', + 'index_service' => 'Our Services', + 'index_advantage' => 'Our Advantages', + 'index_advantage_1_title' => '24/7 Rapid Response', + 'index_advantage_1_content_1' => 'Airport expedited service designed for urgent travel needs', + 'index_advantage_1_content_2' => 'No lengthy queues - submissions processed in just 5-7 minutes upon airport arrival', + 'index_advantage_1_content_3' => 'Simplified procedures for quick clearance, eliminating missed flight risks', + 'index_advantage_2_title' => 'Intelligent Form System', + 'index_advantage_2_content_1' => 'Simplified Chinese form completion in just 5 minutes, significantly reducing language barriers', + 'index_advantage_2_content_2' => 'Dual verification by professionals ensures information accuracy, reducing rejection risks by 8x compared to self-filing (which typically takes 30-40 minutes)', + 'evus_pic' => '/new/assets/images/evus_en.png', + 'evusearch_pic' => '/new/assets/images/evusearch_en.png', + 'esta_pic' => '/new/assets/images/esta_en.png', + 'evus' => [ + 'other_country_acquired_other_required' => 'Please fill in "Others"', + 'other_country_acquired_other_label' => 'other', + 'add' => 'add', + 'delete' => 'delete', + 'title' => 'Travel Document Information', + 'passport_number_label' => 'Passport Number', + 'passport_placeholder' => 'Enter or upload photo', + 'passport_required' => 'Please enter passport number', + 'passport_upload_title' => 'Take photo/upload valid passport image', + 'passport_tooltip' => 'Passport numbers are usually 9 characters starting with G, E, EA, EB, or EC, except for official and diplomatic passports. Please carefully distinguish between number 1 and letter I, and number 0 and letter O.', + 'passport_hint' => 'Enter the passport number from the passport you will use for travel.', + 'passport_country_label' => 'Passport Country', + 'select_country_required' => 'Please select a country', + 'select_country_prompt' => 'Please select a country', + 'china' => 'China', + 'country_tooltip' => '', // Can add tooltip text if needed + 'country_hint' => 'Currently only citizens of the People\'s Republic of China are required to register for EVUS.', + 'pinyin' => 'Pinyin', + 'last_name_label' => 'Last Name', + 'last_name_placeholder' => 'Enter surname in pinyin', + 'last_name_required' => 'Please enter surname in pinyin', + 'last_name_tooltip' => 'Do not enter given name here. For compound surnames, follow passport information. If you have no surname, enter "UNKNOWN"', + 'last_name_hint' => 'Please enter your surname in English letters as shown on your passport', + 'first_name_label' => 'First Name', + 'first_name_placeholder' => 'Enter given name in pinyin', + 'first_name_required' => 'Please enter given name in pinyin', + 'first_name_tooltip' => 'Please enter your given name as shown on your passport. Do not enter surname here', + 'first_name_hint' => 'Enter your name exactly as it appears on your passport', + 'birth_date_label' => 'Date of Birth', + 'birth_date_placeholder' => 'Select date of birth', + 'birth_date_required' => 'Please select date of birth', + 'birth_date_tooltip' => 'Please enter your date of birth exactly as shown on your passport', + 'birth_city_label' => 'City of Birth', + 'birth_city_placeholder' => 'Enter city of birth', + 'birth_city_required' => 'Please enter city of birth', + 'birth_city_tooltip' => 'Please enter your place of birth as shown on your passport. ', + 'birth_country_label' => 'Country of Birth', + 'birth_country_tooltip' => 'Please select your country of birth as shown on your passport', + 'country_required' => 'Please select a country', + 'gender_label' => 'Gender', + 'male' => 'Male', + 'female' => 'Female', + 'passport_issue_date_label' => 'Passport Issue Date', + 'passport_issue_placeholder' => 'Select passport issue date', + 'passport_issue_required' => 'Please select passport issue date', + 'passport_issue_tooltip' => 'Please enter the date exactly as shown on your passport', + 'passport_expiry_label' => 'Passport Expiry Date', + 'passport_expiry_placeholder' => 'Select passport expiry date', + 'passport_expiry_required' => 'Please select passport expiry date', + 'passport_expiry_tooltip' => 'Please enter the date exactly as shown on your passport', + 'ten_year_visa_label' => 'Do you have a 10-year B1/B2/B1-B2 US visitor visa?', + 'ten_year_visa_hint' => 'Please confirm if you hold a 10-year US business/tourist (B1/B2/B1-B2) visa', + 'ten_year_visa_warning' => 'To register for EVUS, you must have a 10-year B1, B2 or B1/B2 US visitor visa. If you wish to travel to the US but don\'t have this type of visa, you must apply at a US embassy', + 'visa_number_label' => 'US B1/B2 Visa Number', + 'visa_number_placeholder' => 'Enter or upload photo', + 'visa_number_required' => 'Please enter visa number', + 'visa_number_tooltip' => 'Please enter the 8-digit red visa number from the bottom right of your US visa sticker', + 'upload_visa_title' => 'Take photo/upload valid passport photo', + 'visa_in_passport_label' => 'Is your US visa in your current passport?', + 'visa_in_passport_hint' => 'If your visa is in an old passport, select "No" and enter old passport information', + 'yes' => 'Yes', + 'no' => 'No', + 'old_passport_number_label' => 'Old Passport Number with US Visa', + 'enter_or_upload' => 'Enter or upload photo', + 'passport_number_required' => 'Please enter passport number', + 'upload_passport_photo' => 'Take photo/upload valid passport photo', + 'old_passport_tooltip' => 'Please enter the old passport number containing the US visa', + 'passport_country_tooltip' => 'Please select the issuing country of the old passport', + 'next_step' => 'Next Step', + 'other_citizenship_title' => 'Other Citizenships, Nationalities, Passports', + 'other_nationality_label' => 'Do you currently have another nationality?', + 'other_nationality_tooltip' => 'Please confirm if you have citizenship in any country other than China', + 'other_citizenship_current_label' => 'Current citizenship in other country', + 'other_citizenship_current_tooltip' => 'Select the country of your other citizenship. If you answered "Yes" above, this country must complete your application', + 'how_acquired_citizenship_label' => 'How did you acquire citizenship from this country?', + 'how_acquired_citizenship_tooltip' => 'Select how you obtained citizenship/nationality from this country', + 'past_nationality_label' => 'Have you ever had another nationality?', + 'past_nationality_tooltip' => 'Answering "Yes" to this question means you no longer have this nationality', + 'past_citizenship_label' => 'Past citizenship in other country', + 'past_citizenship_tooltip' => 'Please select the country name as shown in the birthplace field on your passport', + 'other_passport_label' => 'Have you ever had a passport or resident ID from another country?', + 'other_passport_tooltip' => 'Please confirm if you have a passport from a country other than China. If you have this document but have lost it or don\'t remember the number, you can enter "UNKNOWN"', + 'issuing_country_label' => 'Issuing Country', + 'issuing_country_tooltip' => 'Select the country of citizenship as it appears on your documents. The issuing country\'s documents are required to complete the application.', + 'document_type_label' => 'Document Type', + 'document_type_tooltip' => 'Please select the type of travel document issued by another country', + 'document_number_label' => 'Document Number', + 'document_number_placeholder' => 'Letters and numbers (enter 000000 if unavailable)', + 'document_number_tooltip' => 'Enter the document number as shown on your travel document. Travel documents may contain numbers and/or characters. Please carefully distinguish between the number zero and the letter O.', + 'expiry_year_label' => 'Expiry Year', + 'expiry_year_placeholder' => 'Select expiry year', + 'expiry_year_tooltip' => 'Please indicate the expiry year of your travel document issued by another country, even if it has expired.', + 'social_media_label' => 'Do you have social media accounts?', + 'social_media_tooltip' => 'Please indicate if you have social media accounts', + 'facebook_label' => 'Facebook', + 'facebook_placeholder' => 'Enter Facebook username', + 'facebook_tooltip' => 'If applicable, please enter your Facebook account name', + 'linkedin_label' => 'LinkedIn', + 'linkedin_placeholder' => 'Enter LinkedIn URL', + 'linkedin_tooltip' => 'If applicable, please enter your LinkedIn URL', + 'twitter_label' => 'Twitter', + 'twitter_placeholder' => 'Enter Twitter username', + 'twitter_tooltip' => 'If applicable, please enter your Twitter account name', + 'instagram_label' => 'Instagram', + 'instagram_placeholder' => 'Enter Instagram username', + 'instagram_tooltip' => 'If applicable, please enter your Instagram username', + 'platform_label' => 'Provider/Platform', + 'platform_tooltip' => 'If applicable, please select the provider/platform', + 'identifier_label' => 'Social Media Identifier', + 'identifier_placeholder' => 'Enter social media identifier', + 'identifier_tooltip' => 'If applicable, please enter your social media identifier', + 'alias_label' => 'Do you have any aliases?', + 'alias_tooltip' => 'Do you have any aliases', + 'alias_last_name_label' => 'Alias Last Name', + 'alias_last_name_placeholder' => 'Enter alias last name', + 'alias_last_name_tooltip' => 'Please enter your alias last name', + 'alias_last_name_hint' => 'Please enter your alias last name. Do not enter given name in this field.', + 'alias_first_name_label' => 'Alias First Name', + 'alias_first_name_placeholder' => 'Enter alias first name', + 'alias_first_name_tooltip' => 'Please enter your alias first name', + 'alias_first_name_hint' => 'Please enter your alias first name. Do not enter last name in this field.', + 'select_option_required' => 'Please select', + 'select_option_prompt' => 'Please select', + 'select_document_type_required' => 'Please select document type', + 'select_document_type_prompt' => 'Please select document type', + 'select_platform_required' => 'Please select provider/platform', + 'select_platform_prompt' => 'Please select provider/platform', + 'by_birth' => 'By birth', + 'by_parents' => 'Through parents', + 'naturalization' => 'Naturalization', + 'other' => 'Other', + 'passport_number' => 'Passport Number', + 'permanent_residence_id' => 'Permanent Residence ID (Green Card)', + 'address_contact_title' => 'Address and Contact Information', + 'id_card_instructions' => 'Enter the number or click [Camera] to recognize your valid ID card front photo; Uploading photos can automatically recognize and import your information.', + 'id_number_label' => 'ID Number', + 'id_number_required' => 'Please enter ID number', + 'upload_photo_title' => 'Take photo/upload valid photo', + 'id_number_tooltip' => 'Please enter 18-digit ID number. If you don\'t have an ID number, please enter "UNKNOWN".', + 'email_label' => 'Email (Optional)', + 'email_placeholder' => 'Recommended for receiving EVUS approval letter', + 'email_required' => 'Please enter email', + 'email_tooltip' => 'You will receive your application confirmation via email. Any status updates will also be notified by email.', + 'current_country_label' => 'Current Country', + 'current_country_tooltip' => 'Please select the country where you currently reside', + 'current_province_label' => 'Current Province/State', + 'current_province_placeholder' => 'Enter current province/state', + 'current_province_required' => 'Enter current province/state', + 'current_province_tooltip' => 'Please enter the province or state where you currently reside', + 'current_city_label' => 'Current City', + 'current_city_placeholder' => 'Enter current city', + 'current_city_required' => 'Enter current city', + 'current_city_tooltip' => 'Please enter the city where you currently reside', + 'current_address_label' => 'Current Address', + 'current_address_placeholder' => 'Enter current address', + 'current_address_required' => 'Enter current address', + 'current_address_tooltip' => 'Please enter your current detailed address', + 'phone_label' => 'Phone Number', + 'phone_placeholder' => 'Please enter phone number', + 'phone_tooltip' => 'Please enter a valid phone number', + 'parents_info_title' => 'Parents Information', + 'father_surname_label' => "Father's Surname", + 'father_surname_placeholder' => "Enter father's surname", + 'father_surname_required' => "Please enter father's surname", + 'father_surname_tooltip' => "Please enter the applicant's father's surname", + 'father_name_label' => "Father's Given Name", + 'father_name_placeholder' => "Enter father's given name", + 'father_name_required' => "Please enter father's given name", + 'father_name_tooltip' => "Please enter the applicant's father's given name", + 'mother_surname_label' => "Mother's Surname", + 'mother_surname_placeholder' => "Enter mother's surname", + 'mother_surname_required' => "Please enter mother's surname", + 'mother_surname_tooltip' => "Please enter the applicant's mother's surname", + 'mother_name_label' => "Mother's Given Name", + 'mother_name_placeholder' => "Enter mother's given name", + 'mother_name_required' => "Please enter mother's given name", + 'mother_name_tooltip' => "Please enter the applicant's mother's given name", + 'employment_info_title' => 'Employment Information', + 'has_employer_label' => 'Do you currently or previously have an employer?', + 'has_employer_tooltip' => 'If answering "Yes", please fill in employer information', + 'employer_country_label' => 'Employer Country', + 'employer_country_tooltip' => 'Please select the country where your employer is located from the list', + 'employer_state_label' => 'Employer State/Province', + 'employer_state_placeholder' => 'Enter employer state/province', + 'employer_state_required' => 'Please enter employer state/province', + 'employer_state_tooltip' => 'Recommended to enter in English or Pinyin. If unknown, enter "UNKNOWN"', + 'employer_city_label' => 'Employer City', + 'employer_city_placeholder' => 'Enter employer city', + 'employer_city_required' => 'Please enter employer city (do not include province)', + 'employer_city_tooltip' => 'Recommended to enter in English or Pinyin. If unknown, enter "UNKNOWN"', + 'employer_address_label' => 'Employer Address', + 'employer_address_placeholder' => 'Enter employer address', + 'employer_address_required' => 'Please enter employer address', + 'employer_address_tooltip' => 'Recommended to enter in English or Pinyin. Do not include province or city here. If unknown, enter "UNKNOWN"', + 'employer_name_label' => 'Employer Name', + 'employer_name_placeholder' => 'Enter employer name', + 'employer_name_required' => 'Employer name (max 30 characters)', + 'employer_name_tooltip' => 'Please enter employer name in English or Pinyin. If no employer, you may enter "Self-employed", "Homemaker", etc. to describe your employment status', + 'travel_info_title' => 'Travel Information', + 'transit_purpose_label' => 'Is your purpose for traveling to the US to transit to another country?', + 'transit_purpose_tooltip' => 'Please indicate if your trip to the US is solely for transit without staying. If "No", you may optionally provide US contact information.', + 'us_address_section_title' => 'US Address (Optional)', + 'us_contact_name_label' => 'Hotel name / Business associate / Relative or friend full name in US (Optional)', + 'us_contact_name_placeholder' => 'Should not contain numbers or special characters. Leave blank if unavailable', + 'us_contact_name_required' => 'Should not contain numbers or special characters. Leave blank if unavailable', + 'us_contact_name_tooltip' => 'Your US contact can be a friend, relative or business associate. If you don\'t have a US contact, enter the name, address and phone number of your accommodation (e.g. hotel name). You may also enter "UNKNOWN".', + 'us_state_label' => 'State (Optional)', + 'select_state_required' => 'Please select state', + 'select_state_prompt' => 'Please select state', + 'us_state_tooltip' => 'Please select the state where your US contact is located from the list. If unknown, select "Unknown"', + 'us_city_label' => 'City (Optional)', + 'us_city_placeholder' => 'Enter contact\'s city, do not include state', + 'us_city_required' => 'Enter contact\'s city, do not include state', + 'us_city_tooltip' => 'Please enter the city where your US contact is located. If unknown, enter "UNKNOWN".', + 'us_address_label' => 'Address (Optional)', + 'us_address_placeholder' => 'Enter contact\'s street address and number, do not include state or city', + 'us_address_required' => 'Enter contact\'s street address and number, do not include state or city', + 'us_address_tooltip' => 'Please enter your US contact\'s street address and number. Do not include state or city here. If unknown, enter "UNKNOWN".', + 'us_phone_label' => 'Phone Number (Optional)', + 'select_phone_prefix_prompt' => 'Select phone prefix', + 'us_phone_placeholder' => 'Enter phone number', + 'us_phone_tooltip' => 'Please enter your US contact\'s phone number. If unknown, enter "0".', + + 'emergency_contact_title' => 'Emergency Contact (Optional)', + 'emergency_last_name_label' => 'Last Name (Optional)', + 'emergency_last_name_placeholder' => 'Enter emergency contact last name', + 'emergency_last_name_required' => 'Enter emergency contact last name', + 'emergency_last_name_tooltip' => 'Please enter your emergency contact\'s last name. The emergency contact can be your contact in the US or another country, such as family member, friend or business partner. Leave blank if no emergency contact', + 'emergency_first_name_label' => 'First Name (Optional)', + 'emergency_first_name_placeholder' => 'Enter emergency contact first name', + 'emergency_first_name_required' => 'Enter emergency contact first name', + 'emergency_first_name_tooltip' => 'Please enter your emergency contact\'s first name. The emergency contact can be your contact in the US or another country, such as family member, friend or business partner. Leave blank if no emergency contact', + 'emergency_email_label' => 'Email (Optional)', + 'emergency_email_placeholder' => 'Enter emergency contact email', + 'emergency_email_required' => 'Enter emergency contact email', + 'emergency_email_tooltip' => 'Please enter your emergency contact\'s email. Leave blank if no emergency contact', + 'emergency_phone_label' => 'Phone Number (Optional)', + 'emergency_phone_placeholder' => 'Enter emergency contact phone number', + 'emergency_phone_tooltip' => 'Please enter your emergency contact\'s phone number. Enter 0 if no emergency contact', + + 'eligibility_question' => 'Eligibility Questions', + 'warning_cannot_continue' => 'Are you sure you want to answer "Yes" to this question? If your answer is "Yes", you will not be able to continue the online application.', + 'q_a' => 'Do you currently have any of the following diseases (communicable diseases as defined under Section 361(b) of the Public Health Service Act): cholera, diphtheria, tuberculosis, smallpox, yellow fever, viral hemorrhagic fevers including Ebola, Lassa, Marburg, Crimean-Congo hemorrhagic fever, or severe acute respiratory illnesses capable of spreading to others and likely to cause death?', + 'q_b' => 'Have you ever been arrested or convicted for a crime that caused serious damage to property, serious harm to another person, or serious harm to a government authority?', + 'q_c' => 'Have you ever violated any law related to possessing, using, or distributing illegal drugs?', + 'q_d' => 'Have you ever sought to engage in or have you ever engaged in terrorist activities, espionage, sabotage, or genocide?', + 'q_e' => 'Have you ever committed fraud or misrepresented yourself or others to obtain or assist others in obtaining a visa or entry into the United States?', + 'q_f' => 'Are you currently seeking employment in the United States, or have you ever worked in the United States without authorization?', + 'q_g' => 'Have you ever been denied a U.S. visa, refused admission to the United States, or withdrawn your application for admission at a U.S. port of entry?', + 'q_h' => 'Have you ever overstayed your authorized period of stay in the United States or otherwise violated the terms of a U.S. visa?', + 'q_i' => 'Since March 1, 2011, have you ever traveled to or been present in Iran, Iraq, Libya, North Korea, Somalia, Sudan, Syria, or Yemen?', + 'reject_date' => 'Date of Refusal', + 'reject_address' => 'Place of Refusal', + 'vist_country' => 'Country Visited', + 'vist_from_date' => 'Start Date', + 'vist_end_date' => 'End Date', + 'vist_country_des' => 'Primary Reason for Visit', + 'IRN' => 'Iran', + 'IRQ' => 'Iraq', + 'LBY' => 'Libya', + 'PRK' => 'North Korea', + 'SOM' => 'Somalia', + 'SDN' => 'Sudan', + 'SYR' => 'Syria', + 'YEM' => 'Yemen', + 'reason_1' => 'Tourism', + 'reason_2' => 'Visiting Family', + 'reason_3' => 'Employment', + 'reason_4' => 'Business', + 'reason_5' => 'Study', + 'reason_6' => 'Journalism', + 'reason_7' => 'Conference', + 'reason_8' => 'Cultural Exchange', + 'reason_9' => 'Religious Activities', + 'reason_10' => 'Medical Treatment', + 'reason_11' => 'Transit', + 'reason_12' => 'Diplomatic/Official', + 'reason_13' => 'Other', + 'declaration_title' => 'Applicant Declaration', + 'declaration_check1' => 'I declare that the information provided in this application is true, complete, and correct.', + 'declaration_check2' => 'I have read and understood ', + 'choose_package' => 'Select Package', + 'package_a' => 'Package A: 398 CNY / VIP Fast Registration (Complete information feedback in 15 minutes)', + 'package_b' => 'Package B: 98 CNY / Standard Registration (Complete information feedback in 6 hours)', + 'submit_now' => 'Submit Now', + 'termsCheckbox' => ' +
+

Terms and Conditions

+

+ The Electronic Visa Update System (EVUS) cross-references data with law enforcement databases. All travelers holding 10-year validity visitor visas (B1, B2, or B1/B2) must register on EVUS before traveling to the United States if entering as short-term visitors. + An approved EVUS registration indicates permission to travel to the U.S., but does not guarantee entry. Upon arrival at a U.S. port of entry, you will be inspected by a U.S. Customs and Border Protection officer, who will determine your admissibility under U.S. immigration laws. + All information provided by you or your designated third-party agent must be truthful and accurate. If you or your agent knowingly submit false, fictitious, or fraudulent statements during the application process, resulting in EVUS update failure or visa revocation, you will bear full responsibility. + Once submitted, information cannot be modified. Processing timelines depend on your selected service package. +

+

By proceeding, you confirm having read and understood the above information.

+ +

Privacy Policy

+

+ This application respects and protects the privacy of all users. To provide accurate and personalized services, we collect and use your personal information in accordance with this policy. We exercise high diligence in handling such information and will not disclose it to third parties without your prior consent, except as specified herein. This policy may be updated periodically. + Your agreement to our Terms of Service constitutes acceptance of this Privacy Policy, which forms an integral part thereof. + +

1. Scope

+

(a) Registration information provided when creating an account; + (b) Automatically collected data including IP address, browser type, language preferences, access times/dates, hardware/software characteristics, and visited pages; + (c) User data obtained through legitimate business partnerships. + Exclusions: + (a) Search query keywords; + (b) Public activity/transaction records within the platform; + (c) Information related to policy violations and enforcement actions.

+ +

2. Information Usage

+

(a) We will not share, sell, or trade your personal data with unrelated third parties without permission, except when collaborating with service providers (who will be prohibited from further use post-service). + (b) We prohibit third parties from collecting/exploiting user information. Violations will result in immediate account termination. + (c) We may use your information to deliver targeted content, including product/service announcements or (with consent) partner communications.

+ +

3. Disclosure

+

Your information may be disclosed: + (a) With your consent; + (b) When necessary for service fulfillment; + (c) As required by law or governmental/legal authorities; + (d) For investigating policy violations; + (e) To resolve intellectual property disputes; + (f) To facilitate transactions between users; + (g) Other legally permissible circumstances.

+ +

4. Data Storage

+

Collected information may be stored on servers located domestically or internationally, potentially outside your country of residence.

+ +

5. Cookies

+

(a) Cookies may be used to enhance personalized services unless disabled. + (b) You may refuse cookies via browser settings, though this may limit functionality. + (c) Cookie-derived data follows this policy.

+ +

6. Security

+

(a) Account credentials are encrypted, though no system is completely secure. + (b) Exercise caution when sharing personal data during transactions.

+ +

7. Policy Updates

+

(a) Changes will be published in prominent locations. + (b) We reserve modification rights. Material changes will be notified via platform announcements. + Immediately contact customer service if your login credentials are compromised.

+
+ ', + 'terms_privacy_title' => 'Terms and Conditions & Privacy Policy', + 'close' => 'Close' + ], + 'lookup' => [ + 'hot_price' => 'Popular packages', + 'status_check_title' => 'Check EVUS Status', + 'passport_number_label' => 'Passport Number', + 'enter_or_upload' => 'Enter or upload photo', + 'passport_number_required' => 'Please enter passport number', + 'upload_passport_photo' => 'Take/upload valid passport photo', + 'passport_number_tooltip' => 'Passport numbers usually start with G, E, EA, EB, or EC and are 9 characters long, except for official and diplomatic passports. Please carefully distinguish between number 1 and letter I, and number 0 and letter O.', + 'visa_number_label' => 'US B1/B2 Visa Number', + 'visa_number_required' => 'Please enter visa number', + 'visa_number_tooltip' => 'Please refer to your US visa sticker and enter the 8-digit red visa number at the bottom right.', + 'last_name_label' => 'Last Name', + 'pinyin' => 'Pinyin', + 'last_name_placeholder' => 'Enter surname in pinyin', + 'last_name_required' => 'Please enter surname', + 'last_name_tooltip' => 'Do not enter given name here. For compound surnames, follow passport information. If you have no surname, enter "UNKNOWN".', + 'last_name_hint' => 'Please enter your surname in English letters as shown on your passport', + 'first_name_label' => 'First Name', + 'first_name_placeholder' => 'Enter given name in pinyin', + 'first_name_required' => 'Please enter given name', + 'first_name_tooltip' => 'Please enter your given name as shown on your passport. Do not enter surname here.', + 'first_name_hint' => 'Enter your name exactly as it appears on your passport', + 'birth_date_label' => 'Date of Birth', + 'birth_date_placeholder' => 'Select date of birth', + 'birth_date_required' => 'Please select date of birth', + 'birth_date_tooltip' => 'Please enter your date of birth exactly as shown on your passport', + 'citizenship_label' => 'Country of Citizenship', + 'select_country_required' => 'Please select a country', + 'select_country_prompt' => 'Please select a country', + 'citizenship_tooltip' => 'Please select your country of birth as shown on your passport from the dropdown menu.', + 'terms_acceptance' => 'I have read and understood the Terms and Conditions and Privacy Policy.', + 'check_status_button' => 'Check Status', + 'status_registered' => 'Registered', + 'registered_description1' => '"Registered" EVUS status means the EVUS requirements have been met for travel to the United States 1) valid for two years from the date of registration approval, or 2) until the primary passport expires ("primary passport" is the passport used for registration that was valid and not expired at the time of registration application) or 3) until the visa expires, whichever comes first. This does not guarantee entry into the United States. U.S. Customs and Border Protection officers at U.S. ports of entry will make the final decision.', + 'registered_description2' => 'To access your EVUS registration application, you will be required to provide your enrollment application number, passport number, visa number, and date of birth. If necessary, you can update the following information in a successful registration: 1) U.S. address and 2) email address. If you need to change or update any other information on the form, you must apply for new travel authorization.', + 'registered_description3' => 'You have successfully submitted the registration application listed below. For your personal records, please print this page.', + 'status_pending' => 'Under Review', + 'pending_description' => 'Your information is being processed, please wait patiently!', + 'status_unsuccessful' => 'Registration Unsuccessful', + 'unsuccessful_description1' => 'Your EVUS registration was unsuccessful and you are currently not authorized to travel to the United States.', + 'unsuccessful_description2' => 'Common reasons for EVUS registration application failure include: you did not complete all required information; you did not provide correct information; you did not use a valid passport or U.S. visa to apply for registration, or other reasons.', + 'unsuccessful_description3' => 'For assistance, please call the EVUS Help Center at 400-0878-958. The help center is available 24 hours a day, 7 days a week to assist you with your EVUS enrollment.', + 'unsuccessful_description4' => 'You have successfully submitted the registration application listed below. For your personal records, please print this page.', + 'table_name' => 'Name', + 'table_birth_date' => 'Date of Birth', + 'table_enrollment_number' => 'Enrollment Number', + 'table_passport_number' => 'Passport Number', + 'table_visa_number' => 'B1/B2 Visa Number', + 'table_status' => 'Status', + 'table_expiry' => 'Expiry', + 'table_view' => 'View', + 'visa_services' => 'US Visa Services', + 'package1_title' => 'Package 1', + 'package1_price' => '¥198', + 'package1_feature1' => 'DS-160 English translation and completion', + 'package2_title' => 'Package 2', + 'package2_price' => '¥1998', + 'package2_feature1' => 'DS-160 English translation and completion', + 'package2_feature2' => 'Immediate interview appointment', + 'package2_feature3' => 'Includes visa fee', + 'package3_title' => 'Package 3 (Limited Time Offer)', + 'package3_price' => '¥2098¥2250', + 'package3_feature1' => 'DS-160 English translation and completion', + 'package3_feature2' => 'Immediate interview appointment', + 'package3_feature3' => 'Interview coaching', + 'package3_feature4' => 'Includes visa fee', + 'package4_title' => 'Package 4', + 'package4_price' => '¥209', + 'package4_feature1' => 'Interview waiver drop-off (visa renewal)', + 'package4_feature2' => 'DS-160 English translation and completion', + 'package4_feature3' => 'Immediate drop-off appointment', + 'package4_feature4' => 'Includes visa fee', + 'package4_feature5' => '(Purpose of visit explanation)', + ], + 'esta' => [ + 'notice' => 'Notice: You are applying for ESTA. If you hold a Chinese passport, please click to apply', + 'personal_details_title' => 'Personal Details', + 'passport_photo_label' => 'Passport Photo', + 'upload_instructions' => 'Click to upload or drag file here', + 'upload_success_alt' => 'Upload successful preview', + 'passport_photo_required' => 'Please upload passport photo', + 'passport_example_label' => 'Passport Example', + 'personal_photo_label' => 'Personal Photo', + 'personal_photo_required' => 'Please upload personal photo', + 'personal_photo_example_label' => 'Personal Photo Example', + 'last_name_label' => 'Last Name', + 'pinyin' => 'Pinyin', + 'last_name_placeholder' => 'Enter surname in pinyin', + 'last_name_required' => 'Please enter surname', + 'last_name_tooltip' => 'Do not enter given name here. For compound surnames, follow passport information. If you have no surname, enter "UNKNOWN".', + 'last_name_hint' => 'Please enter your surname in English letters as shown on your passport', + 'first_name_label' => 'First Name', + 'first_name_placeholder' => 'Enter given name in pinyin', + 'first_name_required' => 'Please enter given name', + 'first_name_tooltip' => 'Please enter your given name as shown on your passport. Do not enter surname here.', + 'first_name_hint' => 'Enter your name exactly as it appears on your passport', + 'birth_date_label' => 'Date of Birth', + 'birth_date_placeholder' => 'Select date of birth', + 'birth_date_required' => 'Please select date of birth', + 'birth_date_tooltip' => 'Please enter your date of birth exactly as shown on your passport', + 'birth_city_label' => 'City of Birth', + 'birth_city_placeholder' => 'Enter city of birth', + 'birth_city_required' => 'Please enter city of birth', + 'birth_city_tooltip' => 'Please enter your place of birth as shown on your passport. ', + 'birth_country_label' => 'Country of Birth', + 'select_country_required' => 'Please select a country', + 'select_country_prompt' => 'Please select a country', + 'birth_country_tooltip' => 'Please select your country of birth as shown on your passport from the dropdown menu.', + 'gender_label' => 'Gender', + 'male' => 'Male', + 'female' => 'Female', + 'id_number_label' => 'ID Number', + 'id_number_placeholder' => 'Enter ID number', + 'id_number_required' => 'Please enter ID number', + 'id_number_tooltip' => 'Please enter your national ID number. If you don\'t have one, enter "UNKNOWN"', + 'former_name_label' => 'Former Name (Optional)', + 'former_name_placeholder' => 'Enter former name', + 'former_name_required' => 'Please enter former name', + 'next_step' => 'Next Step', + 'travel_documents_title' => 'Travel Document Details', + 'passport_country_label' => 'Passport Country', + 'passport_number_label' => 'Passport Number', + 'passport_number_placeholder' => 'Enter passport number', + 'passport_number_required' => 'Please enter passport number', + 'passport_number_tooltip' => 'Passport numbers usually start with G, E, EA, EB or EC and are 9 characters long, except for official and diplomatic passports. Please carefully distinguish between number 1 and letter I, and number 0 and letter O.', + 'passport_issue_date_label' => 'Passport Issue Date', + 'passport_issue_date_placeholder' => 'Select passport issue date', + 'passport_issue_date_required' => 'Please select passport issue date', + 'passport_issue_date_tooltip' => 'Please enter the issue date exactly as shown on your passport', + 'passport_expiry_label' => 'Passport Expiry Date', + 'passport_expiry_placeholder' => 'Select passport expiry date', + 'passport_expiry_required' => 'Please select passport expiry date', + 'passport_expiry_tooltip' => 'Please enter the expiry date exactly as shown on your passport', + 'visa_number_label' => 'Visa Number (if applicable)', + 'visa_number_placeholder' => 'Enter visa number', + 'visa_number_required' => 'Please enter visa number', + 'other_citizenship_title' => 'Other Citizenships, Nationalities, Passports', + 'current_other_nationality_label' => 'Do you currently have another nationality?', + 'current_other_nationality_tooltip' => 'Please confirm if you have citizenship in any country other than China', + 'other_citizenship_current_label' => 'Current citizenship in other country', + 'other_citizenship_current_tooltip' => 'Select the country of your other citizenship. If you answered "Yes" above, this country must complete your application', + 'how_acquired_citizenship_label' => 'How did you acquire citizenship from this country?', + 'how_acquired_citizenship_tooltip' => 'Select how you obtained citizenship/nationality from this country', + 'past_other_nationality_label' => 'Have you ever had another nationality?', + 'past_other_nationality_tooltip' => 'Answering "Yes" to this question means you no longer have this nationality', + 'past_nationality_start_date_label' => 'Former nationality start date', + 'past_nationality_end_date_label' => 'Former nationality end date', + 'past_citizenship_label' => 'Past citizenship in other country', + 'past_citizenship_tooltip' => 'Please select the country name as shown in the birthplace field on your passport', + 'other_passport_label' => 'Have you ever had a passport or resident ID from another country?', + 'other_passport_tooltip' => 'Please confirm if you have a passport from a country other than China. If you have this document but have lost it or don\'t remember the number, you can enter "UNKNOWN"', + 'issuing_country_label' => 'Issuing Country', + 'issuing_country_tooltip' => 'Select the country of citizenship as it appears on your documents. The issuing country\'s documents are required to complete the application', + 'document_type_label' => 'Document Type', + 'document_type_tooltip' => 'Please select the type of travel document issued by another country', + 'document_number_label' => 'Document Number (Optional)', + 'document_number_placeholder' => 'Letters and numbers (enter 000000 if unavailable)', + 'document_number_required' => 'Please enter document number', + 'document_number_tooltip' => 'Enter the document number as shown on your travel document. Travel documents may contain numbers and/or characters. Please carefully distinguish between the number zero and the letter O', + 'expiry_year_label' => 'Expiry Year', + 'expiry_year_placeholder' => 'Select expiry year', + 'expiry_year_required' => 'Please select expiry year', + 'expiry_year_tooltip' => 'Please indicate the expiry year of your travel document issued by another country, even if it has expired', + 'select_option_required' => 'Please select', + 'select_option_prompt' => 'Please select', + 'select_document_type_required' => 'Please select document type', + 'select_document_type_prompt' => 'Please select document type', + 'select_date_required' => 'Please select date', + 'select_date_prompt' => 'Please select date', + 'passport_number' => 'Passport Number', + 'national_id' => 'National ID', + 'by_birth' => 'By birth', + 'by_parents' => 'Through parents', + 'naturalization' => 'Naturalization', + 'other' => 'Other', + 'yes' => 'Yes', + 'no' => 'No', + 'contact_information_title' => 'Contact Information', + 'email_label' => 'Email (Optional)', + 'email_placeholder' => 'Recommended for receiving ESTA approval letter', + 'email_required' => 'Please enter email', + 'email_tooltip' => 'You will receive your application confirmation via email. Any status updates will also be notified by email.', + 'confirm_email_label' => 'Confirm Email (Optional)', + 'confirm_email_placeholder' => 'Recommended for receiving ESTA approval letter', + 'confirm_email_required' => 'Please enter email', + 'confirm_email_tooltip' => 'You will receive your application confirmation via email. Any status updates will also be notified by email.', + 'phone_number_label' => 'Phone Number', + 'phone_number_placeholder' => 'Please enter phone number', + 'select_phone_prefix_prompt' => 'Select phone prefix', + 'address_details_title' => 'Address Details', + 'current_country_label' => 'Current Country', + 'current_province_label' => 'Current Province/State', + 'current_province_placeholder' => 'Enter current province/state', + 'current_province_required' => 'Please enter current province/state', + 'current_city_label' => 'Current City', + 'current_city_placeholder' => 'Enter current city', + 'current_city_required' => 'Please enter current city', + 'current_address_label' => 'Current Address', + 'current_address_placeholder' => 'Enter current address', + 'current_address_required' => 'Please enter current address', + + 'parents_info_title' => 'Parents Information', + 'father_surname_label' => "Father's Surname", + 'father_surname_placeholder' => "Enter father's surname", + 'father_surname_required' => "Please enter father's surname", + 'father_surname_tooltip' => "Please enter the applicant's father's surname", + 'father_name_label' => "Father's Given Name", + 'father_name_placeholder' => "Enter father's given name", + 'father_name_required' => "Please enter father's given name", + 'father_name_tooltip' => "Please enter the applicant's father's given name", + 'mother_surname_label' => "Mother's Surname", + 'mother_surname_placeholder' => "Enter mother's surname", + 'mother_surname_required' => "Please enter mother's surname", + 'mother_surname_tooltip' => "Please enter the applicant's mother's surname", + 'mother_name_label' => "Mother's Given Name", + 'mother_name_placeholder' => "Enter mother's given name", + 'mother_name_required' => "Please enter mother's given name", + 'mother_name_tooltip' => "Please enter the applicant's mother's given name", + 'employment_info_title' => 'Employment Information', + 'has_employer_label' => 'Do you currently or previously have an employer?', + 'has_employer_tooltip' => 'If answering "Yes", please fill in employer information', + 'employer_country_label' => 'Employer Country', + 'employer_country_tooltip' => 'Please select the country where your employer is located from the list', + 'employer_state_label' => 'Employer State/Province', + 'employer_state_placeholder' => 'Enter employer state/province', + 'employer_state_required' => 'Enter employer state/province', + 'employer_state_tooltip' => 'Recommended to enter in English or Pinyin. If unknown, enter "UNKNOWN"', + 'employer_city_label' => 'Employer City', + 'employer_city_placeholder' => 'Enter employer city', + 'employer_city_required' => 'Enter employer city (do not include province)', + 'employer_city_tooltip' => 'Recommended to enter in English or Pinyin. If unknown, enter "UNKNOWN"', + 'employer_address_label' => 'Employer Address', + 'employer_address_placeholder' => 'Enter employer address', + 'employer_address_required' => 'Enter employer address', + 'employer_address_tooltip' => 'Recommended to enter in English or Pinyin. Do not include province or city here. If unknown, enter "UNKNOWN"', + 'employer_name_label' => 'Employer Name', + 'employer_name_placeholder' => 'Enter employer name', + 'employer_name_required' => 'Employer name (max 30 characters)', + 'employer_name_tooltip' => 'Please enter employer name in English or Pinyin. If no employer, you may enter "Self-employed", "Homemaker", etc. to describe your employment status', + 'travel_info_title' => 'Travel Information', + 'transit_purpose_label' => 'Is your purpose for traveling to the US to transit to another country?', + 'transit_purpose_tooltip' => 'Please indicate if your trip to the US is solely for transit without staying. If "No", you may optionally provide US contact information', + 'us_address_section_title' => 'US Address (Optional)', + 'us_contact_name_label' => 'Hotel name / Business associate / Relative or friend full name in US (Optional)', + 'us_contact_name_placeholder' => 'Should not contain numbers or special characters. Leave blank if unavailable', + 'us_contact_name_required' => 'Should not contain numbers or special characters. Leave blank if unavailable', + 'us_contact_name_tooltip' => 'Your US contact can be a friend, relative or business associate. If you don\'t have a US contact, enter the name, address and phone number of your accommodation (e.g. hotel name). You may also enter "UNKNOWN"', + 'us_state_label' => 'State (Optional)', + 'select_state_required' => 'Please select state', + 'select_state_prompt' => 'Please select state', + 'us_state_tooltip' => 'Please select the state where your US contact is located from the list. If unknown, select "Unknown"', + 'us_city_label' => 'City (Optional)', + 'us_city_placeholder' => 'Enter contact\'s city, do not include state', + 'us_city_required' => 'Enter contact\'s city, do not include state', + 'us_city_tooltip' => 'Please enter the city where your US contact is located. If unknown, enter "UNKNOWN"', + 'us_address_label' => 'Address (Optional)', + 'us_address_placeholder' => 'Enter contact\'s street address and number, do not include state or city', + 'us_address_required' => 'Enter contact\'s street address and number, do not include state or city', + 'us_address_tooltip' => 'Please enter your US contact\'s street address and number. Do not include state or city here. If unknown, enter "UNKNOWN"', + 'us_phone_label' => 'Phone Number (Optional)', + 'us_phone_placeholder' => 'Enter phone number', + 'us_phone_tooltip' => 'Please enter your US contact\'s phone number. If unknown, enter "0"', + 'emergency_contact_title' => 'Emergency Contact (Optional)', + 'emergency_last_name_label' => 'Last Name (Optional)', + 'emergency_last_name_placeholder' => 'Enter emergency contact last name', + 'emergency_last_name_required' => 'Enter emergency contact last name', + 'emergency_last_name_tooltip' => 'Please enter your emergency contact\'s last name. The emergency contact can be your contact in the US or another country, such as family member, friend or business partner. Leave blank if no emergency contact', + 'emergency_first_name_label' => 'First Name (Optional)', + 'emergency_first_name_placeholder' => 'Enter emergency contact first name', + 'emergency_first_name_required' => 'Enter emergency contact first name', + 'emergency_first_name_tooltip' => 'Please enter your emergency contact\'s first name. The emergency contact can be your contact in the US or another country, such as family member, friend or business partner. Leave blank if no emergency contact', + 'emergency_email_label' => 'Email (Optional)', + 'emergency_email_placeholder' => 'Enter emergency contact email', + 'emergency_email_required' => 'Enter emergency contact email', + 'emergency_email_tooltip' => 'Please enter your emergency contact\'s email. Leave blank if no emergency contact', + 'emergency_phone_label' => 'Phone Number (Optional)', + 'emergency_phone_placeholder' => 'Enter emergency contact phone number', + 'emergency_phone_tooltip' => 'Please enter your emergency contact\'s phone number. Enter 0 if no emergency contact', + 'applicant_declaration_title' => 'Applicant Declaration', + 'declaration_statement' => 'I declare that the information provided in this application is true, complete and correct.', + 'terms_acceptance' => 'I have read and understood the Terms and Conditions and Privacy Policy.', + 'select_package_title' => 'Select Package', + 'package_a_option' => 'Package A: ¥958 (VIP Fast Registration - approval within 6 hours if documents are complete)', + 'package_b_option' => 'Package B: ¥495 (Standard Registration - approval within 48 hours if documents are complete)', + 'submit_application_button' => 'Submit Application', + 'eligibility_questions_title' => 'Eligibility Questions', + 'question_a_label' => 'Do you currently have any of the following diseases (Public Health Act Section 361(b))? Cholera, diphtheria, tuberculosis, plague, smallpox, yellow fever, viral hemorrhagic fevers including Ebola, Lassa, Marburg, Crimean-Congo hemorrhagic fever, severe acute respiratory syndromes that are communicable and potentially fatal', + 'question_b_label' => 'Have you ever been arrested or convicted for seriously damaging property or injuring others or government agencies?', + 'question_c_label' => 'Have you ever violated any laws involving possession, use or distribution of illegal drugs?', + 'question_d_label' => 'Have you attempted or engaged in terrorist activities, espionage, sabotage or genocide?', + 'question_e_label' => 'Have you ever committed fraud or falsified personal or others\' information to obtain a visa, assist others in obtaining a visa, or enter the United States?', + 'question_f_label' => 'Are you currently seeking work in the United States or have you ever worked in the United States without authorization from the U.S. government?', + 'question_g_label' => 'Have you ever been denied a U.S. visa using your current or previous passport? Or have you ever been denied entry to the United States or had your application rejected at a U.S. port of entry?', + 'question_h_label' => 'Have you ever stayed in the United States beyond the period of admission permitted by the U.S. government?', + 'question_i_label' => 'Have you ever been to Iraq, Syria, Iran or Sudan on or after March 1, 2011?', + 'eligibility_warning' => 'Are you sure you want to answer "Yes" to this question? If your answer is "Yes", you cannot continue with the online application.', + ], + 'pay' => [ + 'success_message' => 'Order submitted successfully. Please complete payment as soon as possible. Order number', + 'payment_amount' => 'Amount due', + 'order_success_message' => 'Your order has been submitted successfully. Order number: ', + 'notice_1' => '1. The information you provide must match your real information. This center is not responsible for any consequences caused by submitting false information.', + 'notice_3' => '2 Working hours: Monday to Sunday 09:00 - 22:00 (working on holidays). Applications submitted outside working hours will be automatically extended to the next working day. Thank you for your understanding.', + 'notice_4' => '3. After submission, we will review and verify your documents within the specified time. Please check your email. If it is not in your inbox, it may have been filtered to your spam folder.', + ], + 'jump' => [ + 'auto_redirect' => 'seconds remaining, redirecting', + 'redirect_now' => 'Redirect Now' + ], + 'js' => [ + 'daxie' => 'Please enter uppercase letters', + 'zhongwen' => 'Please enter Chinese characters', + 'len40' => 'Maximum 100 characters allowed', + 'required_field' => 'This field is required', + 'min_length' => 'Minimum %d characters required', + 'max_length' => 'Maximum %d characters allowed', + 'ppt_min' => 'Minimum 9 characters required', + 'ppt_max' => 'Maximum 9 characters allowed', + 'ppt_format' => 'Passport format should be one letter followed by at least 6 digits', + 'visa_min' => 'Minimum 8 characters required', + 'visa_max' => 'Maximum 8 characters allowed', + 'visa_format' => 'Invalid visa format', + 'default_reqtext' => 'Required field cannot be empty', + 'checkbox_checked' => 'Please select at least one option', + 'checkbox_required' => 'Please check the declaration', + 'english_only' => 'English letters only', + 'success_message' => 'Upload successful', + 'fail_message' => 'Upload failed: ', + 'error_message' => 'Upload error', + 'upload_image_only' => 'File must be an image', + 'browser_not_supported' => 'Your browser does not support upload', + 'visa_unrecognized' => 'Unrecognized, please enter visa number manually', + 'manual_entry_required' => 'Unrecognized, please enter manually', + 'upload_retry' => 'Please upload again', + 'status_enrolled' => 'Enrolled', + 'status_pending' => 'Under Review', + 'status_unsuccessful' => 'Unsuccessful Enrollment', + 'status_revoked' => 'Your visa has been revoked by DOS', + 'click_to_view' => 'Click to view' + ], + 'controller' => [ + 'success' => 'success', + 'fail' => 'fail', + 'price_error' => 'Price error', + 'server_error' => 'Server error', + 'no_registration_info' => 'No registration information found', + 'registration_expired' => 'The registration you are searching for has expired or been cancelled', + 'registration_success' => 'Registration successful', + 'registration_failed' => 'Unsuccessful registration', + 'registration_pending' => 'Registration in progress', + 'visa_revoked' => 'Your visa has been revoked', + 'missing_order_sn' => 'Missing order number, please fill in again', + 'order_not_exist' => 'Order number does not exist, please fill in again', + 'payment_success' => 'Payment successful', + 'parameter_error' => 'Parameter error', + 'payment_not_completed' => 'Payment not completed', + 'order_not_exist_retry' => 'Order number does not exist, please pay again', + 'payment_not_completed_retry' => 'Payment not completed, please try again', + ], + 'payment' => [ + 'select_payment_method' => 'Select Payment Method', + 'wechat_pay' => 'WeChat Pay', + 'alipay' => 'Alipay', + 'checkout' => 'checkout', + 'success' => 'Payment successful', + 'fail' => 'Payment failed' + ], + 'foot' => [ + 'user_agreement' => 'Terms of Service', + 'privacy_policy' => 'Privacy Policy', + 'disclaimer' => 'Disclaimer', + 'refund_policy' => 'Refund & Payment Policy', + 'cookie_policy' => 'Cookies Policy', + + 'user_agreement_info' => '
+ Please note: Using this website indicates that you have read, understood, and agreed to comply with all the following terms and conditions. If you do not agree to these terms, please do not use our services. +
+
+
+
+ 1 + Service Content +
+
+

Our company (ITS INTERNATIONAL TRAVEL SERVICE COMPANY) is a professional institution providing travel-related services, specializing in assisting clients with EVUS registration applications.

+
+

Important Note: Our company only provides form filling guidance, information review, and technical assistance services related to EVUS registration, and is not affiliated with any government agencies. Our services aim to help clients complete the application process more accurately and avoid common errors.

+
+

Our services include: assisting with filling out EVUS application forms, reviewing provided information, submitting applications to the official system, and providing necessary technical support during the application process. Please note that we cannot guarantee that the application will be approved, as the final decision rests entirely with U.S. Customs and Border Protection (CBP).

+
+
+ +
+
+ 2 + Fee Explanation +
+
+

Using our EVUS registration service requires payment of corresponding service fees, which do not include official application fees that may be charged by the U.S. government (if applicable).

+

Our service fee structure is clear and transparent. Users must pay the service fee according to the prices published on this website. Service fees may be adjusted without notice, but applications already started will be executed according to the fee standards applicable at the time of application initiation.

+
+

Fees include: application guidance services, information review services, technical support services, and subsequent application status inquiry assistance. All fees are clearly informed before the service begins, and users need to complete payment before continuing with the service.

+
+
+
+ +
+
+ 3 + User Responsibility +
+
+

When using this service, users are responsible for providing true, accurate, complete, and up-to-date personal information. This information includes but is not limited to: name, date of birth, passport information, visa information, and other data required for EVUS application.

+

Users should ensure that all provided materials are true and valid. If EVUS application fails, is delayed, or is rejected due to incorrect, incomplete, outdated, or misleading information provided by the user, our company shall not bear any responsibility.

+
+

User declares and guarantees: All provided information is true and accurate; has legal rights to provide this information; this information does not infringe upon any third-party rights; and using this service does not violate any applicable laws and regulations.

+
+
+
+ +
+
+ 4 + Company Liability Limitations +
+
+

Our company provides EVUS application assistance services, not official application channels. The outcome of EVUS registration is entirely determined by U.S. Customs and Border Protection (CBP), and our company cannot influence or control the approval results.

+

Therefore, our company does not assume any guarantees or promises regarding EVUS application results. Regardless of whether the application is successful or not, paid service fees are non-refundable as the service has been completed upon submission of the application.

+
+

Liability limitation: To the maximum extent permitted by law, our company and its employees and agents shall not be liable for any indirect, incidental, special, consequential damages, or loss of profits arising from the use of this service. Our maximum liability is limited to the amount of service fees paid by the user.

+
+
+
+ +
+
+ 5 + Dispute Resolution +
+
+

These service terms and any disputes arising from the use of this service shall be governed by the laws of California, USA, without regard to its conflict of law provisions.

+

Any disputes related to these service terms should first be resolved through friendly negotiation. If negotiation fails, both parties agree to submit the dispute to the competent court in Los Angeles County, California for resolution.

+
+

User agrees: Regardless of location, using this service indicates acceptance of the exclusive jurisdiction of California courts and waives any objections to the jurisdiction and venue of such courts.

+
+
+
+
', + + 'privacy_policy_info' => '
+

ITS INTERNATIONAL TRAVEL SERVICE COMPANY (hereinafter referred to as "the company", "we", "our") is firmly committed to regulatory compliance and the privacy and protection of personal data. Therefore, in this privacy policy, users (hereinafter referred to as "user", "you", "your") will find all relevant information to better understand how we process your personal data.

+ +

We may update this privacy policy based on new legislation or judicial requirements and/or business needs, etc. Any updates or modifications to this privacy policy will be considered applicable from the date of its publication on the website. Therefore, it is recommended that users regularly review this privacy policy.

+ +

Please remember that to access and use our website, you must be an adult and have the legal capacity to enter into contracts according to the national laws and regulations applicable in your country of birth or residence.

+ +

Without prejudice to your rights under applicable law, this privacy policy is not a contract or part of your contract with us. This privacy policy will always be available on this website so that data subjects can consult it at any time.

+
+ +
+

2. Definition of Personal Data

+

For the purposes of this privacy policy, "personal data" means all data that identifies a data subject or can be used to identify him/her, such as the data you provide when filling out the application form to obtain or update EVUS registration for travel to the United States. Additionally, we process your personal data when you contact our customer service team, as well as process other information provided during your browsing of this website or from your IP address.

+
+ +
+

3. Data Controller

+

Our company, as described in our terms and conditions, will be the controller of any personal data collected from you, including but not limited to, when you browse our website, fill out your application form to obtain or update EVUS registration, and/or when you contact our customer service team via email.

+
+ +
+

4. Scope of Application

+

This privacy policy applies to personal data we collect, use, and process from you as users of our website and/or customers.

+ +

Our website may contain features or links that may redirect you to third-party websites. In this case, please note that these third-party websites are not operated by us, so we are not responsible for the information and content they provide, nor for the correct provision of functions and/or services offered by these third parties as we cannot control this. These third-party websites are governed by their own cookie and privacy policies.

+
+ +
+

5. Information Collection

+

Our company may collect your name, passport information, contact details, and payment information, solely for EVUS registration services.

+ +

We collect the following categories of personal data:

+ +

1. Direct interactions, such as when you complete an application on our website to obtain or update EVUS registration, or when we request additional information from you as required by U.S. consulates or embassies, or when you fill out our contact form, or when you may contact our customer service team directly via email.

+

2. Automated technologies, we may automatically collect information such as your IP address, sections you consult on our website, or time spent on our website through the use of our own or third-party cookies. You can consult our Cookie Policy for more information about the use of cookies on our website, their purposes, and other information of interest.

+

3. Payment data, we will only request credit or debit card information related to our service fees on the payment page. The captured data will be securely sent to our certified payment service provider to authorize the corresponding transaction. Under no circumstances will we visualize or access the complete data of your credit or debit card. If the customer enters, provides, or sends his/her card information through channels not authorized by our company, the customer is responsible.

+
+

In all cases, we only process personal data necessary to achieve the purposes mentioned above. In this sense, if you provide us with information beyond what is explicitly requested, you consent to the processing of said information for the informed purpose for which you sent it.

+
+ +

To be able to properly use our services now and at any time thereafter, you must provide us with accurate, true, up-to-date, and complete information about your current personal situation.

+ +

If you provide us with personal data of third parties, whether minors or adults, you confirm that you have informed them of the purpose of processing their personal data, and you guarantee that you have obtained their prior explicit consent to communicate their personal data to us. In this sense, if you provide us with personal data of minors, you guarantee that you are the parent and/or legal guardian, and therefore, you agree to the processing of your child/wards personal data.

+
+

6. Information Usage

+

Your information is only used for processing EVUS registration and customer service, and will not be sold or shared without authorization.

+ +

Please note that you only need to provide the personal data and information necessary to fill out the application form you selected to obtain and/or through our contact form. In this sense, if you provide us with information beyond what is explicitly requested, it means you consent to its processing for the purpose for which you sent the information.

+ +

We use your personal data for the following purposes:

+ + +
+ + + +
+

8. Data Retention

+

Information will be stored on secure servers for a period not exceeding 12 months after application completion.

+ +

We will only retain your personal data for the time necessary to achieve its processing purposes. Beyond that, your personal data will be retained and appropriately blocked until the company complies with its legal obligations and has satisfied its business needs, objectives, and strategies. In this sense, your personal data will be retained, for example, to address and defend any claims related to the services provided; until your information and/or refund requests are answered; complete investigations of detected fraudulent or illegal activities; if you do not revoke your consent, we will retain cookie data.

+ +

Once the necessary retention period ends, your personal data will be securely deleted from our information systems.

+ +

Furthermore, if you consent to us processing your personal data for specific purposes, please note that you can withdraw this consent at any time. Upon receiving your withdrawal request, we will proceed to delete your personal data.

+
+ +
+

9. Data Sharing

+

When necessary, we may share your information with payment service providers or the EVUS system.

+ +

We may communicate your personal data to the following third parties, including but not limited to:

+ + + +

The headquarters of the aforementioned third parties may be located within the European Economic Area; therefore, your personal data will not be subject to international transfer. In this regard, we inform you that we will only make international transfers of personal data to recipients established in countries that provide an adequate level of data protection; otherwise, we will adopt appropriate safeguards required by current applicable laws and regulations regarding the protection of personal data to ensure that your personal data is properly protected and your personal rights and freedoms are guaranteed.

+
+ +
+

10. Data Security

+

Your trust is very important to us. Therefore, your personal data will be stored confidentially and securely in our information systems. We have implemented appropriate technical and organizational measures to protect and safeguard your personal data against illegal or unauthorized access, loss or accidental destruction, damage, use, and illegal or unauthorized disclosure.

+ +

Similarly, we have taken reasonable precautions to ensure that all our employees and vendors or collaborators who have access to customers personal data are adequately trained in the processing of collected personal data and that they comply with the aforementioned data protection obligations.

+ +

Although we will do our best to guarantee the protection of personal data transmitted through our website and/or that you may provide to us through other means such as email, please remember that you should also take precautions to keep your personal data secure, for example, you must not enter or confirm banking details through false information and/or websites.

+
+ +
+

11. User Rights

+

You have the right to request to view, correct, or delete your personal information.

+ +

You can exercise your rights through our contact form. You can modify the "privacy settings" of your web browser at any time to set tracking cookies. Additionally, you can install programs or plugins in your browser, known as "Do Not Track" tools, which will allow you to choose which cookies you want to allow.

+ +

Generally, we respond to data protection rights requests within one (1) month. Sometimes, this period may be extended by another two (2) months if necessary, considering whether your request is particularly complex or if you have made multiple requests. In this case, we will notify you of this event and explain the reason for the delay.

+ +

Finally, we inform you that, where you deem appropriate, you have the right to file a complaint with the corresponding regulatory authority, especially if you believe that your data protection rights have not been adequately addressed.

+
+ +
+

12. Cookie Policy

+

Unless you refuse to accept cookies, this application will set or access cookies on your computer to allow you to log in or use this applications platform services or features that rely on cookies. This application uses cookies to provide you with more comprehensive personalized services, including promotional services.

+ +

You have the right to choose to accept or refuse cookies. You can refuse to accept cookies by modifying your browser settings. However, if you choose to refuse cookies, you may not be able to log in or use this applications web services or features that rely on cookies.

+ +

Information obtained through cookies set by this application will be subject to this policy.

+
+ +
+

13. Policy Updates

+

If we decide to change the privacy policy, we will publish these changes in this policy, on our companys website, and in locations we deem appropriate so that you are aware of how we collect and use your personal information, who can access this information, and under what circumstances we disclose it.

+ +

Our company reserves the right to modify this policy at any time, so please check it frequently. If significant changes are made to this policy, our company will inform you through website notifications.

+
+ +
+

14. Contact Us

+
+

If you have any questions or concerns about this privacy policy, you can contact our customer service team.

+

If you discover that your personal information has been leaked, especially if your application username and password have been compromised, please immediately contact our application customer service so that we can take appropriate measures.

+
+
', + + 'disclaimer_info' => '
+
+

1. Non-Official Nature Statement

+

This website is not an official U.S. government website, nor is it affiliated with U.S. Customs and Border Protection (CBP). We are an independent service provider specializing in assisting applicants with the EVUS registration process.

+
+ +
+

2. Service Scope Explanation

+

ITS INTERNATIONAL TRAVEL SERVICE COMPANY only provides EVUS form filling assistance and related technical support services. We do not make any guarantees or promises regarding the final approval results, as the approval authority rests entirely with relevant U.S. government departments.

+
+ +
+

3. Approval Authority Statement

+

Whether an EVUS application is approved is entirely determined by relevant U.S. government departments. We cannot influence or expedite the approval process. Our services are limited to assisting you in correctly completing and submitting application forms.

+
+ +
+

Using this service indicates that you have read, understood, and agreed to the above disclaimer.

+
+
+ ', + + 'refund_policy_info' => '

1. Payment Methods

(a) Our company accepts various payment methods including credit cards, debit cards, PayPal, and more

(b) All payment transactions are processed through secure encryption to protect your funds

2. Refunds and Payments

+

(a) Before submission, users can request a refund, which will be processed within 7-14 business days

+

(b) Once the application is submitted to the EVUS system, fees are non-refundable as the service has been actually provided

+

(c) In case of system issues such as duplicate charges, full refund will be issued after verification

+ +

3. Service Failure

+

(a) If the application fails due to inaccurate or incomplete information provided by the user, our company will not refund

+

(b) If the application fails due to U.S. government system issues, partial refund can be applied for with corresponding proof

+

(c) If the application fails due to our companys technical issues, full refund will be issued or the application will be resubmitted

+ ', + + 'cookie_policy_info' => '
+ +
' + + ] +]; diff --git a/app/lang/zh-cn.php b/app/lang/zh-cn.php new file mode 100644 index 0000000..ac7566c --- /dev/null +++ b/app/lang/zh-cn.php @@ -0,0 +1,911 @@ + [ + 'title' => 'EVUS中文网_evus美国签证登记_evus登记步骤', + 'description' => 'evus,evus登记步骤,evus系统登记入口,evus是什么,evus美国签证登记,evus官网中文', + 'keywords' => 'EVUS中文网为您提供申请登记新的签证更新电子系统(EVUS)。提供evus官网查询、更新、evus系统登记入口、evus登记步骤等相关信息。', + 'footer_1' => '声明:本网站是经工商注册、工信部备案的专业服务站点,本网站致力于协助个人或者企业获得他们得旅行许可或短时间的入境停留。登记不成功全额退费,登记成功服务费用不退。纠纷解决,适用本网站所属机构注册地仲裁委员会管辖', + 'footer_2' => 'ITS INTERNATIONAL TRAVEL SERVICE COMPANY Copyright © 2014-2025 All rights reserved', + ], + 'menu_home' => '首页', + 'menu_apply' => 'EVUS登记', + 'menu_search' => '查询EVUS状态', + 'menu_us_apply' => '美签申请', + 'menu_esta_apply' => 'ESTA申请', + 'menu_help' => '使用帮助', + 'menu_user' => '个人中心', + 'menu_news' => '新闻资讯', + 'menu_company' => '关于我们', + 'user_my_order' => '我的订单', + 'user_invoice' => '自助开票', + 'user_multiple_invoice' => '合并开票', + 'user_logout' => '退出', + 'order_paid' => '已支付', + 'order_unpaid' => '未支付', + 'index_title' => 'eVUS中文办理登记', + 'index_desc' => '点击登记按钮,轻松完成办理', + 'index_button' => 'eVUS登记', + 'index_step1' => '填写旅行信息', + 'index_step2' => '3-5分钟信息录入', + 'index_step3' => '支付服务费', + 'index_step4' => '3-15分钟内递交', + 'index_step5' => '查询登记结果', + 'index_attention_tips' => '请注意', + 'index_attention_1' => '根据美国海关和边境保护局(CBP)规定,自2025年9月30日起,eVUS登记将收取30美元官方费用。', + 'index_attention_2' => '本网站为独立运营的商务服务平台,凭借自主研发的智能系统,带来三大核心服务:智能填表系统可高效简化表单填写流程,精准 OCR 识别能快速提取图文信息,智能 AI 翻译则支持多语种精准转换。网站经相关机构注册、登记和备案后上线运营,专注为用户提供专业有偿服务,不隶属于任何政府部门。', + 'index_attention_3' => '登记成功,所有费用不予退还;若登记未成功,官方登记费无法退回,但我们承诺全额退还服务费。', + 'index_price_1_1' => 'eVUS快速登记', + 'index_price_1_2' => '精准OCR识别', + 'index_price_1_3' => '智能AI翻译', + 'index_price_1_4' => '6小时内递交', + 'index_price_1_5' => '包含30.75美金官方收费', + 'index_price_1_6' => '6小时内递交', + 'index_price_2_1' => 'eVUS专业登记', + 'index_price_2_2' => '精准OCR识别', + 'index_price_2_3' => '智能AI翻译', + 'index_price_2_4' => '15分钟内递交', + 'index_service' => '我们的服务', + 'index_advantage' => '我们的优势', + 'index_advantage_1_title' => '7×24小时急速响应', + 'index_advantage_1_content_1' => '提供机场加急服务,专为应对各类临时出行需求而设,为赶时间的旅客开辟高效登记服务', + 'index_advantage_1_content_2' => '旅客抵达机场后,无需繁琐排队,仅需 5-7 分钟即可递交', + 'index_advantage_1_content_3' => '简化流程,助您快速通关,彻底规避误机风险,让紧急出行也能从容无忧', + 'index_advantage_2_title' => '智能填表系统', + 'index_advantage_2_content_1' => '我们推出简化中文表单填写服务,全程仅需5分钟,即可完成核心信息录入,大幅降低语言壁垒带来的操作困扰', + 'index_advantage_2_content_2' => '专业团队开展二次审核,重点核查信息逻辑、格式规范及关键内容匹配度,从源头减少登记失误,显著降低因信息错漏导致的不成功风险,较用户自行英文操作(30-40分钟)提速8倍', + 'evus_pic' => '/new/assets/images/evus.jpg', + 'evusearch_pic' => '/new/assets/images/evusearch.jpg', + 'esta_pic' => '/new/assets/images/esta.jpg', + 'evus' => [ + 'other_country_acquired_other_required' => '请填写其他', + 'other_country_acquired_other_label' => '其他', + 'add' => '添加', + 'delete' => '删除', + 'title' => '旅行证件信息', + 'passport_number_label' => '护照号码', + 'passport_placeholder' => '输入或拍照上传', + 'passport_required' => '请填写护照号码', + 'passport_upload_title' => '拍照/上传有效护照照片', + 'passport_tooltip' => '护照号码通常为G、E、EA、EB、EC等开头的9位字符,公务护照以及外交护照例外。请仔细区分数字1与字母I,以及数字0与字母O。', + 'passport_hint' => '依照您旅游时将使用的护照来输入护照号。', + 'passport_country_label' => '护照国家', + 'select_country_required' => '请选择一个国家', + 'select_country_prompt' => '请选择一个国家', + 'china' => '中国', + 'country_tooltip' => '', // Can add tooltip text if needed + 'country_hint' => '目前只有中华人民共和国的公民国民必须登记 EVUS。', + 'pinyin' => '拼音', + 'last_name_label' => '姓氏', + 'last_name_placeholder' => '请填写拼音姓', + 'last_name_required' => '请填写拼音姓', + 'last_name_tooltip' => '请勿在此栏输入名字。复姓请按照护照信息为准。若您没有姓氏,请在姓氏栏位填 "UNKNOWN"', + 'last_name_hint' => '请参考护照上的信息用英文字母填写您的姓氏', + 'first_name_label' => '名字', + 'first_name_placeholder' => '请填写拼音名', + 'first_name_required' => '请填写拼音名', + 'first_name_tooltip' => '请参考护照上的信息填写您的名字,请勿在此栏输入姓氏', + 'first_name_hint' => '依照您的护照正确输入您的名字', + 'birth_date_label' => '出生日期', + 'birth_date_placeholder' => '请选择出生日期', + 'birth_date_required' => '请选择出生日期', + 'birth_date_tooltip' => '请参考您护照上的信息填写您的出生日期,请确保出生日期正确', + 'birth_city_label' => '出生城市', + 'birth_city_placeholder' => '请填写出生城市', + 'birth_city_required' => '请填写出生城市', + 'birth_city_tooltip' => '请参考您护照上的信息填写您的出生地点。', + 'birth_country_label' => '出生国家', + 'birth_country_tooltip' => '请从下拉式菜单选择您护照上出生地栏位显示的国家名称', + 'country_required' => '请选择一个国家', + 'gender_label' => '性别', + 'male' => '男性', + 'female' => '女性', + 'passport_issue_date_label' => '护照签发时间', + 'passport_issue_placeholder' => '请选择护照签发日期', + 'passport_issue_required' => '请选择护照签发日期', + 'passport_issue_tooltip' => '请参照护照上的签发日期填写', + 'passport_expiry_label' => '护照有效期', + 'passport_expiry_placeholder' => '请选择护照有效期', + 'passport_expiry_required' => '请选择护照有效期', + 'passport_expiry_tooltip' => '请参照护照上的有效期填写', + 'ten_year_visa_label' => '您持有十年效期的美国访客签证吗(B1、B2 或 B1/B2 类)?', + 'ten_year_visa_hint' => '请确认是否持有美国十年效期商务/旅游(B1、B2、B1/B2)类型签证', + 'ten_year_visa_warning' => '要在 EVUS 登记,您必须持有 10 年效期的美国访客签证(B1、 B2 或 B1/B2 类)。若希望到美国旅游,但未持有这类的签证,您必须到美国大使馆申请', + 'visa_number_label' => '美国B1/B2签证号码', + 'visa_number_placeholder' => '输入或拍照上传', + 'visa_number_required' => '请填写签证号码', + 'visa_number_tooltip' => '请参考您的美国签证贴纸,输入右下角8位红色字符的签证号码', + 'upload_visa_title' => '拍照/上传有效护照照片', + 'visa_in_passport_label' => '您旅行时所使用的护照是否含有您的美国签证?', + 'visa_in_passport_hint' => '如果你的签证在旧护照上面,请选择"否",并填写旧护照信息', + 'yes' => '是', + 'no' => '否', + 'old_passport_number_label' => '含美国签证的旧护照号码', + 'enter_or_upload' => '输入或拍照上传', + 'passport_number_required' => '请填写护照号码', + 'upload_passport_photo' => '拍照/上传有效护照照片', + 'old_passport_tooltip' => '请输入包含美国签证的旧护照号码', + 'passport_country_tooltip' => '请选择旧护照的签发国家', + 'next_step' => '下一步', + 'other_citizenship_title' => '其他公民身份、国籍、护照', + 'other_nationality_label' => '您现在是否拥有其他国籍?', + 'other_nationality_tooltip' => '请确认是否拥有除中国以外的他国国籍', + 'other_citizenship_current_label' => '其他国家公民当前', + 'other_citizenship_current_tooltip' => '选择您的其他国籍的国家。如果您以上回答"是",该国家必须完成您的申请', + 'how_acquired_citizenship_label' => '你如何从这个国家获得公民/国籍', + 'how_acquired_citizenship_tooltip' => '选择你如何获得国籍/从这个国家的国籍', + 'past_nationality_label' => '您曾经是否拥有其他国籍?', + 'past_nationality_tooltip' => '在此问题上回答"是"代表着现在已无此国籍', + 'past_citizenship_label' => '其他国家公民过去', + 'past_citizenship_tooltip' => '请从下拉式菜单选择您护照上出生地栏位显示的国家名称', + 'other_passport_label' => '您曾经是否拥有其他国家的护照或居民身份证?', + 'other_passport_tooltip' => '请确认是否拥有除中国以外的他国护照。若您有此材料但已遗失或不记得号码,可填写"UNKNOWN"', + 'issuing_country_label' => '发行国', + 'issuing_country_tooltip' => '选择国家的公民身份,因为它出现在您的文档。完成应用程序需签发国的文档。', + 'document_type_label' => '文档类型', + 'document_type_tooltip' => '请选择另一个国家颁布的旅行文件类型', + 'document_number_label' => '文档编号', + 'document_number_placeholder' => '字母及数字(如无法提供请填写000000)', + 'document_number_tooltip' => '输入您的旅行证件上显示的文件编号。旅行证件可能包含数字和/或字符。请仔细区分数字零和字母O.', + 'expiry_year_label' => '到期年份', + 'expiry_year_placeholder' => '请选择到期年份', + 'expiry_year_tooltip' => '请即使它已过期,说明颁发的另一个国家,你的旅行证件到期年份。', + 'social_media_label' => '是否有社交媒体?', + 'social_media_tooltip' => '请选择是否有社交媒体', + 'facebook_label' => '脸书(facebook)', + 'facebook_placeholder' => '请填写脸书用户名', + 'facebook_tooltip' => '如有,请填写facebook账号名称。', + 'linkedin_label' => '领英链接(linkedin)', + 'linkedin_placeholder' => '请填写领英链接', + 'linkedin_tooltip' => '如有,请填写linkedin链接。', + 'twitter_label' => '推特(Twitter)', + 'twitter_placeholder' => '请填写推特用户名', + 'twitter_tooltip' => '如有,请填写Twitter账号名称。', + 'instagram_label' => '照片墙(Instagram)', + 'instagram_placeholder' => '请填写照片墙用户名', + 'instagram_tooltip' => '如有,请填写照片墙用户名。', + 'platform_label' => '提供者/平台', + 'platform_tooltip' => '如有,请请选择提供者/平台。', + 'identifier_label' => '社交媒体标识符', + 'identifier_placeholder' => '请填写社交媒体标识符', + 'identifier_tooltip' => '如有,请填写社交媒体标识符。', + 'alias_label' => '是否有曾用名?', + 'alias_tooltip' => '是否有曾用名', + 'alias_last_name_label' => '曾用 姓氏', + 'alias_last_name_placeholder' => '请填写曾用 姓氏', + 'alias_last_name_tooltip' => '请填写您曾用名的姓氏', + 'alias_last_name_hint' => '请填写您曾用名的姓氏,请勿在此栏输入名字。', + 'alias_first_name_label' => '曾用 名字', + 'alias_first_name_placeholder' => '请填写曾用 名字', + 'alias_first_name_tooltip' => '请填写您曾用名的名字', + 'alias_first_name_hint' => '请填写您曾用名的名字,请勿在此栏输入名字。', + 'select_option_required' => '请选择', + 'select_option_prompt' => '请选择', + 'select_document_type_required' => '请选择文档类型', + 'select_document_type_prompt' => '请选择文档类型', + 'select_platform_required' => '请选择提供者/平台', + 'select_platform_prompt' => '请选择提供者/平台', + 'by_birth' => '经由出生', + 'by_parents' => '通过父母', + 'naturalization' => '归化', + 'other' => '其他', + 'passport_number' => '护照号', + 'permanent_residence_id' => '永久居留证件号码(绿卡号)', + 'address_contact_title' => '住址及联系方式', + 'id_card_instructions' => '输入号码或点击【相机】识别您的有效身份证正面照信息;拍照上传方式,可自动识别导入您的信息。', + 'id_number_label' => '身份证号码', + 'id_number_required' => '请填写身份证号码', + 'upload_photo_title' => '拍照/上传有效照片', + 'id_number_tooltip' => '请输入18位的身份证号码。如果没有身份证号码,请填写‘‘UNKNOWN’’。', + 'email_label' => '电子邮箱(选填)', + 'email_placeholder' => '建议填写,用于收入eVUS批准信', + 'email_required' => '请填写电子邮箱', + 'email_tooltip' => '您将通过邮件方式收到您的申请确认函。如有任何状态更新也将通过邮件通知您。', + 'current_country_label' => '现居住国家', + 'current_country_tooltip' => '请选择您当前居住的国家', + 'current_province_label' => '现居住省份/州', + 'current_province_placeholder' => '填写居住省份/州', + 'current_province_required' => '填写居住省份/州', + 'current_province_tooltip' => '请填写您当前居住的省份或州', + 'current_city_label' => '现居住城市', + 'current_city_placeholder' => '填写现居住城市', + 'current_city_required' => '填写现居住城市', + 'current_city_tooltip' => '请填写您当前居住的城市', + 'current_address_label' => '现居住地址', + 'current_address_placeholder' => '填写现居住地址', + 'current_address_required' => '填写现居住地址', + 'current_address_tooltip' => '请填写您当前居住的详细地址', + 'phone_label' => '联系电话', + 'phone_placeholder' => '请输入手机号码', + 'phone_tooltip' => '请填写有效的联系电话号码', + 'parents_info_title' => '父母信息', + 'father_surname_label' => '父亲的姓氏', + 'father_surname_placeholder' => '填写父亲的姓氏', + 'father_surname_required' => '填写父亲的姓氏', + 'father_surname_tooltip' => '请输入申请人父亲的姓氏', + 'father_name_label' => '父亲的名字', + 'father_name_placeholder' => '填写父亲的名字', + 'father_name_required' => '填写父亲的名字', + 'father_name_tooltip' => '请输入申请人父亲的名字', + 'mother_surname_label' => '母亲的姓氏', + 'mother_surname_placeholder' => '填写母亲的姓氏', + 'mother_surname_required' => '填写母亲的姓氏', + 'mother_surname_tooltip' => '请输入申请人母亲的姓氏', + 'mother_name_label' => '母亲的名字', + 'mother_name_placeholder' => '填写母亲的名字', + 'mother_name_required' => '填写母亲的名字', + 'mother_name_tooltip' => '请输入申请人母亲的名字', + 'employment_info_title' => '工作信息', + 'has_employer_label' => '您现在或之前是否有过工作单位或雇主', + 'has_employer_tooltip' => '如填"是"请填写工作单位信息', + 'employer_country_label' => '工作单位所在国家', + 'employer_country_tooltip' => '请在列表中选择工作单位所在国家', + 'employer_state_label' => '工作单位所在省份/州', + 'employer_state_placeholder' => '请填写工作单位所在省份/州', + 'employer_state_required' => '请填写工作单位所在省份/州', + 'employer_state_tooltip' => '建议使用英文或拼音输入工作单位所在省份。若不清楚可填写"UNKNOWN"', + 'employer_city_label' => '工作单位所在城市', + 'employer_city_placeholder' => '请填写工作单位所在城市', + 'employer_city_required' => '请填写工作单位所在城市,请勿填写省份', + 'employer_city_tooltip' => '建议使用英文或拼音输入工作单位所在城市。若不清楚可填写"UNKNOWN"', + 'employer_address_label' => '工作单位地址', + 'employer_address_placeholder' => '请填写工作单位地址', + 'employer_address_required' => '请填写工作单位地址', + 'employer_address_tooltip' => '建议使用英文或拼音输入工作单位的地址,不必在此栏填写省份或城市。若不清楚可填写"UNKNOWN"', + 'employer_name_label' => '工作单位名称', + 'employer_name_placeholder' => '请填写工作单位名称', + 'employer_name_required' => '填写工作单位名称限30字', + 'employer_name_tooltip' => '请使用英文或拼音输入工作单位的名称。若没有工作单位,您也可以填写自雇、家庭主妇、等信息形容您的工作状况', + 'travel_info_title' => '旅游信息', + 'transit_purpose_label' => '您到美国的目的,是为了过境到另一国家吗?', + 'transit_purpose_tooltip' => '请选择您前往美国是否只是为了过境而不停留。选否可选择填写在美联系人。', + 'us_address_section_title' => '在美国的地址(选填)', + 'us_contact_name_label' => '将在美国到访的酒店名称 / 商业上往来的友人 / 亲友全名(选填)', + 'us_contact_name_placeholder' => '不得含有数字和特殊字符。如无法提供请留空', + 'us_contact_name_required' => '不得含有数字和特殊字符。如无法提供请留空', + 'us_contact_name_tooltip' => '在美国的联系人可以是友人、亲戚或生意上的伙伴。若您在美国没有联系人,请输入您住宿地点的名称、地址和电话号码(例如酒店名称)。您也可输入"UNKNOWN"。', + 'us_state_label' => '所在州(选填)', + 'select_state_required' => '请选择所在州', + 'select_state_prompt' => '请选择所在州', + 'us_state_tooltip' => '请在列表中选择您在美国的联系人所在的州。若不清楚可选择"未知"', + 'us_city_label' => '所在城市(选填)', + 'us_city_placeholder' => '填写联系人所在城市,不必填写省份', + 'us_city_required' => '填写联系人所在城市,不必填写省份', + 'us_city_tooltip' => '请输入您在美国的联系人所在城市。若不清楚可填写"UNKNOWN"。', + 'us_address_label' => '地址(选填)', + 'us_address_placeholder' => '填写联系人的地址街道及号码,不必填写省份或城市', + 'us_address_required' => '填写联系人的地址街道及号码,不必填写省份或城市', + 'us_address_tooltip' => '请输入您在美国的联系人的地址街道及号码,不必在此栏填写省份或城市。若不清楚可填写"UNKNOWN"。', + 'us_phone_label' => '电话号码(选填)', + 'select_phone_prefix_prompt' => '请选择手机号前缀', + 'us_phone_placeholder' => '请输入手机号码', + 'us_phone_tooltip' => '请输入您在美国的联系人的电话号码。若不清楚可填写"0"。', + + 'emergency_contact_title' => '紧急联系人(选填)', + 'emergency_last_name_label' => '姓氏(选填)', + 'emergency_last_name_placeholder' => '填写紧急联系人姓氏', + 'emergency_last_name_required' => '填写紧急联系人姓氏', + 'emergency_last_name_tooltip' => '请输入您的紧急联系人姓氏。紧急联系人可以是您在美国或其他国家的联系人,如家属、好友或商业伙伴。若没有紧急联系人,请留空', + 'emergency_first_name_label' => '名字(选填)', + 'emergency_first_name_placeholder' => '填写紧急联系人名字', + 'emergency_first_name_required' => '填写紧急联系人名字', + 'emergency_first_name_tooltip' => '请输入您的紧急联系人名字。紧急联系人名字可以是您在美国或其他国家的联系人,如家属、好友或商业伙伴。若没有紧急联系人,请留空', + 'emergency_email_label' => '电子邮箱(选填)', + 'emergency_email_placeholder' => '填写紧急联系人电子邮箱', + 'emergency_email_required' => '填写紧急联系人电子邮箱', + 'emergency_email_tooltip' => '请输入您的紧急联系人的电子邮箱。若没有紧急联系人,请留空', + 'emergency_phone_label' => '电话号码(选填)', + 'emergency_phone_placeholder' => '填写紧急联系人电话号码', + 'emergency_phone_tooltip' => '请输入您的紧急联系人的电话号码。若没有紧急联系人,请输入0', + + 'eligibility_question' => '资格问题', + 'warning_cannot_continue' => '您确定要对此问题回答「是」吗?如果您的答案为「是」,您将不能继续在线申请。', + 'q_a' => '您目前是否患有以下任何疾病(《公共健康法》第361条b款所列传染病):霍乱、白喉、肺结核、天花、黄热病、病毒性出血热(包括埃博拉、拉沙热、马尔堡病、克里米亚-刚果出血热)、可传染他人且可能致命的严重急性呼吸道疾病?', + 'q_b' => '您是否曾因严重破坏财产或严重伤害他人或政府机关而被逮捕或定罪?', + 'q_c' => '您是否曾违反过与非法药物的持有、使用或分发相关的法律?', + 'q_d' => '您是否曾经或试图从事恐怖活动、间谍活动、破坏活动或种族灭绝?', + 'q_e' => '您是否曾为获取签证或协助他人获取签证、或进入美国而欺诈或伪造自己或他人的信息?', + 'q_f' => '您目前是否在美国寻求工作,或是否曾在未获许可的情况下在美国工作?', + 'q_g' => '您是否曾被拒签美国签证或被拒绝入境美国,或在入境口岸撤回过申请?', + 'q_h' => '您是否曾逾期居留美国或违反过美国签证的规定?', + 'q_i' => '自2011年3月1日以来,您是否曾去过或居住在伊朗、伊拉克、利比亚、朝鲜、索马里、苏丹、叙利亚或也门?', + 'reject_date' => '拒签日期', + 'reject_address' => '拒签地点', + 'vist_country' => '访问国家', + 'vist_from_date' => '开始日期', + 'vist_end_date' => '结束日期', + 'vist_country_des' => '访问主要原因', + 'IRN' => '伊朗', + 'IRQ' => '伊拉克', + 'LBY' => '利比亚', + 'PRK' => '朝鲜', + 'SOM' => '索马里', + 'SDN' => '苏丹', + 'SYR' => '叙利亚', + 'YEM' => '也门', + 'reason_1' => '旅游', + 'reason_2' => '探亲', + 'reason_3' => '工作', + 'reason_4' => '商务', + 'reason_5' => '学习', + 'reason_6' => '新闻报道', + 'reason_7' => '会议', + 'reason_8' => '文化交流', + 'reason_9' => '宗教活动', + 'reason_10' => '医疗', + 'reason_11' => '过境', + 'reason_12' => '外交/公务', + 'reason_13' => '其他', + 'declaration_title' => '申请人声明', + 'declaration_check1' => '本人声明在此申请中提供真实丶完整和正确的信息。', + 'declaration_check2' => '我已阅读并理解', + 'choose_package' => '选择套餐', + 'package_a' => 'A套餐:398元/人民币 Vip快速登记(资料完整15分钟反馈信息)', + 'package_b' => 'B套餐:98元/人民币 安逸登记(资料完整6小时内反馈信息)', + 'submit_now' => '立即提交', + 'termsCheckbox' => ' +
+
条款与条件
+

+ 签证更新电子系统(EVUS)与执法部门 的数据库进行比对。所有持10年有效期访客签证的旅客(B1, B2 或 B1/B2), + 如果需要以短期访客身份入境美国,都必须在赴美前在EVUS上登记。 + 如果您的EVUS登记获得批准,就意味着您可以前往美国。但这并不意味着您可以入境美国。抵达美国入境口岸时,您将接受United States + Customs and Border Protection官员的检查。 入境口岸的官员会根据美国移民法的规定决定您是否可以入境。 + 由您或指定的第三方代理人所提供的所有信息,必须是真实和正确的。如果您在填写信息时由您或您的代理人有意提交任何虚假、虚构或伪造的声明或陈述,造成EVUS更新失败或者美国签证被注销,责任由您本人承担。 + 信息填写完成后,我们根据你所选择的套餐时效反馈信息,提交后信息将不能再更改。 +

+

请表明您已阅读并了解上述所提供的信息

+
隐私政策
+

+

+ 本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,本应用不会将这些信息对外披露或向第三方提供。本应用会不时更新本隐私权政策。 + 您在同意本应用服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本应用服务使用协议不可分割的一部分。 +

1. 适用范围
+ +

(a) 在您注册本应用帐号时,您根据本应用要求提供的个人注册信息; + (b) + 在您使用本应用网络服务,或访问本应用平台网页时,本应用自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据; + (c) 本应用通过合法途径从商业伙伴处取得的用户个人数据。 + 您了解并同意,以下信息不适用本隐私权政策: + (a) 您在使用本应用平台提供的搜索服务时输入的关键字信息; + (b) 本应用收集到的您在本应用发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情; + (c) 违反法律规定或违反本应用规则行为及本应用已对您采取的措施。

+ +
2. 信息使用
+ +

+ (a)本应用不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和本应用(含本应用关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。 + (b) + 本应用亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何本应用平台用户如从事上述活动,一经发现,本应用有权立即终止与该用户的服务协议。 + (c) + 为服务用户的目的,本应用可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与本应用合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意)

+ +
3. 信息披露
+ +

在如下情况下,本应用将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息: + (a) 经您事先同意,向第三方披露; + (b)为提供您所要求的产品和服务,而必须和第三方分享您的个人信息; + (c) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露; + (d) 如您出现违反中国有关法律、法规或者本应用服务协议或相关规则的情况,需要向第三方披露; + (e) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷; + (f) + 在本应用平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,本应用有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。 + (g) 其它本应用根据法律、法规或者网站政策认为合适的披露。

+ +
4. 信息存储和交换
+ +

+ 本应用收集的有关您的信息和资料将保存在本应用及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或本应用收集信息和资料所在地的境外并在境外被访问、存储和展示。

+ +
5. Cookie的使用
+ +

(a) 在您未拒绝接受cookies的情况下,本应用会在您的计算机上设定或取用cookies + ,以便您能登录或使用依赖于cookies的本应用平台服务或功能。本应用使用cookies可为您提供更加周到的个性化服务,包括推广服务。 + (b) + 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的本应用网络服务或功能。 + (c) 通过本应用所设cookies所取得的有关信息,将适用本政策。

+ +
6. 信息安全
+ +

(a) + 本应用帐号均有安全保护功能,请妥善保管您的用户名及密码信息。本应用将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。 + (b) 在使用本应用网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易对

+ +
7.本隐私政策的更改
+ +

+ (a)如果决定更改隐私政策,我们会在本政策中、本公司网站中以及我们认为适当的位置发布这些更改,以便您了解我们如何收集、使用您的个人信息,哪些人可以访问这些信息,以及在什么情况下我们会透露这些信息。 + (b)本公司保留随时修改本政策的权利,因此请经常查看。如对本政策作出重大更改,本公司会通过网站通知的形式告知。 + 方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是本应用用户名及密码发生泄露,请您立即联络本应用客服,以便本应用采取相应措施。

+
+ ', + 'terms_privacy_title' => '条款与条件及隐私政策', + 'close' => '关闭' + ], + 'lookup' => [ + 'hot_price' => '热门套餐', + 'status_check_title' => '查询EVUS状态', + 'passport_number_label' => '护照号码', + 'enter_or_upload' => '输入或拍照上传', + 'passport_number_required' => '请填写护照号码', + 'upload_passport_photo' => '拍照/上传有效护照照片', + 'passport_number_tooltip' => '护照号码通常为G、E、EA、EB、EC等开头的9位字符,公务护照以及外交护照例外。请仔细区分数字1与字母I,以及数字0与字母O。', + 'visa_number_label' => '美国B1/B2签证号码', + 'visa_number_required' => '请填写签证号码', + 'visa_number_tooltip' => '请参考您的美国签证贴纸,输入右下角8位红色字符的签证号码。', + 'last_name_label' => '姓氏', + 'pinyin' => '拼音', + 'last_name_placeholder' => '请填写拼音姓', + 'last_name_required' => '请填写拼音姓', + 'last_name_tooltip' => '请勿在此栏输入名字。复姓请按照护照信息为准。若您没有姓氏,请在姓氏栏位填 "UNKNOWN"。', + 'last_name_hint' => '请参考护照上的信息用英文字母填写您的姓氏', + 'first_name_label' => '名字', + 'first_name_placeholder' => '请填写拼音名', + 'first_name_required' => '请填写拼音名', + 'first_name_tooltip' => '请参考护照上的信息填写您的名字,请勿在此栏输入姓氏。', + 'first_name_hint' => '依照您的护照正确输入您的名字', + 'birth_date_label' => '出生日期', + 'birth_date_placeholder' => '请选择出生日期', + 'birth_date_required' => '请选择出生日期', + 'birth_date_tooltip' => '请参考您护照上的信息填写您的出生日期,请确保出生日期正确', + 'citizenship_label' => '公民身份国家', + 'select_country_required' => '请选择国家', + 'select_country_prompt' => '请选择国家', + 'citizenship_tooltip' => '请从下拉式菜单选择您护照上出生地栏位显示的国家名称。', + 'terms_acceptance' => '我已阅读并理解条款与条件及隐私政策。', + 'check_status_button' => '查询状态', + + 'status_registered' => '已登记', + 'registered_description1' => '“已登记”的EVUS状态意味着EVUS的要求得到了满足得以前往美国 1)从登记批准之日起两年内有效期,或 2),直到主要的护照到期(“主要的护照”是用于登记的护照是有效的,并在登记申请时尚未过期)或 3),直到签证过期,以先到者为准。这样并不保证入境美国。美国联邦Customs and Border Protection 的官员在美国的入境口岸将做最终决定。', + 'registered_description2' => '要进入您的EVUS登记申请,会要求您提供您的登记申请号码,护照号码,签证号码和出生日期。如果有必要,您可以更新一份成功的登记内以下信息:1)在美地址和 2)电子邮件地址。如果您需要更改或更新表格上的任何其他信息,您必须申请新的旅行授权。', + 'registered_description3' => '您已成功提交了以下所列', + 'status_pending' => '审批中', + 'pending_description' => '您的信息正在登记中,请耐心等候!', + 'status_unsuccessful' => '登记不成功', + 'unsuccessful_description1' => '您的EVUS登记不成功,并且您目前没有得到授权前往美国。', + 'unsuccessful_description2' => 'EVUS登记申请失败的常见原因包括:您没有完成所有必填的资料; 您没有提供正确的信息; 您没有用有效的护照或美国签证申请登记,或者其他原因。', + 'unsuccessful_description3' => '如需帮助,请拨打EVUS帮助中心400-0878-958 。帮助中心每天24小時,每周7天提供,以帮助您与您的EVUS招生。', + 'unsuccessful_description4' => '您已成功提交了以下所列的登记申请。为您的个人记录,请印列此页。', + 'table_name' => '姓名', + 'table_birth_date' => '出生日期', + 'table_enrollment_number' => '登记申请号码', + 'table_passport_number' => '护照号码', + 'table_visa_number' => 'B1/B2签证的签证号码', + 'table_status' => '状态', + 'table_expiry' => '到期', + 'table_view' => '查看', + 'visa_services' => '美国签证服务', + 'package1_title' => '套餐一', + 'package1_price' => '¥198', + 'package1_feature1' => 'DS-160 英文翻译填写', + 'package2_title' => '套餐二', + 'package2_price' => '¥1998', + 'package2_feature1' => 'DS-160 英文翻译填写', + 'package2_feature2' => '即时预约面签', + 'package2_feature3' => '包含签证费用', + 'package3_title' => '套餐三(限时特惠)', + 'package3_price' => '¥2098¥2250', + 'package3_feature1' => 'DS-160 英文翻译填写', + 'package3_feature2' => '即时预约', + 'package3_feature3' => '面签辅导', + 'package3_feature4' => '包含签证费用', + 'package4_title' => '套餐四', + 'package4_price' => '¥2099', + 'package4_feature1' => '免面谈代传递(签证续签)', + 'package4_feature2' => 'DS-160 英文翻译填写', + 'package4_feature3' => '即时预约代传递', + 'package4_feature4' => '包含签证费用', + 'package4_feature5' => '(赴美目的说明)', + ], + 'esta' => [ + 'notice' => '注意:您正在申请ESTA,如果您拥有中国护照的请点击申请', + 'personal_details_title' => '个人详细信息', + 'passport_photo_label' => '护照照片', + 'upload_instructions' => '点击上传,或将文件拖拽到此处', + 'upload_success_alt' => '上传成功后渲染', + 'passport_photo_required' => '请上传护照照片', + 'passport_example_label' => '护照示例', + 'personal_photo_label' => '个人照片', + 'personal_photo_required' => '请上传个人照片', + 'personal_photo_example_label' => '个人照示例', + 'last_name_label' => '姓氏', + 'pinyin' => '拼音', + 'last_name_placeholder' => '请填写拼音姓', + 'last_name_required' => '请填写拼音姓', + 'last_name_tooltip' => '请勿在此栏输入名字。复姓请按照护照信息为准。若您没有姓氏,请在姓氏栏位填 "UNKNOWN"。', + 'last_name_hint' => '请参考护照上的信息用英文字母填写您的姓氏', + 'first_name_label' => '名字', + 'first_name_placeholder' => '请填写拼音名', + 'first_name_required' => '请填写拼音名', + 'first_name_tooltip' => '请参考护照上的信息填写您的名字,请勿在此栏输入姓氏。', + 'first_name_hint' => '依照您的护照正确输入您的名字', + 'birth_date_label' => '出生日期', + 'birth_date_placeholder' => '请选择出生日期', + 'birth_date_required' => '请选择出生日期', + 'birth_date_tooltip' => '请参考您护照上的信息填写您的出生日期,请确保出生日期正确', + 'birth_city_label' => '出生城市', + 'birth_city_placeholder' => '请填写出生城市', + 'birth_city_required' => '请填写出生城市', + 'birth_city_tooltip' => '请参考您护照上的信息填写您的出生地点。', + 'birth_country_label' => '出生国家', + 'select_country_required' => '请选择一个国家', + 'select_country_prompt' => '请选择一个国家', + 'birth_country_tooltip' => '请从下拉式菜单选择您护照上出生地栏位显示的国家名称。', + 'gender_label' => '性别', + 'male' => '男性', + 'female' => '女性', + 'id_number_label' => 'ID证件号码', + 'id_number_placeholder' => '请填写ID证件号码', + 'id_number_required' => '请填写ID证件号码', + 'id_number_tooltip' => '请输入身份证号码。如果没有身份证号码,请填写"UNKNOWN"', + 'former_name_label' => '曾用名(选填)', + 'former_name_placeholder' => '请填写曾用名', + 'former_name_required' => '请填写曾用名', + 'next_step' => '下一步', + 'travel_documents_title' => '旅行文件详细信息', + 'passport_country_label' => '护照国家', + 'passport_number_label' => '护照号码', + 'passport_number_placeholder' => '请填写护照号码', + 'passport_number_required' => '请填写护照号码', + 'passport_number_tooltip' => '护照号码通常为G、E、EA、EB、EC等开头的9位字符,公务护照以及外交护照例外。请仔细区分数字1与字母I,以及数字0与字母O。', + 'passport_issue_date_label' => '护照签发时间', + 'passport_issue_date_placeholder' => '请选择护照签发日期', + 'passport_issue_date_required' => '请选择护照签发日期', + 'passport_issue_date_tooltip' => '请参照护照上的签发日期填写', + 'passport_expiry_label' => '护照有效期', + 'passport_expiry_placeholder' => '请选择护照有效期', + 'passport_expiry_required' => '请选择护照有效期', + 'passport_expiry_tooltip' => '请参照护照上的有效期填写', + 'visa_number_label' => '填写签证号码:(如果有)', + 'visa_number_placeholder' => '请填写签证号码', + 'visa_number_required' => '请填写签证号码', + 'other_citizenship_title' => '其他公民身份、国籍、护照', + 'current_other_nationality_label' => '您现在是否拥有其他国籍?', + 'current_other_nationality_tooltip' => '请确认是否拥有除中国以外的他国国籍', + 'other_citizenship_current_label' => '其他国家公民当前', + 'other_citizenship_current_tooltip' => '选择您的其他国籍的国家。如果您以上回答"是",该国家必须完成您的申请', + 'how_acquired_citizenship_label' => '你如何从这个国家获得公民/国籍', + 'how_acquired_citizenship_tooltip' => '选择你如何获得国籍/从这个国家的国籍', + 'past_other_nationality_label' => '您曾经是否拥有其他国籍?', + 'past_other_nationality_tooltip' => '在此问题上回答"是"代表着现在已无此国籍', + 'past_nationality_start_date_label' => '曾经拥有其他国籍的开始日期', + 'past_nationality_end_date_label' => '曾经拥有其他国籍的结束日期', + 'past_citizenship_label' => '其他国家公民过去', + 'past_citizenship_tooltip' => '请从下拉式菜单选择您护照上出生地栏位显示的国家名称', + 'other_passport_label' => '您曾经是否拥有其他国家的护照或居民身份证?', + 'other_passport_tooltip' => '请确认是否拥有除中国以外的他国护照。若您有此材料但已遗失或不记得号码,可填写"UNKNOWN"', + 'issuing_country_label' => '发行国', + 'issuing_country_tooltip' => '选择国家的公民身份,因为它出现在您的文档。完成应用程序需签发国的文档', + 'document_type_label' => '文档类型', + 'document_type_tooltip' => '请选择另一个国家颁布的旅行文件类型', + 'document_number_label' => '文档编号(选填)', + 'document_number_placeholder' => '字母及数字(如无法提供请填写000000)', + 'document_number_required' => '请填写文档编号', + 'document_number_tooltip' => '输入您的旅行证件上显示的文件编号。旅行证件可能包含数字和/或字符。请仔细区分数字零和字母O', + 'expiry_year_label' => '到期年份', + 'expiry_year_placeholder' => '请选择到期年份', + 'expiry_year_required' => '请选择到期年份', + 'expiry_year_tooltip' => '请即使它已过期,说明颁发的另一个国家,你的旅行证件到期年份', + 'select_option_required' => '请选择', + 'select_option_prompt' => '请选择', + 'select_document_type_required' => '请选择文档类型', + 'select_document_type_prompt' => '请选择文档类型', + 'select_date_required' => '请选择日期', + 'select_date_prompt' => '请选择日期', + 'passport_number' => '护照号', + 'national_id' => '身份证号码', + 'by_birth' => '经由出生', + 'by_parents' => '通过父母', + 'naturalization' => '归化', + 'other' => '其他', + 'yes' => '是', + 'no' => '否', + 'contact_information_title' => '联系方式', + 'email_label' => '电子邮箱(选填)', + 'email_placeholder' => '建议填写,用于接收ESTA批准信', + 'email_required' => '请填写电子邮箱', + 'email_tooltip' => '您将通过邮件方式收到您的申请确认函。如有任何状态更新也将通过邮件通知您。', + 'confirm_email_label' => '确认电子邮箱(选填)', + 'confirm_email_placeholder' => '建议填写,用于接收ESTA批准信', + 'confirm_email_required' => '请填写电子邮箱', + 'confirm_email_tooltip' => '您将通过邮件方式收到您的申请确认函。如有任何状态更新也将通过邮件通知您。', + 'phone_number_label' => '联系电话', + 'phone_number_placeholder' => '请输入手机号码', + 'select_phone_prefix_prompt' => '请选择手机号前缀', + 'address_details_title' => '详细地址', + 'current_country_label' => '现居住国家', + 'current_province_label' => '现居住省份/州', + 'current_province_placeholder' => '填写居住省份/州', + 'current_province_required' => '填写居住省份/州', + 'current_city_label' => '现居住城市', + 'current_city_placeholder' => '填写现居住城市', + 'current_city_required' => '填写现居住城市', + 'current_address_label' => '现居住地址', + 'current_address_placeholder' => '填写现居住地址', + 'current_address_required' => '填写现居住地址', + + 'parents_info_title' => '父母信息', + 'father_surname_label' => '父亲的姓氏', + 'father_surname_placeholder' => '填写父亲的姓氏', + 'father_surname_required' => '填写父亲的姓氏', + 'father_surname_tooltip' => '请输入申请人父亲的姓氏', + 'father_name_label' => '父亲的名字', + 'father_name_placeholder' => '填写父亲的名字', + 'father_name_required' => '填写父亲的名字', + 'father_name_tooltip' => '请输入申请人父亲的名字', + 'mother_surname_label' => '母亲的姓氏', + 'mother_surname_placeholder' => '填写母亲的姓氏', + 'mother_surname_required' => '填写母亲的姓氏', + 'mother_surname_tooltip' => '请输入申请人母亲的姓氏', + 'mother_name_label' => '母亲的名字', + 'mother_name_placeholder' => '填写母亲的名字', + 'mother_name_required' => '填写母亲的名字', + 'mother_name_tooltip' => '请输入申请人母亲的名字', + 'employment_info_title' => '工作信息', + 'has_employer_label' => '您现在或之前是否有过工作单位或雇主', + 'has_employer_tooltip' => '如填"是"请填写工作单位信息', + 'employer_country_label' => '工作单位所在国家', + 'employer_country_tooltip' => '请在列表中选择工作单位所在国家', + 'employer_state_label' => '工作单位所在省份/州', + 'employer_state_placeholder' => '填写居住省份/州', + 'employer_state_required' => '填写居住省份/州', + 'employer_state_tooltip' => '建议使用英文或拼音输入工作单位所在省份。若不清楚可填写"UNKNOWN"', + 'employer_city_label' => '工作单位所在城市', + 'employer_city_placeholder' => '填写现居住城市', + 'employer_city_required' => '填写现居住城市,请勿填写省份', + 'employer_city_tooltip' => '建议使用英文或拼音输入工作单位所在城市。若不清楚可填写"UNKNOWN"', + 'employer_address_label' => '工作单位地址', + 'employer_address_placeholder' => '填写现居住地址', + 'employer_address_required' => '填写现居住地址', + 'employer_address_tooltip' => '建议使用英文或拼音输入工作单位的地址,不必在此栏填写省份或城市。若不清楚可填写"UNKNOWN"', + 'employer_name_label' => '工作单位名称', + 'employer_name_placeholder' => '填写工作单位名称', + 'employer_name_required' => '填写工作单位名称限30字', + 'employer_name_tooltip' => '请使用英文或拼音输入工作单位的名称。若没有工作单位,您也可以填写自雇、家庭主妇、等信息形容您的工作状况', + 'travel_info_title' => '旅游信息', + 'transit_purpose_label' => '您到美国的目的,是为了过境到另一国家吗?', + 'transit_purpose_tooltip' => '请选择您前往美国是否只是为了过境而不停留。选否可选择填写在美联系人', + 'us_address_section_title' => '在美国的地址(选填)', + 'us_contact_name_label' => '将在美国到访的酒店名称 / 商业上往来的友人 / 亲友全名(选填)', + 'us_contact_name_placeholder' => '不得含有数字和特殊字符。如无法提供请留空', + 'us_contact_name_required' => '不得含有数字和特殊字符。如无法提供请留空', + 'us_contact_name_tooltip' => '在美国的联系人可以是友人、亲戚或生意上的伙伴。若您在美国没有联系人,请输入您住宿地点的名称、地址和电话号码(例如酒店名称)。您也可输入"UNKNOWN"', + 'us_state_label' => '所在州(选填)', + 'select_state_required' => '请选择所在州', + 'select_state_prompt' => '请选择所在州', + 'us_state_tooltip' => '请在列表中选择您在美国的联系人所在的州。若不清楚可选择"未知"', + 'us_city_label' => '所在城市(选填)', + 'us_city_placeholder' => '填写联系人所在城市,不必填写省份', + 'us_city_required' => '填写联系人所在城市,不必填写省份', + 'us_city_tooltip' => '请输入您在美国的联系人所在城市。若不清楚可填写"UNKNOWN"', + 'us_address_label' => '地址(选填)', + 'us_address_placeholder' => '填写联系人的地址街道及号码,不必填写省份或城市', + 'us_address_required' => '填写联系人的地址街道及号码,不必填写省份或城市', + 'us_address_tooltip' => '请输入您在美国的联系人的地址街道及号码,不必在此栏填写省份或城市。若不清楚可填写"UNKNOWN"', + 'us_phone_label' => '电话号码(选填)', + 'us_phone_placeholder' => '请输入手机号码', + 'us_phone_tooltip' => '请输入您在美国的联系人的电话号码。若不清楚可填写"0"', + 'emergency_contact_title' => '紧急联系人(选填)', + 'emergency_last_name_label' => '姓氏(选填)', + 'emergency_last_name_placeholder' => '填写紧急联系人姓氏', + 'emergency_last_name_required' => '填写紧急联系人姓氏', + 'emergency_last_name_tooltip' => '请输入您的紧急联系人姓氏。紧急联系人可以是您在美国或其他国家的联系人,如家属、好友或商业伙伴。若没有紧急联系人,请留空', + 'emergency_first_name_label' => '名字(选填)', + 'emergency_first_name_placeholder' => '填写紧急联系人名字', + 'emergency_first_name_required' => '填写紧急联系人名字', + 'emergency_first_name_tooltip' => '请输入您的紧急联系人名字。紧急联系人名字可以是您在美国或其他国家的联系人,如家属、好友或商业伙伴。若没有紧急联系人,请留空', + 'emergency_email_label' => '电子邮箱(选填)', + 'emergency_email_placeholder' => '填写紧急联系人电子邮箱', + 'emergency_email_required' => '填写紧急联系人电子邮箱', + 'emergency_email_tooltip' => '请输入您的紧急联系人的电子邮箱。若没有紧急联系人,请留空', + 'emergency_phone_label' => '电话号码(选填)', + 'emergency_phone_placeholder' => '填写紧急联系人电话号码', + 'emergency_phone_tooltip' => '请输入您的紧急联系人的电话号码。若没有紧急联系人,请输入0', + 'applicant_declaration_title' => '申请人声明', + 'declaration_statement' => '本人声明在此申请中提供真实、完整和正确的信息。', + 'terms_acceptance' => '我已阅读并理解条款与条件及隐私政策。', + 'select_package_title' => '选择套餐', + 'package_a_option' => 'A套餐:958元/人民币 Vip快速登记(资料完整6小时内通过)', + 'package_b_option' => 'B套餐:495元/人民币 安逸登记(资料完整48小时内通过)', + 'submit_application_button' => '立即提交', + + 'eligibility_questions_title' => '资格问题', + 'question_a_label' => '您目前是否患有任何下列疾病(《公共健康法案》第 361 号 b 项)?霍乱、白喉、肺结核、结核、天花、黄热病、病毒性出血热,包括埃博拉病毒、拉萨热、马尔堡病、克里米亚-刚果出血热、可传染他人且可能致死的严重急性呼吸道疾病', + 'question_b_label' => '您是否曾因严重破坏财产或伤及他人或政府机关,而被逮或被判罪?', + 'question_c_label' => '您是否曾违反任何涉及持有、使用或分发非法药物的法律?', + 'question_d_label' => '您是否试图或曾经从事恐怖活动、间谍、破坏活动或种族灭绝?', + 'question_e_label' => '您是否曾为了取得签证、协助他人取得签证、或入境美国,犯下欺诈或伪造个人或他人的资料?', + 'question_f_label' => '您目前是否在美国寻求工作或是您是否曾未经美国政府许可在美国工作?', + 'question_g_label' => '您是否曾使用目前或先前的护照申请美国签证被拒?或者您是否曾被拒绝入境美国、或在美国入境口岸时,申请遭到驳回?', + 'question_h_label' => '您是否曾在美国停留超过美国政府允许的入境期间?', + 'question_i_label' => '您是否曾在 2011 年三月 1 日当日或其后到过伊拉克、叙利亚、伊朗或苏丹', + 'eligibility_warning' => '您确定要对此问题回答「是」吗?如果您的答案为「是」,您就不能继续在线申请了。', + ], + 'pay' => [ + 'success_message' => '订单提交成功,请尽快付款,订单号', + 'payment_amount' => '应付金额', + 'order_success_message' => '您的订单已经提交成功,订单号为:', + 'notice_1' => '1、您填写的信息必须和您的真实信息一致,如提交的信息与事实不符合,由此造成的后果,本中心概不负责。', + 'notice_3' => '2、工作时间:周一至周日09:00 - 22:00 (节假日正常工作),在非工作时间段提交的申请表,系统自动延伸到下一工作日,敬请谅解。', + 'notice_4' => '3、提交后,我们会在规定的时间内翻译审核校对资料信息,请注意查收邮件,如收件箱里没有,则很可能被隔离到了垃圾箱里。', + ], + 'jump' => [ + 'auto_redirect' => '秒后自动跳转', + 'redirect_now' => '立即跳转' + ], + 'js' => [ + 'daxie' => '请填写大写字母', + 'zhongwen' => '请填写填写中文', + 'len40' => '请控制在100字以内', + 'required_field' => '此项为必填项', + 'min_length' => '至少需要%d个字符', + 'max_length' => '最多允许%d个字符', + 'ppt_min' => '至少需要9个字符', + 'ppt_max' => '最多允许9个字符', + 'ppt_format' => '护照格式应为字母开头 + 至少6位数字或字母', + 'visa_min' => '至少需要8个字符', + 'visa_max' => '最多允许8个字符', + 'visa_format' => '签证格式不正确', + 'default_reqtext' => '必填项不能为空', + 'checkbox_checked' => '必须选择一个选项', + 'checkbox_required' => '请勾选声明', + 'english_only' => '只能输入英文字母', + 'success_message' => '上传成功', + 'fail_message' => '上传失败:', + 'error_message' => '上传出错', + 'upload_image_only' => '文件必须为图片', + 'browser_not_supported' => '你的浏览器不支持上传', + 'visa_unrecognized' => '无法识别,请手动填写签证号', + 'manual_entry_required' => '无法识别,请手动填写', + 'upload_retry' => '请重新上传', + 'status_enrolled' => '已登记', + 'status_pending' => '审批中', + 'status_unsuccessful' => '登记不成功', + 'status_revoked' => 'DOS已撤销您的签证', + 'click_to_view' => '点击查看' + ], + 'controller' => [ + 'success' => '操作成功', + 'fail' => '操作失败', + 'price_error' => '价格错误', + 'server_error' => '服务器错误', + 'no_registration_info' => '未检索到登记信息', + 'registration_expired' => '您正在搜索的登记申请已过期或取消', + 'registration_success' => '登记成功', + 'registration_failed' => '登记不成功', + 'registration_pending' => '登记中', + 'visa_revoked' => '已撤销您的签证', + 'missing_order_sn' => '缺少订单号,请重新填写', + 'order_not_exist' => '订单号不存在,请重新填写', + 'payment_success' => '订单已支付成功', + 'parameter_error' => '参数错误', + 'payment_not_completed' => '订单未支付', + 'order_not_exist_retry' => '订单号不存在,请重新支付', + 'payment_not_completed_retry' => '您还未支付,请重新支付', + ], + 'payment' => [ + 'select_payment_method' => '选择支付方式', + 'wechat_pay' => '微信支付', + 'alipay' => '支付宝', + 'checkout' => 'checkout', + 'success' => '支付成功', + 'fail' => '支付失败' + ], + 'foot' => [ + 'user_agreement' => '条款与条件', + 'privacy_policy' => '隐私政策', + 'disclaimer' => '免责声明', + 'refund_policy' => '退款与支付条款', + 'cookie_policy' => 'Cookies 使用声明', + + 'user_agreement_info' => '

+ 签证更新电子系统(EVUS)与执法部门 的数据库进行比对。所有持10年有效期访客签证的旅客(B1, B2 或 B1/B2), + 如果需要以短期访客身份入境美国,都必须在赴美前在EVUS上登记。 + 如果您的EVUS登记获得批准,就意味着您可以前往美国。但这并不意味着您可以入境美国。抵达美国入境口岸时,您将接受United States + Customs and Border Protection官员的检查。 入境口岸的官员会根据美国移民法的规定决定您是否可以入境。 + 由您或指定的第三方代理人所提供的所有信息,必须是真实和正确的。如果您在填写信息时由您或您的代理人有意提交任何虚假、虚构或伪造的声明或陈述,造成EVUS更新失败或者美国签证被注销,责任由您本人承担。 + 信息填写完成后,我们根据你所选择的套餐时效反馈信息,提交后信息将不能再更改。 +

+

请表明您已阅读并了解上述所提供的信息

', + + 'privacy_policy_info' => '

+ 本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,本应用不会将这些信息对外披露或向第三方提供。本应用会不时更新本隐私权政策。 您在同意本应用服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本应用服务使用协议不可分割的一部分。注意:为更好的提供您所要求的产品和服务上文所述对“第三方”的限制不包括本公司的关联公司(母公司,子公司,控股、被控股公司等),“第三方”是指本司及本司关联公司之外的主体,即下文:信息披露款项中(b)款之规定。 +

+

1. 适用范围

+ +

(a) 在您注册本应用帐号时,您根据本应用要求提供的个人注册信息; (b) 在您使用本应用网络服务,或访问本应用平台网页时,本应用自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据; (c) 本应用通过合法途径从商业伙伴处取得的用户个人数据。 您了解并同意,以下信息不适用本隐私权政策: (a) 您在使用本应用平台提供的搜索服务时输入的关键字信息; (b) 本应用收集到的您在本应用发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情; (c) 违反法律规定或违反本应用规则行为及本应用已对您采取的措施。 +

+ +

2. 信息使用

+ +

+ (a)本应用不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和本应用(含本应用关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。 (b) 本应用亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何本应用平台用户如从事上述活动,一经发现,本应用有权立即终止与该用户的服务协议。 (c) 为服务用户的目的,本应用可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与本应用合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意) +

+ +

3. 信息披露

+ +

在如下情况下,本应用将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息: (a) 经您事先同意,向第三方披露; (b)为提供您所要求的产品和服务,而必须和第三方分享您的个人信息; (c) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露; (d) 如您出现违反中国有关法律、法规或者本应用服务协议或相关规则的情况,需要向第三方披露; (e) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷; (f) 在本应用平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,本应用有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。 (g) 其它本应用根据法律、法规或者网站政策认为合适的披露。 +

+ +

4. 信息存储和交换

+ +

+ 本应用收集的有关您的信息和资料将保存在本应用及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或本应用收集信息和资料所在地的境外并在境外被访问、存储和展示。 +

+ +

5. Cookie的使用

+ +

(a) 在您未拒绝接受cookies的情况下,本应用会在您的计算机上设定或取用cookies ,以便您能登录或使用依赖于cookies的本应用平台服务或功能。本应用使用cookies可为您提供更加周到的个性化服务,包括推广服务。 (b) 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的本应用网络服务或功能。 (c) 通过本应用所设cookies所取得的有关信息,将适用本政策。 +

+ +

6. 信息安全

+ +

(a) 本应用帐号均有安全保护功能,请妥善保管您的用户名及密码信息。本应用将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。 (b) 在使用本应用网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易 +

+ +

7.本隐私政策的更改

+ +

+ (a)如果决定更改隐私政策,我们会在本政策中、本公司网站中以及我们认为适当的位置发布这些更改,以便您了解我们如何收集、使用您的个人信息,哪些人可以访问这些信息,以及在什么情况下我们会透露这些信息。 (b)本公司保留随时修改本政策的权利,因此请经常查看。如对本政策作出重大更改,本公司会通过网站通知的形式告知。 方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是本应用用户名及密码发生泄露,请您立即联络本应用客服,以便本应用采取相应措施。 +

+
', + + 'disclaimer_info' => '
+ +
+

1. 非官方性质声明

+

本网站并非美国政府官方网站,也不隶属于美国海关与边境保护局(CBP)。我们是独立的服务提供商,专门协助申请人完成EVUS登记流程。

+
+ +
+

2. 服务范围说明

+

ITS INTERNATIONAL TRAVEL SERVICE COMPANY 仅提供 EVUS 表格填写协助和相关技术支持服务。我们不对最终审批结果作出任何保证或承诺,因为审批权完全在于美国政府相关部门。

+
+ +
+

3. 审批权限声明

+

EVUS申请是否获批完全由美国政府相关部门决定,我们无法影响或加快审批进程。我们的服务仅限于协助您正确填写和提交申请表格。

+
+ +
+

使用本服务即表示您已阅读、理解并同意上述免责声明。

+
+
+ ', + + 'refund_policy_info' => '

1. 支付方式

(a) 本公司接受信用卡、借记卡、PayPal等多种支付方式

(b) 所有支付交易均通过安全加密处理,保障您的资金安全

2. 退款与支付

+

(a) 在提交前,用户可申请退款,退款将在7-14个工作日内处理

+

(b) 一旦申请提交至EVUS系统,费用不予退还,因服务已实际提供

+

(c) 如遇重复扣款等系统问题,经核实后将全额退款

+ +

3. 服务失败

+

(a) 因用户提供的信息不准确或不完整导致申请失败,本公司不退款

+

(b) 因美国政府系统问题导致的申请失败,可提供相应证明申请部分退款

+

(c) 因本公司技术问题导致申请失败,将全额退款或重新提交申请

+', + + 'cookie_policy_info' => '
+ +
' + ], +]; diff --git a/app/log/driver/Monolog.php b/app/log/driver/Monolog.php new file mode 100644 index 0000000..07c7e3b --- /dev/null +++ b/app/log/driver/Monolog.php @@ -0,0 +1,81 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace app\log\driver; + +use think\App; +use think\contract\LogHandlerInterface; + +/** + * 本地化调试输出到文件 + */ +class Monolog implements LogHandlerInterface +{ + /** + * 配置参数 + * @var array + */ + protected $config = [ + 'time_format' => 'c', + 'json_options' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, + + ]; + + + /** + * 日志写入接口 + * @access public + * @param array $log 日志信息 + * @return bool + */ + public function save(array $log): bool + { + $info = []; + // 日志信息封装 + $time = \DateTime::createFromFormat('0.u00 U', microtime())->setTimezone(new \DateTimeZone(date_default_timezone_get()))->format($this->config['time_format']); + foreach ($log as $type => $val) { + $message = []; + foreach ($val as $msg) { + + $message[] = json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) ; + } + $info[$type] = $message; + } + if ($info) { + return $this->write($info); + } + + return true; + } + + /** + * 日志写入 + * @access protected + * @param array $message 日志信息 + * @param string $destination 日志文件 + * @return bool + */ + protected function write(array $message): bool + { + $tcp_log_url = env('TCP_LOG_URL'); + $tcp_log_port = intval(env('TCP_LOG_PORT')); + $project = env('PROJECT_NAME'); + $socket = @fsockopen($tcp_log_url,$tcp_log_port ,$errno, $errstr, 1); + if ($socket) { + fwrite($socket, json_encode(['message' => $message, 'project' => $project], $this->config['json_options'])); + fclose($socket); + } +// + return true; + } + +} diff --git a/app/middleware.php b/app/middleware.php new file mode 100644 index 0000000..13ed756 --- /dev/null +++ b/app/middleware.php @@ -0,0 +1,11 @@ + date('Y-m-d H:i:s'), + 'method' => $request->method(), + 'uri' => $request->url(), + 'params' => $request->param(), + 'headers' => $request->header(), + 'ip' => $request->ip(), + ]; + Log::write($requestInfo, 'request'); + + // 继续处理请求 + $response = $next($request); + + // 记录响应信息 + $responseInfo = [ + 'status' => $response->getCode(), + 'data' => $response->getContent(), + ]; + Log::write($responseInfo, 'response'); + return $response; + } +} diff --git a/app/miniapi/common.php b/app/miniapi/common.php new file mode 100644 index 0000000..ed12357 --- /dev/null +++ b/app/miniapi/common.php @@ -0,0 +1,413 @@ + $value) { + $entry = []; + foreach ($fields as $field) { + $entry[$field] = isset($postData[$field][$index]) ? $postData[$field][$index] : null; + } + $data[] = $entry; + } + + $postData[$kew_key] = json_encode($data, JSON_UNESCAPED_UNICODE); + foreach ($fields as $field) { + unset($postData[$field]); + } + + return $postData; +} + +function find_json($json_name, $field, $field_value) +{ + $data = file_get_contents($json_name); + $data_arr = json_decode($data, true); + $found = array_filter($data_arr, function ($item) use ($field, $field_value) { + return $item[$field] === $field_value; + }); + // 输出结果 + if ($found) { + $found = array_values($found); // 获取过滤后的第一个元素 + return $found; + } else { + return false; + } +} + +function getNameById($json_name, $id) +{ + $data = file_get_contents('./json/' . $json_name . '.json'); + $data_arr = json_decode($data, true); + foreach ($data_arr as $item) { + if (array_key_exists('data', $item['data'])) { + foreach ($item['data']['data'] as $dataItem) { + if ($dataItem['id'] === $id) { + return $dataItem['name']; + } + } + } + } + return null; +} + +function getIdByName($json_name, $id) +{ + $data = file_get_contents('./json/' . $json_name . '.json'); + $data_arr = json_decode($data, true); + foreach ($data_arr as $item) { + if (array_key_exists('data', $item['data'])) { + foreach ($item['data']['data'] as $dataItem) { + if ($dataItem['name'] === $id) { + return $dataItem['id']; + } + } + } + } + return null; +} + +function isMobile() +{ + $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : ''; + + if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', + strtolower($_SERVER['HTTP_USER_AGENT']))) { + return true; + } + if ((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']), + 'application/vnd.wap.xhtml+xml') !== false)) { + return true; + } + if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) { + return true; + } + if (isset($_SERVER['HTTP_PROFILE'])) { + return true; + } + $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)); + $mobile_agents = array( + 'w3c ', + 'acs-', + 'alav', + 'alca', + 'amoi', + 'audi', + 'avan', + 'benq', + 'bird', + 'blac', + 'blaz', + 'brew', + 'cell', + 'cldc', + 'cmd-', + 'dang', + 'doco', + 'eric', + 'hipt', + 'inno', + 'ipaq', + 'java', + 'jigs', + 'kddi', + 'keji', + 'leno', + 'lg-c', + 'lg-d', + 'lg-g', + 'lge-', + 'maui', + 'maxo', + 'midp', + 'mits', + 'mmef', + 'mobi', + 'mot-', + 'moto', + 'mwbp', + 'nec-', + 'newt', + 'noki', + 'oper', + 'palm', + 'pana', + 'pant', + 'phil', + 'play', + 'port', + 'prox', + 'qwap', + 'sage', + 'sams', + 'sany', + 'sch-', + 'sec-', + 'send', + 'seri', + 'sgh-', + 'shar', + 'sie-', + 'siem', + 'smal', + 'smar', + 'sony', + 'sph-', + 'symb', + 't-mo', + 'teli', + 'tim-', + 'tosh', + 'tsm-', + 'upg1', + 'upsi', + 'vk-v', + 'voda', + 'wap-', + 'wapa', + 'wapi', + 'wapp', + 'wapr', + 'webc', + 'winw', + 'winw', + 'xda', + 'xda-' + ); + if (in_array($mobile_ua, $mobile_agents)) { + return true; + } + if (strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) { + return true; + } + // Pre-final check to reset everything if the user is on Windows + if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) { + return false; + } + // But WP7 is also Windows, with a slightly different characteristic + if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) { + return true; + } + return false; +} + +function getOrderNumber() +{ + return date('YmdHis') . mt_rand(10, 99); +} + +function cmf_get_current_user_id() +{ + $sessionUserId = session('user.id'); + if (empty($sessionUserId)) { + return 0; + } + return $sessionUserId; + +} +function getIP() +{ + $realip = ''; + $unknown = 'unknown'; + if (isset($_SERVER)){ + if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_FOR'], $unknown)){ + $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); + foreach($arr as $ip){ + $ip = trim($ip); + if ($ip != 'unknown'){ + $realip = $ip; + break; + } + } + }else if(isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP']) && strcasecmp($_SERVER['HTTP_CLIENT_IP'], $unknown)){ + $realip = $_SERVER['HTTP_CLIENT_IP']; + }else if(isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) && strcasecmp($_SERVER['REMOTE_ADDR'], $unknown)){ + $realip = $_SERVER['REMOTE_ADDR']; + }else{ + $realip = $unknown; + } + }else{ + if(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), $unknown)){ + $realip = getenv("HTTP_X_FORWARDED_FOR"); + }else if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), $unknown)){ + $realip = getenv("HTTP_CLIENT_IP"); + }else if(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), $unknown)){ + $realip = getenv("REMOTE_ADDR"); + }else{ + $realip = $unknown; + } + } + $realip = preg_match("/[\d\.]{7,15}/", $realip, $matches) ? $matches[0] : $unknown; + return $realip; +} +function build_ocr_signature(string $appId, string $secret, ?int $timestamp = null): array +{ + $timestamp = $timestamp ?? time(); + $signString = $appId . "\n" . (string)$timestamp; + $signature = hash_hmac('sha256', $signString, $secret); + + return [ + 'app_id' => $appId, + 'timestamp' => (string)$timestamp, + 'signature' => $signature, + 'base_url' => config('app.OCR_BASE_URL'), + ]; +} +// 这是系统自动生成的公共文件 + +function arrayToJson($params, $values) +{ + + $datas = []; + $count = count($values[0]); + $valcount = count($params); + for ($i = 0; $i < $count; $i++) { + for ($j = 0; $j < $valcount; $j++) { + $data[$params[$j]] = $values[$j][$i]; + } + $datas[] = $data; + } + if (empty($datas)) { + return ''; + } + return json_encode($datas); +} + +function getCate($val) +{ + $cates = explode('-', $val); + if (count($cates) == 1) { + if ($val == 'CNMI') { + return 'CW/E2C'; + } + } else { + preg_match_all('/[A-Z]+/', $val, $matches); + return $matches[0][0]; + } + + +} +//非常给力的authcode加密函数,Discuz!经典代码(带详解) +function authcode($string, $operation = 'DECODE', $key = '20241021', $expiry = 0) +{ + // 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙 + $ckey_length = 4; + + // 密匙 + $key = md5($key ? $key : $GLOBALS['discuz_auth_key']); + + // 密匙a会参与加解密 + $keya = md5(substr($key, 0, 16)); + // 密匙b会用来做数据完整性验证 + $keyb = md5(substr($key, 16, 16)); + // 密匙c用于变化生成的密文 + $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length)) : ''; + // 参与运算的密匙 + $cryptkey = $keya . md5($keya . $keyc); + $key_length = strlen($cryptkey); + // 明文,前10位用来保存时间戳,解密时验证数据有效性,10到26位用来保存$keyb(密匙b), + //解密时会通过这个密匙验证数据完整性 + // 如果是解码的话,会从第$ckey_length位开始,因为密文前$ckey_length位保存 动态密匙,以保证解密正确 + $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string; + $string_length = strlen($string); + $result = ''; + $box = range(0, 255); + $rndkey = array(); + // 产生密匙簿 + for ($i = 0; $i <= 255; $i++) { + $rndkey[$i] = ord($cryptkey[$i % $key_length]); + } + // 用固定的算法,打乱密匙簿,增加随机性,好像很复杂,实际上对并不会增加密文的强度 + for ($j = $i = 0; $i < 256; $i++) { + $j = ($j + $box[$i] + $rndkey[$i]) % 256; + $tmp = $box[$i]; + $box[$i] = $box[$j]; + $box[$j] = $tmp; + } + // 核心加解密部分 + for ($a = $j = $i = 0; $i < $string_length; $i++) { + $a = ($a + 1) % 256; + $j = ($j + $box[$a]) % 256; + $tmp = $box[$a]; + $box[$a] = $box[$j]; + $box[$j] = $tmp; + // 从密匙簿得出密匙进行异或,再转成字符 + $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); + } + if ($operation == 'DECODE') { + // 验证数据有效性,请看未加密明文的格式 + if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) { + return substr($result, 26); + } else { + return ''; + } + } else { + // 把动态密匙保存在密文里,这也是为什么同样的明文,生产不同密文后能解密的原因 + // 因为加密后的密文可能是一些特殊字符,复制过程可能会丢失,所以用base64编码 + return $keyc . str_replace('=', '', base64_encode($result)); + } +} +function getChineseCode($code) +{ + $url = "http://code.mcdvisa.com/save.php?action=getcode&i=0&w={$code}"; + $data = file_get_contents($url); + if (empty($data)){ + return [ + 'code'=>0, + 'data'=>[] + ]; + } +// 创建 DOMDocument 对象并加载 HTML + $dom = new DOMDocument(); + libxml_use_internal_errors(true); // 抑制 HTML 解析错误 + $dom->loadHTML($data); + libxml_clear_errors(); + // 获取所有的
  • 元素 + $lis = $dom->getElementsByTagName('li'); + $pattern = '/-?\d+(?:\.\d+)?/'; + $datas=[]; + foreach ($lis as $li) { + $text = $li->textContent; + preg_match_all($pattern, $text, $matches); + $datas[] = $matches[0][0]; + } + return [ + 'code'=>200, + 'data'=>$datas + ]; +} diff --git a/app/miniapi/controller/Auth.php b/app/miniapi/controller/Auth.php new file mode 100644 index 0000000..bc51484 --- /dev/null +++ b/app/miniapi/controller/Auth.php @@ -0,0 +1,134 @@ +postData(); + if ($error = $this->requireFields($data, ['mobile'])) { + return $error; + } + + $code = mt_rand(1001, 9999); + $response = Httpcurl::request(YZM_URL, 'post', [ + 'mobile' => $data['mobile'], + 'code' => $code, + ]); + $result = $this->decodeResponse($response, 'miniapi send sms'); + if (empty($result) || intval($result['code'] ?? 0) !== 1) { + return $this->fail('发送验证码失败'); + } + + Session::set($data['mobile'] . '_code', $code); + Session::set($data['mobile'] . '_' . $code, time()); + return $this->ok([], '发送成功'); + } + + public function login() + { + $data = $this->postData(); + try { + $this->validate($data, [ + 'mobile' => 'require', + 'code' => 'require', + ], [ + 'mobile.require' => '手机号不能为空', + 'code.require' => '验证码不能为空', + ]); + } catch (ValidateException $e) { + return $this->fail($e->getError()); + } + + $sms = Session::get($data['mobile'] . '_code'); + if (empty($sms) || strval($sms) !== strval($data['code'])) { + return $this->fail('验证码不正确'); + } + + $codeTime = Session::get($data['mobile'] . '_' . $data['code']); + if (empty($codeTime) || (time() - intval($codeTime)) > 300) { + Session::delete($data['mobile'] . '_code'); + Session::delete($data['mobile'] . '_' . $data['code']); + return $this->fail('验证码超时,请重新发送'); + } + + $openid = ''; + if (!empty($data['login_code'])) { + $openid = $this->wechatService()->openidByLoginCode((string)$data['login_code']); + } + + return $this->loginByMobile((string)$data['mobile'], $openid); + } + + public function wxPhoneLogin() + { + $data = $this->postData(); + if ($error = $this->requireFields($data, ['phone_code', 'login_code'])) { + return $error; + } + + $wechat = $this->wechatService(); + $openid = $wechat->openidByLoginCode((string)$data['login_code'], true); + if ($openid === '') { + return $this->fail('微信登录失败,请使用验证码登录'); + } + + $mobile = $wechat->mobileByPhoneCode((string)$data['phone_code']); + if ($mobile === '') { + return $this->fail('微信手机号获取失败,请使用验证码登录'); + } + + return $this->loginByMobile($mobile, $openid); + } + + public function me() + { + $userId = $this->currentUserId(); + if ($userId <= 0) { + return $this->ok(['isLogin' => false]); + } + + return $this->ok([ + 'isLogin' => true, + 'user' => [ + 'id' => $userId, + ], + ]); + } + + private function loginByMobile(string $mobile, string $openid = '') + { + $response = Httpcurl::request(config('app.user_url'), 'post', [ + 'model' => MODEL, + 'mobile' => $mobile, + ]); + $result = $this->decodeResponse($response, 'miniapi login'); + if (empty($result) || intval($result['code'] ?? 0) !== 1 || empty($result['data']['id'])) { + return $this->fail('账号不存在'); + } + + $user = $result['data']; + return $this->ok([ + 'token' => authcode((string)$user['id'], 'ENCODE', MINIAPI_TOKEN_KEY, MINIAPI_TOKEN_EXPIRE), + 'expires_in' => MINIAPI_TOKEN_EXPIRE, + 'openid' => $openid, + 'user' => [ + 'id' => intval($user['id']), + 'mobile' => $user['mobile'] ?? $mobile, + 'nickname' => $user['nickname'] ?? '微信用户', + ], + ], '登录成功'); + } + + private function wechatService(): MiniProgramWechatService + { + return new MiniProgramWechatService($this->currentMiniAppCode(), $this->currentMiniApp()); + } +} diff --git a/app/miniapi/controller/Base.php b/app/miniapi/controller/Base.php new file mode 100644 index 0000000..baa0eab --- /dev/null +++ b/app/miniapi/controller/Base.php @@ -0,0 +1,283 @@ +initializeMiniAppContext(); + $this->loadSiteConfig(); + } + + protected function ok($data = [], string $msg = 'ok') + { + return json([ + 'code' => 1, + 'msg' => $msg, + 'data' => $data, + ]); + } + + protected function fail(string $msg = '操作失败', int $code = 0, $data = []) + { + $httpStatus = in_array($code, [401, 403], true) ? $code : 200; + + return json([ + 'code' => $code, + 'msg' => $msg, + 'data' => $data, + ], $httpStatus); + } + + protected function postData(): array + { + $data = $this->request->post(); + if (!empty($data)) { + return $data; + } + + $raw = $this->request->getInput(); + $json = json_decode($raw, true); + return is_array($json) ? $json : []; + } + + protected function requireFields(array $data, array $fields) + { + foreach ($fields as $field) { + if (!isset($data[$field]) || $data[$field] === '') { + return $this->fail('缺少参数:' . $field); + } + } + + return null; + } + + protected function decodeResponse($response, string $scene): array + { + if (!is_array($response) || !isset($response[0]) || !empty($response[3])) { + Log::error($scene . ' request failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); + return []; + } + + $result = json_decode($response[0], true); + if (!is_array($result)) { + Log::error($scene . ' response decode failed: ' . $response[0]); + return []; + } + + return $result; + } + + protected function currentUserId(): int + { + $token = $this->currentToken(); + if ($token === '') { + return 0; + } + + $userId = authcode($token, 'DECODE', MINIAPI_TOKEN_KEY); + return is_numeric($userId) ? intval($userId) : 0; + } + + protected function requireLogin() + { + $userId = $this->currentUserId(); + if ($userId <= 0) { + return $this->fail('请先登录', 401); + } + + return $userId; + } + + protected function currentMiniAppCode(): string + { + return $this->miniAppCode; + } + + protected function currentMiniApp(): array + { + return $this->miniApp; + } + + protected function currentCompanyCode(): string + { + return (string)($this->miniApp['company_code'] ?? ''); + } + + protected function currentMiniAppContext(string $businessCode = 'evus'): MiniAppContext + { + $context = (array)Config::get('app.miniapi_context', []); + + return new MiniAppContext([ + 'mini_app_code' => $this->currentMiniAppCode(), + 'company_code' => $this->currentCompanyCode(), + 'business_code' => $businessCode, + 'site_domain' => (string)($context['site_domain'] ?? ''), + 'mini_app' => $this->currentMiniApp(), + 'site' => (array)Config::get('app.miniapi_site', []), + ]); + } + + private function currentToken(): string + { + $token = trim((string)$this->request->header('Authorization', '')); + if (stripos($token, 'Bearer ') === 0) { + $token = trim(substr($token, 7)); + } + + if ($token === '') { + $token = trim((string)$this->request->param('token', '')); + } + + return $token; + } + + private function loadSiteConfig(): void + { + $configFile = $this->siteConfigFile(); + if (!file_exists($configFile)) { + $legacyConfig = $this->legacySiteConfig(); + if (!empty($legacyConfig)) { + $config = $legacyConfig; + file_put_contents($configFile, json_encode($config, JSON_UNESCAPED_UNICODE)); + } else { + $domain = $this->siteConfigDomain(); + $response = Httpcurl::request(GET_WEB_CONFIG_URL . '/domain/' . $domain, 'get'); + $config = $this->decodeResponse($response, 'site config'); + if (empty($config) || intval($config['code'] ?? 0) !== 1) { + return; + } + file_put_contents($configFile, json_encode($config, JSON_UNESCAPED_UNICODE)); + } + } else { + $config = json_decode(file_get_contents($configFile), true); + } + + if (empty($config['data']) || !is_array($config['data'])) { + return; + } + + $data = $config['data']; + Config::set(['EVUS_GOODS' => $data['EVUS_GOODS'] ?? []], 'app'); + Config::set(['ESTA_GOODS' => $data['ESTA_GOODS'] ?? []], 'app'); + Config::set(['pay_url' => $data['pay']['pay_url'] ?? ''], 'app'); + Config::set(['order_url' => $data['order_url'] ?? ''], 'app'); + Config::set(['user_url' => $data['user_url'] ?? ''], 'app'); + Config::set(['get_evus_detail_url' => $data['get_evus_detail_url'] ?? ''], 'app'); + Config::set(['get_order_detail_url' => $data['get_order_detail_url'] ?? ''], 'app'); + Config::set(['download_evus_url' => $data['download_evus_url'] ?? ''], 'app'); + Config::set(['update_order_url' => $data['update_order_url'] ?? ''], 'app'); + Config::set(['LOOKUP_URL' => $data['evus_look_url'] ?? ''], 'app'); + Config::set(['OCR_BASE_URL' => $data['ocr_base_url'] ?? ''], 'app'); + Config::set(['OCR_APP_ID' => $data['ocr_app_id'] ?? ''], 'app'); + Config::set(['OCR_SECRET' => $data['ocr_secret'] ?? ''], 'app'); + Config::set(['miniapi_site' => [ + 'company_name' => $data['company_name'] ?? '', + 'principals' => $data['principals'] ?? '', + 'phone' => $data['phone'] ?? '', + 'brief' => $data['brief'] ?? '', + 'footer' => $data['footer'] ?? '', + 'logo' => $data['logo'] ?? '', + 'logo_icon' => $data['logo_icon'] ?? '', + ]], 'app'); + } + + private function initializeMiniAppContext(): void + { + $apps = Config::get('miniapp.apps', []); + $headerName = (string)Config::get('miniapp.header_name', 'X-Mini-App-Code'); + $defaultCode = (string)Config::get('miniapp.default_code', ''); + + $code = trim((string)$this->request->header($headerName, '')); + if ($code === '') { + $code = trim((string)$this->request->param('mini_app_code', '')); + } + $hasExplicitCode = $code !== ''; + if ($code === '') { + $code = $defaultCode; + } + + if ($code !== '' && (!isset($apps[$code]) || intval($apps[$code]['status'] ?? 1) !== 1)) { + Log::warning('miniapp config not found or disabled: ' . $code); + if ($hasExplicitCode) { + throw new HttpResponseException($this->fail('mini app config not found', 403)); + } + $code = $defaultCode; + } + + $this->miniAppCode = $code; + $this->miniApp = $apps[$code] ?? []; + if (!empty($this->miniApp)) { + $this->miniApp['code'] = $code; + } + + Config::set(['miniapi_context' => [ + 'mini_app_code' => $this->miniAppCode, + 'company_code' => $this->currentCompanyCode(), + 'site_domain' => $this->siteConfigDomain(), + ]], 'app'); + } + + private function siteConfigFile(): string + { + $configDir = app()->getRootPath() . 'data/config/'; + if (!is_dir($configDir)) { + mkdir($configDir, 0755, true); + } + + return $configDir . $this->siteConfigCacheKey() . '.json'; + } + + private function legacySiteConfig(): array + { + $defaultCode = (string)Config::get('miniapp.default_code', ''); + if ($this->miniAppCode !== $defaultCode) { + return []; + } + + $legacyFile = app()->getRootPath() . 'data/config.json'; + if (!file_exists($legacyFile)) { + return []; + } + + $config = json_decode(file_get_contents($legacyFile), true); + return is_array($config) ? $config : []; + } + + private function siteConfigDomain(): string + { + $domain = trim((string)($this->miniApp['site_domain'] ?? '')); + if ($domain === '') { + $domain = trim((string)Config::get('app.site_domain', '')); + } + if ($domain === '') { + return $this->request->host(); + } + + if (stripos($domain, 'http://') === 0 || stripos($domain, 'https://') === 0) { + $host = parse_url($domain, PHP_URL_HOST); + return $host ?: $this->request->host(); + } + + return trim(explode('/', $domain)[0]); + } + + private function siteConfigCacheKey(): string + { + $key = $this->miniAppCode ?: $this->siteConfigDomain(); + $key = preg_replace('/[^a-zA-Z0-9_.-]/', '_', $key); + return $key ?: 'default'; + } +} diff --git a/app/miniapi/controller/Esta.php b/app/miniapi/controller/Esta.php new file mode 100644 index 0000000..b7e55e2 --- /dev/null +++ b/app/miniapi/controller/Esta.php @@ -0,0 +1,107 @@ +requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $data = $this->postData(); + if (empty($data['passport_img'])) { + return $this->fail('请上传护照照片'); + } + if (empty($data['person_img'])) { + return $this->fail('请上传个人照片'); + } + if ($error = $this->requireFields($data, ['total_price'])) { + return $error; + } + + $context = $this->currentMiniAppContext('esta'); + $product = (new ProductService())->findByValue($context, $data['total_price']); + if (empty($product)) { + return $this->fail('价格错误'); + } + + $totalPrice = $product['value']; + $orderSn = getOrderNumber(); + $payload = $this->buildOrderPayload($data, $orderSn, $product, $userId); + $response = Httpcurl::request(CREATE_ORDER_URL, 'post', $payload); + $result = $this->decodeResponse($response, 'miniapi esta apply'); + if (empty($result) || intval($result['code'] ?? 0) !== 1) { + return $this->fail($result['msg'] ?? '提交失败,请联系管理员'); + } + + if (!empty($data['openid'])) { + $pay = $this->requestMiniPay($context, $orderSn, $totalPrice, $data['openid']); + if ($pay['code'] !== 1) { + return $this->fail($pay['msg']); + } + + return $this->ok([ + 'order_sn' => $orderSn, + 'pay' => $pay['data'], + ], '提交成功'); + } + + return $this->ok([ + 'order_sn' => $orderSn, + 'pay' => null, + ], '提交成功'); + } + + private function buildOrderPayload(array $data, string $orderSn, array $product, int $userId): array + { + $payload = $data; + unset($payload['token']); + + $totalPrice = (string)$product['value']; + $payload['user_id'] = $userId; + $payload['order_sn'] = $orderSn; + $payload['source'] = 'qlwxmini'; + $payload['is_mobile'] = 1; + $payload['total_price'] = $totalPrice; + $payload['origin_price'] = $totalPrice; + $payload['product_value'] = $totalPrice; + $payload['product_name'] = (string)($product['name'] ?? ''); + $payload['product_desc'] = (string)($product['desc'] ?? ''); + $payload['ip'] = getIP(); + $payload['coupon_code'] = $payload['coupon_code'] ?? ''; + $payload['model'] = ESTA_MODEL; + $payload['token'] = md5(ESTA_MODEL); + $payload['other_country_acquired_other'] = $payload['other_country_acquired_other'] ?? ''; + + foreach ([ + 'birth_date' => 'birth_date', + 'passport_expedition_date' => 'passport_expedition_date', + 'passport_expiration_date' => 'passport_expiration_date', + 'other_country_date' => 'other_country_date', + 'other_country_edate' => 'other_country_edate', + ] as $field => $prefix) { + $date = date_parse($payload[$field] ?? ''); + $payload[$prefix . '_day'] = (string)($date['day'] ?: ''); + $payload[$prefix . '_month'] = (string)($date['month'] ?: ''); + $payload[$prefix . '_year'] = (string)($date['year'] ?: ''); + } + + unset($payload['other_country_date'], $payload['other_country_edate']); + + return $payload; + } + + private function requestMiniPay(MiniAppContext $context, string $orderSn, $money, string $openid): array + { + return (new MiniPayService())->request($context, $orderSn, $money, $openid, 'miniapi esta mini pay'); + } +} diff --git a/app/miniapi/controller/Evus.php b/app/miniapi/controller/Evus.php new file mode 100644 index 0000000..91dcfeb --- /dev/null +++ b/app/miniapi/controller/Evus.php @@ -0,0 +1,139 @@ +postData(); + if ($error = $this->requireFields($data, [ + 'passport_number', + 'visa_foil_number', + 'last_name', + 'first_name', + 'birth_date', + 'country_birth', + ])) { + return $error; + } + + $birth = date_parse($data['birth_date']); + $params = [ + 'passportNum' => $data['passport_number'], + 'b1b2Num' => $data['visa_foil_number'], + 'surname' => $data['last_name'], + 'givenname' => $data['first_name'], + 'year_birthday' => (string)($birth['year'] ?: ''), + 'month_birthday' => (string)($birth['month'] ?: ''), + 'day_birthday' => (string)($birth['day'] ?: ''), + 'country_birth' => $data['country_birth'], + ]; + + $response = Httpcurl::request(config('app.LOOKUP_URL'), 'post', json_encode($params, JSON_UNESCAPED_UNICODE), [ + 'Content-Type: application/json', + ]); + $result = $this->decodeResponse($response, 'miniapi evus lookup'); + if (empty($result)) { + return $this->fail('服务异常,请稍后重试'); + } + + return $this->ok($result); + } + + public function apply() + { + $userId = $this->requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $data = $this->postData(); + if ($error = $this->requireFields($data, ['total_price'])) { + return $error; + } + + $context = $this->currentMiniAppContext('evus'); + $product = (new ProductService())->findByValue($context, $data['total_price']); + if (empty($product)) { + return $this->fail('价格错误'); + } + $totalPrice = $product['value']; + + $orderSn = getOrderNumber(); + $payload = $this->buildOrderPayload($data, $orderSn, $product, $userId); + $response = Httpcurl::request(CREATE_EVUS_ORDER_URL, 'post', $payload); + $result = $this->decodeResponse($response, 'miniapi evus apply'); + if (empty($result) || intval($result['code'] ?? 0) !== 1) { + return $this->fail($result['msg'] ?? '提交失败,请联系管理员'); + } + + if (!empty($data['openid'])) { + $pay = $this->requestMiniPay($context, $orderSn, $totalPrice, $data['openid']); + if ($pay['code'] !== 1) { + return $this->fail($pay['msg']); + } + return $this->ok([ + 'order_sn' => $orderSn, + 'pay' => $pay['data'], + ], '提交成功'); + } + + return $this->ok([ + 'order_sn' => $orderSn, + 'pay' => null, + ], '提交成功'); + } + + private function buildOrderPayload(array $data, string $orderSn, array $product, int $userId): array + { + $payload = $data; + unset($payload['token']); + $totalPrice = (string)$product['value']; + $payload['user_id'] = $userId; + $payload['order_sn'] = $orderSn; + $payload['source'] = 'qlwxmini'; + $payload['is_mobile'] = 1; + $payload['total_price'] = $totalPrice; + $payload['origin_price'] = $totalPrice; + $payload['product_value'] = $totalPrice; + $payload['product_name'] = (string)($product['name'] ?? ''); + $payload['product_desc'] = (string)($product['desc'] ?? ''); + $payload['ip'] = getIP(); + $payload['coupon_code'] = $payload['coupon_code'] ?? ''; + $payload['model'] = MODEL; + $payload['token'] = md5(MODEL); + + foreach ([ + 'birth_date' => 'birth_date', + 'passport_expedition_date' => 'passport_expedition_date', + 'passport_expiration_date' => 'passport_expiration_date', + 'us_visa_passport_issue_date' => 'us_visa_passport_issue_date', + 'us_visa_passport_expiration_date' => 'us_visa_passport_expiration_date', + 'us_visa_birth_date' => 'us_visa_birth_date', + ] as $field => $prefix) { + $date = date_parse($payload[$field] ?? ''); + $payload[$prefix . '_day'] = (string)($date['day'] ?: ''); + $payload[$prefix . '_month'] = (string)($date['month'] ?: ''); + $payload[$prefix . '_year'] = (string)($date['year'] ?: ''); + } + + if (isset($payload['vist_country']) && is_array($payload['vist_country'])) { + $payload = formDataToJson(['vist_country', 'vist_from_date', 'vist_end_date', 'vist_country_des'], $payload, 'vistitem', 'question_i'); + } + + $payload['other_country_acquired_other'] = $payload['other_country_acquired_other'] ?? ''; + return $payload; + } + + private function requestMiniPay(MiniAppContext $context, string $orderSn, $money, string $openid): array + { + return (new MiniPayService())->request($context, $orderSn, $money, $openid, 'miniapi evus mini pay'); + } +} diff --git a/app/miniapi/controller/Help.php b/app/miniapi/controller/Help.php new file mode 100644 index 0000000..cc4ff88 --- /dev/null +++ b/app/miniapi/controller/Help.php @@ -0,0 +1,57 @@ +ok([ + [ + 'question' => '什么是签证更新电子系统(EVUS)?', + 'answer' => '签证更新电子系统是持有十年有效 B1/B2、B1 或 B2 访问者签证的中国公民使用的个人基本信息在线定期更新系统。除有效签证外,相关旅客还需要完成 EVUS 登记,才能获得赴美旅行许可。' + ], + [ + 'question' => 'EVUS登记从哪一天开始强制施行?', + 'answer' => '自 2016 年 11 月 29 日起,持中华人民共和国护照并持有最长有效期十年 B1/B2、B1 或 B2 签证的个人,必须持有有效的 EVUS 登记才能赴美旅行。没有有效登记的旅客将不能获得登机牌或经由陆地入境口入境。' + ], + [ + 'question' => 'B1/B2签证有效期有什么要求?', + 'answer' => '绝大多数 B1/B2 签证有效期为 10 年,所有十年 B1/B2 签证在前往美国前都需要完成 EVUS 更新。极个别低于 10 年有效期的 B1/B2 签证,通常不需要进行 EVUS 登记。' + ], + [ + 'question' => '护照有效期和换发护照会影响EVUS吗?', + 'answer' => '16 岁以上护照有效期通常为 10 年,16 岁以下通常为 5 年。护照有效期低于 6 个月时禁止前往美国。如果护照过期或有效期不足,需要换发新护照;换发时应保留含有效美国签证的旧护照。' + ], + [ + 'question' => '美国B1/B2签证EVUS有效期是多久?', + 'answer' => '如果十年 B1/B2 签证有效且护照有效期大于 2 年 6 个月,EVUS 通常有效期为 2 年。如果护照有效期少于 2 年 6 个月,EVUS 有效期通常按护照实际有效期减去 6 个月计算。' + ], + [ + 'question' => 'EVUS失效或个人信息变更后需要更新吗?', + 'answer' => 'EVUS 过期并不必然导致美国签证失效,可以在前往美国前重新登记。若住址、工作信息、赴美地址、联系方式等个人信息发生变化,建议及时更新 EVUS。' + ], + [ + 'question' => 'EVUS登记需要准备什么?', + 'answer' => '旅客需要准备含有最长有效期十年 B1/B2、B1 或 B2 签证的中华人民共和国护照,并确保可以连接互联网。持十年有效期签证的未成年人,也需要持有效个人护照并在赴美前申请 EVUS。' + ], + [ + 'question' => 'EVUS表格上会填写哪些问题?', + 'answer' => '每次登记都需要提供姓名、出生日期、紧急联系人、护照信息、个人和就业信息,并回答旅行资格相关问题。朋友、亲属、专业旅游从业人员或第三方可以代为提交,但旅客本人应对信息真实性和准确性负责。' + ], + [ + 'question' => '进入美国是否需要登记EVUS?', + 'answer' => '是的。自 2016 年 11 月起需要登记。该要求用于定期更新旅客个人信息,有助于加快中国旅客入境美国。' + ], + [ + 'question' => '其他国家是否也有EVUS要求?', + 'answer' => 'EVUS 是一项针对特定旅客的信息更新要求。美国政府曾预期未来可能将类似要求适用于其他国家。' + ], + [ + 'question' => '刚拿到十年B1/B2签证,还需要申请新签证吗?', + 'answer' => '不需要,原签证仍然有效。但如果在 2016 年 11 月以后前往美国,需要先完成 EVUS 登记。EVUS 登记和申请签证是两个不同的程序。' + ], + ]); + } +} diff --git a/app/miniapi/controller/Index.php b/app/miniapi/controller/Index.php new file mode 100644 index 0000000..7101812 --- /dev/null +++ b/app/miniapi/controller/Index.php @@ -0,0 +1,87 @@ +ok([ + 'site' => Config::get('app.miniapi_site', []), + 'packages' => $products->list($this->currentMiniAppContext('evus')), + 'quickEntries' => [ + ['key' => 'apply', 'title' => '开始登记', 'path' => '/pages/apply/index'], + ['key' => 'query', 'title' => '状态查询', 'path' => '/pages/query/index'], + ['key' => 'orders', 'title' => '我的订单', 'path' => '/pages/orders/index'], + ['key' => 'help', 'title' => '帮助中心', 'path' => '/pages/help/index'], + ], + ]); + } + + public function packages() + { + $businessCode = strtolower(trim((string)$this->request->param('business', 'evus'))) ?: 'evus'; + return $this->ok((new ProductService())->list($this->currentMiniAppContext($businessCode))); + } + + public function about() + { + $site = Config::get('app.miniapi_site', []); + $companyName = trim((string)($site['company_name'] ?? '')) ?: 'EVUS登记助手'; + $brief = $this->plainText((string)($site['brief'] ?? '')); + + return $this->ok([ + 'title' => '关于我们', + 'company_name' => $companyName, + 'content' => $brief ?: $companyName . '提供 EVUS 登记资料提交、订单查询和进度管理服务。', + 'phone' => (string)($site['phone'] ?? ''), + 'notice' => '我们不是美国政府官方网站,登记结果以官方系统为准。', + 'logo' => (string)($site['logo'] ?? ''), + 'logo_icon' => (string)($site['logo_icon'] ?? ''), + ]); + } + + public function legal() + { + $type = strtolower(trim((string)$this->request->param('type', 'terms'))); + $businessCode = strtolower(trim((string)$this->request->param('business', 'evus'))) ?: 'evus'; + $document = (new LegalDocumentService())->get($this->currentMiniAppContext($businessCode), $type); + + if (empty($document)) { + return $this->fail('legal type not found', 404); + } + + return $this->ok($document); + } + + public function countries() + { + $file = app()->getRootPath() . 'public/json/country.json'; + if (!file_exists($file)) { + return $this->ok([]); + } + + $countries = json_decode(file_get_contents($file), true); + return $this->ok(is_array($countries) ? $countries : []); + } + + private function plainText(string $html): string + { + $html = preg_replace('/<\s*(h[1-6]|div|section|li)\b[^>]*>/i', "\n", $html); + $html = preg_replace('/<\s*\/\s*(h[1-6]|div|section|li)\s*>/i', "\n", (string)$html); + $text = preg_replace('/<\s*br\s*\/?\s*>/i', "\n", $html); + $text = preg_replace('/<\s*\/p\s*>/i', "\n", $text); + $text = strip_tags((string)$text); + $text = html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $text = preg_replace("/[ \t\r]+/", ' ', $text); + $text = preg_replace("/\n{3,}/", "\n\n", $text); + return trim((string)$text); + } + +} diff --git a/app/miniapi/controller/News.php b/app/miniapi/controller/News.php new file mode 100644 index 0000000..d7ccc01 --- /dev/null +++ b/app/miniapi/controller/News.php @@ -0,0 +1,79 @@ +request->param('page', 1))); + $size = max(1, intval($this->request->param('size', 10))); + $response = Httpcurl::request(NEWS_LIST, 'post', [ + 'model' => 'article', + 'page' => $page, + 'size' => $size, + ]); + $result = $this->decodeResponse($response, 'miniapi news list'); + if (empty($result) || intval($result['code'] ?? 0) !== 1) { + return $this->ok(['list' => [], 'count' => 0, 'page' => $page, 'size' => $size]); + } + + return $this->ok([ + 'list' => $this->normalizeList($result['data'] ?? []), + 'count' => intval($result['count'] ?? count($result['data'] ?? [])), + 'page' => $page, + 'size' => $size, + ]); + } + + public function detail() + { + $id = intval($this->request->param('id', 0)); + if ($id <= 0) { + return $this->fail('参数错误'); + } + + $response = Httpcurl::request(NEWS_DETAIL, 'post', [ + 'model' => 'article', + 'id' => $id, + ]); + $result = $this->decodeResponse($response, 'miniapi news detail'); + if (empty($result) || intval($result['code'] ?? 0) !== 1 || empty($result['data'])) { + return $this->fail('新闻详情获取失败'); + } + + return $this->ok($this->normalizeItem($result['data'])); + } + + private function normalizeList($list): array + { + if (!is_array($list)) { + return []; + } + + $data = []; + foreach ($list as $item) { + $data[] = $this->normalizeItem($item); + } + + return $data; + } + + private function normalizeItem($item): array + { + if (!is_array($item)) { + return []; + } + + return [ + 'id' => intval($item['id'] ?? 0), + 'title' => $item['title'] ?? '', + 'content' => $item['contents'] ?? ($item['content'] ?? ''), + 'create_time' => $item['create_time'] ?? '', + ]; + } +} + diff --git a/app/miniapi/controller/Ocr.php b/app/miniapi/controller/Ocr.php new file mode 100644 index 0000000..ba5dc4b --- /dev/null +++ b/app/miniapi/controller/Ocr.php @@ -0,0 +1,68 @@ + '/ocr/passport/base64', + 'visa' => '/ocr/visa-number/base64', + 'identification' => '/ocr/idcard/base64', + ]; + + public function signature() + { + $type = strtolower(trim((string)$this->request->param('type', 'passport'))); + if (!isset(self::ENDPOINTS[$type])) { + return $this->fail('不支持的识别类型'); + } + + $appId = (string)(config('app.OCR_APP_ID') ?? ''); + $secret = (string)(config('app.OCR_SECRET') ?? ''); + $baseUrl = (string)(config('app.OCR_BASE_URL') ?? ''); + if ($appId === '' || $secret === '' || $baseUrl === '') { + return $this->fail('OCR服务配置未完成'); + } + + $signature = build_ocr_signature($appId, $secret); + $signature['endpoint'] = self::ENDPOINTS[$type]; + $signature['origin'] = $this->resolveOrigin(); + $signature['expires_in'] = 300; + $signature['auto_rotate'] = true; + $signature['return_debug'] = false; + + return $this->ok($signature); + } + + private function resolveOrigin(): string + { + $origin = trim((string)(config('app.OCR_ORIGIN') ?? config('ocr.origin', ''))); + if ($origin === '') { + $context = (array)(config('app.miniapi_context') ?? []); + $origin = trim((string)($context['site_domain'] ?? '')); + } + if ($origin === '') { + return ''; + } + + if (!preg_match('/^https?:\/\//i', $origin)) { + $origin = 'https://' . $origin; + } + + $parts = parse_url($origin); + if (!is_array($parts) || empty($parts['host'])) { + return ''; + } + + $scheme = strtolower((string)($parts['scheme'] ?? 'https')); + if (!in_array($scheme, ['http', 'https'], true)) { + return ''; + } + + $port = isset($parts['port']) ? ':' . (int)$parts['port'] : ''; + return $scheme . '://' . $parts['host'] . $port; + } +} diff --git a/app/miniapi/controller/Order.php b/app/miniapi/controller/Order.php new file mode 100644 index 0000000..8192032 --- /dev/null +++ b/app/miniapi/controller/Order.php @@ -0,0 +1,193 @@ +requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $payStatus = (string)$this->request->param('pay_status', 'pay'); + if (!in_array($payStatus, ['pay', 'nopay'], true)) { + return $this->fail('参数错误'); + } + + $business = $this->businessCode((string)$this->request->param('business', 'evus')); + $model = $this->businessModel($business); + $invoiceType = $this->businessInvoiceType($business); + + $response = Httpcurl::request(GET_ORDER_URL, 'post', [ + 'model' => $model, + 'user_id' => $userId, + 'invoiceType' => $invoiceType, + 'pay_status' => $payStatus, + ]); + $result = $this->decodeResponse($response, 'miniapi order list'); + if (empty($result) || intval($result['code'] ?? 0) !== 1) { + return $this->ok([]); + } + + $orders = array_map(static function ($item) use ($business) { + if (is_array($item)) { + $item['business'] = $business; + $item['business_text'] = $business === 'esta' ? 'ESTA' : 'EVUS'; + } + return $item; + }, (array)($result['data'] ?? [])); + + return $this->ok($orders); + } + + public function detail() + { + $userId = $this->requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $orderSn = (string)$this->request->param('order_sn', ''); + if ($orderSn === '') { + return $this->fail('参数错误'); + } + + $business = $this->businessCode((string)$this->request->param('business', 'evus')); + $data = $this->fetchOrderDetail($orderSn, $business, $userId); + if (isset($data['error'])) { + return $this->fail($data['error'], intval($data['code'] ?? 0)); + } + + return $this->ok($data); + } + + public function pay() + { + $userId = $this->requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $data = $this->postData(); + $orderSn = trim((string)($data['order_sn'] ?? '')); + $business = $this->businessCode((string)($data['business'] ?? 'evus')); + $openid = trim((string)($data['openid'] ?? '')); + if ($orderSn === '' || $openid === '') { + return $this->fail('参数错误'); + } + + $detail = $this->fetchOrderDetail($orderSn, $business, $userId); + if (isset($detail['error'])) { + return $this->fail($detail['error'], intval($detail['code'] ?? 0)); + } + + $money = $this->payMoney($detail); + if ($money === '') { + return $this->fail('订单金额异常'); + } + + $pay = (new MiniPayService())->request( + $this->currentMiniAppContext($business), + $orderSn, + $money, + $openid, + 'miniapi order mini pay' + ); + if ($pay['code'] !== 1) { + return $this->fail($pay['msg']); + } + + return $this->ok([ + 'order_sn' => $orderSn, + 'pay' => $pay['data'], + ], 'ok'); + } + + private function fetchOrderDetail(string $orderSn, string $business, int $userId): array + { + $model = $this->businessModel($business); + $detailUrl = $business === 'esta' ? config('app.get_order_detail_url') : config('app.get_evus_detail_url'); + if (empty($detailUrl)) { + return ['error' => '订单详情接口未配置']; + } + + $response = Httpcurl::request($detailUrl, 'post', [ + 'order_sn' => $orderSn, + 'model' => $model, + 'user_id' => $userId, + ]); + $result = $this->decodeResponse($response, 'miniapi order detail'); + if (empty($result) || intval($result['code'] ?? 0) !== 1) { + return ['error' => $result['msg'] ?? '订单不存在']; + } + + $data = $result['data'] ?? []; + $orderUserId = intval($data['user_id'] ?? $data['order']['user_id'] ?? 0); + if ($orderUserId > 0 && $orderUserId !== $userId) { + return ['error' => '无权访问该订单', 'code' => 403]; + } + + if (is_array($data)) { + $data['business'] = $business; + $data['business_text'] = $business === 'esta' ? 'ESTA' : 'EVUS'; + } + + return is_array($data) ? $data : []; + } + + private function businessCode(string $business): string + { + $business = strtolower(trim($business)); + return $business === 'esta' ? 'esta' : 'evus'; + } + + private function businessModel(string $business): string + { + return $business === 'esta' ? ESTA_MODEL : MODEL; + } + + private function businessInvoiceType(string $business): string + { + return $business === 'esta' ? ESTA_INCOICETYPE : INCOICETYPE; + } + + private function payMoney(array $detail): string + { + $scopes = [$detail]; + if (isset($detail['order']) && is_array($detail['order'])) { + $scopes[] = $detail['order']; + } + + foreach ($scopes as $scope) { + foreach (['total_price', 'money', 'pay_money', 'order_amount', 'amount', 'product_value', 'origin_price'] as $field) { + $money = $this->cleanMoney($scope[$field] ?? ''); + if ($money !== '') { + return $money; + } + } + } + + return ''; + } + + private function cleanMoney($value): string + { + if (is_int($value) || is_float($value)) { + return (string)$value; + } + + $value = trim((string)$value); + if ($value === '') { + return ''; + } + + $value = str_replace([',', '¥', '¥', '元', ' '], '', $value); + return preg_match('/^\d+(\.\d+)?$/', $value) ? $value : ''; + } +} diff --git a/app/miniapi/controller/Upload.php b/app/miniapi/controller/Upload.php new file mode 100644 index 0000000..ff242ec --- /dev/null +++ b/app/miniapi/controller/Upload.php @@ -0,0 +1,74 @@ +file('file'); + if (!$file) { + return $this->fail('请上传图片'); + } + + $path = $file->getPathname(); + if (!is_file($path)) { + return $this->fail('上传文件读取失败'); + } + + $size = filesize($path); + if ($size === false || $size <= 0) { + return $this->fail('上传文件为空'); + } + if ($size > 10 * 1024 * 1024) { + return $this->fail('图片不能超过10MB'); + } + + $originalName = (string)($_FILES['file']['name'] ?? 'upload.jpg'); + $ext = strtolower(pathinfo($originalName, PATHINFO_EXTENSION)); + $ext = $ext === 'jpeg' ? 'jpg' : $ext; + if (!in_array($ext, ['jpg', 'png', 'gif', 'webp', 'bmp'], true)) { + return $this->fail('请上传图片文件'); + } + + $mime = function_exists('mime_content_type') ? (string)mime_content_type($path) : ''; + if ($mime !== '' && strpos($mime, 'image/') !== 0) { + return $this->fail('请上传图片文件'); + } + + $content = file_get_contents($path); + if ($content === false || $content === '') { + return $this->fail('上传文件读取失败'); + } + + $fileName = date('YmdHis') . uniqid('', true) . '.' . $ext; + + try { + $client = SwooleService::getInstance(); + $sent = $client->sendTask([ + 'type' => 'upload_ali', + 'data' => [ + 'Bucket' => BUCKET, + 'Key' => $fileName, + 'file_content' => base64_encode($content), + ], + ]); + $client->close(); + + if (!$sent) { + return $this->fail('上传失败,请重试'); + } + + $url = OSS_URL . $fileName; + return $this->ok([ + 'path' => $url, + 'url' => $url, + ], '上传成功'); + } catch (\Throwable $e) { + return $this->fail('上传失败,请重试'); + } + } +} diff --git a/app/miniapi/service/Context/MiniAppContext.php b/app/miniapi/service/Context/MiniAppContext.php new file mode 100644 index 0000000..3774126 --- /dev/null +++ b/app/miniapi/service/Context/MiniAppContext.php @@ -0,0 +1,66 @@ +miniAppCode = (string)($data['mini_app_code'] ?? ''); + $this->companyCode = (string)($data['company_code'] ?? ''); + $this->businessCode = (string)($data['business_code'] ?? ''); + $this->siteDomain = (string)($data['site_domain'] ?? ''); + $this->miniApp = is_array($data['mini_app'] ?? null) ? $data['mini_app'] : []; + $this->site = is_array($data['site'] ?? null) ? $data['site'] : []; + } + + public function miniAppCode(): string + { + return $this->miniAppCode; + } + + public function companyCode(): string + { + return $this->companyCode; + } + + public function businessCode(): string + { + return $this->businessCode; + } + + public function siteDomain(): string + { + return $this->siteDomain; + } + + public function miniApp(): array + { + return $this->miniApp; + } + + public function site(): array + { + return $this->site; + } + + public function toArray(): array + { + return [ + 'mini_app_code' => $this->miniAppCode, + 'company_code' => $this->companyCode, + 'business_code' => $this->businessCode, + 'site_domain' => $this->siteDomain, + 'mini_app' => $this->miniApp, + 'site' => $this->site, + ]; + } +} diff --git a/app/miniapi/service/Legal/LegalDocumentService.php b/app/miniapi/service/Legal/LegalDocumentService.php new file mode 100644 index 0000000..60f4c03 --- /dev/null +++ b/app/miniapi/service/Legal/LegalDocumentService.php @@ -0,0 +1,144 @@ +businessCode() ?: (string)Config::get('mini_legal.default_business_code', 'evus'); + $business = (array)Config::get('mini_legal.businesses.' . $businessCode, []); + $companyCode = $this->resolveCompanyCode($business, $context); + $document = $this->resolveDocument($business, $context, $companyCode, $type); + if (empty($document)) { + return []; + } + + $company = $this->resolveCompany($business, $context, $companyCode); + $title = $this->resolveText($document, 'title', 'title_key', $type === 'privacy' ? '隐私政策' : '条款与条件'); + $body = $this->resolveText($document, 'content', 'content_key', ''); + $content = $this->plainText($this->buildContent($document, $company, $body)); + + return [ + 'type' => $type, + 'business_code' => $businessCode, + 'mini_app_code' => $context->miniAppCode(), + 'company_code' => $companyCode, + 'company_name' => $company['company_name'], + 'site_domain' => $company['site_domain'], + 'title' => $title, + 'content' => $content, + ]; + } + + private function resolveDocument(array $business, MiniAppContext $context, string $companyCode, string $type): array + { + $document = (array)($business['documents'][$type] ?? []); + if (empty($document)) { + return []; + } + + $company = (array)($business['companies'][$companyCode] ?? []); + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + + $companyDocument = (array)($company['documents'][$type] ?? []); + $appDocument = (array)($app['documents'][$type] ?? []); + + return array_replace_recursive($document, $companyDocument, $appDocument); + } + + private function resolveCompany(array $business, MiniAppContext $context, string $companyCode): array + { + $site = $context->site(); + $company = (array)($business['companies'][$companyCode] ?? []); + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + + $company = array_replace_recursive($company, (array)($app['company'] ?? [])); + + return [ + 'company_name' => trim((string)($company['company_name'] ?? '')) ?: trim((string)($site['company_name'] ?? '')) ?: 'EVUS登记服务', + 'site_domain' => trim((string)($company['site_domain'] ?? '')) ?: $context->siteDomain(), + 'phone' => trim((string)($company['phone'] ?? '')) ?: trim((string)($site['phone'] ?? '')), + ]; + } + + private function resolveCompanyCode(array $business, MiniAppContext $context): string + { + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + return trim((string)($app['company_code'] ?? '')) ?: $context->companyCode(); + } + + private function resolveText(array $document, string $literalKey, string $langKey, string $fallback): string + { + $literal = trim((string)($document[$literalKey] ?? '')); + if ($literal !== '') { + return $literal; + } + + $key = trim((string)($document[$langKey] ?? '')); + if ($key === '') { + return $fallback; + } + + $value = (string)lang($key); + return trim($value) !== '' ? $value : $fallback; + } + + private function buildContent(array $document, array $company, string $body): string + { + $companyName = $company['company_name'] ?: 'EVUS登记服务'; + $siteUrl = $this->siteUrl((string)($company['site_domain'] ?? '')); + $phone = $company['phone'] ?: '请通过小程序客服入口联系我们'; + $intro = $this->replaceTokens((string)($document['intro_template'] ?? ''), $company, $siteUrl, $phone); + $subjectLabel = trim((string)($document['subject_label'] ?? '服务主体')); + + $prefix = [ + $intro, + $subjectLabel . ':' . $companyName, + $siteUrl ? '适用网站:' . $siteUrl : '', + '联系方式:' . $phone, + ]; + + $prefix = array_values(array_filter($prefix, static function ($line) { + return trim((string)$line) !== ''; + })); + + return implode("\n", $prefix) . "\n\n" . $body; + } + + private function replaceTokens(string $text, array $company, string $siteUrl, string $phone): string + { + return strtr($text, [ + '{company_name}' => (string)($company['company_name'] ?? ''), + '{site_url}' => $siteUrl, + '{phone}' => $phone, + ]); + } + + private function siteUrl(string $siteDomain): string + { + $siteDomain = trim($siteDomain); + if ($siteDomain === '') { + return ''; + } + return preg_match('/^https?:\/\//i', $siteDomain) ? rtrim($siteDomain, '/') : 'https://' . rtrim($siteDomain, '/'); + } + + private function plainText(string $html): string + { + $html = preg_replace('/<\s*(h[1-6]|div|section|li)\b[^>]*>/i', "\n", $html); + $html = preg_replace('/<\s*\/\s*(h[1-6]|div|section|li)\s*>/i', "\n", (string)$html); + $text = preg_replace('/<\s*br\s*\/?\s*>/i', "\n", (string)$html); + $text = preg_replace('/<\s*\/p\s*>/i', "\n", (string)$text); + $text = strip_tags((string)$text); + $text = html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $text = preg_replace("/[ \t\r]+/", ' ', (string)$text); + $text = preg_replace("/\n{3,}/", "\n\n", (string)$text); + return trim((string)$text); + } +} diff --git a/app/miniapi/service/Payment/MiniPayService.php b/app/miniapi/service/Payment/MiniPayService.php new file mode 100644 index 0000000..17ab1a1 --- /dev/null +++ b/app/miniapi/service/Payment/MiniPayService.php @@ -0,0 +1,65 @@ +miniPay($context); + if ($payConfig['url'] === '') { + return [ + 'code' => 0, + 'msg' => '支付配置未完成', + 'data' => [], + ]; + } + + $response = Httpcurl::request($payConfig['url'], 'post', [ + 'order_sn' => $orderSn, + 'body' => $payConfig['body'], + 'money' => $money, + 'openid' => $openid, + 'attach' => $payConfig['attach'], + ]); + $result = $this->decodeResponse($response, $scene); + if (empty($result) || intval($result['code'] ?? 0) !== 200) { + return [ + 'code' => 0, + 'msg' => $result['msg'] ?? '支付参数获取失败', + 'data' => [], + ]; + } + + if (isset($result['data']['package'])) { + $result['data']['package'] = urlencode($result['data']['package']); + } + + return [ + 'code' => 1, + 'msg' => 'ok', + 'data' => $result['data'], + ]; + } + + private function decodeResponse($response, string $scene): array + { + if (!is_array($response) || !isset($response[0]) || !empty($response[3])) { + Log::error($scene . ' request failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); + return []; + } + + $result = json_decode($response[0], true); + if (!is_array($result)) { + Log::error($scene . ' response decode failed: ' . $response[0]); + return []; + } + + return $result; + } +} diff --git a/app/miniapi/service/Payment/PaymentChannelService.php b/app/miniapi/service/Payment/PaymentChannelService.php new file mode 100644 index 0000000..8707a85 --- /dev/null +++ b/app/miniapi/service/Payment/PaymentChannelService.php @@ -0,0 +1,35 @@ +businessCode() ?: (string)Config::get('mini_payment.default_business_code', 'evus'); + $business = (array)Config::get('mini_payment.businesses.' . $businessCode, []); + $companyCode = $this->resolveCompanyCode($business, $context); + + $config = (array)($business['mini_pay'] ?? []); + $company = (array)($business['companies'][$companyCode] ?? []); + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + + $config = array_replace_recursive($config, (array)($company['mini_pay'] ?? []), (array)($app['mini_pay'] ?? [])); + + return [ + 'url' => trim((string)($config['url'] ?? '')), + 'body' => trim((string)($config['body'] ?? 'EVUS登记服务费')) ?: 'EVUS登记服务费', + 'attach' => trim((string)($config['attach'] ?? 'msg')) ?: 'msg', + ]; + } + + private function resolveCompanyCode(array $business, MiniAppContext $context): string + { + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + return trim((string)($app['company_code'] ?? '')) ?: $context->companyCode(); + } +} diff --git a/app/miniapi/service/Product/ProductService.php b/app/miniapi/service/Product/ProductService.php new file mode 100644 index 0000000..91a9c03 --- /dev/null +++ b/app/miniapi/service/Product/ProductService.php @@ -0,0 +1,94 @@ +businessCode() ?: (string)Config::get('mini_product.default_business_code', 'evus'); + $business = (array)Config::get('mini_product.businesses.' . $businessCode, []); + $products = $this->resolveConfiguredProducts($business, $context); + + if (empty($products)) { + $legacyKey = (string)($business['legacy_config_key'] ?? ''); + $products = $legacyKey !== '' ? (array)Config::get('app.' . $legacyKey, []) : []; + } + + return $this->normalizeProducts($products); + } + + public function values(MiniAppContext $context): array + { + $products = $this->list($context); + + return array_values(array_filter(array_map(static function ($item) { + return isset($item['value']) ? (string)$item['value'] : ''; + }, $products), static function ($value) { + return $value !== ''; + })); + } + + public function isValidValue(MiniAppContext $context, $value): bool + { + $values = $this->values($context); + return empty($values) || in_array((string)$value, $values, true); + } + + public function findByValue(MiniAppContext $context, $value): array + { + $value = (string)$value; + foreach ($this->list($context) as $product) { + if ((string)($product['value'] ?? '') === $value) { + return $product; + } + } + + return []; + } + + private function resolveConfiguredProducts(array $business, MiniAppContext $context): array + { + $companyCode = $this->resolveCompanyCode($business, $context); + $company = (array)($business['companies'][$companyCode] ?? []); + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + + $products = (array)($company['products'] ?? []); + if (!empty($app['products']) && is_array($app['products'])) { + $products = (array)$app['products']; + } + + return $products; + } + + private function resolveCompanyCode(array $business, MiniAppContext $context): string + { + $app = (array)($business['apps'][$context->miniAppCode()] ?? []); + return trim((string)($app['company_code'] ?? '')) ?: $context->companyCode(); + } + + private function normalizeProducts(array $products): array + { + return array_values(array_filter(array_map(function ($item) { + if (!is_array($item)) { + return null; + } + + $value = isset($item['value']) ? (string)$item['value'] : ''; + if ($value === '') { + return null; + } + + return [ + 'value' => $value, + 'desc' => (string)($item['desc'] ?? ''), + 'is_checked' => (string)($item['is_checked'] ?? '0'), + 'name' => (string)($item['name'] ?? ''), + ]; + }, $products))); + } +} diff --git a/app/provider.php b/app/provider.php new file mode 100644 index 0000000..73d99fa --- /dev/null +++ b/app/provider.php @@ -0,0 +1,9 @@ + Request::class, + 'think\exception\Handle' => ExceptionHandle::class, +]; diff --git a/app/service.php b/app/service.php new file mode 100644 index 0000000..db1ee6a --- /dev/null +++ b/app/service.php @@ -0,0 +1,9 @@ +getMime(); + $s3config = config('filesystem.disks.s3'); + $s3 = new S3Client($s3config); + try { + $config = config('app.upload_conf'); + $configs=[]; + foreach ($config as $key=>$con){ + $configs[] = $key.':'.$con; + } + + // 验证文件 + $validate = validate([ + $fileField =>implode('|',$configs), + ]); + + if (!$validate->check([$fileField => $file])) { + return $this->createErrorResult($validate->getError()); + } + + // 根据文件类型设置 Content-Type + if (in_array($mimeType, config('app.imageMimeTypes'))) { + $contentType = $mimeType; // 使用图片的实际 MIME 类型 + } else { + $contentType = 'application/octet-stream'; // 非图片文件使用默认类型 + } + $checkBucket = $this->checkBucket($s3, $extraFields['Bucket']); + if (!$checkBucket) { + return $this->createErrorResult('Bucket error'); + } + $s3->putObject([ + 'Bucket' => $extraFields['Bucket'], + 'Key' => $extraFields['Key'], + 'Body' => fopen($file->getRealPath(), 'r'), + 'ACL' => 'public-read', + 'ContentType' => $contentType, // 设置检测到的 Content-Type + ]); + return [ + 'code' => 1, + 'data' =>[ + 'savename'=>$s3config['endpoint'].'/'.$extraFields['Bucket'].'/'.$extraFields['Key'] + ] , + ]; + } catch (\Exception $e) { + return $this->createErrorResult('上传过程中发生异常: ' . $e->getMessage()); + } + } + public function checkBucket($s3, $bucket) + { + try { + $buckets = $s3->listBuckets()->get('Buckets'); + $buckets_arr = array_column($buckets, 'Name'); + if (!in_array($bucket, $buckets_arr)) { + $s3->createBucket([ + 'Bucket' => $bucket, + ]); + $policy = [ + 'Version' => '2012-10-17', + 'Statement' => [ + [ + 'Effect' => 'Allow', + 'Principal' => ['AWS' => ['*']], + 'Action' => [ + 's3:GetBucketLocation', + 's3:ListBucket', + 's3:ListBucketMultipartUploads', + ], + 'Resource' => "arn:aws:s3:::$bucket", + ], + [ + 'Effect' => 'Allow', + 'Principal' => ['AWS' => ['*']], + 'Action' => [ + 's3:DeleteObject', + 's3:GetObject', + 's3:ListMultipartUploadParts', + 's3:PutObject', + 's3:AbortMultipartUpload', + ], + 'Resource' => "arn:aws:s3:::$bucket/*", + ], + ], + ]; + $s3->putBucketPolicy([ + 'Bucket' => $bucket, + 'Policy' => json_encode($policy), + ]); + } + return true; + } catch (\Exception $e) { + Log::info('checkBucket error:' . $e->getMessage()); + return false; + } + + } + /** + * 创建错误结果数组 + * + * @param string $message 错误信息 + * @return array 错误结果 + */ + private function createErrorResult(string $message): array + { + return [ + 'code' => 0, + 'error' => $message + ]; + } +} \ No newline at end of file diff --git a/app/service/BaiduOcrService.php b/app/service/BaiduOcrService.php new file mode 100644 index 0000000..cf27bba --- /dev/null +++ b/app/service/BaiduOcrService.php @@ -0,0 +1,122 @@ + 0, + 'msg' => '无法读取上传的文件', + ]; + } + $curl = new Curl(); + $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); + $curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0); + + $curl->post($this->url.'passport', [ + 'image' => $fileData, + ]); + if ($curl->error) { + return [ + 'code' => 0, + 'msg' => $curl->errorMessage, + ]; + } else { + if (!$curl->response->code){ + return [ + 'code' => 0, + 'msg' => '解析失败', + ]; + } + return [ + 'code' => 1, + 'data' => $curl->response->data, + ]; + } + } + /** + * + *身份证识别 + * @param string $fileData 图片的二进制数据 + * @return array + */ + function identification($fileData) + { + if ($fileData === false) { + return [ + 'code' => 0, + 'msg' => '无法读取上传的文件', + ]; + } + $curl = new Curl(); + $curl->post($this->url.'identification', [ + 'image' => $fileData, + ]); + if ($curl->error) { + return [ + 'code' => 0, + 'msg' => $curl->errorMessage, + ]; + } else { + if (!$curl->response->code){ + return [ + 'code' => 0, + 'msg' => '解析失败', + ]; + } + return [ + 'code' => 1, + 'data' => $curl->response->data, + ]; + } + } + /** + * + *护照识别 + * @param string $fileData 图片的二进制数据 + * @return array 包含压缩后图片信息的数组 + */ + function visa($fileData) + { + if ($fileData === false) { + return [ + 'code' => 0, + 'msg' => '无法读取上传的文件', + ]; + } + $curl = new Curl(); + $curl->post($this->url.'visa', [ + 'image' => $fileData, + ]); + if ($curl->error) { + return [ + 'code' => 0, + 'msg' => $curl->errorMessage, + ]; + } else { + if (!$curl->response->code){ + return [ + 'code' => 0, + 'msg' => '解析失败', + ]; + } + return [ + 'code' => 1, + 'data' => $curl->response->data, + ]; + } + } + +} \ No newline at end of file diff --git a/app/service/CompressImgService.php b/app/service/CompressImgService.php new file mode 100644 index 0000000..5b15d82 --- /dev/null +++ b/app/service/CompressImgService.php @@ -0,0 +1,185 @@ + 0, + 'message' => '无法读取上传的文件', + ]; + } + + // 获取图片信息 + $imageInfo = getimagesizefromstring($imageData); + if (!$imageInfo) { + return [ + 'code' => 0, + 'message' => '无法解析图片信息', + ]; + } + + // 确定原始和目标格式 + $originalMimeType = $imageInfo['mime']; + $originalExtension = image_type_to_extension($imageInfo[2], false); + + if ($targetFormat === null) { + $targetFormat = $originalExtension; + } + + // 创建图片资源 + switch (strtolower($originalExtension)) { + case 'jpeg': + case 'jpg': + $image = imagecreatefromstring($imageData); + break; + case 'png': + $image = imagecreatefromstring($imageData); + break; + case 'webp': + $image = imagecreatefromstring($imageData); + break; + default: + return [ + 'code' => 0, + 'message' => '不支持的图片格式', + ]; + } + + if (!$image) { + return [ + 'code' => 0, + 'message' => '无法创建图片资源', + ]; + } + + // 压缩并转换图片 + ob_start(); + switch (strtolower($targetFormat)) { + case 'jpeg': + case 'jpg': + imagejpeg($image, null, $quality); + $compressedMimeType = 'image/jpeg'; + break; + case 'png': + $pngQuality = 9 - floor($quality / 11); + imagepng($image, null, $pngQuality); + $compressedMimeType = 'image/png'; + break; + case 'webp': + if (function_exists('imagewebp')) { + imagewebp($image, null, $quality); + $compressedMimeType = 'image/webp'; + } else { + imagejpeg($image, null, $quality); + $compressedMimeType = 'image/jpeg'; + } + break; + default: + imagedestroy($image); + ob_end_clean(); + return [ + 'code' => 0, + 'message' => "不支持的目标格式: {$targetFormat}", + ]; + } + + $compressedData = ob_get_clean(); + imagedestroy($image); + // 返回结果 + return [ + 'code' => 1, + 'compressed_data' => $compressedData, + 'base64' => 'data:' . $compressedMimeType . ';base64,' . base64_encode($compressedData), + ]; + } + + public function compressImage($filePath, $fileSize) + { + // 获取图片信息 + $imageInfo = getimagesize($filePath); + if (!$imageInfo) { + return false; + } + + $mime = $imageInfo['mime']; + + // 根据MIME类型创建图像资源 + switch ($mime) { + case 'image/jpeg': + $image = imagecreatefromjpeg($filePath); + break; + case 'image/png': + $image = imagecreatefrompng($filePath); + break; + case 'image/gif': + $image = imagecreatefromgif($filePath); + break; + default: + return false; + } + + if (!$image) { + return false; + } + + // 计算压缩质量(根据文件大小动态调整) + $originalQuality = 85; // 初始质量 + $targetSize = 2.5 * 1024 * 1024; // 目标大小2.5MB + + // 如果文件很大,降低初始质量 + if ($fileSize > 5 * 1024 * 1024) { + $quality = 75; + } elseif ($fileSize > 10 * 1024 * 1024) { + $quality = 65; + } else { + $quality = $originalQuality; + } + + // 创建临时文件 + $tempFile = tempnam(sys_get_temp_dir(), 'compressed_'); + + // 保存压缩后的图片 + switch ($mime) { + case 'image/jpeg': + imagejpeg($image, $tempFile, $quality); + break; + case 'image/png': + // PNG使用压缩级别(0-9),需要转换 + $pngQuality = 9 - round(($quality / 100) * 9); + imagepng($image, $tempFile, $pngQuality); + break; + case 'image/gif': + imagegif($image, $tempFile); + break; + } + + // 释放内存 + imagedestroy($image); + + // 检查压缩后文件大小,如果仍然大于3MB,继续压缩 + $compressedSize = filesize($tempFile); + if ($compressedSize > 3 * 1024 * 1024) { + // 递归压缩直到满足要求 + return $this->compressImage($tempFile, $compressedSize); + } + + return $tempFile; + } +} \ No newline at end of file diff --git a/app/service/MiniProgramWechatService.php b/app/service/MiniProgramWechatService.php new file mode 100644 index 0000000..1bb67ad --- /dev/null +++ b/app/service/MiniProgramWechatService.php @@ -0,0 +1,127 @@ +miniAppCode = $miniAppCode; + $this->miniApp = $miniApp; + } + + public function openidByLoginCode(string $loginCode, bool $required = false): string + { + $config = $this->wechatConfig(); + if ($loginCode === '' || $config['appid'] === '' || $config['secret'] === '') { + return ''; + } + + $response = Httpcurl::request('https://api.weixin.qq.com/sns/jscode2session', 'get', [ + 'appid' => $config['appid'], + 'secret' => $config['secret'], + 'js_code' => $loginCode, + 'grant_type' => 'authorization_code', + ], [], 8); + $result = $this->decodeWechatResponse($response, 'miniapi wx code2session'); + if (!empty($result['openid'])) { + return (string)$result['openid']; + } + + if ($required) { + Log::warning('miniapi wx openid missing: ' . json_encode($result, JSON_UNESCAPED_UNICODE)); + } + return ''; + } + + public function mobileByPhoneCode(string $phoneCode): string + { + $accessToken = $this->wechatAccessToken(); + if ($phoneCode === '' || $accessToken === '') { + return ''; + } + + $response = Httpcurl::request( + 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' . urlencode($accessToken), + 'post', + json_encode(['code' => $phoneCode], JSON_UNESCAPED_UNICODE), + ['Content-Type: application/json'], + 8 + ); + $result = $this->decodeWechatResponse($response, 'miniapi wx get phone number'); + $phoneInfo = $result['phone_info'] ?? []; + return (string)($phoneInfo['purePhoneNumber'] ?? $phoneInfo['phoneNumber'] ?? ''); + } + + private function wechatAccessToken(): string + { + $config = $this->wechatConfig(); + if ($config['appid'] === '' || $config['secret'] === '') { + Log::warning('miniapi wx config missing: ' . $this->miniAppCode); + return ''; + } + + $cacheKey = 'miniapp_access_token_' . $this->miniAppCode; + $cached = Cache::get($cacheKey); + if (!empty($cached)) { + return (string)$cached; + } + + $response = Httpcurl::request('https://api.weixin.qq.com/cgi-bin/token', 'get', [ + 'grant_type' => 'client_credential', + 'appid' => $config['appid'], + 'secret' => $config['secret'], + ], [], 8); + $result = $this->decodeWechatResponse($response, 'miniapi wx access token'); + if (empty($result['access_token'])) { + return ''; + } + + $ttl = max(60, intval($result['expires_in'] ?? 7200) - 300); + Cache::set($cacheKey, $result['access_token'], $ttl); + return (string)$result['access_token']; + } + + private function wechatConfig(): array + { + return [ + 'appid' => trim((string)($this->miniApp['wechat_appid'] ?? '')), + 'secret' => trim((string)($this->miniApp['wechat_secret'] ?? '')), + ]; + } + + private function decodeWechatResponse($response, string $scene): array + { + $result = $this->decodeResponse($response, $scene); + if (isset($result['errcode']) && intval($result['errcode']) !== 0) { + Log::warning($scene . ' failed: ' . json_encode($result, JSON_UNESCAPED_UNICODE)); + return []; + } + + return $result; + } + + private function decodeResponse($response, string $scene): array + { + if (!is_array($response) || !isset($response[0]) || !empty($response[3])) { + Log::error($scene . ' request failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); + return []; + } + + $result = json_decode($response[0], true); + if (!is_array($result)) { + Log::error($scene . ' response decode failed: ' . $response[0]); + return []; + } + + return $result; + } +} diff --git a/app/service/OssService.php b/app/service/OssService.php new file mode 100644 index 0000000..c68bdf8 --- /dev/null +++ b/app/service/OssService.php @@ -0,0 +1,301 @@ +region = $config['region'] ?? ''; + $this->bucket = $config['bucket'] ?? ''; + $this->endpoint = $config['endpoint'] ?? null; + + if ($this->region === '' || $this->bucket === '') { + throw new Exception('OSS config missing: region/bucket'); + } + + if (!empty($config['access_key_id']) && !empty($config['access_key_secret'])) { + $credentialsProvider = new FixedCredentialsProvider( + (string)$config['access_key_id'], + (string)$config['access_key_secret'], + $config['session_token'] ?? null + ); + } else { + $credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + } + + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider($credentialsProvider); + $cfg->setRegion($this->region); + if ($this->endpoint) { + $cfg->setEndpoint($this->endpoint); + if ($this->shouldUseCname($this->endpoint)) { + $cfg->setUseCname(true); + } + } + + $this->client = new Oss\Client($cfg); + $this->assertCredentialsVisible($config); + } + + public function upload(string $source, string $key, ?string $bucket = null, array $options = []): array + { + if ($this->isBase64DataUri($source)) { + return $this->uploadFromBase64($source, $key, $bucket, $options); + } + + if ($this->isUrl($source)) { + return $this->uploadFromUrl($source, $key, $bucket, $options); + } + + return $this->uploadFromFile($source, $key, $bucket, $options); + } + + public function uploadFromBase64(string $base64, string $key, ?string $bucket = null, array $options = []): array + { + $contentType = null; + $payload = $base64; + + if (preg_match('/^data:([a-zA-Z0-9.+\\/-]+);base64,(.*)$/s', $base64, $m)) { + $contentType = strtolower((string)$m[1]); + $payload = (string)$m[2]; + } + + $payload = preg_replace('/\\s+/', '', $payload ?? ''); + if ($payload === '') { + throw new Exception('Base64 payload is empty'); + } + + $binary = base64_decode($payload, true); + if ($binary === false) { + throw new Exception('Invalid base64 payload'); + } + + if ($contentType && empty($options['contentType'])) { + $options['contentType'] = $contentType; + } + + return $this->uploadFromBinary($binary, $key, $bucket, $options); + } + + public function uploadFromBinary(string $binary, string $key, ?string $bucket = null, array $options = []): array + { + if ($binary === '') { + throw new Exception('Binary payload is empty'); + } + + $stream = fopen('php://temp', 'wb+'); + if ($stream === false) { + throw new Exception('Unable to create temporary stream for binary upload'); + } + + fwrite($stream, $binary); + rewind($stream); + + return $this->putObjectFromResource($stream, $key, $bucket, $options); + } + + public function uploadFromFile(string $filePath, string $key, ?string $bucket = null, array $options = []): array + { + if (!is_file($filePath)) { + throw new Exception("Local file not found: {$filePath}"); + } + + $fp = fopen($filePath, 'rb'); + if ($fp === false) { + throw new Exception("Unable to open local file: {$filePath}"); + } + + return $this->putObjectFromResource($fp, $key, $bucket, $options); + } + + public function uploadFromUrl(string $url, string $key, ?string $bucket = null, array $options = []): array + { + $fp = @fopen($url, 'rb'); + if ($fp !== false) { + return $this->putObjectFromResource($fp, $key, $bucket, $options); + } + + $tmp = tmpfile(); + if ($tmp === false) { + throw new Exception('Unable to create tmpfile() for remote download'); + } + + $this->downloadToStreamByCurl($url, $tmp); + rewind($tmp); + + return $this->putObjectFromResource($tmp, $key, $bucket, $options); + } + + public function buildObjectUrl(string $key, ?string $bucket = null, bool $useHttps = true): string + { + $bucket = $bucket ?: $this->bucket; + $key = ltrim($key, '/'); + $endpoint = $this->endpoint ?: sprintf('oss-%s.aliyuncs.com', $this->region); + $host = $this->extractEndpointHost($endpoint); + $scheme = $useHttps ? 'https' : 'http'; + $encodedKey = implode('/', array_map('rawurlencode', explode('/', $key))); + + if ($this->shouldUseCname($endpoint)) { + return sprintf('%s://%s/%s', $scheme, $host, $encodedKey); + } + + return sprintf('%s://%s.%s/%s', $scheme, $bucket, $host, $encodedKey); + } + + private function putObjectFromResource($resource, string $key, ?string $bucket = null, array $options = []): array + { + $bucket = $bucket ?: $this->bucket; + $key = ltrim($key, '/'); + $metadata = $options['metadata'] ?? []; + $contentType = $options['contentType'] ?? null; + $acl = $options['acl'] ?? null; + + $body = Oss\Utils::streamFor($resource); + $request = new Oss\Models\PutObjectRequest( + bucket: $bucket, + key: $key, + metadata: $metadata ?: null, + contentType: $contentType, + objectAcl: $acl + ); + $request->body = $body; + + $result = $this->client->putObject($request); + + return [ + 'statusCode' => $result->statusCode, + 'requestId' => $result->requestId, + 'etag' => $result->etag, + 'bucket' => $bucket, + 'key' => $key, + ]; + } + + private function downloadToStreamByCurl(string $url, $destStream): void + { + if (!function_exists('curl_init')) { + throw new Exception('cURL extension is required when allow_url_fopen is disabled.'); + } + + $ch = curl_init($url); + curl_setopt_array($ch, [ + CURLOPT_FILE => $destStream, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_MAXREDIRS => 5, + CURLOPT_CONNECTTIMEOUT => 10, + CURLOPT_TIMEOUT => 60, + CURLOPT_FAILONERROR => true, + CURLOPT_USERAGENT => 'OssService/1.0', + ]); + + $ok = curl_exec($ch); + if ($ok !== true) { + $err = curl_error($ch); + $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); + curl_close($ch); + throw new Exception("Failed to download remote file. HTTP={$code}, error={$err}"); + } + + curl_close($ch); + } + + private function isUrl(string $value): bool + { + return (bool)filter_var($value, FILTER_VALIDATE_URL); + } + + private function isBase64DataUri(string $value): bool + { + return (bool)preg_match('/^data:[a-zA-Z0-9.+\\/-]+;base64,/i', $value); + } + + private function assertCredentialsVisible(array $config): void + { + if (!empty($config['access_key_id']) && !empty($config['access_key_secret'])) { + return; + } + + $ak = getenv('OSS_ACCESS_KEY_ID'); + $sk = getenv('OSS_ACCESS_KEY_SECRET'); + + if (empty($ak) || empty($sk)) { + throw new Exception( + "OSS credentials missing in PHP process env. " . + "getenv('OSS_ACCESS_KEY_ID')/getenv('OSS_ACCESS_KEY_SECRET') is empty. " . + "Fix: make sure the PHP runtime process can see env vars, or pass access_key_id/access_key_secret into OssService config." + ); + } + } + + private function shouldUseCname(string $endpoint): bool + { + $host = strtolower($this->extractEndpointHost($endpoint)); + + if ($host === '' || str_contains($host, 'aliyuncs.com') || str_contains($host, '.oss-')) { + return false; + } + + return true; + } + + private function extractEndpointHost(string $endpoint): string + { + $normalized = preg_match('#^https?://#i', $endpoint) ? $endpoint : 'https://' . ltrim($endpoint, '/'); + return (string)(parse_url($normalized, PHP_URL_HOST) ?: ''); + } + + public function presignGetObjectUrl(string $key, ?string $bucket = null, int $expireSeconds = 900): array + { + $bucket = $bucket ?: $this->bucket; + $key = ltrim($key, '/'); + + $request = new Oss\Models\GetObjectRequest(bucket: $bucket, key: $key); + $result = $this->client->presign($request, [ + 'expires' => new \DateInterval("PT{$expireSeconds}S"), + ]); + + return [ + 'url' => $result->url, + 'expire' => $expireSeconds, + 'bucket' => $bucket, + 'key' => $key, + ]; + } +} + +final class FixedCredentialsProvider implements Oss\Credentials\CredentialsProvider +{ + private string $ak; + private string $sk; + private ?string $token; + + public function __construct(string $ak, string $sk, ?string $token = null) + { + $this->ak = $ak; + $this->sk = $sk; + $this->token = $token; + } + + public function getCredentials(): Oss\Credentials\Credentials + { + return new Oss\Credentials\Credentials($this->ak, $this->sk, $this->token); + } +} diff --git a/app/service/OssUploadService.php b/app/service/OssUploadService.php new file mode 100644 index 0000000..0071020 --- /dev/null +++ b/app/service/OssUploadService.php @@ -0,0 +1,203 @@ +createErrorResult('文件解析错误'); + } + + return $this->uploadBinaryContent($fileName, $fileContent, $extraFields); + } + + public function uploadBinary(string $fileName, string $fileContent, array $extraFields = []): array + { + if ($fileContent === '') { + return $this->createErrorResult('Binary payload is empty'); + } + + return $this->uploadBinaryContent($fileName, $fileContent, $extraFields); + } + + private function uploadBinaryContent(string $fileName, string $fileContent, array $extraFields = []): array + { + $uploadConfig = config('filesystem.upload_conf') ?: []; + $maxSize = (int)($uploadConfig['fileSize'] ?? 10 * 1024 * 1024); + if (strlen($fileContent) > $maxSize) { + return $this->createErrorResult('File size exceeds limit'); + } + + $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); + $allowedExts = $uploadConfig['fileExt'] ?? []; + if ($ext === '' || (!empty($allowedExts) && !in_array($ext, $allowedExts, true))) { + return $this->createErrorResult('File extension not allowed'); + } + + $bucket = (string)config('oss.bucket'); + $folder = (string)($extraFields['Folder'] ?? ($extraFields['Bucket'] ?? '')); + $key = $extraFields['Key'] ?? basename($fileName); + $objectKey = $this->buildObjectKey($folder, (string)$key); + if ($bucket === '' || $objectKey === '') { + return $this->createErrorResult('Bucket or key missing'); + } + + $finfo = new \finfo(FILEINFO_MIME_TYPE); + $mimeType = (string)$finfo->buffer($fileContent); + + try { + $service = new OssService(config('oss')); + $result = $service->uploadFromBinary($fileContent, $objectKey, $bucket, [ + 'contentType' => $this->resolveContentType($mimeType, $ext), + ]); + $result['url'] = $service->buildObjectUrl($objectKey, $bucket); + $result['folder'] = $folder; + + return [ + 'code' => 1, + 'msg' => 'upload ok', + 'data' => $result, + ]; + } catch (Throwable $e) { + $fallback = $this->saveToLocalFallback($fileContent, $bucket, $objectKey); + + return $this->createErrorResult( + 'OSS upload failed: ' . $e->getMessage(), + [ + 'bucket' => $bucket, + 'key' => $objectKey, + 'folder' => $folder, + 'fallback_saved' => $fallback['saved'], + 'fallback_path' => $fallback['path'], + 'fallback_error' => $fallback['error'], + ] + ); + } + } + + private function buildObjectKey(string $folder, string $key): string + { + $folder = trim(str_replace('\\', '/', $folder), '/'); + $key = trim(str_replace('\\', '/', $key), '/'); + + if ($folder === '') { + return $key; + } + + if ($key === '') { + return $folder; + } + + if (str_starts_with($key . '/', $folder . '/')) { + return $key; + } + + return $folder . '/' . $key; + } + + private function saveToLocalFallback(string $fileContent, string $bucket, string $key): array + { + $baseDir = $this->resolveFallbackBaseDir(); + $safeBucket = $this->sanitizePathSegment($bucket); + $safeKey = $this->sanitizeObjectKey($key); + $fullPath = $baseDir . DIRECTORY_SEPARATOR . $safeBucket . DIRECTORY_SEPARATOR . $safeKey; + $directory = dirname($fullPath); + + try { + if (!is_dir($directory) && !mkdir($directory, 0777, true) && !is_dir($directory)) { + throw new \RuntimeException('Unable to create fallback directory'); + } + + if (file_put_contents($fullPath, $fileContent) === false) { + throw new \RuntimeException('Unable to write fallback file'); + } + + return [ + 'saved' => true, + 'path' => $fullPath, + 'error' => null, + ]; + } catch (Throwable $e) { + return [ + 'saved' => false, + 'path' => $fullPath, + 'error' => $e->getMessage(), + ]; + } + } + + private function resolveFallbackBaseDir(): string + { + $uploadConfig = config('filesystem.upload_conf') ?: []; + $configured = (string)($uploadConfig['fallbackDir'] ?? ''); + if ($configured !== '') { + return rtrim($configured, "\\/"); + } + + $localRoot = (string)(config('filesystem.disks.local.root') ?? ''); + if ($localRoot !== '') { + return rtrim($localRoot, "\\/") . DIRECTORY_SEPARATOR . 'oss-fallback'; + } + + return app()->getRuntimePath() . 'storage' . DIRECTORY_SEPARATOR . 'oss-fallback'; + } + + private function sanitizeObjectKey(string $key): string + { + $normalized = str_replace('\\', '/', $key); + $segments = array_filter(explode('/', $normalized), static function (string $segment): bool { + return $segment !== '' && $segment !== '.' && $segment !== '..'; + }); + + if ($segments === []) { + return 'unnamed-file'; + } + + $safeSegments = array_map([$this, 'sanitizePathSegment'], $segments); + return implode(DIRECTORY_SEPARATOR, $safeSegments); + } + + private function sanitizePathSegment(string $segment): string + { + $cleaned = preg_replace('/[^A-Za-z0-9._-]/', '_', $segment) ?? ''; + return $cleaned !== '' ? $cleaned : 'unknown'; + } + + private function resolveContentType(string $mimeType, string $ext): string + { + if ($mimeType !== '' && $mimeType !== 'application/octet-stream') { + return $mimeType; + } + + return match ($ext) { + 'jpg', 'jpeg' => 'image/jpeg', + 'png' => 'image/png', + 'gif' => 'image/gif', + 'webp' => 'image/webp', + 'bmp' => 'image/bmp', + 'svg' => 'image/svg+xml', + 'pdf' => 'application/pdf', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + default => 'application/octet-stream', + }; + } + + private function createErrorResult(string $message, array $data = []): array + { + $result = [ + 'code' => 0, + 'msg' => $message, + ]; + + if ($data !== []) { + $result['data'] = $data; + } + + return $result; + } +} diff --git a/app/service/PassportOcrService.php b/app/service/PassportOcrService.php new file mode 100644 index 0000000..3b293fe --- /dev/null +++ b/app/service/PassportOcrService.php @@ -0,0 +1,233 @@ +request(self::PASSPORT_ENDPOINT, $fileData); + } + + public function identification($fileData): array + { + return $this->request(self::IDCARD_ENDPOINT, $fileData); + } + + public function visa($fileData): array + { + return $this->request(self::VISA_ENDPOINT, $fileData); + } + + private function request(string $endpoint, $fileData): array + { + if (!is_string($fileData) || $fileData === '') { + return $this->error('Unable to read uploaded file'); + } + + $config = $this->loadConfig(); + if ($config['base_url'] === '' || $config['app_id'] === '' || $config['secret'] === '') { + return $this->error('OCR config missing: app.OCR_BASE_URL, app.OCR_APP_ID and app.OCR_SECRET are required'); + } + + try { + $payload = $this->buildPayload($fileData, $config); + } catch (Throwable $e) { + return $this->error('Unable to build OCR payload: ' . $e->getMessage()); + } + + $timestamp = (string) time(); + $signature = hash_hmac('sha256', $config['app_id'] . "\n" . $timestamp, $config['secret']); + $headers = [ + 'Content-Type: application/json', + 'Accept: application/json', + 'X-App-Id: ' . $config['app_id'], + 'X-Timestamp: ' . $timestamp, + 'X-Signature: ' . $signature, + ]; + + if ($config['origin'] !== '') { + $headers[] = 'Origin: ' . $config['origin']; + } + + $ch = curl_init($config['base_url'] . $endpoint); + if ($ch === false) { + return $this->error('Unable to initialize cURL'); + } + + try { + curl_setopt_array($ch, [ + CURLOPT_POST => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => $headers, + CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE), + CURLOPT_TIMEOUT => $config['timeout'], + CURLOPT_CONNECTTIMEOUT => $config['connect_timeout'], + ]); + + if (!$config['verify_ssl']) { + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + } + + $response = curl_exec($ch); + $httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($response === false) { + return $this->error('OCR request failed: ' . curl_error($ch)); + } + + $decoded = json_decode((string) $response, true); + if (!is_array($decoded)) { + return $this->error('OCR response is not valid JSON', [ + 'http_code' => $httpCode, + 'response' => substr((string) $response, 0, 300), + ]); + } + + return $decoded; + } finally { + curl_close($ch); + } + } + + private function buildPayload(string $fileData, array $config): array + { + $mimeType = $this->detectMimeType($fileData); + $extension = $this->extensionForMimeType($mimeType); + + return [ + 'filename' => 'upload.' . $extension, + 'content_type' => $mimeType, + 'image_base64' => 'data:' . $mimeType . ';base64,' . base64_encode($fileData), + 'auto_rotate' => $config['auto_rotate'], + 'return_debug' => $config['return_debug'], + ]; + } + + private function loadConfig(): array + { + $config = config('ocr') ?: []; + + return [ + 'base_url' => rtrim((string) (config('app.OCR_BASE_URL') ?? ''), '/'), + 'app_id' => (string) (config('app.OCR_APP_ID') ?? ''), + 'secret' => (string) (config('app.OCR_SECRET') ?? ''), + 'origin' => $this->resolveOrigin((string) (config('app.OCR_ORIGIN') ?? ($config['origin'] ?? ''))), + 'timeout' => max(1, (int) ($config['timeout'] ?? 60)), + 'connect_timeout' => max(1, (int) ($config['connect_timeout'] ?? 10)), + 'auto_rotate' => $this->boolValue($config['auto_rotate'] ?? true), + 'return_debug' => $this->boolValue($config['return_debug'] ?? false), + 'verify_ssl' => $this->boolValue($config['verify_ssl'] ?? true), + ]; + } + + private function resolveOrigin(string $configuredOrigin): string + { + $configuredOrigin = trim($configuredOrigin); + if ($configuredOrigin !== '') { + return rtrim($configuredOrigin, '/'); + } + + $requestOrigin = trim((string) ($_SERVER['HTTP_ORIGIN'] ?? '')); + if ($this->isValidOrigin($requestOrigin)) { + return rtrim($requestOrigin, '/'); + } + + $host = trim((string) ($_SERVER['HTTP_HOST'] ?? '')); + if ($host === '' || !preg_match('/^[A-Za-z0-9.-]+(?::\d+)?$/', $host)) { + return ''; + } + + return $this->currentScheme() . '://' . $host; + } + + private function isValidOrigin(string $origin): bool + { + if ($origin === '') { + return false; + } + + $parts = parse_url($origin); + if (!is_array($parts)) { + return false; + } + + $scheme = strtolower((string) ($parts['scheme'] ?? '')); + return in_array($scheme, ['http', 'https'], true) + && !empty($parts['host']) + && empty($parts['path']) + && empty($parts['query']) + && empty($parts['fragment']); + } + + private function currentScheme(): string + { + $forwardedProto = trim((string) ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')); + if ($forwardedProto !== '') { + $forwardedProto = strtolower(trim(explode(',', $forwardedProto)[0])); + if (in_array($forwardedProto, ['http', 'https'], true)) { + return $forwardedProto; + } + } + + $requestScheme = strtolower((string) ($_SERVER['REQUEST_SCHEME'] ?? '')); + if (in_array($requestScheme, ['http', 'https'], true)) { + return $requestScheme; + } + + $https = strtolower((string) ($_SERVER['HTTPS'] ?? '')); + return $https !== '' && $https !== 'off' ? 'https' : 'http'; + } + + private function detectMimeType(string $fileData): string + { + if (!class_exists(\finfo::class)) { + return 'image/jpeg'; + } + + $finfo = new \finfo(FILEINFO_MIME_TYPE); + $mimeType = $finfo->buffer($fileData); + if (is_string($mimeType) && $mimeType !== '' && $mimeType !== 'application/octet-stream') { + return $mimeType; + } + + return 'image/jpeg'; + } + + private function extensionForMimeType(string $mimeType): string + { + return match ($mimeType) { + 'image/png' => 'png', + 'image/gif' => 'gif', + 'image/webp' => 'webp', + 'image/bmp', 'image/x-ms-bmp' => 'bmp', + default => 'jpg', + }; + } + + private function boolValue($value): bool + { + $parsed = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); + return $parsed ?? (bool) $value; + } + + private function error(string $message, array $data = []): array + { + $result = [ + 'code' => 0, + 'msg' => $message, + ]; + + if ($data !== []) { + $result['data'] = $data; + } + + return $result; + } +} diff --git a/app/service/SwooleService.php b/app/service/SwooleService.php new file mode 100644 index 0000000..dde6a1f --- /dev/null +++ b/app/service/SwooleService.php @@ -0,0 +1,63 @@ +connect($this->host, $this->port, $this->timeout)) { + throw new \RuntimeException( + "Cannot connect to Swoole Server {$this->host}:{$this->port}, error: {$client->errCode}" + ); + } + + $data = json_encode($task, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + + if ($data === false) { + throw new \RuntimeException('JSON encode failed: ' . json_last_error_msg()); + } + + // 你的服务端使用 \r\n 作为 package_eof,所以这里必须加 \r\n + $sendResult = $client->send($data . "\r\n"); + + return $sendResult !== false; + } finally { + if ($client->isConnected()) { + $client->close(); + } + } + } + + // 保留 close 方法,避免旧代码调用时报错 + public function close(): void + { + self::$instance = null; + } +} \ No newline at end of file diff --git a/app/service/UploadService.php b/app/service/UploadService.php new file mode 100644 index 0000000..95eaadb --- /dev/null +++ b/app/service/UploadService.php @@ -0,0 +1,133 @@ +file($fileField); + + if (!$file) { + return $this->createErrorResult('未上传文件或上传失败'); + } + try { + $config = config('app.upload_conf'); + $configs=[]; + foreach ($config as $key=>$con){ + $configs[] = $key.':'.$con; + } + + // 验证文件 + $validate = validate([ + $fileField =>implode('|',$configs), + ]); + + if (!$validate->check([$fileField => $file])) { + return $this->createErrorResult($validate->getError()); + } + + // 使用cURL转发到目标服务器 + $result = $this->forwardToTargetServer($file, $targetUrl, $extraFields, $headers); + + return $result; + } catch (\Exception $e) { + return $this->createErrorResult('上传过程中发生异常: ' . $e->getMessage()); + } + } + + /** + * 使用cURL将文件转发到目标服务器 + * + * @param \think\File $file 文件对象 + * @param string $targetUrl 目标URL + * @param array $extraFields 额外字段 + * @param array $headers 请求头 + * @return array 包含响应信息的数组 + */ + private function forwardToTargetServer(\think\File $file, string $targetUrl, array $extraFields = [], array $headers = []): array + { + $ch = curl_init(); + + try { + // 设置基本选项 + curl_setopt($ch, CURLOPT_URL, $targetUrl); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_TIMEOUT, 300); // 5分钟超时 + + // 构建上传数据 + $postData = [ + 'file' => new \CURLFile( + $file->getPathname(), + $file->getOriginalMime(), + $file->getOriginalName() + ) + ]; + + // 添加额外字段 + $postData = array_merge($postData, $extraFields); + + curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); + + // 设置请求头 + $httpHeaders = []; + foreach ($headers as $headerName => $headerValue) { + $httpHeaders[] = "$headerName: $headerValue"; + } + + if (!empty($httpHeaders)) { + curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders); + } + + // 执行请求 + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $curlInfo = curl_getinfo($ch); + + // 检查错误 + if ($response === false) { + throw new Exception('cURL错误: ' . curl_error($ch)); + } + + return [ + 'code' => 1, + 'http_code' => $httpCode, + 'response' => $response, + ]; + } catch (\Exception $e) { + return [ + 'code' => 0, + 'error' => $e->getMessage() + ]; + } finally { + curl_close($ch); + } + } + + /** + * 创建错误结果数组 + * + * @param string $message 错误信息 + * @return array 错误结果 + */ + private function createErrorResult(string $message): array + { + return [ + 'code' => 0, + 'error' => $message + ]; + } +} \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3c1e9a8 --- /dev/null +++ b/composer.json @@ -0,0 +1,53 @@ +{ + "name": "topthink/think", + "description": "the new thinkphp framework", + "type": "project", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "https://www.thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + }, + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "require": { + "php": ">=8.0.0", + "topthink/framework": "^8.0", + "topthink/think-orm": "^3.0|^4.0", + "topthink/think-multi-app": "^1.1", + "topthink/think-view": "^2.0", + "topthink/think-filesystem": "^3.0", + "php-curl-class/php-curl-class": "^12.0", + "alibabacloud/oss-v2": "^0.4.0" + }, + "require-dev": { + "topthink/think-dumper": "^1.0", + "topthink/think-trace": "^1.0" + }, + "autoload": { + "psr-4": { + "app\\": "app" + }, + "psr-0": { + "": "extend/" + } + }, + "config": { + "preferred-install": "dist" + }, + "scripts": { + "post-autoload-dump": [ + "@php think service:discover", + "@php think vendor:publish" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..296cab7 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1794 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "83be36c0f1537ea8383186c68c98d174", + "packages": [ + { + "name": "alibabacloud/oss-v2", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2.git", + "reference": "a65ffd843cc8429c24a091804edd3a05f43050e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/alibabacloud-oss-php-sdk-v2/zipball/a65ffd843cc8429c24a091804edd3a05f43050e4", + "reference": "a65ffd843cc8429c24a091804edd3a05f43050e4", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "guzzlehttp/promises": "^1.4.0 || ^2.0", + "guzzlehttp/psr7": "^2.7", + "php": "^7.4 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\Oss\\V2\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud OSS SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Aliyun OSS SDK for PHP v2", + "homepage": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2", + "support": { + "issues": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/issues", + "source": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/tree/0.4.0" + }, + "time": "2025-12-25T08:21:31+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2025-03-27T13:37:11+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2025-03-27T13:27:01+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2025-03-27T12:30:47+00:00" + }, + { + "name": "league/flysystem", + "version": "3.30.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "2203e3151755d874bb2943649dae1eb8533ac93e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/2203e3151755d874bb2943649dae1eb8533ac93e", + "reference": "2203e3151755d874bb2943649dae1eb8533ac93e", + "shasum": "" + }, + "require": { + "league/flysystem-local": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "conflict": { + "async-aws/core": "<1.19.0", + "async-aws/s3": "<1.14.0", + "aws/aws-sdk-php": "3.209.31 || 3.210.0", + "guzzlehttp/guzzle": "<7.0", + "guzzlehttp/ringphp": "<1.1.1", + "phpseclib/phpseclib": "3.0.15", + "symfony/http-client": "<5.2" + }, + "require-dev": { + "async-aws/s3": "^1.5 || ^2.0", + "async-aws/simple-s3": "^1.1 || ^2.0", + "aws/aws-sdk-php": "^3.295.10", + "composer/semver": "^3.0", + "ext-fileinfo": "*", + "ext-ftp": "*", + "ext-mongodb": "^1.3|^2", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.5", + "google/cloud-storage": "^1.23", + "guzzlehttp/psr7": "^2.6", + "microsoft/azure-storage-blob": "^1.1", + "mongodb/mongodb": "^1.2|^2", + "phpseclib/phpseclib": "^3.0.36", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.11|^10.0", + "sabre/dav": "^4.6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "File storage abstraction for PHP", + "keywords": [ + "WebDAV", + "aws", + "cloud", + "file", + "files", + "filesystem", + "filesystems", + "ftp", + "s3", + "sftp", + "storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem/issues", + "source": "https://github.com/thephpleague/flysystem/tree/3.30.0" + }, + "time": "2025-06-25T13:29:59+00:00" + }, + { + "name": "league/flysystem-local", + "version": "3.30.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-local.git", + "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/6691915f77c7fb69adfb87dcd550052dc184ee10", + "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "league/flysystem": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\Local\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Local filesystem adapter for Flysystem.", + "keywords": [ + "Flysystem", + "file", + "files", + "filesystem", + "local" + ], + "support": { + "source": "https://github.com/thephpleague/flysystem-local/tree/3.30.0" + }, + "time": "2025-05-21T10:34:19+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": "php-curl-class/php-curl-class", + "version": "12.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-curl-class/php-curl-class.git", + "reference": "7a8f05efb18bb865dbce864b8fd34d4f5d920c74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-curl-class/php-curl-class/zipball/7a8f05efb18bb865dbce864b8fd34d4f5d920c74", + "reference": "7a8f05efb18bb865dbce864b8fd34d4f5d920c74", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "*", + "ext-gd": "*", + "friendsofphp/php-cs-fixer": "*", + "phpcompatibility/php-compatibility": "dev-develop", + "phpcsstandards/phpcsutils": "@alpha", + "phpstan/phpstan": "*", + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "*" + }, + "suggest": { + "ext-mbstring": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Curl\\": "src/Curl/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Unlicense" + ], + "authors": [ + { + "name": "Zach Borboa" + }, + { + "name": "Contributors", + "homepage": "https://github.com/php-curl-class/php-curl-class/graphs/contributors" + } + ], + "description": "PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.", + "homepage": "https://github.com/php-curl-class/php-curl-class", + "keywords": [ + "API-Client", + "api", + "class", + "client", + "curl", + "framework", + "http", + "http-client", + "http-proxy", + "json", + "php", + "php-curl", + "php-curl-library", + "proxy", + "requests", + "restful", + "web-scraper", + "web-scraping ", + "web-service", + "xml" + ], + "support": { + "issues": "https://github.com/php-curl-class/php-curl-class/issues", + "source": "https://github.com/php-curl-class/php-curl-class/tree/12.0.0" + }, + "time": "2025-03-25T18:04:16+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "1.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/1.1" + }, + "time": "2023-04-04T09:50:52+00:00" + }, + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "time": "2024-09-11T13:17:53+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://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/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "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": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + }, + { + "name": "topthink/framework", + "version": "v8.1.2", + "source": { + "type": "git", + "url": "https://github.com/top-think/framework.git", + "reference": "8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/framework/zipball/8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c", + "reference": "8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": ">=8.0.0", + "psr/http-message": "^1.0", + "psr/log": "^1.0|^2.0|^3.0", + "psr/simple-cache": "^1.0|^2.0|^3.0", + "topthink/think-container": "^3.0", + "topthink/think-helper": "^3.1", + "topthink/think-orm": "^3.0|^4.0", + "topthink/think-validate": "^3.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^2.1.0", + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "files": [], + "psr-4": { + "think\\": "src/think/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + }, + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP Framework.", + "homepage": "http://thinkphp.cn/", + "keywords": [ + "framework", + "orm", + "thinkphp" + ], + "support": { + "issues": "https://github.com/top-think/framework/issues", + "source": "https://github.com/top-think/framework/tree/v8.1.2" + }, + "time": "2025-01-14T08:04:03+00:00" + }, + { + "name": "topthink/think-container", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-container.git", + "reference": "b2df244be1e7399ad4c8be1ccc40ed57868f730a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-container/zipball/b2df244be1e7399ad4c8be1ccc40ed57868f730a", + "reference": "b2df244be1e7399ad4c8be1ccc40ed57868f730a", + "shasum": "" + }, + "require": { + "php": ">=8.0", + "psr/container": "^2.0", + "topthink/think-helper": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "files": [], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "PHP Container & Facade Manager", + "support": { + "issues": "https://github.com/top-think/think-container/issues", + "source": "https://github.com/top-think/think-container/tree/v3.0.2" + }, + "time": "2025-04-07T03:21:51+00:00" + }, + { + "name": "topthink/think-filesystem", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-filesystem.git", + "reference": "7a1231a65bca278de9b7f9236767eef9741dfe5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-filesystem/zipball/7a1231a65bca278de9b7f9236767eef9741dfe5c", + "reference": "7a1231a65bca278de9b7f9236767eef9741dfe5c", + "shasum": "" + }, + "require": { + "league/flysystem": "^3.0", + "php": "^8.2", + "topthink/framework": "^8.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^11.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP6.1 Filesystem Package", + "support": { + "issues": "https://github.com/top-think/think-filesystem/issues", + "source": "https://github.com/top-think/think-filesystem/tree/v3.0.0" + }, + "time": "2024-12-10T06:23:28+00:00" + }, + { + "name": "topthink/think-helper", + "version": "v3.1.11", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-helper.git", + "reference": "1d6ada9b9f3130046bf6922fe1bd159c8d88a33c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/1d6ada9b9f3130046bf6922fe1bd159c8d88a33c", + "reference": "1d6ada9b9f3130046bf6922fe1bd159c8d88a33c", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP6 Helper Package", + "support": { + "issues": "https://github.com/top-think/think-helper/issues", + "source": "https://github.com/top-think/think-helper/tree/v3.1.11" + }, + "time": "2025-04-07T06:55:59+00:00" + }, + { + "name": "topthink/think-multi-app", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-multi-app.git", + "reference": "f93c604d5cfac2b613756273224ee2f88e457b88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/f93c604d5cfac2b613756273224ee2f88e457b88", + "reference": "f93c604d5cfac2b613756273224ee2f88e457b88", + "shasum": "" + }, + "require": { + "php": ">=7.1.0", + "topthink/framework": "^6.0|^8.0" + }, + "type": "library", + "extra": { + "think": { + "services": [ + "think\\app\\Service" + ] + } + }, + "autoload": { + "psr-4": { + "think\\app\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp multi app support", + "support": { + "issues": "https://github.com/top-think/think-multi-app/issues", + "source": "https://github.com/top-think/think-multi-app/tree/v1.1.1" + }, + "time": "2024-11-25T08:52:44+00:00" + }, + { + "name": "topthink/think-orm", + "version": "v4.0.46", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-orm.git", + "reference": "4bb0a5679a97db8de1c0eb02bbbe179cb3afd901" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-orm/zipball/4bb0a5679a97db8de1c0eb02bbbe179cb3afd901", + "reference": "4bb0a5679a97db8de1c0eb02bbbe179cb3afd901", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-pdo": "*", + "php": ">=8.0.0", + "psr/log": ">=1.0", + "psr/simple-cache": ">=1.0", + "topthink/think-helper": "^3.1", + "topthink/think-validate": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6|^10" + }, + "suggest": { + "ext-mongodb": "provide mongodb support" + }, + "type": "library", + "autoload": { + "files": [ + "src/helper.php", + "stubs/load_stubs.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the PHP Database&ORM Framework", + "keywords": [ + "database", + "orm" + ], + "support": { + "issues": "https://github.com/top-think/think-orm/issues", + "source": "https://github.com/top-think/think-orm/tree/v4.0.46" + }, + "time": "2025-06-26T06:05:35+00:00" + }, + { + "name": "topthink/think-template", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-template.git", + "reference": "0b88bd449f0f7626dd75b05f557c8bc208c08b0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-template/zipball/0b88bd449f0f7626dd75b05f557c8bc208c08b0c", + "reference": "0b88bd449f0f7626dd75b05f557c8bc208c08b0c", + "shasum": "" + }, + "require": { + "php": ">=8.0.0", + "psr/simple-cache": ">=1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the php template engine", + "support": { + "issues": "https://github.com/top-think/think-template/issues", + "source": "https://github.com/top-think/think-template/tree/v3.0.2" + }, + "time": "2024-10-16T03:41:06+00:00" + }, + { + "name": "topthink/think-validate", + "version": "v3.0.7", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-validate.git", + "reference": "85063f6d4ef8ed122f17a36179dc3e0949b30988" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-validate/zipball/85063f6d4ef8ed122f17a36179dc3e0949b30988", + "reference": "85063f6d4ef8ed122f17a36179dc3e0949b30988", + "shasum": "" + }, + "require": { + "php": ">=8.0", + "topthink/think-container": ">=3.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "think validate", + "support": { + "issues": "https://github.com/top-think/think-validate/issues", + "source": "https://github.com/top-think/think-validate/tree/v3.0.7" + }, + "time": "2025-06-11T05:51:40+00:00" + }, + { + "name": "topthink/think-view", + "version": "v2.0.5", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-view.git", + "reference": "b42009b98199b5a3833d3d6fd18c8a55aa511fad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-view/zipball/b42009b98199b5a3833d3d6fd18c8a55aa511fad", + "reference": "b42009b98199b5a3833d3d6fd18c8a55aa511fad", + "shasum": "" + }, + "require": { + "php": ">=8.0.0", + "topthink/think-template": "^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "think\\view\\driver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp template driver", + "support": { + "issues": "https://github.com/top-think/think-view/issues", + "source": "https://github.com/top-think/think-view/tree/v2.0.5" + }, + "time": "2025-03-19T07:04:19+00:00" + } + ], + "packages-dev": [ + { + "name": "symfony/polyfill-mbstring", + "version": "v1.32.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "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 for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-12-23T08:48:59+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v7.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "548f6760c54197b1084e1e5c71f6d9d523f2f78e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/548f6760c54197b1084e1e5c71f6d9d523f2f78e", + "reference": "548f6760c54197b1084e1e5c71f6d9d523f2f78e", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/uid": "^6.4|^7.0", + "twig/twig": "^3.12" + }, + "bin": [ + "Resources/bin/var-dump-server" + ], + "type": "library", + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "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": "Provides mechanisms for walking through any arbitrary PHP variable", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "support": { + "source": "https://github.com/symfony/var-dumper/tree/v7.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-04-27T18:39:23+00:00" + }, + { + "name": "topthink/think-dumper", + "version": "v1.0.5", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-dumper.git", + "reference": "eba662a1843d5db68059050c530f7d43287289fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-dumper/zipball/eba662a1843d5db68059050c530f7d43287289fc", + "reference": "eba662a1843d5db68059050c530f7d43287289fc", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/var-dumper": ">=6.0", + "topthink/framework": "^6.0|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.4" + }, + "type": "library", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\dumper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "Dumper extend for thinkphp", + "support": { + "issues": "https://github.com/top-think/think-dumper/issues", + "source": "https://github.com/top-think/think-dumper/tree/v1.0.5" + }, + "time": "2025-03-21T07:15:45+00:00" + }, + { + "name": "topthink/think-trace", + "version": "v1.6", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-trace.git", + "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-trace/zipball/136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", + "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", + "shasum": "" + }, + "require": { + "php": ">=7.1.0", + "topthink/framework": "^6.0|^8.0" + }, + "type": "library", + "extra": { + "think": { + "config": { + "trace": "src/config.php" + }, + "services": [ + "think\\trace\\Service" + ] + } + }, + "autoload": { + "psr-4": { + "think\\trace\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp debug trace", + "support": { + "issues": "https://github.com/top-think/think-trace/issues", + "source": "https://github.com/top-think/think-trace/tree/v1.6" + }, + "time": "2023-02-07T08:36:32+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.0.0" + }, + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/config/app.php b/config/app.php new file mode 100644 index 0000000..3c5b726 --- /dev/null +++ b/config/app.php @@ -0,0 +1,31 @@ + '', + // 是否启用路由 + 'with_route' => true, + // 默认应用 + 'default_app' => 'miniapi', + // 默认时区 + 'default_timezone' => 'Asia/Shanghai', + 'site_domain' => env('SITE_DOMAIN', ''), + + // 应用映射(自动多应用模式有效) + 'app_map' => [], + // 域名绑定(自动多应用模式有效) + 'domain_bind' => [], + // 禁止URL访问的应用列表(自动多应用模式有效) + 'deny_app_list' => [], + + // 异常页面的模板文件 + 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl', + + // 错误显示信息,非调试模式有效 + 'error_message' => '页面错误!请稍后再试~', + // 显示错误信息 + 'show_error_msg' => false, +]; diff --git a/config/cache.php b/config/cache.php new file mode 100644 index 0000000..6b72dc8 --- /dev/null +++ b/config/cache.php @@ -0,0 +1,29 @@ + 'file', + + // 缓存连接方式配置 + 'stores' => [ + 'file' => [ + // 驱动方式 + 'type' => 'File', + // 缓存保存目录 + 'path' => '', + // 缓存前缀 + 'prefix' => '', + // 缓存有效期 0表示永久缓存 + 'expire' => 0, + // 缓存标签前缀 + 'tag_prefix' => 'tag:', + // 序列化机制 例如 ['serialize', 'unserialize'] + 'serialize' => [], + ], + // 更多的缓存连接 + ], +]; diff --git a/config/citic.php b/config/citic.php new file mode 100644 index 0000000..e0a8c5a --- /dev/null +++ b/config/citic.php @@ -0,0 +1,6 @@ + ['49900', '74500'], +]; diff --git a/config/console.php b/config/console.php new file mode 100644 index 0000000..a818a98 --- /dev/null +++ b/config/console.php @@ -0,0 +1,9 @@ + [ + ], +]; diff --git a/config/cookie.php b/config/cookie.php new file mode 100644 index 0000000..d3b3aab --- /dev/null +++ b/config/cookie.php @@ -0,0 +1,20 @@ + 0, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => false, + // 是否使用 setcookie + 'setcookie' => true, + // samesite 设置,支持 'strict' 'lax' + 'samesite' => '', +]; diff --git a/config/database.php b/config/database.php new file mode 100644 index 0000000..430934d --- /dev/null +++ b/config/database.php @@ -0,0 +1,63 @@ + env('DB_DRIVER', 'mysql'), + + // 自定义时间查询规则 + 'time_query_rule' => [], + + // 自动写入时间戳字段 + // true为自动识别类型 false关闭 + // 字符串则明确指定时间字段类型 支持 int timestamp datetime date + 'auto_timestamp' => true, + + // 时间字段取出后的默认时间格式 + 'datetime_format' => 'Y-m-d H:i:s', + + // 时间字段配置 配置格式:create_time,update_time + 'datetime_field' => '', + + // 数据库连接配置信息 + 'connections' => [ + 'mysql' => [ + // 数据库类型 + 'type' => env('DB_TYPE', 'mysql'), + // 服务器地址 + 'hostname' => env('DB_HOST', '127.0.0.1'), + // 数据库名 + 'database' => env('DB_NAME', ''), + // 用户名 + 'username' => env('DB_USER', 'root'), + // 密码 + 'password' => env('DB_PASS', ''), + // 端口 + 'hostport' => env('DB_PORT', '3306'), + // 数据库连接参数 + 'params' => [], + // 数据库编码 + 'charset' => env('DB_CHARSET', 'utf8mb4'), + // 数据库表前缀 + 'prefix' => env('DB_PREFIX', 'zy_'), + + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 是否需要断线重连 + 'break_reconnect' => false, + // 监听SQL + 'trigger_sql' => env('APP_DEBUG', true), + // 开启字段缓存 + 'fields_cache' => false, + ], + + // 更多的数据库配置信息 + ], +]; diff --git a/config/filesystem.php b/config/filesystem.php new file mode 100644 index 0000000..e8f6178 --- /dev/null +++ b/config/filesystem.php @@ -0,0 +1,47 @@ + 'local', + // 磁盘列表 + 'disks' => [ + 'local' => [ + 'type' => 'local', + 'root' => app()->getRuntimePath() . 'storage', + ], + 'public' => [ + // 磁盘类型 + 'type' => 'local', + // 磁盘路径 + 'root' => app()->getRootPath() . 'public/storage', + // 磁盘路径对应的外部URL路径 + 'url' => '/storage', + // 可见性 + 'visibility' => 'public', + ], + 's3'=>[ + 'version' => 'latest', + 'region' => 'us-east-1', + 'endpoint' => 'https://oss.jzvisa.com', + 'use_path_style_endpoint' => true, + 'credentials' => [ + 'key' => 'aq72GoQAniHsTgXMmC9Z', + 'secret' => '4ucvm7yvoGV9bAimLSHNXIWC7NkaZjLKOHEZeHUe', + ], + ], + ], + 'upload_conf' => [ + 'fileSize'=>'10485760', + 'fileExt'=>['jpg','png','gif','pdf','doc','docx'], + 'fallbackDir'=>app()->getRuntimePath() . 'storage/oss-fallback', + ], + 'imageMimeTypes' => [ + 'image/jpeg', + 'image/png', + 'image/gif', + 'image/webp', + 'image/svg+xml', + 'image/bmp', + ], + +]; diff --git a/config/lang.php b/config/lang.php new file mode 100644 index 0000000..e883dbc --- /dev/null +++ b/config/lang.php @@ -0,0 +1,29 @@ + env('DEFAULT_LANG', 'zh-cn'), + // 自动侦测浏览器语言 + 'auto_detect_browser' => true, + // 允许的语言列表 + 'allow_lang_list' => [], + // 多语言自动侦测变量名 + 'detect_var' => 'lang', + // 是否使用Cookie记录 + 'use_cookie' => true, + // 多语言cookie变量 + 'cookie_var' => 'think_var', + // 多语言header变量 + 'header_var' => 'think-lang', + // 扩展语言包 + 'extend_list' => [], + // Accept-Language转义为对应语言包名称 + 'accept_language' => [ + 'zh-hans-cn' => 'zh-cn', + ], + // 是否支持语言分组 + 'allow_group' => true, +]; diff --git a/config/log.php b/config/log.php new file mode 100644 index 0000000..82de7ed --- /dev/null +++ b/config/log.php @@ -0,0 +1,50 @@ + 'file', + // 日志记录级别 + 'level' => [], + // 日志类型记录的通道 ['error'=>'email',...] + 'type_channel' => [], + // 关闭全局日志写入 + 'close' => false, + // 全局日志处理 支持闭包 + 'processor' => null, + + // 日志通道列表 + 'channels' => [ + 'file' => [ + // 日志记录方式 + 'type' => 'File', + // 日志保存目录 + 'path' => '', + // 单文件日志写入 + 'single' => false, + // 独立日志级别 + 'apart_level' => [], + // 最大日志文件数量 + 'max_files' => 0, + // 使用JSON格式记录 + 'json' => false, + // 日志处理 + 'processor' => null, + // 关闭通道日志写入 + 'close' => false, + // 日志输出格式化 + 'format' => '[%s][%s] %s', + // 是否实时写入 + 'realtime_write' => false, + ], + // 其它日志通道配置 + 'monolog' => [ + // 驱动类型 + 'type' => '\\app\\log\\driver\\Monolog', + // 日志保存目录 + ], + ], + +]; diff --git a/config/middleware.php b/config/middleware.php new file mode 100644 index 0000000..7e1972f --- /dev/null +++ b/config/middleware.php @@ -0,0 +1,8 @@ + [], + // 优先级设置,此数组中的中间件会按照数组中的顺序优先执行 + 'priority' => [], +]; diff --git a/config/mini_legal.php b/config/mini_legal.php new file mode 100644 index 0000000..19e337d --- /dev/null +++ b/config/mini_legal.php @@ -0,0 +1,43 @@ + 'evus', + 'businesses' => [ + 'evus' => [ + 'documents' => [ + 'terms' => [ + 'title_key' => 'foot.user_agreement', + 'content_key' => 'foot.user_agreement_info', + 'intro_template' => '本条款与条件适用于{company_name}提供的EVUS登记小程序服务。', + 'subject_label' => '服务主体', + ], + 'privacy' => [ + 'title_key' => 'foot.privacy_policy', + 'content_key' => 'foot.privacy_policy_info', + 'intro_template' => '本隐私政策适用于{company_name}提供的EVUS登记小程序服务。', + 'subject_label' => '个人信息处理者', + ], + ], + 'companies' => [ + 'jn' => [ + 'company_name' => '济南经纬九州出入境服务有限公司', + 'site_domain' => 'www.evus.cn', + 'phone' => '', + ], + 'bj' => [ + 'company_name' => '北京签律出入境服务有限公司', + 'site_domain' => 'www.evus.com.cn', + 'phone' => '', + ], + ], + 'apps' => [ + 'evus_jn_mp' => [ + 'company_code' => 'jn', + ], + 'evus_bj_mp' => [ + 'company_code' => 'bj', + ], + ], + ], + ], +]; diff --git a/config/mini_payment.php b/config/mini_payment.php new file mode 100644 index 0000000..1c14931 --- /dev/null +++ b/config/mini_payment.php @@ -0,0 +1,57 @@ + 'evus', + 'businesses' => [ + 'evus' => [ + 'mini_pay' => [ + 'url' => 'https://pay.qlevisa.com/home/pay/miniwxevuspay', + 'body' => 'EVUS登记服务费', + 'attach' => 'msg', + ], + 'companies' => [ + 'jn' => [ + 'mini_pay' => [], + ], + 'bj' => [ + 'mini_pay' => [], + ], + ], + 'apps' => [ + 'evus_jn_mp' => [ + 'company_code' => 'jn', + 'mini_pay' => [], + ], + 'evus_bj_mp' => [ + 'company_code' => 'bj', + 'mini_pay' => [], + ], + ], + ], + 'esta' => [ + 'mini_pay' => [ + 'url' => 'https://pay.qlevisa.com/home/pay/miniwxevuspay', + 'body' => 'ESTA登记签证服务费', + 'attach' => 'esta', + ], + 'companies' => [ + 'jn' => [ + 'mini_pay' => [], + ], + 'bj' => [ + 'mini_pay' => [], + ], + ], + 'apps' => [ + 'evus_jn_mp' => [ + 'company_code' => 'jn', + 'mini_pay' => [], + ], + 'evus_bj_mp' => [ + 'company_code' => 'bj', + 'mini_pay' => [], + ], + ], + ], + ], +]; diff --git a/config/mini_product.php b/config/mini_product.php new file mode 100644 index 0000000..eaca435 --- /dev/null +++ b/config/mini_product.php @@ -0,0 +1,49 @@ + 'evus', + 'businesses' => [ + 'evus' => [ + 'legacy_config_key' => 'EVUS_GOODS', + 'companies' => [ + 'jn' => [ + 'products' => [], + ], + 'bj' => [ + 'products' => [], + ], + ], + 'apps' => [ + 'evus_jn_mp' => [ + 'company_code' => 'jn', + 'products' => [], + ], + 'evus_bj_mp' => [ + 'company_code' => 'bj', + 'products' => [], + ], + ], + ], + 'esta' => [ + 'legacy_config_key' => 'ESTA_GOODS', + 'companies' => [ + 'jn' => [ + 'products' => [], + ], + 'bj' => [ + 'products' => [], + ], + ], + 'apps' => [ + 'evus_jn_mp' => [ + 'company_code' => 'jn', + 'products' => [], + ], + 'evus_bj_mp' => [ + 'company_code' => 'bj', + 'products' => [], + ], + ], + ], + ], +]; diff --git a/config/miniapp.php b/config/miniapp.php new file mode 100644 index 0000000..c8ec853 --- /dev/null +++ b/config/miniapp.php @@ -0,0 +1,24 @@ + 'X-Mini-App-Code', + 'default_code' => 'evus_jn_mp', + 'apps' => [ + 'evus_jn_mp' => [ + 'company_code' => 'jn', + 'company_name' => 'jinan', + 'site_domain' => env('SITE_DOMAIN', 'www.evus.cn'), + 'wechat_appid' => env('WECHAT_MINI_APPID', 'wx91fe9316ef97178c'), + 'wechat_secret' => env('WECHAT_MINI_SECRET', ''), + 'status' => 1, + ], + 'evus_bj_mp' => [ + 'company_code' => 'bj', + 'company_name' => 'beijing', + 'site_domain' => env('SITE_DOMAIN_BJ', 'www.evus.com.cn'), + 'wechat_appid' => env('WECHAT_MINI_APPID_BJ', ''), + 'wechat_secret' => env('WECHAT_MINI_SECRET_BJ', ''), + 'status' => 1, + ], + ], +]; diff --git a/config/ocr.php b/config/ocr.php new file mode 100644 index 0000000..1b5685e --- /dev/null +++ b/config/ocr.php @@ -0,0 +1,10 @@ + env('OCR_ORIGIN', ''), + 'timeout' => (int) env('OCR_TIMEOUT', 60), + 'connect_timeout' => (int) env('OCR_CONNECT_TIMEOUT', 10), + 'auto_rotate' => env('OCR_AUTO_ROTATE', true), + 'return_debug' => env('OCR_RETURN_DEBUG', false), + 'verify_ssl' => env('OCR_VERIFY_SSL', true), +]; diff --git a/config/oss.php b/config/oss.php new file mode 100644 index 0000000..e37326c --- /dev/null +++ b/config/oss.php @@ -0,0 +1,13 @@ + 'cn-hangzhou', + 'endpoint' => 'oss-cn-hangzhou.aliyuncs.com', + 'bucket' => 'filesoa', + 'access_key_id' => 'LTAI5tBscvVZHW7P9F7NT1K2', + 'access_key_secret' => 'NIVu6LYDaYRJBrexqMpqAFe2d52CwB', +]; diff --git a/config/route.php b/config/route.php new file mode 100644 index 0000000..41ba1ed --- /dev/null +++ b/config/route.php @@ -0,0 +1,51 @@ + '/', + // 是否开启路由延迟解析 + 'url_lazy_route' => false, + // 是否强制使用路由 + 'url_route_must' => false, + // 是否区分大小写 + 'url_case_sensitive' => false, + // 合并路由规则 + 'route_rule_merge' => false, + // 路由是否完全匹配 + 'route_complete_match' => false, + // 去除斜杠 + 'remove_slash' => false, + // 默认的路由变量规则 + 'default_route_pattern' => '[\w\.]+', + // URL伪静态后缀 + 'url_html_suffix' => 'html', + // 访问控制器层名称 + 'controller_layer' => 'controller', + // 空控制器名 + 'empty_controller' => 'Error', + // 是否使用控制器后缀 + 'controller_suffix' => false, + // 默认模块名(开启自动多模块有效) + 'default_module' => 'index', + // 默认控制器名 + 'default_controller' => 'Index', + // 默认操作名 + 'default_action' => 'index', + // 操作方法后缀 + 'action_suffix' => '', + // 非路由变量是否使用普通参数方式(用于URL生成) + 'url_common_param' => true, + // 操作方法的参数绑定方式 route get param + 'action_bind_param' => 'get', + // 请求缓存规则 true为自动规则 + 'request_cache_key' => true, + // 请求缓存有效期 + 'request_cache_expire' => null, + // 全局请求缓存排除规则 + 'request_cache_except' => [], + // 请求缓存的Tag + 'request_cache_tag' => '', +]; diff --git a/config/session.php b/config/session.php new file mode 100644 index 0000000..c1ef6e1 --- /dev/null +++ b/config/session.php @@ -0,0 +1,19 @@ + 'PHPSESSID', + // SESSION_ID的提交变量,解决flash上传跨域 + 'var_session_id' => '', + // 驱动方式 支持file cache + 'type' => 'file', + // 存储连接标识 当type使用cache的时候有效 + 'store' => null, + // 过期时间 + 'expire' => 1440, + // 前缀 + 'prefix' => '', +]; diff --git a/config/trace.php b/config/trace.php new file mode 100644 index 0000000..fad2392 --- /dev/null +++ b/config/trace.php @@ -0,0 +1,10 @@ + 'Html', + // 读取的日志通道名 + 'channel' => '', +]; diff --git a/config/view.php b/config/view.php new file mode 100644 index 0000000..01259a0 --- /dev/null +++ b/config/view.php @@ -0,0 +1,25 @@ + 'Think', + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 + 'auto_rule' => 1, + // 模板目录名 + 'view_dir_name' => 'view', + // 模板后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DIRECTORY_SEPARATOR, + // 模板引擎普通标签开始标记 + 'tpl_begin' => '{', + // 模板引擎普通标签结束标记 + 'tpl_end' => '}', + // 标签库标签开始标记 + 'taglib_begin' => '{', + // 标签库标签结束标记 + 'taglib_end' => '}', +]; diff --git a/extend/api/Httpcurl.php b/extend/api/Httpcurl.php new file mode 100644 index 0000000..d76fc82 --- /dev/null +++ b/extend/api/Httpcurl.php @@ -0,0 +1,125 @@ + + * @link https://github.com/gaoming13/HttpCurl + * @link http://me.diary8.com/ + */ +namespace api; +class Httpcurl +{ + /** + * 模拟POST与GET请求 + * + * Examples: + * ``` + * HttpCurl::request('http://example.com/', 'post', array( + * 'user_uid' => 'root', + * 'user_pwd' => '123456' + * )); + * + * HttpCurl::request('http://example.com/', 'post', '{"name": "peter"}'); + * + * HttpCurl::request('http://example.com/', 'post', array( + * 'file1' => '@/data/sky.jpg', + * 'file2' => '@/data/bird.jpg' + * )); + * + * // windows + * HttpCurl::request('http://example.com/', 'post', array( + * 'file1' => '@G:\wamp\www\data\1.jpg', + * 'file2' => '@G:\wamp\www\data\2.jpg' + * )); + * + * HttpCurl::request('http://example.com/', 'get'); + * + * HttpCurl::request('http://example.com/?a=123', 'get', array('b'=>456)); + * ``` + * + * @param string $url [请求地址] + * @param string $type [请求方式 post or get] + * @param bool|string|array $data [传递的参数] + * @param array $header [可选:请求头] eg: ['Content-Type:application/json'] + * @param int $timeout [可选:超时时间] + * + * @return array($body, $header, $status, $errno, $error) + * - $body string [响应正文] + * - $header string [响应头] + * - $status array [响应状态] + * - $errno int [错误码] + * - $error string [错误描述] + */ + public static function request($url, $type, $data = false, $header = [], $timeout = 0) + { + $cl = curl_init(); + + // 兼容HTTPS + if (stripos($url, 'https://') !== FALSE) { + curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($cl, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($cl, CURLOPT_SSLVERSION, 1); + } + + // 设置返回内容做变量存储 + curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1); + + // 设置需要返回Header + curl_setopt($cl, CURLOPT_HEADER, true); + + // 设置请求头 + if (count($header) > 0) { + curl_setopt($cl, CURLOPT_HTTPHEADER, $header); + } + + // 设置需要返回Body + curl_setopt($cl, CURLOPT_NOBODY, 0); + + // 设置超时时间 + if ($timeout > 0) { + curl_setopt($cl, CURLOPT_TIMEOUT, $timeout); + } + + // POST/GET参数处理 + $type = strtoupper($type); + if ($type == 'POST') { + curl_setopt($cl, CURLOPT_POST, true); + // convert @ prefixed file names to CurlFile class + // since @ prefix is deprecated as of PHP 5.6 + if (class_exists('\CURLFile') && is_array($data)) { + foreach ($data as $k => $v) { + if (is_string($v) && strpos($v, '@') === 0) { + $v = ltrim($v, '@'); + $data[$k] = new \CURLFile($v); + } + } + } + curl_setopt($cl, CURLOPT_POSTFIELDS, $data); + } + if ($type == 'GET' && is_array($data)) { + if (stripos($url, "?") === FALSE) { + $url .= '?'; + } + $url .= http_build_query($data); + } + curl_setopt($cl, CURLOPT_URL, $url); + // 读取获取内容 + $response = curl_exec($cl); + // 读取状态 + $status = curl_getinfo($cl); + // 读取错误号 + $errno = curl_errno($cl); + // 读取错误详情 + $error = curl_error($cl); + + // 关闭Curl + curl_close($cl); + if ($errno == 0 && isset($status['http_code'])) { + $header = substr($response, 0, $status['header_size']); + $body = substr($response, $status['header_size']); + return array($body, $header, $status, 0, ''); + } else { + return array('', '', $status, $errno, $error); + } + } +} diff --git a/extend/api/Verify.php b/extend/api/Verify.php new file mode 100644 index 0000000..cf59a0c --- /dev/null +++ b/extend/api/Verify.php @@ -0,0 +1,337 @@ + +// +---------------------------------------------------------------------- + +namespace api; +class Verify { + protected $config = array( + 'seKey' => 'ThinkPHP.CN', // 验证码加密密钥 + 'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY', // 验证码字符集合 + 'expire' => 1800, // 验证码过期时间(s) + 'useZh' => false, // 使用中文验证码 + 'zhSet' => '们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在了不和有大这主中人上为来分生对于学下级地个用同行面说种过命度革而多子后自社加小机也经力线本电高量长党得实家定深法表着水理化争现所二起政三好十战无农使性前等反体合斗路图把结第里正新开论之物从当两些还天资事队批点育重其思与间内去因件日利相由压员气业代全组数果期导平各基或月毛然如应形想制心样干都向变关问比展那它最及外没看治提五解系林者米群头意只明四道马认次文通但条较克又公孔领军流入接席位情运器并飞原油放立题质指建区验活众很教决特此常石强极土少已根共直团统式转别造切九你取西持总料连任志观调七么山程百报更见必真保热委手改管处己将修支识病象几先老光专什六型具示复安带每东增则完风回南广劳轮科北打积车计给节做务被整联步类集号列温装即毫知轴研单色坚据速防史拉世设达尔场织历花受求传口断况采精金界品判参层止边清至万确究书术状厂须离再目海交权且儿青才证低越际八试规斯近注办布门铁需走议县兵固除般引齿千胜细影济白格效置推空配刀叶率述今选养德话查差半敌始片施响收华觉备名红续均药标记难存测士身紧液派准斤角降维板许破述技消底床田势端感往神便贺村构照容非搞亚磨族火段算适讲按值美态黄易彪服早班麦削信排台声该击素张密害侯草何树肥继右属市严径螺检左页抗苏显苦英快称坏移约巴材省黑武培著河帝仅针怎植京助升王眼她抓含苗副杂普谈围食射源例致酸旧却充足短划剂宣环落首尺波承粉践府鱼随考刻靠够满夫失包住促枝局菌杆周护岩师举曲春元超负砂封换太模贫减阳扬江析亩木言球朝医校古呢稻宋听唯输滑站另卫字鼓刚写刘微略范供阿块某功套友限项余倒卷创律雨让骨远帮初皮播优占死毒圈伟季训控激找叫云互跟裂粮粒母练塞钢顶策双留误础吸阻故寸盾晚丝女散焊功株亲院冷彻弹错散商视艺灭版烈零室轻血倍缺厘泵察绝富城冲喷壤简否柱李望盘磁雄似困巩益洲脱投送奴侧润盖挥距触星松送获兴独官混纪依未突架宽冬章湿偏纹吃执阀矿寨责熟稳夺硬价努翻奇甲预职评读背协损棉侵灰虽矛厚罗泥辟告卵箱掌氧恩爱停曾溶营终纲孟钱待尽俄缩沙退陈讨奋械载胞幼哪剥迫旋征槽倒握担仍呀鲜吧卡粗介钻逐弱脚怕盐末阴丰雾冠丙街莱贝辐肠付吉渗瑞惊顿挤秒悬姆烂森糖圣凹陶词迟蚕亿矩康遵牧遭幅园腔订香肉弟屋敏恢忘编印蜂急拿扩伤飞露核缘游振操央伍域甚迅辉异序免纸夜乡久隶缸夹念兰映沟乙吗儒杀汽磷艰晶插埃燃欢铁补咱芽永瓦倾阵碳演威附牙芽永瓦斜灌欧献顺猪洋腐请透司危括脉宜笑若尾束壮暴企菜穗楚汉愈绿拖牛份染既秋遍锻玉夏疗尖殖井费州访吹荣铜沿替滚客召旱悟刺脑措贯藏敢令隙炉壳硫煤迎铸粘探临薄旬善福纵择礼愿伏残雷延烟句纯渐耕跑泽慢栽鲁赤繁境潮横掉锥希池败船假亮谓托伙哲怀割摆贡呈劲财仪沉炼麻罪祖息车穿货销齐鼠抽画饲龙库守筑房歌寒喜哥洗蚀废纳腹乎录镜妇恶脂庄擦险赞钟摇典柄辩竹谷卖乱虚桥奥伯赶垂途额壁网截野遗静谋弄挂课镇妄盛耐援扎虑键归符庆聚绕摩忙舞遇索顾胶羊湖钉仁音迹碎伸灯避泛亡答勇频皇柳哈揭甘诺概宪浓岛袭谁洪谢炮浇斑讯懂灵蛋闭孩释乳巨徒私银伊景坦累匀霉杜乐勒隔弯绩招绍胡呼痛峰零柴簧午跳居尚丁秦稍追梁折耗碱殊岗挖氏刃剧堆赫荷胸衡勤膜篇登驻案刊秧缓凸役剪川雪链渔啦脸户洛孢勃盟买杨宗焦赛旗滤硅炭股坐蒸凝竟陷枪黎救冒暗洞犯筒您宋弧爆谬涂味津臂障褐陆啊健尊豆拔莫抵桑坡缝警挑污冰柬嘴啥饭塑寄赵喊垫丹渡耳刨虎笔稀昆浪萨茶滴浅拥穴覆伦娘吨浸袖珠雌妈紫戏塔锤震岁貌洁剖牢锋疑霸闪埔猛诉刷狠忽灾闹乔唐漏闻沈熔氯荒茎男凡抢像浆旁玻亦忠唱蒙予纷捕锁尤乘乌智淡允叛畜俘摸锈扫毕璃宝芯爷鉴秘净蒋钙肩腾枯抛轨堂拌爸循诱祝励肯酒绳穷塘燥泡袋朗喂铝软渠颗惯贸粪综墙趋彼届墨碍启逆卸航衣孙龄岭骗休借', // 中文验证码字符串 + 'useImgBg' => false, // 使用背景图片 + 'fontSize' => 25, // 验证码字体大小(px) + 'useCurve' => true, // 是否画混淆曲线 + 'useNoise' => true, // 是否添加杂点 + 'imageH' => 0, // 验证码图片高度 + 'imageW' => 0, // 验证码图片宽度 + 'length' => 5, // 验证码位数 + 'fontttf' => '', // 验证码字体,不设置随机获取 + 'bg' => array(243, 251, 254), // 背景颜色 + 'reset' => true, // 验证成功后是否重置 + ); + + private $_image = NULL; // 验证码图片实例 + private $_color = NULL; // 验证码字体颜色 + + /** + * 架构方法 设置参数 + * @access public + * @param array $config 配置参数 + */ + public function __construct($config=array()){ + $this->config = array_merge($this->config, $config); + } + + /** + * 使用 $this->name 获取配置 + * @access public + * @param string $name 配置名称 + * @return multitype 配置值 + */ + public function __get($name) { + return $this->config[$name] ?? null; + } + + /** + * 设置验证码配置 + * @access public + * @param string $name 配置名称 + * @param string $value 配置值 + * @return void + */ + public function __set($name,$value){ + if(isset($this->config[$name])) { + $this->config[$name] = $value; + } + } + + /** + * 检查配置 + * @access public + * @param string $name 配置名称 + * @return bool + */ + public function __isset($name){ + return isset($this->config[$name]); + } + + /** + * 验证验证码是否正确 + * @access public + * @param string $code 用户验证码 + * @param string $id 验证码标识 + * @return bool 用户验证码是否正确 + */ + public function check($code, $id = '') { + $code = $this->normalizeCode($code); + $key = $this->authcode($this->seKey).$id; + // 验证码不能为空 + $secode = session($key); + if(empty($code) || empty($secode) || !is_array($secode) || empty($secode['verify_code']) || empty($secode['verify_time'])) { + return false; + } + // session 过期 + if(time() - $secode['verify_time'] > $this->expire) { + session($key, null); + return false; + } + + if($this->authcode($code) == $secode['verify_code']) { + $this->reset && session($key, null); + return true; + } + + return false; + } + + /** + * 输出验证码并把验证码的值保存的session中 + * 验证码保存到session的格式为: array('verify_code' => '验证码值', 'verify_time' => '验证码创建时间'); + * @access public + * @param string $id 要生成验证码的标识 + * @return void + */ + public function entry($id = '') { + // 图片宽(px) + $this->imageW || $this->imageW = max(1, (int) ceil($this->length * $this->fontSize * 1.5 + $this->length * $this->fontSize / 2)); + // 图片高(px) + $this->imageH || $this->imageH = max(1, (int) ceil($this->fontSize * 2.5)); + // 建立一幅 $this->imageW x $this->imageH 的图像 + $this->_image = imagecreate((int) $this->imageW, (int) $this->imageH); + if (!$this->_image) { + throw new \RuntimeException('Verify image create failed.'); + } + // 设置背景 + imagecolorallocate($this->_image, $this->bg[0], $this->bg[1], $this->bg[2]); + + // 验证码字体随机颜色 + $this->_color = imagecolorallocate($this->_image, mt_rand(1,150), mt_rand(1,150), mt_rand(1,150)); + // 验证码使用随机字体 + $ttfPath = dirname(__FILE__) . '/Verify/' . ($this->useZh ? 'zhttfs' : 'ttfs') . '/'; + + if(empty($this->fontttf)){ + $ttfs = is_dir($ttfPath) ? glob($ttfPath . '*.ttf') : array(); + if (empty($ttfs)) { + throw new \RuntimeException('Verify font file not found.'); + } + $this->fontttf = $ttfs[array_rand($ttfs)]; + } else { + $this->fontttf = $ttfPath . $this->fontttf; + } + if (!is_file($this->fontttf)) { + throw new \RuntimeException('Verify font file not found.'); + } + + if($this->useImgBg) { + $this->_background(); + } + + if ($this->useNoise) { + // 绘杂点 + $this->_writeNoise(); + } + if ($this->useCurve) { + // 绘干扰线 + $this->_writeCurve(); + } + + // 绘验证码 + $code = array(); // 验证码 + $codeNX = 0; // 验证码第N个字符的左边距 + if($this->useZh){ // 中文验证码 + for ($i = 0; $i<$this->length; $i++) { + $code[$i] = iconv_substr($this->zhSet,floor(mt_rand(0,mb_strlen($this->zhSet,'utf-8')-1)),1,'utf-8'); + imagettftext($this->_image, (int) $this->fontSize, mt_rand(-40, 40), (int) round($this->fontSize * ($i + 1) * 1.5), (int) round($this->fontSize + mt_rand(10, 20)), $this->_color, $this->fontttf, $code[$i]); + } + }else{ + for ($i = 0; $i<$this->length; $i++) { + $code[$i] = $this->codeSet[mt_rand(0, strlen($this->codeSet)-1)]; + $codeNX += $this->randInt($this->fontSize * 1.2, $this->fontSize * 1.6); + imagettftext($this->_image, (int) $this->fontSize, mt_rand(-40, 40), (int) $codeNX, (int) round($this->fontSize * 1.6), $this->_color, $this->fontttf, $code[$i]); + } + } + + // 保存验证码 + $key = $this->authcode($this->seKey); + $code = $this->authcode($this->normalizeCode(implode('', $code))); + $secode = array(); + $secode['verify_code'] = $code; // 把校验码保存到session + $secode['verify_time'] = time(); // 验证码创建时间 + session($key.$id, $secode); + + header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate'); + header('Cache-Control: post-check=0, pre-check=0', false); + header('Pragma: no-cache'); + header("content-type: image/png"); + + // 输出图像 + imagepng($this->_image); + imagedestroy($this->_image); + } + + /** + * 画一条由两条连在一起构成的随机正弦函数曲线作干扰线(你可以改成更帅的曲线函数) + * + * 高中的数学公式咋都忘了涅,写出来 + * 正弦型函数解析式:y=Asin(ωx+φ)+b + * 各常数值对函数图像的影响: + * A:决定峰值(即纵向拉伸压缩的倍数) + * b:表示波形在Y轴的位置关系或纵向移动距离(上加下减) + * φ:决定波形与X轴位置关系或横向移动距离(左加右减) + * ω:决定周期(最小正周期T=2π/∣ω∣) + * + */ + private function _writeCurve() { + $px = $py = 0; + + // 曲线前部分 + $A = $this->randInt(1, $this->imageH / 2); // 振幅 + $b = $this->randInt(-$this->imageH / 4, $this->imageH / 4); // Y轴方向偏移量 + $f = $this->randInt(-$this->imageH / 4, $this->imageH / 4); // X轴方向偏移量 + $T = $this->randInt($this->imageH, $this->imageW * 2); // 周期 + $w = (2* M_PI)/$T; + + $px1 = 0; // 曲线横坐标起始位置 + $px2 = $this->randInt($this->imageW / 2, $this->imageW * 0.8); // 曲线横坐标结束位置 + + for ($px=$px1; $px<=$px2; $px = $px + 1) { + if ($w!=0) { + $py = $A * sin($w*$px + $f)+ $b + $this->imageH/2; // y = Asin(ωx+φ) + b + $i = (int) ($this->fontSize/5); + while ($i > 0) { + imagesetpixel($this->_image, $px + $i , (int) round($py) + $i, $this->_color); // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出(不用这while循环)性能要好很多 + $i--; + } + } + } + + // 曲线后部分 + $A = $this->randInt(1, $this->imageH / 2); // 振幅 + $f = $this->randInt(-$this->imageH / 4, $this->imageH / 4); // X轴方向偏移量 + $T = $this->randInt($this->imageH, $this->imageW * 2); // 周期 + $w = (2* M_PI)/$T; + $b = $py - $A * sin($w*$px + $f) - $this->imageH/2; + $px1 = $px2; + $px2 = (int) $this->imageW; + + for ($px=$px1; $px<=$px2; $px=$px+ 1) { + if ($w!=0) { + $py = $A * sin($w*$px + $f)+ $b + $this->imageH/2; // y = Asin(ωx+φ) + b + $i = (int) ($this->fontSize/5); + while ($i > 0) { + imagesetpixel($this->_image, $px + $i, (int) round($py) + $i, $this->_color); + $i--; + } + } + } + } + + /** + * 画杂点 + * 往图片上写不同颜色的字母或数字 + */ + private function _writeNoise() { + $codeSet = '2345678abcdefhijkmnpqrstuvwxyz'; + for($i = 0; $i < 10; $i++){ + //杂点颜色 + $noiseColor = imagecolorallocate($this->_image, mt_rand(150,225), mt_rand(150,225), mt_rand(150,225)); + for($j = 0; $j < 5; $j++) { + // 绘杂点 + imagestring($this->_image, 5, mt_rand(-10, (int) $this->imageW), mt_rand(-10, (int) $this->imageH), $codeSet[mt_rand(0, 29)], $noiseColor); + } + } + } + + /** + * 绘制背景图片 + * 注:如果验证码输出图片比较大,将占用比较多的系统资源 + */ + private function _background() { + $path = dirname(__FILE__).'/Verify/bgs/'; + if (!is_dir($path)) { + return; + } + + $dir = dir($path); + if (!$dir) { + return; + } + + $bgs = array(); + while (false !== ($file = $dir->read())) { + if($file[0] != '.' && substr($file, -4) == '.jpg') { + $bgs[] = $path . $file; + } + } + $dir->close(); + if (empty($bgs)) { + return; + } + + $gb = $bgs[array_rand($bgs)]; + + $size = @getimagesize($gb); + if (!$size) { + return; + } + list($width, $height) = $size; + // Resample + $bgImage = @imagecreatefromjpeg($gb); + if (!$bgImage) { + return; + } + @imagecopyresampled($this->_image, $bgImage, 0, 0, 0, 0, (int) $this->imageW, (int) $this->imageH, (int) $width, (int) $height); + @imagedestroy($bgImage); + } + + private function randInt($min, $max) { + $min = (int) round($min); + $max = (int) round($max); + if ($min > $max) { + list($min, $max) = array($max, $min); + } + + return mt_rand($min, $max); + } + + private function normalizeCode($code) { + $code = trim((string) $code); + if (function_exists('mb_convert_kana')) { + $code = mb_convert_kana($code, 'as', 'UTF-8'); + } + + $normalized = preg_replace('/\s+/u', '', $code); + if (is_string($normalized)) { + $code = $normalized; + } + + return strtoupper($code); + } + + /* 加密验证码 */ + private function authcode($str){ + $key = substr(md5($this->seKey), 5, 8); + $str = substr(md5($str), 8, 10); + return md5($key . $str); + } + +} diff --git a/extend/api/Verify/bgs/1.jpg b/extend/api/Verify/bgs/1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d417136bb4613984dd88ac25590d2794344c990f GIT binary patch literal 30428 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 literal 0 HcmV?d00001 diff --git a/extend/api/Verify/bgs/2.jpg b/extend/api/Verify/bgs/2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..56640bde4ed9a02c4e46b951f2108e5e4814b14a GIT binary patch literal 29677 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 literal 0 HcmV?d00001 diff --git a/extend/api/Verify/bgs/3.jpg b/extend/api/Verify/bgs/3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..83e5bd9026f9d46c96738a4209f1abb91f7e1e6f GIT binary patch literal 32109 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 WW2Q1p-X6|ip1UGwC*Qp@{Qm&B(nP5M literal 0 HcmV?d00001 diff --git a/extend/api/Verify/bgs/4.jpg b/extend/api/Verify/bgs/4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..97a3721bc777a569c6665e38dec04a82df9176da GIT binary patch literal 29081 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�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
    5eqK))^(a`g}#Vel}`0jqQ{$m(#9bM;B`pV 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%0Dja6n-|cc61%dSLS`lUd7W-JGp5n>o88 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૦ilU=I8^3w$Rh1aryLRN1@vEe`O?@pzT+nv6 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 R;s=GvM3(ZxPL-v5{|~;{ne6}o literal 0 HcmV?d00001 diff --git a/extend/api/Verify/bgs/8.jpg b/extend/api/Verify/bgs/8.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e10cf28115e47d1f5413e76efeccc39cd655b6cc GIT binary patch literal 30188 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 literal 0 HcmV?d00001 diff --git a/extend/api/Verify/ttfs/1.ttf b/extend/api/Verify/ttfs/1.ttf new file mode 100644 index 0000000000000000000000000000000000000000..d4ee155870e0011906a24cf200a8f6a11d2daa0a GIT binary patch literal 57520 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 literal 0 HcmV?d00001 diff --git a/extend/api/Verify/ttfs/2.ttf b/extend/api/Verify/ttfs/2.ttf new file mode 100644 index 0000000000000000000000000000000000000000..3a452b68f3baa612539ad43cd427725e96f44100 GIT binary patch literal 28328 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
    h?Dh;`UO$BEWkO}@9qw>ZI2^xAN(lX_pcD;%+W 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 c%R7_2IG>vddcb)xU-zgoC({L12w|r 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 literal 0 HcmV?d00001 diff --git a/extend/api/Verify/ttfs/6.ttf b/extend/api/Verify/ttfs/6.ttf new file mode 100644 index 0000000000000000000000000000000000000000..7f183e20820646f07ae833b64230629ce815fd36 GIT binary patch literal 28036 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

    NiFR; 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 +// +---------------------------------------------------------------------- + +use think\App; + +// [ 应用入口文件 ] + +require __DIR__ . '/../vendor/autoload.php'; + +// 执行HTTP应用并响应 +$http = (new App())->http; + +$response = $http->run(); + +$response->send(); + +$http->end($response); diff --git a/public/json/country.json b/public/json/country.json new file mode 100644 index 0000000..9316e25 --- /dev/null +++ b/public/json/country.json @@ -0,0 +1,978 @@ +[ + { + "value": "BT", + "text": "不丹" + }, + { + "value": "TL", + "text": "东帝汶" + }, + { + "value": "AS", + "text": "东萨摩亚" + }, + { + "value": "CN", + "text": "中国" + }, + { + "value": "CF", + "text": "中非共和国" + }, + { + "value": "DK", + "text": "丹麦" + }, + { + "value": "UA", + "text": "乌克兰" + }, + { + "value": "UZ", + "text": "乌兹别克斯坦" + }, + { + "value": "UG", + "text": "乌干达" + }, + { + "value": "UY", + "text": "乌拉圭" + }, + { + "value": "TD", + "text": "乍得" + }, + { + "value": "YE", + "text": "也门" + }, + { + "value": "AM", + "text": "亚美尼亚" + }, + { + "value": "IL", + "text": "以色列" + }, + { + "value": "IQ", + "text": "伊拉克" + }, + { + "value": "IR", + "text": "伊朗,伊斯兰共和国" + }, + { + "value": "BZ", + "text": "伯利兹" + }, + { + "value": "CV", + "text": "佛得角" + }, + { + "value": "RU", + "text": "俄罗斯联邦" + }, + { + "value": "BG", + "text": "保加利亚" + }, + { + "value": "HR", + "text": "克罗地亚" + }, + { + "value": "GU", + "text": "关岛" + }, + { + "value": "GM", + "text": "冈比亚" + }, + { + "value": "IS", + "text": "冰岛" + }, + { + "value": "GN", + "text": "几内亚" + }, + { + "value": "GW", + "text": "几内亚比绍" + }, + { + "value": "LI", + "text": "列支敦士登" + }, + { + "value": "CG", + "text": "刚果" + }, + { + "value": "CD", + "text": "刚果民主共和国" + }, + { + "value": "LY", + "text": "利比亚" + }, + { + "value": "LR", + "text": "利比里亚" + }, + { + "value": "CA", + "text": "加拿大" + }, + { + "value": "GH", + "text": "加纳" + }, + { + "value": "GA", + "text": "加蓬" + }, + { + "value": "HU", + "text": "匈牙利" + }, + { + "value": "MP", + "text": "北马里亚纳群岛" + }, + { + "value": "GS", + "text": "南乔治亚岛和南桑威奇群岛" + }, + { + "value": "AQ", + "text": "南极洲" + }, + { + "value": "SS", + "text": "南苏丹" + }, + { + "value": "ZA", + "text": "南非" + }, + { + "value": "BQ", + "text": "博内尔岛;圣尤斯特歇斯和萨巴" + }, + { + "value": "BW", + "text": "博茨瓦纳" + }, + { + "value": "QA", + "text": "卡塔尔" + }, + { + "value": "RW", + "text": "卢旺达" + }, + { + "value": "LU", + "text": "卢森堡" + }, + { + "value": "ID", + "text": "印尼" + }, + { + "value": "IN", + "text": "印度" + }, + { + "value": "GT", + "text": "危地马拉" + }, + { + "value": "EC", + "text": "厄瓜多尔" + }, + { + "value": "ER", + "text": "厄立特里亚" + }, + { + "value": "CU", + "text": "古巴" + }, + { + "value": "TW", + "text": "中国台湾" + }, + { + "value": "KG", + "text": "吉尔吉斯斯坦" + }, + { + "value": "DJ", + "text": "吉布提" + }, + { + "value": "KZ", + "text": "哈萨克斯坦" + }, + { + "value": "CO", + "text": "哥伦比亚" + }, + { + "value": "CR", + "text": "哥斯达黎加" + }, + { + "value": "CM", + "text": "喀麦隆" + }, + { + "value": "TV", + "text": "图瓦卢" + }, + { + "value": "TM", + "text": "土库曼斯坦" + }, + { + "value": "TR", + "text": "土耳其" + }, + { + "value": "LC", + "text": "圣卢西亚" + }, + { + "value": "KN", + "text": "圣基茨和尼维斯" + }, + { + "value": "ST", + "text": "圣多美和普林西比" + }, + { + "value": "BL", + "text": "圣巴泰勒米" + }, + { + "value": "VC", + "text": "圣文森特和格林纳丁斯" + }, + { + "value": "SH", + "text": "圣海伦娜" + }, + { + "value": "PM", + "text": "圣皮埃尔和密克隆" + }, + { + "value": "CX", + "text": "圣诞岛" + }, + { + "value": "SX", + "text": "圣马丁 (荷兰领地)" + }, + { + "value": "MF", + "text": "圣马丁岛" + }, + { + "value": "SM", + "text": "圣马利诺" + }, + { + "value": "GY", + "text": "圭亚那" + }, + { + "value": "TZ", + "text": "坦桑尼亚联合共和国" + }, + { + "value": "EG", + "text": "埃及" + }, + { + "value": "ET", + "text": "埃塞俄比亚" + }, + { + "value": "KI", + "text": "基里巴斯" + }, + { + "value": "TJ", + "text": "塔吉克斯坦" + }, + { + "value": "SN", + "text": "塞内加尔" + }, + { + "value": "RS", + "text": "塞尔维亚" + }, + { + "value": "SL", + "text": "塞拉利昂" + }, + { + "value": "CY", + "text": "塞浦路斯共和国" + }, + { + "value": "SC", + "text": "塞舌尔" + }, + { + "value": "MX", + "text": "墨西哥" + }, + { + "value": "TG", + "text": "多哥" + }, + { + "value": "DM", + "text": "多米尼克" + }, + { + "value": "DO", + "text": "多米尼克共和国" + }, + { + "value": "KR", + "text": "大韩民国" + }, + { + "value": "AX", + "text": "奥兰群岛" + }, + { + "value": "AT", + "text": "奥地利" + }, + { + "value": "VE", + "text": "委内瑞拉" + }, + { + "value": "BD", + "text": "孟加拉" + }, + { + "value": "AO", + "text": "安哥拉" + }, + { + "value": "AI", + "text": "安圭拉" + }, + { + "value": "AG", + "text": "安提瓜和巴布达" + }, + { + "value": "AD", + "text": "安道尔" + }, + { + "value": "FM", + "text": "密克罗尼西亚联邦国" + }, + { + "value": "NI", + "text": "尼加拉瓜" + }, + { + "value": "NG", + "text": "尼日利亚" + }, + { + "value": "NE", + "text": "尼日尔" + }, + { + "value": "NP", + "text": "尼泊尔" + }, + { + "value": "PS", + "text": "巴勒斯坦领土" + }, + { + "value": "BS", + "text": "巴哈马" + }, + { + "value": "PK", + "text": "巴基斯坦" + }, + { + "value": "BB", + "text": "巴巴多斯" + }, + { + "value": "PG", + "text": "巴布亚新几内亚" + }, + { + "value": "PY", + "text": "巴拉圭" + }, + { + "value": "PA", + "text": "巴拿马" + }, + { + "value": "BH", + "text": "巴林" + }, + { + "value": "BR", + "text": "巴西" + }, + { + "value": "BF", + "text": "布吉纳法索" + }, + { + "value": "BI", + "text": "布隆迪" + }, + { + "value": "GR", + "text": "希腊" + }, + { + "value": "PW", + "text": "帕劳" + }, + { + "value": "CK", + "text": "库克群岛" + }, + { + "value": "CW", + "text": "库拉索岛" + }, + { + "value": "KY", + "text": "开曼群岛" + }, + { + "value": "DE", + "text": "德国" + }, + { + "value": "IT", + "text": "意大利" + }, + { + "value": "SB", + "text": "所罗门群岛" + }, + { + "value": "TK", + "text": "托克劳" + }, + { + "value": "LV", + "text": "拉托维亚" + }, + { + "value": "NO", + "text": "挪威" + }, + { + "value": "CZ", + "text": "捷克共和国" + }, + { + "value": "MD", + "text": "摩尔多瓦共和国" + }, + { + "value": "MA", + "text": "摩洛哥" + }, + { + "value": "MC", + "text": "摩纳哥" + }, + { + "value": "BN", + "text": "文莱达鲁萨兰国" + }, + { + "value": "FJ", + "text": "斐济" + }, + { + "value": "SZ", + "text": "斯威士兰" + }, + { + "value": "SK", + "text": "斯洛伐克" + }, + { + "value": "SI", + "text": "斯洛文尼亚" + }, + { + "value": "SJ", + "text": "斯瓦尔巴和扬马延岛" + }, + { + "value": "LK", + "text": "斯里兰卡" + }, + { + "value": "SG", + "text": "新加坡" + }, + { + "value": "NC", + "text": "新喀里多尼亚" + }, + { + "value": "NZ", + "text": "新西兰" + }, + { + "value": "JP", + "text": "日本" + }, + { + "value": "CL", + "text": "智利" + }, + { + "value": "KP", + "text": "朝鲜民主人民共和国" + }, + { + "value": "KH", + "text": "柬埔寨" + }, + { + "value": "GG", + "text": "根西岛" + }, + { + "value": "GD", + "text": "格林纳达" + }, + { + "value": "GL", + "text": "格陵兰岛" + }, + { + "value": "GE", + "text": "格鲁吉亚" + }, + { + "value": "VA", + "text": "梵蒂冈" + }, + { + "value": "BE", + "text": "比利时" + }, + { + "value": "MR", + "text": "毛里塔尼亚" + }, + { + "value": "MU", + "text": "毛里求斯" + }, + { + "value": "TO", + "text": "汤加" + }, + { + "value": "SA", + "text": "沙特阿拉伯" + }, + { + "value": "FR", + "text": "法国" + }, + { + "value": "GF", + "text": "法属圭亚那" + }, + { + "value": "PF", + "text": "法属波利尼西亚" + }, + { + "value": "FO", + "text": "法罗群岛" + }, + { + "value": "PL", + "text": "波兰" + }, + { + "value": "PR", + "text": "波多黎各" + }, + { + "value": "BA", + "text": "波斯尼亚和黑塞哥维那" + }, + { + "value": "TH", + "text": "泰国" + }, + { + "value": "JE", + "text": "泽西岛" + }, + { + "value": "ZW", + "text": "津巴布韦" + }, + { + "value": "HN", + "text": "洪都拉斯" + }, + { + "value": "HT", + "text": "海地" + }, + { + "value": "AU", + "text": "澳大利亚" + }, + { + "value": "MO", + "text": "中国澳门" + }, + { + "value": "IE", + "text": "爱尔兰" + }, + { + "value": "EE", + "text": "爱沙尼亚" + }, + { + "value": "JM", + "text": "牙买加" + }, + { + "value": "TC", + "text": "特克斯和凯科斯群岛" + }, + { + "value": "TT", + "text": "特立尼达和多巴哥" + }, + { + "value": "BO", + "text": "玻利维亚" + }, + { + "value": "NR", + "text": "瑙鲁" + }, + { + "value": "SE", + "text": "瑞典" + }, + { + "value": "CH", + "text": "瑞士" + }, + { + "value": "GP", + "text": "瓜德罗普岛" + }, + { + "value": "WF", + "text": "瓦利斯和富图纳群岛" + }, + { + "value": "VU", + "text": "瓦努阿图" + }, + { + "value": "RE", + "text": "留尼汪" + }, + { + "value": "BY", + "text": "白俄罗斯" + }, + { + "value": "BM", + "text": "百慕大" + }, + { + "value": "PN", + "text": "皮特凯恩群岛" + }, + { + "value": "GI", + "text": "直布罗陀" + }, + { + "value": "FK", + "text": "福克兰群岛 (马尔维纳斯群岛)" + }, + { + "value": "KW", + "text": "科威特" + }, + { + "value": "KM", + "text": "科摩罗" + }, + { + "value": "CI", + "text": "科特迪瓦" + }, + { + "value": "CC", + "text": "科科斯 (基林) 群岛" + }, + { + "value": "PE", + "text": "秘鲁" + }, + { + "value": "TN", + "text": "突尼西亚" + }, + { + "value": "LT", + "text": "立陶宛" + }, + { + "value": "SO", + "text": "索马里" + }, + { + "value": "JO", + "text": "约旦" + }, + { + "value": "NA", + "text": "纳米比亚" + }, + { + "value": "NU", + "text": "纽埃" + }, + { + "value": "MM", + "text": "缅甸" + }, + { + "value": "RO", + "text": "罗马尼亚" + }, + { + "value": "US", + "text": "美国" + }, + { + "value": "VI", + "text": "美属维京群岛" + }, + { + "value": "LA", + "text": "老挝人民民主共和国" + }, + { + "value": "KE", + "text": "肯尼亚" + }, + { + "value": "FI", + "text": "芬兰" + }, + { + "value": "SD", + "text": "苏丹" + }, + { + "value": "SR", + "text": "苏里南" + }, + { + "value": "GB", + "text": "英国" + }, + { + "value": "IO", + "text": "英属印度洋领地" + }, + { + "value": "VG", + "text": "英属维京群岛" + }, + { + "value": "NL", + "text": "荷兰" + }, + { + "value": "MZ", + "text": "莫桑比克" + }, + { + "value": "LS", + "text": "莱索托" + }, + { + "value": "PH", + "text": "菲律宾" + }, + { + "value": "SV", + "text": "萨尔瓦多" + }, + { + "value": "WS", + "text": "萨摩亚" + }, + { + "value": "PT", + "text": "葡萄牙" + }, + { + "value": "MN", + "text": "蒙古" + }, + { + "value": "MS", + "text": "蒙特塞拉特" + }, + { + "value": "ES", + "text": "西班牙" + }, + { + "value": "NF", + "text": "诺福克岛" + }, + { + "value": "BJ", + "text": "贝宁" + }, + { + "value": "ZM", + "text": "赞比亚" + }, + { + "value": "GQ", + "text": "赤道几内亚" + }, + { + "value": "VN", + "text": "越南" + }, + { + "value": "AZ", + "text": "阿塞拜疆" + }, + { + "value": "AF", + "text": "阿富汗" + }, + { + "value": "DZ", + "text": "阿尔及利亚" + }, + { + "value": "AL", + "text": "阿尔巴尼亚" + }, + { + "value": "SY", + "text": "阿拉伯叙利亚共和国" + }, + { + "value": "OM", + "text": "阿曼" + }, + { + "value": "AR", + "text": "阿根廷" + }, + { + "value": "AE", + "text": "阿联酋" + }, + { + "value": "AW", + "text": "阿鲁巴" + }, + { + "value": "HK", + "text": "中国香港" + }, + { + "value": "MK", + "text": "马其顿" + }, + { + "value": "MV", + "text": "马尔代夫" + }, + { + "value": "IM", + "text": "马恩岛" + }, + { + "value": "MW", + "text": "马拉维" + }, + { + "value": "MQ", + "text": "马提尼克岛" + }, + { + "value": "MY", + "text": "马来西亚" + }, + { + "value": "YT", + "text": "马约特岛" + }, + { + "value": "MH", + "text": "马绍尔群岛" + }, + { + "value": "MT", + "text": "马耳他" + }, + { + "value": "MG", + "text": "马达加斯加" + }, + { + "value": "ML", + "text": "马里" + }, + { + "value": "LB", + "text": "黎巴嫩" + }, + { + "value": "ME", + "text": "黑山" + } +] \ No newline at end of file diff --git a/public/json/country_en.json b/public/json/country_en.json new file mode 100644 index 0000000..b1e871e --- /dev/null +++ b/public/json/country_en.json @@ -0,0 +1,978 @@ +[ + { + "value": "BT", + "text": "Bhutan" + }, + { + "value": "TL", + "text": "East Timor" + }, + { + "value": "AS", + "text": "American Samoa" + }, + { + "value": "CN", + "text": "China" + }, + { + "value": "CF", + "text": "CentralAfricanRepublic" + }, + { + "value": "DK", + "text": "Denmark" + }, + { + "value": "UA", + "text": "Ukraine" + }, + { + "value": "UZ", + "text": "Uzbekistan" + }, + { + "value": "UG", + "text": "Uganda" + }, + { + "value": "UY", + "text": "Uruguay" + }, + { + "value": "TD", + "text": "Chad" + }, + { + "value": "YE", + "text": "Yemen" + }, + { + "value": "AM", + "text": "Armenia" + }, + { + "value": "IL", + "text": "Israel" + }, + { + "value": "IQ", + "text": "Iraq" + }, + { + "value": "IR", + "text": "Iran, Islamic Republic of" + }, + { + "value": "BZ", + "text": "Belize" + }, + { + "value": "CV", + "text": "Cape Verde" + }, + { + "value": "RU", + "text": "Russian Federation" + }, + { + "value": "BG", + "text": "Bulgaria" + }, + { + "value": "HR", + "text": "Croatia" + }, + { + "value": "GU", + "text": "Guam" + }, + { + "value": "GM", + "text": "Gambia" + }, + { + "value": "IS", + "text": "Iceland" + }, + { + "value": "GN", + "text": "Guinea" + }, + { + "value": "GW", + "text": "Guinea-Bissau" + }, + { + "value": "LI", + "text": "Liechtenstein" + }, + { + "value": "CG", + "text": "Congo" + }, + { + "value": "CD", + "text": "Democratic Republic of the Congo" + }, + { + "value": "LY", + "text": "Libya" + }, + { + "value": "LR", + "text": "Liberia" + }, + { + "value": "CA", + "text": "Canada" + }, + { + "value": "GH", + "text": "Ghana" + }, + { + "value": "GA", + "text": "Gabon" + }, + { + "value": "HU", + "text": "Hungary" + }, + { + "value": "MP", + "text": "Northern Mariana Islands" + }, + { + "value": "GS", + "text": "South Georgia and the South Sandwich Islands" + }, + { + "value": "AQ", + "text": "Antarctica" + }, + { + "value": "SS", + "text": "South Sudan" + }, + { + "value": "ZA", + "text": "South Africa" + }, + { + "value": "BQ", + "text": "Bonaire, Sint Eustatius and Saba" + }, + { + "value": "BW", + "text": "Botswana" + }, + { + "value": "QA", + "text": "Qatar" + }, + { + "value": "RW", + "text": "Rwanda" + }, + { + "value": "LU", + "text": "Luxembourg" + }, + { + "value": "ID", + "text": "Indonesia" + }, + { + "value": "IN", + "text": "India" + }, + { + "value": "GT", + "text": "Guatemala" + }, + { + "value": "EC", + "text": "Ecuador" + }, + { + "value": "ER", + "text": "Eritrea" + }, + { + "value": "CU", + "text": "Cuba" + }, + { + "value": "TW", + "text": "Taiwan, China" + }, + { + "value": "KG", + "text": "Kyrgyzstan" + }, + { + "value": "DJ", + "text": "Djibouti" + }, + { + "value": "KZ", + "text": "Kazakhstan" + }, + { + "value": "CO", + "text": "Colombia" + }, + { + "value": "CR", + "text": "Costa Rica" + }, + { + "value": "CM", + "text": "Cameroon" + }, + { + "value": "TV", + "text": "Tuvalu" + }, + { + "value": "TM", + "text": "Turkmenistan" + }, + { + "value": "TR", + "text": "Turkey" + }, + { + "value": "LC", + "text": "Saint Lucia" + }, + { + "value": "KN", + "text": "Saint Kitts and Nevis" + }, + { + "value": "ST", + "text": "Sao Tome and Principe" + }, + { + "value": "BL", + "text": "Saint Barthélemy" + }, + { + "value": "VC", + "text": "Saint Vincent and the Grenadines" + }, + { + "value": "SH", + "text": "Saint Helena" + }, + { + "value": "PM", + "text": "Saint Pierre and Miquelon" + }, + { + "value": "CX", + "text": "Christmas Island" + }, + { + "value": "SX", + "text": "Sint Maarten (Dutch part)" + }, + { + "value": "MF", + "text": "Saint Martin (French part)" + }, + { + "value": "SM", + "text": "San Marino" + }, + { + "value": "GY", + "text": "Guyana" + }, + { + "value": "TZ", + "text": "United Republic of Tanzania" + }, + { + "value": "EG", + "text": "Egypt" + }, + { + "value": "ET", + "text": "Ethiopia" + }, + { + "value": "KI", + "text": "Kiribati" + }, + { + "value": "TJ", + "text": "Tajikistan" + }, + { + "value": "SN", + "text": "Senegal" + }, + { + "value": "RS", + "text": "Serbia" + }, + { + "value": "SL", + "text": "Sierra Leone" + }, + { + "value": "CY", + "text": "Cyprus" + }, + { + "value": "SC", + "text": "Seychelles" + }, + { + "value": "MX", + "text": "Mexico" + }, + { + "value": "TG", + "text": "Togo" + }, + { + "value": "DM", + "text": "Dominica" + }, + { + "value": "DO", + "text": "Dominican Republic" + }, + { + "value": "KR", + "text": "South Korea" + }, + { + "value": "AX", + "text": "Åland Islands" + }, + { + "value": "AT", + "text": "Austria" + }, + { + "value": "VE", + "text": "Venezuela" + }, + { + "value": "BD", + "text": "Bangladesh" + }, + { + "value": "AO", + "text": "Angola" + }, + { + "value": "AI", + "text": "Anguilla" + }, + { + "value": "AG", + "text": "Antigua and Barbuda" + }, + { + "value": "AD", + "text": "Andorra" + }, + { + "value": "FM", + "text": "Federated States of Micronesia" + }, + { + "value": "NI", + "text": "Nicaragua" + }, + { + "value": "NG", + "text": "Nigeria" + }, + { + "value": "NE", + "text": "Niger" + }, + { + "value": "NP", + "text": "Nepal" + }, + { + "value": "PS", + "text": "Palestinian Territory" + }, + { + "value": "BS", + "text": "Bahamas" + }, + { + "value": "PK", + "text": "Pakistan" + }, + { + "value": "BB", + "text": "Barbados" + }, + { + "value": "PG", + "text": "Papua New Guinea" + }, + { + "value": "PY", + "text": "Paraguay" + }, + { + "value": "PA", + "text": "Panama" + }, + { + "value": "BH", + "text": "Bahrain" + }, + { + "value": "BR", + "text": "Brazil" + }, + { + "value": "BF", + "text": "Burkina Faso" + }, + { + "value": "BI", + "text": "Burundi" + }, + { + "value": "GR", + "text": "Greece" + }, + { + "value": "PW", + "text": "Palau" + }, + { + "value": "CK", + "text": "Cook Islands" + }, + { + "value": "CW", + "text": "Curaçao" + }, + { + "value": "KY", + "text": "Cayman Islands" + }, + { + "value": "DE", + "text": "Germany" + }, + { + "value": "IT", + "text": "Italy" + }, + { + "value": "SB", + "text": "Solomon Islands" + }, + { + "value": "TK", + "text": "Tokelau" + }, + { + "value": "LV", + "text": "Latvia" + }, + { + "value": "NO", + "text": "Norway" + }, + { + "value": "CZ", + "text": "Czech Republic" + }, + { + "value": "MD", + "text": "Republic of Moldova" + }, + { + "value": "MA", + "text": "Morocco" + }, + { + "value": "MC", + "text": "Monaco" + }, + { + "value": "BN", + "text": "Brunei Darussalam" + }, + { + "value": "FJ", + "text": "Fiji" + }, + { + "value": "SZ", + "text": "Eswatini" + }, + { + "value": "SK", + "text": "Slovakia" + }, + { + "value": "SI", + "text": "Slovenia" + }, + { + "value": "SJ", + "text": "Svalbard and Jan Mayen" + }, + { + "value": "LK", + "text": "Sri Lanka" + }, + { + "value": "SG", + "text": "Singapore" + }, + { + "value": "NC", + "text": "New Caledonia" + }, + { + "value": "NZ", + "text": "New Zealand" + }, + { + "value": "JP", + "text": "Japan" + }, + { + "value": "CL", + "text": "Chile" + }, + { + "value": "KP", + "text": "North Korea" + }, + { + "value": "KH", + "text": "Cambodia" + }, + { + "value": "GG", + "text": "Guernsey" + }, + { + "value": "GD", + "text": "Grenada" + }, + { + "value": "GL", + "text": "Greenland" + }, + { + "value": "GE", + "text": "Georgia" + }, + { + "value": "VA", + "text": "Vatican" + }, + { + "value": "BE", + "text": "Belgium" + }, + { + "value": "MR", + "text": "Mauritania" + }, + { + "value": "MU", + "text": "Mauritius" + }, + { + "value": "TO", + "text": "Tonga" + }, + { + "value": "SA", + "text": "Saudi Arabia" + }, + { + "value": "FR", + "text": "France" + }, + { + "value": "GF", + "text": "French Guiana" + }, + { + "value": "PF", + "text": "French Polynesia" + }, + { + "value": "FO", + "text": "Faroe Islands" + }, + { + "value": "PL", + "text": "Poland" + }, + { + "value": "PR", + "text": "Puerto Rico" + }, + { + "value": "BA", + "text": "Bosnia and Herzegovina" + }, + { + "value": "TH", + "text": "Thailand" + }, + { + "value": "JE", + "text": "Jersey" + }, + { + "value": "ZW", + "text": "Zimbabwe" + }, + { + "value": "HN", + "text": "Honduras" + }, + { + "value": "HT", + "text": "Haiti" + }, + { + "value": "AU", + "text": "Australia" + }, + { + "value": "MO", + "text": "Macao, China" + }, + { + "value": "IE", + "text": "Ireland" + }, + { + "value": "EE", + "text": "Estonia" + }, + { + "value": "JM", + "text": "Jamaica" + }, + { + "value": "TC", + "text": "Turks and Caicos Islands" + }, + { + "value": "TT", + "text": "Trinidad and Tobago" + }, + { + "value": "BO", + "text": "Bolivia" + }, + { + "value": "NR", + "text": "Nauru" + }, + { + "value": "SE", + "text": "Sweden" + }, + { + "value": "CH", + "text": "Switzerland" + }, + { + "value": "GP", + "text": "Guadeloupe" + }, + { + "value": "WF", + "text": "Wallis and Futuna" + }, + { + "value": "VU", + "text": "Vanuatu" + }, + { + "value": "RE", + "text": "Réunion" + }, + { + "value": "BY", + "text": "Belarus" + }, + { + "value": "BM", + "text": "Bermuda" + }, + { + "value": "PN", + "text": "Pitcairn Islands" + }, + { + "value": "GI", + "text": "Gibraltar" + }, + { + "value": "FK", + "text": "Falkland Islands (Malvinas)" + }, + { + "value": "KW", + "text": "Kuwait" + }, + { + "value": "KM", + "text": "Comoros" + }, + { + "value": "CI", + "text": "Côte d'Ivoire" + }, + { + "value": "CC", + "text": "Cocos (Keeling) Islands" + }, + { + "value": "PE", + "text": "Peru" + }, + { + "value": "TN", + "text": "Tunisia" + }, + { + "value": "LT", + "text": "Lithuania" + }, + { + "value": "SO", + "text": "Somalia" + }, + { + "value": "JO", + "text": "Jordan" + }, + { + "value": "NA", + "text": "Namibia" + }, + { + "value": "NU", + "text": "Niue" + }, + { + "value": "MM", + "text": "Myanmar" + }, + { + "value": "RO", + "text": "Romania" + }, + { + "value": "US", + "text": "United States" + }, + { + "value": "VI", + "text": "U.S. Virgin Islands" + }, + { + "value": "LA", + "text": "Lao People's Democratic Republic" + }, + { + "value": "KE", + "text": "Kenya" + }, + { + "value": "FI", + "text": "Finland" + }, + { + "value": "SD", + "text": "Sudan" + }, + { + "value": "SR", + "text": "Suriname" + }, + { + "value": "GB", + "text": "United Kingdom" + }, + { + "value": "IO", + "text": "British Indian Ocean Territory" + }, + { + "value": "VG", + "text": "British Virgin Islands" + }, + { + "value": "NL", + "text": "Netherlands" + }, + { + "value": "MZ", + "text": "Mozambique" + }, + { + "value": "LS", + "text": "Lesotho" + }, + { + "value": "PH", + "text": "Philippines" + }, + { + "value": "SV", + "text": "El Salvador" + }, + { + "value": "WS", + "text": "Samoa" + }, + { + "value": "PT", + "text": "Portugal" + }, + { + "value": "MN", + "text": "Mongolia" + }, + { + "value": "MS", + "text": "Montserrat" + }, + { + "value": "ES", + "text": "Spain" + }, + { + "value": "NF", + "text": "Norfolk Island" + }, + { + "value": "BJ", + "text": "Benin" + }, + { + "value": "ZM", + "text": "Zambia" + }, + { + "value": "GQ", + "text": "Equatorial Guinea" + }, + { + "value": "VN", + "text": "Viet Nam" + }, + { + "value": "AZ", + "text": "Azerbaijan" + }, + { + "value": "AF", + "text": "Afghanistan" + }, + { + "value": "DZ", + "text": "Algeria" + }, + { + "value": "AL", + "text": "Albania" + }, + { + "value": "SY", + "text": "Syrian Arab Republic" + }, + { + "value": "OM", + "text": "Oman" + }, + { + "value": "AR", + "text": "Argentina" + }, + { + "value": "AE", + "text": "United Arab Emirates" + }, + { + "value": "AW", + "text": "Aruba" + }, + { + "value": "HK", + "text": "Hong Kong, China" + }, + { + "value": "MK", + "text": "North Macedonia" + }, + { + "value": "MV", + "text": "Maldives" + }, + { + "value": "IM", + "text": "Isle of Man" + }, + { + "value": "MW", + "text": "Malawi" + }, + { + "value": "MQ", + "text": "Martinique" + }, + { + "value": "MY", + "text": "Malaysia" + }, + { + "value": "YT", + "text": "Mayotte" + }, + { + "value": "MH", + "text": "Marshall Islands" + }, + { + "value": "MT", + "text": "Malta" + }, + { + "value": "MG", + "text": "Madagascar" + }, + { + "value": "ML", + "text": "Mali" + }, + { + "value": "LB", + "text": "Lebanon" + }, + { + "value": "ME", + "text": "Montenegro" + } +] \ No newline at end of file diff --git a/public/json/phone_prefix.json b/public/json/phone_prefix.json new file mode 100644 index 0000000..4a3afcf --- /dev/null +++ b/public/json/phone_prefix.json @@ -0,0 +1,978 @@ +[ + { + "value": "CN:86", + "text": "中国 (+86)" + }, + { + "value": "US:1", + "text": "美国 (+1)" + }, + { + "value": "CA:1", + "text": "加拿大 (+1)" + }, + { + "value": "AU:61", + "text": "澳大利亚 (+61)" + }, + { + "value": "JP:81", + "text": "日本 (+81)" + }, + { + "value": "MX:52", + "text": "墨西哥 (+52)" + }, + { + "value": "GB:44", + "text": "英国 (+44)" + }, + { + "value": "DE:49", + "text": "德国 (+49)" + }, + { + "value": "FR:33", + "text": "法国 (+33)" + }, + { + "value": "AF:93", + "text": "阿富汗 (+93)" + }, + { + "value": "AX:358", + "text": "奥兰群岛 (+358)" + }, + { + "value": "AL:355", + "text": "阿尔巴尼亚 (+355)" + }, + { + "value": "DZ:213", + "text": "阿尔及利亚 (+213)" + }, + { + "value": "AS:1", + "text": "东萨摩亚 (+1)" + }, + { + "value": "AD:376", + "text": "安道尔 (+376)" + }, + { + "value": "AO:244", + "text": "安哥拉 (+244)" + }, + { + "value": "AI:1", + "text": "安圭拉 (+1)" + }, + { + "value": "AQ:672", + "text": "南极洲 (+672)" + }, + { + "value": "AG:1", + "text": "安提瓜和巴布达 (+1)" + }, + { + "value": "AR:54", + "text": "阿根廷 (+54)" + }, + { + "value": "AM:374", + "text": "亚美尼亚 (+374)" + }, + { + "value": "AW:297", + "text": "阿鲁巴 (+297)" + }, + { + "value": "AT:43", + "text": "奥地利 (+43)" + }, + { + "value": "AZ:994", + "text": "阿塞拜疆 (+994)" + }, + { + "value": "BS:1", + "text": "巴哈马 (+1)" + }, + { + "value": "BH:973", + "text": "巴林 (+973)" + }, + { + "value": "BD:880", + "text": "孟加拉 (+880)" + }, + { + "value": "BB:1", + "text": "巴巴多斯 (+1)" + }, + { + "value": "BY:375", + "text": "白俄罗斯 (+375)" + }, + { + "value": "BE:32", + "text": "比利时 (+32)" + }, + { + "value": "BZ:501", + "text": "伯利兹 (+501)" + }, + { + "value": "BJ:229", + "text": "贝宁 (+229)" + }, + { + "value": "BM:1", + "text": "百慕大 (+1)" + }, + { + "value": "BT:975", + "text": "不丹 (+975)" + }, + { + "value": "BO:591", + "text": "玻利维亚 (+591)" + }, + { + "value": "BQ:599", + "text": "博内尔岛;圣尤斯特歇斯和萨巴 (+599)" + }, + { + "value": "BA:387", + "text": "波斯尼亚和黑塞哥维那 (+387)" + }, + { + "value": "BW:267", + "text": "博茨瓦纳 (+267)" + }, + { + "value": "BR:55", + "text": "巴西 (+55)" + }, + { + "value": "IO:246", + "text": "英属印度洋领地 (+246)" + }, + { + "value": "BN:673", + "text": "文莱达鲁萨兰国 (+673)" + }, + { + "value": "BG:359", + "text": "保加利亚 (+359)" + }, + { + "value": "BF:226", + "text": "布吉纳法索 (+226)" + }, + { + "value": "BI:257", + "text": "布隆迪 (+257)" + }, + { + "value": "KH:855", + "text": "柬埔寨 (+855)" + }, + { + "value": "CM:237", + "text": "喀麦隆 (+237)" + }, + { + "value": "CV:238", + "text": "佛得角 (+238)" + }, + { + "value": "KY:1", + "text": "开曼群岛 (+1)" + }, + { + "value": "CF:236", + "text": "中非共和国 (+236)" + }, + { + "value": "TD:235", + "text": "乍得 (+235)" + }, + { + "value": "CL:56", + "text": "智利 (+56)" + }, + { + "value": "CX:61", + "text": "圣诞岛 (+61)" + }, + { + "value": "CC:61", + "text": "科科斯 (基林) 群岛 (+61)" + }, + { + "value": "CO:57", + "text": "哥伦比亚 (+57)" + }, + { + "value": "KM:269", + "text": "科摩罗 (+269)" + }, + { + "value": "CG:242", + "text": "刚果 (+243)" + }, + { + "value": "CD:243", + "text": "刚果民主共和国 (+243)" + }, + { + "value": "CK:682", + "text": "库克群岛 (+682)" + }, + { + "value": "CR:506", + "text": "哥斯达黎加 (+506)" + }, + { + "value": "CI:225", + "text": "科特迪瓦 (+225)" + }, + { + "value": "HR:385", + "text": "克罗地亚 (+385)" + }, + { + "value": "CU:53", + "text": "古巴 (+53)" + }, + { + "value": "CW:599", + "text": "库拉索岛 (+599)" + }, + { + "value": "CZ:420", + "text": "捷克共和国 (+420)" + }, + { + "value": "DK:45", + "text": "丹麦 (+45)" + }, + { + "value": "DJ:253", + "text": "吉布提 (+253)" + }, + { + "value": "DM:1", + "text": "多米尼克 (+1)" + }, + { + "value": "DO:1", + "text": "多米尼克共和国 (+1)" + }, + { + "value": "EC:593", + "text": "厄瓜多尔 (+593)" + }, + { + "value": "EG:20", + "text": "埃及 (+20)" + }, + { + "value": "SV:503", + "text": "萨尔瓦多 (+503)" + }, + { + "value": "GQ:240", + "text": "赤道几内亚 (+240)" + }, + { + "value": "ER:291", + "text": "厄立特里亚 (+291)" + }, + { + "value": "EE:372", + "text": "爱沙尼亚 (+372)" + }, + { + "value": "ET:251", + "text": "埃塞俄比亚 (+251)" + }, + { + "value": "FK:500", + "text": "福克兰群岛 (马尔维纳斯群岛) (+500)" + }, + { + "value": "FO:298", + "text": "法罗群岛 (+298)" + }, + { + "value": "FJ:679", + "text": "斐济 (+679)" + }, + { + "value": "FI:358", + "text": "芬兰 (+358)" + }, + { + "value": "GY:592", + "text": "法属圭亚那 (+592)" + }, + { + "value": "PF:689", + "text": "法属波利尼西亚 (+689)" + }, + { + "value": "GA:241", + "text": "加蓬 (+241)" + }, + { + "value": "GM:220", + "text": "冈比亚 (+220)" + }, + { + "value": "GE:995", + "text": "格鲁吉亚 (+995)" + }, + { + "value": "GH:233", + "text": "加纳 (+233)" + }, + { + "value": "GI:350", + "text": "直布罗陀 (+350)" + }, + { + "value": "GR:30", + "text": "希腊 (+30)" + }, + { + "value": "GL:299", + "text": "格陵兰岛 (+299)" + }, + { + "value": "GD:1", + "text": "格林纳达 (+1)" + }, + { + "value": "GP:590", + "text": "瓜德罗普岛 (+590)" + }, + { + "value": "GU:1", + "text": "关岛 (+1)" + }, + { + "value": "GT:502", + "text": "危地马拉 (+502)" + }, + { + "value": "GG:44", + "text": "根西岛 (+44)" + }, + { + "value": "GN:224", + "text": "几内亚 (+224)" + }, + { + "value": "GW:245", + "text": "几内亚比绍 (+245)" + }, + { + "value": "GY:592", + "text": "圭亚那 (+592)" + }, + { + "value": "HT:509", + "text": "海地 (+509)" + }, + { + "value": "HN:504", + "text": "洪都拉斯 (+504)" + }, + { + "value": "HK:852", + "text": "中国香港 (+852)" + }, + { + "value": "HU:36", + "text": "匈牙利 (+36)" + }, + { + "value": "IS:354", + "text": "冰岛 (+354)" + }, + { + "value": "IN:91", + "text": "印度 (+91)" + }, + { + "value": "ID:62", + "text": "印尼 (+62)" + }, + { + "value": "IR:98", + "text": "伊朗,伊斯兰共和国 (+98)" + }, + { + "value": "IQ:964", + "text": "伊拉克 (+964)" + }, + { + "value": "IE:353", + "text": "爱尔兰 (+353)" + }, + { + "value": "IM:44", + "text": "马恩岛 (+44)" + }, + { + "value": "IL:972", + "text": "以色列 (+972)" + }, + { + "value": "IT:39", + "text": "意大利 (+39)" + }, + { + "value": "JM:1", + "text": "牙买加 (+1)" + }, + { + "value": "JE:44", + "text": "泽西岛 (+44)" + }, + { + "value": "JO:962", + "text": "约旦 (+962)" + }, + { + "value": "KZ:7", + "text": "哈萨克斯坦 (+7)" + }, + { + "value": "KE:254", + "text": "肯尼亚 (+254)" + }, + { + "value": "KI:686", + "text": "基里巴斯 (+686)" + }, + { + "value": "KP:850", + "text": "朝鲜民主人民共和国 (+850)" + }, + { + "value": "KR:82", + "text": "大韩民国 (+82)" + }, + { + "value": "KW:965", + "text": "科威特 (+965)" + }, + { + "value": "KG:996", + "text": "吉尔吉斯斯坦 (+996)" + }, + { + "value": "LA:856", + "text": "老挝人民民主共和国 (+856)" + }, + { + "value": "LV:371", + "text": "拉托维亚 (+371)" + }, + { + "value": "LB:961", + "text": "黎巴嫩 (+961)" + }, + { + "value": "LS:266", + "text": "莱索托 (+266)" + }, + { + "value": "LR:231", + "text": "利比里亚 (+231)" + }, + { + "value": "LY:218", + "text": "利比亚 (+218)" + }, + { + "value": "LI:423", + "text": "列支敦士登 (+423)" + }, + { + "value": "LT:370", + "text": "立陶宛 (+370)" + }, + { + "value": "LU:352", + "text": "卢森堡 (+352)" + }, + { + "value": "MO:853", + "text": "中国澳门 (+853)" + }, + { + "value": "MK:389", + "text": "马其顿 (+389)" + }, + { + "value": "MG:261", + "text": "马达加斯加 (+261)" + }, + { + "value": "MW:265", + "text": "马拉维 (+265)" + }, + { + "value": "MY:60", + "text": "马来西亚 (+60)" + }, + { + "value": "MV:960", + "text": "马尔代夫 (+960)" + }, + { + "value": "ML:223", + "text": "马里 (+223)" + }, + { + "value": "MT:356", + "text": "马耳他 (+356)" + }, + { + "value": "MH:692", + "text": "马绍尔群岛 (+692)" + }, + { + "value": "MQ:596", + "text": "马提尼克岛 (+596)" + }, + { + "value": "MR:222", + "text": "毛里塔尼亚 (+222)" + }, + { + "value": "MU:230", + "text": "毛里求斯 (+230)" + }, + { + "value": "YT:262", + "text": "马约特岛 (+262)" + }, + { + "value": "FM:691", + "text": "密克罗尼西亚联邦国 (+691)" + }, + { + "value": "MD:373", + "text": "摩尔多瓦共和国 (+373)" + }, + { + "value": "MC:377", + "text": "摩纳哥 (+377)" + }, + { + "value": "MN:976", + "text": "蒙古 (+976)" + }, + { + "value": "ME:382", + "text": "黑山 (+382)" + }, + { + "value": "MS:1", + "text": "蒙特塞拉特 (+1)" + }, + { + "value": "MA:212", + "text": "摩洛哥 (+212)" + }, + { + "value": "MZ:258", + "text": "莫桑比克 (+258)" + }, + { + "value": "MM:95", + "text": "缅甸 (+95)" + }, + { + "value": "NA:264", + "text": "纳米比亚 (+264)" + }, + { + "value": "NR:674", + "text": "瑙鲁 (+674)" + }, + { + "value": "NP:977", + "text": "尼泊尔 (+977)" + }, + { + "value": "NL:31", + "text": "荷兰 (+31)" + }, + { + "value": "NC:687", + "text": "新喀里多尼亚 (+687)" + }, + { + "value": "NZ:64", + "text": "新西兰 (+64)" + }, + { + "value": "NI:505", + "text": "尼加拉瓜 (+505)" + }, + { + "value": "NE:227", + "text": "尼日尔 (+227)" + }, + { + "value": "NG:234", + "text": "尼日利亚 (+234)" + }, + { + "value": "NU:683", + "text": "纽埃 (+683)" + }, + { + "value": "NF:672", + "text": "诺福克岛 (+672)" + }, + { + "value": "MP:1", + "text": "北马里亚纳群岛 (+1)" + }, + { + "value": "NO:47", + "text": "挪威 (+47)" + }, + { + "value": "OM:968", + "text": "阿曼 (+968)" + }, + { + "value": "PK:92", + "text": "巴基斯坦 (+92)" + }, + { + "value": "PW:680", + "text": "帕劳 (+680)" + }, + { + "value": "PS:970", + "text": "巴勒斯坦领土 (+970)" + }, + { + "value": "PA:507", + "text": "巴拿马 (+507)" + }, + { + "value": "PG:675", + "text": "巴布亚新几内亚 (+675)" + }, + { + "value": "PY:595", + "text": "巴拉圭 (+595)" + }, + { + "value": "PE:51", + "text": "秘鲁 (+51)" + }, + { + "value": "PH:63", + "text": "菲律宾 (+63)" + }, + { + "value": "PN:64", + "text": "皮特凯恩群岛 (+64)" + }, + { + "value": "PL:48", + "text": "波兰 (+48)" + }, + { + "value": "PT:351", + "text": "葡萄牙 (+351)" + }, + { + "value": "PR:1", + "text": "波多黎各 (+1)" + }, + { + "value": "QA:974", + "text": "卡塔尔 (+974)" + }, + { + "value": "CY:357", + "text": "塞浦路斯共和国 (+357)" + }, + { + "value": "TF:262", + "text": "留尼汪 (+262)" + }, + { + "value": "RO:40", + "text": "罗马尼亚 (+40)" + }, + { + "value": "RU:7", + "text": "俄罗斯联邦 (+7)" + }, + { + "value": "RW:250", + "text": "卢旺达 (+250)" + }, + { + "value": "BL:590", + "text": "圣巴泰勒米 (+590)" + }, + { + "value": "SH:290", + "text": "圣海伦娜 (+290)" + }, + { + "value": "KN:1", + "text": "圣基茨和尼维斯 (+1)" + }, + { + "value": "LC:1", + "text": "圣卢西亚 (+1)" + }, + { + "value": "MF:590", + "text": "圣马丁岛 (+590)" + }, + { + "value": "PM:508", + "text": "圣皮埃尔和密克隆 (+508)" + }, + { + "value": "VC:1", + "text": "圣文森特和格林纳丁斯 (+1)" + }, + { + "value": "WS:685", + "text": "萨摩亚 (+685)" + }, + { + "value": "SM:378", + "text": "圣马利诺 (+378)" + }, + { + "value": "ST:239", + "text": "圣多美和普林西比 (+239)" + }, + { + "value": "SA:966", + "text": "沙特阿拉伯 (+966)" + }, + { + "value": "SN:221", + "text": "塞内加尔 (+221)" + }, + { + "value": "RS:381", + "text": "塞尔维亚 (+381)" + }, + { + "value": "SC:248", + "text": "塞舌尔 (+248)" + }, + { + "value": "SL:232", + "text": "塞拉利昂 (+232)" + }, + { + "value": "SG:65", + "text": "新加坡 (+65)" + }, + { + "value": "MF:590", + "text": "圣马丁 (荷兰领地) (+590)" + }, + { + "value": "SK:421", + "text": "斯洛伐克 (+421)" + }, + { + "value": "SI:386", + "text": "斯洛文尼亚 (+386)" + }, + { + "value": "SB:677", + "text": "所罗门群岛 (+677)" + }, + { + "value": "SO:252", + "text": "索马里 (+252)" + }, + { + "value": "ZA:27", + "text": "南非 (+27)" + }, + { + "value": "GS:500", + "text": "南乔治亚岛和南桑威奇群岛 (+500)" + }, + { + "value": "SS:211", + "text": "南苏丹 (+211)" + }, + { + "value": "ES:34", + "text": "西班牙 (+34)" + }, + { + "value": "LK:94", + "text": "斯里兰卡 (+94)" + }, + { + "value": "SD:249", + "text": "苏丹 (+249)" + }, + { + "value": "SR:597", + "text": "苏里南 (+597)" + }, + { + "value": "SJ:47", + "text": "斯瓦尔巴和扬马延岛 (+47)" + }, + { + "value": "SZ:268", + "text": "斯威士兰 (+268)" + }, + { + "value": "SE:46", + "text": "瑞典 (+46)" + }, + { + "value": "CH:41", + "text": "瑞士 (+41)" + }, + { + "value": "SY:963", + "text": "阿拉伯叙利亚共和国 (+963)" + }, + { + "value": "TW:886", + "text": "中国台湾 (+886)" + }, + { + "value": "TJ:992", + "text": "塔吉克斯坦 (+992)" + }, + { + "value": "TZ:255", + "text": "坦桑尼亚联合共和国 (+255)" + }, + { + "value": "TH:66", + "text": "泰国 (+66)" + }, + { + "value": "TL:670", + "text": "东帝汶 (+670)" + }, + { + "value": "TG:228", + "text": "多哥 (+228)" + }, + { + "value": "TK:690", + "text": "托克劳 (+690)" + }, + { + "value": "TO:676", + "text": "汤加 (+676)" + }, + { + "value": "TT:1", + "text": "特立尼达和多巴哥 (+1)" + }, + { + "value": "TN:216", + "text": "突尼西亚 (+216)" + }, + { + "value": "TR:90", + "text": "土耳其 (+90)" + }, + { + "value": "TM:993", + "text": "土库曼斯坦 (+993)" + }, + { + "value": "TC:1", + "text": "特克斯和凯科斯群岛 (+1)" + }, + { + "value": "TV:688", + "text": "图瓦卢 (+688)" + }, + { + "value": "UG:256", + "text": "乌干达 (+256)" + }, + { + "value": "UA:380", + "text": "乌克兰 (+380)" + }, + { + "value": "AE:971", + "text": "阿联酋 (+971)" + }, + { + "value": "UY:598", + "text": "乌拉圭 (+598)" + }, + { + "value": "UZ:998", + "text": "乌兹别克斯坦 (+998)" + }, + { + "value": "VU:678", + "text": "瓦努阿图 (+678)" + }, + { + "value": "VA:379", + "text": "梵蒂冈 (+379)" + }, + { + "value": "VE:58", + "text": "委内瑞拉 (+58)" + }, + { + "value": "VN:84", + "text": "越南 (+84)" + }, + { + "value": "VG:1", + "text": "英属维京群岛 (+1)" + }, + { + "value": "VI:1", + "text": "美属维京群岛 (+1)" + }, + { + "value": "WF:681", + "text": "瓦利斯和富图纳群岛 (+681)" + }, + { + "value": "YE:967", + "text": "也门 (+967)" + }, + { + "value": "ZM:260", + "text": "赞比亚 (+260)" + }, + { + "value": "ZW:263", + "text": "津巴布韦 (+263)" + } +] \ No newline at end of file diff --git a/public/json/phone_prefix_en.json b/public/json/phone_prefix_en.json new file mode 100644 index 0000000..84022bf --- /dev/null +++ b/public/json/phone_prefix_en.json @@ -0,0 +1,979 @@ +[ + { + "value": "CN:86", + "text": "China (+86)" + }, + { + "value": "US:1", + "text": "United States (+1)" + }, + { + "value": "CA:1", + "text": "Canada (+1)" + }, + { + "value": "AU:61", + "text": "Australia (+61)" + }, + { + "value": "JP:81", + "text": "Japan (+81)" + }, + { + "value": "MX:52", + "text": "Mexico (+52)" + }, + { + "value": "GB:44", + "text": "United Kingdom (+44)" + }, + { + "value": "DE:49", + "text": "Germany (+49)" + }, + { + "value": "FR:33", + "text": "France (+33)" + }, + { + "value": "AF:93", + "text": "Afghanistan (+93)" + }, + { + "value": "AX:358", + "text": "Åland Islands (+358)" + }, + { + "value": "AL:355", + "text": "Albania (+355)" + }, + { + "value": "DZ:213", + "text": "Algeria (+213)" + }, + { + "value": "AS:1", + "text": "American Samoa (+1)" + }, + { + "value": "AD:376", + "text": "Andorra (+376)" + }, + { + "value": "AO:244", + "text": "Angola (+244)" + }, + { + "value": "AI:1", + "text": "Anguilla (+1)" + }, + { + "value": "AQ:672", + "text": "Antarctica (+672)" + }, + { + "value": "AG:1", + "text": "Antigua and Barbuda (+1)" + }, + { + "value": "AR:54", + "text": "Argentina (+54)" + }, + { + "value": "AM:374", + "text": "Armenia (+374)" + }, + { + "value": "AW:297", + "text": "Aruba (+297)" + }, + { + "value": "AT:43", + "text": "Austria (+43)" + }, + { + "value": "AZ:994", + "text": "Azerbaijan (+994)" + }, + { + "value": "BS:1", + "text": "Bahamas (+1)" + }, + { + "value": "BH:973", + "text": "Bahrain (+973)" + }, + { + "value": "BD:880", + "text": "Bangladesh (+880)" + }, + { + "value": "BB:1", + "text": "Barbados (+1)" + }, + { + "value": "BY:375", + "text": "Belarus (+375)" + }, + { + "value": "BE:32", + "text": "Belgium (+32)" + }, + { + "value": "BZ:501", + "text": "Belize (+501)" + }, + { + "value": "BJ:229", + "text": "Benin (+229)" + }, + { + "value": "BM:1", + "text": "Bermuda (+1)" + }, + { + "value": "BT:975", + "text": "Bhutan (+975)" + }, + { + "value": "BO:591", + "text": "Bolivia (+591)" + }, + { + "value": "BQ:599", + "text": "Bonaire, Sint Eustatius and Saba (+599)" + }, + { + "value": "BA:387", + "text": "Bosnia and Herzegovina (+387)" + }, + { + "value": "BW:267", + "text": "Botswana (+267)" + }, + { + "value": "BR:55", + "text": "Brazil (+55)" + }, + { + "value": "IO:246", + "text": "British Indian Ocean Territory (+246)" + }, + { + "value": "BN:673", + "text": "Brunei Darussalam (+673)" + }, + { + "value": "BG:359", + "text": "Bulgaria (+359)" + }, + { + "value": "BF:226", + "text": "Burkina Faso (+226)" + }, + { + "value": "BI:257", + "text": "Burundi (+257)" + }, + { + "value": "KH:855", + "text": "Cambodia (+855)" + }, + { + "value": "CM:237", + "text": "Cameroon (+237)" + }, + { + "value": "CV:238", + "text": "Cape Verde (+238)" + }, + { + "value": "KY:1", + "text": "Cayman Islands (+1)" + }, + { + "value": "CF:236", + "text": "Central African Republic (+236)" + }, + { + "value": "TD:235", + "text": "Chad (+235)" + }, + { + "value": "CL:56", + "text": "Chile (+56)" + }, + { + "value": "CX:61", + "text": "Christmas Island (+61)" + }, + { + "value": "CC:61", + "text": "Cocos (Keeling) Islands (+61)" + }, + { + "value": "CO:57", + "text": "Colombia (+57)" + }, + { + "value": "KM:269", + "text": "Comoros (+269)" + }, + { + "value": "CG:242", + "text": "Congo (+242)" + }, + { + "value": "CD:243", + "text": "Democratic Republic of the Congo (+243)" + }, + { + "value": "CK:682", + "text": "Cook Islands (+682)" + }, + { + "value": "CR:506", + "text": "Costa Rica (+506)" + }, + { + "value": "CI:225", + "text": "Côte d'Ivoire (+225)" + }, + { + "value": "HR:385", + "text": "Croatia (+385)" + }, + { + "value": "CU:53", + "text": "Cuba (+53)" + }, + { + "value": "CW:599", + "text": "Curaçao (+599)" + }, + { + "value": "CZ:420", + "text": "Czech Republic (+420)" + }, + { + "value": "DK:45", + "text": "Denmark (+45)" + }, + { + "value": "DJ:253", + "text": "Djibouti (+253)" + }, + { + "value": "DM:1", + "text": "Dominica (+1)" + }, + { + "value": "DO:1", + "text": "Dominican Republic (+1)" + }, + { + "value": "EC:593", + "text": "Ecuador (+593)" + }, + { + "value": "EG:20", + "text": "Egypt (+20)" + }, + { + "value": "SV:503", + "text": "El Salvador (+503)" + }, + { + "value": "GQ:240", + "text": "Equatorial Guinea (+240)" + }, + { + "value": "ER:291", + "text": "Eritrea (+291)" + }, + { + "value": "EE:372", + "text": "Estonia (+372)" + }, + { + "value": "ET:251", + "text": "Ethiopia (+251)" + }, + { + "value": "FK:500", + "text": "Falkland Islands (Malvinas) (+500)" + }, + { + "value": "FO:298", + "text": "Faroe Islands (+298)" + }, + { + "value": "FJ:679", + "text": "Fiji (+679)" + }, + { + "value": "FI:358", + "text": "Finland (+358)" + }, + { + "value": "GF:594", + "text": "French Guiana (+594)" + }, + { + "value": "PF:689", + "text": "French Polynesia (+689)" + }, + { + "value": "GA:241", + "text": "Gabon (+241)" + }, + { + "value": "GM:220", + "text": "Gambia (+220)" + }, + { + "value": "GE:995", + "text": "Georgia (+995)" + }, + { + "value": "GH:233", + "text": "Ghana (+233)" + }, + { + "value": "GI:350", + "text": "Gibraltar (+350)" + }, + { + "value": "GR:30", + "text": "Greece (+30)" + }, + { + "value": "GL:299", + "text": "Greenland (+299)" + }, + { + "value": "GD:1", + "text": "Grenada (+1)" + }, + { + "value": "GP:590", + "text": "Guadeloupe (+590)" + }, + { + "value": "GU:1", + "text": "Guam (+1)" + }, + { + "value": "GT:502", + "text": "Guatemala (+502)" + }, + { + "value": "GG:44", + "text": "Guernsey (+44)" + }, + { + "value": "GN:224", + "text": "Guinea (+224)" + }, + { + "value": "GW:245", + "text": "Guinea-Bissau (+245)" + }, + { + "value": "GY:592", + "text": "Guyana (+592)" + }, + { + "value": "HT:509", + "text": "Haiti (+509)" + }, + { + "value": "HN:504", + "text": "Honduras (+504)" + }, + { + "value": "HK:852", + "text": "Hong Kong, China (+852)" + }, + { + "value": "HU:36", + "text": "Hungary (+36)" + }, + { + "value": "IS:354", + "text": "Iceland (+354)" + }, + { + "value": "IN:91", + "text": "India (+91)" + }, + { + "value": "ID:62", + "text": "Indonesia (+62)" + }, + { + "value": "IR:98", + "text": "Iran, Islamic Republic of (+98)" + }, + { + "value": "IQ:964", + "text": "Iraq (+964)" + }, + { + "value": "IE:353", + "text": "Ireland (+353)" + }, + { + "value": "IM:44", + "text": "Isle of Man (+44)" + }, + { + "value": "IL:972", + "text": "Israel (+972)" + }, + { + "value": "IT:39", + "text": "Italy (+39)" + }, + { + "value": "JM:1", + "text": "Jamaica (+1)" + }, + { + "value": "JE:44", + "text": "Jersey (+44)" + }, + { + "value": "JO:962", + "text": "Jordan (+962)" + }, + { + "value": "KZ:7", + "text": "Kazakhstan (+7)" + }, + { + "value": "KE:254", + "text": "Kenya (+254)" + }, + { + "value": "KI:686", + "text": "Kiribati (+686)" + }, + { + "value": "KP:850", + "text": "North Korea (+850)" + }, + { + "value": "KR:82", + "text": "South Korea (+82)" + }, + { + "value": "KW:965", + "text": "Kuwait (+965)" + }, + { + "value": "KG:996", + "text": "Kyrgyzstan (+996)" + }, + { + "value": "LA:856", + "text": "Lao People's Democratic Republic (+856)" + }, + { + "value": "LV:371", + "text": "Latvia (+371)" + }, + { + "value": "LB:961", + "text": "Lebanon (+961)" + }, + { + "value": "LS:266", + "text": "Lesotho (+266)" + }, + { + "value": "LR:231", + "text": "Liberia (+231)" + }, + { + "value": "LY:218", + "text": "Libya (+218)" + }, + { + "value": "LI:423", + "text": "Liechtenstein (+423)" + }, + { + "value": "LT:370", + "text": "Lithuania (+370)" + }, + { + "value": "LU:352", + "text": "Luxembourg (+352)" + }, + { + "value": "MO:853", + "text": "Macao, China (+853)" + }, + { + "value": "MK:389", + "text": "North Macedonia (+389)" + }, + { + "value": "MG:261", + "text": "Madagascar (+261)" + }, + { + "value": "MW:265", + "text": "Malawi (+265)" + }, + { + "value": "MY:60", + "text": "Malaysia (+60)" + }, + { + "value": "MV:960", + "text": "Maldives (+960)" + }, + { + "value": "ML:223", + "text": "Mali (+223)" + }, + { + "value": "MT:356", + "text": "Malta (+356)" + }, + { + "value": "MH:692", + "text": "Marshall Islands (+692)" + }, + { + "value": "MQ:596", + "text": "Martinique (+596)" + }, + { + "value": "MR:222", + "text": "Mauritania (+222)" + }, + { + "value": "MU:230", + "text": "Mauritius (+230)" + }, + { + "value": "YT:262", + "text": "Mayotte (+262)" + }, + { + "value": "FM:691", + "text": "Federated States of Micronesia (+691)" + }, + { + "value": "MD:373", + "text": "Republic of Moldova (+373)" + }, + { + "value": "MC:377", + "text": "Monaco (+377)" + }, + { + "value": "MN:976", + "text": "Mongolia (+976)" + }, + { + "value": "ME:382", + "text": "Montenegro (+382)" + }, + { + "value": "MS:1", + "text": "Montserrat (+1)" + }, + { + "value": "MA:212", + "text": "Morocco (+212)" + }, + { + "value": "MZ:258", + "text": "Mozambique (+258)" + }, + { + "value": "MM:95", + "text": "Myanmar (+95)" + }, + { + "value": "NA:264", + "text": "Namibia (+264)" + }, + { + "value": "NR:674", + "text": "Nauru (+674)" + }, + { + "value": "NP:977", + "text": "Nepal (+977)" + }, + { + "value": "NL:31", + "text": "Netherlands (+31)" + }, + { + "value": "NC:687", + "text": "New Caledonia (+687)" + }, + { + "value": "NZ:64", + "text": "New Zealand (+64)" + }, + { + "value": "NI:505", + "text": "Nicaragua (+505)" + }, + { + "value": "NE:227", + "text": "Niger (+227)" + }, + { + "value": "NG:234", + "text": "Nigeria (+234)" + }, + { + "value": "NU:683", + "text": "Niue (+683)" + }, + { + "value": "NF:672", + "text": "Norfolk Island (+672)" + }, + { + "value": "MP:1", + "text": "Northern Mariana Islands (+1)" + }, + { + "value": "NO:47", + "text": "Norway (+47)" + }, + { + "value": "OM:968", + "text": "Oman (+968)" + }, + { + "value": "PK:92", + "text": "Pakistan (+92)" + }, + { + "value": "PW:680", + "text": "Palau (+680)" + }, + { + "value": "PS:970", + "text": "Palestinian Territory (+970)" + }, + { + "value": "PA:507", + "text": "Panama (+507)" + }, + { + "value": "PG:675", + "text": "Papua New Guinea (+675)" + }, + { + "value": "PY:595", + "text": "Paraguay (+595)" + }, + { + "value": "PE:51", + "text": "Peru (+51)" + }, + { + "value": "PH:63", + "text": "Philippines (+63)" + }, + { + "value": "PN:64", + "text": "Pitcairn Islands (+64)" + }, + { + "value": "PL:48", + "text": "Poland (+48)" + }, + { + "value": "PT:351", + "text": "Portugal (+351)" + }, + { + "value": "PR:1", + "text": "Puerto Rico (+1)" + }, + { + "value": "QA:974", + "text": "Qatar (+974)" + }, + { + "value": "CY:357", + "text": "Cyprus (+357)" + }, + { + "value": "RE:262", + "text": "Réunion (+262)" + }, + { + "value": "RO:40", + "text": "Romania (+40)" + }, + { + "value": "RU:7", + "text": "Russian Federation (+7)" + }, + { + "value": "RW:250", + "text": "Rwanda (+250)" + }, + { + "value": "BL:590", + "text": "Saint Barthélemy (+590)" + }, + { + "value": "SH:290", + "text": "Saint Helena (+290)" + }, + { + "value": "KN:1", + "text": "Saint Kitts and Nevis (+1)" + }, + { + "value": "LC:1", + "text": "Saint Lucia (+1)" + }, + { + "value": "MF:590", + "text": "Saint Martin (French part) (+590)" + }, + { + "value": "PM:508", + "text": "Saint Pierre and Miquelon (+508)" + }, + { + "value": "VC:1", + "text": "Saint Vincent and the Grenadines (+1)" + }, + { + "value": "WS:685", + "text": "Samoa (+685)" + }, + { + "value": "SM:378", + "text": "San Marino (+378)" + }, + { + "value": "ST:239", + "text": "Sao Tome and Principe (+239)" + }, + { + "value": "SA:966", + "text": "Saudi Arabia (+966)" + }, + { + "value": "SN:221", + "text": "Senegal (+221)" + }, + { + "value": "RS:381", + "text": "Serbia (+381)" + }, + { + "value": "SC:248", + "text": "Seychelles (+248)" + }, + { + "value": "SL:232", + "text": "Sierra Leone (+232)" + }, + { + "value": "SG:65", + "text": "Singapore (+65)" + }, + { + "value": "SX:599", + "text": "Sint Maarten (Dutch part) (+599)" + }, + { + "value": "SK:421", + "text": "Slovakia (+421)" + }, + { + "value": "SI:386", + "text": "Slovenia (+386)" + }, + { + "value": "SB:677", + "text": "Solomon Islands (+677)" + }, + { + "value": "SO:252", + "text": "Somalia (+252)" + + }, + { + "value": "ZA:27", + "text": "South Africa (+27)" + }, + { + "value": "GS:500", + "text": "South Georgia and the South Sandwich Islands (+500)" + }, + { + "value": "SS:211", + "text": "South Sudan (+211)" + }, + { + "value": "ES:34", + "text": "Spain (+34)" + }, + { + "value": "LK:94", + "text": "Sri Lanka (+94)" + }, + { + "value": "SD:249", + "text": "Sudan (+249)" + }, + { + "value": "SR:597", + "text": "Suriname (+597)" + }, + { + "value": "SJ:47", + "text": "Svalbard and Jan Mayen (+47)" + }, + { + "value": "SZ:268", + "text": "Eswatini (+268)" + }, + { + "value": "SE:46", + "text": "Sweden (+46)" + }, + { + "value": "CH:41", + "text": "Switzerland (+41)" + }, + { + "value": "SY:963", + "text": "Syrian Arab Republic (+963)" + }, + { + "value": "TW:886", + "text": "Taiwan, China (+886)" + }, + { + "value": "TJ:992", + "text": "Tajikistan (+992)" + }, + { + "value": "TZ:255", + "text": "United Republic of Tanzania (+255)" + }, + { + "value": "TH:66", + "text": "Thailand (+66)" + }, + { + "value": "TL:670", + "text": "East Timor (+670)" + }, + { + "value": "TG:228", + "text": "Togo (+228)" + }, + { + "value": "TK:690", + "text": "Tokelau (+690)" + }, + { + "value": "TO:676", + "text": "Tonga (+676)" + }, + { + "value": "TT:1", + "text": "Trinidad and Tobago (+1)" + }, + { + "value": "TN:216", + "text": "Tunisia (+216)" + }, + { + "value": "TR:90", + "text": "Turkey (+90)" + }, + { + "value": "TM:993", + "text": "Turkmenistan (+993)" + }, + { + "value": "TC:1", + "text": "Turks and Caicos Islands (+1)" + }, + { + "value": "TV:688", + "text": "Tuvalu (+688)" + }, + { + "value": "UG:256", + "text": "Uganda (+256)" + }, + { + "value": "UA:380", + "text": "Ukraine (+380)" + }, + { + "value": "AE:971", + "text": "United Arab Emirates (+971)" + }, + { + "value": "UY:598", + "text": "Uruguay (+598)" + }, + { + "value": "UZ:998", + "text": "Uzbekistan (+998)" + }, + { + "value": "VU:678", + "text": "Vanuatu (+678)" + }, + { + "value": "VA:379", + "text": "Vatican (+379)" + }, + { + "value": "VE:58", + "text": "Venezuela (+58)" + }, + { + "value": "VN:84", + "text": "Viet Nam (+84)" + }, + { + "value": "VG:1", + "text": "British Virgin Islands (+1)" + }, + { + "value": "VI:1", + "text": "U.S. Virgin Islands (+1)" + }, + { + "value": "WF:681", + "text": "Wallis and Futuna (+681)" + }, + { + "value": "YE:967", + "text": "Yemen (+967)" + }, + { + "value": "ZM:260", + "text": "Zambia (+260)" + }, + { + "value": "ZW:263", + "text": "Zimbabwe (+263)" + } +] \ No newline at end of file diff --git a/public/json/us.json b/public/json/us.json new file mode 100644 index 0000000..bd650d3 --- /dev/null +++ b/public/json/us.json @@ -0,0 +1,234 @@ +[ +{ + "value": "AL", + "text": "阿拉巴马州(ALABAMA)" +}, +{ + "value": "AK", + "text": "阿拉斯加(ALASKA)" +}, +{ + "value": "AS", + "text": "美属萨摩亚(AMERICAN SAMOA)" +}, +{ + "value": "AZ", + "text": "亚利桑那州(ARIZONA)" +}, +{ + "value": "AR", + "text": "阿肯色州(ARKANSAS)" +}, +{ + "value": "CA", + "text": "加利福尼亚州(CALIFORNIA)" +}, +{ + "value": "CO", + "text": "科罗拉多州(COLORADO)" +}, +{ + "value": "CT", + "text": "康涅狄格州(CONNECTICUT)" +}, +{ + "value": "DE", + "text": "特拉华州(DELAWARE)" +}, +{ + "value": "DC", + "text": "哥伦比亚特区(DISTRICT OF COLUMBIA)" +}, +{ + "value": "FL", + "text": "佛罗里达(FLORIDA)" +}, +{ + "value": "GA", + "text": "格鲁吉亚(GEORGIA)" +}, +{ + "value": "GU", + "text": "关岛(GUAM)" +}, +{ + "value": "HI", + "text": "夏威夷(HAWAII)" +}, +{ + "value": "ID", + "text": "爱达荷州(IDAHO)" +}, +{ + "value": "IL", + "text": "伊利诺伊州(ILLINOIS)" +}, +{ + "value": "IN", + "text": "印地安那(INDIANA)" +}, +{ + "value": "IA", + "text": "爱荷华州(IOWA)" +}, +{ + "value": "KS", + "text": "堪萨斯州(KANSAS)" +}, +{ + "value": "KY", + "text": "肯塔基州(KENTUCKY)" +}, +{ + "value": "LA", + "text": "路易斯安那州(LOUISIANA)" +}, +{ + "value": "ME", + "text": "缅因州(MAINE)" +}, +{ + "value": "MD", + "text": "马里兰州(MARYLAND)" +}, +{ + "value": "MA", + "text": "马萨诸塞州(MASSACHUSETTS)" +}, +{ + "value": "MI", + "text": "密歇根州(MICHIGAN)" +}, +{ + "value": "MN", + "text": "明尼苏达州(MINNESOTA)" +}, +{ + "value": "MS", + "text": "密西西比州(MISSISSIPPI)" +}, +{ + "value": "MO", + "text": "密苏里州(MISSOURI)" +}, +{ + "value": "MT", + "text": "蒙大拿州(MONTANA)" +}, +{ + "value": "NE", + "text": "内布拉斯加州(NEBRASKA)" +}, +{ + "value": "NV", + "text": "内华达州(NEVADA)" +}, +{ + "value": "NH", + "text": "新汉普郡(NEW HAMPSHIRE)" +}, +{ + "value": "NJ", + "text": "新泽西州(NEW JERSEY)" +}, +{ + "value": "NM", + "text": "新墨西哥(NEW MEXICO)" +}, +{ + "value": "NY", + "text": "纽约(NEW YORK)" +}, +{ + "value": "NC", + "text": "北卡罗莱纳州(NORTH CAROLINA)" +}, +{ + "value": "ND", + "text": "北达科塔州(NORTH DAKOTA)" +}, +{ + "value": "MP", + "text": "北马里亚纳群岛(NORTHERN MARIANA ISLANDS)" +}, +{ + "value": "OH", + "text": "俄亥俄州(OHIO)" +}, +{ + "value": "OK", + "text": "奥克拉荷马(OKLAHOMA)" +}, +{ + "value": "OR", + "text": "俄勒冈州(OREGON)" +}, +{ + "value": "PA", + "text": "宾夕法尼亚州(PENNSYLVANIA)" +}, +{ + "value": "PR", + "text": "波多黎各(PUERTO RICO)" +}, +{ + "value": "RI", + "text": "罗德岛(RHODE ISLAND)" +}, +{ + "value": "SC", + "text": "南卡罗莱纳州(SOUTH CAROLINA)" +}, +{ + "value": "SD", + "text": "南达科他州(SOUTH DAKOTA)" +}, +{ + "value": "TN", + "text": "田纳西州(TENNESSEE)" +}, +{ + "value": "TX", + "text": "德克萨斯州(TEXAS)" +}, +{ + "value": "UM", + "text": "美国本土外小岛屿(UNITED STATES MINOR OUTLYING ISLANDS)" +}, +{ + "value": "UT", + "text": "犹他州(UTAH)" +}, +{ + "value": "VT", + "text": "佛蒙特州(VERMONT)" +}, +{ + "value": "VI", + "text": "美属维尔京群岛(VIRGIN ISLANDS, U.S.)" +}, +{ + "value": "VA", + "text": "弗吉尼亚州(VIRGINIA)" +}, +{ + "value": "WA", + "text": "华盛顿(WASHINGTON)" +}, +{ + "value": "WV", + "text": "西弗吉尼亚州(WEST VIRGINIA)" +}, +{ + "value": "WI", + "text": "威斯康星州(WISCONSIN)" +}, +{ + "value": "WY", + "text": "怀俄明州(WYOMING)" +}, +{ + "value": "XX", + "text": "未知(UNKNOWN)" +} +] \ No newline at end of file diff --git a/public/json/us_en.json b/public/json/us_en.json new file mode 100644 index 0000000..8f6df1f --- /dev/null +++ b/public/json/us_en.json @@ -0,0 +1,234 @@ +[ + { + "value": "AL", + "text": "Alabama" + }, + { + "value": "AK", + "text": "Alaska" + }, + { + "value": "AS", + "text": "American Samoa" + }, + { + "value": "AZ", + "text": "Arizona" + }, + { + "value": "AR", + "text": "Arkansas" + }, + { + "value": "CA", + "text": "California" + }, + { + "value": "CO", + "text": "Colorado" + }, + { + "value": "CT", + "text": "Connecticut" + }, + { + "value": "DE", + "text": "Delaware" + }, + { + "value": "DC", + "text": "District of Columbia" + }, + { + "value": "FL", + "text": "Florida" + }, + { + "value": "GA", + "text": "Georgia" + }, + { + "value": "GU", + "text": "Guam" + }, + { + "value": "HI", + "text": "Hawaii" + }, + { + "value": "ID", + "text": "Idaho" + }, + { + "value": "IL", + "text": "Illinois" + }, + { + "value": "IN", + "text": "Indiana" + }, + { + "value": "IA", + "text": "Iowa" + }, + { + "value": "KS", + "text": "Kansas" + }, + { + "value": "KY", + "text": "Kentucky" + }, + { + "value": "LA", + "text": "Louisiana" + }, + { + "value": "ME", + "text": "Maine" + }, + { + "value": "MD", + "text": "Maryland" + }, + { + "value": "MA", + "text": "Massachusetts" + }, + { + "value": "MI", + "text": "Michigan" + }, + { + "value": "MN", + "text": "Minnesota" + }, + { + "value": "MS", + "text": "Mississippi" + }, + { + "value": "MO", + "text": "Missouri" + }, + { + "value": "MT", + "text": "Montana" + }, + { + "value": "NE", + "text": "Nebraska" + }, + { + "value": "NV", + "text": "Nevada" + }, + { + "value": "NH", + "text": "New Hampshire" + }, + { + "value": "NJ", + "text": "New Jersey" + }, + { + "value": "NM", + "text": "New Mexico" + }, + { + "value": "NY", + "text": "New York" + }, + { + "value": "NC", + "text": "North Carolina" + }, + { + "value": "ND", + "text": "North Dakota" + }, + { + "value": "MP", + "text": "Northern Mariana Islands" + }, + { + "value": "OH", + "text": "Ohio" + }, + { + "value": "OK", + "text": "Oklahoma" + }, + { + "value": "OR", + "text": "Oregon" + }, + { + "value": "PA", + "text": "Pennsylvania" + }, + { + "value": "PR", + "text": "Puerto Rico" + }, + { + "value": "RI", + "text": "Rhode Island" + }, + { + "value": "SC", + "text": "South Carolina" + }, + { + "value": "SD", + "text": "South Dakota" + }, + { + "value": "TN", + "text": "Tennessee" + }, + { + "value": "TX", + "text": "Texas" + }, + { + "value": "UM", + "text": "United States Minor Outlying Islands" + }, + { + "value": "UT", + "text": "Utah" + }, + { + "value": "VT", + "text": "Vermont" + }, + { + "value": "VI", + "text": "U.S. Virgin Islands" + }, + { + "value": "VA", + "text": "Virginia" + }, + { + "value": "WA", + "text": "Washington" + }, + { + "value": "WV", + "text": "West Virginia" + }, + { + "value": "WI", + "text": "Wisconsin" + }, + { + "value": "WY", + "text": "Wyoming" + }, + { + "value": "XX", + "text": "Unknown" + } +] \ No newline at end of file diff --git a/public/nginx.htaccess b/public/nginx.htaccess new file mode 100644 index 0000000..250ba18 --- /dev/null +++ b/public/nginx.htaccess @@ -0,0 +1,8 @@ +location ~* (runtime|application)/{ + return 403; +} +location / { + if (!-e $request_filename){ + rewrite ^(.*)$ /index.php?s=$1 last; break; + } +} \ No newline at end of file diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/public/router.php b/public/router.php new file mode 100644 index 0000000..6497978 --- /dev/null +++ b/public/router.php @@ -0,0 +1,19 @@ + +// +---------------------------------------------------------------------- +// $Id$ + +if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) { + return false; +} else { + $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php'; + + require __DIR__ . "/index.php"; +} \ No newline at end of file diff --git a/route/app.php b/route/app.php new file mode 100644 index 0000000..35709e7 --- /dev/null +++ b/route/app.php @@ -0,0 +1,41 @@ + +// +---------------------------------------------------------------------- + +use think\facade\Route; + +Route::group('miniapi', function () { + Route::get('index/home', 'Index/home'); + Route::get('index/about', 'Index/about'); + Route::get('index/legal', 'Index/legal'); + Route::get('index/packages', 'Index/packages'); + Route::get('index/countries', 'Index/countries'); + + Route::post('auth/sendSms', 'Auth/sendSms'); + Route::post('auth/login', 'Auth/login'); + Route::post('auth/wxPhoneLogin', 'Auth/wxPhoneLogin'); + Route::get('auth/me', 'Auth/me'); + + Route::get('news/lists', 'News/lists'); + Route::get('news/detail', 'News/detail'); + + Route::get('help/faqs', 'Help/faqs'); + + Route::get('order/lists', 'Order/lists'); + Route::get('order/detail', 'Order/detail'); + Route::post('order/pay', 'Order/pay'); + + Route::get('ocr/signature', 'Ocr/signature'); + Route::post('upload/image', 'Upload/image'); + + Route::post('evus/lookup', 'Evus/lookup'); + Route::post('evus/apply', 'Evus/apply'); + Route::post('esta/apply', 'Esta/apply'); +})->namespace('app\\miniapi\\controller'); diff --git a/think b/think new file mode 100644 index 0000000..979ac35 --- /dev/null +++ b/think @@ -0,0 +1,11 @@ +#!/usr/bin/env php +console->run(); diff --git a/thinkphp/lang/zh-cn.php b/thinkphp/lang/zh-cn.php new file mode 100644 index 0000000..eb7a914 --- /dev/null +++ b/thinkphp/lang/zh-cn.php @@ -0,0 +1,136 @@ + +// +---------------------------------------------------------------------- + +// 核心中文语言包 +return [ + // 系统错误提示 + 'Undefined variable' => '未定义变量', + 'Undefined index' => '未定义数组索引', + 'Undefined offset' => '未定义数组下标', + 'Parse error' => '语法解析错误', + 'Type error' => '类型错误', + 'Fatal error' => '致命错误', + 'syntax error' => '语法错误', + + // 框架核心错误提示 + 'dispatch type not support' => '不支持的调度类型', + 'method param miss' => '方法参数错误', + 'method not exists' => '方法不存在', + 'module not exists' => '模块不存在', + 'controller not exists' => '控制器不存在', + 'class not exists' => '类不存在', + 'property not exists' => '类的属性不存在', + 'template not exists' => '模板文件不存在', + 'illegal controller name' => '非法的控制器名称', + 'illegal action name' => '非法的操作名称', + 'url suffix deny' => '禁止的URL后缀访问', + 'Route Not Found' => '当前访问路由未定义', + 'Undefined db type' => '未定义数据库类型', + 'variable type error' => '变量类型错误', + 'PSR-4 error' => 'PSR-4 规范错误', + 'not support total' => '简洁模式下不能获取数据总数', + 'not support last' => '简洁模式下不能获取最后一页', + 'error session handler' => '错误的SESSION处理器类', + 'not allow php tag' => '模板不允许使用PHP语法', + 'not support' => '不支持', + 'redisd master' => 'Redisd 主服务器错误', + 'redisd slave' => 'Redisd 从服务器错误', + 'must run at sae' => '必须在SAE运行', + 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', + 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', + 'fields not exists' => '数据表字段不存在', + 'where express error' => '查询表达式错误', + 'not support data' => '不支持的数据表达式', + 'no data to update' => '没有任何数据需要更新', + 'miss data to insert' => '缺少需要写入的数据', + 'miss complex primary data' => '缺少复合主键数据', + 'miss update condition' => '缺少更新条件', + 'model data Not Found' => '模型数据不存在', + 'table data not Found' => '表数据不存在', + 'delete without condition' => '没有条件不会执行删除操作', + 'miss relation data' => '缺少关联表数据', + 'tag attr must' => '模板标签属性必须', + 'tag error' => '模板标签错误', + 'cache write error' => '缓存写入失败', + 'sae mc write error' => 'SAE mc 写入错误', + 'route name not exists' => '路由标识不存在(或参数不够)', + 'invalid request' => '非法请求', + 'bind attr has exists' => '模型的属性已经存在', + 'relation data not exists' => '关联数据不存在', + 'relation not support' => '关联不支持', + 'chunk not support order' => 'Chunk不支持调用order方法', + 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', + + // 上传错误信息 + 'unknown upload error' => '未知上传错误!', + 'file write error' => '文件写入失败!', + 'upload temp dir not found' => '找不到临时文件夹!', + 'no file to uploaded' => '没有文件被上传!', + 'only the portion of file is uploaded' => '文件只有部分被上传!', + 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', + 'upload write error' => '文件上传保存错误!', + 'has the same filename: {:filename}' => '存在同名文件:{:filename}', + 'upload illegal files' => '非法上传文件', + 'illegal image files' => '非法图片文件', + 'extensions to upload is not allowed' => '上传文件后缀不允许', + 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', + 'filesize not match' => '上传文件大小不符!', + 'directory {:path} creation failed' => '目录 {:path} 创建失败!', + + // Validate Error Message + ':attribute require' => ':attribute不能为空', + ':attribute must be numeric' => ':attribute必须是数字', + ':attribute must be integer' => ':attribute必须是整数', + ':attribute must be float' => ':attribute必须是浮点数', + ':attribute must be bool' => ':attribute必须是布尔值', + ':attribute not a valid email address' => ':attribute格式不符', + ':attribute not a valid mobile' => ':attribute格式不符', + ':attribute must be a array' => ':attribute必须是数组', + ':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1', + ':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式', + ':attribute not a valid file' => ':attribute不是有效的上传文件', + ':attribute not a valid image' => ':attribute不是有效的图像文件', + ':attribute must be alpha' => ':attribute只能是字母', + ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', + ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', + ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', + ':attribute must be chinese' => ':attribute只能是汉字', + ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', + ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', + ':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', + ':attribute not a valid url' => ':attribute不是有效的URL地址', + ':attribute not a valid ip' => ':attribute不是有效的IP地址', + ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', + ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', + ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', + ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', + ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', + 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', + 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', + 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', + ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', + ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', + ':attribute not within :rule' => '不在有效期内 :rule', + 'access IP is not allowed' => '不允许的IP访问', + 'access IP denied' => '禁止的IP访问', + ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', + ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', + ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', + ':attribute must greater than :rule' => ':attribute必须大于 :rule', + ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', + ':attribute must less than :rule' => ':attribute必须小于 :rule', + ':attribute must equal :rule' => ':attribute必须等于 :rule', + ':attribute has exists' => ':attribute已存在', + ':attribute not conform to the rules' => ':attribute不符合指定规则', + 'invalid Request method' => '无效的请求类型', + 'invalid token' => '令牌数据无效', + 'not conform to the rules' => '规则错误', +]; diff --git a/vendor/alibabacloud/oss-v2/.github/workflows/main.yml b/vendor/alibabacloud/oss-v2/.github/workflows/main.yml new file mode 100644 index 0000000..8f02591 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: main +on: [push, pull_request] +jobs: + phpunit: + name: PHPUnit + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + steps: + - name: Install SASL library on macOS + if: matrix.operating-system == 'macos-latest' && matrix.php-version >= 8.5 + run: brew update && brew install cyrus-sasl + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: bz2, curl, fileinfo, mbstring, exif, openssl, zip + coverage: xdebug + + - name: Checkout + uses: actions/checkout@v5 + + - name: Install dependencies + run: composer install --ansi --prefer-dist --no-interaction --no-progress + + - name: PHPUnit Migrate Configuration + if: ${{ matrix.php-version != '7.4' && matrix.php-version != '8.0'}} + run: vendor/bin/phpunit --migrate-configuration + + - name: Run PHPUnit + run: vendor/bin/phpunit --testsuite UnitTest --fail-on-warning --fail-on-incomplete --fail-on-risky + + diff --git a/vendor/alibabacloud/oss-v2/.gitignore b/vendor/alibabacloud/oss-v2/.gitignore new file mode 100644 index 0000000..f35ee35 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/.gitignore @@ -0,0 +1,10 @@ +.vscode/ +.DS_Store +vendor/ +composer.lock +.phpunit.result.cache +.phpunit.cache +coverage.xml +phpunit.xml.bak +report/ +*.phar \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/CHANGELOG.md b/vendor/alibabacloud/oss-v2/CHANGELOG.md new file mode 100644 index 0000000..9d56db3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/CHANGELOG.md @@ -0,0 +1,72 @@ +# ChangeLog - Alibaba Cloud OSS SDK for PHP v2 + +## 版本号:0.4.0 日期:2025-12-25 +### 变更内容 +- Feature: Add seal append object api +- Feature: Add bucket overwrite config api +- Break Change: Change the name and type of LifecycleRuleFilter.not + +## 版本号:0.3.2 日期:2025-11-07 +### 变更内容 +- Update: ListBuckets api supports more parameters +- Update: Routing rule supports more parameters +- Update: Bucket logging supports more parameters +- Update: Bucket https configuration supports more parameters +- Update: Normalize parameter naming +- Fix:Rename bucket request payment class name + +## 版本号:0.3.1 日期:2025-06-13 +### 变更内容 +- Update:Meta query api supports more search condition settings +- Update:Api-level options supports credentials_provider + +## 版本号:0.3.0 日期:2025-04-24 +### 变更内容 +- Feature:Add bucket inventory api +- Feature:Add bucket style api +- Feature:Add bucket resource group api +- Feature:Add bucket https config api +- Feature:Add bucket redundancy transition api +- Feature:Add list cloud boxes api and add cloud box id param +- Feature:Add bucket replication api +- Feature:Add access point api + +## 版本号:0.2.1 日期:2025-03-18 +### 变更内容 +- Fix:Add a default content-type if possible. +- Fix:Use end() to get last error +- Fix:Compatibility with php 8.0 + +## 版本号:0.2.0 日期:2025-02-27 +### 变更内容 +- Feature:Add bucket lifecycle api +- Feature:Add bucket bucket transfer acceleration api +- Feature:Add bucket policy api +- Feature:Add bucket logging api +- Feature:Add bucket website api +- Feature:Add bucket referer api +- Feature:Add bucket tags api +- Feature:Add bucket request payment api +- Feature:Add bucket cors api +- Feature:Add bucket cname api +- Feature:Add bucket access monitor api +- Feature:Add bucket meta query api +- Feature:Add bucket encryption api +- Feature:Add bucket archive direct read api +- Feature:Add public access block api for oss resource, bucket resource +- Update:change guzzlehttp/psr7 version to "^2.7" + +## 版本号:0.1.0 日期:2025-01-03 +### 变更内容 +- Feature:Add credentials provider +- Feature:Add retryer +- Feature:Add signer v4/v1 +- Feature:Add annotation for 8.x +- Feature:Add bucket's basic api +- Feature:Add object's api +- Feature:Add presigner +- Feature:Add paginator +- Feature:Add uploader, downloader and copier +- Feature:Add encryption client +- Feature:Add isObjectExist/isBucketExist api +- Feature:Add putObjectFromFile/getObjectToFile api diff --git a/vendor/alibabacloud/oss-v2/DEVGUIDE-CN.md b/vendor/alibabacloud/oss-v2/DEVGUIDE-CN.md new file mode 100644 index 0000000..bf92ff8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/DEVGUIDE-CN.md @@ -0,0 +1,1767 @@ + + +# 开发者指南 +## [English](DEVGUIDE.md) + +阿里云对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量、安全、低成本、高可靠的云存储服务。用户可以通过调用API,在任何应用、任何时间、任何地点上传和下载数据,也可以通过用户Web控制台对数据进行简单的管理。OSS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。 + +该开发套件隐藏了许多较低级别的实现,例如身份验证、请求重试和错误处理, 通过其提供的接口,让您不用复杂编程即可访问阿里云OSS服务。 + +该开发套件同时提供实用的模块,例如上传和下载管理器,自动将大对象分成多块并行传输。 + +您可以参阅该指南,来帮助您安装、配置和使用该开发套件。 + +跳转到: + +* [安装](#安装) +* [配置](#配置) +* [接口说明](#接口说明) +* [场景示例](#场景示例) +* [迁移指南](#迁移指南) + +# 安装 + +## 环境准备 + +使用PHP 7.4及以上版本。 +请参考[php安装](https://www.php.net/manual/install.php)下载和安装php运行环境。 +您可以执行以下命令查看php语言版本。 +``` +php -v +``` + +## 安装SDK + +### composer 方式 +在项目的根目录运行 composer require alibabacloud/oss-v2, +
    或者在composer.json文件中添加如下依赖关系,并运行 composer install 安装依赖。 +``` +"require": { + "alibabacloud/oss-v2": "*" +} +``` +安装完成后,目录结构如下,其中app.php是您的应用程序: +``` + . + ├── src + | └──app.php + ├── composer.json + ├── composer.lock + └── vendor + +``` +您可以通过将以下内容添加到您的代码中来自动加载所有依赖项 +``` +require_once __DIR__ . '/../vendor/autoload.php'; +``` + +### phar方式 +在[GitHub](https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/releases)中选择相应的版本并下载打包好的phar文件。 + +在代码中引入phar文件: +``` +require_once '/path/to/alibabacloud-oss-php-sdk-v2-{version}.phar'; +``` + +### 源码方式 +在[GitHub](https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/releases)中选择相应的版本并并下载打包好的zip文件。 + +解压后的根目录中包含一个autoload.php文件,在代码中引入此文件: +``` +require_once '/path/to/alibabacloud-oss-php-sdk-v2/autoload.php'; +``` + +## 验证SDK +运行以下代码查看SDK版本: +``` +setCredentialsProvider($credentialsProvider); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); +``` + +## 区域 +指定区域时,您可以指定向何处发送请求,例如 cn-hangzhou 或 cn-shanghai。有关所支持的区域列表,请参阅 [OSS访问域名和数据中心](https://www.alibabacloud.com/help/zh/oss/user-guide/regions-and-endpoints)。 +SDK 没有默认区域,您需要加载配置时使用`(new Config())->setRegion`作为参数显式设置区域。例如 +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion("cn-hangzhou"); +``` + +>**说明**:该SDK默认使用v4签名,所以必须指定该参数。 + +## 凭证 + +SDK需要凭证(访问密钥)来签署对 OSS 的请求, 所以您需要显式指定这些信息。当前支持凭证配置如下: +* [环境变量](#环境变量) +* [静态凭证](#静态凭证) +* [ECS实例角色](#ecs实例角色) +* [RAM角色](#ram角色) +* [OIDC角色SSO](#oidc角色sso) +* [自定义凭证提供者](#自定义凭证提供者) + +### 环境变量 + +SDK 支持从环境变量获取凭证,支持的环境变量名如下: +* OSS_ACCESS_KEY_ID +* OSS_ACCESS_KEY_SECRET +* OSS_SESSION_TOKEN(可选) + +以下展示了如何配置环境变量。 + +1. Linux、OS X 或 Unix +``` +$ export OSS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID +$ export OSS_ACCESS_KEY_SECRET=YOUR_ACCESS_KEY_SECRET +$ export OSS_SESSION_TOKEN=TOKEN +``` + +2. Windows +``` +$ set OSS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID +$ set OSS_ACCESS_KEY_SECRET=YOUR_ACCESS_KEY_SECRET +$ set OSS_SESSION_TOKEN=TOKEN +``` + +使用环境变量凭证 + +``` +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +``` +### 静态凭证 + +您可以在应用程序中对凭据进行硬编码,显式设置要使用的访问密钥。 + +> **注意:** 请勿将凭据嵌入应用程序中,此方法仅用于测试目的。 + +1. 长期凭证 +``` +$credentialsProvider = new Oss\Credentials\StaticCredentialsProvider("AKId", "AKSecrect"); +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +``` + +2. 临时凭证 +``` +$credentialsProvider = new Oss\Credentials\StaticCredentialsProvider("AKId", "AKSecrect","Token"); +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +``` + +### ECS实例角色 + +如果你需要在阿里云的云服务器ECS中访问您的OSS,您可以通过ECS实例RAM角色的方式访问OSS。实例RAM角色允许您将一个角色关联到云服务器实例,在实例内部基于STS临时凭证通过指定方法访问OSS。 + +SDK 不直接提供该访问凭证实现,需要结合阿里云凭证库[credentials-php](https://github.com/aliyun/credentials-php),具体配置如下: + +``` + 'ecs_ram_role', + 'roleName' => "", +]); + +$credential = new Credential($config); +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider(new Oss\Credentials\CredentialsProviderFunc(function () use ($credential) { + $cred = $credential->getCredential(); + return new AlibabaCloud\Oss\V2\Credentials\Credentials($cred->getAccessKeyId(), $cred->getAccessKeySecret(), $cred->getSecurityToken()); +})); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); + +``` + +### RAM角色 + +如果您需要授权访问或跨账号访问OSS,您可以通过RAM用户扮演对应RAM角色的方式授权访问或跨账号访问OSS。 + +SDK 不直接提供该访问凭证实现,需要结合阿里云凭证库[credentials-php](https://github.com/aliyun/credentials-php),具体配置如下: + +``` + 'ram_role_arn', + // AccessKeyId of your account + 'accessKeyId' => 'AccessKeyId', + // AccessKeySecret of your account + 'accessKeySecret' => 'AccessKeySecret', + // Format: acs:ram::USER_Id:role/ROLE_NAME + 'roleArn' => 'RoleArn', + // Role Session Name + 'roleSessionName' => 'yourRoleSessionName', + // Not required, limit the permissions of STS Token + 'policy' => 'Policy', +]); + +$credential = new Credential($config); +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider(new Oss\Credentials\CredentialsProviderFunc(function () use ($credential) { + $cred = $credential->getCredential(); + return new AlibabaCloud\Oss\V2\Credentials\Credentials($cred->getAccessKeyId(), $cred->getAccessKeySecret(), $cred->getSecurityToken()); +})); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); + +``` + +### OIDC角色SSO + +您也可以在应用或服务中使用OIDC认证访问OSS服务,关于OIDC角色SSO的更多信息,请参见[OIDC角色SSO概览](https://www.alibabacloud.com/help/zh/ram/user-guide/overview-of-oidc-based-sso)。 + +SDK 不直接提供该访问凭证实现,需要结合阿里云凭证库[credentials-php](https://github.com/aliyun/credentials-php),具体配置如下: + +``` + 'oidc_role_arn', + // Specify the ARN of the OIDC IdP by specifying the ALIBABA_CLOUD_OIDC_PROVIDER_ARN environment variable. + 'oidcProviderArn' => '', + // Specify the path of the OIDC token file by specifying the ALIBABA_CLOUD_OIDC_TOKEN_FILE environment variable. + 'oidcTokenFilePath' => '', + // Specify the ARN of the RAM role by specifying the ALIBABA_CLOUD_ROLE_ARN environment variable. + 'roleArn' => '', + // Specify the role session name by specifying the ALIBABA_CLOUD_ROLE_SESSION_NAME environment variable. + 'roleSessionName' => '', + // Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}. + 'policy' => '', + // Optional. Specify the validity period of the session. + 'roleSessionExpiration' => 3600, +]); + +$credential = new Credential($config); +$cfg = Oss\Config::loadDefault(); +$providerWrapper = new AlibabaCloudCredentialsWrapper($credential); +$cfg->setCredentialsProvider(new Oss\Credentials\CredentialsProviderFunc(function () use ($credential) { + $cred = $credential->getCredential(); + return new AlibabaCloud\Oss\V2\Credentials\Credentials($cred->getAccessKeyId(), $cred->getAccessKeySecret(), $cred->getSecurityToken()); +})); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); +``` + +### 自定义凭证提供者 + +当以上凭证配置方式不满足要求时,您可以自定义获取凭证的方式。SDK 支持多种实现方式。 + +1. 实现 Oss\Credentials\CredentialsProvider 接口 +``` +setCredentialsProvider($provider); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); + +``` + +2. 通过 Oss\Credentials\CredentialsProviderFunc + +Oss\Credentials\CredentialsProviderFunc 是 Oss\Credentials\CredentialsProvider 的 易用性封装。 + +``` +setCredentialsProvider($provider); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); +``` +## 访问域名 + +您可以通过Endpoint参数,自定义服务请求的访问域名。 + +当不指定时,SDK根据Region信息,构造公网访问域名。例如当Region为'cn-hangzhou'时,构造出来的访问域名为'oss-cn-hangzhou.aliyuncs.com'。 + +您可以通过修改配置参数,构造出其它访问域名,例如 内网访问域名,传输加速访问域名 和 双栈(IPV6,IPV4)访问域名。有关OSS访问域名规则,请参考[OSS访问域名使用规则](https://www.alibabacloud.com/help/zh/oss/user-guide/oss-domain-names)。 + +当通过自定义域名访问OSS服务时,您需要指定该配置参数。在使用自定义域名发送请求时,请先绑定自定域名至Bucket默认域名,具体操作详见 [绑定自定义域名](https://www.alibabacloud.com/help/zh/oss/user-guide/map-custom-domain-names-5)。 + +### 使用标准域名访问 + +以 访问 Region 'cn-hangzhou' 为例 + +1. 使用公网域名 + +``` +$cfg = Oss\Config::loadDefault(); +$region = 'cn-hangzhou'; +$cfg->setRegion($region); + +或者 + +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setEndpoint('oss-cn-hanghzou.aliyuncs.com'); +``` + +2. 使用内网域名 + +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setUseInternalEndpoint(true); + +或者 + +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setEndpoint('oss-cn-hanghzou-internal.aliyuncs.com'); +``` + +3. 使用传输加速域名 +``` +$cfg = Oss\Config::loadDefault(); +$cfg = $cfg->setRegion('cn-hangzhou')->setUseAccelerateEndpoint(true); + +或者 + +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setEndpoint('oss-accelerate.aliyuncs.com'); +``` + +4. 使用双栈域名 +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setUseDualStackEndpoint(true); + +或者 + +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setEndpoint('cn-hangzhou.oss.aliyuncs.com'); +``` + +### 使用自定义域名访问 + +以 'www.example-***.com' 域名 绑定到 'cn-hangzhou' 区域 的 bucket-example 存储空间为例 + +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion('cn-hangzhou')->setEndpoint('www.example-***.com')->setUseCname(true); +``` + +### 访问专有云或专有域 + +``` +$region = 'YOUR Region'; +$endpoint = 'YOUR Endpoint'; +$cfg = Oss\Config::loadDefault(); +$cfg->setRegion($region)->setEndpoint($endpoint); +``` + +## HTTP客户端 + +在大多数情况下,使用具有默认值的默认HTTP客户端 能够满足业务需求。您也可以更改HTTP 客户端,或者更改 HTTP 客户端的默认配置,以满足特定环境下的使用需求。 + +本部分将介绍如何设置 和 创建 HTTP 客户端。 + +### 设置HTTP客户端常用配置 + +通过config修改常用的配置,支持参数如下: + +|参数名字 | 说明 | 示例 +|:-------|:-------|:------- +|connectTimeout|建立连接的超时时间, 默认值为 10 秒|setConnectTimeout(10) +|readWriteTimeout|应用读写数据的超时时间, 默认值为 20 秒|setReadWriteTimeout(30) +|insecureSkipVerify|是否跳过SSL证书校验,默认检查SSL证书|setInsecureSkipVerify(true) +|enabledRedirect|是否开启HTTP重定向, 默认不开启|setEnabledRedirect(true) +|proxyHost|设置代理服务器|setProxyHost(’http://user:passswd@proxy.example-***.com’) + +示例 + +``` +$cfg->setConnectTimeout(10)->setInsecureSkipVerify(true); +``` + +### 使用 Swoole 配置 + +常用配置参数在 Swoole 项目中运行会出错,可以使用 $options 中的 handler 修改默认的 HTTP 客户端。 + +以 hyperf 框架为例,常用配置已经无法正常运行 sdk,需要添加 handler 。 + +``` +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +$cfg->setEndpoint('http://oss-cn-hangzhou.aliyuncs.com'); +$client = new Oss\Client($cfg, ['handler' => HandlerStack::create(new CoroutineHandler())]); +co(function () use ($client, $bucket) { + try { + $key = 'swoole.txt'; + $data = 'Hello OSS'; + $request = new Oss\Models\PutObjectRequest($bucket, $key); + $request->body = Oss\Utils::streamFor($data); + $result = $client->putObject($request); + echo var_export($result, true); + } catch (\Exception $e) { + print_r($e->getMessage()); + } +}); + +co(function () use ($client, $bucket) { + try { + $key = 'hyperf.txt'; + $data = 'Hello OSS'; + $request = new Oss\Models\PutObjectRequest($bucket, $key); + $request->body = Oss\Utils::streamFor($data); + $result = $client->putObject($request); + echo var_export($result, true); + } catch (\Exception $e) { + print_r($e->getMessage()); + } +}); +``` + +## 重试 + +您可以配置对HTTP请求的重试行为。 + +### 默认重试策略 + +当没有配置重试策略时,SDK 使用 AlibabaCloud\Oss\V2\Retry\StandardRetryer 作为客户端的默认实现,其默认配置如下: + +|参数名称 | 说明 | 默认值 +|:-------|:-------|:------- +|maxAttempts|最大尝试次数| 3 +|maxBackoff|最大退避时间| 20秒, 20 +|baseDelay|基础延迟| 200毫秒, 0.2 +|backoff|退避算法| FullJitter 退避, [0.0, 1.0) * min(2 ^ attempts * baseDealy, maxBackoff) +|errorRetryables|可重试的错误| 具体的错误信息,请参见[重试错误](src/Retry) + +当发生可重试错误时,将使用其提供的配置来延迟并随后重试该请求。请求的总体延迟会随着重试次数而增加,如果默认配置不满足您的场景需求时,需要配置重试参数 或者修改重试实现。 + +### 调整最大尝试次数 + +您可以通过以下两种方式修改最大尝试次数。例如 最多尝试 5 次 + +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRetryMaxAttempts(5); + +或者 + +$cfg = Oss\Config::loadDefault(); +$cfg->setRetryer(new AlibabaCloud\Oss\V2\Retry\StandardRetryer( + maxAttempts: 5 +)); +``` + +### 调整退避延迟 + +例如 调整 BaseDelay 为 500毫秒,最大退避时间为 25秒 + +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRetryer(new AlibabaCloud\Oss\V2\Retry\StandardRetryer( + maxBackoff: 25, + baseDelay: 0.5 +)); +``` + +### 调整退避算法 + +例如 使用固定时间退避算法,每次延迟2秒 + +``` +$cfg = Oss\Config::loadDefault(); +$cfg->setRetryer(new AlibabaCloud\Oss\V2\Retry\StandardRetryer( + backoffDelayer: new Oss\Retry\FixedDelayBackoff(2) +)); +``` + +### 调整重试错误 + +例如 在原有基础上,新增自定义可重试错误 + +``` +class CustomErrorCodeRetryable implements AlibabaCloud\Oss\V2\Retry\ErrorRetryableInterface +{ + public function isErrorRetryable(\Throwable $reason): bool + { + return false; + } +} + +$cfg = Oss\Config::loadDefault(); +$cfg->setRetryer(new AlibabaCloud\Oss\V2\Retry\StandardRetryer( + errorRetryables: [ + new AlibabaCloud\Oss\V2\Retry\ClientErrorRetryable(), + new AlibabaCloud\Oss\V2\Retry\ServiceErrorCodeRetryable(), + new AlibabaCloud\Oss\V2\Retry\HTTPStatusCodeRetryable(), + new CustomErrorCodeRetryable() + ] +)); +``` + +### 禁用重试 + +当您希望禁用所有重试尝试时,可以使用 AlibabaCloud\Oss\V2\Retry\NopRetryer 实现 +``` +$cfg->setRetryer(new AlibabaCloud\Oss\V2\Retry\NopRetryer()); +``` +## 配置参数汇总 + +支持的配置参数: + +|参数名字 | 说明 | 示例 +|:-------|:-------|:------- +|region|(必选)请求发送的区域, 必选|setRegion("cn-hangzhou") +|credentialsProvider|(必选)设置访问凭证|setCredentialsProvider(provider) +|endpoint|访问域名|setEndpoint("oss-cn-hanghzou.aliyuncs.com") +|retryMaxAttempts|HTTP请求时的最大尝试次数, 默认值为 3|setRetryMaxAttempts(5) +|retryer|HTTP请求时的重试实现|setRetryer(customRetryer) +|connectTimeout|建立连接的超时时间, 默认值为 10 秒|setConnectTimeout(5* time.Second) +|readWriteTimeout|应用读写数据的超时时间, 默认值为 20 秒|setReadWriteTimeout(30 * time.Second) +|insecureSkipVerify|是否跳过SSL证书校验,默认检查SSL证书|setInsecureSkipVerify(true) +|enabledRedirect|是否开启HTTP重定向, 默认不开启|setEnabledRedirect(true) +|proxyHost|设置代理服务器|setProxyHost(‘http://user:passswd@proxy.example-***.com’) +|signatureVersion|签名版本,默认值为v4|setSignatureVersion("v1") +|disableSSL|不使用https请求,默认使用https|setDisableSSL(true) +|usePathStyle|使用路径请求风格,即二级域名请求风格,默认为bucket托管域名|setUsePathStyle(true) +|useCName|是否使用自定义域名访问,默认不使用|setUseCName(true) +|useDualStackEndpoint|是否使用双栈域名访问,默认不使用|setUseDualStackEndpoint(true) +|useAccelerateEndpoint|是否使用传输加速域名访问,默认不使用|setUseAccelerateEndpoint(true) +|useInternalEndpoint|是否使用内网域名访问,默认不使用|setUseInternalEndpoint(true) +|additionalHeaders|指定额外的签名请求头,V4签名下有效|setAdditionalHeaders([‘content-length’]) +|userAgent|指定额外的User-Agent信息|setUserAgent(‘user identifier’) + +# 接口说明 + +本部分介绍SDK提供的接口, 以及如何使用这些接口。 + +此部分的其它主题 +* [基础接口](#基础接口) +* [预签名接口](#预签名接口) +* [分页器](#分页器) +* [传输管理器](#传输管理器) +* [客户端加密](#客户端加密) +* [其它接口](#其它接口) +* [上传下载接口对比](#上传下载接口对比) + +## 基础接口 + +SDK 提供了 与 REST API 对应的接口,把这类接口叫做 基础接口 或者 低级别API。您可以通过这些接口访问OSS的服务,例如创建存储空间,更新和删除存储空间的配置等。 + +这些接口采用了相同的命名规则,其接口定义如下: + +``` +public function (Models\Request $request, array $args = []): Models\Result +public function Async(Models\Request $request, array $args = []): \GuzzleHttp\Promise\Promise +``` + +**参数列表**: +|参数名|类型|说明 +|:-------|:-------|:------- +|request|\Request|设置具体接口的请求参数,例如bucket,key +|args|array|(可选)接口级的配置参数, 例如修改此次调用接口时读写超时 + +**返回值列表**: +|返回值名|类型|说明 +|:-------|:-------|:------- +|result|\Result|接口返回值 +## 预签名接口 + +您可以使用预签名接口生成预签名URL,授予对存储空间中对象的限时访问权限,或者允许他人将特定对象的上传到存储空间。在过期时间之前,您可以多次使用预签名URL。 + +预签名接口定义如下: +``` +public function presign(request: Request,args: $args): Models\PresignResult +``` + +**参数列表**: +|参数名|类型|说明 +|:-------|:-------|:------- +|request|object|设置需要生成签名URL的接口名,和 '$OperationNameRequest' 一致 +|args|array|(可选),设置过期时间,如果不指定,默认有效期为15分钟 + +**返回值列表**: +|返回值名|类型|说明 +|:-------|:-------|:------- +|result|PresignResult|返回结果,包含 预签名URL,HTTP 方法,过期时间 和 参与签名的请求头 + +**request参数支持的类型**: +|类型|对应的接口 +|:-------|:------- +|GetObjectRequest|GetObject +|PutObjectRequest|PutObject +|HeadObjectRequest|HeadObject +|InitiateMultipartUploadRequest|InitiateMultipartUpload +|UploadPartRequest|UploadPart +|CompleteMultipartUploadRequest|CompleteMultipartUpload +|AbortMultipartUploadRequest|AbortMultipartUpload + +**args选项** +|选项值|类型|说明 +|:-------|:-------|:------- +|expires|DateTime|从当前时间开始,多长时间过期。例如 设置一个有效期为30分钟,new DateInterval('PT30M') +|expiration|DateInterval|绝对过期时间 + +> **注意:** 在签名版本4下,有效期最长为7天。同时设置 expiration和 expires时,优先取 expiration。 + +**PresignResult返回值**: +|参数名|类型|说明 +|:-------|:-------|:------- +|method|string|HTTP 方法,和 接口对应,例如GetObject接口,返回 GET +|url|string|预签名 URL +|expiration|DateTime| 签名URL的过期时间 +|signedHeaders|array|被签名的请求头,例如PutObject接口,设置了Content-Type 时,会返回 Content-Type 的信息。 + + +示例 +1. 为对象生成预签名 URL,然后下载对象(GET 请求) +``` +$client = new Oss\Client($cfg); +$result = $client->presign(new Oss\Models\GetObjectRequest('bucket', 'key')); +$httpClient = new GuzzleHttp\Client(); +$response = $httpClient->request($result->method, $result->url); +``` + +2. 为上传生成预签名 URL, 设置自定义元数据,有效期为10分钟,然后上传文件(PUT 请求) +``` +$client = new Oss\Client($cfg); +$result = $client->presign(new Oss\Models\PutObjectRequest('bucket', 'key', metadata: ['user' => 'jack']), ['expires' => new DateInterval('PT10M')]); +$httpClient = new GuzzleHttp\Client(); +$response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); +``` + +更多的示例,请参考 sample 目录 + +## 分页器 + +对于列举类接口,当响应结果太大而无法在单个响应中返回时,都会返回分页结果,该结果同时包含一个用于检索下一页结果的标记。当需要获取下一页结果时,您需要在发送请求时设置该标记。 + +对常用的列举接口,V2 SDK 提供了分页器(Paginator),支持自动分页,当进行多次调用时,自动为您获取下一页结果。使用分页器时,您只需要编写处理结果的代码。 + +分页器 包含了 分页器对象 '\Paginator'。分页器创建方法返回一个分页器对象,该对象通过'isTruncated' 参数判断是否还有更多页, 并调用操作来获取下一页。 + +分页器对象初始化 '\Paginator' 里的 request 参数类型 与 '\' 接口中的 reqeust 参数类型一致。 + +'\Paginator' 返回的结果类型是一个Generator 对象, 该对象是 '\' 接口 返回的结果类型 的集合。 + +``` +public function iterPage(Request $request, array $args = []): \Generator +{ + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->($req, $args); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->continuationToken = $result->nextContinuationToken; + } +} + +``` + +支持的分页器对象如下: +|分页器对象|创建方法|对应的列举接口 +|:-------|:-------|:------- +|ListObjectsPaginator|new Oss\Paginator\ListObjectsPaginator($client)|ListObjects, 列举存储空间中的对象信息 +|ListObjectsV2Paginator|new Oss\Paginator\ListObjectsV2Paginator($client)|ListObjectsV2, 列举存储空间中的对象信息 +|ListObjectVersionsPaginator|new Oss\Paginator\ListObjectVersionsPaginator($client)|ListObjectVersions, 列举存储空间中的对象版本信息 +|ListBucketsPaginator|new Oss\Paginator\ListBucketsPaginator($client)|ListBuckets, 列举存储空间 +|ListPartsPaginator|new Oss\Paginator\ListPartsPaginator($client)|ListParts, 列举指定Upload ID所属的所有已经上传成功分片 +|ListMultipartUploadsPaginator|new Oss\Paginator\ListMultipartUploadsPaginator($client)|ListMultipartUploads, 列举存储空间中的执行中的分片上传事件 + +**args选项说明:** +|参数|说明 +|:-------|:------- +|Limit|指定返回结果的最大数 + + +以 ListObjects 为例,分页器遍历所有对象 和 手动分页遍历所有对象 对比 + +``` +// 分页器遍历所有对象 +... +$client = new Oss\Client($cfg); +$paginator = new Oss\Paginator\ListObjectsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListObjectsRequest($bucket)); +foreach ($iter as $page) { + foreach ($page->contents ?? [] as $object) { + printf("object name:%s,type:%s,size:%s" . PHP_EOL, $object->key, $object->type, $object->size); + } +} +``` + +``` +// 手动分页遍历所有对象 +... +$client = new Oss\Client($cfg); +$firstPage = true; +$isTruncated = false; +$request = new Oss\Models\ListObjectsRequest($bucket); +while ($firstPage || $isTruncated) { + $result = $client->listObjects($request); + foreach ($result->contents as $object) { + printf("object name:%s,type:%s,size:%s" . PHP_EOL, $object->key, $object->type, $object->size); + } + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $request->marker = $result->nextMarker; +} +``` + +## 传输管理器 + +针对大文件的传输场景,新增了 'Uploader','Downloader' 和 'Copier' 模块,分别管理对象的 上传,下载 和 拷贝。 + +### 上传管理器(Uploader) + +上传管理器 利用分片上传接口,把大文件或者流分成多个较小的分片并发上传,提升上传的性能。 +
    针对文件的上传场景,还提供了断点续传的能力,即在上传过程中,记录已完成的分片状态,如果出现网络中断、程序异常退出等问题导致文件上传失败,甚至重试多次仍无法完成上传,再次上传时,可以通过断点记录文件恢复上传。 + +``` +final class Uploader +{ + ... + public function __construct($client, array $args = []) + + public function uploadFile(Models\PutObjectRequest $request, string $filepath, array $args = []): Models\UploadResult + + public function uploadFrom(Models\PutObjectRequest $request, StreamInterface $stream, array $args = []): Models\UploadResult + ... +} +``` + +**参数列表**: +|参数名|类型|说明 +|:-------|:-------|:------- +|request|PutObjectRequest|上传对象的请求参数,和 PutObject 接口的 请求参数一致 +|stream|StreamInterface|需要上传的流。 +|filePath|string|本地文件路径 +|args|array|(可选),配置选项 + + +**args选项说明:** +|参数|类型|说明 +|:-------|:-------|:------- +|part_size|int|指定分片大小,默认值为 6MiB +|parallel_num|int|指定上传任务的并发数,默认值为 3。针对的是单次调用的并发限制,而不是全局的并发限制 +|leave_parts_on_error|bool|当上传失败时,是否保留已上传的分片,默认不保留 + +当使用Uploader实例化实例时,您可以指定多个配置选项来自定义对象的上传行为。也可以在每次调用上传接口时,指定多个配置选项来自定义每次上传对象的行为。 + +设置Uploader的配置参数 +``` +$u = $client->newUploader(['part_size' => 10 * 1024 * 1024]); +``` + +设置每次上传请求的配置参数 +``` +$u->uploadFile( + new Oss\Models\PutObjectRequest( + bucket: 'bucket', + key: 'key' + ), + filepath: '/local/dir/example', + args: [ + 'part_size' => 10 * 1024 * 1024, + ] +); +``` + +示例 + +1. 使用 Uploader上传流 + +``` +... +$client = new Oss\Client($cfg); +$u = $client->newUploader(); +$result = $u->uploadFrom( + new Oss\Models\PutObjectRequest( + bucket: 'bucket', + key: 'key' + ), + stream: new \GuzzleHttp\Psr7\LazyOpenStream('/local/dir/example', 'rb'), +); +printf( + 'upload form status code:' . $result->statusCode . PHP_EOL . + 'upload form request id:' . $result->requestId . PHP_EOL . + 'upload form result:' . var_export($result, true) . PHP_EOL +); +``` + +2. 使用 Uploader上传文件 + +``` +... +$client = new Oss\Client($cfg); +$u = $client->newUploader(); +$result = $u->uploadFile( + new Oss\Models\PutObjectRequest( + bucket: 'bucket', + key: 'key' + ), + filepath: '/local/dir/example', +); +printf( + 'upload file status code:' . $result->statusCode . PHP_EOL . + 'upload file request id:' . $result->requestId . PHP_EOL . + 'upload file result:' . var_export($result, true) . PHP_EOL +); +``` +### 下载管理器(Downloader) + +下载管理器 利用范围下载,把大文件分成多个较小的分片并发下载,提升下载的性能。 + +``` +final class Downloader +{ + ... + public function __construct($client, array $args = []) + + public function downloadFile(Models\GetObjectRequest $request, string $filepath, array $args = []): Models\DownloadResult + + public function downloadTo(Models\GetObjectRequest $request, \Psr\Http\Message\StreamInterface $stream, array $args = []): Models\DownloadResult +} +``` + +**参数列表**: +|参数名|类型|说明 +|:-------|:-------|:------- +|request|GetObjectRequest|下载对象的请求参数,和 GetObject 接口的 请求参数一致 +|filePath|string|本地文件路径 +|args|array|(可选),配置选项 + + +**args选项说明:** +|参数|类型|说明 +|:-------|:-------|:------- +|part_size|int|指定分片大小,默认值为 6MiB +|parallel_num|int|指定上传任务的并发数,默认值为 3。针对的是单次调用的并发限制,而不是全局的并发限制 +|use_temp_file|bool|下载文件时,是否使用临时文件,默认使用。先下载到临时文件上,当成功后,再重命名为目标文件 + +当使用Downloader实例化实例时,您可以指定多个配置选项来自定义对象的下载行为。也可以在每次调用下载接口时,指定多个配置选项来自定义每次下载对象的行为。 + +设置Downloader的配置参数 +``` +$d = $client->newDownloader(['part_size' => 10 * 1024 * 1024]); +``` + +设置每次下载请求的配置参数 +``` +$d->downloadFile( + new Oss\Models\GetObjectRequest( + bucket: 'bucket', + key: 'key' + ), + filepath: '/local/dir/example', + args: ['part_size' => 10 * 1024 * 1024] +); +``` + +示例 + +1. 使用 Downloader 下载到本地文件 + +``` +... +$client = new Oss\Client($cfg); +$d = $client->newDownloader(); +$d->downloadFile( + new Oss\Models\GetObjectRequest( + bucket: 'bucket', + key: 'key' + ), + filepath: '/local/dir/example', +); +``` +2. 使用 Downloader 下载到流中 + +``` +... +$client = new Oss\Client($cfg); +$d = $client->newDownloader(); +$stream = new \GuzzleHttp\Psr7\BufferStream(1 * 1024 * 1024); +$d->downloadTo( + new Oss\Models\GetObjectRequest( + bucket: 'bucket', + key: 'key' + ), + stream: $stream, +); +``` + +### 拷贝管理器(Copier) +当需要将对象从存储空间复制到另外一个存储空间,或者修改对象的属性时,您可以通过拷贝接口 或者分片拷贝接口来完成这个操作。 +
    这两个接口有其适用的场景,例如: +* 拷贝接口(CopyObject) 只适合拷贝 5GiB 以下的对象; +* 分片拷贝接口(UploadPartCopy) 不支持 元数据指令(x-oss-metadata-directive) 和 标签指令(x-oss-tagging-directive) 参数, + 拷贝时,您需要主动去设置需要复制的元数据和标签。 +* 服务端优化了拷贝(CopyObject)接口,使其具备浅拷贝的能力,在特定的场景下也支持拷贝大文件。 + +拷贝管理器提供了通用的拷贝接口,隐藏了接口的差异和实现细节,根据拷贝的请求参数,自动选择合适的接口复制对象。 + +``` +final class Copier +{ + ... + public function __construct($client, array $args = []) + + public function copy(Models\CopyObjectRequest $request, array $args = []): Models\CopyResult +} +``` +**参数列表**: +|参数名|类型|说明 +|:-------|:-------|:------- +|request|CopyObjectRequest|拷贝对象的请求参数,和 CopyObject 接口的 请求参数一致 +|args|array|(可选),配置选项 + + +**args选项说明:** +|参数|类型|说明 +|:-------|:-------|:------- +|part_size|int|指定分片大小,默认值为 64MiB +|parallel_num|int|指定上传任务的并发数,默认值为 3。针对的是单次调用的并发限制,而不是全局的并发限制 +|multipart_copy_threshold|int|使用分片拷贝的阈值,默认值为 200MiB +|leave_parts_on_error|bool|当拷贝失败时,是否保留已拷贝的分片,默认不保留 +|disable_shallow_copy|bool|不使用浅拷贝行为,默认使用 + + +当使用Copier实例化实例时,您可以指定多个配置选项来自定义对象的下载行为。也可以在每次调用下载接口时,指定多个配置选项来自定义每次下载对象的行为。 + +设置Copier的配置参数 +``` +$c = $client->newCopier(['part_size' => 100 * 1024 * 1024]); +``` + +设置每次拷贝请求的配置参数 +``` +$c->copy( + new Oss\Models\CopyObjectRequest( + bucket: 'bucket', + key: 'key', + sourceBucket: 'src-bucket', + sourceKey: 'src-key', + ), + args: ['part_size' => 100 * 1024 * 1024] +); +``` + +> **注意:** +>
    拷贝对象时,CopyObjectRequest 中 metadataDirective 属性决定了对象元数据的拷贝行为,默认 复制 源对象标签 +>
    拷贝对象时,CopyObjectRequest 中 taggingDirective 属性决定了对象标签的拷贝行为,默认 复制 源对象标签 + + +示例 + +1. 拷贝文件,默认会复制 元数据 和 标签 +``` +... +$client = new Oss\Client($cfg); +$c = $client->newCopier(); +$result = $c->copy( + new Oss\Models\CopyObjectRequest( + bucket: 'bucket', + key: 'key', + sourceBucket: 'src-bucket', + sourceKey: 'src-key', + ) +); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); +``` + +2. 拷贝文件,只拷贝数据,不拷贝元数据和标签 +``` +... +$client = new Oss\Client($cfg); +$c = $client->newCopier(); +$result = $c->copy( + new Oss\Models\CopyObjectRequest( + bucket: 'bucket', + key: 'key', + sourceBucket: 'src-bucket', + sourceKey: 'src-key', + metadataDirective: 'Replace', + taggingDirective: 'Replace' + ) +); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); +``` + +3. 修改 对象的存储类型 为标准类型 + +``` +... +$client = new Oss\Client($cfg); +$c = $client->newCopier(); +$result = $c->copy( + new Oss\Models\CopyObjectRequest( + bucket: 'bucket', + key: 'key', + sourceBucket: 'src-bucket', + sourceKey: 'src-key', + storageClass: 'Standard', + ) +); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); +``` +## 客户端加密 + +客户端加密是在数据上传至OSS之前,由用户在本地对数据进行加密处理,确保只有密钥持有者才能解密数据,增强数据在传输和存储过程中的安全性。 + +> **注意:** +>
    使用客户端加密功能时,您需要对主密钥的完整性和正确性负责。 +>
    在对加密数据进行复制或者迁移时,您需要对加密元数据的完整性和正确性负责。 + +如果您需要了解OSS客户端加密实现的原理,请参考OSS用户指南中的[客户端加密](https://www.alibabacloud.com/help/zh/oss/user-guide/client-side-encryption)。 + +使用客户端加密,首先您需要实例化加密客户端,然后调用其提供的接口进行操作。您的对象将作为请求的一部分自动加密和解密。 + +``` +final class EncryptionClient +{ + ... + + public function __construct(Client $client, Crypto\MasterCipherInterface $masterCipher, ?array $decryptMasterCiphers = null) +} +``` + +**参数列表**: +|参数名|类型|说明 +|:-------|:-------|:------- +|client|Client| 非加密客户端实例 +|masterCipher|Crypto\MasterCipherInterface|主密钥实例,用于加密和解密数据密钥 +|decryptMasterCiphers|array|(可选),加密客户端配置选项 + +**返回值列表**: +|返回值名|类型|说明 +|:-------|:-------|:------- +|eclient|EncryptionClient|加密客户端实例 + +**decryptMasterCiphers选项说明:** +|参数|类型|说明 +|:-------|:-------|:------- +|decryptMasterCiphers|array|主密钥实例组, 用于解密数据密钥。 + +**EncryptionClient接口:** +|基础接口名|说明 +|:-------|:------- +|GetObjectMeta|获取对象的部分元信息 +|HeadObject|获取对象的部元信息 +|GetObject|下载对象,并自动解密 +|PutObject|上传对象,并自动加密 +|InitiateMultipartUpload|初始化一个分片上传事件 和 分片加密上下文(EncryptionMultiPartContext) +|UploadPart|初始化一个分片上传事件, 调用该接口上传分片数据,并自动加密。调用该接口时,需要设置 分片加密上下文 +|CompleteMultipartUpload|在将所有分片数据上传完成后,调用该接口合并成一个文件 +|AbortMultipartUpload|取消分片上传事件,并删除对应的分片数据 +|ListParts|列举指定上传事件所属的所有已经上传成功分片 +|**高级接口名**|**说明** +|NewDownloader|创建下载管理器实例 +|NewUploader|创建上传管理器实例 +|**辅助接口名**|**说明** +|Unwrap|获取非加密客户端实例,可以通过该实例访问其它基础接口 + +> **说明:** EncryptionClient 采用了 和 Client 一样的接口命名规则 和 调用方式,有关接口的详细用法,请参考指南的其它章节说明。 + +### 使用RSA主密钥 + +**创建RAS加密客户端** + +``` +use AlibabaCloud\Oss\V2 as Oss; +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion('cn-hangzhou'); +$client = new Oss\Client($cfg); + +// 创建一个主密钥的描述信息,创建后不允许修改。主密钥描述信息和主密钥一一对应。 +// 如果所有的对象都使用相同的主密钥,主密钥描述信息可以为空,但后续不支持更换主密钥。 +// 如果主密钥描述信息为空,解密时无法判断使用的是哪个主密钥。 +// 强烈建议为每个主密钥都配置主密钥描述信息,由客户端保存主密钥和描述信息之间的对应关系。 +$materialDesc['desc'] = 'your master encrypt key material describe information'; + +// 创建只包含 主密钥 的 加密客户端 +$masterCipher = new Oss\Crypto\MasterRsaCipher( + publicKey: "yourRsaPublicKey", + privateKey: "yourRsaPrivateKey", + matDesc: $materialDesc +); +$eclient = new Oss\EncryptionClient($client, $masterCipher); + +// 创建包含主密钥 和 多个解密密钥的 加密客户端 +// 当解密时,先匹配解密密钥的描述信息,如果不匹配,则使用主密钥解密 +//$decryptMC = new Oss\Crypto\MasterRsaCipher( +// // TODO +//); +//$eclient = new Oss\EncryptionClient($client, $masterCipher,[$decryptMC]); +``` + +**使用加密客户端上传或者下载** +``` +... +$eclient = new Oss\EncryptionClient($client, $masterCipher); +// Use PutObject +$eclient->putObject( + new Oss\Models\PutObjectRequest( + bucket: 'bucket', + key: 'key', + body: Oss\Utils::streamFor('hi oss') + ) +); + +// Use GetObject +$eclient->getObject( + new Oss\Models\GetObjectRequest( + bucket: 'bucket', + key: 'key', + ) +); + +// Use Downloader +$d = $eclient->newDownloader(); +$d->downloadFile( + new Oss\Models\GetObjectRequest( + bucket: 'bucket', + key: 'key', + ), + filepath: '/local/dir/example', +); + +// Use Uploader +$u = $eclient->newUploader(); +$u->uploadFile( + new Oss\Models\PutObjectRequest( + bucket: 'bucket', + key: 'key', + body: Oss\Utils::streamFor('hi oss') + ), + filepath: '/local/dir/example', +); +``` + +**使用加密客户端以分片方式上传数据** +
    以上传500K内存数据为例 +``` +... +$eclient = new Oss\EncryptionClient($client, $masterCipher); +$partSize = 200 * 1024; +$length = 500 * 1024; +$bucket = 'bucket'; +$key = 'key'; +// 文件的大小是 500 * 1024 +$fileName = '/local/dir/example'; + +// 加密客户端 需要 设置分片大小和总文件大小 +$initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + bucket: $bucket, + key: $key, + cseDataSize: $length, + csePartSize: $partSize + ) +); + +$file = fopen($fileName, 'r'); +$parts = array(); +if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $eclient->uploadPart(new Oss\Models\UploadPartRequest( + bucket: $bucket, + key: $key, + partNumber: $i, + uploadId: $initResult->uploadId, + contentLength: strlen($chunk), + body: Oss\Utils::streamFor($chunk), + encryptionMultipartContext: $initResult->encryptionMultipartContext, + )); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); +} +$comResult = $eclient->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + bucket: $bucket, + key: $key, + uploadId: $initResult->uploadId, + completeMultipartUpload: new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) +); +``` +### 使用自定义主密钥 +当RSA主密钥方式无法满足需求时,您可自定主密钥的加密实现。主密钥的接口定义如下: +``` +interface MasterCipherInterface +{ + public function encrypt(string $data): string; + + public function decrypt(string $data): string; + + public function getWrapAlgorithm(): string; + + public function getMatDesc(): string; +} +``` +**MasterCipher接口说明** +|接口名|说明 +|:-------|:------- +|encrypt|加密 数据加密密钥 和 加密数据的初始值(IV) +|decrypt|解密 数据加密密钥 和 加密数据的初始值(IV) +|getWrapAlgorithm|返回 数据密钥的加密算法信息,建议采用 算法/模式/填充 格式,例如RSA/NONE/PKCS1Padding +|getMatDesc|返回 主密钥的描述信息,JSON格式 + +例如 + +``` +... +final class MasterCustomCipher implements Oss\Crypto\MasterCipherInterface +{ + private $matDesc; + + private ?string $secrectKey; + + public function __construct( + $matDesc = null, + ?string $secrectKey = null + ) + { + $this->secrectKey = $secrectKey; + $this->matDesc = null; + if (\is_array($matDesc)) { + $val = json_encode($matDesc); + if ($val !== false) { + $this->matDesc = $val; + } + } else if (is_string($matDesc)) { + $this->matDesc = $matDesc; + } + } + + public function encrypt(string $data): string + { + // TODO + } + + public function decrypt(string $data): string + { + // TODO + } + + public function getWrapAlgorithm(): string + { + return "Custom/None/NoPadding"; + } + + public function getMatDesc(): string + { + return $this->matDesc; + } +} + +$client = new Oss\Client($cfg); +$materialDesc['desc'] = 'your master encrypt key material describe information'; +$masterCipher = new MasterCustomCipher( + matDesc: $materialDesc, + secrectKey: "yourSecrectKey" +); +$eclient = new Oss\EncryptionClient($client, $masterCipher); +``` + +## 其它接口 + +为了方便用户使用,封装了一些易用性接口。当前扩展的接口如下: + +|接口名 | 说明 +|:-------|:------- +|isObjectExist|判断对象(object)是否存在 +|isBucketExist|判断存储空间(bucket)是否存在 +|putObjectFromFile|上传本地文件到存储空间 +|getObjectToFile|下载对象到本地文件 + +### isObjectExist/isBucketExist + +这两个接口的返回值为 bool 如果bool 为 true,表示存在,如果 bool值为 false,表示不存在。当抛出异常 时,表示无法从该错误信息判断 是否存在。 + +``` +public function isObjectExist(string $bucket, string $key, ?string $versionId = null, array $args = []): bool +public function isBucketExist(string $bucket, array $args = []): bool +``` + +例如 判断对象是否存在 + +``` +client := oss.NewClient(cfg) + +$existed = $client->isObjectExist( bucket: "examplebucket", key: "exampleobject"); +//$existed = $client->isObjectExist( bucket: 'examplebucket', key: 'exampleobject',versionId: 'versionId'); + +printf('object existed :%s',var_export($existed,true)); +``` + +### PutObjectFromFile + +使用简单上传(PutObject)接口 把本地文件上传到存储空间,该接口不支持并发。 + +``` +public function putObjectFromFile(Models\PutObjectRequest $request, string $filePath, array $args = []): Models\PutObjectResult +``` + +示例 + +``` +... +$client = new Oss\Client($cfg); + +$result = $client->putObjectFromFile( + new Oss\Models\PutObjectRequest( + bucket: 'examplebucket', + key: 'exampleobject', + ), + filePath: '/local/dir/example' +); +``` + +### GetObjectToFile + +使用GetObject接口,把存储空间的对象下载到本地文件,该接口不支持并发。 + +``` +public function getObjectToFile(Models\GetObjectRequest $request, string $filePath, array $args = []): Models\GetObjectResult +``` + +示例 + +``` +... +$client = new Oss\Client($cfg); + +$client->getObjectToFile( + new Oss\Models\GetObjectRequest( + bucket: 'examplebucket', + key: 'exampleobject', + ), + filePath: '/local/dir/example' +); +``` + +## 上传下载接口对比 + +提供了各种上传下载接口,您可以根据使用场景,选择适合的接口。 + +**上传接口** +|接口名 | 说明 +|:-------|:------- +|putObject|简单上传, 最大支持5GiB +|putObjectFromFile|与putObject接口能力一致
    请求body数据来源于文件路径 +|分片上传接口
    initiateMultipartUpload
    uploadPart
    completeMultipartUpload|分片上传,单个分片最大5GiB,文件最大48.8TiB +|uploadFrom|封装了简单上传 和 分片上传接口,最大支持48.8TiB +|uploadFile|与uploadFrom接口能力一致
    请求body数据来源于文件路径 +|appendObject|追加上传, 最终文件最大支持5GiB + +**下载接口** +|接口名| 说明 +|:-------|:------- +|getObject|流式下载, 响应体为StreamInterface类型 +|getObjectToFile|下载到本地文件
    单连接下载 +|downloadFile|采用分片方式下载到本地文件
    支持自定义分片大小和并发数 +# 场景示例 + +本部分将从使用场景出发, 介绍如何使用SDK。 + +包含的主题 +* [数据校验](#数据校验) + +OSS提供基于MD5的数据校验,确保请求的过程中的数据完整性。 + +## MD5校验 + +当向OSS发送请求时,如果设置了Content-MD5,OSS会根据接收的内容计算MD5。当OSS计算的MD5值和上传提供的MD5值不一致时,则返回InvalidDigest异常,从而保证数据的完整性。 + +基础接口里, 除了PutObject, AppendObject, UploadPart 接口外,会自动计算MD5, 并设置Content-MD5, 保证请求的完整性。 + +如果您需要在 PutObject, AppendObject, UploadPart 接口里使用MD5校验,可以参考以下写法 + +``` +... +$client = new Oss\Client($cfg); + +$body = Oss\Utils::streamFor('hi oss'); +$result = $client->putObject( + new Oss\Models\PutObjectRequest( + bucket: 'demo-1889', + key: 'demo', + contentMd5: base64_encode(md5($body, true)), + body: $body + )); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); +``` +# 迁移指南 + +本部分介绍如何从V1 版本([aliyun-oss-php-sdk](https://github.com/aliyun/aliyun-oss-php-sdk)) 迁移到 V2 版本。 +## 最低 PHP 版本 + +V2 版本 要求 PHP 版本最低为 7.4。 +## 导入路径 + +V2 版本使用新的代码仓库,同时也对代码结构进行了调整,按照功能模块组织,以下是这些模块路径和说明: + +|模块路径 | 说明 +|:-------|:------- +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src|SDK核心,接口 和 高级接口实现 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Credentials|访问凭证相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Retry|重试相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Signer|签名相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Annotation|tag,xml 转换相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Crypto|客户端加密相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Models|请求对象,返回对象相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Paginator|列表分页器相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Exception|异常类型相关 +|github.com/aliyun/alibabacloud-oss-php-sdk-v2/src/Types|类型相关 + +示例 + +``` +// v1 +require_once 'vendor/autoload.php'; +use OSS\OssClient; +``` + +``` +// v2 +require_once 'vendor/autoload.php'; + +use AlibabaCloud\Oss\V2 as Oss; +``` + +## 配置加载 + +V2 版本简化了配置设置方式,全部迁移到 [config](src/Config.php) 下,并提供了以set为前缀的辅助函数,方便以编程方式覆盖缺省配置。 + +V2 默认使用 V4签名,所以必须配置区域(Region)。 + +V2 支持从区域(Region)信息构造 访问域名(Endpoint), 当访问的是公有云时,可以不设置Endpoint。 + +示例 + +``` +// v1 +require_once 'vendor/autoload.php'; +use OSS\OssClient; +... + +// 环境变量中获取访问凭证 +$provider = new \OSS\Credentials\EnvironmentVariableCredentialsProvider(); + +// Endpoint +$endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; + +$config = array( + "provider" => $provider, + "endpoint" => $endpoint, + "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, + "region" => "cn-hangzhou" + ); +$ossClient = new OssClient($config); +// 不校验SSL证书校验 +$ossClient->setUseSSL(false); +``` + +``` +// v2 +require_once 'vendor/autoload.php'; +use AlibabaCloud\Oss\V2 as Oss; +... + +// 环境变量中获取访问凭证 +$provider = new \OSS\Credentials\EnvironmentVariableCredentialsProvider(); + +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +// 设置HTTP连接超时时间为20秒 +$cfg->setConnectTimeout(20); +// HTTP读取或写入超时时间为60秒 +$cfg->setReadWriteTimeout(60); +// 不校验SSL证书校验 +$cfg->setDisableSSL(true); +// 设置区域 +$cfg->setRegion('cn-hangzhou'); +$client = new Oss\Client($cfg); +``` + +## 创建Client + +V2 版本 把 Client 的创建 函数 从 New 修改 为 NewClient, 同时 创建函数 不在支持传入Endpoint 以及 access key id 和 access key secrect 参数。 + +示例 + +``` +// v1 +$endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; + +$config = array( + "provider" => $provider, + "endpoint" => $endpoint, + "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, + "region" => "cn-hangzhou" +); +$ossClient = new OssClient($config); + +or + +$ossClient = new OssClient('accessKeyId','accessKeySecret','endpoint'); +``` + +``` +// v2 +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion('cn-hangzhou'); +$ossClient = new Oss\Client($cfg); +``` + +## 调用API操作 + +基础 API 接口 都 合并为 单一操作方法 '\',操作的请求参数为 '\Request',操作的返回值为 '\Result'。这些操作方法都 迁移到 Client下,如下格式: + +``` +public function (Models\Request $request, array $args = []): Models\Result +public function Async(Models\Request $request, array $args = []): \GuzzleHttp\Promise\Promise +``` + +关于API接口的详细使用说明,请参考[基础接口](#基础接口)。 + +示例 + +``` +// v1 +require_once 'vendor/autoload.php'; +use OSS\OssClient; +$provider = new \OSS\Credentials\EnvironmentVariableCredentialsProvider(); +$endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; +$config = array( + "provider" => $provider, + "endpoint" => $endpoint, + "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, + "region" => "cn-hangzhou" +); +$ossClient = new OssClient($config); +$ossClient->putObject('examplebucket','exampleobject.txt','example data'); +``` + +``` +// v2 +require_once 'vendor/autoload.php'; +use AlibabaCloud\Oss\V2 as Oss; + +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion('cn-hangzhou'); +$ossClient = new Oss\Client($cfg); + +$client->putObject( + new Oss\Models\PutObjectRequest( + bucket: 'examplebucket', + key: 'exampleobject.txt', + body: Oss\Utils::streamFor('example data'), + ), +); +``` + +## 预签名 + +V2 版本 把 预签名接口 名字从 signUrl 修改为 presign,接口形式如下: + +``` +public function presign(request: $request,args: $options): Models\PresignResult +``` +对于 request 参数,其类型 与 API 接口中的 '\Request' 一致。 + +对于返回结果,除了返回 预签名 URL 外,还返回 HTTP 方法,过期时间 和 被签名的请求头,如下: +``` +final class PresignResult +{ + public ?string $method; + + public ?string $url; + + public ?\DateTime $expiration; + + public ?array $signedHeaders; +} +``` + +关于预签名的详细使用说明,请参考[预签名接口](#预签名接口)。 + +以 生成下载对象的预签名URL 为例,如何从 V1 迁移到 V2 + +``` +// v1 +require_once 'vendor/autoload.php'; +use OSS\OssClient; +$provider = new \OSS\Credentials\EnvironmentVariableCredentialsProvider(); +$endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; +$config = array( + "provider" => $provider, + "endpoint" => $endpoint, + "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, + "region" => "cn-hangzhou" +); +$ossClient = new OssClient($config); +$url = $ossClient->signUrl('examplebucket','exampleobject.txt',60,OssClient::OSS_HTTP_GET); + +printf("Sign Url:%s\n", $url); +``` +``` +// v2 +require_once 'vendor/autoload.php'; +use AlibabaCloud\Oss\V2 as Oss; + +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion('cn-hangzhou'); +$ossClient = new Oss\Client($cfg); + +$result = $ossClient->presign( + new Oss\Models\GetObjectRequest( + bucket: 'examplebucket', + key: 'exampleobject.txt', + ), + args: ['expiration' => (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT60S'))], +); +print( + 'sign url:' . $result->url . PHP_EOL . + 'sign method :' . $result->method . PHP_EOL . + 'sign expiration:' . var_export($result->expiration, true) . PHP_EOL . + 'sign headers:' . var_export($result->signedHeaders, true) . PHP_EOL +); +``` \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/DEVGUIDE.md b/vendor/alibabacloud/oss-v2/DEVGUIDE.md new file mode 100644 index 0000000..e69de29 diff --git a/vendor/alibabacloud/oss-v2/LICENSE b/vendor/alibabacloud/oss-v2/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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/vendor/alibabacloud/oss-v2/README-CN.md b/vendor/alibabacloud/oss-v2/README-CN.md new file mode 100644 index 0000000..7ab3bc5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/README-CN.md @@ -0,0 +1,146 @@ +# Alibaba Cloud OSS SDK for PHP v2 + +[![GitHub version](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-php-sdk-v2.svg)](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-php-sdk-v2) + +alibabacloud-oss-php-sdk-v2 是OSS在PHP编译语言下的第二版SDK + +## [English](README.md) + +## 关于 +> - 此PHP SDK基于[阿里云对象存储服务](http://www.aliyun.com/product/oss/)官方API构建。 +> - 阿里云对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量,安全,低成本,高可靠的云存储服务。 +> - OSS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。 +> - 使用此SDK,用户可以方便地在任何应用、任何时间、任何地点上传,下载和管理数据。 + +## 运行环境 +> - PHP 7.4及以上。 + +## 安装方法 +### 通过 composer 安装 +如果您通过composer管理您的项目依赖,可以在你的项目根目录运行: +```bash +$ composer require alibabacloud/oss-v2 +``` +或者在你的`composer.json`中声明对Alibaba Cloud OSS SDK for PHP v2的依赖: +```php +"require": { + "alibabacloud/oss-v2": "*" +} +``` +然后通过`composer install`安装依赖 + +### 通过[PHAR 文件](https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/releases)安装 +```bash +require_once '/path/to/alibabacloud-oss-php-sdk-v2-{version}.phar' +``` + +## 快速使用 +#### 获取存储空间列表(List Bucket) +```php +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); + +$client = new Oss\Client($cfg); + +// Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListBucketsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListBucketsRequest()); + +// Iterate through the bucket pages +foreach ($iter as $page) { + foreach ($page->buckets ?? [] as $bucket) { + print("Bucket: $bucket->name, $bucket->location\n"); + } +} +``` + +#### 获取文件列表(List Objects) +```php +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); + +$client = new Oss\Client($cfg); + +# Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListObjectsV2Paginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListObjectsV2Request($bucket)); + +// Iterate through the object pages +foreach ($iter as $page) { + foreach ($page->contents ?? [] as $object) { + print("Object: $object->key, $object->type, $object->size\n"); + } +} +``` + +#### 上传文件(Put Object) +```php +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); + +$client = new Oss\Client($cfg); + +$data = 'Hello OSS'; + +$request = new Oss\Models\PutObjectRequest($bucket, $key); +$request->body = Oss\Utils::streamFor($data); + +$result = $client->putObject($request); + +printf( + 'status code:'. $result->statusCode .PHP_EOL. + 'request id:'. $result->requestId .PHP_EOL. + 'etag:'. $result->etag. PHP_EOL +); +``` + +## 更多示例 +请参看`sample`目录 + +### 运行示例 +> - 执行`composer install`下载依赖的库 +> - 进入示例程序目录 `sample`。 +> - 通过环境变量,配置访问凭证, `export OSS_ACCESS_KEY_ID="your access key id"`, `export OSS_ACCESS_KEY_SECRET="your access key secrect"` +> - 以 ListBuckets.php 为例,执行 `php ListBuckets.php --region cn-hangzhou`。 + +## 资源 +[开发者指南](DEVGUIDE-CN.md) - 参阅该指南,来帮助您安装、配置和使用该开发套件。 + +## 许可协议 +> - Apache-2.0, 请参阅 [许可文件](LICENSE) \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/README.md b/vendor/alibabacloud/oss-v2/README.md new file mode 100644 index 0000000..56d35ef --- /dev/null +++ b/vendor/alibabacloud/oss-v2/README.md @@ -0,0 +1,146 @@ +# Alibaba Cloud OSS SDK for PHP v2 + +[![GitHub version](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-php-sdk-v2.svg)](https://badge.fury.io/gh/aliyun%2Falibabacloud-oss-php-sdk-v2) + +alibabacloud-oss-php-sdk-v2 is the v2 of the OSS SDK for the PHP programming language + +## [简体中文](README-CN.md) + +## About +> - This PHP SDK is based on the official APIs of [Alibaba Cloud OSS](http://www.aliyun.com/product/oss/). +> - Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring massive capacity, security, a low cost, and high reliability. +> - The OSS can store any type of files and therefore applies to various websites, development enterprises and developers. +> - With this SDK, you can upload, download and manage data on any app anytime and anywhere conveniently. + +## Running Environment +> - PHP 7.4 or above. + +## Installing +### Install the sdk through composer +If you use the composer to manage project dependencies, run the following command in your project's root directory: +```bash +$ composer require alibabacloud/oss-v2 +``` +You can also declare the dependency on Alibaba Cloud OSS SDK for PHP v2 in the composer.json file. +```json +"require": { + "alibabacloud/oss-v2": "*" +} +``` + +### Install from the [PHAR File](https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/releases) directly +```bash +$ require_once '/path/to/alibabacloud-oss-php-sdk-v2-{version}.phar' +``` + + +## Getting Started +#### List Bucket +```php +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); + +$client = new Oss\Client($cfg); + +// Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListBucketsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListBucketsRequest()); + +// Iterate through the bucket pages +foreach ($iter as $page) { + foreach ($page->buckets ?? [] as $bucket) { + print("Bucket: $bucket->name, $bucket->location\n"); + } +} +``` + +#### List Objects +```php +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); + +$client = new Oss\Client($cfg); + +# Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListObjectsV2Paginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListObjectsV2Request($bucket)); + +// Iterate through the object pages +foreach ($iter as $page) { + foreach ($page->contents ?? [] as $object) { + print("Object: $object->key, $object->type, $object->size\n"); + } +} +``` + +#### Put Object +```php +setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); + +$client = new Oss\Client($cfg); + +$data = 'Hello OSS'; + +$request = new Oss\Models\PutObjectRequest($bucket, $key); +$request->body = Oss\Utils::streamFor($data); + +$result = $client->putObject($request); + +printf( + 'status code:'. $result->statusCode .PHP_EOL. + 'request id:'. $result->requestId .PHP_EOL. + 'etag:'. $result->etag. PHP_EOL +); +``` + +## Complete Example +More example projects can be found in the `sample` folder + +### Running Example +> - Run `composer install` to download the dependent libraries. +> - Go to the sample code folder `sample`。 +> - Configure credentials values from the environment variables, like `export OSS_ACCESS_KEY_ID="your access key id"`, `export OSS_ACCESS_KEY_SECRET="your access key secrect"` +> - Take ListBuckets.php as an example,run `php ListBuckets.php --region cn-hangzhou` command。 + +## Resources +[Developer Guide](DEVGUIDE-CN.md) - Use this document to learn how to get started and use this sdk. + +## License +> - Apache-2.0, see [license file](LICENSE) \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/autoload.php b/vendor/alibabacloud/oss-v2/autoload.php new file mode 100644 index 0000000..ec13201 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/autoload.php @@ -0,0 +1,11 @@ + + + + + + src + + + + + + + + + + ./tests/UnitTests/Exception + ./tests/UnitTests/Retry + ./tests/UnitTests/Signer + ./tests/UnitTests/Types + ./tests/UnitTests/Crypto + ./tests/UnitTests/Credentials + ./tests/UnitTests/ClientImplTest.php + ./tests/UnitTests/UtilsTest.php + ./tests/UnitTests/ValidationTest.php + ./tests/UnitTests/Transform/BucketBasicTest.php + ./tests/UnitTests/Transform/FunctionsTest.php + ./tests/UnitTests/Transform/ObjectMultipartTest.php + ./tests/UnitTests/Transform/ObjectBasicTest.php + + ./tests/UnitTests/ + + + + ./tests/IntegrationTests/ClientBucketBasicTest.php + ./tests/IntegrationTests/ClientObjectMultipartTest.php + ./tests/IntegrationTests/ClientMiscTest.php + ./tests/IntegrationTests/ClientExtensionTest.php + ./tests/IntegrationTests/ClientObjectBasicTest.php + ./tests/IntegrationTests/ClientPaginatorTest.php + ./tests/IntegrationTests/ClientPresignerTest.php + ./tests/IntegrationTests/EncryptionClientTest.php + + ./tests/IntegrationTests + + + diff --git a/vendor/alibabacloud/oss-v2/sample/AbortBucketWorm.php b/vendor/alibabacloud/oss-v2/sample/AbortBucketWorm.php new file mode 100644 index 0000000..c8a9927 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/AbortBucketWorm.php @@ -0,0 +1,45 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\AbortBucketWormRequest($bucket); +$result = $client->abortBucketWorm($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/AbortMultipartUpload.php b/vendor/alibabacloud/oss-v2/sample/AbortMultipartUpload.php new file mode 100644 index 0000000..87975ee --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/AbortMultipartUpload.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "upload-id" => ['help' => 'The upload id', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$uploadId = $options["upload-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\AbortMultipartUploadRequest($bucket, $key); +$request->uploadId = $uploadId; +$result = $client->abortMultipartUpload($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/AppendObject.php b/vendor/alibabacloud/oss-v2/sample/AppendObject.php new file mode 100644 index 0000000..8b0bbc2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/AppendObject.php @@ -0,0 +1,54 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$data = 'Hello Append Object'; + +$request = new Oss\Models\AppendObjectRequest($bucket, $key); +$request->body = Oss\Utils::streamFor($data); +$request->position = 0; + +$result = $client->appendObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/AsyncProcessObject.php b/vendor/alibabacloud/oss-v2/sample/AsyncProcessObject.php new file mode 100644 index 0000000..12376c0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/AsyncProcessObject.php @@ -0,0 +1,59 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$style = "video/convert,f_avi,vcodec_h265,s_1920x1080,vb_2000000,fps_30,acodec_aac,ab_100000,sn_1"; +$process = sprintf("%s|sys/saveas,b_%s,o_%s", + $style, + rtrim(base64_encode($bucket), '='), + rtrim(base64_encode($key), '=') +); + +$request = new Oss\Models\AsyncProcessObjectRequest($bucket, $key); +$request->process = $process; + +$result = $client->asyncProcessObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'async process result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/CleanRestoredObject.php b/vendor/alibabacloud/oss-v2/sample/CleanRestoredObject.php new file mode 100644 index 0000000..b067623 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CleanRestoredObject.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\CleanRestoredObjectRequest($bucket, $key); +$result = $client->cleanRestoredObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/CloseMetaQuery.php b/vendor/alibabacloud/oss-v2/sample/CloseMetaQuery.php new file mode 100644 index 0000000..3e15141 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CloseMetaQuery.php @@ -0,0 +1,45 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new \AlibabaCloud\Oss\V2\Models\CloseMetaQueryRequest($bucket); +$result = $client->closeMetaQuery($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/CompleteMultipartUpload.php b/vendor/alibabacloud/oss-v2/sample/CompleteMultipartUpload.php new file mode 100644 index 0000000..2459358 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CompleteMultipartUpload.php @@ -0,0 +1,125 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "upload-id" => ['help' => 'The upload id', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$uploadId = $options["upload-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\UploadPartRequest($bucket, $key); +$bigFileName = "upload.tmp"; +$partSize = 200 * 1024; +generateFile($bigFileName, 500 * 1024); +$file = fopen($bigFileName, 'r'); +$parts = array(); +if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + $bucket, + $key, + $i, + $uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); +} +$comResult = $client->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + $bucket, + $key, + $uploadId, + null, + new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) +); +unlink($bigFileName); +printf( + 'status code:' . $comResult->statusCode . PHP_EOL . + 'request id:' . $comResult->requestId . PHP_EOL . + 'complete multipart upload result:' . var_export($comResult, true) +); + +function generateFile($filename, $size) +{ + if ( + file_exists($filename) && + $size == sprintf('%u', filesize($filename)) + ) { + return; + } + $part_size = 32; + $fp = fopen($filename, "w"); + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $charactersLength = strlen($characters); + if ($fp) { + while ($size > 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + break; + } + } + } + fclose($fp); +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/Copier.php b/vendor/alibabacloud/oss-v2/sample/Copier.php new file mode 100644 index 0000000..ffb4054 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/Copier.php @@ -0,0 +1,120 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "src-key" => ['help' => 'The name of the source object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$srcKey = $options["src-key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$copier = $client->newCopier(); + +// case 1, empty metadata & tagging +$dstKey = "multipart-copy-repalce-empty-metadata-and-tagging-$key.js"; +$copyRequest = new Oss\Models\CopyObjectRequest( + $bucket, + $dstKey, + $bucket, + $srcKey +); +$copyRequest->metadataDirective = 'REPLACE'; +$copyRequest->taggingDirective = 'REPLACE'; +$result = $copier->copy( + $copyRequest, + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true + ] +); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); + +// case 2, has metadata & tagging +$dstKey = "multipart-copy-repalce-metadata-and-tagging-$key.js"; +$copyRequest = new Oss\Models\CopyObjectRequest( + $bucket, + $dstKey, + $bucket, + $srcKey +); +$copyRequest->metadataDirective = 'REPLACE'; +$copyRequest->taggingDirective = 'REPLACE'; +$copyRequest->contentType = 'text/txt'; +$copyRequest->cacheControl = 'cache-123'; +$copyRequest->contentDisposition = 'contentDisposition'; +$copyRequest->expires = '123'; +$copyRequest->metadata = ['test1' => 'val1', 'test2' => 'value2']; +$copyRequest->tagging = 'k3=v3&k4=v4'; +$result = $copier->copy( + $copyRequest, + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true + ] +); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); + +// multipart copy, 'copy' directive +$copyRequest = new Oss\Models\CopyObjectRequest( + $bucket, + $dstKey, + $bucket, + $srcKey +); +$copyRequest->contentType = 'text/txt'; +$copyRequest->cacheControl = 'cache-123'; +$copyRequest->contentDisposition = 'contentDisposition'; +$copyRequest->expires = '123'; +$copyRequest->metadata = ['test1' => 'val1', 'test2' => 'value2']; +$copyRequest->tagging = 'k3=v3&k4=v4'; +$result = $copier->copy( + $copyRequest, + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true + ] +); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/CopyObject.php b/vendor/alibabacloud/oss-v2/sample/CopyObject.php new file mode 100644 index 0000000..df1aea5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CopyObject.php @@ -0,0 +1,57 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "src-bucket" => ['help' => 'The name of the source bucket', 'required' => False], + "src-key" => ['help' => 'The name of the source object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$srcKey = $options["src-key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\CopyObjectRequest($bucket, $key); +if (!empty($options["src-bucket"])) { + $request->sourceBucket = $options["src-bucket"]; +} +$request->sourceKey = $srcKey; + +$result = $client->copyObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/CreateAccessPoint.php b/vendor/alibabacloud/oss-v2/sample/CreateAccessPoint.php new file mode 100644 index 0000000..b5f61df --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CreateAccessPoint.php @@ -0,0 +1,52 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$accessPointName = 'ap-01'; +$config = new Oss\Models\CreateAccessPointConfiguration(); +$config->accessPointName = $accessPointName; +$config->networkOrigin = 'internet'; +$request = new Oss\Models\CreateAccessPointRequest($bucket, $config); +$result = $client->createAccessPoint($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'create access point:' . var_export($result->createAccessPoint, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/CreateBucketDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/sample/CreateBucketDataRedundancyTransition.php new file mode 100644 index 0000000..e5a51ba --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CreateBucketDataRedundancyTransition.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\CreateBucketDataRedundancyTransitionRequest($bucket, 'ZRS'); +$result = $client->createBucketDataRedundancyTransition($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'task id:' . $result->bucketDataRedundancyTransition->taskId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/CreateCnameToken.php b/vendor/alibabacloud/oss-v2/sample/CreateCnameToken.php new file mode 100644 index 0000000..339c820 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/CreateCnameToken.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\CreateCnameTokenRequest($bucket, new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) +)); +$result = $client->createCnameToken($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'cname token:' . var_export($result->cnameToken, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteAccessPoint.php b/vendor/alibabacloud/oss-v2/sample/DeleteAccessPoint.php new file mode 100644 index 0000000..20afd80 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteAccessPoint.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$accessPointName = 'ap-01'; +$request = new Oss\Models\DeleteAccessPointRequest($bucket, $accessPointName); +$result = $client->deleteAccessPoint($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucket.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucket.php new file mode 100644 index 0000000..1a22d2f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucket.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\DeleteBucketRequest($bucket); +$result = $client->deleteBucket($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketCors.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketCors.php new file mode 100644 index 0000000..6fcff22 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketCors.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketCorsRequest($bucket); +$result = $client->deleteBucketCors($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketDataRedundancyTransition.php new file mode 100644 index 0000000..c26cad7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketDataRedundancyTransition.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "task-id" => ['help' => 'The Id of the redundancy change task.', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$taskId = $options["task-id"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketDataRedundancyTransitionRequest($bucket, $taskId); +$result = $client->deleteBucketDataRedundancyTransition($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketEncryption.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketEncryption.php new file mode 100644 index 0000000..fcb9524 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketEncryption.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketEncryptionRequest($bucket); +$result = $client->deleteBucketEncryption($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketInventory.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketInventory.php new file mode 100644 index 0000000..684c6ad --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketInventory.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$inventoryId = 'test-inventory-id'; +$request = new Oss\Models\DeleteBucketInventoryRequest( + $bucket, + inventoryId: $inventoryId +); +$result = $client->deleteBucketInventory($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketLifecycle.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketLifecycle.php new file mode 100644 index 0000000..d3b3a37 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketLifecycle.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketLifecycleRequest($bucket); +$result = $client->deleteBucketLifecycle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketLogging.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketLogging.php new file mode 100644 index 0000000..4b55268 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketLogging.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketLoggingRequest($bucket); +$result = $client->deleteBucketLogging($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketOverwrite.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketOverwrite.php new file mode 100644 index 0000000..4ebe9b2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketOverwrite.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketOverwriteConfigRequest($bucket); +$result = $client->deleteBucketOverwriteConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketPolicy.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketPolicy.php new file mode 100644 index 0000000..f0db4ad --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketPolicy.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketPolicyRequest($bucket); +$result = $client->deleteBucketPolicy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketPublicAccessBlock.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketPublicAccessBlock.php new file mode 100644 index 0000000..0b24f1f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketPublicAccessBlock.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketPublicAccessBlockRequest($bucket); +$result = $client->deleteBucketPublicAccessBlock($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketReplication.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketReplication.php new file mode 100644 index 0000000..20523c0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketReplication.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "rule-id" => ['help' => 'The replication rule id of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$ruleId = $options["rule-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketReplicationRequest($bucket, replicationRules: new Oss\Models\ReplicationRules( + ids: [$ruleId] +)); +$result = $client->deleteBucketReplication($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketTags.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketTags.php new file mode 100644 index 0000000..ba3b0ec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketTags.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketTagsRequest($bucket); +$result = $client->deleteBucketTags($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteBucketWebsite.php b/vendor/alibabacloud/oss-v2/sample/DeleteBucketWebsite.php new file mode 100644 index 0000000..c4e18f0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteBucketWebsite.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteBucketWebsiteRequest($bucket); +$result = $client->deleteBucketWebsite($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteCname.php b/vendor/alibabacloud/oss-v2/sample/DeleteCname.php new file mode 100644 index 0000000..3be8fce --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteCname.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteCnameRequest($bucket, new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) +)); +$result = $client->deleteCname($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteMultipleObjects.php b/vendor/alibabacloud/oss-v2/sample/DeleteMultipleObjects.php new file mode 100644 index 0000000..f65ebf2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteMultipleObjects.php @@ -0,0 +1,57 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "keys" => ['help' => 'The name of the objects', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$keys = $options["keys"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\DeleteMultipleObjectsRequest($bucket); +$objects = explode(',', $keys); +$deleteObjects = []; +foreach ($objects as $key => $object) { + $deleteObjects[] = new Oss\Models\DeleteObject($object); +} +$request->objects = $deleteObjects; + +$result = $client->deleteMultipleObjects($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'deleted objects' . var_export($result->deletedObjects, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteObject.php b/vendor/alibabacloud/oss-v2/sample/DeleteObject.php new file mode 100644 index 0000000..92e850f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteObject.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\DeleteObjectRequest($bucket, $key); + +$result = $client->deleteObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteObjectTagging.php b/vendor/alibabacloud/oss-v2/sample/DeleteObjectTagging.php new file mode 100644 index 0000000..0dfe457 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteObjectTagging.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteObjectTaggingRequest($bucket, $key); +$result = $client->deleteObjectTagging($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeletePublicAccessBlock.php b/vendor/alibabacloud/oss-v2/sample/DeletePublicAccessBlock.php new file mode 100644 index 0000000..ef50c0b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeletePublicAccessBlock.php @@ -0,0 +1,44 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeletePublicAccessBlockRequest(); +$result = $client->deletePublicAccessBlock($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteStyle.php b/vendor/alibabacloud/oss-v2/sample/DeleteStyle.php new file mode 100644 index 0000000..6d402ec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteStyle.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteStyleRequest( + $bucket, + styleName: 'test', +); +$result = $client->deleteStyle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeleteUserDefinedLogFieldsConfig.php b/vendor/alibabacloud/oss-v2/sample/DeleteUserDefinedLogFieldsConfig.php new file mode 100644 index 0000000..f12ee9f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeleteUserDefinedLogFieldsConfig.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\DeleteUserDefinedLogFieldsConfigRequest($bucket); +$result = $client->deleteUserDefinedLogFieldsConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/DeletetAccessPointPolicy.php b/vendor/alibabacloud/oss-v2/sample/DeletetAccessPointPolicy.php new file mode 100644 index 0000000..41a59f6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DeletetAccessPointPolicy.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$accessPointName = 'ap-01'; +$request = new Oss\Models\DeleteAccessPointPolicyRequest($bucket, $accessPointName); +$result = $client->deleteAccessPointPolicy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/DescribeRegions.php b/vendor/alibabacloud/oss-v2/sample/DescribeRegions.php new file mode 100644 index 0000000..05a97ae --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DescribeRegions.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\DescribeRegionsRequest(); + +$result = $client->describeRegions($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); diff --git a/vendor/alibabacloud/oss-v2/sample/DoMetaQuery.php b/vendor/alibabacloud/oss-v2/sample/DoMetaQuery.php new file mode 100644 index 0000000..eb203fd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/DoMetaQuery.php @@ -0,0 +1,80 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +// case 1:meta search +$request = new \AlibabaCloud\Oss\V2\Models\DoMetaQueryRequest($bucket, new \AlibabaCloud\Oss\V2\Models\MetaQuery( + maxResults: 5, + query: "{'Field': 'Size','Value': '1048576','Operation': 'gt'}", + sort: 'Size', + order: \AlibabaCloud\Oss\V2\Models\MetaQueryOrderType::ASC, + aggregations: new \AlibabaCloud\Oss\V2\Models\MetaQueryAggregations( + [ + new \AlibabaCloud\Oss\V2\Models\MetaQueryAggregation( + field: 'Size', + operation: 'sum' + ), + new \AlibabaCloud\Oss\V2\Models\MetaQueryAggregation( + field: 'Size', + operation: 'max' + ), + ] +), +)); +$result = $client->doMetaQuery($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); + +// case 2: ai search +/*$request = new Oss\Models\DoMetaQueryRequest($bucket, new Oss\Models\MetaQuery( + maxResults: 99, + query: "Overlook the snow-covered forest", + mediaTypes: new Oss\Models\MetaQueryMediaTypes('image'), + simpleQuery: '{"Operation":"gt", "Field": "Size", "Value": "30"}', +), 'semantic'); + +$result = $client->doMetaQuery($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +);*/ \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/Downloader.php b/vendor/alibabacloud/oss-v2/sample/Downloader.php new file mode 100644 index 0000000..7803520 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/Downloader.php @@ -0,0 +1,71 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$downloader = $client->newDownloader(); + +// download to +$stream = new \GuzzleHttp\Psr7\BufferStream(1 * 1024 * 1024); +$result = $downloader->downloadTo( + new Oss\Models\GetObjectRequest( + $bucket, + $key + ), + $stream, +); +printf( + 'download to body:' . $stream->getContents() . PHP_EOL +); + +// download file +$filename = "download.tmp"; +touch($filename); +$result = $downloader->downloadFile( + new Oss\Models\GetObjectRequest( + $bucket, + $key + ), + $filename, +); +printf( + 'download file body:' . file_get_contents($filename) +); +unlink($filename); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/EncryptionClient.php b/vendor/alibabacloud/oss-v2/sample/EncryptionClient.php new file mode 100644 index 0000000..8f54b24 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/EncryptionClient.php @@ -0,0 +1,172 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$masterCipher = new Oss\Crypto\MasterRsaCipher( + RSA_PUBLIC_KEY, + RSA_PRIVATE_KEY, + ['tag' => 'value'] +); + +$eclient = new Oss\EncryptionClient($client, $masterCipher); + +// case 1: Simple Upload +$putObjRequest = new Oss\Models\PutObjectRequest($bucket, $key); +$putObjResult = $eclient->putObject($putObjRequest); +printf( + 'put object status code:' . $putObjResult->statusCode . PHP_EOL . + 'request id:' . $putObjResult->requestId . PHP_EOL +); + +// case 2: Multipart Upload +$initRequest = new Oss\Models\InitiateMultipartUploadRequest($bucket, $key); +$initRequest->cseDataSize = 500 * 1024; +$initRequest->csePartSize = 200 * 1024; +$initResult = $eclient->initiateMultipartUpload($initRequest); +$uploadPartRequest = new Oss\Models\UploadPartRequest($bucket, $key); +$bigFileName = "upload.tmp"; +$partSize = 200 * 1024; +generateFile($bigFileName, 500 * 1024); +$file = fopen($bigFileName, 'r'); +$parts = array(); +if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $uploadPartRequest = new Oss\Models\UploadPartRequest( + $bucket, + $key, + $i, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ); + $uploadPartRequest->encryptionMultipartContext = $initResult->encryptionMultipartContext; + $partResult = $eclient->uploadPart($uploadPartRequest); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); +} +$comResult = $eclient->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + $bucket, + $key, + $initResult->uploadId, + null, + new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) +); +unlink($bigFileName); +printf( + 'complete multipart upload status code:' . $comResult->statusCode . PHP_EOL . + 'complete multipart upload request id:' . $comResult->requestId . PHP_EOL . + 'complete multipart upload result:' . var_export($comResult, true) +); + +function generateFile($filename, $size) +{ + if ( + file_exists($filename) && + $size == sprintf('%u', filesize($filename)) + ) { + return; + } + $part_size = 32; + $fp = fopen($filename, "w"); + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $charactersLength = strlen($characters); + if ($fp) { + while ($size > 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + break; + } + } + } + fclose($fp); +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ExtentBucketWorm.php b/vendor/alibabacloud/oss-v2/sample/ExtentBucketWorm.php new file mode 100644 index 0000000..745bbb8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ExtentBucketWorm.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "worm-id" => ['help' => 'The worm id of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$wormId = $options["worm-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ExtendBucketWormRequest($bucket, $wormId, new Oss\Models\ExtendWormConfiguration(3)); +$result = $client->extendBucketWorm($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetAccessPoint.php b/vendor/alibabacloud/oss-v2/sample/GetAccessPoint.php new file mode 100644 index 0000000..51269fe --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetAccessPoint.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$accessPointName = 'ap-01'; +$request = new Oss\Models\GetAccessPointRequest($bucket, $accessPointName); +$result = $client->getAccessPoint($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'get access point:' . var_export($result->getAccessPoint, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetAccessPointPolicy.php b/vendor/alibabacloud/oss-v2/sample/GetAccessPointPolicy.php new file mode 100644 index 0000000..1b527dd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetAccessPointPolicy.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$accessPointName = 'ap-01'; +$request = new Oss\Models\GetAccessPointPolicyRequest($bucket, $accessPointName); +$result = $client->getAccessPointPolicy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'access point policy:' . $result->body +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketAccessMonitor.php b/vendor/alibabacloud/oss-v2/sample/GetBucketAccessMonitor.php new file mode 100644 index 0000000..fff642a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketAccessMonitor.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketAccessMonitorRequest($bucket); +$result = $client->GetBucketAccessMonitor($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'access monitor status:' . $result->accessMonitorConfiguration->status +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketAcl.php b/vendor/alibabacloud/oss-v2/sample/GetBucketAcl.php new file mode 100644 index 0000000..44bb513 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketAcl.php @@ -0,0 +1,45 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketAclRequest($bucket); +$result = $client->getBucketAcl($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket acl:' . $result->accessControlList->grant +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketArchiveDirectRead.php b/vendor/alibabacloud/oss-v2/sample/GetBucketArchiveDirectRead.php new file mode 100644 index 0000000..7c5250b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketArchiveDirectRead.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketArchiveDirectReadRequest($bucket); +$result = $client->getBucketArchiveDirectRead($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'archive direct read config:' . var_export($result->archiveDirectReadConfiguration->enabled, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketCors.php b/vendor/alibabacloud/oss-v2/sample/GetBucketCors.php new file mode 100644 index 0000000..aab48a5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketCors.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketCorsRequest($bucket); +$result = $client->getBucketCors($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'cors:' . var_export($result->corsConfiguration, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/sample/GetBucketDataRedundancyTransition.php new file mode 100644 index 0000000..5282fbc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketDataRedundancyTransition.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "task-id" => ['help' => 'The Id of the redundancy change task.', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$taskId = $options["task-id"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketDataRedundancyTransitionRequest($bucket, $taskId); +$result = $client->getBucketDataRedundancyTransition($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket data redundancy transition:' . var_export($result->bucketDataRedundancyTransition, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketEncryption.php b/vendor/alibabacloud/oss-v2/sample/GetBucketEncryption.php new file mode 100644 index 0000000..dbb9e3a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketEncryption.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketEncryptionRequest($bucket); +$result = $client->getBucketEncryption($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'encryption:' . var_export($result->serverSideEncryptionRule, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketHttpsConfig.php b/vendor/alibabacloud/oss-v2/sample/GetBucketHttpsConfig.php new file mode 100644 index 0000000..febad8b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketHttpsConfig.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketHttpsConfigRequest( + $bucket, +); +$result = $client->getBucketHttpsConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'https config:' . var_export($result->httpsConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketInfo.php b/vendor/alibabacloud/oss-v2/sample/GetBucketInfo.php new file mode 100644 index 0000000..6882276 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketInfo.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetBucketInfoRequest($bucket); + +$result = $client->getBucketInfo($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket info:' . var_export($result->bucketInfo, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketInventory.php b/vendor/alibabacloud/oss-v2/sample/GetBucketInventory.php new file mode 100644 index 0000000..6013afd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketInventory.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$inventoryId = 'test-inventory-id'; +$request = new Oss\Models\GetBucketInventoryRequest( + $bucket, + inventoryId: $inventoryId +); +$result = $client->getBucketInventory($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'inventory config:' . var_export($result->inventoryConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketLifecycle.php b/vendor/alibabacloud/oss-v2/sample/GetBucketLifecycle.php new file mode 100644 index 0000000..023c5ec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketLifecycle.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketLifecycleRequest($bucket); +$result = $client->getBucketLifecycle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'lifecycle:' . var_export($result->lifecycleConfiguration, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketLocation.php b/vendor/alibabacloud/oss-v2/sample/GetBucketLocation.php new file mode 100644 index 0000000..9dc0850 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketLocation.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetBucketLocationRequest($bucket); + +$result = $client->getBucketLocation($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket location:' . var_export($result->location, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketLogging.php b/vendor/alibabacloud/oss-v2/sample/GetBucketLogging.php new file mode 100644 index 0000000..18a8a7e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketLogging.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketLoggingRequest($bucket); +$result = $client->getBucketLogging($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'logging status:' . var_export($result->bucketLoggingStatus, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketOverwrite.php b/vendor/alibabacloud/oss-v2/sample/GetBucketOverwrite.php new file mode 100644 index 0000000..dbea4ee --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketOverwrite.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketOverwriteConfigRequest($bucket); +$result = $client->getBucketOverwriteConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'overwrite config:' . var_export($result->overwriteConfiguration, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketPolicy.php b/vendor/alibabacloud/oss-v2/sample/GetBucketPolicy.php new file mode 100644 index 0000000..8a640ed --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketPolicy.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketPolicyRequest($bucket); +$result = $client->getBucketPolicy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'policy:' . $result->body +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketPolicyStatus.php b/vendor/alibabacloud/oss-v2/sample/GetBucketPolicyStatus.php new file mode 100644 index 0000000..45e24fb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketPolicyStatus.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketPolicyStatusRequest($bucket); +$result = $client->getBucketPolicyStatus($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'policy status:' . var_export($result->policyStatus->isPublic, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketPublicAccessBlock.php b/vendor/alibabacloud/oss-v2/sample/GetBucketPublicAccessBlock.php new file mode 100644 index 0000000..f4ba6b8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketPublicAccessBlock.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketPublicAccessBlockRequest($bucket); +$result = $client->getBucketPublicAccessBlock($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket public access block config:' . var_export($result->publicAccessBlockConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketReferer.php b/vendor/alibabacloud/oss-v2/sample/GetBucketReferer.php new file mode 100644 index 0000000..c22b3bc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketReferer.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketRefererRequest($bucket); +$result = $client->getBucketReferer($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'referer config:' . var_export($result->refererConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketReplication.php b/vendor/alibabacloud/oss-v2/sample/GetBucketReplication.php new file mode 100644 index 0000000..03ef523 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketReplication.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketReplicationRequest($bucket); +$result = $client->getBucketReplication($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'replication config:' . var_export($result->replicationConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketReplicationLocation.php b/vendor/alibabacloud/oss-v2/sample/GetBucketReplicationLocation.php new file mode 100644 index 0000000..5de86e6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketReplicationLocation.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketReplicationLocationRequest($bucket); +$result = $client->getBucketReplicationLocation($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'replication location:' . var_export($result->replicationLocation, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketReplicationProgress.php b/vendor/alibabacloud/oss-v2/sample/GetBucketReplicationProgress.php new file mode 100644 index 0000000..92db65a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketReplicationProgress.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "rule-id" => ['help' => 'The replication rule id of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$ruleId = $options["rule-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketReplicationProgressRequest($bucket, $ruleId); +$result = $client->getBucketReplicationProgress($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'replication progress:' . var_export($result->replicationProgress, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketRequestPayment.php b/vendor/alibabacloud/oss-v2/sample/GetBucketRequestPayment.php new file mode 100644 index 0000000..a999109 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketRequestPayment.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketRequestPaymentRequest($bucket); +$result = $client->getBucketRequestPayment($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'request payer:' . $result->requestPaymentConfiguration->payer +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketResourceGroup.php b/vendor/alibabacloud/oss-v2/sample/GetBucketResourceGroup.php new file mode 100644 index 0000000..320680f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketResourceGroup.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketResourceGroupRequest($bucket); +$result = $client->getBucketResourceGroup($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'resource group id:' . var_export($result->bucketResourceGroupConfiguration->resourceGroupId, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketStat.php b/vendor/alibabacloud/oss-v2/sample/GetBucketStat.php new file mode 100644 index 0000000..a5d9541 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketStat.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetBucketStatRequest($bucket); + +$result = $client->getBucketStat($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketTags.php b/vendor/alibabacloud/oss-v2/sample/GetBucketTags.php new file mode 100644 index 0000000..e22dcfc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketTags.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketTagsRequest($bucket); +$result = $client->getBucketTags($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'tags:' . var_export($result->tagging, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketTransferAcceleration.php b/vendor/alibabacloud/oss-v2/sample/GetBucketTransferAcceleration.php new file mode 100644 index 0000000..dfde7ec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketTransferAcceleration.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketTransferAccelerationRequest($bucket); +$result = $client->getBucketTransferAcceleration($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'transfer acceleration status:' . var_export($result->transferAccelerationConfiguration->enabled, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketVersioning.php b/vendor/alibabacloud/oss-v2/sample/GetBucketVersioning.php new file mode 100644 index 0000000..aea20ba --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketVersioning.php @@ -0,0 +1,45 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketVersioningRequest($bucket); +$result = $client->getBucketVersioning($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'version status:' . $result->versioningConfiguration->status +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketWebsite.php b/vendor/alibabacloud/oss-v2/sample/GetBucketWebsite.php new file mode 100644 index 0000000..6d8e189 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketWebsite.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketWebsiteRequest($bucket); +$result = $client->getBucketWebsite($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'website config:' . var_export($result->websiteConfiguration, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/GetBucketWorm.php b/vendor/alibabacloud/oss-v2/sample/GetBucketWorm.php new file mode 100644 index 0000000..1038c22 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetBucketWorm.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "worm-id" => ['help' => 'The worm id of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$wormId = $options["worm-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetBucketWormRequest($bucket); +$result = $client->getBucketWorm($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'worm config:' . var_export($result->wormConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetCnameToken.php b/vendor/alibabacloud/oss-v2/sample/GetCnameToken.php new file mode 100644 index 0000000..99e29b8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetCnameToken.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetCnameTokenRequest($bucket, 'example.com'); +$result = $client->getCnameToken($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'cname token:' . var_export($result->cnameToken, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetMetaQueryStatus.php b/vendor/alibabacloud/oss-v2/sample/GetMetaQueryStatus.php new file mode 100644 index 0000000..df18079 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetMetaQueryStatus.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetMetaQueryStatusRequest($bucket); +$result = $client->getMetaQueryStatus($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'meta query status:' . var_export($result->metaQueryStatus, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetObject.php b/vendor/alibabacloud/oss-v2/sample/GetObject.php new file mode 100644 index 0000000..27654a3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetObject.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetObjectRequest($bucket, $key); + +$result = $client->getObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'body:' . $result->body->getContents() +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetObjectAcl.php b/vendor/alibabacloud/oss-v2/sample/GetObjectAcl.php new file mode 100644 index 0000000..c8d6e39 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetObjectAcl.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetObjectAclRequest($bucket, $key); +$result = $client->getObjectAcl($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'acl:' . $result->accessControlList->grant +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetObjectMeta.php b/vendor/alibabacloud/oss-v2/sample/GetObjectMeta.php new file mode 100644 index 0000000..5f686bd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetObjectMeta.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\GetObjectMetaRequest($bucket, $key); + +$result = $client->getObjectMeta($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetObjectTagging.php b/vendor/alibabacloud/oss-v2/sample/GetObjectTagging.php new file mode 100644 index 0000000..cc02176 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetObjectTagging.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetObjectTaggingRequest($bucket, $key); +$result = $client->getObjectTagging($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetPublicAccessBlock.php b/vendor/alibabacloud/oss-v2/sample/GetPublicAccessBlock.php new file mode 100644 index 0000000..22a08d0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetPublicAccessBlock.php @@ -0,0 +1,45 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetPublicAccessBlockRequest(); +$result = $client->getPublicAccessBlock($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'public access block config:' . var_export($result->publicAccessBlockConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetStyle.php b/vendor/alibabacloud/oss-v2/sample/GetStyle.php new file mode 100644 index 0000000..fe03144 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetStyle.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetStyleRequest( + $bucket, + styleName: 'test', +); +$result = $client->getStyle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'style info:' . var_export($result->style, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetSymlink.php b/vendor/alibabacloud/oss-v2/sample/GetSymlink.php new file mode 100644 index 0000000..c6ebdd5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetSymlink.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetSymlinkRequest($bucket, $key); +$result = $client->getSymlink($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/GetUserDefinedLogFieldsConfig.php b/vendor/alibabacloud/oss-v2/sample/GetUserDefinedLogFieldsConfig.php new file mode 100644 index 0000000..128014a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/GetUserDefinedLogFieldsConfig.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\GetUserDefinedLogFieldsConfigRequest($bucket); +$result = $client->getUserDefinedLogFieldsConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId. PHP_EOL . + 'user defined log fields config:'. var_export($result->userDefinedLogFieldsConfiguration, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/HeadObject.php b/vendor/alibabacloud/oss-v2/sample/HeadObject.php new file mode 100644 index 0000000..43fa8aa --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/HeadObject.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\HeadObjectRequest($bucket, $key); + +$result = $client->headObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/InitiateBucketWorm.php b/vendor/alibabacloud/oss-v2/sample/InitiateBucketWorm.php new file mode 100644 index 0000000..da2e1b7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/InitiateBucketWorm.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\InitiateBucketWormRequest($bucket, new Oss\Models\InitiateWormConfiguration( + 3 +)); +$result = $client->initiateBucketWorm($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'worm id:' . $result->wormId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/InitiateMultipartUpload.php b/vendor/alibabacloud/oss-v2/sample/InitiateMultipartUpload.php new file mode 100644 index 0000000..7b9b999 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/InitiateMultipartUpload.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\InitiateMultipartUploadRequest($bucket, $key); +$result = $client->initiateMultipartUpload($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/InvokeOperation.php b/vendor/alibabacloud/oss-v2/sample/InvokeOperation.php new file mode 100644 index 0000000..c1e7d7f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/InvokeOperation.php @@ -0,0 +1,98 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +// PutCname sample case 1: +$body = Oss\Utils::streamFor(" + + example.com + +"); + +$input = new Oss\OperationInput( + "PutCname", + "POST", +); +$input->setParameter("cname", ""); +$input->setParameter("comp", "add"); +$input->setBody($body); +$input->setBucket($bucket); + +$result = $client->invokeOperation($input); +printf( + 'status code:' . $result->GetStatusCode() . PHP_EOL . + 'request id:' . $result->getHeaders()["x-oss-request-id"] . PHP_EOL +); + +// PutCname sample case 2: +//$body = Oss\Utils::streamFor(" +// +// example.com +// +//"); +// +// +//$input = new Oss\OperationInput( +// opName: "PutCname", +// method: "POST", +// headers: null, +// parameters: ["cname" => "", "comp" => "add"], +// body: $body, +// bucket: $bucket +//); +//$result = $client->invokeOperation($input); +//printf( +// 'status code:' . $result->GetStatusCode() . PHP_EOL . +// 'request id:' . $result->getHeaders()["x-oss-request-id"] . PHP_EOL +//); + +// GetCnameToken sample +$input = new Oss\OperationInput( + "GetCnameToken", + "GET", + null, + ["cname" => "example.com", "comp" => "token"], + NULL, + $bucket +); +$result = $client->invokeOperation($input); +printf( + 'status code:' . $result->GetStatusCode() . PHP_EOL . + 'request id:' . $result->getHeaders()["x-oss-request-id"] . PHP_EOL . + 'body:' . $result->getBody()->getContents() +); diff --git a/vendor/alibabacloud/oss-v2/sample/IsBucketExist.php b/vendor/alibabacloud/oss-v2/sample/IsBucketExist.php new file mode 100644 index 0000000..aa0e145 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/IsBucketExist.php @@ -0,0 +1,45 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$exist = $client->isBucketExist($bucket); + +printf( + 'bucket is exist:' . var_export($exist, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/IsObjectExist.php b/vendor/alibabacloud/oss-v2/sample/IsObjectExist.php new file mode 100644 index 0000000..4c054c8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/IsObjectExist.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$exist = $client->isObjectExist($bucket, $key); + +printf( + 'object is exist:' . var_export($exist, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ListAccessPoint.php b/vendor/alibabacloud/oss-v2/sample/ListAccessPoint.php new file mode 100644 index 0000000..26606c4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListAccessPoint.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ListAccessPointsRequest(); +$result = $client->listAccessPoints($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'list access points:' . var_export($result->listAccessPoints, true) +); + diff --git a/vendor/alibabacloud/oss-v2/sample/ListBucketDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/sample/ListBucketDataRedundancyTransition.php new file mode 100644 index 0000000..cdc6f80 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListBucketDataRedundancyTransition.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ListBucketDataRedundancyTransitionRequest($bucket); +$result = $client->listBucketDataRedundancyTransition($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket data redundancy transitions:' . var_export($result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ListBucketInventory.php b/vendor/alibabacloud/oss-v2/sample/ListBucketInventory.php new file mode 100644 index 0000000..421be56 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListBucketInventory.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ListBucketInventoryRequest( + $bucket, +); +$result = $client->listBucketInventory($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'list inventory config:' . var_export($result->listInventoryConfigurationsResult->inventoryConfigurations, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ListBuckets.php b/vendor/alibabacloud/oss-v2/sample/ListBuckets.php new file mode 100644 index 0000000..5a43e31 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListBuckets.php @@ -0,0 +1,46 @@ + ['help'=>'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help'=>'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function($key){return "$key:";}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +// Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListBucketsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListBucketsRequest()); + +// Iterate through the bucket pages +foreach ($iter as $page) { + foreach ($page->buckets ?? [] as $bucket) { + print ("Bucket: $bucket->name, $bucket->location\n"); + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/ListCloudBoxes.php b/vendor/alibabacloud/oss-v2/sample/ListCloudBoxes.php new file mode 100644 index 0000000..f954935 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListCloudBoxes.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\ListCloudBoxesRequest(); + +$result = $client->listCloudBoxes($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'list cloud box:' . var_export($result->listCloudBoxes, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ListCname.php b/vendor/alibabacloud/oss-v2/sample/ListCname.php new file mode 100644 index 0000000..847f5b0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListCname.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ListCnameRequest($bucket); +$result = $client->listCname($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'cnames:' . var_export($result->cnames, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ListMultipartUploads.php b/vendor/alibabacloud/oss-v2/sample/ListMultipartUploads.php new file mode 100644 index 0000000..4e5dfb9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListMultipartUploads.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +// Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListMultipartUploadsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListMultipartUploadsRequest($bucket)); + +// Iterate through the bucket pages +foreach ($iter as $page) { + foreach ($page->uploads ?? [] as $upload) { + printf( + 'upload:' . var_export($upload, true) . PHP_EOL + ); + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/ListObjectVersions.php b/vendor/alibabacloud/oss-v2/sample/ListObjectVersions.php new file mode 100644 index 0000000..18c01f6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListObjectVersions.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +# Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListObjectVersionsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListObjectVersionsRequest($bucket)); + +// Iterate through the object pages +foreach ($iter as $page) { + foreach ($page->versions ?? [] as $version) { + print("Object: $version->key, $version->type, $version->size,$version->versionId \n"); + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/ListObjects.php b/vendor/alibabacloud/oss-v2/sample/ListObjects.php new file mode 100644 index 0000000..412964d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListObjects.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +# Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListObjectsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListObjectsRequest($bucket)); + +// Iterate through the object pages +foreach ($iter as $page) { + foreach ($page->contents ?? [] as $object) { + print("Object: $object->key, $object->type, $object->size\n"); + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/ListObjectsV2.php b/vendor/alibabacloud/oss-v2/sample/ListObjectsV2.php new file mode 100644 index 0000000..90b5016 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListObjectsV2.php @@ -0,0 +1,48 @@ + ['help'=>'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help'=>'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help'=>'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function($key){return "$key:";}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +# Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListObjectsV2Paginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListObjectsV2Request($bucket)); + +// Iterate through the object pages +foreach ($iter as $page) { + foreach ($page->contents ?? [] as $object) { + print("Object: $object->key, $object->type, $object->size\n"); + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/ListParts.php b/vendor/alibabacloud/oss-v2/sample/ListParts.php new file mode 100644 index 0000000..89d8501 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListParts.php @@ -0,0 +1,55 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "upload-id" => ['help' => 'The upload id', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$uploadId = $options["upload-id"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +// Create the Paginator for the ListBuckets operation +$paginator = new Oss\Paginator\ListPartsPaginator($client); +$iter = $paginator->iterPage(new Oss\Models\ListPartsRequest($bucket, $key, $uploadId)); + +// Iterate through the bucket pages +foreach ($iter as $page) { + foreach ($page->parts ?? [] as $part) { + printf( + 'part:' . var_export($part, true) . PHP_EOL + ); + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/ListStyle.php b/vendor/alibabacloud/oss-v2/sample/ListStyle.php new file mode 100644 index 0000000..27f69b0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListStyle.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ListStyleRequest( + $bucket, +); +$result = $client->listStyle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'styles:' . var_export($result->styleList->styles, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/ListUserDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/sample/ListUserDataRedundancyTransition.php new file mode 100644 index 0000000..3568c2a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ListUserDataRedundancyTransition.php @@ -0,0 +1,44 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\ListUserDataRedundancyTransitionRequest(); +$result = $client->listUserDataRedundancyTransition($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'bucket data redundancy transitions:' . var_export($result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/OpenMetaQuery.php b/vendor/alibabacloud/oss-v2/sample/OpenMetaQuery.php new file mode 100644 index 0000000..da1b693 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/OpenMetaQuery.php @@ -0,0 +1,57 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +// case 1: meta search +$request = new Oss\Models\OpenMetaQueryRequest($bucket); +$result = $client->openMetaQuery($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + +// case 2: ai search +//$request = new Oss\Models\OpenMetaQueryRequest($bucket,'semantic'); +//$result = $client->openMetaQuery($request); +// +//printf( +// 'status code:' . $result->statusCode . PHP_EOL . +// 'request id:' . $result->requestId +//); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/OptionObject.php b/vendor/alibabacloud/oss-v2/sample/OptionObject.php new file mode 100644 index 0000000..5922a3f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/OptionObject.php @@ -0,0 +1,53 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$result = $client->optionObject(new Oss\Models\OptionObjectRequest( + $bucket, + $key, + origin: 'http://www.example.com', + accessControlRequestMethod: 'PUT', +)); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PostObject.php b/vendor/alibabacloud/oss-v2/sample/PostObject.php new file mode 100644 index 0000000..741d966 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PostObject.php @@ -0,0 +1,156 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$product = 'oss'; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); +$cred = $credentialsProvider->getCredentials(); +$data = 'hi oss'; +$utcTime = new DateTime('now', new DateTimeZone('UTC')); +$date = $utcTime->format('Ymd'); +$expiration = clone $utcTime; +$expiration->add(new DateInterval('PT1H')); +$policyMap = [ + "expiration" => $expiration->format('Y-m-d\TH:i:s.000\Z'), + "conditions" => [ + ["bucket" => $bucket], + ["x-oss-signature-version" => "OSS4-HMAC-SHA256"], + ["x-oss-credential" => sprintf("%s/%s/%s/%s/aliyun_v4_request", + $cred->getAccessKeyId(), $date, $region, $product)], + ["x-oss-date" => $utcTime->format('Ymd\THis\Z')], + // other condition + ["content-length-range", 1, 1024], + // ["eq", "$success_action_status", "201"], + // ["starts-with", "$key", "user/eric/"], + // ["in", "$content-type", ["image/jpg", "image/png"]], + // ["not-in", "$cache-control", ["no-cache"]], + ], +]; +$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; +$policy = json_encode($policyMap, $jsonOptions); +if (json_last_error() !== JSON_ERROR_NONE) { + error_log("json_encode fail, err: " . json_last_error_msg()); + exit(1); +} +$stringToSign = base64_encode($policy); +$signingKey = "aliyun_v4" . $cred->getAccessKeySecret(); +$h1Key = hmacSign($signingKey, $date); +$h2Key = hmacSign($h1Key, $region); +$h3Key = hmacSign($h2Key, $product); +$h4Key = hmacSign($h3Key, "aliyun_v4_request"); + +// Signature +$signature = hash_hmac('sha256', $stringToSign, $h4Key); + +// Post Request +$bodyBuf = ''; +$bodyWriter = new \CURLFileUpload(); + +// object info, key & metadata +$bodyWriter->addField('key', $key); +// meta-data +// $bodyWriter->addField('x-oss-', $value); +// Policy +$bodyWriter->addField('policy', $stringToSign); +// Signature +$bodyWriter->addField('x-oss-signature-version', 'OSS4-HMAC-SHA256'); +$bodyWriter->addField('x-oss-credential', sprintf("%s/%s/%s/%s/aliyun_v4_request", $cred->getAccessKeyId(), $date, $region, $product)); +$bodyWriter->addField('x-oss-date', $utcTime->format('Ymd\THis\Z')); +$bodyWriter->addField('x-oss-signature', $signature); + +// Data +$bodyWriter->addFileFromString('file', $data); +$postData = $bodyWriter->getFormData(); +$client = new \GuzzleHttp\Client(); +$response = $client->post(sprintf("http://%s.oss-%s.aliyuncs.com/", $bucket, $region), + [ + 'headers' => [ + 'content-type' => $bodyWriter->getContentType(), + ], + 'body' => $postData + ] +); +if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) { + echo "Post Object Fail, status code:" . $response->getStatusCode() . ", reason: " . $response->getReasonPhrase(); + exit(1); +} +echo "post object done, status code:" . $response->getStatusCode() . ", request id:" . $response->getHeaderLine('x-oss-request-id') . PHP_EOL; + +function hmacSign($key, $data) +{ + return hash_hmac('sha256', $data, $key, true); +} + +class CURLFileUpload +{ + private $fields = []; + private $files = []; + private $boundary; + + public function __construct() + { + $this->boundary = uniqid(); + } + + public function addField($name, $value) + { + $this->fields[$name] = $value; + } + + public function addFileFromString($name, $content) + { + $this->files[$name] = [ + 'content' => $content, + 'filename' => $name, + 'type' => 'application/octet-stream' + ]; + } + + public function getFormData() + { + $data = ''; + foreach ($this->fields as $name => $value) { + $data .= "--{$this->boundary}\r\n"; + $data .= "Content-Disposition: form-data; name=\"$name\"\r\n\r\n"; + $data .= $value . "\r\n"; + } + foreach ($this->files as $name => $file) { + $data .= "--{$this->boundary}\r\n"; + $data .= "Content-Disposition: form-data; name=\"$name\"; filename=\"{$file['filename']}\"\r\n"; + $data .= "Content-Type: {$file['type']}\r\n\r\n"; + $data .= $file['content'] . "\r\n"; + } + $data .= "--{$this->boundary}--\r\n"; + return $data; + } + + public function getContentType() + { + return "multipart/form-data; boundary={$this->boundary}"; + } +} diff --git a/vendor/alibabacloud/oss-v2/sample/Presign.php b/vendor/alibabacloud/oss-v2/sample/Presign.php new file mode 100644 index 0000000..775cb8d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/Presign.php @@ -0,0 +1,102 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +// case 1:PutObject +$request = new Oss\Models\PutObjectRequest($bucket, $key); +$result = $client->presign($request); +print( + 'put object presign result:' . var_export($result, true) . PHP_EOL . + 'put object url:' . $result->url . PHP_EOL +); + +// case 2:GetObject +$request = new Oss\Models\GetObjectRequest($bucket, $key); +$result = $client->presign($request); +print( + 'get object presign result:' . var_export($result, true) . PHP_EOL . + 'get object url:' . $result->url . PHP_EOL +); + +// case 3:HeadObject +$request = new Oss\Models\HeadObjectRequest($bucket, $key); +$result = $client->presign($request); +print( + 'head object presign result:' . var_export($result, true) . PHP_EOL . + 'head object url:' . $result->url . PHP_EOL +); + +// case 4:InitiateMultipartUpload +$request = new Oss\Models\InitiateMultipartUploadRequest($bucket, $key); +$result = $client->presign($request); +print( + 'initiate multipart upload presign result:' . var_export($result, true) . PHP_EOL . + 'initiate multipart upload url:' . $result->url . PHP_EOL +); + +// case 5:UploadPart +$request = new Oss\Models\UploadPartRequest($bucket, $key); +$request->partNumber = 1; +$request->uploadId = 'your upload id'; +$result = $client->presign($request); +print( + 'upload part presign result:' . var_export($result, true) . PHP_EOL . + 'upload part url:' . $result->url . PHP_EOL +); + +// case 6:CompleteMultipartUpload +$request = new Oss\Models\CompleteMultipartUploadRequest($bucket, $key); +$request->uploadId = 'your upload id'; +$result = $client->presign($request); +print( + 'complete multipart upload presign result:' . var_export($result, true) . PHP_EOL . + 'complete multipart upload url:' . $result->url . PHP_EOL +); + +// case 6:AbortMultipartUpload +$request = new Oss\Models\AbortMultipartUploadRequest($bucket, $key); +$request->uploadId = 'your upload id'; +$result = $client->presign($request); +print( + 'abort multipart upload presign result:' . var_export($result, true) . PHP_EOL . + 'abort multipart upload url:' . $result->url +); + diff --git a/vendor/alibabacloud/oss-v2/sample/ProcessObject.php b/vendor/alibabacloud/oss-v2/sample/ProcessObject.php new file mode 100644 index 0000000..3e64c37 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/ProcessObject.php @@ -0,0 +1,56 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$process = sprintf("image/resize,w_100|sys/saveas,o_%s", + base64_encode($key) +); + +$request = new Oss\Models\ProcessObjectRequest($bucket, $key); +$request->process = $process; + +$result = $client->processObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'process result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutAccessPointPolicy.php b/vendor/alibabacloud/oss-v2/sample/PutAccessPointPolicy.php new file mode 100644 index 0000000..43f09da --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutAccessPointPolicy.php @@ -0,0 +1,67 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$accessPointName = 'ap-01'; +$request = new Oss\Models\PutAccessPointPolicyRequest($bucket); +$request->accessPointName = $accessPointName; +$policy = '{ + "Version":"1", + "Statement":[ + { + "Action":[ + "oss:PutObject", + "oss:GetObject" + ], + "Effect":"Deny", + "Principal":["27737962156157xxxx"], + "Resource":[ + "acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01", + "acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01/object/*" + ] + } + ] + }'; +$request->body = Oss\Utils::streamFor($policy); +$result = $client->putAccessPointPolicy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); + diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucket.php b/vendor/alibabacloud/oss-v2/sample/PutBucket.php new file mode 100644 index 0000000..9d5c5b7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucket.php @@ -0,0 +1,47 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\PutBucketRequest($bucket); +$result = $client->putBucket($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketAccessMonitor.php b/vendor/alibabacloud/oss-v2/sample/PutBucketAccessMonitor.php new file mode 100644 index 0000000..da371ce --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketAccessMonitor.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketAccessMonitorRequest($bucket, new Oss\Models\AccessMonitorConfiguration( + status: Oss\Models\AccessMonitorStatusType::ENABLED +)); +$result = $client->putBucketAccessMonitor($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketAcl.php b/vendor/alibabacloud/oss-v2/sample/PutBucketAcl.php new file mode 100644 index 0000000..fd5a62d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketAcl.php @@ -0,0 +1,44 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketAclRequest($bucket, Oss\Models\BucketACLType::PRIVATE); +$result = $client->putBucketAcl($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketArchiveDirectRead.php b/vendor/alibabacloud/oss-v2/sample/PutBucketArchiveDirectRead.php new file mode 100644 index 0000000..ac29e96 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketArchiveDirectRead.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketArchiveDirectReadRequest($bucket, new Oss\Models\ArchiveDirectReadConfiguration( + true +)); +$result = $client->putBucketArchiveDirectRead($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketCors.php b/vendor/alibabacloud/oss-v2/sample/PutBucketCors.php new file mode 100644 index 0000000..5f970ca --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketCors.php @@ -0,0 +1,54 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketCorsRequest($bucket, corsConfiguration: new Oss\Models\CORSConfiguration( + array( + new Oss\Models\CORSRule( + allowedOrigins: ['*'], + allowedMethods: ['PUT', 'GET'] + ) + ) + ) +); +$result = $client->putBucketCors($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketEncryption.php b/vendor/alibabacloud/oss-v2/sample/PutBucketEncryption.php new file mode 100644 index 0000000..2557ea4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketEncryption.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketEncryptionRequest($bucket, new Oss\Models\ServerSideEncryptionRule( + new Oss\Models\ApplyServerSideEncryptionByDefault( + sseAlgorithm: 'KMS', + kmsDataEncryption: 'SM4' + ))); +$result = $client->putBucketEncryption($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketHttpsConfig.php b/vendor/alibabacloud/oss-v2/sample/PutBucketHttpsConfig.php new file mode 100644 index 0000000..33f77ff --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketHttpsConfig.php @@ -0,0 +1,54 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketHttpsConfigRequest( + $bucket, + new Oss\Models\HttpsConfiguration( + tls: new Oss\Models\TLS( + tlsVersions: ['TLSv1.2', 'TLSv1.3'], + enable: true + ) + ) +); +$result = $client->putBucketHttpsConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketInventory.php b/vendor/alibabacloud/oss-v2/sample/PutBucketInventory.php new file mode 100644 index 0000000..70313fd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketInventory.php @@ -0,0 +1,81 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "account-id" => ['help' => 'The account id of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$accountId = $options["account-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$inventoryId = 'test-inventory-id'; +$request = new Oss\Models\PutBucketInventoryRequest( + $bucket, + inventoryId: $inventoryId, + inventoryConfiguration: new Oss\Models\InventoryConfiguration( + isEnabled: true, + destination: new Oss\Models\InventoryDestination( + ossBucketDestination: new Oss\Models\InventoryOSSBucketDestination( + bucket: 'acs:oss:::' . $bucket, + prefix: 'prefix1', + format: Oss\Models\InventoryFormatType::CSV, + accountId: $accountId, + roleArn: 'acs:ram::' . $accountId . ':role/AliyunOSSRole' + ) +), + schedule: new Oss\Models\InventorySchedule( + frequency: Oss\Models\InventoryFrequencyType::DAILY +), + filter: new Oss\Models\InventoryFilter( + prefix: 'filterPrefix', + lastModifyBeginTimeStamp: 1637883649, + lastModifyEndTimeStamp: 1638347592, + lowerSizeBound: 1024, + upperSizeBound: 1048576, + storageClass: 'Standard,IA' +), + includedObjectVersions: 'All', + optionalFields: new Oss\Models\OptionalFields( + fields: array( + Oss\Models\InventoryOptionalFieldType::STORAGE_CLASS + ) +), + id: $inventoryId +)); +$result = $client->putBucketInventory($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketLifecycle.php b/vendor/alibabacloud/oss-v2/sample/PutBucketLifecycle.php new file mode 100644 index 0000000..78f4300 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketLifecycle.php @@ -0,0 +1,59 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketLifecycleRequest($bucket, lifecycleConfiguration: new LifecycleConfiguration( + array(new Oss\Models\LifecycleRule( + prefix: 'log/', + transitions: array( + new Oss\Models\LifecycleRuleTransition( + days: 30, + storageClass: 'IA' + ) + ), + id: 'rule', + status: 'Enabled' + )) +)); +$result = $client->putBucketLifecycle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketLogging.php b/vendor/alibabacloud/oss-v2/sample/PutBucketLogging.php new file mode 100644 index 0000000..b40e347 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketLogging.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketLoggingRequest($bucket, new Oss\Models\BucketLoggingStatus( + new Oss\Models\LoggingEnabled( + $bucket, + 'log/' + ) +)); +$result = $client->putBucketLogging($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketOverwrite.php b/vendor/alibabacloud/oss-v2/sample/PutBucketOverwrite.php new file mode 100644 index 0000000..0ffa1da --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketOverwrite.php @@ -0,0 +1,57 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketOverwriteConfigRequest($bucket, new Oss\Models\OverwriteConfiguration( + array( + new Oss\Models\OverwriteRule( + 'forbid', 'pre', 'txt', new Oss\Models\OverwritePrincipals( + array( + '1234567890' + ), + ), + 'rule-001' + ) + ) +)); +$result = $client->putBucketOverwriteConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketPolicy.php b/vendor/alibabacloud/oss-v2/sample/PutBucketPolicy.php new file mode 100644 index 0000000..fea771e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketPolicy.php @@ -0,0 +1,59 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketPolicyRequest($bucket, '{ + "Version":"1", + "Statement":[ + { + "Action":[ + "oss:PutObject", + "oss:GetObject" + ], + "Effect":"Deny", + "Principal":["1234567890"], + "Resource":["acs:oss:*:1234567890:*/*"] + } + ] + }'); +$result = $client->putBucketPolicy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketPublicAccessBlock.php b/vendor/alibabacloud/oss-v2/sample/PutBucketPublicAccessBlock.php new file mode 100644 index 0000000..83e6c16 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketPublicAccessBlock.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketPublicAccessBlockRequest($bucket, + new Oss\Models\PublicAccessBlockConfiguration(true) +); +$result = $client->putBucketPublicAccessBlock($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketReferer.php b/vendor/alibabacloud/oss-v2/sample/PutBucketReferer.php new file mode 100644 index 0000000..e1f24b6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketReferer.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketRefererRequest($bucket, + refererConfiguration: new Oss\Models\RefererConfiguration( + allowEmptyReferer: false, + refererList: new Oss\Models\RefererList([""]), + ) +); +$result = $client->putBucketReferer($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketReplication.php b/vendor/alibabacloud/oss-v2/sample/PutBucketReplication.php new file mode 100644 index 0000000..ed362be --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketReplication.php @@ -0,0 +1,64 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "target-bucket" => ['help' => 'The name of the target bucket', 'required' => True], + "target-location" => ['help' => 'The location of the target bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$targetBucket = $options["target-bucket"]; +$targetLocation = $options["target-location"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketReplicationRequest($bucket, replicationConfiguration: new Oss\Models\ReplicationConfiguration( + array( + new Oss\Models\ReplicationRule( + destination: new Oss\Models\ReplicationDestination( + bucket: $targetBucket, + location: $targetLocation, + ), + rtc: new Oss\Models\ReplicationTimeControl( + status: 'enabled' + ) + ) + ) +)); +$result = $client->putBucketReplication($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'replication rule id:' . $result->replicationRuleId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketRequestPayment.php b/vendor/alibabacloud/oss-v2/sample/PutBucketRequestPayment.php new file mode 100644 index 0000000..76eaeb3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketRequestPayment.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketRequestPaymentRequest($bucket, new Oss\Models\RequestPaymentConfiguration( + 'Requester' +)); +$result = $client->putBucketRequestPayment($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketResourceGroup.php b/vendor/alibabacloud/oss-v2/sample/PutBucketResourceGroup.php new file mode 100644 index 0000000..3992d12 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketResourceGroup.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketResourceGroupRequest($bucket, new Oss\Models\BucketResourceGroupConfiguration( + 'rg-123' +)); +$result = $client->putBucketResourceGroup($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketRtc.php b/vendor/alibabacloud/oss-v2/sample/PutBucketRtc.php new file mode 100644 index 0000000..f4eb472 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketRtc.php @@ -0,0 +1,57 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "rule-id" => ['help' => 'The replication rule id of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$ruleId = $options["rule-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketRtcRequest( + $bucket, + rtcConfiguration: new Oss\Models\RtcConfiguration( + rtc: new Oss\Models\ReplicationTimeControl( + status: 'disabled' +), + id: $ruleId +), +); +$result = $client->putBucketRtc($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketTags.php b/vendor/alibabacloud/oss-v2/sample/PutBucketTags.php new file mode 100644 index 0000000..8bf3e44 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketTags.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketTagsRequest($bucket, tagging: new Oss\Models\Tagging( + tagSet: new Oss\Models\TagSet( + [new Oss\Models\Tag(key: 'key1', value: 'value1'), new Oss\Models\Tag(key: 'key2', value: 'value2')]) + ) +); +$result = $client->putBucketTags($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketTransferAcceleration.php b/vendor/alibabacloud/oss-v2/sample/PutBucketTransferAcceleration.php new file mode 100644 index 0000000..3ae4ce6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketTransferAcceleration.php @@ -0,0 +1,48 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketTransferAccelerationRequest($bucket, new Oss\Models\TransferAccelerationConfiguration( + true +)); +$result = $client->putBucketTransferAcceleration($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketVersioning.php b/vendor/alibabacloud/oss-v2/sample/PutBucketVersioning.php new file mode 100644 index 0000000..4ffa288 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketVersioning.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketVersioningRequest($bucket, new Oss\Models\VersioningConfiguration( + 'Enabled' +)); +$result = $client->putBucketVersioning($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutBucketWebsite.php b/vendor/alibabacloud/oss-v2/sample/PutBucketWebsite.php new file mode 100644 index 0000000..b4f65ed --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutBucketWebsite.php @@ -0,0 +1,55 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutBucketWebsiteRequest($bucket, + websiteConfiguration: new Oss\Models\WebsiteConfiguration( + indexDocument: new Oss\Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + errorDocument: new Oss\Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ) + ) +); +$result = $client->putBucketWebsite($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutCname.php b/vendor/alibabacloud/oss-v2/sample/PutCname.php new file mode 100644 index 0000000..cfe4abc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutCname.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutCnameRequest($bucket, new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) +)); +$result = $client->putCname($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutObject.php b/vendor/alibabacloud/oss-v2/sample/PutObject.php new file mode 100644 index 0000000..6913233 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutObject.php @@ -0,0 +1,52 @@ + ['help'=>'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help'=>'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help'=>'The name of the bucket', 'required' => True], + "key" => ['help'=>'The name of the object', 'required' => True], +]; +$longopts = \array_map(function($key){return "$key:";}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$data = 'Hello OSS'; + +$request = new Oss\Models\PutObjectRequest($bucket, $key); +$request->body = Oss\Utils::streamFor($data); + +$result = $client->putObject($request); + +printf( + 'status code:'. $result->statusCode .PHP_EOL. + 'request id:'. $result->requestId .PHP_EOL. + 'etag:'. $result->etag. PHP_EOL +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutObjectAcl.php b/vendor/alibabacloud/oss-v2/sample/PutObjectAcl.php new file mode 100644 index 0000000..06bc259 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutObjectAcl.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutObjectAclRequest($bucket, $key, Oss\Models\ObjectACLType::PUBLIC_READ); +$result = $client->putObjectAcl($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutObjectTagging.php b/vendor/alibabacloud/oss-v2/sample/PutObjectTagging.php new file mode 100644 index 0000000..286dddd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutObjectTagging.php @@ -0,0 +1,53 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutObjectTaggingRequest($bucket, $key, new Oss\Models\Tagging( + new Oss\Models\TagSet( + [ + new Oss\Models\Tag('k1', 'v1'), + new Oss\Models\Tag('k2', 'v2') + ] + ) +)); +$result = $client->putObjectTagging($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutPublicAccessBlock.php b/vendor/alibabacloud/oss-v2/sample/PutPublicAccessBlock.php new file mode 100644 index 0000000..28172a1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutPublicAccessBlock.php @@ -0,0 +1,46 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutPublicAccessBlockRequest( + new Oss\Models\PublicAccessBlockConfiguration(true) +); +$result = $client->putPublicAccessBlock($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutStyle.php b/vendor/alibabacloud/oss-v2/sample/PutStyle.php new file mode 100644 index 0000000..2413d97 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutStyle.php @@ -0,0 +1,50 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutStyleRequest( + $bucket, + styleName: 'test', + style: new Oss\Models\StyleContent('image/resize,p_50') +); +$result = $client->putStyle($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutSymlink.php b/vendor/alibabacloud/oss-v2/sample/PutSymlink.php new file mode 100644 index 0000000..e910b5e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutSymlink.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "symlink" => ['help' => 'The name of the symlink object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$symlink = $options["symlink"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutSymlinkRequest($bucket, $key, $symlink); +$result = $client->putSymlink($request); +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/PutUserDefinedLogFieldsConfig.php b/vendor/alibabacloud/oss-v2/sample/PutUserDefinedLogFieldsConfig.php new file mode 100644 index 0000000..28d168f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/PutUserDefinedLogFieldsConfig.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\PutUserDefinedLogFieldsConfigRequest($bucket, new Oss\Models\UserDefinedLogFieldsConfiguration( + new Oss\Models\LoggingParamSet(['param1', 'params2']), + new Oss\Models\LoggingHeaderSet(['header1', 'header2']) +)); +$result = $client->putUserDefinedLogFieldsConfig($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/RestoreObject.php b/vendor/alibabacloud/oss-v2/sample/RestoreObject.php new file mode 100644 index 0000000..f8876c7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/RestoreObject.php @@ -0,0 +1,49 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$request = new Oss\Models\RestoreObjectRequest($bucket, $key); +$result = $client->restoreObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/SealAppendObject.php b/vendor/alibabacloud/oss-v2/sample/SealAppendObject.php new file mode 100644 index 0000000..f112b94 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/SealAppendObject.php @@ -0,0 +1,51 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$request = new Oss\Models\SealAppendObjectRequest($bucket, $key); +$request->position = 100; + +$result = $client->sealAppendObject($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'sealed time:' . $result->sealedTime +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/UploadPart.php b/vendor/alibabacloud/oss-v2/sample/UploadPart.php new file mode 100644 index 0000000..cbb4e4f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/UploadPart.php @@ -0,0 +1,107 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "upload-id" => ['help' => 'The upload id', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$uploadId = $options["upload-id"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$bigFileName = "upload.tmp"; +$partSize = 200 * 1024; +generateFile($bigFileName, 500 * 1024); +$file = fopen($bigFileName, 'r'); +$parts = array(); +if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $result = $client->uploadPart( + new Oss\Models\UploadPartRequest( + $bucket, + $key, + $i, + $uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) . PHP_EOL + ); + $i++; + } + fclose($file); +} +unlink($bigFileName); + +function generateFile($filename, $size) +{ + if ( + file_exists($filename) && + $size == sprintf('%u', filesize($filename)) + ) { + return; + } + $part_size = 32; + $fp = fopen($filename, "w"); + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $charactersLength = strlen($characters); + if ($fp) { + while ($size > 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + break; + } + } + } + fclose($fp); +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/UploadPartCopy.php b/vendor/alibabacloud/oss-v2/sample/UploadPartCopy.php new file mode 100644 index 0000000..5f2daa2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/UploadPartCopy.php @@ -0,0 +1,60 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], + "src-bucket" => ['help' => 'The name of the source bucket', 'required' => False], + "src-key" => ['help' => 'The name of the source object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; +$srcKey = $options["src-key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); + +$initRequest = new Oss\Models\InitiateMultipartUploadRequest($bucket, $key); +$initResult = $client->initiateMultipartUpload($initRequest); + +$request = new Oss\Models\UploadPartCopyRequest($bucket, $key, 1, $initResult->uploadId); +if (!empty($options["src-bucket"])) { + $request->sourceBucket = $options["src-bucket"]; +} +$request->sourceKey = $srcKey; +$result = $client->uploadPartCopy($request); + +printf( + 'status code:' . $result->statusCode . PHP_EOL . + 'request id:' . $result->requestId . PHP_EOL . + 'result:' . var_export($result, true) . PHP_EOL +); \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/sample/Uploader.php b/vendor/alibabacloud/oss-v2/sample/Uploader.php new file mode 100644 index 0000000..271bb01 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/sample/Uploader.php @@ -0,0 +1,133 @@ + ['help' => 'The region in which the bucket is located.', 'required' => True], + "endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False], + "bucket" => ['help' => 'The name of the bucket', 'required' => True], + "key" => ['help' => 'The name of the object', 'required' => True], +]; +$longopts = \array_map(function ($key) { + return "$key:"; +}, array_keys($optsdesc)); +$options = getopt("", $longopts); +foreach ($optsdesc as $key => $value) { + if ($value['required'] === True && empty($options[$key])) { + $help = $value['help']; + echo "Error: the following arguments are required: --$key, $help"; + exit(1); + } +} + +$region = $options["region"]; +$bucket = $options["bucket"]; +$key = $options["key"]; + +// Loading credentials values from the environment variables +$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider(); + +// Using the SDK's default configuration +$cfg = Oss\Config::loadDefault(); +$cfg->setCredentialsProvider($credentialsProvider); +$cfg->setRegion($region); +if (isset($options["endpoint"])) { + $cfg->setEndpoint($options["endpoint"]); +} + +$client = new Oss\Client($cfg); +$totalSize = 250 * 1024 + 123; +$partSize = 100 * 1024; + +$filename = "upload.tmp"; +$partSize = 200 * 1024; +generateFile($filename, $totalSize); + +// multi-part upload +$uploader = $client->newUploader(); + +$result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucket, + $key + ), + $filename, + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] +); +printf( + 'multipart upload status code:' . $result->statusCode . PHP_EOL . + 'multipart upload request id:' . $result->requestId . PHP_EOL . + 'multipart upload result:' . var_export($result, true) . PHP_EOL +); + +// single part upload +$result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucket, + $key + ), + $filename, + [ + 'part_size' => $totalSize * 2, + ] +); +printf( + 'single part upload status code:' . $result->statusCode . PHP_EOL . + 'single part upload request id:' . $result->requestId . PHP_EOL . + 'single part upload result:' . var_export($result, true) . PHP_EOL +); + +// upload from +$result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucket, + $key + ), + new \GuzzleHttp\Psr7\LazyOpenStream($filename, 'rb'), + [ + 'part_size' => $totalSize * 2, + ] +); +printf( + 'upload from status code:' . $result->statusCode . PHP_EOL . + 'upload from request id:' . $result->requestId . PHP_EOL . + 'upload from result:' . var_export($result, true) . PHP_EOL +); + +function generateFile($filename, $size) +{ + if ( + file_exists($filename) && + $size == sprintf('%u', filesize($filename)) + ) { + return; + } + $part_size = 32; + $fp = fopen($filename, "w"); + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $charactersLength = strlen($characters); + if ($fp) { + while ($size > 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + break; + } + } + } + fclose($fp); +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Annotation/AnnotationInterface.php b/vendor/alibabacloud/oss-v2/src/Annotation/AnnotationInterface.php new file mode 100644 index 0000000..c714b1c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Annotation/AnnotationInterface.php @@ -0,0 +1,10 @@ + $attribute->newInstance(), + $obj->getAttributes(XmlRoot::class, \ReflectionAttribute::IS_INSTANCEOF), + ); + + if (count($result) > 0) { + return $result[0]; + } + return null; + } + + public static function isRequiredProperty(\ReflectionProperty $property): bool + { + $result = $property->getAttributes(RequiredProperty::class, \ReflectionAttribute::IS_INSTANCEOF); + return count($result) > 0; + } + + public static function getXmlElementAnnotation(\ReflectionProperty $property): ?XmlElement + { + $result = self::getPropertyAnnotationsBy($property, XmlElement::class); + if (count($result) > 0) { + return $result[0]; + } + return null; + } + + public static function getTagAnnotation(\ReflectionProperty $property): ?TagProperty + { + $result = self::getPropertyAnnotationsBy($property, TagProperty::class); + if (count($result) > 0) { + return $result[0]; + } + return null; + } + + public static function getHeaderAnnotation(\ReflectionProperty $property): ?TagProperty + { + $result = self::getPropertyAnnotationsBy($property, TagHeader::class); + if (count($result) > 0) { + return $result[0]; + } + return null; + } + + public static function getQueryAnnotation(\ReflectionProperty $property): ?TagProperty + { + $result = self::getPropertyAnnotationsBy($property, TagQuery::class); + if (count($result) > 0) { + return $result[0]; + } + return null; + } + + public static function getBodyAnnotation(\ReflectionProperty $property): ?TagProperty + { + $result = self::getPropertyAnnotationsBy($property, TagBody::class); + if (count($result) > 0) { + return $result[0]; + } + return null; + } + + public static function getPropertyAnnotations(\ReflectionProperty $property): array + { + return self::getPropertyAnnotationsBy($property, AnnotationInterface::class); + } + + private static function getPropertyAnnotationsBy(\ReflectionProperty $property, string $name): array + { + return array_map( + static fn(\ReflectionAttribute $attribute): object => $attribute->newInstance(), + $property->getAttributes($name, \ReflectionAttribute::IS_INSTANCEOF), + ); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Annotation/RequiredProperty.php b/vendor/alibabacloud/oss-v2/src/Annotation/RequiredProperty.php new file mode 100644 index 0000000..b4e495e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Annotation/RequiredProperty.php @@ -0,0 +1,8 @@ +tag = $tag; + $this->position = $position; + $this->rename = $rename; + $this->type = $type; + $this->format = $format; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Annotation/TagQuery.php b/vendor/alibabacloud/oss-v2/src/Annotation/TagQuery.php new file mode 100644 index 0000000..c9fdae3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Annotation/TagQuery.php @@ -0,0 +1,14 @@ +rename = $rename; + $this->type = $type; + $this->format = $format; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Annotation/XmlRoot.php b/vendor/alibabacloud/oss-v2/src/Annotation/XmlRoot.php new file mode 100644 index 0000000..83fc6c5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Annotation/XmlRoot.php @@ -0,0 +1,16 @@ +name = $name; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Client.php b/vendor/alibabacloud/oss-v2/src/Client.php new file mode 100644 index 0000000..edbea97 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Client.php @@ -0,0 +1,435 @@ + ['connect_timeout' => 10.0 ]] + * + * @method \GuzzleHttp\Promise\Promise putBucketAsync(Models\PutBucketRequest $request, array $args = []) Creates a bucket. + * @method Models\PutBucketResult putBucket(Models\PutBucketRequest $request, array $args = []) Creates a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketAsync(Models\DeleteBucketRequest $request, array $args = []) Deletes a bucket. + * @method Models\PutBucketResult deleteBucket(Models\DeleteBucketRequest $request, array $args = []) Deletes a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketAclAsync(Models\PutBucketAclRequest $request, array $args = []) Configures or modifies the access control list (ACL) for a bucket. + * @method Models\PutBucketAclResult putBucketAcl(Models\PutBucketAclRequest $request, array $args = []) Configures or modifies the access control list (ACL) for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketAclAsync(Models\GetBucketAclRequest $request, array $args = []) Queries the access control list (ACL) of a bucket. Only the owner of a bucket can query the ACL of the bucket. + * @method Models\GetBucketAclResult getBucketAcl(Models\GetBucketAclRequest $request, array $args = []) Queries the access control list (ACL) of a bucket. Only the owner of a bucket can query the ACL of the bucket. + * @method \GuzzleHttp\Promise\Promise getBucketStatAsync(Models\GetBucketStatRequest $request, array $args = []) Queries the storage capacity of a bucket and the number of objects that are stored in the bucket. + * @method Models\GetBucketStatResult getBucketStat(Models\GetBucketStatRequest $request, array $args = []) Queries the storage capacity of a bucket and the number of objects that are stored in the bucket. + * @method \GuzzleHttp\Promise\Promise getBucketLocationAsync(Models\GetBucketLocationRequest $request, array $args = []) Queries the region in which a bucket resides. Only the owner of a bucket can query the region in which the bucket resides. + * @method Models\GetBucketLocationResult getBucketLocation(Models\GetBucketLocationRequest $request, array $args = []) Queries the region in which a bucket resides. Only the owner of a bucket can query the region in which the bucket resides. + * @method \GuzzleHttp\Promise\Promise getBucketInfoAsync(Models\GetBucketInfoRequest $request, array $args = []) Queries the information about a bucket. Only the owner of a bucket can query the information about the bucket. You can call this operation from an Object Storage Service (OSS) endpoint. + * @method Models\GetBucketInfoResult getBucketInfo(Models\GetBucketInfoRequest $request, array $args = []) Queries the information about a bucket. Only the owner of a bucket can query the information about the bucket. You can call this operation from an Object Storage Service (OSS) endpoint. + * @method \GuzzleHttp\Promise\Promise putBucketVersioningAsync(Models\PutBucketVersioningRequest $request, array $args = []) Configures the versioning state for a bucket. + * @method Models\PutBucketVersioningResult putBucketVersioning(Models\PutBucketVersioningRequest $request, array $args = []) Configures the versioning state for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketVersioningAsync(Models\GetBucketVersioningRequest $request, array $args = []) Queries the versioning state of a bucket. + * @method Models\GetBucketVersioningResult getBucketVersioning(Models\GetBucketVersioningRequest $request, array $args = []) Queries the versioning state of a bucket. + * @method \GuzzleHttp\Promise\Promise listObjectsAsync(Models\ListObjectsRequest $request, array $args = []) Queries the information about all objects in a bucket. + * @method Models\ListObjectsResult listObjects(Models\ListObjectsRequest $request, array $args = []) Queries the information about all objects in a bucket. + * @method \GuzzleHttp\Promise\Promise listObjectsV2Async(Models\ListObjectsV2Request $request, array $args = []) Queries the information about all objects in a bucket. + * @method Models\ListObjectsV2Result listObjectsV2(Models\ListObjectsV2Request $request, array $args = []) Queries the information about all objects in a bucket. + * @method \GuzzleHttp\Promise\Promise listObjectVersionsAsync(Models\ListObjectVersionsRequest $request, array $args = []) Queries the information about the versions of all objects in a bucket, including the delete markers. + * @method Models\ListObjectVersionsResult listObjectVersions(Models\ListObjectVersionsRequest $request, array $args = []) Queries the information about the versions of all objects in a bucket, including the delete markers. + * @method Models\PutObjectResult putObject(Models\PutObjectRequest $request, array $args = []) You can call this operation to upload an object. + * @method \GuzzleHttp\Promise\Promise putObjectAsync(Models\PutObjectRequest $request, array $args = []) You can call this operation to upload an object. + * @method Models\CopyObjectResult copyObject(Models\CopyObjectRequest $request, array $args = []) Copies objects within a bucket or between buckets in the same region. + * @method \GuzzleHttp\Promise\Promise copyObjectAsync(Models\CopyObjectRequest $request, array $args = []) Copies objects within a bucket or between buckets in the same region. + * @method Models\GetObjectResult getObject(Models\GetObjectRequest $request, array $args = []) You can call this operation to query an object. + * @method \GuzzleHttp\Promise\Promise getObjectAsync(Models\GetObjectRequest $request, array $args = []) You can call this operation to query an object. + * @method Models\AppendObjectResult appendObject(Models\AppendObjectRequest $request, array $args = []) You can call this operation to upload an object by appending the object to an existing object. + * @method \GuzzleHttp\Promise\Promise appendObjectAsync(Models\AppendObjectRequest $request, array $args = []) You can call this operation to upload an object by appending the object to an existing object. + * @method Models\SealAppendObjectResult sealAppendObject(Models\SealAppendObjectRequest $request, array $args = []) This operation stops writing to the Appendable Object, after which the user can configure lifecycle rules to change the storage class of the corresponding Appendable Object to Cold Archive or Deep Cold Archive. + * @method \GuzzleHttp\Promise\Promise sealAppendObjectAsync(Models\SealAppendObjectRequest $request, array $args = []) This operation stops writing to the Appendable Object, after which the user can configure lifecycle rules to change the storage class of the corresponding Appendable Object to Cold Archive or Deep Cold Archive. + * @method Models\DeleteObjectResult deleteObject(Models\DeleteObjectRequest $request, array $args = []) You can call this operation to delete an object. + * @method \GuzzleHttp\Promise\Promise deleteObjectAsync(Models\DeleteObjectRequest $request, array $args = []) You can call this operation to delete an object. + * @method Models\DeleteMultipleObjectsResult deleteMultipleObjects(Models\DeleteMultipleObjectsRequest $request, array $args = []) You can call this operation to delete an object. + * @method \GuzzleHttp\Promise\Promise deleteMultipleObjectsAsync(Models\DeleteMultipleObjectsRequest $request, array $args = []) You can call this operation to delete an object. + * @method Models\HeadObjectResult headObject(Models\HeadObjectRequest $request, array $args = []) You can call this operation to query the metadata of an object. + * @method \GuzzleHttp\Promise\Promise headObjectAsync(Models\HeadObjectRequest $request, array $args = []) You can call this operation to query the metadata of an object. + * @method Models\GetObjectMetaResult getObjectMeta(Models\GetObjectMetaRequest $request, array $args = []) You can call this operation to query the metadata of an object, including ETag, Size, and LastModified. The content of the object is not returned. + * @method \GuzzleHttp\Promise\Promise getObjectMetaAsync(Models\GetObjectMetaRequest $request, array $args = []) You can call this operation to query the metadata of an object, including ETag, Size, and LastModified. The content of the object is not returned. + * @method Models\RestoreObjectResult restoreObject(Models\RestoreObjectRequest $request, array $args = []) You can call this operation to restore objects of the Archive and Cold Archive storage classes. You are charged based on tier(restoration priority) when you restore object. For more information, see OSS document. + * @method \GuzzleHttp\Promise\Promise restoreObjectAsync(Models\RestoreObjectRequest $request, array $args = []) You can call this operation to restore objects of the Archive and Cold Archive storage classes. You are charged based on tier(restoration priority) when you restore object. For more information, see OSS document. + * @method Models\PutObjectAclResult putObjectAcl(Models\PutObjectAclRequest $request, array $args = []) You can call this operation to modify the ACL of an object. + * @method \GuzzleHttp\Promise\Promise putObjectAclAsync(Models\PutObjectAclRequest $request, array $args = []) You can call this operation to modify the ACL of an object. + * @method Models\GetObjectAclResult getObjectAcl(Models\GetObjectAclRequest $request, array $args = []) You can call this operation to query the ACL of an object in a bucket. + * @method \GuzzleHttp\Promise\Promise getObjectAclAsync(Models\GetObjectAclRequest $request, array $args = []) You can call this operation to query the ACL of an object in a bucket. + * @method Models\PutObjectTaggingResult putObjectTagging(Models\PutObjectTaggingRequest $request, array $args = []) You can call this operation to add tags to or modify the tags of an object. + * @method \GuzzleHttp\Promise\Promise putObjectTaggingAsync(Models\PutObjectTaggingRequest $request, array $args = []) You can call this operation to add tags to or modify the tags of an object. + * @method Models\GetObjectTaggingResult getObjectTagging(Models\GetObjectTaggingRequest $request, array $args = []) You can call this operation to query the tags of an object. + * @method \GuzzleHttp\Promise\Promise getObjectTaggingAsync(Models\GetObjectTaggingRequest $request, array $args = []) You can call this operation to query the tags of an object. + * @method Models\DeleteObjectTaggingResult deleteObjectTagging(Models\DeleteObjectTaggingRequest $request, array $args = []) You can call this operation to delete the tags of a specified object. + * @method \GuzzleHttp\Promise\Promise deleteObjectTaggingAsync(Models\DeleteObjectTaggingRequest $request, array $args = []) You can call this operation to delete the tags of a specified object. + * @method Models\PutSymlinkResult putSymlink(Models\PutSymlinkRequest $request, array $args = []) You can create a symbolic link for a target object. + * @method \GuzzleHttp\Promise\Promise putSymlinkAsync(Models\PutSymlinkRequest $request, array $args = []) You can create a symbolic link for a target object. + * @method Models\GetSymlinkResult getSymlink(Models\GetSymlinkRequest $request, array $args = []) You can call this operation to query a symbolic link of an object. + * @method \GuzzleHttp\Promise\Promise getSymlinkAsync(Models\GetSymlinkRequest $request, array $args = []) You can call this operation to query a symbolic link of an object. + * @method Models\InitiateMultipartUploadResult initiateMultipartUpload(Models\InitiateMultipartUploadRequest $request, array $args = []) Initiates a multipart upload task. + * @method \GuzzleHttp\Promise\Promise initiateMultipartUploadAsync(Models\InitiateMultipartUploadRequest $request, array $args = []) Initiates a multipart upload task. + * @method Models\UploadPartResult uploadPart(Models\UploadPartRequest $request, array $args = []) You can call this operation to upload an object by part based on the object name and the upload ID that you specify. + * @method \GuzzleHttp\Promise\Promise uploadPartAsync(Models\UploadPartRequest $request, array $args = []) You can call this operation to upload an object by part based on the object name and the upload ID that you specify. + * @method Models\CompleteMultipartUploadResult completeMultipartUpload(Models\CompleteMultipartUploadRequest $request, array $args = []) You can call this operation to complete the multipart upload task of an object. + * @method \GuzzleHttp\Promise\Promise completeMultipartUploadAsync(Models\CompleteMultipartUploadRequest $request, array $args = []) You can call this operation to complete the multipart upload task of an object. + * @method Models\UploadPartCopyResult uploadPartCopy(Models\UploadPartCopyRequest $request, array $args = []) Copies data from an existing object to upload a part. + * @method \GuzzleHttp\Promise\Promise uploadPartCopyAsync(Models\UploadPartCopyRequest $request, array $args = []) Copies data from an existing object to upload a part. + * @method Models\AbortMultipartUploadResult abortMultipartUpload(Models\AbortMultipartUploadRequest $request, array $args = []) You can call this operation to cancel a multipart upload task and delete the parts that are uploaded by the multipart upload task. + * @method \GuzzleHttp\Promise\Promise abortMultipartUploadAsync(Models\AbortMultipartUploadRequest $request, array $args = []) You can call this operation to cancel a multipart upload task and delete the parts that are uploaded by the multipart upload task. + * @method Models\ListMultipartUploadsResult listMultipartUploads(Models\ListMultipartUploadsRequest $request, array $args = []) You can call this operation to list all ongoing multipart upload tasks. + * @method \GuzzleHttp\Promise\Promise listMultipartUploadsAsync(Models\ListMultipartUploadsRequest $request, array $args = []) You can call this operation to list all ongoing multipart upload tasks. + * @method Models\ListPartsResult listParts(Models\ListPartsRequest $request, array $args = []) You can call this operation to list all parts that are uploaded by using a specified upload ID. + * @method \GuzzleHttp\Promise\Promise listPartsAsync(Models\ListPartsRequest $request, array $args = []) You can call this operation to list all parts that are uploaded by using a specified upload ID. + * @method Models\CleanRestoredObjectResult cleanRestoredObject(Models\CleanRestoredObjectRequest $request, array $args = []) You can call this operation to clean an object restored from Archive or Cold Archive state. After that, the restored object returns to the frozen state. + * @method \GuzzleHttp\Promise\Promise cleanRestoredObjectAsync(Models\CleanRestoredObjectRequest $request, array $args = []) You can call this operation to clean an object restored from Archive or Cold Archive state. After that, the restored object returns to the frozen state. + * @method Models\ProcessObjectResult processObject(Models\ProcessObjectRequest $request, array $args = []) You can call this operation to apply process on the specified image file. + * @method \GuzzleHttp\Promise\Promise processObjectAsync(Models\ProcessObjectRequest $request, array $args = []) You can call this operation to apply process on the specified image file. + * @method Models\AsyncProcessObjectResult asyncProcessObject(Models\AsyncProcessObjectRequest $request, array $args = []) You can call this operation to apply async process on the specified image file. + * @method \GuzzleHttp\Promise\Promise asyncProcessObjectAsync(Models\AsyncProcessObjectRequest $request, array $args = []) You can call this operation to apply async process on the specified image file. + * @method Models\InitiateBucketWormResult initiateBucketWorm(Models\InitiateBucketWormRequest $request, array $args = []) Creates a retention policy. + * @method \GuzzleHttp\Promise\Promise initiateBucketWormAsync(Models\InitiateBucketWormRequest $request, array $args = []) Creates a retention policy. + * @method Models\AbortBucketWormResult abortBucketWorm(Models\AbortBucketWormRequest $request, array $args = []) Deletes an unlocked retention policy for a bucket. + * @method \GuzzleHttp\Promise\Promise abortBucketWormAsync(Models\AbortBucketWormRequest $request, array $args = []) Deletes an unlocked retention policy for a bucket. + * @method Models\CompleteBucketWormResult completeBucketWorm(Models\CompleteBucketWormRequest $request, array $args = []) Locks a retention policy. + * @method \GuzzleHttp\Promise\Promise completeBucketWormAsync(Models\CompleteBucketWormRequest $request, array $args = []) Locks a retention policy. + * @method Models\ExtendBucketWormResult extendBucketWorm(Models\ExtendBucketWormRequest $request, array $args = []) Extends the retention period of objects in a bucket for which a retention policy is locked. + * @method \GuzzleHttp\Promise\Promise extendBucketWormAsync(Models\ExtendBucketWormRequest $request, array $args = []) Extends the retention period of objects in a bucket for which a retention policy is locked. + * @method Models\GetBucketWormResult getBucketWorm(Models\GetBucketWormRequest $request, array $args = []) Queries the retention policy configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketWormAsync(Models\GetBucketWormRequest $request, array $args = []) Queries the retention policy configured for a bucket. + * @method Models\ListBucketsResult listBuckets(Models\ListBucketsRequest $request, array $args = []) Queries all buckets that are owned by a requester. + * @method \GuzzleHttp\Promise\Promise listBucketsAsync(Models\ListBucketsRequest $request, array $args = []) Queries all buckets that are owned by a requester. + * @method Models\DescribeRegionsResult describeRegions(Models\DescribeRegionsRequest $request, array $args = []) Queries the endpoints of all supported regions or the endpoints of a specific region. + * @method \GuzzleHttp\Promise\Promise describeRegionsAsync(Models\DescribeRegionsRequest $request, array $args = []) Queries the endpoints of all supported regions or the endpoints of a specific region. + * @method Models\PutBucketLifecycleResult putBucketLifecycle(Models\PutBucketLifecycleRequest $request, array $args = []) Configures a lifecycle rule for a bucket. After you configure a lifecycle rule for a bucket, Object Storage Service (OSS) automatically deletes the objects that matching the rule or converts the storage type of the objects based on the point in time that is specified in the lifecycle rule. + * @method \GuzzleHttp\Promise\Promise putBucketLifecycleAsync(Models\PutBucketLifecycleRequest $request, array $args = []) Configures a lifecycle rule for a bucket. After you configure a lifecycle rule for a bucket, Object Storage Service (OSS) automatically deletes the objects that matching the rule or converts the storage type of the objects based on the point in time that is specified in the lifecycle rule. + * @method Models\GetBucketLifecycleResult getBucketLifecycle(Models\GetBucketLifecycleRequest $request, array $args = []) Queries the lifecycle rules configured for a bucket. Only the owner of a bucket has the permissions to query the lifecycle rules configured for the bucket. + * @method \GuzzleHttp\Promise\Promise getBucketLifecycleAsync(Models\GetBucketLifecycleRequest $request, array $args = []) Queries the lifecycle rules configured for a bucket. Only the owner of a bucket has the permissions to query the lifecycle rules configured for the bucket. + * @method Models\DeleteBucketLifecycleResult deleteBucketLifecycle(Models\DeleteBucketLifecycleRequest $request, array $args = []) Deletes the lifecycle rules of a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketLifecycleAsync(Models\DeleteBucketLifecycleRequest $request, array $args = []) Deletes the lifecycle rules of a bucket. + * @method Models\PutBucketTransferAccelerationResult putBucketTransferAcceleration(Models\PutBucketTransferAccelerationRequest $request, array $args = []) Configures transfer acceleration for a bucket. After you enable transfer acceleration for a bucket, the object access speed is accelerated for users worldwide. The transfer acceleration feature is applicable to scenarios where data needs to be transferred over long geographical distances. This feature can also be used to download or upload objects that are gigabytes or terabytes in size. + * @method \GuzzleHttp\Promise\Promise putBucketTransferAccelerationAsync(Models\PutBucketTransferAccelerationRequest $request, array $args = []) Configures transfer acceleration for a bucket. After you enable transfer acceleration for a bucket, the object access speed is accelerated for users worldwide. The transfer acceleration feature is applicable to scenarios where data needs to be transferred over long geographical distances. This feature can also be used to download or upload objects that are gigabytes or terabytes in size. + * @method Models\GetBucketTransferAccelerationResult getBucketTransferAcceleration(Models\GetBucketTransferAccelerationRequest $request, array $args = []) Queries the transfer acceleration configurations of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketTransferAccelerationAsync(Models\GetBucketTransferAccelerationRequest $request, array $args = []) Queries the transfer acceleration configurations of a bucket. + * @method Models\GetMetaQueryStatusResult getMetaQueryStatus(Models\GetMetaQueryStatusRequest $request, array $args = []) Queries the information about the metadata index library of a bucket. + * @method \GuzzleHttp\Promise\Promise getMetaQueryStatusAsync(Models\GetMetaQueryStatusRequest $request, array $args = []) Queries the information about the metadata index library of a bucket. + * @method Models\CloseMetaQueryResult closeMetaQuery(Models\CloseMetaQueryRequest $request, array $args = []) Disables the metadata management feature for an Object Storage Service (OSS) bucket. After the metadata management feature is disabled for a bucket, OSS automatically deletes the metadata index library of the bucket and you cannot perform metadata indexing. + * @method \GuzzleHttp\Promise\Promise closeMetaQueryAsync(Models\CloseMetaQueryRequest $request, array $args = []) Disables the metadata management feature for an Object Storage Service (OSS) bucket. After the metadata management feature is disabled for a bucket, OSS automatically deletes the metadata index library of the bucket and you cannot perform metadata indexing. + * @method Models\DoMetaQueryResult doMetaQuery(Models\DoMetaQueryRequest $request, array $args = []) Queries the objects in a bucket that meet the specified conditions by using the data indexing feature. The information about the objects is listed based on the specified fields and sorting methods. + * @method \GuzzleHttp\Promise\Promise doMetaQueryAsync(Models\DoMetaQueryRequest $request, array $args = []) Queries the objects in a bucket that meet the specified conditions by using the data indexing feature. The information about the objects is listed based on the specified fields and sorting methods. + * @method Models\OpenMetaQueryResult openMetaQuery(Models\OpenMetaQueryRequest $request, array $args = []) Enables metadata management for a bucket. After you enable the metadata management feature for a bucket, Object Storage Service (OSS) creates a metadata index library for the bucket and creates metadata indexes for all objects in the bucket. After the metadata index library is created, OSS continues to perform quasi-real-time scans on incremental objects in the bucket and creates metadata indexes for the incremental objects. + * @method \GuzzleHttp\Promise\Promise openMetaQueryAsync(Models\OpenMetaQueryRequest $request, array $args = []) Enables metadata management for a bucket. After you enable the metadata management feature for a bucket, Object Storage Service (OSS) creates a metadata index library for the bucket and creates metadata indexes for all objects in the bucket. After the metadata index library is created, OSS continues to perform quasi-real-time scans on incremental objects in the bucket and creates metadata indexes for the incremental objects. + * @method Models\PutBucketAccessMonitorResult putBucketAccessMonitor(Models\PutBucketAccessMonitorRequest $request, array $args = []) Modifies the access tracking status of a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketAccessMonitorAsync(Models\PutBucketAccessMonitorRequest $request, array $args = []) Modifies the access tracking status of a bucket. + * @method Models\GetBucketAccessMonitorResult getBucketAccessMonitor(Models\GetBucketAccessMonitorRequest $request, array $args = []) Queries the access tracking status of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketAccessMonitorAsync(Models\GetBucketAccessMonitorRequest $request, array $args = []) Queries the access tracking status of a bucket. + * @method Models\PutCnameResult putCname(Models\PutCnameRequest $request, array $args = []) Maps a CNAME record to a bucket. + * @method \GuzzleHttp\Promise\Promise putCnameAsync(Models\PutCnameRequest $request, array $args = []) Maps a CNAME record to a bucket. + * @method Models\ListCnameResult listCname(Models\ListCnameRequest $request, array $args = []) Queries all CNAME records that are mapped to a bucket. + * @method \GuzzleHttp\Promise\Promise listCnameAsync(Models\ListCnameRequest $request, array $args = []) Queries all CNAME records that are mapped to a bucket. + * @method Models\DeleteCnameResult deleteCname(Models\DeleteCnameRequest $request, array $args = []) Deletes a CNAME record that is mapped to a bucket. + * @method \GuzzleHttp\Promise\Promise deleteCnameAsync(Models\DeleteCnameRequest $request, array $args = []) Deletes a CNAME record that is mapped to a bucket. + * @method Models\GetCnameTokenResult getCnameToken(Models\GetCnameTokenRequest $request, array $args = []) Queries the created CNAME tokens. + * @method \GuzzleHttp\Promise\Promise getCnameTokenAsync(Models\GetCnameTokenRequest $request, array $args = []) Queries the created CNAME tokens. + * @method Models\CreateCnameTokenResult createCnameToken(Models\CreateCnameTokenRequest $request, array $args = []) Creates a CNAME token to verify the ownership of a domain name. + * @method \GuzzleHttp\Promise\Promise createCnameTokenAsync(Models\CreateCnameTokenRequest $request, array $args = []) Creates a CNAME token to verify the ownership of a domain name. + * @method Models\PutBucketCorsResult putBucketCors(Models\PutBucketCorsRequest $request, array $args = []) Configures cross-origin resource sharing (CORS) rules for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketCorsAsync(Models\PutBucketCorsRequest $request, array $args = []) Configures cross-origin resource sharing (CORS) rules for a bucket. + * @method Models\GetBucketCorsResult getBucketCors(Models\GetBucketCorsRequest $request, array $args = []) Queries the cross-origin resource sharing (CORS) rules that are configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketCorsAsync(Models\GetBucketCorsRequest $request, array $args = []) Queries the cross-origin resource sharing (CORS) rules that are configured for a bucket. + * @method Models\DeleteBucketCorsResult deleteBucketCors(Models\DeleteBucketCorsRequest $request, array $args = []) Disables the cross-origin resource sharing (CORS) feature and deletes all CORS rules for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketCorsAsync(Models\DeleteBucketCorsRequest $request, array $args = []) Disables the cross-origin resource sharing (CORS) feature and deletes all CORS rules for a bucket. + * @method Models\OptionObjectResult optionObject(Models\OptionObjectRequest $request, array $args = []) Determines whether to send a cross-origin request. Before a cross-origin request is sent, the browser sends a preflight OPTIONS request that includes a specific origin, HTTP method, and header information to Object Storage Service (OSS) to determine whether to send the cross-origin request. + * @method \GuzzleHttp\Promise\Promise optionObjectAsync(Models\OptionObjectRequest $request, array $args = []) Determines whether to send a cross-origin request. Before a cross-origin request is sent, the browser sends a preflight OPTIONS request that includes a specific origin, HTTP method, and header information to Object Storage Service (OSS) to determine whether to send the cross-origin request. + * @method Models\PutBucketRequestPaymentResult putBucketRequestPayment(Models\PutBucketRequestPaymentRequest $request, array $args = []) Enables pay-by-requester for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketRequestPaymentAsync(Models\PutBucketRequestPaymentRequest $request, array $args = []) Enables pay-by-requester for a bucket. + * @method Models\GetBucketRequestPaymentResult getBucketRequestPayment(Models\GetBucketRequestPaymentRequest $request, array $args = []) Queries pay-by-requester configurations for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketRequestPaymentAsync(Models\GetBucketRequestPaymentRequest $request, array $args = []) Queries pay-by-requester configurations for a bucket. + * @method Models\PutBucketTagsResult putBucketTags(Models\PutBucketTagsRequest $request, array $args = []) Adds tags to or modifies the existing tags of a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketTagsAsync(Models\PutBucketTagsRequest $request, array $args = []) Adds tags to or modifies the existing tags of a bucket. + * @method Models\GetBucketTagsResult getBucketTags(Models\GetBucketTagsRequest $request, array $args = []) Queries the tags of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketTagsAsync(Models\GetBucketTagsRequest $request, array $args = []) Queries the tags of a bucket. + * @method Models\DeleteBucketTagsResult deleteBucketTags(Models\DeleteBucketTagsRequest $request, array $args = []) Deletes tags configured for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketTagsAsync(Models\DeleteBucketTagsRequest $request, array $args = []) Deletes tags configured for a bucket. + * @method Models\PutBucketRefererResult putBucketReferer(Models\PutBucketRefererRequest $request, array $args = []) Configures a Referer whitelist for an Object Storage Service (OSS) bucket. You can specify whether to allow the requests whose Referer field is empty or whose query strings are truncated. + * @method \GuzzleHttp\Promise\Promise putBucketRefererAsync(Models\PutBucketRefererRequest $request, array $args = []) Configures a Referer whitelist for an Object Storage Service (OSS) bucket. You can specify whether to allow the requests whose Referer field is empty or whose query strings are truncated. + * @method Models\GetBucketRefererResult getBucketReferer(Models\GetBucketRefererRequest $request, array $args = []) Queries the hotlink protection configurations for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketRefererAsync(Models\GetBucketRefererRequest $request, array $args = []) Queries the hotlink protection configurations for a bucket. + * @method Models\GetBucketWebsiteResult getBucketWebsite(Models\GetBucketWebsiteRequest $request, array $args = []) Queries the static website hosting status and redirection rules configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketWebsiteAsync(Models\GetBucketWebsiteRequest $request, array $args = []) Queries the static website hosting status and redirection rules configured for a bucket. + * @method Models\PutBucketWebsiteResult putBucketWebsite(Models\PutBucketWebsiteRequest $request, array $args = []) Enables the static website hosting mode for a bucket and configures redirection rules for the bucket. + * @method \GuzzleHttp\Promise\Promise putBucketWebsiteAsync(Models\PutBucketWebsiteRequest $request, array $args = []) Enables the static website hosting mode for a bucket and configures redirection rules for the bucket. + * @method Models\DeleteBucketWebsiteResult deleteBucketWebsite(Models\DeleteBucketWebsiteRequest $request, array $args = []) Disables the static website hosting mode and deletes the redirection rules for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketWebsiteAsync(Models\DeleteBucketWebsiteRequest $request, array $args = []) Disables the static website hosting mode and deletes the redirection rules for a bucket. + * @method Models\PutBucketLoggingResult putBucketLogging(Models\PutBucketLoggingRequest $request, array $args = []) Enables logging for a bucket. After you enable logging for a bucket, Object Storage Service (OSS) generates logs every hour based on the defined naming rule and stores the logs as objects in the specified destination bucket. + * @method \GuzzleHttp\Promise\Promise putBucketLoggingAsync(Models\PutBucketLoggingRequest $request, array $args = []) Enables logging for a bucket. After you enable logging for a bucket, Object Storage Service (OSS) generates logs every hour based on the defined naming rule and stores the logs as objects in the specified destination bucket. + * @method Models\GetBucketLoggingResult getBucketLogging(Models\GetBucketLoggingRequest $request, array $args = []) Queries the configurations of access log collection of a bucket. Only the owner of a bucket can query the configurations of access log collection of the bucket. + * @method \GuzzleHttp\Promise\Promise getBucketLoggingAsync(Models\GetBucketLoggingRequest $request, array $args = []) Queries the configurations of access log collection of a bucket. Only the owner of a bucket can query the configurations of access log collection of the bucket. + * @method Models\DeleteBucketLoggingResult deleteBucketLogging(Models\DeleteBucketLoggingRequest $request, array $args = []) Disables the logging feature for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketLoggingAsync(Models\DeleteBucketLoggingRequest $request, array $args = []) Disables the logging feature for a bucket. + * @method Models\PutUserDefinedLogFieldsConfigResult putUserDefinedLogFieldsConfig(Models\PutUserDefinedLogFieldsConfigRequest $request, array $args = []) Customizes the user_defined_log_fields field in real-time logs by adding custom request headers or query parameters to the field for subsequent analysis of requests. + * @method \GuzzleHttp\Promise\Promise putUserDefinedLogFieldsConfigAsync(Models\PutUserDefinedLogFieldsConfigRequest $request, array $args = []) Customizes the user_defined_log_fields field in real-time logs by adding custom request headers or query parameters to the field for subsequent analysis of requests. + * @method Models\GetUserDefinedLogFieldsConfigResult getUserDefinedLogFieldsConfig(Models\GetUserDefinedLogFieldsConfigRequest $request, array $args = []) Queries the custom configurations of the user_defined_log_fields field in the real-time logs of a bucket. + * @method \GuzzleHttp\Promise\Promise getUserDefinedLogFieldsConfigAsync(Models\GetUserDefinedLogFieldsConfigRequest $request, array $args = []) Queries the custom configurations of the user_defined_log_fields field in the real-time logs of a bucket. + * @method Models\DeleteUserDefinedLogFieldsConfigResult deleteUserDefinedLogFieldsConfig(Models\DeleteUserDefinedLogFieldsConfigRequest $request, array $args = []) Deletes the custom configurations of the user_defined_log_fields field in the real-time logs of a bucket. + * @method \GuzzleHttp\Promise\Promise deleteUserDefinedLogFieldsConfigAsync(Models\DeleteUserDefinedLogFieldsConfigRequest $request, array $args = []) Deletes the custom configurations of the user_defined_log_fields field in the real-time logs of a bucket. + * @method Models\PutBucketPolicyResult putBucketPolicy(Models\PutBucketPolicyRequest $request, array $args = []) Configures a policy for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketPolicyAsync(Models\PutBucketPolicyRequest $request, array $args = []) Configures a policy for a bucket. + * @method Models\GetBucketPolicyResult getBucketPolicy(Models\GetBucketPolicyRequest $request, array $args = []) Queries the policies configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketPolicyAsync(Models\GetBucketPolicyRequest $request, array $args = []) Queries the policies configured for a bucket. + * @method Models\DeleteBucketPolicyResult deleteBucketPolicy(Models\DeleteBucketPolicyRequest $request, array $args = []) Deletes a policy for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketPolicyAsync(Models\DeleteBucketPolicyRequest $request, array $args = []) Deletes a policy for a bucket. + * @method Models\GetBucketPolicyStatusResult getBucketPolicyStatus(Models\GetBucketPolicyStatusRequest $request, array $args = []) Checks whether the current bucket policy allows public access. + * @method \GuzzleHttp\Promise\Promise getBucketPolicyStatusAsync(Models\GetBucketPolicyStatusRequest $request, array $args = []) Checks whether the current bucket policy allows public access. + * @method Models\PutBucketEncryptionResult putBucketEncryption(Models\PutBucketEncryptionRequest $request, array $args = []) Configures encryption rules for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketEncryptionAsync(Models\PutBucketEncryptionRequest $request, array $args = []) Configures encryption rules for a bucket. + * @method Models\GetBucketEncryptionResult getBucketEncryption(Models\GetBucketEncryptionRequest $request, array $args = []) Queries the encryption rules configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketEncryptionAsync(Models\GetBucketEncryptionRequest $request, array $args = []) Queries the encryption rules configured for a bucket. + * @method Models\DeleteBucketEncryptionResult deleteBucketEncryption(Models\DeleteBucketEncryptionRequest $request, array $args = []) Deletes encryption rules for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketEncryptionAsync(Models\DeleteBucketEncryptionRequest $request, array $args = []) Deletes encryption rules for a bucket. + * @method Models\GetBucketArchiveDirectReadResult getBucketArchiveDirectRead(Models\GetBucketArchiveDirectReadRequest $request, array $args = []) Queries whether real-time access of Archive objects is enabled for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketArchiveDirectReadAsync(Models\GetBucketArchiveDirectReadRequest $request, array $args = []) Queries whether real-time access of Archive objects is enabled for a bucket. + * @method Models\PutBucketArchiveDirectReadResult putBucketArchiveDirectRead(Models\PutBucketArchiveDirectReadRequest $request, array $args = []) Enables or disables real-time access of Archive objects for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketArchiveDirectReadAsync(Models\PutBucketArchiveDirectReadRequest $request, array $args = []) Enables or disables real-time access of Archive objects for a bucket. + * @method Models\GetPublicAccessBlockResult getPublicAccessBlock(Models\GetPublicAccessBlockRequest $request, array $args = []) Queries the Block Public Access configurations of OSS resources. + * @method \GuzzleHttp\Promise\Promise getPublicAccessBlockAsync(Models\GetPublicAccessBlockRequest $request, array $args = []) Queries the Block Public Access configurations of OSS resources. + * @method Models\PutPublicAccessBlockResult putPublicAccessBlock(Models\PutPublicAccessBlockRequest $request, array $args = []) Enables or disables Block Public Access for Object Storage Service (OSS) resources. + * @method \GuzzleHttp\Promise\Promise putPublicAccessBlockAsync(Models\PutPublicAccessBlockRequest $request, array $args = []) Enables or disables Block Public Access for Object Storage Service (OSS) resources. + * @method Models\DeletePublicAccessBlockResult deletePublicAccessBlock(Models\DeletePublicAccessBlockRequest $request, array $args = []) Deletes the Block Public Access configurations of OSS resources. + * @method \GuzzleHttp\Promise\Promise deletePublicAccessBlockAsync(Models\DeletePublicAccessBlockRequest $request, array $args = []) Deletes the Block Public Access configurations of OSS resources. + * @method Models\GetBucketPublicAccessBlockResult getBucketPublicAccessBlock(Models\GetBucketPublicAccessBlockRequest $request, array $args = []) Queries the Block Public Access configurations of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketPublicAccessBlockAsync(Models\GetBucketPublicAccessBlockRequest $request, array $args = []) Queries the Block Public Access configurations of a bucket. + * @method Models\PutBucketPublicAccessBlockResult putBucketPublicAccessBlock(Models\PutBucketPublicAccessBlockRequest $request, array $args = []) Enables or disables Block Public Access for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketPublicAccessBlockAsync(Models\PutBucketPublicAccessBlockRequest $request, array $args = []) Enables or disables Block Public Access for a bucket. + * @method Models\DeleteBucketPublicAccessBlockResult deleteBucketPublicAccessBlock(Models\DeleteBucketPublicAccessBlockRequest $request, array $args = []) Deletes the Block Public Access configurations of a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketPublicAccessBlockAsync(Models\DeleteBucketPublicAccessBlockRequest $request, array $args = []) Deletes the Block Public Access configurations of a bucket. + * @method Models\ListAccessPointsResult listAccessPoints(Models\ListAccessPointsRequest $request, array $args = []) Queries the information about user-level or bucket-level access points. + * @method \GuzzleHttp\Promise\Promise listAccessPointsAsync(Models\ListAccessPointsRequest $request, array $args = []) Queries the information about user-level or bucket-level access points. + * @method Models\GetAccessPointResult getAccessPoint(Models\GetAccessPointRequest $request, array $args = []) Queries the information about an access point. + * @method \GuzzleHttp\Promise\Promise getAccessPointAsync(Models\GetAccessPointRequest $request, array $args = []) Queries the information about an access point. + * @method Models\GetAccessPointPolicyResult getAccessPointPolicy(Models\GetAccessPointPolicyRequest $request, array $args = []) Queries the configurations of an access point policy. + * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyAsync(Models\GetAccessPointPolicyRequest $request, array $args = []) Queries the configurations of an access point policy. + * @method Models\DeleteAccessPointPolicyResult deleteAccessPointPolicy(Models\DeleteAccessPointPolicyRequest $request, array $args = []) Deletes an access point policy. + * @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyAsync(Models\DeleteAccessPointPolicyRequest $request, array $args = []) Deletes an access point policy. + * @method Models\PutAccessPointPolicyResult putAccessPointPolicy(Models\PutAccessPointPolicyRequest $request, array $args = []) Configures an access point policy. + * @method \GuzzleHttp\Promise\Promise putAccessPointPolicyAsync(Models\PutAccessPointPolicyRequest $request, array $args = []) Configures an access point policy. + * @method Models\DeleteAccessPointResult deleteAccessPoint(Models\DeleteAccessPointRequest $request, array $args = []) Deletes an access point. + * @method \GuzzleHttp\Promise\Promise deleteAccessPointAsync(Models\DeleteAccessPointRequest $request, array $args = []) Deletes an access point. + * @method Models\CreateAccessPointResult createAccessPoint(Models\CreateAccessPointRequest $request, array $args = []) Creates an access point. + * @method \GuzzleHttp\Promise\Promise createAccessPointAsync(Models\CreateAccessPointRequest $request, array $args = []) Creates an access point. + * @method Models\PutBucketRtcResult putBucketRtc(Models\PutBucketRtcRequest $request, array $args = []) Enables or disables the Replication Time Control (RTC) feature for existing cross-region replication (CRR) rules. + * @method \GuzzleHttp\Promise\Promise putBucketRtcAsync(Models\PutBucketRtcRequest $request, array $args = []) Enables or disables the Replication Time Control (RTC) feature for existing cross-region replication (CRR) rules. + * @method Models\PutBucketReplicationResult putBucketReplication(Models\PutBucketReplicationRequest $request, array $args = []) Configures data replication rules for a bucket. Object Storage Service (OSS) supports cross-region replication (CRR) and same-region replication (SRR). + * @method \GuzzleHttp\Promise\Promise putBucketReplicationAsync(Models\PutBucketReplicationRequest $request, array $args = []) Configures data replication rules for a bucket. Object Storage Service (OSS) supports cross-region replication (CRR) and same-region replication (SRR). + * @method Models\GetBucketReplicationResult getBucketReplication(Models\GetBucketReplicationRequest $request, array $args = []) Queries the data replication rules configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketReplicationAsync(Models\GetBucketReplicationRequest $request, array $args = []) Queries the data replication rules configured for a bucket. + * @method Models\GetBucketReplicationLocationResult getBucketReplicationLocation(Models\GetBucketReplicationLocationRequest $request, array $args = []) Queries the regions in which available destination buckets reside. You can determine the region of the destination bucket to which the data in the source bucket are replicated based on the returned response. + * @method \GuzzleHttp\Promise\Promise getBucketReplicationLocationAsync(Models\GetBucketReplicationLocationRequest $request, array $args = []) Queries the regions in which available destination buckets reside. You can determine the region of the destination bucket to which the data in the source bucket are replicated based on the returned response. + * @method Models\GetBucketReplicationProgressResult getBucketReplicationProgress(Models\GetBucketReplicationProgressRequest $request, array $args = []) Queries the information about the data replication process of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketReplicationProgressAsync(Models\GetBucketReplicationProgressRequest $request, array $args = []) Queries the information about the data replication process of a bucket. + * @method Models\DeleteBucketReplicationResult deleteBucketReplication(Models\DeleteBucketReplicationRequest $request, array $args = []) Disables data replication for a bucket and deletes the data replication rule configured for the bucket. After you call this operation, all operations performed on the source bucket are not synchronized to the destination bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketReplicationAsync(Models\DeleteBucketReplicationRequest $request, array $args = []) Disables data replication for a bucket and deletes the data replication rule configured for the bucket. After you call this operation, all operations performed on the source bucket are not synchronized to the destination bucket. + * @method Models\ListCloudBoxesResult listCloudBoxes(Models\ListCloudBoxesRequest $request, array $args = []) Lists cloud box buckets that belong to the current account. + * @method \GuzzleHttp\Promise\Promise listCloudBoxesAsync(Models\ListCloudBoxesRequest $request, array $args = []) Lists cloud box buckets that belong to the current account. + * @method Models\ListBucketDataRedundancyTransitionResult listBucketDataRedundancyTransition(Models\ListBucketDataRedundancyTransitionRequest $request, array $args = []) Lists all redundancy type conversion tasks of a bucket. + * @method \GuzzleHttp\Promise\Promise listBucketDataRedundancyTransitionAsync(Models\ListBucketDataRedundancyTransitionRequest $request, array $args = []) Lists all redundancy type conversion tasks of a bucket. + * @method Models\ListUserDataRedundancyTransitionResult listUserDataRedundancyTransition(Models\ListUserDataRedundancyTransitionRequest $request, array $args = []) Lists all redundancy type conversion tasks. + * @method \GuzzleHttp\Promise\Promise listUserDataRedundancyTransitionAsync(Models\ListUserDataRedundancyTransitionRequest $request, array $args = []) Lists all redundancy type conversion tasks. + * @method Models\GetBucketDataRedundancyTransitionResult getBucketDataRedundancyTransition(Models\GetBucketDataRedundancyTransitionRequest $request, array $args = []) Queries the redundancy type conversion tasks of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketDataRedundancyTransitionAsync(Models\GetBucketDataRedundancyTransitionRequest $request, array $args = []) Queries the redundancy type conversion tasks of a bucket. + * @method Models\CreateBucketDataRedundancyTransitionResult createBucketDataRedundancyTransition(Models\CreateBucketDataRedundancyTransitionRequest $request, array $args = []) Creates a redundancy type conversion task for a bucket. + * @method \GuzzleHttp\Promise\Promise createBucketDataRedundancyTransitionAsync(Models\CreateBucketDataRedundancyTransitionRequest $request, array $args = []) Creates a redundancy type conversion task for a bucket. + * @method Models\DeleteBucketDataRedundancyTransitionResult deleteBucketDataRedundancyTransition(Models\DeleteBucketDataRedundancyTransitionRequest $request, array $args = []) Deletes a redundancy type conversion task of a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketDataRedundancyTransitionAsync(Models\DeleteBucketDataRedundancyTransitionRequest $request, array $args = []) Deletes a redundancy type conversion task of a bucket. + * @method Models\GetBucketHttpsConfigResult getBucketHttpsConfig(Models\GetBucketHttpsConfigRequest $request, array $args = []) Queries the Transport Layer Security (TLS) version configurations of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketHttpsConfigAsync(Models\GetBucketHttpsConfigRequest $request, array $args = []) Queries the Transport Layer Security (TLS) version configurations of a bucket. + * @method Models\PutBucketHttpsConfigResult putBucketHttpsConfig(Models\PutBucketHttpsConfigRequest $request, array $args = []) Enables or disables Transport Layer Security (TLS) version management for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketHttpsConfigAsync(Models\PutBucketHttpsConfigRequest $request, array $args = []) Enables or disables Transport Layer Security (TLS) version management for a bucket. + * @method Models\GetBucketResourceGroupResult getBucketResourceGroup(Models\GetBucketResourceGroupRequest $request, array $args = []) Queries the ID of the resource group to which a bucket belongs. + * @method \GuzzleHttp\Promise\Promise getBucketResourceGroupAsync(Models\GetBucketResourceGroupRequest $request, array $args = []) Queries the ID of the resource group to which a bucket belongs. + * @method Models\PutBucketResourceGroupResult putBucketResourceGroup(Models\PutBucketResourceGroupRequest $request, array $args = []) Modifies the ID of the resource group to which a bucket belongs. + * @method \GuzzleHttp\Promise\Promise putBucketResourceGroupAsync(Models\PutBucketResourceGroupRequest $request, array $args = []) Modifies the ID of the resource group to which a bucket belongs. + * @method Models\PutStyleResult putStyle(Models\PutStyleRequest $request, array $args = []) Adds an image style to a bucket. An image style contains one or more image processing parameters. + * @method \GuzzleHttp\Promise\Promise putStyleAsync(Models\PutStyleRequest $request, array $args = []) Adds an image style to a bucket. An image style contains one or more image processing parameters. + * @method Models\ListStyleResult listStyle(Models\ListStyleRequest $request, array $args = []) Queries all image styles that are created for a bucket. + * @method \GuzzleHttp\Promise\Promise listStyleAsync(Models\ListStyleRequest $request, array $args = []) Queries all image styles that are created for a bucket. + * @method Models\GetStyleResult getStyle(Models\GetStyleRequest $request, array $args = []) Queries the information about an image style of a bucket. + * @method \GuzzleHttp\Promise\Promise getStyleAsync(Models\GetStyleRequest $request, array $args = []) Queries the information about an image style of a bucket. + * @method Models\DeleteStyleResult deleteStyle(Models\DeleteStyleRequest $request, array $args = []) Deletes an image style from a bucket. + * @method \GuzzleHttp\Promise\Promise deleteStyleAsync(Models\DeleteStyleRequest $request, array $args = []) Deletes an image style from a bucket. + * @method Models\PutBucketInventoryResult putBucketInventory(Models\PutBucketInventoryRequest $request, array $args = []) Configures an inventory for a bucket. + * @method \GuzzleHttp\Promise\Promise putBucketInventoryAsync(Models\PutBucketInventoryRequest $request, array $args = []) Configures an inventory for a bucket. + * @method Models\GetBucketInventoryResult getBucketInventory(Models\GetBucketInventoryRequest $request, array $args = []) Queries the inventories that are configured for a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketInventoryAsync(Models\GetBucketInventoryRequest $request, array $args = []) Queries the inventories that are configured for a bucket. + * @method Models\ListBucketInventoryResult listBucketInventory(Models\ListBucketInventoryRequest $request, array $args = []) Queries all inventories in a bucket at a time. + * @method \GuzzleHttp\Promise\Promise listBucketInventoryAsync(Models\ListBucketInventoryRequest $request, array $args = []) Queries all inventories in a bucket at a time. + * @method Models\DeleteBucketInventoryResult deleteBucketInventory(Models\DeleteBucketInventoryRequest $request, array $args = []) Deletes an inventory for a bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketInventoryAsync(Models\DeleteBucketInventoryRequest $request, array $args = []) Deletes an inventory for a bucket. + * @method Models\PutBucketOverwriteConfigResult putBucketOverwriteConfig(Models\PutBucketOverwriteConfigRequest $request, array $args = []) Call the PutBucketOverwriteConfig operation to configure overwrite protection for a bucket. This prevents specified objects from being overwritten. + * @method \GuzzleHttp\Promise\Promise putBucketOverwriteConfigAsync(Models\PutBucketOverwriteConfigRequest $request, array $args = []) Call the PutBucketOverwriteConfig operation to configure overwrite protection for a bucket. This prevents specified objects from being overwritten. + * @method Models\GetBucketOverwriteConfigResult getBucketOverwriteConfig(Models\GetBucketOverwriteConfigRequest $request, array $args = []) Call the GetBucketOverwriteConfig operation to retrieve the overwrite configuration of a bucket. + * @method \GuzzleHttp\Promise\Promise getBucketOverwriteConfigAsync(Models\GetBucketOverwriteConfigRequest $request, array $args = []) Call the GetBucketOverwriteConfig operation to retrieve the overwrite configuration of a bucket. + * @method Models\DeleteBucketOverwriteConfigResult deleteBucketOverwriteConfig(Models\DeleteBucketOverwriteConfigRequest $request, array $args = []) Delete overwrite configuration rule for the bucket. + * @method \GuzzleHttp\Promise\Promise deleteBucketOverwriteConfigAsync(Models\DeleteBucketOverwriteConfigRequest $request, array $args = []) Delete overwrite configuration rule for the bucket. + */ +final class Client +{ + use ClientExtensionTrait; + + /** + * @var ClientImpl + */ + private ClientImpl $client; + + /** + * Client constructor. + * @param Config $config + * @param array $options + */ + public function __construct(Config $config, array $options = []) + { + $this->client = new ClientImpl($config, $options); + } + + /** + * @param OperationInput $input + * @param array $options + * @return OperationOutput + */ + public function invokeOperation(OperationInput $input, array $options = []): OperationOutput + { + return $this->client->executeAsync($input, $options)->wait(); + } + + /** + * @param OperationInput $input + * @param array $options + * @return GuzzleHttp\Promise\Promise + */ + public function invokeOperationAsync(OperationInput $input, array $options = []): GuzzleHttp\Promise\Promise + { + return $this->client->executeAsync($input, $options); + } + + /** + * @param string $name The api name. + * @param array $args + * @return GuzzleHttp\Promise\PromiseInterface|mixed + */ + public function __call($name, $args) + { + if (substr($name, -5) === 'Async') { + $name = substr($name, 0, -5); + $isAsync = true; + } + + // api name + $opName = ucfirst($name); + $class = Transform\Functions::getTransformClass($opName); + $fromFunc = "from$opName"; + $toFunc = "to$opName"; + + if ( + !\method_exists($class, $fromFunc) || + !\method_exists($class, $toFunc) + ) { + throw new \BadMethodCallException('Not implement ' . self::class . '::' . $name); + } + + // args, {Operation}Request request, array options + $request = isset($args[0]) ? $args[0] : []; + $options = count($args) > 1 ? $args[1] : []; + + if (!($request instanceof Types\RequestModel)) { + throw new \InvalidArgumentException('args[0] is not subclass of RequestModel, got ' . \gettype($request)); + } + + if (!\is_array($options)) { + $options = []; + } + + // execute + $input = call_user_func([$class, $fromFunc], $request); + $promise = $this->client->executeAsync($input, $options)->then( + function (OperationOutput $output) use ($toFunc, $class) { + return call_user_func([$class, $toFunc], $output); + } + ); + + // result + return !empty($isAsync) ? $promise : $promise->wait(); + } + + /** + * Generates the presigned URL. + * If you do not specify expires or expiration, the pre-signed URL uses 15 minutes as default. + * @param Models\GetObjectRequest|Models\PutObjectRequest|Models\HeadObjectRequest|Models\InitiateMultipartUploadRequest|Models\UploadPartRequest|Models\CompleteMultipartUploadRequest|Models\AbortMultipartUploadRequest $request The request for the Presign operation. + * @param array $args accepts the following: + * - expires \DateInterval: The expiration duration for the generated presign url. + * For example, ['expires' => \DateInterval::createFromDateString('1 day')] + * - expiration \DateTime: The expiration time for the generated presign url. + * For example, ['expiration' => \DateTime::createFromFormat(''Y-m-d\TH:i:s\Z'', '2024-12-03T03:30:19Z', new \DateTimeZone('UTC')] + * @return Models\PresignResult + * @throws \Exception + */ + public function presign($request, $args = []): Models\PresignResult + { + if (!($request instanceof Types\RequestModel)) { + throw new \InvalidArgumentException( + '$request is not subclass of RequestModel, got ' . \gettype($request) + ); + } + $validRequestTypes = [ + Models\GetObjectRequest::class, + Models\PutObjectRequest::class, + Models\HeadObjectRequest::class, + Models\InitiateMultipartUploadRequest::class, + Models\UploadPartRequest::class, + Models\CompleteMultipartUploadRequest::class, + Models\AbortMultipartUploadRequest::class, + ]; + + if (!in_array(get_class($request), $validRequestTypes, true)) { + throw new \InvalidArgumentException("Invalid request type: " . get_class($request)); + } + $name = \get_class($request); + $pos = \strrpos($name, '\\'); + $opName = \substr($name, $pos + 1, -7); + $class = Transform\Functions::getTransformClass($opName); + $fromFunc = "from$opName"; + + // prepare + $input = call_user_func([$class, $fromFunc], $request); + + $options = $args; + $options['sdk_presign'] = true; + $options['auth_method'] = 'query'; + if (isset($args['expiration']) && ($args['expiration'] instanceof \DateTime)) { + $input->setOpMetadata('expiration_time', $args['expiration']); + } else if (isset($args['expires']) && ($args['expires'] instanceof \DateInterval)) { + $expirationTime = (new \DateTime('now', new \DateTimeZone('UTC')))->add($args['expires']); + $input->setOpMetadata('expiration_time', $expirationTime); + } + + // execute + $result = $this->client->presignInner($input, $options); + + return new Models\PresignResult( + $result['method'], + $result['url'], + $result['expiration'] ?? null, + $result['signedHeaders'] ?? null + ); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/ClientExtensionTrait.php b/vendor/alibabacloud/oss-v2/src/ClientExtensionTrait.php new file mode 100644 index 0000000..c1901ac --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/ClientExtensionTrait.php @@ -0,0 +1,202 @@ +getBucketAcl(new Models\GetBucketAclRequest( + $bucket + ), $args); + } catch (Exception\OperationException $e) { + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + return $se->getErrorCode() !== "NoSuchBucket"; + } + // an unhandled exception + throw $e; + } + + return $result != null; + } + + /** + * Determines whether or not a object exists by name. + * This method uses GetObjectMeta operation. + * + * @param string $bucket The name of the bucket + * @param string $key The name of the key + * @param string|null $versionId The version id of the object. + * @param array $args + * @return bool + */ + public function isObjectExist(string $bucket, string $key, ?string $versionId = null, array $args = []): bool + { + try { + $result = $this->getObjectMeta(new Models\GetObjectMetaRequest( + $bucket, + $key, + $versionId + ), $args); + } catch (Exception\OperationException $e) { + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $errorCode = $se->getErrorCode(); + if ( + $errorCode === "NoSuchKey" || + ($errorCode === "BadErrorResponse" && $se->getStatusCode() === 404) + ) { + return false; + } + } + // an unhandled exception + throw $e; + } + + return $result != null; + } + + /** + * Creates uploader. + * The uploader calls the multipart upload operation to split a large local file or + * stream into multiple smaller parts and upload the parts in parallel to improve upload performance. + * + * @param array $args accepts the following: + * - part_size: (int) The part size. Default value: 6 MiB. + * - parallel_num: (int) The number of the upload tasks in parallel. + * Default value: 3. + * - leave_parts_on_error: (bool) Specifies whether to retain the uploaded parts when an upload task fails. + * By default, the uploaded parts are not retained. + * @return Uploader + */ + public function newUploader(array $args = []): Uploader + { + return new Uploader($this, $args); + } + + /** + * Creates downloader. + * The Downloader uses range download to split a large object into multiple smaller parts + * and download the parts in parallel to improve download performance. + * + * @param array $args accepts the following: + * - part_size: (int) The part size. Default value: 6 MiB. + * - parallel_num: (int) The number of the download tasks in parallel. + * Default value: 3. + * - use_temp_file: (bool) Specifies whether to use a temporary file when you download an object. + * @return Downloader + */ + public function newDownloader(array $args = []): Downloader + { + return new Downloader($this, $args); + } + + /** + * Creates Copier. + * Copier provides common copy operations, hides the differences and implementation details of the operations, + * and automatically selects the appropriate operation to copy objects + * according to the request parameters of the copy task. + * + * @param array $args accepts the following: + * - part_size int: The part size. Default value: 64 MiB. + * - parallel_num int: The number of the upload tasks in parallel. Default value: 3. + * - multipart_copy_threshold int: The minimum object size for calling the multipart copy operation. + * Default value: 200 MiB. + * - leave_parts_on_error bool: Specifies whether to retain the uploaded parts when an upload task fails. + * By default, the uploaded parts are not retained. + * - disable_shallow_copy bool: Specifies that the shallow copy capability is not used. + * By default, the shallow copy capability is used. + * @return Copier + */ + public function newCopier(array $args = []): Copier + { + return new Copier($this, $args); + } + + /** + * @param Models\GetObjectRequest $request The get object request. + * @param string $filePath The file path name. + * @param array $args + * @return Models\GetObjectResult + * @throws Exception\OperationException + */ + public function getObjectToFile(Models\GetObjectRequest $request, string $filePath, array $args = []): Models\GetObjectResult + { + return $this->getObjectToFileAsync($request, $filePath, $args)->wait(); + } + + /** + * Get object to local file. + * @param Models\GetObjectRequest $request The get object request. + * @param string $filePath The file path name. + * @param array $args + * @return \GuzzleHttp\Promise\PromiseInterface + * @throws Exception\OperationException + */ + public function getObjectToFileAsync(Models\GetObjectRequest $request, string $filePath, array $args = []) + { + return $this->getObjectAsync( + $request, + array_merge($args, [ + 'request_options' => array_merge( + $args['request_options'] ?? [], + ['sink' => $filePath] + ) + ]) + + ); + } + + /** + * Put Object from local file. + * @param Models\PutObjectRequest $request + * @param string $filePath + * @param array $args + * @return Models\PutObjectResult + * @throws Exception\OperationException + */ + public function putObjectFromFile(Models\PutObjectRequest $request, string $filePath, array $args = []): Models\PutObjectResult + { + return $this->putObjectFromFileAsync($request, $filePath, $args)->wait(); + } + + /** + * Put Object from local file. + * @param Models\PutObjectRequest $request + * @param string $filePath + * @param array $args + * @return \GuzzleHttp\Promise\Promise + * @throws Exception\OperationException + */ + public function putObjectFromFileAsync(Models\PutObjectRequest $request, string $filePath, array $args = []) + { + $stream = new \GuzzleHttp\Psr7\LazyOpenStream($filePath, 'rb'); + $stream->seek(0); + $req = clone $request; + $req->body = $stream; + if (empty($req->contentType)) { + $req->contentType = Utils::guessContentType($filePath, 'application/octet-stream'); + } + return $this->putObjectAsync($req, $args); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/ClientImpl.php b/vendor/alibabacloud/oss-v2/src/ClientImpl.php new file mode 100644 index 0000000..2c723ef --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/ClientImpl.php @@ -0,0 +1,752 @@ + + */ + private $sdkOptions = [ + 'product' => 'oss', + 'region' => null, + 'endpoint' => null, + 'retry_max_attempts' => null, + 'retryer' => null, + 'signer' => null, + 'credentials_provider' => null, + 'address_style' => 'virtual', + 'auth_method' => 'header', + 'response_handlers' => null, + 'feature_flags' => 0, + 'additional_headers' => null, + 'response_stream' => null, + ]; + + private $innerOptions = [ + 'handler' => null, + 'user_agent' => null, + ]; + + // guzzle + private GuzzleHttp\Client $httpClient; + private $requestOptions = [ + //GuzzleHttp\RequestOptions::ALLOW_REDIRECTS + 'allow_redirects' => false, + //GuzzleHttp\RequestOptions::CONNECT_TIMEOUT + 'connect_timeout' => Defaults::CONNECT_TIMEOUT, + //GuzzleHttp\RequestOptions::READ_TIMEOUT + 'read_timeout' => Defaults::READWRITE_TIMEOUT, + //GuzzleHttp\RequestOptions::VERIFY + 'verify' => true, + ]; + + public function __construct(Config $config, array $options = []) + { + $this->resolveConfig($config); + $this->resolveOptions($options); + $this->applyOptions(); + } + + public function executeAsync(OperationInput &$input, array &$options = []): GuzzleHttp\Promise\PromiseInterface + { + $this->verifyOperation($input); + [$request, $context] = $this->buildRequestContext($input, $options); + /** + * @var GuzzleHttp\Psr7\Request $request + */ + return $this->httpClient->sendAsync($request, $context)->then( + function ($response) use ($input) { + // unwrap stream from SinkStreamWrapper + $body = $response->getBody(); + if ($body instanceof SinkStreamWrapper) { + $body = $body->isFromFilepath() ? null : $body->unwrap(); + $responseRo = new \ReflectionObject($response); + if ($responseRo->hasProperty('stream')) { + $pp = $responseRo->getProperty('stream'); + if (PHP_VERSION_ID < 80100) { + $pp->setAccessible(true); + } + $pp->setValue($response, $body); + } + } + return new OperationOutput( + $response->getReasonPhrase(), + $response->getStatusCode(), + Utils::toSimpleArray($response->getHeaders()), + $body, + $input, + null, + $response, + ); + }, + function ($reason) use ($input) { + return GuzzleHttp\Promise\Create::rejectionFor(new Exception\OperationException( + $input->getOpName(), + $reason + )); + } + ); + } + + public function presignInner(OperationInput &$input, array &$options = []): array + { + $this->verifyOperation($input); + /** + * @var GuzzleHttp\Psr7\Request $request + */ + [$request, $context] = $this->buildRequestContext($input, $options); + $sdk_context = $context['sdk_context']; + /** + * @var Credentials\CredentialsProvider $provider + */ + $provider = $sdk_context['credentials_provider']; + $result = []; + if (!($provider instanceof Credentials\AnonymousCredentialsProvider)) { + try { + $cred = $provider->getCredentials(); + } catch (\Exception $e) { + throw new Exception\CredentialsException('Fetch Credentials raised an exception', $e); + } + if ($cred == null || !$cred->hasKeys()) { + throw new \InvalidArgumentException("Credentials is null or empty."); + } + /** + * @var Signer\SignerInterface $signer + */ + $signer = $sdk_context['signer']; + /** + * @var Signer\SigningContext $signingContext + */ + $signingContext = $context['signing_context']; + $signingContext->request = $request; + $signingContext->credentials = $cred; + $signer->sign($signingContext); + $request = $signingContext->request; + if ($signer instanceof Signer\SignerV4) { + if (isset($signingContext->time) && $signingContext->time instanceof \DateTime) { + $nowPlusSevenDays = new \DateTime(); + $nowPlusSevenDays->modify('+7 days'); + if ($signingContext->time > $nowPlusSevenDays) { + throw new \InvalidArgumentException("Expires should not be greater than 604800 (seven days)"); + } + } + } + //save to result + $result['expiration'] = $signingContext->time; + $matches = ['content-type', 'content-md5']; + if ($signer instanceof Signer\SignerV4 && !empty($signingContext->additionalHeaders)) { + foreach ($signingContext->additionalHeaders as $k) { + $matches[] = strtolower($k); + } + } + //signed headers + $signedHeaders = []; + foreach ($request->getHeaders() as $name => $values) { + $lowName = strtolower((string)$name); + if ( + \in_array($lowName, $matches) || + (strncmp($lowName, 'x-oss-', 6) == 0) + ) { + $signedHeaders[(string)$name] = $values[0]; + } + } + $result['signedHeaders'] = $signedHeaders; + } + + $result['url'] = $request->getUri()->__toString(); + $result['method'] = $request->getMethod(); + + return $result; + } + + private function resolveConfig(Config &$config) + { + // client's options + $options = $this->sdkOptions; + $options['region'] = $config->getRegion(); + $options['credentials_provider'] = $config->getCredentialsProvider(); + $options['additional_headers'] = $config->getAdditionalHeaders(); + $this->resolveEndpoint($config, $options); + $this->resolveRetryer($config, $options); + $this->resolveSigner($config, $options); + $this->resolveAddressStyle($config, $options); + $this->resolveFeatureFlags($config, $options); + $this->resolveCloudBox($config, $options); + + $this->sdkOptions = $options; + + // user-agent + $this->innerOptions['user_agent'] = $this->buildUserAgent($config); + + // guzzle's client + $options = $this->requestOptions; + $this->resolveHttpClient($config, $options); + $this->requestOptions = $options; + } + + private function resolveEndpoint(Config &$config, array &$options) + { + $disableSSL = Utils::safetyBool($config->getDisableSSL()); + $endpoint = Utils::safetyString($config->getEndpoint()); + $region = Utils::safetyString($config->getRegion()); + if (\strlen($endpoint) > 0) { + $endpoint = Utils::addScheme($endpoint, $disableSSL); + } else if (Validation::isValidRegion($region)) { + if (Utils::safetyBool($config->getUseDualStackEndpoint())) { + $etype = 'dualstack'; + } else if (Utils::safetyBool($config->getUseInternalEndpoint())) { + $etype = 'internal'; + } else if (Utils::safetyBool($config->getUseAccelerateEndpoint())) { + $etype = 'accelerate'; + } else { + $etype = 'default'; + } + $endpoint = Utils::regionToEndpoint($region, $disableSSL, $etype); + } + + if ($endpoint === '') { + return; + } + + $options['endpoint'] = new GuzzleHttp\Psr7\Uri($endpoint); + } + + private function resolveRetryer(Config &$config, array &$options) + { + if (Utils::safetyInt($config->getRetryMaxAttempts()) > 0) { + $options['retry_max_attempts'] = $config->getRetryMaxAttempts(); + } + + $options['retryer'] = $config->getRetryer() ?? new Retry\StandardRetryer(); + } + + private function resolveSigner(Config &$config, array &$options) + { + $value = Utils::safetyString($config->getSignatureVersion()); + $options['signer'] = $value == 'v1' ? new Signer\SignerV1() : new Signer\SignerV4(); + } + + private function resolveAddressStyle(Config &$config, array &$options) + { + if (Utils::safetyBool($config->getUseCname())) { + $options['address_style'] = 'cname'; + } else if (Utils::safetyBool($config->getUsePathStyle())) { + $options['address_style'] = 'path'; + } else { + $options['address_style'] = 'virtual'; + } + + if ($options['endpoint'] instanceof GuzzleHttp\Psr7\Uri) { + if (Utils::isIPFormat($options['endpoint']->getHost())) { + $options['address_style'] = 'path'; + } + } + } + + private function resolveFeatureFlags(Config &$config, array &$options) + { + } + + private function resolveHttpClient(Config &$config, array &$options) + { + // map into GuzzleHttp request options + if (Utils::safetyBool($config->getEnabledRedirect())) { + //GuzzleHttp\RequestOptions::ALLOW_REDIRECTS + $options['allow_redirects'] = true; + } + + if (Utils::safetyBool($config->getInsecureSkipVerify())) { + //GuzzleHttp\RequestOptions::VERIFY + $options['verify'] = false; + } + + $value = $config->getConnectTimeout(); + if (Utils::safetyFloat($value) > 0) { + //GuzzleHttp\RequestOptions::CONNECT_TIMEOUT + $options['connect_timeout'] = $value; + } + + $value = $config->getReadwriteTimeout(); + if (Utils::safetyFloat($value) > 0) { + //GuzzleHttp\RequestOptions::READ_TIMEOUT + $options['read_timeout'] = $value; + } + + $value = $config->getProxyHost(); + if (Utils::safetyString($value) !== '') { + //GuzzleHttp\RequestOptions::PROXY + $options['proxy'] = $value; + } + } + + private function resolveCloudBox(Config &$config, array &$options) + { + if ($config->getCloudBoxId() !== null) { + $options['region'] = $config->getCloudBoxId(); + $options['product'] = Defaults::CLOUD_BOX_PRODUCT; + return; + } + if ($config->getEnableAutoDetectCloudBoxId() == false) { + return; + } + if ($config->getEndpoint() == null) { + return; + } + //cb-***.{region}.oss-cloudbox-control.aliyuncs.com + //cb-***.{region}.oss-cloudbox.aliyuncs.com + $uri = new GuzzleHttp\Psr7\Uri($config->getEndpoint()); + $path = !empty($uri->getHost()) ? $uri->getHost() : $uri->getPath(); + if (!(substr($path, -strlen('.oss-cloudbox.aliyuncs.com')) === '.oss-cloudbox.aliyuncs.com' || substr($path, -strlen('.oss-cloudbox-control.aliyuncs.com')) === '.oss-cloudbox-control.aliyuncs.com')) { + return; + } + $keys = explode('.', $path); + if ($keys == false || + count($keys) !== 5 || + substr($keys[0], 0, strlen('cb-')) !== 'cb-') { + return; + } + $options['region'] = $keys[0]; + $options['product'] = Defaults::CLOUD_BOX_PRODUCT; + } + + private function resolveOptions(array &$options) + { + if (empty($options)) { + return; + } + + // sdk options + $opt = \array_filter($options, function ($key) { + return \array_key_exists($key, $this->sdkOptions); + }, \ARRAY_FILTER_USE_KEY); + $this->sdkOptions = array_replace($this->sdkOptions, $opt); + + // inner options + $opt = \array_filter($options, function ($key) { + return \array_key_exists($key, $this->innerOptions); + }, \ARRAY_FILTER_USE_KEY); + $this->innerOptions = array_replace($this->innerOptions, $opt); + + // Guzzle's request options + $src = $options['request_options'] ?? []; + if (!empty($src)) { + $allows = [ + 'allow_redirects', + 'proxy', + 'expect', + 'cert', + 'verify', + 'ssl_key', + 'connect_timeout', + 'read_timeout', + 'debug', + 'decode_content', + ]; + $opt = \array_filter($src, function ($key) use ($allows) { + return in_array($key, $allows); + }, \ARRAY_FILTER_USE_KEY); + $this->requestOptions = array_replace($this->requestOptions, $opt); + } + } + + private function applyOptions() + { + // GuzzleHttp\Client + // request options + $config = \array_merge([], $this->requestOptions); + + // stack + $handler = $this->innerOptions['handler'] ?: GuzzleHttp\Utils::chooseHandler(); + $stack = new GuzzleHttp\HandlerStack($handler); + + // retryer + $stack->push(RetryMiddleware::create( + static function ( + int $retries, + \Psr\Http\Message\RequestInterface $request, + \Throwable $reason, + array $options + ) { + + if (!$request->getBody()->isSeekable()) { + return false; + } + + // check sink + if (isset($options['sink']) && !$options['sink']->isSeekable()) { + return false; + } + + if ($retries + 1 >= $options['sdk_context']['retry_max_attempts']) { + return false; + } + + // api's timeout + + + // retryable error + if (!$options['sdk_context']['retryer']->isErrorRetryable($reason)) { + return false; + } + + // reset state + try { + $request->getBody()->rewind(); + if (isset($options['sink'])) { + $options['sink']->rewind(); + $options['sink']->resetMemState(); + } + } catch (\Exception $e) { + throw new Exception\StreamRewindException($e->getMessage(), $reason); + } + + if ($options['sdk_context']['reset_time']) { + $options['signing_context']->time = null; + } + + //printf("retry cnt %d, %d\n", $retries, $options['sdk_context']['retry_max_attempts']); + return true; + }, + static function (int $retries, array $options): int { + //int in milliseconds + $delay = $options['sdk_context']['retryer']->retryDelay($retries, null); + return (int)($delay * 1000); + }, + ), 'retryer'); + + // signer + $stack->push(static function (callable $handler): callable { + return static function (\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { + $sdk_context = $options['sdk_context']; + $provider = $sdk_context['credentials_provider']; + if (!($provider instanceof Credentials\AnonymousCredentialsProvider)) { + try { + $cred = $provider->getCredentials(); + } catch (\Exception $e) { + throw new Exception\CredentialsException('Fetch Credentials raised an exception', $e); + } + + if ($cred == null || !$cred->hasKeys()) { + throw new \InvalidArgumentException("Credentials is null or empty."); + } + $signer = $sdk_context['signer']; + $signingContext = $options['signing_context']; + $signingContext->request = $request; + $signingContext->credentials = $cred; + $signer->sign($signingContext); + $request = $signingContext->request; + } + return $handler($request, $options); + }; + }, 'signer'); + + // http response checker + $stack->push(static function (callable $handler): callable { + return static function ($request, array $options) use ($handler) { + if (empty($options['response_handlers'])) { + return $handler($request, $options); + } + return $handler($request, $options)->then( + static function (\Psr\Http\Message\ResponseInterface $response) use ($request, $options) { + foreach ($options['response_handlers'] as $h) { + if (\is_callable($h)) { + $h($request, $response, $options); + } else { + call_user_func($h, $request, $response, $options); + } + } + return $response; + } + ); + }; + }, 'response_handlers'); + + $stack->push(GuzzleHttp\Middleware::redirect(), 'allow_redirects'); + $stack->push(GuzzleHttp\Middleware::prepareBody(), 'prepare_body'); + + $config['handler'] = $stack; + + $this->httpClient = new GuzzleHttp\Client($config); + } + + + private function buildUserAgent(Config &$config) + { + $value = Utils::defaultUserAgent(); + + if ($config->getUserAgent() != null) { + $value = $value . '/' . $config->getUserAgent(); + } + + return $value; + } + + private function buildUri(OperationInput &$input, \Psr\Http\Message\UriInterface $uri): \Psr\Http\Message\UriInterface + { + $paths = []; + if ($input->getBucket() != null) { + switch ($this->sdkOptions['address_style']) { + case 'path': + array_push($paths, $input->getBucket()); + if ($input->getKey() == null) { + array_push($paths, ''); + } + break; + case 'cname': + break; + default: + $uri = $uri->withHost($input->getBucket() . '.' . $uri->getHost()); + break; + } + } + + if ($input->getKey() != null) { + array_push($paths, Utils::urlEncode($input->getKey(), true)); + } + + return $uri->withPath('/' . implode('/', $paths)); + } + + private function verifyOperation(OperationInput &$input) + { + if (!isset($this->sdkOptions['endpoint'])) { + throw new \InvalidArgumentException('endpoint is invalid.'); + } + + if ( + $input->getBucket() != null && + !Validation::isValidBucketName($input->getBucket()) + ) { + throw new \InvalidArgumentException('Bucket name is invalid, got ' . $input->getBucket()); + } + + if ( + $input->getKey() != null && + !Validation::isValidObjectName($input->getKey()) + ) { + throw new \InvalidArgumentException('Object name is invalid, got ' . $input->getKey()); + } + } + + /** + * @param OperationInput $input + * @param array $options + * @return array + */ + private function buildRequestContext(OperationInput &$input, array &$options) + { + $context = []; + // GuzzleHttp's request options for api + if (isset($options['request_options'])) { + if (isset($options['request_options']['connect_timeout'])) { + $context['connect_timeout'] = $options['request_options']['connect_timeout']; + } + if (isset($options['request_options']['read_timeout'])) { + $context['read_timeout'] = $options['request_options']['read_timeout']; + } + if (isset($options['request_options']['timeout'])) { + $context['timeout'] = $options['request_options']['timeout']; + } + if (isset($options['request_options']['on_headers'])) { + $context['on_headers'] = $options['request_options']['on_headers']; + } + if (isset($options['request_options']['sink'])) { + $sink = $options['request_options']['sink']; + $sink = SinkStreamWrapper::sinkFor($sink); + $context['sink'] = $sink; + $context['on_headers'] = function (\Psr\Http\Message\ResponseInterface $response) use (&$sink) { + $sink->on_headers($response); + }; + } + if (isset($options['request_options']['stream'])) { + $context['stream'] = $options['request_options']['stream']; + } + if (isset($options['request_options']['on_stats'])) { + $context['on_stats'] = $options['request_options']['on_stats']; + } + } + + // retry options for api + $retryer = $options['retryer'] ?? $this->sdkOptions['retryer']; + if (Utils::safetyInt($options['retry_max_attempts'] ?? 0) > 0) { + $retry_max_attempts = $options['retry_max_attempts']; + } else if (isset($this->sdkOptions['retry_max_attempts'])) { + $retry_max_attempts = $this->sdkOptions['retry_max_attempts']; + } else { + $retry_max_attempts = $retryer->getMaxAttempts(); + } + + // sdk's part + $sdk_context = [ + 'retry_max_attempts' => \max($retry_max_attempts, 1), + 'retryer' => $retryer, + 'signer' => $this->sdkOptions['signer'], + 'credentials_provider' => $options['credentials_provider'] ?? $this->sdkOptions['credentials_provider'], + ]; + + $context['sdk_context'] = $sdk_context; + + + // Request + // host & path & query + /** + * @var \Psr\Http\Message\UriInterface $endpoint + */ + $endpoint = $this->sdkOptions['endpoint']; + $baseuri = $endpoint->getScheme() . "://" . $endpoint->getAuthority(); + $uri = $this->buildUri($input, new GuzzleHttp\Psr7\Uri($baseuri)); + $query = $input->getParameters(); + if (!empty($query)) { + $uri = $uri->withQuery( + http_build_query($query, '', '&', PHP_QUERY_RFC3986) + ); + } + + $request = new GuzzleHttp\Psr7\Request( + $input->getMethod(), + $uri, + $input->getHeaders(), + $input->getBody(), + ); + + // user agent + $request = $request->withAddedHeader('User-Agent', $this->innerOptions['user_agent']); + + // Add a default content-type if possible. + if ($input->hasOpMetadata('detect_content_type') && + !isset($options['sdk_presign']) && + !$request->hasHeader('Content-Type')) { + $value = Utils::guessContentType($input->getKey()); + // compatibility with PrepareBodyMiddleware + if ($value == null && $request->getBody() != null) { + if ($uri = $request->getBody()->getMetadata('uri')) { + if (is_string($uri) && $type = Utils::guessContentType($uri)) { + $value = $type; + } + } + } + if ($value == null) { + $value = 'application/octet-stream'; + } + $request = $request->withAddedHeader('Content-Type', $value); + } + + // signing context + $signingContext = new Signer\SigningContext( + $this->sdkOptions['product'], + $this->sdkOptions['region'], + $input->getBucket(), + $input->getKey(), + $request + ); + if (isset($this->sdkOptions['additional_headers'])) { + $signingContext->additionalHeaders = $this->sdkOptions['additional_headers']; + } + $auth_method = $options['auth_method'] ?? $this->sdkOptions['auth_method']; + $signingContext->authMethodQuery = $auth_method === 'query'; + $signingContext->subResource = ($input->getOpMetadata())['sub-resource'] ?? []; + + // signing time from user + if (isset(($input->getOpMetadata())['expiration_time'])) { + $signingContext->time = ($input->getOpMetadata())['expiration_time']; + } + + $context['signing_context'] = $signingContext; + + $context['sdk_context']['reset_time'] = $signingContext->time == null; + + // response-handler + $responseHandlers = [ + [ClientImpl::class, 'httpErrors'], + ]; + + if (isset($options['response_handlers'])) { + foreach ($options['response_handlers'] as $h) { + \array_push($responseHandlers, $h); + } + } + + $context['response_handlers'] = $responseHandlers; + + return [$request, $context]; + } + + private static function httpErrors( + \Psr\Http\Message\RequestInterface $request, + \Psr\Http\Message\ResponseInterface $response, + array $options + ) + { + $statusCode = $response->getStatusCode(); + if (intval($statusCode / 100) == 2) { + return; + } + $content = isset($options['sink']) ? $options['sink']->getMemContent() : + $response->getBody()->getContents(); + $code = 'BadErrorResponse'; + $message = ''; + $ec = ''; + $requestId = ''; + $errorFields = []; + + $xmlStr = $content; + if ($xmlStr === '' && $response->hasHeader('x-oss-err')) { + $xmlStr = base64_decode($response->getHeader('x-oss-err')[0]); + } + + if (strpos($xmlStr, '') !== false) { + try { + $xml = Utils::parseXml($xmlStr); + $code = isset($xml->Code) ? (string)$xml->Code : $code; + $message = isset($xml->Message) ? (string)$xml->Message : ''; + $ec = isset($xml->EC) ? (string)$xml->EC : ''; + $requestId = isset($xml->RequestId) ? (string)$xml->RequestId : ''; + foreach ($xml as $key => $val) { + $errorFields[$key] = (string)$val; + } + } catch (\Exception $e) { + //maybe contains speical char, from 0x1 - 0x1F + //find ... ... ... ... + $value = Utils::findXmlElementText($xmlStr, 'Code'); + if ($value !== '') { + $code = $value; + $message = Utils::findXmlElementText($xmlStr, 'Message'); + $requestId = Utils::findXmlElementText($xmlStr, 'RequestId'); + $ec = Utils::findXmlElementText($xmlStr, 'EC'); + } else { + $message = 'Failed to parse xml from response body, part response body ' . substr($xmlStr, 0, 256); + } + } + } else { + $message = 'Not found tag , part response body ' . substr($xmlStr, 0, 256); + } + + if ($requestId == '' && $response->hasHeader('x-oss-request-id')) { + $requestId = $response->getHeader('x-oss-request-id')[0]; + } + + if ($ec == '' && $response->hasHeader('x-oss-ec')) { + $ec = $response->getHeader('x-oss-ec')[0]; + } + + throw new Exception\ServiceException( + [ + 'status_code' => $statusCode, + 'request_id' => $requestId, + 'code' => $code, + 'message' => $message, + 'ec' => $ec, + 'request_target' => $request->getMethod() . ' ' . $request->getUri(), + 'snapshot' => $content, + 'headers' => $response->getHeaders(), + 'error_fields' => $errorFields + ] + ); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Config.php b/vendor/alibabacloud/oss-v2/src/Config.php new file mode 100644 index 0000000..9d82294 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Config.php @@ -0,0 +1,700 @@ +region = $region; + $this->endpoint = $endpoint; + $this->signatureVersion = $signatureVersion; + $this->credentialsProvider = $credentialsProvider; + $this->disableSSL = $disableSSL; + $this->insecureSkipVerify = $insecureSkipVerify; + $this->connectTimeout = $connectTimeout; + $this->readwriteTimeout = $readwriteTimeout; + $this->proxyHost = $proxyHost; + $this->useDualStackEndpoint = $useDualStackEndpoint; + $this->useAccelerateEndpoint = $useAccelerateEndpoint; + $this->useInternalEndpoint = $useInternalEndpoint; + $this->useCname = $useCname; + $this->usePathStyle = $usePathStyle; + $this->retryMaxAttempts = $retryMaxAttempts; + $this->retryer = $retryer; + $this->userAgent = $userAgent; + $this->additionalHeaders = $additionalHeaders; + $this->cloudBoxId = $cloudBoxId; + $this->enableAutoDetectCloudBoxId = $enableAutoDetectCloudBoxId; + } + + public static function loadDefault(): Config + { + return new Config(); + } + + /** + * Get the region in which the bucket is located. + * + * @return string + */ + public function getRegion() + { + return $this->region; + } + + /** + * Set the region in which the bucket is located. + * + * @param string $region The region in which the bucket is located. + * + * @return self + */ + public function setRegion(string $region) + { + $this->region = $region; + + return $this; + } + + /** + * Get the domain names that other services can use to access OSS. + * + * @return string + */ + public function getEndpoint() + { + return $this->endpoint; + } + + /** + * Set the domain names that other services can use to access OSS. + * + * @param string $endpoint The domain names that other services can use to access OSS. + * + * @return self + */ + public function setEndpoint(string $endpoint) + { + $this->endpoint = $endpoint; + + return $this; + } + + /** + * Get the signature version when signing requests. Valid values v4, v1 + * + * @return string + */ + public function getSignatureVersion() + { + return $this->signatureVersion; + } + + /** + * Set the signature version when signing requests. Valid values v4, v1 + * + * @param string $signatureVersion The signature version when signing requests. Valid values v4, v1 + * + * @return self + */ + public function setSignatureVersion(string $signatureVersion) + { + $this->signatureVersion = $signatureVersion; + + return $this; + } + + /** + * Get the credentials provider to use when signing requests. + * + * @return CredentialsProvider + */ + public function getCredentialsProvider() + { + return $this->credentialsProvider; + } + + /** + * Set the credentials provider to use when signing requests. + * + * @param CredentialsProvider $credentialsProvider The credentials provider to use when signing requests. + * + * @return self + */ + public function setCredentialsProvider(CredentialsProvider $credentialsProvider) + { + $this->credentialsProvider = $credentialsProvider; + + return $this; + } + + /** + * Get forces the endpoint to be resolved as HTTP. + * + * @return ?bool + */ + public function getDisableSSL() + { + return $this->disableSSL; + } + + /** + * Set forces the endpoint to be resolved as HTTP. + * + * @param bool $disableSSL Forces the endpoint to be resolved as HTTP. + * + * @return self + */ + public function setDisableSSL(bool $disableSSL) + { + $this->disableSSL = $disableSSL; + + return $this; + } + + /** + * Get enable http redirect or not. Default is disable + * + * @return ?bool + */ + public function getEnabledRedirect() + { + return $this->enabledRedirect; + } + + /** + * Set enable http redirect or not. Default is disable + * + * @param ?bool $enabledRedirect Enable http redirect or not. Default is disable + * + * @return self + */ + public function setEnabledRedirect(bool $enabledRedirect) + { + $this->enabledRedirect = $enabledRedirect; + + return $this; + } + + /** + * Get skip server certificate verification. + * + * @return ?bool + */ + public function getInsecureSkipVerify() + { + return $this->insecureSkipVerify; + } + + /** + * Set skip server certificate verification. + * + * @param ?bool $insecureSkipVerify Skip server certificate verification. + * + * @return self + */ + public function setInsecureSkipVerify(bool $insecureSkipVerify) + { + $this->insecureSkipVerify = $insecureSkipVerify; + + return $this; + } + + /** + * Get the time in seconds till a timeout exception is thrown when attempting to make a connection. + * + * @return ?float + */ + public function getConnectTimeout() + { + return $this->connectTimeout; + } + + /** + * Set the time in seconds till a timeout exception is thrown when attempting to make a connection. + * + * @param ?float $connectTimeout The time in seconds till a timeout exception is thrown when attempting to make a connection. + * + * @return self + */ + public function setConnectTimeout(float $connectTimeout) + { + $this->connectTimeout = $connectTimeout; + + return $this; + } + + /** + * Get the time in seconds till a timeout exception is thrown when attempting to read from a connection. + * + * @return ?float + */ + public function getReadwriteTimeout() + { + return $this->readwriteTimeout; + } + + /** + * Set the time in seconds till a timeout exception is thrown when attempting to read from a connection. + * + * @param ?float $readwriteTimeout The time in seconds till a timeout exception is thrown when attempting to read from a connection. + * + * @return self + */ + public function setReadwriteTimeout(float $readwriteTimeout) + { + $this->readwriteTimeout = $readwriteTimeout; + + return $this; + } + + /** + * Get the proxy setting. + * + * @return ?string + */ + public function getProxyHost() + { + return $this->proxyHost; + } + + /** + * Set the proxy setting. + * + * @param ?string $proxyHost The proxy setting. + * + * @return self + */ + public function setProxyHost(string $proxyHost) + { + $this->proxyHost = $proxyHost; + + return $this; + } + + /** + * Get dual-stack endpoints are provided in some regions. + * + * @return ?bool + */ + public function getUseDualStackEndpoint() + { + return $this->useDualStackEndpoint; + } + + /** + * Set dual-stack endpoints are provided in some regions. + * + * @param ?bool $useDualStackEndpoint Dual-stack endpoints are provided in some regions. + * + * @return self + */ + public function setUseDualStackEndpoint(bool $useDualStackEndpoint) + { + $this->useDualStackEndpoint = $useDualStackEndpoint; + + return $this; + } + + /** + * Get oSS provides the transfer acceleration feature to accelerate date transfers + * + * @return ?bool + */ + public function getUseAccelerateEndpoint() + { + return $this->useAccelerateEndpoint; + } + + /** + * Set oSS provides the transfer acceleration feature to accelerate date transfers + * + * @param ?bool $useAccelerateEndpoint OSS provides the transfer acceleration feature to accelerate date transfers + * + * @return self + */ + public function setUseAccelerateEndpoint(bool $useAccelerateEndpoint) + { + $this->useAccelerateEndpoint = $useAccelerateEndpoint; + + return $this; + } + + /** + * Get you can use an internal endpoint to communicate between Alibaba Cloud services located + * + * @return ?bool + */ + public function getUseInternalEndpoint() + { + return $this->useInternalEndpoint; + } + + /** + * Set you can use an internal endpoint to communicate between Alibaba Cloud services located + * + * @param ?bool $useInternalEndpoint You can use an internal endpoint to communicate between Alibaba Cloud services located + * + * @return self + */ + public function setUseInternalEndpoint(bool $useInternalEndpoint) + { + $this->useInternalEndpoint = $useInternalEndpoint; + + return $this; + } + + /** + * Get if the endpoint is s CName, set this flag to true + * + * @return ?bool + */ + public function getUseCname() + { + return $this->useCname; + } + + /** + * Set if the endpoint is s CName, set this flag to true + * + * @param ?bool $useCname If the endpoint is s CName, set this flag to true + * + * @return self + */ + public function setUseCname(bool $useCname) + { + $this->useCname = $useCname; + + return $this; + } + + /** + * Get allows you to enable the client to use path-style addressing, + * + * @return ?bool + */ + public function getUsePathStyle() + { + return $this->usePathStyle; + } + + /** + * Set allows you to enable the client to use path-style addressing, + * + * @param ?bool $usePathStyle Allows you to enable the client to use path-style addressing, + * + * @return self + */ + public function setUsePathStyle(bool $usePathStyle) + { + $this->usePathStyle = $usePathStyle; + + return $this; + } + + /** + * Get specifies the maximum number attempts an API client will call + * + * @return ?int + */ + public function getRetryMaxAttempts() + { + return $this->retryMaxAttempts; + } + + /** + * Set specifies the maximum number attempts an API client will call + * + * @param ?int $retryMaxAttempts Specifies the maximum number attempts an API client will call + * + * @return self + */ + public function setRetryMaxAttempts(int $retryMaxAttempts) + { + $this->retryMaxAttempts = $retryMaxAttempts; + + return $this; + } + + /** + * Get guides how HTTP requests should be retried in case of recoverable failures. + * + * @return ?Retry\RetryerInterface + */ + public function getRetryer() + { + return $this->retryer; + } + + /** + * Set guides how HTTP requests should be retried in case of recoverable failures. + * + * @param ?Retry\RetryerInterface $retryer Guides how HTTP requests should be retried in case of recoverable failures. + * + * @return self + */ + public function setRetryer(Retry\RetryerInterface $retryer) + { + $this->retryer = $retryer; + + return $this; + } + + /** + * Get the optional user specific identifier appended to the User-Agent header. + * + * @return ?string + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Set the optional user specific identifier appended to the User-Agent header. + * + * @param ?string $userAgent The optional user specific identifier appended to the User-Agent header. + * + * @return self + */ + public function setUserAgent(string $userAgent) + { + $this->userAgent = $userAgent; + + return $this; + } + + /** + * Get additional signable headers. + * + * @return ?array + */ + public function getAdditionalHeaders() + { + return $this->additionalHeaders; + } + + /** + * Set additional signable headers. + * + * @param ?array $additionalHeaders Additional signable headers. + * + * @return self + */ + public function setAdditionalHeaders(array $additionalHeaders) + { + $this->additionalHeaders = $additionalHeaders; + + return $this; + } + + /** + * Set enable auto detect cloud box id. + * @param bool $enableAutoDetectCloudBoxId + * @return $this + */ + public function setEnableAutoDetectCloudBoxId(bool $enableAutoDetectCloudBoxId) + { + $this->enableAutoDetectCloudBoxId = $enableAutoDetectCloudBoxId; + + return $this; + } + + /** + * Get enable auto detect cloud box id. + * @return bool|null + */ + public function getEnableAutoDetectCloudBoxId() + { + return $this->enableAutoDetectCloudBoxId; + } + + /** + * Set cloud box id. + * @param string $cloudBoxId + * @return self + */ + public function setCloudBoxId(string $cloudBoxId) + { + $this->cloudBoxId = $cloudBoxId; + return $this; + } + + /** + * Get cloud box id. + * @return string + */ + public function getCloudBoxId() + { + return $this->cloudBoxId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Copier.php b/vendor/alibabacloud/oss-v2/src/Copier.php new file mode 100644 index 0000000..cc3ecd7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Copier.php @@ -0,0 +1,533 @@ + + */ + private $options; + + /** + * @var array Default values for copy configuration. + */ + private $defaultConfig = [ + 'part_size' => Defaults::DEFAULT_COPY_PART_SIZE, + 'parallel_num' => Defaults::DEFAULT_COPY_PARALLEL, + 'multipart_copy_threshold' => Defaults::DEFAULT_COPY_THRESHOLD, + 'leave_parts_on_error' => false, + 'disable_shallow_copy' => false, + ]; + + private const MetadataCopied = [ + 'content-type', + 'content-language', + 'content-encoding', + 'content-disposition', + 'cache-control', + 'expires', + ]; + + /** + * Copier constructor. + * @param Client $client The client instance. + * @param array $args accepts the following: + * - part_size int: The part size. Default value: 64 MiB. + * - parallel_num int: The number of the upload tasks in parallel. Default value: 3. + * - multipart_copy_threshold int: The minimum object size for calling the multipart copy operation. + * Default value: 200 MiB. + * - leave_parts_on_error bool: Specifies whether to retain the uploaded parts when an upload task fails. + * By default, the uploaded parts are not retained. + * - disable_shallow_copy bool: Specifies that the shallow copy capability is not used. + * By default, the shallow copy capability is used. + * @return Copier + */ + public function __construct( + $client, + array $args = [] + ) + { + $this->client = $client; + $this->options = $this->filterArgs($args) + $this->defaultConfig; + } + + /** + * copy object + * @param Models\CopyObjectRequest $request + * @param array $args + * @return \GuzzleHttp\Promise\Promise + */ + public function copyAsync( + Models\CopyObjectRequest $request, + array $args = [] + ): GuzzleHttp\Promise\Promise + { + $context = []; + $this->checkArgs($context, $request, $args); + + return $this->doCopy($context); + } + + /** + * copy object + * @param Models\CopyObjectRequest $request + * @param array $args + * @return Models\CopyResult + */ + public function copy( + Models\CopyObjectRequest $request, + array $args = [] + ): Models\CopyResult + { + return $this->copyAsync($request, $args)->wait(); + } + + private function checkArgs(array &$context, Models\CopyObjectRequest &$request, array &$args): array + { + $context = $this->filterArgs($args) + $this->options; + + if (!Validation::isValidBucketName(Utils::safetyString($request->bucket))) { + throw new \InvalidArgumentException('invalid field, request.bucket.'); + } + + if (!Validation::isValidObjectName(Utils::safetyString($request->key))) { + throw new \InvalidArgumentException('invalid field, request.key.'); + } + + if (!Validation::isValidObjectName(Utils::safetyString($request->sourceKey))) { + throw new \InvalidArgumentException('invalid field, request.sourceKey.'); + } + + if ($request->metadataDirective != null && !in_array($request->metadataDirective, ['COPY', 'REPLACE'])) { + throw new \InvalidArgumentException('invalid field, request.metadataDirective.'); + } + + if ($request->taggingDirective != null && !in_array($request->taggingDirective, ['COPY', 'REPLACE'])) { + throw new \InvalidArgumentException('invalid field, request.taggingDirective.'); + } + + if (Utils::safetyInt($context['part_size']) <= 0) { + $context['part_size'] = Defaults::DEFAULT_COPY_PART_SIZE; + } + + if (Utils::safetyInt($context['parallel_num']) <= 0) { + $context['parallel_num'] = Defaults::DEFAULT_COPY_PARALLEL; + } + + if (Utils::safetyInt($context['multipart_copy_threshold']) < 0) { + $context['multipart_copy_threshold'] = Defaults::DEFAULT_COPY_THRESHOLD; + } + + $context['request'] = $request; + $context['path'] = sprintf('oss://%s/%s', $request->bucket, $request->key); + + //meta_prop & tag_prop + if (isset($args['meta_prop']) && $args['meta_prop'] instanceof Models\HeadObjectResult) { + $context['total_size'] = $args['meta_prop']->contentLength; + $context['meta_prop'] = $args['meta_prop']; + } + + return $context; + } + + private function doCopy(array &$context): GuzzleHttp\Promise\Promise + { + return GuzzleHttp\Promise\Coroutine::of(function () use (&$context) { + + // get object meta + if (!isset($context['meta_prop'])) { + /** + * @var Models\CopyObjectRequest $sourceRequest + */ + $sourceRequest = $context['request']; + $request = new Models\HeadObjectRequest(); + Utils::copyRequest($request, $sourceRequest); + if ($sourceRequest->sourceBucket != null) { + $request->bucket = $sourceRequest->sourceBucket; + } + $request->key = $sourceRequest->sourceKey; + $request->versionId = $sourceRequest->sourceVersionId; + yield $this->client->headObjectAsync($request)->then( + function (Models\HeadObjectResult $result) use (&$context) { + $context['total_size'] = $result->contentLength; + $context['meta_prop'] = $result; + }, + ); + } + + self::adjustPartsize($context); + + if ($context['total_size'] <= $context['multipart_copy_threshold']) { + yield $this->singleCopy($context); + } else if (self::canUseShallowCopy($context)) { + // Use singleCopy first, + // and then use multipartCopy if you encounter an timeout error + $ctx_errors = []; + yield $this->singleCopy($context)->otherwise( + function ($reason) use (&$ctx_errors) { + $ctx_errors[] = $reason; + }, + ); + + if (!empty($ctx_errors)) { + //TODO yield $this->multipartCopy($context); + throw end($ctx_errors); + } + } else { + yield $this->multipartCopy($context); + } + })->then( + function ($result) use (&$context) { + return $context['copy_result']; + }, + function ($reason) use (&$context) { + return GuzzleHttp\Promise\Create::rejectionFor(new Exception\CopyException( + $context['upload_id'] ?? '', + $context['path'] ?? '', + $reason + )); + } + ); + } + + private function singleCopy(array &$context): GuzzleHttp\Promise\Promise + { + $request = $context['request']; + return $this->client->copyObjectAsync($request)->then( + function (Models\CopyObjectResult $result) use (&$context) { + $res = new Models\CopyResult(); + Utils::copyResult($res, $result); + $context['copy_result'] = $res; + return $res; + } + ); + } + + private static function canUseShallowCopy(array &$context) + { + if ($context['disable_shallow_copy'] === true) { + return false; + } + + /** + * @var Models\CopyObjectRequest $request + * @var Models\CopyObjectResult $metaProp + */ + $request = $context['request']; + $metaProp = $context['meta_prop']; + + // change StorageClass + if ($request->storageClass != null) { + return false; + } + + // Cross bucket + if ( + $request->sourceBucket != null && + $request->sourceBucket !== $request->bucket + ) { + return false; + } + + // Decryption + if ($metaProp->serverSideEncryption != null) { + return false; + } + + return true; + } + + private static function adjustPartsize(array &$context) + { + $total_size = $context['total_size']; + $part_size = $context['part_size']; + if ($total_size > 0) { + while ($total_size / $part_size >= Defaults::MAX_UPLOAD_PARTS) { + $part_size += $context['part_size']; + } + } + $context['part_size'] = $part_size; + } + + private static function iterPart(array &$context): \Generator + { + $total_size = $context['total_size']; + $part_size = $context['part_size']; + $start = 0; + + for ( + $partNumber = 1; + $start < $total_size; + $partNumber++ + ) { + + yield [$partNumber, $start, min($part_size, $total_size - $start)]; + $start += $part_size; + } + } + + private static function overwirteMetadataProp(Models\InitiateMultipartUploadRequest &$imRequest, array &$context) + { + /** + * @var Models\CopyObjectRequest $request + * @var Models\CopyObjectResult $metaProp + */ + $request = $context['request']; + $metaProp = $context['meta_prop']; + $directive = $request->metadataDirective ?? ''; + + switch (strtolower($directive)) { + case '': + case 'copy': + if ($metaProp == null) { + throw new \InvalidArgumentException("request.metadataDirective is COPY, but meets nil metaProp for source"); + } + $imRequest->cacheControl = null; + $imRequest->contentType = null; + $imRequest->contentDisposition = null; + $imRequest->contentEncoding = null; + $imRequest->expires = null; + $imRequest->metadata = null; + $imRequest->expires = null; + $imHeaders = []; + + // copy meta form source + foreach ($metaProp->headers as $k => $v) { + $lk = strtolower($k); + if (strncmp($lk, 'x-oss-meta', 10) == 0) { + $imHeaders[$k] = $v; + } else if (in_array($lk, self::MetadataCopied)) { + $imHeaders[$k] = $v; + } + } + $imRequestRo = new \ReflectionObject($imRequest); + $pp = $imRequestRo->getProperty('headers'); + if (PHP_VERSION_ID < 80100) { + $pp->setAccessible(true); + } + $pp->setValue($imRequest, $imHeaders); + + break; + case 'replace': + // the metedata has been copied via the copyRequest function before + break; + default: + //unsupport Directive + throw new \InvalidArgumentException("Unsupport MetadataDirective, $directive"); + } + } + + private static function needFetchTagProp(array &$context) + { + if (isset($context['tag_prop'])) { + return false; + } + + /** + * @var Models\CopyObjectRequest $request + * @var Models\CopyObjectResult $metaProp + */ + $request = $context['request']; + $metaProp = $context['meta_prop']; + + if (Utils::safetyInt($metaProp->taggingCount) <= 0) { + return false; + } + + $directive = strtolower($request->taggingDirective ?? ''); + + return $directive === '' || $directive === 'copy'; + } + + private static function overwirteTagProp(Models\InitiateMultipartUploadRequest &$imRequest, array &$context) + { + $request = $context['request']; + $tagProp = $context['tag_prop'] ?? null; + /** + * @var Models\CopyObjectRequest $request + * @var Models\GetObjectTaggingResult $tagProp + */ + $directive = $request->taggingDirective ?? ''; + + switch (strtolower($directive)) { + case '': + case 'copy': + $imRequest->tagging = null; + if ($tagProp != null && $tagProp->tagSet != null) { + $tags = []; + foreach ($tagProp->tagSet->tags ?? [] as $tag) { + $tags[] = sprintf('%s=%s', $tag->key, $tag->value); + } + + if (!empty($tags)) { + $imRequest->tagging = implode('&', $tags); + } + } + break; + case 'replace': + // the tagging has been copied via the copyRequest function before + break; + default: + //unsupport Directive + throw new \InvalidArgumentException("Unsupport TaggingDirective, $directive"); + } + } + + private function multipartCopy(array &$context): GuzzleHttp\Promise\Promise + { + return GuzzleHttp\Promise\Coroutine::of(function () use (&$context) { + + // tag prop + if (self::needFetchTagProp($context)) { + /** + * @var Models\CopyObjectRequest $sourceRequest + */ + $sourceRequest = $context['request']; + $request = new Models\GetObjectTaggingRequest(); + Utils::copyRequest($request, $sourceRequest); + if ($sourceRequest->sourceBucket != null) { + $request->bucket = $sourceRequest->sourceBucket; + } + $request->key = $sourceRequest->sourceKey; + $request->versionId = $sourceRequest->sourceVersionId; + yield $this->client->getObjectTaggingAsync($request)->then( + function (Models\GetObjectTaggingResult $result) use (&$context) { + $context['tag_prop'] = $result; + }, + ); + } + + // init the multipart + $request = new Models\InitiateMultipartUploadRequest(); + Utils::copyRequest($request, $context['request']); + $request->disableAutoDetectMimeType = true; + self::overwirteMetadataProp($request, $context); + self::overwirteTagProp($request, $context); + yield $this->client->initiateMultipartUploadAsync($request)->then( + function (Models\InitiateMultipartUploadResult $result) use (&$context) { + $context['upload_id'] = $result->uploadId; + }, + ); + + // timeout for MultiPartCopy API, 10s per 200M, max timeout is 50s + $PART_SIZE = 200 * 1024 * 1024; + $STEP = 10; + $mpcReadTimeout = Defaults::READWRITE_TIMEOUT; + $part_size = intval($context['part_size']); + while ($part_size > $PART_SIZE) { + $mpcReadTimeout += $STEP; + $part_size -= $PART_SIZE; + if ($mpcReadTimeout > 50) { + break; + } + } + $context['mpc_read_timeout'] = $mpcReadTimeout; + + // upload part + $context['errors'] = []; + $context['parts'] = []; + $uploadFns = function () use (&$context) { + foreach (self::iterPart($context) as $args) { + $request = new Models\UploadPartCopyRequest(); + Utils::copyRequest($request, $context['request']); + $request->partNumber = $args[0]; + $request->uploadId = $context['upload_id']; + $request->sourceRange = sprintf('bytes=%d-%d', $args[1], $args[1] + $args[2] - 1); + yield $args[0] => $this->client->uploadPartCopyAsync($request)->otherwise( + function ($reason) use (&$context) { + $context['errors'][] = $reason; + return GuzzleHttp\Promise\Create::rejectionFor($reason); + }, + ); + if (!empty($context['errors'])) { + break; + } + } + }; + + $each = new GuzzleHttp\Promise\EachPromise( + $uploadFns(), + [ + 'concurrency' => $context['parallel_num'], + 'fulfilled' => function (Models\UploadPartCopyResult $result, $key) use (&$context) { + $context['parts'][] = new Models\UploadPart($key, $result->etag); + return $result; + } + ] + ); + yield $each->promise(); + + // complete upload + if (empty($context['errors'])) { + $parts = $context['parts']; + usort($parts, function ($a, $b) { + if ($a->partNumber == $b->partNumber) return 0; + return $a->partNumber < $b->partNumber ? -1 : 1; + }); + + $request = new Models\CompleteMultipartUploadRequest(); + Utils::copyRequest($request, $context['request']); + $request->uploadId = $context['upload_id']; + $request->completeMultipartUpload = new Models\CompleteMultipartUpload($parts); + yield $this->client->completeMultipartUploadAsync($request)->then( + function (Models\CompleteMultipartUploadResult $result) use (&$context) { + $context['upload_result'] = $result; + return $result; + }, + function ($reason) use (&$context) { + $context['errors'][] = $reason; + }, + ); + } + + if (!empty($context['errors'])) { + if ($context['leave_parts_on_error'] === false) { + $request = new Models\AbortMultipartUploadRequest(); + Utils::copyRequest($request, $context['request']); + $request->uploadId = $context['upload_id']; + yield $this->client->abortMultipartUploadAsync($request); + } + throw end($context['errors']); + } + })->then( + function ($result) use (&$context) { + $result = $context['upload_result']; + $res = new Models\CopyResult(); + Utils::copyResult($res, $result); + $res->uploadId = $context['upload_id']; + $context['copy_result'] = $res; + return $res; + }, + function ($reason) use (&$context) { + return GuzzleHttp\Promise\Create::rejectionFor($reason); + } + ); + } + + private function filterArgs(array &$args) + { + return \array_filter($args, function ($key) { + return \array_key_exists($key, $this->defaultConfig); + }, \ARRAY_FILTER_USE_KEY); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Credentials/AnonymousCredentialsProvider.php b/vendor/alibabacloud/oss-v2/src/Credentials/AnonymousCredentialsProvider.php new file mode 100644 index 0000000..e833286 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Credentials/AnonymousCredentialsProvider.php @@ -0,0 +1,14 @@ +accessKeyId = $accessKeyId; + $this->accessKeySecret = $accessKeySecret; + $this->securityToken = $securityToken; + $this->expiration = $expiration; + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string|null + */ + public function getSecurityToken(): ?string + { + return $this->securityToken; + } + + /** + * @return \DateTimeInterface|null + */ + public function getExpiration(): ?\DateTimeInterface + { + return $this->expiration; + } + + /** + * Check whether the credentials keys are set. + * True if the credentials keys are set. + */ + public function hasKeys(): bool + { + return !empty($this->accessKeyId) && !empty($this->accessKeySecret); + } + + /** + * Check whether the credentials have expired. + * True if the credentials have expired. + */ + public function isExpired(): bool + { + return null !== $this->expiration && new \DateTimeImmutable() >= $this->expiration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Credentials/CredentialsProvider.php b/vendor/alibabacloud/oss-v2/src/Credentials/CredentialsProvider.php new file mode 100644 index 0000000..a28259a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Credentials/CredentialsProvider.php @@ -0,0 +1,13 @@ +handler = $handler; + } + + public function getCredentials(): Credentials + { + return ($this->handler)(); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Credentials/EnvironmentVariableCredentialsProvider.php b/vendor/alibabacloud/oss-v2/src/Credentials/EnvironmentVariableCredentialsProvider.php new file mode 100644 index 0000000..b3b7570 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Credentials/EnvironmentVariableCredentialsProvider.php @@ -0,0 +1,20 @@ +credentials = new Credentials($key, $secret, $token); + } + + public function getCredentials(): Credentials + { + return $this->credentials; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/AesCtr.php b/vendor/alibabacloud/oss-v2/src/Crypto/AesCtr.php new file mode 100644 index 0000000..2282699 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/AesCtr.php @@ -0,0 +1,152 @@ +cipherData = $cipherData; + $this->offset = $offset; + $this->lastData = ''; + if ($offset % self::BLOCK_SIZE_LEN !== 0) { + throw new \InvalidArgumentException('offset is not align to encrypt block'); + } + $this->highIv = substr($this->cipherData->iv, 0, 8); + $this->counter = $this->lowIvToInt($cipherData->iv) + intval($offset / self::BLOCK_SIZE_LEN); + } + + /** + * @param string $data + * @return string + */ + public function encrypt(string $data): string + { + if ($data === '') { + return ''; + } + $lastLen = strlen($this->lastData); + if ($lastLen > 0) { + $data = $this->lastData . $data; + } + + $edata = openssl_encrypt( + $data, + self::CIPHER_NAME, + $this->cipherData->key, + self::OPTIONS, + $this->countToIv() + ); + if ($edata === false) { + throw new \RuntimeException('AesCtr encrypt fail'); + } + if ($lastLen > 0) { + $edata = substr($edata, $lastLen); + } + $this->counter += intval(strlen($data) / self::BLOCK_SIZE_LEN); + + $remains = strlen($data) % self::BLOCK_SIZE_LEN; + + $this->lastData = $remains > 0 ? substr($data, -$remains) : ''; + //print("counter: $this->counter \n"); + return $edata; + } + + /** + * @param string $data + * @return string + */ + public function decrypt(string $data): string + { + if ($data === '') { + return ''; + } + $lastLen = strlen($this->lastData); + if ($lastLen > 0) { + $data = $this->lastData . $data; + } + + $edata = openssl_decrypt( + $data, + self::CIPHER_NAME, + $this->cipherData->key, + self::OPTIONS, + $this->countToIv() + ); + if ($edata === false) { + throw new \RuntimeException('AesCtr decrypt fail'); + } + if ($lastLen > 0) { + $edata = substr($edata, $lastLen); + } + $this->counter += intval(strlen($data) / self::BLOCK_SIZE_LEN); + + $remains = strlen($data) % self::BLOCK_SIZE_LEN; + + $this->lastData = $remains > 0 ? substr($data, -$remains) : ''; + return $edata; + } + + public function reset() + { + $this->counter = $this->lowIvToInt($this->cipherData->iv) + intval($this->offset / self::BLOCK_SIZE_LEN); + $this->lastData = ''; + } + + static public function randomKey(): string + { + return openssl_random_pseudo_bytes(self::KEY_SIZE); + } + + static public function randomIv(): string + { + $iv = openssl_random_pseudo_bytes(self::IV_SIZE); + // only use 4 byte,in order not to overflow when SeekIV() + $iv = substr($iv, 0, 8) . pack('N', 0) . substr($iv, 12, 4); + + return $iv; + } + + private function lowIvToInt(string $iv): int + { + $vals = unpack('J2', $iv, 0); + return $vals[2]; + } + + private function countToIv(): string + { + return $this->highIv . pack('J', $this->counter); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipher.php b/vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipher.php new file mode 100644 index 0000000..77da9a2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipher.php @@ -0,0 +1,61 @@ +cipherData = $cipherData; + } + + /** + * @param int $length + * @return int + */ + public function getEncryptedLen(int $length): int + { + //AES CTR encryption mode does not change content length + return $length; + } + + /** + * @return CipherData + */ + public function getCipherData(): CipherData + { + return $this->cipherData; + } + + /** + * @return int + */ + public function getAlignLen(): int + { + return AesCtr::BLOCK_SIZE_LEN; + } + + /** + * @param int $offset + * @return CipherInterface + */ + public function getCipher(int $offset = 0): CipherInterface + { + return new AesCtr($this->cipherData, $offset); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipherBuilder.php b/vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipherBuilder.php new file mode 100644 index 0000000..26f5113 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/AesCtrCipherBuilder.php @@ -0,0 +1,65 @@ +masterCipher = $masterCipher; + } + + public function createCipherData() + { + $key = AesCtr::randomKey(); + $iv = AesCtr::randomIv(); + + $encIv = $this->masterCipher->encrypt($iv); + $enckey = $this->masterCipher->encrypt($key); + + return new CipherData( + $iv, + $key, + $encIv, + $enckey, + $this->masterCipher->getMatDesc(), + $this->masterCipher->getWrapAlgorithm(), + AesCtr::ALGORITHM + ); + } + + public function fromCipherData(?CipherData $cipherData = null): ContentCipherInterface + { + if ($cipherData == null) { + $cipherData = $this->createCipherData(); + } + return new AesCtrCipher($cipherData); + } + + public function fromEnvelope(Envelope $envelope): ContentCipherInterface + { + $plainIv = $this->masterCipher->decrypt($envelope->iv); + $plainKey = $this->masterCipher->decrypt($envelope->key); + + $cipherData = new CipherData( + $plainIv, + $plainKey, + $envelope->iv, + $envelope->key, + $envelope->matDesc, + $envelope->wrapAlg, + $envelope->cekAlg + ); + + return $this->fromCipherData($cipherData); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/CipherData.php b/vendor/alibabacloud/oss-v2/src/Crypto/CipherData.php new file mode 100644 index 0000000..49df24e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/CipherData.php @@ -0,0 +1,43 @@ +iv = $iv; + $this->key = $key; + $this->encryptedIv = $encryptedIv; + $this->encryptedKey = $encryptedKey; + $this->matDesc = $matDesc; + $this->wrapAlgorithm = $wrapAlgorithm; + $this->cekAlgorithm = $cekAlgorithm; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/CipherInterface.php b/vendor/alibabacloud/oss-v2/src/Crypto/CipherInterface.php new file mode 100644 index 0000000..6ef9882 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/CipherInterface.php @@ -0,0 +1,18 @@ +iv = $iv; + $this->key = $key; + $this->cekAlg = $cekAlg; + $this->wrapAlg = $wrapAlg; + $this->matDesc = $matDesc; + $this->unencryptedMd5 = $unencryptedMd5; + $this->unencryptedContentLen = $unencryptedContentLen; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/LazyDecryptStream.php b/vendor/alibabacloud/oss-v2/src/Crypto/LazyDecryptStream.php new file mode 100644 index 0000000..cac2778 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/LazyDecryptStream.php @@ -0,0 +1,107 @@ +stream = $stream; + $this->discardSize = $discardSize; + $this->getContentCipher = $getContentCipher; + $this->discard = $discardSize; + $this->cipher = null; + } + + public function on_headers(ResponseInterface $response) + { + /** + * @var ContentCipherInterface $contentCipher + * @var array $contentRange + */ + $contentCipher = ($this->getContentCipher)($response); + if ($contentCipher != null) { + $offset = 0; + if ($response->hasHeader('content-range')) { + $contentRange = $response->getHeader('content-range')[0]; + $vals = Utils::parseContentRange($contentRange); + if ($vals === false) { + throw new \RuntimeException("parse Content-Range error, got $contentRange"); + } + $offset = $vals[0]; + } + $this->cipher = $contentCipher->getCipher($offset); + } + } + + public function rewind(): void + { + $this->discard = $this->discardSize; + if ($this->cipher != null) { + $this->cipher->reset(); + } + $this->seek(0); + } + + public function write($string): int + { + $len = strlen($string); + if ($len == 0) { + return 0; + } + if ($this->cipher != null) { + $string = $this->cipher->decrypt($string); + } + if ($this->discard > 0) { + $min = min($this->discard, $len); + $string = substr($string, $min); + $this->discard -= $min; + } + $this->stream->write($string); + return $len; + } + + public function unwrap(): StreamInterface + { + return $this->stream; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/MasterCipherInterface.php b/vendor/alibabacloud/oss-v2/src/Crypto/MasterCipherInterface.php new file mode 100644 index 0000000..03eb2c3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/MasterCipherInterface.php @@ -0,0 +1,45 @@ +publicKey = $publicKey; + $this->publicKeyResource = null; + if ($publicKey != null) { + $ret = openssl_pkey_get_public($publicKey); + if ($ret === false) { + throw new \InvalidArgumentException('RSA key format is not supported'); + } + $this->publicKeyResource = $ret; + } + + $this->privateKey = $privateKey; + if ($privateKey != null) { + $ret = openssl_pkey_get_private($privateKey); + if ($ret === false) { + throw new \InvalidArgumentException('RSA key format is not supported'); + } + $this->privateKeyResource = $ret; + } + + $this->matDesc = null; + if (\is_array($matDesc)) { + $val = json_encode($matDesc); + if ($val !== false) { + $this->matDesc = $val; + } + } else if (is_string($matDesc)) { + $this->matDesc = $matDesc; + } + } + + public function encrypt(string $data): string + { + if ($this->publicKeyResource == null) { + throw new \InvalidArgumentException('RSA public key is none or invalid.'); + } + + $encdata = ""; + + if (!openssl_public_encrypt($data, $encdata, $this->publicKeyResource)) { + throw new \RuntimeException('encrypt data error.'); + } + + return $encdata; + } + + public function decrypt(string $data): string + { + if ($this->privateKeyResource == null) { + throw new \InvalidArgumentException('RSA private key is none or invalid.'); + } + + $decdata = ""; + if (!openssl_private_decrypt($data, $decdata, $this->privateKeyResource)) { + throw new \RuntimeException('decrypt data error.'); + } + + return $decdata; + } + + public function getWrapAlgorithm(): string + { + return 'RSA/NONE/PKCS1Padding'; + } + + public function getMatDesc(): string + { + return $this->matDesc ?? ''; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/ReadDecryptStream.php b/vendor/alibabacloud/oss-v2/src/Crypto/ReadDecryptStream.php new file mode 100644 index 0000000..16b39e4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/ReadDecryptStream.php @@ -0,0 +1,56 @@ +stream = $stream; + $this->cipher = $cipher; + } + + public function rewind(): void + { + $this->cipher->reset(); + $this->seek(0); + } + + public function read($length): string + { + $data = $this->stream->read($length); + $data = $this->cipher->decrypt($data); + return $data; + } + + public function write($string): int + { + throw new \RuntimeException('Cannot write a ReadDecryptStream'); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Crypto/ReadEncryptStream.php b/vendor/alibabacloud/oss-v2/src/Crypto/ReadEncryptStream.php new file mode 100644 index 0000000..4731773 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Crypto/ReadEncryptStream.php @@ -0,0 +1,56 @@ +stream = $stream; + $this->cipher = $cipher; + } + + public function rewind(): void + { + $this->cipher->reset(); + $this->seek(0); + } + + public function read($length): string + { + $data = $this->stream->read($length); + $data = $this->cipher->encrypt($data); + return $data; + } + + public function write($string): int + { + throw new \RuntimeException('Cannot write a ReadEncryptStream'); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Defaults.php b/vendor/alibabacloud/oss-v2/src/Defaults.php new file mode 100644 index 0000000..23b6a42 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Defaults.php @@ -0,0 +1,113 @@ +]*)>/", $value) + ) { + throw new DeserializationExecption("Not found tag <$expect>"); + } + + return self::deserializeXmlModel($xml, $className); + } + + private static function deserializeXmlAny(\SimpleXMLElement $element, string $type, XmlElement $annotation) + { + $values = []; + foreach ($element as $item) { + switch ($annotation->type) { + case "bool": + $vv = self::castToBool($item->__toString()); + break; + case "string": + $vv = $item->__toString(); + break; + case "int": + $vv = self::castToInt($item->__toString()); + break; + case "float": + $vv = self::castToFloat($item->__toString()); + break; + case "DateTime": + $vv = self::castToDatetime($item->__toString(), $annotation->format); + break; + default: + $vv = self::deserializeXmlModel($item, $annotation->type); + } + array_push($values, $vv); + } + + if (\in_array($type, ['?array', 'array'])) { + return $values; + } + return $values[0]; + } + + private static function deserializeXmlModel(\SimpleXMLElement $element, $class): Model + { + if (\is_object($class)) { + if (!($class instanceof Model)) { + throw new DeserializationExecption($class . " is not subclass of Model"); + } + $rc = new \ReflectionObject($class); + $obj = $class; + } else { + $rc = new \ReflectionClass($class); + $obj = $rc->newInstance(); + if (!($obj instanceof Model)) { + throw new DeserializationExecption($class . " is not subclass of Model"); + } + } + + // children element + foreach ($rc->getProperties() as $property) { + $annotation = Functions::getXmlElementAnnotation($property); + if ($annotation == null) { + continue; + } + + $name = $annotation->rename; + if (!isset($element->$name)) { + continue; + } + + $type = (string)$property->getType(); + $value = self::deserializeXmlAny($element->$name, $type, $annotation); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($obj, $value); + } + + return $obj; + } + + private static function castToBool(string $value): bool + { + $v = strtolower($value); + if ('true' === $v || '1' === $v) { + return true; + } elseif ('false' === $v || '0' === $v) { + return false; + } else { + throw new DeserializationExecption( + sprintf('Could not convert data to boolean. Expected "true", "false", "1" or "0", but got %s.', $value) + ); + } + } + + private static function castToInt(string $value): int + { + return (int)$value; + } + + private static function castToFloat(string $value): float + { + return (float)$value; + } + + private static function castToAny(string $value, string $type, ?string $format) + { + switch ($type) { + case "bool": + $vv = self::castToBool($value); + break; + case "string": + $vv = $value; + break; + case "int": + $vv = self::castToInt($value); + break; + case "float": + $vv = self::castToFloat($value); + break; + case "DateTime": + $vv = self::castToDatetime($value, $format); + break; + default: + throw new DeserializationExecption("Unsupport type:$type"); + } + return $vv; + } + + private static function castToDatetime(string $value, ?string $format): \DateTime + { + switch ($format) { + case 'httptime': + return \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $value, + new \DateTimeZone('UTC') + ); + case 'unixtime': + $datetime = new \DateTime(); + $datetime->setTimestamp((int)$value); + return $datetime; + } + return \DateTime::createFromFormat( + 'Y-m-d\TH:i:s\Z', + $value, + new \DateTimeZone('UTC') + ); + } + + public static function deserializeOutput(ResultModel $result, OperationOutput $output, array $customDeserializer = []): void + { + $ro = new \ReflectionObject($result); + + //common part + $p = $ro->getProperty('status'); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } + $p->setValue($result, $output->getStatus()); + + $p = $ro->getProperty('statusCode'); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } + $p->setValue($result, $output->GetStatusCode()); + + $headers = $output->getHeaders() ?? []; + $p = $ro->getProperty('headers'); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } + $p->setValue($result, $headers); + + if (isset($headers['x-oss-request-id'])) { + $p = $ro->getProperty('requestId'); + if (PHP_VERSION_ID < 80100) { + $p->setAccessible(true); + } + $p->setValue($result, $headers['x-oss-request-id']); + } + + // custom deserializer + foreach ($customDeserializer as $deserializer) { + if (\is_callable($deserializer)) { + $deserializer($result, $output); + } else { + call_user_func($deserializer, $result, $output); + } + } + } + + public static function deserializeOutputHeaders(ResultModel $result, OperationOutput $output) + { + $headers = $output->getHeaders(); + if (empty($headers)) { + return; + } + + $usermetas = []; + $ro = new \ReflectionObject($result); + foreach ($ro->getProperties() as $property) { + $annotation = Functions::getHeaderAnnotation($property); + if ($annotation == null) { + continue; + } + + #usermeta + if ($annotation->format === 'usermeta') { + \array_push($usermetas, ['property' => $property, 'annotation' => $annotation]); + continue; + } + + $name = $annotation->rename; + if (!\array_key_exists($name, $headers)) { + continue; + } + + $value = self::castToAny($headers[$name], $annotation->type, $annotation->format); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($result, $value); + } + + foreach ($usermetas as $item) { + $annotation = $item['annotation']; + $property = $item['property']; + $prefix = strtolower($annotation->rename); + $len = strlen($prefix); + $meta = []; + foreach ($headers as $key => $value) { + if (strncasecmp($key, $prefix, $len) == 0) { + $meta[strtolower(substr($key, $len))] = $value; + } + } + + if (count($meta) > 0) { + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($result, $meta); + } + } + } + + public static function deserializeOutputBody(ResultModel $result, OperationOutput $output) + { + //#[TagProperty(tag: 'output', position: 'body', rename: '...', type: 'xml')] + $body = $output->getBody(); + if ($body == null) { + return; + } + + $content = $body->getContents(); + + if ($content === '') { + return; + } + + $ro = new \ReflectionObject($result); + foreach ($ro->getProperties() as $property) { + $annotation = Functions::getBodyAnnotation($property); + if ($annotation == null) { + continue; + } + + if ('xml' === $annotation->format) { + $value = self::deserializeXml($content, $annotation->type, $annotation->rename); + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($result, $value); + } else { + throw new DeserializationExecption("Unsupport body format:$annotation->format"); + } + + // only one body tag + break; + } + } + + public static function deserializeOutputInnerBody(ResultModel $result, OperationOutput $output) + { + $body = $output->getBody(); + if ($body == null) { + return; + } + + $content = $body->getContents(); + + if ($content === '') { + return; + } + + self::deserializeXml($content, $result); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Downloader.php b/vendor/alibabacloud/oss-v2/src/Downloader.php new file mode 100644 index 0000000..23abca7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Downloader.php @@ -0,0 +1,422 @@ + + */ + private $options; + + /** + * @var array Default values for download configuration. + */ + private $defaultConfig = [ + 'part_size' => Defaults::DEFAULT_DOWNLOAD_PART_SIZE, + 'parallel_num' => Defaults::DEFAULT_DOWNLOAD_PARALLEL, + 'use_temp_file' => false, + ]; + + /** + * Downloader constructor. + * @param Client|EncryptionClient $client The client instance. + * @param array $args accepts the following: + * - part_size int: The part size. Default value: 6 MiB. + * - parallel_num int: The number of the upload tasks in parallel. Default value: 3. + * - use_temp_file bool: Specifies whether to use a temporary file when you download an object. + */ + public function __construct( + $client, + array $args = [] + ) + { + $this->client = $client; + $this->options = $this->filterArgs($args) + $this->defaultConfig; + } + + /** + * download file + * @param Models\GetObjectRequest $request + * @param string $filepath + * @param array $args + * @return \GuzzleHttp\Promise\Promise + */ + public function downloadFileAsync( + Models\GetObjectRequest $request, + string $filepath, + array $args = [] + ): GuzzleHttp\Promise\Promise + { + $context = []; + $this->checkArgs($context, $request, $args); + $this->checkFilepath($context, $filepath); + return $this->writeParallel($context); + } + + /** + * download file + * @param Models\GetObjectRequest $request + * @param string $filepath + * @param array $args + * @return Models\DownloadResult + */ + public function downloadFile( + Models\GetObjectRequest $request, + string $filepath, + array $args = [] + ): Models\DownloadResult + { + return $this->downloadFileAsync($request, $filepath, $args)->wait(); + } + + /** + * download to + * @param Models\GetObjectRequest $request + * @param \Psr\Http\Message\StreamInterface $stream + * @param array $args + * @return \GuzzleHttp\Promise\Promise + */ + public function downloadToAsync( + Models\GetObjectRequest $request, + \Psr\Http\Message\StreamInterface $stream, + array $args = [] + ): GuzzleHttp\Promise\Promise + { + $context = []; + $this->checkArgs($context, $request, $args); + $this->checkStream($context, $stream); + + if ($stream->isSeekable() && $stream->getMetadata('wrapper_type') === 'plainfile') { + return $this->writeParallel($context); + } + + return $this->writeSequential($context); + } + + /** + * download to + * @param Models\GetObjectRequest $request + * @param \Psr\Http\Message\StreamInterface $stream + * @param array $args + * @return Models\DownloadResult + */ + public function downloadTo( + Models\GetObjectRequest $request, + \Psr\Http\Message\StreamInterface $stream, + array $args = [] + ): Models\DownloadResult + { + return $this->downloadToAsync($request, $stream, $args)->wait(); + } + + private function checkArgs(array &$context, Models\GetObjectRequest &$request, array &$args): array + { + $context = $this->filterArgs($args) + $this->options; + + if (!Validation::isValidBucketName(Utils::safetyString($request->bucket))) { + throw new \InvalidArgumentException('invalid field, request.bucket.'); + } + + if (!Validation::isValidObjectName(Utils::safetyString($request->key))) { + throw new \InvalidArgumentException('invalid field, request.key.'); + } + + // range + $pos = 0; + $epos = -1; + if ($request->rangeHeader != null) { + if ($this->client instanceof EncryptionClient) { + throw new \InvalidArgumentException("encryption client does not support range."); + } + $vals = Utils::parseHttpRange($request->rangeHeader); + if ($vals === false) { + throw new \InvalidArgumentException("invalid field, request.rangeHeader."); + } + if ($vals[0] > 0) { + $pos = $vals[0]; + } + if ($vals[1] > 0) { + $epos = $vals[1] + 1; + } + } + $context['pos'] = $pos; + $context['epos'] = $epos; + + if (Utils::safetyInt($context['part_size']) <= 0) { + $context['part_size'] = Defaults::DEFAULT_PART_SIZE; + } + + if (Utils::safetyInt($context['parallel_num']) <= 0) { + $context['parallel_num'] = Defaults::DEFAULT_DOWNLOAD_PARALLEL; + } + + $context['request'] = $request; + + return $context; + } + + private function checkFilepath(array &$context, string $filepath) + { + if ($filepath == '') { + throw new \InvalidArgumentException('invalid field, filepath.'); + } + + $absfilepath = realpath($filepath); + + if ($absfilepath === false) { + $absfilepath = $filepath; + } + + $stream = new GuzzleHttp\Psr7\LazyOpenStream($absfilepath, 'w'); + if (!$stream->isWritable()) { + throw new \InvalidArgumentException("File is not writable, $filepath"); + } + $context['filepath'] = $filepath; + $context['abs_filepath'] = $absfilepath; + $context['stream'] = $stream; + } + + private function checkStream(array &$context, \Psr\Http\Message\StreamInterface $stream) + { + if (!$stream->isWritable()) { + throw new \InvalidArgumentException('Stream is not writable'); + } + $context['filepath'] = 'to stream'; + $context['abs_filepath'] = 'to stream'; + $context['stream'] = $stream; + } + + /** + * Summary of iterPart + * @param array $context + * @return \Generator + */ + private static function iterPart(array &$context): \Generator + { + $start = $context['pos']; + $end = $context['epos']; + $part_size = $context['part_size']; + while ($start < $end) { + yield [$start, min($part_size, $end - $start)]; + $start += $part_size; + } + } + + private static function drainPart(array &$context) + { + /** + * @var \Psr\Http\Message\StreamInterface $stream + * @var int $rstart + */ + $stream = $context['stream']; + $wstart = $context['wstart']; + + usort($context['parts'], function ($a, $b) { + if ($a['start'] == $b['start']) return 0; + return $a['start'] < $b['start'] ? -1 : 1; + }); + + while (!empty($context['parts'])) { + $item = $context['parts'][0]; + if ($item['start'] !== $wstart) { + break; + } + /** + * @var Models\GetObjectResult $result + */ + $result = $item['result']; + GuzzleHttp\Psr7\Utils::copyToStream($result->body, $stream); + $wstart += $result->body->getSize(); + array_shift($context['parts']); + } + $context['wstart'] = $wstart; + } + + private function writeSequential(array &$context): GuzzleHttp\Promise\Promise + { + return GuzzleHttp\Promise\Coroutine::of(function () use (&$context) { + // get object meta + $request = new Models\HeadObjectRequest(); + Utils::copyRequest($request, $context['request']); + yield $this->client->headObjectAsync($request)->then( + function (Models\HeadObjectResult $result) use (&$context) { + $pos = $context['epos']; + $context['epos'] = $pos < 0 ? $result->contentLength : min($pos, $result->contentLength); + }, + ); + + // download parallel & write sequential + $context['errors'] = []; + $context['parts'] = []; + $context['wstart'] = $context['pos']; + + $downloadFns = function () use (&$context) { + foreach (self::iterPart($context) as $args) { + /** + * @var Models\GetObjectRequest $request + */ + $request = clone $context['request']; + $request->rangeHeader = sprintf('bytes=%d-%d', $args[0], $args[0] + $args[1] - 1); + $request->rangeBehavior = 'standard'; + $request->progressFn = null; + yield $this->client->getObjectAsync($request)->otherwise( + function ($reason) use (&$context) { + $context['errors'][] = $reason; + return GuzzleHttp\Promise\Create::rejectionFor($reason); + }, + ); + if (!empty($context['errors'])) { + break; + } + } + }; + + $each = new GuzzleHttp\Promise\EachPromise( + $downloadFns(), + [ + 'concurrency' => $context['parallel_num'], + 'fulfilled' => function (Models\GetObjectResult $result, $key) use (&$context) { + $rangeStart = $result->contentRange != null ? Utils::parseContentRange($result->contentRange) : 0; + $rangeStart = \is_array($rangeStart) ? $rangeStart[0] : 0; + $context['parts'][] = ['start' => $rangeStart, 'result' => $result]; + self::drainPart($context); + return $result; + } + ] + ); + yield $each->promise(); + + // remains parts + self::drainPart($context); + + if (!empty($context['errors'])) { + throw end($context['errors']); + } + + if (!empty($context['parts'])) { + throw new \RuntimeException('There are still unsaved parts.'); + } + })->then( + function ($result) use (&$context) { + $res = new Models\DownloadResult(); + $res->written = $context['epos'] - $context['pos']; + return $res; + }, + function ($reason) use (&$context) { + return GuzzleHttp\Promise\Create::rejectionFor(new Exception\DownloadException( + $context['filepath'] ?? '', + $reason + )); + } + ); + } + + private function writeParallel(array &$context): GuzzleHttp\Promise\Promise + { + return GuzzleHttp\Promise\Coroutine::of(function () use (&$context) { + + // get object meta + $request = new Models\HeadObjectRequest(); + Utils::copyRequest($request, $context['request']); + yield $this->client->headObjectAsync($request)->then( + function (Models\HeadObjectResult $result) use (&$context) { + $pos = $context['epos']; + $context['epos'] = $pos < 0 ? $result->contentLength : min($pos, $result->contentLength); + }, + ); + + // download & write parallel + $context['errors'] = []; + $context['parts'] = []; + + $downloadFns = function () use (&$context) { + /** + * @var \Psr\Http\Message\StreamInterface $stream + * @var int $rstart + */ + $stream = $context['stream']; + $rstart = $context['pos']; + foreach (self::iterPart($context) as $args) { + /** + * @var Models\GetObjectRequest $request + */ + $request = clone $context['request']; + $request->rangeHeader = sprintf('bytes=%d-%d', $args[0], $args[0] + $args[1] - 1); + $request->rangeBehavior = 'standard'; + $request->progressFn = null; + $offset = $stream->tell() + $args[0] - $rstart; + $sink = new GuzzleHttp\Psr7\LimitStream( + new GuzzleHttp\Psr7\LazyOpenStream($stream->getMetadata('uri'), 'rb+'), + -1, + $offset + ); + yield $this->client->getObjectAsync( + $request, + [ + 'request_options' => [ + 'sink' => $sink + ] + ] + )->otherwise( + function ($reason) use (&$context) { + $context['errors'][] = $reason; + return GuzzleHttp\Promise\Create::rejectionFor($reason); + }, + ); + if (!empty($context['errors'])) { + break; + } + } + }; + + $each = new GuzzleHttp\Promise\EachPromise( + $downloadFns(), + [ + 'concurrency' => $context['parallel_num'], + ] + ); + yield $each->promise(); + + if (!empty($context['errors'])) { + throw end($context['errors']); + } + })->then( + function ($result) use (&$context) { + $res = new Models\DownloadResult(); + $res->written = $context['epos'] - $context['pos']; + return $res; + }, + function ($reason) use (&$context) { + return GuzzleHttp\Promise\Create::rejectionFor(new Exception\DownloadException( + $context['filepath'] ?? '', + $reason + )); + } + ); + } + + private function filterArgs(array &$args) + { + return \array_filter($args, function ($key) { + return \array_key_exists($key, $this->defaultConfig); + }, \ARRAY_FILTER_USE_KEY); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/EncryptionClient.php b/vendor/alibabacloud/oss-v2/src/EncryptionClient.php new file mode 100644 index 0000000..3c93239 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/EncryptionClient.php @@ -0,0 +1,750 @@ + + */ + private array $cipherBuilderMap; + + /** + * @var int + */ + private int $alignLen = Crypto\AesCtr::BLOCK_SIZE_LEN; + + /** + * EncryptionClient constructor + * @param Client $client + * @param Crypto\MasterCipherInterface $masterCipher + * @param array $decryptMasterCiphers + */ + public function __construct( + Client $client, + Crypto\MasterCipherInterface $masterCipher, + ?array $decryptMasterCiphers = null + ) + { + $this->client = $client; + $this->defaultCipherBuilder = new Crypto\AesCtrCipherBuilder($masterCipher); + $this->cipherBuilderMap = []; + foreach ($decryptMasterCiphers ?? [] as $mc) { + if ($mc->getMatDesc() === '') { + continue; + } + $this->cipherBuilderMap[$mc->getMatDesc()] = new Crypto\AesCtrCipherBuilder($mc); + } + } + + public function unwrap(): Client + { + return $this->client; + } + + /** + * You can call this operation to upload an object. + * @param Models\PutObjectRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function putObjectAsync(Models\PutObjectRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->putObjectSecurelyAsync($request, $args); + } + + /** + * You can call this operation to upload an object. + * @param Models\PutObjectRequest $request + * @param array $args + * @return Models\PutObjectResult + */ + public function putObject(Models\PutObjectRequest $request, array $args = []): Models\PutObjectResult + { + return $this->putObjectAsync($request, $args)->wait(); + } + + /** + * @param Models\GetObjectRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function getObjectAsync(Models\GetObjectRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->getObjectSecurelyAsync($request, $args); + } + + /** + * You can call this operation to query an object. + * @param Models\GetObjectRequest $request + * @param array $args + * @return Models\GetObjectResult + */ + public function getObject(Models\GetObjectRequest $request, array $args = []): Models\GetObjectResult + { + return $this->getObjectAsync($request, $args)->wait(); + } + + /** + * You can call this operation to query the metadata of an object. + * @param Models\HeadObjectRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function headObjectAsync(Models\HeadObjectRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->client->headObjectAsync($request, $args); + } + + /** + * You can call this operation to query the metadata of an object. + * @param Models\HeadObjectRequest $request + * @param array $args + * @return Models\HeadObjectResult + */ + public function headObject(Models\HeadObjectRequest $request, array $args = []): Models\HeadObjectResult + { + return $this->headObjectAsync($request, $args)->wait(); + } + + /** + * Initiates a multipart upload task. + * @param Models\InitiateMultipartUploadRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + * @throws \Exception + */ + public function initiateMultipartUploadAsync(Models\InitiateMultipartUploadRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->initiateMultipartUploadSecurelyAsync($request, $args); + } + + /** + * Initiates a multipart upload task. + * @param Models\InitiateMultipartUploadRequest $request + * @param array $args + * @return Models\InitiateMultipartUploadResult + * @throws \Exception + */ + public function initiateMultipartUpload(Models\InitiateMultipartUploadRequest $request, array $args = []): Models\InitiateMultipartUploadResult + { + return $this->initiateMultipartUploadAsync($request, $args)->wait(); + } + + /** + * You can call this operation to upload an object by part based on the object name and the upload ID that you specify. + * @param Models\UploadPartRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function uploadPartAsync(Models\UploadPartRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->uploadPartSecurelyAsync($request, $args); + } + + /** + * You can call this operation to upload an object by part based on the object name and the upload ID that you specify. + * @param Models\UploadPartRequest $request + * @param array $args + * @return Models\UploadPartResult + */ + public function uploadPart(Models\UploadPartRequest $request, array $args = []): Models\UploadPartResult + { + return $this->uploadPartAsync($request, $args)->wait(); + } + + /** + * You can call this operation to complete the multipart upload task of an object. + * @param Models\CompleteMultipartUploadRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function completeMultipartUploadAsync(Models\CompleteMultipartUploadRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->client->completeMultipartUploadAsync($request, $args); + } + + /** + * You can call this operation to complete the multipart upload task of an object. + * @param Models\CompleteMultipartUploadRequest $request + * @param array $args + * @return Models\CompleteMultipartUploadResult + */ + public function completeMultipartUpload(Models\CompleteMultipartUploadRequest $request, array $args = []): Models\CompleteMultipartUploadResult + { + return $this->completeMultipartUploadAsync($request, $args)->wait(); + } + + /** + * Cancels a multipart upload task and deletes the parts uploaded in the task + * @param Models\AbortMultipartUploadRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function abortMultipartUploadAsync(Models\AbortMultipartUploadRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->client->abortMultipartUploadAsync($request, $args); + } + + /** + * Cancels a multipart upload task and deletes the parts uploaded in the task + * @param Models\AbortMultipartUploadRequest $request + * @param array $args + * @return Models\AbortMultipartUploadResult + */ + public function abortMultipartUpload(Models\AbortMultipartUploadRequest $request, array $args = []): Models\AbortMultipartUploadResult + { + return $this->abortMultipartUploadAsync($request, $args)->wait(); + } + + /** + * Lists all parts that are uploaded by using a specified upload ID. + * @param Models\ListPartsRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function listPartsAsync(Models\ListPartsRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->client->listPartsAsync($request, $args); + } + + /** + * Lists all parts that are uploaded by using a specified upload ID. + * @param Models\ListPartsRequest $request + * @param array $args + * @return Models\ListPartsResult + */ + public function listParts(Models\ListPartsRequest $request, array $args = []): Models\ListPartsResult + { + return $this->listPartsAsync($request, $args)->wait(); + } + + /** + * You can call this operation to query the metadata of an object, including ETag, Size, and LastModified. The content of the object is not returned. + * @param Models\GetObjectMetaRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function getObjectMetaAsync(Models\GetObjectMetaRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + return $this->client->getObjectMetaAsync($request, $args); + } + + /** + * You can call this operation to query the metadata of an object, including ETag, Size, and LastModified. The content of the object is not returned. + * @param Models\GetObjectMetaRequest $request + * @param array $args + * @return Models\GetObjectMetaResult + */ + public function getObjectMeta(Models\GetObjectMetaRequest $request, array $args = []): Models\GetObjectMetaResult + { + return $this->getObjectMetaAsync($request, $args)->wait(); + } + + /** + * Creates uploader. + * The uploader calls the multipart upload operation to split a large local file or + * stream into multiple smaller parts and upload the parts in parallel to improve upload performance. + * + * @param array $args accepts the following: + * - part_size: (int) The part size. Default value: 6 MiB. + * - parallel_num: (int) The number of the upload tasks in parallel. + * Default value: 3. + * - leave_parts_on_error: (bool) Specifies whether to retain the uploaded parts when an upload task fails. + * By default, the uploaded parts are not retained. + * @return Uploader + */ + public function newUploader(array $args = []): Uploader + { + return new Uploader($this, $args); + } + + /** + * Creates a new Downloader instance to download objects. + * @param array $args + * @return Downloader + */ + public function newDownloader(array $args = []): Downloader + { + return new Downloader($this, $args); + } + + /** + * @param Models\PutObjectRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function putObjectSecurelyAsync(Models\PutObjectRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + $eRequest = clone $request; + $cc = $this->defaultCipherBuilder->fromCipherData(); + if ($request->body != null) { + $cipher = $cc->getCipher(0); + $eRequest->body = new Crypto\ReadEncryptStream($request->body, $cipher); + } + $this->addCryptoHeaders($eRequest, $cc->getCipherData()); + return $this->client->putObjectAsync($eRequest, $args); + } + + /** + * @param Models\GetObjectRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function getObjectSecurelyAsync(Models\GetObjectRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + $rangeHeader = null; + $discardCount = 0; + $adjustOffset = 0; + if ($request->rangeHeader != null) { + $ranges = Utils::parseHttpRange($request->rangeHeader); + if ($ranges === false) { + throw new \InvalidArgumentException("request.rangeHeader is invalid, got $request->rangeHeader"); + } + $start = $ranges[0] < 0 ? 0 : $ranges[0]; + $adjustOffset = $this->adjustRangeStart($start); + $discardCount = $start - $adjustOffset; + if ($discardCount > 0) { + // bytes=0-1023 or bytes=0- + $rangeHeader = sprintf('bytes=%d-', $adjustOffset); + if ($ranges[1] >= 0) { + $rangeHeader .= strval($ranges[1]); + } + } + } + + $eRequest = $request; + if ($rangeHeader != null) { + $eRequest = clone $request; + $eRequest->rangeHeader = $rangeHeader; + $eRequest->rangeBehavior = 'standard'; + } + + // stream mode + if ( + isset($args['request_options']) && + isset($args['request_options']['stream']) && + $args['request_options']['stream'] === true + ) { + /** + * @var Crypto\ContentCipherInterface $contentCipher + */ + $contentCipher = null; + $args['request_options'] = array_merge($args['request_options'], [ + 'on_headers' => function ($response) use (&$contentCipher) { + $contentCipher = $this->contentCipherfromHeaders($response); + } + ]); + return $this->client->getObjectAsync($eRequest, $args)->then( + function (Models\GetObjectResult $result) use (&$adjustOffset, &$discardCount, &$contentCipher) { + $body = $result->body; + if ($contentCipher !== null) { + $cipher = $contentCipher->getCipher($adjustOffset); + $body = new Crypto\ReadDecryptStream($body, $cipher); + } + if ($discardCount > 0) { + $body->read($discardCount); + } + $result = $this->adjustGetObjectResult($result, $discardCount); + $result->body = $body; + return $result; + } + ); + } + + // non stream mode, and save into + $sink = null; + if (isset($args['request_options']) && isset($args['request_options']['sink'])) { + $sink = $args['request_options']['sink']; + } + $fromFilepath = \is_string($sink); + $stream = $fromFilepath ? + new GuzzleHttp\Psr7\LazyOpenStream($sink, 'w+') : Utils::streamFor($sink); + + $esink = new Crypto\LazyDecryptStream( + $stream, + $discardCount, + function ($response) { + return $this->contentCipherfromHeaders($response); + } + ); + + $args['request_options'] = array_merge($args['request_options'] ?? [], [ + 'sink' => $esink + ]); + return $this->client->getObjectAsync($eRequest, $args)->then( + function (Models\GetObjectResult $result) use (&$discardCount, &$fromFilepath) { + $result = $this->adjustGetObjectResult($result, $discardCount); + // unwrap stream from LazyDecryptStream + if ($result->body instanceof Crypto\LazyDecryptStream) { + $result->body = $fromFilepath ? null : $result->body->unwrap(); + } + return $result; + } + ); + } + + /** + * @param Models\InitiateMultipartUploadRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + * @throws \Exception + */ + public function initiateMultipartUploadSecurelyAsync(Models\InitiateMultipartUploadRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + $eRequest = clone $request; + $this->validEncryption($eRequest); + $cc = $this->defaultCipherBuilder->fromCipherData(); + $this->addMultiPartCryptoHeaders($eRequest, $cc->getCipherData()); + return $this->client->initiateMultipartUploadAsync($eRequest, $args)->then(function (Models\InitiateMultipartUploadResult $result) use ($eRequest, $cc) { + $result->encryptionMultipartContext = new Models\EncryptionMultipartContext( + $cc, + $eRequest->cseDataSize, + $eRequest->csePartSize + ); + return $result; + }); + } + + /** + * @param Models\UploadPartRequest $request + * @param array $args + * @return GuzzleHttp\Promise\Promise + */ + public function uploadPartSecurelyAsync(Models\UploadPartRequest $request, array $args = []): GuzzleHttp\Promise\Promise + { + $eRequest = clone $request; + if ($eRequest->encryptionMultipartContext === null) { + throw new \InvalidArgumentException("request.encryptionMultiPart is null."); + } + + if (!$eRequest->encryptionMultipartContext->valid()) { + throw new \InvalidArgumentException("request.encryptionMultiPart is invalid."); + } + + if ($eRequest->encryptionMultipartContext->partSize % $this->alignLen != 0) { + throw new \InvalidArgumentException("request.encryptionMultiPart.partSize must be aligned to " . $this->alignLen); + } + + $cipherData = clone $eRequest->encryptionMultipartContext->contentCipher->getCipherData(); + $offset = 0; + if ($request->partNumber > 1) { + $offset = ($request->partNumber - 1) * $eRequest->encryptionMultipartContext->partSize; + } + $cc = $this->defaultCipherBuilder->fromCipherData($cipherData); + if ($request->body != null) { + $cipher = $cc->getCipher($offset); + $eRequest->body = new Crypto\ReadEncryptStream($request->body, $cipher); + } + + $this->addUploadPartCryptoHeaders($eRequest, $cc->getCipherData(), $eRequest->encryptionMultipartContext); + + return $this->client->uploadPartAsync($eRequest, $args); + } + + /** + * @param Models\PutObjectRequest $request + * @param Crypto\CipherData $cipherData + */ + private function addCryptoHeaders(Models\PutObjectRequest &$request, Crypto\CipherData $cipherData) + { + if ($request->metadata == null) { + $request->metadata = []; + } + + /* + "X-Oss-Meta-Client-Side-Encryption-Key" + "X-Oss-Meta-Client-Side-Encryption-Start" + "X-Oss-Meta-Client-Side-Encryption-Cek-Alg" + "X-Oss-Meta-Client-Side-Encryption-Wrap-Alg" + "X-Oss-Meta-Client-Side-Encryption-Matdesc" + "X-Oss-Meta-Client-Side-Encryption-Unencrypted-Content-Length" + "X-Oss-Meta-client-side-encryption-unencrypted-content-md5" + "X-Oss-Meta-Client-Side-Encryption-Data-Size" + "X-Oss-Meta-Client-Side-Encryption-Part-Size" + */ + + // convert content-md5 + if ($request->contentMd5 != null) { + $request->metadata['client-side-encryption-unencrypted-content-md5'] = $request->contentMd5; + $request->contentMd5 = null; + } + + // convert content-length + if ($request->contentLength != null) { + $request->metadata['client-side-encryption-unencrypted-content-length'] = strval($request->contentLength); + $request->contentLength = null; + } + + // matDesc + if (Utils::safetyString($cipherData->matDesc) != '') { + $request->metadata['client-side-encryption-matdesc'] = $cipherData->matDesc; + } + + // encrypted key + $request->metadata['client-side-encryption-key'] = base64_encode($cipherData->encryptedKey); + + // encrypted iv + $request->metadata['client-side-encryption-start'] = base64_encode($cipherData->encryptedIv); + + // wrap alg + $request->metadata['client-side-encryption-wrap-alg'] = $cipherData->wrapAlgorithm; + + // cek alg + $request->metadata['client-side-encryption-cek-alg'] = $cipherData->cekAlgorithm; + } + + /** + * @param Models\InitiateMultipartUploadRequest $request + * @param Crypto\CipherData $cipherData + */ + private function addMultiPartCryptoHeaders(Models\InitiateMultipartUploadRequest &$request, Crypto\CipherData $cipherData) + { + if ($request->metadata == null) { + $request->metadata = []; + } + + /* + "X-Oss-Meta-Client-Side-Encryption-Key" + "X-Oss-Meta-Client-Side-Encryption-Start" + "X-Oss-Meta-Client-Side-Encryption-Cek-Alg" + "X-Oss-Meta-Client-Side-Encryption-Wrap-Alg" + "X-Oss-Meta-Client-Side-Encryption-Matdesc" + "X-Oss-Meta-Client-Side-Encryption-Unencrypted-Content-Length" + "X-Oss-Meta-client-side-encryption-unencrypted-content-md5" + "X-Oss-Meta-Client-Side-Encryption-Data-Size" + "X-Oss-Meta-Client-Side-Encryption-Part-Size" + */ + + // convert content-md5 + if ($request->contentMd5 != null) { + $request->metadata['client-side-encryption-unencrypted-content-md5'] = $request->contentMd5; + $request->contentMd5 = null; + } + + // convert content-length + if ($request->contentLength != null) { + $request->metadata['client-side-encryption-unencrypted-content-length'] = strval($request->contentLength); + $request->contentLength = null; + } + + // matDesc + if (Utils::safetyString($cipherData->matDesc) != '') { + $request->metadata['client-side-encryption-matdesc'] = $cipherData->matDesc; + } + + // data size + $request->metadata['client-side-encryption-data-size'] = $request->cseDataSize; + + // part size + $request->metadata['client-side-encryption-part-size'] = $request->csePartSize; + + // encrypted key + $request->metadata['client-side-encryption-key'] = base64_encode($cipherData->encryptedKey); + + // encrypted iv + $request->metadata['client-side-encryption-start'] = base64_encode($cipherData->encryptedIv); + + // wrap alg + $request->metadata['client-side-encryption-wrap-alg'] = $cipherData->wrapAlgorithm; + + // cek alg + $request->metadata['client-side-encryption-cek-alg'] = $cipherData->cekAlgorithm; + } + + /** + * @param Models\UploadPartRequest $request + * @param Crypto\CipherData $cipherData + * @param Models\EncryptionMultiPart $encryptionMultiPart + */ + private function addUploadPartCryptoHeaders(Models\UploadPartRequest &$request, Crypto\CipherData $cipherData, Models\EncryptionMultipartContext $encryptionMultipart) + { + /* + "X-Oss-Meta-Client-Side-Encryption-Key" + "X-Oss-Meta-Client-Side-Encryption-Start" + "X-Oss-Meta-Client-Side-Encryption-Cek-Alg" + "X-Oss-Meta-Client-Side-Encryption-Wrap-Alg" + "X-Oss-Meta-Client-Side-Encryption-Matdesc" + "X-Oss-Meta-Client-Side-Encryption-Unencrypted-Content-Length" + "X-Oss-Meta-client-side-encryption-unencrypted-content-md5" + "X-Oss-Meta-Client-Side-Encryption-Data-Size" + "X-Oss-Meta-Client-Side-Encryption-Part-Size" + */ + + // convert content-md5 + if ($request->contentMd5 != null) { + $request->clientSideEncryptionUnencryptedContentMd5 = $request->contentMd5; + $request->contentMd5 = null; + } + + // convert content-length + if ($request->contentLength != null) { + $request->clientSideEncryptionUnencryptedContentLength = $request->contentLength; + $request->contentLength = null; + } + + // matDesc + if (Utils::safetyString($cipherData->matDesc) != '') { + $request->clientSideEncryptionMatdesc = $cipherData->matDesc; + } + + // data size + $request->clientSideEncryptionDataSize = $encryptionMultipart->dataSize; + + // part size + $request->clientSideEncryptionPartSize = $encryptionMultipart->partSize; + + // encrypted key + $request->clientSideEncryptionKey = base64_encode($cipherData->encryptedKey); + + // encrypted iv + $request->clientSideEncryptionStart = base64_encode($cipherData->encryptedIv); + + // wrap alg + $request->clientSideEncryptionWrapAlg = $cipherData->wrapAlgorithm; + + // cek alg + $request->clientSideEncryptionCekAlg = $cipherData->cekAlgorithm; + } + + /** + * @param int $offset + * @return int + */ + private function adjustRangeStart(int $offset): int + { + $remians = $offset % $this->alignLen; + return $remians > 0 ? $offset - $remians : $offset; + } + + /** + * @param Models\GetObjectResult $result + * @param $discardCount + * @return Models\GetObjectResult + */ + private function adjustGetObjectResult(Models\GetObjectResult $result, $discardCount) + { + if ($discardCount == 0) { + return $result; + } + + if ($result->contentLength != null) { + $result->contentLength -= $discardCount; + $result->headers['Content-Length'] = strval($result->contentLength); + } + + if ($result->contentRange != null) { + //"bytes 0-10239/25723" + $vals = Utils::parseContentRange($result->contentRange); + if ($vals === false) { + throw new \RuntimeException("parse Content-Range error, got $result->contentRange"); + } + $offset = $vals[0]; + $pos = strpos($result->contentRange, '-'); + $start = $offset + $discardCount; + $val = "bytes $start" . substr($result->contentRange, $pos); + $result->headers['Content-Range'] = $val; + $result->contentRange = $val; + } + + return $result; + } + + /** + * @param \Psr\Http\Message\ResponseInterface $response + * @return bool + */ + private function hasEncryptedHeader(\Psr\Http\Message\ResponseInterface $response): bool + { + return $response->hasHeader('x-oss-meta-client-side-encryption-key'); + } + + /** + * @param \Psr\Http\Message\ResponseInterface $response + * @return Crypto\ContentCipherInterface|null + */ + private function contentCipherfromHeaders(\Psr\Http\Message\ResponseInterface $response) + { + if (!$this->hasEncryptedHeader($response)) { + return null; + } + + // env from headers + $envelope = new Crypto\Envelope(); + $envelope->iv = base64_decode($response->getHeader('x-oss-meta-client-side-encryption-start')[0]); + $envelope->key = base64_decode($response->getHeader('x-oss-meta-client-side-encryption-key')[0]); + if ($response->hasHeader('x-oss-meta-client-side-encryption-matdesc')) { + $envelope->matDesc = $response->getHeader('x-oss-meta-client-side-encryption-matdesc')[0]; + } + + $envelope->cekAlg = $response->getHeader('x-oss-meta-client-side-encryption-cek-alg')[0]; + $envelope->wrapAlg = $response->getHeader('x-oss-meta-client-side-encryption-wrap-alg')[0]; + + if ($response->hasHeader('x-oss-meta-client-side-encryption-unencrypted-content-length')) { + $envelope->unencryptedContentLen = $response->getHeader('x-oss-meta-client-side-encryption-unencrypted-content-length')[0]; + } + + if ($response->hasHeader('x-oss-meta-client-side-encryption-unencrypted-content-md5')) { + $envelope->unencryptedMd5 = $response->getHeader('x-oss-meta-client-side-encryption-unencrypted-content-md5')[0]; + } + + $ccbuilder = $this->getContentCipherBuilder($envelope->matDesc); + + return $ccbuilder->fromEnvelope($envelope); + } + + /** + * @param string|null $matDesc + * @return Crypto\AesCtrCipherBuilder|mixed + */ + private function getContentCipherBuilder(?string $matDesc) + { + if ( + $matDesc != null && + $matDesc != '' && + \array_key_exists($matDesc, $this->cipherBuilderMap) + ) { + return $this->cipherBuilderMap[$matDesc]; + } + + return $this->defaultCipherBuilder; + } + + /** + * Valid part size. + * @throws \InvalidArgumentException + */ + private function validEncryption(Models\InitiateMultipartUploadRequest $request) + { + $partSize = intval($request->csePartSize); + if ($partSize <= 0) { + throw new \InvalidArgumentException('request.csePartSize is invalid.'); + } + $dataSize = intval($request->cseDataSize); + if ($dataSize <= 0) { + throw new \InvalidArgumentException('request.cseDataSize is invalid.'); + } + + if ($partSize % $this->alignLen != 0) { + throw new \InvalidArgumentException("request.csePartSize must be aligned to " . $this->alignLen); + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Exception/CopyException.php b/vendor/alibabacloud/oss-v2/src/Exception/CopyException.php new file mode 100644 index 0000000..cad3a50 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Exception/CopyException.php @@ -0,0 +1,41 @@ +uploadId = $uploadId; + $this->path = $path; + + $message = "copy failed, $uploadId, $path"; + if ($previous !== null) { + $message = $message . ', ' . $previous->getMessage(); + } + parent::__construct($message, 0, $previous); + } + + public function getUploadId() + { + return $this->uploadId; + } + + public function getPath() + { + return $this->path; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Exception/CredentialsException.php b/vendor/alibabacloud/oss-v2/src/Exception/CredentialsException.php new file mode 100644 index 0000000..879e13c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Exception/CredentialsException.php @@ -0,0 +1,18 @@ +filepath = $filepath; + + $message = "download failed, $filepath"; + if ($previous !== null) { + $message = $message . ', ' . $previous->getMessage(); + } + parent::__construct($message, 0, $previous); + } + + public function getFilepath() + { + return $this->filepath; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Exception/InconsistentExecption.php b/vendor/alibabacloud/oss-v2/src/Exception/InconsistentExecption.php new file mode 100644 index 0000000..f3d9db7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Exception/InconsistentExecption.php @@ -0,0 +1,25 @@ +hasHeader('x-oss-request-id')) { + $requestId = $response->getHeader('x-oss-request-id')[0]; + } + } + parent::__construct("crc is inconsistent, client crc: $crc1, server crc: $crc2, request id: $requestId"); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Exception/OperationException.php b/vendor/alibabacloud/oss-v2/src/Exception/OperationException.php new file mode 100644 index 0000000..6636255 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Exception/OperationException.php @@ -0,0 +1,22 @@ +getMessage(); + } + parent::__construct($message, 0, $previous); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Exception/ParserException.php b/vendor/alibabacloud/oss-v2/src/Exception/ParserException.php new file mode 100644 index 0000000..267fd10 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Exception/ParserException.php @@ -0,0 +1,17 @@ +details = $details; + $message = "Error returned by Service.\n" . + "Http Status Code: " . $this->getStatusCode() . "\n" . + "Error Code: " . $this->getErrorCode() . "\n" . + "Request Id: " . $this->getRequestId() . "\n" . + "Message: " . $this->getErrorMessage() . "\n" . + "EC: " . $this->getEC() . "\n" . + "Timestamp: " . $this->getHeader('Date') . "\n" . + "Request Endpoint: " . $this->getRequestTarget(); + } else { + $this->details = []; + } + + parent::__construct($message); + } + + public function getStatusCode() + { + return $this->details['status_code'] ?? 0; + } + + public function getRequestId() + { + return $this->details['request_id'] ?? ''; + } + + public function getErrorCode() + { + return $this->details['code'] ?? ''; + } + + public function getErrorMessage() + { + return $this->details['message'] ?? ''; + } + + public function getEC() + { + return $this->details['ec'] ?? ''; + } + + public function getTimestamp(): ?\DateTime + { + $date = $this->getHeader('Date'); + $timestamp = \DateTime::createFromFormat('D, d M Y H:i:s \G\M\T', $date, new \DateTimeZone('UTC')); + if ($timestamp === false) { + return null; + } + return $timestamp; + } + + public function getRequestTarget(): string + { + return $this->details['request_target'] ?? ''; + } + + public function getSnapshot(): string + { + return $this->details['snapshot'] ?? ''; + } + + public function getHeaders(): array + { + return $this->details['headers'] ?? []; + } + + public function getHeader(string $key): string + { + if ( + isset($this->details['headers']) && + isset($this->details['headers'][$key]) + ) { + $v = $this->details['headers'][$key]; + if (\is_array($v)) { + return $v[0]; + } + return $v; + } + return ''; + } + + public function getErrorFields() + { + return $this->details['error_fields'] ?? []; + } + + public function getErrorField(string $field): string + { + if (isset($this->details['error_fields'])) { + return $this->details['error_fields'][$field] ?? ''; + } + return ''; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Exception/StreamRewindException.php b/vendor/alibabacloud/oss-v2/src/Exception/StreamRewindException.php new file mode 100644 index 0000000..4c4caa7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Exception/StreamRewindException.php @@ -0,0 +1,17 @@ +uploadId = $uploadId; + $this->filepath = $filepath; + + $message = "upload failed, $uploadId, $filepath"; + if ($previous !== null) { + $message = $message . ', ' . $previous->getMessage(); + } + parent::__construct($message, 0, $previous); + } + + public function getUploadId() + { + return $this->uploadId; + } + + public function getFilepath() + { + return $this->filepath; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormRequest.php b/vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormRequest.php new file mode 100644 index 0000000..4608765 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormResult.php b/vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormResult.php new file mode 100644 index 0000000..1b0cc76 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AbortBucketWormResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/AbortMultipartUploadResult.php b/vendor/alibabacloud/oss-v2/src/Models/AbortMultipartUploadResult.php new file mode 100644 index 0000000..fdb14a3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AbortMultipartUploadResult.php @@ -0,0 +1,16 @@ +grant = $grant; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/AccessMonitorConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/AccessMonitorConfiguration.php new file mode 100644 index 0000000..76505d8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AccessMonitorConfiguration.php @@ -0,0 +1,36 @@ +status = $status; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AccessMonitorStatusType.php b/vendor/alibabacloud/oss-v2/src/Models/AccessMonitorStatusType.php new file mode 100644 index 0000000..4599684 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AccessMonitorStatusType.php @@ -0,0 +1,15 @@ +networkOrigin = $networkOrigin; + $this->vpcConfiguration = $vpcConfiguration; + $this->status = $status; + $this->bucket = $bucket; + $this->accessPointName = $accessPointName; + $this->alias = $alias; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AccessPointEndpoints.php b/vendor/alibabacloud/oss-v2/src/Models/AccessPointEndpoints.php new file mode 100644 index 0000000..c2aac1b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AccessPointEndpoints.php @@ -0,0 +1,45 @@ +publicEndpoint = $publicEndpoint; + $this->internalEndpoint = $internalEndpoint; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AccessPointVpcConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/AccessPointVpcConfiguration.php new file mode 100644 index 0000000..24884b8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AccessPointVpcConfiguration.php @@ -0,0 +1,35 @@ +vpcId = $vpcId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AccessPoints.php b/vendor/alibabacloud/oss-v2/src/Models/AccessPoints.php new file mode 100644 index 0000000..a3d855d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AccessPoints.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'AccessPoint', type: AccessPoint::class)] + public ?array $accessPoints; + + /** + * AccessPoints constructor. + * @param array|null $accessPoints The container that stores the information about all access point. + */ + public function __construct( + ?array $accessPoints = null + ) + { + $this->accessPoints = $accessPoints; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AppendObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/AppendObjectRequest.php new file mode 100644 index 0000000..20a2ecf --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AppendObjectRequest.php @@ -0,0 +1,234 @@ +|null + */ + public ?array $metadata; + + /** + * The web page caching behavior for the object. For more information, see **[RFC 2616](https://www.ietf.org/rfc/rfc2616.txt)**. Default value: null. + * @var string|null + */ + public ?string $cacheControl; + + /** + * The name of the object when the object is downloaded. For more information, see **[RFC 2616](https://www.ietf.org/rfc/rfc2616.txt)**. Default value: null. + * @var string|null + */ + public ?string $contentDisposition; + + /** + * The encoding format of the object content. For more information, see **[RFC 2616](https://www.ietf.org/rfc/rfc2616.txt)**. Default value: null. + * @var string|null + */ + public ?string $contentEncoding; + + /** + * The size of the data in the HTTP message body. + * @var int|null + */ + public ?int $contentLength; + + /** + * The Content-MD5 header value is a string calculated by using the MD5 algorithm. The header is used to check whether the content of the received message is the same as that of the sent message. To obtain the value of the Content-MD5 header, calculate a 128-bit number based on the message content except for the header, and then encode the number in Base64. Default value: null.Limits: none. + * @var string|null + */ + public ?string $contentMd5; + + /** + * The content type of an HTTP request. + * @var string|null + */ + public ?string $contentType; + + /** + * The expiration time. For more information, see **[RFC 2616](https://www.ietf.org/rfc/rfc2616.txt)**. Default value: null. + * @var string|null + */ + public ?string $expires; + + /** + * The method used to encrypt objects on the specified OSS server. Valid values:- AES256: Keys managed by OSS are used for encryption and decryption (SSE-OSS). - KMS: Keys managed by Key Management Service (KMS) are used for encryption and decryption. - SM4: The SM4 block cipher algorithm is used for encryption and decryption. + * @var string|null + */ + public ?string $serverSideEncryption; + + /** + * Specify the encryption algorithm for the object. Valid values: SM4. + * If this option is not specified, it indicates that the Object uses AES256 encryption algorithm. + * This option is only valid when x-oss-ser-side-encryption is KMS. + * @var string|null + */ + public ?string $serverSideDataEncryption; + + /** + * The ID of the CMK that is managed by KMS. This header is valid only when **x-oss-server-side-encryption** is set to KMS. + * @var string|null + */ + public ?string $serverSideEncryptionKeyId; + + /** + * The tags that are specified for the object by using a key-value pair. + * You can specify multiple tags for an object. Example: TagA=A&TagB=B. + * @var string|null + */ + public ?string $tagging; + + /** + * Specifies whether the AppendObject operation overwrites objects with the same name. The x-oss-forbid-overwrite request header does not take effect when versioning is enabled or suspended for the destination bucket. In this case, the AppendObject operation overwrites the existing object that has the same name as the destination object. + * If you do not specify the x-oss-forbid-overwrite header or set the header to false, an existing object that has the same name as the object that you want to copy is overwritten. + * If you set the x-oss-forbid-overwrite header to true, an existing object that has the same name as the object that you want to copy is not overwritten. + * @var bool|null + */ + public ?bool $forbidOverwrite; + + /** + * Specify the speed limit value. The speed limit value ranges from 245760 to 838860800, with a unit of bit/s. + * @var int|null + */ + public ?int $trafficLimit; + + /** + * To indicate that the requester is aware that the request and data download will incur costs. + * @var string|null + */ + public ?string $requestPayer; + + /** + * The request body. + * @var \Psr\Http\Message\StreamInterface|null + */ + public ?\Psr\Http\Message\StreamInterface $body; + + /** + * Progress callback function + * @var callable|null + */ + public $progressFn; + + /** + * AppendObjectRequest constructor. + * @param string|null $bucket The name of the bucket. + * @param string|null $key The full path of the object. + * @param int|null $position The position from which the AppendObject operation starts. + * @param string|null $acl The access control list (ACL) of the object. + * @param string|null $storageClass The storage class of the object that you want to upload. + * @param array|null $metadata The metadata of the object that you want to upload. + * @param string|null $cacheControl The web page caching behavior for the object. + * @param string|null $contentDisposition The name of the object when the object is downloaded. + * @param string|null $contentEncoding The encoding format of the object content. + * @param string|null $contentLength The content length of an HTTP request. + * @param string|null $contentMd5 The Content-MD5 header value is a string calculated by using the MD5 algorithm. + * @param string|null $contentType The content type of an HTTP request. + * @param string|null $expires The expiration time. + * @param string|null $serverSideEncryption The method used to encrypt objects on the specified OSS server. + * @param string|null $serverSideDataEncryption Specify the encryption algorithm for the object. + * @param string|null $serverSideEncryptionKeyId The ID of the CMK that is managed by KMS. + * @param string|null $tagging The tags that are specified for the object by using a key-value pair. + * @param bool|null $forbidOverwrite Specifies whether the AppendObject operation overwrites objects with the same name. + * @param int|null $trafficLimit Specify the speed limit value. + * @param string|null $requestPayer To indicate that the requester is aware that the request and data download will incur costs. + * @param \Psr\Http\Message\StreamInterface|null $body The request body. + * @param callable|null $progressFn Progress callback function + * @param array|null $options + * @param string|null $objectAcl The access control list (ACL) of the object. The object acl parameter has the same functionality as the acl parameter. it is the standardized name for acl. If both exist simultaneously, the value of objectAcl will take precedence. + */ + public function __construct( + ?string $bucket = null, + ?string $key = null, + ?int $position = null, + ?string $acl = null, + ?string $storageClass = null, + ?array $metadata = null, + ?string $cacheControl = null, + ?string $contentDisposition = null, + ?string $contentEncoding = null, + ?string $contentLength = null, + ?string $contentMd5 = null, + ?string $contentType = null, + ?string $expires = null, + ?string $serverSideEncryption = null, + ?string $serverSideDataEncryption = null, + ?string $serverSideEncryptionKeyId = null, + ?string $tagging = null, + ?bool $forbidOverwrite = null, + ?int $trafficLimit = null, + ?string $requestPayer = null, + ?\Psr\Http\Message\StreamInterface $body = null, + ?callable $progressFn = null, + ?array $options = null, + ?string $objectAcl = null + ) + { + $this->bucket = $bucket; + $this->key = $key; + $this->position = $position; + $this->acl = $objectAcl ?? $acl; + $this->storageClass = $storageClass; + $this->metadata = $metadata; + $this->cacheControl = $cacheControl; + $this->contentDisposition = $contentDisposition; + $this->contentEncoding = $contentEncoding; + $this->contentLength = $contentLength; + $this->contentMd5 = $contentMd5; + $this->contentType = $contentType; + $this->expires = $expires; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->tagging = $tagging; + $this->forbidOverwrite = $forbidOverwrite; + $this->trafficLimit = $trafficLimit; + $this->requestPayer = $requestPayer; + $this->body = $body; + $this->progressFn = $progressFn; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/AppendObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/AppendObjectResult.php new file mode 100644 index 0000000..5230b36 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AppendObjectResult.php @@ -0,0 +1,86 @@ +nextPosition = $nextPosition; + $this->etag = $etag; + $this->hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ApplyServerSideEncryptionByDefault.php b/vendor/alibabacloud/oss-v2/src/Models/ApplyServerSideEncryptionByDefault.php new file mode 100644 index 0000000..8edb107 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ApplyServerSideEncryptionByDefault.php @@ -0,0 +1,56 @@ +sseAlgorithm = $sseAlgorithm; + $this->kmsMasterKeyID = $kmsMasterKeyID; + $this->kmsDataEncryption = $kmsDataEncryption; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ArchiveDirectReadConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/ArchiveDirectReadConfiguration.php new file mode 100644 index 0000000..bc1347c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ArchiveDirectReadConfiguration.php @@ -0,0 +1,35 @@ +enabled = $enabled; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectRequest.php new file mode 100644 index 0000000..8ebd2bc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->process = $process; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectResult.php new file mode 100644 index 0000000..259fd01 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/AsyncProcessObjectResult.php @@ -0,0 +1,50 @@ +eventId = $eventId; + $this->taskId = $taskId; + $this->processRequestId = $processRequestId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/Bucket.php b/vendor/alibabacloud/oss-v2/src/Models/Bucket.php new file mode 100644 index 0000000..54df2a3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Bucket.php @@ -0,0 +1,106 @@ +storageClass = $storageClass; + $this->region = $region; + $this->creationDate = $creationDate; + $this->extranetEndpoint = $extranetEndpoint; + $this->intranetEndpoint = $intranetEndpoint; + $this->location = $location; + $this->name = $name; + $this->resourceGroupId = $resourceGroupId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketACLType.php b/vendor/alibabacloud/oss-v2/src/Models/BucketACLType.php new file mode 100644 index 0000000..8221aa9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketACLType.php @@ -0,0 +1,30 @@ +cname = $cname; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/src/Models/BucketDataRedundancyTransition.php new file mode 100644 index 0000000..58423d0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketDataRedundancyTransition.php @@ -0,0 +1,106 @@ +processPercentage = $processPercentage; + $this->estimatedRemainingTime = $estimatedRemainingTime; + $this->bucket = $bucket; + $this->status = $status; + $this->taskId = $taskId; + $this->createTime = $createTime; + $this->startTime = $startTime; + $this->endTime = $endTime; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketInfo.php b/vendor/alibabacloud/oss-v2/src/Models/BucketInfo.php new file mode 100644 index 0000000..15dc10e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketInfo.php @@ -0,0 +1,189 @@ +name = $name; + $this->accessMonitor = $accessMonitor; + $this->location = $location; + $this->creationDate = $creationDate; + $this->extranetEndpoint = $extranetEndpoint; + $this->intranetEndpoint = $intranetEndpoint; + $this->acl = $acl; + $this->dataRedundancyType = $dataRedundancyType; + $this->owner = $owner; + $this->storageClass = $storageClass; + $this->resourceGroupId = $resourceGroupId; + $this->sseRule = $sseRule; + $this->versioning = $versioning; + $this->transferAcceleration = $transferAcceleration; + $this->crossRegionReplication = $crossRegionReplication; + $this->comment = $comment; + $this->blockPublicAccess = $blockPublicAccess; + $this->bucketPolicy = $bucketPolicy; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketLoggingStatus.php b/vendor/alibabacloud/oss-v2/src/Models/BucketLoggingStatus.php new file mode 100644 index 0000000..2d88ae7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketLoggingStatus.php @@ -0,0 +1,36 @@ +loggingEnabled = $loggingEnabled; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketPolicy.php b/vendor/alibabacloud/oss-v2/src/Models/BucketPolicy.php new file mode 100644 index 0000000..00420f7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketPolicy.php @@ -0,0 +1,45 @@ +logBucket = $logBucket; + $this->logPrefix = $logPrefix; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketResourceGroupConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/BucketResourceGroupConfiguration.php new file mode 100644 index 0000000..81110ec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketResourceGroupConfiguration.php @@ -0,0 +1,35 @@ +resourceGroupId = $resourceGroupId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/BucketVersioningStatusType.php b/vendor/alibabacloud/oss-v2/src/Models/BucketVersioningStatusType.php new file mode 100644 index 0000000..20c8e0a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/BucketVersioningStatusType.php @@ -0,0 +1,22 @@ +|null + */ + #[XmlElement(rename: 'CORSRule', type: CORSRule::class)] + public ?array $corsRules; + + /** + * Indicates whether the Vary: Origin header was returned. Default value: false.- true: The Vary: Origin header is returned regardless whether the request is a cross-origin request or whether the cross-origin request succeeds.- false: The Vary: Origin header is not returned. + * @var bool|null + */ + #[XmlElement(rename: 'ResponseVary', type: 'bool')] + public ?bool $responseVary; + + + /** + * CORSConfiguration constructor. + * @param array|null $corsRules The container that stores CORS rules. + * @param bool|null $responseVary Indicates whether the Vary: Origin header was returned. + */ + public function __construct( + ?array $corsRules = null, + ?bool $responseVary = null + ) + { + $this->corsRules = $corsRules; + $this->responseVary = $responseVary; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CORSRule.php b/vendor/alibabacloud/oss-v2/src/Models/CORSRule.php new file mode 100644 index 0000000..15530b9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CORSRule.php @@ -0,0 +1,76 @@ +|null + */ + #[XmlElement(rename: 'AllowedHeader', type: 'string')] + public ?array $allowedHeaders; + + /** + * The response headers for allowed access requests from applications, such as an XMLHttpRequest object in JavaScript. The asterisk (\*) wildcard character is not supported. + * @var array|null + */ + #[XmlElement(rename: 'ExposeHeader', type: 'string')] + public ?array $exposeHeaders; + + /** + * The period of time within which the browser can cache the response to an OPTIONS preflight request for the specified resource. Unit: seconds.You can specify only one MaxAgeSeconds element in a CORS rule. + * @var int|null + */ + #[XmlElement(rename: 'MaxAgeSeconds', type: 'int')] + public ?int $maxAgeSeconds; + + /** + * The origins from which cross-origin requests are allowed. + * @var array|null + */ + #[XmlElement(rename: 'AllowedOrigin', type: 'string')] + public ?array $allowedOrigins; + + /** + * The methods that you can use in cross-origin requests. + * @var array|null + */ + #[XmlElement(rename: 'AllowedMethod', type: 'string')] + public ?array $allowedMethods; + + + /** + * CORSRule constructor. + * @param array|null $allowedHeaders Specifies whether the headers specified by Access-Control-Request-Headers in the OPTIONS preflight request are allowed. + * @param array|null $exposeHeaders The response headers for allowed access requests from applications, such as an XMLHttpRequest object in JavaScript. + * @param int|null $maxAgeSeconds The period of time within which the browser can cache the response to an OPTIONS preflight request for the specified resource. + * @param array|null $allowedOrigins The origins from which cross-origin requests are allowed. + * @param array|null $allowedMethods The methods that you can use in cross-origin requests. + */ + public function __construct( + ?array $allowedHeaders = null, + ?array $exposeHeaders = null, + ?int $maxAgeSeconds = null, + ?array $allowedOrigins = null, + ?array $allowedMethods = null + ) + { + $this->allowedHeaders = $allowedHeaders; + $this->exposeHeaders = $exposeHeaders; + $this->maxAgeSeconds = $maxAgeSeconds; + $this->allowedOrigins = $allowedOrigins; + $this->allowedMethods = $allowedMethods; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CertificateConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/CertificateConfiguration.php new file mode 100644 index 0000000..6df58e9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CertificateConfiguration.php @@ -0,0 +1,86 @@ +force = $force; + $this->deleteCertificate = $deleteCertificate; + $this->certId = $certId; + $this->certificate = $certificate; + $this->privateKey = $privateKey; + $this->previousCertId = $previousCertId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CipherSuite.php b/vendor/alibabacloud/oss-v2/src/Models/CipherSuite.php new file mode 100644 index 0000000..39c7a6f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CipherSuite.php @@ -0,0 +1,61 @@ +|null + */ + #[XmlElement(rename: 'CustomCipherSuite', type: 'string')] + public ?array $customCipherSuites; + + /** + * @var array|null + */ + #[XmlElement(rename: 'TLS13CustomCipherSuite', type: 'string')] + public ?array $tls13CustomCipherSuites; + + /** + * CipherSuite constructor. + * @param bool|null $enable + * @param bool|null $strongCipherSuite + * @param array|null $customCipherSuites + * @param array|null $tls13CustomCipherSuites + */ + public function __construct( + ?bool $enable = null, + ?bool $strongCipherSuite = null, + ?array $customCipherSuites = null, + ?array $tls13CustomCipherSuites = null + ) + { + $this->enable = $enable; + $this->strongCipherSuite = $strongCipherSuite; + $this->customCipherSuites = $customCipherSuites; + $this->tls13CustomCipherSuites = $tls13CustomCipherSuites; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectRequest.php new file mode 100644 index 0000000..deb0d0d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectRequest.php @@ -0,0 +1,61 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectResult.php new file mode 100644 index 0000000..ef94485 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CleanRestoredObjectResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CloseMetaQueryResult.php b/vendor/alibabacloud/oss-v2/src/Models/CloseMetaQueryResult.php new file mode 100644 index 0000000..a5566f9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CloseMetaQueryResult.php @@ -0,0 +1,15 @@ +id = $id; + $this->name = $name; + $this->region = $region; + $this->controlEndpoint = $controlEndpoint; + $this->dataEndpoint = $dataEndpoint; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CloudBoxes.php b/vendor/alibabacloud/oss-v2/src/Models/CloudBoxes.php new file mode 100644 index 0000000..55699f0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CloudBoxes.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'CloudBox', type: CloudBox::class)] + public ?array $cloudBox; + + /** + * CloudBoxes constructor. + * @param array|null $cloudBox The container that stores information about cloud box bucket. + */ + public function __construct( + ?array $cloudBox = null + ) + { + $this->cloudBox = $cloudBox; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/Cname.php b/vendor/alibabacloud/oss-v2/src/Models/Cname.php new file mode 100644 index 0000000..a043e65 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Cname.php @@ -0,0 +1,45 @@ +domain = $domain; + $this->certificateConfiguration = $certificateConfiguration; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CnameCertificate.php b/vendor/alibabacloud/oss-v2/src/Models/CnameCertificate.php new file mode 100644 index 0000000..e02feee --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CnameCertificate.php @@ -0,0 +1,95 @@ +type = $type; + $this->certId = $certId; + $this->status = $status; + $this->creationDate = $creationDate; + $this->fingerprint = $fingerprint; + $this->validStartDate = $validStartDate; + $this->validEndDate = $validEndDate; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CnameInfo.php b/vendor/alibabacloud/oss-v2/src/Models/CnameInfo.php new file mode 100644 index 0000000..a52b457 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CnameInfo.php @@ -0,0 +1,65 @@ +domain = $domain; + $this->lastModified = $lastModified; + $this->status = $status; + $this->certificate = $certificate; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CnameToken.php b/vendor/alibabacloud/oss-v2/src/Models/CnameToken.php new file mode 100644 index 0000000..efe32ad --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CnameToken.php @@ -0,0 +1,65 @@ +bucket = $bucket; + $this->cname = $cname; + $this->token = $token; + $this->expireTime = $expireTime; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CommonPrefix.php b/vendor/alibabacloud/oss-v2/src/Models/CommonPrefix.php new file mode 100644 index 0000000..e71dcd2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CommonPrefix.php @@ -0,0 +1,35 @@ +prefix = $prefix; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormRequest.php new file mode 100644 index 0000000..e5d9c97 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->wormId = $wormId; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormResult.php b/vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormResult.php new file mode 100644 index 0000000..fcfbc20 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CompleteBucketWormResult.php @@ -0,0 +1,15 @@ +|null + */ + #[XmlElement(rename: 'Part', type: UploadPart::class)] + public ?array $parts; + + /** + * CompleteMultipartUpload constructor. + * + * @param array|null $parts The container that stores the uploaded parts. + */ + public function __construct( + ?array $parts = null + ) + { + $this->parts = $parts; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadRequest.php new file mode 100644 index 0000000..40af7b3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadRequest.php @@ -0,0 +1,128 @@ +bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->acl = $objectAcl ?? $acl; + $this->completeMultipartUpload = $completeMultipartUpload; + $this->completeAll = $completeAll; + $this->callback = $callback; + $this->callbackVar = $callbackVar; + $this->forbidOverwrite = $forbidOverwrite; + $this->encodingType = $encodingType; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadResult.php b/vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadResult.php new file mode 100644 index 0000000..9adb9e6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CompleteMultipartUploadResult.php @@ -0,0 +1,96 @@ +bucket = $bucket; + $this->key = $key; + $this->location = $location; + $this->etag = $etag; + $this->encodingType = $encodingType; + $this->hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->callbackResult = $callbackResult; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CopyObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CopyObjectRequest.php new file mode 100644 index 0000000..c8a8b9a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CopyObjectRequest.php @@ -0,0 +1,291 @@ +|null + */ + public ?array $metadata; + + /** + * The caching behavior of the web page when the object is downloaded. + * @var string|null + */ + public ?string $cacheControl; + + /** + * The method that is used to access the object. + * @var string|null + */ + public ?string $contentDisposition; + + /** + * The method that is used to encode the object. + * @var string|null + */ + public ?string $contentEncoding; + + /** + * The size of the data in the HTTP message body. Unit: bytes. + * @var int|null + */ + public ?int $contentLength; + + /** + * The MD5 hash of the object that you want to upload. + * @var string|null + */ + public ?string $contentMd5; + + /** + * A standard MIME type describing the format of the contents. + * @var string|null + */ + public ?string $contentType; + + /** + * The expiration time of the cache in UTC. + * @var string|null + */ + public ?string $expires; + + /** + * The method that is used to configure the metadata of the destination object. Default value: COPY.* **COPY**: The metadata of the source object is copied to the destination object. The **x-oss-server-side-encryption** attribute of the source object is not copied to the destination object. The **x-oss-server-side-encryption** header in the CopyObject request specifies the method that is used to encrypt the destination object.* **REPLACE**: The metadata that you specify in the request is used as the metadata of the destination object. If the path of the source object is the same as the path of the destination object and versioning is disabled for the bucket in which the source and destination objects are stored, the metadata that you specify in the CopyObject request is used as the metadata of the destination object regardless of the value of the x-oss-metadata-directive header. + * @var string|null + */ + public ?string $metadataDirective; + + /** + * The entropy coding-based encryption algorithm that OSS uses to encrypt an object when you create the object. The valid values of the header are **AES256** and **KMS**. You must activate Key Management Service (KMS) in the OSS console before you can use the KMS encryption algorithm. Otherwise, the KmsServiceNotEnabled error is returned.* If you do not specify the **x-oss-server-side-encryption** header in the CopyObject request, the destination object is not encrypted on the server regardless of whether the source object is encrypted on the server.* If you specify the **x-oss-server-side-encryption** header in the CopyObject request, the destination object is encrypted on the server after the CopyObject operation is performed regardless of whether the source object is encrypted on the server. In addition, the response to a CopyObject request contains the **x-oss-server-side-encryption** header whose value is the encryption algorithm of the destination object. When the destination object is downloaded, the **x-oss-server-side-encryption** header is included in the response. The value of this header is the encryption algorithm of the destination object. + * @var string|null + */ + public ?string $serverSideEncryption; + + /** + * The server side data encryption algorithm. Invalid value: SM4 + * @var string|null + */ + public ?string $serverSideDataEncryption; + + /** + * The ID of the customer master key (CMK) that is managed by KMS. This parameter is available only if you set **x-oss-server-side-encryption** to KMS. + * @var string|null + */ + public ?string $serverSideEncryptionKeyId; + + /** + * The tag of the destination object. You can add multiple tags to the destination object. Example: TagA=A\&TagB=B. The tag key and tag value must be URL-encoded. If a key-value pair does not contain an equal sign (=), the tag value is considered an empty string. + * @var string|null + */ + public ?string $tagging; + + /** + * The method that is used to add tags to the destination object. Default value: Copy. Valid values:* **Copy**: The tags of the source object are copied to the destination object.* **Replace**: The tags that you specify in the request are added to the destination object. + * @var string|null + */ + public ?string $taggingDirective; + + /** + * Specifies whether the CopyObject operation overwrites objects with the same name. The **x-oss-forbid-overwrite** request header does not take effect when versioning is enabled or suspended for the destination bucket. In this case, the CopyObject operation overwrites the existing object that has the same name as the destination object.* If you do not specify the **x-oss-forbid-overwrite** header or set the header to **false**, an existing object that has the same name as the object that you want to copy is overwritten.***** If you set the **x-oss-forbid-overwrite** header to **true**, an existing object that has the same name as the object that you want to copy is not overwritten.If you specify the **x-oss-forbid-overwrite** header, the queries per second (QPS) performance of OSS may be degraded. If you want to specify the **x-oss-forbid-overwrite** header in a large number of requests (QPS greater than 1,000), contact technical support. Default value: false. + * @var bool|null + */ + public ?bool $forbidOverwrite; + + /** + * Specify the speed limit value. The speed limit value ranges from 245760 to 838860800, with a unit of bit/s. + * @var int|null + */ + public ?int $trafficLimit; + + /** + * To indicate that the requester is aware that the request and data download will incur costs + * @var string|null + */ + public ?string $requestPayer; + + /** + * Progress callback function + * @var callable|null + */ + public $progressFn; + + /** + * CopyObjectRequest constructor. + * @param string|null $bucket The name of the bucket. + * @param string|null $key The full path of the object. + * @param string|null $sourceBucket The name of the source bucket. + * @param string|null $sourceKey The path of the source object. + * @param string|null $sourceVersionId The version ID of the source object. + * @param string|null $ifMatch If the ETag specified in the request matches the ETag value of the object, the object and 200 OK are returned. + * @param string|null $ifNoneMatch If the ETag specified in the request does not match the ETag value of the object, the object and 200 OK are returned. + * @param string|null $ifModifiedSince If the time specified in this header is earlier than the object modified time or is invalid, the object and 200 OK are returned. + * @param string|null $ifUnmodifiedSince If the time specified in this header is the same as or later than the object modified time, the object and 200 OK are returned. + * @param string|null $acl The access control list (ACL) of the object. + * @param string|null $storageClass The storage class of the object. + * @param array|null $metadata The metadata of the object that you want to upload. + * @param string|null $cacheControl The caching behavior of the web page when the object is downloaded. + * @param string|null $contentDisposition The method that is used to access the object. + * @param string|null $contentEncoding The method that is used to encode the object. + * @param string|null $contentLength The size of the data in the HTTP message body. + * @param string|null $contentMd5 The Content-MD5 header value is a string calculated by using the MD5 algorithm. + * @param string|null $contentType A standard MIME type describing the format of the contents. + * @param string|null $expires The expiration time of the cache in UTC. + * @param string|null $metadataDirective The method that is used to configure the metadata of the destination object. + * @param string|null $serverSideEncryption The encryption method on the server side when an object is created. + * @param string|null $serverSideDataEncryption The server side data encryption algorithm. + * @param string|null $serverSideEncryptionKeyId The ID of the customer master key (CMK) that is managed by Key Management Service (KMS). + * @param string|null $tagging The tags that are specified for the object by using a key-value pair. + * @param string|null $taggingDirective The method that is used to configure tags for the destination object. + * @param bool|null $forbidOverwrite Specifies whether the CopyObject operation overwrites objects with the same name. + * @param int|null $trafficLimit Specify the speed limit value. + * @param string|null $requestPayer To indicate that the requester is aware that the request and data download will incur costs. + * @param callable|null $progressFn Progress callback function, it works in Copier.Copy only. + * @param array|null $options + * @param string|null $objectAcl The access control list (ACL) of the object. The object acl parameter has the same functionality as the acl parameter. it is the standardized name for acl. If both exist simultaneously, the value of objectAcl will take precedence. + */ + public function __construct( + ?string $bucket = null, + ?string $key = null, + ?string $sourceBucket = null, + ?string $sourceKey = null, + ?string $sourceVersionId = null, + ?string $ifMatch = null, + ?string $ifNoneMatch = null, + ?string $ifModifiedSince = null, + ?string $ifUnmodifiedSince = null, + ?string $acl = null, + ?string $storageClass = null, + ?array $metadata = null, + ?string $cacheControl = null, + ?string $contentDisposition = null, + ?string $contentEncoding = null, + ?string $contentLength = null, + ?string $contentMd5 = null, + ?string $contentType = null, + ?string $expires = null, + ?string $metadataDirective = null, + ?string $serverSideEncryption = null, + ?string $serverSideDataEncryption = null, + ?string $serverSideEncryptionKeyId = null, + ?string $tagging = null, + ?string $taggingDirective = null, + ?bool $forbidOverwrite = null, + ?int $trafficLimit = null, + ?string $requestPayer = null, + ?callable $progressFn = null, + ?array $options = null, + ?string $objectAcl = null + ) + { + $this->bucket = $bucket; + $this->key = $key; + $this->sourceBucket = $sourceBucket; + $this->sourceKey = $sourceKey; + $this->sourceVersionId = $sourceVersionId; + $this->ifMatch = $ifMatch; + $this->ifNoneMatch = $ifNoneMatch; + $this->ifModifiedSince = $ifModifiedSince; + $this->ifUnmodifiedSince = $ifUnmodifiedSince; + $this->acl = $objectAcl ?? $acl; + $this->storageClass = $storageClass; + $this->metadata = $metadata; + $this->cacheControl = $cacheControl; + $this->contentDisposition = $contentDisposition; + $this->contentEncoding = $contentEncoding; + $this->contentLength = $contentLength; + $this->contentMd5 = $contentMd5; + $this->contentType = $contentType; + $this->expires = $expires; + $this->metadataDirective = $metadataDirective; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->tagging = $tagging; + $this->taggingDirective = $taggingDirective; + $this->forbidOverwrite = $forbidOverwrite; + $this->trafficLimit = $trafficLimit; + $this->requestPayer = $requestPayer; + $this->progressFn = $progressFn; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CopyObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/CopyObjectResult.php new file mode 100644 index 0000000..33170ae --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CopyObjectResult.php @@ -0,0 +1,96 @@ +hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->sourceVersionId = $sourceVersionId; + $this->lastModified = $lastModified; + $this->etag = $etag; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CopyResult.php b/vendor/alibabacloud/oss-v2/src/Models/CopyResult.php new file mode 100644 index 0000000..2c207dc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CopyResult.php @@ -0,0 +1,68 @@ +uploadId = $uploadId; + $this->etag = $etag; + $this->hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->callbackResult = $callbackResult; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPoint.php b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPoint.php new file mode 100644 index 0000000..aba99da --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPoint.php @@ -0,0 +1,46 @@ +alias = $alias; + $this->accessPointArn = $accessPointArn; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointConfiguration.php new file mode 100644 index 0000000..f87f9d8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointConfiguration.php @@ -0,0 +1,55 @@ +vpcConfiguration = $vpcConfiguration; + $this->accessPointName = $accessPointName; + $this->networkOrigin = $networkOrigin; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointRequest.php new file mode 100644 index 0000000..0cdd808 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->createAccessPointConfiguration = $createAccessPointConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointResult.php b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointResult.php new file mode 100644 index 0000000..ee29ca7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateAccessPointResult.php @@ -0,0 +1,33 @@ +createAccessPoint = $createAccessPoint; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateBucketConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/CreateBucketConfiguration.php new file mode 100644 index 0000000..aa0ff5c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateBucketConfiguration.php @@ -0,0 +1,45 @@ +storageClass = $storageClass; + $this->dataRedundancyType = $dataRedundancyType; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionRequest.php new file mode 100644 index 0000000..f2fa1b7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->targetRedundancyType = $targetRedundancyType; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionResult.php b/vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionResult.php new file mode 100644 index 0000000..2dccbc6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateBucketDataRedundancyTransitionResult.php @@ -0,0 +1,33 @@ +bucketDataRedundancyTransition = $bucketDataRedundancyTransition; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenRequest.php b/vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenRequest.php new file mode 100644 index 0000000..b150c8b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->bucketCnameConfiguration = $bucketCnameConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenResult.php b/vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenResult.php new file mode 100644 index 0000000..fa84d67 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/CreateCnameTokenResult.php @@ -0,0 +1,33 @@ +cnameToken = $cnameToken; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DataRedundancyType.php b/vendor/alibabacloud/oss-v2/src/Models/DataRedundancyType.php new file mode 100644 index 0000000..81950af --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DataRedundancyType.php @@ -0,0 +1,25 @@ +|null + */ + public ?array $objects; + + /** + * Specifies whether to enable the Quiet return mode. + * The DeleteMultipleObjects operation provides the following return modes: Valid value: true,false + * @var bool|null + */ + public ?bool $quiet; + + /** + * DeleteMultipleObjectsRequest constructor. + * @param array|null $objects The container that stores information about you want to delete objects. + * @param bool|null $quiet Specifies whether to enable the Quiet return mode. + * @param array|null $options + */ + public function __construct( + ?array $objects = null, + ?bool $quiet = null, + ?array $options = null + ) + { + $this->objects = $objects; + $this->quiet = $quiet; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyRequest.php new file mode 100644 index 0000000..ac5bd4e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointName = $accessPointName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyResult.php new file mode 100644 index 0000000..e7e306d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointPolicyResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->accessPointName = $accessPointName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointResult.php new file mode 100644 index 0000000..eb63164 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteAccessPointResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketCorsResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketCorsResult.php new file mode 100644 index 0000000..ab68a86 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketCorsResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->redundancyTransitionTaskid = $redundancyTransitionTaskid; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketDataRedundancyTransitionResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketDataRedundancyTransitionResult.php new file mode 100644 index 0000000..026d436 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketDataRedundancyTransitionResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketEncryptionResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketEncryptionResult.php new file mode 100644 index 0000000..3b3473a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketEncryptionResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->inventoryId = $inventoryId; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketInventoryResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketInventoryResult.php new file mode 100644 index 0000000..e5ba3d9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketInventoryResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLifecycleResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLifecycleResult.php new file mode 100644 index 0000000..5bba990 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLifecycleResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLoggingResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLoggingResult.php new file mode 100644 index 0000000..195c5c7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketLoggingResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketOverwriteConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketOverwriteConfigResult.php new file mode 100644 index 0000000..c6a9324 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketOverwriteConfigResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPolicyResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPolicyResult.php new file mode 100644 index 0000000..466a7a1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPolicyResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPublicAccessBlockResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPublicAccessBlockResult.php new file mode 100644 index 0000000..fa9e8f3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketPublicAccessBlockResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->replicationRules = $replicationRules; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketReplicationResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketReplicationResult.php new file mode 100644 index 0000000..8071992 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketReplicationResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketResult.php new file mode 100644 index 0000000..9c65edf --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketResult.php @@ -0,0 +1,16 @@ +bucket = $bucket; + $this->tagging = $tagging; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketTagsResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketTagsResult.php new file mode 100644 index 0000000..faf63bd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketTagsResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketWebsiteResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketWebsiteResult.php new file mode 100644 index 0000000..4cacf00 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteBucketWebsiteResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->bucketCnameConfiguration = $bucketCnameConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteCnameResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteCnameResult.php new file mode 100644 index 0000000..0477494 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteCnameResult.php @@ -0,0 +1,15 @@ +key = $key; + $this->versionId = $versionId; + $this->isLatest = $isLatest; + $this->lastModified = $lastModified; + $this->owner = $owner; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsRequest.php new file mode 100644 index 0000000..15cdc07 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsRequest.php @@ -0,0 +1,83 @@ +|null + */ + public ?array $objects; + + /** + * Specifies whether to enable the Quiet return mode. + * The DeleteMultipleObjects operation provides the following return modes: Valid value: true,false + * @var bool|null + */ + public ?bool $quiet; + + /** + * To indicate that the requester is aware that the request and data download will incur costs + * @var string|null + */ + public ?string $requestPayer; + + /** + * The container that stores information about you want to delete objects. + * @var Delete|null + */ + public ?Delete $delete; + + /** + * DeleteMultipleObjectsRequest constructor. + * @param string|null $bucket The name of the bucket. + * @param array|null $objects The container that stores information about you want to delete objects. + * @param string|null $encodingType The encoding type of the object names in the response. Valid value: url + * @param bool|null $quiet Specifies whether to enable the Quiet return mode. + * @param string|null $requestPayer To indicate that the requester is aware that the request and data download will incur costs. + * @param Delete|null $delete The container that stores information about you want to delete objects. + * The delete parameter is functionally equivalent to specifying objects and quiet parameters separately. + * It is recommended to use the delete parameter for unified configuration. + * @param array|null $options + */ + public function __construct( + ?string $bucket = null, + ?array $objects = null, + ?string $encodingType = null, + ?bool $quiet = null, + ?string $requestPayer = null, + ?array $options = null, + ?Delete $delete = null + ) + { + $this->bucket = $bucket; + $this->objects = $objects; + $this->encodingType = $encodingType; + $this->quiet = $quiet; + $this->requestPayer = $requestPayer; + $this->delete = $delete; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsResult.php new file mode 100644 index 0000000..3d2c99b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteMultipleObjectsResult.php @@ -0,0 +1,41 @@ +|null + */ + public ?array $deletedObjects; + + /** + * The encoding type of the name of the deleted object in the response. + * If encoding-type is specified in the request, the object name is encoded in the returned result. + * @var string|null + */ + public ?string $encodingType; + + /** + * DeleteMultipleObjectsResult constructor. + * @param array|null $deletedObjects The container that stores information about the deleted objects. + * @param string|null $encodingType The encoding type of the object names in the response. Valid value: url + */ + public function __construct( + ?array $deletedObjects = null, + ?string $encodingType = null + ) { + $this->deletedObjects = $deletedObjects; + $this->encodingType = $encodingType; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteObject.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteObject.php new file mode 100644 index 0000000..9beb8d6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteObject.php @@ -0,0 +1,44 @@ +key = $key; + $this->versionId = $versionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectRequest.php new file mode 100644 index 0000000..1ec4987 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectResult.php new file mode 100644 index 0000000..cb77472 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectResult.php @@ -0,0 +1,41 @@ +versionId = $versionId; + $this->deleteMarker = $deleteMarker; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingRequest.php new file mode 100644 index 0000000..96ed6e5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingResult.php new file mode 100644 index 0000000..2bff9fe --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteObjectTaggingResult.php @@ -0,0 +1,32 @@ +versionId = $versionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeletePublicAccessBlockRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DeletePublicAccessBlockRequest.php new file mode 100644 index 0000000..f0007d4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeletePublicAccessBlockRequest.php @@ -0,0 +1,25 @@ +bucket = $bucket; + $this->styleName = $styleName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteStyleResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteStyleResult.php new file mode 100644 index 0000000..4a0b621 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteStyleResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DeleteUserDefinedLogFieldsConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/DeleteUserDefinedLogFieldsConfigResult.php new file mode 100644 index 0000000..14881e2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DeleteUserDefinedLogFieldsConfigResult.php @@ -0,0 +1,15 @@ +key = $key; + $this->versionId = $versionId; + $this->deleteMarker = $deleteMarker; + $this->deleteMarkerVersionId = $deleteMarkerVersionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsRequest.php new file mode 100644 index 0000000..375c7f0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsRequest.php @@ -0,0 +1,36 @@ +regions = $regions; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsResult.php b/vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsResult.php new file mode 100644 index 0000000..d8fdc2d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DescribeRegionsResult.php @@ -0,0 +1,32 @@ +|null + */ + public ?array $regionInfos; + + /** + * DescribeRegionsRequest constructor. + * @param array|null $regionInfos The information about the regions. + */ + public function __construct( + ?array $regionInfos = null + ) + { + $this->regionInfos = $regionInfos; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryRequest.php b/vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryRequest.php new file mode 100644 index 0000000..c9ca101 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryRequest.php @@ -0,0 +1,59 @@ +bucket = $bucket; + $this->metaQuery = $metaQuery; + $this->mode = $mode; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryResult.php b/vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryResult.php new file mode 100644 index 0000000..53a6e60 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DoMetaQueryResult.php @@ -0,0 +1,54 @@ +aggregations = $aggregations; + $this->nextToken = $nextToken; + $this->files = $files; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/DownloadResult.php b/vendor/alibabacloud/oss-v2/src/Models/DownloadResult.php new file mode 100644 index 0000000..ac4482a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/DownloadResult.php @@ -0,0 +1,29 @@ +written = $written; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/EncodeType.php b/vendor/alibabacloud/oss-v2/src/Models/EncodeType.php new file mode 100644 index 0000000..dca764b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/EncodeType.php @@ -0,0 +1,14 @@ +contentCipher = $contentCipher; + $this->dataSize = $dataSize; + $this->partSize = $partSize; + } + + /** + * @return bool + */ + public function valid() + { + if ($this->contentCipher === null || $this->dataSize === 0 || $this->partSize === 0) { + return false; + } + return true; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ErrorDocument.php b/vendor/alibabacloud/oss-v2/src/Models/ErrorDocument.php new file mode 100644 index 0000000..095e1a6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ErrorDocument.php @@ -0,0 +1,46 @@ +key = $key; + $this->httpStatus = $httpStatus; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormRequest.php new file mode 100644 index 0000000..4a459c9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormRequest.php @@ -0,0 +1,60 @@ +bucket = $bucket; + $this->wormId = $wormId; + $this->extendWormConfiguration = $extendWormConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormResult.php b/vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormResult.php new file mode 100644 index 0000000..01b86b3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ExtendBucketWormResult.php @@ -0,0 +1,15 @@ +retentionPeriodInDays = $retentionPeriodInDays; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetAccessPoint.php b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPoint.php new file mode 100644 index 0000000..e141ced --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPoint.php @@ -0,0 +1,135 @@ +networkOrigin = $networkOrigin; + $this->accessPointArn = $accessPointArn; + $this->alias = $alias; + $this->status = $status; + $this->bucket = $bucket; + $this->accountId = $accountId; + $this->endpoints = $endpoints; + $this->publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + $this->creationDate = $creationDate; + $this->accessPointName = $accessPointName; + $this->vpcConfiguration = $vpcConfiguration; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyRequest.php new file mode 100644 index 0000000..ae213a6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointName = $accessPointName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyResult.php new file mode 100644 index 0000000..0ff2157 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointPolicyResult.php @@ -0,0 +1,30 @@ +body = $body; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointRequest.php new file mode 100644 index 0000000..da59d78 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->accessPointName = $accessPointName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointResult.php new file mode 100644 index 0000000..d3eb0d3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetAccessPointResult.php @@ -0,0 +1,33 @@ +getAccessPoint = $getAccessPoint; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorRequest.php new file mode 100644 index 0000000..9e277a4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorResult.php new file mode 100644 index 0000000..f45b99b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAccessMonitorResult.php @@ -0,0 +1,33 @@ +accessMonitorConfiguration = $accessMonitorConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketAclRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAclRequest.php new file mode 100644 index 0000000..7dfecf3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAclRequest.php @@ -0,0 +1,35 @@ +bucket = $bucket; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketAclResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAclResult.php new file mode 100644 index 0000000..93ad7dd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketAclResult.php @@ -0,0 +1,42 @@ +owner = $owner; + $this->accessControlList = $accessControlList; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadRequest.php new file mode 100644 index 0000000..a10881d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadResult.php new file mode 100644 index 0000000..7441d26 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketArchiveDirectReadResult.php @@ -0,0 +1,34 @@ +archiveDirectReadConfiguration = $archiveDirectReadConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsRequest.php new file mode 100644 index 0000000..8cdba61 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsResult.php new file mode 100644 index 0000000..76eb5f3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketCorsResult.php @@ -0,0 +1,34 @@ +corsConfiguration = $corsConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionRequest.php new file mode 100644 index 0000000..9f5f638 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->redundancyTransitionTaskid = $redundancyTransitionTaskid; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionResult.php new file mode 100644 index 0000000..2b7ffea --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketDataRedundancyTransitionResult.php @@ -0,0 +1,33 @@ +bucketDataRedundancyTransition = $bucketDataRedundancyTransition; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionRequest.php new file mode 100644 index 0000000..ffa53d0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionResult.php new file mode 100644 index 0000000..1bd0b99 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketEncryptionResult.php @@ -0,0 +1,33 @@ +serverSideEncryptionRule = $serverSideEncryptionRule; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigRequest.php new file mode 100644 index 0000000..d8df139 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigResult.php new file mode 100644 index 0000000..342df94 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketHttpsConfigResult.php @@ -0,0 +1,33 @@ +httpsConfiguration = $httpsConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoRequest.php new file mode 100644 index 0000000..8ee0951 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoRequest.php @@ -0,0 +1,35 @@ +bucket = $bucket; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoResult.php new file mode 100644 index 0000000..f2a9a34 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInfoResult.php @@ -0,0 +1,32 @@ +bucketInfo = $bucketInfo; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryRequest.php new file mode 100644 index 0000000..8caed04 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->inventoryId = $inventoryId; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryResult.php new file mode 100644 index 0000000..e90ba7b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketInventoryResult.php @@ -0,0 +1,33 @@ +inventoryConfiguration = $inventoryConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleRequest.php new file mode 100644 index 0000000..c598f47 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleResult.php new file mode 100644 index 0000000..c203963 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLifecycleResult.php @@ -0,0 +1,34 @@ +lifecycleConfiguration = $lifecycleConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationRequest.php new file mode 100644 index 0000000..094b0c8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationRequest.php @@ -0,0 +1,35 @@ +bucket = $bucket; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationResult.php new file mode 100644 index 0000000..43b5afa --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLocationResult.php @@ -0,0 +1,32 @@ +location = $location; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingRequest.php new file mode 100644 index 0000000..996b38f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingResult.php new file mode 100644 index 0000000..cd5a3f8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketLoggingResult.php @@ -0,0 +1,33 @@ +bucketLoggingStatus = $bucketLoggingStatus; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigRequest.php new file mode 100644 index 0000000..8ac1191 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigResult.php new file mode 100644 index 0000000..916aea6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketOverwriteConfigResult.php @@ -0,0 +1,33 @@ +overwriteConfiguration = $overwriteConfiguration; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyRequest.php new file mode 100644 index 0000000..495186a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyResult.php new file mode 100644 index 0000000..29eb0f4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyResult.php @@ -0,0 +1,30 @@ +body = $body; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusRequest.php new file mode 100644 index 0000000..e5c6b20 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusResult.php new file mode 100644 index 0000000..6daf94a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPolicyStatusResult.php @@ -0,0 +1,33 @@ +policyStatus = $policyStatus; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockRequest.php new file mode 100644 index 0000000..63b02e9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockRequest.php @@ -0,0 +1,37 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockResult.php new file mode 100644 index 0000000..7841cde --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketPublicAccessBlockResult.php @@ -0,0 +1,34 @@ +publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererRequest.php new file mode 100644 index 0000000..7447049 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererResult.php new file mode 100644 index 0000000..a0e1d9b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRefererResult.php @@ -0,0 +1,34 @@ +refererConfiguration = $refererConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationRequest.php new file mode 100644 index 0000000..35fbe0d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationResult.php new file mode 100644 index 0000000..602beaa --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationLocationResult.php @@ -0,0 +1,33 @@ +replicationLocation = $replicationLocation; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressRequest.php new file mode 100644 index 0000000..2ea1528 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->ruleId = $ruleId; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressResult.php new file mode 100644 index 0000000..ccfc59d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationProgressResult.php @@ -0,0 +1,33 @@ +replicationProgress = $replicationProgress; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationRequest.php new file mode 100644 index 0000000..212beb6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationResult.php new file mode 100644 index 0000000..41fc268 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketReplicationResult.php @@ -0,0 +1,33 @@ +replicationConfiguration = $replicationConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentRequest.php new file mode 100644 index 0000000..24f6ad8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentResult.php new file mode 100644 index 0000000..0fa7817 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketRequestPaymentResult.php @@ -0,0 +1,33 @@ +requestPaymentConfiguration = $requestPaymentConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupRequest.php new file mode 100644 index 0000000..b9150ac --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupResult.php new file mode 100644 index 0000000..25c614d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketResourceGroupResult.php @@ -0,0 +1,33 @@ +bucketResourceGroupConfiguration = $bucketResourceGroupConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketStatRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketStatRequest.php new file mode 100644 index 0000000..6f91ea3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketStatRequest.php @@ -0,0 +1,35 @@ +bucket = $bucket; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketStatResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketStatResult.php new file mode 100644 index 0000000..ed1e0b3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketStatResult.php @@ -0,0 +1,212 @@ +storage = $storage; + $this->objectCount = $objectCount; + $this->multipartUploadCount = $multipartUploadCount; + $this->multipartPartCount = $multipartPartCount; + $this->liveChannelCount = $liveChannelCount; + $this->lastModifiedTime = $lastModifiedTime; + $this->standardStorage = $standardStorage; + $this->standardObjectCount = $standardObjectCount; + $this->infrequentAccessStorage = $infrequentAccessStorage; + $this->infrequentAccessRealStorage = $infrequentAccessRealStorage; + $this->infrequentAccessObjectCount = $infrequentAccessObjectCount; + $this->archiveStorage = $archiveStorage; + $this->archiveRealStorage = $archiveRealStorage; + $this->archiveObjectCount = $archiveObjectCount; + $this->coldArchiveStorage = $coldArchiveStorage; + $this->coldArchiveRealStorage = $coldArchiveRealStorage; + $this->coldArchiveObjectCount = $coldArchiveObjectCount; + $this->deepColdArchiveStorage = $deepColdArchiveStorage; + $this->deepColdArchiveRealStorage = $deepColdArchiveRealStorage; + $this->deepColdArchiveObjectCount = $deepColdArchiveObjectCount; + $this->deleteMarkerCount = $deleteMarkerCount; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsRequest.php new file mode 100644 index 0000000..d60a859 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsResult.php new file mode 100644 index 0000000..3fbe067 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTagsResult.php @@ -0,0 +1,33 @@ +tagging = $tagging; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationRequest.php new file mode 100644 index 0000000..b158349 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationResult.php new file mode 100644 index 0000000..e3fae1f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketTransferAccelerationResult.php @@ -0,0 +1,34 @@ +transferAccelerationConfiguration = $transferAccelerationConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningRequest.php new file mode 100644 index 0000000..46a0d7a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningRequest.php @@ -0,0 +1,35 @@ +bucket = $bucket; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningResult.php new file mode 100644 index 0000000..33936ae --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketVersioningResult.php @@ -0,0 +1,32 @@ +versioningConfiguration = $versioningConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteRequest.php new file mode 100644 index 0000000..cd5f5d2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteResult.php new file mode 100644 index 0000000..bc2d2fa --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWebsiteResult.php @@ -0,0 +1,33 @@ +websiteConfiguration = $websiteConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketWormRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWormRequest.php new file mode 100644 index 0000000..5139897 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWormRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetBucketWormResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWormResult.php new file mode 100644 index 0000000..361f97e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetBucketWormResult.php @@ -0,0 +1,33 @@ +wormConfiguration = $wormConfiguration; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenRequest.php new file mode 100644 index 0000000..d41dfb6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->cname = $cname; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenResult.php new file mode 100644 index 0000000..4b74120 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetCnameTokenResult.php @@ -0,0 +1,33 @@ +cnameToken = $cnameToken; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusRequest.php new file mode 100644 index 0000000..9e374ce --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusResult.php new file mode 100644 index 0000000..9b37270 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetMetaQueryStatusResult.php @@ -0,0 +1,33 @@ +metaQueryStatus = $metaQueryStatus; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectAclRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectAclRequest.php new file mode 100644 index 0000000..cbfb5d3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectAclRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectAclResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectAclResult.php new file mode 100644 index 0000000..5b43b04 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectAclResult.php @@ -0,0 +1,45 @@ +versionId = $versionId; + $this->owner = $owner; + $this->accessControlList = $accessControlList; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaRequest.php new file mode 100644 index 0000000..275e1a3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaResult.php new file mode 100644 index 0000000..411b551 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectMetaResult.php @@ -0,0 +1,76 @@ +contentLength = $contentLength; + $this->etag = $etag; + $this->lastModified = $lastModified; + $this->hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->lastAccessTime = $lastAccessTime; + $this->transitionTime = $transitionTime; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectRequest.php new file mode 100644 index 0000000..37e88c4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectRequest.php @@ -0,0 +1,208 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->ifMatch = $ifMatch; + $this->ifNoneMatch = $ifNoneMatch; + $this->ifModifiedSince = $ifModifiedSince; + $this->ifUnmodifiedSince = $ifUnmodifiedSince; + $this->rangeHeader = $rangeHeader; + $this->rangeBehavior = $rangeBehavior; + $this->responseCacheControl = $responseCacheControl; + $this->responseContentDisposition = $responseContentDisposition; + $this->responseContentEncoding = $responseContentEncoding; + $this->responseContentLanguage = $responseContentLanguage; + $this->responseContentType = $responseContentType; + $this->responseExpires = $responseExpires; + $this->trafficLimit = $trafficLimit; + $this->process = $process; + $this->requestPayer = $requestPayer; + $this->progressFn = $progressFn; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectResult.php new file mode 100644 index 0000000..5de296c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectResult.php @@ -0,0 +1,257 @@ +contentLength = $contentLength; + $this->contentRange = $contentRange; + $this->contentType = $contentType; + $this->etag = $etag; + $this->lastModified = $lastModified; + $this->contentMd5 = $contentMd5; + $this->metadata = $metadata; + $this->cacheControl = $cacheControl; + $this->contentDisposition = $contentDisposition; + $this->contentEncoding = $contentEncoding; + $this->expires = $expires; + $this->storageClass = $storageClass; + $this->hashCrc64 = $hashCrc64; + $this->objectType = $objectType; + $this->versionId = $versionId; + $this->taggingCount = $taggingCount; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->nextAppendPosition = $nextAppendPosition; + $this->expiration = $expiration; + $this->restore = $restore; + $this->processStatus = $processStatus; + $this->deleteMarker = $deleteMarker; + $this->body = $body; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingRequest.php new file mode 100644 index 0000000..345987e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingResult.php new file mode 100644 index 0000000..0130c60 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetObjectTaggingResult.php @@ -0,0 +1,34 @@ +versionId = $versionId; + $this->tagSet = $tagSet; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetPublicAccessBlockRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetPublicAccessBlockRequest.php new file mode 100644 index 0000000..7bb2afe --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetPublicAccessBlockRequest.php @@ -0,0 +1,28 @@ +publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetStyleRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetStyleRequest.php new file mode 100644 index 0000000..0148ab5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetStyleRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->styleName = $styleName; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetStyleResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetStyleResult.php new file mode 100644 index 0000000..64c4f8c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetStyleResult.php @@ -0,0 +1,33 @@ +style = $style; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetSymlinkRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetSymlinkRequest.php new file mode 100644 index 0000000..e154af0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetSymlinkRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetSymlinkResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetSymlinkResult.php new file mode 100644 index 0000000..d2f1cc8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetSymlinkResult.php @@ -0,0 +1,52 @@ +|null + */ + public ?array $metadata; + + public function __construct( + ?string $versionId = null, + ?string $target = null, + ?string $etag = null, + ?array $metadata = null + ) + { + $this->versionId = $versionId; + $this->target = $target; + $this->etag = $etag; + $this->metadata = $metadata; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigRequest.php b/vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigRequest.php new file mode 100644 index 0000000..a88644d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigResult.php new file mode 100644 index 0000000..8e91530 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/GetUserDefinedLogFieldsConfigResult.php @@ -0,0 +1,33 @@ +userDefinedLogFieldsConfiguration = $userDefinedLogFieldsConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/HeadObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/HeadObjectRequest.php new file mode 100644 index 0000000..443c683 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/HeadObjectRequest.php @@ -0,0 +1,98 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->ifMatch = $ifMatch; + $this->ifNoneMatch = $ifNoneMatch; + $this->ifModifiedSince = $ifModifiedSince; + $this->ifUnmodifiedSince = $ifUnmodifiedSince; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/HeadObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/HeadObjectResult.php new file mode 100644 index 0000000..9e99719 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/HeadObjectResult.php @@ -0,0 +1,300 @@ +|null + */ + public ?array $metadata; + + /** + * The caching behavior of the web page when the object is downloaded. + * @var string|null + */ + public ?string $cacheControl; + + /** + * The method that is used to access the object. + * @var string|null + */ + public ?string $contentDisposition; + + /** + * The method that is used to encode the object. + * @var string|null + */ + public ?string $contentEncoding; + + /** + * The expiration time of the cache in UTC. + * @var string|null + */ + public ?string $expires; + + /** + * The 64-bit CRC value of the object. + * @var string|null + */ + public ?string $hashCrc64; + + /** + * The storage class of the object. + * @var string|null + */ + public ?string $storageClass; + + /** + * The type of the object. + * @var string|null + */ + public ?string $objectType; + + /** + * Version of the object. + * @var string|null + */ + public ?string $versionId; + + /** + * The origins allowed for cross-origin resource sharing (CORS). + * If a CORS rule is configured for the bucket that stores the object and the Origin header + * in the request meets the CORS rule, this header is included in the response. + * @var string|null + */ + public ?string $allowOrigin; + + /** + * The maximum caching period for CORS. + * If a CORS rule is configured for the bucket that stores the object and the request meets the CORS rule, + * this header is included in the response. + * @var string|null + */ + public ?string $allowAge; + + /** + * The methods allowed for CORS. If a CORS rule is configured for the bucket that stores the object + * and the Access-Control-Request-Method header in the request meets the CORS rule, + * this header is included in the response. + * @var string|null + */ + public ?string $allowMethods; + + /** + * The headers allowed for CORS. + * If a CORS rule is configured for the bucket that stores + * the object and the request meets the CORS rule, this header is included in the response + * @var string|null + */ + public ?string $allowHeaders; + + /** + * The headers that can be accessed by JavaScript applications on the client. + * If a CORS rule is configured for the bucket that stores the object and the request meets + * the CORS rule, this header is included in the response + * @var string|null + */ + public ?string $exposeHeaders; + + /** + * The number of tags added to the object. + * This header is included in the response only when you have read permissions on tags. + * @var int|null + */ + public ?int $taggingCount; + + /** + * If the requested object is encrypted by using a server-side encryption algorithm based on entropy encoding, + * OSS automatically decrypts the object and returns the decrypted object after OSS receives the GetObject request. + * The x-oss-server-side-encryption header is included in the response to indicate + * the encryption algorithm used to encrypt the object on the server. + * @var string|null + */ + public ?string $serverSideEncryption; + + /** + * The server side data encryption algorithm. + * @var string|null + */ + public ?string $serverSideDataEncryption; + + /** + * The ID of the customer master key (CMK) that is managed by Key Management Service (KMS). + * @var string|null + */ + public ?string $serverSideEncryptionKeyId; + + /** + * The position for the next append operation. + * @var int|null + */ + public ?int $nextAppendPosition; + + /** + * The lifecycle information about the object. + * @var string|null + */ + public ?string $expiration; + + /** + * The status of the object when you restore an object. + * @var string|null + */ + public ?string $restore; + + /** + * The result of an event notification that is triggered for the object. + * @var string|null + */ + public ?string $processStatus; + + /** + * The requester. This header is included in the response if the pay-by-requester mode + * is enabled for the bucket and the requester is not the bucket owner. The value of this header is requester + * @var string|null + */ + public ?string $requestCharged; + + /** + * The time when the storage class of the object is converted to Cold Archive or Deep Cold Archive based on lifecycle rules. + * @var \DateTime|null + */ + public ?\DateTime $transitionTime; + + + /** + * HeadObjectResult constructor. + * @param int|null $contentLength Size of the body in bytes. + * @param string|null $contentType A standard MIME type describing the format of the object data. + * @param string|null $etag The entity tag (ETag). + * @param \DateTime|null $lastModified The time when the returned objects were last modified. + * @param string|null $contentMd5 Content-Md5 for the uploaded object. + * @param array|null $metadata A map of metadata to store with the object. + * @param string|null $cacheControl The caching behavior of the web page when the object is downloaded. + * @param string|null $contentDisposition The method that is used to access the object. + * @param string|null $contentEncoding The method that is used to encode the object. + * @param string|null $expires The expiration time of the cache in UTC. + * @param string|null $hashCrc64 The 64-bit CRC value of the object. + * @param string|null $storageClass The storage class of the object. + * @param string|null $objectType The type of the object. + * @param string|null $versionId Version of the object. + * @param string|null $allowOrigin The origins allowed for cross-origin resource sharing (CORS). + * @param string|null $allowMethods The methods allowed for CORS. + * @param string|null $allowAge The maximum caching period for CORS. + * @param string|null $allowHeaders The headers allowed for CORS. + * @param string|null $exposeHeaders The headers that can be accessed by JavaScript applications on the client. + * @param int|null $taggingCount The number of tags added to the object. + * @param string|null $serverSideEncryption The encryption algorithm used to encrypt the object on the server. + * @param string|null $serverSideDataEncryption The server side data encryption algorithm. + * @param string|null $serverSideEncryptionKeyId The ID of the customer master key (CMK) that is managed by Key Management Service (KMS). + * @param int|null $nextAppendPosition The position for the next append operation. + * @param string|null $expiration The lifecycle information about the object. + * @param string|null $restore The status of the object when you restore an object. + * @param string|null $processStatus The result of an event notification that is triggered for the object. + * @param string|null $requestCharged The requester. + * @param \DateTime|null $transitionTime The time when the storage class of the object is converted to Cold Archive or Deep Cold Archive based on lifecycle rules. + */ + public function __construct( + ?int $contentLength = null, + ?string $contentType = null, + ?string $etag = null, + ?\DateTime $lastModified = null, + ?string $contentMd5 = null, + ?array $metadata = null, + ?string $cacheControl = null, + ?string $contentDisposition = null, + ?string $contentEncoding = null, + ?string $expires = null, + ?string $hashCrc64 = null, + ?string $storageClass = null, + ?string $objectType = null, + ?string $versionId = null, + ?string $allowOrigin = null, + ?string $allowMethods = null, + ?string $allowAge = null, + ?string $allowHeaders = null, + ?string $exposeHeaders = null, + ?int $taggingCount = null, + ?string $serverSideEncryption = null, + ?string $serverSideDataEncryption = null, + ?string $serverSideEncryptionKeyId = null, + ?int $nextAppendPosition = null, + ?string $expiration = null, + ?string $restore = null, + ?string $processStatus = null, + ?string $requestCharged = null, + ?\DateTime $transitionTime = null + ) + { + $this->contentLength = $contentLength; + $this->contentType = $contentType; + $this->etag = $etag; + $this->lastModified = $lastModified; + $this->contentMd5 = $contentMd5; + $this->metadata = $metadata; + $this->cacheControl = $cacheControl; + $this->contentDisposition = $contentDisposition; + $this->contentEncoding = $contentEncoding; + $this->expires = $expires; + $this->storageClass = $storageClass; + $this->hashCrc64 = $hashCrc64; + $this->objectType = $objectType; + $this->versionId = $versionId; + $this->allowOrigin = $allowOrigin; + $this->allowMethods = $allowMethods; + $this->allowHeaders = $allowHeaders; + $this->allowAge = $allowAge; + $this->exposeHeaders = $exposeHeaders; + $this->taggingCount = $taggingCount; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->nextAppendPosition = $nextAppendPosition; + $this->expiration = $expiration; + $this->restore = $restore; + $this->processStatus = $processStatus; + $this->requestCharged = $requestCharged; + $this->transitionTime = $transitionTime; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/HistoricalObjectReplicationType.php b/vendor/alibabacloud/oss-v2/src/Models/HistoricalObjectReplicationType.php new file mode 100644 index 0000000..dbdfa2f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/HistoricalObjectReplicationType.php @@ -0,0 +1,15 @@ +tls = $tls; + $this->cipherSuite = $cipherSuite; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/IndexDocument.php b/vendor/alibabacloud/oss-v2/src/Models/IndexDocument.php new file mode 100644 index 0000000..fc938e6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/IndexDocument.php @@ -0,0 +1,56 @@ +suffix = $suffix; + $this->supportSubDir = $supportSubDir; + $this->type = $type; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormRequest.php b/vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormRequest.php new file mode 100644 index 0000000..62ee492 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->initiateWormConfiguration = $initiateWormConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormResult.php b/vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormResult.php new file mode 100644 index 0000000..45a8686 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InitiateBucketWormResult.php @@ -0,0 +1,33 @@ +wormId = $wormId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadRequest.php b/vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadRequest.php new file mode 100644 index 0000000..bd90e73 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadRequest.php @@ -0,0 +1,219 @@ +bucket = $bucket; + $this->key = $key; + $this->encodingType = $encodingType; + $this->storageClass = $storageClass; + $this->metadata = $metadata; + $this->cacheControl = $cacheControl; + $this->contentDisposition = $contentDisposition; + $this->contentEncoding = $contentEncoding; + $this->contentLength = $contentLength; + $this->contentMd5 = $contentMd5; + $this->contentType = $contentType; + $this->expires = $expires; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->tagging = $tagging; + $this->forbidOverwrite = $forbidOverwrite; + $this->requestPayer = $requestPayer; + $this->disableAutoDetectMimeType = $disableAutoDetectMimeType; + $this->cseDataSize = $cseDataSize; + $this->csePartSize = $csePartSize; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadResult.php b/vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadResult.php new file mode 100644 index 0000000..a460718 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InitiateMultipartUploadResult.php @@ -0,0 +1,68 @@ +bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->encodingType = $encodingType; + $this->encryptionMultipartContext = $encryptionMultipartContext; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/InitiateWormConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/InitiateWormConfiguration.php new file mode 100644 index 0000000..f836c7c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InitiateWormConfiguration.php @@ -0,0 +1,35 @@ +retentionPeriodInDays = $retentionPeriodInDays; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InventoryConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/InventoryConfiguration.php new file mode 100644 index 0000000..31e6d0d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InventoryConfiguration.php @@ -0,0 +1,95 @@ +isEnabled = $isEnabled; + $this->destination = $destination; + $this->schedule = $schedule; + $this->filter = $filter; + $this->includedObjectVersions = $includedObjectVersions; + $this->optionalFields = $optionalFields; + $this->id = $id; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InventoryDestination.php b/vendor/alibabacloud/oss-v2/src/Models/InventoryDestination.php new file mode 100644 index 0000000..fee6d40 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InventoryDestination.php @@ -0,0 +1,35 @@ +ossBucketDestination = $ossBucketDestination; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InventoryEncryption.php b/vendor/alibabacloud/oss-v2/src/Models/InventoryEncryption.php new file mode 100644 index 0000000..3807932 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InventoryEncryption.php @@ -0,0 +1,45 @@ +sseOss = $sseOss; + $this->sseKms = $sseKms; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InventoryFilter.php b/vendor/alibabacloud/oss-v2/src/Models/InventoryFilter.php new file mode 100644 index 0000000..ad8dd03 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InventoryFilter.php @@ -0,0 +1,85 @@ +prefix = $prefix; + $this->lastModifyBeginTimeStamp = $lastModifyBeginTimeStamp; + $this->lastModifyEndTimeStamp = $lastModifyEndTimeStamp; + $this->lowerSizeBound = $lowerSizeBound; + $this->upperSizeBound = $upperSizeBound; + $this->storageClass = $storageClass; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InventoryFormatType.php b/vendor/alibabacloud/oss-v2/src/Models/InventoryFormatType.php new file mode 100644 index 0000000..d13e175 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InventoryFormatType.php @@ -0,0 +1,14 @@ +bucket = $bucket; + $this->prefix = $prefix; + $this->encryption = $encryption; + $this->format = $format; + $this->accountId = $accountId; + $this->roleArn = $roleArn; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/InventoryOptionalFieldType.php b/vendor/alibabacloud/oss-v2/src/Models/InventoryOptionalFieldType.php new file mode 100644 index 0000000..1284eb8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/InventoryOptionalFieldType.php @@ -0,0 +1,20 @@ +frequency = $frequency; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleConfiguration.php new file mode 100644 index 0000000..05fb83b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleConfiguration.php @@ -0,0 +1,36 @@ +|null + */ + #[XmlElement(rename: 'Rule', type: LifecycleRule::class)] + public ?array $rules; + + + /** + * LifecycleConfiguration constructor. + * @param array|null $rules The container that stores the lifecycle rules. + */ + public function __construct( + ?array $rules = null + ) + { + $this->rules = $rules; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleRule.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRule.php new file mode 100644 index 0000000..d5054ca --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRule.php @@ -0,0 +1,136 @@ +|null + */ + #[XmlElement(rename: 'Transition', type: LifecycleRuleTransition::class)] + public ?array $transitions; + + /** + * The tag of the objects to which the lifecycle rule applies. You can specify multiple tags. + * @var array|null + */ + #[XmlElement(rename: 'Tag', type: Tag::class)] + public ?array $tags; + + /** + * The conversion of the storage class of previous versions of the objects that match the lifecycle rule when the previous versions expire. The storage class of the previous versions can be converted to IA or Archive. The period of time from when the previous versions expire to when the storage class of the previous versions is converted to Archive must be longer than the period of time from when the previous versions expire to when the storage class of the previous versions is converted to IA. + * @var array|null + */ + #[XmlElement(rename: 'NoncurrentVersionTransition', type: NoncurrentVersionTransition::class)] + public ?array $noncurrentVersionTransitions; + + /** + * The container that stores the Not parameter that is used to filter objects. + * @var LifecycleRuleFilter|null + */ + #[XmlElement(rename: 'Filter', type: LifecycleRuleFilter::class)] + public ?LifecycleRuleFilter $filter; + + /** + * Timestamp for when access tracking was enabled. + * @var int|null + */ + #[XmlElement(rename: 'AtimeBase', type: 'int')] + public ?int $atimeBase; + + /** + * The ID of the lifecycle rule. The ID can contain up to 255 characters. If you do not specify the ID, OSS automatically generates a unique ID for the lifecycle rule. + * @var string|null + */ + #[XmlElement(rename: 'ID', type: 'string')] + public ?string $id; + + /** + * The delete operation to perform on objects based on the lifecycle rule. For an object in a versioning-enabled bucket, the delete operation specified by this parameter is performed only on the current version of the object.The period of time from when the objects expire to when the objects are deleted must be longer than the period of time from when the objects expire to when the storage class of the objects is converted to IA or Archive. + * @var LifecycleRuleExpiration|null + */ + #[XmlElement(rename: 'Expiration', type: LifecycleRuleExpiration::class)] + public ?LifecycleRuleExpiration $expiration; + + /** + * The delete operation that you want OSS to perform on the parts that are uploaded in incomplete multipart upload tasks when the parts expire. + * @var LifecycleRuleAbortMultipartUpload|null + */ + #[XmlElement(rename: 'AbortMultipartUpload', type: LifecycleRuleAbortMultipartUpload::class)] + public ?LifecycleRuleAbortMultipartUpload $abortMultipartUpload; + + /** + * The delete operation that you want OSS to perform on the previous versions of the objects that match the lifecycle rule when the previous versions expire. + * @var NoncurrentVersionExpiration|null + */ + #[XmlElement(rename: 'NoncurrentVersionExpiration', type: NoncurrentVersionExpiration::class)] + public ?NoncurrentVersionExpiration $noncurrentVersionExpiration; + + /** + * Specifies whether to enable the rule. Valid values:* Enabled: enables the rule. OSS periodically executes the rule.* Disabled: does not enable the rule. OSS ignores the rule. + * @var string|null + */ + #[XmlElement(rename: 'Status', type: 'string')] + public ?string $status; + + + /** + * LifecycleRule constructor. + * @param string|null $prefix The prefix in the names of the objects to which the rule applies. + * @param array|null $transitions The conversion of the storage class of objects that match the lifecycle rule when the objects expire. + * @param array|null $tags The tag of the objects to which the lifecycle rule applies. + * @param array|null $noncurrentVersionTransitions The conversion of the storage class of previous versions of the objects that match the lifecycle rule when the previous versions expire. + * @param LifecycleRuleFilter|null $filter The container that stores the Not parameter that is used to filter objects. + * @param int|null $atimeBase Timestamp for when access tracking was enabled. + * @param string|null $id The ID of the lifecycle rule. + * @param LifecycleRuleExpiration|null $expiration The delete operation to perform on objects based on the lifecycle rule. + * @param LifecycleRuleAbortMultipartUpload|null $abortMultipartUpload The delete operation that you want OSS to perform on the parts that are uploaded in incomplete multipart upload tasks when the parts expire. + * @param NoncurrentVersionExpiration|null $noncurrentVersionExpiration The delete operation that you want OSS to perform on the previous versions of the objects that match the lifecycle rule when the previous versions expire. + * @param string|null $status Specifies whether to enable the rule. + */ + public function __construct( + ?string $prefix = null, + ?array $transitions = null, + ?array $tags = null, + ?array $noncurrentVersionTransitions = null, + ?LifecycleRuleFilter $filter = null, + ?int $atimeBase = null, + ?string $id = null, + ?LifecycleRuleExpiration $expiration = null, + ?LifecycleRuleAbortMultipartUpload $abortMultipartUpload = null, + ?NoncurrentVersionExpiration $noncurrentVersionExpiration = null, + ?string $status = null + ) + { + $this->prefix = $prefix; + $this->transitions = $transitions; + $this->tags = $tags; + $this->noncurrentVersionTransitions = $noncurrentVersionTransitions; + $this->filter = $filter; + $this->atimeBase = $atimeBase; + $this->id = $id; + $this->expiration = $expiration; + $this->abortMultipartUpload = $abortMultipartUpload; + $this->noncurrentVersionExpiration = $noncurrentVersionExpiration; + $this->status = $status; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleAbortMultipartUpload.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleAbortMultipartUpload.php new file mode 100644 index 0000000..da4d0e3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleAbortMultipartUpload.php @@ -0,0 +1,46 @@ +days = $days; + $this->createdBeforeDate = $createdBeforeDate; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleExpiration.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleExpiration.php new file mode 100644 index 0000000..395093f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleExpiration.php @@ -0,0 +1,56 @@ +days = $days; + $this->expiredObjectDeleteMarker = $expiredObjectDeleteMarker; + $this->createdBeforeDate = $createdBeforeDate; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleFilter.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleFilter.php new file mode 100644 index 0000000..b6e69ae --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleFilter.php @@ -0,0 +1,56 @@ +|null + */ + #[XmlElement(rename: 'Not', type: LifecycleRuleNot::class)] + public ?array $nots; + + /** + * This lifecycle rule only applies to files larger than this size. + * @var int|null + */ + #[XmlElement(rename: 'ObjectSizeGreaterThan', type: 'int')] + public ?int $objectSizeGreaterThan; + + /** + * This lifecycle rule only applies to files smaller than this size. + * @var int|null + */ + #[XmlElement(rename: 'ObjectSizeLessThan', type: 'int')] + public ?int $objectSizeLessThan; + + + /** + * LifecycleRuleFilter constructor. + * @param array|null $nots The condition that is matched by objects to which the lifecycle rule does not apply. + * @param int|null $objectSizeGreaterThan This lifecycle rule only applies to files larger than this size. + * @param int|null $objectSizeLessThan This lifecycle rule only applies to files smaller than this size. + */ + public function __construct( + ?array $nots = null, + ?int $objectSizeGreaterThan = null, + ?int $objectSizeLessThan = null + ) + { + $this->nots = $nots; + $this->objectSizeGreaterThan = $objectSizeGreaterThan; + $this->objectSizeLessThan = $objectSizeLessThan; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleNot.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleNot.php new file mode 100644 index 0000000..2ff924f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleNot.php @@ -0,0 +1,46 @@ +tag = $tag; + $this->prefix = $prefix; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleTransition.php b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleTransition.php new file mode 100644 index 0000000..0724445 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LifecycleRuleTransition.php @@ -0,0 +1,87 @@ +allowSmallFile = $allowSmallFile; + $this->createdBeforeDate = $createdBeforeDate; + $this->days = $days; + $this->storageClass = $storageClass; + $this->isAccessTime = $isAccessTime; + $this->returnToStdWhenVisit = $returnToStdWhenVisit; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListAccessPoints.php b/vendor/alibabacloud/oss-v2/src/Models/ListAccessPoints.php new file mode 100644 index 0000000..290abb1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListAccessPoints.php @@ -0,0 +1,75 @@ +isTruncated = $isTruncated; + $this->nextContinuationToken = $nextContinuationToken; + $this->accountId = $accountId; + $this->accessPoints = $accessPoints; + $this->maxKeys = $maxKeys; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsRequest.php new file mode 100644 index 0000000..8ea5da5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsRequest.php @@ -0,0 +1,58 @@ +maxKeys = $maxKeys; + $this->continuationToken = $continuationToken; + $this->bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsResult.php new file mode 100644 index 0000000..7990e43 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListAccessPointsResult.php @@ -0,0 +1,33 @@ +listAccessPoints = $listAccessPoints; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransition.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransition.php new file mode 100644 index 0000000..e5991be --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransition.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'BucketDataRedundancyTransition', type: BucketDataRedundancyTransition::class)] + public ?array $bucketDataRedundancyTransitions; + + /** + * ListBucketDataRedundancyTransition constructor. + * @param array|null $bucketDataRedundancyTransitions + */ + public function __construct( + ?array $bucketDataRedundancyTransitions = null + ) + { + $this->bucketDataRedundancyTransitions = $bucketDataRedundancyTransitions; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionRequest.php new file mode 100644 index 0000000..cd7fe21 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionRequest.php @@ -0,0 +1,37 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionResult.php new file mode 100644 index 0000000..d0767e9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketDataRedundancyTransitionResult.php @@ -0,0 +1,33 @@ +listBucketDataRedundancyTransition = $listBucketDataRedundancyTransition; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryRequest.php new file mode 100644 index 0000000..d030741 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryRequest.php @@ -0,0 +1,48 @@ +bucket = $bucket; + $this->continuationToken = $continuationToken; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryResult.php new file mode 100644 index 0000000..c7ac501 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketInventoryResult.php @@ -0,0 +1,34 @@ +listInventoryConfigurationsResult = $listInventoryConfigurationsResult; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketsRequest.php new file mode 100644 index 0000000..f519c93 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketsRequest.php @@ -0,0 +1,94 @@ +resourceGroupId = $resourceGroupId; + $this->prefix = $prefix; + $this->marker = $marker; + $this->maxKeys = $maxKeys; + $this->tagKey = $tagKey; + $this->tagValue = $tagValue; + $this->tagging = $tagging; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListBucketsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListBucketsResult.php new file mode 100644 index 0000000..ad59eda --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListBucketsResult.php @@ -0,0 +1,85 @@ +|null + */ + public ?array $buckets; + + /** + * The container that stores the information about the bucket owner. + * @var Owner|null + */ + public ?Owner $owner; + + /** + * The prefix contained in the names of returned buckets. + * @var string|null + */ + public ?string $prefix; + + /** + * The name of the bucket from which the buckets are returned. + * @var string|null + */ + public ?string $marker; + + /** + * The maximum number of buckets that can be returned. + * @var int|null + */ + public ?int $maxKeys; + + /** + * Indicates whether all results are returned. Valid values:- true: All results are not returned in the response. - false: All results are returned in the response. + * @var bool|null + */ + public ?bool $isTruncated; + + /** + * ListAllMyBucketsResult constructor. + * @param string|null $nextMarker The marker for the next ListBuckets (GetService) request. + * @param array|null $buckets The container that stores the information about multiple buckets. + * @param Owner|null $owner The container that stores the information about the bucket owner. + * @param string|null $prefix The prefix contained in the names of returned buckets. + * @param string|null $marker The name of the bucket from which the buckets are returned. + * @param int|null $maxKeys The maximum number of buckets that can be returned. + * @param bool|null $isTruncated Indicates whether all results are returned. + */ + public function __construct( + ?string $nextMarker = null, + ?array $buckets = null, + ?Owner $owner = null, + ?string $prefix = null, + ?string $marker = null, + ?int $maxKeys = null, + ?bool $isTruncated = null + ) + { + $this->nextMarker = $nextMarker; + $this->buckets = $buckets; + $this->owner = $owner; + $this->prefix = $prefix; + $this->marker = $marker; + $this->maxKeys = $maxKeys; + $this->isTruncated = $isTruncated; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxes.php b/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxes.php new file mode 100644 index 0000000..9ea9332 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxes.php @@ -0,0 +1,97 @@ +prefix = $prefix; + $this->marker = $marker; + $this->maxKeys = $maxKeys; + $this->isTruncated = $isTruncated; + $this->nextMarker = $nextMarker; + $this->owner = $owner; + $this->cloudBoxes = $cloudBoxes; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesRequest.php new file mode 100644 index 0000000..8f307a1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesRequest.php @@ -0,0 +1,57 @@ +marker = $marker; + $this->maxKeys = $maxKeys; + $this->prefix = $prefix; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesResult.php new file mode 100644 index 0000000..b11e80a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListCloudBoxesResult.php @@ -0,0 +1,33 @@ +listCloudBoxes = $listCloudBoxes; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListCnameRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListCnameRequest.php new file mode 100644 index 0000000..3f19d52 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListCnameRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListCnameResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListCnameResult.php new file mode 100644 index 0000000..2c9c622 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListCnameResult.php @@ -0,0 +1,54 @@ +|null + */ + #[XmlElement(rename: 'Cname', type: CnameInfo::class)] + public ?array $cnames; + + /** + * ListCnameRequest constructor. + * @param string|null $bucket The name of the bucket to which the CNAME records you want to query are mapped. + * @param string|null $owner The name of the bucket owner. + * @param array|null $cnames The container that is used to store the information about all CNAME records. + */ + public function __construct( + ?string $bucket = null, + ?string $owner = null, + ?array $cnames = null + ) + { + $this->bucket = $bucket; + $this->owner = $owner; + $this->cnames = $cnames; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListInventoryConfigurationsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListInventoryConfigurationsResult.php new file mode 100644 index 0000000..7658ea2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListInventoryConfigurationsResult.php @@ -0,0 +1,55 @@ +|null + */ + #[XmlElement(rename: 'InventoryConfiguration', type: InventoryConfiguration::class)] + public ?array $inventoryConfigurations; + + /** + * Specifies whether to list all inventory tasks configured for the bucket.Valid values: true and false- The value of false indicates that all inventory tasks configured for the bucket are listed.- The value of true indicates that not all inventory tasks configured for the bucket are listed. To list the next page of inventory configurations, set the continuation-token parameter in the next request to the value of the NextContinuationToken header in the response to the current request. + * @var bool|null + */ + #[XmlElement(rename: 'IsTruncated', type: 'bool')] + public ?bool $isTruncated; + + /** + * If the value of IsTruncated in the response is true and value of this header is not null, set the continuation-token parameter in the next request to the value of this header. + * @var string|null + */ + #[XmlElement(rename: 'NextContinuationToken', type: 'string')] + public ?string $nextContinuationToken; + + /** + * ListInventoryConfigurationsResult constructor. + * @param array|null $inventoryConfigurations The container that stores inventory configurations. + * @param bool|null $isTruncated Specifies whether to list all inventory tasks configured for the bucket. + * @param string|null $nextContinuationToken If the value of IsTruncated in the response is true and value of this header is not null, set the continuation-token parameter in the next request to the value of this header. + */ + public function __construct( + ?array $inventoryConfigurations = null, + ?bool $isTruncated = null, + ?string $nextContinuationToken = null + ) + { + $this->inventoryConfigurations = $inventoryConfigurations; + $this->isTruncated = $isTruncated; + $this->nextContinuationToken = $nextContinuationToken; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsRequest.php new file mode 100644 index 0000000..54b7d8c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsRequest.php @@ -0,0 +1,99 @@ +bucket = $bucket; + $this->delimiter = $delimiter; + $this->encodingType = $encodingType; + $this->keyMarker = $keyMarker; + $this->uploadIdMarker = $uploadIdMarker; + $this->maxUploads = $maxUploads; + $this->prefix = $prefix; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsResult.php new file mode 100644 index 0000000..309d83a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListMultipartUploadsResult.php @@ -0,0 +1,122 @@ +|null + */ + public ?array $uploads; + + /** + * ListMultipartUploadsResult constructor. + * @param string|null $bucket The name of the bucket. + * @param string|null $prefix The prefix that the returned object names must contain. + * @param string|null $keyMarker The name of the object that corresponds to the multipart upload task after which the list begins. + * @param string|null $uploadIdMarker The upload ID of the multipart upload task after which the list begins. + * @param int|null $maxUploads The maximum number of multipart upload tasks returned by OSS. + * @param string|null $delimiter The character used to group objects by name. + * @param bool|null $isTruncated Indicates whether the list of multipart upload tasks returned in the response is truncated. + * @param string|null $nextKeyMarker The object name marker in the response for the next request to return the remaining results. + * @param string|null $nextUploadIdMarker The NextUploadMarker value that is used for the UploadMarker value in the next request if the response does not contain all required results. + * @param string|null $encodingType The method used to encode the object name in the response. + * @param array|null $uploads The ID list of the multipart upload tasks. + */ + public function __construct( + ?string $bucket = null, + ?string $prefix = null, + ?string $keyMarker = null, + ?string $uploadIdMarker = null, + ?int $maxUploads = null, + ?string $delimiter = null, + ?bool $isTruncated = null, + ?string $nextKeyMarker = null, + ?string $nextUploadIdMarker = null, + ?string $encodingType = null, + ?array $uploads = null + ) + { + $this->bucket = $bucket; + $this->prefix = $prefix; + $this->keyMarker = $keyMarker; + $this->uploadIdMarker = $uploadIdMarker; + $this->maxUploads = $maxUploads; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->nextKeyMarker = $nextKeyMarker; + $this->nextUploadIdMarker = $nextUploadIdMarker; + $this->encodingType = $encodingType; + $this->uploads = $uploads; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsRequest.php new file mode 100644 index 0000000..ca99770 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsRequest.php @@ -0,0 +1,99 @@ +bucket = $bucket; + $this->delimiter = $delimiter; + $this->encodingType = $encodingType; + $this->keyMarker = $keyMarker; + $this->versionIdMarker = $versionIdMarker; + $this->maxKeys = $maxKeys; + $this->prefix = $prefix; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsResult.php new file mode 100644 index 0000000..4dcd8c2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListObjectVersionsResult.php @@ -0,0 +1,141 @@ +|null + */ + public ?array $versions; + + /** + * The container that stores delete markers. + * @var array|null + */ + public ?array $deleteMarkers; + + /** + * Objects whose names contain the same string that ranges from the prefix to the next occurrence of the delimiter are grouped as a single result element. + * @var array|null + */ + public ?array $commonPrefixes; + + + /** + * ListObjectVersionsResult constructor. + * @param string|null $name The bucket name. + * @param string|null $prefix The prefix contained in the names of the returned objects. + * @param string|null $keyMarker Indicates the object from which the ListObjectVersions (GetBucketVersions) operation starts. + * @param string|null $versionIdMarker The version from which the ListObjectVersions (GetBucketVersions) operation starts. + * @param int|null $maxKeys The maximum number of objects that can be returned in the response. + * @param string|null $delimiter The character that is used to group objects by name. + * @param bool|null $isTruncated Indicates whether the returned results are truncated. + * @param string|null $encodingType The encoding type of the content in the response. + * @param string|null $nextKeyMarker If not all results are returned for the request, the NextKeyMarker parameter is included in the response to indicate the key-marker value of the next ListObjectVersions (GetBucketVersions) request. + * @param string|null $nextVersionIdMarker If not all results are returned for the request, the NextVersionIdMarker parameter is included in the response to indicate the version-id-marker value of the next ListObjectVersions (GetBucketVersions) request. + * @param array|null $versions The container that stores the versions of objects except for delete markers. + * @param array|null $deleteMarkers The container that stores delete markers. + * @param array|null $commonPrefixes Objects whose names contain the same string that ranges from the prefix to the next occurrence of the delimiter are grouped as a single result element. + */ + public function __construct( + ?string $name = null, + ?string $prefix = null, + ?string $keyMarker = null, + ?string $versionIdMarker = null, + ?int $maxKeys = null, + ?string $delimiter = null, + ?bool $isTruncated = null, + ?string $encodingType = null, + ?string $nextKeyMarker = null, + ?string $nextVersionIdMarker = null, + ?array $versions = null, + ?array $deleteMarkers = null, + ?array $commonPrefixes = null + ) + { + $this->name = $name; + $this->prefix = $prefix; + $this->keyMarker = $keyMarker; + $this->versionIdMarker = $versionIdMarker; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->encodingType = $encodingType; + $this->nextKeyMarker = $nextKeyMarker; + $this->nextVersionIdMarker = $nextVersionIdMarker; + $this->versions = $versions; + $this->deleteMarkers = $deleteMarkers; + $this->commonPrefixes = $commonPrefixes; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListObjectsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsRequest.php new file mode 100644 index 0000000..d3af022 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsRequest.php @@ -0,0 +1,91 @@ +bucket = $bucket; + $this->delimiter = $delimiter; + $this->encodingType = $encodingType; + $this->marker = $marker; + $this->maxKeys = $maxKeys; + $this->prefix = $prefix; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListObjectsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsResult.php new file mode 100644 index 0000000..a522dc6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsResult.php @@ -0,0 +1,113 @@ +|null + */ + public ?array $contents; + + /** + * Summary of contents + * @var array|null + */ + public ?array $commonPrefixes; + + /** + * ListObjectsResult constructor. + * @param string|null $name The name of the bucket. + * @param string|null $prefix The prefix in the names of the returned objects. + * @param string|null $marker The name of the object after which the GetBucket (ListObjects) operation begins. + * @param int|null $maxKeys The maximum number of returned objects in the response. + * @param string|null $delimiter The character that is used to group objects by name. + * @param bool|null $isTruncated $isTruncated Indicates whether the returned list in the result is truncated. + * @param string|null $encodingType The encoding type of the content in the response. + * @param string|null $nextMarker If not all results are returned, NextMarker is included in the response to indicate the value of marker in the next request. + * @param array|null $contents The container that stores the metadata of the returned objects. + * @param array|null $commonPrefixes If delimiter is specified in the request, the response contains CommonPrefixes. + */ + public function __construct( + ?string $name = null, + ?string $prefix = null, + ?string $marker = null, + ?int $maxKeys = null, + ?string $delimiter = null, + ?bool $isTruncated = null, + ?string $encodingType = null, + ?string $nextMarker = null, + ?array $contents = null, + ?array $commonPrefixes = null + ) + { + $this->name = $name; + $this->prefix = $prefix; + $this->marker = $marker; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->encodingType = $encodingType; + $this->nextMarker = $nextMarker; + $this->contents = $contents; + $this->commonPrefixes = $commonPrefixes; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Request.php b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Request.php new file mode 100644 index 0000000..c449f50 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Request.php @@ -0,0 +1,109 @@ +bucket = $bucket; + $this->delimiter = $delimiter; + $this->encodingType = $encodingType; + $this->startAfter = $startAfter; + $this->continuationToken = $continuationToken; + $this->maxKeys = $maxKeys; + $this->prefix = $prefix; + $this->requestPayer = $requestPayer; + $this->fetchOwner = $fetchOwner; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Result.php b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Result.php new file mode 100644 index 0000000..61ef0b6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListObjectsV2Result.php @@ -0,0 +1,131 @@ +|null + */ + public ?array $contents; + + /** + * Summary of contents + * @var array|null + */ + public ?array $commonPrefixes; + + /** + * ListObjectsV2Result constructor. + * @param string|null $name The name of the bucket. + * @param string|null $prefix The prefix in the names of the returned objects. + * @param string|null $startAfter If start-after is specified in the request, the response contains StartAfter. + * @param string|null $continuationToken If continuation-token is specified in the request, the response contains ContinuationToken. + * @param int|null $maxKeys The maximum number of returned objects in the response. + * @param string|null $delimiter The character that is used to group objects by name. + * @param bool|null $isTruncated Indicates whether the returned results are truncated. + * @param string|null $nextContinuationToken The token from which the next list operation starts. + * @param string|null $encodingType The encoding type of the content in the response. + * @param int|null $keyCount The number of objects returned for this request. + * @param array|null $contents The container that stores the metadata of the returned objects. + * @param array|null $commonPrefixes Objects whose names contain the same string that ranges from the prefix to the next occurrence of the delimiter are grouped as a single result element + */ + public function __construct( + ?string $name = null, + ?string $prefix = null, + ?string $startAfter = null, + ?string $continuationToken = null, + ?int $maxKeys = null, + ?string $delimiter = null, + ?bool $isTruncated = null, + ?string $nextContinuationToken = null, + ?string $encodingType = null, + ?int $keyCount = null, + ?array $contents = null, + ?array $commonPrefixes = null + ) + { + $this->name = $name; + $this->prefix = $prefix; + $this->startAfter = $startAfter; + $this->continuationToken = $continuationToken; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->nextContinuationToken = $nextContinuationToken; + $this->encodingType = $encodingType; + $this->keyCount = $keyCount; + $this->contents = $contents; + $this->commonPrefixes = $commonPrefixes; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListPartsRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListPartsRequest.php new file mode 100644 index 0000000..f7fd788 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListPartsRequest.php @@ -0,0 +1,89 @@ +bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->encodingType = $encodingType; + $this->partNumberMarker = $partNumberMarker; + $this->maxParts = $maxParts; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListPartsResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListPartsResult.php new file mode 100644 index 0000000..7f12482 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListPartsResult.php @@ -0,0 +1,115 @@ +|null + */ + public ?array $parts; + + /** + * ListPartsResult constructor. + * @param string|null $bucket The name of the bucket. + * @param string|null $key The name of the object. + * @param string|null $uploadId The ID of the upload task. + * @param string|null $partNumberMarker The position from which the list starts. + * @param string|null $nextPartNumberMarker The NextPartNumberMarker value that is used for the PartNumberMarker value in a subsequent request when the response does not contain all required results. + * @param int|null $maxParts The maximum number of parts in the response. + * @param bool|null $isTruncated Indicates whether the list of parts returned in the response has been truncated. + * @param string|null $storageClass The storage class of the object. + * @param string|null $encodingType The method used to encode the object name in the response. + * @param array|null $parts The list of all parts. + */ + public function __construct( + ?string $bucket = null, + ?string $key = null, + ?string $uploadId = null, + ?string $partNumberMarker = null, + ?string $nextPartNumberMarker = null, + ?int $maxParts = null, + ?bool $isTruncated = null, + ?string $storageClass = null, + ?string $encodingType = null, + ?array $parts = null + ) + { + $this->bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->partNumberMarker = $partNumberMarker; + $this->nextPartNumberMarker = $nextPartNumberMarker; + $this->maxParts = $maxParts; + $this->isTruncated = $isTruncated; + $this->storageClass = $storageClass; + $this->encodingType = $encodingType; + $this->parts = $parts; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListStyleRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListStyleRequest.php new file mode 100644 index 0000000..0025371 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListStyleRequest.php @@ -0,0 +1,38 @@ +bucket = $bucket; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListStyleResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListStyleResult.php new file mode 100644 index 0000000..c1b49e8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListStyleResult.php @@ -0,0 +1,33 @@ +styleList = $styleList; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionRequest.php new file mode 100644 index 0000000..1850b4f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionRequest.php @@ -0,0 +1,45 @@ +continuationToken = $continuationToken; + $this->maxKeys = $maxKeys; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionResult.php b/vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionResult.php new file mode 100644 index 0000000..b94c16e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ListUserDataRedundancyTransitionResult.php @@ -0,0 +1,32 @@ +listBucketDataRedundancyTransition = $listBucketDataRedundancyTransition; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/LocationRTCConstraint.php b/vendor/alibabacloud/oss-v2/src/Models/LocationRTCConstraint.php new file mode 100644 index 0000000..2325a41 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LocationRTCConstraint.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Location', type: 'string')] + public ?array $locations; + + /** + * LocationRTCConstraint constructor. + * @param array|null $locations The regions where RTC is supported. + */ + public function __construct( + ?array $locations = null + ) + { + $this->locations = $locations; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LocationTransferType.php b/vendor/alibabacloud/oss-v2/src/Models/LocationTransferType.php new file mode 100644 index 0000000..2a7942b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LocationTransferType.php @@ -0,0 +1,44 @@ +location = $location; + $this->transferTypes = $transferTypes; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LocationTransferTypeConstraint.php b/vendor/alibabacloud/oss-v2/src/Models/LocationTransferTypeConstraint.php new file mode 100644 index 0000000..30521eb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LocationTransferTypeConstraint.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'LocationTransferType', type: LocationTransferType::class)] + public ?array $locationTransferTypes; + + /** + * LocationTransferTypeConstraint constructor. + * @param array|null $locationTransferTypes The container that stores regions in which the destination bucket can be located with the TransferType information. + */ + public function __construct( + ?array $locationTransferTypes = null + ) + { + $this->locationTransferTypes = $locationTransferTypes; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LoggingEnabled.php b/vendor/alibabacloud/oss-v2/src/Models/LoggingEnabled.php new file mode 100644 index 0000000..ce87a02 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LoggingEnabled.php @@ -0,0 +1,56 @@ +targetBucket = $targetBucket; + $this->targetPrefix = $targetPrefix; + $this->loggingRole = $loggingRole; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LoggingHeaderSet.php b/vendor/alibabacloud/oss-v2/src/Models/LoggingHeaderSet.php new file mode 100644 index 0000000..948edec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LoggingHeaderSet.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'header', type: 'string')] + public ?array $headers; + + /** + * LoggingHeaderSet constructor. + * @param array|null $headers The list of the custom request headers. + */ + public function __construct( + ?array $headers = null + ) + { + $this->headers = $headers; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/LoggingParamSet.php b/vendor/alibabacloud/oss-v2/src/Models/LoggingParamSet.php new file mode 100644 index 0000000..834d792 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/LoggingParamSet.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'parameter', type: 'string')] + public ?array $parameters; + + /** + * LoggingParamSet constructor. + * @param array|null $parameters The list of the custom URL parameters. + */ + public function __construct( + ?array $parameters = null + ) + { + $this->parameters = $parameters; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQuery.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQuery.php new file mode 100644 index 0000000..1712f6d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQuery.php @@ -0,0 +1,106 @@ +maxResults = $maxResults; + $this->query = $query; + $this->sort = $sort; + $this->order = $order; + $this->aggregations = $aggregations; + $this->nextToken = $nextToken; + $this->mediaType = $mediaTypes; + $this->simpleQuery = $simpleQuery; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddress.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddress.php new file mode 100644 index 0000000..592f5b5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddress.php @@ -0,0 +1,95 @@ +addressLine = $addressLine; + $this->city = $city; + $this->district = $district; + $this->language = $language; + $this->province = $province; + $this->township = $township; + $this->country = $country; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddresses.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddresses.php new file mode 100644 index 0000000..496d0d2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAddresses.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'Address', type: MetaQueryAddress::class)] + public ?array $address; + + /** + * MetaQueryAddresses constructor. + * @param array|null $address + */ + public function __construct( + ?array $address = null + ) + { + $this->address = $address; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregation.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregation.php new file mode 100644 index 0000000..0e918ab --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregation.php @@ -0,0 +1,65 @@ +field = $field; + $this->operation = $operation; + $this->value = $value; + $this->groups = $groups; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregations.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregations.php new file mode 100644 index 0000000..b44a7bc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAggregations.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'Aggregation', type: MetaQueryAggregation::class)] + public ?array $aggregations; + + /** + * MetaQueryAggregations constructor. + * @param array|null $aggregations + */ + public function __construct( + ?array $aggregations = null + ) + { + $this->aggregations = $aggregations; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStream.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStream.php new file mode 100644 index 0000000..5b2a439 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStream.php @@ -0,0 +1,95 @@ +duration = $duration; + $this->channels = $channels; + $this->language = $language; + $this->codecName = $codecName; + $this->bitrate = $bitrate; + $this->sampleRate = $sampleRate; + $this->startTime = $startTime; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStreams.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStreams.php new file mode 100644 index 0000000..78f29ce --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryAudioStreams.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'AudioStream', type: MetaQueryAudioStream::class)] + public ?array $audioStream; + + /** + * AudioStreams constructor. + * @param array|null $audioStream + */ + public function __construct( + ?array $audioStream = null + ) + { + $this->audioStream = $audioStream; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryFile.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryFile.php new file mode 100644 index 0000000..109e432 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryFile.php @@ -0,0 +1,481 @@ +filename = $filename; + $this->fileModifiedTime = $fileModifiedTime; + $this->ossStorageClass = $ossStorageClass; + $this->etag = $etag; + $this->ossCrc64 = $ossCrc64; + $this->ossTaggingCount = $ossTaggingCount; + $this->size = $size; + $this->ossObjectType = $ossObjectType; + $this->objectACL = $objectACL; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideEncryptionCustomerAlgorithm = $serverSideEncryptionCustomerAlgorithm; + $this->ossTagging = $ossTagging; + $this->ossUserMeta = $ossUserMeta; + $this->accessControlAllowOrigin = $accessControlAllowOrigin; + $this->album = $album; + $this->serverSideEncryptionCustomerAlgorithm = $serverSideEncryptionCustomerAlgorithm; + $this->uri = $uri; + $this->cacheControl = $cacheControl; + $this->contentEncoding = $contentEncoding; + $this->videoHeight = $videoHeight; + $this->bitrate = $bitrate; + $this->ossCrc64 = $ossCrc64; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->contentDisposition = $contentDisposition; + $this->subtitles = $subtitles; + $this->addresses = $addresses; + $this->ossObjectType = $ossObjectType; + $this->contentType = $contentType; + $this->produceTime = $produceTime; + $this->imageHeight = $imageHeight; + $this->artist = $artist; + $this->ossStorageClass = $ossStorageClass; + $this->objectACL = $objectACL; + $this->latLong = $latLong; + $this->imageWidth = $imageWidth; + $this->composer = $composer; + $this->performer = $performer; + $this->serverSideEncryption = $serverSideEncryption; + $this->mediaType = $mediaType; + $this->ossTagging = $ossTagging; + $this->title = $title; + $this->videoWidth = $videoWidth; + $this->audioStreams = $audioStreams; + $this->filename = $filename; + $this->ossTaggingCount = $ossTaggingCount; + $this->etag = $etag; + $this->ossUserMeta = $ossUserMeta; + $this->ossExpiration = $ossExpiration; + $this->accessControlRequestMethod = $accessControlRequestMethod; + $this->contentLanguage = $contentLanguage; + $this->albumArtist = $albumArtist; + $this->size = $size; + $this->fileModifiedTime = $fileModifiedTime; + $this->duration = $duration; + $this->videoStreams = $videoStreams; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryFiles.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryFiles.php new file mode 100644 index 0000000..9403822 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryFiles.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'File', type: MetaQueryFile::class)] + public ?array $file; + + /** + * MetaQueryFiles constructor. + * @param array|null $file + */ + public function __construct( + ?array $file = null + ) + { + $this->file = $file; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroup.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroup.php new file mode 100644 index 0000000..680eb15 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroup.php @@ -0,0 +1,45 @@ +value = $value; + $this->count = $count; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroups.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroups.php new file mode 100644 index 0000000..ebd7dfd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryGroups.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Group', type: MetaQueryGroup::class)] + public ?array $groups; + + /** + * MetaQueryGroups constructor. + * @param array|null $groups The grouped aggregations. + */ + public function __construct( + ?array $groups = null + ) + { + $this->groups = $groups; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryMediaTypes.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryMediaTypes.php new file mode 100644 index 0000000..90faece --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryMediaTypes.php @@ -0,0 +1,35 @@ +mediaType = $mediaType; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryOrderType.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryOrderType.php new file mode 100644 index 0000000..0169314 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryOrderType.php @@ -0,0 +1,15 @@ +|null + */ + #[XmlElement(rename: 'Tagging', type: MetaQueryTagging::class)] + public ?array $taggings; + + /** + * MetaQueryOssTagging constructor. + * @param array|null $taggings + */ + public function __construct( + ?array $taggings = null + ) + { + $this->taggings = $taggings; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryOssUserMeta.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryOssUserMeta.php new file mode 100644 index 0000000..f6e5b94 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryOssUserMeta.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'UserMeta', type: MetaQueryUserMeta::class)] + public ?array $userMetas; + + /** + * MetaQueryOssUserMeta constructor. + * @param array|null $userMetas + */ + public function __construct( + ?array $userMetas = null + ) + { + $this->userMetas = $userMetas; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryStatus.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryStatus.php new file mode 100644 index 0000000..bd2af2c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryStatus.php @@ -0,0 +1,65 @@ +state = $state; + $this->phase = $phase; + $this->createTime = $createTime; + $this->updateTime = $updateTime; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitle.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitle.php new file mode 100644 index 0000000..8808ed1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitle.php @@ -0,0 +1,65 @@ +codecName = $codecName; + $this->language = $language; + $this->startTime = $startTime; + $this->duration = $duration; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitles.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitles.php new file mode 100644 index 0000000..bd017fb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQuerySubtitles.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'Subtitle', type: MetaQuerySubtitle::class)] + public ?array $subtitle; + + /** + * MetaQuerySubtitles constructor. + * @param array|null $subtitle + */ + public function __construct( + ?array $subtitle = null + ) + { + $this->subtitle = $subtitle; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryTagging.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryTagging.php new file mode 100644 index 0000000..c0fce21 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryTagging.php @@ -0,0 +1,45 @@ +key = $key; + $this->value = $value; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryUserMeta.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryUserMeta.php new file mode 100644 index 0000000..ab53fc5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryUserMeta.php @@ -0,0 +1,44 @@ +value = $value; + $this->key = $key; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStream.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStream.php new file mode 100644 index 0000000..f626c47 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStream.php @@ -0,0 +1,145 @@ +duration = $duration; + $this->frameCount = $frameCount; + $this->bitDepth = $bitDepth; + $this->pixelFormat = $pixelFormat; + $this->colorSpace = $colorSpace; + $this->height = $height; + $this->bitrate = $bitrate; + $this->frameRate = $frameRate; + $this->startTime = $startTime; + $this->width = $width; + $this->codecName = $codecName; + $this->language = $language; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStreams.php b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStreams.php new file mode 100644 index 0000000..0ae16bd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MetaQueryVideoStreams.php @@ -0,0 +1,34 @@ +|null + */ + #[XmlElement(rename: 'VideoStream', type: MetaQueryVideoStream::class)] + public ?array $videoStream; + + /** + * MetaQueryVideoStreams constructor. + * @param array|null $videoStream + */ + public function __construct( + ?array $videoStream = null + ) + { + $this->videoStream = $videoStream; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorAuth.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorAuth.php new file mode 100644 index 0000000..55e4ffe --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorAuth.php @@ -0,0 +1,65 @@ +authType = $authType; + $this->region = $region; + $this->accessKeyId = $accessKeyId; + $this->accessKeySecret = $accessKeySecret; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorHeaderSet.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorHeaderSet.php new file mode 100644 index 0000000..28b5f29 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorHeaderSet.php @@ -0,0 +1,46 @@ +key = $key; + $this->value = $value; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorHeaders.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorHeaders.php new file mode 100644 index 0000000..110b2a7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorHeaders.php @@ -0,0 +1,66 @@ +|null + */ + #[XmlElement(rename: 'Pass', type: 'string')] + public ?array $passs; + + /** + * The headers that are not allowed to pass through to the origin. This parameter takes effect only when the value of RedirectType is Mirror. Each header can be up to 1,024 bytes in length and can contain only letters, digits, and hyphens (-). You can specify up to 10 headers. This parameter is used together with PassAll. + * @var array|null + */ + #[XmlElement(rename: 'Remove', type: 'string')] + public ?array $removes; + + /** + * The headers that are sent to the origin. The specified headers are configured in the data returned by the origin regardless of whether the headers are contained in the request. This parameter takes effect only when the value of RedirectType is Mirror. You can specify up to 10 headers. + * @var array|null + */ + #[XmlElement(rename: 'Set', type: MirrorHeaderSet::class)] + public ?array $sets; + + /** + * Specifies whether to pass through all request headers other than the following headers to the origin. This parameter takes effect only when the value of RedirectType is Mirror.* Headers such as content-length, authorization2, authorization, range, and date* Headers that start with oss-, x-oss-, and x-drs-Default value: false.Valid values:* true * false + * @var bool|null + */ + #[XmlElement(rename: 'PassAll', type: 'bool')] + public ?bool $passAll; + + + /** + * MirrorHeaders constructor. + * @param array|null $passs The headers to pass through to the origin. + * @param array|null $removes The headers that are not allowed to pass through to the origin. + * @param array|null $sets The headers that are sent to the origin. + * @param bool|null $passAll Specifies whether to pass through all request headers other than the following headers to the origin. + */ + public function __construct( + ?array $passs = null, + ?array $removes = null, + ?array $sets = null, + ?bool $passAll = null + ) + { + $this->passs = $passs; + $this->removes = $removes; + $this->sets = $sets; + $this->passAll = $passAll; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternate.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternate.php new file mode 100644 index 0000000..bb83d34 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternate.php @@ -0,0 +1,65 @@ +mirrorMultiAlternateNumber = $mirrorMultiAlternateNumber; + $this->mirrorMultiAlternateURL = $mirrorMultiAlternateURL; + $this->mirrorMultiAlternateVpcId = $mirrorMultiAlternateVpcId; + $this->mirrorMultiAlternateDstRegion = $mirrorMultiAlternateDstRegion; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternates.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternates.php new file mode 100644 index 0000000..492d930 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorMultiAlternates.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'MirrorMultiAlternate', type: MirrorMultiAlternate::class)] + public ?array $mirrorMultiAlternates; + + /** + * MirrorMultiAlternates constructor. + * @param array|null $mirrorMultiAlternates The configuration list for multiple origins. + */ + public function __construct( + ?array $mirrorMultiAlternates = null + ) + { + $this->mirrorMultiAlternates = $mirrorMultiAlternates; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorReturnHeaders.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorReturnHeaders.php new file mode 100644 index 0000000..c4cdefd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorReturnHeaders.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'ReturnHeader', type: ReturnHeader::class)] + public ?array $returnHeaders; + + /** + * MirrorReturnHeaders constructor. + * @param array|null $returnHeaders The rule list for setting response headers in mirror-based back-to-origin. + */ + public function __construct( + ?array $returnHeaders = null + ) + { + $this->returnHeaders = $returnHeaders; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorTagging.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorTagging.php new file mode 100644 index 0000000..a934ea4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorTagging.php @@ -0,0 +1,45 @@ +value = $value; + $this->key = $key; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/MirrorTaggings.php b/vendor/alibabacloud/oss-v2/src/Models/MirrorTaggings.php new file mode 100644 index 0000000..83ebdb3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/MirrorTaggings.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Taggings', type: MirrorTagging::class)] + public ?array $taggings; + + /** + * MirrorTaggings constructor. + * @param array|null $taggings The rule list for setting tags. + */ + public function __construct( + ?array $taggings = null + ) + { + $this->taggings = $taggings; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionExpiration.php b/vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionExpiration.php new file mode 100644 index 0000000..8df4e2c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionExpiration.php @@ -0,0 +1,36 @@ +noncurrentDays = $noncurrentDays; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionTransition.php b/vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionTransition.php new file mode 100644 index 0000000..4e51712 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/NoncurrentVersionTransition.php @@ -0,0 +1,77 @@ +noncurrentDays = $noncurrentDays; + $this->storageClass = $storageClass; + $this->isAccessTime = $isAccessTime; + $this->returnToStdWhenVisit = $returnToStdWhenVisit; + $this->allowSmallFile = $allowSmallFile; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ObjectACLType.php b/vendor/alibabacloud/oss-v2/src/Models/ObjectACLType.php new file mode 100644 index 0000000..f38e55e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ObjectACLType.php @@ -0,0 +1,34 @@ +key = $key; + $this->versionId = $versionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ObjectProperties.php b/vendor/alibabacloud/oss-v2/src/Models/ObjectProperties.php new file mode 100644 index 0000000..a4bffe1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ObjectProperties.php @@ -0,0 +1,116 @@ +key = $key; + $this->type = $type; + $this->size = $size; + $this->etag = $etag; + $this->lastModified = $lastModified; + $this->storageClass = $storageClass; + $this->owner = $owner; + $this->restoreInfo = $restoreInfo; + $this->transitionTime = $transitionTime; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ObjectVersionProperties.php b/vendor/alibabacloud/oss-v2/src/Models/ObjectVersionProperties.php new file mode 100644 index 0000000..4d9ac93 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ObjectVersionProperties.php @@ -0,0 +1,137 @@ +key = $key; + $this->versionId = $versionId; + $this->isLatest = $isLatest; + $this->type = $type; + $this->size = $size; + $this->etag = $etag; + $this->lastModified = $lastModified; + $this->storageClass = $storageClass; + $this->owner = $owner; + $this->restoreInfo = $restoreInfo; + $this->transitionTime = $transitionTime; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryRequest.php b/vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryRequest.php new file mode 100644 index 0000000..fdbd75a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryRequest.php @@ -0,0 +1,48 @@ +bucket = $bucket; + $this->mode = $mode; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryResult.php b/vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryResult.php new file mode 100644 index 0000000..99ca15d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OpenMetaQueryResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->key = $key; + $this->origin = $origin; + $this->accessControlRequestMethod = $accessControlRequestMethod; + $this->accessControlRequestHeaders = $accessControlRequestHeaders; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/OptionObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/OptionObjectResult.php new file mode 100644 index 0000000..ef1cb8c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OptionObjectResult.php @@ -0,0 +1,67 @@ +accessControlAllowOrigin = $accessControlAllowOrigin; + $this->accessControlAllowMethods = $accessControlAllowMethods; + $this->accessControlAllowHeaders = $accessControlAllowHeaders; + $this->accessControlExposeHeaders = $accessControlExposeHeaders; + $this->accessControlMaxAge = $accessControlMaxAge; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/OptionalFields.php b/vendor/alibabacloud/oss-v2/src/Models/OptionalFields.php new file mode 100644 index 0000000..8076089 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OptionalFields.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Field', type: 'string')] + public ?array $fields; + + /** + * OptionalFields constructor. + * @param array|null $fields The configuration fields that are included in inventory lists. + */ + public function __construct( + ?array $fields = null + ) + { + $this->fields = $fields; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/OverwriteConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/OverwriteConfiguration.php new file mode 100644 index 0000000..929ff00 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OverwriteConfiguration.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Rule', type: OverwriteRule::class)] + public ?array $rules; + + /** + * OverwriteConfiguration constructor. + * @param array|null $rules List of overwrite protection rules. + */ + public function __construct( + ?array $rules = null + ) + { + $this->rules = $rules; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/OverwritePrincipals.php b/vendor/alibabacloud/oss-v2/src/Models/OverwritePrincipals.php new file mode 100644 index 0000000..369459f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OverwritePrincipals.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Principal', type: 'string')] + public ?array $principals; + + /** + * Principals constructor. + * @param array|null $principals A collection of authorized entities. + */ + public function __construct( + ?array $principals = null + ) + { + $this->principals = $principals; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/OverwriteRule.php b/vendor/alibabacloud/oss-v2/src/Models/OverwriteRule.php new file mode 100644 index 0000000..c153f0f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/OverwriteRule.php @@ -0,0 +1,75 @@ +action = $action; + $this->prefix = $prefix; + $this->suffix = $suffix; + $this->principals = $principals; + $this->id = $id; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/Owner.php b/vendor/alibabacloud/oss-v2/src/Models/Owner.php new file mode 100644 index 0000000..da7f848 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Owner.php @@ -0,0 +1,45 @@ +id = $id; + $this->displayName = $displayName; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/Part.php b/vendor/alibabacloud/oss-v2/src/Models/Part.php new file mode 100644 index 0000000..147ebd3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Part.php @@ -0,0 +1,77 @@ +partNumber = $partNumber; + $this->etag = $etag; + $this->lastModified = $lastModified; + $this->size = $size; + $this->hashCrc64 = $hashCrc64; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PolicyStatus.php b/vendor/alibabacloud/oss-v2/src/Models/PolicyStatus.php new file mode 100644 index 0000000..8279431 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PolicyStatus.php @@ -0,0 +1,35 @@ +isPublic = $isPublic; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PresignResult.php b/vendor/alibabacloud/oss-v2/src/Models/PresignResult.php new file mode 100644 index 0000000..20ccb62 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PresignResult.php @@ -0,0 +1,56 @@ +|null + */ + public ?array $signedHeaders; + + /** + * PresignResult constructor. + * @param mixed $method The HTTP method, which corresponds to the operation. + * @param mixed $url The pre-signed URL. + * @param mixed $expiration The time when the pre-signed URL expires. + * @param mixed $signedHeaders The request headers specified in the request. + */ + public function __construct( + ?string $method = null, + ?string $url = null, + ?\DateTime $expiration = null, + ?array $signedHeaders = null + ) { + $this->method = $method; + $this->url = $url; + $this->expiration = $expiration; + $this->signedHeaders = $signedHeaders; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ProcessObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/ProcessObjectRequest.php new file mode 100644 index 0000000..44200d2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ProcessObjectRequest.php @@ -0,0 +1,62 @@ +bucket = $bucket; + $this->key = $key; + $this->process = $process; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ProcessObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/ProcessObjectResult.php new file mode 100644 index 0000000..43fef83 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ProcessObjectResult.php @@ -0,0 +1,59 @@ +bucket = $bucket; + $this->key = $key; + $this->fileSize = $fileSize; + $this->processStatus = $processStatus; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PublicAccessBlockConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/PublicAccessBlockConfiguration.php new file mode 100644 index 0000000..a8b74a4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PublicAccessBlockConfiguration.php @@ -0,0 +1,35 @@ +blockPublicAccess = $blockPublicAccess; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyRequest.php new file mode 100644 index 0000000..5068e05 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyRequest.php @@ -0,0 +1,60 @@ +bucket = $bucket; + $this->accessPointName = $accessPointName; + $this->body = $body; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyResult.php new file mode 100644 index 0000000..3c8c1a4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutAccessPointPolicyResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->accessMonitorConfiguration = $accessMonitorConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketAccessMonitorResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketAccessMonitorResult.php new file mode 100644 index 0000000..b43a068 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketAccessMonitorResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->acl = $acl; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketAclResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketAclResult.php new file mode 100644 index 0000000..2f03003 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketAclResult.php @@ -0,0 +1,16 @@ +bucket = $bucket; + $this->archiveDirectReadConfiguration = $archiveDirectReadConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketArchiveDirectReadResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketArchiveDirectReadResult.php new file mode 100644 index 0000000..9a46057 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketArchiveDirectReadResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->corsConfiguration = $corsConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketCorsResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketCorsResult.php new file mode 100644 index 0000000..f070f15 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketCorsResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->serverSideEncryptionRule = $serverSideEncryptionRule; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketEncryptionResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketEncryptionResult.php new file mode 100644 index 0000000..5db708b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketEncryptionResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->httpsConfiguration = $httpsConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketHttpsConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketHttpsConfigResult.php new file mode 100644 index 0000000..5c5fc09 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketHttpsConfigResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->inventoryId = $inventoryId; + $this->inventoryConfiguration = $inventoryConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketInventoryResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketInventoryResult.php new file mode 100644 index 0000000..d5356bb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketInventoryResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->allowSameActionOverlap = $allowSameActionOverlap; + $this->lifecycleConfiguration = $lifecycleConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketLifecycleResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketLifecycleResult.php new file mode 100644 index 0000000..5a74fc8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketLifecycleResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->bucketLoggingStatus = $bucketLoggingStatus; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketLoggingResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketLoggingResult.php new file mode 100644 index 0000000..f483643 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketLoggingResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->overwriteConfiguration = $overwriteConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketOverwriteConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketOverwriteConfigResult.php new file mode 100644 index 0000000..91f509b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketOverwriteConfigResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->body = $body; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketPolicyResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketPolicyResult.php new file mode 100644 index 0000000..e5d4a8e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketPolicyResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketPublicAccessBlockResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketPublicAccessBlockResult.php new file mode 100644 index 0000000..b44aef7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketPublicAccessBlockResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->refererConfiguration = $refererConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketRefererResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRefererResult.php new file mode 100644 index 0000000..7838cfd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRefererResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->replicationConfiguration = $replicationConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketReplicationResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketReplicationResult.php new file mode 100644 index 0000000..04a02ba --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketReplicationResult.php @@ -0,0 +1,32 @@ +replicationRuleId = $replicationRuleId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequest.php new file mode 100644 index 0000000..ac4ef8d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequest.php @@ -0,0 +1,63 @@ +bucket = $bucket; + $this->acl = $acl; + $this->resourceGroupId = $resourceGroupId; + $this->createBucketConfiguration = $createBucketConfiguration; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentRequest.php new file mode 100644 index 0000000..bd9a1e7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->requestPaymentConfiguration = $requestPaymentConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentResult.php new file mode 100644 index 0000000..fc0fc51 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRequestPaymentResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->bucketResourceGroupConfiguration = $bucketResourceGroupConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketResourceGroupResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketResourceGroupResult.php new file mode 100644 index 0000000..0a90c83 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketResourceGroupResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->rtcConfiguration = $rtcConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketRtcResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRtcResult.php new file mode 100644 index 0000000..d3ec60b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketRtcResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->tagging = $tagging; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketTagsResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketTagsResult.php new file mode 100644 index 0000000..51f115b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketTagsResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->transferAccelerationConfiguration = $transferAccelerationConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketTransferAccelerationResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketTransferAccelerationResult.php new file mode 100644 index 0000000..e8731a0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketTransferAccelerationResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->versioningConfiguration = $versioningConfiguration; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketVersioningResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketVersioningResult.php new file mode 100644 index 0000000..57daf32 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketVersioningResult.php @@ -0,0 +1,16 @@ +bucket = $bucket; + $this->websiteConfiguration = $websiteConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutBucketWebsiteResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutBucketWebsiteResult.php new file mode 100644 index 0000000..5056e0a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutBucketWebsiteResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->bucketCnameConfiguration = $bucketCnameConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutCnameResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutCnameResult.php new file mode 100644 index 0000000..47bb96d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutCnameResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->key = $key; + $this->acl = $objectAcl ?? $acl; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutObjectAclResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutObjectAclResult.php new file mode 100644 index 0000000..2598da9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutObjectAclResult.php @@ -0,0 +1,30 @@ +versionId = $versionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutObjectRequest.php new file mode 100644 index 0000000..e964bf7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutObjectRequest.php @@ -0,0 +1,253 @@ +|null + */ + public ?array $metadata; + + /** + * The caching behavior of the web page when the object is downloaded. + * @var string|null + */ + public ?string $cacheControl; + + /** + * The method that is used to access the object. + * @var string|null + */ + public ?string $contentDisposition; + + /** + * The method that is used to encode the object. + * @var string|null + */ + public ?string $contentEncoding; + + /** + * The size of the data in the HTTP message body. Unit: bytes. + * @var int|null + */ + public ?int $contentLength; + + /** + * The MD5 hash of the object that you want to upload. + * @var string|null + */ + public ?string $contentMd5; + + /** + * A standard MIME type describing the format of the contents. + * @var string|null + */ + public ?string $contentType; + + /** + * The expiration time of the cache in UTC. + * @var string|null + */ + public ?string $expires; + + /** + * The method that is used to encrypt the object on the OSS server when the object is created. Valid values: AES256, KMS, and SM4. + * If you specify the header, the header is returned in the response. + * OSS uses the method that is specified by this header to encrypt the uploaded object. + * When you download the encrypted object, the x-oss-server-side-encryption header is included in the response and the header value is set to the algorithm that is used to encrypt the object. + * @var string|null + */ + public ?string $serverSideEncryption; + + /** + * Specify the encryption algorithm for the object. Valid values: SM4. + * If this option is not specified, it indicates that the Object uses AES256 encryption algorithm. + * This option is only valid when x-oss-ser-side-encryption is KMS. + * @var string|null + */ + public ?string $serverSideDataEncryption; + + /** + * The ID of the customer master key (CMK) that is managed by Key Management Service (KMS). + * This header is valid only when the x-oss-server-side-encryption header is set to KMS. + * @var string|null + */ + public ?string $serverSideEncryptionKeyId; + + /** + * The tag of the object. You can configure multiple tags for the object. Example: TagA=A&TagB=B. + * The key and value of a tag must be URL-encoded. + * If a tag does not contain an equal sign (=), the value of the tag is considered an empty string. + * @var string|null + */ + public ?string $tagging; + + /** + * A callback parameter is a Base64-encoded string that contains multiple fields in the JSON format. + * @var string|null + */ + public ?string $callback; + + /** + * Configure custom parameters by using the callback-var parameter. + * @var string|null + */ + public ?string $callbackVar; + + /** + * Specifies whether the object that is uploaded by calling the PutObject operation overwrites the existing object that has the same name. + * When versioning is enabled or suspended for the bucket to which you want to upload the object, the x-oss-forbid-overwrite header does not take effect. + * In this case, the object that is uploaded by calling the PutObject operation overwrites the existing object that has the same name. + * - If you do not specify the **x-oss-forbid-overwrite** header or set the x-oss-forbid-overwrite header to false, + * the object that is uploaded by calling the PutObject operation overwrites the existing object that has the same name. + * - If the value of x-oss-forbid-overwrite is set to **true**, existing objects cannot be overwritten by objects that have the same names. + * If you specify the x-oss-forbid-overwrite request header, the queries per second (QPS) performance of OSS is degraded. + * If you want to use the x-oss-forbid-overwrite request header to perform a large number of operations (QPS greater than 1,000), contact technical support. + * Default value: false. + * @var bool|null + */ + public ?bool $forbidOverwrite; + + /** + * Specify the speed limit value. The speed limit value ranges from 245760 to 838860800, with a unit of bit/s. + * @var int|null + */ + public ?int $trafficLimit; + + /** + * To indicate that the requester is aware that the request and data download will incur costs. + * @var string|null + */ + public ?string $requestPayer; + + /** + * Object data. + * @var \Psr\Http\Message\StreamInterface|null + */ + public ?\Psr\Http\Message\StreamInterface $body; + + /** + * Progress callback function. + * @var callable|null + */ + public $progressFn; + + /** + * PutObjectRequest constructor. + * @param string|null $bucket The name of the bucket. + * @param string|null $key The full path of the object. + * @param string|null $acl The access control list (ACL) of the object. + * @param string|null $storageClass The storage class of the object. + * @param array|null $metadata The tag of the object. + * @param string|null $cacheControl The caching behavior of the web page when the object is downloaded. + * @param string|null $contentDisposition The method that is used to access the object. + * @param string|null $contentEncoding The method that is used to encode the object. + * @param string|null $contentLength The size of the data in the HTTP message body. + * @param string|null $contentMd5 The MD5 hash of the object that you want to upload. + * @param string|null $contentType A standard MIME type describing the format of the contents. + * @param string|null $expires The expiration time of the cache in UTC. + * @param string|null $serverSideEncryption The method that is used to encrypt the object on the OSS server when the object is created. + * @param string|null $serverSideDataEncryption Specify the encryption algorithm for the object. + * @param string|null $serverSideEncryptionKeyId The ID of the customer master key (CMK) that is managed by Key Management Service (KMS). + * @param string|null $tagging The tags that are specified for the object by using a key-value pair. + * @param string|null $callback A callback parameter is a Base64-encoded string that contains multiple fields in the JSON format. + * @param string|null $callbackVar Configure custom parameters by using the callback-var parameter. + * @param bool|null $forbidOverwrite Specifies whether the object that is uploaded by calling the PutObject operation overwrites the existing object that has the same name. + * @param int|null $trafficLimit Specify the speed limit value. + * @param string|null $requestPayer To indicate that the requester is aware that the request and data download will incur costs. + * @param \Psr\Http\Message\StreamInterface|null $body Object data. + * @param callable|null $progressFn Progress callback function. + * @param array|null $options + * @param string|null $objectAcl The access control list (ACL) of the object. The object acl parameter has the same functionality as the acl parameter. it is the standardized name for acl. If both exist simultaneously, the value of objectAcl will take precedence. + */ + public function __construct( + ?string $bucket = null, + ?string $key = null, + ?string $acl = null, + ?string $storageClass = null, + ?array $metadata = null, + ?string $cacheControl = null, + ?string $contentDisposition = null, + ?string $contentEncoding = null, + ?string $contentLength = null, + ?string $contentMd5 = null, + ?string $contentType = null, + ?string $expires = null, + ?string $serverSideEncryption = null, + ?string $serverSideDataEncryption = null, + ?string $serverSideEncryptionKeyId = null, + ?string $tagging = null, + ?string $callback = null, + ?string $callbackVar = null, + ?bool $forbidOverwrite = null, + ?int $trafficLimit = null, + ?string $requestPayer = null, + ?\Psr\Http\Message\StreamInterface $body = null, + ?callable $progressFn = null, + ?array $options = null, + ?string $objectAcl = null + ) + { + $this->bucket = $bucket; + $this->key = $key; + $this->acl = $objectAcl ?? $acl; + $this->storageClass = $storageClass; + $this->metadata = $metadata; + $this->cacheControl = $cacheControl; + $this->contentDisposition = $contentDisposition; + $this->contentEncoding = $contentEncoding; + $this->contentLength = $contentLength; + $this->contentMd5 = $contentMd5; + $this->contentType = $contentType; + $this->expires = $expires; + $this->serverSideEncryption = $serverSideEncryption; + $this->serverSideDataEncryption = $serverSideDataEncryption; + $this->serverSideEncryptionKeyId = $serverSideEncryptionKeyId; + $this->tagging = $tagging; + $this->callback = $callback; + $this->callbackVar = $callbackVar; + $this->forbidOverwrite = $forbidOverwrite; + $this->trafficLimit = $trafficLimit; + $this->requestPayer = $requestPayer; + $this->body = $body; + $this->progressFn = $progressFn; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutObjectResult.php new file mode 100644 index 0000000..7b9b7e8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutObjectResult.php @@ -0,0 +1,69 @@ +contentMd5 = $contentMd5; + $this->etag = $etag; + $this->hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->callbackResult = $callbackResult; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingRequest.php new file mode 100644 index 0000000..259cc76 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingRequest.php @@ -0,0 +1,71 @@ +bucket = $bucket; + $this->key = $key; + $this->tagging = $tagging; + $this->versionId = $versionId; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingResult.php new file mode 100644 index 0000000..4551c78 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutObjectTaggingResult.php @@ -0,0 +1,32 @@ +versionId = $versionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockRequest.php new file mode 100644 index 0000000..4711d38 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockRequest.php @@ -0,0 +1,39 @@ +publicAccessBlockConfiguration = $publicAccessBlockConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockResult.php new file mode 100644 index 0000000..69eb65e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutPublicAccessBlockResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->styleName = $styleName; + $this->category = $category; + $this->style = $style; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutStyleResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutStyleResult.php new file mode 100644 index 0000000..8767aab --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutStyleResult.php @@ -0,0 +1,15 @@ +bucket = $bucket; + $this->key = $key; + $this->target = $symlinkTarget ?? $target; + $this->acl = $objectAcl ?? $acl; + $this->storageClass = $storageClass; + $this->metadata = $metadata; + $this->forbidOverwrite = $forbidOverwrite; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutSymlinkResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutSymlinkResult.php new file mode 100644 index 0000000..d2a6517 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutSymlinkResult.php @@ -0,0 +1,32 @@ +versionId = $versionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigRequest.php b/vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigRequest.php new file mode 100644 index 0000000..b01accf --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigRequest.php @@ -0,0 +1,49 @@ +bucket = $bucket; + $this->userDefinedLogFieldsConfiguration = $userDefinedLogFieldsConfiguration; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigResult.php b/vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigResult.php new file mode 100644 index 0000000..157bfd3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/PutUserDefinedLogFieldsConfigResult.php @@ -0,0 +1,15 @@ +|null + */ + #[XmlElement(rename: 'Referer', type: 'string')] + public ?array $referers; + + /** + * RefererBlacklist constructor. + * @param array|null $referers The addresses in the Referer blacklist. + */ + public function __construct( + ?array $referers = null + ) + { + $this->referers = $referers; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RefererConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/RefererConfiguration.php new file mode 100644 index 0000000..481331e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RefererConfiguration.php @@ -0,0 +1,75 @@ +allowEmptyReferer = $allowEmptyReferer; + $this->allowTruncateQueryString = $allowTruncateQueryString; + $this->truncatePath = $truncatePath; + $this->refererList = $refererList; + $this->refererBlacklist = $refererBlacklist; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RefererList.php b/vendor/alibabacloud/oss-v2/src/Models/RefererList.php new file mode 100644 index 0000000..68adb12 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RefererList.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Referer', type: 'string')] + public ?array $referers; + + /** + * RefererList constructor. + * @param array|null $referers The addresses in the Referer whitelist. + */ + public function __construct( + ?array $referers = null + ) + { + $this->referers = $referers; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RegionInfo.php b/vendor/alibabacloud/oss-v2/src/Models/RegionInfo.php new file mode 100644 index 0000000..ac6bec4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RegionInfo.php @@ -0,0 +1,66 @@ +region = $region; + $this->internetEndpoint = $internetEndpoint; + $this->internalEndpoint = $internalEndpoint; + $this->accelerateEndpoint = $accelerateEndpoint; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationConfiguration.php new file mode 100644 index 0000000..05d7a50 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationConfiguration.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Rule', type: ReplicationRule::class)] + public ?array $rules; + + /** + * ReplicationConfiguration constructor. + * @param array|null $rules The container that stores the data replication rules. + */ + public function __construct( + ?array $rules = null + ) + { + $this->rules = $rules; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationDestination.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationDestination.php new file mode 100644 index 0000000..df5d7e6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationDestination.php @@ -0,0 +1,56 @@ +bucket = $bucket; + $this->location = $location; + $this->transferType = $transferType; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationEncryptionConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationEncryptionConfiguration.php new file mode 100644 index 0000000..86e0aa1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationEncryptionConfiguration.php @@ -0,0 +1,34 @@ +replicaKmsKeyID = $replicaKmsKeyID; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationLocation.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationLocation.php new file mode 100644 index 0000000..7dc5933 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationLocation.php @@ -0,0 +1,55 @@ +|null + */ + #[XmlElement(rename: 'Location', type: 'string')] + public ?array $locations; + + /** + * ReplicationLocation constructor. + * @param LocationTransferTypeConstraint|null $locationTransferTypeConstraint The container that stores regions in which the destination bucket can be located with TransferType specified. + * @param LocationRTCConstraint|null $locationRTCConstraint The container that stores regions in which the RTC can be enabled. + * @param array|null $locations The regions in which the destination bucket can be located. + */ + public function __construct( + ?LocationTransferTypeConstraint $locationTransferTypeConstraint = null, + ?LocationRTCConstraint $locationRTCConstraint = null, + ?array $locations = null + ) + { + $this->locationTransferTypeConstraint = $locationTransferTypeConstraint; + $this->locationRTCConstraint = $locationRTCConstraint; + $this->locations = $locations; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationPrefixSet.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationPrefixSet.php new file mode 100644 index 0000000..7f07d29 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationPrefixSet.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Prefix', type: 'string')] + public ?array $prefixs; + + /** + * ReplicationPrefixSet constructor. + * @param array|null $prefixs The prefix that is used to specify the object that you want to replicate. + */ + public function __construct( + ?array $prefixs = null + ) + { + $this->prefixs = $prefixs; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgress.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgress.php new file mode 100644 index 0000000..1ba2263 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgress.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Rule', type: ReplicationProgressRule::class)] + public ?array $rules; + + /** + * ReplicationProgress constructor. + * @param array|null $rules The container that stores the progress of the data replication task corresponding to each data replication rule. + */ + public function __construct( + ?array $rules = null + ) + { + $this->rules = $rules; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressInformation.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressInformation.php new file mode 100644 index 0000000..b14ef14 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressInformation.php @@ -0,0 +1,44 @@ +historicalObject = $historicalObject; + $this->newObject = $newObject; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressRule.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressRule.php new file mode 100644 index 0000000..3479c77 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationProgressRule.php @@ -0,0 +1,95 @@ +id = $id; + $this->prefixSet = $prefixSet; + $this->action = $action; + $this->destination = $destination; + $this->status = $status; + $this->historicalObjectReplication = $historicalObjectReplication; + $this->progress = $progress; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationRule.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationRule.php new file mode 100644 index 0000000..e976a8a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationRule.php @@ -0,0 +1,126 @@ +status = $status; + $this->sourceSelectionCriteria = $sourceSelectionCriteria; + $this->id = $id; + $this->prefixSet = $prefixSet; + $this->action = $action; + $this->destination = $destination; + $this->historicalObjectReplication = $historicalObjectReplication; + $this->syncRole = $syncRole; + $this->encryptionConfiguration = $encryptionConfiguration; + $this->rtc = $rtc; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationRules.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationRules.php new file mode 100644 index 0000000..547bbc6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationRules.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'ID', type: 'string')] + public ?array $ids; + + /** + * ReplicationConfiguration constructor. + * @param array|null $ids The ID of data replication rules that you want to delete. + */ + public function __construct( + ?array $ids = null + ) + { + $this->ids = $ids; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationSourceSelectionCriteria.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationSourceSelectionCriteria.php new file mode 100644 index 0000000..11c56f4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationSourceSelectionCriteria.php @@ -0,0 +1,35 @@ +sseKmsEncryptedObjects = $sseKmsEncryptedObjects; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReplicationTimeControl.php b/vendor/alibabacloud/oss-v2/src/Models/ReplicationTimeControl.php new file mode 100644 index 0000000..413e8b0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReplicationTimeControl.php @@ -0,0 +1,35 @@ +status = $status; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RequestPaymentConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/RequestPaymentConfiguration.php new file mode 100644 index 0000000..dd68434 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RequestPaymentConfiguration.php @@ -0,0 +1,35 @@ +payer = $payer; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RestoreObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/RestoreObjectRequest.php new file mode 100644 index 0000000..3291ffc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RestoreObjectRequest.php @@ -0,0 +1,71 @@ +bucket = $bucket; + $this->key = $key; + $this->versionId = $versionId; + $this->restoreRequest = $restoreRequest; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/RestoreObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/RestoreObjectResult.php new file mode 100644 index 0000000..dc71d5b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RestoreObjectResult.php @@ -0,0 +1,42 @@ +versionId = $versionId; + $this->restorePriority = $restorePriority; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/RestoreRequest.php b/vendor/alibabacloud/oss-v2/src/Models/RestoreRequest.php new file mode 100644 index 0000000..f598499 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RestoreRequest.php @@ -0,0 +1,43 @@ +days = $days; + $this->tier = $tier; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/ReturnHeader.php b/vendor/alibabacloud/oss-v2/src/Models/ReturnHeader.php new file mode 100644 index 0000000..faced0f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ReturnHeader.php @@ -0,0 +1,45 @@ +key = $key; + $this->value = $value; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RoutingRule.php b/vendor/alibabacloud/oss-v2/src/Models/RoutingRule.php new file mode 100644 index 0000000..880df29 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RoutingRule.php @@ -0,0 +1,64 @@ +redirect = $redirect; + $this->ruleNumber = $ruleNumber; + $this->condition = $condition; + $this->luaConfig = $luaConfig; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleCondition.php b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleCondition.php new file mode 100644 index 0000000..19fadec --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleCondition.php @@ -0,0 +1,66 @@ +|null + */ + #[XmlElement(rename: 'IncludeHeader', type: RoutingRuleIncludeHeader::class)] + public ?array $includeHeaders; + + /** + * RoutingRuleCondition constructor. + * @param string|null $keyPrefixEquals The prefix of object names. + * @param string|null $keySuffixEquals Only objects that match this suffix can match this rule. + * @param int|null $httpErrorCodeReturnedEquals The HTTP status code. + * @param array|null $includeHeaders This rule can only be matched if the request contains the specified header and the value is the specified value. + */ + public function __construct( + ?string $keyPrefixEquals = null, + ?string $keySuffixEquals = null, + ?int $httpErrorCodeReturnedEquals = null, + ?array $includeHeaders = null + ) + { + $this->keyPrefixEquals = $keyPrefixEquals; + $this->keySuffixEquals = $keySuffixEquals; + $this->httpErrorCodeReturnedEquals = $httpErrorCodeReturnedEquals; + $this->includeHeaders = $includeHeaders; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleIncludeHeader.php b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleIncludeHeader.php new file mode 100644 index 0000000..52a0d24 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleIncludeHeader.php @@ -0,0 +1,66 @@ +key = $key; + $this->equals = $equals; + $this->startsWith = $startsWith; + $this->endsWith = $endsWith; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleLuaConfig.php b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleLuaConfig.php new file mode 100644 index 0000000..a02fa59 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleLuaConfig.php @@ -0,0 +1,35 @@ +script = $script; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleRedirect.php b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleRedirect.php new file mode 100644 index 0000000..f47f6ee --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RoutingRuleRedirect.php @@ -0,0 +1,403 @@ +mirrorPassOriginalSlashes = $mirrorPassOriginalSlashes; + $this->redirectType = $redirectType; + $this->mirrorURL = $mirrorURL; + $this->mirrorPassQueryString = $mirrorPassQueryString; + $this->mirrorCheckMd5 = $mirrorCheckMd5; + $this->mirrorSNI = $mirrorSNI; + $this->protocol = $protocol; + $this->replaceKeyPrefixWith = $replaceKeyPrefixWith; + $this->mirrorFollowRedirect = $mirrorFollowRedirect; + $this->hostName = $hostName; + $this->mirrorHeaders = $mirrorHeaders; + $this->passQueryString = $passQueryString; + $this->enableReplacePrefix = $enableReplacePrefix; + $this->replaceKeyWith = $replaceKeyWith; + $this->httpRedirectCode = $httpRedirectCode; + $this->mirrorURLSlave = $mirrorURLSlave; + $this->mirrorURLProbe = $mirrorURLProbe; + $this->mirrorSaveOssMeta = $mirrorSaveOssMeta; + $this->mirrorProxyPass = $mirrorProxyPass; + $this->mirrorAllowGetImageInfo = $mirrorAllowGetImageInfo; + $this->mirrorAllowVideoSnapshot = $mirrorAllowVideoSnapshot; + $this->mirrorIsExpressTunnel = $mirrorIsExpressTunnel; + $this->mirrorDstRegion = $mirrorDstRegion; + $this->mirrorDstVpcId = $mirrorDstVpcId; + $this->mirrorDstSlaveVpcId = $mirrorDstSlaveVpcId; + $this->mirrorUserLastModified = $mirrorUserLastModified; + $this->mirrorSwitchAllErrors = $mirrorSwitchAllErrors; + $this->mirrorTunnelId = $mirrorTunnelId; + $this->mirrorUsingRole = $mirrorUsingRole; + $this->mirrorRole = $mirrorRole; + $this->mirrorAllowHeadObject = $mirrorAllowHeadObject; + $this->transparentMirrorResponseCodes = $transparentMirrorResponseCodes; + $this->mirrorAsyncStatus = $mirrorAsyncStatus; + $this->mirrorTaggings = $mirrorTaggings; + $this->mirrorReturnHeaders = $mirrorReturnHeaders; + $this->mirrorAuth = $mirrorAuth; + $this->mirrorMultiAlternates = $mirrorMultiAlternates; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RoutingRules.php b/vendor/alibabacloud/oss-v2/src/Models/RoutingRules.php new file mode 100644 index 0000000..a8a6e41 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RoutingRules.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'RoutingRule', type: RoutingRule::class)] + public ?array $routingRules; + + /** + * RoutingRules constructor. + * @param array|null $routingRules The specified redirection rule or mirroring-based back-to-origin rule. + */ + public function __construct( + ?array $routingRules = null + ) + { + $this->routingRules = $routingRules; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/RtcConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/RtcConfiguration.php new file mode 100644 index 0000000..dfe2a46 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/RtcConfiguration.php @@ -0,0 +1,45 @@ +rtc = $rtc; + $this->id = $id; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/SSEKMS.php b/vendor/alibabacloud/oss-v2/src/Models/SSEKMS.php new file mode 100644 index 0000000..60845a7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/SSEKMS.php @@ -0,0 +1,35 @@ +keyId = $keyId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectRequest.php b/vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectRequest.php new file mode 100644 index 0000000..28981a2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectRequest.php @@ -0,0 +1,52 @@ +bucket = $bucket; + $this->key = $key; + $this->position = $position; + parent::__construct($options); + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectResult.php b/vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectResult.php new file mode 100644 index 0000000..5d4bb12 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/SealAppendObjectResult.php @@ -0,0 +1,30 @@ +sealedTime = $sealedTime; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRule.php b/vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRule.php new file mode 100644 index 0000000..8acd995 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRule.php @@ -0,0 +1,36 @@ +applyServerSideEncryptionByDefault = $applyServerSideEncryptionByDefault; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRuleInfo.php b/vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRuleInfo.php new file mode 100644 index 0000000..78a7edd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/ServerSideEncryptionRuleInfo.php @@ -0,0 +1,55 @@ +kmsMasterKeyId = $kmsMasterKeyId; + $this->sseAlgorithm = $sseAlgorithm; + $this->kmsDataEncryption = $kmsDataEncryption; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/SseKmsEncryptedObjects.php b/vendor/alibabacloud/oss-v2/src/Models/SseKmsEncryptedObjects.php new file mode 100644 index 0000000..cc47f88 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/SseKmsEncryptedObjects.php @@ -0,0 +1,36 @@ +status = $status; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/StatusType.php b/vendor/alibabacloud/oss-v2/src/Models/StatusType.php new file mode 100644 index 0000000..0ca0fad --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/StatusType.php @@ -0,0 +1,16 @@ +content = $content; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/StyleInfo.php b/vendor/alibabacloud/oss-v2/src/Models/StyleInfo.php new file mode 100644 index 0000000..1a49794 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/StyleInfo.php @@ -0,0 +1,75 @@ +content = $content; + $this->createTime = $createTime; + $this->lastModifyTime = $lastModifyTime; + $this->category = $category; + $this->name = $name; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/StyleList.php b/vendor/alibabacloud/oss-v2/src/Models/StyleList.php new file mode 100644 index 0000000..dffd072 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/StyleList.php @@ -0,0 +1,35 @@ +|null + */ + #[XmlElement(rename: 'Style', type: StyleInfo::class)] + public ?array $styles; + + /** + * StyleList constructor. + * @param array|null $styles The list of styles. + */ + public function __construct( + ?array $styles = null + ) + { + $this->styles = $styles; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/TLS.php b/vendor/alibabacloud/oss-v2/src/Models/TLS.php new file mode 100644 index 0000000..b114434 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/TLS.php @@ -0,0 +1,44 @@ +|null + */ + #[XmlElement(rename: 'TLSVersion', type: 'string')] + public ?array $tlsVersions; + /** + * Specifies whether to enable TLS version management for the bucket.Valid values:* true * false + * @var bool|null + */ + #[XmlElement(rename: 'Enable', type: 'bool')] + public ?bool $enable; + + /** + * TLS constructor. + * @param array|null $tlsVersions The TLS versions. + * @param bool|null $enable Specifies whether to enable TLS version management for the bucket. + */ + public function __construct( + ?array $tlsVersions = null, + ?bool $enable = null + ) + { + $this->tlsVersions = $tlsVersions; + $this->enable = $enable; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/Tag.php b/vendor/alibabacloud/oss-v2/src/Models/Tag.php new file mode 100644 index 0000000..bac1760 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Tag.php @@ -0,0 +1,40 @@ +key = $key; + $this->value = $value; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/TagSet.php b/vendor/alibabacloud/oss-v2/src/Models/TagSet.php new file mode 100644 index 0000000..c482913 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/TagSet.php @@ -0,0 +1,36 @@ +|null + */ + #[XmlElement(rename: 'Tag', type: Tag::class)] + public ?array $tags; + + /** + * TagSet constructor. + * @param array|null $tags The tags. + */ + public function __construct( + ?array $tags = null + ) + { + $this->tags = $tags; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/Tagging.php b/vendor/alibabacloud/oss-v2/src/Models/Tagging.php new file mode 100644 index 0000000..8f3a90e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Tagging.php @@ -0,0 +1,35 @@ +tagSet = $tagSet; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/TransferAccelerationConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/TransferAccelerationConfiguration.php new file mode 100644 index 0000000..6fe7e7a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/TransferAccelerationConfiguration.php @@ -0,0 +1,35 @@ +enabled = $enabled; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/TransferType.php b/vendor/alibabacloud/oss-v2/src/Models/TransferType.php new file mode 100644 index 0000000..07abd8e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/TransferType.php @@ -0,0 +1,16 @@ +|null + */ + #[XmlElement(rename: 'Type', type: 'string')] + public ?array $types; + + /** + * TransferTypes constructor. + * @param array|null $types The data transfer type that is used to transfer data in data replication. + */ + public function __construct( + ?array $types = null + ) + { + $this->types = $types; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/Upload.php b/vendor/alibabacloud/oss-v2/src/Models/Upload.php new file mode 100644 index 0000000..05cc71b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/Upload.php @@ -0,0 +1,56 @@ +key = $key; + $this->uploadId = $uploadId; + $this->initiated = $initiated; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UploadPart.php b/vendor/alibabacloud/oss-v2/src/Models/UploadPart.php new file mode 100644 index 0000000..78b0891 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UploadPart.php @@ -0,0 +1,47 @@ +partNumber = $partNumber; + $this->etag = $eTag ?? $etag; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyRequest.php b/vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyRequest.php new file mode 100644 index 0000000..e0e7cda --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyRequest.php @@ -0,0 +1,152 @@ +bucket = $bucket; + $this->key = $key; + $this->partNumber = $partNumber; + $this->uploadId = $uploadId; + $this->sourceBucket = $sourceBucket; + $this->sourceKey = $sourceKey; + $this->sourceVersionId = $sourceVersionId; + $this->sourceRange = $sourceRange; + $this->ifMatch = $ifMatch; + $this->ifNoneMatch = $ifNoneMatch; + $this->ifModifiedSince = $ifModifiedSince; + $this->ifUnmodifiedSince = $ifUnmodifiedSince; + $this->trafficLimit = $trafficLimit; + $this->requestPayer = $requestPayer; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyResult.php b/vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyResult.php new file mode 100644 index 0000000..c959bb2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UploadPartCopyResult.php @@ -0,0 +1,51 @@ +lastModified = $lastModified; + $this->etag = $etag; + $this->sourceVersionId = $sourceVersionId; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UploadPartRequest.php b/vendor/alibabacloud/oss-v2/src/Models/UploadPartRequest.php new file mode 100644 index 0000000..1868d80 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UploadPartRequest.php @@ -0,0 +1,193 @@ +bucket = $bucket; + $this->key = $key; + $this->partNumber = $partNumber; + $this->uploadId = $uploadId; + $this->contentLength = $contentLength; + $this->contentMd5 = $contentMd5; + $this->trafficLimit = $trafficLimit; + $this->requestPayer = $requestPayer; + $this->body = $body; + $this->progressFn = $progressFn; + $this->encryptionMultipartContext = $encryptionMultipartContext; + $this->clientSideEncryptionKey = $clientSideEncryptionKey; + $this->clientSideEncryptionStart = $clientSideEncryptionStart; + $this->clientSideEncryptionCekAlg = $clientSideEncryptionCekAlg; + $this->clientSideEncryptionWrapAlg = $clientSideEncryptionWrapAlg; + $this->clientSideEncryptionUnencryptedContentMd5 = $clientSideEncryptionUnencryptedContentMd5; + $this->clientSideEncryptionUnencryptedContentLength = $clientSideEncryptionUnencryptedContentLength; + $this->clientSideEncryptionPartSize = $clientSideEncryptionPartSize; + $this->clientSideEncryptionDataSize = $clientSideEncryptionDataSize; + parent::__construct($options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UploadPartResult.php b/vendor/alibabacloud/oss-v2/src/Models/UploadPartResult.php new file mode 100644 index 0000000..c2454b3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UploadPartResult.php @@ -0,0 +1,51 @@ +contentMd5 = $contentMd5; + $this->etag = $etag; + $this->hashCrc64 = $hashCrc64; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UploadResult.php b/vendor/alibabacloud/oss-v2/src/Models/UploadResult.php new file mode 100644 index 0000000..1694096 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UploadResult.php @@ -0,0 +1,74 @@ +uploadId = $uploadId; + $this->etag = $etag; + $this->hashCrc64 = $hashCrc64; + $this->versionId = $versionId; + $this->callbackResult = $callbackResult; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/UserDefinedLogFieldsConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/UserDefinedLogFieldsConfiguration.php new file mode 100644 index 0000000..6ce3877 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/UserDefinedLogFieldsConfiguration.php @@ -0,0 +1,46 @@ +paramSet = $paramSet; + $this->headerSet = $headerSet; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/VersioningConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/VersioningConfiguration.php new file mode 100644 index 0000000..312e8a5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/VersioningConfiguration.php @@ -0,0 +1,36 @@ +status = $status; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Models/WebsiteConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/WebsiteConfiguration.php new file mode 100644 index 0000000..efab51c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/WebsiteConfiguration.php @@ -0,0 +1,56 @@ +indexDocument = $indexDocument; + $this->errorDocument = $errorDocument; + $this->routingRules = $routingRules; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Models/WormConfiguration.php b/vendor/alibabacloud/oss-v2/src/Models/WormConfiguration.php new file mode 100644 index 0000000..0834f78 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Models/WormConfiguration.php @@ -0,0 +1,77 @@ +state = $state; + $this->retentionPeriodInDays = $retentionPeriodInDays; + $this->creationDate = $creationDate; + $this->expirationDate = $expirationDate; + $this->wormId = $wormId; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/OperationInput.php b/vendor/alibabacloud/oss-v2/src/OperationInput.php new file mode 100644 index 0000000..c0bb4fa --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/OperationInput.php @@ -0,0 +1,180 @@ + + */ + private $headers; + + /** + * @var array + */ + private $parameters; + + /** + * @var StreamInterface|null + */ + private $body; + + /** + * @var string|null + */ + private $bucket; + + /** + * @var string|null + */ + private $key; + + /** + * @var array + */ + private $opMetadata; + + public function __construct( + string $opName, + string $method, + ?array $headers = null, + ?array $parameters = null, + ?StreamInterface $body = null, + ?string $bucket = null, + ?string $key = null, + ?array $opMetadata = null + ) { + $this->opName = $opName; + $this->method = $method; + $this->headers = []; + if (\is_array($headers)) { + foreach ($headers as $k => $v) { + $this->headers[strtolower($k)] = (string) $v; + } + } + $this->parameters = $parameters ?? []; + $this->body = $body; + $this->bucket = $bucket; + $this->key = $key; + $this->opMetadata = $opMetadata ?? []; + } + + public function getOpName(): string + { + return $this->opName; + } + + public function setOpName(string $opName): void + { + $this->opName = $opName; + } + + public function getMethod(): string + { + return $this->method; + } + + public function setMethod(string $method): void + { + $this->method = $method; + } + + public function hasHeader(string $name): bool + { + return \array_key_exists(strtolower($name), $this->headers); + } + + public function setHeader(string $name, string $value): void + { + $this->headers[strtolower($name)] = $value; + } + + /** + * @return array + */ + public function getHeaders(): array + { + return $this->headers; + } + + public function hasParameter(string $name): bool + { + return \array_key_exists($name, $this->parameters); + } + + public function setParameter(string $name, string $value): void + { + $this->parameters[$name] = $value; + } + + /** + * @return array + */ + public function getParameters(): array + { + return $this->parameters; + } + + public function getBody(): ?StreamInterface + { + return $this->body; + } + + public function setBody(StreamInterface $body): void + { + $this->body = $body; + } + + public function getBucket(): ?string + { + return $this->bucket; + } + + public function setBucket(string $bucket): void + { + $this->bucket = $bucket; + } + + public function getKey(): ?string + { + return $this->key; + } + + public function setKey(string $key): void + { + $this->key = $key; + } + + public function hasOpMetadata(string $name): bool + { + return \array_key_exists($name, $this->opMetadata); + } + + public function setOpMetadata(string $name, $value): void + { + $this->opMetadata[$name] = $value; + } + + public function getOpMetadata(): array + { + return $this->opMetadata; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/OperationOutput.php b/vendor/alibabacloud/oss-v2/src/OperationOutput.php new file mode 100644 index 0000000..db1f392 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/OperationOutput.php @@ -0,0 +1,103 @@ + + */ + private $headers; + + /** + * @var StreamInterface + */ + private ?StreamInterface $body; + + /** + * @var OperationInput + */ + private ?OperationInput $opInput; + + /** + * @var array + */ + private $opMetadata; + + /** + * @var ResponseInterface + */ + private ?ResponseInterface $httpResponse; + + public function __construct( + ?string $status = null, + ?int $statusCode = null, + ?array $headers = null, + ?StreamInterface $body = null, + ?OperationInput $opInput = null, + ?array $opMetadata = null, + ?ResponseInterface $httpResponse = null + ) { + $this->status = $status ?? ''; + $this->statusCode = $statusCode ?? 0; + $this->headers = $headers ?? []; + $this->body = $body; + $this->opInput = $opInput; + $this->opMetadata = $opMetadata ?? []; + $this->httpResponse = $httpResponse; + } + + public function getStatus(): string + { + return $this->status; + } + + public function GetStatusCode(): int + { + return $this->statusCode; + } + + public function getHeaders(): array + { + return $this->headers; + } + + public function getBody(): ?StreamInterface + { + return $this->body; + } + + public function getOpInput(): ?OperationInput + { + return $this->opInput; + } + + public function getOpMetadata(): array + { + return $this->opMetadata; + } + + public function getHttpResponse(): ?ResponseInterface + { + return $this->httpResponse; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/ListBucketsPaginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/ListBucketsPaginator.php new file mode 100644 index 0000000..ae2805b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/ListBucketsPaginator.php @@ -0,0 +1,85 @@ + 10] + * @return \Generator + */ + public function iterPage(Models\ListBucketsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->listBuckets($req, $args); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->marker = $result->nextMarker; + } + } + + /** + * Iterates over the buckets asynchronously. + * @param Models\ListBucketsRequest $request The request for the ListBuckets operation. + * @param array $args accepts the following: + * - limit int: The maximum number of items in the response. + * For example, ['limit' => 10] + * @return \Generator<\GuzzleHttp\Promise\Promise> + */ + public function iterPageAsync(Models\ListBucketsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? $this->limit; + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $res = $this->client->listBucketsAsync($req, $args); + $resIsTruncated = false; + $resNextMarker = ''; + yield $res->then(function (Models\ListBucketsResult $result) use (&$resIsTruncated, &$resNextMarker) { + $resIsTruncated = $result->isTruncated ?? false; + $resNextMarker = $result->nextMarker; + return $result; + }); + + $firstPage = false; + $isTruncated = $resIsTruncated; + $req->marker = $resNextMarker; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/ListMultipartUploadsPaginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/ListMultipartUploadsPaginator.php new file mode 100644 index 0000000..d978f9c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/ListMultipartUploadsPaginator.php @@ -0,0 +1,89 @@ + 10] + * @return \Generator + */ + public function iterPage(Models\ListMultipartUploadsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxUploads = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->listMultipartUploads($req); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->uploadIdMarker = $result->nextUploadIdMarker; + $req->keyMarker = $result->nextKeyMarker; + } + } + + /** + * Iterates over the multipart uploads asynchronously. + * @param Models\ListMultipartUploadsRequest $request The request for the ListMultipartUploads operation. + * @param array $args accepts the following: + * - limit int: The maximum number of items in the response. + * For example, ['limit' => 10] + * @return \Generator<\GuzzleHttp\Promise\Promise> + */ + public function iterPageAsync(Models\ListMultipartUploadsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? $this->limit; + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxUploads = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $res = $this->client->listMultipartUploadsAsync($req, $args); + $resIsTruncated = false; + $resNextKeyMarker = ''; + $resNextUploadIdMarker = ''; + yield $res->then(function (Models\ListMultipartUploadsResult $result) use (&$resIsTruncated, &$resNextKeyMarker, &$resNextUploadIdMarker) { + $resIsTruncated = $result->isTruncated ?? false; + $resNextKeyMarker = $result->nextKeyMarker; + $resNextUploadIdMarker = $result->nextUploadIdMarker; + return $result; + }); + + $firstPage = false; + $isTruncated = $resIsTruncated; + $req->keyMarker = $resNextKeyMarker; + $req->uploadIdMarker = $resNextUploadIdMarker; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectVersionsPaginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectVersionsPaginator.php new file mode 100644 index 0000000..04fe11e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectVersionsPaginator.php @@ -0,0 +1,89 @@ + 10] + * @return \Generator + */ + public function iterPage(Models\ListObjectVersionsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->listObjectVersions($req, $args); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->keyMarker = $result->nextKeyMarker; + $req->versionIdMarker = $result->nextVersionIdMarker; + } + } + + /** + * Iterates over the object versions. + * @param Models\ListObjectVersionsRequest $request The request for the ListObjectVersions operation. + * @param array $args accepts the following: + * - limit int: The maximum number of items in the response. + * For example, ['limit' => 10] + * @return \Generator<\GuzzleHttp\Promise\Promise> + */ + public function iterPageAsync(Models\ListObjectVersionsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? $this->limit; + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $res = $this->client->listObjectVersionsAsync($req, $args); + $resIsTruncated = false; + $resKeyMarker = ''; + $resVersionIdMarker = ''; + yield $res->then(function (Models\ListObjectVersionsResult $result) use (&$resIsTruncated, &$resKeyMarker, &$resVersionIdMarker) { + $resIsTruncated = $result->isTruncated ?? false; + $resKeyMarker = $result->nextKeyMarker; + $resVersionIdMarker = $result->nextVersionIdMarker; + return $result; + }); + + $firstPage = false; + $isTruncated = $resIsTruncated; + $req->keyMarker = $resKeyMarker; + $req->versionIdMarker = $resVersionIdMarker; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsPaginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsPaginator.php new file mode 100644 index 0000000..53f075c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsPaginator.php @@ -0,0 +1,85 @@ + 10] + * @return \Generator + */ + public function iterPage(Models\ListObjectsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->listObjects($req, $args); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->marker = $result->nextMarker; + } + } + + /** + * Iterates over the objects asynchronously. + * @param Models\ListObjectsRequest $request The request for the ListObjects operation. + * @param array $args accepts the following: + * - limit int: The maximum number of items in the response. + * For example, ['limit' => 10] + * @return \Generator<\GuzzleHttp\Promise\Promise> + */ + public function iterPageAsync(Models\ListObjectsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? $this->limit; + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $res = $this->client->listObjectsAsync($req, $args); + $resIsTruncated = false; + $resNextMarker = ''; + yield $res->then(function (Models\ListObjectsResult $result) use (&$resIsTruncated, &$resNextMarker) { + $resIsTruncated = $result->isTruncated ?? false; + $resNextMarker = $result->nextMarker; + return $result; + }); + + $firstPage = false; + $isTruncated = $resIsTruncated; + $req->marker = $resNextMarker; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsV2Paginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsV2Paginator.php new file mode 100644 index 0000000..7ad78eb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/ListObjectsV2Paginator.php @@ -0,0 +1,85 @@ + 10] + * @return \Generator + */ + public function iterPage(Models\ListObjectsV2Request $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->listObjectsV2($req, $args); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->continuationToken = $result->nextContinuationToken; + } + } + + /** + * Iterates over the objects asynchronously. + * @param Models\ListObjectsV2Request $request The request for the ListObjectsV2 operation. + * @param array $args accepts the following: + * - limit int: The maximum number of items in the response. + * For example, ['limit' => 10] + * @return \Generator<\GuzzleHttp\Promise\Promise> + */ + public function iterPageAsync(Models\ListObjectsV2Request $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? $this->limit; + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxKeys = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $res = $this->client->listObjectsV2Async($req, $args); + $resIsTruncated = false; + $resNextContinuationToken = ''; + yield $res->then(function (Models\ListObjectsV2Result $result) use (&$resIsTruncated, &$resNextContinuationToken) { + $resIsTruncated = $result->isTruncated ?? false; + $resNextContinuationToken = $result->nextContinuationToken; + return $result; + }); + + $firstPage = false; + $isTruncated = $resIsTruncated; + $req->continuationToken = $resNextContinuationToken; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/ListPartsPaginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/ListPartsPaginator.php new file mode 100644 index 0000000..c260b60 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/ListPartsPaginator.php @@ -0,0 +1,85 @@ + 10] + * @return \Generator + */ + public function iterPage(Models\ListPartsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? ($this->limit ?? null); + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxParts = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $result = $this->client->listParts($req, $args); + yield $result; + + $firstPage = false; + $isTruncated = $result->isTruncated ?? false; + $req->partNumberMarker = $result->nextPartNumberMarker; + } + } + + /** + * Iterates over the parts asynchronously. + * @param Models\ListPartsRequest $request The request for the ListParts operation. + * @param array $args accepts the following: + * - limit int: The maximum number of items in the response. + * For example, ['limit' => 10] + * @return \Generator<\GuzzleHttp\Promise\Promise> + */ + public function iterPageAsync(Models\ListPartsRequest $request, array $args = []): \Generator + { + $limit = $args['limit'] ?? $this->limit; + if (isset($args['limit'])) { + unset($args['limit']); + } + $req = clone $request; + if (isset($limit) && is_int($limit)) { + $req->maxParts = $limit; + } + + $firstPage = true; + $isTruncated = false; + + while ($firstPage || $isTruncated) { + $res = $this->client->listPartsAsync($req, $args); + $resIsTruncated = false; + $resNextPartNumberMarker = ''; + yield $res->then(function (Models\ListPartsResult $result) use (&$resIsTruncated, &$resNextPartNumberMarker) { + $resIsTruncated = $result->isTruncated ?? false; + $resNextPartNumberMarker = $result->nextPartNumberMarker; + return $result; + }); + + $firstPage = false; + $isTruncated = $resIsTruncated; + $req->partNumberMarker = $resNextPartNumberMarker; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Paginator/Paginator.php b/vendor/alibabacloud/oss-v2/src/Paginator/Paginator.php new file mode 100644 index 0000000..7189b32 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Paginator/Paginator.php @@ -0,0 +1,40 @@ +client = $client; + if ( + isset($args['limit']) && + is_int($args['limit']) + ) { + $this->limit = $args['limit']; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/ProgressStream.php b/vendor/alibabacloud/oss-v2/src/ProgressStream.php new file mode 100644 index 0000000..e347c90 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/ProgressStream.php @@ -0,0 +1,73 @@ +stream = $stream; + $this->onProgress = $onProgress; + $this->lwritten = 0; + $this->written = 0; + $this->total = $total ?? -1; + } + + public function read($length): string + { + $data = $this->stream->read($length); + $n = strlen($data); + $this->written += $n; + if ($this->written >= $this->lwritten) { + call_user_func($this->onProgress, $n, $this->written, $this->total); + } + return $data; + } + + public function seek($offset, $whence = SEEK_SET): void + { + // Seeking arbitrarily is not supported. + if ($offset !== 0) { + throw new \InvalidArgumentException('Seeking arbitrarily is not supported for ProgressStream'); + } + + $this->lwritten = $this->written; + $this->written = 0; + $this->stream->seek($offset); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Retry/BackoffDelayerInterface.php b/vendor/alibabacloud/oss-v2/src/Retry/BackoffDelayerInterface.php new file mode 100644 index 0000000..1dde08c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Retry/BackoffDelayerInterface.php @@ -0,0 +1,17 @@ +baseDelay = $baseDelay; + $this->maxBackOff = $maxBackOff; + $value = log(PHP_FLOAT_MAX / $baseDelay, 2); + if (is_finite($value)) { + $intValue = (int)$value; + } else { + $intValue = 64; + } + $this->attemptCelling = $intValue; + } + + public function backoffDelay(int $attempt, ?\Throwable $reason): float + { + $attempt = min($attempt, $this->attemptCelling); + + $delay = min(2 ** $attempt * $this->baseDelay, $this->maxBackOff); + + $half = $delay / 2; + + $rand = mt_rand(0, 1000000) / 1000000; + + return $half + $rand * ($half + 1); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Retry/ErrorRetryableInterface.php b/vendor/alibabacloud/oss-v2/src/Retry/ErrorRetryableInterface.php new file mode 100644 index 0000000..a6a34b0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Retry/ErrorRetryableInterface.php @@ -0,0 +1,11 @@ +backoff = $backoff; + } + + /** + * Returns the delay that should be used before retrying the attempt. + * @param int $attempt current retry attempt + * @param \Throwable $reason the error meets + * @return float delay duration in second. + */ + public function backoffDelay(int $attempt, ?\Throwable $reason): float + { + return $this->backoff; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Retry/FullJitterBackoff.php b/vendor/alibabacloud/oss-v2/src/Retry/FullJitterBackoff.php new file mode 100644 index 0000000..5d76e20 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Retry/FullJitterBackoff.php @@ -0,0 +1,51 @@ +baseDelay = $baseDelay; + $this->maxBackOff = $maxBackOff; + $value = log(PHP_FLOAT_MAX / $baseDelay, 2); + if (is_finite($value)) { + $intValue = (int)$value; + } else { + $intValue = 64; + } + $this->attemptCelling = $intValue; + } + + public function backoffDelay(int $attempt, ?\Throwable $reason): float + { + $attempt = min($attempt, $this->attemptCelling); + + $delay = min(2 ** $attempt * $this->baseDelay, $this->maxBackOff); + + $rand = mt_rand(0, 1000000) / 1000000; + + return $delay * $rand; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Retry/HTTPStatusCodeRetryable.php b/vendor/alibabacloud/oss-v2/src/Retry/HTTPStatusCodeRetryable.php new file mode 100644 index 0000000..97656a3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Retry/HTTPStatusCodeRetryable.php @@ -0,0 +1,27 @@ +getStatusCode(); + if ($code >= 500) { + return true; + } + + if (in_array($code, self::$statusCode)) { + return true; + } + } + return false; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Retry/NopRetryer.php b/vendor/alibabacloud/oss-v2/src/Retry/NopRetryer.php new file mode 100644 index 0000000..5039595 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Retry/NopRetryer.php @@ -0,0 +1,23 @@ +getErrorCode(); + if (in_array($code, self::$errorCodes)) { + return true; + } + } + return false; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Retry/StandardRetryer.php b/vendor/alibabacloud/oss-v2/src/Retry/StandardRetryer.php new file mode 100644 index 0000000..9cc9ba1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Retry/StandardRetryer.php @@ -0,0 +1,64 @@ +maxAttempts = $maxAttempts ?? Defaults::MAX_ATTEMPTS; + $this->maxBackoff = $maxBackoff ?? Defaults::MAX_BACKOFF_S; + $this->baseDelay = $baseDelay ?? Defaults::BASE_DELAY_S; + $this->errorRetryables = $errorRetryables ?? [ + new HTTPStatusCodeRetryable(), + new ServiceErrorCodeRetryable(), + new ClientErrorRetryable(), + ]; + $this->backoffDelayer = $backoffDelayer ?? + new FullJitterBackoff($this->baseDelay, $this->maxBackoff); + } + + + public function isErrorRetryable(\Throwable $reason): bool + { + foreach ($this->errorRetryables as $h) { + if ($h->isErrorRetryable($reason)) { + return true; + } + } + return false; + } + + public function getMaxAttempts(): int + { + return $this->maxAttempts; + } + + public function retryDelay(int $attempt, ?\Throwable $reason): float + { + return $this->backoffDelayer->backoffDelay($attempt, $reason); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/RetryMiddleware.php b/vendor/alibabacloud/oss-v2/src/RetryMiddleware.php new file mode 100644 index 0000000..c402ed7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/RetryMiddleware.php @@ -0,0 +1,138 @@ +decider = $decider; + $this->nextHandler = $nextHandler; + $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; + } + + /** + * Default exponential backoff delay function. + * + * @param int $retries + * @param array $options + * @return int milliseconds. + */ + public static function exponentialDelay(int $retries, array $options): int + { + return (int)2 ** ($retries - 1) * 1000; + } + + /** + * @param RequestInterface $request + * @param array $options + * @return PromiseInterface + */ + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + if (!isset($options['retries'])) { + $options['retries'] = 0; + } + + $fn = $this->nextHandler; + + return $fn($request, $options) + ->then( + $this->onFulfilled($request, $options), + $this->onRejected($request, $options) + ); + } + + /** + * Execute fulfilled closure + * @param RequestInterface $request + * @param array $options + * @return callable + */ + private function onFulfilled(RequestInterface $request, array $options): callable + { + return function ($value) use ($request, $options) { + return $value; + }; + } + + /** + * Execute rejected closure + * @param RequestInterface $req + * @param array $options + * @return callable + */ + private function onRejected(RequestInterface $req, array $options): callable + { + return function ($reason) use ($req, $options) { + if (!($this->decider)( + $options['retries'], + $req, + $reason, + $options + )) { + return P\Create::rejectionFor($reason); + } + + return $this->doRetry($req, $options); + }; + } + + /** + * @param RequestInterface $request + * @param array $options + * @param ResponseInterface|null $response + * @return PromiseInterface + */ + private function doRetry(RequestInterface $request, array $options, ?ResponseInterface $response = null): PromiseInterface + { + $options['delay'] = ($this->delay)(++$options['retries'], $options); + + return $this($request, $options); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Serializer.php b/vendor/alibabacloud/oss-v2/src/Serializer.php new file mode 100644 index 0000000..a10677c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Serializer.php @@ -0,0 +1,265 @@ +openMemory(); + $writer->startDocument('1.0', 'UTF-8'); + self::serializeXmlModel($writer, $root, $model); + $writer->endDocument(); + return $writer->flush(); + } + + private static function serializeXmlAny(\XMLWriter $writer, string $name, $value, ?string $format) + { + if ($value instanceof Model) { + self::serializeXmlModel($writer, $name, $value); + return; + } + + if ($value instanceof \DateTimeInterface) { + $stamp = $value->getTimestamp(); + if ($format == null) { + $format = 'iso8601'; + } + switch ($format) { + case 'httptime': + $tval = gmdate('D, d M Y H:i:s \G\M\T', $stamp); + break; + case 'unixtime': + $tval = (string)$stamp; + break; + default: + $tval = gmdate('Y-m-d\TH:i:s\Z', $stamp); + } + $writer->startElement($name); + $writer->text($tval); + $writer->endElement(); + return; + } + + $type = \gettype($value); + + // bool + if (\in_array($type, ['bool', 'boolean'])) { + $writer->startElement($name); + $writer->text($value === true ? 'true' : 'false'); + $writer->endElement(); + return; + } + + // other primitive type + if (\in_array($type, ['int', 'integer', 'float', 'double', 'string'])) { + $writer->startElement($name); + $writer->text((string)$value); + $writer->endElement(); + return; + } + + + // enum, since 8.1 + // TODO + + throw new SerializationExecption("Unsupport type " . \gettype($value)); + } + + private static function serializeXmlModel(\XMLWriter $writer, string $name, Model $value): void + { + $ro = new \ReflectionObject($value); + + if (empty($name)) { + $annotation = Functions::getXmlRootAnnotation($ro); + if ($annotation != null) { + $name = $annotation->name; + } + if (empty($name)) { + $name = \get_class($value); + if ($pos = \strrpos($name, '\\')) { + $name = \substr($name, $pos + 1); + } + } + } + + // start element + $writer->startElement($name); + + // children element + foreach ($ro->getProperties() as $property) { + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $val = $property->getValue($value); + if (!isset($val)) { + continue; + } + + $annotation = Functions::getXmlElementAnnotation($property); + if ($annotation == null) { + continue; + } + + if (is_array($val)) { + foreach ($val as $vval) { + self::serializeXmlAny($writer, $annotation->rename, $vval, $annotation->format); + } + } else { + self::serializeXmlAny($writer, $annotation->rename, $val, $annotation->format); + } + } + + // end element + $writer->endElement(); + } + + public static function serializeInput(RequestModel $request, OperationInput $input, array $customSerializer = []): OperationInput + { + $ro = new \ReflectionObject($request); + + //headers + $hp = $ro->getProperty('headers'); + if (PHP_VERSION_ID < 80100) { + $hp->setAccessible(true); + } + $h = $hp->getValue($request); + if (is_array($h)) { + foreach ($h as $key => $value) { + $input->setHeader($key, (string)$value); + } + } + + //parameters + $pp = $ro->getProperty('parameters'); + if (PHP_VERSION_ID < 80100) { + $pp->setAccessible(true); + } + $p = $pp->getValue($request); + if (is_array($p)) { + foreach ($p as $key => $value) { + $input->setParameter($key, (string) $value); + } + } + + //payload + $pd = $ro->getProperty('payload'); + if (PHP_VERSION_ID < 80100) { + $pd->setAccessible(true); + } + $payload = $pd->getValue($request); + if ($payload instanceof StreamInterface) { + $input->setBody($payload); + } + + // all properties in request + foreach ($ro->getProperties() as $property) { + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $val = $property->getValue($request); + if (!isset($val)) { + if (Functions::isRequiredProperty($property)) { + throw new \InvalidArgumentException('missing required field, ' . $property->getName() . '.'); + } + continue; + } + + $annotation = Functions::getTagAnnotation($property); + if ($annotation == null) { + continue; + } + + switch ($annotation->position) { + case 'query': + $input->setParameter( + $annotation->rename, + self::castToString($val, $annotation->format) + ); + break; + case 'header': + if ($annotation->format === 'usermeta' && \is_array($val)) { + //user metadata + foreach ($val as $k => $v) { + $input->setHeader( + (string)$annotation->rename . $k, + (string)$v + ); + } + } else { + $input->setHeader( + $annotation->rename, + self::castToString($val, $annotation->format) + ); + } + break; + case 'body': + $body = $val; + if ($annotation->type === 'xml') { + $body = self::serializeXml($val, $annotation->rename); + } + $input->setBody(Utils::streamFor($body)); + break; + }; + } + + // custom serializer + foreach ($customSerializer as $serializer) { + if (\is_callable($serializer)) { + $serializer($request, $input); + } else { + call_user_func($serializer, $request, $input); + } + } + + return $input; + } + + private static function castToString($value, ?string $format): string + { + if ($value instanceof \DateTimeInterface) { + $stamp = $value->getTimestamp(); + if ($format == null) { + $format = 'iso8601'; + } + switch ($format) { + case 'httptime': + $tval = gmdate('D, d M Y H:i:s \G\M\T', $stamp); + break; + case 'unixtime': + $tval = (string)$stamp; + break; + default: + $tval = gmdate('Y-m-d\TH:i:s\Z', $stamp); + } + + return $tval; + } + + $type = \gettype($value); + + // bool + if (\in_array($type, ['bool', 'boolean'])) { + return $value === true ? 'true' : 'false'; + } + + // other primitive type + if (\in_array($type, ['int', 'integer', 'float', 'double', 'string'])) { + return (string)$value; + } + + throw new SerializationExecption("Unsupport type " . \gettype($value)); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Signer/NopSigner.php b/vendor/alibabacloud/oss-v2/src/Signer/NopSigner.php new file mode 100644 index 0000000..a71e22a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Signer/NopSigner.php @@ -0,0 +1,13 @@ +credentials === null || !$signingCtx->credentials->hasKeys()) { + throw new \InvalidArgumentException("SigningContext Credentials is null or empty."); + } + + if ($signingCtx->request === null) { + throw new \InvalidArgumentException("SigningContext Request is null."); + } + if ($signingCtx->authMethodQuery) { + $this->authQuery($signingCtx); + } else { + $this->authHeader($signingCtx); + } + } + + + /** + * @param array $list + * @param string $key + * @return bool + */ + private function isSubResource(array $list, string $key): bool + { + return in_array($key, $list); + } + + /** + * @param string $date + * @param SigningContext $signingCtx + * @return string + */ + private function calcStringToSign(string $date, SigningContext $signingCtx): string + { + $request = $signingCtx->request; + $contentMd5 = $request->getHeaderLine(self::CONTENT_MD5_HEADER); + $contentType = $request->getHeaderLine(self::CONTENT_TYPE_HEADER); + + // CanonicalizedOSSHeaders + $headers = []; + foreach ($request->getHeaders() as $k => $v) { + $lowerCaseKey = strtolower((string)$k); + if (strncmp($lowerCaseKey, self::OSS_HEADER_PREFIX, 6) == 0) { + $headers[] = $lowerCaseKey; + } + } + sort($headers); + $headerItems = []; + foreach ($headers as $k) { + $headerValues = array_map('trim', $request->getHeader($k)); + $headerItems[] = $k . ':' . implode(',', $headerValues) . "\n"; + } + $canonicalizedOSSHeaders = implode('', $headerItems); + + // CanonicalizedResource + $query = []; + parse_str($request->getUri()->getQuery(), $query); + $params = []; + foreach ($query as $k => $v) { + if (in_array($k, self::$requiredSignedParametersMap) || + strncmp($k, self::OSS_HEADER_PREFIX, 6) == 0 || + $this->isSubResource($signingCtx->subResource, $k)) { + $params[] = ($v !== "") ? "$k=$v" : $k; + } + } + sort($params); + $subResource = implode('&', $params); + $canonicalizedResource = '/' . ($signingCtx->bucket ? $signingCtx->bucket . '/' : '') . + ($signingCtx->key ? $signingCtx->key : '') . + ($subResource ? '?' . $subResource : ''); + + // String to Sign + return $request->getMethod() . "\n" . + $contentMd5 . "\n" . + $contentType . "\n" . + $date . "\n" . + $canonicalizedOSSHeaders . + $canonicalizedResource; + } + + + /** + * @param SigningContext $signingCtx + * @throws \Exception + */ + public function authHeader(SigningContext $signingCtx): void + { + $request = $signingCtx->request; + $cred = $signingCtx->credentials; + + // Date + if (!isset($signingCtx->time)) { + $signingCtx->time = (new DateTime('now', new DateTimeZone('UTC')))->modify('+' . $signingCtx->clockOffset . 'seconds'); + } + + $datetime = $signingCtx->time->format("D, d M Y H:i:s \G\M\T"); + $request = $request->withHeader(self::DATE_HEADER, $datetime); + + // Credentials information + if ((string)$cred->getSecurityToken() !== '') { + $request = $request->withHeader(self::SECURITY_TOKEN_HEADER, $cred->getSecurityToken()); + } + + // StringToSign + $stringToSign = $this->calcStringToSign($datetime, $signingCtx); + $signingCtx->stringToSign = $stringToSign; + + // Signature + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $cred->getAccessKeySecret(), true)); + + // Authorization header + $request = $request->withHeader(self::AUTHORIZATION_HEADER, sprintf("OSS %s:%s", $cred->getAccessKeyId(), $signature)); + $signingCtx->request = $request; + } + + + /** + * @param SigningContext $signingCtx + * @throws \Exception + */ + public function authQuery(SigningContext $signingCtx): void + { + $request = $signingCtx->request; + $cred = $signingCtx->credentials; + + // Date + if (!isset($signingCtx->time)) { + $signingCtx->time = (new DateTime('now', new DateTimeZone('UTC')))->modify('+' . self::DEFAULT_EXPIRES_DURATION . 'seconds'); + } + $datetime = (string)$signingCtx->time->getTimestamp(); + + // Credentials information + $query = Query::parse($request->getUri()->getQuery()); + if ((string)$cred->getSecurityToken() !== '') { + $query[self::SECURITY_TOKEN_QUERY] = $cred->getSecurityToken(); + $request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + $signingCtx->request = $request; + } + + // StringToSign + $stringToSign = $this->calcStringToSign($datetime, $signingCtx); + $signingCtx->stringToSign = $stringToSign; + + // Signature + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $cred->getAccessKeySecret(), true)); + + // Authorization query + $query[self::EXPIRES_QUERY] = $datetime; + $query[self::ACCESS_KEY_ID_QUERY] = $cred->getAccessKeyId(); + $query[self::SIGNATURE_QUERY] = $signature; + ksort($query); + $request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + $signingCtx->request = $request; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Signer/SignerV4.php b/vendor/alibabacloud/oss-v2/src/Signer/SignerV4.php new file mode 100644 index 0000000..45c5e48 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Signer/SignerV4.php @@ -0,0 +1,317 @@ +credentials === null || !$signingCtx->credentials->hasKeys()) { + throw new \InvalidArgumentException("SigningContext Credentials is null or empty."); + } + + if (empty($signingCtx->region)) { + throw new \InvalidArgumentException("SigningContext Region is empty."); + } + + if ($signingCtx->request === null) { + throw new \InvalidArgumentException("SigningContext Request is null."); + } + + if ($signingCtx->authMethodQuery) { + $this->authQuery($signingCtx); + } else { + $this->authHeader($signingCtx); + } + } + + /** + * @param SigningContext $signingCtx + * @throws \Exception + */ + public function authQuery(SigningContext $signingCtx): void + { + $request = $signingCtx->request; + $cred = $signingCtx->credentials; + + // Date + $now = new DateTime('now', new DateTimeZone('UTC')); + if (!isset($signingCtx->time)) { + $signingCtx->time = clone $now; + $signingCtx->time->modify('+' . self::DEFAULT_EXPIRES_DURATION . 'seconds'); + } + + if (isset($signingCtx->signTime)) { + $now = $signingCtx->signTime; + } + $datetime = $now->format("Ymd\THis\Z"); + $date = $now->format("Ymd"); + $expires = $signingCtx->time->getTimestamp() - $now->getTimestamp(); + + // Scope + $region = $signingCtx->region; + $product = $signingCtx->product; + $scope = $this->buildScope($date, $region, $product); + $additionalHeaders = $this->getCommonAdditionalHeaders($request->getHeaders(), $signingCtx->additionalHeaders); + // Credentials information + $query = Query::parse($request->getUri()->getQuery()); + if ((string)$cred->getSecurityToken() !== '') { + $query['x-oss-security-token'] = $cred->getSecurityToken(); + } + $query['x-oss-signature-version'] = self::ALGORITHM_V4; + $query['x-oss-date'] = $datetime; + $query['x-oss-expires'] = $expires; + $query['x-oss-credential'] = sprintf("%s/%s", $cred->getAccessKeyId(), $scope); + if (count($additionalHeaders) > 0) { + $query['x-oss-additional-headers'] = implode(';', $additionalHeaders); + } + ksort($query); + $signingCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + // CanonicalRequest + $canonicalRequest = $this->calcCanonicalRequest($signingCtx, $additionalHeaders); +// printf("canonicalRequest:%s" . PHP_EOL, $canonicalRequest); + // StringToSign + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); + $signingCtx->stringToSign = $stringToSign; +// printf("stringToSign:%s" . PHP_EOL, $stringToSign); + // Signature + $signature = $this->calcSignature($cred->getAccessKeySecret(), $date, $region, $product, $stringToSign); +// printf("signature:%s" . PHP_EOL, $signature); + // Authorization query + $query['x-oss-signature'] = $signature; + ksort($query); + $request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + $signingCtx->request = $request; + } + + /** + * @param SigningContext $signingCtx + * @throws \Exception + */ + public function authHeader(SigningContext $signingCtx): void + { + $request = $signingCtx->request; + $cred = $signingCtx->credentials; + + // Date + if (!isset($signingCtx->time)) { + $signingCtx->time = (new DateTime('now', new DateTimeZone('UTC')))->modify('+' . $signingCtx->clockOffset . 'seconds'); + } + $datetime = $signingCtx->time->format("Ymd\THis\Z"); + $dateGmt = $signingCtx->time->format("D, d M Y H:i:s \G\M\T"); + $date = $signingCtx->time->format("Ymd"); + $request = $request->withHeader(self::OSS_DATE_HEADER, $datetime) + ->withHeader(self::DATE_HEADER, $dateGmt); + + // Credentials information + if ($cred->getSecurityToken() != '') { + $request = $request->withHeader(self::SECURITY_TOKEN_HEADER, $cred->getSecurityToken()); + } + + if ($request->getHeaderLine(self::CONTENT_SHA256_HEADER) == "") { + $request = $request->withHeader(self::CONTENT_SHA256_HEADER, self::UNSIGNED_PAYLOAD); + } + // Scope + $region = $signingCtx->region; + $product = $signingCtx->product; + $scope = $this->buildScope($date, $region, $product); + $additionalHeaders = $this->getCommonAdditionalHeaders($request->getHeaders(), $signingCtx->additionalHeaders); + + // CanonicalRequest + $signingCtx->request = $request; + $canonicalRequest = $this->calcCanonicalRequest($signingCtx, $additionalHeaders); +// printf("canonicalRequest:%s" . PHP_EOL, $canonicalRequest); + // StringToSign + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); + $signingCtx->stringToSign = $stringToSign; +// printf("stringToSign:%s" . PHP_EOL, $stringToSign); + // Signature + $signature = $this->calcSignature($cred->getAccessKeySecret(), $date, $region, $product, $stringToSign); +// printf("signature:%s" . PHP_EOL, $signature); + + // credential + $buf = 'OSS4-HMAC-SHA256 Credential='; + $buf .= $cred->getAccessKeyId() . '/' . $scope; + if (count($additionalHeaders) > 0) { + $buf .= ',AdditionalHeaders=' . implode(';', $additionalHeaders); + } + $buf .= ",Signature=$signature"; + $request = $request->withHeader(self::AUTHORIZATION_HEADER, $buf); + $signingCtx->request = $request; + } + + /** + * @param string $h + * @return bool + */ + public function isSignedHeader(string $h): bool + { + $lowerCaseKey = strtolower($h); + return (strncmp($lowerCaseKey, self::OSS_HEADER_PREFIX, 6) == 0) || + ($lowerCaseKey === "content-type") || + ($lowerCaseKey === "content-md5"); + } + + /** + * @param string $datetime + * @param string $scope + * @param string $canonicalRequest + * @return string + */ + private function calcStringToSign(string $datetime, string $scope, string $canonicalRequest): string + { + $hashValue = hash('sha256', $canonicalRequest); + return "OSS4-HMAC-SHA256\n" . + $datetime . "\n" . + $scope . "\n" . + $hashValue; + } + + + /** + * @param string $sk + * @param string $date + * @param string $region + * @param string $product + * @param string $stringToSign + * @return string + */ + private function calcSignature(string $sk, string $date, string $region, string $product, string $stringToSign) + { + $signingKey = "aliyun_v4" . $sk; + $h1Key = hash_hmac('sha256', $date, $signingKey, true); + $h2Key = hash_hmac('sha256', $region, $h1Key, true); + $h3Key = hash_hmac('sha256', $product, $h2Key, true); + $h4Key = hash_hmac('sha256', 'aliyun_v4_request', $h3Key, true); + $signatureBinary = hash_hmac('sha256', $stringToSign, $h4Key, true); + return bin2hex($signatureBinary); + } + + /** + * @param array $headers + * @param array $additionalHeaders + * @return array + */ + private function getCommonAdditionalHeaders(array $headers, array $additionalHeaders): array + { + $addHeaders = array(); + foreach ($additionalHeaders as $key) { + $lowk = strtolower($key); + if ($this->isSignedHeader($lowk)) { + continue; + } + $addHeaders[$lowk] = ''; + } + $keys = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower((string)$key); + if (isset($addHeaders[$lowk])) { + $keys[$lowk] = ''; + } + } + ksort($keys); + return array_keys($keys); + } + + /** + * @param $date string + * @param $region string + * @param $product string + * @return string + */ + private function buildScope(string $date, string $region, string $product): string + { + return sprintf("%s/%s/%s/aliyun_v4_request", $date, $region, $product); + } + + + /** + * @param SigningContext $signingCtx + * @param array $additionalHeaders + * @return string + */ + private function calcCanonicalRequest(SigningContext $signingCtx, array $additionalHeaders): string + { + $request = $signingCtx->request; + // Canonical Request + // HTTP Verb + "\n" + + // Canonical URI + "\n" + + // Canonical Query String + "\n" + + // Canonical Headers + "\n" + + // Additional Headers + "\n" + + // Hashed PayLoad + + // Canonical Uri + $uri = "/"; + if (isset($signingCtx->bucket)) { + $uri .= $signingCtx->bucket . "/"; + } + if (isset($signingCtx->key)) { + $uri .= $signingCtx->key; + } + $canonicalUri = str_replace(array('%2F'), array('/'), rawurlencode($uri)); + // Canonical Query + $query = Query::parse($request->getUri()->getQuery(), false); + ksort($query); + $canonicalQuery = ''; + foreach ($query as $k => $v) { + if (!empty($canonicalQuery)) { + $canonicalQuery .= '&'; + } + $canonicalQuery .= $k; + if ($v != '') { + $canonicalQuery .= '=' . $v; + } + } + // Canonical Headers + $headers = []; + $addHeadersMap = array_map('strtolower', $additionalHeaders); + foreach (array_keys($request->getHeaders()) as $k) { + $lowk = strtolower((string)$k); + if ($this->isSignedHeader($lowk)) { + $headers[] = $lowk; + } elseif (in_array($lowk, $addHeadersMap, true)) { + $headers[] = $lowk; + } + } + sort($headers); + $canonicalHeaders = ''; + foreach ($headers as $k) { + $headerValues = array_map('trim', $request->getHeader($k)); + $canonicalHeaders .= $k . ':' . implode(',', $headerValues) . "\n"; + } + + // Additional Headers + $canonicalAdditionalHeaders = implode(';', $additionalHeaders); + // Assuming unsignedPayload is defined somewhere in the class + $hashPayload = self::UNSIGNED_PAYLOAD; + if (!empty($request->getHeaderLine(self::CONTENT_SHA256_HEADER))) { + $hashPayload = $request->getHeaderLine(self::CONTENT_SHA256_HEADER); + } + + // Build Canonical Request + $canonicalRequest = + $request->getMethod() . "\n" . + $canonicalUri . "\n" . + $canonicalQuery . "\n" . + $canonicalHeaders . "\n" . + $canonicalAdditionalHeaders . "\n" . + $hashPayload; + + return $canonicalRequest; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Signer/SigningContext.php b/vendor/alibabacloud/oss-v2/src/Signer/SigningContext.php new file mode 100644 index 0000000..3e11987 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Signer/SigningContext.php @@ -0,0 +1,115 @@ +product = $product; + $this->region = $region; + $this->bucket = $bucket; + $this->key = $key; + $this->request = $request; + $this->subResource = $subResource; + $this->additionalHeaders = $additionalHeaders; + $this->credentials = $credentials; + $this->time = $time; + $this->signedHeaders = $signedHeaders; + $this->stringToSign = $stringToSign; + $this->authMethodQuery = $authMethodQuery; + $this->clockOffset = $clockOffset; + } +} + diff --git a/vendor/alibabacloud/oss-v2/src/SinkStreamWrapper.php b/vendor/alibabacloud/oss-v2/src/SinkStreamWrapper.php new file mode 100644 index 0000000..0bb8cd8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/SinkStreamWrapper.php @@ -0,0 +1,91 @@ +stream = $stream; + $this->fromFilepath = $fromFilepath; + } + + public function write($string): int + { + if ($this->isMem) { + $this->memString .= $string; + return strlen($string); + } + return $this->stream->write($string); + } + + public function on_headers(\Psr\Http\Message\ResponseInterface $response) + { + if (method_exists($this->stream, 'on_headers')) { + call_user_func([$this->stream, 'on_headers'], $response); + } + + if ($response->getStatusCode() >= 400) { + $this->isMem = true; + } + } + + public function resetMemState(): void + { + $this->memString = ''; + $this->isMem = false; + } + + public function getMemContent(): string + { + return $this->memString; + } + + public function isFromFilepath(): bool + { + return $this->fromFilepath; + } + + public function unwrap(): StreamInterface + { + return $this->stream; + } + + /** + * Create a new stream based on the sink. + * if $sink type is string, it's filepath + * @return SinkStreamWrapper + */ + public static function sinkFor($sink): SinkStreamWrapper + { + $fromFilepath = \is_string($sink); + $stream = $fromFilepath ? + new LazyOpenStream($sink, 'w+') : Utils::streamFor($sink); + return new SinkStreamWrapper($stream, $fromFilepath); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/AccessPoint.php b/vendor/alibabacloud/oss-v2/src/Transform/AccessPoint.php new file mode 100644 index 0000000..d1eea4b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/AccessPoint.php @@ -0,0 +1,260 @@ + 'application/xml'], + ); + $input->setParameter('accessPoint', ''); + if (isset($request->bucket)) { + $input->setBucket($request->bucket); + } + $input->setOpMetadata('sub-resource', ['accessPoint',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListAccessPointsResult + */ + public static function toListAccessPoints(OperationOutput $output): Models\ListAccessPointsResult + { + $result = new Models\ListAccessPointsResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetAccessPointRequest $request + * @return OperationInput + */ + public static function fromGetAccessPoint(Models\GetAccessPointRequest $request): OperationInput + { + $input = new OperationInput( + 'GetAccessPoint', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPoint', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPoint',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetAccessPointResult + */ + public static function toGetAccessPoint(OperationOutput $output): Models\GetAccessPointResult + { + $result = new Models\GetAccessPointResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetAccessPointPolicyRequest $request + * @return OperationInput + */ + public static function fromGetAccessPointPolicy(Models\GetAccessPointPolicyRequest $request): OperationInput + { + $input = new OperationInput( + 'GetAccessPointPolicy', + 'GET', + ); + $input->setParameter('accessPointPolicy', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointPolicy',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetAccessPointPolicyResult + */ + public static function toGetAccessPointPolicy(OperationOutput $output): Models\GetAccessPointPolicyResult + { + $result = new Models\GetAccessPointPolicyResult(); + if ($output->getBody() !== null) { + $result->body = $output->getBody()->getContents(); + } + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeleteAccessPointPolicyRequest $request + * @return OperationInput + */ + public static function fromDeleteAccessPointPolicy(Models\DeleteAccessPointPolicyRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteAccessPointPolicy', + 'DELETE', + ); + $input->setParameter('accessPointPolicy', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointPolicy',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteAccessPointPolicyResult + */ + public static function toDeleteAccessPointPolicy(OperationOutput $output): Models\DeleteAccessPointPolicyResult + { + $result = new Models\DeleteAccessPointPolicyResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\PutAccessPointPolicyRequest $request + * @return OperationInput + */ + public static function fromPutAccessPointPolicy(Models\PutAccessPointPolicyRequest $request): OperationInput + { + $input = new OperationInput( + 'PutAccessPointPolicy', + 'PUT', + ); + $input->setParameter('accessPointPolicy', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPointPolicy',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutAccessPointPolicyResult + */ + public static function toPutAccessPointPolicy(OperationOutput $output): Models\PutAccessPointPolicyResult + { + $result = new Models\PutAccessPointPolicyResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeleteAccessPointRequest $request + * @return OperationInput + */ + public static function fromDeleteAccessPoint(Models\DeleteAccessPointRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteAccessPoint', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPoint', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPoint',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteAccessPointResult + */ + public static function toDeleteAccessPoint(OperationOutput $output): Models\DeleteAccessPointResult + { + $result = new Models\DeleteAccessPointResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\CreateAccessPointRequest $request + * @return OperationInput + */ + public static function fromCreateAccessPoint(Models\CreateAccessPointRequest $request): OperationInput + { + $input = new OperationInput( + 'CreateAccessPoint', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessPoint', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['accessPoint',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CreateAccessPointResult + */ + public static function toCreateAccessPoint(OperationOutput $output): Models\CreateAccessPointResult + { + $result = new Models\CreateAccessPointResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketAccessMonitor.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketAccessMonitor.php new file mode 100644 index 0000000..7cb594a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketAccessMonitor.php @@ -0,0 +1,83 @@ + 'application/xml'] + ); + $input->setParameter('accessmonitor', ''); + $input->setBucket($request->bucket ?? ''); + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketAccessMonitorResult + */ + public static function toPutBucketAccessMonitor(OperationOutput $output): Models\PutBucketAccessMonitorResult + { + $result = new Models\PutBucketAccessMonitorResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketAccessMonitorRequest $request + * @return OperationInput + */ + public static function fromGetBucketAccessMonitor(Models\GetBucketAccessMonitorRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketAccessMonitor', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('accessmonitor', ''); + $input->setBucket($request->bucket ?? ''); + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketAccessMonitorResult + */ + public static function toGetBucketAccessMonitor(OperationOutput $output): Models\GetBucketAccessMonitorResult + { + $result = new Models\GetBucketAccessMonitorResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketArchiveDirectRead.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketArchiveDirectRead.php new file mode 100644 index 0000000..3e33bbb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketArchiveDirectRead.php @@ -0,0 +1,87 @@ + 'application/xml'] + ); + $input->setParameter('bucketArchiveDirectRead', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['bucketArchiveDirectRead',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketArchiveDirectReadResult + */ + public static function toGetBucketArchiveDirectRead(OperationOutput $output): Models\GetBucketArchiveDirectReadResult + { + $result = new Models\GetBucketArchiveDirectReadResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutBucketArchiveDirectReadRequest $request + * @return OperationInput + */ + public static function fromPutBucketArchiveDirectRead(Models\PutBucketArchiveDirectReadRequest $request): OperationInput + { + $input = new OperationInput( + 'PutBucketArchiveDirectRead', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('bucketArchiveDirectRead', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['bucketArchiveDirectRead',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketArchiveDirectReadResult + */ + public static function toPutBucketArchiveDirectRead(OperationOutput $output): Models\PutBucketArchiveDirectReadResult + { + $result = new Models\PutBucketArchiveDirectReadResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketBasic.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketBasic.php new file mode 100644 index 0000000..cfc9356 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketBasic.php @@ -0,0 +1,958 @@ +bucket); + + $input = new OperationInput( + 'PutBucket', + 'PUT', + ['Content-Type' => 'application/xml'], + ); + + $input->setBucket($request->bucket); + + $customSerializer = [ + static function (Models\PutBucketRequest $request, OperationInput $input) { + if (isset($request->acl)) { + $input->setHeader('x-oss-acl', $request->acl); + } + + if (isset($request->resourceGroupId)) { + $input->setHeader('x-oss-resource-group-id', $request->resourceGroupId); + } + + if (isset($request->createBucketConfiguration)) { + $xml = new \SimpleXMLElement(''); + if (isset($request->createBucketConfiguration->storageClass)) { + $xml->addChild('StorageClass', $request->createBucketConfiguration->storageClass); + } + if (isset($request->createBucketConfiguration->dataRedundancyType)) { + $xml->addChild('DataRedundancyType', $request->createBucketConfiguration->dataRedundancyType); + } + $input->setBody(Utils::streamFor($xml->asXML())); + } + }, + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketResult + */ + public static function toPutBucket(OperationOutput $output): Models\PutBucketResult + { + $result = new Models\PutBucketResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeleteBucketRequest $request + * @return OperationInput + */ + public static function fromDeleteBucket(Models\DeleteBucketRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'DeleteBucket', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setBucket($request->bucket); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketResult + */ + public static function toDeleteBucket(OperationOutput $output): Models\DeleteBucketResult + { + $result = new Models\DeleteBucketResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\PutBucketAclRequest $request + * @return OperationInput + */ + public static function fromPutBucketAcl(Models\PutBucketAclRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('acl', $request->acl); + + $input = new OperationInput( + 'PutBucketAcl', + 'PUT', + ['Content-Type' => 'application/xml'], + ['acl' => ''] + ); + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['acl']); + + $customSerializer = [ + static function (Models\PutBucketAclRequest $request, OperationInput $input) { + if (isset($request->acl)) { + $input->setHeader('x-oss-acl', $request->acl); + } + }, + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketAclResult + */ + public static function toPutBucketAcl(OperationOutput $output): Models\PutBucketAclResult + { + $result = new Models\PutBucketAclResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketAclRequest $request + * @return OperationInput + */ + public static function fromGetBucketAcl(Models\GetBucketAclRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'GetBucketAcl', + 'GET', + ['Content-Type' => 'application/xml'], + ['acl' => ''] + ); + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['acl']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketAclResult + */ + public static function toGetBucketAcl(OperationOutput $output): Models\GetBucketAclResult + { + $result = new Models\GetBucketAclResult(); + $customDeserializer = [ + static function (Models\GetBucketAclResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'AccessControlPolicy'); + $xml = Utils::parseXml($body); + if (isset($xml->Owner)) { + $result->owner = new Models\Owner( + Functions::tryToString($xml->Owner->ID), + Functions::tryToString($xml->Owner->DisplayName) + ); + } + if (isset($xml->AccessControlList)) { + $result->accessControlList = new Models\AccessControlList( + Functions::tryToString($xml->AccessControlList->Grant) + ); + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketStatRequest $request + * @return OperationInput + */ + public static function fromGetBucketStat(Models\GetBucketStatRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'GetBucketStat', + 'GET', + ['Content-Type' => 'application/xml'], + ['stat' => ''] + ); + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['stat']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketStatResult + */ + public static function toGetBucketStat(OperationOutput $output): Models\GetBucketStatResult + { + $result = new Models\GetBucketStatResult(); + $customDeserializer = [ + static function (Models\GetBucketStatResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'BucketStat'); + $xml = Utils::parseXml($body); + $result->storage = Functions::tryToInt($xml->Storage); + $result->objectCount = Functions::tryToInt($xml->ObjectCount); + $result->multipartUploadCount = Functions::tryToInt($xml->MultipartUploadCount); + $result->liveChannelCount = Functions::tryToInt($xml->LiveChannelCount); + $result->lastModifiedTime = Functions::tryToInt($xml->LastModifiedTime); + $result->standardStorage = Functions::tryToInt($xml->StandardStorage); + $result->standardObjectCount = Functions::tryToInt($xml->StandardObjectCount); + $result->infrequentAccessStorage = Functions::tryToInt($xml->InfrequentAccessStorage); + $result->infrequentAccessRealStorage = Functions::tryToInt($xml->InfrequentAccessRealStorage); + $result->infrequentAccessObjectCount = Functions::tryToInt($xml->InfrequentAccessObjectCount); + $result->archiveStorage = Functions::tryToInt($xml->ArchiveStorage); + $result->archiveRealStorage = Functions::tryToInt($xml->ArchiveRealStorage); + $result->archiveObjectCount = Functions::tryToInt($xml->ArchiveObjectCount); + $result->coldArchiveStorage = Functions::tryToInt($xml->ColdArchiveStorage); + $result->coldArchiveRealStorage = Functions::tryToInt($xml->ColdArchiveRealStorage); + $result->coldArchiveObjectCount = Functions::tryToInt($xml->ColdArchiveObjectCount); + $result->deepColdArchiveStorage = Functions::tryToInt($xml->DeepColdArchiveStorage); + $result->deepColdArchiveRealStorage = Functions::tryToInt($xml->DeepColdArchiveRealStorage); + $result->deepColdArchiveObjectCount = Functions::tryToInt($xml->DeepColdArchiveObjectCount); + $result->deleteMarkerCount = Functions::tryToInt($xml->DeleteMarkerCount); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketLocationRequest $request + * @return OperationInput + */ + public static function fromGetBucketLocation(Models\GetBucketLocationRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'GetBucketLocation', + 'GET', + ['Content-Type' => 'application/xml'], + ['location' => ''] + ); + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['location']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketLocationResult + */ + public static function toGetBucketLocation(OperationOutput $output): Models\GetBucketLocationResult + { + $result = new Models\GetBucketLocationResult(); + $customDeserializer = [ + static function (Models\GetBucketLocationResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'LocationConstraint'); + $xml = Utils::parseXml($body); + $result->location = Functions::tryToString($xml); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketInfoRequest $request + * @return OperationInput + */ + public static function fromGetBucketInfo(Models\GetBucketInfoRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'GetBucketInfo', + 'GET', + ['Content-Type' => 'application/xml'], + ['bucketInfo' => ''] + ); + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['bucketInfo']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketInfoResult + */ + public static function toGetBucketInfo(OperationOutput $output): Models\GetBucketInfoResult + { + $result = new Models\GetBucketInfoResult(); + $customDeserializer = [ + static function (Models\GetBucketInfoResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'BucketInfo'); + $xml = Utils::parseXml($body); + Functions::assertXmlNodeExist($xml->Bucket, 'Bucket'); + $info = new Models\BucketInfo(); + $xml = $xml->Bucket; + $info->name = Functions::tryToString($xml->Name); + $info->accessMonitor = Functions::tryToString($xml->AccessMonitor); + $info->location = Functions::tryToString($xml->Location); + $info->creationDate = Functions::tryToDatetime($xml->CreationDate, 'Y-m-d\TH:i:s.000\Z'); + $info->extranetEndpoint = Functions::tryToString($xml->ExtranetEndpoint); + $info->intranetEndpoint = Functions::tryToString($xml->IntranetEndpoint); + $info->acl = isset($xml->AccessControlList) ? Functions::tryToString($xml->AccessControlList->Grant) : null; + $info->dataRedundancyType = Functions::tryToString($xml->DataRedundancyType); + $info->owner = isset($xml->Owner) ? new Models\Owner( + Functions::tryToString($xml->Owner->ID), + Functions::tryToString($xml->Owner->DisplayName) + ) : null; + $info->storageClass = Functions::tryToString($xml->StorageClass); + $info->resourceGroupId = Functions::tryToString($xml->ResourceGroupId); + $info->sseRule = isset($xml->ServerSideEncryptionRule) ? new Models\ServerSideEncryptionRuleInfo( + Functions::tryToString($xml->ServerSideEncryptionRule->KMSMasterKeyID), + Functions::tryToString($xml->ServerSideEncryptionRule->SSEAlgorithm), + Functions::tryToString($xml->ServerSideEncryptionRule->KMSDataEncryption), + ) : null; + $info->versioning = Functions::tryToString($xml->Versioning); + $info->transferAcceleration = Functions::tryToString($xml->TransferAcceleration); + $info->crossRegionReplication = Functions::tryToString($xml->CrossRegionReplication); + $info->bucketPolicy = isset($xml->BucketPolicy) ? new Models\BucketPolicy( + Functions::tryToString($xml->BucketPolicy->LogBucket), + Functions::tryToString($xml->BucketPolicy->LogPrefix) + ) : null; + $info->comment = Functions::tryToString($xml->Comment); + $info->blockPublicAccess = Functions::tryToBool($xml->BlockPublicAccess); + $result->bucketInfo = $info; + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutBucketVersioningRequest $request + * @return OperationInput + */ + public static function fromPutBucketVersioning(Models\PutBucketVersioningRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'PutBucketVersioning', + 'PUT', + ['Content-Type' => 'application/xml'], + ['versioning' => ''] + ); + + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['versioning']); + + $customSerializer = [ + static function (Models\PutBucketVersioningRequest $request, OperationInput $input) { + if (isset($request->versioningConfiguration)) { + $xml = new \SimpleXMLElement(''); + if (isset($request->versioningConfiguration->status)) { + $xml->addChild('Status', $request->versioningConfiguration->status); + } + $input->setBody(Utils::streamFor($xml->asXML())); + } + }, + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketVersioningResult + */ + public static function toPutBucketVersioning(OperationOutput $output): Models\PutBucketVersioningResult + { + $result = new Models\PutBucketVersioningResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketVersioningRequest $request + * @return OperationInput + */ + public static function fromGetBucketVersioning(Models\GetBucketVersioningRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'GetBucketVersioning', + 'GET', + ['Content-Type' => 'application/xml'], + ['versioning' => ''] + ); + $input->setBucket($request->bucket); + $input->setOpMetadata('sub-resource', ['versioning']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketVersioningResult + */ + public static function toGetBucketVersioning(OperationOutput $output): Models\GetBucketVersioningResult + { + $result = new Models\GetBucketVersioningResult(); + $customDeserializer = [ + static function (Models\GetBucketVersioningResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'VersioningConfiguration'); + $xml = Utils::parseXml($body); + $result->versioningConfiguration = new Models\VersioningConfiguration( + Functions::tryToString($xml->Status) + ); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListObjectsRequest $request + * @return OperationInput + */ + public static function fromListObjects(Models\ListObjectsRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'ListObjects', + 'GET', + ['Content-Type' => 'application/octet-stream'], + ['encoding-type' => 'url'] + ); + $input->setBucket($request->bucket); + + $customSerializer = [ + static function (Models\ListObjectsRequest $request, OperationInput $input) { + if (isset($request->delimiter)) { + $input->setParameter('delimiter', $request->delimiter); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->marker)) { + $input->setParameter('marker', $request->marker); + } + if (isset($request->maxKeys)) { + $input->setParameter('max-keys', strval($request->maxKeys)); + } + if (isset($request->prefix)) { + $input->setParameter('prefix', $request->prefix); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListObjectsResult + */ + public static function toListObjects(OperationOutput $output): Models\ListObjectsResult + { + $result = new Models\ListObjectsResult(); + $customDeserializer = [ + static function (Models\ListObjectsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'ListBucketResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->name = Functions::tryToString($xml->Name); + $result->prefix = Functions::tryUrldecodeString($xml->Prefix, $decode); + $result->marker = Functions::tryUrldecodeString($xml->Marker, $decode); + $result->maxKeys = Functions::tryToInt($xml->MaxKeys); + $result->delimiter = Functions::tryUrldecodeString($xml->Delimiter, $decode); + $result->isTruncated = Functions::tryToBool($xml->IsTruncated); + $result->nextMarker = Functions::tryUrldecodeString($xml->NextMarker, $decode); + if (isset($xml->Contents)) { + $result->contents = []; + foreach ($xml->Contents as $content) { + $o = new Models\ObjectProperties(); + $o->key = Functions::tryUrldecodeString($content->Key, $decode); + $o->type = Functions::tryToString($content->Type); + $o->size = Functions::tryToInt($content->Size); + $o->etag = Functions::tryToString($content->ETag); + $o->lastModified = Functions::tryToDatetime($content->LastModified, 'Y-m-d\TH:i:s.000\Z'); + $o->storageClass = Functions::tryToString($content->StorageClass); + if (isset($content->Owner)) { + $o->owner = new Models\Owner( + Functions::tryToString($content->Owner->ID), + Functions::tryToString($content->Owner->DisplayName) + ); + } + $o->restoreInfo = Functions::tryToString($content->RestoreInfo); + $o->transitionTime = Functions::tryToDatetime($content->TransitionTime, 'Y-m-d\TH:i:s.000\Z'); + $result->contents[] = $o; + } + } + if (isset($xml->CommonPrefixes)) { + $result->commonPrefixes = []; + foreach ($xml->CommonPrefixes as $commonPrefix) { + $result->commonPrefixes[] = new Models\CommonPrefix( + Functions::tryUrldecodeString($commonPrefix->Prefix, $decode) + ); + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListObjectsV2Request $request + * @return OperationInput + */ + public static function fromListObjectsV2(Models\ListObjectsV2Request $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'ListObjectsV2', + 'GET', + ['Content-Type' => 'application/octet-stream'], + ['encoding-type' => 'url', 'list-type' => '2'] + ); + $input->setBucket($request->bucket); + + $customSerializer = [ + static function (Models\ListObjectsV2Request $request, OperationInput $input) { + if (isset($request->delimiter)) { + $input->setParameter('delimiter', $request->delimiter); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->startAfter)) { + $input->setParameter('start-after', $request->startAfter); + } + if (isset($request->continuationToken)) { + $input->setParameter('continuation-token', $request->continuationToken); + } + if (isset($request->maxKeys)) { + $input->setParameter('max-keys', strval($request->maxKeys)); + } + if (isset($request->prefix)) { + $input->setParameter('prefix', $request->prefix); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->fetchOwner)) { + $input->setParameter('fetch-owner', $request->fetchOwner === true ? 'true' : 'false'); + } + }, + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListObjectsV2Result + */ + public static function toListObjectsV2(OperationOutput $output): Models\ListObjectsV2Result + { + $result = new Models\ListObjectsV2Result(); + $customDeserializer = [ + static function (Models\ListObjectsV2Result $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'ListBucketResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->name = Functions::tryToString($xml->Name); + $result->prefix = Functions::tryUrldecodeString($xml->Prefix, $decode); + $result->startAfter = Functions::tryUrldecodeString($xml->StartAfter, $decode); + $result->continuationToken = Functions::tryUrldecodeString($xml->ContinuationToken, $decode); + $result->maxKeys = Functions::tryToInt($xml->MaxKeys); + $result->delimiter = Functions::tryUrldecodeString($xml->Delimiter, $decode); + $result->isTruncated = Functions::tryToBool($xml->IsTruncated); + $result->nextContinuationToken = Functions::tryUrldecodeString($xml->NextContinuationToken, $decode); + $result->keyCount = Functions::tryToInt($xml->KeyCount); + if (isset($xml->Contents)) { + $result->contents = []; + foreach ($xml->Contents as $content) { + $o = new Models\ObjectProperties(); + $o->key = Functions::tryUrldecodeString($content->Key, $decode); + $o->type = Functions::tryToString($content->Type); + $o->size = Functions::tryToInt($content->Size); + $o->etag = Functions::tryToString($content->ETag); + $o->lastModified = Functions::tryToDatetime($content->LastModified, 'Y-m-d\TH:i:s.000\Z'); + $o->storageClass = Functions::tryToString($content->StorageClass); + if (isset($content->Owner)) { + $o->owner = new Models\Owner( + Functions::tryToString($content->Owner->ID), + Functions::tryToString($content->Owner->DisplayName) + ); + } + $o->restoreInfo = Functions::tryToString($content->RestoreInfo); + $o->transitionTime = Functions::tryToDatetime($content->TransitionTime, 'Y-m-d\TH:i:s.000\Z'); + $result->contents[] = $o; + } + } + if (isset($xml->CommonPrefixes)) { + $result->commonPrefixes = []; + foreach ($xml->CommonPrefixes as $commonPrefix) { + $result->commonPrefixes[] = new Models\CommonPrefix( + Functions::tryUrldecodeString($commonPrefix->Prefix, $decode) + ); + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListObjectVersionsRequest $request + * @return OperationInput + */ + public static function fromListObjectVersions(Models\ListObjectVersionsRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + + $input = new OperationInput( + 'ListObjectVersions', + 'GET', + ['Content-Type' => 'application/octet-stream'], + ['encoding-type' => 'url', 'versions' => ''] + ); + $input->setBucket($request->bucket); + + $customSerializer = [ + static function (Models\ListObjectVersionsRequest $request, OperationInput $input) { + if (isset($request->delimiter)) { + $input->setParameter('delimiter', $request->delimiter); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->keyMarker)) { + $input->setParameter('key-marker', $request->keyMarker); + } + if (isset($request->versionIdMarker)) { + $input->setParameter('version-id-marker', $request->versionIdMarker); + } + if (isset($request->maxKeys)) { + $input->setParameter('max-keys', strval($request->maxKeys)); + } + if (isset($request->prefix)) { + $input->setParameter('prefix', $request->prefix); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + + Functions::serializeInputLite($request, $input, $customSerializer); + + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListObjectVersionsResult + */ + public static function toListObjectVersions(OperationOutput $output): Models\ListObjectVersionsResult + { + $result = new Models\ListObjectVersionsResult(); + $customDeserializer = [ + static function (Models\ListObjectVersionsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'ListVersionsResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->name = Functions::tryToString($xml->Name); + $result->prefix = Functions::tryUrldecodeString($xml->Prefix, $decode); + $result->keyMarker = Functions::tryUrldecodeString($xml->KeyMarker, $decode); + $result->versionIdMarker = Functions::tryToString($xml->VersionIdMarker); + $result->maxKeys = Functions::tryToInt($xml->MaxKeys); + $result->delimiter = Functions::tryUrldecodeString($xml->Delimiter, $decode); + $result->isTruncated = Functions::tryToBool($xml->IsTruncated); + $result->nextKeyMarker = Functions::tryUrldecodeString($xml->NextKeyMarker, $decode); + $result->nextVersionIdMarker = Functions::tryToString($xml->NextVersionIdMarker); + if (isset($xml->Version)) { + $result->versions = []; + foreach ($xml->Version as $version) { + $o = new Models\ObjectVersionProperties(); + $o->key = Functions::tryUrldecodeString($version->Key, $decode); + $o->versionId = Functions::tryToString($version->VersionId); + $o->isLatest = Functions::tryToBool($version->IsLatest); + $o->type = Functions::tryToString($version->Type); + $o->size = Functions::tryToInt($version->Size); + $o->etag = Functions::tryToString($version->ETag); + $o->lastModified = Functions::tryToDatetime($version->LastModified, 'Y-m-d\TH:i:s.000\Z'); + $o->storageClass = Functions::tryToString($version->StorageClass); + if (isset($version->Owner)) { + $o->owner = new Models\Owner( + Functions::tryToString($version->Owner->ID), + Functions::tryToString($version->Owner->DisplayName) + ); + } + $o->restoreInfo = Functions::tryToString($version->RestoreInfo); + $o->transitionTime = Functions::tryToDatetime($version->TransitionTime, 'Y-m-d\TH:i:s.000\Z'); + $result->versions[] = $o; + } + } + if (isset($xml->DeleteMarker)) { + $result->deleteMarkers = []; + foreach ($xml->DeleteMarker as $deleteMarker) { + $o = new Models\DeleteMarkerProperties(); + $o->key = Functions::tryUrldecodeString($deleteMarker->Key, $decode); + $o->versionId = Functions::tryToString($deleteMarker->VersionId); + $o->isLatest = Functions::tryToBool($deleteMarker->IsLatest); + $o->lastModified = Functions::tryToDatetime($deleteMarker->LastModified, 'Y-m-d\TH:i:s.000\Z'); + if (isset($deleteMarker->Owner)) { + $o->owner = new Models\Owner( + Functions::tryToString($deleteMarker->Owner->ID), + Functions::tryToString($deleteMarker->Owner->DisplayName) + ); + } + $result->deleteMarkers[] = $o; + } + } + if (isset($xml->CommonPrefixes)) { + $result->commonPrefixes = []; + foreach ($xml->CommonPrefixes as $commonPrefix) { + $result->commonPrefixes[] = new Models\CommonPrefix( + Functions::tryUrldecodeString($commonPrefix->Prefix, $decode) + ); + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListBucketsRequest $request + * @return OperationInput + */ + public static function fromListBuckets(Models\ListBucketsRequest $request): OperationInput + { + $input = new OperationInput( + 'ListBuckets', + 'GET', + ['Content-Type' => 'application/xml'], + ); + $customSerializer = [ + static function (Models\ListBucketsRequest $request, OperationInput $input) { + if (isset($request->marker)) { + $input->setParameter('marker', $request->marker); + } + if (isset($request->maxKeys)) { + $input->setParameter('max-keys', strval($request->maxKeys)); + } + if (isset($request->prefix)) { + $input->setParameter('prefix', $request->prefix); + } + if (isset($request->resourceGroupId)) { + $input->setHeader('x-oss-resource-group-id', $request->resourceGroupId); + } + if (isset($request->tagKey)) { + $input->setParameter('tag-key', $request->tagKey); + } + if (isset($request->tagValue)) { + $input->setParameter('tag-value', $request->tagValue); + } + if (isset($request->tagging)) { + $input->setParameter('tagging', $request->tagging); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListBucketsResult + */ + public static function toListBuckets(OperationOutput $output): Models\ListBucketsResult + { + $result = new Models\ListBucketsResult(); + $customDeserializer = [ + static function (Models\ListBucketsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'ListAllMyBucketsResult'); + $xml = Utils::parseXml($body); + $result->prefix = Functions::tryToString($xml->Prefix); + $result->marker = Functions::tryToString($xml->Marker); + $result->maxKeys = Functions::tryToInt($xml->MaxKeys); + $result->isTruncated = Functions::tryToBool($xml->IsTruncated); + $result->nextMarker = Functions::tryToString($xml->NextMarker); + if (isset($xml->Owner)) { + $result->owner = new Models\Owner( + Functions::tryToString($xml->Owner->ID), + Functions::tryToString($xml->Owner->DisplayName) + ); + } + if (isset($xml->Buckets->Bucket)) { + foreach ($xml->Buckets->Bucket as $bucket) { + $o = new Models\Bucket(); + $o->creationDate = Functions::tryToDatetime($bucket->CreationDate, 'Y-m-d\TH:i:s.000\Z'); + $o->extranetEndpoint = Functions::tryToString($bucket->ExtranetEndpoint); + $o->intranetEndpoint = Functions::tryToString($bucket->IntranetEndpoint); + $o->location = Functions::tryToString($bucket->Location); + $o->name = Functions::tryToString($bucket->Name); + $o->region = Functions::tryToString($bucket->Region); + $o->storageClass = Functions::tryToString($bucket->StorageClass); + $o->resourceGroupId = Functions::tryToString($bucket->ResourceGroupId); + $result->buckets[] = $o; + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DescribeRegionsRequest $request + * @return OperationInput + */ + public static function fromDescribeRegions(Models\DescribeRegionsRequest $request): OperationInput + { + $input = new OperationInput( + 'DescribeRegions', + 'GET', + ['Content-Type' => 'application/xml'], + ); + $customSerializer = [ + static function (Models\DescribeRegionsRequest $request, OperationInput $input) { + if (isset($request->regions)) { + $input->setParameter('regions', $request->regions); + } else { + $input->setParameter('regions', ''); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DescribeRegionsResult + */ + public static function toDescribeRegions(OperationOutput $output): Models\DescribeRegionsResult + { + $result = new Models\DescribeRegionsResult(); + $customDeserializer = [ + static function (Models\DescribeRegionsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'RegionInfoList'); + $xml = Utils::parseXml($body); + if (isset($xml->RegionInfo)) { + foreach ($xml->RegionInfo as $regionInfo) { + $o = new Models\RegionInfo(); + $o->region = Functions::tryToString($regionInfo->Region); + $o->internalEndpoint = Functions::tryToString($regionInfo->InternalEndpoint); + $o->internetEndpoint = Functions::tryToString($regionInfo->InternetEndpoint); + $o->accelerateEndpoint = Functions::tryToString($regionInfo->AccelerateEndpoint); + $result->regionInfos[] = $o; + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketCname.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketCname.php new file mode 100644 index 0000000..654b5a4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketCname.php @@ -0,0 +1,195 @@ + 'application/xml'] + ); + $input->setParameter('cname', ''); + $input->setParameter('comp', 'add'); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cname', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutCnameResult + */ + public static function toPutCname(OperationOutput $output): Models\PutCnameResult + { + $result = new Models\PutCnameResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\ListCnameRequest $request + * @return OperationInput + */ + public static function fromListCname(Models\ListCnameRequest $request): OperationInput + { + $input = new OperationInput( + 'ListCname', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('cname', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cname',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListCnameResult + */ + public static function toListCname(OperationOutput $output): Models\ListCnameResult + { + $result = new Models\ListCnameResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteCnameRequest $request + * @return OperationInput + */ + public static function fromDeleteCname(Models\DeleteCnameRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteCname', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('cname', ''); + $input->setParameter('comp', 'delete'); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cname', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteCnameResult + */ + public static function toDeleteCname(OperationOutput $output): Models\DeleteCnameResult + { + $result = new Models\DeleteCnameResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetCnameTokenRequest $request + * @return OperationInput + */ + public static function fromGetCnameToken(Models\GetCnameTokenRequest $request): OperationInput + { + $input = new OperationInput( + 'GetCnameToken', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('comp', 'token'); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['comp', 'cname']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetCnameTokenResult + */ + public static function toGetCnameToken(OperationOutput $output): Models\GetCnameTokenResult + { + $result = new Models\GetCnameTokenResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\CreateCnameTokenRequest $request + * @return OperationInput + */ + public static function fromCreateCnameToken(Models\CreateCnameTokenRequest $request): OperationInput + { + $input = new OperationInput( + 'CreateCnameToken', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('cname', ''); + $input->setParameter('comp', 'token'); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cname', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CreateCnameTokenResult + */ + public static function toCreateCnameToken(OperationOutput $output): Models\CreateCnameTokenResult + { + $result = new Models\CreateCnameTokenResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketCors.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketCors.php new file mode 100644 index 0000000..111cd5e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketCors.php @@ -0,0 +1,155 @@ + 'application/xml'] + ); + $input->setParameter('cors', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cors',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketCorsResult + */ + public static function toPutBucketCors(OperationOutput $output): Models\PutBucketCorsResult + { + $result = new Models\PutBucketCorsResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketCorsRequest $request + * @return OperationInput + */ + public static function fromGetBucketCors(Models\GetBucketCorsRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketCors', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('cors', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cors',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketCorsResult + */ + public static function toGetBucketCors(OperationOutput $output): Models\GetBucketCorsResult + { + $result = new Models\GetBucketCorsResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketCorsRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketCors(Models\DeleteBucketCorsRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketCors', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('cors', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['cors',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketCorsResult + */ + public static function toDeleteBucketCors(OperationOutput $output): Models\DeleteBucketCorsResult + { + $result = new Models\DeleteBucketCorsResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\OptionObjectRequest $request + * @return OperationInput + */ + public static function fromOptionObject(Models\OptionObjectRequest $request): OperationInput + { + $input = new OperationInput( + 'OptionObject', + 'OPTIONS', + ['Content-Type' => 'application/xml'] + ); + $input->setBucket($request->bucket ?? ''); + $input->setKey($request->key ?? ''); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\OptionObjectResult + */ + public static function toOptionObject(OperationOutput $output): Models\OptionObjectResult + { + $result = new Models\OptionObjectResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketEncryption.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketEncryption.php new file mode 100644 index 0000000..a269be5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketEncryption.php @@ -0,0 +1,120 @@ + 'application/xml'] + ); + $input->setParameter('encryption', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['encryption',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketEncryptionResult + */ + public static function toPutBucketEncryption(OperationOutput $output): Models\PutBucketEncryptionResult + { + $result = new Models\PutBucketEncryptionResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketEncryptionRequest $request + * @return OperationInput + */ + public static function fromGetBucketEncryption(Models\GetBucketEncryptionRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketEncryption', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('encryption', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['encryption',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketEncryptionResult + */ + public static function toGetBucketEncryption(OperationOutput $output): Models\GetBucketEncryptionResult + { + $result = new Models\GetBucketEncryptionResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketEncryptionRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketEncryption(Models\DeleteBucketEncryptionRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketEncryption', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('encryption', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['encryption',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketEncryptionResult + */ + public static function toDeleteBucketEncryption(OperationOutput $output): Models\DeleteBucketEncryptionResult + { + $result = new Models\DeleteBucketEncryptionResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketHttpsConfig.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketHttpsConfig.php new file mode 100644 index 0000000..5dd0612 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketHttpsConfig.php @@ -0,0 +1,87 @@ + 'application/xml'] + ); + $input->setParameter('httpsConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['httpsConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketHttpsConfigResult + */ + public static function toGetBucketHttpsConfig(OperationOutput $output): Models\GetBucketHttpsConfigResult + { + $result = new Models\GetBucketHttpsConfigResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutBucketHttpsConfigRequest $request + * @return OperationInput + */ + public static function fromPutBucketHttpsConfig(Models\PutBucketHttpsConfigRequest $request): OperationInput + { + $input = new OperationInput( + 'PutBucketHttpsConfig', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('httpsConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['httpsConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketHttpsConfigResult + */ + public static function toPutBucketHttpsConfig(OperationOutput $output): Models\PutBucketHttpsConfigResult + { + $result = new Models\PutBucketHttpsConfigResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketInventory.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketInventory.php new file mode 100644 index 0000000..9ab27de --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketInventory.php @@ -0,0 +1,156 @@ + 'application/xml'] + ); + $input->setParameter('inventory', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['inventory', 'inventoryId']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketInventoryResult + */ + public static function toPutBucketInventory(OperationOutput $output): Models\PutBucketInventoryResult + { + $result = new Models\PutBucketInventoryResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketInventoryRequest $request + * @return OperationInput + */ + public static function fromGetBucketInventory(Models\GetBucketInventoryRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketInventory', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('inventory', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['inventory', 'inventoryId']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketInventoryResult + */ + public static function toGetBucketInventory(OperationOutput $output): Models\GetBucketInventoryResult + { + $result = new Models\GetBucketInventoryResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListBucketInventoryRequest $request + * @return OperationInput + */ + public static function fromListBucketInventory(Models\ListBucketInventoryRequest $request): OperationInput + { + $input = new OperationInput( + 'ListBucketInventory', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('inventory', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['inventory',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListBucketInventoryResult + */ + public static function toListBucketInventory(OperationOutput $output): Models\ListBucketInventoryResult + { + $result = new Models\ListBucketInventoryResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketInventoryRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketInventory(Models\DeleteBucketInventoryRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketInventory', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('inventory', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['inventory', 'inventoryId']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketInventoryResult + */ + public static function toDeleteBucketInventory(OperationOutput $output): Models\DeleteBucketInventoryResult + { + $result = new Models\DeleteBucketInventoryResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketLifecycle.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketLifecycle.php new file mode 100644 index 0000000..b328819 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketLifecycle.php @@ -0,0 +1,118 @@ + 'application/xml'] + ); + $input->setParameter('lifecycle', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['lifecycle',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketLifecycleResult + */ + public static function toPutBucketLifecycle(OperationOutput $output): Models\PutBucketLifecycleResult + { + $result = new Models\PutBucketLifecycleResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + /** + * @param Models\GetBucketLifecycleRequest $request + * @return OperationInput + */ + public static function fromGetBucketLifecycle(Models\GetBucketLifecycleRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketLifecycle', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('lifecycle', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['lifecycle',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketLifecycleResult + */ + public static function toGetBucketLifecycle(OperationOutput $output): Models\GetBucketLifecycleResult + { + $result = new Models\GetBucketLifecycleResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + /** + * @param Models\DeleteBucketLifecycleRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketLifecycle(Models\DeleteBucketLifecycleRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketLifecycle', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('lifecycle', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['lifecycle',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketLifecycleResult + */ + public static function toDeleteBucketLifecycle(OperationOutput $output): Models\DeleteBucketLifecycleResult + { + $result = new Models\DeleteBucketLifecycleResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketLogging.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketLogging.php new file mode 100644 index 0000000..0c5d60b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketLogging.php @@ -0,0 +1,217 @@ + 'application/xml'] + ); + $input->setParameter('logging', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['logging',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketLoggingResult + */ + public static function toPutBucketLogging(OperationOutput $output): Models\PutBucketLoggingResult + { + $result = new Models\PutBucketLoggingResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + /** + * @param Models\GetBucketLoggingRequest $request + * @return OperationInput + */ + public static function fromGetBucketLogging(Models\GetBucketLoggingRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketLogging', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('logging', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['logging',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketLoggingResult + */ + public static function toGetBucketLogging(OperationOutput $output): Models\GetBucketLoggingResult + { + $result = new Models\GetBucketLoggingResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + /** + * @param Models\DeleteBucketLoggingRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketLogging(Models\DeleteBucketLoggingRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketLogging', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('logging', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['logging',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketLoggingResult + */ + public static function toDeleteBucketLogging(OperationOutput $output): Models\DeleteBucketLoggingResult + { + $result = new Models\DeleteBucketLoggingResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + /** + * @param Models\PutUserDefinedLogFieldsConfigRequest $request + * @return OperationInput + */ + public static function fromPutUserDefinedLogFieldsConfig(Models\PutUserDefinedLogFieldsConfigRequest $request): OperationInput + { + $input = new OperationInput( + 'PutUserDefinedLogFieldsConfig', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('userDefinedLogFieldsConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['userDefinedLogFieldsConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutUserDefinedLogFieldsConfigResult + */ + public static function toPutUserDefinedLogFieldsConfig(OperationOutput $output): Models\PutUserDefinedLogFieldsConfigResult + { + $result = new Models\PutUserDefinedLogFieldsConfigResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + /** + * @param Models\GetUserDefinedLogFieldsConfigRequest $request + * @return OperationInput + */ + public static function fromGetUserDefinedLogFieldsConfig(Models\GetUserDefinedLogFieldsConfigRequest $request): OperationInput + { + $input = new OperationInput( + 'GetUserDefinedLogFieldsConfig', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('userDefinedLogFieldsConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['userDefinedLogFieldsConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetUserDefinedLogFieldsConfigResult + */ + public static function toGetUserDefinedLogFieldsConfig(OperationOutput $output): Models\GetUserDefinedLogFieldsConfigResult + { + $result = new Models\GetUserDefinedLogFieldsConfigResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + /** + * @param Models\DeleteUserDefinedLogFieldsConfigRequest $request + * @return OperationInput + */ + public static function fromDeleteUserDefinedLogFieldsConfig(Models\DeleteUserDefinedLogFieldsConfigRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteUserDefinedLogFieldsConfig', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('userDefinedLogFieldsConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['userDefinedLogFieldsConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteUserDefinedLogFieldsConfigResult + */ + public static function toDeleteUserDefinedLogFieldsConfig(OperationOutput $output): Models\DeleteUserDefinedLogFieldsConfigResult + { + $result = new Models\DeleteUserDefinedLogFieldsConfigResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketMetaQuery.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketMetaQuery.php new file mode 100644 index 0000000..4d86aca --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketMetaQuery.php @@ -0,0 +1,159 @@ + 'application/xml'] + ); + $input->setParameter('metaQuery', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['metaQuery',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetMetaQueryStatusResult + */ + public static function toGetMetaQueryStatus(OperationOutput $output): Models\GetMetaQueryStatusResult + { + $result = new Models\GetMetaQueryStatusResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\CloseMetaQueryRequest $request + * @return OperationInput + */ + public static function fromCloseMetaQuery(Models\CloseMetaQueryRequest $request): OperationInput + { + $input = new OperationInput( + 'CloseMetaQuery', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('comp', 'delete'); + $input->setParameter('metaQuery', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['metaQuery', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CloseMetaQueryResult + */ + public static function toCloseMetaQuery(OperationOutput $output): Models\CloseMetaQueryResult + { + $result = new Models\CloseMetaQueryResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DoMetaQueryRequest $request + * @return OperationInput + */ + public static function fromDoMetaQuery(Models\DoMetaQueryRequest $request): OperationInput + { + $input = new OperationInput( + 'DoMetaQuery', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('comp', 'query'); + $input->setParameter('metaQuery', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['metaQuery', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DoMetaQueryResult + */ + public static function toDoMetaQuery(OperationOutput $output): Models\DoMetaQueryResult + { + $result = new Models\DoMetaQueryResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\OpenMetaQueryRequest $request + * @return OperationInput + */ + public static function fromOpenMetaQuery(Models\OpenMetaQueryRequest $request): OperationInput + { + $input = new OperationInput( + 'OpenMetaQuery', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('comp', 'add'); + $input->setParameter('metaQuery', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['metaQuery', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\OpenMetaQueryResult + */ + public static function toOpenMetaQuery(OperationOutput $output): Models\OpenMetaQueryResult + { + $result = new Models\OpenMetaQueryResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketOverwriteConfig.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketOverwriteConfig.php new file mode 100644 index 0000000..7ac165c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketOverwriteConfig.php @@ -0,0 +1,120 @@ + 'application/xml'] + ); + $input->setParameter('overwriteConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['overwriteConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketOverwriteConfigResult + */ + public static function toPutBucketOverwriteConfig(OperationOutput $output): Models\PutBucketOverwriteConfigResult + { + $result = new Models\PutBucketOverwriteConfigResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketOverwriteConfigRequest $request + * @return OperationInput + */ + public static function fromGetBucketOverwriteConfig(Models\GetBucketOverwriteConfigRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketOverwriteConfig', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('overwriteConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['overwriteConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketOverwriteConfigResult + */ + public static function toGetBucketOverwriteConfig(OperationOutput $output): Models\GetBucketOverwriteConfigResult + { + $result = new Models\GetBucketOverwriteConfigResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketOverwriteConfigRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketOverwriteConfig(Models\DeleteBucketOverwriteConfigRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketOverwriteConfig', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('overwriteConfig', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['overwriteConfig',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketOverwriteConfigResult + */ + public static function toDeleteBucketOverwriteConfig(OperationOutput $output): Models\DeleteBucketOverwriteConfigResult + { + $result = new Models\DeleteBucketOverwriteConfigResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketPolicy.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketPolicy.php new file mode 100644 index 0000000..4d8ee9a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketPolicy.php @@ -0,0 +1,155 @@ +setParameter('policy', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['policy',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketPolicyResult + */ + public static function toPutBucketPolicy(OperationOutput $output): Models\PutBucketPolicyResult + { + $result = new Models\PutBucketPolicyResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketPolicyRequest $request + * @return OperationInput + */ + public static function fromGetBucketPolicy(Models\GetBucketPolicyRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketPolicy', + 'GET', + ); + $input->setParameter('policy', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['policy',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketPolicyResult + */ + public static function toGetBucketPolicy(OperationOutput $output): Models\GetBucketPolicyResult + { + $result = new Models\GetBucketPolicyResult(); + if ($output->getBody() !== null) { + $result->body = $output->getBody()->getContents(); + } + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeleteBucketPolicyRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketPolicy(Models\DeleteBucketPolicyRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketPolicy', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('policy', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['policy',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketPolicyResult + */ + public static function toDeleteBucketPolicy(OperationOutput $output): Models\DeleteBucketPolicyResult + { + $result = new Models\DeleteBucketPolicyResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketPolicyStatusRequest $request + * @return OperationInput + */ + public static function fromGetBucketPolicyStatus(Models\GetBucketPolicyStatusRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketPolicyStatus', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('policyStatus', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['policyStatus',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketPolicyStatusResult + */ + public static function toGetBucketPolicyStatus(OperationOutput $output): Models\GetBucketPolicyStatusResult + { + $result = new Models\GetBucketPolicyStatusResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketPublicAccessBlock.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketPublicAccessBlock.php new file mode 100644 index 0000000..27c2d03 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketPublicAccessBlock.php @@ -0,0 +1,120 @@ + 'application/xml'] + ); + $input->setParameter('publicAccessBlock', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['publicAccessBlock',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketPublicAccessBlockResult + */ + public static function toGetBucketPublicAccessBlock(OperationOutput $output): Models\GetBucketPublicAccessBlockResult + { + $result = new Models\GetBucketPublicAccessBlockResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutBucketPublicAccessBlockRequest $request + * @return OperationInput + */ + public static function fromPutBucketPublicAccessBlock(Models\PutBucketPublicAccessBlockRequest $request): OperationInput + { + $input = new OperationInput( + 'PutBucketPublicAccessBlock', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('publicAccessBlock', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['publicAccessBlock',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketPublicAccessBlockResult + */ + public static function toPutBucketPublicAccessBlock(OperationOutput $output): Models\PutBucketPublicAccessBlockResult + { + $result = new Models\PutBucketPublicAccessBlockResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeleteBucketPublicAccessBlockRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketPublicAccessBlock(Models\DeleteBucketPublicAccessBlockRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketPublicAccessBlock', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('publicAccessBlock', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['publicAccessBlock',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketPublicAccessBlockResult + */ + public static function toDeleteBucketPublicAccessBlock(OperationOutput $output): Models\DeleteBucketPublicAccessBlockResult + { + $result = new Models\DeleteBucketPublicAccessBlockResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketRedundancyTransition.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketRedundancyTransition.php new file mode 100644 index 0000000..f85a86d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketRedundancyTransition.php @@ -0,0 +1,194 @@ + 'application/xml'] + ); + $input->setParameter('redundancyTransition', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['redundancyTransition',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListBucketDataRedundancyTransitionResult + */ + public static function toListBucketDataRedundancyTransition(OperationOutput $output): Models\ListBucketDataRedundancyTransitionResult + { + $result = new Models\ListBucketDataRedundancyTransitionResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketDataRedundancyTransitionRequest $request + * @return OperationInput + */ + public static function fromGetBucketDataRedundancyTransition(Models\GetBucketDataRedundancyTransitionRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketDataRedundancyTransition', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('redundancyTransition', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['redundancyTransition',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketDataRedundancyTransitionResult + */ + public static function toGetBucketDataRedundancyTransition(OperationOutput $output): Models\GetBucketDataRedundancyTransitionResult + { + $result = new Models\GetBucketDataRedundancyTransitionResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\CreateBucketDataRedundancyTransitionRequest $request + * @return OperationInput + */ + public static function fromCreateBucketDataRedundancyTransition(Models\CreateBucketDataRedundancyTransitionRequest $request): OperationInput + { + $input = new OperationInput( + 'CreateBucketDataRedundancyTransition', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('redundancyTransition', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['redundancyTransition',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CreateBucketDataRedundancyTransitionResult + */ + public static function toCreateBucketDataRedundancyTransition(OperationOutput $output): Models\CreateBucketDataRedundancyTransitionResult + { + $result = new Models\CreateBucketDataRedundancyTransitionResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketDataRedundancyTransitionRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketDataRedundancyTransition(Models\DeleteBucketDataRedundancyTransitionRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketDataRedundancyTransition', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('redundancyTransition', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['redundancyTransition',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketDataRedundancyTransitionResult + */ + public static function toDeleteBucketDataRedundancyTransition(OperationOutput $output): Models\DeleteBucketDataRedundancyTransitionResult + { + $result = new Models\DeleteBucketDataRedundancyTransitionResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\ListUserDataRedundancyTransitionRequest $request + * @return OperationInput + */ + public static function fromListUserDataRedundancyTransition(Models\ListUserDataRedundancyTransitionRequest $request): OperationInput + { + $input = new OperationInput( + 'ListUserDataRedundancyTransition', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('redundancyTransition', ''); + $input->setOpMetadata('sub-resource', ['redundancyTransition',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListUserDataRedundancyTransitionResult + */ + public static function toListUserDataRedundancyTransition(OperationOutput $output): Models\ListUserDataRedundancyTransitionResult + { + $result = new Models\ListUserDataRedundancyTransitionResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketReferer.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketReferer.php new file mode 100644 index 0000000..28bc6b5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketReferer.php @@ -0,0 +1,87 @@ + 'application/xml'] + ); + $input->setParameter('referer', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['referer',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketRefererResult + */ + public static function toPutBucketReferer(OperationOutput $output): Models\PutBucketRefererResult + { + $result = new Models\PutBucketRefererResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketRefererRequest $request + * @return OperationInput + */ + public static function fromGetBucketReferer(Models\GetBucketRefererRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketReferer', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('referer', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['referer',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketRefererResult + */ + public static function toGetBucketReferer(OperationOutput $output): Models\GetBucketRefererResult + { + $result = new Models\GetBucketRefererResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketReplication.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketReplication.php new file mode 100644 index 0000000..0c816c8 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketReplication.php @@ -0,0 +1,230 @@ + 'application/xml'] + ); + $input->setParameter('rtc', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['rtc',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketRtcResult + */ + public static function toPutBucketRtc(OperationOutput $output): Models\PutBucketRtcResult + { + $result = new Models\PutBucketRtcResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\PutBucketReplicationRequest $request + * @return OperationInput + */ + public static function fromPutBucketReplication(Models\PutBucketReplicationRequest $request): OperationInput + { + $input = new OperationInput( + 'PutBucketReplication', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('comp', 'add'); + $input->setParameter('replication', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['replication', 'comp',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketReplicationResult + */ + public static function toPutBucketReplication(OperationOutput $output): Models\PutBucketReplicationResult + { + $result = new Models\PutBucketReplicationResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketReplicationRequest $request + * @return OperationInput + */ + public static function fromGetBucketReplication(Models\GetBucketReplicationRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketReplication', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('replication', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['replication',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketReplicationResult + */ + public static function toGetBucketReplication(OperationOutput $output): Models\GetBucketReplicationResult + { + $result = new Models\GetBucketReplicationResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketReplicationLocationRequest $request + * @return OperationInput + */ + public static function fromGetBucketReplicationLocation(Models\GetBucketReplicationLocationRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketReplicationLocation', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('replicationLocation', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['replicationLocation',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketReplicationLocationResult + */ + public static function toGetBucketReplicationLocation(OperationOutput $output): Models\GetBucketReplicationLocationResult + { + $result = new Models\GetBucketReplicationLocationResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetBucketReplicationProgressRequest $request + * @return OperationInput + */ + public static function fromGetBucketReplicationProgress(Models\GetBucketReplicationProgressRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketReplicationProgress', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('replicationProgress', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['replicationProgress',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketReplicationProgressResult + */ + public static function toGetBucketReplicationProgress(OperationOutput $output): Models\GetBucketReplicationProgressResult + { + $result = new Models\GetBucketReplicationProgressResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketReplicationRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketReplication(Models\DeleteBucketReplicationRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketReplication', + 'POST', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('comp', 'delete'); + $input->setParameter('replication', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['comp', 'replication',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketReplicationResult + */ + public static function toDeleteBucketReplication(OperationOutput $output): Models\DeleteBucketReplicationResult + { + $result = new Models\DeleteBucketReplicationResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketRequestPayment.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketRequestPayment.php new file mode 100644 index 0000000..7c7dcfe --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketRequestPayment.php @@ -0,0 +1,87 @@ + 'application/xml'] + ); + $input->setParameter('requestPayment', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['requestPayment',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketRequestPaymentResult + */ + public static function toPutBucketRequestPayment(OperationOutput $output): Models\PutBucketRequestPaymentResult + { + $result = new Models\PutBucketRequestPaymentResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketRequestPaymentRequest $request + * @return OperationInput + */ + public static function fromGetBucketRequestPayment(Models\GetBucketRequestPaymentRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketRequestPayment', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('requestPayment', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['requestPayment',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketRequestPaymentResult + */ + public static function toGetBucketRequestPayment(OperationOutput $output): Models\GetBucketRequestPaymentResult + { + $result = new Models\GetBucketRequestPaymentResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketResourceGroup.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketResourceGroup.php new file mode 100644 index 0000000..c378b60 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketResourceGroup.php @@ -0,0 +1,87 @@ + 'application/xml'] + ); + $input->setParameter('resourceGroup', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['resourceGroup',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketResourceGroupResult + */ + public static function toGetBucketResourceGroup(OperationOutput $output): Models\GetBucketResourceGroupResult + { + $result = new Models\GetBucketResourceGroupResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutBucketResourceGroupRequest $request + * @return OperationInput + */ + public static function fromPutBucketResourceGroup(Models\PutBucketResourceGroupRequest $request): OperationInput + { + $input = new OperationInput( + 'PutBucketResourceGroup', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('resourceGroup', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['resourceGroup',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketResourceGroupResult + */ + public static function toPutBucketResourceGroup(OperationOutput $output): Models\PutBucketResourceGroupResult + { + $result = new Models\PutBucketResourceGroupResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketStyle.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketStyle.php new file mode 100644 index 0000000..ddee277 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketStyle.php @@ -0,0 +1,156 @@ + 'application/xml'] + ); + $input->setParameter('style', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['style', 'styleName']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutStyleResult + */ + public static function toPutStyle(OperationOutput $output): Models\PutStyleResult + { + $result = new Models\PutStyleResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\ListStyleRequest $request + * @return OperationInput + */ + public static function fromListStyle(Models\ListStyleRequest $request): OperationInput + { + $input = new OperationInput( + 'ListStyle', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('style', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['style',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListStyleResult + */ + public static function toListStyle(OperationOutput $output): Models\ListStyleResult + { + $result = new Models\ListStyleResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetStyleRequest $request + * @return OperationInput + */ + public static function fromGetStyle(Models\GetStyleRequest $request): OperationInput + { + $input = new OperationInput( + 'GetStyle', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('style', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['style', 'styleName']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetStyleResult + */ + public static function toGetStyle(OperationOutput $output): Models\GetStyleResult + { + $result = new Models\GetStyleResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteStyleRequest $request + * @return OperationInput + */ + public static function fromDeleteStyle(Models\DeleteStyleRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteStyle', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('style', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['style', 'styleName']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteStyleResult + */ + public static function toDeleteStyle(OperationOutput $output): Models\DeleteStyleResult + { + $result = new Models\DeleteStyleResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketTags.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketTags.php new file mode 100644 index 0000000..89a95f9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketTags.php @@ -0,0 +1,120 @@ + 'application/xml'] + ); + $input->setParameter('tagging', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['tagging',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketTagsResult + */ + public static function toPutBucketTags(OperationOutput $output): Models\PutBucketTagsResult + { + $result = new Models\PutBucketTagsResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketTagsRequest $request + * @return OperationInput + */ + public static function fromGetBucketTags(Models\GetBucketTagsRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketTags', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('tagging', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['tagging',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketTagsResult + */ + public static function toGetBucketTags(OperationOutput $output): Models\GetBucketTagsResult + { + $result = new Models\GetBucketTagsResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteBucketTagsRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketTags(Models\DeleteBucketTagsRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketTags', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('tagging', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['tagging',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketTagsResult + */ + public static function toDeleteBucketTags(OperationOutput $output): Models\DeleteBucketTagsResult + { + $result = new Models\DeleteBucketTagsResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketTransferAcceleration.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketTransferAcceleration.php new file mode 100644 index 0000000..cfd911c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketTransferAcceleration.php @@ -0,0 +1,87 @@ + 'application/xml'] + ); + $input->setParameter('transferAcceleration', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['transferAcceleration',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketTransferAccelerationResult + */ + public static function toPutBucketTransferAcceleration(OperationOutput $output): Models\PutBucketTransferAccelerationResult + { + $result = new Models\PutBucketTransferAccelerationResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketTransferAccelerationRequest $request + * @return OperationInput + */ + public static function fromGetBucketTransferAcceleration(Models\GetBucketTransferAccelerationRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketTransferAcceleration', + 'GET', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('transferAcceleration', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['transferAcceleration',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketTransferAccelerationResult + */ + public static function toGetBucketTransferAcceleration(OperationOutput $output): Models\GetBucketTransferAccelerationResult + { + $result = new Models\GetBucketTransferAccelerationResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketWebsite.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketWebsite.php new file mode 100644 index 0000000..8980ab7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketWebsite.php @@ -0,0 +1,118 @@ + 'application/xml'] + ); + $input->setParameter('website', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['website',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketWebsiteResult + */ + public static function toGetBucketWebsite(OperationOutput $output): Models\GetBucketWebsiteResult + { + $result = new Models\GetBucketWebsiteResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + /** + * @param Models\PutBucketWebsiteRequest $request + * @return OperationInput + */ + public static function fromPutBucketWebsite(Models\PutBucketWebsiteRequest $request): OperationInput + { + $input = new OperationInput( + 'PutBucketWebsite', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('website', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['website',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutBucketWebsiteResult + */ + public static function toPutBucketWebsite(OperationOutput $output): Models\PutBucketWebsiteResult + { + $result = new Models\PutBucketWebsiteResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + /** + * @param Models\DeleteBucketWebsiteRequest $request + * @return OperationInput + */ + public static function fromDeleteBucketWebsite(Models\DeleteBucketWebsiteRequest $request): OperationInput + { + $input = new OperationInput( + 'DeleteBucketWebsite', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('website', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['website',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteBucketWebsiteResult + */ + public static function toDeleteBucketWebsite(OperationOutput $output): Models\DeleteBucketWebsiteResult + { + $result = new Models\DeleteBucketWebsiteResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/BucketWorm.php b/vendor/alibabacloud/oss-v2/src/Transform/BucketWorm.php new file mode 100644 index 0000000..a9c28b0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/BucketWorm.php @@ -0,0 +1,181 @@ + 'application/xml'], + ); + $input->setParameter('worm', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['worm']); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\InitiateBucketWormResult + */ + public static function toInitiateBucketWorm(OperationOutput $output): Models\InitiateBucketWormResult + { + $result = new Models\InitiateBucketWormResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\AbortBucketWormRequest $request + * @return OperationInput + */ + public static function fromAbortBucketWorm(Models\AbortBucketWormRequest $request): OperationInput + { + $input = new OperationInput( + 'AbortBucketWorm', + 'DELETE', + ); + $input->setParameter('worm', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['worm']); + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\AbortBucketWormResult + */ + public static function toAbortBucketWorm(OperationOutput $output): Models\AbortBucketWormResult + { + $result = new Models\AbortBucketWormResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\CompleteBucketWormRequest $request + * @return OperationInput + */ + public static function fromCompleteBucketWorm(Models\CompleteBucketWormRequest $request): OperationInput + { + $input = new OperationInput( + 'CompleteBucketWorm', + 'POST', + ); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['wormId']); + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CompleteBucketWormResult + */ + public static function toCompleteBucketWorm(OperationOutput $output): Models\CompleteBucketWormResult + { + $result = new Models\CompleteBucketWormResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\ExtendBucketWormRequest $request + * @return OperationInput + */ + public static function fromExtendBucketWorm(Models\ExtendBucketWormRequest $request): OperationInput + { + $input = new OperationInput( + 'ExtendBucketWorm', + 'POST', + ['Content-Type' => 'application/xml'], + ); + $input->setParameter('wormExtend', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['wormExtend', 'wormId']); + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ExtendBucketWormResult + */ + public static function toExtendBucketWorm(OperationOutput $output): Models\ExtendBucketWormResult + { + $result = new Models\ExtendBucketWormResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\GetBucketWormRequest $request + * @return OperationInput + */ + public static function fromGetBucketWorm(Models\GetBucketWormRequest $request): OperationInput + { + $input = new OperationInput( + 'GetBucketWorm', + 'GET', + ); + $input->setParameter('worm', ''); + $input->setBucket($request->bucket ?? ''); + $input->setOpMetadata('sub-resource', ['worm']); + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetBucketWormResult + */ + public static function toGetBucketWorm(OperationOutput $output): Models\GetBucketWormResult + { + $result = new Models\GetBucketWormResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/CloudBoxes.php b/vendor/alibabacloud/oss-v2/src/Transform/CloudBoxes.php new file mode 100644 index 0000000..ca06fd5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/CloudBoxes.php @@ -0,0 +1,53 @@ + 'application/xml'] + ); + $input->setParameter('cloudboxes', ''); + $input->setOpMetadata('sub-resource', ['cloudboxes',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListCloudBoxesResult + */ + public static function toListCloudBoxes(OperationOutput $output): Models\ListCloudBoxesResult + { + $result = new Models\ListCloudBoxesResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/Functions.php b/vendor/alibabacloud/oss-v2/src/Transform/Functions.php new file mode 100644 index 0000000..a07f9b2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/Functions.php @@ -0,0 +1,367 @@ + 'BucketBasic', + 'DeleteBucket' => 'BucketBasic', + 'PutBucketAcl' => 'BucketBasic', + 'GetBucketAcl' => 'BucketBasic', + 'GetBucketStat' => 'BucketBasic', + 'GetBucketLocation' => 'BucketBasic', + 'GetBucketInfo' => 'BucketBasic', + 'PutBucketVersioning' => 'BucketBasic', + 'GetBucketVersioning' => 'BucketBasic', + 'ListObjects' => 'BucketBasic', + 'ListObjectsV2' => 'BucketBasic', + 'ListObjectVersions' => 'BucketBasic', + // service + 'ListBuckets' => 'BucketBasic', + // region + 'DescribeRegions' => 'BucketBasic', + //object basic + 'PutObject' => 'ObjectBasic', + 'CopyObject' => 'ObjectBasic', + 'GetObject' => 'ObjectBasic', + 'AppendObject' => 'ObjectBasic', + 'SealAppendObject' => 'ObjectBasic', + 'DeleteObject' => 'ObjectBasic', + 'DeleteMultipleObjects' => 'ObjectBasic', + 'HeadObject' => 'ObjectBasic', + 'GetObjectMeta' => 'ObjectBasic', + 'RestoreObject' => 'ObjectBasic', + 'CleanRestoredObject' => 'ObjectBasic', + //object acl + 'PutObjectAcl' => 'ObjectBasic', + 'GetObjectAcl' => 'ObjectBasic', + //object tagging + 'PutObjectTagging' => 'ObjectBasic', + 'GetObjectTagging' => 'ObjectBasic', + 'DeleteObjectTagging' => 'ObjectBasic', + //object symlink + 'PutSymlink' => 'ObjectBasic', + 'GetSymlink' => 'ObjectBasic', + //object process + 'ProcessObject' => 'ObjectBasic', + 'AsyncProcessObject' => 'ObjectBasic', + //object multipart + 'InitiateMultipartUpload' => 'ObjectMultipart', + 'UploadPart' => 'ObjectMultipart', + 'CompleteMultipartUpload' => 'ObjectMultipart', + 'UploadPartCopy' => 'ObjectMultipart', + 'AbortMultipartUpload' => 'ObjectMultipart', + 'ListMultipartUploads' => 'ObjectMultipart', + 'ListParts' => 'ObjectMultipart', + ]; + + const API_MAPS_8_ONLY = [ + // bucket worm + 'InitiateBucketWorm' => 'BucketWorm', + 'AbortBucketWorm' => 'BucketWorm', + 'CompleteBucketWorm' => 'BucketWorm', + 'ExtendBucketWorm' => 'BucketWorm', + 'GetBucketWorm' => 'BucketWorm', + // bucket lifecycle + 'PutBucketLifecycle' => 'BucketLifecycle', + 'GetBucketLifecycle' => 'BucketLifecycle', + 'DeleteBucketLifecycle' => 'BucketLifecycle', + // bucket transfer acceleration + 'PutBucketTransferAcceleration' => 'BucketTransferAcceleration', + 'GetBucketTransferAcceleration' => 'BucketTransferAcceleration', + // bucket meta query + 'GetMetaQueryStatus' => 'BucketMetaQuery', + 'CloseMetaQuery' => 'BucketMetaQuery', + 'DoMetaQuery' => 'BucketMetaQuery', + 'OpenMetaQuery' => 'BucketMetaQuery', + // bucket access monitor + 'PutBucketAccessMonitor' => 'BucketAccessMonitor', + 'GetBucketAccessMonitor' => 'BucketAccessMonitor', + // bucket cname + 'PutCname' => 'BucketCname', + 'ListCname' => 'BucketCname', + 'DeleteCname' => 'BucketCname', + 'GetCnameToken' => 'BucketCname', + 'CreateCnameToken' => 'BucketCname', + // bucket cors + 'PutBucketCors' => 'BucketCors', + 'GetBucketCors' => 'BucketCors', + 'DeleteBucketCors' => 'BucketCors', + 'OptionObject' => 'BucketCors', + // bucket request payment + 'PutBucketRequestPayment' => 'BucketRequestPayment', + 'GetBucketRequestPayment' => 'BucketRequestPayment', + // bucket tags + 'PutBucketTags' => 'BucketTags', + 'GetBucketTags' => 'BucketTags', + 'DeleteBucketTags' => 'BucketTags', + // bucket referer + 'PutBucketReferer' => 'BucketReferer', + 'GetBucketReferer' => 'BucketReferer', + // bucket website + 'PutBucketWebsite' => 'BucketWebsite', + 'GetBucketWebsite' => 'BucketWebsite', + 'DeleteBucketWebsite' => 'BucketWebsite', + // bucket transfer acceleration + 'PutBucketLogging' => 'BucketLogging', + 'GetBucketLogging' => 'BucketLogging', + 'DeleteBucketLogging' => 'BucketLogging', + 'PutUserDefinedLogFieldsConfig' => 'BucketLogging', + 'GetUserDefinedLogFieldsConfig' => 'BucketLogging', + 'DeleteUserDefinedLogFieldsConfig' => 'BucketLogging', + // bucket policy + 'PutBucketPolicy' => 'BucketPolicy', + 'GetBucketPolicy' => 'BucketPolicy', + 'GetBucketPolicyStatus' => 'BucketPolicy', + 'DeleteBucketPolicy' => 'BucketPolicy', + // bucket encryption + 'PutBucketEncryption' => 'BucketEncryption', + 'GetBucketEncryption' => 'BucketEncryption', + 'DeleteBucketEncryption' => 'BucketEncryption', + // bucket archive direct read + 'GetBucketArchiveDirectRead' => 'BucketArchiveDirectRead', + 'PutBucketArchiveDirectRead' => 'BucketArchiveDirectRead', + // public access block + 'GetPublicAccessBlock' => 'PublicAccessBlock', + 'PutPublicAccessBlock' => 'PublicAccessBlock', + 'DeletePublicAccessBlock' => 'PublicAccessBlock', + // bucket public access block + 'GetBucketPublicAccessBlock' => 'BucketPublicAccessBlock', + 'PutBucketPublicAccessBlock' => 'BucketPublicAccessBlock', + 'DeleteBucketPublicAccessBlock' => 'BucketPublicAccessBlock', + // access point + 'ListAccessPoints' => 'AccessPoint', + 'GetAccessPoint' => 'AccessPoint', + 'GetAccessPointPolicy' => 'AccessPoint', + 'DeleteAccessPointPolicy' => 'AccessPoint', + 'PutAccessPointPolicy' => 'AccessPoint', + 'DeleteAccessPoint' => 'AccessPoint', + 'CreateAccessPoint' => 'AccessPoint', + // bucket replication + 'PutBucketRtc' => 'BucketReplication', + 'PutBucketReplication' => 'BucketReplication', + 'GetBucketReplication' => 'BucketReplication', + 'GetBucketReplicationLocation' => 'BucketReplication', + 'GetBucketReplicationProgress' => 'BucketReplication', + 'DeleteBucketReplication' => 'BucketReplication', + // list cloud boxes + 'ListCloudBoxes' => 'CloudBoxes', + // bucket redundancy transition + 'ListBucketDataRedundancyTransition' => 'BucketRedundancyTransition', + 'ListUserDataRedundancyTransition' => 'BucketRedundancyTransition', + 'GetBucketDataRedundancyTransition' => 'BucketRedundancyTransition', + 'CreateBucketDataRedundancyTransition' => 'BucketRedundancyTransition', + 'DeleteBucketDataRedundancyTransition' => 'BucketRedundancyTransition', + // bucket https config + 'GetBucketHttpsConfig' => 'BucketHttpsConfig', + 'PutBucketHttpsConfig' => 'BucketHttpsConfig', + // bucket resource group + 'GetBucketResourceGroup' => 'BucketResourceGroup', + 'PutBucketResourceGroup' => 'BucketResourceGroup', + // bucket style + 'PutStyle' => 'BucketStyle', + 'ListStyle' => 'BucketStyle', + 'GetStyle' => 'BucketStyle', + 'DeleteStyle' => 'BucketStyle', + // bucket inventory + 'PutBucketInventory' => 'BucketInventory', + 'GetBucketInventory' => 'BucketInventory', + 'ListBucketInventory' => 'BucketInventory', + 'DeleteBucketInventory' => 'BucketInventory', + // bucket overwrite config + 'PutBucketOverwriteConfig' => 'BucketOverwriteConfig', + 'GetBucketOverwriteConfig' => 'BucketOverwriteConfig', + 'DeleteBucketOverwriteConfig' => 'BucketOverwriteConfig', + ]; + + public static function getTransformClass(string $apiName) + { + $group = self::API_MAPS_DEFAULT[$apiName] ?? ''; + if ($group == '') { + $group = self::API_MAPS_8_ONLY[$apiName] ?? ''; + if ($group != '' && version_compare(PHP_VERSION, '8.0.0', '<')) { + throw new \BadMethodCallException("$apiName is available only on php 8 or higher"); + } + } + if ($group != '') { + $group = str_replace('Functions', $group, self::class); + } + return $group; + } + + public static function serializeInputLite(RequestModel $request, OperationInput $input, array $customSerializer = []): OperationInput + { + $ro = new \ReflectionObject($request); + + //headers + $hp = $ro->getProperty('headers'); + if (PHP_VERSION_ID < 80100){ + $hp->setAccessible(true); + } + $h = $hp->getValue($request); + if (is_array($h)) { + foreach ($h as $key => $value) { + $input->setHeader($key, (string)$value); + } + } + + //parameters + $pp = $ro->getProperty('parameters'); + if (PHP_VERSION_ID < 80100){ + $pp->setAccessible(true); + } + $p = $pp->getValue($request); + if (is_array($p)) { + foreach ($p as $key => $value) { + $input->setParameter($key, (string)$value); + } + } + + //payload + $pd = $ro->getProperty('payload'); + if (PHP_VERSION_ID < 80100){ + $pd->setAccessible(true); + } + $payload = $pd->getValue($request); + if ($payload instanceof \Psr\Http\Message\StreamInterface) { + $input->setBody($payload); + } + + // custom serializer + foreach ($customSerializer as $serializer) { + if (\is_callable($serializer)) { + $serializer($request, $input); + } else { + call_user_func($serializer, $request, $input); + } + } + + return $input; + } + + public static function assertFieldRequired(string $filed, $value) + { + if (!isset($value)) { + throw new \InvalidArgumentException("missing required field, $filed."); + } + } + + public static function assertXmlRoot(string $xml, string $expect) + { + if (!preg_match("/<$expect([^>]*)>/", $xml)) { + throw new Exception\DeserializationExecption("Not found tag <$expect>"); + } + } + + public static function assertXmlNodeExist(\SimpleXMLElement $elem, $name) + { + if (empty($elem)) { + throw new Exception\DeserializationExecption("Not found tag <$name>"); + } + } + + public static function tryToString(\SimpleXMLElement &$elem) + { + if ($elem === null || ($elem->count() === 0 && trim((string)$elem) === '')) { + return null; + } + return $elem->__toString(); + } + + public static function tryToDatetime(\SimpleXMLElement &$elem, ?string $format = null) + { + if ($elem === null || ($elem->count() === 0 && trim((string)$elem) === '')) { + return null; + } + + if ($format == null) { + $format = 'Y-m-d\TH:i:s\Z'; + } + $ret = \DateTime::createFromFormat( + $format, + $elem->__toString(), + new \DateTimeZone('UTC') + ); + + if ($ret === false) { + return null; + } + + return $ret; + } + + public static function tryToBool(\SimpleXMLElement &$elem) + { + if ($elem === null || ($elem->count() === 0 && trim((string)$elem) === '')) { + return null; + } + return Utils::safetyBool(strtolower($elem->__toString())); + } + + public static function tryToInt(\SimpleXMLElement &$elem) + { + if ($elem === null || ($elem->count() === 0 && trim((string)$elem) === '')) { + return null; + } + return intval($elem->__toString()); + } + + public static function tryUrldecodeString(\SimpleXMLElement &$elem, bool $decode = false) + { + if ($elem === null || ($elem->count() === 0 && trim((string)$elem) === '')) { + return null; + } + $val = $elem->__toString(); + return $decode == true ? \rawurldecode($val) : $val; + } + + public static function tryUserMetadata(?array $headers) + { + if (!isset($headers)) { + return null; + } + $result = []; + foreach ($headers as $k => $v) { + if (\strncasecmp($k, 'x-oss-meta-', 11) == 0) { + $result[substr($k, 11)] = $v; + } + } + return empty($result) ? null : $result; + } + + public static function addContentType(RequestModel $request, OperationInput $input) + { + if ($input->hasHeader('Content-Type')) { + return; + } + /* + $value = Utils::guessContentType($input->getKey()); + if ($value != null) { + $input->setHeader('Content-Type', $value); + } + */ + $input->setOpMetadata('detect_content_type', true); + } + + public static function addContentMd5(RequestModel $request, OperationInput $input) + { + if ($input->hasHeader('Content-MD5')) { + return; + } + + $value = '1B2M2Y8AsgTpgAmY7PhCfg=='; + if ($input->getBody() != null) { + $value = Utils::calcContentMd5($input->getBody()); + } + $input->setHeader('Content-MD5', $value); + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/ObjectBasic.php b/vendor/alibabacloud/oss-v2/src/Transform/ObjectBasic.php new file mode 100644 index 0000000..21d5fda --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/ObjectBasic.php @@ -0,0 +1,1690 @@ +bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'PutObject', + 'PUT', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\PutObjectRequest $request, OperationInput $input) { + if (isset($request->acl)) { + $input->setHeader('x-oss-object-acl', $request->acl); + } + if (isset($request->storageClass)) { + $input->setHeader('x-oss-storage-class', $request->storageClass); + } + if (isset($request->metadata)) { + foreach ($request->metadata as $k => $v) { + $input->setHeader("x-oss-meta-$k", (string)$v); + } + } + if (isset($request->cacheControl)) { + $input->setHeader('Cache-Control', $request->cacheControl); + } + if (isset($request->contentDisposition)) { + $input->setHeader('Content-Disposition', $request->contentDisposition); + } + if (isset($request->contentEncoding)) { + $input->setHeader('Content-Encoding', $request->contentEncoding); + } + if (isset($request->contentLength)) { + $input->setHeader('Content-Length', (string)$request->contentLength); + } + if (isset($request->contentMd5)) { + $input->setHeader('Content-MD5', $request->contentMd5); + } + if (isset($request->contentType)) { + $input->setHeader('Content-Type', $request->contentType); + } + if (isset($request->expires)) { + $input->setHeader('Expires', $request->expires); + } + if (isset($request->serverSideEncryption)) { + $input->setHeader('x-oss-server-side-encryption', $request->serverSideEncryption); + } + if (isset($request->serverSideDataEncryption)) { + $input->setHeader('x-oss-server-side-data-encryption', $request->serverSideDataEncryption); + } + if (isset($request->serverSideEncryptionKeyId)) { + $input->setHeader('x-oss-server-side-encryption-key-id', $request->serverSideEncryptionKeyId); + } + if (isset($request->tagging)) { + $input->setHeader('x-oss-tagging', $request->tagging); + } + if (isset($request->callback)) { + $input->setHeader('x-oss-callback', $request->callback); + } + if (isset($request->callbackVar)) { + $input->setHeader('x-oss-callback-var', $request->callbackVar); + } + if (isset($request->forbidOverwrite)) { + $input->setHeader('x-oss-forbid-overwrite', $request->forbidOverwrite == true ? 'true' : 'false'); + } + if (isset($request->trafficLimit)) { + $input->setHeader('x-oss-traffic-limit', (string)$request->trafficLimit); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->body)) { + $input->setBody($request->body); + } + if (isset($request->progressFn) && $input->getBody() != null) { + $input->setBody(new ProgressStream( + $input->getBody(), + $request->progressFn, + $input->getBody()->getSize() + )); + } + }, + [Functions::class, 'addContentType'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutObjectResult + */ + public static function toPutObject(OperationOutput $output): Models\PutObjectResult + { + $result = new Models\PutObjectResult(); + $customDeserializer = [ + static function (Models\PutObjectResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('Content-MD5')) { + $result->contentMd5 = $resp->getHeader('Content-MD5')[0]; + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + // callbackResult + if ($output->getOpInput()->hasHeader('x-oss-callback')) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + $result->callbackResult = \json_decode($body, true); + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\CopyObjectRequest $request + * @return OperationInput + */ + public static function fromCopyObject(Models\CopyObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('sourceKey', $request->sourceKey); + $input = new OperationInput( + 'CopyObject', + 'PUT', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\CopyObjectRequest $request, OperationInput $input) { + $srcBucket = $request->sourceBucket ?? $request->bucket; + $srcKey = Utils::urlEncode($request->sourceKey, true); + $copySource = "/$srcBucket/$srcKey"; + if (isset($request->sourceVersionId)) { + $copySource .= "?versionId=$request->sourceVersionId"; + } + $input->setHeader('x-oss-copy-source', $copySource); + + if (isset($request->ifMatch)) { + $input->setHeader('x-oss-copy-source-if-match', $request->ifMatch); + } + if (isset($request->ifNoneMatch)) { + $input->setHeader('x-oss-copy-source-if-none-match', $request->ifNoneMatch); + } + if (isset($request->ifModifiedSince)) { + $input->setHeader('x-oss-copy-source-if-modified-since', $request->ifModifiedSince); + } + if (isset($request->ifUnmodifiedSince)) { + $input->setHeader('x-oss-copy-source-if-unmodified-since', $request->ifUnmodifiedSince); + } + if (isset($request->acl)) { + $input->setHeader('x-oss-object-acl', $request->acl); + } + if (isset($request->storageClass)) { + $input->setHeader('x-oss-storage-class', $request->storageClass); + } + if (isset($request->metadata)) { + foreach ($request->metadata as $k => $v) { + $input->setHeader("x-oss-meta-$k", (string)$v); + } + } + if (isset($request->cacheControl)) { + $input->setHeader('Cache-Control', $request->cacheControl); + } + if (isset($request->contentDisposition)) { + $input->setHeader('Content-Disposition', $request->contentDisposition); + } + if (isset($request->contentEncoding)) { + $input->setHeader('Content-Encoding', $request->contentEncoding); + } + if (isset($request->contentLength)) { + $input->setHeader('Content-Length', (string)$request->contentLength); + } + if (isset($request->contentMd5)) { + $input->setHeader('Content-MD5', $request->contentMd5); + } + if (isset($request->contentType)) { + $input->setHeader('Content-Type', $request->contentType); + } + if (isset($request->expires)) { + $input->setHeader('Expires', $request->expires); + } + if (isset($request->metadataDirective)) { + $input->setHeader('x-oss-metadata-directive', $request->metadataDirective); + } + if (isset($request->serverSideEncryption)) { + $input->setHeader('x-oss-server-side-encryption', $request->serverSideEncryption); + } + if (isset($request->serverSideDataEncryption)) { + $input->setHeader('x-oss-server-side-data-encryption', $request->serverSideDataEncryption); + } + if (isset($request->serverSideEncryptionKeyId)) { + $input->setHeader('x-oss-server-side-encryption-key-id', $request->serverSideEncryptionKeyId); + } + if (isset($request->tagging)) { + $input->setHeader('x-oss-tagging', $request->tagging); + } + if (isset($request->taggingDirective)) { + $input->setHeader('x-oss-tagging-directive', $request->taggingDirective); + } + if (isset($request->forbidOverwrite)) { + $input->setHeader('x-oss-forbid-overwrite', $request->forbidOverwrite == true ? 'true' : 'false'); + } + if (isset($request->trafficLimit)) { + $input->setHeader('x-oss-traffic-limit', (string)$request->trafficLimit); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CopyObjectResult + */ + public static function toCopyObject(OperationOutput $output): Models\CopyObjectResult + { + $result = new Models\CopyObjectResult(); + $customDeserializer = [ + static function (Models\CopyObjectResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-copy-source-version-id')) { + $result->sourceVersionId = $resp->getHeader('x-oss-copy-source-version-id')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption')) { + $result->serverSideEncryption = $resp->getHeader('x-oss-server-side-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-data-encryption')) { + $result->serverSideDataEncryption = $resp->getHeader('x-oss-server-side-data-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption-key-id')) { + $result->serverSideEncryptionKeyId = $resp->getHeader('x-oss-server-side-encryption-key-id')[0]; + } + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'CopyObjectResult'); + $xml = Utils::parseXml($body); + $result->etag = Functions::tryToString($xml->ETag); + $result->lastModified = Functions::tryToDatetime($xml->LastModified, 'Y-m-d\TH:i:s.000\Z'); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetObjectRequest $request + * @return OperationInput + */ + public static function fromGetObject(Models\GetObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\GetObjectRequest $request, OperationInput $input) { + if (isset($request->ifMatch)) { + $input->setHeader('If-Match', $request->ifMatch); + } + if (isset($request->ifNoneMatch)) { + $input->setHeader('If-None-Match', $request->ifNoneMatch); + } + if (isset($request->ifModifiedSince)) { + $input->setHeader('If-Modified-Since', $request->ifModifiedSince); + } + if (isset($request->ifUnmodifiedSince)) { + $input->setHeader('If-Unmodified-Since', $request->ifUnmodifiedSince); + } + if (isset($request->rangeHeader)) { + $input->setHeader('Range', $request->rangeHeader); + } + if (isset($request->rangeBehavior)) { + $input->setHeader('x-oss-range-behavior', $request->rangeBehavior); + } + + if (isset($request->responseCacheControl)) { + $input->setParameter('response-cache-control', $request->responseCacheControl); + } + if (isset($request->responseContentDisposition)) { + $input->setParameter('response-content-disposition', $request->responseContentDisposition); + } + if (isset($request->responseContentEncoding)) { + $input->setParameter('response-content-encoding', $request->responseContentEncoding); + } + if (isset($request->responseContentLanguage)) { + $input->setParameter('response-content-language', $request->responseContentLanguage); + } + if (isset($request->responseContentType)) { + $input->setParameter('response-content-type', $request->responseContentType); + } + if (isset($request->responseExpires)) { + $input->setParameter('response-expires', $request->responseExpires); + } + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->process)) { + $input->setParameter('x-oss-process', $request->process); + } + if (isset($request->trafficLimit)) { + $input->setHeader('x-oss-traffic-limit', (string)$request->trafficLimit); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + // TDDO progress_fn + if (isset($request->progressFn)) { + } + } + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetObjectResult + */ + public static function toGetObject(OperationOutput $output): Models\GetObjectResult + { + $result = new Models\GetObjectResult(); + $customDeserializer = [ + static function (Models\GetObjectResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('Content-Length')) { + $result->contentLength = intval($resp->getHeader('Content-Length')[0]); + } + if ($resp->hasHeader('Content-Range')) { + $result->contentRange = $resp->getHeader('Content-Range')[0]; + } + if ($resp->hasHeader('Content-Type')) { + $result->contentType = $resp->getHeader('Content-Type')[0]; + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + if ($resp->hasHeader('Last-Modified')) { + $result->lastModified = \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $resp->getHeader('Last-Modified')[0], + new \DateTimeZone('UTC') + ); + } + if ($resp->hasHeader('Content-MD5')) { + $result->contentMd5 = $resp->getHeader('Content-MD5')[0]; + } + if ($resp->hasHeader('Cache-Control')) { + $result->cacheControl = $resp->getHeader('Cache-Control')[0]; + } + if ($resp->hasHeader('Content-Disposition')) { + $result->contentDisposition = $resp->getHeader('Content-Disposition')[0]; + } + if ($resp->hasHeader('Content-Encoding')) { + $result->contentEncoding = $resp->getHeader('Content-Encoding')[0]; + } + if ($resp->hasHeader('Expires')) { + $result->expires = $resp->getHeader('Expires')[0]; + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-storage-class')) { + $result->storageClass = $resp->getHeader('x-oss-storage-class')[0]; + } + if ($resp->hasHeader('x-oss-object-type')) { + $result->objectType = $resp->getHeader('x-oss-object-type')[0]; + } + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-tagging-count')) { + $result->taggingCount = intval($resp->getHeader('x-oss-tagging-count')[0]); + } + if ($resp->hasHeader('x-oss-next-append-position')) { + $result->nextAppendPosition = intval($resp->getHeader('x-oss-next-append-position')[0]); + } + if ($resp->hasHeader('x-oss-expiration')) { + $result->expiration = $resp->getHeader('x-oss-expiration')[0]; + } + if ($resp->hasHeader('x-oss-restore')) { + $result->restore = $resp->getHeader('x-oss-restore')[0]; + } + if ($resp->hasHeader('x-oss-process-status')) { + $result->processStatus = $resp->getHeader('x-oss-process-status')[0]; + } + if ($resp->hasHeader('x-oss-delete-marker')) { + $result->deleteMarker = $resp->getHeader('x-oss-delete-marker')[0] === 'true'; + } + if ($resp->hasHeader('x-oss-server-side-encryption')) { + $result->serverSideEncryption = $resp->getHeader('x-oss-server-side-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-data-encryption')) { + $result->serverSideDataEncryption = $resp->getHeader('x-oss-server-side-data-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption-key-id')) { + $result->serverSideEncryptionKeyId = $resp->getHeader('x-oss-server-side-encryption-key-id')[0]; + } + // usermetadata + $result->metadata = Functions::tryUserMetadata($output->getHeaders()); + + // body + $result->body = $output->getBody(); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\AppendObjectRequest $request + * @return OperationInput + */ + public static function fromAppendObject(Models\AppendObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('position', $request->position); + $input = new OperationInput( + 'AppendObject', + 'POST', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('append', ''); + $input->setOpMetadata('sub-resource', ["append",]); + $customSerializer = [ + static function (Models\AppendObjectRequest $request, OperationInput $input) { + if (isset($request->position)) { + $input->setParameter('position', (string)$request->position); + } + if (isset($request->acl)) { + $input->setHeader('x-oss-object-acl', $request->acl); + } + if (isset($request->storageClass)) { + $input->setHeader('x-oss-storage-class', $request->storageClass); + } + if (isset($request->metadata)) { + foreach ($request->metadata as $k => $v) { + $input->setHeader("x-oss-meta-$k", (string)$v); + } + } + if (isset($request->cacheControl)) { + $input->setHeader('Cache-Control', $request->cacheControl); + } + if (isset($request->contentDisposition)) { + $input->setHeader('Content-Disposition', $request->contentDisposition); + } + if (isset($request->contentEncoding)) { + $input->setHeader('Content-Encoding', $request->contentEncoding); + } + if (isset($request->contentLength)) { + $input->setHeader('Content-Length', (string)$request->contentLength); + } + if (isset($request->contentMd5)) { + $input->setHeader('Content-MD5', $request->contentMd5); + } + if (isset($request->contentType)) { + $input->setHeader('Content-Type', $request->contentType); + } + if (isset($request->expires)) { + $input->setHeader('Expires', $request->expires); + } + if (isset($request->serverSideEncryption)) { + $input->setHeader('x-oss-server-side-encryption', $request->serverSideEncryption); + } + if (isset($request->serverSideDataEncryption)) { + $input->setHeader('x-oss-server-side-data-encryption', $request->serverSideDataEncryption); + } + if (isset($request->serverSideEncryptionKeyId)) { + $input->setHeader('x-oss-server-side-encryption-key-id', $request->serverSideEncryptionKeyId); + } + if (isset($request->tagging)) { + $input->setHeader('x-oss-tagging', $request->tagging); + } + if (isset($request->forbidOverwrite)) { + $input->setHeader('x-oss-forbid-overwrite', $request->forbidOverwrite == true ? 'true' : 'false'); + } + if (isset($request->trafficLimit)) { + $input->setHeader('x-oss-traffic-limit', (string)$request->trafficLimit); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->body)) { + $input->setBody($request->body); + } + if (isset($request->progressFn) && $input->getBody() != null) { + $input->setBody(new ProgressStream( + $input->getBody(), + $request->progressFn, + $input->getBody()->getSize() + )); + } + }, + [Functions::class, 'addContentType'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\AppendObjectResult + */ + public static function toAppendObject(OperationOutput $output): Models\AppendObjectResult + { + $result = new Models\AppendObjectResult(); + $customDeserializer = [ + static function (Models\AppendObjectResult $result, OperationOutput $output) { + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-next-append-position')) { + $result->nextPosition = intval($resp->getHeader('x-oss-next-append-position')[0]); + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption')) { + $result->serverSideEncryption = $resp->getHeader('x-oss-server-side-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-data-encryption')) { + $result->serverSideDataEncryption = $resp->getHeader('x-oss-server-side-data-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption-key-id')) { + $result->serverSideEncryptionKeyId = $resp->getHeader('x-oss-server-side-encryption-key-id')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\SealAppendObjectRequest $request + * @return OperationInput + */ + public static function fromSealAppendObject(Models\SealAppendObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('position', $request->position); + $input = new OperationInput( + 'SealAppendObject', + 'POST', + ['Content-Type' => 'application/xml'], + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('seal', ''); + $input->setOpMetadata('sub-resource', ["seal",]); + $customSerializer = [ + static function (Models\SealAppendObjectRequest $request, OperationInput $input) { + if (isset($request->position)) { + $input->setParameter('position', (string)$request->position); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\SealAppendObjectResult + */ + public static function toSealAppendObject(OperationOutput $output): Models\SealAppendObjectResult + { + $result = new Models\SealAppendObjectResult(); + $customDeserializer = [ + static function (Models\SealAppendObjectResult $result, OperationOutput $output) { + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-sealed-time')) { + $result->sealedTime = $resp->getHeader('x-oss-sealed-time')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteObjectRequest $request + * @return OperationInput + */ + public static function fromDeleteObject(Models\DeleteObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'DeleteObject', + 'DELETE', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\DeleteObjectRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteObjectResult + */ + public static function toDeleteObject(OperationOutput $output): Models\DeleteObjectResult + { + $result = new Models\DeleteObjectResult(); + $customDeserializer = [ + static function (Models\DeleteObjectResult $result, OperationOutput $output) { + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-delete-marker')) { + $result->deleteMarker = $resp->getHeader('x-oss-delete-marker')[0] == 'true'; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteMultipleObjectsRequest $request + * @return OperationInput + */ + public static function fromDeleteMultipleObjects(Models\DeleteMultipleObjectsRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + if (isset($request->objects) && isset($request->delete)) { + throw new \InvalidArgumentException('The objects and delete parameters cannot be set simultaneously'); + } + $input = new OperationInput( + 'DeleteMultipleObjects', + 'POST', + ['Content-Type' => 'application/xml'], + ['delete' => '', 'encoding-type' => 'url'] + ); + $input->setBucket($request->bucket); + $customSerializer = [ + static function (Models\DeleteMultipleObjectsRequest $request, OperationInput $input) { + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + + if (isset($request->delete)) { + /** + * @var Models\Delete + */ + $delete = $request->delete; + Functions::assertFieldRequired('delete.objects', $delete->objects); + $xmlStr = ''; + $xmlStr .= "\n\n"; + $val = 'false'; + if (isset($delete->quiet)) { + $val = $delete->quiet === true ? 'true' : 'false'; + } + $xmlStr .= "$val\n"; + foreach ($delete->objects as $obj) { + $xmlStr .= "\n"; + if (isset($obj->key)) { + $key = Utils::escapeXml($obj->key); + $xmlStr .= "$key\n"; + } + if (isset($obj->versionId)) { + $xmlStr .= "$obj->versionId\n"; + } + $xmlStr .= "\n"; + } + $xmlStr .= ''; + $input->setBody(Utils::streamFor($xmlStr)); + + } else { + Functions::assertFieldRequired('objects', $request->objects); + $xmlStr = ''; + $xmlStr .= "\n\n"; + if (isset($request->quiet)) { + $val = $request->quiet === true ? 'true' : 'false'; + $xmlStr .= "$val\n"; + } + foreach ($request->objects as $obj) { + $xmlStr .= "\n"; + if (isset($obj->key)) { + $key = Utils::escapeXml($obj->key); + $xmlStr .= "$key\n"; + } + if (isset($obj->versionId)) { + $xmlStr .= "$obj->versionId\n"; + } + $xmlStr .= "\n"; + } + $xmlStr .= ''; + $input->setBody(Utils::streamFor($xmlStr)); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteMultipleObjectsResult + */ + public static function toDeleteMultipleObjects(OperationOutput $output): Models\DeleteMultipleObjectsResult + { + $result = new Models\DeleteMultipleObjectsResult(); + $customDeserializer = [ + static function (Models\DeleteMultipleObjectsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'DeleteResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + if (isset($xml->Deleted)) { + $result->deletedObjects = []; + foreach ($xml->Deleted as $deleted) { + $o = new Models\DeletedInfo(); + $o->key = Functions::tryUrldecodeString($deleted->Key, $decode); + $o->versionId = Functions::tryToString($deleted->VersionId); + $o->deleteMarker = Functions::tryToBool($deleted->DeleteMarker); + $o->deleteMarkerVersionId = Functions::tryToString($deleted->DeleteMarkerVersionId); + $result->deletedObjects[] = $o; + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\HeadObjectRequest $request + * @return OperationInput + */ + public static function fromHeadObject(Models\HeadObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'HeadObject', + 'HEAD', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\HeadObjectRequest $request, OperationInput $input) { + if (isset($request->ifMatch)) { + $input->setHeader('If-Match', $request->ifMatch); + } + if (isset($request->ifNoneMatch)) { + $input->setHeader('If-None-Match', $request->ifNoneMatch); + } + if (isset($request->ifModifiedSince)) { + $input->setHeader('If-Modified-Since', $request->ifModifiedSince); + } + if (isset($request->ifUnmodifiedSince)) { + $input->setHeader('If-Unmodified-Since', $request->ifUnmodifiedSince); + } + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + } + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\HeadObjectResult + */ + public static function toHeadObject(OperationOutput $output): Models\HeadObjectResult + { + $result = new Models\HeadObjectResult(); + $customDeserializer = [ + static function (Models\HeadObjectResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('Content-Length')) { + $result->contentLength = intval($resp->getHeader('Content-Length')[0]); + } + if ($resp->hasHeader('Content-Type')) { + $result->contentType = $resp->getHeader('Content-Type')[0]; + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + if ($resp->hasHeader('Last-Modified')) { + $result->lastModified = \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $resp->getHeader('Last-Modified')[0], + new \DateTimeZone('UTC') + ); + } + if ($resp->hasHeader('Content-MD5')) { + $result->contentMd5 = $resp->getHeader('Content-MD5')[0]; + } + if ($resp->hasHeader('Cache-Control')) { + $result->cacheControl = $resp->getHeader('Cache-Control')[0]; + } + if ($resp->hasHeader('Content-Disposition')) { + $result->contentDisposition = $resp->getHeader('Content-Disposition')[0]; + } + if ($resp->hasHeader('Content-Encoding')) { + $result->contentEncoding = $resp->getHeader('Content-Encoding')[0]; + } + if ($resp->hasHeader('Expires')) { + $result->expires = $resp->getHeader('Expires')[0]; + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-storage-class')) { + $result->storageClass = $resp->getHeader('x-oss-storage-class')[0]; + } + if ($resp->hasHeader('x-oss-object-type')) { + $result->objectType = $resp->getHeader('x-oss-object-type')[0]; + } + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-tagging-count')) { + $result->taggingCount = intval($resp->getHeader('x-oss-tagging-count')[0]); + } + if ($resp->hasHeader('x-oss-next-append-position')) { + $result->nextAppendPosition = intval($resp->getHeader('x-oss-next-append-position')[0]); + } + if ($resp->hasHeader('x-oss-expiration')) { + $result->expiration = $resp->getHeader('x-oss-expiration')[0]; + } + if ($resp->hasHeader('x-oss-restore')) { + $result->restore = $resp->getHeader('x-oss-restore')[0]; + } + if ($resp->hasHeader('x-oss-process-status')) { + $result->processStatus = $resp->getHeader('x-oss-process-status')[0]; + } + if ($resp->hasHeader('x-oss-request-charged')) { + $result->requestCharged = $resp->getHeader('x-oss-request-charged')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption')) { + $result->serverSideEncryption = $resp->getHeader('x-oss-server-side-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-data-encryption')) { + $result->serverSideDataEncryption = $resp->getHeader('x-oss-server-side-data-encryption')[0]; + } + if ($resp->hasHeader('x-oss-server-side-encryption-key-id')) { + $result->serverSideEncryptionKeyId = $resp->getHeader('x-oss-server-side-encryption-key-id')[0]; + } + if ($resp->hasHeader('Access-Control-Allow-Origin')) { + $result->allowOrigin = $resp->getHeader('Access-Control-Allow-Origin')[0]; + } + if ($resp->hasHeader('Access-Control-Allow-Methods')) { + $result->allowMethods = $resp->getHeader('Access-Control-Allow-Methods')[0]; + } + if ($resp->hasHeader('Access-Control-Allow-Age')) { + $result->allowAge = $resp->getHeader('Access-Control-Allow-Age')[0]; + } + if ($resp->hasHeader('Access-Control-Allow-Headers')) { + $result->allowHeaders = $resp->getHeader('Access-Control-Allow-Headers')[0]; + } + if ($resp->hasHeader('Access-Control-Expose-Headers')) { + $result->exposeHeaders = $resp->getHeader('Access-Control-Expose-Headers')[0]; + } + if ($resp->hasHeader('x-oss-transition-time')) { + $result->transitionTime = \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $resp->getHeader('x-oss-transition-time')[0], + new \DateTimeZone('UTC') + ); + } + // usermetadata + $result->metadata = Functions::tryUserMetadata($output->getHeaders()); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetObjectMetaRequest $request + * @return OperationInput + */ + public static function fromGetObjectMeta(Models\GetObjectMetaRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'GetObjectMeta', + 'HEAD', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('objectMeta', ''); + $input->setOpMetadata('sub-resource', ["objectMeta",]); + $customSerializer = [ + static function (Models\GetObjectMetaRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + } + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetObjectMetaResult + */ + public static function toGetObjectMeta(OperationOutput $output): Models\GetObjectMetaResult + { + $result = new Models\GetObjectMetaResult(); + $customDeserializer = [ + static function (Models\GetObjectMetaResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('Content-Length')) { + $result->contentLength = intval($resp->getHeader('Content-Length')[0]); + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + if ($resp->hasHeader('Last-Modified')) { + $result->lastModified = \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $resp->getHeader('Last-Modified')[0], + new \DateTimeZone('UTC') + ); + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-last-access-time')) { + $result->lastAccessTime = \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $resp->getHeader('x-oss-last-access-time')[0], + new \DateTimeZone('UTC') + ); + } + if ($resp->hasHeader('x-oss-transition-time')) { + $result->transitionTime = \DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + $resp->getHeader('x-oss-transition-time')[0], + new \DateTimeZone('UTC') + ); + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\RestoreObjectRequest $request + * @return OperationInput + */ + public static function fromRestoreObject(Models\RestoreObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'RestoreObject', + 'POST', + ['Content-Type' => 'application/xml'], + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('restore', ''); + $input->setOpMetadata('sub-resource', ["restore",]); + $customSerializer = [ + static function (Models\RestoreObjectRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->restoreRequest)) { + $xml = new \SimpleXMLElement(''); + if (isset($request->restoreRequest->days)) { + $xml->addChild('Days', (string)$request->restoreRequest->days); + } + if (isset($request->restoreRequest->tier)) { + $tier = $xml->addChild('JobParameters'); + $tier->addChild('Tier', $request->restoreRequest->tier); + } + $input->setBody(Utils::streamFor($xml->asXML())); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\RestoreObjectResult + */ + public static function toRestoreObject(OperationOutput $output): Models\RestoreObjectResult + { + $result = new Models\RestoreObjectResult(); + $customDeserializer = [ + static function (Models\RestoreObjectResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-object-restore-priority')) { + $result->restorePriority = $resp->getHeader('x-oss-object-restore-priority')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\CleanRestoredObjectRequest $request + * @return OperationInput + */ + public static function fromCleanRestoredObject(Models\CleanRestoredObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'CleanRestoredObject', + 'POST', + ['Content-Type' => 'application/xml'], + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('cleanRestoredObject', ''); + $input->setOpMetadata('sub-resource', ["cleanRestoredObject"]); + $customSerializer = [ + static function (Models\CleanRestoredObjectRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CleanRestoredObjectResult + */ + public static function toCleanRestoredObject(OperationOutput $output): Models\CleanRestoredObjectResult + { + $result = new Models\CleanRestoredObjectResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\PutObjectAclRequest $request + * @return OperationInput + */ + public static function fromPutObjectAcl(Models\PutObjectAclRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('acl', $request->acl); + $input = new OperationInput( + 'PutObjectAcl', + 'PUT', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('acl', ''); + $input->setOpMetadata('sub-resource', ["acl",]); + $customSerializer = [ + static function (Models\PutObjectAclRequest $request, OperationInput $input) { + if (isset($request->acl)) { + $input->setHeader('x-oss-object-acl', $request->acl); + } + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutObjectAclResult + */ + public static function toPutObjectAcl(OperationOutput $output): Models\PutObjectAclResult + { + $result = new Models\PutObjectAclResult(); + $customDeserializer = [ + static function (Models\PutObjectAclResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetObjectAclRequest $request + * @return OperationInput + */ + public static function fromGetObjectAcl(Models\GetObjectAclRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'GetObjectAcl', + 'GET', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('acl', ''); + $input->setOpMetadata('sub-resource', ["acl",]); + $customSerializer = [ + static function (Models\GetObjectAclRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetObjectAclResult + */ + public static function toGetObjectAcl(OperationOutput $output): Models\GetObjectAclResult + { + $result = new Models\GetObjectAclResult(); + $customDeserializer = [ + static function (Models\GetObjectAclResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'AccessControlPolicy'); + $xml = Utils::parseXml($body); + if (isset($xml->Owner)) { + $result->owner = new Models\Owner( + Functions::tryToString($xml->Owner->ID), + Functions::tryToString($xml->Owner->DisplayName) + ); + } + if (isset($xml->AccessControlList)) { + $result->accessControlList = new Models\AccessControlList( + Functions::tryToString($xml->AccessControlList->Grant) + ); + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutObjectTaggingRequest $request + * @return OperationInput + */ + public static function fromPutObjectTagging(Models\PutObjectTaggingRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('tagging', $request->tagging); + $input = new OperationInput( + 'PutObjectTagging', + 'PUT', + ['Content-Type' => 'application/xml'], + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('tagging', ''); + $input->setOpMetadata('sub-resource', ["tagging",]); + $customSerializer = [ + static function (Models\PutObjectTaggingRequest $request, OperationInput $input) { + if (isset($request->tagging)) { + $xml = new \SimpleXMLElement(''); + if (isset($request->tagging->tagSet)) { + $xmlTagSet = $xml->addChild('TagSet'); + foreach ($request->tagging->tagSet->tags as $tag) { + $xmlTag = $xmlTagSet->addChild('Tag'); + $xmlTag->addChild('Key', strval($tag->key)); + $xmlTag->addChild('Value', strval($tag->value)); + } + } + $input->setBody(Utils::streamFor($xml->asXML())); + } + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutObjectTaggingResult + */ + public static function toPutObjectTagging(OperationOutput $output): Models\PutObjectTaggingResult + { + $result = new Models\PutObjectTaggingResult(); + $customDeserializer = [ + static function (Models\PutObjectTaggingResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetObjectTaggingRequest $request + * @return OperationInput + */ + public static function fromGetObjectTagging(Models\GetObjectTaggingRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'GetObjectTagging', + 'GET', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('tagging', ''); + $input->setOpMetadata('sub-resource', ["tagging",]); + $customSerializer = [ + static function (Models\GetObjectTaggingRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetObjectTaggingResult + */ + public static function toGetObjectTagging(OperationOutput $output): Models\GetObjectTaggingResult + { + $result = new Models\GetObjectTaggingResult(); + $customDeserializer = [ + static function (Models\GetObjectTaggingResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'Tagging'); + $xml = Utils::parseXml($body); + if (isset($xml->TagSet)) { + $tagset = new Models\TagSet(); + $tagset->tags = []; + foreach ($xml->TagSet->Tag as $tag) { + $tagset->tags[] = new Models\Tag( + Functions::tryToString($tag->Key), + Functions::tryToString($tag->Value), + ); + } + $result->tagSet = $tagset; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\DeleteObjectTaggingRequest $request + * @return OperationInput + */ + public static function fromDeleteObjectTagging(Models\DeleteObjectTaggingRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'DeleteObjectTagging', + 'DELETE', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('tagging', ''); + $input->setOpMetadata('sub-resource', ["tagging",]); + $customSerializer = [ + static function (Models\DeleteObjectTaggingRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeleteObjectTaggingResult + */ + public static function toDeleteObjectTagging(OperationOutput $output): Models\DeleteObjectTaggingResult + { + $result = new Models\DeleteObjectTaggingResult(); + $customDeserializer = [ + static function (Models\DeleteObjectTaggingResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutSymlinkRequest $request + * @return OperationInput + */ + public static function fromPutSymlink(Models\PutSymlinkRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('target', $request->target); + $input = new OperationInput( + 'PutSymlink', + 'PUT', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('symlink', ''); + $input->setOpMetadata('sub-resource', ["symlink",]); + $customSerializer = [ + static function (Models\PutSymlinkRequest $request, OperationInput $input) { + if (isset($request->target)) { + $input->setHeader('x-oss-symlink-target', $request->target); + } + if (isset($request->acl)) { + $input->setHeader('x-oss-object-acl', $request->acl); + } + if (isset($request->storageClass)) { + $input->setHeader('x-oss-storage-class', $request->storageClass); + } + if (isset($request->metadata)) { + foreach ($request->metadata as $k => $v) { + $input->setHeader("x-oss-meta-$k", (string)$v); + } + } + if (isset($request->forbidOverwrite)) { + $input->setHeader('x-oss-forbid-overwrite', $request->forbidOverwrite == true ? 'true' : 'false'); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutSymlinkResult + */ + public static function toPutSymlink(OperationOutput $output): Models\PutSymlinkResult + { + $result = new Models\PutSymlinkResult(); + $customDeserializer = [ + static function (Models\PutSymlinkResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\GetSymlinkRequest $request + * @return OperationInput + */ + public static function fromGetSymlink(Models\GetSymlinkRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'GetSymlink', + 'GET', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('symlink', ''); + $input->setOpMetadata('sub-resource', ["symlink",]); + $customSerializer = [ + static function (Models\GetSymlinkRequest $request, OperationInput $input) { + if (isset($request->versionId)) { + $input->setParameter('versionId', $request->versionId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetSymlinkResult + */ + public static function toGetSymlink(OperationOutput $output): Models\GetSymlinkResult + { + $result = new Models\GetSymlinkResult(); + $customDeserializer = [ + static function (Models\GetSymlinkResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + if ($resp->hasHeader('x-oss-symlink-target')) { + $result->target = $resp->getHeader('x-oss-symlink-target')[0]; + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + $result->metadata = Functions::tryUserMetadata($output->getHeaders()); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\AsyncProcessObjectRequest $request + * @return OperationInput + */ + public static function fromAsyncProcessObject(Models\AsyncProcessObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('process', $request->process); + $input = new OperationInput( + 'AsyncProcessObject', + 'POST', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('x-oss-async-process', ''); + $customSerializer = [ + static function (Models\AsyncProcessObjectRequest $request, OperationInput $input) { + if (isset($request->process)) { + $input->setBody(Utils::streamFor(sprintf("%s=%s", "x-oss-async-process", $request->process))); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\AsyncProcessObjectResult + */ + public static function toAsyncProcessObject(OperationOutput $output): Models\AsyncProcessObjectResult + { + $result = new Models\AsyncProcessObjectResult(); + $customDeserializer = [ + static function (Models\AsyncProcessObjectResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + if (strlen($body) > 0) { + $processResult = json_decode($body, true); + if (is_array($processResult)) { + if (array_key_exists('EventId', $processResult)) { + $result->eventId = $processResult['EventId']; + } + if (array_key_exists('RequestId', $processResult)) { + $result->processRequestId = $processResult['RequestId']; + } + if (array_key_exists('TaskId', $processResult)) { + $result->taskId = $processResult['TaskId']; + } + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ProcessObjectRequest $request + * @return OperationInput + */ + public static function fromProcessObject(Models\ProcessObjectRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('process', $request->process); + $input = new OperationInput( + 'ProcessObject', + 'POST', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $input->setParameter('x-oss-process', ''); + $customSerializer = [ + static function (Models\ProcessObjectRequest $request, OperationInput $input) { + if (isset($request->process)) { + $input->setBody(Utils::streamFor(sprintf("%s=%s", "x-oss-process", $request->process))); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ProcessObjectResult + */ + public static function toProcessObject(OperationOutput $output): Models\ProcessObjectResult + { + $result = new Models\ProcessObjectResult(); + $customDeserializer = [ + static function (Models\ProcessObjectResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + if (strlen($body) > 0) { + $processResult = json_decode($body, true); + if (is_array($processResult)) { + if (array_key_exists('bucket', $processResult)) { + $result->bucket = $processResult['bucket']; + } + if (array_key_exists('fileSize', $processResult)) { + $result->fileSize = (int)$processResult['fileSize']; + } + if (array_key_exists('object', $processResult)) { + $result->key = $processResult['object']; + } + if (array_key_exists('status', $processResult)) { + $result->processStatus = $processResult['status']; + } + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/ObjectMultipart.php b/vendor/alibabacloud/oss-v2/src/Transform/ObjectMultipart.php new file mode 100644 index 0000000..f3ab2eb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/ObjectMultipart.php @@ -0,0 +1,616 @@ +bucket); + Functions::assertFieldRequired('key', $request->key); + $input = new OperationInput( + 'InitiateMultipartUpload', + 'POST', + [], + ['uploads' => '', 'encoding-type' => 'url'] + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\InitiateMultipartUploadRequest $request, OperationInput $input) { + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->storageClass)) { + $input->setHeader('x-oss-storage-class', $request->storageClass); + } + if (isset($request->metadata)) { + foreach ($request->metadata as $k => $v) { + $input->setHeader("x-oss-meta-$k", (string)$v); + } + } + if (isset($request->cacheControl)) { + $input->setHeader('Cache-Control', $request->cacheControl); + } + if (isset($request->contentDisposition)) { + $input->setHeader('Content-Disposition', $request->contentDisposition); + } + if (isset($request->contentEncoding)) { + $input->setHeader('Content-Encoding', $request->contentEncoding); + } + if (isset($request->contentLength)) { + $input->setHeader('Content-Length', (string)$request->contentLength); + } + if (isset($request->contentMd5)) { + $input->setHeader('Content-MD5', $request->contentMd5); + } + if (isset($request->contentType)) { + $input->setHeader('Content-Type', $request->contentType); + } + if (isset($request->expires)) { + $input->setHeader('Expires', $request->expires); + } + if (isset($request->serverSideEncryption)) { + $input->setHeader('x-oss-server-side-encryption', $request->serverSideEncryption); + } + if (isset($request->serverSideDataEncryption)) { + $input->setHeader('x-oss-server-side-data-encryption', $request->serverSideDataEncryption); + } + if (isset($request->serverSideEncryptionKeyId)) { + $input->setHeader('x-oss-server-side-encryption-key-id', $request->serverSideEncryptionKeyId); + } + if (isset($request->tagging)) { + $input->setHeader('x-oss-tagging', $request->tagging); + } + if (isset($request->forbidOverwrite)) { + $input->setHeader('x-oss-forbid-overwrite', $request->forbidOverwrite == true ? 'true' : 'false'); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + if ($request->disableAutoDetectMimeType !== true) { + $customSerializer[] = [Functions::class, 'addContentType']; + } + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\InitiateMultipartUploadResult + */ + public static function toInitiateMultipartUpload(OperationOutput $output): Models\InitiateMultipartUploadResult + { + $result = new Models\InitiateMultipartUploadResult(); + $customDeserializer = [ + static function (Models\InitiateMultipartUploadResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'InitiateMultipartUploadResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->bucket = Functions::tryToString($xml->Bucket); + $result->key = Functions::tryUrldecodeString($xml->Key, $decode); + $result->uploadId = Functions::tryToString($xml->UploadId); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\UploadPartRequest $request + * @return OperationInput + */ + public static function fromUploadPart(Models\UploadPartRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('partNumber', $request->partNumber); + Functions::assertFieldRequired('uploadId', $request->uploadId); + $input = new OperationInput( + 'UploadPart', + 'PUT', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\UploadPartRequest $request, OperationInput $input) { + if (isset($request->partNumber)) { + $input->setParameter('partNumber', strval($request->partNumber)); + } + if (isset($request->uploadId)) { + $input->setParameter('uploadId', $request->uploadId); + } + if (isset($request->contentLength)) { + $input->setHeader('Content-Length', (string)$request->contentLength); + } + if (isset($request->contentMd5)) { + $input->setHeader('Content-MD5', $request->contentMd5); + } + if (isset($request->trafficLimit)) { + $input->setHeader('x-oss-traffic-limit', (string)$request->trafficLimit); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->body)) { + $input->setBody($request->body); + } + if (isset($request->progressFn) && $input->getBody() != null) { + $input->setBody(new ProgressStream( + $input->getBody(), + $request->progressFn, + $input->getBody()->getSize() + )); + } + if (isset($request->clientSideEncryptionKey)) { + $input->setHeader("x-oss-meta-client-side-encryption-key", $request->clientSideEncryptionKey); + } + if (isset($request->clientSideEncryptionStart)) { + $input->setHeader("x-oss-meta-client-side-encryption-start", $request->clientSideEncryptionStart); + } + if (isset($request->clientSideEncryptionCekAlg)) { + $input->setHeader("x-oss-meta-client-side-encryption-cek-alg", $request->clientSideEncryptionCekAlg); + } + if (isset($request->clientSideEncryptionWrapAlg)) { + $input->setHeader("x-oss-meta-client-side-encryption-wrap-alg", $request->clientSideEncryptionWrapAlg); + } + if (isset($request->clientSideEncryptionMatdesc)) { + $input->setHeader("x-oss-meta-client-side-encryption-Matdesc", $request->clientSideEncryptionMatdesc); + } + if (isset($request->clientSideEncryptionUnencryptedContentMd5)) { + $input->setHeader("x-oss-meta-client-side-encryption-unencrypted-content-md5", $request->clientSideEncryptionUnencryptedContentMd5); + } + if (isset($request->clientSideEncryptionUnencryptedContentLength)) { + $input->setHeader("x-oss-meta-client-side-encryption-unencrypted-content-length", (string)$request->clientSideEncryptionUnencryptedContentLength); + } + if (isset($request->clientSideEncryptionDataSize)) { + $input->setHeader("x-oss-meta-client-side-encryption-data-size", (string)$request->clientSideEncryptionDataSize); + } + if (isset($request->clientSideEncryptionPartSize)) { + $input->setHeader("x-oss-meta-client-side-encryption-part-size", (string)$request->clientSideEncryptionPartSize); + } + }, + [Functions::class, 'addContentType'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\UploadPartResult + */ + public static function toUploadPart(OperationOutput $output): Models\UploadPartResult + { + $result = new Models\UploadPartResult(); + $customDeserializer = [ + static function (Models\UploadPartResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('Content-MD5')) { + $result->contentMd5 = $resp->getHeader('Content-MD5')[0]; + } + if ($resp->hasHeader('ETag')) { + $result->etag = $resp->getHeader('ETag')[0]; + } + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\CompleteMultipartUploadRequest $request + * @return OperationInput + */ + public static function fromCompleteMultipartUpload(Models\CompleteMultipartUploadRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('uploadId', $request->uploadId); + $input = new OperationInput( + 'CompleteMultipartUpload', + 'POST', + ['Content-Type' => 'application/xml'], + ['encoding-type' => 'url'] + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\CompleteMultipartUploadRequest $request, OperationInput $input) { + if (isset($request->uploadId)) { + $input->setParameter('uploadId', $request->uploadId); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->acl)) { + $input->setHeader('x-oss-object-acl', $request->acl); + } + if (isset($request->callback)) { + $input->setHeader('x-oss-callback', $request->callback); + } + if (isset($request->callbackVar)) { + $input->setHeader('x-oss-callback-var', $request->callbackVar); + } + if (isset($request->forbidOverwrite)) { + $input->setHeader('x-oss-forbid-overwrite', $request->forbidOverwrite == true ? 'true' : 'false'); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + if (isset($request->completeMultipartUpload)) { + $xml = new \SimpleXMLElement(''); + if (isset($request->completeMultipartUpload->parts)) { + foreach ($request->completeMultipartUpload->parts as $part) { + $xmlPart = $xml->addChild('Part'); + $xmlPart->addChild('PartNumber', strval($part->partNumber)); + $xmlPart->addChild('ETag', $part->etag); + } + } + $input->setBody(Utils::streamFor($xml->asXML())); + } + if (isset($request->completeAll)) { + $input->setHeader('x-oss-complete-all', $request->completeAll); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\CompleteMultipartUploadResult + */ + public static function toCompleteMultipartUpload(OperationOutput $output): Models\CompleteMultipartUploadResult + { + $result = new Models\CompleteMultipartUploadResult(); + $customDeserializer = [ + static function (Models\CompleteMultipartUploadResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-hash-crc64ecma')) { + $result->hashCrc64 = $resp->getHeader('x-oss-hash-crc64ecma')[0]; + } + if ($resp->hasHeader('x-oss-version-id')) { + $result->versionId = $resp->getHeader('x-oss-version-id')[0]; + } + + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + // callbackResult + if ($output->getOpInput()->hasHeader('x-oss-callback')) { + $result->callbackResult = \json_decode($body, true); + } else { + Functions::assertXmlRoot($body, 'CompleteMultipartUploadResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->bucket = Functions::tryToString($xml->Bucket); + $result->key = Functions::tryUrldecodeString($xml->Key, $decode); + $result->location = Functions::tryToString($xml->Location); + $result->etag = Functions::tryToString($xml->ETag); + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\UploadPartCopyRequest $request + * @return OperationInput + */ + public static function fromUploadPartCopy(Models\UploadPartCopyRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('sourceKey', $request->sourceKey); + Functions::assertFieldRequired('partNumber', $request->partNumber); + Functions::assertFieldRequired('uploadId', $request->uploadId); + $input = new OperationInput( + 'UploadPartCopy', + 'PUT', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\UploadPartCopyRequest $request, OperationInput $input) { + if (isset($request->partNumber)) { + $input->setParameter('partNumber', strval($request->partNumber)); + } + if (isset($request->uploadId)) { + $input->setParameter('uploadId', $request->uploadId); + } + $srcBucket = $request->sourceBucket ?? $request->bucket; + $srcKey = Utils::urlEncode($request->sourceKey, true); + $copySource = "/$srcBucket/$srcKey"; + if (isset($request->sourceVersionId)) { + $copySource .= "?versionId=$request->sourceVersionId"; + } + $input->setHeader('x-oss-copy-source', $copySource); + if (isset($request->sourceRange)) { + $input->setHeader('x-oss-copy-source-range', $request->sourceRange); + } + if (isset($request->ifMatch)) { + $input->setHeader('x-oss-copy-source-if-match', $request->ifMatch); + } + if (isset($request->ifNoneMatch)) { + $input->setHeader('x-oss-copy-source-if-none-match', $request->ifNoneMatch); + } + if (isset($request->ifModifiedSince)) { + $input->setHeader('x-oss-copy-source-if-modified-since', $request->ifModifiedSince); + } + if (isset($request->ifUnmodifiedSince)) { + $input->setHeader('x-oss-copy-source-if-unmodified-since', $request->ifUnmodifiedSince); + } + if (isset($request->trafficLimit)) { + $input->setHeader('x-oss-traffic-limit', (string)$request->trafficLimit); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\UploadPartCopyResult + */ + public static function toUploadPartCopy(OperationOutput $output): Models\UploadPartCopyResult + { + $result = new Models\UploadPartCopyResult(); + $customDeserializer = [ + static function (Models\UploadPartCopyResult $result, OperationOutput $output) { + // ResponseInterface supports case-insensitive header field name + $resp = $output->getHttpResponse(); + if ($resp->hasHeader('x-oss-copy-source-version-id')) { + $result->sourceVersionId = $resp->getHeader('x-oss-copy-source-version-id')[0]; + } + + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'CopyPartResult'); + $xml = Utils::parseXml($body); + $result->etag = Functions::tryToString($xml->ETag); + $result->lastModified = Functions::tryToDatetime($xml->LastModified, 'Y-m-d\TH:i:s.000\Z'); + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\AbortMultipartUploadRequest $request + * @return OperationInput + */ + public static function fromAbortMultipartUpload(Models\AbortMultipartUploadRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('uploadId', $request->uploadId); + $input = new OperationInput( + 'AbortMultipartUpload', + 'DELETE', + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\AbortMultipartUploadRequest $request, OperationInput $input) { + if (isset($request->uploadId)) { + $input->setParameter('uploadId', $request->uploadId); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\AbortMultipartUploadResult + */ + public static function toAbortMultipartUpload(OperationOutput $output): Models\AbortMultipartUploadResult + { + $result = new Models\AbortMultipartUploadResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\ListMultipartUploadsRequest $request + * @return OperationInput + */ + public static function fromListMultipartUploads(Models\ListMultipartUploadsRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + $input = new OperationInput( + 'ListMultipartUploads', + 'GET', + ['Content-Type' => 'application/octet-stream'], + ['uploads' => '', 'encoding-type' => 'url'] + ); + $input->setBucket($request->bucket); + $customSerializer = [ + static function (Models\ListMultipartUploadsRequest $request, OperationInput $input) { + if (isset($request->delimiter)) { + $input->setParameter('delimiter', $request->delimiter); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->keyMarker)) { + $input->setParameter('key-marker', $request->keyMarker); + } + if (isset($request->uploadIdMarker)) { + $input->setParameter('upload-id-marker', $request->uploadIdMarker); + } + if (isset($request->maxUploads)) { + $input->setParameter('max-uploads', strval($request->maxUploads)); + } + if (isset($request->prefix)) { + $input->setParameter('prefix', $request->prefix); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListMultipartUploadsResult + */ + public static function toListMultipartUploads(OperationOutput $output): Models\ListMultipartUploadsResult + { + $result = new Models\ListMultipartUploadsResult(); + $customDeserializer = [ + static function (Models\ListMultipartUploadsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'ListMultipartUploadsResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->bucket = Functions::tryToString($xml->Bucket); + $result->prefix = Functions::tryUrldecodeString($xml->Prefix, $decode); + $result->keyMarker = Functions::tryUrldecodeString($xml->KeyMarker, $decode); + $result->uploadIdMarker = Functions::tryToString($xml->UploadIdMarker); + $result->maxUploads = Functions::tryToInt($xml->MaxUploads); + $result->delimiter = Functions::tryUrldecodeString($xml->Delimiter, $decode); + $result->isTruncated = Functions::tryToBool($xml->IsTruncated); + $result->nextKeyMarker = Functions::tryUrldecodeString($xml->NextKeyMarker, $decode); + $result->nextUploadIdMarker = Functions::tryToString($xml->NextUploadIdMarker); + if (isset($xml->Upload)) { + $result->uploads = []; + foreach ($xml->Upload as $upload) { + $o = new Models\Upload(); + $o->key = Functions::tryUrldecodeString($upload->Key, $decode); + $o->uploadId = Functions::tryToString($upload->UploadId); + $o->initiated = Functions::tryToDatetime($upload->Initiated, 'Y-m-d\TH:i:s.000\Z'); + $result->uploads[] = $o; + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\ListPartsRequest $request + * @return OperationInput + */ + public static function fromListParts(Models\ListPartsRequest $request): OperationInput + { + Functions::assertFieldRequired('bucket', $request->bucket); + Functions::assertFieldRequired('key', $request->key); + Functions::assertFieldRequired('uploadId', $request->uploadId); + $input = new OperationInput( + 'ListParts', + 'GET', + ['Content-Type' => 'application/octet-stream'], + ['encoding-type' => 'url'] + ); + $input->setBucket($request->bucket); + $input->setKey($request->key); + $customSerializer = [ + static function (Models\ListPartsRequest $request, OperationInput $input) { + if (isset($request->uploadId)) { + $input->setParameter('uploadId', $request->uploadId); + } + if (isset($request->encodingType)) { + $input->setParameter('encoding-type', $request->encodingType); + } + if (isset($request->maxParts)) { + $input->setParameter('max-parts', strval($request->maxParts)); + } + if (isset($request->partNumberMarker)) { + $input->setParameter('part-number-marker', $request->partNumberMarker); + } + if (isset($request->requestPayer)) { + $input->setHeader('x-oss-request-payer', $request->requestPayer); + } + }, + [Functions::class, 'addContentMd5'] + ]; + Functions::serializeInputLite($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\ListPartsResult + */ + public static function toListParts(OperationOutput $output): Models\ListPartsResult + { + $result = new Models\ListPartsResult(); + $customDeserializer = [ + static function (Models\ListPartsResult $result, OperationOutput $output) { + $body = $output->getBody() != null ? $output->getBody()->getContents() : ''; + Functions::assertXmlRoot($body, 'ListPartsResult'); + $xml = Utils::parseXml($body); + $result->encodingType = Functions::tryToString($xml->EncodingType); + $decode = $result->encodingType === 'url'; + $result->bucket = Functions::tryToString($xml->Bucket); + $result->key = Functions::tryUrldecodeString($xml->Key, $decode); + $result->uploadId = Functions::tryToString($xml->UploadId); + $result->partNumberMarker = Functions::tryToString($xml->PartNumberMarker); + $result->maxParts = Functions::tryToInt($xml->MaxParts); + $result->isTruncated = Functions::tryToBool($xml->IsTruncated); + $result->nextPartNumberMarker = Functions::tryToString($xml->NextPartNumberMarker); + $result->storageClass = Functions::tryToString($xml->StorageClass); + if (isset($xml->Part)) { + $result->parts = []; + foreach ($xml->Part as $part) { + $o = new Models\Part(); + $o->partNumber = Functions::tryToInt($part->PartNumber); + $o->lastModified = Functions::tryToDatetime($part->LastModified, 'Y-m-d\TH:i:s.000\Z'); + $o->etag = Functions::tryToString($part->ETag); + $o->size = Functions::tryToInt($part->Size); + $o->hashCrc64 = Functions::tryToString($part->HashCrc64ecma); + $result->parts[] = $o; + } + } + }, + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Transform/PublicAccessBlock.php b/vendor/alibabacloud/oss-v2/src/Transform/PublicAccessBlock.php new file mode 100644 index 0000000..a210d81 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Transform/PublicAccessBlock.php @@ -0,0 +1,117 @@ + 'application/xml'] + ); + $input->setParameter('publicAccessBlock', ''); + $input->setOpMetadata('sub-resource', ['publicAccessBlock',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\GetPublicAccessBlockResult + */ + public static function toGetPublicAccessBlock(OperationOutput $output): Models\GetPublicAccessBlockResult + { + $result = new Models\GetPublicAccessBlockResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + return $result; + } + + /** + * @param Models\PutPublicAccessBlockRequest $request + * @return OperationInput + */ + public static function fromPutPublicAccessBlock(Models\PutPublicAccessBlockRequest $request): OperationInput + { + $input = new OperationInput( + 'PutPublicAccessBlock', + 'PUT', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('publicAccessBlock', ''); + $input->setOpMetadata('sub-resource', ['publicAccessBlock',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\PutPublicAccessBlockResult + */ + public static function toPutPublicAccessBlock(OperationOutput $output): Models\PutPublicAccessBlockResult + { + $result = new Models\PutPublicAccessBlockResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } + + /** + * @param Models\DeletePublicAccessBlockRequest $request + * @return OperationInput + */ + public static function fromDeletePublicAccessBlock(Models\DeletePublicAccessBlockRequest $request): OperationInput + { + $input = new OperationInput( + 'DeletePublicAccessBlock', + 'DELETE', + ['Content-Type' => 'application/xml'] + ); + $input->setParameter('publicAccessBlock', ''); + $input->setOpMetadata('sub-resource', ['publicAccessBlock',]); + + $customSerializer = [ + [Functions::class, 'addContentMd5'] + ]; + Serializer::serializeInput($request, $input, $customSerializer); + return $input; + } + + /** + * @param OperationOutput $output + * @return Models\DeletePublicAccessBlockResult + */ + public static function toDeletePublicAccessBlock(OperationOutput $output): Models\DeletePublicAccessBlockResult + { + $result = new Models\DeletePublicAccessBlockResult(); + Deserializer::deserializeOutput($result, $output); + return $result; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/src/Types/Model.php b/vendor/alibabacloud/oss-v2/src/Types/Model.php new file mode 100644 index 0000000..996e1fc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Types/Model.php @@ -0,0 +1,8 @@ +$name = $args[0]; + return $this; + } else if (strncmp($method, "get", 3) === 0) { + $name = lcfirst(substr($method, 3)); + return $this->$name; + } else { + throw new Exception($method . "function does not exist"); + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Types/RequestModel.php b/vendor/alibabacloud/oss-v2/src/Types/RequestModel.php new file mode 100644 index 0000000..aac7427 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Types/RequestModel.php @@ -0,0 +1,34 @@ + + */ + protected $headers; + + /** + * @var array + */ + protected $parameters; + + /** + * @var mixed + */ + protected $payload; + + public function __construct(?array $option) + { + if (\is_array($option)) { + $this->headers = $option['headers'] ?? null; + $this->parameters = $option['parameters'] ?? null; + $this->payload = $option['payload'] ?? null; + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Types/ResultModel.php b/vendor/alibabacloud/oss-v2/src/Types/ResultModel.php new file mode 100644 index 0000000..f50a83e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Types/ResultModel.php @@ -0,0 +1,39 @@ + + */ + public array $headers = []; + + public function __construct(array $options = []) { + if (\is_array($options) && !empty($options)) { + if (isset($options['status'])) { + $this->status = $options['status']; + } + if (isset($options['statusCode'])) { + $this->statusCode = $options['statusCode']; + } + if (isset($options['requestId'])) { + $this->requestId = $options['requestId']; + } + if (isset($options['headers'])) { + $this->headers = $options['headers']; + } + } + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Uploader.php b/vendor/alibabacloud/oss-v2/src/Uploader.php new file mode 100644 index 0000000..be11a8d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Uploader.php @@ -0,0 +1,399 @@ + + */ + private $options; + + /** + * @var array Default values for upload configuration. + */ + private $defaultConfig = [ + 'part_size' => Defaults::DEFAULT_UPLOAD_PART_SIZE, + 'parallel_num' => Defaults::DEFAULT_UPLOAD_PARALLEL, + 'leave_parts_on_error' => false, + ]; + + + /** + * Is or not EncryptionClient + * @var bool|null + */ + private ?bool $isEncryptionClient; + + /** + * Uploader constructor. + * @param Client|EncryptionClient $client The client instance. + * @param array $args accepts the following: + * - part_size int: The part size. Default value: 6 MiB. + * - parallel_num int: The number of the upload tasks in parallel. Default value: 3. + * - leave_parts_on_error bool: Specifies whether to retain the uploaded parts when an upload task fails. + * By default, the uploaded parts are not retained. + */ + public function __construct( + $client, + array $args = [] + ) + { + $this->client = $client; + if ($this->client instanceof Client) { + $this->isEncryptionClient = false; + } else { + $this->isEncryptionClient = true; + } + $this->options = $this->filterArgs($args) + $this->defaultConfig; + } + + /** + * upload file + * @param Models\PutObjectRequest $request + * @param string $filepath + * @param array $args + * @return \GuzzleHttp\Promise\Promise + */ + public function uploadFileAsync( + Models\PutObjectRequest $request, + string $filepath, + array $args = [] + ): GuzzleHttp\Promise\Promise + { + $context = []; + $this->checkArgs($context, $request, $args); + $this->checkFilepath($context, $filepath); + $this->applySource($context); + + return $this->upload($context); + } + + /** + * upload file + * @param Models\PutObjectRequest $request + * @param string $filepath + * @param array $args + * @return Models\UploadResult + */ + public function uploadFile( + Models\PutObjectRequest $request, + string $filepath, + array $args = [] + ): Models\UploadResult + { + return $this->uploadFileAsync($request, $filepath, $args)->wait(); + } + + + /** + * upload stream + * @param Models\PutObjectRequest $request + * @param StreamInterface $stream + * @param array $args + * @return \GuzzleHttp\Promise\Promise + */ + public function uploadFromAsync( + Models\PutObjectRequest $request, + StreamInterface $stream, + array $args = [] + ): GuzzleHttp\Promise\Promise + { + $context = []; + $this->checkArgs($context, $request, $args); + $context['stream'] = $stream; + $this->applySource($context); + + return $this->upload($context); + } + + /** + * upload stream + * @param Models\PutObjectRequest $request + * @param StreamInterface $stream + * @param array $args + * @return Models\UploadResult + */ + public function uploadFrom( + Models\PutObjectRequest $request, + StreamInterface $stream, + array $args = [] + ): Models\UploadResult + { + return $this->uploadFromAsync($request, $stream, $args)->wait(); + } + + private function checkArgs(array &$context, Models\PutObjectRequest &$request, array &$args): array + { + if (!Validation::isValidBucketName(Utils::safetyString($request->bucket))) { + throw new \InvalidArgumentException('invalid field, request.bucket.'); + } + + if (!Validation::isValidObjectName(Utils::safetyString($request->key))) { + throw new \InvalidArgumentException('invalid field, request.key.'); + } + + $context = $this->filterArgs($args) + $this->options; + + if (Utils::safetyInt($context['part_size']) <= 0) { + $context['part_size'] = Defaults::DEFAULT_PART_SIZE; + } + + if (Utils::safetyInt($context['parallel_num']) <= 0) { + $context['parallel_num'] = Defaults::DEFAULT_UPLOAD_PARALLEL; + } + + $context['request'] = $request; + + return $context; + } + + private function checkFilepath(array &$context, string $filepath) + { + if ($filepath == '') { + throw new \InvalidArgumentException('invalid field, filepath.'); + } + + $absfilepath = realpath($filepath); + + if (!is_file($absfilepath)) { + throw new \InvalidArgumentException("File not exists, $filepath"); + } + + if (!is_readable($absfilepath)) { + throw new \InvalidArgumentException("File is not readable, $filepath"); + } + + $stat = stat($absfilepath); + + if ($stat === false) { + throw new \InvalidArgumentException("stat fail, $filepath"); + } + + $stream = new GuzzleHttp\Psr7\LazyOpenStream($absfilepath, 'rb'); + $stream->seek(0); + + $context['filepath'] = $filepath; + $context['abs_filepath'] = $absfilepath; + $context['file_stat'] = $stat; + $context['stream'] = $stream; + } + + private function applySource(array &$context) + { + $total_size = $context['stream']->getSize() ?? -1; + $part_size = $context['part_size']; + if ($total_size > 0) { + while ($total_size / $part_size >= Defaults::MAX_UPLOAD_PARTS) { + $part_size += $context['part_size']; + } + } + + $context['total_size'] = $total_size; + $context['part_size'] = $part_size; + } + + private function upload(array &$context): GuzzleHttp\Promise\Promise + { + if ($context['total_size'] >= 0 && $context['total_size'] < $context['part_size']) { + return $this->singlePart($context); + } + + return $this->multiPart($context); + } + + private function singlePart(array &$context): GuzzleHttp\Promise\Promise + { + $request = clone $context['request']; + $request->body = $context['stream']; + if (empty($request->contentType)) { + $request->contentType = $this->get_content_type($context); + } + return $this->client->putObjectAsync($request)->then( + function (Models\PutObjectResult $result) { + $res = new Models\UploadResult(); + Utils::copyResult($res, $result); + return $res; + }, + function ($reason) use ($context) { + return GuzzleHttp\Promise\Create::rejectionFor(new Exception\UploadException( + $context['upload_id'] ?? '', + $context['filepath'] ?? '', + $reason + )); + } + ); + } + + private static function iterPart(array &$context): \Generator + { + $source = $context['stream']; + $seekable = $source->isSeekable() && $source->getMetadata('wrapper_type') === 'plainfile'; + $part_size = intval($context['part_size']); + + for ( + $partNumber = 1; + $seekable ? $source->tell() < $source->getSize() : !$source->eof(); + $partNumber++ + ) { + if ($seekable) { + $body = new GuzzleHttp\Psr7\LimitStream( + new GuzzleHttp\Psr7\LazyOpenStream($source->getMetadata('uri'), 'rb'), + $part_size, + $source->tell() + ); + $source->seek(min($source->tell() + $part_size, $source->getSize())); + } else { + $body = GuzzleHttp\Psr7\Utils::streamFor(); + GuzzleHttp\Psr7\Utils::copyToStream( + new GuzzleHttp\Psr7\LimitStream($source, $part_size, $source->tell()), + $body + ); + } + + yield [$partNumber, $body]; + } + } + + private function multiPart(array &$context): GuzzleHttp\Promise\Promise + { + return GuzzleHttp\Promise\Coroutine::of(function () use (&$context) { + + // init the multipart + $request = new Models\InitiateMultipartUploadRequest(); + Utils::copyRequest($request, $context['request']); + if ($this->isEncryptionClient) { + $request->csePartSize = $context['part_size']; + $request->cseDataSize = $context['total_size']; + } + if (empty($imRequest->contentType)) { + $request->contentType = $this->get_content_type($context); + } + yield $this->client->initiateMultipartUploadAsync($request)->then( + function (Models\InitiateMultipartUploadResult $result) use (&$context) { + $context['upload_id'] = $result->uploadId; + if ($this->isEncryptionClient) { + $context['encryption_multi_part_context'] = $result->encryptionMultipartContext; + } + }, + ); + + // upload part + $context['errors'] = []; + $context['parts'] = []; + $uploadFns = function () use (&$context) { + foreach (self::iterPart($context) as $args) { + $request = new Models\UploadPartRequest(); + Utils::copyRequest($request, $context['request']); + $request->partNumber = $args[0]; + $request->uploadId = $context['upload_id']; + $request->body = $args[1]; + if ($this->isEncryptionClient) { + $request->encryptionMultipartContext = $context['encryption_multi_part_context']; + } + yield $args[0] => $this->client->uploadPartAsync($request)->otherwise( + function ($reason) use (&$context) { + $context['errors'][] = $reason; + return GuzzleHttp\Promise\Create::rejectionFor($reason); + }, + ); + if (!empty($context['errors'])) { + break; + } + } + }; + + $each = new GuzzleHttp\Promise\EachPromise( + $uploadFns(), + [ + 'concurrency' => $context['parallel_num'], + 'fulfilled' => function (Models\UploadPartResult $result, $key) use (&$context) { + $context['parts'][] = new Models\UploadPart($key, $result->etag); + return $result; + } + ] + ); + yield $each->promise(); + + // complete upload + if (empty($context['errors'])) { + $parts = $context['parts']; + usort($parts, function ($a, $b) { + if ($a->partNumber == $b->partNumber) return 0; + return $a->partNumber < $b->partNumber ? -1 : 1; + }); + + $request = new Models\CompleteMultipartUploadRequest(); + Utils::copyRequest($request, $context['request']); + $request->uploadId = $context['upload_id']; + $request->completeMultipartUpload = new Models\CompleteMultipartUpload($parts); + yield $this->client->completeMultipartUploadAsync($request)->then( + function (Models\CompleteMultipartUploadResult $result) use (&$context) { + $context['upload_result'] = $result; + return $result; + }, + function ($reason) use (&$context) { + $context['errors'][] = $reason; + }, + ); + } + + if (!empty($context['errors'])) { + if ($context['leave_parts_on_error'] === false) { + $request = new Models\AbortMultipartUploadRequest(); + Utils::copyRequest($request, $context['request']); + $request->uploadId = $context['upload_id']; + yield $this->client->abortMultipartUploadAsync($request); + } + throw end($context['errors']); + } + })->then( + function ($result) use (&$context) { + $result = $context['upload_result']; + $res = new Models\UploadResult(); + Utils::copyResult($res, $result); + $res->uploadId = $context['upload_id']; + return $res; + }, + function ($reason) use (&$context) { + return GuzzleHttp\Promise\Create::rejectionFor(new Exception\UploadException( + $context['upload_id'] ?? '', + $context['filepath'] ?? '', + $reason + )); + } + ); + } + + private function filterArgs(array &$args) + { + return \array_filter($args, function ($key) { + return \array_key_exists($key, $this->defaultConfig); + }, \ARRAY_FILTER_USE_KEY); + } + + private function get_content_type(array &$context): ?string + { + if (isset($context['abs_filepath'])) { + return Utils::guessContentType($context['abs_filepath'], 'application/octet-stream'); + } + return null; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Utils.php b/vendor/alibabacloud/oss-v2/src/Utils.php new file mode 100644 index 0000000..d6d4895 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Utils.php @@ -0,0 +1,409 @@ + string[]] to array[string => string] + */ + public static function toSimpleArray(array $value): array + { + $result = []; + foreach ($value as $k => $vv) { + if (\is_array($vv)) { + $result[$k] = $vv[0]; + } else { + $result[$k] = $vv; + } + } + return $result; + } + + /** + * change array[string => string[]] to array[string => string] + */ + public static function findXmlElementText(string $xml, string $tag): string + { + $start = \strpos($xml, "<$tag>"); + $len = strlen($tag) + 2; + if ($start === false) { + return ''; + } + + $end = \strpos($xml, "", $start + $len); + if ($end === false) { + return ''; + } + + return \substr($xml, $start + $len, $end - $start - $len); + } + + public static function parseXml(string $value): \SimpleXMLElement + { + $priorSetting = libxml_use_internal_errors(true); + try { + libxml_clear_errors(); + $xml = new \SimpleXMLElement($value); + if ($error = libxml_get_last_error()) { + throw new \RuntimeException($error->message); + } + } catch (\Exception $e) { + throw new Exception\ParserException( + "Error parsing XML: {$e->getMessage()}", + $e, + ); + } finally { + libxml_use_internal_errors($priorSetting); + } + + return $xml; + } + + /** + * escape to the properly escaped XML equivalent of the plain text data s. + * @param string $s + * @return string + */ + public static function escapeXml(string $s): string + { + $result = ''; + $length = strlen($s); + for ($i = 0; $i < $length; $i++) { + $d = $s[$i]; + switch ($d) { + case '"': + $result .= '"'; + break; + case '&': + $result .= '&'; + break; + case '<': + $result .= '<'; + break; + case '>': + $result .= '>'; + break; + case "\t": + $result .= ' '; + break; + case "\n": + $result .= ' '; + break; + case "\r": + $result .= ' '; + break; + default: + $n = ord($d); + if ($n < 0x20) { + $result .= sprintf('&#%02d;', $n); + } else { + $result .= $d; + } + } + } + return $result; + } + + public static function copyRequest($dst, $src): void + { + if ( + !($dst instanceof Types\RequestModel) || + !($dst instanceof Types\RequestModel) + ) { + throw new \InvalidArgumentException('dst or src is not subclass of RequestModel'); + } + + $dstRo = new \ReflectionObject($dst); + $srcRo = new \ReflectionObject($src); + foreach ($dstRo->getProperties() as $property) { + if ($srcRo->hasProperty($property->getName())) { + $pp = $srcRo->getProperty($property->getName()); + if (PHP_VERSION_ID < 80100) { + $pp->setAccessible(true); + } + $v = $pp->getValue($src); + if (isset($v)) { + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($dst, $v); + } + } + } + } + + public static function copyResult($dst, $src): void + { + if ( + !($dst instanceof Types\ResultModel) || + !($dst instanceof Types\ResultModel) + ) { + throw new \InvalidArgumentException('dst or src is not subclass of ResultModel'); + } + + $dstRo = new \ReflectionObject($dst); + $srcRo = new \ReflectionObject($src); + foreach ($dstRo->getProperties() as $property) { + if ($srcRo->hasProperty($property->getName())) { + $pp = $srcRo->getProperty($property->getName()); + if (PHP_VERSION_ID < 80100) { + $pp->setAccessible(true); + } + $v = $pp->getValue($src); + if (isset($v)) { + if (PHP_VERSION_ID < 80100) { + $property->setAccessible(true); + } + $property->setValue($dst, $v); + } + } + } + } + + /** + * Parses a http range string into array. + * + * @param string $range Http range string (e.g., "bytes=0-1023") + * + * @return array | false + */ + static function parseHttpRange($range) + { + // doesn't start with bytes=. or empty + if (strncmp($range, 'bytes=', 6) != 0) { + return false; + } + $range = substr($range, 6); + + // contains multiple ranges which isn't supported. + if (strpos($range, ',') !== false) { + return false; + } + + // contains no '-' + $vals = explode('-', $range); + if (count($vals) != 2) { + return false; + } + + $start = -1; + if (strlen($vals[0]) > 0) { + $val = intval($vals[0]); + if ($val == 0 && $vals[0] !== '0') { + return false; + } + $start = $val; + } + + $end = -1; + if (strlen($vals[1]) > 0) { + $val = intval($vals[1]); + if ($val == 0 && $vals[1] !== '0') { + return false; + } + $end = $val; + } + + return [$start, $end]; + } + + /** + * Parses a content range string into array. + * + * @param string $range Http range string (e.g., "bytes 0-10239/25723") + * + * @return array | false + */ + static function parseContentRange($range) + { + // doesn't start with 'bytes ' or empty + if (strncmp($range, 'bytes ', 6) != 0) { + return false; + } + $range = substr($range, 6); + + // contains no '-' + $vals = explode('-', $range); + if (count($vals) != 2) { + return false; + } + + // start + $vals[0] = trim($vals[0]); + if ($vals[0] == '') { + return false; + } + $start = intval($vals[0]); + if ($start < 0 || ($start == 0 && $vals[0] != '0')) { + return false; + } + + $vals = explode('/', $vals[1]); + + // end + $vals[0] = trim($vals[0]); + if ($vals[0] == '') { + return false; + } + $end = intval($vals[0]); + if ($end < 0 || ($end == 0 && $vals[0] != '0')) { + return false; + } + + // total + $vals[1] = trim($vals[1]); + if ($vals[1] == '*') { + $total = -1; + } else { + $total = intval($vals[1]); + if ($total < 0 || ($total == 0 && $vals[1] != '0')) { + return false; + } + } + + return [$start, $end, $total]; + } +} diff --git a/vendor/alibabacloud/oss-v2/src/Validation.php b/vendor/alibabacloud/oss-v2/src/Validation.php new file mode 100644 index 0000000..9774817 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/src/Validation.php @@ -0,0 +1,56 @@ +sO@qbs06!kR?lxDnz$rH(!ebD_;iszZ?( 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 literal 0 HcmV?d00001 diff --git a/vendor/alibabacloud/oss-v2/tests/Data/example.jpg b/vendor/alibabacloud/oss-v2/tests/Data/example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ffd46a2f81b1fe020ed0673f27711124110eed3f GIT binary patch literal 21839 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 + $bucketName = self::$bucketName; + // CreateAccessPoint + $accessPointName = 'ap-01-' . strval(rand(0, 100)) . '-' . strval(time()); + $createResult = $client->createAccessPoint(new Oss\Models\CreateAccessPointRequest( + $bucketName, + new Oss\Models\CreateAccessPointConfiguration( + accessPointName: $accessPointName, + networkOrigin: 'internet', + ))); + $this->assertEquals(200, $createResult->statusCode); + $this->assertEquals('OK', $createResult->status); + $this->assertEquals(True, count($createResult->headers) > 0); + $this->assertEquals(24, strlen($createResult->requestId)); + + // GetAccessPoint + $getResult = $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPointName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // ListAccessPoints + $listResult = $client->listAccessPoints(new Oss\Models\ListAccessPointsRequest()); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // PutAccessPointPolicy + $policy = '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["' . self::$USER_ID . '"],"Resource":["acs:oss:' . self::$REGION . ':' . self::$USER_ID . ':accesspoint/' . $accessPointName . '","acs:oss:' . self::$REGION . ':' . self::$USER_ID . ':accesspoint/' . $accessPointName . '/object/*"]}]}'; + $putPolicyResult = $client->putAccessPointPolicy(new Oss\Models\PutAccessPointPolicyRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + body: Oss\Utils::streamFor($policy) + )); + $this->assertEquals(200, $putPolicyResult->statusCode); + $this->assertEquals('OK', $putPolicyResult->status); + $this->assertEquals(True, count($putPolicyResult->headers) > 0); + $this->assertEquals(24, strlen($putPolicyResult->requestId)); + + // GetAccessPointPolicy + $getPolicyResult = $client->getAccessPointPolicy(new Oss\Models\GetAccessPointPolicyRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertEquals(200, $getPolicyResult->statusCode); + $this->assertEquals('OK', $getPolicyResult->status); + $this->assertEquals(True, count($getPolicyResult->headers) > 0); + $this->assertEquals(24, strlen($getPolicyResult->requestId)); + $this->assertEquals($policy, $getPolicyResult->body); + + // DeleteAccessPointPolicy + $delPolicyResult = $client->deleteAccessPointPolicy(new Oss\Models\DeleteAccessPointPolicyRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertEquals(204, $delPolicyResult->statusCode); + $this->assertEquals('No Content', $delPolicyResult->status); + $this->assertEquals(True, count($delPolicyResult->headers) > 0); + $this->assertEquals(24, strlen($delPolicyResult->requestId)); + while (true) { + $getResult = $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPointName + )); + if ($getResult->getAccessPoint->status != 'creating') { + break; + } else { + sleep(3); + } + } + $delResult = $client->deleteAccessPoint(new Oss\Models\DeleteAccessPointRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testAccessPointFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // CreateAccessPoint + try { + $accessPointName = 'ap-01-' . strval(rand(0, 100)) . '-' . strval(time()); + $createResult = $client->createAccessPoint(new Oss\Models\CreateAccessPointRequest( + $bucketName, + new Oss\Models\CreateAccessPointConfiguration( + accessPointName: $accessPointName, + networkOrigin: 'internet', + ))); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CreateAccessPoint', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetAccessPoint + try { + $getResult = $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPointName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetAccessPoint', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // ListAccessPoints + try { + $listResult = $client->listAccessPoints(new Oss\Models\ListAccessPointsRequest()); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListAccessPoints', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // PutAccessPointPolicy + try { + $policy = '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["' . self::$USER_ID . '"],"Resource":["acs:oss:' . self::$REGION . ':' . self::$USER_ID . ':accesspoint/' . $accessPointName . '","acs:oss:' . self::$REGION . ':' . self::$USER_ID . ':accesspoint/' . $accessPointName . '/object/*"]}]}'; + $putPolicyResult = $client->putAccessPointPolicy(new Oss\Models\PutAccessPointPolicyRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + body: Oss\Utils::streamFor($policy) + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutAccessPointPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetAccessPointPolicy + try { + $getPolicyResult = $client->getAccessPointPolicy(new Oss\Models\GetAccessPointPolicyRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetAccessPointPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteAccessPointPolicy + try { + $delPolicyResult = $client->deleteAccessPointPolicy(new Oss\Models\DeleteAccessPointPolicyRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteAccessPointPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetAccessPoint + try { + $getResult = $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPointName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetAccessPoint', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteAccessPoint + try { + $delResult = $client->deleteAccessPoint(new Oss\Models\DeleteAccessPointRequest( + bucket: $bucketName, + accessPointName: $accessPointName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteAccessPoint', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketAccessMonitorTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketAccessMonitorTest.php new file mode 100644 index 0000000..ac19c57 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketAccessMonitorTest.php @@ -0,0 +1,80 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketAccessMonitor + $putResult = $client->putBucketAccessMonitor(new Oss\Models\PutBucketAccessMonitorRequest( + $bucketName, + new Oss\Models\AccessMonitorConfiguration( + status: Oss\Models\AccessMonitorStatusType::ENABLED + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketAccessMonitor + $getResult = $client->getBucketAccessMonitor(new Oss\Models\GetBucketAccessMonitorRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + } + + public function testBucketAccessMonitorFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketAccessMonitor + try { + $putResult = $client->putBucketAccessMonitor(new Oss\Models\PutBucketAccessMonitorRequest( + $bucketName, + new Oss\Models\AccessMonitorConfiguration( + status: Oss\Models\AccessMonitorStatusType::ENABLED + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketAccessMonitor', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketAccessMonitor + try { + $getResult = $client->getBucketAccessMonitor(new Oss\Models\GetBucketAccessMonitorRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketAccessMonitor', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketArchiveDirectReadTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketArchiveDirectReadTest.php new file mode 100644 index 0000000..de6aacf --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketArchiveDirectReadTest.php @@ -0,0 +1,81 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketArchiveDirectRead + $putResult = $client->putBucketArchiveDirectRead(new Oss\Models\PutBucketArchiveDirectReadRequest( + $bucketName, + new Oss\Models\ArchiveDirectReadConfiguration( + true + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketArchiveDirectRead + $getResult = $client->getBucketArchiveDirectRead(new Oss\Models\GetBucketArchiveDirectReadRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + } + + public function testBucketArchiveDirectReadFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketArchiveDirectRead + try { + $putResult = $client->putBucketArchiveDirectRead(new Oss\Models\PutBucketArchiveDirectReadRequest( + $bucketName, + new Oss\Models\ArchiveDirectReadConfiguration( + true + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketArchiveDirectRead', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketArchiveDirectRead + try { + $getResult = $client->getBucketArchiveDirectRead(new Oss\Models\GetBucketArchiveDirectReadRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketArchiveDirectRead', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketBasicTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketBasicTest.php new file mode 100644 index 0000000..cb9316b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketBasicTest.php @@ -0,0 +1,514 @@ +getDefaultClient(); + + //default + $bucketName = self::randomBucketName() . "-default"; + $result = $client->putBucket(new Oss\Models\PutBucketRequest( + $bucketName + )); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get stat + $result = $client->getBucketStat(new Oss\Models\GetBucketStatRequest( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(0, $result->storage); + + // get location + $result = $client->getBucketLocation(new Oss\Models\GetBucketLocationRequest( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $region = self::$REGION; + $this->assertEquals("oss-$region", $result->location); + + // get info + $result = $client->getBucketInfo(new Oss\Models\GetBucketInfoRequest( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals('private', $result->bucketInfo->acl); + + //delete + $result = $client->deleteBucket(new Oss\Models\DeleteBucketRequest( + $bucketName + )); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // create bucket with acl & storage class & data redundancy + $bucketName = self::randomBucketName() . '-acl-storage'; + $result = $client->putBucket(new Oss\Models\PutBucketRequest( + $bucketName, + 'public-read', + null, + new Oss\Models\CreateBucketConfiguration( + 'IA', + 'ZRS' + ) + )); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get info + $result = $client->getBucketInfo(new Oss\Models\GetBucketInfoRequest( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals('public-read', $result->bucketInfo->acl); + $this->assertEquals('IA', $result->bucketInfo->storageClass); + $this->assertEquals('ZRS', $result->bucketInfo->dataRedundancyType); + + $result = $client->listObjects(new Oss\Models\ListObjectsRequest( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + $result = $client->listObjectsV2(new Oss\Models\ListObjectsV2Request( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + //delete + $result = $client->deleteBucket(new Oss\Models\DeleteBucketRequest( + $bucketName + )); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + } + + public function testBucketAcl() + { + $client = $this->getDefaultClient(); + + //default + $bucketName = self::randomBucketName(); + $result = $client->putBucket(new Oss\Models\PutBucketRequest( + $bucketName + )); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // set acl + $result = $client->putBucketAcl(new Oss\Models\PutBucketAclRequest( + $bucketName, + 'private' + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get acl + $result = $client->getBucketAcl(new Oss\Models\GetBucketAclRequest( + $bucketName + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals('private', $result->accessControlList->grant); + + $client->deleteBucket(new Oss\Models\DeleteBucketRequest( + $bucketName + )); + } + + public function testBucketVersioning() + { + $client = $this->getDefaultClient(); + + //default + $bucketName = self::randomBucketName(); + $result = $client->putBucket(new Oss\Models\PutBucketRequest( + $bucketName + )); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + $result = $client->putBucketVersioning(new Oss\Models\PutBucketVersioningRequest( + $bucketName, + new Oss\Models\VersioningConfiguration( + Oss\Models\BucketVersioningStatusType::ENABLED + ) + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + $result = $client->getBucketVersioning(new Oss\Models\GetBucketVersioningRequest( + $bucketName, + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(Oss\Models\BucketVersioningStatusType::ENABLED, $result->versioningConfiguration->status); + + $result = $client->listObjectVersions(new Oss\Models\ListObjectVersionsRequest( + $bucketName, + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->versions); + + $this->waitFor(3); + $client->deleteBucket(new Oss\Models\DeleteBucketRequest( + $bucketName + )); + } + + public function testListBuckets() + { + $client = $this->getDefaultClient(); + + //default + $bucketName = self::randomBucketName(); + $result = $client->putBucket(new Oss\Models\PutBucketRequest( + $bucketName + )); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + $result = $client->listBuckets(new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX)); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(True, count($result->buckets) > 0); + + $request = new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX); + $request->tagging = 'k:v'; + $result = $client->listBuckets($request); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->buckets); + + $request = new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX); + $request->tagKey = 'k'; + $request->tagValue = 'v'; + $result = $client->listBuckets($request); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->buckets); + + $this->waitFor(3); + $client->deleteBucket(new Oss\Models\DeleteBucketRequest( + $bucketName + )); + } + + public function testDescribeRegions() + { + $client = $this->getDefaultClient(); + $result = $client->describeRegions(new Oss\Models\DescribeRegionsRequest()); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(true, count($result->regionInfos) > 1); + + $result = $client->describeRegions(new Oss\Models\DescribeRegionsRequest("oss-cn-hangzhou")); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(1, count($result->regionInfos)); + } + + public function testPutBucketFail() + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::randomBucketName(); + $client->putBucket(new Oss\Models\PutBucketRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucket', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testPutBucketAclFail() + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->putBucketAcl(new Oss\Models\PutBucketAclRequest( + $bucketName, + 'private' + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketAcl', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testGetBucketAclFail() + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->getBucketAcl(new Oss\Models\GetBucketAclRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketAcl', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testGetBucketStatFail() + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->getBucketStat(new Oss\Models\GetBucketStatRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketStat', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testGetBucketLocationFail() + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->getBucketLocation(new Oss\Models\GetBucketLocationRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketLocation', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testGetBucketInfoFail(): void + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->getBucketInfo(new Oss\Models\GetBucketInfoRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketInfo', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testPutBucketVersioningFail(): void + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->putBucketVersioning(new Oss\Models\PutBucketVersioningRequest( + $bucketName, + new Oss\Models\VersioningConfiguration('Enabled') + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketVersioning', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testGetBucketVersioningFail(): void + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->GetBucketVersioning(new Oss\Models\GetBucketVersioningRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketVersioning', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testListObjectVersionsFail(): void + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->listObjectVersions(new Oss\Models\ListObjectVersionsRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjectVersions', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testListObjectsFail(): void + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->listObjects(new Oss\Models\ListObjectsRequest( + $bucketName, + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjects', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testListObjectsV2Fail(): void + { + $client = $this->getInvalidAkClient(); + try { + $bucketName = self::$bucketName; + $client->listObjectsV2(new Oss\Models\ListObjectsV2Request( + $bucketName, + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjectsV2', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testListBucketsFail(): void + { + $client = $this->getInvalidAkClient(); + + try { + $bucketName = self::$bucketName; + $client->listBuckets(new Oss\Models\ListBucketsRequest()); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListBuckets', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCnameTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCnameTest.php new file mode 100644 index 0000000..078d7d3 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCnameTest.php @@ -0,0 +1,166 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // CreateCnameToken + $createResult = $client->createCnameToken(new Oss\Models\CreateCnameTokenRequest( + $bucketName, + new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) + ) + )); + $this->assertEquals(200, $createResult->statusCode); + $this->assertEquals('OK', $createResult->status); + $this->assertEquals(True, count($createResult->headers) > 0); + $this->assertEquals(24, strlen($createResult->requestId)); + + // GetCnameToken + $getResult = $client->getCnameToken(new Oss\Models\GetCnameTokenRequest( + $bucketName, + 'example.com' + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // ListCname + $listResult = $client->listCname(new Oss\Models\ListCnameRequest( + $bucketName, + )); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // DeleteCname + $delResult = $client->deleteCname(new Oss\Models\DeleteCnameRequest( + $bucketName, + new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) + ) + )); + $this->assertEquals(200, $delResult->statusCode); + $this->assertEquals('OK', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + + } + + public function testBucketCnameFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + try { + $putResult = $client->putCname(new Oss\Models\PutCnameRequest( + $bucketName, + new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutCname', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $createResult = $client->createCnameToken(new Oss\Models\CreateCnameTokenRequest( + $bucketName, + new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CreateCnameToken', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getTokenResult = $client->getCnameToken(new Oss\Models\GetCnameTokenRequest( + $bucketName, + 'example.com' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetCnameToken', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $listResult = $client->listCname(new Oss\Models\ListCnameRequest( + $bucketName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListCname', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $delResult = $client->deleteCname(new Oss\Models\DeleteCnameRequest( + $bucketName, + new Oss\Models\BucketCnameConfiguration( + new Oss\Models\Cname( + 'example.com' + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteCname', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCorsTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCorsTest.php new file mode 100644 index 0000000..089a8f5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketCorsTest.php @@ -0,0 +1,159 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketCors + $putResult = $client->putBucketCors(new Oss\Models\PutBucketCorsRequest( + $bucketName, + corsConfiguration: new Oss\Models\CORSConfiguration( + array( + new Oss\Models\CORSRule( + allowedOrigins: ['*'], + allowedMethods: ['PUT', 'GET'] + ) + ) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // OptionObject + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object'; + $putObjResult = $client->putObject(new Oss\Models\PutObjectRequest( + $bucketName, + $objectName, + body: Oss\Utils::streamFor('hi oss') + )); + $this->assertEquals(200, $putObjResult->statusCode); + $this->assertEquals('OK', $putObjResult->status); + $this->assertEquals(True, count($putObjResult->headers) > 0); + $this->assertEquals(24, strlen($putObjResult->requestId)); + + $optionObjResult = $client->optionObject(new Oss\Models\OptionObjectRequest( + $bucketName, + $objectName, + origin: 'http://www.example.com', + accessControlRequestMethod: 'PUT', + )); + $this->assertEquals(200, $optionObjResult->statusCode); + $this->assertEquals('OK', $optionObjResult->status); + $this->assertEquals(True, count($optionObjResult->headers) > 0); + $this->assertEquals(24, strlen($optionObjResult->requestId)); + + // GetBucketCors + $getResult = $client->getBucketCors(new Oss\Models\GetBucketCorsRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketCors + $delResult = $client->deleteBucketCors(new Oss\Models\DeleteBucketCorsRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketCorsFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketCors + try { + $putResult = $client->putBucketCors(new Oss\Models\PutBucketCorsRequest( + $bucketName, + corsConfiguration: new Oss\Models\CORSConfiguration( + array( + new Oss\Models\CORSRule( + allowedOrigins: ['*'], + allowedMethods: ['PUT', 'GET'] + ) + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketCors', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object'; + $optionObjResult = $client->optionObject(new Oss\Models\OptionObjectRequest( + $bucketName, + $objectName, + origin: 'http://www.example.com', + accessControlRequestMethod: 'PUT', + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error OptionObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketCors + try { + $getResult = $client->getBucketCors(new Oss\Models\GetBucketCorsRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketCors', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketCors + try { + $delResult = $client->deleteBucketCors(new Oss\Models\DeleteBucketCorsRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketCors', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketDataRedundancyTransitionTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketDataRedundancyTransitionTest.php new file mode 100644 index 0000000..84dd2d2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketDataRedundancyTransitionTest.php @@ -0,0 +1,147 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // CreateBucketDataRedundancyTransition + $createResult = $client->createBucketDataRedundancyTransition(new Oss\Models\CreateBucketDataRedundancyTransitionRequest( + $bucketName, + targetRedundancyType: 'ZRS' + )); + $this->assertEquals(200, $createResult->statusCode); + $this->assertEquals('OK', $createResult->status); + $this->assertEquals(True, count($createResult->headers) > 0); + $this->assertEquals(24, strlen($createResult->requestId)); + + // GetBucketDataRedundancyTransition + $getResult = $client->getBucketDataRedundancyTransition(new Oss\Models\GetBucketDataRedundancyTransitionRequest( + $bucketName, + redundancyTransitionTaskid: $createResult->bucketDataRedundancyTransition->taskId + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // ListBucketDataRedundancyTransition + $listResult = $client->listBucketDataRedundancyTransition(new Oss\Models\ListBucketDataRedundancyTransitionRequest( + $bucketName, + )); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // ListUserDataRedundancyTransition + $listResult = $client->listUserDataRedundancyTransition(new Oss\Models\ListUserDataRedundancyTransitionRequest()); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // DeleteBucketDataRedundancyTransition + $delResult = $client->deleteBucketDataRedundancyTransition(new Oss\Models\DeleteBucketDataRedundancyTransitionRequest( + $bucketName, $createResult->bucketDataRedundancyTransition->taskId + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketDataRedundancyTransitionFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + try { + $createResult = $client->createBucketDataRedundancyTransition(new Oss\Models\CreateBucketDataRedundancyTransitionRequest( + $bucketName, + targetRedundancyType: 'ZRS' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CreateBucketDataRedundancyTransition', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getResult = $client->getBucketDataRedundancyTransition(new Oss\Models\GetBucketDataRedundancyTransitionRequest( + $bucketName, '123' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketDataRedundancyTransition', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $delResult = $client->deleteBucketDataRedundancyTransition(new Oss\Models\DeleteBucketDataRedundancyTransitionRequest( + $bucketName, '123' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketDataRedundancyTransition', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $listResult = $client->listBucketDataRedundancyTransition(new Oss\Models\ListBucketDataRedundancyTransitionRequest( + $bucketName, + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListBucketDataRedundancyTransition', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $client = $this->getInvalidAkClient(); + $listResult = $client->listUserDataRedundancyTransition(new Oss\Models\ListUserDataRedundancyTransitionRequest()); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListUserDataRedundancyTransition', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketEncryptionTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketEncryptionTest.php new file mode 100644 index 0000000..5b1e0da --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketEncryptionTest.php @@ -0,0 +1,109 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + // PutBucketEncryption + $putResult = $client->putBucketEncryption(new Oss\Models\PutBucketEncryptionRequest( + $bucketName, + new Oss\Models\ServerSideEncryptionRule( + new Oss\Models\ApplyServerSideEncryptionByDefault( + sseAlgorithm: 'KMS', + kmsDataEncryption: 'SM4' + )) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketEncryption + $getResult = $client->getBucketEncryption(new Oss\Models\GetBucketEncryptionRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketEncryption + $delResult = $client->deleteBucketEncryption(new Oss\Models\DeleteBucketEncryptionRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketEncryptionFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketEncryption + try { + $putResult = $client->putBucketEncryption(new Oss\Models\PutBucketEncryptionRequest( + $bucketName, + new Oss\Models\ServerSideEncryptionRule( + new Oss\Models\ApplyServerSideEncryptionByDefault( + sseAlgorithm: 'KMS', + kmsDataEncryption: 'SM4' + )) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketEncryption', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketEncryption + try { + $getResult = $client->getBucketEncryption(new Oss\Models\GetBucketEncryptionRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketEncryption', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketEncryption + try { + $delResult = $client->deleteBucketEncryption(new Oss\Models\DeleteBucketEncryptionRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketEncryption', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketHttpsConfigTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketHttpsConfigTest.php new file mode 100644 index 0000000..935e619 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketHttpsConfigTest.php @@ -0,0 +1,116 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketHttpsConfig + $putResult = $client->putBucketHttpsConfig(new Oss\Models\PutBucketHttpsConfigRequest( + $bucketName, + new Oss\Models\HttpsConfiguration( + tls: new Oss\Models\TLS( + tlsVersions: ['TLSv1.2', 'TLSv1.3'], + enable: true + ) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketHttpsConfig + $getResult = $client->getBucketHttpsConfig(new Oss\Models\GetBucketHttpsConfigRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // PutBucketHttpsConfig + $putResult = $client->putBucketHttpsConfig(new Oss\Models\PutBucketHttpsConfigRequest( + $bucketName, + new Oss\Models\HttpsConfiguration( + tls: new Oss\Models\TLS( + tlsVersions: ['TLSv1.2', 'TLSv1.3'], + enable: true + ), + cipherSuite: new Oss\Models\CipherSuite( + enable: true, + strongCipherSuite: false, + customCipherSuites: ['ECDHE-ECDSA-AES128-SHA256', 'ECDHE-RSA-AES128-GCM-SHA256', 'ECDHE-ECDSA-AES256-CCM8'], + tls13CustomCipherSuites: ['TLS_AES_256_GCM_SHA384', 'TLS_AES_128_GCM_SHA256', 'TLS_CHACHA20_POLY1305_SHA256'], + ) + ), + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketHttpsConfig + $getResult = $client->getBucketHttpsConfig(new Oss\Models\GetBucketHttpsConfigRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + } + + public function testBucketHttpsConfigFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketHttpsConfig + try { + $putResult = $client->putBucketHttpsConfig(new Oss\Models\PutBucketHttpsConfigRequest( + $bucketName, + new Oss\Models\HttpsConfiguration( + tls: new Oss\Models\TLS( + tlsVersions: ['TLSv1.2', 'TLSv1.3'], + enable: true + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketHttpsConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketHttpsConfig + try { + $getResult = $client->getBucketHttpsConfig(new Oss\Models\GetBucketHttpsConfigRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketHttpsConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketInventoryTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketInventoryTest.php new file mode 100644 index 0000000..3ff79d7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketInventoryTest.php @@ -0,0 +1,190 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + $id = 'report1' . rand(0, 100) . '-' . time(); + // PutBucketInventory + $putResult = $client->putBucketInventory(new Oss\Models\PutBucketInventoryRequest( + $bucketName, + inventoryId: $id, + inventoryConfiguration: new Oss\Models\InventoryConfiguration( + isEnabled: true, + destination: new Oss\Models\InventoryDestination( + ossBucketDestination: new Oss\Models\InventoryOSSBucketDestination( + bucket: 'acs:oss:::' . $bucketName, + prefix: 'prefix1', + format: Oss\Models\InventoryFormatType::CSV, + accountId: self::$USER_ID, + roleArn: 'acs:ram::' . self::$USER_ID . ':role/AliyunOSSRole' + ) + ), + schedule: new Oss\Models\InventorySchedule( + frequency: Oss\Models\InventoryFrequencyType::DAILY + ), + filter: new Oss\Models\InventoryFilter( + prefix: 'filterPrefix', + lastModifyBeginTimeStamp: 1637883649, + lastModifyEndTimeStamp: 1638347592, + lowerSizeBound: 1024, + upperSizeBound: 1048576, + storageClass: 'Standard,IA' + ), + includedObjectVersions: 'All', + optionalFields: new Oss\Models\OptionalFields( + fields: array( + Oss\Models\InventoryOptionalFieldType::STORAGE_CLASS + ) + ), + id: $id + ))); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketInventory + $getResult = $client->getBucketInventory(new Oss\Models\GetBucketInventoryRequest( + $bucketName, $id + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // ListBucketInventory + $listResult = $client->listBucketInventory(new Oss\Models\ListBucketInventoryRequest( + $bucketName + )); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // DeleteBucketInventory + $delResult = $client->deleteBucketInventory(new Oss\Models\DeleteBucketInventoryRequest( + $bucketName, $id + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketInventoryFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + $id = 'report1' . rand(0, 100) . '-' . time(); + // PutBucketInventory + try { + $putResult = $client->putBucketInventory(new Oss\Models\PutBucketInventoryRequest( + $bucketName, + inventoryId: $id, + inventoryConfiguration: new Oss\Models\InventoryConfiguration( + isEnabled: true, + destination: new Oss\Models\InventoryDestination( + ossBucketDestination: new Oss\Models\InventoryOSSBucketDestination( + bucket: 'acs:oss:::' . $bucketName, + prefix: 'prefix1', + format: Oss\Models\InventoryFormatType::CSV, + accountId: self::$USER_ID, + roleArn: 'acs:ram::' . self::$USER_ID . ':role/AliyunOSSRole' + ) + ), + schedule: new Oss\Models\InventorySchedule( + frequency: Oss\Models\InventoryFrequencyType::DAILY + ), + filter: new Oss\Models\InventoryFilter( + prefix: 'filterPrefix', + lastModifyBeginTimeStamp: 1637883649, + lastModifyEndTimeStamp: 1638347592, + lowerSizeBound: 1024, + upperSizeBound: 1048576, + storageClass: 'Standard,IA' + ), + includedObjectVersions: 'All', + optionalFields: new Oss\Models\OptionalFields( + fields: array( + Oss\Models\InventoryOptionalFieldType::STORAGE_CLASS + ) + ), + id: $id + ))); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketInventory', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketInventory + try { + $getResult = $client->getBucketInventory(new Oss\Models\GetBucketInventoryRequest( + $bucketName, $id + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketInventory', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // ListBucketInventory + try { + $getResult = $client->listBucketInventory(new Oss\Models\ListBucketInventoryRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListBucketInventory', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketInventory + try { + $delResult = $client->deleteBucketInventory(new Oss\Models\DeleteBucketInventoryRequest( + $bucketName, $id + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketInventory', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLifecycleTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLifecycleTest.php new file mode 100644 index 0000000..2d9ffc0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLifecycleTest.php @@ -0,0 +1,127 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketLifecycle + $putResult = $client->putBucketLifecycle(new Oss\Models\PutBucketLifecycleRequest( + $bucketName, + lifecycleConfiguration: new LifecycleConfiguration( + array(new Oss\Models\LifecycleRule( + prefix: 'log/', + transitions: array( + new Oss\Models\LifecycleRuleTransition( + days: 30, + storageClass: 'IA' + ) + ), + id: 'rule', + status: 'Enabled' + )) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketLifecycle + $getResult = $client->getBucketLifecycle(new Oss\Models\GetBucketLifecycleRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketLifecycle + $delResult = $client->deleteBucketLifecycle(new Oss\Models\DeleteBucketLifecycleRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketLifecycleFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketLifecycle + try { + $putResult = $client->putBucketLifecycle(new Oss\Models\PutBucketLifecycleRequest( + $bucketName, + lifecycleConfiguration: new LifecycleConfiguration( + array(new Oss\Models\LifecycleRule( + prefix: 'log/', + transitions: array( + new Oss\Models\LifecycleRuleTransition( + days: 30, + storageClass: 'IA' + ) + ), + id: 'rule', + status: 'Enabled' + )) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketLifecycle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketLifecycle + try { + $getResult = $client->getBucketLifecycle(new Oss\Models\GetBucketLifecycleRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketLifecycle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketLifecycle + try { + $delResult = $client->deleteBucketLifecycle(new Oss\Models\DeleteBucketLifecycleRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketLifecycle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLoggingTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLoggingTest.php new file mode 100644 index 0000000..065db3b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketLoggingTest.php @@ -0,0 +1,188 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketLogging + $putResult = $client->putBucketLogging(new Oss\Models\PutBucketLoggingRequest( + $bucketName, + new Oss\Models\BucketLoggingStatus( + new Oss\Models\LoggingEnabled( + targetBucket: $bucketName, targetPrefix: 'TargetPrefix', loggingRole: 'AliyunOSSLoggingDefaultRole' + ) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketLogging + $getResult = $client->getBucketLogging(new Oss\Models\GetBucketLoggingRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketLogging + $delResult = $client->deleteBucketLogging(new Oss\Models\DeleteBucketLoggingRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + + // PutUserDefinedLogFieldsConfig + $putResult = $client->putUserDefinedLogFieldsConfig(new Oss\Models\PutUserDefinedLogFieldsConfigRequest( + $bucketName, + new Oss\Models\UserDefinedLogFieldsConfiguration( + paramSet: new Oss\Models\LoggingParamSet(['param1', 'param2']), headerSet: new Oss\Models\LoggingHeaderSet(['header1', 'header2']) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetUserDefinedLogFieldsConfig + $getResult = $client->getUserDefinedLogFieldsConfig(new Oss\Models\GetUserDefinedLogFieldsConfigRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteUserDefinedLogFieldsConfig + $delResult = $client->deleteUserDefinedLogFieldsConfig(new Oss\Models\DeleteUserDefinedLogFieldsConfigRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketLoggingFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + try { + $putResult = $client->putBucketLogging(new Oss\Models\PutBucketLoggingRequest( + $bucketName, + new Oss\Models\BucketLoggingStatus( + new Oss\Models\LoggingEnabled( + targetBucket: $bucketName, targetPrefix: 'TargetPrefix' + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketLogging', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getResult = $client->getBucketLogging(new Oss\Models\GetBucketLoggingRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketLogging', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $delResult = $client->deleteBucketLogging(new Oss\Models\DeleteBucketLoggingRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketLogging', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $putResult = $client->putUserDefinedLogFieldsConfig(new Oss\Models\PutUserDefinedLogFieldsConfigRequest( + $bucketName, + new Oss\Models\UserDefinedLogFieldsConfiguration( + paramSet: new Oss\Models\LoggingParamSet(['param1', 'param2']), headerSet: new Oss\Models\LoggingHeaderSet(['header1', 'header2']) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutUserDefinedLogFieldsConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getResult = $client->getUserDefinedLogFieldsConfig(new Oss\Models\GetUserDefinedLogFieldsConfigRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetUserDefinedLogFieldsConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $delResult = $client->deleteUserDefinedLogFieldsConfig(new Oss\Models\DeleteUserDefinedLogFieldsConfigRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteUserDefinedLogFieldsConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketMetaQueryTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketMetaQueryTest.php new file mode 100644 index 0000000..e498ee5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketMetaQueryTest.php @@ -0,0 +1,184 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // OpenMetaQuery + $putResult = $client->openMetaQuery(new Oss\Models\OpenMetaQueryRequest( + $bucketName, + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetMetaQueryStatus + $getResult = $client->getMetaQueryStatus(new Oss\Models\GetMetaQueryStatusRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DoMetaQuery + $request = new Oss\Models\DoMetaQueryRequest($bucketName, new Oss\Models\MetaQuery( + maxResults: 5, + query: "{'Field': 'Size','Value': '1048576','Operation': 'gt'}", + sort: 'Size', + order: Oss\Models\MetaQueryOrderType::ASC, + aggregations: new Oss\Models\MetaQueryAggregations( + [ + new Oss\Models\MetaQueryAggregation( + field: 'Size', + operation: 'sum' + ), + new Oss\Models\MetaQueryAggregation( + field: 'Size', + operation: 'max' + ), + ] + ), + )); + $doResult = $client->doMetaQuery($request); + $this->assertEquals(200, $doResult->statusCode); + $this->assertEquals('OK', $doResult->status); + $this->assertEquals(True, count($doResult->headers) > 0); + $this->assertEquals(24, strlen($doResult->requestId)); + + // CloseMetaQuery + $closeResult = $client->closeMetaQuery(new Oss\Models\CloseMetaQueryRequest($bucketName)); + $this->assertEquals(200, $closeResult->statusCode); + $this->assertEquals('OK', $closeResult->status); + $this->assertEquals(True, count($closeResult->headers) > 0); + $this->assertEquals(24, strlen($closeResult->requestId)); + + $bucketNameAiSearch = self::$BUCKETNAME_PREFIX . strval(rand(0, 100)) . '-' . strval(time()) . '-semantic'; + $client->putBucket(new Oss\Models\PutBucketRequest($bucketNameAiSearch)); + // OpenMetaQuery with semantic + $putResult = $client->openMetaQuery(new Oss\Models\OpenMetaQueryRequest( + $bucketNameAiSearch, 'semantic' + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // DoMetaQuery with semantic + $request = new Oss\Models\DoMetaQueryRequest($bucketNameAiSearch, new Oss\Models\MetaQuery( + maxResults: 99, + query: "Overlook the snow-covered forest", + mediaTypes: new Oss\Models\MetaQueryMediaTypes('image'), + simpleQuery: '{"Operation":"gt", "Field": "Size", "Value": "30"}', + ), 'semantic'); + $doResult = $client->doMetaQuery($request); + $this->assertEquals(200, $doResult->statusCode); + $this->assertEquals('OK', $doResult->status); + $this->assertEquals(True, count($doResult->headers) > 0); + $this->assertEquals(24, strlen($doResult->requestId)); + + $client->deleteBucket(new Oss\Models\DeleteBucketRequest($bucketNameAiSearch)); + } + + public function testBucketMetaQueryFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // OpenMetaQuery + try { + $putResult = $client->openMetaQuery(new Oss\Models\OpenMetaQueryRequest( + $bucketName, + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error OpenMetaQuery', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetMetaQueryStatus + try { + $getResult = $client->getMetaQueryStatus(new Oss\Models\GetMetaQueryStatusRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetMetaQueryStatus', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DoMetaQuery + try { + $request = new Oss\Models\DoMetaQueryRequest($bucketName, new Oss\Models\MetaQuery( + maxResults: 5, + query: "{'Field': 'Size','Value': '1048576','Operation': 'gt'}", + sort: 'Size', + order: Oss\Models\MetaQueryOrderType::ASC, + aggregations: new Oss\Models\MetaQueryAggregations( + [ + new Oss\Models\MetaQueryAggregation( + field: 'Size', + operation: 'sum' + ), + new Oss\Models\MetaQueryAggregation( + field: 'Size', + operation: 'max' + ), + ] + ), + )); + $doResult = $client->doMetaQuery($request); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DoMetaQuery', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // CloseMetaQuery + try { + $closeResult = $client->closeMetaQuery(new Oss\Models\CloseMetaQueryRequest($bucketName)); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CloseMetaQuery', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketOverwriteTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketOverwriteTest.php new file mode 100644 index 0000000..7146d59 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketOverwriteTest.php @@ -0,0 +1,112 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketOverwriteConfig + $putResult = $client->putBucketOverwriteConfig(new Oss\Models\PutBucketOverwriteConfigRequest( + $bucketName, + new Oss\Models\OverwriteConfiguration( + array( + new Oss\Models\OverwriteRule( + 'forbid', null, null, null, 'rule-001' + ) + ) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketOverwriteConfig + $getResult = $client->getBucketOverwriteConfig(new Oss\Models\GetBucketOverwriteConfigRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketOverwriteConfig + $delResult = $client->deleteBucketOverwriteConfig(new Oss\Models\DeleteBucketOverwriteConfigRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketOverwriteConfigFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + try { + $putResult = $client->putBucketOverwriteConfig(new Oss\Models\PutBucketOverwriteConfigRequest( + $bucketName, + new Oss\Models\OverwriteConfiguration( + array( + new Oss\Models\OverwriteRule( + 'forbid', null, null, null, 'rule-001' + ) + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketOverwriteConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('MalformedXML', $se->getErrorCode()); + $this->assertEquals(400, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getResult = $client->getBucketOverwriteConfig(new Oss\Models\GetBucketOverwriteConfigRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketOverwriteConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $delResult = $client->deleteBucketOverwriteConfig(new Oss\Models\DeleteBucketOverwriteConfigRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketOverwriteConfig', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPolicyTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPolicyTest.php new file mode 100644 index 0000000..860f6f1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPolicyTest.php @@ -0,0 +1,136 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + $client->putBucketPublicAccessBlock(new Oss\Models\PutBucketPublicAccessBlockRequest( + $bucketName, + new Oss\Models\PublicAccessBlockConfiguration( + false + ) + )); + + // PutBucketPolicy + $putResult = $client->putBucketPolicy(new Oss\Models\PutBucketPolicyRequest( + $bucketName, + '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Allow","Resource":["acs:oss:*:*:*"]}]}' + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketPolicy + $getResult = $client->getBucketPolicy(new Oss\Models\GetBucketPolicyRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // GetBucketPolicyStatus + $getResult2 = $client->getBucketPolicyStatus(new Oss\Models\GetBucketPolicyStatusRequest( + $bucketName + )); + $this->assertEquals(200, $getResult2->statusCode); + $this->assertEquals('OK', $getResult2->status); + $this->assertEquals(True, count($getResult2->headers) > 0); + $this->assertEquals(24, strlen($getResult2->requestId)); + + // DeleteBucketPolicy + $delResult = $client->deleteBucketPolicy(new Oss\Models\DeleteBucketPolicyRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketTransferAccelerationFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketPolicy + try { + $putResult = $client->putBucketPolicy(new Oss\Models\PutBucketPolicyRequest( + $bucketName, + '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Allow","Resource":["acs:oss:*:*:*"]}]}' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketPolicy + try { + $getResult = $client->getBucketPolicy(new Oss\Models\GetBucketPolicyRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketPolicyStatus + try { + $getResult = $client->getBucketPolicyStatus(new Oss\Models\GetBucketPolicyStatusRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketPolicyStatus', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketPolicy + try { + $delResult = $client->deleteBucketPolicy(new Oss\Models\DeleteBucketPolicyRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketPolicy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPublicAccessBlockTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPublicAccessBlockTest.php new file mode 100644 index 0000000..a3dda34 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketPublicAccessBlockTest.php @@ -0,0 +1,90 @@ +getDefaultClient(); + $bucket = self::$bucketName; + // PutBucketPublicAccessBlock + $putResult = $client->putBucketPublicAccessBlock(new Oss\Models\PutBucketPublicAccessBlockRequest( + $bucket, new Oss\Models\PublicAccessBlockConfiguration(true) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketPublicAccessBlock + $getResult = $client->getBucketPublicAccessBlock(new Oss\Models\GetBucketPublicAccessBlockRequest($bucket)); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketPublicAccessBlock + $delResult = $client->deleteBucketPublicAccessBlock(new Oss\Models\DeleteBucketPublicAccessBlockRequest($bucket)); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketPublicAccessBlockFail() + { + $client = $this->getInvalidAkClient(); + $bucketName = self::$bucketName; + // PutBucketPublicAccessBlock + try { + $putResult = $client->putBucketPublicAccessBlock(new Oss\Models\PutBucketPublicAccessBlockRequest( + $bucketName, new Oss\Models\PublicAccessBlockConfiguration(true) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketPublicAccessBlock', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketPublicAccessBlock + try { + $getResult = $client->getBucketPublicAccessBlock(new Oss\Models\GetBucketPublicAccessBlockRequest($bucketName)); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketPublicAccessBlock', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketPublicAccessBlock + try { + $delResult = $client->deleteBucketPublicAccessBlock(new Oss\Models\DeleteBucketPublicAccessBlockRequest($bucketName)); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketPublicAccessBlock', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRefererTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRefererTest.php new file mode 100644 index 0000000..b1d57ca --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRefererTest.php @@ -0,0 +1,83 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketReferer + $putResult = $client->putBucketReferer(new Oss\Models\PutBucketRefererRequest( + $bucketName, + refererConfiguration: new Oss\Models\RefererConfiguration( + allowEmptyReferer: false, + refererList: new Oss\Models\RefererList([""]), + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketReferer + $getResult = $client->getBucketReferer(new Oss\Models\GetBucketRefererRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + } + + public function testBucketRefererFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketReferer + try { + $putResult = $client->putBucketReferer(new Oss\Models\PutBucketRefererRequest( + $bucketName, + refererConfiguration: new Oss\Models\RefererConfiguration( + allowEmptyReferer: false, + refererList: new Oss\Models\RefererList([""]), + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketReferer', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketReferer + try { + $getResult = $client->getBucketReferer(new Oss\Models\GetBucketRefererRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketReferer', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketReplicationTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketReplicationTest.php new file mode 100644 index 0000000..48fa021 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketReplicationTest.php @@ -0,0 +1,246 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + $targetBucketName = self::randomBucketName() . '-target'; + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider(new Oss\Credentials\StaticCredentialsProvider( + self::$ACCESS_ID, + self::$ACCESS_KEY + )); + $cfg->setRegion('cn-beijing'); + $client1 = new Oss\Client($cfg); + $client1->putBucket(new Oss\Models\PutBucketRequest( + $targetBucketName + )); + + // PutBucketReplication + $putResult = $client->putBucketReplication(new Oss\Models\PutBucketReplicationRequest( + $bucketName, + new Oss\Models\ReplicationConfiguration( + array( + new Oss\Models\ReplicationRule( + sourceSelectionCriteria: new Oss\Models\ReplicationSourceSelectionCriteria( + sseKmsEncryptedObjects: new Oss\Models\SseKmsEncryptedObjects( + status: 'Enabled' + ) + ), + destination: new Oss\Models\ReplicationDestination( + bucket: $targetBucketName, + location: 'oss-cn-beijing', + transferType: Oss\Models\TransferType::INTERNAL + ), + historicalObjectReplication: Oss\Models\HistoricalObjectReplicationType::ENABLED, + rtc: new Oss\Models\ReplicationTimeControl(status: 'enabled') + ) + ) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketReplication + $getResult = $client->getBucketReplication(new Oss\Models\GetBucketReplicationRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // GetBucketReplicationLocation + $getLocationResult = $client->getBucketReplicationLocation(new Oss\Models\GetBucketReplicationLocationRequest( + $bucketName + )); + $this->assertEquals(200, $getLocationResult->statusCode); + $this->assertEquals('OK', $getLocationResult->status); + $this->assertEquals(True, count($getLocationResult->headers) > 0); + $this->assertEquals(24, strlen($getLocationResult->requestId)); + + // GetBucketReplicationProgress + $getProgressResult = $client->getBucketReplicationProgress(new Oss\Models\GetBucketReplicationProgressRequest( + $bucketName, + $getResult->replicationConfiguration->rules[0]->id + )); + $this->assertEquals(200, $getProgressResult->statusCode); + $this->assertEquals('OK', $getProgressResult->status); + $this->assertEquals(True, count($getProgressResult->headers) > 0); + $this->assertEquals(24, strlen($getProgressResult->requestId)); + + // PutBucketRtc + $putRtcResult = $client->putBucketRtc(new Oss\Models\PutBucketRtcRequest( + $bucketName, + rtcConfiguration: new Oss\Models\RtcConfiguration( + rtc: new Oss\Models\ReplicationTimeControl( + status: 'disabled' + ), + id: $getResult->replicationConfiguration->rules[0]->id + ), + )); + $this->assertEquals(200, $putRtcResult->statusCode); + $this->assertEquals('OK', $putRtcResult->status); + $this->assertEquals(True, count($putRtcResult->headers) > 0); + $this->assertEquals(24, strlen($putRtcResult->requestId)); + + // DeleteBucketReplication + $delResult = $client->deleteBucketReplication(new Oss\Models\DeleteBucketReplicationRequest( + $bucketName, + replicationRules: new Oss\Models\ReplicationRules( + ids: [$getResult->replicationConfiguration->rules[0]->id] + ) + ), + ); + $this->assertEquals(200, $delResult->statusCode); + $this->assertEquals('OK', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + $client1->deleteBucket(new Oss\Models\DeleteBucketRequest( + $targetBucketName + )); + } + + public function testBucketReplicationFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketReplication + try { + $putResult = $client->putBucketReplication(new Oss\Models\PutBucketReplicationRequest( + $bucketName, + new Oss\Models\ReplicationConfiguration( + array( + new Oss\Models\ReplicationRule( + sourceSelectionCriteria: new Oss\Models\ReplicationSourceSelectionCriteria( + sseKmsEncryptedObjects: new Oss\Models\SseKmsEncryptedObjects( + status: 'Enabled' + ) + ), + destination: new Oss\Models\ReplicationDestination( + bucket: 'bucket-not-exist', + location: 'oss-cn-beijing', + transferType: Oss\Models\TransferType::INTERNAL + ), + historicalObjectReplication: Oss\Models\HistoricalObjectReplicationType::ENABLED, + rtc: new Oss\Models\ReplicationTimeControl(status: 'enabled') + ) + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketReplication', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketReplication + try { + $getResult = $client->getBucketReplication(new Oss\Models\GetBucketReplicationRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketReplication', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getLocationResult = $client->getBucketReplicationLocation(new Oss\Models\GetBucketReplicationLocationRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketReplicationLocation', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $getProgressResult = $client->getBucketReplicationProgress(new Oss\Models\GetBucketReplicationProgressRequest( + $bucketName, + 'rule-id' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketReplicationProgress', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $putRtcResult = $client->putBucketRtc(new Oss\Models\PutBucketRtcRequest( + $bucketName, + rtcConfiguration: new Oss\Models\RtcConfiguration( + rtc: new Oss\Models\ReplicationTimeControl( + status: 'disabled' + ), + id: 'rule-id' + ), + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketRtc', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + try { + $delResult = $client->deleteBucketReplication(new Oss\Models\DeleteBucketReplicationRequest( + $bucketName, + replicationRules: new Oss\Models\ReplicationRules( + ids: ['rule-id'] + ) + ), + ); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketReplication', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRequestPaymentTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRequestPaymentTest.php new file mode 100644 index 0000000..8137a49 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketRequestPaymentTest.php @@ -0,0 +1,80 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketRequestPayment + $putResult = $client->putBucketRequestPayment(new Oss\Models\PutBucketRequestPaymentRequest( + $bucketName, + new Oss\Models\RequestPaymentConfiguration( + 'Requester' + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketRequestPayment + $getResult = $client->getBucketRequestPayment(new Oss\Models\GetBucketRequestPaymentRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + } + + public function testBucketRequestPaymentFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketRequestPayment + try { + $putResult = $client->putBucketRequestPayment(new Oss\Models\PutBucketRequestPaymentRequest( + $bucketName, + new Oss\Models\RequestPaymentConfiguration( + 'Requester' + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketRequestPayment', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketRequestPayment + try { + $getResult = $client->getBucketRequestPayment(new Oss\Models\GetBucketRequestPaymentRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketRequestPayment', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketResourceGroupTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketResourceGroupTest.php new file mode 100644 index 0000000..20ab920 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketResourceGroupTest.php @@ -0,0 +1,78 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // GetBucketResourceGroup + $getResult = $client->getBucketResourceGroup(new Oss\Models\GetBucketResourceGroupRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // PutBucketResourceGroup + $putResult = $client->putBucketResourceGroup(new Oss\Models\PutBucketResourceGroupRequest( + $bucketName, + new Oss\Models\BucketResourceGroupConfiguration( + $getResult->bucketResourceGroupConfiguration->resourceGroupId + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + } + + public function testBucketResourceGroupFail() + { + $client = $this->getInvalidAkClient(); + $bucketName = self::$bucketName; + + // PutBucketResourceGroup + try { + $putResult = $client->putBucketResourceGroup(new Oss\Models\PutBucketResourceGroupRequest( + $bucketName, + new Oss\Models\BucketResourceGroupConfiguration('rg-123') + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketResourceGroup', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketResourceGroup + try { + $getResult = $client->getBucketResourceGroup(new Oss\Models\GetBucketResourceGroupRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketResourceGroup', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketStyleTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketStyleTest.php new file mode 100644 index 0000000..08e2e7a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketStyleTest.php @@ -0,0 +1,128 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutStyle + $putResult = $client->putStyle(new Oss\Models\PutStyleRequest( + $bucketName, + styleName: 'test', + style: new Oss\Models\StyleContent('image/resize,p_50') + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetStyle + $getResult = $client->getStyle(new Oss\Models\GetStyleRequest( + $bucketName, 'test' + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // ListStyle + $listResult = $client->listStyle(new Oss\Models\ListStyleRequest( + $bucketName + )); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals('OK', $listResult->status); + $this->assertEquals(True, count($listResult->headers) > 0); + $this->assertEquals(24, strlen($listResult->requestId)); + + // DeleteStyle + $delResult = $client->deleteStyle(new Oss\Models\DeleteStyleRequest( + $bucketName, 'test' + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketStyleFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutStyle + try { + $putResult = $client->putStyle(new Oss\Models\PutStyleRequest( + $bucketName, + styleName: 'test', + style: new Oss\Models\StyleContent('image/resize,p_50') + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutStyle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetStyle + try { + $getResult = $client->getStyle(new Oss\Models\GetStyleRequest( + $bucketName, 'test' + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetStyle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // ListStyle + try { + $listResult = $client->listStyle(new Oss\Models\ListStyleRequest( + $bucketName + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListStyle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteStyle + try { + $delResult = $client->deleteStyle(new Oss\Models\DeleteStyleRequest( + $bucketName, 'test' + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteStyle', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTagsTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTagsTest.php new file mode 100644 index 0000000..699ec8f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTagsTest.php @@ -0,0 +1,109 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketTags + $putResult = $client->putBucketTags(new Oss\Models\PutBucketTagsRequest( + $bucketName, + tagging: new Oss\Models\Tagging( + tagSet: new Oss\Models\TagSet( + [new Oss\Models\Tag(key: 'key1', value: 'value1'), new Oss\Models\Tag(key: 'key2', value: 'value2')]) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketTags + $getResult = $client->getBucketTags(new Oss\Models\GetBucketTagsRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketTags + $delResult = $client->deleteBucketTags(new Oss\Models\DeleteBucketTagsRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketTagsFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketTags + try { + $putResult = $client->putBucketTags(new Oss\Models\PutBucketTagsRequest( + $bucketName, + tagging: new Oss\Models\Tagging( + tagSet: new Oss\Models\TagSet( + [new Oss\Models\Tag(key: 'key1', value: 'value1'), new Oss\Models\Tag(key: 'key2', value: 'value2')]) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketTags', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketTags + try { + $getResult = $client->getBucketTags(new Oss\Models\GetBucketTagsRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketTags', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketTags + try { + $delResult = $client->deleteBucketTags(new Oss\Models\DeleteBucketTagsRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketTags', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTransferAccelerationTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTransferAccelerationTest.php new file mode 100644 index 0000000..44a95be --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketTransferAccelerationTest.php @@ -0,0 +1,81 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketTransferAcceleration + $putResult = $client->putBucketTransferAcceleration(new Oss\Models\PutBucketTransferAccelerationRequest( + $bucketName, + new Oss\Models\TransferAccelerationConfiguration( + true + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketTransferAcceleration + $getResult = $client->getBucketTransferAcceleration(new Oss\Models\GetBucketTransferAccelerationRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + } + + public function testBucketTransferAccelerationFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketTransferAcceleration + try { + $putResult = $client->putBucketTransferAcceleration(new Oss\Models\PutBucketTransferAccelerationRequest( + $bucketName, + new Oss\Models\TransferAccelerationConfiguration( + true + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketTransferAcceleration', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketTransferAcceleration + try { + $getResult = $client->getBucketTransferAcceleration(new Oss\Models\GetBucketTransferAccelerationRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketTransferAcceleration', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWebsiteTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWebsiteTest.php new file mode 100644 index 0000000..581933b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWebsiteTest.php @@ -0,0 +1,242 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // PutBucketWebsite + $putResult = $client->putBucketWebsite(new Oss\Models\PutBucketWebsiteRequest( + $bucketName, + websiteConfiguration: new Oss\Models\WebsiteConfiguration( + indexDocument: new Oss\Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + errorDocument: new Oss\Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ) + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetBucketWebsite + $getResult = $client->getBucketWebsite(new Oss\Models\GetBucketWebsiteRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeleteBucketWebsite + $delResult = $client->deleteBucketWebsite(new Oss\Models\DeleteBucketWebsiteRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + + // PutBucketWebsite + $putResult = $client->putBucketWebsite(new Oss\Models\PutBucketWebsiteRequest( + $bucketName, + websiteConfiguration: new Oss\Models\WebsiteConfiguration( + indexDocument: new Oss\Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + errorDocument: new Oss\Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ), + routingRules: new Oss\Models\RoutingRules([ + new Oss\Models\RoutingRule( + redirect: new Oss\Models\RoutingRuleRedirect( + mirrorPassOriginalSlashes: false, + redirectType: 'Mirror', + mirrorURL: 'http://example.com/', + mirrorPassQueryString: true, + mirrorCheckMd5: true, + mirrorSNI: true, + replaceKeyPrefixWith: "def/", + mirrorFollowRedirect: true, + hostName: "example.com", + mirrorHeaders: new Oss\Models\MirrorHeaders( + passs: ["myheader-key1", "myheader-key2"], + sets: array( + new Oss\Models\MirrorHeaderSet(key: 'myheader-key5', value: 'myheader-value5'), + ), + passAll: true, + ), + passQueryString: true, + enableReplacePrefix: true, + httpRedirectCode: 301, + mirrorURLSlave: 'http://example.com/', + mirrorSaveOssMeta: true, + mirrorProxyPass: false, + mirrorAllowGetImageInfo: true, + mirrorAllowVideoSnapshot: false, + mirrorIsExpressTunnel: true, + mirrorDstRegion: 'cn-hangzhou', + mirrorUserLastModified: false, + mirrorSwitchAllErrors: true, + mirrorUsingRole: true, + mirrorRole: 'aliyun-test-role', + mirrorAllowHeadObject: true, + transparentMirrorResponseCodes: '400', + mirrorTaggings: new Oss\Models\MirrorTaggings( + taggings: [new Oss\Models\MirrorTagging( + value: 'v', + key: 'k' + )] + ), + mirrorReturnHeaders: new Oss\Models\MirrorReturnHeaders( + returnHeaders: [ + new Oss\Models\ReturnHeader( + key: 'k', + value: 'v' + ) + ] + ), + mirrorAuth: new Oss\Models\MirrorAuth( + 'S3V4', 'ap-southeast-1', 'TESTAK', 'TESTSK' + ), + mirrorMultiAlternates: new Oss\Models\MirrorMultiAlternates( + [ + new Oss\Models\MirrorMultiAlternate( + mirrorMultiAlternateNumber: 32, mirrorMultiAlternateURL: 'https://test-multi-alter.example.com', mirrorMultiAlternateVpcId: 'vpc-test-id', mirrorMultiAlternateDstRegion: 'ap-southeast-1' + ) + ] + ) + ), + ruleNumber: 1, + condition: new Oss\Models\RoutingRuleCondition( + keyPrefixEquals: 'abc/', + keySuffixEquals: ".txt", + httpErrorCodeReturnedEquals: 404, + ), + luaConfig: new Oss\Models\RoutingRuleLuaConfig( + script: "test.lua", + ) + ), + new Oss\Models\RoutingRule( + redirect: new Oss\Models\RoutingRuleRedirect( + redirectType: 'AliCDN', + mirrorURL: 'http://example.com/', + mirrorPassQueryString: true, + mirrorCheckMd5: true, + mirrorSNI: true, + protocol: 'http', + mirrorFollowRedirect: true, + mirrorHeaders: new Oss\Models\MirrorHeaders( + passs: ["myheader-key1", "myheader-key2"], + sets: array( + new Oss\Models\MirrorHeaderSet(key: 'myheader-key5', value: 'myheader-value5'), + ), + passAll: true, + ), + passQueryString: true, + replaceKeyWith: "abc", + ), + ruleNumber: 2, + condition: new Oss\Models\RoutingRuleCondition( + keyPrefixEquals: 'abc/', + keySuffixEquals: ".txt", + httpErrorCodeReturnedEquals: 404, + ), + luaConfig: new Oss\Models\RoutingRuleLuaConfig( + script: "test.lua", + ) + ), + ]), + ) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // DeleteBucketWebsite + $delResult = $client->deleteBucketWebsite(new Oss\Models\DeleteBucketWebsiteRequest( + $bucketName + )); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testBucketWebsiteFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // PutBucketWebsite + try { + $putResult = $client->putBucketWebsite(new Oss\Models\PutBucketWebsiteRequest( + $bucketName, + websiteConfiguration: new Oss\Models\WebsiteConfiguration( + indexDocument: new Oss\Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + errorDocument: new Oss\Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ) + ) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutBucketWebsite', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketWebsite + try { + $getResult = $client->getBucketWebsite(new Oss\Models\GetBucketWebsiteRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketWebsite', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeleteBucketWebsite + try { + $delResult = $client->deleteBucketWebsite(new Oss\Models\DeleteBucketWebsiteRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteBucketWebsite', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWormTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWormTest.php new file mode 100644 index 0000000..538efbd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientBucketWormTest.php @@ -0,0 +1,183 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + // InitiateBucketWorm + $initResult = $client->initiateBucketWorm(new Oss\Models\InitiateBucketWormRequest( + $bucketName, + new Oss\Models\InitiateWormConfiguration(1) + )); + $this->assertEquals(200, $initResult->statusCode); + $this->assertEquals('OK', $initResult->status); + $this->assertEquals(True, count($initResult->headers) > 0); + $this->assertEquals(24, strlen($initResult->requestId)); + $this->assertNotEmpty($initResult->wormId); + + // GetBucketWorm + $getResult = $client->getBucketWorm(new Oss\Models\GetBucketWormRequest( + $bucketName + )); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + $this->assertEquals($initResult->wormId, $getResult->wormConfiguration->wormId); + $this->assertNotEmpty($getResult->wormConfiguration->creationDate); + $this->assertNotEmpty($getResult->wormConfiguration->retentionPeriodInDays); + $this->assertNotEmpty($getResult->wormConfiguration->state); + + // AbortBucketWorm + $abortResult = $client->abortBucketWorm(new Oss\Models\AbortBucketWormRequest( + $bucketName + )); + $this->assertEquals(204, $abortResult->statusCode); + $this->assertEquals('No Content', $abortResult->status); + $this->assertEquals(True, count($abortResult->headers) > 0); + $this->assertEquals(24, strlen($abortResult->requestId)); + + // CompleteBucketWorm + try { + $result = $client->completeBucketWorm(new Oss\Models\CompleteBucketWormRequest( + $bucketName, + $initResult->wormId + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CompleteBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchWORMConfiguration', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // ExtendBucketWorm + try { + $result = $client->extendBucketWorm(new Oss\Models\ExtendBucketWormRequest( + $bucketName, + $initResult->wormId, + new Oss\Models\ExtendWormConfiguration(2) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ExtendBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchWORMConfiguration', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } + + public function testBucketWormFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . "-not-exist"; + + // InitiateBucketWorm + try { + $initResult = $client->initiateBucketWorm(new Oss\Models\InitiateBucketWormRequest( + $bucketName, + new Oss\Models\InitiateWormConfiguration(1) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error InitiateBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetBucketWorm + try { + $getResult = $client->getBucketWorm(new Oss\Models\GetBucketWormRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // AbortBucketWorm + try { + $abortResult = $client->abortBucketWorm(new Oss\Models\AbortBucketWormRequest( + $bucketName + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error AbortBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + $wormId = 'not-exist-wormId'; + + // CompleteBucketWorm + try { + $result = $client->completeBucketWorm(new Oss\Models\CompleteBucketWormRequest( + $bucketName, + $wormId + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CompleteBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // ExtendBucketWorm + try { + $result = $client->extendBucketWorm(new Oss\Models\ExtendBucketWormRequest( + $bucketName, + $wormId, + new Oss\Models\ExtendWormConfiguration(2) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ExtendBucketWorm', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientExtensionTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientExtensionTest.php new file mode 100644 index 0000000..1f7f448 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientExtensionTest.php @@ -0,0 +1,1010 @@ +isBucketExist($bucketName); + $this->assertTrue($exist); + + $exist = $client->isBucketExist($bucketNameNoExist); + $this->assertFalse($exist); + + $exist = $noPermClient->isBucketExist($bucketName); + $this->assertTrue($exist); + + $exist = $noPermClient->isBucketExist($bucketNameNoExist); + $this->assertFalse($exist); + + try { + $exist = $errClient->isBucketExist($bucketName); + $this->assertTrue(false, 'shoud not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('InvalidArgumentException: endpoint is invalid', $e); + } + } + + public function testIsObjectExist() + { + $client = self::getDefaultClient(); + $noPermClient = self::getInvalidAkClient(); + $errClient = self::getClient(self::$ACCESS_ID, self::$ACCESS_KEY, '', ''); + $bucketName = self::$bucketName; + $bucketNameNoExist = self::$bucketName . "-no-exist"; + $objectName = 'object-exist'; + $objectNameNoExist = 'object-exist-no-exist'; + + $result = $client->putObject(new Oss\Models\PutObjectRequest($bucketName, $objectName)); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // normal + $exist = $client->isObjectExist($bucketName, $objectName); + $this->assertTrue($exist); + + $exist = $client->isObjectExist($bucketName, $objectNameNoExist); + $this->assertFalse($exist); + + // no exist bucket + try { + $exist = $client->isObjectExist($bucketNameNoExist, $objectName); + $this->assertTrue(false, 'shoud not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('NoSuchBucket', $e); + } + + try { + $exist = $client->isObjectExist($bucketNameNoExist, $objectNameNoExist); + $this->assertTrue(false, 'shoud not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('NoSuchBucket', $e); + } + + // no perm client + try { + $exist = $noPermClient->isObjectExist($bucketName, $objectName); + $this->assertTrue(false, 'shoud not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('InvalidAccessKeyId', $e); + } + + try { + $exist = $noPermClient->isObjectExist($bucketNameNoExist, $objectNameNoExist); + $this->assertTrue(false, 'shoud not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('NoSuchBucket', $e); + } + + // invalid client + try { + $exist = $errClient->isObjectExist($bucketName, $objectName); + $this->assertTrue(false, 'shoud not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('InvalidArgumentException: endpoint is invalid', $e); + } + } + + public function testUploader(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $fileMd5 = md5(file_get_contents($filename), true); + $uploader = $client->newUploader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // multi-part + $result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucketName, + $key + ), + $filename, + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringEndsWith('-3"', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, $key), true); + $this->assertEquals($fileMd5, $objectMd5); + + // single-part + $result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucketName, + "single-part-$key" + ), + $filename, + [ + 'part_size' => $totalSize * 2, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->uploadId); + $this->assertStringNotContainsString('-', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "single-part-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + + // upload from multi-part + $result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucketName, + "multi-part-from-$key" + + ), + new LazyOpenStream($filename, 'rb'), + [ + 'part_size' => 200 * 1024, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringEndsWith('-2"', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "multi-part-from-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + + // upload from single-part + $result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucketName, + "single-part-from-$key" + + ), + new LazyOpenStream($filename, 'rb'), + [ + 'part_size' => $totalSize * 2, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->uploadId); + $this->assertStringNotContainsString('-', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "single-part-from-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + + // upload from multi-part with no-seekable stream + $result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucketName, + "multi-part-from-$key" + + ), + new NoSeekStream(new LazyOpenStream($filename, 'rb')), + [ + 'part_size' => 200 * 1024, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringEndsWith('-2"', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "multi-part-from-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + + // upload from multi-part, and start from 100 + $stream = new LazyOpenStream($filename, 'rb'); + $stream->seek(100); + $result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucketName, + "multi-part-from-100-$key" + + ), + $stream, + [ + 'part_size' => 200 * 1024, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringEndsWith('-2"', $result->etag); + $this->assertNotNull($result->hashCrc64); + $partFileMd5 = md5(substr(file_get_contents($filename), 100), true); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "multi-part-from-100-$key"), true); + $this->assertEquals($partFileMd5, $objectMd5); + } + + public function testUploaderDetectContentType(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName() . '.zip'; + $this->generateFile($filename, $totalSize); + $fileMd5 = md5(file_get_contents($filename), true); + $uploader = $client->newUploader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // multi-part + $result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucketName, + $key + ), + $filename, + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringEndsWith('-3"', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, $key), true); + $this->assertEquals($fileMd5, $objectMd5); + $contentType = $this->object_get_content_type($client, $bucketName, $key); + $this->assertEquals("application/zip", $contentType); + + // single-part + $result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucketName, + "single-part-$key" + ), + $filename, + [ + 'part_size' => $totalSize * 2, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->uploadId); + $this->assertStringNotContainsString('-', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "single-part-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + $contentType = $this->object_get_content_type($client, $bucketName, "single-part-$key"); + $this->assertEquals("application/zip", $contentType); + + // upload from multi-part + $result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucketName, + "multi-part-from-$key" + + ), + new LazyOpenStream($filename, 'rb'), + [ + 'part_size' => 200 * 1024, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringEndsWith('-2"', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "multi-part-from-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + $contentType = $this->object_get_content_type($client, $bucketName, "multi-part-from-$key"); + $this->assertEquals("application/octet-stream", $contentType); + + // upload from single-part + $result = $uploader->uploadFrom( + new Oss\Models\PutObjectRequest( + $bucketName, + "single-part-from-$key" + + ), + new LazyOpenStream($filename, 'rb'), + [ + 'part_size' => $totalSize * 2, + ] + ); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->uploadId); + $this->assertStringNotContainsString('-', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $bucketName, "single-part-from-$key"), true); + $this->assertEquals($fileMd5, $objectMd5); + $contentType = $this->object_get_content_type($client, $bucketName, "single-part-from-$key"); + $this->assertEquals("application/zip", $contentType); + } + + public function testUploaderFail(): void + { + $noPermClient = self::getInvalidAkClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + + $uploader = $noPermClient->newUploader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // multi-part + try { + $result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucketName, + $key + ), + $filename, + ); + } catch (Oss\Exception\UploadException $e) { + $this->assertStringContainsString('upload failed', $e); + $this->assertStringContainsString($filename, $e); + $this->assertStringContainsString('Operation error InitiateMultipartUpload', $e); + $se = $e->getPrevious()->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // single-part + try { + $result = $uploader->uploadFile( + new Oss\Models\PutObjectRequest( + $bucketName, + $key + ), + $filename, + [ + 'part_size' => $totalSize * 2, + ] + ); + } catch (Oss\Exception\UploadException $e) { + $this->assertStringContainsString('upload failed', $e); + $this->assertStringContainsString($filename, $e); + $this->assertStringContainsString('Operation error PutObject', $e); + $se = $e->getPrevious()->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testDownloader(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $totalSize = 25 * 1024 + 123; + $partSize = 10 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $content = \file_get_contents($filename); + + $request = new Oss\Models\PutObjectRequest($bucketName, $key); + $request->body = Oss\Utils::streamFor($content); + + $result = $client->putObject($request); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + $saveToFilename = self::getTempFileName(); + $this->assertFileNotEquals($filename, $saveToFilename); + $downloader = $client->newDownloader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // multipart download + $result = $downloader->downloadFile( + new Oss\Models\GetObjectRequest( + $bucketName, + $key + ), + $saveToFilename, + ); + $this->assertEquals($totalSize, $result->written); + $this->assertFileEquals($filename, $saveToFilename); + + // multipart download + parallel + $saveToFilename = self::getTempFileName(); + $this->assertFileNotEquals($filename, $saveToFilename); + + $result = $downloader->downloadFile( + new Oss\Models\GetObjectRequest( + $bucketName, + $key + ), + $saveToFilename, + [ + 'parallel_num' => 2, + ] + ); + $this->assertEquals($totalSize, $result->written); + $this->assertFileEquals($filename, $saveToFilename); + + // single part download + parallel + $saveToFilename = self::getTempFileName(); + $this->assertFileNotEquals($filename, $saveToFilename); + + $result = $downloader->downloadFile( + new Oss\Models\GetObjectRequest( + $bucketName, + $key + ), + $saveToFilename, + [ + 'part_size' => $totalSize * 2, + 'parallel_num' => 2, + ] + ); + $this->assertEquals($totalSize, $result->written); + $this->assertFileEquals($filename, $saveToFilename); + } + + public function testDownloaderDownloadTo(): void + { + $client = self::getDefaultClient(); + $buckeName = self::$bucketName; + $key = self::randomObjectName(); + $totalSize = 25 * 1024 + 123; + $partSize = 10 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $content = \file_get_contents($filename); + + $request = new Oss\Models\PutObjectRequest($buckeName, $key); + $request->body = Oss\Utils::streamFor($content); + + $result = $client->putObject($request); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + $downloader = $client->newDownloader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // multipart download + $stream = new BufferStream(1 * 1024 * 1024); + $result = $downloader->downloadTo( + new Oss\Models\GetObjectRequest( + $buckeName, + $key + ), + $stream, + ); + $gotContent = $stream->getContents(); + $this->assertEquals($totalSize, $result->written); + $this->assertEquals($totalSize, strlen($gotContent)); + $this->assertEquals($content, $gotContent); + + // multipart download + parallel + $stream = new BufferStream(1 * 1024 * 1024); + $result = $downloader->downloadTo( + new Oss\Models\GetObjectRequest( + $buckeName, + $key + ), + $stream, + [ + 'parallel_num' => 2, + ] + ); + $gotContent = $stream->getContents(); + $this->assertEquals($totalSize, $result->written); + $this->assertEquals($totalSize, strlen($gotContent)); + $this->assertEquals($content, $gotContent); + + // single part download + parallel + $stream = new BufferStream(1 * 1024 * 1024); + $result = $downloader->downloadTo( + new Oss\Models\GetObjectRequest( + $buckeName, + $key + ), + $stream, + [ + 'part_size' => $totalSize * 2, + 'parallel_num' => 2, + ] + ); + $gotContent = $stream->getContents(); + $this->assertEquals($totalSize, $result->written); + $this->assertEquals($totalSize, strlen($gotContent)); + $this->assertEquals($content, $gotContent); + } + + public function testCopier(): void + { + $client = self::getDefaultClient(); + $buckeName = self::$bucketName; + $key = self::randomObjectName(); + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $content = \file_get_contents($filename); + $fileMd5 = md5(file_get_contents($filename), true); + + $request = new Oss\Models\PutObjectRequest($buckeName, $key); + $request->body = Oss\Utils::streamFor($content); + + $result = $client->putObject($request); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $sourceBucket = $buckeName; + $sourceKey = $key; + + $copier = $client->newCopier( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // single copy + $dstBucket = $buckeName; + $dstKey = "single-copy-$key"; + $result = $copier->copy( + new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ), + [ + 'part_size' => $totalSize * 2, + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->uploadId); + $this->assertStringNotContainsString('-', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $dstBucket, $dstKey), true); + $this->assertEquals($fileMd5, $objectMd5); + + // Shallow copy mode, use single copy + $dstBucket = $buckeName; + $dstKey = "shallow-single-copy-$key"; + $result = $copier->copy( + new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ), + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->uploadId); + $this->assertStringNotContainsString('-', $result->etag); + $this->assertNotNull($result->hashCrc64); + $objectMd5 = md5($this->object_get_contents($client, $dstBucket, $dstKey), true); + $this->assertEquals($fileMd5, $objectMd5); + + // shllow copy mode, use multipart copy + + // multipart case + $request = new Oss\Models\PutObjectRequest($buckeName, $sourceKey); + $request->contentType = 'text/js'; + $request->cacheControl = 'no-cache'; + $request->metadata = ['key1' => 'value1', 'key2' => 'value2']; + $request->tagging = 'k1=v1&k2=v2'; + $request->body = Oss\Utils::streamFor($content); + $result = $client->putObject($request); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + // multipart copy, 'replace' directive + // case 1, empty metadata & tagging + $dstBucket = $buckeName; + $dstKey = "multipart-copy-repalce-empty-metadata-and-tagging-$key.js"; + $copyRequest = new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ); + $copyRequest->metadataDirective = 'REPLACE'; + $copyRequest->taggingDirective = 'REPLACE'; + $result = $copier->copy( + $copyRequest, + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringContainsString('-3', $result->etag); + $objectMd5 = md5($this->object_get_contents($client, $dstBucket, $dstKey), true); + $this->assertEquals($fileMd5, $objectMd5); + + $metaProp = $client->headObject(new Oss\Models\HeadObjectRequest($buckeName, $dstKey)); + $tagProp = $client->getObjectTagging(new Oss\Models\GetObjectTaggingRequest($buckeName, $dstKey)); + $this->assertEquals('application/octet-stream', $metaProp->contentType); + $this->assertNull($metaProp->contentEncoding); + $this->assertNull($metaProp->contentDisposition); + $this->assertNull($metaProp->cacheControl); + $this->assertNull($metaProp->expires); + $this->assertNull($metaProp->metadata); + $this->assertNull($metaProp->taggingCount); + $this->assertEmpty($tagProp->tagSet->tags); + + // case 2, has metadata & tagging + $dstBucket = $buckeName; + $dstKey = "multipart-copy-repalce-metadata-and-tagging-$key.js"; + $copyRequest = new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ); + $copyRequest->metadataDirective = 'REPLACE'; + $copyRequest->taggingDirective = 'REPLACE'; + $copyRequest->contentType = 'text/txt'; + $copyRequest->cacheControl = 'cache-123'; + $copyRequest->contentDisposition = 'contentDisposition'; + $copyRequest->expires = '123'; + $copyRequest->metadata = ['test1' => 'val1', 'test2' => 'value2']; + $copyRequest->tagging = 'k3=v3&k4=v4'; + $result = $copier->copy( + $copyRequest, + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringContainsString('-3', $result->etag); + $objectMd5 = md5($this->object_get_contents($client, $dstBucket, $dstKey), true); + $this->assertEquals($fileMd5, $objectMd5); + + $metaProp = $client->headObject(new Oss\Models\HeadObjectRequest($buckeName, $dstKey)); + $tagProp = $client->getObjectTagging(new Oss\Models\GetObjectTaggingRequest($buckeName, $dstKey)); + $this->assertEquals('text/txt', $metaProp->contentType); + $this->assertEquals('cache-123', $metaProp->cacheControl); + $this->assertEquals('contentDisposition', $metaProp->contentDisposition); + $this->assertEquals('123', $metaProp->expires); + $this->assertNull($metaProp->contentEncoding); + $this->assertEquals('val1', $metaProp->metadata['test1']); + $this->assertEquals('value2', $metaProp->metadata['test2']); + $this->assertEquals(2, $metaProp->taggingCount); + $this->assertEquals('k3', $tagProp->tagSet->tags[0]->key); + $this->assertEquals('v3', $tagProp->tagSet->tags[0]->value); + $this->assertEquals('k4', $tagProp->tagSet->tags[1]->key); + $this->assertEquals('v4', $tagProp->tagSet->tags[1]->value); + + // multipart copy, 'copy' directive + $dstBucket = $buckeName; + $dstKey = "multipart-copy-copy-metadata-and-tagging-$key.js"; + $copyRequest = new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ); + $copyRequest->contentType = 'text/txt'; + $copyRequest->cacheControl = 'cache-123'; + $copyRequest->contentDisposition = 'contentDisposition'; + $copyRequest->expires = '123'; + $copyRequest->metadata = ['test1' => 'val1', 'test2' => 'value2']; + $copyRequest->tagging = 'k3=v3&k4=v4'; + $result = $copier->copy( + $copyRequest, + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(32, strlen($result->uploadId)); + $this->assertStringContainsString('-3', $result->etag); + $objectMd5 = md5($this->object_get_contents($client, $dstBucket, $dstKey), true); + $this->assertEquals($fileMd5, $objectMd5); + + $metaProp = $client->headObject(new Oss\Models\HeadObjectRequest($buckeName, $dstKey)); + $tagProp = $client->getObjectTagging(new Oss\Models\GetObjectTaggingRequest($buckeName, $dstKey)); + $this->assertEquals('text/js', $metaProp->contentType); + $this->assertEquals('no-cache', $metaProp->cacheControl); + $this->assertNull($metaProp->contentDisposition); + $this->assertNull($metaProp->expires); + $this->assertNull($metaProp->contentEncoding); + $this->assertEquals('value1', $metaProp->metadata['key1']); + $this->assertEquals('value2', $metaProp->metadata['key2']); + $this->assertEquals(2, $metaProp->taggingCount); + $this->assertEquals('k1', $tagProp->tagSet->tags[0]->key); + $this->assertEquals('v1', $tagProp->tagSet->tags[0]->value); + $this->assertEquals('k2', $tagProp->tagSet->tags[1]->key); + $this->assertEquals('v2', $tagProp->tagSet->tags[1]->value); + } + + public function testCopierFail(): void + { + $client = self::getDefaultClient(); + $noPermClient = self::getInvalidAkClient(); + $buckeName = self::$bucketName; + $key = self::randomObjectName(); + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $content = \file_get_contents($filename); + + $request = new Oss\Models\PutObjectRequest($buckeName, $key); + $request->body = Oss\Utils::streamFor($content); + + $result = $client->putObject($request); + + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + $metaProp = $client->headObject(new Oss\Models\HeadObjectRequest($buckeName, $key)); + + $sourceBucket = $buckeName; + $sourceKey = $key; + + $copier = $noPermClient->newCopier( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + + // get object metafail + try { + $dstBucket = $buckeName; + $dstKey = "single-copy-$key"; + $result = $copier->copy( + new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ), + [ + 'part_size' => $totalSize * 2, + ] + ); + } catch (Oss\Exception\CopyException $e) { + $this->assertStringContainsString('copy failed', $e); + $this->assertStringContainsString("oss://$dstBucket/$dstKey", $e); + $this->assertStringContainsString('Operation error HeadObject', $e); + $se = $e->getPrevious()->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // single copy fail + try { + $dstBucket = $buckeName; + $dstKey = "single-copy-$key"; + $result = $copier->copy( + new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ), + [ + 'part_size' => $totalSize * 2, + 'meta_prop' => $metaProp, + ] + ); + } catch (Oss\Exception\CopyException $e) { + $this->assertStringContainsString('copy failed', $e); + $this->assertStringContainsString("oss://$dstBucket/$dstKey", $e); + $this->assertStringContainsString('Operation error CopyObject', $e); + $se = $e->getPrevious()->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // multipart copy fail + try { + $dstBucket = $buckeName; + $dstKey = "multipart-copy-$key"; + $result = $copier->copy( + new Oss\Models\CopyObjectRequest( + $dstBucket, + $dstKey, + $sourceBucket, + $sourceKey + ), + [ + 'multipart_copy_threshold' => 0, + 'disable_shallow_copy' => true, + 'meta_prop' => $metaProp, + ] + ); + } catch (Oss\Exception\CopyException $e) { + $this->assertStringContainsString('copy failed', $e); + $this->assertStringContainsString("oss://$dstBucket/$dstKey", $e); + $this->assertStringContainsString('Operation error InitiateMultipartUpload', $e); + $se = $e->getPrevious()->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testGetObjectToFile(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $objectName = self::randomObjectName(); + $totalSize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $content = \file_get_contents($filename); + + $request = new Oss\Models\PutObjectRequest($bucketName, $objectName); + $request->body = Oss\Utils::streamFor($content); + $result = $client->putObject($request); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + $saveToFilename = self::getTempFileName(); + $result = $client->getObjectToFile(new Oss\Models\GetObjectRequest( + $bucketName, + $objectName + ), $saveToFilename); + $this->assertEquals($totalSize, $result->contentLength); + $this->assertFileEquals($filename, $saveToFilename); + } + + public function testGetObjectToFileFail(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $objectName = self::randomObjectName(); + $filename = self::getTempFileName(); + try { + $client->getObjectToFile(new Oss\Models\GetObjectRequest( + $bucketName, + $objectName + ), $filename); + } catch (\Exception $e) { + $this->assertStringContainsString('Operation error GetObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchKey', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + } + + public function testPutObjectFromFile(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $objectName = self::randomObjectName(); + $totalSize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + + $request = new Oss\Models\PutObjectRequest($bucketName, $objectName); + $result = $client->putObjectFromFile($request, $filename); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + $saveToFilename = self::getTempFileName(); + $result = $client->getObjectToFile(new Oss\Models\GetObjectRequest( + $bucketName, + $objectName + ), $saveToFilename); + $this->assertEquals($totalSize, $result->contentLength); + $this->assertFileEquals($filename, $saveToFilename); + } + + public function testPutObjectFormFileFail(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $objectName = self::randomObjectName(); + $filename = self::getTempFileName() . '-not-exist'; + try { + $client->putObjectFromFile(new Oss\Models\PutObjectRequest( + $bucketName, + $objectName + ), $filename); + } catch (\Exception $e) { + $this->assertStringContainsString('to open', $e); + $this->assertInstanceOf(\RuntimeException::class, $e); + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientListCloudBoxesTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientListCloudBoxesTest.php new file mode 100644 index 0000000..bd2102c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientListCloudBoxesTest.php @@ -0,0 +1,57 @@ +getDefaultClient(); + + // ListCloudBoxes + try { + $result = $client->listCloudBoxes(new Oss\Models\ListCloudBoxesRequest()); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListCloudBoxes', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('You are forbidden to oss-cloudbox:ListCloudBoxes', $se->getErrorMessage()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } else { + $this->assertTrue(false, "should not here"); + } + } + } + + public function testListCloudBoxesFail() + { + $client = $this->getInvalidAkClient(); + + try { + $result = $client->listCloudBoxes(new Oss\Models\ListCloudBoxesRequest()); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListCloudBoxes', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientMiscTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientMiscTest.php new file mode 100644 index 0000000..6c303a7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientMiscTest.php @@ -0,0 +1,380 @@ +generateFile($filename, $size); + $handle = fopen($filename, 'rb'); + $reqeust = new Oss\Models\PutObjectRequest($bucketName, 'key-123+-/123%/345'); + $reqeust->body = Oss\Utils::streamFor($handle); + $gotIncrement = 0; + $gotSize = 0; + $gotTotal = 0; + $reqeust->progressFn = static function (int $increment, int $transferred, int $total) use (&$gotIncrement, &$gotSize, &$gotTotal) { + $gotIncrement += $increment; + $gotSize = $transferred; + $gotTotal = $total; + }; + $client->putObject($reqeust); + fclose($handle); + $this->assertEquals($size, $gotIncrement); + $this->assertEquals($size, $gotSize); + $this->assertEquals($size, $gotTotal); + } + + public function testAppendObjectProgress() + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $filename = self::getTempFileName(); + $size = 512 * 1024 + 1234; + $this->generateFile($filename, $size); + $handle = fopen($filename, 'rb'); + $reqeust = new Oss\Models\AppendObjectRequest($bucketName, 'append-key-123.txt'); + $reqeust->position = 0; + $reqeust->body = Oss\Utils::streamFor($handle); + $gotIncrement = 0; + $gotSize = 0; + $gotTotal = 0; + $reqeust->progressFn = static function (int $increment, int $transferred, int $total) use (&$gotIncrement, &$gotSize, &$gotTotal) { + $gotIncrement += $increment; + $gotSize = $transferred; + $gotTotal = $total; + }; + $client->appendObject($reqeust); + fclose($handle); + $this->assertEquals($size, $gotIncrement); + $this->assertEquals($size, $gotSize); + $this->assertEquals($size, $gotTotal); + + $reqeust = new Oss\Models\AppendObjectRequest($bucketName, 'append-key-123.txt'); + $reqeust->body = Oss\Utils::streamFor('hello world'); + $reqeust->position = $size; + $gotIncrement = 0; + $gotSize = 0; + $gotTotal = 0; + $reqeust->progressFn = static function (int $increment, int $transferred, int $total) use (&$gotIncrement, &$gotSize, &$gotTotal) { + $gotIncrement += $increment; + $gotSize = $transferred; + $gotTotal = $total; + }; + $client->appendObject($reqeust); + $this->assertEquals(11, $gotIncrement); + $this->assertEquals(11, $gotSize); + $this->assertEquals(11, $gotTotal); + } + + public function testUploadPartProgress() + { + $client = $this->getDefaultClient(); + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $key = 'bigfile.tmp'; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $file = fopen($filename, 'rb'); + $parts = []; + $fileStream = Oss\Utils::streamFor($file); + $gotIncrement = 0; + for ($i = 0, $partNum = 1; $i < $totalSize; $i += $partSize, $partNum++) { + $gotSize = 0; + $gotTotal = 0; + $body = new LimitStream($fileStream, $partSize, $i); + $sendSize = $body->getSize(); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + $partNum, + $initResult->uploadId, + null, + null, + null, + null, + $body, + static function (int $increment, int $transferred, int $total) use (&$gotIncrement, &$gotSize, &$gotTotal) { + $gotIncrement += $increment; + $gotSize = $transferred; + $gotTotal = $total; + } + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $this->assertEquals($sendSize, $gotSize); + $this->assertEquals($sendSize, $gotTotal); + $part = new Oss\Models\UploadPart( + $partNum, + $partResult->etag, + ); + $parts[] = $part; + } + //$this->assertEquals($totalSize, $gotIncrement); + fclose($file); + $comResult = $client->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + self::$bucketName, + $key, + $initResult->uploadId, + null, + new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) + ); + $this->assertEquals(200, $comResult->statusCode); + $this->assertEquals(self::$bucketName, $comResult->bucket); + $this->assertEquals($key, $comResult->key); + $this->assertNotEmpty($comResult->etag); + $this->assertNotEmpty($comResult->location); + + $getObj = $client->getObject(new Oss\Models\GetObjectRequest( + self::$bucketName, + $key, + )); + $objMd5 = base64_encode(md5($getObj->body, true)); + $fileMd5 = base64_encode(md5(file_get_contents($filename), true)); + $this->assertEquals($fileMd5, $objMd5); + } + + public function testUploadPartUseCoroutine(): void + { + $totalSize = 250 * 1024 + 123; + $partSize = 100 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $totalSize); + $key = 'coroutine.tmp'; + + $bucketName = self::$bucketName; + + // upload context + $context['client'] = self::getDefaultClient(); + $context['request'] = new Oss\Models\PutObjectRequest($bucketName, $key); + $context['filename'] = $filename; + $context['parallel_num'] = 2; + $context['part_size'] = $partSize; + + // use coroutine + $promisor = P\Coroutine::of(function () use (&$context) { + $client = $context['client']; + + // initiate multipart upload + $request = new Oss\Models\InitiateMultipartUploadRequest(); + Oss\Utils::copyRequest($request, $context['request']); + yield $client->initiateMultipartUploadAsync($request)->then( + function (Oss\Models\InitiateMultipartUploadResult $result) use (&$context) { + $context['upload_id'] = $result->uploadId; + }, + ); + + // upload part + $context['errors'] = []; + $context['parts'] = []; + $uploadFns = function () use (&$context) { + $client = $context['client']; + $part_size = intval($context['part_size']); + $filepath = strval($context['filename']); + $source = new LazyOpenStream($filepath, 'rb'); + $source->seek(0); + + for ($partNumber = 1; $source->tell() < $source->getSize(); $partNumber++) { + $body = new LimitStream( + new LazyOpenStream($source->getMetadata('uri'), 'rb'), + $part_size, + $source->tell() + ); + $source->seek(min($source->tell() + $part_size, $source->getSize())); + + $request = new Oss\Models\UploadPartRequest(); + Oss\Utils::copyRequest($request, $context['request']); + $request->partNumber = $partNumber; + $request->uploadId = $context['upload_id']; + $request->body = $body; + yield $partNumber => $client->uploadPartAsync($request)->otherwise( + function ($reason) use (&$context) { + $context['errors'][] = $reason; + return P\Create::rejectionFor($reason); + }, + ); + if (!empty($context['errors'])) { + break; + } + } + }; + + $each = new P\EachPromise( + $uploadFns(), + [ + 'concurrency' => $context['parallel_num'], + 'fulfilled' => function (Oss\Models\UploadPartResult $result, $key) use (&$context) { + $context['parts'][] = new Oss\Models\UploadPart($key, $result->etag); + return $result; + } + ] + ); + yield $each->promise(); + + if (!empty($context['errors'])) { + throw end($context['errors']); + } + + $parts = $context['parts']; + usort($parts, function ($a, $b) { + if ($a->partNumber == $b->partNumber) + return 0; + return $a->partNumber < $b->partNumber ? -1 : 1; + }); + $request = new Oss\Models\CompleteMultipartUploadRequest(); + Oss\Utils::copyRequest($request, $context['request']); + $request->uploadId = $context['upload_id']; + $request->completeMultipartUpload = new Oss\Models\CompleteMultipartUpload($parts); + yield $client->completeMultipartUploadAsync($request)->then( + function (Oss\Models\CompleteMultipartUploadResult $result) use (&$context) { + $context['upload_result'] = $result; + return $result; + }, + ); + }); + + // wait finish + $promisor->wait(); + + // check result + $result = $context['upload_result']; + $this->assertInstanceOf(Oss\Models\CompleteMultipartUploadResult::class, $result); + if ($result instanceof Oss\Models\CompleteMultipartUploadResult) { + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertStringEndsWith('-3"', $result->etag); + } + + $fileMd5 = md5(file_get_contents($filename), true); + $objectMd5 = md5($this->object_get_contents(self::getDefaultClient(), $bucketName, $key), true); + $this->assertEquals($fileMd5, $objectMd5); + } + + public function testGetObjectIntoSink(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $filename = self::getTempFileName(); + $key = self::randomObjectName(); + $size = 123 * 1024 + 1234; + $this->generateFile($filename, $size); + $content = file_get_contents($filename); + $handle = fopen($filename, 'rb'); + $request = new Oss\Models\PutObjectRequest($bucketName, $key); + $request->body = Oss\Utils::streamFor($handle); + $result = $client->putObject($request); + fclose($handle); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + // use sink to save object into file + $filenameSave = self::getTempFileName(); + $this->assertFileNotEquals($filename, $filenameSave); + $request = new Oss\Models\GetObjectRequest($bucketName, $key); + $result = $client->getObject( + $request, + [ + 'request_options' => + ['sink' => $filenameSave] + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertFileEquals($filename, $filenameSave); + $this->assertNull($result->body); + + // use sink to save object into memeroy + $sink = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+'); + $request = new Oss\Models\GetObjectRequest($bucketName, $key); + $result = $client->getObject( + $request, + [ + 'request_options' => + ['sink' => $sink] + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertNotNull($result->body); + $this->assertEquals($content, $result->body->getContents()); + } + + public function testGetObjectStreamMode(): void + { + $client = self::getDefaultClient(); + $bucketName = self::$bucketName; + $filename = self::getTempFileName(); + $key = self::randomObjectName(); + $size = 123 * 1024 + 1234; + $this->generateFile($filename, $size); + $content = file_get_contents($filename); + $handle = fopen($filename, 'rb'); + $request = new Oss\Models\PutObjectRequest($bucketName, $key); + $request->body = Oss\Utils::streamFor($handle); + $result = $client->putObject($request); + fclose($handle); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + // use non stream + $request = new Oss\Models\GetObjectRequest($bucketName, $key); + $result = $client->getObject( + $request, + [ + 'request_options' => + ['stream' => false] + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertNotNull($result->body); + $this->assertTrue($result->body->isSeekable()); + $this->assertEquals($content, $result->body->getContents()); + $this->assertEquals($size, $result->body->getSize()); + $this->assertEquals('', $result->body->read(100)); + + // use stream + $request = new Oss\Models\GetObjectRequest($bucketName, $key); + $result = $client->getObject( + $request, + [ + 'request_options' => + ['stream' => true] + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertNotNull($result->body); + $this->assertFalse($result->body->isSeekable()); + $this->assertNull($result->body->getSize()); + $this->assertEquals($content, $result->body->getContents()); + $this->assertEquals('', $result->body->read(100)); + } + +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectBasicTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectBasicTest.php new file mode 100644 index 0000000..bc036eb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectBasicTest.php @@ -0,0 +1,634 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get object + $result = $client->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // copy object + $destKey = self::randomObjectName() . '-dest'; + $copyObjRequest = new Oss\Models\CopyObjectRequest( + $bucketName, + $destKey, + ); + $copyObjRequest->sourceKey = $key; + $result = $client->copyObject($copyObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // append object + $appendKey = self::randomObjectName() . '-append'; + $appendObjRequest = new Oss\Models\AppendObjectRequest( + $bucketName, + $appendKey, + 0 + ); + $result = $client->appendObject($appendObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // head object + $headObjRequest = new Oss\Models\HeadObjectRequest( + $bucketName, + $appendKey, + ); + $result = $client->headObject($headObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get object meta + $getObjMetaRequest = new Oss\Models\GetObjectMetaRequest( + $bucketName, + $appendKey, + ); + $result = $client->getObjectMeta($getObjMetaRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // restore object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->storageClass = Oss\Models\StorageClassType::DEEP_COLD_ARCHIVE; + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + $restoreObjRequest = new Oss\Models\RestoreObjectRequest( + $bucketName, + $key, + ); + $restoreObjRequest->restoreRequest = new Oss\Models\RestoreRequest(3); + $result = $client->restoreObject($restoreObjRequest); + $this->assertEquals(202, $result->statusCode); + $this->assertEquals('Accepted', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // clean restored object + try { + $result = $client->cleanRestoredObject(new Oss\Models\CleanRestoredObjectRequest( + $bucketName, + $key, + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CleanRestoredObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('ArchiveRestoreNotFinished', $se->getErrorCode()); + $this->assertEquals(409, $se->getStatusCode()); + } + } + + // delete object + $delObjRequest = new Oss\Models\DeleteObjectRequest( + $bucketName, + $key, + ); + $result = $client->deleteObject($delObjRequest); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // delete objects + $delObjsRequest = new Oss\Models\DeleteMultipleObjectsRequest( + $bucketName, + ); + $delArray = []; + for ($i = 1; $i <= 10; $i++) { + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key . $i, + ); + $delArray[] = new Oss\Models\ObjectIdentifier($key . $i); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + } + $delObjsRequest->delete = new Oss\Models\Delete($delArray); + $result = $client->deleteMultipleObjects($delObjsRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + } + + public function testObjectBasicFail() + { + $client = $this->getInvalidAkClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + try { + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $result = $client->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $destKey = self::randomObjectName() . '-dest'; + $copyObjRequest = new Oss\Models\CopyObjectRequest( + $bucketName, + $destKey, + ); + $copyObjRequest->sourceKey = $key; + $result = $client->copyObject($copyObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CopyObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // append object + try { + $appendKey = self::randomObjectName() . '-append'; + $appendObjRequest = new Oss\Models\AppendObjectRequest( + $bucketName, + $appendKey, + 0 + ); + $result = $client->appendObject($appendObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error AppendObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // seal append object + try { + $sealAppendObjRequest = new Oss\Models\SealAppendObjectRequest( + $bucketName, + $appendKey, + 0 + ); + $result = $client->sealAppendObject($sealAppendObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error SealAppendObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // head object + try { + $headObjRequest = new Oss\Models\HeadObjectRequest( + $bucketName, + $key, + ); + $result = $client->headObject($headObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error HeadObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $metaObjRequest = new Oss\Models\GetObjectMetaRequest( + $bucketName, + $key, + ); + $result = $client->getObjectMeta($metaObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetObjectMeta', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $result = $client->restoreObject(new Oss\Models\RestoreObjectRequest( + $bucketName, + $key, + null, + new Oss\Models\RestoreRequest(3) + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error RestoreObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $result = $client->cleanRestoredObject(new Oss\Models\CleanRestoredObjectRequest( + $bucketName, + $key, + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error CleanRestoredObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // delete object + try { + $delObjRequest = new Oss\Models\DeleteObjectRequest( + $bucketName, + $key, + ); + $result = $client->deleteObject($delObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteObject', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // delete objects + try { + $delObjRequest = new Oss\Models\DeleteMultipleObjectsRequest( + $bucketName, + ); + $delObjRequest->delete = new Oss\Models\Delete( + [ + new Oss\Models\ObjectIdentifier('key1'), + new Oss\Models\ObjectIdentifier('key2', 'version-id-2'), + ], true + ); + $result = $client->deleteMultipleObjects($delObjRequest); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteMultipleObjects', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + } + + public function testObjectAcl() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // put object acl + $result = $client->putObjectAcl(new Oss\Models\PutObjectAclRequest( + $bucketName, + $key, + Oss\Models\ObjectACLType::PRIVATE + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get object acl + $result = $client->getObjectAcl(new Oss\Models\GetObjectAclRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->versionId); + $this->assertEquals(Oss\Models\ObjectACLType::PRIVATE, $result->accessControlList->grant); + } + + public function testObjectAclFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . "-not-exist"; + try { + $result = $client->putObjectAcl(new Oss\Models\PutObjectAclRequest( + $bucketName, + $key, + Oss\Models\ObjectACLType::PRIVATE + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutObjectAcl', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchKey', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + + try { + $result = $client->getObjectAcl(new Oss\Models\GetObjectAclRequest( + $bucketName, + $key + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetObjectAcl', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchKey', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + } + + public function testObjectTagging() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // put object tagging + $result = $client->putObjectTagging(new Oss\Models\PutObjectTaggingRequest( + $bucketName, + $key, + new Oss\Models\Tagging( + new Oss\Models\TagSet( + [new Oss\Models\Tag('k1', 'v1'), new Oss\Models\Tag('k2', 'v2')] + ) + ) + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get object tagging + $result = $client->getObjectTagging(new Oss\Models\GetObjectTaggingRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNull($result->versionId); + $this->assertEquals(2, count($result->tagSet->tags)); + + // delete object tagging + $result = $client->deleteObjectTagging(new Oss\Models\DeleteObjectTaggingRequest( + $bucketName, + $key + )); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + } + + public function testObjectTaggingFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . "-not-exist"; + try { + $result = $client->putObjectTagging(new Oss\Models\PutObjectTaggingRequest( + $bucketName, + $key, + new Oss\Models\Tagging( + new Oss\Models\TagSet( + [new Oss\Models\Tag('k1', 'v1'), new Oss\Models\Tag('k2', 'v2')] + ) + ) + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutObjectTagging', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchKey', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + + try { + $result = $client->getObjectTagging(new Oss\Models\GetObjectTaggingRequest( + $bucketName, + $key + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetObjectTagging', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchKey', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + + try { + $result = $client->deleteObjectTagging(new Oss\Models\DeleteObjectTaggingRequest( + $bucketName, + $key + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeleteObjectTagging', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchKey', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + } + + public function testSymlink() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . '-target'; + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // put symlink + $symlinkKey = self::randomObjectName() . '-symlink'; + $result = $client->putSymlink(new Oss\Models\PutSymlinkRequest( + $bucketName, + $symlinkKey, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get symlink + $result = $client->getSymlink(new Oss\Models\GetSymlinkRequest( + $bucketName, + $symlinkKey + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + } + + public function testSymlinkFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + $key = self::randomObjectName() . "-target"; + $symlinkKey = self::randomObjectName() . '-symlink'; + try { + $result = $client->putSymlink(new Oss\Models\PutSymlinkRequest( + $bucketName, + $symlinkKey, + $key + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutSymlink', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + + try { + $result = $client->getSymlink(new Oss\Models\GetSymlinkRequest( + $bucketName, + $symlinkKey, + )); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetSymlink', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + } + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectMultipartTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectMultipartTest.php new file mode 100644 index 0000000..fc620f6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientObjectMultipartTest.php @@ -0,0 +1,433 @@ +getDefaultClient(); + // test initiateMultipartUpload, uploadPart, completeMultipartUpload + $partSize = 200 * 1024; + $key = 'bigfile.tmp'; + try { + $bigFileName = self::getTempFileName() . "-bigfile.tmp"; + if (!file_exists($bigFileName)) { + $this->generateFile($bigFileName, 500 * 1024); + } + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + $i, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $comResult = $client->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + self::$bucketName, + $key, + $initResult->uploadId, + null, + new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) + ); + $this->assertEquals(200, $comResult->statusCode); + $this->assertEquals(self::$bucketName, $comResult->bucket); + $this->assertEquals($key, $comResult->key); + $this->assertNotEmpty($comResult->etag); + $this->assertNotEmpty($comResult->location); + $getObj = $client->getObject(new Oss\Models\GetObjectRequest( + self::$bucketName, + $key, + )); + $this->assertEquals(base64_encode(md5(file_get_contents($bigFileName), true)), base64_encode(md5($getObj->body, true))); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + // test initiateMultipartUpload, uploadPartCopy, completeMultipartUpload + try { + $key1 = self::randomObjectName() . "\f\v\t"; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key1, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + + $partResult = $client->uploadPartCopy( + new Oss\Models\UploadPartCopyRequest( + self::$bucketName, + $key1, + 1, + $initResult->uploadId, + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $comResult = $client->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + self::$bucketName, + $key1, + $initResult->uploadId, + null, + null, + 'yes', + ) + ); + $this->assertEquals(200, $comResult->statusCode); + $this->assertEquals(self::$bucketName, $comResult->bucket); + $this->assertEquals($key1, $comResult->key); + $this->assertNotEmpty($comResult->etag); + $this->assertNotEmpty($comResult->location); + $client->deleteObject(new Oss\Models\DeleteObjectRequest( + self::$bucketName, + $key1, + )); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + $client->deleteObject(new Oss\Models\DeleteObjectRequest( + self::$bucketName, + $key, + )); + + // test listParts and listMultipartUploads + $objectPrefix = self::randomObjectName(); + try { + for ($i = 0; $i < 3; $i++) { + $key = $objectPrefix . $i; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $file = fopen($bigFileName, 'r'); + if ($file) { + $n = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + $n, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $n++; + } + fclose($file); + } + } + $listUploads = $client->listMultipartUploads( + new Oss\Models\ListMultipartUploadsRequest( + self::$bucketName, + ) + ); + $this->assertEquals(200, $listUploads->statusCode); + $this->assertCount(3, $listUploads->uploads); + + $listParts = $client->listParts( + new Oss\Models\ListPartsRequest( + self::$bucketName, + $listUploads->uploads[0]->key, + $listUploads->uploads[0]->uploadId, + ) + ); + $this->assertEquals(200, $listParts->statusCode); + $this->assertCount(3, $listParts->parts); + + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + // test abortMultipartUpload + try { + foreach ($listUploads->uploads as $k => $upload) { + $abort = $client->abortMultipartUpload( + new Oss\Models\AbortMultipartUploadRequest( + self::$bucketName, + $upload->key, + $upload->uploadId, + ) + ); + $this->assertEquals(204, $abort->statusCode); + } + $listUploads = $client->listMultipartUploads( + new Oss\Models\ListMultipartUploadsRequest( + self::$bucketName, + ) + ); + $this->assertEquals(200, $listUploads->statusCode); + $this->assertNull($listUploads->uploads); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + } + + public function testObjectMultipartFail() + { + $client = $this->getDefaultClient(); + $invalidAkClient = $this->getInvalidAkClient(); + $partSize = 200 * 1024; + $key = 'bigfile.tmp'; + $bigFileName = self:: getTempFileName() . "-bigfile.tmp"; + if (!file_exists($bigFileName)) { + $this->generateFile($bigFileName, 500 * 1024); + } + + // test initiateMultipartUpload + try { + $invalidAkClient->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error InitiateMultipartUpload', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // test uploadPart + try { + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $invalidAkClient->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + 1, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($bigFileName) + ) + ); + } catch (\Throwable $e) { + $this->assertStringContainsString('Operation error UploadPart', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + // test uploadPartCopy + try { + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + 1, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($bigFileName) + ) + ); + $invalidAkClient->uploadPartCopy( + new Oss\Models\UploadPartCopyRequest( + self::$bucketName, + $key, + 1, + $initResult->uploadId, + self::$bucketName, + $key, + ) + ); + } catch (\Throwable $e) { + $this->assertStringContainsString('Operation error UploadPartCopy', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + $i, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $invalidAkClient->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + self::$bucketName, + $key, + $initResult->uploadId, + null, + new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) + ); + } catch (\Throwable $e) { + $this->assertStringContainsString('Operation error CompleteMultipartUpload', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $invalidAkClient->listMultipartUploads( + new Oss\Models\ListMultipartUploadsRequest( + self::$bucketName, + ) + ); + } catch (\Throwable $e) { + $this->assertStringContainsString('Operation error ListMultipartUploads', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + try { + $invalidAkClient->listParts( + new Oss\Models\ListPartsRequest( + self::$bucketName, + $initResult->uploadId, + $initResult->key, + ) + ); + } catch (\Throwable $e) { + $this->assertStringContainsString('Operation error ListParts', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + } + } + + $listUploads = $client->listMultipartUploads( + new Oss\Models\ListMultipartUploadsRequest( + self::$bucketName, + ) + ); + + foreach ($listUploads->uploads as $k => $upload) { + $abort = $client->abortMultipartUpload( + new Oss\Models\AbortMultipartUploadRequest( + self::$bucketName, + $upload->key, + $upload->uploadId, + ) + ); + $this->assertEquals(204, $abort->statusCode); + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPaginatorTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPaginatorTest.php new file mode 100644 index 0000000..f24811a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPaginatorTest.php @@ -0,0 +1,774 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + + $paginator = new Oss\Paginator\ListObjectsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListObjectsRequest($bucketName), + ['limit' => 1] + ); + + foreach ($iter as $page) { + foreach ($page->contents ?? [] as $content) { + $this->assertEquals($key, $content->key); + } + } + $result = $client->deleteObject(new Oss\Models\DeleteObjectRequest( + $bucketName, $key + )); + $this->assertEquals(204, $result->statusCode); + } + + public function testListObjectsPaginatorFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListObjectsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListObjectsRequest($bucketName), + ['limit' => 1] + ); + foreach ($iter as $page) { + foreach ($page->contents ?? [] as $content) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjects', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + + } + + public function testListObjectsPaginatorAsync() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + + $paginator = new Oss\Paginator\ListObjectsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectsRequest($bucketName), + ['limit' => 10] + ); + $this->assertTrue(is_object($iterPromise)); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->contents ?? [] as $content) { + $this->assertEquals($key, $content->key); + } + } + $result = $client->deleteObject(new Oss\Models\DeleteObjectRequest( + $bucketName, $key + )); + $this->assertEquals(204, $result->statusCode); + } + + public function testListObjectsPaginatorAsyncFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListObjectsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectsRequest($bucketName), + ['limit' => 1] + ); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->contents ?? [] as $content) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjects', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + + } + + public function testListObjectsV2Paginator() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + + $paginator = new Oss\Paginator\ListObjectsV2Paginator($client); + + $iter = $paginator->iterPage( + new Oss\Models\ListObjectsV2Request($bucketName), + ['limit' => 1] + ); + + $this->assertTrue(is_object($iter)); + foreach ($iter as $page) { + foreach ($page->contents ?? [] as $content) { + $this->assertEquals($key, $content->key); + } + } + $result = $client->deleteObject(new Oss\Models\DeleteObjectRequest( + $bucketName, $key + )); + $this->assertEquals(204, $result->statusCode); + } + + public function testListObjectsV2PaginatorFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListObjectsV2Paginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListObjectsV2Request($bucketName), + ['limit' => 1] + ); + foreach ($iter as $page) { + foreach ($page->contents ?? [] as $content) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjects', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + + } + + public function testListObjectsV2PaginatorAsync() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + + $paginator = new Oss\Paginator\ListObjectsV2Paginator($client); + + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectsV2Request($bucketName), + ['limit' => 1] + ); + $this->assertTrue(is_object($iterPromise)); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->contents ?? [] as $content) { + $this->assertEquals($key, $content->key); + } + } + $result = $client->deleteObject(new Oss\Models\DeleteObjectRequest( + $bucketName, $key + )); + $this->assertEquals(204, $result->statusCode); + } + + public function testListObjectsV2PaginatorAsyncFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListObjectsV2Paginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectsV2Request($bucketName), + ['limit' => 1] + ); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->contents ?? [] as $content) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjects', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + + } + + public function testListObjectVersionsPaginator() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + + $paginator = new Oss\Paginator\ListObjectVersionsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListObjectVersionsRequest($bucketName), + ['limit' => 1] + ); + + foreach ($iter as $page) { + foreach ($page->contents ?? [] as $content) { + $this->assertEquals($key, $content->key); + } + } + + } + + public function testListObjectVersionsPaginatorFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListObjectVersionsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListObjectVersionsRequest($bucketName), + ['limit' => 1] + ); + foreach ($iter as $page) { + foreach ($page->contents ?? [] as $content) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjectVersions', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + + } + + public function testListObjectVersionsPaginatorAsync() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $key = self::randomObjectName(); + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $body = 'hi oss'; + $putObjRequest->body = Oss\Utils::streamFor($body); + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + + $paginator = new Oss\Paginator\ListObjectVersionsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectVersionsRequest($bucketName), + ['limit' => 1] + ); + $this->assertTrue(is_object($iterPromise)); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->contents ?? [] as $content) { + $this->assertEquals($key, $content->key); + } + } + } + + public function testListObjectVersionsPaginatorAsyncFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListObjectVersionsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectVersionsRequest($bucketName), + ['limit' => 1] + ); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->contents ?? [] as $content) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListObjectVersions', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + + } + + public function testListMultipartUploadsPaginator() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = 'bigfile.tmp'; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + + $paginator = new Oss\Paginator\ListMultipartUploadsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListMultipartUploadsRequest($bucketName), + ['limit' => 1] + ); + + foreach ($iter as $page) { + foreach ($page->uploads ?? [] as $upload) { + $this->assertEquals($key, $upload->key); + $this->assertEquals($initResult->uploadId, $upload->uploadId); + } + } + } + + public function testListMultipartUploadsPaginatorFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListMultipartUploadsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListMultipartUploadsRequest($bucketName), + ['limit' => 1] + ); + + foreach ($iter as $page) { + foreach ($page->uploads ?? [] as $upload) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListMultipartUploads', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + } + + public function testListMultipartUploadsPaginatorAsync() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = 'bigfile.tmp'; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + + $paginator = new Oss\Paginator\ListObjectsV2Paginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListObjectsV2Request($bucketName), + ['limit' => 1] + ); + $this->assertTrue(is_object($iterPromise)); + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->uploads ?? [] as $upload) { + $this->assertEquals($key, $upload->key); + $this->assertEquals($initResult->uploadId, $upload->uploadId); + } + } + } + + public function testListMultipartUploadsPaginatorAsyncFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListMultipartUploadsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListMultipartUploadsRequest($bucketName), + ['limit' => 1] + ); + + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->uploads ?? [] as $upload) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListMultipartUploads', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + } + + public function testListPartsPaginator() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $partSize = 200 * 1024; + $bigFileName = self::getTempFileName() . "-bigfile.tmp"; + if (!file_exists($bigFileName)) { + $this->generateFile($bigFileName, 500 * 1024); + } + $key = 'bigfile.tmp'; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + $i, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + + $paginator = new Oss\Paginator\ListPartsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListPartsRequest($bucketName, $key, $initResult->uploadId), + ['limit' => 1] + ); + + foreach ($iter as $page) { + foreach ($page->parts ?? [] as $part) { + $this->assertNotEmpty($part->partNumber); + $this->assertNotEmpty($part->etag); + $this->assertNotEmpty($part->size); + } + } + } + + public function testListPartsPaginatorFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListPartsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListPartsRequest($bucketName, "not-exist", "not-exist"), + ['limit' => 1] + ); + + foreach ($iter as $page) { + foreach ($page->parts ?? [] as $part) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListParts', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + } + + public function testListPartsPaginatorAsync() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $partSize = 200 * 1024; + $bigFileName = self::getTempFileName() . "-bigfile.tmp"; + if (!file_exists($bigFileName)) { + $this->generateFile($bigFileName, 500 * 1024); + } + $key = 'bigfile.tmp'; + $initResult = $client->initiateMultipartUpload( + new Oss\Models\InitiateMultipartUploadRequest( + self::$bucketName, + $key, + ) + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partResult = $client->uploadPart( + new Oss\Models\UploadPartRequest( + self::$bucketName, + $key, + $i, + $initResult->uploadId, + null, + null, + null, + null, + Oss\Utils::streamFor($chunk) + ) + ); + $this->assertEquals(200, $partResult->statusCode); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + + $paginator = new Oss\Paginator\ListPartsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListPartsRequest($bucketName, $key, $initResult->uploadId), + ['limit' => 1] + ); + + $resultParts = []; + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->parts ?? [] as $part) { + $resultParts[] = $part; + } + } + $this->assertEquals(count($parts), count($resultParts)); + } + + public function testListPartsPaginatorAsyncFail() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName . '-not-exist'; + try { + $paginator = new Oss\Paginator\ListPartsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListPartsRequest($bucketName, "not-exist", "not-exist"), + ['limit' => 1] + ); + + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->parts ?? [] as $part) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListParts', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('NoSuchBucket', $se->getErrorCode()); + $this->assertEquals(404, $se->getStatusCode()); + $this->assertEquals('The specified bucket does not exist.', $se->getErrorMessage()); + $this->assertEquals('0015-00000101', $se->getEC()); + } + } + } + + public function testListBucketsPaginator() + { + $client = $this->getDefaultClient(); + + $paginator = new Oss\Paginator\ListBucketsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX), + ['limit' => 10] + ); + + foreach ($iter as $page) { + foreach ($page->buckets ?? [] as $bucket) { + $this->assertStringContainsString(self::$BUCKETNAME_PREFIX, $bucket->name); + } + } + } + + public function testListBucketsPaginatorFail() + { + $client = $this->getInvalidAkClient(); + try { + $paginator = new Oss\Paginator\ListBucketsPaginator($client); + $iter = $paginator->iterPage( + new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX), + ['limit' => 10] + ); + foreach ($iter as $page) { + foreach ($page->buckets ?? [] as $bucket) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListBuckets', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals('The OSS Access Key Id you provided does not exist in our records.', $se->getErrorMessage()); + $this->assertEquals('0002-00000902', $se->getEC()); + } + } + + } + + public function testListBucketsPaginatorAsync() + { + $client = $this->getDefaultClient(); + + $paginator = new Oss\Paginator\ListBucketsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX), + ['limit' => 10] + ); + + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->buckets ?? [] as $bucket) { + $this->assertStringContainsString(self::$BUCKETNAME_PREFIX, $bucket->name); + } + } + } + + public function testListBucketsPaginatorAsyncFail() + { + $client = $this->getInvalidAkClient(); + try { + $paginator = new Oss\Paginator\ListBucketsPaginator($client); + $iterPromise = $paginator->iterPageAsync( + new Oss\Models\ListBucketsRequest(self::$BUCKETNAME_PREFIX), + ['limit' => 10] + ); + + foreach ($iterPromise as $pagePromise) { + $page = $pagePromise->wait(); + foreach ($page->buckets ?? [] as $bucket) { + $this->assertTrue(false, 'should not here'); + } + } + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error ListBuckets', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals('The OSS Access Key Id you provided does not exist in our records.', $se->getErrorMessage()); + $this->assertEquals('0002-00000902', $se->getEC()); + } + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPresignerTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPresignerTest.php new file mode 100644 index 0000000..3134ab4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPresignerTest.php @@ -0,0 +1,507 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + $key = 'key-123+-/123%/345'; + $content = 'hello world'; + $request = new Oss\Models\PutObjectRequest($bucketName, $key); + $request->body = Oss\Utils::streamFor($content); + $result = $client->putObject($request); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + + $request = new Oss\Models\GetObjectRequest($bucketName, $key); + $result = $client->presign($request); + $uri = GuzzleHttp\Psr7\Utils::uriFor($result->url); + $this->assertEquals('/key-123%2B-/123%25/345', $uri->getPath()); + $query = GuzzleHttp\Psr7\Query::parse($uri->getQuery()); + $this->assertArrayHasKey('x-oss-credential', $query); + $this->assertArrayHasKey('x-oss-date', $query); + $this->assertArrayHasKey('x-oss-expires', $query); + $this->assertEquals('900', $query['x-oss-expires']); + $this->assertArrayHasKey('x-oss-signature', $query); + $this->assertArrayHasKey('x-oss-signature-version', $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + + $httpClient = new GuzzleHttp\Client(); + $response = $httpClient->get($result->url); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals($content, $response->getBody()->getContents()); + } + + public function testPresign() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object'; + $body = 'hi oss'; + $httpClient = new GuzzleHttp\Client(); + // PutObjRequest + try { + $request = new Oss\Models\PutObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url, ['body' => $body]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + // GetObjRequest + try { + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals($body, $response->getBody()->getContents()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + // HeadObjRequest + try { + $request = new Oss\Models\HeadObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals(strlen($body), $response->getHeaderLine('content-length')); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + // UploadPart + $objectNameMultipart = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-multi-part'; + try { + $request = new Oss\Models\InitiateMultipartUploadRequest($bucketName, $objectNameMultipart); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + $body = $response->getBody()->getContents(); + $xml = Utils::parseXml($body); + $uploadId = Functions::tryToString($xml->UploadId); + try { + $partRequest = new Oss\Models\UploadPartRequest($bucketName, $objectNameMultipart); + $partRequest->partNumber = 1; + $partRequest->uploadId = $uploadId; + $result = $client->presign($partRequest); + $response = $httpClient->request($result->method, $result->url, ['body' => $body, ['headers' => $result->signedHeaders]]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + try { + $request = new Oss\Models\CompleteMultipartUploadRequest($bucketName, $objectNameMultipart); + $request->completeMultipartUpload = new CompleteMultipartUpload( + [new Oss\Models\UploadPart( + $partRequest->partNumber, $response->getHeaderLine('ETag') + )] + ); + $request->uploadId = $uploadId; + $result = $client->presign($request); + $xml = new \SimpleXMLElement(''); + if (isset($request->completeMultipartUpload->parts)) { + foreach ($request->completeMultipartUpload->parts as $part) { + $xmlPart = $xml->addChild('Part'); + $xmlPart->addChild('PartNumber', strval($part->partNumber)); + $xmlPart->addChild('ETag', $part->etag); + } + } + $response = $httpClient->request($result->method, $result->url, ['body' => $xml->asXML(), 'headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $headRequest = new Oss\Models\HeadObjectRequest($bucketName, $objectNameMultipart); + $headResult = $client->headObject($headRequest); + $this->assertEquals(200, $headResult->statusCode); + $this->assertEquals(strlen($body), $headResult->contentLength); + $this->assertEquals('Multipart', $headResult->objectType); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + $objectNameMultipartCopy = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-multi-part-copy'; + + try { + $initRequest = new Oss\Models\InitiateMultipartUploadRequest($bucketName, $objectNameMultipartCopy); + $initResult = $client->presign($initRequest); + $response = $httpClient->request($initResult->method, $initResult->url, ['headers' => $initResult->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $body = $response->getBody()->getContents(); + $xml = Utils::parseXml($body); + $uploadId = Functions::tryToString($xml->UploadId); + + $abortRequest = new Oss\Models\AbortMultipartUploadRequest($bucketName, $objectNameMultipartCopy, $uploadId); + $result = $client->presign($abortRequest); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(204, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + } + + public function testPresignExtra() + { + $bucketName = self::$bucketName; + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object'; + $body = 'hi oss'; + $httpClient = new GuzzleHttp\Client(); + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider(new Oss\Credentials\StaticCredentialsProvider( + self::$ACCESS_ID, + self::$ACCESS_KEY + )); + $cfg->setRegion(self::$REGION); + $cfg->setEndpoint(self::$ENDPOINT); + $cfg->setSignatureVersion('v1'); + $cfg->setAdditionalHeaders(['email', 'name']); + $clientV1 = new Client($cfg); + $cfg->setSignatureVersion('v4'); + $clientV4 = new Client($cfg); + + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $objectName, + ); + $putObjRequest->body = Utils::streamFor($body); + $putObjResult = $clientV1->putObject($putObjRequest); + $this->assertEquals(200, $putObjResult->statusCode); + $this->assertEquals('OK', $putObjResult->status); + + + // GetObjRequest + try { + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ['headers' => ['email' => 'demo@aliyun.com']]); + $options['expiration'] = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1M')); + $result = $clientV1->presign($request, $options); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals($body, $response->getBody()->getContents()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $options = null; + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ['headers' => ['email' => 'demo@aliyun.com']]); + $options['expiration'] = (new \DateTime('now', new \DateTimeZone('UTC')))->modify('-10 second'); + $result = $clientV1->presign($request, $options); + $response = $httpClient->request($result->method, $result->url); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + //$this->assertEquals(403, $e->getMessage()); + $this->assertStringContainsString("403 Forbidden", $e->getMessage()); + $this->assertStringContainsString("Request has expired.", $e->getMessage()); + $this->assertInstanceOf(GuzzleHttp\Exception\ClientException::class, $e); + } + + try { + $options = null; + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName); + $options['expiration'] = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT192H')); + $result = $clientV4->presign($request, $options); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Expires should not be greater than 604800 (seven days)', $e->getMessage()); + } + + $options = null; + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ['headers' => ['email' => 'demo@aliyun.com']]); + $options['expires'] = new DateInterval('PT1H'); + $result = $clientV4->presign($request, $options); + $response = $httpClient->request($result->method, $result->url, ['headers' => ['email' => 'demo@aliyun.com']]); + $this->assertEquals(200, $response->getStatusCode()); + } + + public function testPresignWithStsToken() + { + $client = $this->getClientUseStsToken(); + $bucketName = self::$bucketName; + + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object'; + $body = 'hi oss'; + $httpClient = new GuzzleHttp\Client(); + // PutObjRequest + try { + $request = new Oss\Models\PutObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url, ['body' => $body]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + // GetObjRequest + try { + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals($body, $response->getBody()->getContents()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + // HeadObjRequest + try { + $request = new Oss\Models\HeadObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals(strlen($body), $response->getHeaderLine('content-length')); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + // UploadPart + $objectNameMultipart = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-multi-part'; + try { + $request = new Oss\Models\InitiateMultipartUploadRequest($bucketName, $objectNameMultipart); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + $body = $response->getBody()->getContents(); + $xml = Utils::parseXml($body); + $uploadId = Functions::tryToString($xml->UploadId); + try { + $partRequest = new Oss\Models\UploadPartRequest($bucketName, $objectNameMultipart); + $partRequest->partNumber = 1; + $partRequest->uploadId = $uploadId; + $result = $client->presign($partRequest); + + $response = $httpClient->request($result->method, $result->url, ['body' => $body, ['headers' => $result->signedHeaders]]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $request = new Oss\Models\CompleteMultipartUploadRequest($bucketName, $objectNameMultipart); + $request->completeMultipartUpload = new CompleteMultipartUpload( + [new Oss\Models\UploadPart( + $partRequest->partNumber, $response->getHeaderLine('ETag') + )] + ); + $request->uploadId = $uploadId; + $result = $client->presign($request); + $xml = new \SimpleXMLElement(''); + if (isset($request->completeMultipartUpload->parts)) { + foreach ($request->completeMultipartUpload->parts as $part) { + $xmlPart = $xml->addChild('Part'); + $xmlPart->addChild('PartNumber', strval($part->partNumber)); + $xmlPart->addChild('ETag', $part->etag); + } + } + $response = $httpClient->request($result->method, $result->url, ['body' => $xml->asXML(), 'headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $headRequest = new Oss\Models\HeadObjectRequest($bucketName, $objectNameMultipart); + $headResult = $client->headObject($headRequest); + $this->assertEquals(200, $headResult->statusCode); + $this->assertEquals(strlen($body), $headResult->contentLength); + $this->assertEquals('Multipart', $headResult->objectType); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + $objectNameMultipartCopy = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-multi-part-copy'; + + try { + $initRequest = new Oss\Models\InitiateMultipartUploadRequest($bucketName, $objectNameMultipartCopy); + $initResult = $client->presign($initRequest); + $response = $httpClient->request($initResult->method, $initResult->url, ['headers' => $initResult->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $body = $response->getBody()->getContents(); + $xml = Utils::parseXml($body); + $uploadId = Functions::tryToString($xml->UploadId); + + $abortRequest = new Oss\Models\AbortMultipartUploadRequest($bucketName, $objectNameMultipartCopy, $uploadId); + $result = $client->presign($abortRequest); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(204, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + } + + public function testPresignError() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + try { + $request = new Oss\Models\ListObjectsRequest($bucketName); + $result = $client->presign($request); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString("Invalid request type: AlibabaCloud\Oss\V2\Models\ListObjectsRequest", $e); + } + + try { + $result = $client->presign(null); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString("is not subclass of RequestModel, got NULL", $e); + } + } + + public function testPresignWithContentType() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object.zip'; + $body = 'hi oss'; + $httpClient = new GuzzleHttp\Client(); + // PutObjRequest + try { + $request = new Oss\Models\PutObjectRequest($bucketName, $objectName); + $result = $client->presign($request); + $response = $httpClient->request($result->method, $result->url, ['body' => $body]); + $this->assertCount(0, $result->signedHeaders); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + // UploadPart + $objectNameMultipart = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-multi-part.zip'; + try { + $request = new Oss\Models\InitiateMultipartUploadRequest($bucketName, $objectNameMultipart); + $result = $client->presign($request); + $this->assertCount(1, $result->signedHeaders); + $this->assertArrayHasKey('content-md5', $result->signedHeaders); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + $body = $response->getBody()->getContents(); + $xml = Utils::parseXml($body); + $uploadId = Functions::tryToString($xml->UploadId); + try { + $partRequest = new Oss\Models\UploadPartRequest($bucketName, $objectNameMultipart); + $partRequest->partNumber = 1; + $partRequest->uploadId = $uploadId; + $result = $client->presign($partRequest); + $response = $httpClient->request($result->method, $result->url, ['body' => $body, ['headers' => $result->signedHeaders]]); + $this->assertEquals(200, $response->getStatusCode()); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + try { + $request = new Oss\Models\CompleteMultipartUploadRequest($bucketName, $objectNameMultipart); + $request->completeMultipartUpload = new CompleteMultipartUpload( + [new Oss\Models\UploadPart( + $partRequest->partNumber, $response->getHeaderLine('ETag') + )] + ); + $request->uploadId = $uploadId; + $result = $client->presign($request); + $xml = new \SimpleXMLElement(''); + if (isset($request->completeMultipartUpload->parts)) { + foreach ($request->completeMultipartUpload->parts as $part) { + $xmlPart = $xml->addChild('Part'); + $xmlPart->addChild('PartNumber', strval($part->partNumber)); + $xmlPart->addChild('ETag', $part->etag); + } + } + $response = $httpClient->request($result->method, $result->url, ['body' => $xml->asXML(), 'headers' => $result->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $headRequest = new Oss\Models\HeadObjectRequest($bucketName, $objectNameMultipart); + $headResult = $client->headObject($headRequest); + $this->assertEquals(200, $headResult->statusCode); + $this->assertEquals(strlen($body), $headResult->contentLength); + $this->assertEquals('Multipart', $headResult->objectType); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + $objectNameMultipartCopy = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-multi-part-copy'; + + try { + $initRequest = new Oss\Models\InitiateMultipartUploadRequest($bucketName, $objectNameMultipartCopy); + $initResult = $client->presign($initRequest); + $response = $httpClient->request($initResult->method, $initResult->url, ['headers' => $initResult->signedHeaders]); + $this->assertEquals(200, $response->getStatusCode()); + $body = $response->getBody()->getContents(); + $xml = Utils::parseXml($body); + $uploadId = Functions::tryToString($xml->UploadId); + + $abortRequest = new Oss\Models\AbortMultipartUploadRequest($bucketName, $objectNameMultipartCopy, $uploadId); + $result = $client->presign($abortRequest); + $response = $httpClient->request($result->method, $result->url, ['headers' => $result->signedHeaders]); + $this->assertEquals(204, $response->getStatusCode()); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + } + + public function testPresignWithAnonymous() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName.'-pub'; + $objectName = self::$OBJECTNAME_PREFIX . self::randomLowStr() . '-put-object'; + + $client->putBucket(new Oss\Models\PutBucketRequest($bucketName)); + $client->putBucketPublicAccessBlock(new Oss\Models\PutBucketPublicAccessBlockRequest( + $bucketName, + new Oss\Models\PublicAccessBlockConfiguration( + false + ) + )); + + $content = 'hi oss'; + $putObjectRequest = new Oss\Models\PutObjectRequest( + $bucketName, $objectName + ); + $putObjectRequest->acl = 'public-read'; + $putObjectRequest->body = Utils::streamFor($content); + $client->putObject($putObjectRequest); + + $request = new Oss\Models\GetObjectRequest($bucketName, $objectName); + $options['credentials_provider'] = new Oss\Credentials\AnonymousCredentialsProvider(); + $result = $client->presign($request, $options); + $this->assertNotEmpty($result->url); + $this->assertNotEmpty($result->method); + $this->assertStringNotContainsString('?', $result->url); + $httpClient = new GuzzleHttp\Client(); + $response = $httpClient->get($result->url); + $this->assertEquals($response->getStatusCode(), 200); + $this->assertEquals($response->getBody()->getContents(), $content); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPublicAccessBlockTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPublicAccessBlockTest.php new file mode 100644 index 0000000..7ab50f5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/ClientPublicAccessBlockTest.php @@ -0,0 +1,88 @@ +getDefaultClient(); + // PutPublicAccessBlock + $putResult = $client->putPublicAccessBlock(new Oss\Models\PutPublicAccessBlockRequest( + new Oss\Models\PublicAccessBlockConfiguration(true) + )); + $this->assertEquals(200, $putResult->statusCode); + $this->assertEquals('OK', $putResult->status); + $this->assertEquals(True, count($putResult->headers) > 0); + $this->assertEquals(24, strlen($putResult->requestId)); + + // GetPublicAccessBlock + $getResult = $client->getPublicAccessBlock(new Oss\Models\GetPublicAccessBlockRequest()); + $this->assertEquals(200, $getResult->statusCode); + $this->assertEquals('OK', $getResult->status); + $this->assertEquals(True, count($getResult->headers) > 0); + $this->assertEquals(24, strlen($getResult->requestId)); + + // DeletePublicAccessBlock + $delResult = $client->deletePublicAccessBlock(new Oss\Models\DeletePublicAccessBlockRequest()); + $this->assertEquals(204, $delResult->statusCode); + $this->assertEquals('No Content', $delResult->status); + $this->assertEquals(True, count($delResult->headers) > 0); + $this->assertEquals(24, strlen($delResult->requestId)); + } + + public function testPublicAccessBlockFail() + { + $client = $this->getInvalidAkClient(); + // PutPublicAccessBlock + try { + $putResult = $client->putPublicAccessBlock(new Oss\Models\PutPublicAccessBlockRequest( + new Oss\Models\PublicAccessBlockConfiguration(true) + )); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error PutPublicAccessBlock', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // GetPublicAccessBlock + try { + $getResult = $client->getPublicAccessBlock(new Oss\Models\GetPublicAccessBlockRequest()); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error GetPublicAccessBlock', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + + // DeletePublicAccessBlock + try { + $delResult = $client->deletePublicAccessBlock(new Oss\Models\DeletePublicAccessBlockRequest()); + $this->assertTrue(false, "should not here"); + } catch (Oss\Exception\OperationException $e) { + $this->assertStringContainsString('Operation error DeletePublicAccessBlock', $e); + $se = $e->getPrevious(); + $this->assertInstanceOf(Oss\Exception\ServiceException::class, $se); + if ($se instanceof Oss\Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals(403, $se->getStatusCode()); + $this->assertEquals(24, strlen($se->getRequestId())); + } + } + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/EncryptionClientTest.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/EncryptionClientTest.php new file mode 100644 index 0000000..24816f7 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/EncryptionClientTest.php @@ -0,0 +1,1045 @@ +getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $filesize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $filesize); + $content = file_get_contents($filename); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->contentMd5 = base64_encode(md5_file($filename, true)); + $putObjRequest->contentLength = $filesize; + $putObjRequest->body = Oss\Utils::streamFor($content); + $result = $eclient->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + // undec content + $unDecContent = $this->object_get_contents($client, $bucketName, $key); + $this->assertEquals($filesize, strlen($unDecContent)); + $this->assertNotEquals($content, $unDecContent); + + // get object + $result = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals($content, $result->body->getContents()); + $this->assertEquals($filesize, $result->contentLength); + $this->assertEquals(strval($filesize), $result->headers['Content-Length']); + $this->assertNull($result->contentRange); + + foreach ([0, 1, 2, 3, 4, 5, 7, 16, 17, 32, 63, 64, 79] as $offset) { + $request = new Oss\Models\GetObjectRequest( + $bucketName, + $key + ); + $request->rangeHeader = "bytes=$offset-"; + $result = $eclient->getObject($request); + $this->assertEquals(206, $result->statusCode); + $this->assertEquals('Partial Content', $result->status); + $this->assertEquals(substr($content, $offset), $result->body->getContents()); + $this->assertEquals($filesize - $offset, $result->contentLength); + $this->assertEquals(strval($filesize - $offset), $result->headers['Content-Length']); + $contentRange = sprintf("bytes %d-%d/%d", $offset, $filesize - 1, $filesize); + $this->assertEquals($contentRange, $result->contentRange); + $this->assertEquals($contentRange, $result->headers['Content-Range']); + } + + foreach ([0, 1, 2, 17, 32, 63, 79] as $offset) { + $gotSize = 1234; + $rangeEnd = $offset + $gotSize - 1; + $request = new Oss\Models\GetObjectRequest( + $bucketName, + $key + ); + $request->rangeHeader = "bytes=$offset-$rangeEnd"; + $result = $eclient->getObject($request); + $this->assertEquals(206, $result->statusCode); + $this->assertEquals('Partial Content', $result->status); + $this->assertEquals(substr($content, $offset, $gotSize), $result->body->getContents()); + $this->assertEquals($gotSize, $result->contentLength); + $this->assertEquals(strval($gotSize), $result->headers['Content-Length']); + $contentRange = sprintf("bytes %d-%d/%d", $offset, $rangeEnd, $filesize); + $this->assertEquals($contentRange, $result->contentRange); + $this->assertEquals($contentRange, $result->headers['Content-Range']); + } + } + + public function testPutAndGetObjectWithManyRsa() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $filesize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $filesize); + $content = file_get_contents($filename); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['demo1'] + ); + + $masterCipher2 = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY1, + self::RSA_PRIVATE_KEY1, + ['demo2'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher2, [$masterCipher, $masterCipher2]); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->contentMd5 = base64_encode(md5_file($filename, true)); + $putObjRequest->contentLength = $filesize; + $putObjRequest->body = Oss\Utils::streamFor($content); + $result = $eclient->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + // undec content + $unDecContent = $this->object_get_contents($client, $bucketName, $key); + $this->assertEquals($filesize, strlen($unDecContent)); + $this->assertNotEquals($content, $unDecContent); + + // get object + $result = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals($content, $result->body->getContents()); + $this->assertEquals($filesize, $result->contentLength); + $this->assertEquals(strval($filesize), $result->headers['Content-Length']); + $this->assertNull($result->contentRange); + + foreach ([0, 1, 2, 3, 4, 5, 7, 16, 17, 32, 63, 64, 79] as $offset) { + $request = new Oss\Models\GetObjectRequest( + $bucketName, + $key + ); + $request->rangeHeader = "bytes=$offset-"; + $result = $eclient->getObject($request); + $this->assertEquals(206, $result->statusCode); + $this->assertEquals('Partial Content', $result->status); + $this->assertEquals(substr($content, $offset), $result->body->getContents()); + $this->assertEquals($filesize - $offset, $result->contentLength); + $this->assertEquals(strval($filesize - $offset), $result->headers['Content-Length']); + $contentRange = sprintf("bytes %d-%d/%d", $offset, $filesize - 1, $filesize); + $this->assertEquals($contentRange, $result->contentRange); + $this->assertEquals($contentRange, $result->headers['Content-Range']); + } + + foreach ([0, 1, 2, 17, 32, 63, 79] as $offset) { + $gotSize = 1234; + $rangeEnd = $offset + $gotSize - 1; + $request = new Oss\Models\GetObjectRequest( + $bucketName, + $key + ); + $request->rangeHeader = "bytes=$offset-$rangeEnd"; + $result = $eclient->getObject($request); + $this->assertEquals(206, $result->statusCode); + $this->assertEquals('Partial Content', $result->status); + $this->assertEquals(substr($content, $offset, $gotSize), $result->body->getContents()); + $this->assertEquals($gotSize, $result->contentLength); + $this->assertEquals(strval($gotSize), $result->headers['Content-Length']); + $contentRange = sprintf("bytes %d-%d/%d", $offset, $rangeEnd, $filesize); + $this->assertEquals($contentRange, $result->contentRange); + $this->assertEquals($contentRange, $result->headers['Content-Range']); + } + } + + public function testGetObjectStreamMode() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $filesize = 250 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $filesize); + $content = file_get_contents($filename); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->body = Oss\Utils::streamFor($content); + $result = $eclient->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNotEquals($content, $this->object_get_contents($client, $bucketName, $key)); + + // get object + $args = [ + 'request_options' => + ['stream' => true] + ]; + $result = $eclient->getObject( + new Oss\Models\GetObjectRequest( + $bucketName, + $key + ), + $args + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertFalse($result->body->isSeekable()); + $this->assertInstanceOf(Oss\Crypto\ReadDecryptStream::class, $result->body); + $this->assertEquals($content, $result->body->getContents()); + $this->assertEquals($filesize, $result->contentLength); + $this->assertEquals(strval($filesize), $result->headers['Content-Length']); + $this->assertNull($result->contentRange); + $this->assertCount(1, $args['request_options']); + + // range get + $args = [ + 'request_options' => + ['stream' => true] + ]; + $request = new Oss\Models\GetObjectRequest( + $bucketName, + $key + ); + $offset = 12345; + $gotSize = 22234; + $rangeEnd = $offset + $gotSize - 1; + $request->rangeHeader = sprintf("bytes=%d-%d", $offset, $rangeEnd); + $result = $eclient->getObject($request, $args); + $this->assertEquals(206, $result->statusCode); + $this->assertEquals('Partial Content', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertFalse($result->body->isSeekable()); + $this->assertInstanceOf(Oss\Crypto\ReadDecryptStream::class, $result->body); + $this->assertEquals(substr($content, $offset, $gotSize), $result->body->getContents()); + $this->assertEquals($gotSize, $result->contentLength); + $this->assertEquals(strval($gotSize), $result->headers['Content-Length']); + $contentRange = sprintf("bytes %d-%d/%d", $offset, $rangeEnd, $filesize); + $this->assertEquals($contentRange, $result->contentRange); + $this->assertCount(1, $args['request_options']); + } + + public function testHeadObject() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $filesize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $filesize); + $content = file_get_contents($filename); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->body = Oss\Utils::streamFor($content); + $result = $eclient->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // head object + $result = $eclient->headObject(new Oss\Models\HeadObjectRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertNotEmpty($result->metadata['client-side-encryption-key']); + $this->assertNotEmpty($result->metadata['client-side-encryption-start']); + $this->assertEquals('AES/CTR/NoPadding', $result->metadata['client-side-encryption-cek-alg']); + $this->assertEquals('RSA/NONE/PKCS1Padding', $result->metadata['client-side-encryption-wrap-alg']); + $this->assertEquals('{"key":"value"}', $result->metadata['client-side-encryption-matdesc']); + } + + public function testGetObjectMeta() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $filesize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $filesize); + $content = file_get_contents($filename); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->body = Oss\Utils::streamFor($content); + $result = $eclient->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get object meta + $result = $eclient->getObjectMeta(new Oss\Models\GetObjectMetaRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals(strlen($content), $result->contentLength); + } + + public function testObjectMultipart() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . '-multipart'; + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + $eclient = new Oss\EncryptionClient($client, $masterCipher); + $partSize = 200 * 1024; + $length = 500 * 1024; + $bigFileName = self::getTempFileName() . "-bigfile.tmp"; + $this->generateFile($bigFileName, $length); + try { + $initRequest = new Oss\Models\InitiateMultipartUploadRequest( + $bucketName, + $key, + ); + $initRequest->cseDataSize = $length; + $initRequest->csePartSize = $partSize; + $initRequest->contentMd5 = base64_encode(md5_file($bigFileName, true)); + $initRequest->contentLength = $length; + $initResult = $eclient->initiateMultipartUpload( + $initRequest + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partRequest = new Oss\Models\UploadPartRequest( + $bucketName, + $key, + $i, + $initResult->uploadId, + strlen($chunk), + null, + null, + null, + Oss\Utils::streamFor($chunk) + ); + $partRequest->encryptionMultipartContext = $initResult->encryptionMultipartContext; + $partResult = $eclient->uploadPart($partRequest); + $this->assertEquals(200, $partResult->statusCode); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $comResult = $eclient->completeMultipartUpload( + new Oss\Models\CompleteMultipartUploadRequest( + $bucketName, + $key, + $initResult->uploadId, + null, + new Oss\Models\CompleteMultipartUpload( + $parts + ), + ) + ); + $this->assertEquals(200, $comResult->statusCode); + $this->assertEquals($bucketName, $comResult->bucket); + $this->assertEquals($key, $comResult->key); + $this->assertNotEmpty($comResult->etag); + $this->assertNotEmpty($comResult->location); + $getObj = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key, + )); + $this->assertEquals(base64_encode(md5(file_get_contents($bigFileName), true)), base64_encode(md5($getObj->body, true))); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $initRequest = new Oss\Models\InitiateMultipartUploadRequest( + $bucketName, + $key, + ); + $initRequest->cseDataSize = $length; + $initRequest->csePartSize = $partSize; + $initResult = $eclient->initiateMultipartUpload( + $initRequest + ); + $this->assertEquals(200, $initResult->statusCode); + $this->assertNotEmpty($initResult->uploadId); + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partRequest = new Oss\Models\UploadPartRequest( + $bucketName, + $key, + $i, + $initResult->uploadId, + strlen($chunk), + null, + null, + null, + Oss\Utils::streamFor($chunk) + ); + $partRequest->contentMd5 = base64_encode(md5($chunk, true)); + $partRequest->encryptionMultipartContext = $initResult->encryptionMultipartContext; + $partResult = $eclient->uploadPart($partRequest); + $this->assertEquals(200, $partResult->statusCode); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $listResult = $eclient->listParts( + new Oss\Models\ListPartsRequest( + $bucketName, + $key, + $initResult->uploadId, + ) + ); + $this->assertEquals(200, $listResult->statusCode); + $this->assertEquals($bucketName, $listResult->bucket); + $this->assertEquals($key, $listResult->key); + $this->assertCount(3, $listResult->parts); + + $abort = $eclient->abortMultipartUpload( + new Oss\Models\AbortMultipartUploadRequest( + self::$bucketName, + $key, + $initResult->uploadId, + ) + ); + $this->assertEquals(204, $abort->statusCode); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testUploader() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . '-multipart-uploader'; + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + $partSize = 200 * 1024; + $length = 500 * 1024; + $filename = self::getTempFileName(); + $this->generateFile($filename, $length); + try { + $u = $eclient->newUploader(); + $u->uploadFile(new \AlibabaCloud\Oss\V2\Models\PutObjectRequest( + $bucketName, + $key, + ), $filename); + $getObj = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key, + )); + $this->assertEquals(base64_encode(md5(file_get_contents($filename), true)), base64_encode(md5($getObj->body, true))); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $u = $eclient->newUploader(array( + 'part_size' => $partSize, + 'total_size' => $length, + )); + $u->uploadFile(new \AlibabaCloud\Oss\V2\Models\PutObjectRequest( + $bucketName, + $key, + ), $filename); + $getObj = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key, + )); + $this->assertEquals(base64_encode(md5(file_get_contents($filename), true)), base64_encode(md5($getObj->body, true))); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $u = $eclient->newUploader(array( + 'part_size' => $partSize, + 'total_size' => $length, + )); + $u->uploadFrom(new \AlibabaCloud\Oss\V2\Models\PutObjectRequest( + $bucketName, + $key, + ), + new LazyOpenStream($filename, 'rb'), + [ + 'part_size' => $partSize, + ]); + $getObj = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key, + )); + $this->assertEquals(base64_encode(md5(file_get_contents($filename), true)), base64_encode(md5($getObj->body, true))); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + unlink($filename); + } + + public function testDownloader() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . '-multipart-uploader'; + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ); + $length = 500 * 1024; + $partSize = 200 * 1024; + $eclient = new Oss\EncryptionClient($client, $masterCipher); + $downFileName = self::getTempFileName() . "-download.tmp"; + $bigFileName = self::getTempFileName() . "-bigfile.tmp"; + $this->generateFile($bigFileName, $length); + $content = \file_get_contents($bigFileName); + $u = $eclient->newUploader(); + $u->uploadFile(new \AlibabaCloud\Oss\V2\Models\PutObjectRequest( + $bucketName, + $key, + ), $bigFileName); + + try { + $d = $eclient->newDownloader(); + $d->downloadFile(new Oss\Models\GetObjectRequest($bucketName, $key), $downFileName); + $this->assertEquals(md5_file($bigFileName), md5_file($downFileName)); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $d = $eclient->newDownloader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + $d->downloadFile(new Oss\Models\GetObjectRequest($bucketName, $key), $downFileName); + $this->assertEquals(md5_file($bigFileName), md5_file($downFileName)); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $d = $eclient->newDownloader( + [ + 'part_size' => $partSize, + 'parallel_num' => 2, + ] + ); + $d->downloadFile(new Oss\Models\GetObjectRequest($bucketName, $key), $downFileName); + $this->assertEquals(md5_file($bigFileName), md5_file($downFileName)); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $d = $eclient->newDownloader( + [ + 'part_size' => $partSize, + 'parallel_num' => 1, + ] + ); + $stream = new BufferStream(1 * 1024 * 1024); + $result = $d->downloadTo( + new Oss\Models\GetObjectRequest( + $bucketName, + $key + ), + $stream, + ); + $gotContent = $stream->getContents(); + $this->assertEquals($length, $result->written); + $this->assertEquals($length, strlen($gotContent)); + $this->assertEquals($content, $gotContent); + $this->assertEquals(md5_file($bigFileName), md5_file($downFileName)); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testEncryptionCompatibility() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = 'example.jpg'; + + $filename = self::getDataPath() . DIRECTORY_SEPARATOR . 'example.jpg'; + $filesize = filesize($filename); + $content = file_get_contents($filename); + + $encFilename = self::getDataPath() . DIRECTORY_SEPARATOR . 'enc-example.jpg'; + $encFilesize = filesize($encFilename); + $encContent = file_get_contents($encFilename); + + $this->assertEquals($filesize, $encFilesize); + $this->assertNotEquals($content, $encContent); + + // decrypt only + $masterCipher = new Oss\Crypto\MasterRsaCipher( + null, + self::RSA_PRIVATE_KEY, + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + + // put test encrypted data + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->body = Oss\Utils::streamFor($encContent); + $putObjRequest->metadata = [ + "client-side-encryption-key" => "nyXOp7delQ/MQLjKQMhHLaT0w7u2yQoDLkSnK8MFg/MwYdh4na4/LS8LLbLcM18m8I/ObWUHU775I50sJCpdv+f4e0jLeVRRiDFWe+uo7Puc9j4xHj8YB3QlcIOFQiTxHIB6q+C+RA6lGwqqYVa+n3aV5uWhygyv1MWmESurppg=", + "client-side-encryption-start" => "De/S3T8wFjx7QPxAAFl7h7TeI2EsZlfCwox4WhLGng5DK2vNXxULmulMUUpYkdc9umqmDilgSy5Z3Foafw+v4JJThfw68T/9G2gxZLrQTbAlvFPFfPM9Ehk6cY4+8WpY32uN8w5vrHyoSZGr343NxCUGIp6fQ9sSuOLMoJg7hNw=", + "client-side-encryption-cek-alg" => "AES/CTR/NoPadding", + "client-side-encryption-wrap-alg" => "RSA/NONE/PKCS1Padding", + ]; + $result = $client->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // use non-encryption client to get object + $result = $client->getObject(new Oss\Models\GetObjectRequest($bucketName, $key)); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals($encContent, $result->body->getContents()); + + // use encryption client to get object + $result = $eclient->getObject(new Oss\Models\GetObjectRequest($bucketName, $key)); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals($content, $result->body->getContents()); + $this->assertInstanceOf(GuzzleHttp\Psr7\Stream::class, $result->body); + + // use encryption client to get object into filepath + $filenameSave = self::getTempFileName(); + $result = $eclient->getObject( + new Oss\Models\GetObjectRequest($bucketName, $key), + [ + 'request_options' => + ['sink' => $filenameSave] + ] + ); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertFileEquals($filename, $filenameSave); + $this->assertNull($result->body); + } + + public function testGetObjectInvalidArgument() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + $filesize = 25 * 1024 + 123; + $filename = self::getTempFileName(); + $this->generateFile($filename, $filesize); + $content = file_get_contents($filename); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + + // put object + $putObjRequest = new Oss\Models\PutObjectRequest( + $bucketName, + $key, + ); + $putObjRequest->contentMd5 = base64_encode(md5_file($filename, true)); + $putObjRequest->contentLength = $filesize; + $putObjRequest->body = Oss\Utils::streamFor($content); + $result = $eclient->putObject($putObjRequest); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + + // get object + $result = $eclient->getObject(new Oss\Models\GetObjectRequest( + $bucketName, + $key + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(True, count($result->headers) > 0); + $this->assertEquals(24, strlen($result->requestId)); + $this->assertEquals($content, $result->body->getContents()); + $this->assertEquals($filesize, $result->contentLength); + $this->assertEquals(strval($filesize), $result->headers['Content-Length']); + + try { + $offset = 0; + $request = new Oss\Models\GetObjectRequest( + $bucketName, + $key + ); + $request->rangeHeader = "2bytes=$offset-"; + $result = $eclient->getObject($request); + $this->assertTrue(false, 'should not here'); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('request.rangeHeader is invalid, got', $e->getMessage()); + } + + } + + public function testInitiateMultipartUploadInvalidArgument() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName(); + + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + try { + $result = $eclient->initiateMultipartUpload(new Oss\Models\InitiateMultipartUploadRequest( + $bucketName, + $key + )); + $this->assertTrue(false, 'should not here'); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('request.csePartSize is invalid.', $e->getMessage()); + } + + try { + $request = new Oss\Models\InitiateMultipartUploadRequest( + $bucketName, + $key + ); + $request->csePartSize = 1; + $result = $eclient->initiateMultipartUpload($request); + $this->assertTrue(false, 'should not here'); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('request.cseDataSize is invalid.', $e->getMessage()); + } + + try { + $request = new Oss\Models\InitiateMultipartUploadRequest( + $bucketName, + $key + ); + $request->csePartSize = 1; + $request->cseDataSize = 200; + $result = $eclient->initiateMultipartUpload($request); + $this->assertTrue(false, 'should not here'); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('request.csePartSize must be aligned to', $e->getMessage()); + } + + } + + public function testUploadPartInvalidArgument() + { + $client = $this->getDefaultClient(); + $bucketName = self::$bucketName; + $key = self::randomObjectName() . '-multipart'; + $masterCipher = new Oss\Crypto\MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + + $eclient = new Oss\EncryptionClient($client, $masterCipher); + $partSize = 200 * 1024; + $length = 500 * 1024; + $bigFileName = self::getTempFileName() . "-bigfile.tmp"; + $this->generateFile($bigFileName, $length); + try { + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partRequest = new Oss\Models\UploadPartRequest( + $bucketName, + $key, + $i, + '123', + strlen($chunk), + null, + null, + null, + Oss\Utils::streamFor($chunk) + ); + $partResult = $eclient->uploadPart($partRequest); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $this->assertTrue(false, "should not here"); + } catch (\Throwable $e) { + $this->assertStringContainsString('request.encryptionMultiPart is null.', $e->getMessage()); + } + + try { + $file = fopen($bigFileName, 'r'); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partRequest = new Oss\Models\UploadPartRequest( + $bucketName, + $key, + $i, + '123', + strlen($chunk), + null, + null, + null, + Oss\Utils::streamFor($chunk) + ); + $partRequest->encryptionMultipartContext = new Oss\Models\EncryptionMultipartContext(); + $partResult = $eclient->uploadPart($partRequest); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $this->assertTrue(false, "should not here"); + } catch (\Throwable $e) { + $this->assertStringContainsString('request.encryptionMultiPart is invalid.', $e->getMessage()); + } + + try { + $file = fopen($bigFileName, 'r'); + $builder = new Oss\Crypto\AesCtrCipherBuilder($masterCipher); + $cc = $builder->fromCipherData(); + $cc->getCipherData(); + $parts = array(); + if ($file) { + $i = 1; + while (!feof($file)) { + $chunk = fread($file, $partSize); + $partRequest = new Oss\Models\UploadPartRequest( + $bucketName, + $key, + $i, + '123', + strlen($chunk), + null, + null, + null, + Oss\Utils::streamFor($chunk) + ); + $partRequest->encryptionMultipartContext = new Oss\Models\EncryptionMultipartContext($cc, 100, 2); + $partResult = $eclient->uploadPart($partRequest); + $part = new Oss\Models\UploadPart( + $i, + $partResult->etag, + ); + array_push($parts, $part); + $i++; + } + fclose($file); + } + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString('request.encryptionMultiPart.partSize must be aligned to', $e->getMessage()); + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/IntegrationTests/TestIntegration.php b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/TestIntegration.php new file mode 100644 index 0000000..409f4f9 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/IntegrationTests/TestIntegration.php @@ -0,0 +1,402 @@ +putBucket(new Oss\Models\PutBucketRequest($bucketName)); + } + + public static function tearDownAfterClass(): void + { + //clean access points + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + self::deleteAccessPoint(self::getDefaultClient(), self::$bucketName); + } + + //clean buckets + self::cleanBucket(self::getDefaultClient(), self::$bucketName); + + //clean temp dir + self::deleteDir(self::$tempDir); + } + + static function getDefaultClient() + { + if (self::$defaultClient != null) { + return self::$defaultClient; + } + + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider(new Oss\Credentials\StaticCredentialsProvider( + self::$ACCESS_ID, + self::$ACCESS_KEY + )); + $cfg->setRegion(self::$REGION); + $cfg->setEndpoint(self::$ENDPOINT); + self::$defaultClient = new Oss\Client($cfg); + return self::$defaultClient; + } + + static function getClient(string $ak, $sk, $region, $endpoint) + { + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider(new Oss\Credentials\StaticCredentialsProvider( + $ak, + $sk + )); + $cfg->setRegion($region); + if (!empty($endpoint)) { + $cfg->setEndpoint($endpoint); + } + return new Oss\Client($cfg); + } + + static function getInvalidAkClient() + { + if (self::$invalidAkClient != null) { + return self::$invalidAkClient; + } + + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider(new Oss\Credentials\StaticCredentialsProvider( + 'invalid-ak', + 'invalid' + )); + $cfg->setRegion(self::$REGION); + $cfg->setEndpoint(self::$ENDPOINT); + self::$invalidAkClient = new Oss\Client($cfg); + return self::$invalidAkClient; + } + + public static function getTempFileName() + { + return tempnam(self::$tempDir, 'test'); + } + + /** + * @return Oss\Client|null + * @throws \Throwable + */ + public function getClientUseStsToken() + { + try { + $resp = $this->stsAssumeRole(self::$ACCESS_ID, self::$ACCESS_KEY, self::$RAM_ROLE_ARN); + $accessKeyId = $resp['Credentials']['AccessKeyId']; + $accessKeySecret = $resp['Credentials']['AccessKeySecret']; + $token = $resp['Credentials']['SecurityToken']; + $cfg = Oss\Config::loadDefault(); + $cfg->setCredentialsProvider(new Oss\Credentials\StaticCredentialsProvider( + $accessKeyId, + $accessKeySecret, + $token + )); + $cfg->setRegion(self::$REGION); + $cfg->setEndpoint(self::$ENDPOINT); + return new Oss\Client($cfg); + } catch (\Throwable $e) { + throw $e; + } + } + + private function stsAssumeRole($accessKeyId, $accessKeySecret, $roleArn) + { + // Constants + $StsSignVersion = "1.0"; + $StsAPIVersion = "2015-04-01"; + $StsHost = "https://sts.aliyuncs.com/"; + $TimeFormat = "Y-m-d\TH:i:s\Z"; + $RespBodyFormat = "JSON"; + $PercentEncode = "%2F"; + $HTTPGet = "GET"; + $uuid = "Nonce-" . rand(1000, 9999); + $currentTime = (new \DateTime('now', new \DateTimeZone('UTC')))->format($TimeFormat); + $queryStr = http_build_query([ + "SignatureVersion" => $StsSignVersion, + "Format" => $RespBodyFormat, + "Timestamp" => $currentTime, + "RoleArn" => $roleArn, + "RoleSessionName" => "oss_test_sess", + "AccessKeyId" => $accessKeyId, + "SignatureMethod" => "HMAC-SHA1", + "Version" => $StsAPIVersion, + "Action" => "AssumeRole", + "SignatureNonce" => $uuid, + "DurationSeconds" => 3600 + ]); + parse_str($queryStr, $queryParams); + ksort($queryParams); + $queryStr = http_build_query($queryParams); + $strToSign = $HTTPGet . "&" . $PercentEncode . "&" . rawurlencode($queryStr); + $signature = base64_encode(hash_hmac('sha1', $strToSign, $accessKeySecret . "&", true)); + $assumeURL = $StsHost . "?" . $queryStr . "&Signature=" . urlencode($signature); + $httpClient = new \GuzzleHttp\Client(); + try { + $resp = $httpClient->get($assumeURL); + $result = json_decode($resp->getBody()->getContents(), true); + if (json_last_error() !== JSON_ERROR_NONE) { + throw new \Exception("Failed to decode JSON response"); + } + return $result; + } catch (\Throwable $e) { + throw $e; + } + } + + public static function randomBucketName() + { + return self::$BUCKETNAME_PREFIX . strval(rand(0, 100)) . '-' . strval(time()); + } + + public static function randomObjectName() + { + return self::$OBJECTNAME_PREFIX . strval(rand(0, 100)) . '-' . strval(time()); + } + + public static function randomLowStr() + { + self::$BUCKETNAME_PREFIX . strval(rand(0, 100)) . '-' . strval(time()); + } + + public static function randomStr() + { + self::$BUCKETNAME_PREFIX . strval(rand(0, 100)) . '-' . strval(time()); + } + + public static function waitFor(float $sec) + { + usleep((int)($sec * 1000000)); + } + + public static function cleanBucket(Oss\Client $client, string $bucketName): void + { + //delete Objects + $paginator = new Oss\Paginator\ListObjectsPaginator($client); + $iter = $paginator->iterPage(new Oss\Models\ListObjectsRequest($bucketName)); + foreach ($iter as $page) { + $objects = []; + foreach ($page->contents ?? [] as $content) { + $objects[] = new Oss\Models\DeleteObject($content->key); + } + if (!empty($objects)) { + $client->deleteMultipleObjects(new Oss\Models\DeleteMultipleObjectsRequest( + $bucketName, + $objects + )); + } + } + + //delete uploadpart + $paginator = new Oss\Paginator\ListMultipartUploadsPaginator($client); + $iter = $paginator->iterPage(new Oss\Models\ListMultipartUploadsRequest($bucketName)); + foreach ($iter as $page) { + foreach ($page->uploads ?? [] as $upload) { + $client->abortMultipartUpload(new Oss\Models\AbortMultipartUploadRequest( + $bucketName, + $upload->key, + $upload->uploadId + )); + } + } + + $client->deleteBucket(new Oss\Models\DeleteBucketRequest($bucketName)); + } + + public static function deleteDir(string $dir): void + { + if (!is_dir($dir)) { + return; + } + + if ($handle = opendir($dir)) { + while (($entry = readdir($handle)) !== false) { + if ($entry == '.' || $entry == '..') { + continue; + } + $file = $dir . DIRECTORY_SEPARATOR . $entry; + + if (is_dir($file)) { + self::deleteDir($file); + } else { + unlink($file); + } + } + closedir($handle); + } + + rmdir($dir); + } + + public static function getDataPath(): string + { + return dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Data'; + } + + public static function deleteAccessPoint(Oss\Client $client, string $bucketName): void + { + $listRequest = new Oss\Models\ListAccessPointsRequest(); + $listRequest->bucket = $bucketName; + while (true) { + $listResult = $client->listAccessPoints($listRequest); + if (isset($listResult->listAccessPoints->accessPoints->accessPoints) && count($listResult->listAccessPoints->accessPoints->accessPoints) > 0) { + foreach ($listResult->listAccessPoints->accessPoints->accessPoints as $accessPoint) { + switch ($accessPoint->status) { + case 'creating': + sleep(3); + while (true) { + $getResult = $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPoint->accessPointName + )); + if ($getResult->getAccessPoint->status != 'creating') { + break; + } else { + sleep(3); + } + } + $client->deleteAccessPoint(new Oss\Models\DeleteAccessPointRequest( + $bucketName, $accessPoint->accessPointName + )); + break; + case 'deleting': + sleep(5); + break; + default: + $client->deleteAccessPoint(new Oss\Models\DeleteAccessPointRequest( + $bucketName, $accessPoint->accessPointName + )); + break; + } + while (true) { + try { + $client->getAccessPoint(new Oss\Models\GetAccessPointRequest( + $bucketName, $accessPoint->accessPointName + )); + } catch (Oss\Exception\OperationException $e) { + $se = $e->getPrevious(); + if ($se instanceof Oss\Exception\ServiceException) { + if ($se->getErrorCode() == 'NoSuchAccessPoint' && $se->getStatusCode() == 404) { + break; + } + } + } + sleep(3); + } + + } + if ($listResult->listAccessPoints->isTruncated == false) { + break; + } + if ($listResult->listAccessPoints->nextContinuationToken != "") { + $listRequest->continuationToken = $listResult->listAccessPoints->nextContinuationToken; + } + } else { + break; + } + } + } + + /** + * @param $filename + * @param $size + */ + public function generateFile($filename, $size) + { + if ( + file_exists($filename) && + $size == sprintf('%u', filesize($filename)) + ) { + return; + } + $part_size = 32; + $fp = fopen($filename, "w"); + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $charactersLength = strlen($characters); + if ($fp) { + while ($size > 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + $this->assertTrue(false, "write to $filename failed."); + break; + } + } + } else { + $this->assertTrue(false, "open $filename failed."); + } + fclose($fp); + } + + public function object_get_contents($client, $bucket, $key): string + { + $result = $client->getObject(new Oss\Models\GetObjectRequest( + self::$bucketName, + $key, + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + return $result->body->getContents(); + } + + public function object_get_content_type($client, $bucket, $key): string + { + $result = $client->headObject(new Oss\Models\HeadObjectRequest( + self::$bucketName, + $key, + )); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + return $result->contentType; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/AnnotationTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/AnnotationTest.php new file mode 100644 index 0000000..487accd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/AnnotationTest.php @@ -0,0 +1,80 @@ +getAttributes(); + $this->assertCount(1, $attributes); + $inst = $attributes[0]->newInstance(); + $this->assertNotNull($inst); + $this->assertEquals("XmlRoot", $inst->name); + + $prop = $ro->getProperty("strValue"); + $this->assertNotNull($prop); + $attributes = $prop->getAttributes(); + $this->assertCount(1, $attributes); + $inst = $attributes[0]->newInstance(); + $this->assertNotNull($inst); + $this->assertEquals("StrValue", $inst->rename); + $this->assertEquals("string", $inst->type); + + $prop = $ro->getProperty("strValueLists"); + $this->assertNotNull($prop); + $attributes = $prop->getAttributes(); + $this->assertCount(1, $attributes); + $inst = $attributes[0]->newInstance(); + $this->assertNotNull($inst); + $this->assertEquals("StrValueList", $inst->rename); + $this->assertEquals("string", $inst->type); + } + + public function testRequiredProperty() + { + $obj = new ModelObject(); + $ro = new \ReflectionObject($obj); + + $prop = $ro->getProperty("strValue"); + $this->assertNotNull($prop); + $this->assertTrue(Functions::isRequiredProperty($prop)); + + $prop = $ro->getProperty("intValue"); + $this->assertNotNull($prop); + $this->assertFalse(Functions::isRequiredProperty($prop)); + } + + public function testFunctions() + { + $obj = new ModelObject(); + $ro = new \ReflectionObject($obj); + + $prop = $ro->getProperty("strValue"); + $this->assertNotNull($prop); + + $result = Functions::getXmlElementAnnotation($prop); + $this->assertNull($result); + + $result = Functions::getTagAnnotation($prop); + $this->assertNotNull($result); + $this->assertEquals("input", $result->tag); + $this->assertEquals("nop", $result->position); + $this->assertEquals("StrValue", $result->rename); + $this->assertEquals("string", $result->type); + + $result = Functions::getPropertyAnnotations($prop); + $this->assertCount(2, $result); + + $this->assertEquals("input", $result[1]->tag); + $this->assertEquals("nop", $result[1]->position); + $this->assertEquals("StrValue", $result[1]->rename); + $this->assertEquals("string", $result[1]->type); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/ModelObject.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/ModelObject.php new file mode 100644 index 0000000..869c11e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/ModelObject.php @@ -0,0 +1,39 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + $this->strValueLists = $strValueLists; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/XmlObject.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/XmlObject.php new file mode 100644 index 0000000..2554626 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Annotation/XmlObject.php @@ -0,0 +1,39 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + $this->strValueLists = $strValueLists; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/ClientImplTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/ClientImplTest.php new file mode 100644 index 0000000..f1a44df --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/ClientImplTest.php @@ -0,0 +1,2282 @@ +setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + + $ro = new \ReflectionObject($client); + + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + + $sdkOptions = $pSdkOptions->getValue($client); + $innerOptions = $pInnerOptions->getValue($client); + $requestOptions = $pRequestOptions->getValue($client); + + //default + $this->assertEquals('oss', $sdkOptions['product']); + $this->assertEquals('cn-hangzhou', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + $this->assertEquals(null, $sdkOptions['retry_max_attempts']); + $this->assertInstanceOf(Retry\StandardRetryer::class, $sdkOptions['retryer']); + + $this->assertInstanceOf(Signer\SignerV4::class, $sdkOptions['signer']); + $this->assertInstanceOf(Credentials\AnonymousCredentialsProvider::class, $sdkOptions['credentials_provider']); + + $this->assertEquals('virtual', $sdkOptions['address_style']); + $this->assertEquals('header', $sdkOptions['auth_method']); + $this->assertEquals(null, $sdkOptions['response_handlers']); + $this->assertEquals(0, $sdkOptions['feature_flags']); + $this->assertEquals(null, $cfg->getCloudBoxId()); + $this->assertEquals(null, $cfg->getEnableAutoDetectCloudBoxId()); + + #$this->assertEquals('oss', $sdkOptions['response_stream']); + + $this->assertEquals(null, $innerOptions['handler']); + $this->assertStringContainsString('alibabacloud-php-sdk-v2/0.', $innerOptions['user_agent']); + + $this->assertEquals(False, $requestOptions['allow_redirects']); + $this->assertEquals(10.0, $requestOptions['connect_timeout']); + $this->assertEquals(20.0, $requestOptions['read_timeout']); + $this->assertEquals(True, $requestOptions['verify']); + + // test cloud box id + $cfg = Config::loadDefault(); + $cfg->setCloudBoxId('cb-1234'); + $this->assertEquals('cb-1234', $cfg->getCloudBoxId()); + + $cfg->setEnableAutoDetectCloudBoxId(true); + $this->assertTrue($cfg->getEnableAutoDetectCloudBoxId()); + + $cfg->setEnableAutoDetectCloudBoxId(false); + $this->assertFalse($cfg->getEnableAutoDetectCloudBoxId()); + } + + public function testConfigCredentialsProvider() + { + // default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(null, $sdkOptions['credentials_provider']); + + // set AnonymousCredentialsProvider + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + + $this->assertInstanceOf(Credentials\AnonymousCredentialsProvider::class, $sdkOptions['credentials_provider']); + + // set static + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + + $this->assertInstanceOf(Credentials\StaticCredentialsProvider::class, $sdkOptions['credentials_provider']); + $cred = $sdkOptions['credentials_provider']->getCredentials(); + + $this->assertEquals('ak', $cred->getAccessKeyId()); + $this->assertEquals('sk', $cred->getAccessKeySecret()); + } + + public function testConfigSignatureVersion() + { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + // default + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + + $this->assertInstanceOf(Signer\SignerV4::class, $sdkOptions['signer']); + + // set to v1 + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + + $this->assertInstanceOf(Signer\SignerV1::class, $sdkOptions['signer']); + + + // set invalid + $cfg->setSignatureVersion('any-str'); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + + $this->assertInstanceOf(Signer\SignerV4::class, $sdkOptions['signer']); + + // set v4 + $cfg->setSignatureVersion('v4'); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + + $this->assertInstanceOf(Signer\SignerV4::class, $sdkOptions['signer']); + } + + public function testConfigEndpoint() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('oss-cn-beijing.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // use_internal_endpoint + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-shanghai'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUseInternalEndpoint(true); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('oss-cn-shanghai-internal.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // use_accelerate_endpoint + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUseAccelerateEndpoint(true); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('oss-accelerate.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // use_dualstack_endpoint + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUseDualStackEndpoint(true); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cn-hangzhou.oss.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // user-defined endpoint + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setEndpoint('http://oss-cn-shenzhen.aliyuncs.com'); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('http', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('oss-cn-shenzhen.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // disable ssl + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUseDualStackEndpoint(true); + $cfg->setDisableSSL(true); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('http', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cn-hangzhou.oss.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + + } + + public function testConfigAddressStyle() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('virtual', $sdkOptions['address_style']); + + //set path-style + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUsePathStyle(true); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('path', $sdkOptions['address_style']); + + //set cname + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUseCname(true); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('cname', $sdkOptions['address_style']); + + //use ip endpoint + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setEndpoint('192.168.1.1'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('path', $sdkOptions['address_style']); + } + + public function testConfigRetryer() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(null, $sdkOptions['retry_max_attempts']); + $this->assertInstanceOf(Retry\StandardRetryer::class, $sdkOptions['retryer']); + + //set retry_max_attempts + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setRetryMaxAttempts(2); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(2, $sdkOptions['retry_max_attempts']); + $this->assertInstanceOf(Retry\StandardRetryer::class, $sdkOptions['retryer']); + + //set retryer + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setRetryer(new Retry\NopRetryer()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(null, $sdkOptions['retry_max_attempts']); + $this->assertInstanceOf(Retry\NopRetryer::class, $sdkOptions['retryer']); + + //set retry_max_attempts and retryer + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setRetryMaxAttempts(2); + $cfg->setRetryer(new Retry\StandardRetryer(4)); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(2, $sdkOptions['retry_max_attempts']); + $this->assertInstanceOf(Retry\StandardRetryer::class, $sdkOptions['retryer']); + $this->assertEquals(4, $sdkOptions['retryer']->getMaxAttempts()); + } + + public function testConfigUserAgent() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pInnerOptions = $ro->getProperty('innerOptions'); + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + $innerOptions = $pInnerOptions->getValue($client); + $this->assertEquals(Utils::defaultUserAgent(), $innerOptions['user_agent']); + + //set user-agent + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUserAgent('my-agent'); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pInnerOptions = $ro->getProperty('innerOptions'); + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + $innerOptions = $pInnerOptions->getValue($client); + $this->assertEquals(Utils::defaultUserAgent() . '/my-agent', $innerOptions['user_agent']); + + //set repalce by options + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUserAgent('my-agent'); + + $client = new ClientImpl($cfg, ['user_agent' => 'user-define-agent']); + $ro = new \ReflectionObject($client); + $pInnerOptions = $ro->getProperty('innerOptions'); + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + $innerOptions = $pInnerOptions->getValue($client); + $this->assertEquals('user-define-agent', $innerOptions['user_agent']); + } + + public function testConfigAdditionalHeaders() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(null, $sdkOptions['additional_headers']); + + //set from config + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setAdditionalHeaders(['header1', 'header2']); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(['header1', 'header2'], $sdkOptions['additional_headers']); + } + + public function testConfigTimeout() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + $this->assertEquals(False, $requestOptions['allow_redirects']); + $this->assertEquals(10.0, $requestOptions['connect_timeout']); + $this->assertEquals(20.0, $requestOptions['read_timeout']); + $this->assertEquals(True, $requestOptions['verify']); + + // set from config + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setInsecureSkipVerify(true); + $cfg->setEnabledRedirect(true); + $cfg->setConnectTimeout(30.0); + $cfg->setReadwriteTimeout(40.5); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + $this->assertEquals(true, $requestOptions['allow_redirects']); + $this->assertEquals(30.0, $requestOptions['connect_timeout']); + $this->assertEquals(40.5, $requestOptions['read_timeout']); + $this->assertEquals(false, $requestOptions['verify']); + + // set from options + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl( + $cfg, + [ + 'request_options' => [ + 'allow_redirects' => true, + 'connect_timeout' => 11.0, + 'read_timeout' => 22.0, + 'verify' => false, + ], + ] + ); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + #$this->assertEquals(true, $requestOptions['allow_redirects']); + $this->assertEquals(11.0, $requestOptions['connect_timeout']); + $this->assertEquals(22.0, $requestOptions['read_timeout']); + $this->assertEquals(false, $requestOptions['verify']); + + // set from config + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setInsecureSkipVerify(true); + $cfg->setEnabledRedirect(true); + $cfg->setConnectTimeout(30.0); + $cfg->setReadwriteTimeout(40.5); + + $client = new ClientImpl( + $cfg, + [ + 'request_options' => [ + 'allow_redirects' => false, + 'connect_timeout' => 12.0, + 'read_timeout' => 23.0, + 'verify' => true, + ], + ] + ); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + $this->assertEquals(false, $requestOptions['allow_redirects']); + $this->assertEquals(12.0, $requestOptions['connect_timeout']); + $this->assertEquals(23.0, $requestOptions['read_timeout']); + $this->assertEquals(true, $requestOptions['verify']); + } + + public function testConfigProxy() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + $this->assertEquals(false, isset($requestOptions['proxy'])); + + // set from config + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setProxyHost('http://127.0.0.1:8080'); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + $this->assertEquals('http://127.0.0.1:8080', $requestOptions['proxy']); + + // set from options + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl( + $cfg, + [ + 'request_options' => [ + 'proxy' => 'http://127.0.0.1:3182', + ], + ] + ); + $ro = new \ReflectionObject($client); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $requestOptions = $pRequestOptions->getValue($client); + $this->assertEquals('http://127.0.0.1:3182', $requestOptions['proxy']); + } + + public function testConfigAuthMethod() + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('header', $sdkOptions['auth_method']); + + //set query + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg, ['auth_method' => 'query']); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('query', $sdkOptions['auth_method']); + } + + public function testConfigProduct(): void + { + //default + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('oss', $sdkOptions['product']); + + //set oss-cloudbox + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $client = new ClientImpl($cfg, ['product' => 'oss-cloudbox']); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('oss-cloudbox', $sdkOptions['product']); + } + + public function testInvokeOperationOptions(): void + { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + //default + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT", + ); + $client->executeAsync($input)->wait(); + $options = $mock->getLastOptions(); + #GuzzleHttp's request options + $this->assertEquals(false, $options['allow_redirects']); + $this->assertEquals(Defaults::CONNECT_TIMEOUT, $options['connect_timeout']); + $this->assertEquals(Defaults::READWRITE_TIMEOUT, $options['read_timeout']); + $this->assertEquals(true, $options['verify']); + #sdk's request options + $this->assertEquals(Defaults::MAX_ATTEMPTS, $options['sdk_context']['retry_max_attempts']); + $this->assertInstanceOf(retry\StandardRetryer::class, $options['sdk_context']['retryer']); + + // test retry_max_attempts & retryer + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $opt = [ + 'retry_max_attempts' => 4, + 'retryer' => new Retry\NopRetryer(), + ]; + $client->executeAsync($input, $opt)->wait(); + $options = $mock->getLastOptions(); + // GuzzleHttp's request options + $this->assertEquals(false, $options['allow_redirects']); + $this->assertEquals(Defaults::CONNECT_TIMEOUT, $options['connect_timeout']); + $this->assertEquals(Defaults::READWRITE_TIMEOUT, $options['read_timeout']); + $this->assertEquals(true, $options['verify']); + // sdk's request options + $this->assertEquals(4, $options['sdk_context']['retry_max_attempts']); + $this->assertInstanceOf(retry\NopRetryer::class, $options['sdk_context']['retryer']); + + // test retryer + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $opt = [ + 'retryer' => new Retry\StandardRetryer(10), + ]; + $client->executeAsync($input, $opt)->wait(); + $options = $mock->getLastOptions(); + $this->assertEquals(10, $options['sdk_context']['retry_max_attempts']); + $this->assertInstanceOf(retry\StandardRetryer::class, $options['sdk_context']['retryer']); + + // test request options + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $opt = [ + 'request_options' => + [ + 'allow_redirects' => true, + 'connect_timeout' => 31.0, + 'read_timeout' => 15.2, + 'verify' => false, + ] + ]; + $client->executeAsync($input, $opt)->wait(); + $options = $mock->getLastOptions(); + // GuzzleHttp's request options + $this->assertEquals(31.0, $options['connect_timeout']); + $this->assertEquals(15.2, $options['read_timeout']); + // can't be modified from api options. + $this->assertEquals(false, $options['allow_redirects']); + $this->assertEquals(true, $options['verify']); + } + + public function testRequestContext(): void + { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + // user-agent + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT", + ); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + + $this->assertEquals(Utils::defaultUserAgent(), $request->getHeader('User-Agent')[0]); + + // uri format + # virtual, no bucket and key, only bucket, bucket and key + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT", + ); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://oss-cn-beijing.aliyuncs.com/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://my-bucket.oss-cn-beijing.aliyuncs.com/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('123/321/+? /123.txt'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://my-bucket.oss-cn-beijing.aliyuncs.com/123/321/%2B%3F%20/123.txt', $request->getUri()->__tostring()); + + # cname, no bucket and key, only bucket, bucket and key + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setEndpoint('www.cname.com'); + $cfg->setUseCname(true); + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://www.cname.com/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://www.cname.com/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('123/321/+? /123.txt'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://www.cname.com/123/321/%2B%3F%20/123.txt', $request->getUri()->__tostring()); + + # path-style, no bucket and key, only bucket, bucket and key + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUsePathStyle(true); + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://oss-cn-beijing.aliyuncs.com/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://oss-cn-beijing.aliyuncs.com/my-bucket/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('123/321/+? /123.txt'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://oss-cn-beijing.aliyuncs.com/my-bucket/123/321/%2B%3F%20/123.txt', $request->getUri()->__tostring()); + + # ip format, no bucket and key, only bucket, bucket and key + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setEndpoint('192.168.1.1:3218'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setUsePathStyle(true); + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://192.168.1.1:3218/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://192.168.1.1:3218/my-bucket/', $request->getUri()->__tostring()); + + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('123/321/+? /123.txt'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://192.168.1.1:3218/my-bucket/123/321/%2B%3F%20/123.txt', $request->getUri()->__tostring()); + + // uri format after signing + # signing header, bucket and key + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('123/321/+? /123.txt'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertEquals('https://my-bucket.oss-cn-beijing.aliyuncs.com/123/321/%2B%3F%20/123.txt', $request->getUri()->__tostring()); + + # signing query, bucket and key + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $mock = new GuzzleHttp\Handler\MockHandler([new GuzzleHttp\Psr7\Response()]); + $client = new ClientImpl($cfg, ['handler' => $mock, 'auth_method' => 'query']); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('123/321/+? /123.txt'); + $client->executeAsync($input)->wait(); + $request = $mock->getLastRequest(); + $this->assertStringContainsString('https://my-bucket.oss-cn-beijing.aliyuncs.com/123/321/%2B%3F%20/123.txt?x-oss-credential=ak', $request->getUri()->__tostring()); + } + + public function testHttpErrorsHandler(): void + { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $cfg->setRetryer(new Retry\NopRetryer()); + + $body = ' + + InvalidAccessKeyId + The OSS Access Key Id you provided does not exist in our records. + id-1234 + oss-cn-hangzhou.aliyuncs.com + ak + 0002-00000902 + https://api.aliyun.com/troubleshoot?q=0002-00000902 + + '; + + $response = new GuzzleHttp\Psr7\Response(403, [], $body); + $mock = new GuzzleHttp\Handler\MockHandler([$response]); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('bucket'); + $input->setKey('key0123/321/+?/123.txt'); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertEquals('The OSS Access Key Id you provided does not exist in our records.', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + $this->assertEquals('0002-00000902', $se->getEC()); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $se->getErrorField('HostId')); + $this->assertEquals('ak', $se->getErrorField('OSSAccessKeyId')); + $this->assertEquals('https://api.aliyun.com/troubleshoot?q=0002-00000902', $se->getErrorField('RecommendDoc')); + $this->assertEquals($body, $se->getSnapshot()); + $this->assertEquals('PUT https://bucket.oss-cn-beijing.aliyuncs.com/key0123/321/%2B%3F/123.txt', $se->getRequestTarget()); + } + } + + // invalid xml + $invalidBody = 'Error> + InvalidAccessKeyId + The OSS Access Key Id you provided does not exist in our records. + id-1234 + oss-cn-hangzhou.aliyuncs.com + ak + 0002-00000902 + https://api.aliyun.com/troubleshoot?q=0002-00000902 + + '; + + $response = new GuzzleHttp\Psr7\Response(403, [], $invalidBody); + $mock->append($response); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('BadErrorResponse', $se->getErrorCode()); + $this->assertStringContainsString('Not found tag , part response body Error>', $se->getErrorMessage()); + $this->assertEquals('', $se->getRequestId()); + $this->assertEquals('', $se->getEC()); + $this->assertEquals($invalidBody, $se->getSnapshot()); + $this->assertEquals('PUT https://bucket.oss-cn-beijing.aliyuncs.com/key0123/321/%2B%3F/123.txt', $se->getRequestTarget()); + $this->assertEquals([], $se->getErrorFields()); + $this->assertEquals('', $se->getErrorField('123')); + $this->assertEquals(null, $se->getTimestamp()); + $this->assertEquals([], $se->getHeaders()); + $this->assertEquals('', $se->getHeader('123')); + } + } + + // special char + $specialCharBody = ' + + InvalidAccessKeyId + The OSS Access Key Id you provided does not exist in our records. + id-1234 + oss-cn-hangzhou.aliyuncs.com + ak + 0002-00000902 +  + https://api.aliyun.com/troubleshoot?q=0002-00000902 + + '; + + $response = new GuzzleHttp\Psr7\Response(403, [], $specialCharBody); + $mock->append($response); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InvalidAccessKeyId', $se->getErrorCode()); + $this->assertStringContainsString('The OSS Access Key Id you provided does not exist in our records.', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + $this->assertEquals('0002-00000902', $se->getEC()); + $this->assertEquals($specialCharBody, $se->getSnapshot()); + $this->assertEquals('PUT https://bucket.oss-cn-beijing.aliyuncs.com/key0123/321/%2B%3F/123.txt', $se->getRequestTarget()); + $this->assertEquals([], $se->getErrorFields()); + $this->assertEquals('', $se->getErrorField('123')); + $this->assertEquals(null, $se->getTimestamp()); + $this->assertEquals([], $se->getHeaders()); + $this->assertEquals('', $se->getHeader('123')); + } + } + + // special char + not oss error format + $specialCharBody = ' + + InvalidAccessKeyId + InvalidAccessKeyId +  + + '; + + $response = new GuzzleHttp\Psr7\Response(403, [], $specialCharBody); + $mock->append($response); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('BadErrorResponse', $se->getErrorCode()); + $this->assertStringContainsString('Failed to parse xml from response body', $se->getErrorMessage()); + $this->assertEquals('', $se->getRequestId()); + $this->assertEquals('', $se->getEC()); + $this->assertEquals($specialCharBody, $se->getSnapshot()); + $this->assertEquals('PUT https://bucket.oss-cn-beijing.aliyuncs.com/key0123/321/%2B%3F/123.txt', $se->getRequestTarget()); + $this->assertEquals([], $se->getErrorFields()); + $this->assertEquals('', $se->getErrorField('123')); + $this->assertEquals(null, $se->getTimestamp()); + $this->assertEquals([], $se->getHeaders()); + $this->assertEquals('', $se->getHeader('123')); + } + } + } + + public function testRetryMiddleware(): void + { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $body = ' + + InternalError + Please contact the server administrator, oss@service.aliyun.com + id-1234 + oss-cn-hangzhou.aliyuncs.com + 0002-00000902 + + '; + + $mock = new GuzzleHttp\Handler\MockHandler(); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('key0123/321/+?/123.txt'); + // default retry count is 3 + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(500, [], $body)); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(0, $mock->count()); + + // set from api + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(500, [], $body)); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + try { + $opt = ['retry_max_attempts' => 2,]; + $client->executeAsync($input, $opt)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(Defaults::MAX_ATTEMPTS - 2, $mock->count()); + + // no retry + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(500, [], $body)); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + try { + $opt = ['retryer' => new Retry\NopRetryer()]; + $client->executeAsync($input, $opt)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(Defaults::MAX_ATTEMPTS - 1, $mock->count()); + + // no seekable stream + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(500, [], $body)); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody(new GuzzleHttp\Psr7\NoSeekStream(Utils::streamFor('hello world'))); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(Defaults::MAX_ATTEMPTS - 1, $mock->count()); + + // No retryable error + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(403, [], $body)); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody(new GuzzleHttp\Psr7\NoSeekStream(Utils::streamFor('hello world'))); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(Defaults::MAX_ATTEMPTS - 1, $mock->count()); + + // No rewind stream error + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(500, [], $body)); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody(new NoRewindStream(Utils::streamFor('hello world'))); + try { + $client->executeAsync($input)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\StreamRewindException::class, $e->getPrevious()); + $this->assertStringContainsString('Cannot rewind a NoRewindStream', $e->getPrevious()->getMessage()); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()->getPrevious()); + $se = $e->getPrevious()->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(Defaults::MAX_ATTEMPTS - 1, $mock->count()); + + // InconsistentExecption Error + $mock->reset(); + for ($x = 0; $x < Defaults::MAX_ATTEMPTS; $x++) { + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-1234'])); + } + $this->assertEquals(Defaults::MAX_ATTEMPTS, $mock->count()); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('my-bucket'); + $input->setKey('key0123/321/+?/123.txt'); + try { + $opt = [ + 'response_handlers' => [ + static function ($request, $response, $options) { + throw new Exception\InconsistentExecption('1', '2', $response); + }, + ], + ]; + $client->executeAsync($input, $opt)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\InconsistentExecption::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\InconsistentExecption) { + $this->assertEquals('crc is inconsistent, client crc: 1, server crc: 2, request id: id-1234', $se->getMessage()); + } + } + $this->assertEquals(0, $mock->count()); + + // rewind check, set retry count 3, 500 error, crc error, normal + $mock->reset(); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'])); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-2', 'x-oss-crc-fail' => 'true'])); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-3'])); + $this->assertEquals(3, $mock->count()); + $body = new RewindStatStream(Utils::streamFor('hello world')); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody($body); + $opt = [ + 'response_handlers' => [ + static function ($request, \Psr\Http\Message\ResponseInterface $response, $options) { + if ($response->hasHeader('x-oss-crc-fail')) { + throw new Exception\InconsistentExecption('1', '2', $response); + } + }, + ], + 'retry_max_attempts' => 3, + ]; + $output = $client->executeAsync($input, $opt)->wait(); + $this->assertInstanceOf(OperationOutput::class, $output); + $this->assertEquals(0, $mock->count()); + $this->assertEquals(2, $body->getRewindCount()); + } + + public function testRetryMiddlewareAndSinkOption(): void + { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-beijing'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + + $errBody = ' + + InternalError + Please contact the server administrator, oss@service.aliyun.com + id-1234 + oss-cn-hangzhou.aliyuncs.com + 0002-00000902 + + '; + + $mock = new GuzzleHttp\Handler\MockHandler(); + $client = new ClientImpl($cfg, ['handler' => $mock]); + $respBody = 'respons body'; + + // rewind check, set retry count 3, 500 error, crc error, normal + $mock->reset(); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'], $errBody)); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-2', 'x-oss-crc-fail' => 'true'], $respBody)); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-3'], $respBody)); + $this->assertEquals(3, $mock->count()); + $body = new RewindStatStream(Utils::streamFor('hello world')); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody($body); + $opt = [ + 'response_handlers' => [ + static function ($request, \Psr\Http\Message\ResponseInterface $response, $options) { + if ($response->hasHeader('x-oss-crc-fail')) { + throw new Exception\InconsistentExecption('1', '2', $response); + } + }, + ], + 'retry_max_attempts' => 3, + ]; + $output = $client->executeAsync($input, $opt)->wait(); + $this->assertInstanceOf(OperationOutput::class, $output); + $this->assertEquals(0, $mock->count()); + $this->assertEquals(2, $body->getRewindCount()); + $content = $output->getBody()->getContents(); + $this->assertEquals($respBody, $content); + + //use no seek sink + $mock->reset(); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'], $errBody)); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-2', 'x-oss-crc-fail' => 'true'], $respBody)); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-3'], $respBody)); + $this->assertEquals(3, $mock->count()); + $body = new RewindStatStream(Utils::streamFor('hello world')); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody($body); + $opt = [ + 'response_handlers' => [ + static function ($request, \Psr\Http\Message\ResponseInterface $response, $options) { + if ($response->hasHeader('x-oss-crc-fail')) { + throw new Exception\InconsistentExecption('1', '2', $response); + } + }, + ], + 'retry_max_attempts' => 3, + 'request_options' => [ + 'sink' => new \GuzzleHttp\Psr7\BufferStream() + ], + ]; + + try { + $client->executeAsync($input, $opt)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(Defaults::MAX_ATTEMPTS - 1, $mock->count()); + + //use seek sink + $mock->reset(); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'], $errBody)); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-2', 'x-oss-crc-fail' => 'true'], $respBody)); + $mock->append(new GuzzleHttp\Psr7\Response(200, ['x-oss-request-id' => 'id-3'], $respBody)); + $this->assertEquals(3, $mock->count()); + $body = new RewindStatStream(Utils::streamFor('hello world')); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody($body); + $sink = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+'); + $sink = \GuzzleHttp\Psr7\Utils::streamFor($sink); + $opt = [ + 'response_handlers' => [ + static function ($request, \Psr\Http\Message\ResponseInterface $response, $options) { + if ($response->hasHeader('x-oss-crc-fail')) { + throw new Exception\InconsistentExecption('1', '2', $response); + } + }, + ], + 'retry_max_attempts' => 3, + 'request_options' => [ + 'sink' => $sink + ], + ]; + $output = $client->executeAsync($input, $opt)->wait(); + $this->assertInstanceOf(OperationOutput::class, $output); + $this->assertEquals(0, $mock->count()); + $this->assertEquals(2, $body->getRewindCount()); + $content = $output->getBody()->getContents(); + $this->assertEquals('', $content); + $sink->seek(0); + $sinkContent = $sink->getContents(); + $this->assertEquals($respBody, $sinkContent); + $this->assertEquals(\gettype($sink), \gettype($output->getBody())); + $this->assertNotInstanceOf(SinkStreamWrapper::class, $output->getBody()); + + //use seek sink and fail + $mock->reset(); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'], $errBody)); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'], $errBody)); + $mock->append(new GuzzleHttp\Psr7\Response(500, ['x-oss-request-id' => 'id-1'], $errBody)); + $this->assertEquals(3, $mock->count()); + $body = new RewindStatStream(Utils::streamFor('hello world')); + $input = new OperationInput( + "TestApi", + "PUT" + ); + $input->setBucket('bucket'); + $input->setKey('key0123/321/+?/123.txt'); + $input->setBody($body); + $sink = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+'); + $sink = \GuzzleHttp\Psr7\Utils::streamFor($sink); + $opt = [ + 'response_handlers' => [ + static function ($request, \Psr\Http\Message\ResponseInterface $response, $options) { + if ($response->hasHeader('x-oss-crc-fail')) { + throw new Exception\InconsistentExecption('1', '2', $response); + } + }, + ], + 'retry_max_attempts' => 3, + 'request_options' => [ + 'sink' => $sink + ], + ]; + try { + $client->executeAsync($input, $opt)->wait(); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertInstanceOf(Exception\OperationException::class, $e); + $this->assertInstanceOf(Exception\ServiceException::class, $e->getPrevious()); + $se = $e->getPrevious(); + if ($se instanceof Exception\ServiceException) { + $this->assertEquals('InternalError', $se->getErrorCode()); + $this->assertStringContainsString('Please contact the server administrator, oss@service.aliyun.com', $se->getErrorMessage()); + $this->assertEquals('id-1234', $se->getRequestId()); + } + } + $this->assertEquals(0, $mock->count()); + $sink->seek(0); + $sinkContent = $sink->getContents(); + $this->assertEquals('', $sinkContent); + } + + public function testPresignInner() + { + // Presign Options + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals([], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=', $result['url']); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expires = 'PT50M'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval($expires)); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals([], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=', $result['url']); + + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v4'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $now = new \DateTime('now', new \DateTimeZone('UTC')); + $nowTime = clone $now; + $expiration = $nowTime->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals([], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $expectedDate = $expiration->modify('-1 hour')->format('Ymd'); + $this->assertStringContainsString("x-oss-date={$expectedDate}", $result['url']); + $this->assertStringContainsString('x-oss-expires=3600', $result['url']); + $this->assertStringContainsString('x-oss-signature=', $result['url']); + $credential = urlencode("ak/{$expectedDate}/cn-hangzhou/oss/aliyun_v4_request"); + $this->assertStringContainsString("x-oss-credential={$credential}", $result['url']); + $this->assertStringContainsString('x-oss-signature-version=OSS4-HMAC-SHA256', $result['url']); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expires = 'PT50M'; + $nowTime = clone $now; + $expiration = $nowTime->add(new DateInterval($expires)); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals([], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $expectedDate = $expiration->modify('-50 minutes')->format('Ymd'); + $this->assertStringContainsString("x-oss-date={$expectedDate}", $result['url']); + $this->assertStringContainsString('x-oss-expires=3000', $result['url']); + $this->assertStringContainsString('x-oss-signature=', $result['url']); + $credential = urlencode("ak/{$expectedDate}/cn-hangzhou/oss/aliyun_v4_request"); + $this->assertStringContainsString("x-oss-credential={$credential}", $result['url']); + $this->assertStringContainsString('x-oss-signature-version=OSS4-HMAC-SHA256', $result['url']); + + // token + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk', 'token')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals([], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=', $result['url']); + $this->assertStringContainsString('security-token=token', $result['url']); + + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk', 'token')); + $cfg->setSignatureVersion('v4'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals([], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('x-oss-security-token=token', $result['url']); + $expectedDate = $expiration->modify('-1 hour')->format('Ymd'); + $this->assertStringContainsString("x-oss-date={$expectedDate}", $result['url']); + $this->assertStringContainsString('x-oss-expires=3600', $result['url']); + $this->assertStringContainsString('x-oss-signature=', $result['url']); + $credential = urlencode("ak/{$expectedDate}/cn-hangzhou/oss/aliyun_v4_request"); + $this->assertStringContainsString("x-oss-credential={$credential}", $result['url']); + $this->assertStringContainsString('x-oss-signature-version=OSS4-HMAC-SHA256', $result['url']); + + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $input->setHeader('Content-Type', 'application/octet-stream'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals('application/octet-stream', $result['signedHeaders']['content-type']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=', $result['url']); + + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v4'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $input->setHeader('Content-Type', 'application/octet-stream'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals(['content-type' => 'application/octet-stream'], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $expectedDate = $expiration->modify('-1 hour')->format('Ymd'); + $this->assertStringContainsString("x-oss-date={$expectedDate}", $result['url']); + $this->assertStringContainsString('x-oss-expires=3600', $result['url']); + $this->assertStringContainsString('x-oss-signature=', $result['url']); + $credential = urlencode("ak/{$expectedDate}/cn-hangzhou/oss/aliyun_v4_request"); + $this->assertStringContainsString("x-oss-credential={$credential}", $result['url']); + $this->assertStringContainsString('x-oss-signature-version=OSS4-HMAC-SHA256', $result['url']); + + // with query + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $input->setParameter('x-oss-process', 'abc'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=', $result['url']); + $this->assertStringContainsString('x-oss-process=abc', $result['url']); + + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v4'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $input->setParameter('x-oss-process', 'abc'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $expectedDate = $expiration->modify('-1 hour')->format('Ymd'); + $this->assertStringContainsString("x-oss-date={$expectedDate}", $result['url']); + $this->assertStringContainsString('x-oss-expires=3600', $result['url']); + $this->assertStringContainsString('x-oss-signature=', $result['url']); + $credential = urlencode("ak/{$expectedDate}/cn-hangzhou/oss/aliyun_v4_request"); + $this->assertStringContainsString("x-oss-credential={$credential}", $result['url']); + $this->assertStringContainsString('x-oss-signature-version=OSS4-HMAC-SHA256', $result['url']); + $this->assertStringContainsString('x-oss-process=abc', $result['url']); + + // with version id + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $input->setParameter('versionId', 'versionId'); + $arg['auth_method'] = 'query'; + $expiration = new \DateTime('Sun, 12 Nov 2023 16:43:40 GMT', new \DateTimeZone('UTC')); + + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=dcLTea%2BYh9ApirQ8o8dOPqtvJXQ%3D', $result['url']); + $this->assertStringContainsString('versionId=versionId', $result['url']); + + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk', 'token')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key+123'); + $input->setParameter('versionId', 'versionId'); + $arg['auth_method'] = 'query'; + $expiration = new \DateTime('Sun, 12 Nov 2023 16:56:44 GMT'); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key%2B123?', $result['url']); + $this->assertStringContainsString('OSSAccessKeyId=ak', $result['url']); + $this->assertStringContainsString(sprintf('Expires=%s', $expiration->getTimestamp()), $result['url']); + $this->assertStringContainsString('Signature=jzKYRrM5y6Br0dRFPaTGOsbrDhY%3D', $result['url']); + $this->assertStringContainsString('security-token=token', $result['url']); + $this->assertStringContainsString('versionId=versionId', $result['url']); + + // with add + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v4'); + $cfg->setAdditionalHeaders(['ZAbc', 'abc']); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $input->setHeader('ZAbc', 'value'); + $input->setHeader('abc', 'value'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertEquals('GET', $result['method']); + $this->assertEquals($expiration, $result['expiration']); + $this->assertEquals(['zabc' => 'value', 'abc' => 'value'], $result['signedHeaders']); + $this->assertStringContainsString('bucket.oss-cn-hangzhou.aliyuncs.com/key?', $result['url']); + $expectedDate = $expiration->modify('-1 hour')->format('Ymd'); + $this->assertStringContainsString("x-oss-date={$expectedDate}", $result['url']); + $this->assertStringContainsString('x-oss-expires=3600', $result['url']); + $this->assertStringContainsString('x-oss-signature=', $result['url']); + $credential = urlencode("ak/{$expectedDate}/cn-hangzhou/oss/aliyun_v4_request"); + $this->assertStringContainsString("x-oss-credential={$credential}", $result['url']); + $this->assertStringContainsString('x-oss-signature-version=OSS4-HMAC-SHA256', $result['url']); + $this->assertStringContainsString('x-oss-additional-headers=abc%3Bzabc', $result['url']); + } + + public function testPresignInnerError() + { + try { + $cfg = Config::loadDefault(); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('endpoint is invalid.', $e->getMessage()); + } + + try { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new ErrorProvider()); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket!@!@$'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Bucket name is invalid, got bucket!@!@$', $e->getMessage()); + } + + try { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey(random_bytes(1035)); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Object name is invalid, got', $e->getMessage()); + } + + try { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new ErrorProvider()); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Fetch Credentials raised an exception', $e->getMessage()); + } + + try { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT192H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('ak', 'sk')); + $cfg->setSignatureVersion('v4'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT192H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Expires should not be greater than 604800 (seven days)', $e->getMessage()); + } + + try { + $cfg = Config::loadDefault(); + $cfg->setRegion('cn-hangzhou'); + $cfg->setCredentialsProvider(new Credentials\StaticCredentialsProvider('', '')); + $cfg->setSignatureVersion('v1'); + $client = new ClientImpl($cfg); + $input = new OperationInput( + 'GetObject', + 'GET', + ); + $input->setBucket('bucket'); + $input->setKey('key'); + $arg['auth_method'] = 'query'; + $expiration = (new \DateTime('now', new \DateTimeZone('UTC')))->add(new DateInterval('PT1H')); + $input->setOpMetadata('expiration_time', $expiration); + $result = $client->presignInner($input, $arg); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Credentials is null or empty.', $e->getMessage()); + } + } + + public function testConfigWithCloudBoxId() + { + // set cloud box id + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('test-endpoint'); + $cfg->setCloudBoxId('test-cloudbox-id'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(Defaults::CLOUD_BOX_PRODUCT, $sdkOptions['product']); + $this->assertEquals('test-cloudbox-id', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('test-endpoint', $sdkOptions['endpoint']->getAuthority()); + $this->assertEquals('test-cloudbox-id', $cfg->getCloudBoxId()); + $this->assertEquals(null, $cfg->getEnableAutoDetectCloudBoxId()); + + // cb-***.{region}.oss-cloudbox-control.aliyuncs.com + // cb-***.{region}.oss-cloudbox.aliyuncs.com + + // auto detect cloud box id default + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('cb-123.test-region.oss-cloudbox-control.aliyuncs.com'); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('oss', $sdkOptions['product']); + $this->assertEquals('test-region', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cb-123.test-region.oss-cloudbox-control.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // auto detect cloudbox id set false + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('cb-123.test-region.oss-cloudbox-control.aliyuncs.com'); + $cfg->setEnableAutoDetectCloudBoxId(false); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('oss', $sdkOptions['product']); + $this->assertEquals('test-region', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cb-123.test-region.oss-cloudbox-control.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // auto detect cloudbox id set true + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('cb-123.test-region.oss-cloudbox-control.aliyuncs.com'); + $cfg->setEnableAutoDetectCloudBoxId(true); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(Defaults::CLOUD_BOX_PRODUCT, $sdkOptions['product']); + $this->assertEquals('cb-123', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cb-123.test-region.oss-cloudbox-control.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('cb-123.test-region.oss-cloudbox.aliyuncs.com'); + $cfg->setEnableAutoDetectCloudBoxId(true); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals(Defaults::CLOUD_BOX_PRODUCT, $sdkOptions['product']); + $this->assertEquals('cb-123', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cb-123.test-region.oss-cloudbox.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + // auto detect cloudbox id set true + non cloud box endpoint + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('cb-123.test-region.oss.aliyuncs.com'); + $cfg->setEnableAutoDetectCloudBoxId(true); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('oss', $sdkOptions['product']); + $this->assertEquals('test-region', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cb-123.test-region.oss.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + + $cfg = Config::loadDefault(); + $cfg->setRegion('test-region'); + $cfg->setEndpoint('cb-123.oss-cloudbox.aliyuncs.com'); + $cfg->setEnableAutoDetectCloudBoxId(true); + $cfg->setCredentialsProvider(new Credentials\AnonymousCredentialsProvider()); + $client = new ClientImpl($cfg); + $ro = new \ReflectionObject($client); + $pSdkOptions = $ro->getProperty('sdkOptions'); + $pInnerOptions = $ro->getProperty('innerOptions'); + $pRequestOptions = $ro->getProperty('requestOptions'); + if (PHP_VERSION_ID < 80100) { + $pSdkOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pInnerOptions->setAccessible(true); + } + if (PHP_VERSION_ID < 80100) { + $pRequestOptions->setAccessible(true); + } + $sdkOptions = $pSdkOptions->getValue($client); + $this->assertEquals('oss', $sdkOptions['product']); + $this->assertEquals('test-region', $sdkOptions['region']); + $this->assertInstanceOf(GuzzleHttp\Psr7\Uri::class, $sdkOptions['endpoint']); + $this->assertEquals('https', $sdkOptions['endpoint']->getScheme()); + $this->assertEquals('cb-123.oss-cloudbox.aliyuncs.com', $sdkOptions['endpoint']->getAuthority()); + } +} + +class ErrorProvider implements CredentialsProvider +{ + public function getCredentials(): \AlibabaCloud\Oss\V2\Credentials\Credentials + { + throw new \Exception('Simulated exception'); + + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Credentials/CredentialsTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Credentials/CredentialsTest.php new file mode 100644 index 0000000..2a64fd6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Credentials/CredentialsTest.php @@ -0,0 +1,84 @@ +assertEquals("", $credentials->getAccessKeyId()); + $this->assertEquals("", $credentials->getAccessKeySecret()); + $this->assertNull($credentials->getSecurityToken()); + $this->assertNull($credentials->getExpiration()); + $this->assertFalse($credentials->hasKeys()); + $this->assertFalse($credentials->isExpired()); + + $credentials = new Credentials("ak", "sk"); + $this->assertEquals("ak", $credentials->getAccessKeyId()); + $this->assertEquals("sk", $credentials->getAccessKeySecret()); + $this->assertNull($credentials->getSecurityToken()); + $this->assertNull($credentials->getExpiration()); + $this->assertTrue($credentials->hasKeys()); + $this->assertFalse($credentials->isExpired()); + + $credentials = new Credentials("ak", "sk", "token"); + $this->assertEquals("ak", $credentials->getAccessKeyId()); + $this->assertEquals("sk", $credentials->getAccessKeySecret()); + $this->assertEquals("token", $credentials->getSecurityToken()); + $this->assertNull($credentials->getExpiration()); + $this->assertTrue($credentials->hasKeys()); + $this->assertFalse($credentials->isExpired()); + + + $expiration = new \DateTime('now', new \DateTimeZone('UTC')); + $expiration->modify("+ 100 seconds"); + $credentials = new Credentials("ak", "sk", "token", $expiration); + $this->assertEquals("ak", $credentials->getAccessKeyId()); + $this->assertEquals("sk", $credentials->getAccessKeySecret()); + $this->assertEquals("token", $credentials->getSecurityToken()); + $this->assertNotNull($credentials->getExpiration()); + $this->assertTrue($credentials->hasKeys()); + $this->assertFalse($credentials->isExpired()); + + $expiration = new \DateTime('now', new \DateTimeZone('UTC')); + $expiration->modify("- 100 seconds"); + $credentials = new Credentials("ak", "sk", "token", $expiration); + $this->assertEquals("ak", $credentials->getAccessKeyId()); + $this->assertEquals("sk", $credentials->getAccessKeySecret()); + $this->assertEquals("token", $credentials->getSecurityToken()); + $this->assertNotNull($credentials->getExpiration()); + $this->assertTrue($credentials->hasKeys()); + $this->assertTrue($credentials->isExpired()); + + } + + public function testAnonymousCredentialsProvider() + { + $provider = new AnonymousCredentialsProvider(); + $credentials = $provider->getCredentials(); + $this->assertEquals("", $credentials->getAccessKeyId()); + $this->assertEquals("", $credentials->getAccessKeySecret()); + $this->assertNull($credentials->getSecurityToken()); + $this->assertNull($credentials->getExpiration()); + $this->assertFalse($credentials->isExpired()); + } + + public function testCredentialsProviderFunc() + { + $provider = new CredentialsProviderFunc( function () { + return new Credentials("ak", "sk"); + }); + $credentials = $provider->getCredentials(); + $this->assertEquals("ak", $credentials->getAccessKeyId()); + $this->assertEquals("sk", $credentials->getAccessKeySecret()); + $this->assertNull($credentials->getSecurityToken()); + $this->assertNull($credentials->getExpiration()); + $this->assertTrue($credentials->hasKeys()); + $this->assertFalse($credentials->isExpired()); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/AesCtrCipherTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/AesCtrCipherTest.php new file mode 100644 index 0000000..81ea27c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/AesCtrCipherTest.php @@ -0,0 +1,218 @@ + 'value'] + ); + $cipherBuider = new AesCtrCipherBuilder($cipher); + $cihperData = $cipherBuider->createCipherData(); + $this->assertNotNull($cihperData); + $this->assertEquals(16, strlen($cihperData->iv)); + $this->assertEquals(32, strlen($cihperData->key)); + $this->assertEquals(128, strlen($cihperData->encryptedIv)); + $this->assertEquals(128, strlen($cihperData->encryptedKey)); + $this->assertEquals('{"key":"value"}', $cihperData->matDesc); + $this->assertEquals('RSA/NONE/PKCS1Padding', $cihperData->wrapAlgorithm); + $this->assertEquals('AES/CTR/NoPadding', $cihperData->cekAlgorithm); + } + + public function testFromEnvelope() + { + $cipher = new MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + $cipherBuider = new AesCtrCipherBuilder($cipher); + $envelope = new Envelope( + 'De/S3T8wFjx7QPxAAFl7h7TeI2EsZlfCwox4WhLGng5DK2vNXxULmulMUUpYkdc9umqmDilgSy5Z3Foafw+v4JJThfw68T/9G2gxZLrQTbAlvFPFfPM9Ehk6cY4+8WpY32uN8w5vrHyoSZGr343NxCUGIp6fQ9sSuOLMoJg7hNw=', + 'nyXOp7delQ/MQLjKQMhHLaT0w7u2yQoDLkSnK8MFg/MwYdh4na4/LS8LLbLcM18m8I/ObWUHU775I50sJCpdv+f4e0jLeVRRiDFWe+uo7Puc9j4xHj8YB3QlcIOFQiTxHIB6q+C+RA6lGwqqYVa+n3aV5uWhygyv1MWmESurppg=', + 'AES/CTR/NoPadding', + + ); + + + $cihperData = $cipherBuider->createCipherData(); + $this->assertNotNull($cihperData); + $this->assertEquals(16, strlen($cihperData->iv)); + $this->assertEquals(32, strlen($cihperData->key)); + $this->assertEquals(128, strlen($cihperData->encryptedIv)); + $this->assertEquals(128, strlen($cihperData->encryptedKey)); + $this->assertEquals('{"key":"value"}', $cihperData->matDesc); + $this->assertEquals('RSA/NONE/PKCS1Padding', $cihperData->wrapAlgorithm); + $this->assertEquals('AES/CTR/NoPadding', $cihperData->cekAlgorithm); + } + + public function testEncrypt() + { + $cipherMaster = new MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + $cipherBuider = new AesCtrCipherBuilder($cipherMaster); + $base64_encrypted_key = 'nyXOp7delQ/MQLjKQMhHLaT0w7u2yQoDLkSnK8MFg/MwYdh4na4/LS8LLbLcM18m8I/ObWUHU775I50sJCpdv+f4e0jLeVRRiDFWe+uo7Puc9j4xHj8YB3QlcIOFQiTxHIB6q+C+RA6lGwqqYVa+n3aV5uWhygyv1MWmESurppg='; + $base64_encrypted_iv = 'De/S3T8wFjx7QPxAAFl7h7TeI2EsZlfCwox4WhLGng5DK2vNXxULmulMUUpYkdc9umqmDilgSy5Z3Foafw+v4JJThfw68T/9G2gxZLrQTbAlvFPFfPM9Ehk6cY4+8WpY32uN8w5vrHyoSZGr343NxCUGIp6fQ9sSuOLMoJg7hNw='; + $encrypted_key = base64_decode($base64_encrypted_key); + $encrypted_iv = base64_decode($base64_encrypted_iv); + + $key = $cipherMaster->decrypt($encrypted_key); + $iv = $cipherMaster->decrypt($encrypted_iv); + + $cipherData = new CipherData( + $iv, + $key, + $encrypted_iv, + $encrypted_key, + '', + 'RSA/NONE/PKCS1Padding', + 'AES/CTR/NoPadding' + ); + + $content = file_get_contents(self::getDataPath() . DIRECTORY_SEPARATOR . 'example.jpg'); + $enc_content = file_get_contents(self::getDataPath() . DIRECTORY_SEPARATOR . 'enc-example.jpg'); + + $cipher = new AesCtr($cipherData, 0); + foreach([16, 32, 64]as $key => $step) { + $total = 0; + for ($i = 0; $i < strlen($content); $i += $step) { + $data = substr($content, $i, $step); + $edata_pat = substr($enc_content, $i, $step); + $edata = $cipher->encrypt($data); + $this->assertEquals($edata_pat, $edata); + $total += strlen($edata); + } + + $this->assertEquals($total, strlen($content)); + $cipher->reset(); + } + $cipher->reset(); + $this->assertEquals($enc_content, $cipher->encrypt($content)); + + + foreach([16, 32, 64] as $setp) { + $total = 0; + $cipher = new AesCtr($cipherData, 0); + for ($i = 0; $i < strlen($content); $i += $setp) { + $edata = substr($enc_content, $i, $setp); + $data_pat = substr($content, $i, $setp); + $dedata = $cipher->decrypt($edata); + $this->assertEquals($data_pat, $dedata); + $total += strlen($dedata); + } + $this->assertEquals($total, strlen($content)); + } + $cipher = new AesCtr($cipherData, 0); + $this->assertEquals($content, $cipher->decrypt($enc_content)); + } + + public function testEncrypt2() + { + $cipherMaster = new MasterRsaCipher( + self::RSA_PUBLIC_KEY, + self::RSA_PRIVATE_KEY, + ['key' => 'value'] + ); + $cipherBuider = new AesCtrCipherBuilder($cipherMaster); + $base64_encrypted_key = 'nyXOp7delQ/MQLjKQMhHLaT0w7u2yQoDLkSnK8MFg/MwYdh4na4/LS8LLbLcM18m8I/ObWUHU775I50sJCpdv+f4e0jLeVRRiDFWe+uo7Puc9j4xHj8YB3QlcIOFQiTxHIB6q+C+RA6lGwqqYVa+n3aV5uWhygyv1MWmESurppg='; + $base64_encrypted_iv = 'De/S3T8wFjx7QPxAAFl7h7TeI2EsZlfCwox4WhLGng5DK2vNXxULmulMUUpYkdc9umqmDilgSy5Z3Foafw+v4JJThfw68T/9G2gxZLrQTbAlvFPFfPM9Ehk6cY4+8WpY32uN8w5vrHyoSZGr343NxCUGIp6fQ9sSuOLMoJg7hNw='; + $encrypted_key = base64_decode($base64_encrypted_key); + $encrypted_iv = base64_decode($base64_encrypted_iv); + + $key = $cipherMaster->decrypt($encrypted_key); + $iv = $cipherMaster->decrypt($encrypted_iv); + + $cipherData = new CipherData( + $iv, + $key, + $encrypted_iv, + $encrypted_key, + '', + 'RSA/NONE/PKCS1Padding', + 'AES/CTR/NoPadding' + ); + + $content = file_get_contents(self::getDataPath() . DIRECTORY_SEPARATOR . 'example.jpg'); + $enc_content = file_get_contents(self::getDataPath() . DIRECTORY_SEPARATOR . 'enc-example.jpg'); + + $cipher = new AesCtr($cipherData, 0); + foreach([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]as $key => $step) { + $total = 0; + for ($i = 0; $i < strlen($content); $i += $step) { + $data = substr($content, $i, $step); + $edata_pat = substr($enc_content, $i, $step); + $edata = $cipher->encrypt($data); + $this->assertEquals($edata_pat, $edata); + $total += strlen($edata); + } + + $this->assertEquals($total, strlen($content)); + $cipher->reset(); + } + $cipher->reset(); + $this->assertEquals($enc_content, $cipher->encrypt($content)); + + foreach([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18] as $setp) { + $total = 0; + $cipher = new AesCtr($cipherData, 0); + for ($i = 0; $i < strlen($content); $i += $setp) { + $edata = substr($enc_content, $i, $setp); + $data_pat = substr($content, $i, $setp); + $dedata = $cipher->decrypt($edata); + $this->assertEquals($data_pat, $dedata); + $total += strlen($dedata); + } + $this->assertEquals($total, strlen($content)); + } + $cipher = new AesCtr($cipherData, 0); + $this->assertEquals($content, $cipher->decrypt($enc_content)); + + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/MasterRsaCipherTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/MasterRsaCipherTest.php new file mode 100644 index 0000000..494f181 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/MasterRsaCipherTest.php @@ -0,0 +1,113 @@ +assertNotNull($cipher); + $this->assertEquals('', $cipher->getMatDesc()); + $this->assertEquals('RSA/NONE/PKCS1Padding', $cipher->getWrapAlgorithm()); + + $cipher = new MasterRsaCipher(self::RSA_PUBLIC_KEY, self::RSA_PRIVATE_KEY, ['key' => 'value']); + $this->assertNotNull($cipher); + $this->assertEquals('{"key":"value"}', $cipher->getMatDesc()); + $this->assertEquals('RSA/NONE/PKCS1Padding', $cipher->getWrapAlgorithm()); + $data = 'hello world'; + $edata = $cipher->encrypt($data); + $this->assertNotEquals($data, $edata); + $eedata = $cipher->decrypt($edata); + $this->assertEquals($data, $eedata); + } + + public function testFail() + { + try { + $cipher = new MasterRsaCipher('RSA_PUBLIC_KEY', self::RSA_PRIVATE_KEY, ['key' => 'value']); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('RSA key format is not supported', $e->getMessage()); + } + + try { + $cipher = new MasterRsaCipher(self::RSA_PUBLIC_KEY, 'RSA_PRIVATE_KEY', ['key' => 'value']); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('RSA key format is not supported', $e->getMessage()); + } + + try { + $cipher = new MasterRsaCipher(null, null, null); + $cipher->encrypt('hello world 123'); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('RSA public key is none or invalid', $e->getMessage()); + } + + try { + $cipher = new MasterRsaCipher(null, null, null); + $cipher->decrypt('hello world 123'); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertStringContainsString('RSA private key is none or invalid', $e->getMessage()); + } + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/enc-example.jpg b/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/enc-example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e498969bc41f1f5b8c942d83a3336abcf92c9560 GIT binary patch literal 21839 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 literal 0 HcmV?d00001 diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/example.jpg b/vendor/alibabacloud/oss-v2/tests/UnitTests/Crypto/example.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ffd46a2f81b1fe020ed0673f27711124110eed3f GIT binary patch literal 21839 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\is_scalar($xml->strValue)); + $this->assertEquals('id-124', $xml->strValue); + $this->assertEquals(1234, $xml->intValue); + $this->assertEquals(true, $xml->boolValue); + $this->assertEquals(3.14, $xml->floatValue); + + + $str = ' + + '; + + $xml = new BaiscTypeXml(); + Deserializer::deserializeXml($str, $xml); + $this->assertFalse(isset($xml->StrValue)); + $this->assertFalse(isset($xml->IntValue)); + $this->assertFalse(isset($xml->BoolValue)); + $this->assertFalse(isset($xml->FloatValue)); + + $str = ' + + 1234 + true + '; + + $xml = new BaiscTypeXml(); + Deserializer::deserializeXml($str, $xml); + $this->assertFalse(isset($xml->StrValue)); + $this->assertEquals(1234, $xml->intValue); + $this->assertEquals(true, $xml->boolValue); + $this->assertFalse(isset($xml->FloatValue)); + } + + public function testDeserializeBaiscTypeListXml(): void + { + $str = ' + + str1 + str2 + 1234 + 2234 + true + true + false + 3.14 + '; + $xml = new BaiscTypeListXml(); + Deserializer::deserializeXml($str, $xml); + $this->assertEquals(2, count($xml->strValues)); + $this->assertEquals('str1', $xml->strValues[0]); + $this->assertEquals('str2', $xml->strValues[1]); + $this->assertEquals(2, count($xml->intValues)); + $this->assertEquals(1234, $xml->intValues[0]); + $this->assertEquals(2234, $xml->intValues[1]); + $this->assertEquals(3, count($xml->boolValues)); + $this->assertEquals(true, $xml->boolValues[0]); + $this->assertEquals(true, $xml->boolValues[1]); + $this->assertEquals(false, $xml->boolValues[2]); + $this->assertTrue(\is_array($xml->floatValues)); + $this->assertEquals(1, count($xml->floatValues)); + $this->assertEquals('3.14', $xml->floatValues[0]); + + $str = ' + + '; + + $xml = new BaiscTypeListXml(); + Deserializer::deserializeXml($str, $xml); + $this->assertFalse(isset($xml->strValues)); + $this->assertFalse(isset($xml->intValues)); + $this->assertFalse(isset($xml->boolValues)); + $this->assertFalse(isset($xml->floatValues)); + } + + public function testDeserializeDateTimeTypeXml() + { + $date = new \DateTime(); + $date->setTimestamp(1702783809); + $date1 = new \DateTimeImmutable(); + $date1 = $date1->setTimestamp(1702783819); + + $str = ' + + 2023-12-17T03:30:09Z + 1702783809 + Sun, 17 Dec 2023 03:30:09 GMT + '; + $xml = new DatetimeTypeXml(); + Deserializer::deserializeXml($str, $xml); + $this->assertEquals($date, $xml->isotimeValue); + $this->assertFalse(isset($xml->dateTimeImmutableValue)); + $this->assertEquals($date, $xml->unixtimeValue); + $this->assertEquals($date, $xml->httptimeValue); + } + + public function testDeserializeMixedTypeXml(): void + { + $str = ' + + str-111 + 12 + + str + 123 + true + 1.14 + + + str1 + str2 + 1234 + 2234 + true + true + false + 3.14 + + '; + + $xml = new MixedTypeXml(); + Deserializer::deserializeXml($str, $xml); + $this->assertEquals('str-111', $xml->strValue); + $this->assertEquals(12, $xml->intValue); + + $this->assertEquals('str', $xml->xmlValue->strValue); + $this->assertEquals(123, $xml->xmlValue->intValue); + $this->assertEquals(true, $xml->xmlValue->boolValue); + $this->assertEquals(1.14, $xml->xmlValue->floatValue); + + $this->assertEquals(2, count($xml->xmlListValue->strValues)); + $this->assertEquals('str1', $xml->xmlListValue->strValues[0]); + $this->assertEquals('str2', $xml->xmlListValue->strValues[1]); + $this->assertEquals(2, count($xml->xmlListValue->intValues)); + $this->assertEquals(1234, $xml->xmlListValue->intValues[0]); + $this->assertEquals(2234, $xml->xmlListValue->intValues[1]); + $this->assertEquals(3, count($xml->xmlListValue->boolValues)); + $this->assertEquals(true, $xml->xmlListValue->boolValues[0]); + $this->assertEquals(true, $xml->xmlListValue->boolValues[1]); + $this->assertEquals(false, $xml->xmlListValue->boolValues[2]); + $this->assertEquals(1, count($xml->xmlListValue->floatValues)); + $this->assertEquals('3.14', $xml->xmlListValue->floatValues[0]); + } + + public function testDeserializeMixedTypeListXml(): void + { + $str = ' + + str-111 + 12 + + str + 123 + true + 1.14 + + + str-1 + 223 + false + + '; + + $xml = new MixedTypeListXml(); + Deserializer::deserializeXml($str, $xml); + + $this->assertEquals('str-111', $xml->strValue); + $this->assertEquals(12, $xml->intValue); + $this->assertTrue(\is_array($xml->xmlValues)); + $this->assertEquals(2, count($xml->xmlValues)); + $this->assertEquals('str', $xml->xmlValues[0]->strValue); + $this->assertEquals(123, $xml->xmlValues[0]->intValue); + $this->assertEquals(true, $xml->xmlValues[0]->boolValue); + $this->assertEquals(1.14, $xml->xmlValues[0]->floatValue); + + $this->assertEquals('str-1', $xml->xmlValues[1]->strValue); + $this->assertEquals(223, $xml->xmlValues[1]->intValue); + $this->assertEquals(false, $xml->xmlValues[1]->boolValue); + $this->assertFalse(isset($xml->xmlValues[1]->floatValue)); + + $str = ' + + str-111 + 12 + + str + 123 + true + 1.14 + + '; + + $xml = new MixedTypeListXml(); + Deserializer::deserializeXml($str, $xml); + + $this->assertEquals('str-111', $xml->strValue); + $this->assertEquals(12, $xml->intValue); + $this->assertTrue(\is_array($xml->xmlValues)); + $this->assertEquals(1, count($xml->xmlValues)); + $this->assertEquals('str', $xml->xmlValues[0]->strValue); + $this->assertEquals(123, $xml->xmlValues[0]->intValue); + $this->assertEquals(true, $xml->xmlValues[0]->boolValue); + $this->assertEquals(1.14, $xml->xmlValues[0]->floatValue); + } + + public function testDeserializeCheckXmlRoot(): void + { + $str = ' + + str-111 + 12 + + str + 123 + true + 1.14 + + + str-1 + 223 + false + + '; + + $xml = new MixedTypeListXml(); + + try { + Deserializer::deserializeXml($str, $xml, 'MixedTypeList'); + $this->assertTrue(false, "shoud not here"); + } catch (DeserializationExecption $e) { + $this->assertStringContainsString("Deserialization raised an exception: Not found tag ", (string)$e); + } catch (\Exception $e) { + $this->assertTrue(false, "shoud not here"); + } + } + + public function testDeserializeInvalidXml(): void + { + $str = 'invalid xml'; + + $xml = new MixedTypeListXml(); + + try { + Deserializer::deserializeXml($str, $xml, 'MixedTypeList'); + $this->assertTrue(false, "shoud not here"); + } catch (DeserializationExecption $e) { + $this->assertStringContainsString("Deserialization raised an exception: Error parsing XML: part data ", (string)$e); + } catch (\Exception $e) { + $this->assertTrue(false, "shoud not here"); + } + } + + public function testDeserializeOutputCommon(): void + { + $output = new OperationOutput(); + $result = new PutApiResult(); + Deserializer::deserializeOutput($result, $output); + $this->assertEquals('', $result->getStatus()); + $this->assertEquals(0, $result->getStatusCode()); + $this->assertEquals('', $result->getRequestId()); + $this->assertEquals(0, count($result->getHeaders())); + + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: ['x-oss-request-id' => '123', 'content-type' => 'test'] + ); + $result = new PutApiResult(); + Deserializer::deserializeOutput($result, $output); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(2, count($result->getHeaders())); + $this->assertEquals('test', $result->getHeaders()['content-type']); + $this->assertEquals('123', $result->getHeaders()['x-oss-request-id']); + + $output = new OperationOutput( + status: 'OK', + statusCode: 203, + headers: ['content-type' => 'test'] + ); + $result = new PutApiResult(); + Deserializer::deserializeOutput($result, $output); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(203, $result->getStatusCode()); + $this->assertEquals('', $result->getRequestId()); + $this->assertEquals(1, count($result->getHeaders())); + $this->assertEquals('test', $result->getHeaders()['content-type']); + } + + public function testDeserializeOutputHeaderTag(): void + { + // normal header + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + 'x-oss-str' => 'str-1', + 'x-oss-int' => '123', + 'x-oss-bool' => 'false', + 'x-oss-float' => '3.5', + 'x-oss-isotime' => '2023-12-17T03:30:09Z', + 'x-oss-httptime' => 'Sun, 17 Dec 2023 03:30:09 GMT', + 'x-oss-unixtime' => '1702783809', + ], + ); + $date = new \DateTime(); + $date->setTimestamp(1702783809); + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(9, count($result->getHeaders())); + + $this->assertEquals('str-1', $result->getStrHeader()); + $this->assertEquals(123, $result->getIntHeader()); + $this->assertEquals(false, $result->getBoolHeader()); + $this->assertEquals(3.5, $result->getFloatHeader()); + $this->assertEquals($date, $result->getIsotimeHeader()); + $this->assertEquals($date, $result->getHttptimeHeader()); + $this->assertEquals($date, $result->getUnixtimeHeader()); + + // header array + // normal header + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'x-oss-str' => 'str-1', + 'x-oss-int' => '123', + 'x-oss-prefix-str1' => '123-1', + 'x-oss-prefix-str2' => '123-2', + 'x-oss-prefix-str3' => '123-3', + ], + ); + $date = new \DateTime(); + $date->setTimestamp(1702783809); + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(6, count($result->getHeaders())); + + $this->assertEquals('str-1', $result->getStrHeader()); + $this->assertEquals(123, $result->getIntHeader()); + $this->assertEquals(null, $result->getBoolHeader()); + $this->assertEquals(null, $result->getFloatHeader()); + $this->assertEquals(null, $result->getIsotimeHeader()); + $this->assertEquals(null, $result->getHttptimeHeader()); + $this->assertEquals(null, $result->getUnixtimeHeader()); + + $this->assertEquals(3, count($result->getArrayHeader())); + $this->assertEquals('123-1', $result->getArrayHeader()['str1']); + $this->assertEquals('123-2', $result->getArrayHeader()['str2']); + $this->assertEquals('123-3', $result->getArrayHeader()['str3']); + } + + public function testDeserializeOutputBodyXml(): void + { + // null body + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + ], + ); + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(2, count($result->getHeaders())); + $this->assertEquals(null, $result->getConfiguration()); + + //empty body + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + ], + body: Utils::streamFor(''), + ); + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(2, count($result->getHeaders())); + $this->assertEquals(null, $result->getConfiguration()); + + //xml + $str = ' + + str1 + str2 + + str-sub + 1234 + + '; + + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + ], + body: Utils::streamFor($str), + ); + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(2, count($result->getHeaders())); + $this->assertInstanceOf(RootConfiguration::class, $result->getConfiguration()); + $this->assertEquals('str1', $result->getConfiguration()->getId()); + $this->assertEquals('str2', $result->getConfiguration()->getText()); + $this->assertEquals('str-sub', $result->getConfiguration()->getSubConfiguration()[0]->getStrField()); + $this->assertEquals(1234, $result->getConfiguration()->getSubConfiguration()[0]->getIntField()); + + //xml tag not match + $str = ' + + str1 + str2 + + str-sub + 1234 + + '; + + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + ], + body: Utils::streamFor($str), + ); + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputBody'], + ]; + + try { + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertTrue(false, "shoud not here"); + } catch (DeserializationExecption $e) { + $this->assertStringContainsString("Deserialization raised an exception: Not found tag ", (string)$e); + } catch (\Exception $e) { + $this->assertTrue(false, "shoud not here"); + } + } + + public function testDeserializeOutputHeaderBodyTag(): void + { + //xml + $str = ' + + str1 + str2 + + str-sub + 1234 + + '; + $date = new \DateTime(); + $date->setTimestamp(1702783809); + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + 'x-oss-str' => 'str-1', + 'x-oss-int' => '123', + 'x-oss-bool' => 'false', + 'x-oss-float' => '3.5', + 'x-oss-isotime' => '2023-12-17T03:30:09Z', + 'x-oss-httptime' => 'Sun, 17 Dec 2023 03:30:09 GMT', + 'x-oss-unixtime' => '1702783809', + ], + body: Utils::streamFor($str), + ); + + $result = new PutApiResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + [Deserializer::class, 'deserializeOutputBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(9, count($result->getHeaders())); + + $this->assertEquals('str-1', $result->getStrHeader()); + $this->assertEquals(123, $result->getIntHeader()); + $this->assertEquals(false, $result->getBoolHeader()); + $this->assertEquals(3.5, $result->getFloatHeader()); + $this->assertEquals($date, $result->getIsotimeHeader()); + $this->assertEquals($date, $result->getHttptimeHeader()); + $this->assertEquals($date, $result->getUnixtimeHeader()); + + $this->assertInstanceOf(RootConfiguration::class, $result->getConfiguration()); + $this->assertEquals('str1', $result->getConfiguration()->getId()); + $this->assertEquals('str2', $result->getConfiguration()->getText()); + $this->assertEquals('str-sub', $result->getConfiguration()->getSubConfiguration()[0]->getStrField()); + $this->assertEquals(1234, $result->getConfiguration()->getSubConfiguration()[0]->getIntField()); + } + + public function testDeserializeOutputBodyXmlElement(): void + { + //xml + $str = ' + + str1 + str2 + + str-sub + 1234 + + '; + $date = new \DateTime(); + $date->setTimestamp(1702783809); + $output = new OperationOutput( + status: 'OK', + statusCode: 200, + headers: [ + 'x-oss-request-id' => '123', + 'content-type' => 'test', + 'x-oss-str' => 'str-1', + 'x-oss-int' => '123', + 'x-oss-bool' => 'false', + 'x-oss-float' => '3.5', + ], + body: Utils::streamFor($str), + ); + + $result = new PutApiBResult(); + $customDeserializer = [ + [Deserializer::class, 'deserializeOutputHeaders'], + [Deserializer::class, 'deserializeOutputInnerBody'], + ]; + Deserializer::deserializeOutput($result, $output, $customDeserializer); + $this->assertEquals('OK', $result->getStatus()); + $this->assertEquals(200, $result->getStatusCode()); + $this->assertEquals('123', $result->getRequestId()); + $this->assertEquals(6, count($result->getHeaders())); + + $this->assertEquals('str-1', $result->getStrHeader()); + $this->assertEquals(123, $result->getIntHeader()); + $this->assertEquals(false, $result->getBoolHeader()); + $this->assertEquals(3.5, $result->getFloatHeader()); + + $this->assertEquals('str1', $result->getId()); + $this->assertEquals('str2', $result->getText()); + $this->assertEquals('str-sub', $result->getSubConfiguration()[0]->getStrField()); + $this->assertEquals(1234, $result->getSubConfiguration()[0]->getIntField()); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Exception/ExceptionTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Exception/ExceptionTest.php new file mode 100644 index 0000000..5431e06 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Exception/ExceptionTest.php @@ -0,0 +1,15 @@ +assertNotNull($e); + $this->assertEquals('Operation error GetBucketAcl: abc is invalid', $e->getMessage()); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeLackAnnotationXml.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeLackAnnotationXml.php new file mode 100644 index 0000000..f43af69 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeLackAnnotationXml.php @@ -0,0 +1,32 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeListXml.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeListXml.php new file mode 100644 index 0000000..9657e37 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeListXml.php @@ -0,0 +1,36 @@ +strValues = $strValues; + $this->intValues = $intValues; + $this->boolValues = $boolValues; + $this->floatValues = $floatValues; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeXml.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeXml.php new file mode 100644 index 0000000..7dad374 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/BaiscTypeXml.php @@ -0,0 +1,36 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/DatetimeTypeXml.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/DatetimeTypeXml.php new file mode 100644 index 0000000..c596c21 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/DatetimeTypeXml.php @@ -0,0 +1,36 @@ +isotimeValue = $isotimeValue; + $this->dateTimeImmutableValue = $dateTimeImmutableValue; + $this->unixtimeValue = $unixtimeValue; + $this->httptimeValue = $httptimeValue; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeListXml.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeListXml.php new file mode 100644 index 0000000..e25568e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeListXml.php @@ -0,0 +1,30 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->xmlValues = $xmlValues; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeXml.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeXml.php new file mode 100644 index 0000000..7c8e6b0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/MixedTypeXml.php @@ -0,0 +1,38 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->xmlValue = $xmlValue; + $this->xmlListValue = $xmlListValue; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/NoRewindStream.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/NoRewindStream.php new file mode 100644 index 0000000..706e99c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/NoRewindStream.php @@ -0,0 +1,23 @@ +bucket = $bucket; + $this->key = $key; + $this->strHeader = $strHeader; + $this->strParam = $strParam; + $this->configuration = $configuration; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBRequest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBRequest.php new file mode 100644 index 0000000..39a3df5 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBRequest.php @@ -0,0 +1,44 @@ +bucket = $bucket; + $this->key = $key; + $this->strHeader = $strHeader; + $this->strParam = $strParam; + $this->arrayHeader = $arrayHeader; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBResult.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBResult.php new file mode 100644 index 0000000..d7d7338 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiBResult.php @@ -0,0 +1,52 @@ +strHeader = $strHeader; + $this->intHeader = $intHeader; + $this->boolHeader = $boolHeader; + $this->floatHeader = $floatHeader; + $this->id = $id; + $this->text = $text; + $this->subConfiguration = $subConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiRequest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiRequest.php new file mode 100644 index 0000000..9ec0115 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiRequest.php @@ -0,0 +1,107 @@ +bucket = $bucket; + $this->key = $key; + $this->strHeader = $strHeader; + $this->intHeader = $intHeader; + $this->boolHeader = $boolHeader; + $this->floatHeader = $floatHeader; + $this->isotimeHeader = $isotimeHeader; + $this->httptimeHeader = $httptimeHeader; + $this->unixtimeHeader = $unixtimeHeader; + $this->strParam = $strParam; + $this->intParam = $intParam; + $this->boolParam = $boolParam; + $this->floatParam = $floatParam; + $this->isotimeParam = $isotimeParam; + $this->httptimeParam = $httptimeParam; + $this->unixtimeParam = $unixtimeParam; + $this->configuration = $configuration; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiResult.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiResult.php new file mode 100644 index 0000000..f2e217b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/PutApiResult.php @@ -0,0 +1,62 @@ +strHeader = $strHeader; + $this->intHeader = $intHeader; + $this->boolHeader = $boolHeader; + $this->floatHeader = $floatHeader; + $this->isotimeHeader = $isotimeHeader; + $this->httptimeHeader = $httptimeHeader; + $this->unixtimeHeader = $unixtimeHeader; + $this->arrayHeader = $arrayHeader; + $this->configuration = $configuration; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RewindStatStream.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RewindStatStream.php new file mode 100644 index 0000000..30505cc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RewindStatStream.php @@ -0,0 +1,34 @@ +rewindCount++; + $this->stream->rewind(); + } + + /** + * Get the value of rewindCount + */ + public function getRewindCount() + { + return $this->rewindCount; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RootConfiguration.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RootConfiguration.php new file mode 100644 index 0000000..97524ef --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/RootConfiguration.php @@ -0,0 +1,34 @@ +id = $id; + $this->text = $text; + $this->subConfiguration = $subConfiguration; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/SubConfiguration.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/SubConfiguration.php new file mode 100644 index 0000000..06be052 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Fixtures/SubConfiguration.php @@ -0,0 +1,29 @@ +strField = $strField; + $this->intField = $intField; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/BackoffTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/BackoffTest.php new file mode 100644 index 0000000..570fa7b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/BackoffTest.php @@ -0,0 +1,58 @@ +backoffDelay($x, new \Exception()); + $this->assertLessThan( $maxdelay + 1, $delay); + $this->assertGreaterThan(0, $delay); + } + + $delay = $r->backoffDelay($x, null); + $this->assertLessThan( $maxdelay + 1, $delay); + $this->assertGreaterThan(0, $delay); + } + + public function testFullJitterBackoff() + { + $basedelay = 1.0; + $maxdelay = 20.0; + $r = new Retry\FullJitterBackoff($basedelay, $maxdelay); + + for ($x = 0; $x <= self::ATTEMPTED_CELLING * 2; $x++) { + $delay = $r->backoffDelay($x, new \Exception()); + $this->assertLessThan( $maxdelay + 1, $delay); + $this->assertGreaterThan(0, $delay); + } + + $delay = $r->backoffDelay($x, null); + $this->assertLessThan( $maxdelay + 1, $delay); + $this->assertGreaterThan(0, $delay); + } + + public function testFixedDelayBackoff() + { + $maxdelay = 20.0; + $r = new Retry\FixedDelayBackoff($maxdelay); + + for ($x = 0; $x <= self::ATTEMPTED_CELLING * 2; $x++) { + $delay = $r->backoffDelay($x, new \Exception()); + $this->assertEquals($maxdelay, $delay); + } + + $delay = $r->backoffDelay($x, null); + $this->assertEquals($maxdelay, $delay); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/ErrorRetryableTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/ErrorRetryableTest.php new file mode 100644 index 0000000..d5daac6 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/ErrorRetryableTest.php @@ -0,0 +1,72 @@ +assertEquals(false, $r->isErrorRetryable(new \Exception())); + $this->assertEquals(false, $r->isErrorRetryable(self::genStatusCodeError(403))); + $this->assertEquals(false, $r->isErrorRetryable(self::genStatusCodeError(405))); + + $this->assertEquals(true, $r->isErrorRetryable(self::genStatusCodeError(401))); + $this->assertEquals(true, $r->isErrorRetryable(self::genStatusCodeError(408))); + $this->assertEquals(true, $r->isErrorRetryable(self::genStatusCodeError(429))); + $this->assertEquals(true, $r->isErrorRetryable(self::genStatusCodeError(500))); + $this->assertEquals(true, $r->isErrorRetryable(self::genStatusCodeError(501))); + $this->assertEquals(true, $r->isErrorRetryable(self::genStatusCodeError(599))); + } + + public function testServiceErrorCodeRetryable() + { + $r = new Retry\ServiceErrorCodeRetryable(); + $this->assertEquals(false, $r->isErrorRetryable(new \Exception())); + $this->assertEquals(false, $r->isErrorRetryable(self::genServiceCodeError('123'))); + + $this->assertEquals(true, $r->isErrorRetryable(self::genServiceCodeError('RequestTimeTooSkewed'))); + $this->assertEquals(true, $r->isErrorRetryable(self::genServiceCodeError('BadRequest'))); + } + + public function testClientErrorCodeRetryable() + { + $r = new Retry\ClientErrorRetryable(); + $this->assertEquals(false, $r->isErrorRetryable(new \Exception())); + $this->assertEquals(false, $r->isErrorRetryable(self::genServiceCodeError('123'))); + + $this->assertEquals(true, $r->isErrorRetryable(new Exception\CredentialsException(''))); + $this->assertEquals(true, $r->isErrorRetryable(new Exception\InconsistentExecption('1', '2'))); + + $request = new GuzzleHttp\Psr7\Request('GET', 'http://foo.com'); + $respons = new GuzzleHttp\Psr7\Response(); + $this->assertEquals(true, $r->isErrorRetryable(new GuzzleHttp\Exception\BadResponseException('', $request, $respons))); + + $this->assertEquals(true, $r->isErrorRetryable(new GuzzleHttp\Exception\ConnectException('', $request))); + $this->assertEquals(true, $r->isErrorRetryable(new GuzzleHttp\Exception\RequestException('', $request))); + } + + public static function genStatusCodeError(int $statusCode) + { + return new Exception\ServiceException( + [ + 'status_code' => $statusCode, + ] + ); + } + + public static function genServiceCodeError(string $code) + { + return new Exception\ServiceException( + [ + 'code' => $code, + ] + ); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/RetryerTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/RetryerTest.php new file mode 100644 index 0000000..99bd44a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Retry/RetryerTest.php @@ -0,0 +1,76 @@ +assertEquals(false, $r->isErrorRetryable(new \Exception(''))); + $this->assertEquals(1, $r->getMaxAttempts()); + + try { + + $r->retryDelay(1, new \Exception('')); + $this->assertTrue(false, 'should not here'); + } catch (\Exception $e) { + $this->assertEquals('NotImplemented', $e->getMessage()); + } + } + + public function testStandardRetryer() + { + //default + $r = new Retry\StandardRetryer(); + $this->assertEquals(Defaults::MAX_ATTEMPTS, $r->getMaxAttempts()); + + $this->assertEquals(false, $r->isErrorRetryable(new \Exception())); + $this->assertEquals(false, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(403))); + $this->assertEquals(false, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(405))); + + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(401))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(408))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(429))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(500))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(501))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genStatusCodeError(599))); + + $this->assertEquals(false, $r->isErrorRetryable(ErrorRetryableTest::genServiceCodeError('123'))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genServiceCodeError('RequestTimeTooSkewed'))); + $this->assertEquals(true, $r->isErrorRetryable(ErrorRetryableTest::genServiceCodeError('BadRequest'))); + + $this->assertEquals(true, $r->isErrorRetryable(new Exception\ServiceException([ + 'status_code' => 403, + 'code' => 'RequestTimeTooSkewed', + ]))); + + $this->assertEquals(true, $r->isErrorRetryable(new Exception\CredentialsException(''))); + $this->assertEquals(true, $r->isErrorRetryable(new Exception\InconsistentExecption('1', '2'))); + + $request = new GuzzleHttp\Psr7\Request('GET', 'http://foo.com'); + $respons = new GuzzleHttp\Psr7\Response(); + $this->assertEquals(true, $r->isErrorRetryable(new GuzzleHttp\Exception\BadResponseException('', $request, $respons))); + $this->assertEquals(true, $r->isErrorRetryable(new GuzzleHttp\Exception\ConnectException('', $request))); + $this->assertEquals(true, $r->isErrorRetryable(new GuzzleHttp\Exception\RequestException('', $request))); + + + for ($x = 0; $x <= self::ATTEMPTED_CELLING * 2; $x++) { + $delay = $r->retryDelay($x, new \Exception()); + $this->assertLessThan(Defaults::MAX_BACKOFF_S + 1, $delay); + $this->assertGreaterThan(0, $delay); + } + + $delay = $r->retryDelay($x, null); + $this->assertLessThan(Defaults::MAX_BACKOFF_S + 1, $delay); + $this->assertGreaterThan(0, $delay); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/SerializerTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/SerializerTest.php new file mode 100644 index 0000000..7671722 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/SerializerTest.php @@ -0,0 +1,722 @@ +assertNotEmpty($str); + $this->assertStringContainsString('', $str); + $xml = \simplexml_load_string($str); + $this->assertEquals(0, $xml->count()); + $this->assertFalse(isset($xml->StrValue)); + $this->assertFalse(isset($xml->IntValue)); + $this->assertFalse(isset($xml->BoolValue)); + $this->assertFalse(isset($xml->FloatValue)); + + // all + $obj = new BaiscTypeXml( + strValue: 'str', + intValue: 1234, + boolValue: true, + floatValue: 3.14, + ); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(4, $xml->count()); + $this->assertEquals('str', $xml->StrValue); + $this->assertEquals('1234', $xml->IntValue); + $this->assertEquals('true', $xml->BoolValue); + $this->assertEquals('3.14', $xml->FloatValue); + + // part + $obj = new BaiscTypeXml( + strValue: 'str-123', + floatValue: 2.14, + ); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(2, $xml->count()); + $this->assertEquals('str-123', $xml->StrValue); + $this->assertFalse(isset($xml->IntValue)); + $this->assertFalse(isset($xml->BoolValue)); + $this->assertEquals('2.14', $xml->FloatValue); + + // part 2 + $obj = new BaiscTypeXml( + strValue: 'str-123', + boolValue: false, + ); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(2, $xml->count()); + $this->assertEquals('str-123', $xml->StrValue); + $this->assertFalse(isset($xml->IntValue)); + $this->assertEquals('false', $xml->BoolValue); + $this->assertFalse(isset($xml->FloatValue)); + } + + public function testSerializeBaiscTypeListXml(): void + { + // empty + $obj = new BaiscTypeListXml(); + $str = Serializer::serializeXml($obj); + $this->assertStringContainsString('', $str); + + // all + $obj = new BaiscTypeListXml( + strValues: ['str1', 'str2'], + intValues: [1234, 2234], + boolValues: [true, true, false], + floatValues: [3.14], + ); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(8, $xml->count()); + $this->assertEquals(2, count($xml->StrValue)); + $this->assertEquals('str1', $xml->StrValue[0]); + $this->assertEquals('str2', $xml->StrValue[1]); + $this->assertEquals(2, count($xml->IntValue)); + $this->assertEquals('1234', $xml->IntValue[0]); + $this->assertEquals('2234', $xml->IntValue[1]); + $this->assertEquals(3, count($xml->BoolValue)); + $this->assertEquals('true', $xml->BoolValue[0]); + $this->assertEquals('true', $xml->BoolValue[1]); + $this->assertEquals('false', $xml->BoolValue[2]); + $this->assertEquals(1, count($xml->FloatValue)); + $this->assertEquals('3.14', $xml->FloatValue[0]); + } + + public function testSerializeMixedTypeXml(): void + { + // empty + $obj = new MixedTypeXml(); + $str = Serializer::serializeXml($obj); + $this->assertStringContainsString('', $str); + + // all + $obj = new MixedTypeXml( + strValue: 'str-111', + intValue: 12, + xmlValue: new BaiscTypeXml( + strValue: 'str', + intValue: 123, + boolValue: true, + floatValue: 1.14, + ), + xmlListValue: new BaiscTypeListXml( + strValues: ['str1', 'str2'], + intValues: [1234, 2234], + boolValues: [true, true, false], + floatValues: [3.14], + ), + ); + + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(4, $xml->count()); + $this->assertEquals('str-111', $xml->StrValue); + $this->assertEquals('12', $xml->IntValue); + + $this->assertEquals(1, ($xml->BasicTypeFiled)->count()); + $this->assertEquals('str', $xml->BasicTypeFiled->StrValue); + $this->assertEquals('123', $xml->BasicTypeFiled->IntValue); + $this->assertEquals('true', $xml->BasicTypeFiled->BoolValue); + $this->assertEquals('1.14', $xml->BasicTypeFiled->FloatValue); + + $this->assertEquals(1, ($xml->BasicTypeListFiled)->count()); + $this->assertEquals(2, ($xml->BasicTypeListFiled->StrValue)->count()); + $this->assertEquals('str1', $xml->BasicTypeListFiled->StrValue[0]); + $this->assertEquals('str2', $xml->BasicTypeListFiled->StrValue[1]); + $this->assertEquals(2, ($xml->BasicTypeListFiled->IntValue)->count()); + $this->assertEquals('1234', $xml->BasicTypeListFiled->IntValue[0]); + $this->assertEquals('2234', $xml->BasicTypeListFiled->IntValue[1]); + $this->assertEquals(3, ($xml->BasicTypeListFiled->BoolValue)->count()); + $this->assertEquals('true', $xml->BasicTypeListFiled->BoolValue[0]); + $this->assertEquals('true', $xml->BasicTypeListFiled->BoolValue[1]); + $this->assertEquals('false', $xml->BasicTypeListFiled->BoolValue[2]); + $this->assertEquals(1, ($xml->BasicTypeListFiled->FloatValue)->count()); + $this->assertEquals('3.14', $xml->BasicTypeListFiled->FloatValue[0]); + } + + public function testSerializeMixedTypeListXml(): void + { + // empty + $obj = new MixedTypeListXml(); + $str = Serializer::serializeXml($obj); + $this->assertStringContainsString('', $str); + + // all + $obj = new MixedTypeListXml( + strValue: 'str-111', + intValue: 12, + xmlValues: [ + new BaiscTypeXml( + strValue: 'str', + intValue: 123, + boolValue: true, + floatValue: 1.14, + ), + new BaiscTypeXml( + strValue: 'str-1', + intValue: 223, + boolValue: false, + ), + ], + ); + + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(4, $xml->count()); + $this->assertEquals('str-111', $xml->StrValue); + $this->assertEquals('12', $xml->IntValue); + + $this->assertEquals(2, ($xml->BasicTypeFiled)->count()); + $this->assertEquals('str', $xml->BasicTypeFiled[0]->StrValue); + $this->assertEquals('123', $xml->BasicTypeFiled[0]->IntValue); + $this->assertEquals('true', $xml->BasicTypeFiled[0]->BoolValue); + $this->assertEquals('1.14', $xml->BasicTypeFiled[0]->FloatValue); + + $this->assertEquals('str-1', $xml->BasicTypeFiled[1]->StrValue); + $this->assertEquals('223', $xml->BasicTypeFiled[1]->IntValue); + $this->assertEquals('false', $xml->BasicTypeFiled[1]->BoolValue); + $this->assertFalse(isset($xml->BasicTypeFiled[1]->FloatValue)); + } + + public function testSerializeWithSpecialRootName() + { + $obj = new BaiscTypeXml(); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $this->assertStringContainsString('', $str); + + // empty + $obj = new BaiscTypeXml(); + $str = Serializer::serializeXml($obj, 'MyRoot'); + $this->assertNotEmpty($str); + $this->assertStringContainsString('', $str); + } + + public function testSerializeLackXmlAnnotation() + { + //xml root + $obj = new BaiscTypeLackAnnotationXml(); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $this->assertStringContainsString('', $str); + + $obj = new BaiscTypeLackAnnotationXml(); + $str = Serializer::serializeXml($obj, 'MyRoot'); + $this->assertNotEmpty($str); + $this->assertStringContainsString('', $str); + + //xml element + $obj = new BaiscTypeLackAnnotationXml( + strValue: 'str-123', + intValue: 1234, + boolValue: true, + floatValue: 3.14, + ); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(2, $xml->count()); + $this->assertEquals('str-123', $xml->StrValue); + $this->assertEquals('1234', $xml->IntValue); + $this->assertFalse(isset($xml->BoolValue)); + $this->assertFalse(isset($xml->FloatValue)); + } + + public function testSerializeDateTimeTypeXml() + { + //xml root + $obj = new DatetimeTypeXml(); + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $this->assertStringContainsString('', $str); + + $date = new \DateTime(); + $date->setTimestamp(1702783809); + + $date1 = new \DateTimeImmutable(); + $date1 = $date1->setTimestamp(1702783819); + + //xml element + $obj = new DatetimeTypeXml( + isotimeValue: $date, + dateTimeImmutableValue: $date1, + httptimeValue: $date, + unixtimeValue: $date, + ); + + $str = Serializer::serializeXml($obj); + $this->assertNotEmpty($str); + $xml = \simplexml_load_string($str); + $this->assertEquals(4, $xml->count()); + $this->assertEquals('2023-12-17T03:30:09Z', $xml->DateTimeValue); + $this->assertEquals('2023-12-17T03:30:19Z', $xml->DateTimeImmutableValue); + $this->assertEquals('1702783809', $xml->UnixtimeValue); + $this->assertEquals('Sun, 17 Dec 2023 03:30:09 GMT', $xml->HttptimeValue); + } + + public function testSerializeInput(): void + { + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + + $datetime2Utc = new \DateTime(); + $datetime2Utc->setTimestamp(1702783819); + + $request = new PutApiRequest( + bucket: "bucket-124", + #key: "key-1", + strHeader: "str_header", + intHeader: 123, + boolHeader: true, + floatHeader: 2.5, + isotimeHeader: $datetimeUtc, + httptimeHeader: $datetimeUtc, + unixtimeHeader: $datetimeUtc, + strParam: "str_param", + intParam: 456, + boolParam: false, + floatParam: 4.5, + isotimeParam: $datetime2Utc, + httptimeParam: $datetime2Utc, + unixtimeParam: $datetime2Utc, + configuration: new RootConfiguration( + id: "id-124", + text: "just for test", + subConfiguration: [ + new SubConfiguration( + strField: 'str-1', + intField: 111, + ), + new SubConfiguration( + strField: 'str-2', + intField: 222, + ), + ], + ) + ); + + # miss required field + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + + try { + Serializer::serializeInput($request, $input); + $this->assertTrue(false, "shoud not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } catch (\Exception $e) { + $this->assertTrue(false, "shoud not here"); + } + + #normal case + $request->setKey('key'); + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('123', $input->getHeaders()['x-oss-int']); + $this->assertEquals('true', $input->getHeaders()['x-oss-bool']); + $this->assertEquals('2.5', $input->getHeaders()['x-oss-float']); + $this->assertEquals('2023-12-17T03:30:09Z', $input->getHeaders()['x-oss-isotime']); + $this->assertEquals('Sun, 17 Dec 2023 03:30:09 GMT', $input->getHeaders()['x-oss-httptime']); + $this->assertEquals('1702783809', $input->getHeaders()['x-oss-unixtime']); + + $this->assertEquals('str_param', $input->getParameters()['param-str']); + $this->assertEquals('456', $input->getParameters()['param-int']); + $this->assertEquals('false', $input->getParameters()['param-bool']); + $this->assertEquals('4.5', $input->getParameters()['param-float']); + $this->assertEquals('2023-12-17T03:30:19Z', $input->getParameters()['param-isotime']); + $this->assertEquals('Sun, 17 Dec 2023 03:30:19 GMT', $input->getParameters()['param-httptime']); + $this->assertEquals('1702783819', $input->getParameters()['param-unixtime']); + + $str = $input->getBody()->getContents(); + $this->assertStringContainsString('', $str); + $xml = \simplexml_load_string($str); + $this->assertEquals(4, $xml->count()); + $this->assertEquals('id-124', $xml->Id); + $this->assertEquals('just for test', $xml->Text); + $this->assertEquals(2, ($xml->SubConfiguration)->count()); + $this->assertEquals('str-1', $xml->SubConfiguration[0]->StrField); + $this->assertEquals('111', $xml->SubConfiguration[0]->IntField); + $this->assertEquals('str-2', $xml->SubConfiguration[1]->StrField); + $this->assertEquals('222', $xml->SubConfiguration[1]->IntField); + } + + public function testSerializeInputWithHeadersAndParameters(): void + { + //case 1, input has headers and parameters + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + headers: ['Key' => 'value', 'key-1' => 'value-1'], + parameters: ['Key' => 'value', 'key-1' => 'value-1'], + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('value', $input->getHeaders()['key']); + $this->assertEquals('value-1', $input->getHeaders()['key-1']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + $this->assertEquals('value', $input->getParameters()['Key']); + $this->assertEquals('value-1', $input->getParameters()['key-1']); + + //case 2, input and request has same headers and parameters + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + headers: ['X-OSS-str' => 'value'], + parameters: ['param-str' => 'value', 'param-int' => '123'], + ); + Serializer::serializeInput($request, $input); + $this->assertEquals(1, count($input->getHeaders())); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals(2, count($input->getParameters())); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + $this->assertEquals('123', $input->getParameters()['param-int']); + + //case 3, request has headers and parameters, request.headers and request.parameters + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $request->setHeaders(['X-Oss-header1' => 'value-1', 'x-oss-header2' => 'value-2']); + $request->setParameters(['X-Oss-param1' => 'value-1', 'x-oss-param2' => 'value-2']); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + headers: ['Key' => 'value', 'key-1' => 'value-1'], + parameters: ['Key' => 'value', 'key-1' => 'value-1'], + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('value', $input->getHeaders()['key']); + $this->assertEquals('value-1', $input->getHeaders()['key-1']); + $this->assertEquals('value-1', $input->getHeaders()['x-oss-header1']); + $this->assertEquals('value-2', $input->getHeaders()['x-oss-header2']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + $this->assertEquals('value', $input->getParameters()['Key']); + $this->assertEquals('value-1', $input->getParameters()['key-1']); + $this->assertEquals('value-1', $input->getParameters()['X-Oss-param1']); + $this->assertEquals('value-2', $input->getParameters()['x-oss-param2']); + } + + public function testSerializeInputWithBody(): void + { + #case 1, request with body + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + configuration: "hello world" + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + $str = $input->getBody()->getContents(); + $this->assertEquals('hello world', $str); + + #case 2, request without body + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + $this->assertEquals(null, $input->getBody()); + + #case 3, input with body + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + body: Utils::streamFor('1234'), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + $str = $input->getBody()->getContents(); + $this->assertEquals('1234', $str); + + #case 4, input & request with body + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + configuration: "hello world abc", + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + body: Utils::streamFor('1234'), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + $str = $input->getBody()->getContents(); + $this->assertEquals('hello world abc', $str); + + #case 5, request.paylaod + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $request->setPayload(Utils::streamFor('just a payload')); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + $str = $input->getBody()->getContents(); + $this->assertEquals('just a payload', $str); + + #case 6, request.paylaod and input.body + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $request->setPayload(Utils::streamFor('payload-1234')); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + body: Utils::streamFor('body-1234'), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + $str = $input->getBody()->getContents(); + $this->assertEquals('payload-1234', $str); + + #case 6, request.paylaod and request.body + $request = new PutApiARequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + configuration: 'request body', + ); + + $request->setPayload(Utils::streamFor('payload-1234')); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + body: Utils::streamFor('body-1234'), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + $str = $input->getBody()->getContents(); + $this->assertEquals('request body', $str); + } + + public function testSerializeInputWithArrayHeader(): void + { + # case 1 + $request = new PutApiBRequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + arrayHeader: ['a' => 'value-1', 'b' => 'value-2'], + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('value-1', $input->getHeaders()['x-oss-prefix-a']); + $this->assertEquals('value-2', $input->getHeaders()['x-oss-prefix-b']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + + # case 1 + $request = new PutApiBRequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + Serializer::serializeInput($request, $input); + $this->assertEquals(1, count($input->getHeaders())); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + } + + public static function addTestHeader($request, OperationInput $input): void + { + $input->setHeader('Serializer-Header', '12345'); + } + + public function testSerializeInputWithCustomSerializer(): void + { + # case 1 + $request = new PutApiBRequest( + bucket: "bucket-124", + key: "key-1", + strHeader: "str_header", + strParam: "str_param", + arrayHeader: ['a' => 'value-1', 'b' => 'value-2'], + ); + + $input = new OperationInput( + opName: 'TestApi', + method: 'GET', + bucket: $request->getBucket(), + key: $request->getKey(), + ); + + $customSerializer = [ + static function ($request, OperationInput $input) { + $input->setHeader('my-header', 'just test'); + }, + [self::class, 'addTestHeader'], + ]; + + Serializer::serializeInput($request, $input, $customSerializer); + $this->assertEquals('str_header', $input->getHeaders()['x-oss-str']); + $this->assertEquals('value-1', $input->getHeaders()['x-oss-prefix-a']); + $this->assertEquals('value-2', $input->getHeaders()['x-oss-prefix-b']); + $this->assertEquals('just test', $input->getHeaders()['my-header']); + $this->assertEquals('12345', $input->getHeaders()['serializer-header']); + $this->assertEquals('str_param', $input->getParameters()['param-str']); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/NopSignerTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/NopSignerTest.php new file mode 100644 index 0000000..8335539 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/NopSignerTest.php @@ -0,0 +1,18 @@ +assertNull($r->sign($g)); + } + +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerContextTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerContextTest.php new file mode 100644 index 0000000..41bfdab --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerContextTest.php @@ -0,0 +1,26 @@ +assertIsArray($g->subResource); + $this->assertNull($g->product); + $this->assertNull($g->region); + $this->assertNull($g->bucket); + $this->assertNull($g->key); + $this->assertNull($g->request); + $this->assertNull($g->credentials); + $this->assertNull($g->time); + $this->assertNull($g->signedHeaders); + $this->assertNull($g->stringToSign); + $this->assertFalse($g->authMethodQuery); + } + +} \ No newline at end of file diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV1Test.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV1Test.php new file mode 100644 index 0000000..c555000 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV1Test.php @@ -0,0 +1,258 @@ +getCredentials(); + + // case 1 + $request = new Request("PUT", "https://examplebucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw==") + ->withHeader("Content-Type", "text/html") + ->withHeader("x-oss-meta-author", "alice") + ->withHeader("x-oss-meta-magic", "abracadabra") + ->withHeader("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Wed, 28 Dec 2022 10:27:41 GMT"); + #$signCtx = new SigningContext(bucket: "examplebucket", key: "nelson", request: $request, credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->bucket = 'examplebucket'; + $signCtx->key = 'nelson'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson"; + $this->assertEquals($signToString, $signCtx->stringToSign); + $this->assertEquals($signTime, $signCtx->time); + $request = $signCtx->request; + $this->assertEquals("OSS ak:kSHKmLxlyEAKtZPkJhG9bZb5k7M=", $request->getHeaderLine("Authorization")); + + // case 2 + $request = new Request("PUT", "https://examplebucket.oss-cn-hangzhou.aliyuncs.com/?acl"); + $request = $request->withHeader("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw==") + ->withHeader("Content-Type", "text/html") + ->withHeader("x-oss-meta-author", "alice") + ->withHeader("x-oss-meta-magic", "abracadabra") + ->withHeader("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Wed, 28 Dec 2022 10:27:41 GMT"); + #$signCtx = new SigningContext(bucket: "examplebucket", key: "nelson", request: $request, credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->bucket = 'examplebucket'; + $signCtx->key = 'nelson'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + $this->assertEquals($signToString, $signCtx->stringToSign); + $this->assertEquals($signTime, $signCtx->time); + $request = $signCtx->request; + $this->assertEquals("OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=", $request->getHeaderLine("Authorization")); + + // case 3 + $request = new Request("GET", "https://examplebucket.oss-cn-hangzhou.aliyuncs.com/?resourceGroup&non-resousce=null"); + $request = $request->withHeader("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Wed, 28 Dec 2022 10:27:41 GMT"); + #$signCtx = new SigningContext(bucket: "examplebucket", request: $request, subResource: ["resourceGroup"], credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->bucket = 'examplebucket'; + $signCtx->request = $request; + $signCtx->subResource = ["resourceGroup"]; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signToString = "GET\n\n\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\n/examplebucket/?resourceGroup"; + $this->assertEquals($signToString, $signCtx->stringToSign); + $this->assertEquals($signTime, $signCtx->time); + $request = $signCtx->request; + $this->assertEquals("OSS ak:vkQmfuUDyi1uDi3bKt67oemssIs=", $request->getHeaderLine("Authorization")); + + // case 4 + $request = new Request("GET", "https://examplebucket.oss-cn-hangzhou.aliyuncs.com/?resourceGroup&acl"); + $request = $request->withHeader("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Wed, 28 Dec 2022 10:27:41 GMT"); + #$signCtx = new SigningContext(bucket: "examplebucket", request: $request, subResource: ["resourceGroup"], credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->bucket = 'examplebucket'; + $signCtx->request = $request; + $signCtx->subResource = ["resourceGroup"]; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signToString = "GET\n\n\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\n/examplebucket/?acl&resourceGroup"; + $this->assertEquals($signToString, $signCtx->stringToSign); + $this->assertEquals($signTime, $signCtx->time); + $request = $signCtx->request; + $this->assertEquals("OSS ak:x3E5TgOvl/i7PN618s5mEvpJDYk=", $request->getHeaderLine("Authorization")); + + // case 5 + $request = new Request("GET", "https://examplebucket.oss-cn-hangzhou.aliyuncs.com/?resourceGroup&acl"); + $request = $request->withHeader("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + #$signCtx = new SigningContext(bucket: "examplebucket", request: $request, subResource: ["resourceGroup"], credentials: $cred); + $signCtx = new SigningContext(); + $signCtx->bucket = 'examplebucket'; + $signCtx->request = $request; + $signCtx->subResource = ["resourceGroup"]; + $signCtx->credentials = $cred; + $signer = new SignerV1(); + $signer->sign($signCtx); + $this->assertNotNull($signCtx->stringToSign); + $this->assertNotNull($signCtx->time->format("D, d M Y H:i:s")); + $request = $signCtx->request; + $this->assertNotNull($request->getHeaderLine("Authorization")); + + $provider = new StaticCredentialsProvider("ak", "sk", "token"); + $cred = $provider->getCredentials(); + $request = new Request("GET", "https://examplebucket.oss-cn-hangzhou.aliyuncs.com/?resourceGroup&acl"); + $request = $request->withHeader("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + #$signCtx = new SigningContext(bucket: "examplebucket", request: $request, subResource: ["resourceGroup"], credentials: $cred); + $signCtx = new SigningContext(); + $signCtx->bucket = 'examplebucket'; + $signCtx->request = $request; + $signCtx->subResource = ["resourceGroup"]; + $signCtx->credentials = $cred; + $signer = new SignerV1(); + $signer->sign($signCtx); + $this->assertNotNull($signCtx->stringToSign); + $this->assertNotNull($signCtx->time->format("D, d M Y H:i:s")); + $request = $signCtx->request; + $this->assertNotNull($request->getHeaderLine("Authorization")); + } + + public function testInvalidArgument() + { + try { + $signer = new SignerV1(); + $signer->sign(null); + } catch (\TypeError $e) { + $this->assertStringContainsString("AlibabaCloud\Oss\V2\Signer\SigningContext, null given", $e->getMessage()); + } + + try { + $provider = new StaticCredentialsProvider("", "sk"); + $cred = $provider->getCredentials(); + #$signCtx = new SigningContext(credentials: $cred); + $signCtx = new SigningContext(); + $signCtx->credentials = $cred; + $signer = new SignerV1(); + $signer->sign($signCtx); + } catch (\Exception $e) { + $this->assertSame("SigningContext Credentials is null or empty.", $e->getMessage()); + } + + try { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + #$signCtx = new SigningContext(credentials: $cred); + $signCtx = new SigningContext(); + $signCtx->credentials = $cred; + $signer = new SignerV1(); + $signer->sign($signCtx); + } catch (\Exception $e) { + $this->assertSame("SigningContext Request is null.", $e->getMessage()); + } + } + + public function testAuthQuery() + { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("GET", "https://bucket.oss-cn-hangzhou.aliyuncs.com/key?versionId=versionId"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Sun, 12 Nov 2023 16:43:40 GMT"); + #$signCtx = new SigningContext(bucket: "bucket", key: "key", request: $request, credentials: $cred, time: $signTime, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->bucket = 'bucket'; + $signCtx->key = 'key'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signCtx->authMethodQuery = true; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signUrl = "https://bucket.oss-cn-hangzhou.aliyuncs.com/key?Expires=1699807420&OSSAccessKeyId=ak&Signature=dcLTea%2BYh9ApirQ8o8dOPqtvJXQ%3D&versionId=versionId"; + $request = $signCtx->request; + $uri = $request->getUri(); + $this->assertEquals($signUrl, (string)$uri); + $this->assertEquals($signTime, $signCtx->time); + + // case 2 + $provider = new StaticCredentialsProvider("ak", "sk", "token"); + $cred = $provider->getCredentials(); + $request = new Request("GET", "https://bucket.oss-cn-hangzhou.aliyuncs.com/key%2B123?versionId=versionId"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Sun, 12 Nov 2023 16:56:44 GMT"); + #$signCtx = new SigningContext(bucket: "bucket", key: "key+123", request: $request, credentials: $cred, time: $signTime, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->bucket = 'bucket'; + $signCtx->key = 'key+123'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signCtx->authMethodQuery = true; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signUrl = "https://bucket.oss-cn-hangzhou.aliyuncs.com/key%2B123?Expires=1699808204&OSSAccessKeyId=ak&Signature=jzKYRrM5y6Br0dRFPaTGOsbrDhY%3D&security-token=token&versionId=versionId"; + $request = $signCtx->request; + $uri = $request->getUri(); + $this->assertEquals($signUrl, (string)$uri); + $this->assertEquals($signTime, $signCtx->time); + + // case 3 + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + $request = new Request("GET", "https://bucket.oss-cn-hangzhou.aliyuncs.com/key 123"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Sun, 12 Nov 2023 16:43:40 GMT"); + #$signCtx = new SigningContext(bucket: "bucket", key: "key", request: $request, credentials: $cred, time: $signTime, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->bucket = 'bucket'; + $signCtx->key = 'key'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signCtx->authMethodQuery = true; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signUrl = "https://bucket.oss-cn-hangzhou.aliyuncs.com/key%20123?Expires=1699807420&OSSAccessKeyId=ak&Signature=tYKe4BGVXY%2FMIl5F0qSoNfAnpkk%3D"; + $request = $signCtx->request; + $uri = $request->getUri(); + $this->assertEquals($signUrl, (string)$uri); + $this->assertEquals($signTime, $signCtx->time); + + // case 4 + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + $request = new Request("GET", "https://bucket.oss-cn-hangzhou.aliyuncs.com/key 123"); + $signTime = DateTime::createFromFormat("D, d M Y H:i:s T", "Sun, 12 Nov 2023 16:43:40 GMT"); + $signCtx = new SigningContext(); + $signCtx->bucket = 'bucket'; + $signCtx->key = 'key'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->authMethodQuery = true; + $signer = new SignerV1(); + $signer->sign($signCtx); + $signTime = (new DateTime('now', new DateTimeZone('UTC')))->modify('+' . SignerV1::DEFAULT_EXPIRES_DURATION . 'seconds'); + $request = $signCtx->request; + $uri = $request->getUri(); + $this->assertStringContainsString("https://bucket.oss-cn-hangzhou.aliyuncs.com/key%20123?Expires=" . (string)$signTime->getTimestamp() . "&OSSAccessKeyId=ak&Signature=", (string)$uri); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV4Test.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV4Test.php new file mode 100644 index 0000000..c0a6002 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Signer/SignerV4Test.php @@ -0,0 +1,618 @@ +getCredentials(); + + // case 1 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "text/plain") + ->withHeader("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + $signTime = new DateTime("@1702743657"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertEquals('OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,Signature=e21d18daa82167720f9b1047ae7e7f1ce7cb77a31e8203a7d5f4624fa0284afe', $request->getHeaderLine("Authorization")); + + // case 2 + $query = array(); + $request = new Request("POST", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("content-type", "text/plain") + ->withHeader("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + $signTime = new DateTime("@1702743657"); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = 'object'; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV4(); + $query['position'] = 0; + $query['append'] = ""; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertEquals('OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,Signature=f7a645f23a0434ea90d5e2bb2bca90d0fda9ef4bc54a9c5008b2134e7c9023f2', $request->getHeaderLine("Authorization")); + + // case 3 + $query = array(); + $request = new Request("POST", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("content-type", "text/plain"); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = 'object'; + $signCtx->credentials = $cred; + $signer = new SignerV4(); + $query['position'] = 0; + $query['append'] = ""; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertStringContainsString('OSS4-HMAC-SHA256', $request->getHeaderLine("Authorization")); + $date = (new DateTime('now', new DateTimeZone('UTC')))->format("Ymd"); + $this->assertStringContainsString("ak/{$date}/cn-hangzhou/oss/aliyun_v4_request", $request->getHeaderLine("Authorization")); + $this->assertStringContainsString('Signature=', $request->getHeaderLine("Authorization")); + } + + public function testAuthHeaderWithCloudBox() + { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "http://bucket.cb-123.cn-hangzhou.oss-cloudbox.aliyuncs.com/1234+-/123/1.txt"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "text/plain") + ->withHeader("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + $signTime = new DateTime("@1702743657"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->product = Defaults::CLOUD_BOX_PRODUCT; + $signCtx->region = 'cb-123'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertEquals('OSS4-HMAC-SHA256 Credential=ak/20231216/cb-123/oss-cloudbox/aliyun_v4_request,Signature=94ce1f12c17d148ea681030275a94449d3357f5b5b21133996eec80af3e08a43', $request->getHeaderLine("Authorization")); + } + + public function testAuthHeaderToken() + { + $provider = new StaticCredentialsProvider("ak", "sk", "token"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "text/plain") + ->withHeader("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + $signTime = new DateTime("@1702784856"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->request = $request; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertEquals('OSS4-HMAC-SHA256 Credential=ak/20231217/cn-hangzhou/oss/aliyun_v4_request,Signature=b94a3f999cf85bcdc00d332fbd3734ba03e48382c36fa4d5af5df817395bd9ea', $request->getHeaderLine("Authorization")); + } + + public function testAuthHeaderWithAdditionalHeaders() + { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "text/plain") + ->withHeader("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + $signTime = new DateTime("@1702747512"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, additionalHeaders: ["ZAbc", "abc"], credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->request = $request; + $signCtx->additionalHeaders = ["ZAbc", "abc"]; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertEquals('OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f', $request->getHeaderLine("Authorization")); + + // case 2:with default signed header + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "text/plain") + ->withHeader("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + $signTime = new DateTime("@1702747512"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, additionalHeaders: ["x-oss-no-exist", "ZAbc", "x-oss-head1", "abc"], credentials: $cred, time: $signTime); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->request = $request; + $signCtx->additionalHeaders = ["x-oss-no-exist", "ZAbc", "x-oss-head1", "abc"]; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $this->assertEquals('OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f', $request->getHeaderLine("Authorization")); + } + + public function testInvalidArgument() + { + try { + $signer = new SignerV4(); + $signer->sign(null); + } catch (\TypeError $e) { + $this->assertStringContainsString("AlibabaCloud\Oss\V2\Signer\SigningContext, null given", $e->getMessage()); + } + + try { + $signCtx = new SigningContext(); + $signer = new SignerV4(); + $signer->sign($signCtx); + } catch (\Exception $e) { + $this->assertSame("SigningContext Credentials is null or empty.", $e->getMessage()); + } + + try { + $provider = new StaticCredentialsProvider("", "sk"); + $cred = $provider->getCredentials(); + #$signCtx = new SigningContext(credentials: $cred); + $signCtx = new SigningContext(); + $signCtx->credentials = $cred; + $signer = new SignerV4(); + $signer->sign($signCtx); + } catch (\Exception $e) { + $this->assertSame("SigningContext Credentials is null or empty.", $e->getMessage()); + } + + try { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + #$signCtx = new SigningContext(credentials: $cred); + $signCtx = new SigningContext(); + $signCtx->credentials = $cred; + $signer = new SignerV4(); + $signer->sign($signCtx); + } catch (\Exception $e) { + $this->assertSame("SigningContext Region is empty.", $e->getMessage()); + } + + try { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + #$signCtx = new SigningContext(credentials: $cred, region: 'cn-hangzhou'); + $signCtx = new SigningContext(); + $signCtx->credentials = $cred; + $signCtx->region = 'cn-hangzhou'; + $signer = new SignerV4(); + $signer->sign($signCtx); + } catch (\Exception $e) { + $this->assertSame("SigningContext Request is null.", $e->getMessage()); + } + } + + public function testAuthQuery() + { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702781677"); + $time = new DateTime("@1702782276"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, credentials: $cred, time: $time, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->time = $time; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('a39966c61718be0d5b14e668088b3fa07601033f6518ac7b523100014269c0fe', $parsedQuery['x-oss-signature']); + $this->assertFalse(array_key_exists('x-oss-additional-headers', $parsedQuery)); + + // case 2 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->authMethodQuery = true; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $date = (new DateTime('now', new DateTimeZone('UTC')))->format("Ymd"); + $this->assertEquals('900', $parsedQuery['x-oss-expires']); + $this->assertEquals("ak/{$date}/cn-hangzhou/oss/aliyun_v4_request", $parsedQuery['x-oss-credential']); + $this->assertNotEmpty($parsedQuery['x-oss-signature']); + $this->assertFalse(array_key_exists('x-oss-additional-headers', $parsedQuery)); + + + } + + public function testAuthQueryToken() + { + $provider = new StaticCredentialsProvider("ak", "sk", "token"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702785388"); + $time = new DateTime("@1702785987"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, credentials: $cred, time: $time, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->time = $time; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('3817ac9d206cd6dfc90f1c09c00be45005602e55898f26f5ddb06d7892e1f8b5', $parsedQuery['x-oss-signature']); + $this->assertFalse(array_key_exists('x-oss-additional-headers', $parsedQuery)); + } + + public function testAuthQueryWithAdditionalHeaders() + { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702783809"); + $time = new DateTime("@1702784408"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, additionalHeaders: ["ZAbc", "abc"], credentials: $cred, time: $time, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->additionalHeaders = ["ZAbc", "abc"]; + $signCtx->credentials = $cred; + $signCtx->time = $time; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('6bd984bfe531afb6db1f7550983a741b103a8c58e5e14f83ea474c2322dfa2b7', $parsedQuery['x-oss-signature']); + $this->assertEquals('abc;zabc', $parsedQuery['x-oss-additional-headers']); + + // case 2:with default signed header + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702783809"); + $time = new DateTime("@1702784408"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, additionalHeaders: ["x-oss-no-exist", "abc", "x-oss-head1", "ZAbc"], credentials: $cred, time: $time, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->additionalHeaders = ["x-oss-no-exist", "abc", "x-oss-head1", "ZAbc"]; + $signCtx->credentials = $cred; + $signCtx->time = $time; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('20231217T033009Z', $parsedQuery['x-oss-date']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('6bd984bfe531afb6db1f7550983a741b103a8c58e5e14f83ea474c2322dfa2b7', $parsedQuery['x-oss-signature']); + $this->assertEquals('abc;zabc', $parsedQuery['x-oss-additional-headers']); + + // case 3 + $request = new Request("PUT", "https://bucket.oss-cn-hangzhou.aliyuncs.com/key 123.txt"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702783809"); + $time = new DateTime("@1702784408"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "key 123.txt", request: $request, additionalHeaders: ["ZAbc", "abc"], credentials: $cred, time: $time, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->product = 'oss'; + $signCtx->region = 'cn-hangzhou'; + $signCtx->bucket = 'bucket'; + $signCtx->key = 'key 123.txt'; + $signCtx->additionalHeaders = ["ZAbc", "abc"]; + $signCtx->credentials = $cred; + $signCtx->time = $signTime; + $signCtx->time = $time; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query, '', '&', PHP_QUERY_RFC3986))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $uri = $request->getUri(); + $signUrl = "https://bucket.oss-cn-hangzhou.aliyuncs.com/key%20123.txt?%2Bparam1=value3&%2Bparam2=¶m1=value1¶m2=&x-oss-additional-headers=abc%3Bzabc&x-oss-credential=ak%2F20231217%2Fcn-hangzhou%2Foss%2Faliyun_v4_request&x-oss-date=20231217T033009Z&x-oss-expires=599&x-oss-signature=33208021567953241c3cc1d95ecf1864f8561890c30d29488ce76c7afb81a623&x-oss-signature-version=OSS4-HMAC-SHA256&%7Cparam1=value4&%7Cparam2="; + $this->assertEquals($signUrl, (string)$uri); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('33208021567953241c3cc1d95ecf1864f8561890c30d29488ce76c7afb81a623', $parsedQuery['x-oss-signature']); + $this->assertEquals('abc;zabc', $parsedQuery['x-oss-additional-headers']); + } + + public function testAuthQueryWithCloudBox() + { + $provider = new StaticCredentialsProvider("ak", "sk"); + $cred = $provider->getCredentials(); + + // case 1 + $request = new Request("PUT", "http://bucket.cb-123.cn-hangzhou.oss-cloudbox.aliyuncs.com/1234+-/123/1.txt"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702781677"); + $time = new DateTime("@1702782276"); + #$signCtx = new SigningContext(product: "oss", region: "cn-hangzhou", bucket: "bucket", key: "1234+-/123/1.txt", request: $request, credentials: $cred, time: $time, authMethodQuery: true); + $signCtx = new SigningContext(); + $signCtx->product = Defaults::CLOUD_BOX_PRODUCT; + $signCtx->region = 'cb-123'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->time = $time; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signCtx->additionalHeaders = ["ZAbc", "abc"]; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cb-123/oss-cloudbox/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('07284191b9b4978ac3520cd39ee2dea2747eda454089359371ff463a6c7ba20f', $parsedQuery['x-oss-signature']); + $this->assertTrue(array_key_exists('x-oss-additional-headers', $parsedQuery)); + $this->assertEquals('abc;zabc', $parsedQuery['x-oss-additional-headers']); + + // with default signed header + $request = new Request("PUT", "http://bucket.cb-123.cn-hangzhou.oss-cloudbox.aliyuncs.com/1234+-/123/1.txt"); + $request = $request->withHeader("x-oss-head1", "value") + ->withHeader("x-oss-head1", "value") + ->withHeader("abc", "value") + ->withHeader("ZAbc", "value") + ->withHeader("XYZ", "value") + ->withHeader("content-type", "application/octet-stream"); + $signTime = new DateTime("@1702783809"); + $time = new DateTime("@1702784408"); + $signCtx = new SigningContext(); + $signCtx->product = 'oss-cloudbox'; + $signCtx->region = 'cb-123'; + $signCtx->bucket = 'bucket'; + $signCtx->key = '1234+-/123/1.txt'; + $signCtx->credentials = $cred; + $signCtx->authMethodQuery = true; + $signCtx->signTime = $signTime; + $signCtx->time = $time; + $signCtx->additionalHeaders = ["x-oss-no-exist", "abc", "x-oss-head1", "ZAbc"]; + $signer = new SignerV4(); + $query['param1'] = 'value1'; + $query['+param1'] = 'value3'; + $query['|param1'] = 'value4'; + $query['+param2'] = ''; + $query['|param2'] = ''; + $query['param2'] = ''; + $signCtx->request = $request->withUri($request->getUri()->withQuery(http_build_query($query))); + $signer->sign($signCtx); + $request = $signCtx->request; + $queryParams = $request->getUri()->getQuery(); + parse_str($queryParams, $parsedQuery); + $this->assertEquals('OSS4-HMAC-SHA256', $parsedQuery['x-oss-signature-version']); + $this->assertEquals('599', $parsedQuery['x-oss-expires']); + $this->assertEquals('ak/20231217/cb-123/oss-cloudbox/aliyun_v4_request', $parsedQuery['x-oss-credential']); + $this->assertEquals('16782cc8a7a554523db055eb804b508522e7e370073108ad88ee2f47496701dd', $parsedQuery['x-oss-signature']); + $this->assertTrue(array_key_exists('x-oss-additional-headers', $parsedQuery)); + $this->assertEquals('abc;zabc', $parsedQuery['x-oss-additional-headers']); + + + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/AccessPointTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/AccessPointTest.php new file mode 100644 index 0000000..a0de057 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/AccessPointTest.php @@ -0,0 +1,482 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CreateAccessPointRequest('bucket-123'); + $input = AccessPoint::fromCreateAccessPoint($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, createAccessPointConfiguration", (string)$e); + } + + $request = new Models\CreateAccessPointRequest('bucket-123', new Models\CreateAccessPointConfiguration( + accessPointName: 'ap-01', + networkOrigin: 'internet' + )); + $input = AccessPoint::fromCreateAccessPoint($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<ap-01internet +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\CreateAccessPointRequest('bucket-123', new Models\CreateAccessPointConfiguration( + vpcConfiguration: new Models\AccessPointVpcConfiguration('vpc-t4nlw426y44rd3iq4xxxx'), + accessPointName: 'ap-01', + networkOrigin: 'vpc' + )); + $input = AccessPoint::fromCreateAccessPoint($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<vpc-t4nlw426y44rd3iq4xxxxap-01vpc +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToCreateAccessPoint() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toCreateAccessPoint($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + acs:oss:cn-hangzhou:128364106451xxxx:accesspoint/ap-01 + ap-01-45ee7945007a2f0bcb595f63e2215cxxxx-ossalias +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = AccessPoint::toCreateAccessPoint($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('acs:oss:cn-hangzhou:128364106451xxxx:accesspoint/ap-01', $result->createAccessPoint->accessPointArn); + $this->assertEquals('ap-01-45ee7945007a2f0bcb595f63e2215cxxxx-ossalias', $result->createAccessPoint->alias); + } + + public function testFromGetAccessPoint() + { + // miss required field + try { + $request = new Models\GetAccessPointRequest(); + $input = AccessPoint::fromGetAccessPoint($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetAccessPointRequest('bucket-123'); + $input = AccessPoint::fromGetAccessPoint($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointName", (string)$e); + } + + $request = new Models\GetAccessPointRequest('bucket-123', 'ap-01'); + $input = AccessPoint::fromGetAccessPoint($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-name']); + } + + public function testToGetAccessPoint() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toGetAccessPoint($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + ap-01 + oss-example + 111933544165xxxx + vpc + + vpc-t4nlw426y44rd3iq4xxxx + + arn:acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01 + 1626769503 + ap-01-ossalias + enable + + ap-01.oss-cn-hangzhou.oss-accesspoint.aliyuncs.com + ap-01.oss-cn-hangzhou-internal.oss-accesspoint.aliyuncs.com + + + true + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = AccessPoint::toGetAccessPoint($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('ap-01', $result->getAccessPoint->accessPointName); + $this->assertEquals('oss-example', $result->getAccessPoint->bucket); + $this->assertEquals('111933544165xxxx', $result->getAccessPoint->accountId); + $this->assertEquals('vpc', $result->getAccessPoint->networkOrigin); + $this->assertEquals('vpc-t4nlw426y44rd3iq4xxxx', $result->getAccessPoint->vpcConfiguration->vpcId); + $this->assertEquals('arn:acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01', $result->getAccessPoint->accessPointArn); + $this->assertEquals('1626769503', $result->getAccessPoint->creationDate); + $this->assertEquals('ap-01-ossalias', $result->getAccessPoint->alias); + $this->assertEquals('enable', $result->getAccessPoint->status); + $this->assertEquals('ap-01.oss-cn-hangzhou.oss-accesspoint.aliyuncs.com', $result->getAccessPoint->endpoints->publicEndpoint); + $this->assertEquals('ap-01.oss-cn-hangzhou-internal.oss-accesspoint.aliyuncs.com', $result->getAccessPoint->endpoints->internalEndpoint); + $this->assertTrue($result->getAccessPoint->publicAccessBlockConfiguration->blockPublicAccess); + } + + public function testFromDeleteAccessPoint() + { + // miss required field + try { + $request = new Models\DeleteAccessPointRequest(); + $input = AccessPoint::fromDeleteAccessPoint($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteAccessPointRequest('bucket-123'); + $input = AccessPoint::fromDeleteAccessPoint($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointName", (string)$e); + } + + $request = new Models\DeleteAccessPointRequest('bucket-123', 'ap-01'); + $input = AccessPoint::fromDeleteAccessPoint($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-name']); + } + + public function testToDeleteAccessPoint() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toDeleteAccessPoint($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'], + ); + $result = AccessPoint::toDeleteAccessPoint($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromListAccessPoints() + { + $request = new Models\ListAccessPointsRequest(); + $input = AccessPoint::fromListAccessPoints($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + $request = new Models\ListAccessPointsRequest(10, 'token', 'bucket-123'); + $input = AccessPoint::fromListAccessPoints($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('10', $input->getParameters()['max-keys']); + $this->assertEquals('token', $input->getParameters()['continuation-token']); + } + + public function testToListAccessPoints() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toGetAccessPoint($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + true + abc + 111933544165**** + 3 + + + oss-example + ap-01 + ap-01-ossalias + vpc + + vpc-t4nlw426y44rd3iq4**** + + enable + + + oss-example + ap-02 + ap-02-ossalias + vpc + + vpc-t4nlw426y44rd3iq2**** + + enable + + + oss-example + ap-03 + ap-03-ossalias + internet + + + + enable + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = AccessPoint::toListAccessPoints($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('111933544165****', $result->listAccessPoints->accountId); + $this->assertEquals('abc', $result->listAccessPoints->nextContinuationToken); + $this->assertTrue($result->listAccessPoints->isTruncated); + $this->assertEquals(3, $result->listAccessPoints->maxKeys); + $this->assertEquals(3, count($result->listAccessPoints->accessPoints->accessPoints)); + $this->assertEquals('oss-example', $result->listAccessPoints->accessPoints->accessPoints[0]->bucket); + $this->assertEquals('ap-01', $result->listAccessPoints->accessPoints->accessPoints[0]->accessPointName); + $this->assertEquals('ap-01-ossalias', $result->listAccessPoints->accessPoints->accessPoints[0]->alias); + $this->assertEquals('vpc', $result->listAccessPoints->accessPoints->accessPoints[0]->networkOrigin); + $this->assertEquals('vpc-t4nlw426y44rd3iq4****', $result->listAccessPoints->accessPoints->accessPoints[0]->vpcConfiguration->vpcId); + $this->assertEquals('enable', $result->listAccessPoints->accessPoints->accessPoints[0]->status); + $this->assertEquals('oss-example', $result->listAccessPoints->accessPoints->accessPoints[1]->bucket); + $this->assertEquals('ap-02', $result->listAccessPoints->accessPoints->accessPoints[1]->accessPointName); + $this->assertEquals('ap-02-ossalias', $result->listAccessPoints->accessPoints->accessPoints[1]->alias); + $this->assertEquals('vpc', $result->listAccessPoints->accessPoints->accessPoints[1]->networkOrigin); + $this->assertEquals('vpc-t4nlw426y44rd3iq2****', $result->listAccessPoints->accessPoints->accessPoints[1]->vpcConfiguration->vpcId); + $this->assertEquals('enable', $result->listAccessPoints->accessPoints->accessPoints[1]->status); + $this->assertEquals('oss-example', $result->listAccessPoints->accessPoints->accessPoints[2]->bucket); + $this->assertEquals('ap-03', $result->listAccessPoints->accessPoints->accessPoints[2]->accessPointName); + $this->assertEquals('ap-03-ossalias', $result->listAccessPoints->accessPoints->accessPoints[2]->alias); + $this->assertEquals('internet', $result->listAccessPoints->accessPoints->accessPoints[2]->networkOrigin); + $this->assertEquals('enable', $result->listAccessPoints->accessPoints->accessPoints[2]->status); + } + + public function testFromPutAccessPointPolicy() + { + // miss required field + try { + $request = new Models\PutAccessPointPolicyRequest(); + $input = AccessPoint::fromPutAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutAccessPointPolicyRequest('bucket-123'); + $input = AccessPoint::fromPutAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointName", (string)$e); + } + + try { + $request = new Models\PutAccessPointPolicyRequest('bucket-123', 'ap-01'); + $input = AccessPoint::fromPutAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, body", (string)$e); + } + + $request = new Models\PutAccessPointPolicyRequest('bucket-123', 'ap-01', '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["27737962156157xxxx"],"Resource":["acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01","acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01/object/*"]}]}'); + $input = AccessPoint::fromPutAccessPointPolicy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["27737962156157xxxx"],"Resource":["acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01","acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01/object/*"]}]}', $input->getBody()->getContents()); + } + + public function testToPutAccessPointPolicy() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toPutAccessPointPolicy($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + ); + $result = AccessPoint::toPutAccessPointPolicy($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetAccessPointPolicy() + { + // miss required field + try { + $request = new Models\GetAccessPointPolicyRequest(); + $input = AccessPoint::fromGetAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetAccessPointPolicyRequest('bucket-123'); + $input = AccessPoint::fromGetAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointName", (string)$e); + } + + $request = new Models\GetAccessPointPolicyRequest('bucket-123', 'ap-01'); + $input = AccessPoint::fromGetAccessPointPolicy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-name']); + } + + public function testToGetAccessPointPolicy() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toGetAccessPointPolicy($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["27737962156157xxxx"],"Resource":["acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01","acs:oss:cn-hangzhou:111933544165xxxx:accesspoint/ap-01/object/*"]}]}'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/json'], + body: Utils::streamFor($body) + ); + $result = AccessPoint::toGetAccessPointPolicy($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/json', $result->headers['content-type']); + $this->assertEquals($body, $result->body); + } + + public function testFromDeleteAccessPointPolicy() + { + // miss required field + try { + $request = new Models\DeleteAccessPointPolicyRequest(); + $input = AccessPoint::fromDeleteAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteAccessPointPolicyRequest('bucket-123'); + $input = AccessPoint::fromDeleteAccessPointPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessPointName", (string)$e); + } + + $request = new Models\DeleteAccessPointPolicyRequest('bucket-123', 'ap-01'); + $input = AccessPoint::fromDeleteAccessPointPolicy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('ap-01', $input->getHeaders()['x-oss-access-point-name']); + } + + public function testToDeleteAccessPointPolicy() + { + // empty output + $output = new OperationOutput(); + $result = AccessPoint::toDeleteAccessPointPolicy($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'], + ); + $result = AccessPoint::toDeleteAccessPointPolicy($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketAccessMonitorTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketAccessMonitorTest.php new file mode 100644 index 0000000..16de4d4 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketAccessMonitorTest.php @@ -0,0 +1,115 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketAccessMonitorRequest('bucket-123'); + $input = BucketAccessMonitor::fromPutBucketAccessMonitor($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessMonitorConfiguration", (string)$e); + } + + $request = new Models\PutBucketAccessMonitorRequest('bucket-123', new Models\AccessMonitorConfiguration( + status: Models\AccessMonitorStatusType::ENABLED + )); + $input = BucketAccessMonitor::fromPutBucketAccessMonitor($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketAccessMonitor() + { + // empty output + $output = new OperationOutput(); + $result = BucketAccessMonitor::toPutBucketAccessMonitor($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketAccessMonitor::toPutBucketAccessMonitor($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketAccessMonitor() + { + // miss required field + try { + $request = new Models\GetBucketAccessMonitorRequest(); + $input = BucketAccessMonitor::fromGetBucketAccessMonitor($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketAccessMonitorRequest('bucket-123'); + $input = BucketAccessMonitor::fromGetBucketAccessMonitor($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketAccessMonitor() + { + // empty output + $output = new OperationOutput(); + $result = BucketAccessMonitor::toGetBucketAccessMonitor($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + Enabled +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketAccessMonitor::toGetBucketAccessMonitor($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(Models\AccessMonitorStatusType::ENABLED, $result->accessMonitorConfiguration->status); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketArchiveDirectReadTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketArchiveDirectReadTest.php new file mode 100644 index 0000000..bdd0e91 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketArchiveDirectReadTest.php @@ -0,0 +1,133 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketArchiveDirectReadRequest('bucket-123'); + $input = BucketArchiveDirectRead::fromPutBucketArchiveDirectRead($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, archiveDirectReadConfiguration", (string)$e); + } + + $request = new Models\PutBucketArchiveDirectReadRequest('bucket-123', new Models\ArchiveDirectReadConfiguration( + true + )); + $input = BucketArchiveDirectRead::fromPutBucketArchiveDirectRead($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<true +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketArchiveDirectRead() + { + // empty output + $output = new OperationOutput(); + $result = BucketArchiveDirectRead::toPutBucketArchiveDirectRead($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketArchiveDirectRead::toPutBucketArchiveDirectRead($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketArchiveDirectRead() + { + // miss required field + try { + $request = new Models\GetBucketArchiveDirectReadRequest(); + $input = BucketArchiveDirectRead::fromGetBucketArchiveDirectRead($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketArchiveDirectReadRequest('bucket-123'); + $input = BucketArchiveDirectRead::fromGetBucketArchiveDirectRead($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketArchiveDirectRead() + { + // empty output + $output = new OperationOutput(); + $result = BucketArchiveDirectRead::toGetBucketArchiveDirectRead($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + true +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketArchiveDirectRead::toGetBucketArchiveDirectRead($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertTrue($result->archiveDirectReadConfiguration->enabled); + + $body = ' + + false +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketArchiveDirectRead::toGetBucketArchiveDirectRead($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertFalse($result->archiveDirectReadConfiguration->enabled); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketBasicTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketBasicTest.php new file mode 100644 index 0000000..46c52ce --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketBasicTest.php @@ -0,0 +1,2414 @@ +assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\PutBucketRequest('bucket-123'); + $input = BucketBasic::fromPutBucket($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // all settings + $request = new Models\PutBucketRequest( + 'bucket-123', + Models\BucketACLType::PRIVATE, + 'rg-123', + new Models\CreateBucketConfiguration( + Models\StorageClassType::IA, + Models\DataRedundancyType::LRS + ) + ); + $createXml = <<IALRS +BBB; + + $input = BucketBasic::fromPutBucket($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $str = $input->getBody()->getContents(); + $this->assertEquals(base64_encode(md5($str, true)), $input->getHeaders()['content-md5']); + $this->assertEquals(Models\BucketACLType::PRIVATE, $input->getHeaders()['x-oss-acl']); + $this->assertEquals('rg-123', $input->getHeaders()['x-oss-resource-group-id']); + $this->assertEquals($createXml, $this->cleanXml($str)); + $this->assertStringContainsString('', $str); + $xml = \simplexml_load_string($str); + $this->assertEquals(2, $xml->count()); + $this->assertEquals('IA', $xml->StorageClass); + $this->assertEquals('LRS', $xml->DataRedundancyType); + + // extend header & parameters + $request = new Models\PutBucketRequest( + 'bucket-123', + null, + null, + null, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromPutBucket($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToPutBucket() + { + // empty output + $output = new OperationOutput(); + $result = BucketBasic::toPutBucket($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'] + ); + $result = BucketBasic::toPutBucket($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromDeleteBucket() + { + // miss required field + try { + $request = new Models\DeleteBucketRequest(); + $input = BucketBasic::fromDeleteBucket($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\DeleteBucketRequest('bucket-123'); + $input = BucketBasic::fromDeleteBucket($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // extend header & parameters + $request = new Models\DeleteBucketRequest( + 'bucket-123', + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromDeleteBucket($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToDeleteBucket() + { + // empty output + $output = new OperationOutput(); + $result = BucketBasic::toDeleteBucket($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123', 'content-type' => 'test'] + ); + $result = BucketBasic::toDeleteBucket($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketInfo() + { + // miss required field + try { + $request = new Models\GetBucketInfoRequest(); + $input = BucketBasic::fromGetBucketInfo($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\GetBucketInfoRequest('bucket-123'); + $input = BucketBasic::fromGetBucketInfo($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // extend header & parameters + $request = new Models\GetBucketInfoRequest( + 'bucket-123', + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromGetBucketInfo($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToGetBucketInfo() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toGetBucketInfo($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + // xml invalid + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor('') + ); + $result = BucketBasic::toGetBucketInfo($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketInfo($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNotEmpty($result->bucketInfo); + $this->assertNull($result->bucketInfo->name); + $this->assertNull($result->bucketInfo->accessMonitor); + $this->assertNull($result->bucketInfo->location); + $this->assertNull($result->bucketInfo->creationDate); + $this->assertNull($result->bucketInfo->extranetEndpoint); + $this->assertNull($result->bucketInfo->intranetEndpoint); + $this->assertNull($result->bucketInfo->acl); + $this->assertNull($result->bucketInfo->dataRedundancyType); + $this->assertNull($result->bucketInfo->owner); + $this->assertNull($result->bucketInfo->storageClass); + $this->assertNull($result->bucketInfo->resourceGroupId); + $this->assertNull($result->bucketInfo->sseRule); + $this->assertNull($result->bucketInfo->versioning); + $this->assertNull($result->bucketInfo->transferAcceleration); + $this->assertNull($result->bucketInfo->crossRegionReplication); + $this->assertNull($result->bucketInfo->comment); + $this->assertNull($result->bucketInfo->blockPublicAccess); + + + // xml + $str = ' + + + Enabled + 2023-12-17T03:30:09.000Z + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-cn-hangzhou + Standard + Disabled + Disabled + LRS + oss-example + rg-aek27tc******** + + username + 27183473914**** + + + private + + Suspended + test + + KMS + 123 + + + examplebucket + log/ + + true + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketInfo($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNotEmpty($result->bucketInfo); + + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $this->assertEquals('oss-example', $result->bucketInfo->name); + $this->assertEquals('Enabled', $result->bucketInfo->accessMonitor); + $this->assertEquals('oss-cn-hangzhou', $result->bucketInfo->location); + $this->assertEquals($datetimeUtc, $result->bucketInfo->creationDate); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $result->bucketInfo->extranetEndpoint); + $this->assertEquals('oss-cn-hangzhou-internal.aliyuncs.com', $result->bucketInfo->intranetEndpoint); + $this->assertEquals('private', $result->bucketInfo->acl); + $this->assertEquals('LRS', $result->bucketInfo->dataRedundancyType); + $this->assertEquals('27183473914****', $result->bucketInfo->owner->id); + $this->assertEquals('username', $result->bucketInfo->owner->displayName); + $this->assertEquals('Standard', $result->bucketInfo->storageClass); + $this->assertEquals('rg-aek27tc********', $result->bucketInfo->resourceGroupId); + $this->assertEquals('KMS', $result->bucketInfo->sseRule->sseAlgorithm); + $this->assertEquals('123', $result->bucketInfo->sseRule->kmsMasterKeyId); + $this->assertNull($result->bucketInfo->sseRule->kmsDataEncryption); + $this->assertEquals('Suspended', $result->bucketInfo->versioning); + $this->assertEquals('Disabled', $result->bucketInfo->transferAcceleration); + $this->assertEquals('Disabled', $result->bucketInfo->crossRegionReplication); + + $this->assertEquals('test', $result->bucketInfo->comment); + $this->assertEquals('examplebucket', $result->bucketInfo->bucketPolicy->logBucket); + $this->assertEquals('log/', $result->bucketInfo->bucketPolicy->logPrefix); + $this->assertEquals(true, $result->bucketInfo->blockPublicAccess); + + // xml + $str = ' + + + + + + + + + + + + + + + + + + + + + + + + + / + + + + / + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketInfo($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNotEmpty($result->bucketInfo); + $this->assertEquals('', $result->bucketInfo->name); + $this->assertEquals('', $result->bucketInfo->accessMonitor); + $this->assertEquals('', $result->bucketInfo->location); + } + + public function testFromGetBucketLocation() + { + // miss required field + try { + $request = new Models\GetBucketLocationRequest(); + $input = BucketBasic::fromGetBucketLocation($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\GetBucketLocationRequest('bucket-123'); + $input = BucketBasic::fromGetBucketLocation($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // extend header & parameters + $request = new Models\GetBucketLocationRequest( + 'bucket-123', + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromGetBucketLocation($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToGetBucketLocation() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toGetBucketLocation($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketLocation($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('', $result->location); + + // xml + $str = ' + oss-cn-hangzhou'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketLocation($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('oss-cn-hangzhou', $result->location); + } + + public function testFromGetBucketStat() + { + // miss required field + try { + $request = new Models\GetBucketStatRequest(); + $input = BucketBasic::fromGetBucketStat($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\GetBucketStatRequest('bucket-123'); + $input = BucketBasic::fromGetBucketStat($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // extend header & parameters + $request = new Models\GetBucketStatRequest( + 'bucket-123', + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromGetBucketStat($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToGetBucketStat() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toGetBucketStat($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketStat($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->storage); + $this->assertNull($result->objectCount); + $this->assertNull($result->multipartUploadCount); + $this->assertNull($result->liveChannelCount); + $this->assertNull($result->lastModifiedTime); + $this->assertNull($result->standardStorage); + $this->assertNull($result->standardObjectCount); + $this->assertNull($result->infrequentAccessStorage); + $this->assertNull($result->infrequentAccessRealStorage); + $this->assertNull($result->infrequentAccessObjectCount); + $this->assertNull($result->archiveStorage); + $this->assertNull($result->archiveRealStorage); + $this->assertNull($result->archiveObjectCount); + $this->assertNull($result->coldArchiveStorage); + $this->assertNull($result->coldArchiveRealStorage); + $this->assertNull($result->coldArchiveObjectCount); + $this->assertNull($result->deepColdArchiveStorage); + $this->assertNull($result->deepColdArchiveRealStorage); + $this->assertNull($result->deepColdArchiveObjectCount); + $this->assertNull($result->deleteMarkerCount); + + // xml + $str = ' + + 1600 + 230 + 40 + 4 + 1643341269 + 430 + 66 + 2359296 + 360 + 54 + 2949120 + 450 + 74 + 2359296 + 360 + 36 + 235929 + 30 + 361 + 1361 + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketStat($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(1600, $result->storage); + $this->assertEquals(230, $result->objectCount); + $this->assertEquals(40, $result->multipartUploadCount); + $this->assertEquals(4, $result->liveChannelCount); + $this->assertEquals(1643341269, $result->lastModifiedTime); + $this->assertEquals(430, $result->standardStorage); + $this->assertEquals(66, $result->standardObjectCount); + $this->assertEquals(2359296, $result->infrequentAccessStorage); + $this->assertEquals(360, $result->infrequentAccessRealStorage); + $this->assertEquals(54, $result->infrequentAccessObjectCount); + $this->assertEquals(2949120, $result->archiveStorage); + $this->assertEquals(450, $result->archiveRealStorage); + $this->assertEquals(74, $result->archiveObjectCount); + $this->assertEquals(2359296, $result->coldArchiveStorage); + $this->assertEquals(360, $result->coldArchiveRealStorage); + $this->assertEquals(36, $result->coldArchiveObjectCount); + $this->assertEquals(235929, $result->deepColdArchiveStorage); + $this->assertEquals(30, $result->deepColdArchiveRealStorage); + $this->assertEquals(361, $result->deepColdArchiveObjectCount); + $this->assertEquals(1361, $result->deleteMarkerCount); + + // xml + $str = ' + + + + + + + + + + + + + + + + + + + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketStat($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(0, $result->storage); + $this->assertEquals(0, $result->objectCount); + $this->assertEquals(0, $result->multipartUploadCount); + $this->assertEquals(0, $result->liveChannelCount); + $this->assertEquals(0, $result->lastModifiedTime); + $this->assertEquals(0, $result->standardStorage); + $this->assertEquals(0, $result->standardObjectCount); + $this->assertEquals(0, $result->infrequentAccessStorage); + $this->assertEquals(0, $result->infrequentAccessRealStorage); + $this->assertEquals(0, $result->infrequentAccessObjectCount); + $this->assertEquals(0, $result->archiveStorage); + $this->assertEquals(0, $result->archiveRealStorage); + $this->assertEquals(0, $result->archiveObjectCount); + $this->assertEquals(0, $result->coldArchiveStorage); + $this->assertEquals(0, $result->coldArchiveRealStorage); + $this->assertEquals(0, $result->coldArchiveObjectCount); + $this->assertEquals(0, $result->deepColdArchiveStorage); + $this->assertEquals(0, $result->deepColdArchiveRealStorage); + $this->assertEquals(0, $result->deepColdArchiveObjectCount); + $this->assertEquals(0, $result->deleteMarkerCount); + } + + public function testFromGetBucketVersioning() + { + // miss required field + try { + $request = new Models\GetBucketVersioningRequest(); + $input = BucketBasic::fromGetBucketVersioning($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\GetBucketVersioningRequest('bucket-123'); + $input = BucketBasic::fromGetBucketVersioning($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // extend header & parameters + $request = new Models\GetBucketVersioningRequest( + 'bucket-123', + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromGetBucketVersioning($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToGetBucketVersioning() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toGetBucketVersioning($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketVersioning($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNotNull($result->versioningConfiguration); + $this->assertNull($result->versioningConfiguration->status); + + // xml + $str = ' + + Enabled + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketVersioning($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(Models\BucketVersioningStatusType::ENABLED, $result->versioningConfiguration->status); + + + // xml + $str = ' + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketVersioning($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('', $result->versioningConfiguration->status); + } + + public function testFromPutBucketVersioning() + { + // miss required field + try { + $request = new Models\PutBucketVersioningRequest(); + $input = BucketBasic::fromPutBucketVersioning($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\PutBucketVersioningRequest('bucket-123'); + $input = BucketBasic::fromPutBucketVersioning($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // all settings + $request = new Models\PutBucketVersioningRequest( + 'bucket-123', + new Models\VersioningConfiguration('Enabled'), + ); + $input = BucketBasic::fromPutBucketVersioning($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $str = $input->getBody()->getContents(); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals(base64_encode(md5($str, true)), $input->getHeaders()['content-md5']); + $createXml = <<Enabled +BBB; + $this->assertEquals($createXml, $this->cleanXml($str)); + + $this->assertStringContainsString('', $str); + $xml = \simplexml_load_string($str); + $this->assertEquals(1, $xml->count()); + $this->assertEquals('Enabled', $xml->Status); + + // extend header & parameters + $request = new Models\PutBucketVersioningRequest( + 'bucket-123', + null, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromPutBucketVersioning($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToPutBucketVersioning() + { + // empty output + $output = new OperationOutput(); + $result = BucketBasic::toPutBucketVersioning($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'] + ); + $result = BucketBasic::toPutBucketVersioning($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromPutBucketAcl() + { + // miss required field + try { + $request = new Models\PutBucketAclRequest(); + $input = BucketBasic::fromPutBucketAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + try { + $request = new Models\PutBucketAclRequest('bucket-123'); + $input = BucketBasic::fromPutBucketAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, acl", (string)$e); + } + + // all settings + $request = new Models\PutBucketAclRequest( + 'bucket-123', + Models\BucketACLType::PRIVATE, + ); + $input = BucketBasic::fromPutBucketAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals(Models\BucketACLType::PRIVATE, $input->getHeaders()['x-oss-acl']); + + // extend header & parameters + $request = new Models\PutBucketAclRequest( + 'bucket-123', + Models\BucketACLType::PUBLIC_READ, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromPutBucketAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + $this->assertEquals(Models\BucketACLType::PUBLIC_READ, $input->getHeaders()['x-oss-acl']); + } + + public function testToPutBucketAcl() + { + // empty output + $output = new OperationOutput(); + $result = BucketBasic::toPutBucketAcl($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'] + ); + $result = BucketBasic::toPutBucketAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketAcl() + { + // miss required field + try { + $request = new Models\GetBucketAclRequest(); + $input = BucketBasic::fromGetBucketAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\GetBucketAclRequest('bucket-123'); + $input = BucketBasic::fromGetBucketAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // extend header & parameters + $request = new Models\GetBucketAclRequest( + 'bucket-123', + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromGetBucketAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToGetBucketAcl() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toGetBucketAcl($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->owner); + $this->assertNull($result->accessControlList); + + // xml + $str = ' + + + 0022012**** + user_example + + + public-read + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('0022012****', $result->owner->id); + $this->assertEquals('user_example', $result->owner->displayName); + $this->assertEquals(Models\BucketACLType::PUBLIC_READ, $result->accessControlList->grant); + + + // xml + $str = ' + + + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toGetBucketAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->owner->id); + $this->assertNull($result->owner->displayName); + $this->assertNull($result->accessControlList->grant); + } + + public function testFromListObjects() + { + // miss required field + try { + $request = new Models\ListObjectsRequest(); + $input = BucketBasic::fromListObjects($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\ListObjectsRequest('bucket-123'); + $input = BucketBasic::fromListObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // all settings + $request = new Models\ListObjectsRequest( + 'bucket-123', + 'deli-123', + 'url', + 'marker-123', + 123, + 'prefix-123', + 'requester' + ); + $input = BucketBasic::fromListObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('deli-123', $input->getParameters()['delimiter']); + $this->assertEquals('marker-123', $input->getParameters()['marker']); + $this->assertEquals('url', $input->getParameters()['encoding-type']); + $this->assertEquals('123', $input->getParameters()['max-keys']); + $this->assertEquals('prefix-123', $input->getParameters()['prefix']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + // extend header & parameters + $request = new Models\ListObjectsRequest( + 'bucket-123', + null, + null, + null, + null, + null, + null, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromListObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToListObjects() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toListObjects($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->name); + $this->assertNull($result->prefix); + $this->assertNull($result->marker); + $this->assertNull($result->maxKeys); + $this->assertNull($result->delimiter); + $this->assertNull($result->isTruncated); + $this->assertNull($result->encodingType); + $this->assertNull($result->nextMarker); + $this->assertNull($result->contents); + $this->assertNull($result->commonPrefixes); + + // xml + $str = ' + + examplebucket + fun/ + fu + 2 + / + true + fun/test-1.jpg + + fun/test.jpg + 2023-12-17T03:30:09.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344606 + Standard + + 0022012**** + user_example + + ongoing-request="true" + + + fun/test-1.jpg + 2023-12-17T03:30:19.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344605 + IA + + + + + fun/movie/ + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $datetimeUtc1 = new \DateTime(); + $datetimeUtc1->setTimestamp(1702783819); + $result = BucketBasic::toListObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('examplebucket', $result->name); + $this->assertEquals('fun/', $result->prefix); + $this->assertEquals('fu', $result->marker); + $this->assertEquals(2, $result->maxKeys); + $this->assertEquals('/', $result->delimiter); + $this->assertEquals(true, $result->isTruncated); + $this->assertNull($result->encodingType); + $this->assertEquals('fun/test-1.jpg', $result->nextMarker); + $this->assertEquals(2, count($result->contents)); + $this->assertEquals('fun/test.jpg', $result->contents[0]->key); + $this->assertEquals($datetimeUtc, $result->contents[0]->lastModified); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5A0FE1****"', $result->contents[0]->etag); + $this->assertEquals('Normal', $result->contents[0]->type); + $this->assertEquals(344606, $result->contents[0]->size); + $this->assertEquals('Standard', $result->contents[0]->storageClass); + $this->assertEquals('0022012****', $result->contents[0]->owner->id); + $this->assertEquals('user_example', $result->contents[0]->owner->displayName); + $this->assertEquals('ongoing-request="true"', $result->contents[0]->restoreInfo); + + $this->assertEquals('fun/test-1.jpg', $result->contents[1]->key); + $this->assertEquals($datetimeUtc1, $result->contents[1]->lastModified); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5A0FE1****"', $result->contents[1]->etag); + $this->assertEquals('Normal', $result->contents[1]->type); + $this->assertEquals(344605, $result->contents[1]->size); + $this->assertEquals('IA', $result->contents[1]->storageClass); + $this->assertNull($result->contents[1]->owner->id); + $this->assertNull($result->contents[1]->owner->displayName); + + $this->assertEquals(1, count($result->commonPrefixes)); + $this->assertEquals('fun/movie/', $result->commonPrefixes[0]->prefix); + + // encodingType + $str = ' + + examplebucket + fun%2F + fun%2F + 1 + %2F + false + fun%2Ftest-1.jpg + url + + fun%2Ftest.jpg + 2023-12-17T03:30:09.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344606 + Standard + + + + + 2023-12-17T03:30:19.000Z + + + fun%2Fmovie%2F + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('examplebucket', $result->name); + $this->assertEquals('fun/', $result->prefix); + $this->assertEquals('fun/', $result->marker); + $this->assertEquals(1, $result->maxKeys); + $this->assertEquals('/', $result->delimiter); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals('url', $result->encodingType); + $this->assertEquals('fun/test-1.jpg', $result->nextMarker); + $this->assertEquals(1, count($result->contents)); + $this->assertEquals('fun/test.jpg', $result->contents[0]->key); + $this->assertEquals('', $result->contents[0]->owner->id); + $this->assertEquals('', $result->contents[0]->owner->displayName); + $this->assertEquals($datetimeUtc1, $result->contents[0]->transitionTime); + $this->assertEquals(1, count($result->commonPrefixes)); + $this->assertEquals('fun/movie/', $result->commonPrefixes[0]->prefix); + + // xml + $str = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $datetimeUtc1 = new \DateTime(); + $datetimeUtc1->setTimestamp(1702783819); + $result = BucketBasic::toListObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('', $result->name); + $this->assertEquals('', $result->prefix); + $this->assertEquals('', $result->marker); + $this->assertEquals(0, $result->maxKeys); + $this->assertEquals('', $result->delimiter); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals('', $result->encodingType); + $this->assertEquals('', $result->nextMarker); + $this->assertEquals(1, count($result->contents)); + $this->assertEquals('', $result->contents[0]->key); + $this->assertNull($result->contents[0]->lastModified); + $this->assertEquals('', $result->contents[0]->etag); + $this->assertEquals('', $result->contents[0]->type); + $this->assertEquals(0, $result->contents[0]->size); + $this->assertEquals('', $result->contents[0]->storageClass); + $this->assertEquals('', $result->contents[0]->owner->id); + $this->assertEquals('', $result->contents[0]->owner->displayName); + $this->assertEquals(2, count($result->commonPrefixes)); + $this->assertEquals('', $result->commonPrefixes[0]->prefix); + $this->assertEquals('', $result->commonPrefixes[1]->prefix); + } + + public function testFromListObjectsV2() + { + // miss required field + try { + $request = new Models\ListObjectsV2Request(); + $input = BucketBasic::fromListObjectsV2($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\ListObjectsV2Request('bucket-123'); + $input = BucketBasic::fromListObjectsV2($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // all settings + $request = new Models\ListObjectsV2Request( + 'bucket-123', + 'deli-123', + 'url', + 'start-after-123', + 'token-123', + 123, + 'prefix-123', + 'requester', + true, + ); + $input = BucketBasic::fromListObjectsV2($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('2', $input->getParameters()['list-type']); + $this->assertEquals('deli-123', $input->getParameters()['delimiter']); + $this->assertEquals('url', $input->getParameters()['encoding-type']); + $this->assertEquals('start-after-123', $input->getParameters()['start-after']); + $this->assertEquals('token-123', $input->getParameters()['continuation-token']); + $this->assertEquals('123', $input->getParameters()['max-keys']); + $this->assertEquals('prefix-123', $input->getParameters()['prefix']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals('true', $input->getParameters()['fetch-owner']); + + // extend header & parameters + $request = new Models\ListObjectsV2Request( + 'bucket-123', + null, + null, + null, + null, + null, + null, + null, + null, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromListObjectsV2($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToListObjectsV2() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toListObjectsV2($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListObjectsV2($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->name); + $this->assertNull($result->prefix); + $this->assertNull($result->startAfter); + $this->assertNull($result->continuationToken); + $this->assertNull($result->maxKeys); + $this->assertNull($result->delimiter); + $this->assertNull($result->isTruncated); + $this->assertNull($result->encodingType); + $this->assertNull($result->nextContinuationToken); + $this->assertNull($result->keyCount); + $this->assertNull($result->contents); + $this->assertNull($result->commonPrefixes); + + // xml + $str = ' + + examplebucket + fun/ + fu + AgJiYw-- + 2 + / + true + CgJiYw-- + + fun/test.jpg + 2023-12-17T03:30:09.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344606 + Standard + + 0022012**** + user_example + + ongoing-request="true" + + + fun/test-1.jpg + 2023-12-17T03:30:19.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344605 + IA + + + + + fun/movie/ + + 3 + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $datetimeUtc1 = new \DateTime(); + $datetimeUtc1->setTimestamp(1702783819); + $result = BucketBasic::toListObjectsV2($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('examplebucket', $result->name); + $this->assertEquals('fun/', $result->prefix); + $this->assertEquals('fu', $result->startAfter); + $this->assertEquals('AgJiYw--', $result->continuationToken); + $this->assertEquals(2, $result->maxKeys); + $this->assertEquals('/', $result->delimiter); + $this->assertEquals(true, $result->isTruncated); + $this->assertNull($result->encodingType); + $this->assertEquals('CgJiYw--', $result->nextContinuationToken); + $this->assertEquals(3, $result->keyCount); + $this->assertEquals(2, count($result->contents)); + $this->assertEquals('fun/test.jpg', $result->contents[0]->key); + $this->assertEquals($datetimeUtc, $result->contents[0]->lastModified); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5A0FE1****"', $result->contents[0]->etag); + $this->assertEquals('Normal', $result->contents[0]->type); + $this->assertEquals(344606, $result->contents[0]->size); + $this->assertEquals('Standard', $result->contents[0]->storageClass); + $this->assertEquals('0022012****', $result->contents[0]->owner->id); + $this->assertEquals('user_example', $result->contents[0]->owner->displayName); + $this->assertEquals('ongoing-request="true"', $result->contents[0]->restoreInfo); + + $this->assertEquals('fun/test-1.jpg', $result->contents[1]->key); + $this->assertEquals($datetimeUtc1, $result->contents[1]->lastModified); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5A0FE1****"', $result->contents[1]->etag); + $this->assertEquals('Normal', $result->contents[1]->type); + $this->assertEquals(344605, $result->contents[1]->size); + $this->assertEquals('IA', $result->contents[1]->storageClass); + $this->assertNull($result->contents[1]->owner->id); + $this->assertNull($result->contents[1]->owner->displayName); + + $this->assertEquals(1, count($result->commonPrefixes)); + $this->assertEquals('fun/movie/', $result->commonPrefixes[0]->prefix); + + // encodingType + $str = ' + + examplebucket + fun%2F + fun%2F + fun%2F + 1 + %2F + false + fun%2Ftest-1.jpg + url + + fun%2Ftest.jpg + 2023-12-17T03:30:09.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344606 + Standard + + + + + 2023-12-17T03:30:19.000Z + + + fun%2Fmovie%2F + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListObjectsV2($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('examplebucket', $result->name); + $this->assertEquals('fun/', $result->prefix); + $this->assertEquals('fun/', $result->startAfter); + $this->assertEquals('fun/', $result->continuationToken); + $this->assertEquals(1, $result->maxKeys); + $this->assertEquals('/', $result->delimiter); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals('url', $result->encodingType); + $this->assertEquals('fun/test-1.jpg', $result->nextContinuationToken); + $this->assertEquals(1, count($result->contents)); + $this->assertEquals('fun/test.jpg', $result->contents[0]->key); + $this->assertEquals('', $result->contents[0]->owner->id); + $this->assertEquals('', $result->contents[0]->owner->displayName); + $this->assertEquals($datetimeUtc1, $result->contents[0]->transitionTime); + $this->assertEquals(1, count($result->commonPrefixes)); + $this->assertEquals('fun/movie/', $result->commonPrefixes[0]->prefix); + + // xml + $str = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $datetimeUtc1 = new \DateTime(); + $datetimeUtc1->setTimestamp(1702783819); + $result = BucketBasic::toListObjectsV2($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('', $result->name); + $this->assertEquals('', $result->prefix); + $this->assertEquals('', $result->startAfter); + $this->assertEquals('', $result->continuationToken); + $this->assertEquals(0, $result->maxKeys); + $this->assertEquals('', $result->delimiter); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals('', $result->encodingType); + $this->assertEquals('', $result->nextContinuationToken); + $this->assertEquals(0, $result->keyCount); + $this->assertEquals(1, count($result->contents)); + $this->assertEquals('', $result->contents[0]->key); + $this->assertNull($result->contents[0]->lastModified); + $this->assertEquals('', $result->contents[0]->etag); + $this->assertEquals('', $result->contents[0]->type); + $this->assertEquals(0, $result->contents[0]->size); + $this->assertEquals('', $result->contents[0]->storageClass); + $this->assertEquals('', $result->contents[0]->owner->id); + $this->assertEquals('', $result->contents[0]->owner->displayName); + $this->assertEquals(2, count($result->commonPrefixes)); + $this->assertEquals('', $result->commonPrefixes[0]->prefix); + $this->assertEquals('', $result->commonPrefixes[1]->prefix); + } + + public function testFromListObjectVersions() + { + // miss required field + try { + $request = new Models\ListObjectVersionsRequest(); + $input = BucketBasic::fromListObjectVersions($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + $request = new Models\ListObjectVersionsRequest('bucket-123'); + $input = BucketBasic::fromListObjectVersions($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + // all settings + $request = new Models\ListObjectVersionsRequest( + 'bucket-123', + 'deli-123', + 'url', + 'key-marker-123', + 'version-id-marker-123', + 123, + 'prefix-123', + 'requester' + ); + $input = BucketBasic::fromListObjectVersions($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('', $input->getParameters()['versions']); + $this->assertEquals('deli-123', $input->getParameters()['delimiter']); + $this->assertEquals('url', $input->getParameters()['encoding-type']); + $this->assertEquals('key-marker-123', $input->getParameters()['key-marker']); + $this->assertEquals('version-id-marker-123', $input->getParameters()['version-id-marker']); + $this->assertEquals('123', $input->getParameters()['max-keys']); + $this->assertEquals('prefix-123', $input->getParameters()['prefix']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + // extend header & parameters + $request = new Models\ListObjectVersionsRequest( + 'bucket-123', + null, + null, + null, + null, + null, + null, + null, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ] + ); + $input = BucketBasic::fromListObjectVersions($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/octet-stream', $input->getHeaders()['content-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + } + + public function testToListObjectVersions() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toListObjectVersions($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListObjectVersions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->name); + $this->assertNull($result->prefix); + $this->assertNull($result->keyMarker); + $this->assertNull($result->versionIdMarker); + $this->assertNull($result->maxKeys); + $this->assertNull($result->delimiter); + $this->assertNull($result->isTruncated); + $this->assertNull($result->encodingType); + $this->assertNull($result->nextKeyMarker); + $this->assertNull($result->nextVersionIdMarker); + $this->assertNull($result->versions); + $this->assertNull($result->deleteMarkers); + $this->assertNull($result->commonPrefixes); + + // xml + $str = ' + + examplebucket + fun/ + fu + AgJiYw-- + 2 + / + true + fu123 + AgJiYw--123 + + fun/test.jpg + id-123 + true + 2023-12-17T03:30:09.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344606 + Standard + + 0022012**** + user_example + + ongoing-request="true" + + + example + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + false + 2023-12-17T03:30:19.000Z + + 1234512528586**** + 12345125285864390 + + + + fun/test-1.jpg + 2023-12-17T03:30:19.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344605 + IA + + + + + fun/movie/ + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $datetimeUtc1 = new \DateTime(); + $datetimeUtc1->setTimestamp(1702783819); + $result = BucketBasic::toListObjectVersions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('examplebucket', $result->name); + $this->assertEquals('fun/', $result->prefix); + $this->assertEquals('fu', $result->keyMarker); + $this->assertEquals('AgJiYw--', $result->versionIdMarker); + $this->assertEquals(2, $result->maxKeys); + $this->assertEquals('/', $result->delimiter); + $this->assertEquals(true, $result->isTruncated); + $this->assertNull($result->encodingType); + $this->assertEquals('fu123', $result->nextKeyMarker); + $this->assertEquals('AgJiYw--123', $result->nextVersionIdMarker); + $this->assertEquals(2, count($result->versions)); + $this->assertEquals('fun/test.jpg', $result->versions[0]->key); + $this->assertEquals('id-123', $result->versions[0]->versionId); + $this->assertEquals(true, $result->versions[0]->isLatest); + $this->assertEquals($datetimeUtc, $result->versions[0]->lastModified); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5A0FE1****"', $result->versions[0]->etag); + $this->assertEquals('Normal', $result->versions[0]->type); + $this->assertEquals(344606, $result->versions[0]->size); + $this->assertEquals('Standard', $result->versions[0]->storageClass); + $this->assertEquals('0022012****', $result->versions[0]->owner->id); + $this->assertEquals('user_example', $result->versions[0]->owner->displayName); + $this->assertEquals('ongoing-request="true"', $result->versions[0]->restoreInfo); + + $this->assertEquals('fun/test-1.jpg', $result->versions[1]->key); + $this->assertNull($result->versions[1]->versionId); + $this->assertNull($result->versions[1]->isLatest); + $this->assertEquals($datetimeUtc1, $result->versions[1]->lastModified); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5A0FE1****"', $result->versions[1]->etag); + $this->assertEquals('Normal', $result->versions[1]->type); + $this->assertEquals(344605, $result->versions[1]->size); + $this->assertEquals('IA', $result->versions[1]->storageClass); + $this->assertNull($result->versions[1]->owner->id); + $this->assertNull($result->versions[1]->owner->displayName); + + $this->assertEquals(1, count($result->deleteMarkers)); + $this->assertEquals('example', $result->deleteMarkers[0]->key); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $result->deleteMarkers[0]->versionId); + $this->assertEquals(false, $result->deleteMarkers[0]->isLatest); + $this->assertEquals($datetimeUtc1, $result->deleteMarkers[0]->lastModified); + $this->assertEquals('1234512528586****', $result->deleteMarkers[0]->owner->id); + $this->assertEquals('12345125285864390', $result->deleteMarkers[0]->owner->displayName); + + $this->assertEquals(1, count($result->commonPrefixes)); + $this->assertEquals('fun/movie/', $result->commonPrefixes[0]->prefix); + + // encodingType + $str = ' + + examplebucket + fun%2F + fun%2F + AgJiYw-- + 1 + %2F + false + fun%2Ftest-1.jpg + AgJiYw--123 + url + + fun%2Ftest.jpg + 2023-12-17T03:30:09.000Z + "5B3C1A2E053D763E1B002CC607C5A0FE1****" + Normal + 344606 + Standard + + + + + 2023-12-17T03:30:19.000Z + + + example%2F123 + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + false + 2023-12-17T03:30:19.000Z + + 1234512528586**** + 12345125285864390 + + + + fun%2Fmovie%2F + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListObjectVersions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('examplebucket', $result->name); + $this->assertEquals('fun/', $result->prefix); + $this->assertEquals('fun/', $result->keyMarker); + $this->assertEquals('AgJiYw--', $result->versionIdMarker); + $this->assertEquals(1, $result->maxKeys); + $this->assertEquals('/', $result->delimiter); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals('url', $result->encodingType); + $this->assertEquals('fun/test-1.jpg', $result->nextKeyMarker); + $this->assertEquals('AgJiYw--123', $result->nextVersionIdMarker); + $this->assertEquals(1, count($result->versions)); + $this->assertEquals('fun/test.jpg', $result->versions[0]->key); + $this->assertEquals('', $result->versions[0]->owner->id); + $this->assertEquals('', $result->versions[0]->owner->displayName); + $this->assertEquals(1, count($result->deleteMarkers)); + $this->assertEquals('example/123', $result->deleteMarkers[0]->key); + $this->assertEquals(1, count($result->commonPrefixes)); + $this->assertEquals('fun/movie/', $result->commonPrefixes[0]->prefix); + + // xml + $str = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $datetimeUtc1 = new \DateTime(); + $datetimeUtc1->setTimestamp(1702783819); + $result = BucketBasic::toListObjectVersions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('', $result->name); + $this->assertEquals('', $result->prefix); + $this->assertEquals('', $result->keyMarker); + $this->assertEquals('', $result->versionIdMarker); + $this->assertEquals(0, $result->maxKeys); + $this->assertEquals('', $result->delimiter); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals('', $result->encodingType); + $this->assertEquals('', $result->nextKeyMarker); + $this->assertEquals('', $result->nextVersionIdMarker); + $this->assertEquals(1, count($result->versions)); + $this->assertEquals('', $result->versions[0]->key); + $this->assertEquals('', $result->versions[0]->versionId); + $this->assertEquals(false, $result->versions[0]->isLatest); + $this->assertNull($result->versions[0]->lastModified); + $this->assertEquals('', $result->versions[0]->etag); + $this->assertEquals('', $result->versions[0]->type); + $this->assertEquals(0, $result->versions[0]->size); + $this->assertEquals('', $result->versions[0]->storageClass); + $this->assertEquals('', $result->versions[0]->owner->id); + $this->assertEquals('', $result->versions[0]->owner->displayName); + + $this->assertEquals(2, count($result->deleteMarkers)); + $this->assertEquals('', $result->deleteMarkers[0]->key); + $this->assertEquals('', $result->deleteMarkers[0]->versionId); + $this->assertEquals(false, $result->deleteMarkers[0]->isLatest); + $this->assertNull($result->deleteMarkers[0]->lastModified); + $this->assertEquals('', $result->deleteMarkers[0]->owner->id); + $this->assertEquals('', $result->deleteMarkers[0]->owner->displayName); + + $this->assertEquals('', $result->deleteMarkers[1]->key); + $this->assertEquals('', $result->deleteMarkers[1]->versionId); + $this->assertEquals(false, $result->deleteMarkers[1]->isLatest); + + $this->assertEquals(2, count($result->commonPrefixes)); + $this->assertEquals('', $result->commonPrefixes[0]->prefix); + $this->assertEquals('', $result->commonPrefixes[1]->prefix); + } + + public function testFromListBuckets() + { + // miss required field + try { + $request = new Models\ListBucketsRequest(); + $input = BucketBasic::fromListBuckets($request); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, 'should not here'); + } + + $request = new Models\ListBucketsRequest('/', '', 10,'rg-aek27tc********'); + $input = BucketBasic::fromListBuckets($request); + $this->assertEquals('rg-aek27tc********', $input->getHeaders()['x-oss-resource-group-id']); + $this->assertEquals('', $input->getParameters()['marker']); + $this->assertEquals('/', $input->getParameters()['prefix']); + $this->assertEquals('10', $input->getParameters()['max-keys']); + + $request = new Models\ListBucketsRequest('/', '', 10,'rg-aek27tc********','k','v'); + $input = BucketBasic::fromListBuckets($request); + $this->assertEquals('rg-aek27tc********', $input->getHeaders()['x-oss-resource-group-id']); + $this->assertEquals('', $input->getParameters()['marker']); + $this->assertEquals('/', $input->getParameters()['prefix']); + $this->assertEquals('10', $input->getParameters()['max-keys']); + $this->assertEquals('k', $input->getParameters()['tag-key']); + $this->assertEquals('v', $input->getParameters()['tag-value']); + + $request = new Models\ListBucketsRequest('/', '', 10,'rg-aek27tc********',null,null,"\"k\":\"v\""); + $input = BucketBasic::fromListBuckets($request); + $this->assertEquals('rg-aek27tc********', $input->getHeaders()['x-oss-resource-group-id']); + $this->assertEquals('', $input->getParameters()['marker']); + $this->assertEquals('/', $input->getParameters()['prefix']); + $this->assertEquals('10', $input->getParameters()['max-keys']); + $this->assertEquals("\"k\":\"v\"", $input->getParameters()['tagging']); + } + + public function testToListBuckets() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toListBuckets($output); + $this->assertTrue(false, 'should not here'); + } catch (DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListBuckets($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->prefix); + $this->assertNull($result->marker); + $this->assertNull($result->maxKeys); + $this->assertNull($result->isTruncated); + $this->assertNull($result->nextMarker); + $this->assertNull($result->owner); + $this->assertNull($result->buckets); + + // xml + $str = ' + + + 51264 + 51264 + + + + 2014-02-17T18:12:43.000Z + oss-cn-shanghai.aliyuncs.com + oss-cn-shanghai-internal.aliyuncs.com + oss-cn-shanghai + app-base-oss + cn-shanghai + Standard + + + 2014-02-25T11:21:04.000Z + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-cn-hangzhou + mybucket + cn-hangzhou + IA + + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListBuckets($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('51264', $result->owner->displayName); + $this->assertEquals('51264', $result->owner->id); + $this->assertEquals(2, count($result->buckets)); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2014-02-17T18:12:43.000Z', + new \DateTimeZone('UTC') + ), $result->buckets[0]->creationDate); + $this->assertEquals('oss-cn-shanghai.aliyuncs.com', $result->buckets[0]->extranetEndpoint); + $this->assertEquals('oss-cn-shanghai-internal.aliyuncs.com', $result->buckets[0]->intranetEndpoint); + $this->assertEquals('app-base-oss', $result->buckets[0]->name); + $this->assertEquals('cn-shanghai', $result->buckets[0]->region); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->buckets[0]->storageClass); + $this->assertEquals('oss-cn-shanghai', $result->buckets[0]->location); + + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2014-02-25T11:21:04.000Z', + new \DateTimeZone('UTC') + ), $result->buckets[1]->creationDate); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $result->buckets[1]->extranetEndpoint); + $this->assertEquals('oss-cn-hangzhou-internal.aliyuncs.com', $result->buckets[1]->intranetEndpoint); + $this->assertEquals('mybucket', $result->buckets[1]->name); + $this->assertEquals('cn-hangzhou', $result->buckets[1]->region); + $this->assertEquals(Models\StorageClassType::IA, $result->buckets[1]->storageClass); + $this->assertEquals('oss-cn-hangzhou', $result->buckets[1]->location); + + $str = ' + + my + mybucket + 10 + true + mybucket10 + + ut_test_put_bucket + ut_test_put_bucket + + + + 2014-05-14T11:18:32.000Z + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-cn-hangzhou + mybucket01 + cn-hangzhou + Standard + rg-aek27tc******** + + + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str) + ); + $result = BucketBasic::toListBuckets($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('ut_test_put_bucket', $result->owner->displayName); + $this->assertEquals('ut_test_put_bucket', $result->owner->id); + $this->assertEquals('my', $result->prefix); + $this->assertEquals('mybucket', $result->marker); + $this->assertEquals(10, $result->maxKeys); + $this->assertTrue($result->isTruncated); + $this->assertEquals('mybucket10', $result->nextMarker); + $this->assertEquals(1, count($result->buckets)); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2014-05-14T11:18:32.000Z', + new \DateTimeZone('UTC') + ), $result->buckets[0]->creationDate); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $result->buckets[0]->extranetEndpoint); + $this->assertEquals('oss-cn-hangzhou-internal.aliyuncs.com', $result->buckets[0]->intranetEndpoint); + $this->assertEquals('mybucket01', $result->buckets[0]->name); + $this->assertEquals('cn-hangzhou', $result->buckets[0]->region); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->buckets[0]->storageClass); + $this->assertEquals('oss-cn-hangzhou', $result->buckets[0]->location); + $this->assertEquals('rg-aek27tc********', $result->buckets[0]->resourceGroupId); + } + + public function testFromDescribeRegions() + { + // miss required field + try { + $request = new Models\DescribeRegionsRequest(); + $input = BucketBasic::fromDescribeRegions($request); + $this->assertEquals('', $input->getParameters()['regions']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, 'should not here'); + } + + $request = new Models\DescribeRegionsRequest("oss-cn-hangzhou"); + $input = BucketBasic::fromDescribeRegions($request); + $this->assertEquals('oss-cn-hangzhou', $input->getParameters()['regions']); + } + + public function testToDescribeRegions() + { + // empty output + try { + $output = new OperationOutput(); + $result = BucketBasic::toDescribeRegions($output); + $this->assertTrue(false, 'should not here'); + } catch (DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = BucketBasic::toDescribeRegions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->regionInfos); + + // xml + $str = ' + + + oss-cn-hangzhou + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-accelerate.aliyuncs.com + + + oss-cn-shanghai + oss-cn-shanghai.aliyuncs.com + oss-cn-shanghai-internal.aliyuncs.com + oss-accelerate.aliyuncs.com + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str) + ); + $result = BucketBasic::toDescribeRegions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(2, count($result->regionInfos)); + $this->assertEquals('oss-cn-hangzhou', $result->regionInfos[0]->region); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $result->regionInfos[0]->internetEndpoint); + $this->assertEquals('oss-cn-hangzhou-internal.aliyuncs.com', $result->regionInfos[0]->internalEndpoint); + $this->assertEquals('oss-accelerate.aliyuncs.com', $result->regionInfos[0]->accelerateEndpoint); + + $this->assertEquals('oss-cn-shanghai', $result->regionInfos[1]->region); + $this->assertEquals('oss-cn-shanghai.aliyuncs.com', $result->regionInfos[1]->internetEndpoint); + $this->assertEquals('oss-cn-shanghai-internal.aliyuncs.com', $result->regionInfos[1]->internalEndpoint); + $this->assertEquals('oss-accelerate.aliyuncs.com', $result->regionInfos[1]->accelerateEndpoint); + + $str = ' + + + oss-cn-hangzhou + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-accelerate.aliyuncs.com + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str) + ); + $result = BucketBasic::toDescribeRegions($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->regionInfos)); + $this->assertEquals('oss-cn-hangzhou', $result->regionInfos[0]->region); + $this->assertEquals('oss-cn-hangzhou.aliyuncs.com', $result->regionInfos[0]->internetEndpoint); + $this->assertEquals('oss-cn-hangzhou-internal.aliyuncs.com', $result->regionInfos[0]->internalEndpoint); + $this->assertEquals('oss-accelerate.aliyuncs.com', $result->regionInfos[0]->accelerateEndpoint); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCnameTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCnameTest.php new file mode 100644 index 0000000..0cbc5f0 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCnameTest.php @@ -0,0 +1,377 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutCnameRequest('bucket-123'); + $input = BucketCname::fromPutCname($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucketCnameConfiguration", (string)$e); + } + + $request = new Models\PutCnameRequest('bucket-123', new Models\BucketCnameConfiguration( + new Models\Cname( + domain: 'example.com' + ) + )); + $input = BucketCname::fromPutCname($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<example.com +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\PutCnameRequest('bucket-123', new Models\BucketCnameConfiguration( + new Models\Cname( + domain: 'example.com', + certificateConfiguration: new Models\CertificateConfiguration( + force: true, + certId: '493****-cn-hangzhou', + certificate: '-----BEGIN CERTIFICATE----- MIIDhDCCAmwCCQCFs8ixARsyrDANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMC **** -----END CERTIFICATE-----', + privateKey: '-----BEGIN CERTIFICATE----- MIIDhDCCAmwCCQCFs8ixARsyrDANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMC **** -----END CERTIFICATE-----', + previousCertId: '493****-cn-hangzhou' + ) + ) + )); + $input = BucketCname::fromPutCname($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<example.comtrue493****-cn-hangzhou-----BEGIN CERTIFICATE----- MIIDhDCCAmwCCQCFs8ixARsyrDANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMC **** -----END CERTIFICATE----------BEGIN CERTIFICATE----- MIIDhDCCAmwCCQCFs8ixARsyrDANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMC **** -----END CERTIFICATE-----493****-cn-hangzhou +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\PutCnameRequest('bucket-123', new Models\BucketCnameConfiguration( + new Models\Cname( + domain: 'example.com', + certificateConfiguration: new Models\CertificateConfiguration( + deleteCertificate: true, + ) + ) + )); + $input = BucketCname::fromPutCname($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<example.comtrue +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutCname() + { + // empty output + $output = new OperationOutput(); + $result = BucketCname::toPutCname($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketCname::toPutCname($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromCreateCnameToken() + { + // miss required field + try { + $request = new Models\CreateCnameTokenRequest(); + $input = BucketCname::fromCreateCnameToken($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CreateCnameTokenRequest('bucket-123'); + $input = BucketCname::fromCreateCnameToken($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucketCnameConfiguration", (string)$e); + } + + $request = new Models\CreateCnameTokenRequest('bucket-123', new Models\BucketCnameConfiguration( + new Models\Cname( + domain: 'example.com' + ) + )); + $input = BucketCname::fromCreateCnameToken($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<example.com +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToCreateCnameToken() + { + // empty output + $output = new OperationOutput(); + $result = BucketCname::toCreateCnameToken($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor(' + + bucket + example.com; + be1d49d863dea9ffeff3df7d6455**** + Wed, 23 Feb 2022 21:16:37 GMT +') + ); + $result = BucketCname::toCreateCnameToken($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('bucket', $result->cnameToken->bucket); + $this->assertEquals('example.com', $result->cnameToken->cname); + $this->assertEquals('be1d49d863dea9ffeff3df7d6455****', $result->cnameToken->token); + $this->assertEquals('Wed, 23 Feb 2022 21:16:37 GMT', $result->cnameToken->expireTime); + } + + public function testFromGetCnameToken() + { + // miss required field + try { + $request = new Models\GetCnameTokenRequest(); + $input = BucketCname::fromGetCnameToken($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetCnameTokenRequest('bucket-123'); + $input = BucketCname::fromGetCnameToken($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, cname", (string)$e); + } + + $request = new Models\GetCnameTokenRequest('bucket-123', 'example.com'); + $input = BucketCname::fromGetCnameToken($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('example.com', $input->getParameters()['cname']); + } + + public function testToGetCnameToken() + { + // empty output + $output = new OperationOutput(); + $result = BucketCname::toGetCnameToken($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor(' + + bucket + example.com; + be1d49d863dea9ffeff3df7d6455**** + Wed, 23 Feb 2022 21:16:37 GMT +') + ); + $result = BucketCname::toGetCnameToken($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('bucket', $result->cnameToken->bucket); + $this->assertEquals('example.com', $result->cnameToken->cname); + $this->assertEquals('be1d49d863dea9ffeff3df7d6455****', $result->cnameToken->token); + $this->assertEquals('Wed, 23 Feb 2022 21:16:37 GMT', $result->cnameToken->expireTime); + } + + public function testFromListCname() + { + // miss required field + try { + $request = new Models\ListCnameRequest(); + $input = BucketCname::fromListCname($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\ListCnameRequest('bucket-123'); + $input = BucketCname::fromListCname($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToListCname() + { + // empty output + $output = new OperationOutput(); + $result = BucketCname::toListCname($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + bucket + owner + + example.com + 2021-09-15T02:35:07.000Z + Enabled + + CAS + 493****-cn-hangzhou + Enabled + Wed, 15 Sep 2021 02:35:06 GMT + DE:01:CF:EC:7C:A7:98:CB:D8:6E:FB:1D:97:EB:A9:64:1D:4E:**:** + Wed, 12 Apr 2023 10:14:51 GMT + Mon, 4 May 2048 10:14:51 GMT + + + + example.org + 2021-09-15T02:34:58.000Z + Enabled + + + example.edu + 2021-09-15T02:50:34.000Z + Enabled + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketCname::toListCname($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('bucket', $result->bucket); + $this->assertEquals('owner', $result->owner); + $this->assertEquals(3, count($result->cnames)); + $this->assertEquals('example.com', $result->cnames[0]->domain); + $this->assertEquals('2021-09-15T02:35:07.000Z', $result->cnames[0]->lastModified); + $this->assertEquals('Enabled', $result->cnames[0]->status); + $this->assertEquals('CAS', $result->cnames[0]->certificate->type); + $this->assertEquals('493****-cn-hangzhou', $result->cnames[0]->certificate->certId); + $this->assertEquals('Enabled', $result->cnames[0]->certificate->status); + $this->assertEquals('Wed, 15 Sep 2021 02:35:06 GMT', $result->cnames[0]->certificate->creationDate); + $this->assertEquals('DE:01:CF:EC:7C:A7:98:CB:D8:6E:FB:1D:97:EB:A9:64:1D:4E:**:**', $result->cnames[0]->certificate->fingerprint); + $this->assertEquals('Wed, 12 Apr 2023 10:14:51 GMT', $result->cnames[0]->certificate->validStartDate); + $this->assertEquals('Mon, 4 May 2048 10:14:51 GMT', $result->cnames[0]->certificate->validEndDate); + $this->assertEquals('example.org', $result->cnames[1]->domain); + $this->assertEquals('2021-09-15T02:34:58.000Z', $result->cnames[1]->lastModified); + $this->assertEquals('Enabled', $result->cnames[1]->status); + $this->assertEquals('example.edu', $result->cnames[2]->domain); + $this->assertEquals('2021-09-15T02:50:34.000Z', $result->cnames[2]->lastModified); + $this->assertEquals('Enabled', $result->cnames[2]->status); + } + + public function testFromDeleteCname() + { + // miss required field + try { + $request = new Models\DeleteCnameRequest(); + $input = BucketCname::fromDeleteCname($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteCnameRequest('bucket-123'); + $input = BucketCname::fromDeleteCname($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucketCnameConfiguration", (string)$e); + } + + $request = new Models\DeleteCnameRequest('bucket-123', new Models\BucketCnameConfiguration( + new Models\Cname( + domain: 'example.com' + ) + )); + $input = BucketCname::fromDeleteCname($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<example.com +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToDeleteCname() + { + // empty output + $output = new OperationOutput(); + $result = BucketCname::toDeleteCname($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + ); + $result = BucketCname::toDeleteCname($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCorsTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCorsTest.php new file mode 100644 index 0000000..fcf821f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketCorsTest.php @@ -0,0 +1,271 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketCorsRequest('bucket-123'); + $input = BucketCors::fromPutBucketCors($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, corsConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketCorsRequest('bucket-123', new Models\CORSConfiguration( + [ + new Models\CORSRule( + allowedHeaders: ['Authorization'], + allowedOrigins: ['*'], + allowedMethods: ['PUT', 'GET'] + ), + new Models\CORSRule( + allowedHeaders: ['Authorization'], + exposeHeaders: ["x-oss-test", "x-oss-test1"], + maxAgeSeconds: 100, + allowedOrigins: ["http://example.com", "http://example.net"], + allowedMethods: ['GET'], + ), + ], + responseVary: false + )); + $input = BucketCors::fromPutBucketCors($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<Authorization*PUTGETAuthorizationx-oss-testx-oss-test1100http://example.comhttp://example.netGETfalse +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketCors() + { + // empty output + $output = new OperationOutput(); + $result = BucketCors::toPutBucketCors($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketCors::toPutBucketCors($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketCors() + { + // miss required field + try { + $request = new Models\GetBucketCorsRequest(); + $input = BucketCors::fromGetBucketCors($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketCorsRequest('bucket-123'); + $input = BucketCors::fromGetBucketCors($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketCors() + { + // empty output + $output = new OperationOutput(); + $result = BucketCors::toGetBucketCors($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + * + PUT + GET + Authorization + + + http://example.com + http://example.net + GET + Authorization + x-oss-test + x-oss-test1 + 100 + + false +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketCors::toGetBucketCors($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(2, count($result->corsConfiguration->corsRules)); + $this->assertFalse($result->corsConfiguration->responseVary); + $this->assertEquals($result->corsConfiguration->corsRules[0]->allowedOrigins[0], '*'); + $this->assertEquals(count($result->corsConfiguration->corsRules[0]->allowedMethods), 2); + $this->assertEquals($result->corsConfiguration->corsRules[0]->allowedMethods[0], 'PUT'); + $this->assertEquals($result->corsConfiguration->corsRules[0]->allowedMethods[1], 'GET'); + $this->assertEquals(count($result->corsConfiguration->corsRules[0]->allowedHeaders), 1); + $this->assertEquals($result->corsConfiguration->corsRules[0]->allowedHeaders[0], 'Authorization'); + + $this->assertEquals($result->corsConfiguration->corsRules[1]->allowedOrigins[0], 'http://example.com'); + $this->assertEquals($result->corsConfiguration->corsRules[1]->allowedOrigins[1], 'http://example.net'); + $this->assertEquals(count($result->corsConfiguration->corsRules[1]->allowedMethods), 1); + $this->assertEquals($result->corsConfiguration->corsRules[1]->allowedMethods[0], 'GET'); + $this->assertEquals(count($result->corsConfiguration->corsRules[1]->allowedHeaders), 1); + $this->assertEquals($result->corsConfiguration->corsRules[1]->allowedHeaders[0], 'Authorization'); + $this->assertEquals(count($result->corsConfiguration->corsRules[1]->exposeHeaders), 2); + $this->assertEquals($result->corsConfiguration->corsRules[1]->exposeHeaders[0], "x-oss-test"); + $this->assertEquals($result->corsConfiguration->corsRules[1]->exposeHeaders[1], "x-oss-test1"); + $this->assertEquals($result->corsConfiguration->corsRules[1]->maxAgeSeconds, 100); + } + + public function testFromDeleteBucketCors() + { + // miss required field + try { + $request = new Models\DeleteBucketCorsRequest(); + $input = BucketCors::fromDeleteBucketCors($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketCorsRequest('bucket-123'); + $input = BucketCors::fromDeleteBucketCors($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketCors() + { + // empty output + $output = new OperationOutput(); + $result = BucketCors::toDeleteBucketCors($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketCors::toDeleteBucketCors($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromOptionObject() + { + // miss required field + try { + $request = new Models\OptionObjectRequest(); + $input = BucketCors::fromOptionObject($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\OptionObjectRequest('bucket-123'); + $input = BucketCors::fromOptionObject($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\OptionObjectRequest('bucket-123', 'key-123'); + $input = BucketCors::fromOptionObject($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, origin", (string)$e); + } + + try { + $request = new Models\OptionObjectRequest('bucket-123', 'key-123', 'http://www.example.com'); + $input = BucketCors::fromOptionObject($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, accessControlRequestMethod", (string)$e); + } + + $request = new Models\OptionObjectRequest('bucket-123', 'key-123', 'http://www.example.com', 'PUT'); + $input = BucketCors::fromOptionObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToOptionObject() + { + // empty output + $output = new OperationOutput(); + $result = BucketCors::toOptionObject($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Access-Control-Allow-Origin' => 'http://www.example.com', 'Access-Control-Allow-Methods' => 'PUT', 'Access-Control-Allow-Headers' => 'x-oss-allow', 'Access-Control-Expose-Headers' => 'x-oss-test1,x-oss-test2', 'Access-Control-Max-Age' => "60"] + ); + $result = BucketCors::toOptionObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(6, count($result->headers)); + $this->assertEquals('http://www.example.com', $result->accessControlAllowOrigin); + $this->assertEquals('x-oss-test1,x-oss-test2', $result->accessControlExposeHeaders); + $this->assertEquals('x-oss-allow', $result->accessControlAllowHeaders); + $this->assertEquals('PUT', $result->accessControlAllowMethods); + $this->assertEquals(60, $result->accessControlMaxAge); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketEncryptionTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketEncryptionTest.php new file mode 100644 index 0000000..e3390ad --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketEncryptionTest.php @@ -0,0 +1,232 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketEncryptionRequest('bucket-123'); + $input = BucketEncryption::fromPutBucketEncryption($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, serverSideEncryptionRule", (string)$e); + } + + // demo1 + $request = new Models\PutBucketEncryptionRequest('bucket-123', new Models\ServerSideEncryptionRule( + new Models\ApplyServerSideEncryptionByDefault( + sseAlgorithm: 'KMS', + kmsDataEncryption: 'SM4' + ))); + $input = BucketEncryption::fromPutBucketEncryption($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<KMSSM4 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketEncryptionRequest('bucket-123', new Models\ServerSideEncryptionRule( + new Models\ApplyServerSideEncryptionByDefault( + sseAlgorithm: 'KMS', + kmsMasterKeyID: '9468da86-3509-4f8d-a61e-6eab1eac****', + kmsDataEncryption: 'SM4' + ))); + $input = BucketEncryption::fromPutBucketEncryption($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<KMS9468da86-3509-4f8d-a61e-6eab1eac****SM4 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo3 + $request = new Models\PutBucketEncryptionRequest('bucket-123', new Models\ServerSideEncryptionRule( + new Models\ApplyServerSideEncryptionByDefault( + sseAlgorithm: 'AES256', + ))); + $input = BucketEncryption::fromPutBucketEncryption($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<AES256 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketEncryption() + { + // empty output + $output = new OperationOutput(); + $result = BucketEncryption::toPutBucketEncryption($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketEncryption::toPutBucketEncryption($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketEncryption() + { + // miss required field + try { + $request = new Models\GetBucketEncryptionRequest(); + $input = BucketEncryption::fromGetBucketEncryption($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketEncryptionRequest('bucket-123'); + $input = BucketEncryption::fromGetBucketEncryption($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketEncryption() + { + // empty output + $output = new OperationOutput(); + $result = BucketEncryption::toGetBucketEncryption($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + KMS + 9468da86-3509-4f8d-a61e-6eab1eac**** + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketEncryption::toGetBucketEncryption($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $result->serverSideEncryptionRule->applyServerSideEncryptionByDefault->kmsMasterKeyID); + $this->assertEquals('KMS', $result->serverSideEncryptionRule->applyServerSideEncryptionByDefault->sseAlgorithm); + + $body = ' + + + KMS + SM4 + 9468da86-3509-4f8d-a61e-6eab1eac**** + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketEncryption::toGetBucketEncryption($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $result->serverSideEncryptionRule->applyServerSideEncryptionByDefault->kmsMasterKeyID); + $this->assertEquals('KMS', $result->serverSideEncryptionRule->applyServerSideEncryptionByDefault->sseAlgorithm); + $this->assertEquals('SM4', $result->serverSideEncryptionRule->applyServerSideEncryptionByDefault->kmsDataEncryption); + + $body = ' + + + AES256 + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketEncryption::toGetBucketEncryption($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('AES256', $result->serverSideEncryptionRule->applyServerSideEncryptionByDefault->sseAlgorithm); + } + + public function testFromDeleteBucketEncryption() + { + // miss required field + try { + $request = new Models\DeleteBucketEncryptionRequest(); + $input = BucketEncryption::fromDeleteBucketEncryption($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketEncryptionRequest('bucket-123'); + $input = BucketEncryption::fromDeleteBucketEncryption($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketEncryption() + { + // empty output + $output = new OperationOutput(); + $result = BucketEncryption::toDeleteBucketEncryption($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketEncryption::toDeleteBucketEncryption($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketHttpsConfigTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketHttpsConfigTest.php new file mode 100644 index 0000000..e435567 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketHttpsConfigTest.php @@ -0,0 +1,177 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketHttpsConfigRequest('bucket-123'); + $input = BucketHttpsConfig::fromPutBucketHttpsConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, httpsConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketHttpsConfigRequest('bucket-123', new Models\HttpsConfiguration( + tls: new Models\TLS( + tlsVersions: ['TLSv1.2', 'TLSv1.3'], + enable: true + ) + )); + $input = BucketHttpsConfig::fromPutBucketHttpsConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<TLSv1.2TLSv1.3true +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketHttpsConfigRequest('bucket-123', new Models\HttpsConfiguration( + tls: new Models\TLS( + tlsVersions: ['TLSv1.2', 'TLSv1.3'], + enable: true + ), + cipherSuite: new Models\CipherSuite( + enable: true, + strongCipherSuite: false, + customCipherSuites: ['ECDHE-ECDSA-AES128-SHA256', 'ECDHE-RSA-AES128-GCM-SHA256', 'ECDHE-ECDSA-AES256-CCM8'], + tls13CustomCipherSuites: ['ECDHE-ECDSA-AES256-CCM8', 'ECDHE-ECDSA-AES256-CCM8', 'ECDHE-ECDSA-AES256-CCM8'], + ) + )); + $input = BucketHttpsConfig::fromPutBucketHttpsConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<TLSv1.2TLSv1.3truetruefalseECDHE-ECDSA-AES128-SHA256ECDHE-RSA-AES128-GCM-SHA256ECDHE-ECDSA-AES256-CCM8ECDHE-ECDSA-AES256-CCM8ECDHE-ECDSA-AES256-CCM8ECDHE-ECDSA-AES256-CCM8 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketHttpsConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketHttpsConfig::toPutBucketHttpsConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketHttpsConfig::toPutBucketHttpsConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketHttpsConfig() + { + // miss required field + try { + $request = new Models\GetBucketHttpsConfigRequest(); + $input = BucketHttpsConfig::fromGetBucketHttpsConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketHttpsConfigRequest('bucket-123'); + $input = BucketHttpsConfig::fromGetBucketHttpsConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketHttpsConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketHttpsConfig::toGetBucketHttpsConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + true + TLSv1.2 + TLSv1.3 + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketHttpsConfig::toGetBucketHttpsConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertTrue($result->httpsConfiguration->tls->enable); + $this->assertEquals(2, count($result->httpsConfiguration->tls->tlsVersions)); + $this->assertEquals("TLSv1.2", $result->httpsConfiguration->tls->tlsVersions[0]); + $this->assertEquals("TLSv1.3", $result->httpsConfiguration->tls->tlsVersions[1]); + + $body = 'TLSv1.2TLSv1.3truetruefalseECDHE-ECDSA-AES128-SHA256ECDHE-RSA-AES128-GCM-SHA256ECDHE-ECDSA-AES256-CCM8ECDHE-ECDSA-AES256-CCM8ECDHE-ECDSA-AES256-CCM8ECDHE-ECDSA-AES256-CCM8'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketHttpsConfig::toGetBucketHttpsConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertTrue($result->httpsConfiguration->tls->enable); + $this->assertEquals(2, count($result->httpsConfiguration->tls->tlsVersions)); + $this->assertEquals("TLSv1.2", $result->httpsConfiguration->tls->tlsVersions[0]); + $this->assertEquals("TLSv1.3", $result->httpsConfiguration->tls->tlsVersions[1]); + + $this->assertTrue($result->httpsConfiguration->cipherSuite->enable); + $this->assertFalse($result->httpsConfiguration->cipherSuite->strongCipherSuite); + $this->assertEquals(3, count($result->httpsConfiguration->cipherSuite->customCipherSuites)); + $this->assertEquals('ECDHE-ECDSA-AES128-SHA256', $result->httpsConfiguration->cipherSuite->customCipherSuites[0]); + $this->assertEquals('ECDHE-RSA-AES128-GCM-SHA256', $result->httpsConfiguration->cipherSuite->customCipherSuites[1]); + $this->assertEquals('ECDHE-ECDSA-AES256-CCM8', $result->httpsConfiguration->cipherSuite->customCipherSuites[2]); + $this->assertEquals(3, count($result->httpsConfiguration->cipherSuite->tls13CustomCipherSuites)); + $this->assertEquals('ECDHE-ECDSA-AES256-CCM8', $result->httpsConfiguration->cipherSuite->tls13CustomCipherSuites[0]); + $this->assertEquals('ECDHE-ECDSA-AES256-CCM8', $result->httpsConfiguration->cipherSuite->tls13CustomCipherSuites[1]); + $this->assertEquals('ECDHE-ECDSA-AES256-CCM8', $result->httpsConfiguration->cipherSuite->tls13CustomCipherSuites[2]); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketInventoryTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketInventoryTest.php new file mode 100644 index 0000000..56a3f6f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketInventoryTest.php @@ -0,0 +1,497 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketInventoryRequest('bucket-123'); + $input = BucketInventory::fromPutBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, inventoryId", (string)$e); + } + + try { + $request = new Models\PutBucketInventoryRequest('bucket-123', 'inventory-id'); + $input = BucketInventory::fromPutBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, inventoryConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketInventoryRequest('bucket-123', 'report1', inventoryConfiguration: new Models\InventoryConfiguration( + isEnabled: true, + destination: new Models\InventoryDestination( + ossBucketDestination: new Models\InventoryOSSBucketDestination( + bucket: 'acs:oss:::destination-bucket', + prefix: 'prefix1', + encryption: new Models\InventoryEncryption( + sseKms: new Models\SSEKMS('keyId') + ), + format: Models\InventoryFormatType::CSV, + accountId: '1000000000000000', roleArn: 'acs:ram::1000000000000000:role/AliyunOSSRole' + ) + ), + filter: new Models\InventoryFilter( + prefix: 'filterPrefix', + lastModifyBeginTimeStamp: 1637883649, + lastModifyEndTimeStamp: 1638347592, + lowerSizeBound: 1024, + upperSizeBound: 1048576, + storageClass: 'Standard,IA' + ), + includedObjectVersions: 'All', + optionalFields: new Models\OptionalFields( + [ + Models\InventoryOptionalFieldType::SIZE, + Models\InventoryOptionalFieldType::LAST_MODIFIED_DATE, + Models\InventoryOptionalFieldType::ETAG, + Models\InventoryOptionalFieldType::STORAGE_CLASS, + Models\InventoryOptionalFieldType::IS_MULTIPART_UPLOADED, + Models\InventoryOptionalFieldType::ENCRYPTION_STATUS, + Models\InventoryOptionalFieldType::TRANSITION_TIME, + ] + ), + id: 'report1' + )); + $input = BucketInventory::fromPutBucketInventory($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<trueacs:oss:::destination-bucketprefix1keyIdCSV1000000000000000acs:ram::1000000000000000:role/AliyunOSSRolefilterPrefix1637883649163834759210241048576Standard,IAAllSizeLastModifiedDateETagStorageClassIsMultipartUploadedEncryptionStatusTransitionTimereport1 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketInventoryRequest('bucket-123', 'report1', inventoryConfiguration: new Models\InventoryConfiguration( + isEnabled: true, + destination: new Models\InventoryDestination( + ossBucketDestination: new Models\InventoryOSSBucketDestination( + bucket: 'acs:oss:::destination-bucket', + format: Models\InventoryFormatType::CSV, + accountId: '1000000000000000', + roleArn: 'acs:ram::1000000000000000:role/AliyunOSSRole' + ) + ), + schedule: new Models\InventorySchedule( + frequency: Models\InventoryFrequencyType::DAILY + ), + filter: new Models\InventoryFilter( + prefix: 'filterPrefix', + lastModifyBeginTimeStamp: 1637883649, + lastModifyEndTimeStamp: 1638347592, + lowerSizeBound: 1024, + upperSizeBound: 1048576, + storageClass: 'Standard,IA' + ), + includedObjectVersions: 'All', + id: 'report1' + )); + $input = BucketInventory::fromPutBucketInventory($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<trueacs:oss:::destination-bucketCSV1000000000000000acs:ram::1000000000000000:role/AliyunOSSRoleDailyfilterPrefix1637883649163834759210241048576Standard,IAAllreport1 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketInventory() + { + // empty output + $output = new OperationOutput(); + $result = BucketInventory::toPutBucketInventory($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketInventory::toPutBucketInventory($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketInventory() + { + // miss required field + try { + $request = new Models\GetBucketInventoryRequest(); + $input = BucketInventory::fromGetBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetBucketInventoryRequest('bucket-123'); + $input = BucketInventory::fromGetBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, inventoryId", (string)$e); + } + + $request = new Models\GetBucketInventoryRequest('bucket-123', 'inventoryId'); + $input = BucketInventory::fromGetBucketInventory($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketInventory() + { + // empty output + $output = new OperationOutput(); + $result = BucketInventory::toGetBucketInventory($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + report1 + true + + + CSV + 1000000000000000 + acs:ram::1000000000000000:role/AliyunOSSRole + acs:oss:::bucket_0001 + prefix1 + + + keyId + + + + + + Daily + + + 1637883649 + 1638347592 + 1024 + 1048576 + Standard,IA + myprefix/ + + All + + Size + LastModifiedDate + ETag + StorageClass + IsMultipartUploaded + EncryptionStatus + TransitionTime + + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketInventory::toGetBucketInventory($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('report1', $result->inventoryConfiguration->id); + $this->assertTrue($result->inventoryConfiguration->isEnabled); + $this->assertEquals(Models\InventoryFormatType::CSV, $result->inventoryConfiguration->destination->ossBucketDestination->format); + $this->assertEquals('1000000000000000', $result->inventoryConfiguration->destination->ossBucketDestination->accountId); + $this->assertEquals('acs:ram::1000000000000000:role/AliyunOSSRole', $result->inventoryConfiguration->destination->ossBucketDestination->roleArn); + $this->assertEquals('acs:oss:::bucket_0001', $result->inventoryConfiguration->destination->ossBucketDestination->bucket); + $this->assertEquals('prefix1', $result->inventoryConfiguration->destination->ossBucketDestination->prefix); + $this->assertEquals('keyId', $result->inventoryConfiguration->destination->ossBucketDestination->encryption->sseKms->keyId); + $this->assertEquals(Models\InventoryFrequencyType::DAILY, $result->inventoryConfiguration->schedule->frequency); + $this->assertEquals('All', $result->inventoryConfiguration->includedObjectVersions); + $this->assertEquals(7, count($result->inventoryConfiguration->optionalFields->fields)); + $this->assertEquals(Models\InventoryOptionalFieldType::STORAGE_CLASS, $result->inventoryConfiguration->optionalFields->fields[3]); + $this->assertEquals(Models\InventoryOptionalFieldType::TRANSITION_TIME, $result->inventoryConfiguration->optionalFields->fields[6]); + $this->assertEquals('myprefix/', $result->inventoryConfiguration->filter->prefix); + $this->assertEquals(1637883649, $result->inventoryConfiguration->filter->lastModifyBeginTimeStamp); + $this->assertEquals(1638347592, $result->inventoryConfiguration->filter->lastModifyEndTimeStamp); + $this->assertEquals(1024, $result->inventoryConfiguration->filter->lowerSizeBound); + $this->assertEquals(1048576, $result->inventoryConfiguration->filter->upperSizeBound); + $this->assertEquals('Standard,IA', $result->inventoryConfiguration->filter->storageClass); + $body = ' + + report1 + true + + + CSV + 1000000000000000 + acs:ram::1000000000000000:role/AliyunOSSRole + acs:oss:::destination-bucket + + + + Weekly + + Current +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketInventory::toGetBucketInventory($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('report1', $result->inventoryConfiguration->id); + $this->assertTrue($result->inventoryConfiguration->isEnabled); + $this->assertEquals(Models\InventoryFormatType::CSV, $result->inventoryConfiguration->destination->ossBucketDestination->format); + $this->assertEquals('1000000000000000', $result->inventoryConfiguration->destination->ossBucketDestination->accountId); + $this->assertEquals('acs:ram::1000000000000000:role/AliyunOSSRole', $result->inventoryConfiguration->destination->ossBucketDestination->roleArn); + $this->assertEquals('acs:oss:::destination-bucket', $result->inventoryConfiguration->destination->ossBucketDestination->bucket); + $this->assertEquals(Models\InventoryFrequencyType::WEEKLY, $result->inventoryConfiguration->schedule->frequency); + $this->assertEquals('Current', $result->inventoryConfiguration->includedObjectVersions); + } + + public function testFromListBucketInventory() + { + // miss required field + try { + $request = new Models\ListBucketInventoryRequest(); + $input = BucketInventory::fromListBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\ListBucketInventoryRequest('bucket-123'); + $input = BucketInventory::fromListBucketInventory($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + $request = new Models\ListBucketInventoryRequest('bucket-123', 'token'); + $input = BucketInventory::fromListBucketInventory($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('token', $input->getParameters()['continuation-token']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToListBucketInventory() + { + // empty output + $output = new OperationOutput(); + $result = BucketInventory::toListBucketInventory($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + report1 + true + + + CSV + 1000000000000000 + acs:ram::1000000000000000:role/AliyunOSSRole + acs:oss:::destination-bucket + prefix1 + + + + Daily + + + prefix/One + + All + + Size + LastModifiedDate + ETag + StorageClass + IsMultipartUploaded + EncryptionStatus + + + + report2 + true + + + CSV + 1000000000000000 + acs:ram::1000000000000000:role/AliyunOSSRole + acs:oss:::destination-bucket + prefix2 + + + + Daily + + + prefix/Two + + All + + Size + LastModifiedDate + ETag + StorageClass + IsMultipartUploaded + EncryptionStatus + + + + report3 + true + + + CSV + 1000000000000000 + acs:ram::1000000000000000:role/AliyunOSSRole + acs:oss:::destination-bucket + prefix3 + + + + Daily + + + prefix/Three + + All + + Size + LastModifiedDate + ETag + StorageClass + IsMultipartUploaded + EncryptionStatus + + + false + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketInventory::toListBucketInventory($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(3, count($result->listInventoryConfigurationsResult->inventoryConfigurations)); + $this->assertEquals('report1', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->id); + $this->assertTrue($result->listInventoryConfigurationsResult->inventoryConfigurations[0]->isEnabled); + $this->assertEquals(Models\InventoryFormatType::CSV, $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->destination->ossBucketDestination->format); + $this->assertEquals('1000000000000000', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->destination->ossBucketDestination->accountId); + $this->assertEquals('acs:ram::1000000000000000:role/AliyunOSSRole', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->destination->ossBucketDestination->roleArn); + $this->assertEquals('acs:oss:::destination-bucket', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->destination->ossBucketDestination->bucket); + $this->assertEquals('prefix1', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->destination->ossBucketDestination->prefix); + $this->assertEquals(Models\InventoryFrequencyType::DAILY, $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->schedule->frequency); + $this->assertEquals('All', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->includedObjectVersions); + $this->assertEquals(6, count($result->listInventoryConfigurationsResult->inventoryConfigurations[0]->optionalFields->fields)); + $this->assertEquals(Models\InventoryOptionalFieldType::STORAGE_CLASS, $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->optionalFields->fields[3]); + $this->assertEquals('prefix/One', $result->listInventoryConfigurationsResult->inventoryConfigurations[0]->filter->prefix); + + $this->assertEquals('report2', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->id); + $this->assertTrue($result->listInventoryConfigurationsResult->inventoryConfigurations[1]->isEnabled); + $this->assertEquals(Models\InventoryFormatType::CSV, $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->destination->ossBucketDestination->format); + $this->assertEquals('1000000000000000', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->destination->ossBucketDestination->accountId); + $this->assertEquals('acs:ram::1000000000000000:role/AliyunOSSRole', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->destination->ossBucketDestination->roleArn); + $this->assertEquals('acs:oss:::destination-bucket', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->destination->ossBucketDestination->bucket); + $this->assertEquals('prefix2', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->destination->ossBucketDestination->prefix); + $this->assertEquals(Models\InventoryFrequencyType::DAILY, $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->schedule->frequency); + $this->assertEquals('All', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->includedObjectVersions); + $this->assertEquals(6, count($result->listInventoryConfigurationsResult->inventoryConfigurations[1]->optionalFields->fields)); + $this->assertEquals(Models\InventoryOptionalFieldType::STORAGE_CLASS, $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->optionalFields->fields[3]); + $this->assertEquals('prefix/Two', $result->listInventoryConfigurationsResult->inventoryConfigurations[1]->filter->prefix); + $this->assertFalse($result->listInventoryConfigurationsResult->isTruncated); + } + + public function testFromDeleteBucketInventory() + { + // miss required field + try { + $request = new Models\DeleteBucketInventoryRequest(); + $input = BucketInventory::fromDeleteBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteBucketInventoryRequest('bucket-123'); + $input = BucketInventory::fromDeleteBucketInventory($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, inventoryId", (string)$e); + } + + $request = new Models\DeleteBucketInventoryRequest('bucket-123', 'inventoryId'); + $input = BucketInventory::fromDeleteBucketInventory($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketInventory() + { + // empty output + $output = new OperationOutput(); + $result = BucketInventory::toDeleteBucketInventory($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketInventory::toDeleteBucketInventory($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLifecycleTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLifecycleTest.php new file mode 100644 index 0000000..83a266e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLifecycleTest.php @@ -0,0 +1,538 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, lifecycleConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: '', id: 'rule', expiration: new Models\LifecycleRuleExpiration(expiredObjectDeleteMarker: true), noncurrentVersionExpiration: new Models\NoncurrentVersionExpiration(noncurrentDays: 5), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<ruletrue5Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: 'log/', id: 'rule', expiration: new Models\LifecycleRuleExpiration(days: 90), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<log/rule90Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo3 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: 'log/', transitions: array( + new Models\LifecycleRuleTransition(days: 30, storageClass: 'IA'), + new Models\LifecycleRuleTransition(days: 60, storageClass: 'Archive'), + ), id: 'rule', expiration: new Models\LifecycleRuleExpiration(days: 3600), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<log/30IA60Archiverule3600Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo4 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: '', id: 'rule', expiration: new Models\LifecycleRuleExpiration(expiredObjectDeleteMarker: true), noncurrentVersionExpiration: new Models\NoncurrentVersionExpiration(noncurrentDays: 5), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<ruletrue5Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo5 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: '', transitions: array( + new Models\LifecycleRuleTransition(days: 30, storageClass: 'Archive'), + ), filter: new Models\LifecycleRuleFilter(nots: array(new Models\LifecycleRuleNot(tag: new Models\Tag(key: 'key1', value: 'value1'), prefix: 'log') + )), id: 'rule', expiration: new Models\LifecycleRuleExpiration(expiredObjectDeleteMarker: true), noncurrentVersionExpiration: new Models\NoncurrentVersionExpiration(noncurrentDays: 5), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<30Archivekey1value1logruletrue5Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule( + prefix: '', + transitions: array( + new Models\LifecycleRuleTransition(days: 30, storageClass: 'Archive'), + ), + filter: new Models\LifecycleRuleFilter( + nots: array( + new Models\LifecycleRuleNot(tag: new Models\Tag(key: 'key1', value: 'value1'), prefix: 'log'), + new Models\LifecycleRuleNot(tag: new Models\Tag(key: 'key2', value: 'value2'), prefix: 'pre') + )), + id: 'rule', + expiration: new Models\LifecycleRuleExpiration(expiredObjectDeleteMarker: true), + noncurrentVersionExpiration: new Models\NoncurrentVersionExpiration(noncurrentDays: 5), + status: 'Enabled' + ); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<30Archivekey1value1logkey2value2preruletrue5Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo6 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: '', transitions: array( + new Models\LifecycleRuleTransition(days: 30, storageClass: 'Archive', isAccessTime: true, returnToStdWhenVisit: true), + ), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<30ArchivetruetrueEnabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo7 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $rule = new Models\LifecycleRule(prefix: '', id: 'rule', abortMultipartUpload: new Models\LifecycleRuleAbortMultipartUpload(days: 30), status: 'Enabled'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + $rule + ) + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<rule30Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo8 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + new Models\LifecycleRule(prefix: 'dir1', id: 'rule1', expiration: new Models\LifecycleRuleExpiration(days: 180), status: 'Enabled'), + new Models\LifecycleRule(prefix: 'dir1/dir2/', id: 'rule2', expiration: new Models\LifecycleRuleExpiration(days: 30), status: 'Enabled'), + ), + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<dir1rule1180Enableddir1/dir2/rule230Enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo9 + $request = new Models\PutBucketLifecycleRequest('bucket-123'); + $request->lifecycleConfiguration = new Models\LifecycleConfiguration( + array( + new Models\LifecycleRule(prefix: 'prefix0', id: 'r0', expiration: new Models\LifecycleRuleExpiration(days: 40, expiredObjectDeleteMarker: false), status: 'Enabled'), + new Models\LifecycleRule(prefix: 'prefix1', filter: new Models\LifecycleRuleFilter(objectSizeGreaterThan: 500, objectSizeLessThan: 64500), id: 'r1', expiration: new Models\LifecycleRuleExpiration(days: 40, expiredObjectDeleteMarker: false), status: 'Enabled'), + new Models\LifecycleRule(prefix: 'prefix3', transitions: array(new Models\LifecycleRuleTransition(days: 30, storageClass: 'IA', isAccessTime: false)), id: 'r3', expiration: new Models\LifecycleRuleExpiration(days: 40, expiredObjectDeleteMarker: false), status: 'Enabled'), + new Models\LifecycleRule(prefix: 'prefix4', transitions: array(new Models\LifecycleRuleTransition(days: 30, storageClass: 'IA', isAccessTime: false)), noncurrentVersionTransitions: array(new NoncurrentVersionTransition(noncurrentDays: 10, storageClass: 'IA', isAccessTime: true, returnToStdWhenVisit: true)), id: 'r4', abortMultipartUpload: new Models\LifecycleRuleAbortMultipartUpload(createdBeforeDate: new DateTime('2015-11-11T00:00:00.000Z', new DateTimeZone('UTC'))), status: 'Enabled'), + new Models\LifecycleRule(prefix: 'pre_', expiration: new Models\LifecycleRuleExpiration(days: 40, expiredObjectDeleteMarker: false), status: 'Enabled'), + ), + ); + $input = BucketLifecycle::fromPutBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<prefix0r040falseEnabledprefix150064500r140falseEnabledprefix330IAfalser340falseEnabledprefix430IAfalse10IAtruetruer42015-11-11T00:00:00ZEnabledpre_40falseEnabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketLifecycle() + { + // empty output + $output = new OperationOutput(); + $result = BucketLifecycle::toPutBucketLifecycle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketLifecycle::toPutBucketLifecycle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketLifecycle() + { + // miss required field + try { + $request = new Models\GetBucketLifecycleRequest(); + $input = BucketLifecycle::fromGetBucketLifecycle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketLifecycleRequest('bucket-123'); + $input = BucketLifecycle::fromGetBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketLifecycle() + { + // empty output + $output = new OperationOutput(); + $result = BucketLifecycle::toGetBucketLifecycle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + delete after one day + logs1/ + Enabled + + 1 + + + + mtime transition1 + logs2/ + Enabled + + 30 + IA + + + + mtime transition2 + logs3/ + Enabled + + 30 + IA + false + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketLifecycle::toGetBucketLifecycle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(3, count($result->lifecycleConfiguration->rules)); + $this->assertEquals('delete after one day', $result->lifecycleConfiguration->rules[0]->id); + $this->assertEquals('logs1/', $result->lifecycleConfiguration->rules[0]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[0]->status); + $this->assertEquals(1, $result->lifecycleConfiguration->rules[0]->expiration->days); + + $this->assertEquals('mtime transition1', $result->lifecycleConfiguration->rules[1]->id); + $this->assertEquals('logs2/', $result->lifecycleConfiguration->rules[1]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[1]->status); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules[1]->transitions)); + $this->assertEquals(30, $result->lifecycleConfiguration->rules[1]->transitions[0]->days); + $this->assertEquals('IA', $result->lifecycleConfiguration->rules[1]->transitions[0]->storageClass); + + $this->assertEquals('mtime transition2', $result->lifecycleConfiguration->rules[2]->id); + $this->assertEquals('logs3/', $result->lifecycleConfiguration->rules[2]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[2]->status); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules[2]->transitions)); + $this->assertEquals(30, $result->lifecycleConfiguration->rules[2]->transitions[0]->days); + $this->assertEquals('IA', $result->lifecycleConfiguration->rules[2]->transitions[0]->storageClass); + $this->assertFalse($result->lifecycleConfiguration->rules[2]->transitions[0]->isAccessTime); + + $body = ' + + + atime transition1 + logs1/ + Enabled + + 30 + IA + true + false + + 1631698332 + + + atime transition2 + logs2/ + Enabled + + 10 + IA + true + false + + 1631698332 + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketLifecycle::toGetBucketLifecycle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(2, count($result->lifecycleConfiguration->rules)); + $this->assertEquals('atime transition1', $result->lifecycleConfiguration->rules[0]->id); + $this->assertEquals('logs1/', $result->lifecycleConfiguration->rules[0]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[0]->status); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules[0]->transitions)); + $this->assertEquals(30, $result->lifecycleConfiguration->rules[0]->transitions[0]->days); + $this->assertEquals('IA', $result->lifecycleConfiguration->rules[0]->transitions[0]->storageClass); + $this->assertFalse($result->lifecycleConfiguration->rules[0]->transitions[0]->returnToStdWhenVisit); + $this->assertTrue($result->lifecycleConfiguration->rules[0]->transitions[0]->isAccessTime); + $this->assertEquals(1631698332, $result->lifecycleConfiguration->rules[0]->atimeBase); + + $this->assertEquals('atime transition2', $result->lifecycleConfiguration->rules[1]->id); + $this->assertEquals('logs2/', $result->lifecycleConfiguration->rules[1]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[1]->status); + $this->assertEquals(10, $result->lifecycleConfiguration->rules[1]->noncurrentVersionTransitions[0]->noncurrentDays); + $this->assertEquals('IA', $result->lifecycleConfiguration->rules[1]->noncurrentVersionTransitions[0]->storageClass); + $this->assertFalse($result->lifecycleConfiguration->rules[1]->noncurrentVersionTransitions[0]->returnToStdWhenVisit); + $this->assertTrue($result->lifecycleConfiguration->rules[1]->noncurrentVersionTransitions[0]->isAccessTime); + $this->assertEquals(1631698332, $result->lifecycleConfiguration->rules[1]->atimeBase); + + $body = ' + + + + + 30 + Archive + + + + + key1 + value1 + + log + + + rule + + true + + + 5 + + Enabled + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketLifecycle::toGetBucketLifecycle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules)); + $this->assertEquals('rule', $result->lifecycleConfiguration->rules[0]->id); + $this->assertEquals('', $result->lifecycleConfiguration->rules[0]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[0]->status); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules[0]->transitions)); + $this->assertEquals(30, $result->lifecycleConfiguration->rules[0]->transitions[0]->days); + $this->assertEquals('Archive', $result->lifecycleConfiguration->rules[0]->transitions[0]->storageClass); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules[0]->filter->nots)); + $this->assertEquals('log', $result->lifecycleConfiguration->rules[0]->filter->nots[0]->prefix); + $this->assertEquals('key1', $result->lifecycleConfiguration->rules[0]->filter->nots[0]->tag->key); + $this->assertEquals('value1', $result->lifecycleConfiguration->rules[0]->filter->nots[0]->tag->value); + + $body = ' + + + + + 30 + Archive + + + + + key1 + value1 + + log + + + + key2 + value2 + + pre + + + rule + + true + + + 5 + + Enabled + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketLifecycle::toGetBucketLifecycle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules)); + $this->assertEquals('rule', $result->lifecycleConfiguration->rules[0]->id); + $this->assertEquals('', $result->lifecycleConfiguration->rules[0]->prefix); + $this->assertEquals('Enabled', $result->lifecycleConfiguration->rules[0]->status); + $this->assertEquals(1, count($result->lifecycleConfiguration->rules[0]->transitions)); + $this->assertEquals(30, $result->lifecycleConfiguration->rules[0]->transitions[0]->days); + $this->assertEquals('Archive', $result->lifecycleConfiguration->rules[0]->transitions[0]->storageClass); + $this->assertEquals(2, count($result->lifecycleConfiguration->rules[0]->filter->nots)); + $this->assertEquals('log', $result->lifecycleConfiguration->rules[0]->filter->nots[0]->prefix); + $this->assertEquals('key1', $result->lifecycleConfiguration->rules[0]->filter->nots[0]->tag->key); + $this->assertEquals('value1', $result->lifecycleConfiguration->rules[0]->filter->nots[0]->tag->value); + $this->assertEquals('pre', $result->lifecycleConfiguration->rules[0]->filter->nots[1]->prefix); + $this->assertEquals('key2', $result->lifecycleConfiguration->rules[0]->filter->nots[1]->tag->key); + $this->assertEquals('value2', $result->lifecycleConfiguration->rules[0]->filter->nots[1]->tag->value); + } + + public function testFromDeleteBucketLifecycle() + { + // miss required field + try { + $request = new Models\DeleteBucketLifecycleRequest(); + $input = BucketLifecycle::fromDeleteBucketLifecycle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketLifecycleRequest('bucket-123'); + $input = BucketLifecycle::fromDeleteBucketLifecycle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketLifecycle() + { + // empty output + $output = new OperationOutput(); + $result = BucketLifecycle::toDeleteBucketLifecycle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketLifecycle::toDeleteBucketLifecycle($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLoggingTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLoggingTest.php new file mode 100644 index 0000000..78b07bb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketLoggingTest.php @@ -0,0 +1,354 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketLoggingRequest('bucket-123'); + $input = BucketLogging::fromPutBucketLogging($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucketLoggingStatus", (string)$e); + } + + $request = new Models\PutBucketLoggingRequest('bucket-123', new Models\BucketLoggingStatus(new Models\LoggingEnabled( + targetBucket: 'TargetBucket', targetPrefix: 'TargetPrefix' + ))); + $input = BucketLogging::fromPutBucketLogging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<TargetBucketTargetPrefix +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\PutBucketLoggingRequest('bucket-123', new Models\BucketLoggingStatus(new Models\LoggingEnabled( + targetBucket: 'TargetBucket', targetPrefix: 'TargetPrefix', loggingRole: 'AliyunOSSLoggingDefaultRole' + ))); + $input = BucketLogging::fromPutBucketLogging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<TargetBucketTargetPrefixAliyunOSSLoggingDefaultRole +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketLogging() + { + // empty output + $output = new OperationOutput(); + $result = BucketLogging::toPutBucketLogging($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketLogging::toPutBucketLogging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketLogging() + { + // miss required field + try { + $request = new Models\GetBucketLoggingRequest(); + $input = BucketLogging::fromGetBucketLogging($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketLoggingRequest('bucket-123'); + $input = BucketLogging::fromGetBucketLogging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketLogging() + { + // empty output + $output = new OperationOutput(); + $result = BucketLogging::toGetBucketLogging($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + bucket-log + prefix-access_log + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketLogging::toGetBucketLogging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('bucket-log', $result->bucketLoggingStatus->loggingEnabled->targetBucket); + $this->assertEquals('prefix-access_log', $result->bucketLoggingStatus->loggingEnabled->targetPrefix); + + + $output = new OperationOutput(); + $result = BucketLogging::toGetBucketLogging($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + bucket-log + prefix-access_log + AliyunOSSLoggingDefaultRole + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketLogging::toGetBucketLogging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('bucket-log', $result->bucketLoggingStatus->loggingEnabled->targetBucket); + $this->assertEquals('prefix-access_log', $result->bucketLoggingStatus->loggingEnabled->targetPrefix); + $this->assertEquals('AliyunOSSLoggingDefaultRole', $result->bucketLoggingStatus->loggingEnabled->loggingRole); + } + + public function testFromDeleteBucketLogging() + { + // miss required field + try { + $request = new Models\DeleteBucketLoggingRequest(); + $input = BucketLogging::fromDeleteBucketLogging($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketLoggingRequest('bucket-123'); + $input = BucketLogging::fromDeleteBucketLogging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketLogging() + { + // empty output + $output = new OperationOutput(); + $result = BucketLogging::toDeleteBucketLogging($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketLogging::toDeleteBucketLogging($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromPutUserDefinedLogFieldsConfig() + { + // miss required field + try { + $request = new Models\PutUserDefinedLogFieldsConfigRequest(); + $input = BucketLogging::fromPutUserDefinedLogFieldsConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutUserDefinedLogFieldsConfigRequest('bucket-123'); + $input = BucketLogging::fromPutUserDefinedLogFieldsConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, userDefinedLogFieldsConfiguration", (string)$e); + } + + $request = new Models\PutUserDefinedLogFieldsConfigRequest('bucket-123', new Models\UserDefinedLogFieldsConfiguration( + new Models\LoggingParamSet(array("param1", "param2")), + new Models\LoggingHeaderSet(array("header1", "header2", "header3")) + )); + $input = BucketLogging::fromPutUserDefinedLogFieldsConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<param1param2

    header1
    header2
    header3
    +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutUserDefinedLogFieldsConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketLogging::toPutUserDefinedLogFieldsConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketLogging::toPutUserDefinedLogFieldsConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetUserDefinedLogFieldsConfig() + { + // miss required field + try { + $request = new Models\GetUserDefinedLogFieldsConfigRequest(); + $input = BucketLogging::fromGetUserDefinedLogFieldsConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetUserDefinedLogFieldsConfigRequest('bucket-123'); + $input = BucketLogging::fromGetUserDefinedLogFieldsConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetUserDefinedLogFieldsConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketLogging::toGetUserDefinedLogFieldsConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + +
    header1
    +
    header2
    +
    header3
    +
    + + param1 + param2 + +
    '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketLogging::toGetUserDefinedLogFieldsConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('header1', $result->userDefinedLogFieldsConfiguration->headerSet->headers[0]); + $this->assertEquals('header3', $result->userDefinedLogFieldsConfiguration->headerSet->headers[2]); + $this->assertEquals('param2', $result->userDefinedLogFieldsConfiguration->paramSet->parameters[1]); + } + + public function testFromUserDefinedLogFieldsConfig() + { + // miss required field + try { + $request = new Models\DeleteUserDefinedLogFieldsConfigRequest(); + $input = BucketLogging::fromDeleteUserDefinedLogFieldsConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteUserDefinedLogFieldsConfigRequest('bucket-123'); + $input = BucketLogging::fromDeleteUserDefinedLogFieldsConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToUserDefinedLogFieldsConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketLogging::toDeleteUserDefinedLogFieldsConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketLogging::toDeleteUserDefinedLogFieldsConfig($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketMetaQueryTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketMetaQueryTest.php new file mode 100644 index 0000000..af387df --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketMetaQueryTest.php @@ -0,0 +1,639 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\OpenMetaQueryRequest('bucket-123'); + $input = BucketMetaQuery::fromOpenMetaQuery($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('add', $input->getParameters()['comp']); + $this->assertEquals('', $input->getParameters()['metaQuery']); + + $request = new Models\OpenMetaQueryRequest('bucket-123', 'basic'); + $input = BucketMetaQuery::fromOpenMetaQuery($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('add', $input->getParameters()['comp']); + $this->assertEquals('', $input->getParameters()['metaQuery']); + $this->assertEquals('basic', $input->getParameters()['mode']); + + $request = new Models\OpenMetaQueryRequest('bucket-123', 'semantic'); + $input = BucketMetaQuery::fromOpenMetaQuery($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('add', $input->getParameters()['comp']); + $this->assertEquals('', $input->getParameters()['metaQuery']); + $this->assertEquals('semantic', $input->getParameters()['mode']); + } + + public function testToOpenMetaQuery() + { + // empty output + $output = new OperationOutput(); + $result = BucketMetaQuery::toOpenMetaQuery($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketMetaQuery::toOpenMetaQuery($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetMetaQueryStatus() + { + // miss required field + try { + $request = new Models\GetMetaQueryStatusRequest(); + $input = BucketMetaQuery::fromGetMetaQueryStatus($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetMetaQueryStatusRequest('bucket-123'); + $input = BucketMetaQuery::fromGetMetaQueryStatus($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('', $input->getParameters()['metaQuery']); + } + + public function testToGetMetaQueryStatus() + { + // empty output + $output = new OperationOutput(); + $result = BucketMetaQuery::toGetMetaQueryStatus($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + Running + FullScanning + 2021-08-02T10:49:17.289372919+08:00 + 2021-08-02T10:49:17.289372919+08:00 +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketMetaQuery::toGetMetaQueryStatus($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('Running', $result->metaQueryStatus->state); + $this->assertEquals('FullScanning', $result->metaQueryStatus->phase); + $this->assertEquals('2021-08-02T10:49:17.289372919+08:00', $result->metaQueryStatus->createTime); + $this->assertEquals('2021-08-02T10:49:17.289372919+08:00', $result->metaQueryStatus->updateTime); + } + + public function testFromDoMetaQuery() + { + // miss required field + try { + $request = new Models\DoMetaQueryRequest(); + $input = BucketMetaQuery::fromDoMetaQuery($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DoMetaQueryRequest('bucket-123'); + $input = BucketMetaQuery::fromDoMetaQuery($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, metaQuery", (string)$e); + } + + $request = new Models\DoMetaQueryRequest('bucket-123', new Models\MetaQuery( + maxResults: 5, + query: "{'Field': 'Size','Value': '1048576','Operation': 'gt'}", + sort: 'Size', + order: Models\MetaQueryOrderType::ASC, + aggregations: new Models\MetaQueryAggregations( + [ + new Models\MetaQueryAggregation( + field: 'Size', + operation: 'sum' + ), + new Models\MetaQueryAggregation( + field: 'Size', + operation: 'max' + ), + ] + ), + nextToken: 'MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw****' + )); + $input = BucketMetaQuery::fromDoMetaQuery($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<5{'Field': 'Size','Value': '1048576','Operation': 'gt'}SizeascSizesumSizemaxMTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw**** +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\DoMetaQueryRequest('bucket-123', new Models\MetaQuery( + maxResults: 99, + query: "Overlook the snow-covered forest", + nextToken: 'MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw****', + mediaTypes: new Models\MetaQueryMediaTypes('image'), + simpleQuery: "{'Operation':'gt', 'Field': 'Size', 'Value': '30'}" + ), mode: 'semantic'); + $input = BucketMetaQuery::fromDoMetaQuery($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<99Overlook the snow-covered forestMTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw****image{'Operation':'gt', 'Field': 'Size', 'Value': '30'} +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToDoMetaQuery() + { + // empty output + $output = new OperationOutput(); + $result = BucketMetaQuery::toDoMetaQuery($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw**** + + + exampleobject.txt + 120 + 2021-06-29T15:04:05.000000000Z07:00 + Normal + Standard + default + "fba9dede5f27731c9771645a3986****" + 4858A48BD1466884 + 2 + + + owner + John + + + type + document + + + + + x-oss-meta-location + hangzhou + + + + + + + Size + sum + 4859250309 + + + Size + max + 2235483240 + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketMetaQuery::toDoMetaQuery($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('MTIzNDU2Nzg6aW1tdGVzdDpleGFtcGxlYnVja2V0OmRhdGFzZXQwMDE6b3NzOi8vZXhhbXBsZWJ1Y2tldC9zYW1wbGVvYmplY3QxLmpw****', $result->nextToken); + + $this->assertEquals(1, count($result->files->file)); + $this->assertEquals('exampleobject.txt', $result->files->file[0]->filename); + $this->assertEquals(120, $result->files->file[0]->size); + $this->assertEquals('2021-06-29T15:04:05.000000000Z07:00', $result->files->file[0]->fileModifiedTime); + $this->assertEquals('Normal', $result->files->file[0]->ossObjectType); + $this->assertEquals('Standard', $result->files->file[0]->ossStorageClass); + $this->assertEquals('default', $result->files->file[0]->objectACL); + $this->assertEquals('"fba9dede5f27731c9771645a3986****"', $result->files->file[0]->etag); + $this->assertEquals(2, $result->files->file[0]->ossTaggingCount); + $this->assertEquals('owner', $result->files->file[0]->ossTagging->taggings[0]->key); + $this->assertEquals('John', $result->files->file[0]->ossTagging->taggings[0]->value); + $this->assertEquals('type', $result->files->file[0]->ossTagging->taggings[1]->key); + $this->assertEquals('document', $result->files->file[0]->ossTagging->taggings[1]->value); + $this->assertEquals(1, count($result->files->file[0]->ossUserMeta->userMetas)); + $this->assertEquals('x-oss-meta-location', $result->files->file[0]->ossUserMeta->userMetas[0]->key); + $this->assertEquals('hangzhou', $result->files->file[0]->ossUserMeta->userMetas[0]->value); + $this->assertEquals('Size', $result->aggregations->aggregations[0]->field); + $this->assertEquals('sum', $result->aggregations->aggregations[0]->operation); + $this->assertEquals(4859250309, $result->aggregations->aggregations[0]->value); + $this->assertEquals('Size', $result->aggregations->aggregations[1]->field); + $this->assertEquals('max', $result->aggregations->aggregations[1]->operation); + $this->assertEquals(2235483240, $result->aggregations->aggregations[1]->value); + + $body = ' + + + + + Size + sum + 30930054 + + + Size + group + + + 1536000 + 1 + + + 5472362 + 1 + + + 10354204 + 1 + + + 1890304 + 3 + + + 2632192 + 3 + + + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketMetaQuery::toDoMetaQuery($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals(2, count($result->aggregations->aggregations)); + $this->assertEquals('Size', $result->aggregations->aggregations[0]->field); + $this->assertEquals('sum', $result->aggregations->aggregations[0]->operation); + $this->assertEquals(30930054, $result->aggregations->aggregations[0]->value); + $this->assertEquals('Size', $result->aggregations->aggregations[1]->field); + $this->assertEquals('group', $result->aggregations->aggregations[1]->operation); + $this->assertEquals(5, count($result->aggregations->aggregations[1]->groups->groups)); + $this->assertEquals(1, $result->aggregations->aggregations[1]->groups->groups[0]->count); + $this->assertEquals('1536000', $result->aggregations->aggregations[1]->groups->groups[0]->value); + $this->assertEquals(1, $result->aggregations->aggregations[1]->groups->groups[1]->count); + $this->assertEquals('5472362', $result->aggregations->aggregations[1]->groups->groups[1]->value); + $this->assertEquals(1, $result->aggregations->aggregations[1]->groups->groups[2]->count); + $this->assertEquals('10354204', $result->aggregations->aggregations[1]->groups->groups[2]->value); + $this->assertEquals(3, $result->aggregations->aggregations[1]->groups->groups[3]->count); + $this->assertEquals('1890304', $result->aggregations->aggregations[1]->groups->groups[3]->value); + $this->assertEquals(3, $result->aggregations->aggregations[1]->groups->groups[4]->count); + $this->assertEquals('2632192', $result->aggregations->aggregations[1]->groups->groups[4]->value); + + $body = ' + + + + oss://bucket/sample-object.jpg + sample-object.jpg + 1000 + default + 2021-06-29T14:50:14.011643661+08:00 + AES256 + SM4 + "1D9C280A7C4F67F7EF873E28449****" + 559890638950338001 + 2021-06-29T14:50:15.011643661+08:00 + image/jpeg + image + 30.134390,120.074997 + test + 2024-12-01T12:00:00.000Z + https://aliyundoc.com + PUT + SM4 + 9468da86-3509-4f8d-a61e-6eab1eac**** + no-cache + attachment; filename=test.jpg + UTF-8 + zh-CN + 500 + 270 + 1080 + 1920 + + + h264 + en + 5407765 + 25/1 + 0 + 22.88 + 572 + 8 + yuv420p + bt709 + 720 + 1280 + + + h264 + en + 5407765 + 25/1 + 0 + 22.88 + 572 + 8 + yuv420p + bt709 + 720 + 1280 + + + + + aac + 1048576 + 48000 + 0.0235 + 3.690667 + 2 + en + + + + + mov_text + en + 0 + 71.378 + + + mov_text + en + 72 + 71.378 + + + 5407765 + Jane + Jenny + Jane + Jane + FirstAlbum + 71.378 + +
    + 中国浙江省杭州市余杭区文一西路969号 + 杭州市 + 中国 + 余杭区 + zh-Hans + 浙江省 + 文一西路 +
    +
    + 中国浙江省杭州市余杭区文一西路970号 + 杭州市 + 中国 + 余杭区 + zh-Hans + 浙江省 + 文一西路 +
    +
    + Normal + Standard + 2 + + + key + val + + + key2 + val2 + + + + + key + val + + +
    +
    +
    '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketMetaQuery::toDoMetaQuery($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals(1, count($result->files->file)); + $this->assertEquals('oss://bucket/sample-object.jpg', $result->files->file[0]->uri); + $this->assertEquals('sample-object.jpg', $result->files->file[0]->filename); + $this->assertEquals(1000, $result->files->file[0]->size); + $this->assertEquals('2021-06-29T14:50:14.011643661+08:00', $result->files->file[0]->fileModifiedTime); + $this->assertEquals('AES256', $result->files->file[0]->serverSideEncryption); + $this->assertEquals('SM4', $result->files->file[0]->serverSideEncryptionCustomerAlgorithm); + $this->assertEquals('"1D9C280A7C4F67F7EF873E28449****"', $result->files->file[0]->etag); + $this->assertEquals('559890638950338001', $result->files->file[0]->ossCrc64); + $this->assertEquals('2021-06-29T14:50:15.011643661+08:00', $result->files->file[0]->produceTime); + $this->assertEquals('image/jpeg', $result->files->file[0]->contentType); + $this->assertEquals('image', $result->files->file[0]->mediaType); + $this->assertEquals('30.134390,120.074997', $result->files->file[0]->latLong); + $this->assertEquals('test', $result->files->file[0]->title); + $this->assertEquals('2024-12-01T12:00:00.000Z', $result->files->file[0]->ossExpiration); + $this->assertEquals('https://aliyundoc.com', $result->files->file[0]->accessControlAllowOrigin); + $this->assertEquals('PUT', $result->files->file[0]->accessControlRequestMethod); + $this->assertEquals('SM4', $result->files->file[0]->serverSideDataEncryption); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $result->files->file[0]->serverSideEncryptionKeyId); + $this->assertEquals('no-cache', $result->files->file[0]->cacheControl); + $this->assertEquals('attachment; filename=test.jpg', $result->files->file[0]->contentDisposition); + $this->assertEquals('UTF-8', $result->files->file[0]->contentEncoding); + $this->assertEquals('zh-CN', $result->files->file[0]->contentLanguage); + $this->assertEquals(500, $result->files->file[0]->imageHeight); + $this->assertEquals(270, $result->files->file[0]->imageWidth); + $this->assertEquals(1920, $result->files->file[0]->videoHeight); + $this->assertEquals(1080, $result->files->file[0]->videoWidth); + $this->assertEquals(2, count($result->files->file[0]->videoStreams->videoStream)); + $this->assertEquals('h264', $result->files->file[0]->videoStreams->videoStream[0]->codecName); + $this->assertEquals('en', $result->files->file[0]->videoStreams->videoStream[0]->language); + $this->assertEquals(5407765, $result->files->file[0]->videoStreams->videoStream[0]->bitrate); + $this->assertEquals(8, $result->files->file[0]->videoStreams->videoStream[0]->bitDepth); + $this->assertEquals('25/1', $result->files->file[0]->videoStreams->videoStream[0]->frameRate); + $this->assertEquals(0, $result->files->file[0]->videoStreams->videoStream[0]->startTime); + $this->assertEquals(22.88, $result->files->file[0]->videoStreams->videoStream[0]->duration); + $this->assertEquals(572, $result->files->file[0]->videoStreams->videoStream[0]->frameCount); + $this->assertEquals('yuv420p', $result->files->file[0]->videoStreams->videoStream[0]->pixelFormat); + $this->assertEquals('bt709', $result->files->file[0]->videoStreams->videoStream[0]->colorSpace); + $this->assertEquals(720, $result->files->file[0]->videoStreams->videoStream[0]->height); + $this->assertEquals(1280, $result->files->file[0]->videoStreams->videoStream[0]->width); + $this->assertEquals('h264', $result->files->file[0]->videoStreams->videoStream[1]->codecName); + $this->assertEquals('en', $result->files->file[0]->videoStreams->videoStream[1]->language); + $this->assertEquals(5407765, $result->files->file[0]->videoStreams->videoStream[1]->bitrate); + $this->assertEquals('25/1', $result->files->file[0]->videoStreams->videoStream[1]->frameRate); + $this->assertEquals(0, $result->files->file[0]->videoStreams->videoStream[1]->startTime); + $this->assertEquals(22.88, $result->files->file[0]->videoStreams->videoStream[1]->duration); + $this->assertEquals(572, $result->files->file[0]->videoStreams->videoStream[1]->frameCount); + $this->assertEquals(8, $result->files->file[0]->videoStreams->videoStream[1]->bitDepth); + $this->assertEquals('yuv420p', $result->files->file[0]->videoStreams->videoStream[1]->pixelFormat); + $this->assertEquals('bt709', $result->files->file[0]->videoStreams->videoStream[1]->colorSpace); + $this->assertEquals(720, $result->files->file[0]->videoStreams->videoStream[1]->height); + $this->assertEquals(1280, $result->files->file[0]->videoStreams->videoStream[1]->width); + + $this->assertEquals(1, count($result->files->file[0]->audioStreams->audioStream)); + $this->assertEquals('aac', $result->files->file[0]->audioStreams->audioStream[0]->codecName); + $this->assertEquals(1048576, $result->files->file[0]->audioStreams->audioStream[0]->bitrate); + $this->assertEquals(48000, $result->files->file[0]->audioStreams->audioStream[0]->sampleRate); + $this->assertEquals(0.0235, $result->files->file[0]->audioStreams->audioStream[0]->startTime); + $this->assertEquals(3.690667, $result->files->file[0]->audioStreams->audioStream[0]->duration); + $this->assertEquals(2, $result->files->file[0]->audioStreams->audioStream[0]->channels); + $this->assertEquals('en', $result->files->file[0]->audioStreams->audioStream[0]->language); + + $this->assertEquals(2, count($result->files->file[0]->subtitles->subtitle)); + $this->assertEquals('mov_text', $result->files->file[0]->subtitles->subtitle[0]->codecName); + $this->assertEquals('en', $result->files->file[0]->subtitles->subtitle[0]->language); + $this->assertEquals(0, $result->files->file[0]->subtitles->subtitle[0]->startTime); + $this->assertEquals(71.378, $result->files->file[0]->subtitles->subtitle[0]->duration); + $this->assertEquals('mov_text', $result->files->file[0]->subtitles->subtitle[1]->codecName); + $this->assertEquals('en', $result->files->file[0]->subtitles->subtitle[1]->language); + $this->assertEquals(72, $result->files->file[0]->subtitles->subtitle[1]->startTime); + $this->assertEquals(71.378, $result->files->file[0]->subtitles->subtitle[1]->duration); + + $this->assertEquals(5407765, $result->files->file[0]->bitrate); + $this->assertEquals('Jane', $result->files->file[0]->artist); + $this->assertEquals('Jenny', $result->files->file[0]->albumArtist); + $this->assertEquals('Jane', $result->files->file[0]->composer); + $this->assertEquals('Jane', $result->files->file[0]->performer); + $this->assertEquals('FirstAlbum', $result->files->file[0]->album); + $this->assertEquals(71.378, $result->files->file[0]->duration); + + $this->assertEquals(2, count($result->files->file[0]->addresses->address)); + $this->assertEquals('中国浙江省杭州市余杭区文一西路969号', $result->files->file[0]->addresses->address[0]->addressLine); + $this->assertEquals('杭州市', $result->files->file[0]->addresses->address[0]->city); + $this->assertEquals('中国', $result->files->file[0]->addresses->address[0]->country); + $this->assertEquals('余杭区', $result->files->file[0]->addresses->address[0]->district); + $this->assertEquals('zh-Hans', $result->files->file[0]->addresses->address[0]->language); + $this->assertEquals('浙江省', $result->files->file[0]->addresses->address[0]->province); + $this->assertEquals('文一西路', $result->files->file[0]->addresses->address[0]->township); + + $this->assertEquals('中国浙江省杭州市余杭区文一西路970号', $result->files->file[0]->addresses->address[1]->addressLine); + $this->assertEquals('杭州市', $result->files->file[0]->addresses->address[1]->city); + $this->assertEquals('中国', $result->files->file[0]->addresses->address[1]->country); + $this->assertEquals('余杭区', $result->files->file[0]->addresses->address[1]->district); + $this->assertEquals('zh-Hans', $result->files->file[0]->addresses->address[1]->language); + $this->assertEquals('浙江省', $result->files->file[0]->addresses->address[1]->province); + $this->assertEquals('文一西路', $result->files->file[0]->addresses->address[1]->township); + + $this->assertEquals('Normal', $result->files->file[0]->ossObjectType); + $this->assertEquals('Standard', $result->files->file[0]->ossStorageClass); + $this->assertEquals(2, $result->files->file[0]->ossTaggingCount); + $this->assertEquals('key', $result->files->file[0]->ossTagging->taggings[0]->key); + $this->assertEquals('val', $result->files->file[0]->ossTagging->taggings[0]->value); + $this->assertEquals('key2', $result->files->file[0]->ossTagging->taggings[1]->key); + $this->assertEquals('val2', $result->files->file[0]->ossTagging->taggings[1]->value); + $this->assertEquals(1, count($result->files->file[0]->ossUserMeta->userMetas)); + $this->assertEquals('key', $result->files->file[0]->ossUserMeta->userMetas[0]->key); + $this->assertEquals('val', $result->files->file[0]->ossUserMeta->userMetas[0]->value); + } + + public function testFromCloseMetaQuery() + { + // miss required field + try { + $request = new Models\CloseMetaQueryRequest(); + $input = BucketMetaQuery::fromCloseMetaQuery($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\CloseMetaQueryRequest('bucket-123'); + $input = BucketMetaQuery::fromCloseMetaQuery($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketMetaQuery() + { + // empty output + $output = new OperationOutput(); + $result = BucketMetaQuery::toCloseMetaQuery($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + ); + $result = BucketMetaQuery::toCloseMetaQuery($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketOverwriteConfigTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketOverwriteConfigTest.php new file mode 100644 index 0000000..5d63cc1 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketOverwriteConfigTest.php @@ -0,0 +1,200 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketOverwriteConfigRequest('bucket-123'); + $input = BucketOverwriteConfig::fromPutBucketOverwriteConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, overwriteConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketOverwriteConfigRequest('bucket-123', new Models\OverwriteConfiguration( + rules: array( + new Models\OverwriteRule(action: 'forbid', id: 'rule-001') + ) + )); + $input = BucketOverwriteConfig::fromPutBucketOverwriteConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<forbidrule-001 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketOverwriteConfigRequest('bucket-123', new Models\OverwriteConfiguration( + rules: array( + new Models\OverwriteRule(action: 'forbid', id: 'rule-001'), + new Models\OverwriteRule(action: 'forbid', prefix: 'pre', suffix: '.txt', principals: new Models\OverwritePrincipals(array('1234567890')), id: 'rule-002') + ) + )); + $input = BucketOverwriteConfig::fromPutBucketOverwriteConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<forbidrule-001forbidpre.txt1234567890rule-002 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketOverwriteConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketOverwriteConfig::toPutBucketOverwriteConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketOverwriteConfig::toPutBucketOverwriteConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketOverwriteConfig() + { + // miss required field + try { + $request = new Models\GetBucketOverwriteConfigRequest(); + $input = BucketOverwriteConfig::fromGetBucketOverwriteConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketOverwriteConfigRequest('bucket-123'); + $input = BucketOverwriteConfig::fromGetBucketOverwriteConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketOverwriteConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketOverwriteConfig::toGetBucketOverwriteConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + 1 + forbid + + + + + + 2 + forbid + pre + .txt + + 1234567890 + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketOverwriteConfig::toGetBucketOverwriteConfig($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals(2, count($result->overwriteConfiguration->rules)); + $this->assertEquals("1", $result->overwriteConfiguration->rules[0]->id); + $this->assertEquals("forbid", $result->overwriteConfiguration->rules[0]->action); + $this->assertEquals("", $result->overwriteConfiguration->rules[0]->prefix); + $this->assertEquals("", $result->overwriteConfiguration->rules[0]->suffix); + $this->assertEquals(new Models\OverwritePrincipals(), $result->overwriteConfiguration->rules[0]->principals); + $this->assertEquals("2", $result->overwriteConfiguration->rules[1]->id); + $this->assertEquals("forbid", $result->overwriteConfiguration->rules[1]->action); + $this->assertEquals("pre", $result->overwriteConfiguration->rules[1]->prefix); + $this->assertEquals(".txt", $result->overwriteConfiguration->rules[1]->suffix); + $this->assertEquals(1, count($result->overwriteConfiguration->rules[1]->principals->principals)); + $this->assertEquals("1234567890", $result->overwriteConfiguration->rules[1]->principals->principals[0]); + } + + public function testFromDeleteBucketOverwriteConfig() + { + // miss required field + try { + $request = new Models\DeleteBucketOverwriteConfigRequest(); + $input = BucketOverwriteConfig::fromDeleteBucketOverwriteConfig($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketOverwriteConfigRequest('bucket-123'); + $input = BucketOverwriteConfig::fromDeleteBucketOverwriteConfig($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketOverwriteConfig() + { + // empty output + $output = new OperationOutput(); + $result = BucketOverwriteConfig::toDeleteBucketOverwriteConfig($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketOverwriteConfig::toDeleteBucketOverwriteConfig($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPolicyTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPolicyTest.php new file mode 100644 index 0000000..8eeee0e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPolicyTest.php @@ -0,0 +1,197 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketPolicyRequest('bucket-123'); + $input = BucketPolicy::fromPutBucketPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, body.", (string)$e); + } + + // all settings + $body = '{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["1234567890"],"Resource":["acs:oss:*:1234567890:*/*"]}]}'; + $request = new Models\PutBucketPolicyRequest( + bucket: 'bucket-123', + body: $body + ); + $json = <<assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals($json, $input->getBody()->getContents()); + $this->assertEquals(base64_encode(md5($input->getBody(), true)), $input->getHeaders()['content-md5']); + } + + public function testToPutBucketPolicy() + { + // empty output + $output = new OperationOutput(); + $result = BucketPolicy::toPutBucketPolicy($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketPolicy::toPutBucketPolicy($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketPolicy() + { + // miss required field + try { + $request = new Models\GetBucketPolicyRequest(); + $input = BucketPolicy::fromGetBucketPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketPolicyRequest('bucket-123'); + $input = BucketPolicy::fromGetBucketPolicy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketPolicy() + { + // empty output + $output = new OperationOutput(); + $result = BucketPolicy::toGetBucketPolicy($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor('{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["1234567890"],"Resource":["acs:oss:*:1234567890:*/*"]}]}') + ); + $result = BucketPolicy::toGetBucketPolicy($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertCount(2, $result->headers); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('{"Version":"1","Statement":[{"Action":["oss:PutObject","oss:GetObject"],"Effect":"Deny","Principal":["1234567890"],"Resource":["acs:oss:*:1234567890:*/*"]}]}', $result->body); + } + + public function testFromGetBucketPolicyStatus() + { + // miss required field + try { + $request = new Models\GetBucketPolicyStatusRequest(); + $input = BucketPolicy::fromGetBucketPolicyStatus($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketPolicyStatusRequest('bucket-123'); + $input = BucketPolicy::fromGetBucketPolicyStatus($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketPolicyStatus() + { + // empty output + $output = new OperationOutput(); + $result = BucketPolicy::toGetBucketPolicyStatus($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor(' + + true +') + ); + $result = BucketPolicy::toGetBucketPolicyStatus($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertCount(2, $result->headers); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertTrue($result->policyStatus->isPublic); + } + + public function testFromDeleteBucketPolicy() + { + // miss required field + try { + $request = new Models\DeleteBucketPolicyRequest(); + $input = BucketPolicy::fromDeleteBucketPolicy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketPolicyRequest('bucket-123'); + $input = BucketPolicy::fromDeleteBucketPolicy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketPolicy() + { + // empty output + $output = new OperationOutput(); + $result = BucketPolicy::toDeleteBucketPolicy($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketPolicy::toDeleteBucketPolicy($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php new file mode 100644 index 0000000..755c99c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketPublicAccessBlockTest.php @@ -0,0 +1,155 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketPublicAccessBlockRequest('bucket-123'); + $input = BucketPublicAccessBlock::fromPutBucketPublicAccessBlock($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, publicAccessBlockConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketPublicAccessBlockRequest('bucket-123', new Models\PublicAccessBlockConfiguration( + true + )); + $input = BucketPublicAccessBlock::fromPutBucketPublicAccessBlock($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<true +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketPublicAccessBlock() + { + // empty output + $output = new OperationOutput(); + $result = BucketPublicAccessBlock::toPutBucketPublicAccessBlock($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketPublicAccessBlock::toPutBucketPublicAccessBlock($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketPublicAccessBlock() + { + try { + $request = new Models\GetBucketPublicAccessBlockRequest(); + $input = BucketPublicAccessBlock::fromGetBucketPublicAccessBlock($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketPublicAccessBlockRequest('bucket-123'); + $input = BucketPublicAccessBlock::fromGetBucketPublicAccessBlock($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketPublicAccessBlock() + { + // empty output + $output = new OperationOutput(); + $result = BucketPublicAccessBlock::toGetBucketPublicAccessBlock($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + true + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketPublicAccessBlock::toGetBucketPublicAccessBlock($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertTrue($result->publicAccessBlockConfiguration->blockPublicAccess); + } + + public function testFromDeleteBucketPublicAccessBlock() + { + try { + $request = new Models\DeleteBucketPublicAccessBlockRequest(); + $input = BucketPublicAccessBlock::fromDeleteBucketPublicAccessBlock($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketPublicAccessBlockRequest('bucket-123'); + $input = BucketPublicAccessBlock::fromDeleteBucketPublicAccessBlock($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketPublicAccessBlock() + { + // empty output + $output = new OperationOutput(); + $result = BucketPublicAccessBlock::toDeleteBucketPublicAccessBlock($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketPublicAccessBlock::toDeleteBucketPublicAccessBlock($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRedundancyTransitionTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRedundancyTransitionTest.php new file mode 100644 index 0000000..0839acc --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRedundancyTransitionTest.php @@ -0,0 +1,467 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CreateBucketDataRedundancyTransitionRequest('bucket-123'); + $input = BucketRedundancyTransition::fromCreateBucketDataRedundancyTransition($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, targetRedundancyType", (string)$e); + } + + $request = new Models\CreateBucketDataRedundancyTransitionRequest('bucket-123', Models\DataRedundancyType::ZRS); + $input = BucketRedundancyTransition::fromCreateBucketDataRedundancyTransition($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals(Models\DataRedundancyType::ZRS, $input->getParameters()['x-oss-target-redundancy-type']); + } + + public function testToCreateBucketDataRedundancyTransition() + { + // empty output + $output = new OperationOutput(); + $result = BucketRedundancyTransition::toCreateBucketDataRedundancyTransition($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = << + + 4be5beb0f74f490186311b268bf6**** + +BBB; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toCreateBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('4be5beb0f74f490186311b268bf6****', $result->bucketDataRedundancyTransition->taskId); + } + + public function testFromGetBucketDataRedundancyTransition() + { + // miss required field + try { + $request = new Models\GetBucketDataRedundancyTransitionRequest(); + $input = BucketRedundancyTransition::fromGetBucketDataRedundancyTransition($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetBucketDataRedundancyTransitionRequest('bucket-123'); + $input = BucketRedundancyTransition::fromGetBucketDataRedundancyTransition($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, redundancyTransitionTaskid", (string)$e); + } + + $request = new Models\GetBucketDataRedundancyTransitionRequest('bucket-123', 'task-123'); + $input = BucketRedundancyTransition::fromGetBucketDataRedundancyTransition($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('task-123', $input->getParameters()['x-oss-redundancy-transition-taskid']); + } + + public function testToGetBucketDataRedundancyTransition() + { + // empty output + $output = new OperationOutput(); + $result = BucketRedundancyTransition::toGetBucketDataRedundancyTransition($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + examplebucket + 4be5beb0f74f490186311b268bf6**** + Queueing + 2023-11-17T09:11:58.000Z +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toGetBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('examplebucket', $result->bucketDataRedundancyTransition->bucket); + $this->assertEquals('4be5beb0f74f490186311b268bf6****', $result->bucketDataRedundancyTransition->taskId); + $this->assertEquals('Queueing', $result->bucketDataRedundancyTransition->status); + $this->assertEquals('2023-11-17T09:11:58.000Z', $result->bucketDataRedundancyTransition->createTime); + + $body = ' + + examplebucket + 909c6c818dd041d1a44e0fdc66aa**** + Processing + 2023-11-17T09:14:39.000Z + 2023-11-17T09:14:39.000Z + 0 + 100 +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toGetBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('examplebucket', $result->bucketDataRedundancyTransition->bucket); + $this->assertEquals('909c6c818dd041d1a44e0fdc66aa****', $result->bucketDataRedundancyTransition->taskId); + $this->assertEquals('Processing', $result->bucketDataRedundancyTransition->status); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->bucketDataRedundancyTransition->createTime); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->bucketDataRedundancyTransition->startTime); + $this->assertEquals(0, $result->bucketDataRedundancyTransition->processPercentage); + $this->assertEquals(100, $result->bucketDataRedundancyTransition->estimatedRemainingTime); + + $body = ' + + examplebucket + 909c6c818dd041d1a44e0fdc66aa**** + Finished + 2023-11-17T09:14:39.000Z + 2023-11-17T09:14:39.000Z + 100 + 0 + 2023-11-18T09:14:39.000Z +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toGetBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('examplebucket', $result->bucketDataRedundancyTransition->bucket); + $this->assertEquals('909c6c818dd041d1a44e0fdc66aa****', $result->bucketDataRedundancyTransition->taskId); + $this->assertEquals('Finished', $result->bucketDataRedundancyTransition->status); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->bucketDataRedundancyTransition->createTime); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->bucketDataRedundancyTransition->startTime); + $this->assertEquals(100, $result->bucketDataRedundancyTransition->processPercentage); + $this->assertEquals(0, $result->bucketDataRedundancyTransition->estimatedRemainingTime); + $this->assertEquals('2023-11-18T09:14:39.000Z', $result->bucketDataRedundancyTransition->endTime); + } + + public function testFromDeleteBucketDataRedundancyTransition() + { + // miss required field + try { + $request = new Models\DeleteBucketDataRedundancyTransitionRequest(); + $input = BucketRedundancyTransition::fromDeleteBucketDataRedundancyTransition($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteBucketDataRedundancyTransitionRequest('bucket-123'); + $input = BucketRedundancyTransition::fromDeleteBucketDataRedundancyTransition($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, redundancyTransitionTaskid", (string)$e); + } + + $request = new Models\DeleteBucketDataRedundancyTransitionRequest('bucket-123', 'task-123'); + $input = BucketRedundancyTransition::fromDeleteBucketDataRedundancyTransition($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('task-123', $input->getParameters()['x-oss-redundancy-transition-taskid']); + } + + public function testToDeleteBucketDataRedundancyTransition() + { + // empty output + $output = new OperationOutput(); + $result = BucketRedundancyTransition::toDeleteBucketDataRedundancyTransition($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketRedundancyTransition::toDeleteBucketDataRedundancyTransition($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromListBucketDataRedundancyTransition() + { + // miss required field + try { + $request = new Models\ListBucketDataRedundancyTransitionRequest(); + $input = BucketRedundancyTransition::fromListBucketDataRedundancyTransition($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\ListBucketDataRedundancyTransitionRequest('bucket-123'); + $input = BucketRedundancyTransition::fromListBucketDataRedundancyTransition($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToListBucketDataRedundancyTransition() + { + // empty output + $output = new OperationOutput(); + $result = BucketRedundancyTransition::toListBucketDataRedundancyTransition($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + examplebucket + 4be5beb0f74f490186311b268bf6**** + Queueing + 2023-11-17T09:11:58.000Z + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toListBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('examplebucket', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->bucket); + $this->assertEquals('4be5beb0f74f490186311b268bf6****', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->taskId); + $this->assertEquals('Queueing', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->status); + $this->assertEquals('2023-11-17T09:11:58.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->createTime); + + $body = ' + + + examplebucket + 909c6c818dd041d1a44e0fdc66aa**** + Processing + 2023-11-17T09:14:39.000Z + 2023-11-17T09:14:39.000Z + 0 + 100 + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toListBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('examplebucket', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->bucket); + $this->assertEquals('909c6c818dd041d1a44e0fdc66aa****', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->taskId); + $this->assertEquals('Processing', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->status); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->createTime); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->startTime); + $this->assertEquals(0, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->processPercentage); + $this->assertEquals(100, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->estimatedRemainingTime); + + $body = ' + + + examplebucket + 909c6c818dd041d1a44e0fdc66aa**** + Finished + 2023-11-17T09:14:39.000Z + 2023-11-17T09:14:39.000Z + 100 + 0 + 2023-11-18T09:14:39.000Z + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toListBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('examplebucket', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->bucket); + $this->assertEquals('909c6c818dd041d1a44e0fdc66aa****', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->taskId); + $this->assertEquals('Finished', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->status); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->createTime); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->startTime); + $this->assertEquals(100, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->processPercentage); + $this->assertEquals(0, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->estimatedRemainingTime); + $this->assertEquals('2023-11-18T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->endTime); + } + + public function testFromListUserDataRedundancyTransition() + { + $request = new Models\ListUserDataRedundancyTransitionRequest(); + $input = BucketRedundancyTransition::fromListUserDataRedundancyTransition($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + $request = new Models\ListUserDataRedundancyTransitionRequest('token'); + $input = BucketRedundancyTransition::fromListUserDataRedundancyTransition($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('token', $input->getParameters()['continuation-token']); + + $request = new Models\ListUserDataRedundancyTransitionRequest('token', '100'); + $input = BucketRedundancyTransition::fromListUserDataRedundancyTransition($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('token', $input->getParameters()['continuation-token']); + $this->assertEquals(100, $input->getParameters()['max-keys']); + } + + public function testToListUserDataRedundancyTransition() + { + // empty output + $output = new OperationOutput(); + $result = BucketRedundancyTransition::toListBucketDataRedundancyTransition($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + examplebucket + 4be5beb0f74f490186311b268bf6**** + Queueing + 2023-11-17T09:11:58.000Z + + + examplebucket1 + 909c6c818dd041d1a44e0fdc66aa**** + Processing + 2023-11-17T09:14:39.000Z + 2023-11-17T09:14:39.000Z + 0 + 100 + + + examplebucket2 + 909c6c818dd041d1a44e0fdc66aa**** + Finished + 2023-11-17T09:14:39.000Z + 2023-11-17T09:14:39.000Z + 100 + 0 + 2023-11-18T09:14:39.000Z + +false + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketRedundancyTransition::toListBucketDataRedundancyTransition($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals(3, count($result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions)); + $this->assertEquals('examplebucket', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->bucket); + $this->assertEquals('4be5beb0f74f490186311b268bf6****', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->taskId); + $this->assertEquals('Queueing', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->status); + $this->assertEquals('2023-11-17T09:11:58.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[0]->createTime); + + $this->assertEquals('examplebucket1', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->bucket); + $this->assertEquals('909c6c818dd041d1a44e0fdc66aa****', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->taskId); + $this->assertEquals('Processing', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->status); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->createTime); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->startTime); + $this->assertEquals(0, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->processPercentage); + $this->assertEquals(100, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[1]->estimatedRemainingTime); + + $this->assertEquals('examplebucket2', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->bucket); + $this->assertEquals('909c6c818dd041d1a44e0fdc66aa****', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->taskId); + $this->assertEquals('Finished', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->status); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->createTime); + $this->assertEquals('2023-11-17T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->startTime); + $this->assertEquals(100, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->processPercentage); + $this->assertEquals(0, $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->estimatedRemainingTime); + $this->assertEquals('2023-11-18T09:14:39.000Z', $result->listBucketDataRedundancyTransition->bucketDataRedundancyTransitions[2]->endTime); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRefererTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRefererTest.php new file mode 100644 index 0000000..20d6635 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRefererTest.php @@ -0,0 +1,200 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketRefererRequest('bucket-123'); + $input = BucketReferer::fromPutBucketReferer($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, refererConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketRefererRequest('bucket-123', new Models\RefererConfiguration( + allowEmptyReferer: false, + allowTruncateQueryString: true, + truncatePath: true, + refererList: new Models\RefererList(["http://www.aliyun.com", "https://www.aliyun.com", "http://www.*.com", "https://www.?.aliyuncs.com",]), + refererBlacklist: new Models\RefererBlacklist(["http://www.refuse.com", "https://*.hack.com", "http://ban.*.com", "https://www.?.deny.com",]) + )); + $input = BucketReferer::fromPutBucketReferer($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<falsetruetruehttp://www.aliyun.comhttps://www.aliyun.comhttp://www.*.comhttps://www.?.aliyuncs.comhttp://www.refuse.comhttps://*.hack.comhttp://ban.*.comhttps://www.?.deny.com +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketRefererRequest('bucket-123', new Models\RefererConfiguration( + allowEmptyReferer: false, + allowTruncateQueryString: true, + truncatePath: true, + refererList: new Models\RefererList(["http://www.aliyun.com", "https://www.aliyun.com", "http://www.*.com", "https://www.?.aliyuncs.com",]), + )); + $input = BucketReferer::fromPutBucketReferer($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<falsetruetruehttp://www.aliyun.comhttps://www.aliyun.comhttp://www.*.comhttps://www.?.aliyuncs.com +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo3 + $request = new Models\PutBucketRefererRequest('bucket-123', new Models\RefererConfiguration( + allowEmptyReferer: false, + refererList: new Models\RefererList([""]), + )); + $input = BucketReferer::fromPutBucketReferer($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<false +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketReferer() + { + // empty output + $output = new OperationOutput(); + $result = BucketReferer::toPutBucketReferer($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketReferer::toPutBucketReferer($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketReferer() + { + // miss required field + try { + $request = new Models\GetBucketRefererRequest(); + $input = BucketReferer::fromGetBucketReferer($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketRefererRequest('bucket-123'); + $input = BucketReferer::fromGetBucketReferer($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketReferer() + { + // empty output + $output = new OperationOutput(); + $result = BucketReferer::toGetBucketReferer($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + false + true + true + + http://www.aliyun.com + https://www.aliyun.com + http://www.*.com + https://www.?.aliyuncs.com + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketReferer::toGetBucketReferer($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertFalse($result->refererConfiguration->allowEmptyReferer); + $this->assertTrue($result->refererConfiguration->allowTruncateQueryString); + $this->assertTrue($result->refererConfiguration->truncatePath); + $this->assertEquals(4, count($result->refererConfiguration->refererList->referers)); + $this->assertEquals("https://www.?.aliyuncs.com", ($result->refererConfiguration->refererList->referers[3])); + + $body = ' + + false + true + true + + http://www.aliyun.com + https://www.aliyun.com + http://www.*.com + https://www.?.aliyuncs.com + + + http://www.refuse.com + https://*.hack.com + http://ban.*.com + https://www.?.deny.com + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketReferer::toGetBucketReferer($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertFalse($result->refererConfiguration->allowEmptyReferer); + $this->assertTrue($result->refererConfiguration->allowTruncateQueryString); + $this->assertTrue($result->refererConfiguration->truncatePath); + $this->assertEquals(4, count($result->refererConfiguration->refererList->referers)); + $this->assertEquals(4, count($result->refererConfiguration->refererBlacklist->referers)); + $this->assertEquals("https://www.?.aliyuncs.com", ($result->refererConfiguration->refererList->referers[3])); + $this->assertEquals("http://ban.*.com", ($result->refererConfiguration->refererBlacklist->referers[2])); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketReplicationTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketReplicationTest.php new file mode 100644 index 0000000..deec46e --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketReplicationTest.php @@ -0,0 +1,428 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketRtcRequest('bucket-123'); + $input = BucketReplication::fromPutBucketRtc($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, rtcConfiguration", (string)$e); + } + + $request = new Models\PutBucketRtcRequest('bucket-123', new Models\RtcConfiguration( + rtc: new Models\ReplicationTimeControl( + status: 'enabled' + ), + id: 'test_replication_rule_1' + )); + $input = BucketReplication::fromPutBucketRtc($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<enabledtest_replication_rule_1 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketRtc() + { + // empty output + $output = new OperationOutput(); + $result = BucketReplication::toPutBucketRtc($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketReplication::toPutBucketRtc($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromPutBucketReplication() + { + // miss required field + try { + $request = new Models\PutBucketReplicationRequest(); + $input = BucketReplication::fromPutBucketReplication($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketReplicationRequest('bucket-123'); + $input = BucketReplication::fromPutBucketReplication($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, replicationConfiguration", (string)$e); + } + + $request = new Models\PutBucketReplicationRequest('bucket-123', new Models\ReplicationConfiguration( + array(new Models\ReplicationRule( + sourceSelectionCriteria: new Models\ReplicationSourceSelectionCriteria( + sseKmsEncryptedObjects: new Models\SseKmsEncryptedObjects( + status: 'Enabled', + ) + ), + destination: new Models\ReplicationDestination( + bucket: 'destBucket', + location: 'oss-cn-beijing', + transferType: Models\TransferType::OSS_ACC + ), + historicalObjectReplication: Models\HistoricalObjectReplicationType::ENABLED, + syncRole: 'aliyunramrole', + encryptionConfiguration: new Models\ReplicationEncryptionConfiguration( + replicaKmsKeyID: 'c4d49f85-ee30-426b-a5ed-95e9139d****' + ), + rtc: new Models\ReplicationTimeControl( + status: 'enabled' + ) + )) + )); + $input = BucketReplication::fromPutBucketReplication($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<EnableddestBucketoss-cn-beijingoss_accenabledaliyunramrolec4d49f85-ee30-426b-a5ed-95e9139d****enabled +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketReplication() + { + // empty output + $output = new OperationOutput(); + $result = BucketReplication::toPutBucketReplication($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'x-oss-replication-rule-id' => 'b890c26e-907e-4692-b9ac-ec4c11ec****'] + ); + $result = BucketReplication::toPutBucketReplication($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('b890c26e-907e-4692-b9ac-ec4c11ec****', $result->replicationRuleId); + } + + public function testFromGetBucketReplication() + { + // miss required field + try { + $request = new Models\GetBucketReplicationRequest(); + $input = BucketReplication::fromGetBucketReplication($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketReplicationRequest('bucket-123'); + $input = BucketReplication::fromGetBucketReplication($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketReplication() + { + // empty output + $output = new OperationOutput(); + $result = BucketReplication::toGetBucketReplication($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + test_replication_1 + + source1 + video + + PUT + + destbucket + oss-cn-beijing + oss_acc + + doing + enabled + aliyunramrole + + enabled + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketReplication::toGetBucketReplication($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(1, count($result->replicationConfiguration->rules)); + $this->assertEquals('enabled', $result->replicationConfiguration->rules[0]->rtc->status); + $this->assertEquals('test_replication_1', $result->replicationConfiguration->rules[0]->id); + $this->assertEquals('source1', $result->replicationConfiguration->rules[0]->prefixSet->prefixs[0]); + $this->assertEquals('video', $result->replicationConfiguration->rules[0]->prefixSet->prefixs[1]); + $this->assertEquals('PUT', $result->replicationConfiguration->rules[0]->action); + $this->assertEquals(Models\TransferType::OSS_ACC, $result->replicationConfiguration->rules[0]->destination->transferType); + $this->assertEquals('oss-cn-beijing', $result->replicationConfiguration->rules[0]->destination->location); + $this->assertEquals('doing', $result->replicationConfiguration->rules[0]->status); + $this->assertEquals(Models\HistoricalObjectReplicationType::ENABLED, $result->replicationConfiguration->rules[0]->historicalObjectReplication); + $this->assertEquals('aliyunramrole', $result->replicationConfiguration->rules[0]->syncRole); + } + + public function testFromGetBucketReplicationLocation() + { + // miss required field + try { + $request = new Models\GetBucketReplicationLocationRequest(); + $input = BucketReplication::fromGetBucketReplicationLocation($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketReplicationLocationRequest('bucket-123'); + $input = BucketReplication::fromGetBucketReplicationLocation($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketReplicationLocation() + { + // empty output + $output = new OperationOutput(); + $result = BucketReplication::toGetBucketReplicationLocation($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + oss-cn-beijing + oss-cn-qingdao + oss-cn-shenzhen + oss-cn-hongkong + oss-us-west-1 + + + oss-cn-hongkong + + oss_acc + + + + oss-us-west-1 + + oss_acc + + + + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketReplication::toGetBucketReplicationLocation($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(5, count($result->replicationLocation->locations)); + $this->assertEquals('oss-cn-beijing', $result->replicationLocation->locations[0]); + $this->assertEquals('oss-cn-qingdao', $result->replicationLocation->locations[1]); + $this->assertEquals('oss-cn-shenzhen', $result->replicationLocation->locations[2]); + $this->assertEquals('oss-cn-hongkong', $result->replicationLocation->locations[3]); + $this->assertEquals('oss-us-west-1', $result->replicationLocation->locations[4]); + $this->assertEquals(2, count($result->replicationLocation->locationTransferTypeConstraint->locationTransferTypes)); + $this->assertEquals('oss-cn-hongkong', $result->replicationLocation->locationTransferTypeConstraint->locationTransferTypes[0]->location); + $this->assertEquals('oss_acc', $result->replicationLocation->locationTransferTypeConstraint->locationTransferTypes[0]->transferTypes->types[0]); + $this->assertEquals('oss-us-west-1', $result->replicationLocation->locationTransferTypeConstraint->locationTransferTypes[1]->location); + $this->assertEquals('oss_acc', $result->replicationLocation->locationTransferTypeConstraint->locationTransferTypes[1]->transferTypes->types[0]); + } + + public function testFromGetBucketReplicationProgress() + { + // miss required field + try { + $request = new Models\GetBucketReplicationProgressRequest(); + $input = BucketReplication::fromGetBucketReplicationProgress($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetBucketReplicationProgressRequest('bucket-123'); + $input = BucketReplication::fromGetBucketReplicationProgress($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, ruleId", (string)$e); + } + + $request = new Models\GetBucketReplicationProgressRequest('bucket-123', 'rule-1'); + $input = BucketReplication::fromGetBucketReplicationProgress($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketReplicationProgress() + { + // empty output + $output = new OperationOutput(); + $result = BucketReplication::toGetBucketReplicationProgress($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + test_replication_1 + + source_image + video + + PUT + + target-bucket + oss-cn-beijing + oss_acc + + doing + enabled + + 0.85 + 2015-09-24T15:28:14.000Z + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketReplication::toGetBucketReplicationProgress($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(1, count($result->replicationProgress->rules)); + $this->assertEquals('test_replication_1', $result->replicationProgress->rules[0]->id); + $this->assertEquals('source_image', $result->replicationProgress->rules[0]->prefixSet->prefixs[0]); + $this->assertEquals('video', $result->replicationProgress->rules[0]->prefixSet->prefixs[1]); + $this->assertEquals('PUT', $result->replicationProgress->rules[0]->action); + $this->assertEquals(Models\TransferType::OSS_ACC, $result->replicationProgress->rules[0]->destination->transferType); + $this->assertEquals('target-bucket', $result->replicationProgress->rules[0]->destination->bucket); + $this->assertEquals('oss-cn-beijing', $result->replicationProgress->rules[0]->destination->location); + $this->assertEquals('doing', $result->replicationProgress->rules[0]->status); + $this->assertEquals('0.85', $result->replicationProgress->rules[0]->progress->historicalObject); + $this->assertEquals('2015-09-24T15:28:14.000Z', $result->replicationProgress->rules[0]->progress->newObject); + } + + public function testFromDeleteBucketReplication() + { + // miss required field + try { + $request = new Models\DeleteBucketReplicationRequest(); + $input = BucketReplication::fromDeleteBucketReplication($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteBucketReplicationRequest('bucket-123'); + $input = BucketReplication::fromDeleteBucketReplication($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, replicationRules", (string)$e); + } + + $request = new Models\DeleteBucketReplicationRequest('bucket-123', new Models\ReplicationRules( + ids: ['test_replication_1'] + )); + $input = BucketReplication::fromDeleteBucketReplication($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<test_replication_1 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToDeleteBucketReplication() + { + // empty output + $output = new OperationOutput(); + $result = BucketReplication::toGetBucketReplicationProgress($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + ); + $result = BucketReplication::toGetBucketReplicationProgress($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRequestPaymentTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRequestPaymentTest.php new file mode 100644 index 0000000..df4b821 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketRequestPaymentTest.php @@ -0,0 +1,143 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketRequestPaymentRequest('bucket-123'); + $input = BucketRequestPayment::fromPutBucketRequestPayment($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, requestPaymentConfiguration", (string)$e); + } + + $request = new Models\PutBucketRequestPaymentRequest('bucket-123', new Models\RequestPaymentConfiguration( + 'Requester' + )); + $input = BucketRequestPayment::fromPutBucketRequestPayment($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<Requester +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\PutBucketRequestPaymentRequest('bucket-123', new Models\RequestPaymentConfiguration( + 'BucketOwner' + )); + $input = BucketRequestPayment::fromPutBucketRequestPayment($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<BucketOwner +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketRequestPayment() + { + // empty output + $output = new OperationOutput(); + $result = BucketRequestPayment::toPutBucketRequestPayment($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketRequestPayment::toPutBucketRequestPayment($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketRequestPayment() + { + // miss required field + try { + $request = new Models\GetBucketRequestPaymentRequest(); + $input = BucketRequestPayment::fromGetBucketRequestPayment($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketRequestPaymentRequest('bucket-123'); + $input = BucketRequestPayment::fromGetBucketRequestPayment($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketRequestPayment() + { + // empty output + $output = new OperationOutput(); + $result = BucketRequestPayment::toGetBucketRequestPayment($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + Requester +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketRequestPayment::toGetBucketRequestPayment($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('Requester', $result->requestPaymentConfiguration->payer); + + $body = ' + + BucketOwner +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketRequestPayment::toGetBucketRequestPayment($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('BucketOwner', $result->requestPaymentConfiguration->payer); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketResourceGroupTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketResourceGroupTest.php new file mode 100644 index 0000000..633749b --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketResourceGroupTest.php @@ -0,0 +1,115 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketResourceGroupRequest('bucket-123'); + $input = BucketResourceGroup::fromPutBucketResourceGroup($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucketResourceGroupConfiguration", (string)$e); + } + + $request = new Models\PutBucketResourceGroupRequest('bucket-123', new Models\BucketResourceGroupConfiguration( + 'rg-aekz****' + )); + $input = BucketResourceGroup::fromPutBucketResourceGroup($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<rg-aekz**** +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketResourceGroup() + { + // empty output + $output = new OperationOutput(); + $result = BucketResourceGroup::toPutBucketResourceGroup($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketResourceGroup::toPutBucketResourceGroup($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketResourceGroup() + { + // miss required field + try { + $request = new Models\GetBucketResourceGroupRequest(); + $input = BucketResourceGroup::fromGetBucketResourceGroup($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketResourceGroupRequest('bucket-123'); + $input = BucketResourceGroup::fromGetBucketResourceGroup($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketResourceGroup() + { + // empty output + $output = new OperationOutput(); + $result = BucketResourceGroup::toGetBucketResourceGroup($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + rg-aekz**** +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketResourceGroup::toGetBucketResourceGroup($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('rg-aekz****', $result->bucketResourceGroupConfiguration->resourceGroupId); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketStyleTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketStyleTest.php new file mode 100644 index 0000000..f6c55a2 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketStyleTest.php @@ -0,0 +1,274 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutStyleRequest('bucket-123'); + $input = BucketStyle::fromPutStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, styleName", (string)$e); + } + + try { + $request = new Models\PutStyleRequest('bucket-123', 'test'); + $input = BucketStyle::fromPutStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, style", (string)$e); + } + + // demo1 + $request = new Models\PutStyleRequest('bucket-123', + styleName: 'test', + style: new Models\StyleContent( + 'image/resize,p_50' + ) + ); + $input = BucketStyle::fromPutStyle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = << +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutStyle() + { + // empty output + $output = new OperationOutput(); + $result = BucketStyle::toPutStyle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketStyle::toPutStyle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetStyle() + { + // miss required field + try { + $request = new Models\GetStyleRequest(); + $input = BucketStyle::fromGetStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetStyleRequest('bucket-123'); + $input = BucketStyle::fromGetStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, styleName", (string)$e); + } + + $request = new Models\GetStyleRequest('bucket-123', 'style-123'); + $input = BucketStyle::fromGetStyle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetStyle() + { + // empty output + $output = new OperationOutput(); + $result = BucketStyle::toGetStyle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketStyle::toGetStyle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('imagestyle', $result->style->name); + $this->assertEquals('image/resize,p_50', $result->style->content); + $this->assertEquals('image', $result->style->category); + $this->assertEquals('Wed, 20 May 2020 12:07:15 GMT', $result->style->createTime); + $this->assertEquals('Wed, 21 May 2020 12:07:15 GMT', $result->style->lastModifyTime); + } + + public function testFromListStyle() + { + // miss required field + try { + $request = new Models\ListStyleRequest(); + $input = BucketStyle::fromListStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\ListStyleRequest('bucket-123'); + $input = BucketStyle::fromListStyle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToListStyle() + { + // empty output + $output = new OperationOutput(); + $result = BucketStyle::toListStyle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketStyle::toListStyle($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('imagestyle', $result->styleList->styles[0]->name); + $this->assertEquals('image/resize,p_50', $result->styleList->styles[0]->content); + $this->assertEquals('image', $result->styleList->styles[0]->category); + $this->assertEquals('Wed, 20 May 2020 12:07:15 GMT', $result->styleList->styles[0]->createTime); + $this->assertEquals('Wed, 21 May 2020 12:07:15 GMT', $result->styleList->styles[0]->lastModifyTime); + $this->assertEquals('imagestyle1', $result->styleList->styles[1]->name); + $this->assertEquals('image/resize,w_200', $result->styleList->styles[1]->content); + $this->assertEquals('image', $result->styleList->styles[1]->category); + $this->assertEquals('Wed, 20 May 2020 12:08:04 GMT', $result->styleList->styles[1]->createTime); + $this->assertEquals('Wed, 21 May 2020 12:08:04 GMT', $result->styleList->styles[1]->lastModifyTime); + + $this->assertEquals('imagestyle2', $result->styleList->styles[2]->name); + $this->assertEquals('image/resize,w_300', $result->styleList->styles[2]->content); + $this->assertEquals('image', $result->styleList->styles[2]->category); + $this->assertEquals('Fri, 12 Mar 2021 06:19:13 GMT', $result->styleList->styles[2]->createTime); + $this->assertEquals('Fri, 13 Mar 2021 06:27:21 GMT', $result->styleList->styles[2]->lastModifyTime); + } + + public function testFromDeleteStyle() + { + // miss required field + try { + $request = new Models\DeleteStyleRequest(); + $input = BucketStyle::fromDeleteStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteStyleRequest('bucket-123'); + $input = BucketStyle::fromDeleteStyle($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, styleName", (string)$e); + } + + $request = new Models\DeleteStyleRequest('bucket-123', 'style-123'); + $input = BucketStyle::fromDeleteStyle($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteStyle() + { + // empty output + $output = new OperationOutput(); + $result = BucketStyle::toDeleteStyle($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketStyle::toDeleteStyle($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTagsTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTagsTest.php new file mode 100644 index 0000000..b929a4c --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTagsTest.php @@ -0,0 +1,177 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketTagsRequest('bucket-123'); + $input = BucketTags::fromPutBucketTags($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, tagging", (string)$e); + } + + // demo1 + $request = new Models\PutBucketTagsRequest('bucket-123', + tagging: new Models\Tagging( + tagSet: new Models\TagSet( + [new Models\Tag(key: 'key1', value: 'value1'), new Models\Tag(key: 'key2', value: 'value2')]) + ) + ); + $input = BucketTags::fromPutBucketTags($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<key1value1key2value2 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketTags() + { + // empty output + $output = new OperationOutput(); + $result = BucketTags::toPutBucketTags($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketTags::toPutBucketTags($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketTags() + { + // miss required field + try { + $request = new Models\GetBucketTagsRequest(); + $input = BucketTags::fromGetBucketTags($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketTagsRequest('bucket-123'); + $input = BucketTags::fromGetBucketTags($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketTags() + { + // empty output + $output = new OperationOutput(); + $result = BucketTags::toGetBucketTags($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + + testa + testv1 + + + testb + testv2 + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($body) + ); + $result = BucketTags::toGetBucketTags($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals(2, count($result->tagging->tagSet->tags)); + $this->assertEquals('testa', $result->tagging->tagSet->tags[0]->key); + $this->assertEquals('testv2', $result->tagging->tagSet->tags[1]->value); + } + + public function testFromDeleteBucketTags() + { + // miss required field + try { + $request = new Models\DeleteBucketTagsRequest(); + $input = BucketTags::fromDeleteBucketTags($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketTagsRequest('bucket-123'); + $input = BucketTags::fromDeleteBucketTags($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + + $request = new Models\DeleteBucketTagsRequest('bucket-123', tagging: 'k1,k2'); + $input = BucketTags::fromDeleteBucketTags($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('k1,k2', $input->getParameters()['tagging']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketTags() + { + // empty output + $output = new OperationOutput(); + $result = BucketTags::toDeleteBucketTags($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketTags::toDeleteBucketTags($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTransferAccelerationTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTransferAccelerationTest.php new file mode 100644 index 0000000..ecac316 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketTransferAccelerationTest.php @@ -0,0 +1,133 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketTransferAccelerationRequest('bucket-123'); + $input = BucketTransferAcceleration::fromPutBucketTransferAcceleration($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, transferAccelerationConfiguration", (string)$e); + } + + $request = new Models\PutBucketTransferAccelerationRequest('bucket-123', new Models\TransferAccelerationConfiguration( + true + )); + $input = BucketTransferAcceleration::fromPutBucketTransferAcceleration($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<true +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketTransferAcceleration() + { + // empty output + $output = new OperationOutput(); + $result = BucketTransferAcceleration::toPutBucketTransferAcceleration($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketTransferAcceleration::toPutBucketTransferAcceleration($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketTransferAcceleration() + { + // miss required field + try { + $request = new Models\GetBucketTransferAccelerationRequest(); + $input = BucketTransferAcceleration::fromGetBucketTransferAcceleration($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketTransferAccelerationRequest('bucket-123'); + $input = BucketTransferAcceleration::fromGetBucketTransferAcceleration($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketTransferAcceleration() + { + // empty output + $output = new OperationOutput(); + $result = BucketTransferAcceleration::toGetBucketTransferAcceleration($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + true +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketTransferAcceleration::toGetBucketTransferAcceleration($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertTrue($result->transferAccelerationConfiguration->enabled); + + $body = ' + + false +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketTransferAcceleration::toGetBucketTransferAcceleration($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertFalse($result->transferAccelerationConfiguration->enabled); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWebsiteTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWebsiteTest.php new file mode 100644 index 0000000..9a6274d --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWebsiteTest.php @@ -0,0 +1,590 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutBucketWebsiteRequest('bucket-123'); + $input = BucketWebsite::fromPutBucketWebsite($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, websiteConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutBucketWebsiteRequest('bucket-123'); + $request->websiteConfiguration = new Models\WebsiteConfiguration( + new Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + new Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ), + new Models\RoutingRules([ + new Models\RoutingRule( + redirect: new Models\RoutingRuleRedirect( + redirectType: 'Mirror', + mirrorURL: 'http://example.com/', + mirrorPassQueryString: true, + mirrorCheckMd5: true, + mirrorFollowRedirect: true, + mirrorHeaders: new Models\MirrorHeaders( + passs: ["myheader-key1", "myheader-key2"], + sets: array( + new Models\MirrorHeaderSet(key: 'myheader-key5', value: 'myheader-value5'), + ), + passAll: true, + ), + passQueryString: true, + ), + ruleNumber: 1, + condition: new Models\RoutingRuleCondition( + keyPrefixEquals: 'abc/', + httpErrorCodeReturnedEquals: 404, + ) + ), + new Models\RoutingRule( + redirect: new Models\RoutingRuleRedirect( + redirectType: 'AliCDN', + protocol: 'http', + replaceKeyPrefixWith: 'prefix/${key}.suffix', + hostName: 'example.com', + passQueryString: false, + httpRedirectCode: 301 + ), + ruleNumber: 2, + condition: new Models\RoutingRuleCondition( + keyPrefixEquals: 'abc/', + httpErrorCodeReturnedEquals: 404, + includeHeaders: [ + new Models\RoutingRuleIncludeHeader( + key: 'host', + equals: 'test.oss-cn-beijing-internal.aliyuncs.com', + ) + ] + ) + ), + new Models\RoutingRule( + redirect: new Models\RoutingRuleRedirect( + redirectType: 'External', + protocol: 'http', + replaceKeyPrefixWith: 'prefix/${key}', + hostName: 'example.com', + passQueryString: false, + enableReplacePrefix: false, + httpRedirectCode: 302, + ), + ruleNumber: 3, + condition: new Models\RoutingRuleCondition( + httpErrorCodeReturnedEquals: 404, + ) + ) + ]) + ); + $input = BucketWebsite::fromPutBucketWebsite($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = 'index.htmltrue0error.html404Mirrorhttp://example.com/truetruetruemyheader-key1myheader-key2myheader-key5myheader-value5truetrue1abc/404AliCDNhttpprefix/${key}.suffixexample.comfalse3012abc/404hosttest.oss-cn-beijing-internal.aliyuncs.comExternalhttpprefix/${key}example.comfalsefalse3023404'; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + // demo2 + $request = new Models\PutBucketWebsiteRequest('bucket-123'); + $request->websiteConfiguration = new Models\WebsiteConfiguration( + new Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + new Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ), + new Models\RoutingRules([ + new Models\RoutingRule( + redirect: new Models\RoutingRuleRedirect( + mirrorPassOriginalSlashes: false, + redirectType: 'Mirror', + mirrorURL: 'http://example.com/', + mirrorPassQueryString: true, + mirrorCheckMd5: true, + mirrorSNI: true, + replaceKeyPrefixWith: "def/", + mirrorFollowRedirect: true, + hostName: "example.com", + mirrorHeaders: new Models\MirrorHeaders( + passs: ["myheader-key1", "myheader-key2"], + sets: array( + new Models\MirrorHeaderSet(key: 'myheader-key5', value: 'myheader-value5'), + ), + passAll: true, + ), + passQueryString: true, + enableReplacePrefix: true, + httpRedirectCode: 301, + mirrorURLSlave: 'http://example.com/', + mirrorSaveOssMeta: true, + mirrorProxyPass: false, + mirrorAllowGetImageInfo: true, + mirrorAllowVideoSnapshot: false, + mirrorIsExpressTunnel: true, + mirrorDstRegion: 'cn-hangzhou', + mirrorDstVpcId: 'vpc-test-id', + mirrorDstSlaveVpcId: 'vpc-test-id', + mirrorUserLastModified: false, + mirrorSwitchAllErrors: true, + mirrorTunnelId: 'test-tunnel-id', + mirrorUsingRole: false, + mirrorRole: 'aliyun-test-role', + mirrorAllowHeadObject: true, + transparentMirrorResponseCodes: '400', + mirrorAsyncStatus: 303, + mirrorTaggings: new Models\MirrorTaggings( + taggings: [new Models\MirrorTagging( + value: 'v', + key: 'k' + )] + ), + mirrorReturnHeaders: new Models\MirrorReturnHeaders( + returnHeaders: [ + new Models\ReturnHeader( + key: 'k', + value: 'v' + ) + ] + ), + mirrorAuth: new Models\MirrorAuth( + 'S3V4', 'ap-southeast-1', 'TESTAK', 'TESTSK' + ), + mirrorMultiAlternates: new Models\MirrorMultiAlternates( + [ + new Models\MirrorMultiAlternate( + mirrorMultiAlternateNumber: 32, mirrorMultiAlternateURL: 'https://test-multi-alter.example.com', mirrorMultiAlternateVpcId: 'vpc-test-id', mirrorMultiAlternateDstRegion: 'ap-southeast-1' + ) + ] + ) + ), + ruleNumber: 1, + condition: new Models\RoutingRuleCondition( + keyPrefixEquals: 'abc/', + keySuffixEquals: ".txt", + httpErrorCodeReturnedEquals: 404, + ), + luaConfig: new Models\RoutingRuleLuaConfig( + script: "test.lua", + ) + ), + new Models\RoutingRule( + redirect: new Models\RoutingRuleRedirect( + redirectType: 'AliCDN', + mirrorURL: 'http://example.com/', + mirrorPassQueryString: true, + mirrorCheckMd5: true, + mirrorSNI: true, + protocol: 'http', + mirrorFollowRedirect: true, + mirrorHeaders: new Models\MirrorHeaders( + passs: ["myheader-key1", "myheader-key2"], + sets: array( + new Models\MirrorHeaderSet(key: 'myheader-key5', value: 'myheader-value5'), + ), + passAll: true, + ), + passQueryString: true, + replaceKeyWith: "abc", + ), + ruleNumber: 2, + condition: new Models\RoutingRuleCondition( + keyPrefixEquals: 'abc/', + keySuffixEquals: ".txt", + httpErrorCodeReturnedEquals: 404, + ), + luaConfig: new Models\RoutingRuleLuaConfig( + script: "test.lua", + ) + ), + ]), + ); + $input = BucketWebsite::fromPutBucketWebsite($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<index.htmltrue0error.html404falseMirrorhttp://example.com/truetruetruedef/trueexample.commyheader-key1myheader-key2myheader-key5myheader-value5truetruetrue301http://example.com/truefalsetruefalsetruecn-hangzhouvpc-test-idvpc-test-idfalsetruetest-tunnel-idfalsealiyun-test-roletrue400303vkkvS3V4ap-southeast-1TESTAKTESTSK32https://test-multi-alter.example.comvpc-test-idap-southeast-11abc/.txt404AliCDNhttp://example.com/truetruetruehttptruemyheader-key1myheader-key2myheader-key5myheader-value5truetrueabc2abc/.txt404 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + + $request = new Models\PutBucketWebsiteRequest('bucket-123'); + $request->websiteConfiguration = new Models\WebsiteConfiguration( + new Models\IndexDocument( + suffix: 'index.html', supportSubDir: true, type: 0 + ), + new Models\ErrorDocument( + key: 'error.html', httpStatus: 404 + ) + ); + $input = BucketWebsite::fromPutBucketWebsite($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $xml = <<index.htmltrue0error.html404 +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutBucketWebsite() + { + // empty output + $output = new OperationOutput(); + $result = BucketWebsite::toPutBucketWebsite($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketWebsite::toPutBucketWebsite($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketWebsite() + { + // miss required field + try { + $request = new Models\GetBucketWebsiteRequest(); + $input = BucketWebsite::fromGetBucketWebsite($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketWebsiteRequest('bucket-123'); + $input = BucketWebsite::fromGetBucketWebsite($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketWebsite() + { + // empty output + $output = new OperationOutput(); + $result = BucketWebsite::toGetBucketWebsite($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + index.html + + + error.html + 404 + + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketWebsite::toGetBucketWebsite($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('index.html', $result->websiteConfiguration->indexDocument->suffix); + $this->assertNull($result->websiteConfiguration->indexDocument->supportSubDir); + $this->assertNull($result->websiteConfiguration->indexDocument->type); + $this->assertEquals('error.html', $result->websiteConfiguration->errorDocument->key); + $this->assertEquals('404', $result->websiteConfiguration->errorDocument->httpStatus); + + $body = ' + + index.html + true + 0 + + + error.html + 404 + + + + 1 + + abc/ + 404 + + + Mirror + true + http://example.com/ + true + true + false + + true + myheader-key1 + myheader-key2 + myheader-key3 + myheader-key4 + + myheader-key5 + myheader-value5 + + + + + + 2 + + abc/ + 404 + + host + test.oss-cn-beijing-internal.aliyuncs.com + + + + AliCDN + http + example.com + false + prefix/${key}.suffix + 301 + + + + + 404 + + 3 + + prefix/${key} + 302 + false + false + http + example.com + External + + + + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketWebsite::toGetBucketWebsite($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('index.html', $result->websiteConfiguration->indexDocument->suffix); + $this->assertTrue($result->websiteConfiguration->indexDocument->supportSubDir); + $this->assertEquals(0, $result->websiteConfiguration->indexDocument->type); + $this->assertEquals('error.html', $result->websiteConfiguration->errorDocument->key); + $this->assertEquals('404', $result->websiteConfiguration->errorDocument->httpStatus); + $this->assertEquals(3, count($result->websiteConfiguration->routingRules->routingRules)); + $this->assertEquals(1, $result->websiteConfiguration->routingRules->routingRules[0]->ruleNumber); + $this->assertEquals('abc/', $result->websiteConfiguration->routingRules->routingRules[0]->condition->keyPrefixEquals); + $this->assertEquals(404, $result->websiteConfiguration->routingRules->routingRules[0]->condition->httpErrorCodeReturnedEquals); + $this->assertEquals('Mirror', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->redirectType); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->passQueryString); + $this->assertEquals('http://example.com/', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorURL); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorPassQueryString); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorFollowRedirect); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorCheckMd5); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->passAll); + $this->assertEquals('myheader-key1', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->passs[0]); + $this->assertEquals('myheader-key2', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->passs[1]); + $this->assertEquals('myheader-key3', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->removes[0]); + $this->assertEquals('myheader-key4', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->removes[1]); + $this->assertEquals('myheader-key5', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->sets[0]->key); + $this->assertEquals('myheader-value5', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->sets[0]->value); + + $this->assertEquals(2, $result->websiteConfiguration->routingRules->routingRules[1]->ruleNumber); + $this->assertEquals('abc/', $result->websiteConfiguration->routingRules->routingRules[1]->condition->keyPrefixEquals); + $this->assertEquals(404, $result->websiteConfiguration->routingRules->routingRules[1]->condition->httpErrorCodeReturnedEquals); + $this->assertEquals('host', $result->websiteConfiguration->routingRules->routingRules[1]->condition->includeHeaders[0]->key); + $this->assertEquals('test.oss-cn-beijing-internal.aliyuncs.com', $result->websiteConfiguration->routingRules->routingRules[1]->condition->includeHeaders[0]->equals); + $this->assertEquals('AliCDN', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->redirectType); + $this->assertEquals('http', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->protocol); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[1]->redirect->passQueryString); + $this->assertEquals('prefix/${key}.suffix', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->replaceKeyWith); + $this->assertEquals(301, $result->websiteConfiguration->routingRules->routingRules[1]->redirect->httpRedirectCode); + + $this->assertEquals(3, $result->websiteConfiguration->routingRules->routingRules[2]->ruleNumber); + $this->assertEquals('External', $result->websiteConfiguration->routingRules->routingRules[2]->redirect->redirectType); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[2]->redirect->passQueryString); + $this->assertEquals('prefix/${key}', $result->websiteConfiguration->routingRules->routingRules[2]->redirect->replaceKeyWith); + $this->assertEquals(302, $result->websiteConfiguration->routingRules->routingRules[2]->redirect->httpRedirectCode); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[2]->redirect->enableReplacePrefix); + $this->assertEquals('http', $result->websiteConfiguration->routingRules->routingRules[2]->redirect->protocol); + $this->assertEquals('example.com', $result->websiteConfiguration->routingRules->routingRules[2]->redirect->hostName); + + $body = <<index.htmltrue0error.html404falseMirrorhttp://example.com/truetruetruedef/trueexample.commyheader-key1myheader-key2myheader-key5myheader-value5truetruetrue301http://example.com/truefalsetruefalsetruecn-hangzhouvpc-test-idvpc-test-idfalsetruetest-tunnel-idfalsealiyun-test-roletrue400303vkkvS3V4ap-southeast-1TESTAKTESTSK32https://test-multi-alter.example.comvpc-test-idap-southeast-11abc/.txt404AliCDNhttp://example.com/truetruetruehttptruemyheader-key1myheader-key2myheader-key5myheader-value5truetrueabc2abc/.txt404 +BBB; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = BucketWebsite::toGetBucketWebsite($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('index.html', $result->websiteConfiguration->indexDocument->suffix); + $this->assertTrue($result->websiteConfiguration->indexDocument->supportSubDir); + $this->assertEquals(0, $result->websiteConfiguration->indexDocument->type); + $this->assertEquals('error.html', $result->websiteConfiguration->errorDocument->key); + $this->assertEquals('404', $result->websiteConfiguration->errorDocument->httpStatus); + $this->assertEquals(2, count($result->websiteConfiguration->routingRules->routingRules)); + $this->assertEquals(1, $result->websiteConfiguration->routingRules->routingRules[0]->ruleNumber); + $this->assertEquals('abc/', $result->websiteConfiguration->routingRules->routingRules[0]->condition->keyPrefixEquals); + $this->assertEquals('.txt', $result->websiteConfiguration->routingRules->routingRules[0]->condition->keySuffixEquals); + $this->assertEquals(404, $result->websiteConfiguration->routingRules->routingRules[0]->condition->httpErrorCodeReturnedEquals); + + $this->assertEquals('Mirror', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->redirectType); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorPassOriginalSlashes); + $this->assertEquals('http://example.com/', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorURL); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorPassQueryString); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorCheckMd5); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorSNI); + $this->assertEquals('def/', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->replaceKeyPrefixWith); + $this->assertEquals('example.com', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->hostName); + $this->assertEquals('myheader-key1', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->passs[0]); + $this->assertEquals('myheader-key2', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->passs[1]); + $this->assertEquals('myheader-key5', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->sets[0]->key); + $this->assertEquals('myheader-value5', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->sets[0]->value); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorHeaders->passAll); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->passQueryString); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->enableReplacePrefix); + $this->assertEquals(301, $result->websiteConfiguration->routingRules->routingRules[0]->redirect->httpRedirectCode); + $this->assertEquals('http://example.com/', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorURLSlave); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorSaveOssMeta); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorProxyPass); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAllowGetImageInfo); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAllowVideoSnapshot); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorIsExpressTunnel); + $this->assertEquals('cn-hangzhou', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorDstRegion); + $this->assertEquals('vpc-test-id', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorDstVpcId); + $this->assertEquals('vpc-test-id', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorDstSlaveVpcId); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorUserLastModified); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorSwitchAllErrors); + $this->assertEquals('test-tunnel-id', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorTunnelId); + $this->assertFalse($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorUsingRole); + $this->assertEquals('aliyun-test-role', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorRole); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAllowHeadObject); + $this->assertEquals("400", $result->websiteConfiguration->routingRules->routingRules[0]->redirect->transparentMirrorResponseCodes); + $this->assertEquals(303, $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAsyncStatus); + $this->assertEquals('k', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorTaggings->taggings[0]->key); + $this->assertEquals('v', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorTaggings->taggings[0]->value); + $this->assertEquals('k', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorReturnHeaders->returnHeaders[0]->key); + $this->assertEquals('v', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorReturnHeaders->returnHeaders[0]->value); + $this->assertEquals('S3V4', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAuth->authType); + $this->assertEquals('ap-southeast-1', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAuth->region); + $this->assertEquals('TESTAK', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAuth->accessKeyId); + $this->assertEquals('TESTSK', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorAuth->accessKeySecret); + $this->assertEquals(32, $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorMultiAlternates->mirrorMultiAlternates[0]->mirrorMultiAlternateNumber); + $this->assertEquals('https://test-multi-alter.example.com', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorMultiAlternates->mirrorMultiAlternates[0]->mirrorMultiAlternateURL); + $this->assertEquals('vpc-test-id', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorMultiAlternates->mirrorMultiAlternates[0]->mirrorMultiAlternateVpcId); + $this->assertEquals('ap-southeast-1', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorMultiAlternates->mirrorMultiAlternates[0]->mirrorMultiAlternateDstRegion); + $this->assertEquals('test.lua', $result->websiteConfiguration->routingRules->routingRules[0]->luaConfig->script); + + + $this->assertEquals(2, $result->websiteConfiguration->routingRules->routingRules[1]->ruleNumber); + + $this->assertEquals('abc/', $result->websiteConfiguration->routingRules->routingRules[1]->condition->keyPrefixEquals); + $this->assertEquals('.txt', $result->websiteConfiguration->routingRules->routingRules[1]->condition->keySuffixEquals); + $this->assertEquals(404, $result->websiteConfiguration->routingRules->routingRules[1]->condition->httpErrorCodeReturnedEquals); + + $this->assertEquals('AliCDN', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->redirectType); + $this->assertEquals('http', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->protocol); + $this->assertEquals('test.lua', $result->websiteConfiguration->routingRules->routingRules[0]->luaConfig->script); + $this->assertEquals('http://example.com/', $result->websiteConfiguration->routingRules->routingRules[0]->redirect->mirrorURL); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorPassQueryString); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorCheckMd5); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorSNI); + $this->assertEquals('myheader-key1', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorHeaders->passs[0]); + $this->assertEquals('myheader-key2', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorHeaders->passs[1]); + $this->assertEquals('myheader-key5', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorHeaders->sets[0]->key); + $this->assertEquals('myheader-value5', $result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorHeaders->sets[0]->value); + $this->assertTrue($result->websiteConfiguration->routingRules->routingRules[1]->redirect->mirrorHeaders->passAll); + } + + public function testFromDeleteBucketWebsite() + { + // miss required field + try { + $request = new Models\DeleteBucketWebsiteRequest(); + $input = BucketWebsite::fromDeleteBucketWebsite($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\DeleteBucketWebsiteRequest('bucket-123'); + $input = BucketWebsite::fromDeleteBucketWebsite($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeleteBucketWebsite() + { + // empty output + $output = new OperationOutput(); + $result = BucketWebsite::toDeleteBucketWebsite($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketWebsite::toDeleteBucketWebsite($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWormTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWormTest.php new file mode 100644 index 0000000..7ef0b49 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/BucketWormTest.php @@ -0,0 +1,276 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\InitiateBucketWormRequest('bucket-123'); + $input = BucketWorm::fromInitiateBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, initiateWormConfiguration", (string)$e); + } + + // all settings + $request = new Models\InitiateBucketWormRequest( + bucket: 'bucket-123', + initiateWormConfiguration: new Models\InitiateWormConfiguration(retentionPeriodInDays: 3) + ); + $xml = <<3 +BBB; + + $input = BucketWorm::fromInitiateBucketWorm($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals(base64_encode(md5($input->getBody(), true)), $input->getHeaders()['content-md5']); + } + + public function testToInitiateBucketWorm() + { + // empty output + $output = new OperationOutput(); + $result = BucketWorm::toInitiateBucketWorm($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'x-oss-worm-id' => '234'] + ); + $result = BucketWorm::toInitiateBucketWorm($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('234', $result->wormId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromAbortBucketWorm() + { + // miss required field + try { + $request = new Models\AbortBucketWormRequest(); + $input = BucketWorm::fromAbortBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\AbortBucketWormRequest('bucket-123'); + $input = BucketWorm::fromAbortBucketWorm($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToAbortBucketWorm() + { + // empty output + $output = new OperationOutput(); + $result = BucketWorm::toAbortBucketWorm($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = BucketWorm::toAbortBucketWorm($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromCompleteBucketWorm() + { + // miss required field + try { + $request = new Models\CompleteBucketWormRequest(); + $input = BucketWorm::fromCompleteBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CompleteBucketWormRequest('bucket-123'); + $input = BucketWorm::fromCompleteBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, wormId", (string)$e); + } + + $request = new Models\CompleteBucketWormRequest('bucket-123', 'wormId-123'); + $input = BucketWorm::fromCompleteBucketWorm($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('wormId-123', $input->getParameters()['wormId']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToCompleteBucketWorm() + { + // empty output + $output = new OperationOutput(); + $result = BucketWorm::toCompleteBucketWorm($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketWorm::toCompleteBucketWorm($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromExtendBucketWorm() + { + // miss required field + try { + $request = new Models\ExtendBucketWormRequest(); + $input = BucketWorm::fromExtendBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\ExtendBucketWormRequest('bucket-123'); + $input = BucketWorm::fromExtendBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, wormId", (string)$e); + } + + try { + $request = new Models\ExtendBucketWormRequest('bucket-123', 'wormId-123'); + $input = BucketWorm::fromExtendBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString($e->getMessage(), "missing required field, extendWormConfiguration.", (string)$e); + } + + $xml = <<3 +BBB; + $request = new Models\ExtendBucketWormRequest('bucket-123', 'wormId-123', new Models\ExtendWormConfiguration(3)); + $input = BucketWorm::fromExtendBucketWorm($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('wormId-123', $input->getParameters()['wormId']); + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + $this->assertEquals(base64_encode(md5($input->getBody(), true)), $input->getHeaders()['content-md5']); + } + + public function testToExtendBucketWorm() + { + // empty output + $output = new OperationOutput(); + $result = BucketWorm::toExtendBucketWorm($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = BucketWorm::toCompleteBucketWorm($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetBucketWorm() + { + // miss required field + try { + $request = new Models\GetBucketWormRequest(); + $input = BucketWorm::fromGetBucketWorm($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + $request = new Models\GetBucketWormRequest('bucket-123'); + $input = BucketWorm::fromGetBucketWorm($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetBucketWorm() + { + // empty output + $output = new OperationOutput(); + $result = BucketWorm::toGetBucketWorm($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor(' + 1666E2CFB2B3418**** + Locked + 1 + 2020-10-15T15:50:32 +') + ); + $result = BucketWorm::toGetBucketWorm($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertCount(2, $result->headers); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('1666E2CFB2B3418****', $result->wormConfiguration->wormId); + $this->assertEquals('Locked', $result->wormConfiguration->state); + $this->assertEquals(1, $result->wormConfiguration->retentionPeriodInDays); + $this->assertEquals("2020-10-15T15:50:32", $result->wormConfiguration->creationDate); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/CloudBoxesTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/CloudBoxesTest.php new file mode 100644 index 0000000..9bfe68f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/CloudBoxesTest.php @@ -0,0 +1,85 @@ +assertEquals('', $input->getParameters()['cloudboxes']); + $this->assertEquals('', $input->getParameters()['marker']); + $this->assertEquals('10', $input->getParameters()['max-keys']); + $this->assertEquals('/', $input->getParameters()['prefix']); + } + + public function testToListCloudBoxes() + { + // empty output + $output = new OperationOutput(); + $result = CloudBoxes::toListCloudBoxes($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + + 51264 + 51264 + + + + cb-f8z7yvzgwfkl9q0h**** + bucket1 + cn-shanghai + cb-f8z7yvzgwfkl9q0h****.cn-shanghai.oss-cloudbox-control.aliyuncs.com + cb-f8z7yvzgwfkl9q0h****.cn-shanghai.oss-cloudbox.aliyuncs.com + + + cb-f9z7yvzgwfkl9q0h**** + bucket2 + cn-hangzhou + cb-f9z7yvzgwfkl9q0h****.cn-hangzhou.oss-cloudbox-control.aliyuncs.com + cb-f9z7yvzgwfkl9q0h****.cn-hangzhou.oss-cloudbox.aliyuncs.com + + +'; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + body: Utils::streamFor($body) + ); + $result = CloudBoxes::toListCloudBoxes($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('51264', $result->listCloudBoxes->owner->id); + $this->assertEquals('51264', $result->listCloudBoxes->owner->displayName); + $this->assertEquals(2, count($result->listCloudBoxes->cloudBoxes->cloudBox)); + $this->assertEquals('cb-f8z7yvzgwfkl9q0h****', $result->listCloudBoxes->cloudBoxes->cloudBox[0]->id); + $this->assertEquals('cb-f8z7yvzgwfkl9q0h****.cn-shanghai.oss-cloudbox.aliyuncs.com', $result->listCloudBoxes->cloudBoxes->cloudBox[0]->dataEndpoint); + $this->assertEquals('cb-f8z7yvzgwfkl9q0h****.cn-shanghai.oss-cloudbox-control.aliyuncs.com', $result->listCloudBoxes->cloudBoxes->cloudBox[0]->controlEndpoint); + $this->assertEquals('bucket1', $result->listCloudBoxes->cloudBoxes->cloudBox[0]->name); + $this->assertEquals('cn-shanghai', $result->listCloudBoxes->cloudBoxes->cloudBox[0]->region); + $this->assertEquals('cb-f9z7yvzgwfkl9q0h****', $result->listCloudBoxes->cloudBoxes->cloudBox[1]->id); + $this->assertEquals('cb-f9z7yvzgwfkl9q0h****.cn-hangzhou.oss-cloudbox.aliyuncs.com', $result->listCloudBoxes->cloudBoxes->cloudBox[1]->dataEndpoint); + $this->assertEquals('cb-f9z7yvzgwfkl9q0h****.cn-hangzhou.oss-cloudbox-control.aliyuncs.com', $result->listCloudBoxes->cloudBoxes->cloudBox[1]->controlEndpoint); + $this->assertEquals('bucket2', $result->listCloudBoxes->cloudBoxes->cloudBox[1]->name); + $this->assertEquals('cn-hangzhou', $result->listCloudBoxes->cloudBoxes->cloudBox[1]->region); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/FunctionsTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/FunctionsTest.php new file mode 100644 index 0000000..e36c287 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/FunctionsTest.php @@ -0,0 +1,105 @@ +assertStringContainsString('missing required field, field', $e); + } + + Functions::assertFieldRequired('field', 'hello world'); + } + + public function testAssertXmlRoot() + { + try { + Functions::assertXmlRoot('', ''); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag', $e); + } + + try { + Functions::assertXmlRoot('', ''); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag', $e); + } + + try { + Functions::assertXmlRoot('', '123'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag', $e); + } + + Functions::assertXmlRoot('', 'Root'); + Functions::assertXmlRoot('', 'Root'); + Functions::assertXmlRoot('', 'Root'); + + $str = ' + + str1 + str2 + + str-sub + 1234 + + '; + try { + Functions::assertXmlRoot($str, 'Configuration'); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag', $e); + } + + } + + + public function testtryToDatetime() + { + $elem = new \SimpleXMLElement('2023-12-17T03:30:09Zinvalid value'); + $this->assertNull(Functions::tryToDatetime($elem->NoNode)); + $this->assertNull(Functions::tryToDatetime($elem->Data1)); + $datetimeUtc = new \DateTime(); + $datetimeUtc->setTimestamp(1702783809); + $this->assertEquals($datetimeUtc, Functions::tryToDatetime($elem->Data)); + } + + public function testtryToBool() + { + $elem = new \SimpleXMLElement('Truetruefalse'); + $this->assertNull(Functions::tryToBool($elem->NoNode)); + $this->assertEquals(true, Functions::tryToBool($elem->Data)); + $this->assertEquals(true, Functions::tryToBool($elem->Data1)); + $this->assertEquals(false, Functions::tryToBool($elem->Data2)); + $this->assertNotNull(Functions::tryToBool($elem->DataEmpty)); + $this->assertEquals(false, Functions::tryToBool($elem->DataEmpty)); + } + + public function testtryToInt() + { + $elem = new \SimpleXMLElement('1230invalid value'); + $this->assertNull(Functions::tryToInt($elem->NoNode)); + $this->assertEquals(123, Functions::tryToInt($elem->Data)); + $this->assertEquals(0, Functions::tryToInt($elem->Data1)); + $this->assertEquals(0, Functions::tryToInt($elem->Data2)); + $this->assertNotNull(Functions::tryToInt($elem->DataEmpty)); + $this->assertEquals(0, Functions::tryToInt($elem->DataEmpty)); + } + + public function testtryToString() + { + $elem = new \SimpleXMLElement('1230'); + $this->assertNull(Functions::tryToString($elem->NoNode)); + $this->assertEquals('123', Functions::tryToString($elem->Data)); + $this->assertEquals('0', Functions::tryToString($elem->Data1)); + $this->assertNotNull(Functions::tryToString($elem->Data2)); + $this->assertEquals('', Functions::tryToString($elem->Data2)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectBasicTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectBasicTest.php new file mode 100644 index 0000000..f0c0117 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectBasicTest.php @@ -0,0 +1,2903 @@ +assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteMultipleObjectsRequest('bucket-123'); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, objects", (string)$e); + } + + try { + $request = new Models\DeleteMultipleObjectsRequest('bucket-123'); + $request->objects = [ + new Models\DeleteObject('key1'), + new Models\DeleteObject('key2', 'version-id-2'), + ]; + $request->delete = new Models\Delete([ + new Models\ObjectIdentifier('key1'), + new Models\ObjectIdentifier('key2', 'version-id-2'), + ], true); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("InvalidArgumentException: The objects and delete parameters cannot be set simultaneously", (string)$e); + } + + try { + $request = new Models\DeleteMultipleObjectsRequest('bucket-123'); + $request->delete = new Models\Delete(); + $request->delete->quiet = true; + $input = ObjectBasic::fromDeleteMultipleObjects($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, delete.objects", (string)$e); + } + + + // bucket only + $request = new Models\DeleteMultipleObjectsRequest('bucket-123', []); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('D0iFyCSGo62Kd/zfca7aPg==', $input->getHeaders()['content-md5']); + $this->assertEquals('url', $input->getParameters()['encoding-type']); + + // no quiet + $request = new Models\DeleteMultipleObjectsRequest( + 'bucket-123', + [ + new Models\DeleteObject('key1'), + new Models\DeleteObject('key2', 'version-id-2'), + ], + 'url1', + null, + 'request-payer' + ); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('CNLPZjtD0MZNPvjKGf3yBg==', $input->getHeaders()['content-md5']); + $this->assertEquals('request-payer', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals('url1', $input->getParameters()['encoding-type']); + + $str = $input->getBody()->getContents(); + $this->assertStringContainsString('', $str); + $xml = \simplexml_load_string($str); + $this->assertEquals(2, $xml->count()); + $this->assertEquals(false, isset($xml->Quiet)); + $this->assertEquals(2, $xml->Object->count()); + $this->assertEquals('key1', $xml->Object[0]->Key); + $this->assertEquals(false, isset($xml->Object[0]->VersionId)); + $this->assertEquals('key2', $xml->Object[1]->Key); + $this->assertEquals('version-id-2', $xml->Object[1]->VersionId); + + + // all settings + $xmlStr = <<truekey1key2version-id-2 +BBB; + + $request = new Models\DeleteMultipleObjectsRequest( + 'bucket-123', + [ + new Models\DeleteObject('key1'), + new Models\DeleteObject('key2', 'version-id-2'), + ], + 'url1', + true, + 'request-payer' + ); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('BesWzihB4UGzEXQLrXWg0w==', $input->getHeaders()['content-md5']); + $this->assertEquals('request-payer', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals('url1', $input->getParameters()['encoding-type']); + + $str = $input->getBody()->getContents(); + $this->assertEquals($xmlStr, $this->cleanXml($str)); + $this->assertStringContainsString('', $str); + $xml = \simplexml_load_string($str); + $this->assertEquals(3, $xml->count()); + $this->assertEquals('true', $xml->Quiet); + $this->assertEquals(2, $xml->Object->count()); + $this->assertEquals('key1', $xml->Object[0]->Key); + $this->assertEquals(false, isset($xml->Object[0]->VersionId)); + $this->assertEquals('key2', $xml->Object[1]->Key); + $this->assertEquals('version-id-2', $xml->Object[1]->VersionId); + + // extend header & parameters + $request = new Models\DeleteMultipleObjectsRequest( + 'bucket-123', + [], + null, + null, + null, + [ + 'headers' => ['x-oss-test' => 'test-123'], + 'parameters' => ['x-oss-param' => 'param-123'] + ], + null, + ); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('D0iFyCSGo62Kd/zfca7aPg==', $input->getHeaders()['content-md5']); + $this->assertEquals('test-123', $input->getHeaders()['x-oss-test']); + $this->assertEquals('param-123', $input->getParameters()['x-oss-param']); + + $request = new Models\DeleteMultipleObjectsRequest( + 'bucket-123', + ); + $request->delete = new Models\Delete( + [ + new Models\ObjectIdentifier('key1'), + new Models\ObjectIdentifier('key2', 'version-id-2'), + ], true + ); + $input = ObjectBasic::fromDeleteMultipleObjects($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('application/xml', $input->getHeaders()['content-type']); + $this->assertEquals('BesWzihB4UGzEXQLrXWg0w==', $input->getHeaders()['content-md5']); + $this->assertEquals($xmlStr, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToDeleteMultipleObjects() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toDeleteMultipleObjects($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = ObjectBasic::toDeleteMultipleObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->deletedObjects); + $this->assertNull($result->encodingType); + + // xml + $str = ' + + + multipart.data + + + test.jpg + + + demo.jpg + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = ObjectBasic::toDeleteMultipleObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(3, count($result->deletedObjects)); + $this->assertEquals('multipart.data', $result->deletedObjects[0]->key); + $this->assertNull($result->deletedObjects[0]->versionId); + $this->assertNull($result->deletedObjects[0]->deleteMarker); + $this->assertNull($result->deletedObjects[0]->deleteMarkerVersionId); + + $this->assertEquals('test.jpg', $result->deletedObjects[1]->key); + $this->assertEquals('demo.jpg', $result->deletedObjects[2]->key); + + // encodingType + $str = ' + + url + + 123%2Fmultipart.data + + + 135%2Ftest.jpg + + + 136%2Fdemo.jpg + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = ObjectBasic::toDeleteMultipleObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(3, count($result->deletedObjects)); + $this->assertEquals('123/multipart.data', $result->deletedObjects[0]->key); + $this->assertNull($result->deletedObjects[0]->versionId); + $this->assertNull($result->deletedObjects[0]->deleteMarker); + $this->assertNull($result->deletedObjects[0]->deleteMarkerVersionId); + + $this->assertEquals('135/test.jpg', $result->deletedObjects[1]->key); + $this->assertEquals('136/demo.jpg', $result->deletedObjects[2]->key); + + // xml + $str = ' + + + multipart.data + CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4**** + + + demo.jpg + CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk**** + true + THUQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk**** + + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str) + ); + $result = ObjectBasic::toDeleteMultipleObjects($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(2, count($result->deletedObjects)); + $this->assertEquals('multipart.data', $result->deletedObjects[0]->key); + $this->assertEquals('CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****', $result->deletedObjects[0]->versionId); + $this->assertNull($result->deletedObjects[0]->deleteMarker); + $this->assertNull($result->deletedObjects[0]->deleteMarkerVersionId); + + $this->assertEquals('demo.jpg', $result->deletedObjects[1]->key); + $this->assertEquals('CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****', $result->deletedObjects[1]->versionId); + $this->assertEquals(true, $result->deletedObjects[1]->deleteMarker); + $this->assertEquals('THUQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****', $result->deletedObjects[1]->deleteMarkerVersionId); + } + + public function testFromPutObject() + { + // miss required field + try { + $request = new Models\PutObjectRequest(); + $input = ObjectBasic::fromPutObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutObjectRequest('bucket-123'); + $input = ObjectBasic::fromPutObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\PutObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123'); + $request->cacheControl = 'no-cache'; + $request->contentDisposition = 'attachment'; + $request->contentEncoding = 'utf-8'; + $request->contentMd5 = 'eB5eJF1ptWaXm4bijSPyxw=='; + $request->contentLength = 100; + $request->expires = '2022-10-12T00:00:00.000Z'; + $request->forbidOverwrite = true; + $request->serverSideEncryption = 'AES256'; + $request->acl = Models\ObjectACLType::PRIVATE; + $request->storageClass = Models\StorageClassType::STANDARD; + $request->metadata = array( + "location" => "demo", + "user" => "walker", + ); + $request->tagging = 'TagA=A&TagB=B'; + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + $this->assertEquals('no-cache', $input->getHeaders()['cache-control']); + $this->assertEquals('attachment', $input->getHeaders()['content-disposition']); + $this->assertEquals('utf-8', $input->getHeaders()['content-encoding']); + $this->assertEquals('100', $input->getHeaders()['content-length']); + $this->assertEquals('eB5eJF1ptWaXm4bijSPyxw==', $input->getHeaders()['content-md5']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-user']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-location']); + $this->assertEquals('AES256', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('2022-10-12T00:00:00.000Z', $input->getHeaders()['expires']); + $this->assertEquals('TagA=A&TagB=B', $input->getHeaders()['x-oss-tagging']); + $this->assertEquals([], $input->getParameters()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123'); + $request->cacheControl = 'no-cache'; + $request->contentDisposition = 'attachment'; + $request->contentEncoding = 'utf-8'; + $request->contentMd5 = 'eB5eJF1ptWaXm4bijSPyxw=='; + $request->contentLength = 1000; + $request->expires = '2022-10-12T00:00:00.000Z'; + $request->forbidOverwrite = true; + $request->serverSideEncryption = 'KMS'; + $request->serverSideDataEncryption = 'SM4'; + $request->serverSideEncryptionKeyId = '9468da86-3509-4f8d-a61e-6eab1eac****'; + $request->acl = Models\ObjectACLType::PRIVATE; + $request->storageClass = Models\StorageClassType::STANDARD; + $request->metadata = array( + "name" => "walker", + "email" => "demo@aliyun.com", + ); + $request->tagging = 'TagA=B&TagC=D'; + $body = random_bytes(1000); + $request->body = Utils::streamFor($body); + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($input->getBody()->getContents(), $body); + $this->assertEquals('no-cache', $input->getHeaders()['cache-control']); + $this->assertEquals('attachment', $input->getHeaders()['content-disposition']); + $this->assertEquals('utf-8', $input->getHeaders()['content-encoding']); + $this->assertEquals('1000', $input->getHeaders()['content-length']); + $this->assertEquals('eB5eJF1ptWaXm4bijSPyxw==', $input->getHeaders()['content-md5']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + $this->assertEquals('KMS', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals('SM4', $input->getHeaders()['x-oss-server-side-data-encryption']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $input->getHeaders()['x-oss-server-side-encryption-key-id']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('2022-10-12T00:00:00.000Z', $input->getHeaders()['expires']); + $this->assertEquals('TagA=B&TagC=D', $input->getHeaders()['x-oss-tagging']); + $this->assertEquals([], $input->getParameters()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123'); + $callback = base64_encode('{ + "callbackUrl":"www.aliyuncs.com", + "callbackBody":"filename=${object}&size=${size}&mimeType=${mimeType}", + "callbackBodyType":"application/x-www-form-urlencoded", + }'); + $callbackVar = base64_encode('{"x:a":"a", "x:b":"b"}'); + $request->callback = $callback; + $request->callbackVar = $callbackVar; + $request->body = Utils::streamFor($body); + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($input->getBody()->getContents(), $body); + $this->assertEquals($callback, $input->getHeaders()['x-oss-callback']); + $this->assertEquals($callbackVar, $input->getHeaders()['x-oss-callback-var']); + $this->assertEquals([], $input->getParameters()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123'); + $request->body = Utils::streamFor($body); + $request->trafficLimit = 102400; + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($input->getBody()->getContents(), $body); + $this->assertEquals('102400', $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals([], $input->getParameters()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Models\ObjectACLType::PUBLIC_READ); + $request->body = Utils::streamFor($body); + $request->trafficLimit = 102400; + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($input->getBody()->getContents(), $body); + $this->assertEquals('102400', $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals([], $input->getParameters()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + $this->assertEquals(true, $input->getHeaders()['x-oss-object-acl']); + + $request = new Models\PutObjectRequest('bucket-123', 'key-123', Models\ObjectACLType::PRIVATE, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Models\ObjectACLType::PUBLIC_READ); + $request->body = Utils::streamFor($body); + $request->trafficLimit = 102400; + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromPutObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($input->getBody()->getContents(), $body); + $this->assertEquals('102400', $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals([], $input->getParameters()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + $this->assertEquals(true, $input->getHeaders()['x-oss-object-acl']); + } + + public function testToPutObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toPutObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"7265F4D211B56873A381D321F586****"', 'Content-MD5' => '1B2M2Y8AsgTpgAmY7Ph****', 'x-oss-hash-crc64ecma' => '316181249502703*****'], + null, + new OperationInput('PutObject', 'PUT', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"7265F4D211B56873A381D321F586****"', 'Content-MD5' => '1B2M2Y8AsgTpgAmY7Ph****', 'x-oss-hash-crc64ecma' => '316181249502703*****'], + ), + ); + $result = ObjectBasic::toPutObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(4, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"7265F4D211B56873A381D321F586****"', $result->etag); + $this->assertEquals('1B2M2Y8AsgTpgAmY7Ph****', $result->contentMd5); + $this->assertEquals('316181249502703*****', $result->hashCrc64); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $body = '{"filename":"object.txt","size":"100","mimeType":""}'; + $callback = base64_encode('{ + "callbackUrl":"www.aliyuncs.com", + "callbackBody":"filename=${object}&size=${size}&mimeType=${mimeType}", + "callbackBodyType":"application/x-www-form-urlencoded", + }'); + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"7265F4D211B56873A381D321F586****"', 'Content-MD5' => '1B2M2Y8AsgTpgAmY7Ph****', 'x-oss-hash-crc64ecma' => '316181249502703*****', 'x-oss-version-id' => 'CAEQNhiBgMDJgZCA0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY0****'], + Utils::streamFor($body), + new OperationInput('PutObject', 'PUT', ['x-oss-callback' => $callback]), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"7265F4D211B56873A381D321F586****"', 'Content-MD5' => '1B2M2Y8AsgTpgAmY7Ph****', 'x-oss-hash-crc64ecma' => '316181249502703*****', 'x-oss-version-id' => 'CAEQNhiBgMDJgZCA0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY0****'], + ), + ); + $result = ObjectBasic::toPutObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(5, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"7265F4D211B56873A381D321F586****"', $result->etag); + $this->assertEquals('1B2M2Y8AsgTpgAmY7Ph****', $result->contentMd5); + $this->assertEquals('316181249502703*****', $result->hashCrc64); + $this->assertEquals('CAEQNhiBgMDJgZCA0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY0****', $result->versionId); + $this->assertEquals($body, json_encode($result->callbackResult)); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromGetObject() + { + // miss required field + try { + $request = new Models\GetObjectRequest(); + $input = ObjectBasic::fromGetObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetObjectRequest('bucket-123'); + $input = ObjectBasic::fromGetObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\GetObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromGetObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + + $request = new Models\GetObjectRequest('bucket-123', 'key-123'); + $request->trafficLimit = 102400; + $request->ifMatch = '"D41D8CD98F00B204E9800998ECF8****"'; + $request->ifNoneMatch = '"D41D8CD98F00B204E9800998ECF9****"'; + $request->ifModifiedSince = 'Fri, 13 Nov 2023 14:47:53 GMT'; + $request->ifUnmodifiedSince = 'Fri, 13 Nov 2015 14:47:53 GMT'; + $request->rangeHeader = 'bytes 0~9/44'; + $request->responseCacheControl = 'gzip'; + $request->responseContentDisposition = 'attachment; filename=testing.txt'; + $request->responseContentEncoding = 'utf-8'; + $request->responseContentLanguage = '中文'; + $request->responseContentType = 'text'; + $request->responseExpires = 'Fri, 24 Feb 2012 17:00:00 GMT'; + $request->versionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****'; + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromGetObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF8****"', $input->getHeaders()['if-match']); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF9****"', $input->getHeaders()['if-none-match']); + $this->assertEquals('Fri, 13 Nov 2023 14:47:53 GMT', $input->getHeaders()['if-modified-since']); + $this->assertEquals('Fri, 13 Nov 2015 14:47:53 GMT', $input->getHeaders()['if-unmodified-since']); + $this->assertEquals('bytes 0~9/44', $input->getHeaders()['range']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals('102400', $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('gzip', $input->getParameters()['response-cache-control']); + $this->assertEquals('attachment; filename=testing.txt', $input->getParameters()['response-content-disposition']); + $this->assertEquals('utf-8', $input->getParameters()['response-content-encoding']); + $this->assertEquals('中文', $input->getParameters()['response-content-language']); + $this->assertEquals('Fri, 24 Feb 2012 17:00:00 GMT', $input->getParameters()['response-expires']); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', $input->getParameters()['versionId']); + $this->assertEquals([], $input->getOpMetadata()); + } + + public function testToGetObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toGetObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + $length = 1000; + $body = random_bytes($length); + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"D41D8CD98F00B204E9800998ECF8****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length], + Utils::streamFor($body), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"D41D8CD98F00B204E9800998ECF8****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length], + $body + ), + ); + $result = ObjectBasic::toGetObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(6, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF8****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals($length, $result->contentLength); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals($body, $result->body->getContents()); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + $length2 = 800; + $body2 = random_bytes($length2); + try { + $output = new OperationOutput( + 'Partial Content', + 206, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length2, 'Accept-Ranges' => 'bytes', 'Content-Range' => 'bytes 100-900/34460'], + Utils::streamFor($body2), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length2, 'Accept-Ranges' => 'bytes', 'Content-Range' => 'bytes 100-900/34460'], + $body2 + ), + ); + $result = ObjectBasic::toGetObject($output); + $this->assertEquals('Partial Content', $result->status); + $this->assertEquals(206, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(8, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals($length2, $result->contentLength); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals('bytes 100-900/34460', $result->contentRange); + $this->assertEquals($body2, $result->body->getContents()); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'Accept-Ranges' => 'bytes', 'Content-disposition' => 'attachment; filename=testing.txt', 'Cache-control' => 'no-cache', 'X-Oss-Storage-Class' => 'Standard', 'x-oss-server-side-encryption' => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-tagging-count' => '2', 'Content-MD5' => 'si4Nw3Cn9wZ/rPX3XX+j****', 'x-oss-hash-crc64ecma' => '870718044876840****', 'x-oss-meta-name' => 'demo', 'x-oss-meta-email' => 'demo@aliyun.com'], + Utils::streamFor($body), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'Accept-Ranges' => 'bytes', 'Content-disposition' => 'attachment; filename=testing.txt', 'Cache-control' => 'no-cache', 'X-Oss-Storage-Class' => 'Standard', 'x-oss-server-side-encryption' => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-tagging-count' => '2', 'Content-MD5' => 'si4Nw3Cn9wZ/rPX3XX+j****', 'x-oss-hash-crc64ecma' => '870718044876840****', 'x-oss-meta-name' => 'demo', 'x-oss-meta-email' => 'demo@aliyun.com'], + $body + ), + ); + $result = ObjectBasic::toGetObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals('no-cache', $result->cacheControl); + $this->assertEquals('attachment; filename=testing.txt', $result->contentDisposition); + $this->assertEquals($length, $result->contentLength); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals('KMS', $result->serverSideEncryption); + $this->assertEquals($body, $result->body->getContents()); + $this->assertEquals('SM4', $result->serverSideDataEncryption); + $this->assertEquals('12f8711f-90df-4e0d-903d-ab972b0f****', $result->serverSideEncryptionKeyId); + $this->assertEquals(2, $result->taggingCount); + $this->assertEquals('demo', $result->metadata['name']); + $this->assertEquals('demo@aliyun.com', $result->metadata['email']); + $this->assertEquals('si4Nw3Cn9wZ/rPX3XX+j****', $result->contentMd5); + $this->assertEquals('870718044876840****', $result->hashCrc64); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'X-Oss-Storage-Class' => 'Standard', 'x-oss-restore' => 'ongoing-request="false", expiry-date="Sun, 16 Apr 2017 08:12:33 GMT"'], + Utils::streamFor($body), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'X-Oss-Storage-Class' => 'Standard', 'x-oss-restore' => 'ongoing-request="false", expiry-date="Sun, 16 Apr 2017 08:12:33 GMT"'], + $body + ), + ); + $result = ObjectBasic::toGetObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals($length, $result->contentLength); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals($body, $result->body->getContents()); + $this->assertEquals('ongoing-request="false", expiry-date="Sun, 16 Apr 2017 08:12:33 GMT"', $result->restore); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'X-Oss-Storage-Class' => 'Standard', 'x-oss-version-id' => 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', 'x-oss-delete-marker' => 'true'], + Utils::streamFor($body), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'X-Oss-Storage-Class' => 'Standard', 'x-oss-version-id' => 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', 'x-oss-delete-marker' => 'true'], + $body + ), + ); + $result = ObjectBasic::toGetObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals($length, $result->contentLength); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals($body, $result->body->getContents()); + $this->assertTrue($result->deleteMarker); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', $result->versionId); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Appendable', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'text', 'Content-Length' => $length, 'X-Oss-Storage-Class' => 'Standard', 'x-oss-next-append-position' => '1001'], + Utils::streamFor($body), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Appendable', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'text', 'Content-Length' => $length, 'X-Oss-Storage-Class' => 'Standard', 'x-oss-next-append-position' => '1001'], + $body + ), + ); + $result = ObjectBasic::toGetObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('text', $result->contentType); + $this->assertEquals($length, $result->contentLength); + $this->assertEquals('Appendable', $result->objectType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals($body, $result->body->getContents()); + $this->assertEquals(1001, $result->nextAppendPosition); + } + + public function testFromCopyObject() + { + // miss required field + try { + $request = new Models\CopyObjectRequest(); + $input = ObjectBasic::fromCopyObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CopyObjectRequest('bucket-123'); + $input = ObjectBasic::fromCopyObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\CopyObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromCopyObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, sourceKey", (string)$e); + } + + $request = new Models\CopyObjectRequest('bucket-123', 'key-123'); + $request->sourceKey = 'src-key'; + $request->trafficLimit = 245760; + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromCopyObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('/bucket-123/src-key', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals(245760, $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + $request = new Models\CopyObjectRequest('bucket-123', 'key-123'); + $request->sourceBucket = 'src-bucket'; + $request->sourceKey = 'src-key'; + $request->trafficLimit = 102400; + $request->ifMatch = '"D41D8CD98F00B204E9800998ECF8****"'; + $request->ifNoneMatch = '"D41D8CD98F00B204E9800998ECF9****"'; + $request->ifModifiedSince = 'Fri, 13 Nov 2023 14:47:53 GMT'; + $request->ifUnmodifiedSince = 'Fri, 13 Nov 2015 14:47:53 GMT'; + $request->sourceVersionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****'; + $input = ObjectBasic::fromCopyObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF8****"', $input->getHeaders()['x-oss-copy-source-if-match']); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF9****"', $input->getHeaders()['x-oss-copy-source-if-none-match']); + $this->assertEquals('Fri, 13 Nov 2023 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-modified-since']); + $this->assertEquals('Fri, 13 Nov 2015 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-unmodified-since']); + $this->assertEquals('/src-bucket/src-key?versionId=CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals([], $input->getOpMetadata()); + + $request = new Models\CopyObjectRequest('bucket-123', 'key-123'); + $request->sourceKey = 'src-key'; + $request->trafficLimit = 102400; + $request->ifMatch = '"D41D8CD98F00B204E9800998ECF8****"'; + $request->ifNoneMatch = '"D41D8CD98F00B204E9800998ECF9****"'; + $request->ifModifiedSince = 'Fri, 13 Nov 2023 14:47:53 GMT'; + $request->ifUnmodifiedSince = 'Fri, 13 Nov 2015 14:47:53 GMT'; + $request->sourceVersionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****'; + $request->forbidOverwrite = true; + $request->serverSideEncryption = 'KMS'; + $request->serverSideDataEncryption = 'SM4'; + $request->serverSideEncryptionKeyId = '9468da86-3509-4f8d-a61e-6eab1eac****'; + $request->metadataDirective = 'REPLACE'; + $request->taggingDirective = 'Replace'; + $request->acl = Models\ObjectACLType::PRIVATE; + $request->storageClass = Models\StorageClassType::STANDARD; + $request->metadata = array( + "name" => "walker", + "email" => "demo@aliyun.com", + ); + $request->tagging = 'TagA=B&TagC=D'; + $input = ObjectBasic::fromCopyObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF8****"', $input->getHeaders()['x-oss-copy-source-if-match']); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF9****"', $input->getHeaders()['x-oss-copy-source-if-none-match']); + $this->assertEquals('Fri, 13 Nov 2023 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-modified-since']); + $this->assertEquals('Fri, 13 Nov 2015 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-unmodified-since']); + $this->assertEquals('/bucket-123/src-key?versionId=CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + $this->assertEquals('KMS', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals('SM4', $input->getHeaders()['x-oss-server-side-data-encryption']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $input->getHeaders()['x-oss-server-side-encryption-key-id']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('TagA=B&TagC=D', $input->getHeaders()['x-oss-tagging']); + $this->assertEquals('Replace', $input->getHeaders()['x-oss-tagging-directive']); + $this->assertEquals('REPLACE', $input->getHeaders()['x-oss-metadata-directive']); + $this->assertEquals([], $input->getOpMetadata()); + + $request = new Models\CopyObjectRequest('bucket-123', 'key-123', null, 'src-key', 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', '"D41D8CD98F00B204E9800998ECF8****"', '"D41D8CD98F00B204E9800998ECF9****"', 'Fri, 13 Nov 2023 14:47:53 GMT', 'Fri, 13 Nov 2015 14:47:53 GMT', null, Models\StorageClassType::STANDARD, array( + "name" => "walker", + "email" => "demo@aliyun.com", + ), null, null, null, null, null, null, null, 'REPLACE', 'KMS', 'SM4', '9468da86-3509-4f8d-a61e-6eab1eac****', 'TagA=B&TagC=D', 'Replace', true, 102400, null, null, null, Models\ObjectACLType::PRIVATE); + $input = ObjectBasic::fromCopyObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF8****"', $input->getHeaders()['x-oss-copy-source-if-match']); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF9****"', $input->getHeaders()['x-oss-copy-source-if-none-match']); + $this->assertEquals('Fri, 13 Nov 2023 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-modified-since']); + $this->assertEquals('Fri, 13 Nov 2015 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-unmodified-since']); + $this->assertEquals('/bucket-123/src-key?versionId=CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + $this->assertEquals('KMS', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals('SM4', $input->getHeaders()['x-oss-server-side-data-encryption']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $input->getHeaders()['x-oss-server-side-encryption-key-id']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('TagA=B&TagC=D', $input->getHeaders()['x-oss-tagging']); + $this->assertEquals('Replace', $input->getHeaders()['x-oss-tagging-directive']); + $this->assertEquals('REPLACE', $input->getHeaders()['x-oss-metadata-directive']); + $this->assertEquals([], $input->getOpMetadata()); + + $request = new Models\CopyObjectRequest('bucket-123', 'key-123', null, 'src-key', 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', '"D41D8CD98F00B204E9800998ECF8****"', '"D41D8CD98F00B204E9800998ECF9****"', 'Fri, 13 Nov 2023 14:47:53 GMT', 'Fri, 13 Nov 2015 14:47:53 GMT', Models\ObjectACLType::PUBLIC_READ, Models\StorageClassType::STANDARD, array( + "name" => "walker", + "email" => "demo@aliyun.com", + ), null, null, null, null, null, null, null, 'REPLACE', 'KMS', 'SM4', '9468da86-3509-4f8d-a61e-6eab1eac****', 'TagA=B&TagC=D', 'Replace', true, 102400, null, null, null, Models\ObjectACLType::PRIVATE); + $input = ObjectBasic::fromCopyObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF8****"', $input->getHeaders()['x-oss-copy-source-if-match']); + $this->assertEquals('"D41D8CD98F00B204E9800998ECF9****"', $input->getHeaders()['x-oss-copy-source-if-none-match']); + $this->assertEquals('Fri, 13 Nov 2023 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-modified-since']); + $this->assertEquals('Fri, 13 Nov 2015 14:47:53 GMT', $input->getHeaders()['x-oss-copy-source-if-unmodified-since']); + $this->assertEquals('/bucket-123/src-key?versionId=CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY*****', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + $this->assertEquals('KMS', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals('SM4', $input->getHeaders()['x-oss-server-side-data-encryption']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $input->getHeaders()['x-oss-server-side-encryption-key-id']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('TagA=B&TagC=D', $input->getHeaders()['x-oss-tagging']); + $this->assertEquals('Replace', $input->getHeaders()['x-oss-tagging-directive']); + $this->assertEquals('REPLACE', $input->getHeaders()['x-oss-metadata-directive']); + $this->assertEquals([], $input->getOpMetadata()); + } + + public function testToCopyObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toCopyObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + $body = ' + + "F2064A169EE92E9775EE5324D0B1****" + 2018-02-24T09:41:56.000Z +'; + $length = strlen($body); + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'x-oss-hash-crc64ecma' => '1275300285919610****'], + Utils::streamFor($body), + new OperationInput('CopyObject', 'PUT', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'Content-Type' => 'image/jpg', 'Content-Length' => $length, 'x-oss-hash-crc64ecma' => '1275300285919610****'], + $body + ), + ); + $result = ObjectBasic::toCopyObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"F2064A169EE92E9775EE5324D0B1****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2018-02-24T09:41:56.000Z', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('1275300285919610****', $result->hashCrc64); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'Content-Type' => 'text', 'Content-Length' => $length, 'x-oss-hash-crc64ecma' => '1275300285919610****', "x-oss-server-side-encryption" => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-copy-source-version-id' => 'CAEQHxiBgICDvseg3hgiIGZmOGNjNWJiZDUzNjQxNDM4MWM2NDc1YjhkYTk3****', 'x-oss-version-id' => 'CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****'], + Utils::streamFor($body), + new OperationInput('CopyObject', 'PUT', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'Content-Type' => 'text', 'Content-Length' => $length, 'x-oss-hash-crc64ecma' => '1275300285919610****', "x-oss-server-side-encryption" => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-copy-source-version-id' => 'CAEQHxiBgICDvseg3hgiIGZmOGNjNWJiZDUzNjQxNDM4MWM2NDc1YjhkYTk3****', 'x-oss-version-id' => 'CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****'], + $body + ), + ); + $result = ObjectBasic::toCopyObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"F2064A169EE92E9775EE5324D0B1****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2018-02-24T09:41:56.000Z', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('1275300285919610****', $result->hashCrc64); + $this->assertEquals('KMS', $result->serverSideEncryption); + $this->assertEquals('SM4', $result->serverSideDataEncryption); + $this->assertEquals('12f8711f-90df-4e0d-903d-ab972b0f****', $result->serverSideEncryptionKeyId); + $this->assertEquals('CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', $result->versionId); + $this->assertEquals('CAEQHxiBgICDvseg3hgiIGZmOGNjNWJiZDUzNjQxNDM4MWM2NDc1YjhkYTk3****', $result->sourceVersionId); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromAppendObject() + { + // miss required field + try { + $request = new Models\AppendObjectRequest(); + $input = ObjectBasic::fromAppendObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\AppendObjectRequest('bucket-123'); + $input = ObjectBasic::fromAppendObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\AppendObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromAppendObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, position", (string)$e); + } + $body = 'hi oss'; + $request = new Models\AppendObjectRequest('bucket-123', 'key-123', 0); + $request->trafficLimit = 245760; + $request->requestPayer = 'requester'; + $request->body = Utils::streamFor($body); + $input = ObjectBasic::fromAppendObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($body, $input->getBody()->getContents()); + $this->assertEquals('0', $input->getParameters()['position']); + $this->assertEquals(245760, $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + $request = new Models\AppendObjectRequest('bucket-123', 'key-123', 0); + $request->cacheControl = 'no-cache'; + $request->contentDisposition = 'attachment'; + $request->contentEncoding = 'gzip'; + $request->contentMd5 = 'eB5eJF1ptWaXm4bijSPyxw=='; + $request->expires = '2022-10-12T00:00:00.000Z'; + $request->forbidOverwrite = true; + $request->serverSideEncryption = 'AES256'; + $request->acl = Models\ObjectACLType::PRIVATE; + $request->storageClass = Models\StorageClassType::STANDARD; + $request->metadata = array( + "location" => "demo", + "user" => "walker", + ); + $request->tagging = 'TagA=A&TagB=B'; + $input = ObjectBasic::fromAppendObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + + $this->assertEquals('no-cache', $input->getHeaders()['cache-control']); + $this->assertEquals('attachment', $input->getHeaders()['content-disposition']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-user']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-location']); + $this->assertEquals('AES256', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('gzip', $input->getHeaders()['content-encoding']); + $this->assertEquals('eB5eJF1ptWaXm4bijSPyxw==', $input->getHeaders()['content-md5']); + $this->assertEquals('2022-10-12T00:00:00.000Z', $input->getHeaders()['expires']); + $this->assertEquals('TagA=A&TagB=B', $input->getHeaders()['x-oss-tagging']); + $this->assertEmpty($input->getParameters()['append']); + $this->assertEquals('0', $input->getParameters()['position']); + + $request = new Models\AppendObjectRequest('bucket-123', 'key-123', 0, null, Models\StorageClassType::STANDARD, array( + "location" => "demo", + "user" => "walker", + ), 'no-cache', 'attachment', 'gzip', null, 'eB5eJF1ptWaXm4bijSPyxw==', null, '2022-10-12T00:00:00.000Z', 'AES256', null, null, 'TagA=A&TagB=B', true, null, null, null, null, null, Models\ObjectACLType::PRIVATE); + $input = ObjectBasic::fromAppendObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + + $this->assertEquals('no-cache', $input->getHeaders()['cache-control']); + $this->assertEquals('attachment', $input->getHeaders()['content-disposition']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-user']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-location']); + $this->assertEquals('AES256', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('gzip', $input->getHeaders()['content-encoding']); + $this->assertEquals('eB5eJF1ptWaXm4bijSPyxw==', $input->getHeaders()['content-md5']); + $this->assertEquals('2022-10-12T00:00:00.000Z', $input->getHeaders()['expires']); + $this->assertEquals('TagA=A&TagB=B', $input->getHeaders()['x-oss-tagging']); + $this->assertEmpty($input->getParameters()['append']); + $this->assertEquals('0', $input->getParameters()['position']); + + $request = new Models\AppendObjectRequest('bucket-123', 'key-123', 0, Models\ObjectACLType::PUBLIC_READ, Models\StorageClassType::STANDARD, array( + "location" => "demo", + "user" => "walker", + ), 'no-cache', 'attachment', 'gzip', null, 'eB5eJF1ptWaXm4bijSPyxw==', null, '2022-10-12T00:00:00.000Z', 'AES256', null, null, 'TagA=A&TagB=B', true, null, null, null, null, null, Models\ObjectACLType::PRIVATE); + $input = ObjectBasic::fromAppendObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertNull($input->getBody()); + + $this->assertEquals('no-cache', $input->getHeaders()['cache-control']); + $this->assertEquals('attachment', $input->getHeaders()['content-disposition']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-user']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-location']); + $this->assertEquals('AES256', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('gzip', $input->getHeaders()['content-encoding']); + $this->assertEquals('eB5eJF1ptWaXm4bijSPyxw==', $input->getHeaders()['content-md5']); + $this->assertEquals('2022-10-12T00:00:00.000Z', $input->getHeaders()['expires']); + $this->assertEquals('TagA=A&TagB=B', $input->getHeaders()['x-oss-tagging']); + $this->assertEmpty($input->getParameters()['append']); + $this->assertEquals('0', $input->getParameters()['position']); + + $request = new Models\AppendObjectRequest('bucket-123', 'key-123', 0); + $request->cacheControl = 'no-cache'; + $request->contentDisposition = 'attachment'; + $request->contentEncoding = 'gzip'; + $request->contentMd5 = 'eB5eJF1ptWaXm4bijSPyxw=='; + $request->expires = '2022-10-12T00:00:00.000Z'; + $request->forbidOverwrite = true; + $request->serverSideEncryption = 'KMS'; + $request->serverSideDataEncryption = 'SM4'; + $request->serverSideEncryptionKeyId = '9468da86-3509-4f8d-a61e-6eab1eac****'; + $request->body = Utils::streamFor($body); + $input = ObjectBasic::fromAppendObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals($input->getBody()->getContents(), $body); + $this->assertEquals('no-cache', $input->getHeaders()['cache-control']); + $this->assertEquals('attachment', $input->getHeaders()['content-disposition']); + $this->assertEquals('KMS', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals('SM4', $input->getHeaders()['x-oss-server-side-data-encryption']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $input->getHeaders()['x-oss-server-side-encryption-key-id']); + $this->assertEmpty($input->getParameters()['append']); + $this->assertEquals('0', $input->getParameters()['position']); + } + + public function testToAppendObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toAppendObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'x-oss-next-append-position' => '0', 'x-oss-hash-crc64ecma' => '1275300285919610****'], + null, + new OperationInput('AppendObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'x-oss-next-append-position' => '0', 'x-oss-hash-crc64ecma' => '1275300285919610****'], + ), + ); + $result = ObjectBasic::toAppendObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"F2064A169EE92E9775EE5324D0B1****"', $result->etag); + $this->assertEquals('1275300285919610****', $result->hashCrc64); + $this->assertEquals(0, $result->nextPosition); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'Content-Type' => 'text', 'x-oss-hash-crc64ecma' => '1275300285919610****', "x-oss-server-side-encryption" => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-version-id' => 'CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', 'x-oss-next-append-position' => '1717',], + null, + new OperationInput('AppendObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'Content-Type' => 'text', 'x-oss-hash-crc64ecma' => '1275300285919610****', "x-oss-server-side-encryption" => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-version-id' => 'CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', 'x-oss-next-append-position' => '1717'], + ), + ); + $result = ObjectBasic::toAppendObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"F2064A169EE92E9775EE5324D0B1****"', $result->etag); + $this->assertEquals('1275300285919610****', $result->hashCrc64); + $this->assertEquals('KMS', $result->serverSideEncryption); + $this->assertEquals('SM4', $result->serverSideDataEncryption); + $this->assertEquals('12f8711f-90df-4e0d-903d-ab972b0f****', $result->serverSideEncryptionKeyId); + $this->assertEquals('CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', $result->versionId); + $this->assertEquals(1717, $result->nextPosition); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromDeleteObject() + { + // miss required field + try { + $request = new Models\DeleteObjectRequest(); + $input = ObjectBasic::fromDeleteObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteObjectRequest('bucket-123'); + $input = ObjectBasic::fromDeleteObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\DeleteObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromDeleteObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\DeleteObjectRequest('bucket-123', 'key-123'); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****'; + $input = ObjectBasic::fromDeleteObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToDeleteObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toDeleteObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123',], + null, + new OperationInput('DeleteObject', 'DELETE', []), + null, + new \GuzzleHttp\Psr7\Response( + 204, + ['x-oss-request-id' => '123'], + ), + ); + $result = ObjectBasic::toDeleteObject($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123', 'x-oss-version-id' => 'CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', 'x-oss-delete-marker' => 'true'], + null, + new OperationInput('DeleteObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 204, + ['x-oss-request-id' => '123', 'x-oss-version-id' => 'CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', 'x-oss-delete-marker' => 'true'], + ), + ); + $result = ObjectBasic::toDeleteObject($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertTrue($result->deleteMarker); + $this->assertEquals('CAEQHxiBgMD4qOWz3hgiIDUyMWIzNTBjMWM4NjQ5MDJiNTM4YzEwZGQxM2Rk****', $result->versionId); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromHeadObject() + { + // miss required field + try { + $request = new Models\HeadObjectRequest(); + $input = ObjectBasic::fromHeadObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\HeadObjectRequest('bucket-123'); + $input = ObjectBasic::fromHeadObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\HeadObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromHeadObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\HeadObjectRequest('bucket-123', 'key-123'); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****'; + $input = ObjectBasic::fromHeadObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToHeadObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toHeadObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'x-oss-object-type' => 'Normal', 'x-oss-storage-class' => 'Archive', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'Content-Type' => 'image/jpg', 'ETag' => '"fba9dede5f27731c9771645a3986****"'], + null, + new OperationInput('HeadObject', 'HEAD', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'x-oss-object-type' => 'Normal', 'x-oss-storage-class' => 'Archive', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'Content-Type' => 'image/jpg', 'ETag' => '"fba9dede5f27731c9771645a3986****"'], + ), + ); + $result = ObjectBasic::toHeadObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"fba9dede5f27731c9771645a3986****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2018 09:41:56 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals(344606, $result->contentLength); + $this->assertEquals('Archive', $result->storageClass); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals('image/jpg', $result->contentType); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'x-oss-object-type' => 'Normal', 'x-oss-storage-class' => 'ColdArchive', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'Content-Type' => 'image/jpg', 'ETag' => '"fba9dede5f27731c9771645a3986****"', 'x-oss-transition-time' => 'Thu, 31 Oct 2024 00:24:17 GMT', 'x-oss-restore' => 'ongoing-request="false", expiry-date="Fri, 08 Nov 2024 08:15:52 GMT"', 'x-oss-version-Id' => 'CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****'], + null, + new OperationInput('HeadObject', 'HEAD', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'x-oss-object-type' => 'Normal', 'x-oss-storage-class' => 'ColdArchive', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'Content-Type' => 'image/jpg', 'ETag' => '"fba9dede5f27731c9771645a3986****"', 'x-oss-transition-time' => 'Thu, 31 Oct 2024 00:24:17 GMT', 'x-oss-restore' => 'ongoing-request="false", expiry-date="Fri, 08 Nov 2024 08:15:52 GMT"', 'x-oss-version-Id' => 'CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****'], + ), + ); + $result = ObjectBasic::toHeadObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"fba9dede5f27731c9771645a3986****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2018 09:41:56 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals(344606, $result->contentLength); + $this->assertEquals('ColdArchive', $result->storageClass); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Thu, 31 Oct 2024 00:24:17 GMT', + new \DateTimeZone('UTC') + ), $result->transitionTime); + $this->assertEquals('ongoing-request="false", expiry-date="Fri, 08 Nov 2024 08:15:52 GMT"', $result->restore); + $this->assertEquals('CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****', $result->versionId); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => '20', 'Accept-Ranges' => 'bytes', 'Content-disposition' => 'attachment; filename=testing.txt', 'Cache-control' => 'no-cache', 'X-Oss-Storage-Class' => 'Standard', 'x-oss-server-side-encryption' => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-tagging-count' => '2', 'Content-MD5' => 'si4Nw3Cn9wZ/rPX3XX+j****', 'x-oss-hash-crc64ecma' => '870718044876840****', 'x-oss-meta-name' => 'demo', 'x-oss-meta-email' => 'demo@aliyun.com'], + Utils::streamFor(), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Normal', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'image/jpg', 'Content-Length' => '20', 'Accept-Ranges' => 'bytes', 'Content-disposition' => 'attachment; filename=testing.txt', 'Cache-control' => 'no-cache', 'X-Oss-Storage-Class' => 'Standard', 'x-oss-server-side-encryption' => 'KMS', 'x-oss-server-side-data-encryption' => 'SM4', 'x-oss-server-side-encryption-key-id' => '12f8711f-90df-4e0d-903d-ab972b0f****', 'x-oss-tagging-count' => '2', 'Content-MD5' => 'si4Nw3Cn9wZ/rPX3XX+j****', 'x-oss-hash-crc64ecma' => '870718044876840****', 'x-oss-meta-name' => 'demo', 'x-oss-meta-email' => 'demo@aliyun.com'], + null + ), + ); + $result = ObjectBasic::toHeadObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('image/jpg', $result->contentType); + $this->assertEquals('no-cache', $result->cacheControl); + $this->assertEquals('attachment; filename=testing.txt', $result->contentDisposition); + $this->assertEquals(20, $result->contentLength); + $this->assertEquals('Normal', $result->objectType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals('KMS', $result->serverSideEncryption); + $this->assertEquals('SM4', $result->serverSideDataEncryption); + $this->assertEquals('12f8711f-90df-4e0d-903d-ab972b0f****', $result->serverSideEncryptionKeyId); + $this->assertEquals(2, $result->taggingCount); + $this->assertEquals('demo', $result->metadata['name']); + $this->assertEquals('demo@aliyun.com', $result->metadata['email']); + $this->assertEquals('si4Nw3Cn9wZ/rPX3XX+j****', $result->contentMd5); + $this->assertEquals('870718044876840****', $result->hashCrc64); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Appendable', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'text', 'X-Oss-Storage-Class' => 'Standard', 'x-oss-next-append-position' => '1001'], + Utils::streamFor(), + new OperationInput('GetObject', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"5B3C1A2E05E1B002CC607C****"', 'x-oss-object-type' => 'Appendable', 'Last-Modified' => 'Fri, 24 Feb 2012 06:07:48 GMT', 'Content-Type' => 'text', 'X-Oss-Storage-Class' => 'Standard', 'x-oss-next-append-position' => '1001'], + null + ), + ); + $result = ObjectBasic::toHeadObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('"5B3C1A2E05E1B002CC607C****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2012 06:07:48 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('text', $result->contentType); + $this->assertEquals('Appendable', $result->objectType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals(1001, $result->nextAppendPosition); + } + + public function testFromGetObjectMeta() + { + // miss required field + try { + $request = new Models\GetObjectMetaRequest(); + $input = ObjectBasic::fromGetObjectMeta($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetObjectMetaRequest('bucket-123'); + $input = ObjectBasic::fromGetObjectMeta($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\GetObjectMetaRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromGetObjectMeta($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\GetObjectMetaRequest('bucket-123', 'key-123'); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****'; + $input = ObjectBasic::fromGetObjectMeta($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToGetObjectMeta() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toGetObjectMeta($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'x-oss-object-type' => 'Normal', 'x-oss-storage-class' => 'Archive', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'Content-Type' => 'image/jpg', 'ETag' => '"fba9dede5f27731c9771645a3986****"'], + null, + new OperationInput('GetObjectMeta', 'HEAD', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'x-oss-object-type' => 'Normal', 'x-oss-storage-class' => 'Archive', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'Content-Type' => 'image/jpg', 'ETag' => '"fba9dede5f27731c9771645a3986****"'], + ), + ); + $result = ObjectBasic::toGetObjectMeta($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"fba9dede5f27731c9771645a3986****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2018 09:41:56 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals(344606, $result->contentLength); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'ETag' => '"fba9dede5f27731c9771645a3986****"', 'x-oss-transition-time' => 'Thu, 31 Oct 2024 00:24:17 GMT', 'x-oss-version-Id' => 'CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****', 'x-oss-last-access-time' => 'Thu, 14 Oct 2021 11:49:05 GMT'], + null, + new OperationInput('GetObjectMeta', 'HEAD', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'Last-Modified' => 'Fri, 24 Feb 2018 09:41:56 GMT', 'Content-Length' => '344606', 'ETag' => '"fba9dede5f27731c9771645a3986****"', 'x-oss-transition-time' => 'Thu, 31 Oct 2024 00:24:17 GMT', 'x-oss-version-Id' => 'CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****', 'x-oss-last-access-time' => 'Thu, 14 Oct 2021 11:49:05 GMT'], + ), + ); + $result = ObjectBasic::toGetObjectMeta($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"fba9dede5f27731c9771645a3986****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Fri, 24 Feb 2018 09:41:56 GMT', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals(344606, $result->contentLength); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Thu, 31 Oct 2024 00:24:17 GMT', + new \DateTimeZone('UTC') + ), $result->transitionTime); + $this->assertEquals(\DateTime::createFromFormat( + 'D, d M Y H:i:s \G\M\T', + 'Thu, 14 Oct 2021 11:49:05 GMT', + new \DateTimeZone('UTC') + ), $result->lastAccessTime); + $this->assertEquals('CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****', $result->versionId); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromRestoreObject() + { + // miss required field + try { + $request = new Models\RestoreObjectRequest(); + $input = ObjectBasic::fromRestoreObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\RestoreObjectRequest('bucket-123'); + $input = ObjectBasic::fromRestoreObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\RestoreObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromRestoreObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\RestoreObjectRequest('bucket-123', 'key-123'); + $request->restoreRequest = new RestoreRequest(3); + $input = ObjectBasic::fromRestoreObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $xml = <<3 +BBB; + $body = $input->getBody()->getContents(); + $this->assertEquals($xml, $this->cleanXml($body)); + + $request = new Models\RestoreObjectRequest('bucket-123', 'key-123'); + $request->restoreRequest = new RestoreRequest(3, 'Bulk'); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****'; + $input = ObjectBasic::fromRestoreObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $xml = <<3Bulk +BBB; + $body = $input->getBody()->getContents(); + $this->assertEquals($xml, $this->cleanXml($body)); + } + + public function testToRestoreObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toRestoreObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'Accepted', + 202, + ['x-oss-request-id' => '123'], + null, + new OperationInput('RestoreObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 202, + ['x-oss-request-id' => '123',], + ), + ); + $result = ObjectBasic::toRestoreObject($output); + $this->assertEquals('Accepted', $result->status); + $this->assertEquals(202, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'Accepted', + 202, + ['x-oss-request-id' => '123', 'x-oss-object-restore-priority' => 'Standard', 'x-oss-version-id' => 'CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****'], + null, + new OperationInput('RestoreObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 202, + ['x-oss-request-id' => '123', 'x-oss-object-restore-priority' => 'Standard', 'x-oss-version-id' => 'CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****'], + ), + ); + $result = ObjectBasic::toRestoreObject($output); + $this->assertEquals('Accepted', $result->status); + $this->assertEquals(202, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('Standard', $result->restorePriority); + $this->assertEquals('CAEQNRiBgICb8o6D0BYiIDNlNzk5NGE2M2Y3ZjRhZTViYTAxZGE0ZTEyMWYy****', $result->versionId); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + } + + public function testFromCleanRestoredObject() + { + // miss required field + try { + $request = new Models\CleanRestoredObjectRequest(); + $input = ObjectBasic::fromCleanRestoredObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CleanRestoredObjectRequest('bucket-123'); + $input = ObjectBasic::fromCleanRestoredObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\CleanRestoredObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromCleanRestoredObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\CleanRestoredObjectRequest('bucket-123', 'key-123'); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****'; + $input = ObjectBasic::fromCleanRestoredObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQNhiBgM0BYiIDc4MGZjZGI2OTBjOTRmNTE5NmU5NmFhZjhjYmY****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToCleanRestoredObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toCleanRestoredObject($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + null, + new OperationInput('CleanRestoredObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123',], + ), + ); + $result = ObjectBasic::toCleanRestoredObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromPutObjectAcl() + { + // miss required field + try { + $request = new Models\PutObjectAclRequest(); + $input = ObjectBasic::fromPutObjectAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutObjectAclRequest('bucket-123'); + $input = ObjectBasic::fromPutObjectAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\PutObjectAclRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromPutObjectAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, acl", (string)$e); + } + + $request = new Models\PutObjectAclRequest('bucket-123', 'key-123', Models\ObjectACLType::PRIVATE); + $input = ObjectBasic::fromPutObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()["x-oss-object-acl"]); + + $request = new Models\PutObjectAclRequest('bucket-123', 'key-123', Models\ObjectACLType::PRIVATE, "CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****"); + $input = ObjectBasic::fromPutObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()["x-oss-object-acl"]); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $input->getParameters()['versionId']); + + $request = new Models\PutObjectAclRequest('bucket-123', 'key-123', Models\ObjectACLType::PRIVATE); + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromPutObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()["x-oss-object-acl"]); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + $request = new Models\PutObjectAclRequest('bucket-123', 'key-123', null, null, null, null, Models\ObjectACLType::PRIVATE); + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromPutObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()["x-oss-object-acl"]); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + $request = new Models\PutObjectAclRequest('bucket-123', 'key-123',Models\ObjectACLType::PUBLIC_READ,null,'requester',null,Models\ObjectACLType::PRIVATE); + $input = ObjectBasic::fromPutObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()["x-oss-object-acl"]); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToPutObjectAcl() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toPutObjectAcl($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + null, + new OperationInput('PutObjectAcl', 'PUT', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123',], + ), + ); + $result = ObjectBasic::toPutObjectAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + null, + new OperationInput('PutObjectAcl', 'PUT', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + ), + ); + $result = ObjectBasic::toPutObjectAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $result->versionId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromGetObjectAcl() + { + // miss required field + try { + $request = new Models\GetObjectAclRequest(); + $input = ObjectBasic::fromGetObjectAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetObjectAclRequest('bucket-123'); + $input = ObjectBasic::fromGetObjectAcl($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\GetObjectAclRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromGetObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\GetObjectAclRequest('bucket-123', 'key-123', "CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****"); + $input = ObjectBasic::fromGetObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $input->getParameters()['versionId']); + + $request = new Models\GetObjectAclRequest('bucket-123', 'key-123'); + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromGetObjectAcl($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToGetObjectAcl() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toGetObjectAcl($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + null, + new OperationInput('GetObjectAcl', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toGetObjectAcl($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str), + new OperationInput('GetObjectAcl', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toGetObjectAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->accessControlList); + + $str = ' + + + 0022012**** + 0022012**** + + + public-read + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str), + new OperationInput('GetObjectAcl', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + ), + ); + $result = ObjectBasic::toGetObjectAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(Models\ObjectACLType::PUBLIC_READ, $result->accessControlList->grant); + $this->assertEquals('0022012****', $result->owner->id); + $this->assertEquals('0022012****', $result->owner->displayName); + + $str = ' + + + 0022012**** + 0022012**** + + + private + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + Utils::streamFor($str), + new OperationInput('GetObjectAcl', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + ), + ); + $result = ObjectBasic::toGetObjectAcl($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(3, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $result->accessControlList->grant); + $this->assertEquals('0022012****', $result->owner->id); + $this->assertEquals('0022012****', $result->owner->displayName); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $result->versionId); + } + + public function testFromGetObjectTagging() + { + // miss required field + try { + $request = new Models\GetObjectTaggingRequest(); + $input = ObjectBasic::fromGetObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetObjectTaggingRequest('bucket-123'); + $input = ObjectBasic::fromGetObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\GetObjectTaggingRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromGetObjectTagging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\GetObjectTaggingRequest('bucket-123', 'key-123', "CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****", "requester"); + $input = ObjectBasic::fromGetObjectTagging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToGetObjectTagging() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toGetObjectTagging($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + null, + new OperationInput('GetObjectTagging', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toGetObjectTagging($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + $str = ' + '; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + Utils::streamFor($str), + new OperationInput('GetObjectTagging', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toGetObjectTagging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->tagSet); + + $str = ' + + + a + 1 + + + b + 2 + + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str), + new OperationInput('GetObjectTagging', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + ), + ); + $result = ObjectBasic::toGetObjectTagging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(2, count($result->tagSet->tags)); + $this->assertEquals('a', $result->tagSet->tags[0]->key); + $this->assertEquals('1', $result->tagSet->tags[0]->value); + $this->assertEquals('b', $result->tagSet->tags[1]->key); + $this->assertEquals('2', $result->tagSet->tags[1]->value); + + $str = ' + + + + age + 18 + + +'; + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + Utils::streamFor($str), + new OperationInput('GetObjectTagging', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + ), + ); + $result = ObjectBasic::toGetObjectTagging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(3, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals(1, count($result->tagSet->tags)); + $this->assertEquals('age', $result->tagSet->tags[0]->key); + $this->assertEquals('18', $result->tagSet->tags[0]->value); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $result->versionId); + } + + public function testFromPutObjectTagging() + { + // miss required field + try { + $request = new Models\PutObjectTaggingRequest(); + $input = ObjectBasic::fromPutObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutObjectTaggingRequest('bucket-123'); + $input = ObjectBasic::fromPutObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\PutObjectTaggingRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromPutObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, tagging", (string)$e); + } + + $request = new Models\PutObjectTaggingRequest('bucket-123', 'key-123'); + $request->tagging = new Models\Tagging( + new Models\TagSet( + [new Models\Tag('k1', 'v1'), new Models\Tag('k2', 'v2')] + ) + ); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'; + $input = ObjectBasic::fromPutObjectTagging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $inputXml = <<k1v1k2v2 +BBB; + $this->assertEquals($inputXml, $this->cleanXml($input->getBody()->getContents())); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $input->getParameters()['versionId']); + } + + public function testToPutObjectTagging() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toPutObjectTagging($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + null, + new OperationInput('PutObjectTagging', 'PUT', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toPutObjectTagging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + null, + new OperationInput('PutObjectTagging', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + ), + ); + $result = ObjectBasic::toPutObjectTagging($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $result->versionId); + } + + public function testFromDeleteObjectTagging() + { + // miss required field + try { + $request = new Models\DeleteObjectTaggingRequest(); + $input = ObjectBasic::fromDeleteObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\DeleteObjectTaggingRequest('bucket-123'); + $input = ObjectBasic::fromDeleteObjectTagging($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\DeleteObjectTaggingRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromDeleteObjectTagging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\DeleteObjectTaggingRequest('bucket-123', 'key-123'); + $request->requestPayer = 'requester'; + $request->versionId = 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'; + $input = ObjectBasic::fromDeleteObjectTagging($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $input->getParameters()['versionId']); + } + + public function testToDeleteObjectTagging() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toDeleteObjectTagging($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e); + } + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + null, + new OperationInput('DeleteObjectTagging', 'DELETE', []), + null, + new \GuzzleHttp\Psr7\Response( + 204, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toDeleteObjectTagging($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + null, + new OperationInput('DeleteObjectTagging', 'DELETE', []), + null, + new \GuzzleHttp\Psr7\Response( + 204, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + ), + ); + $result = ObjectBasic::toDeleteObjectTagging($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $result->versionId); + } + + public function testFromPutSymlink() + { + // miss required field + try { + $request = new Models\PutSymlinkRequest(); + $input = ObjectBasic::fromPutSymlink($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\PutSymlinkRequest('bucket-123'); + $input = ObjectBasic::fromPutSymlink($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\PutSymlinkRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromPutSymlink($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, target", (string)$e); + } + + $request = new Models\PutSymlinkRequest('bucket-123', 'key-123', 'target-key'); + $input = ObjectBasic::fromPutSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('target-key', $input->getHeaders()['x-oss-symlink-target']); + + $request = new Models\PutSymlinkRequest('bucket-123', 'key-123', 'target-key', Models\ObjectACLType::PRIVATE, Models\StorageClassType::STANDARD, ['name' => 'demo', 'email' => 'demo@aliyun.com'], true); + $input = ObjectBasic::fromPutSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('target-key', $input->getHeaders()['x-oss-symlink-target']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + + $request = new Models\PutSymlinkRequest('bucket-123', 'key-123', 'target-key'); + $request->requestPayer = 'requester'; + $input = ObjectBasic::fromPutSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('target-key', $input->getHeaders()['x-oss-symlink-target']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + + $request = new Models\PutSymlinkRequest('bucket-123', 'key-123', null, null, Models\StorageClassType::STANDARD, ['name' => 'demo', 'email' => 'demo@aliyun.com'], true, null, null, Models\ObjectACLType::PUBLIC_READ, 'target-key'); + $input = ObjectBasic::fromPutSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('target-key', $input->getHeaders()['x-oss-symlink-target']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals(Models\ObjectACLType::PUBLIC_READ, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + + $request = new Models\PutSymlinkRequest('bucket-123', 'key-123', 'target-key',Models\ObjectACLType::PRIVATE, Models\StorageClassType::STANDARD, ['name' => 'demo', 'email' => 'demo@aliyun.com'], true,null,null,Models\ObjectACLType::PUBLIC_READ,'target-key2'); + $input = ObjectBasic::fromPutSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('target-key2', $input->getHeaders()['x-oss-symlink-target']); + $this->assertEquals('true', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals(Models\ObjectACLType::PUBLIC_READ, $input->getHeaders()['x-oss-object-acl']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals('demo', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + } + + public function testToPutSymlink() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toPutSymlink($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + null, + new OperationInput('PutSymlink', 'DELETE', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'content-type' => 'test'], + ), + ); + $result = ObjectBasic::toPutSymlink($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('test', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + null, + new OperationInput('PutSymlink', 'DELETE', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'X-Oss-Version-Id' => 'CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****'], + ), + ); + $result = ObjectBasic::toPutSymlink($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('CAEQMhiBgMC1qpSD0BYiIGQ0ZmI5ZDEyYWVkNTQwMjBiNTliY2NjNmY3ZTVk****', $result->versionId); + } + + public function testFromGetSymlink() + { + // miss required field + try { + $request = new Models\GetSymlinkRequest(); + $input = ObjectBasic::fromGetSymlink($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\GetSymlinkRequest('bucket-123'); + $input = ObjectBasic::fromGetSymlink($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + $request = new Models\GetSymlinkRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromGetSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + + $request = new Models\GetSymlinkRequest('bucket-123', 'key-123', 'CAEQNRiBgMClj7qD0BYiIDQ5Y2QyMjc3NGZkODRlMTU5M2VkY2U3MWRiNGRh****', 'requester'); + $input = ObjectBasic::fromGetSymlink($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('CAEQNRiBgMClj7qD0BYiIDQ5Y2QyMjc3NGZkODRlMTU5M2VkY2U3MWRiNGRh****', $input->getParameters()['versionId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToGetSymlink() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toGetSymlink($output); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => 'A797938C31D59EDD08D86188F6D5****', 'x-oss-symlink-target' => 'example.jpg'], + null, + new OperationInput('GetSymlink', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => 'A797938C31D59EDD08D86188F6D5****', 'x-oss-symlink-target' => 'example.jpg'], + ), + ); + $result = ObjectBasic::toGetSymlink($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(3, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('A797938C31D59EDD08D86188F6D5****', $result->etag); + $this->assertEquals('example.jpg', $result->target); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => 'A797938C31D59EDD08D86188F6D5****', 'x-oss-symlink-target' => 'example.jpg', 'x-oss-version-id' => 'CAEQNRiBgMClj7qD0BYiIDQ5Y2QyMjc3NGZkODRlMTU5M2VkY2U3MWRiNGRh****'], + null, + new OperationInput('GetSymlink', 'GET', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => 'A797938C31D59EDD08D86188F6D5****', 'x-oss-symlink-target' => 'example.jpg', 'x-oss-version-id' => 'CAEQNRiBgMClj7qD0BYiIDQ5Y2QyMjc3NGZkODRlMTU5M2VkY2U3MWRiNGRh****'], + ), + ); + $result = ObjectBasic::toGetSymlink($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(4, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('CAEQNRiBgMClj7qD0BYiIDQ5Y2QyMjc3NGZkODRlMTU5M2VkY2U3MWRiNGRh****', $result->versionId); + $this->assertEquals('A797938C31D59EDD08D86188F6D5****', $result->etag); + $this->assertEquals('example.jpg', $result->target); + } + + public function testFromAsyncProcessObject() + { + // miss required field + try { + $request = new Models\AsyncProcessObjectRequest(); + $input = ObjectBasic::fromAsyncProcessObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\AsyncProcessObjectRequest('bucket-123'); + $input = ObjectBasic::fromAsyncProcessObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\AsyncProcessObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromAsyncProcessObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, process", (string)$e); + } + + $base = 'video/convert,f_avi,vcodec_h265,s_1920x1080,vb_2000000,fps_30,acodec_aac,ab_100000,sn_1'; + $bucket = 'dest-bucket'; + $file = 'demo.mp4'; + $encoded_bucket = rtrim(base64_encode($bucket), '='); + $encoded_file = rtrim(base64_encode($file), '='); + $process = sprintf("%s|sys/saveas,b_%s,o_%s", $base, $encoded_bucket, $encoded_file); + $request = new Models\AsyncProcessObjectRequest('bucket-123', 'key-123', $process, 'requester'); + $input = ObjectBasic::fromAsyncProcessObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('x-oss-async-process=video/convert,f_avi,vcodec_h265,s_1920x1080,vb_2000000,fps_30,acodec_aac,ab_100000,sn_1|sys/saveas,b_ZGVzdC1idWNrZXQ,o_ZGVtby5tcDQ', $input->getBody()->getContents()); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToAsyncProcessObject() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toAsyncProcessObject($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json;charset=utf-8'], + null, + new OperationInput('AsyncProcessObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json;charset=utf-8'], + ), + ); + $result = ObjectBasic::toAsyncProcessObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->eventId); + $this->assertNull($result->taskId); + $this->assertNull($result->processRequestId); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json;charset=utf-8'], + Utils::streamFor('{"EventId":"181-1kZUlN60OH4fWOcOjZEnGnG****","RequestId":"1D99637F-F59E-5B41-9200-C4892F52****","TaskId":"MediaConvert-e4a737df-69e9-4fca-8d9b-17c40ea3****"}'), + new OperationInput('AsyncProcessObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json;charset=utf-8'], + ), + ); + $result = ObjectBasic::toAsyncProcessObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('181-1kZUlN60OH4fWOcOjZEnGnG****', $result->eventId); + $this->assertEquals('1D99637F-F59E-5B41-9200-C4892F52****', $result->processRequestId); + $this->assertEquals('MediaConvert-e4a737df-69e9-4fca-8d9b-17c40ea3****', $result->taskId); + } + + public function testFromProcessObject() + { + // miss required field + try { + $request = new Models\ProcessObjectRequest(); + $input = ObjectBasic::fromProcessObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\ProcessObjectRequest('bucket-123'); + $input = ObjectBasic::fromProcessObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\ProcessObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromProcessObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, process", (string)$e); + } + + $process = sprintf("image/resize,w_100|sys/saveas,o_%s", base64_encode("dest.jpg")); + $request = new Models\ProcessObjectRequest('bucket-123', 'key-123', $process, 'requester'); + $input = ObjectBasic::fromProcessObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('x-oss-process=image/resize,w_100|sys/saveas,o_ZGVzdC5qcGc=', $input->getBody()->getContents()); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } + + public function testToProcessObject() + { + try { + $output = new OperationOutput(); + $result = ObjectBasic::toProcessObject($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json'], + null, + new OperationInput('ProcessObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json'], + ), + ); + $result = ObjectBasic::toProcessObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->processStatus); + $this->assertNull($result->fileSize); + $this->assertNull($result->bucket); + $this->assertNull($result->key); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json;charset=utf-8'], + Utils::streamFor('{ + "bucket": "dest-bucket", + "fileSize": 3267, + "object": "dest.jpg", + "status": "OK"}'), + new OperationInput('ProcessObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json;charset=utf-8'], + ), + ); + $result = ObjectBasic::toProcessObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('dest-bucket', $result->bucket); + $this->assertEquals('dest.jpg', $result->key); + $this->assertEquals(3267, $result->fileSize); + $this->assertEquals('OK', $result->processStatus); + } + + public function testFromSealAppendObject() + { + // miss required field + try { + $request = new Models\SealAppendObjectRequest(); + $input = ObjectBasic::fromSealAppendObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\SealAppendObjectRequest('bucket-123'); + $input = ObjectBasic::fromSealAppendObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\SealAppendObjectRequest('bucket-123', 'key-123'); + $input = ObjectBasic::fromSealAppendObject($request); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, position", (string)$e); + } + $body = 'hi oss'; + $request = new Models\SealAppendObjectRequest('bucket-123', 'key-123', 0); + $input = ObjectBasic::fromSealAppendObject($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('0', $input->getParameters()['position']); + } + + public function testToSealAppendObject() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectBasic::toSealAppendObject($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'x-oss-sealed-time' => 'Wed, 07 May 2025 23:00:00 GMT'], + null, + new OperationInput('SealAppendObject', 'POST', []), + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"F2064A169EE92E9775EE5324D0B1****"', 'x-oss-sealed-time' => 'Wed, 07 May 2025 23:00:00 GMT'], + ), + ); + $result = ObjectBasic::toSealAppendObject($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('Wed, 07 May 2025 23:00:00 GMT', $result->sealedTime); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectMultipartTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectMultipartTest.php new file mode 100644 index 0000000..3b0f0bd --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/ObjectMultipartTest.php @@ -0,0 +1,1121 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + // bucket only + try { + $request = new Models\InitiateMultipartUploadRequest('bucket-123'); + $input = ObjectMultipart::fromInitiateMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\InitiateMultipartUploadRequest('bucket-123', 'key-123'); + $input = ObjectMultipart::fromInitiateMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\EncodeType::URL, $input->getParameters()['encoding-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\InitiateMultipartUploadRequest('bucket-123', 'key-123', Models\EncodeType::URL, Models\StorageClassType::STANDARD, array('name' => 'walker', 'email' => 'demo@aliyun.com'), 'no-cache', 'attachment', 'utf-8', null, null, null, '2022-10-12T00:00:00.000Z', 'KMS', 'SM4', '9468da86-3509-4f8d-a61e-6eab1eac****', 'TagA=B&TagC=D', false, 'requester'); + $input = ObjectMultipart::fromInitiateMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals(Models\EncodeType::URL, $input->getParameters()['encoding-type']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals(Models\StorageClassType::STANDARD, $input->getHeaders()['x-oss-storage-class']); + $this->assertEquals('walker', $input->getHeaders()['x-oss-meta-name']); + $this->assertEquals('demo@aliyun.com', $input->getHeaders()['x-oss-meta-email']); + $this->assertEquals('KMS', $input->getHeaders()['x-oss-server-side-encryption']); + $this->assertEquals('SM4', $input->getHeaders()['x-oss-server-side-data-encryption']); + $this->assertEquals('9468da86-3509-4f8d-a61e-6eab1eac****', $input->getHeaders()['x-oss-server-side-encryption-key-id']); + $this->assertEquals('false', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals('utf-8', $input->getHeaders()['content-encoding']); + $this->assertEquals('2022-10-12T00:00:00.000Z', $input->getHeaders()['expires']); + $this->assertEquals('TagA=B&TagC=D', $input->getHeaders()['x-oss-tagging']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + $this->assertEmpty($input->getParameters()['uploads']); + $this->assertNotEmpty($input->getOpMetadata()); + $this->assertEquals(true, $input->getOpMetadata()['detect_content_type']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testToInitiateMultipartUpload() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toInitiateMultipartUpload($output); + $this->assertTrue(false, 'should not here'); + } catch (Exception\DeserializationExecption $e) { + $this->assertStringContainsString('Not found tag ', $e); + } + + //empty xml + try { + $str = ' + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str) + ); + $result = ObjectMultipart::toInitiateMultipartUpload($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertNull($result->bucket); + $this->assertNull($result->key); + $this->assertNull($result->uploadId); + $this->assertNull($result->encodingType); + } catch (Exception\DeserializationExecption $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $str = ' + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor($str) + ); + $result = ObjectMultipart::toInitiateMultipartUpload($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('', $result->bucket); + $this->assertEquals('', $result->key); + $this->assertNull($result->uploadId); + $this->assertNull($result->encodingType); + } catch (Exception\DeserializationExecption $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'content-type' => 'application/xml'], + Utils::streamFor(' + oss-example + multipart.data + 0004B9894A22E5B1888A1E29F823**** +') + ); + $result = ObjectMultipart::toInitiateMultipartUpload($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('application/xml', $result->headers['content-type']); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('oss-example', $result->bucket); + $this->assertEquals('multipart.data', $result->key); + $this->assertEquals('0004B9894A22E5B1888A1E29F823****', $result->uploadId); + $this->assertEquals('', $result->encodingType); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromUploadPart() + { + // miss required field + try { + $request = new Models\UploadPartRequest(); + $input = ObjectMultipart::fromUploadPart($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\UploadPartRequest('bucket-123'); + $input = ObjectMultipart::fromUploadPart($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\UploadPartRequest('bucket-123', 'key-123'); + $input = ObjectMultipart::fromUploadPart($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, partNumber", (string)$e); + } + + try { + $request = new Models\UploadPartRequest('bucket-123', 'key-123', 1); + $input = ObjectMultipart::fromUploadPart($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, uploadId", (string)$e); + } + + try { + $request = new Models\UploadPartRequest('bucket-123', 'key-123', 1, '0004B9895DBBB6EC9****'); + $input = ObjectMultipart::fromUploadPart($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('1', $input->getParameters()['partNumber']); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\UploadPartRequest('bucket-123', 'key-123', 1, '0004B9895DBBB6EC9****', null, null, 100 * 1024 * 8, 'requester'); + $input = ObjectMultipart::fromUploadPart($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('1', $input->getParameters()['partNumber']); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals('819200', $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testToUploadPart() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toUploadPart($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'ETag' => '"7265F4D211B56873A381D321F586****"', 'Content-MD5' => '1B2M2Y8AsgTpgAmY7Ph****', 'x-oss-hash-crc64ecma' => '316181249502703*****'], + null, + null, + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'ETag' => '"7265F4D211B56873A381D321F586****"', 'Content-MD5' => '1B2M2Y8AsgTpgAmY7Ph****', 'x-oss-hash-crc64ecma' => '316181249502703*****'], + ), + ); + $result = ObjectMultipart::toUploadPart($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(4, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"7265F4D211B56873A381D321F586****"', $result->etag); + $this->assertEquals('1B2M2Y8AsgTpgAmY7Ph****', $result->contentMd5); + $this->assertEquals('316181249502703*****', $result->hashCrc64); + } catch (Exception\DeserializationExecption $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromUploadPartCopy() + { + // miss required field + try { + $request = new Models\UploadPartCopyRequest(); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\UploadPartCopyRequest('bucket-123'); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\UploadPartCopyRequest('bucket-123', 'key-123'); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, sourceKey", (string)$e); + } + + try { + $request = new Models\UploadPartCopyRequest('bucket-123', 'key-123', null, null, null, 'key-source'); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, partNumber", (string)$e); + } + + try { + $request = new Models\UploadPartCopyRequest('bucket-123', 'key-123', 1, null, null, 'key-source'); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, uploadId", (string)$e); + } + + try { + $request = new Models\UploadPartCopyRequest('bucket-123', 'key-123', 1, '0004B9895DBBB6EC9****', null, 'oss-src-dir/oss-src-obj+123'); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('/bucket-123/oss-src-dir/oss-src-obj%2B123', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('1', $input->getParameters()['partNumber']); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\UploadPartCopyRequest('bucket-123', 'key-123', 1, '0004B9895DBBB6EC9****', 'src-bucket', 'oss-src-dir/oss-src-obj', 'CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', null, null, null, null, null, 100 * 1024 * 8, 'requester'); + $input = ObjectMultipart::fromUploadPartCopy($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('/src-bucket/oss-src-dir/oss-src-obj?versionId=CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', $input->getHeaders()['x-oss-copy-source']); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + $this->assertEquals('1', $input->getParameters()['partNumber']); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals('819200', $input->getHeaders()['x-oss-traffic-limit']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testToUploadPartCopy() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toUploadPartCopy($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'x-oss-copy-source-version-id' => 'CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', 'Content-Type' => 'application/xml'], + Utils::streamFor(' + + 2014-07-17T06:27:54.000Z + "5B3C1A2E053D763E1B002CC607C5****" +'), + null, + null, + new \GuzzleHttp\Psr7\Response( + 200, + ['x-oss-request-id' => '123', 'x-oss-copy-source-version-id' => 'CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', 'Content-Type' => 'application/xml'], + ), + ); + $result = ObjectMultipart::toUploadPartCopy($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(3, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"5B3C1A2E053D763E1B002CC607C5****"', $result->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2014-07-17T06:27:54.000Z', + new \DateTimeZone('UTC') + ), $result->lastModified); + $this->assertEquals('CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', $result->sourceVersionId); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromCompleteMultipartUpload() + { + // miss required field + try { + $request = new Models\CompleteMultipartUploadRequest(); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123'); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123'); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, uploadId", (string)$e); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****'); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', Models\ObjectACLType::PUBLIC_READ, null, null, null, null, null, null, null, null, Models\ObjectACLType::PRIVATE); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', Models\ObjectACLType::PUBLIC_READ, null, null, null, null, null, null, null, null, Models\ObjectACLType::PRIVATE); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertEquals(Models\ObjectACLType::PRIVATE, $input->getHeaders()['x-oss-object-acl']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', null, new Models\CompleteMultipartUpload([new Models\UploadPart(1, '"3349DC700140D7F86A0784842780****"'), new Models\UploadPart(2, '"8C315065167132444177411FDA14****"'), new Models\UploadPart(3, '"8EFDA8BE206636A695359836FE0A****"'),]), null, null, null, null, Models\EncodeType::URL); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals(Models\EncodeType::URL, $input->getParameters()['encoding-type']); + $body = $input->getBody()->getContents(); + $this->assertEquals(base64_encode(md5($body, true)), $input->getHeaders()['content-md5']); + $xml = <<1"3349DC700140D7F86A0784842780****"2"8C315065167132444177411FDA14****"3"8EFDA8BE206636A695359836FE0A****" +BBB; + $this->assertEquals($xml, $this->cleanXml($body)); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', null, new Models\CompleteMultipartUpload([new Models\UploadPart(1, null, '"3349DC700140D7F86A0784842780****1"',), new Models\UploadPart(2, null, '"8C315065167132444177411FDA14****2"'), new Models\UploadPart(3, null, '"8EFDA8BE206636A695359836FE0A****3"'),]), null, null, null, null, Models\EncodeType::URL); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals(Models\EncodeType::URL, $input->getParameters()['encoding-type']); + $body = $input->getBody()->getContents(); + $this->assertEquals(base64_encode(md5($body, true)), $input->getHeaders()['content-md5']); + $xml = <<1"3349DC700140D7F86A0784842780****1"2"8C315065167132444177411FDA14****2"3"8EFDA8BE206636A695359836FE0A****3" +BBB; + $this->assertEquals($xml, $this->cleanXml($body)); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', null, new Models\CompleteMultipartUpload([new Models\UploadPart(1, '"3349DC700140D7F86A0784842780****"', '"3349DC700140D7F86A0784842780****1"',), new Models\UploadPart(2, '"8C315065167132444177411FDA14****"', '"8C315065167132444177411FDA14****2"'), new Models\UploadPart(3, '"8EFDA8BE206636A695359836FE0A****"', '"8EFDA8BE206636A695359836FE0A****3"'),]), null, null, null, null, Models\EncodeType::URL); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals(Models\EncodeType::URL, $input->getParameters()['encoding-type']); + $body = $input->getBody()->getContents(); + $this->assertEquals(base64_encode(md5($body, true)), $input->getHeaders()['content-md5']); + $xml = <<1"3349DC700140D7F86A0784842780****1"2"8C315065167132444177411FDA14****2"3"8EFDA8BE206636A695359836FE0A****3" +BBB; + $this->assertEquals($xml, $this->cleanXml($body)); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $callback = base64_encode('{"callbackUrl":"www.aliyuncs.com", "callbackBody":"filename=${object}&size=${size}&mimeType=${mimeType}&x=${x:a}&b=${x:b}"}'); + $callbackVar = base64_encode('{"x:a":"a", "x:b":"b"}'); + $request = new Models\CompleteMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', null, null, 'yes', $callback, $callbackVar, false, null, 'requester'); + $input = ObjectMultipart::fromCompleteMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals('false', $input->getHeaders()['x-oss-forbid-overwrite']); + $this->assertEquals($callback, $input->getHeaders()['x-oss-callback']); + $this->assertEquals($callbackVar, $input->getHeaders()['x-oss-callback-var']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testToCompleteMultipartUpload() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toCompleteMultipartUpload($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Call to a member function hasHeader() on null', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + null, + new OperationInput('CompleteMultipartUpload', 'POST'), + null, + new \GuzzleHttp\Psr7\Response( + 200, ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + ), + ); + $result = ObjectMultipart::toCompleteMultipartUpload($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e->getMessage()); + } + + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' + + url + http://oss-example.oss-cn-hangzhou.aliyuncs.com/multipart.data + oss-example + demo%2Fmultipart.data + "097DE458AD02B5F89F9D0530231876****" +'), + new OperationInput('CompleteMultipartUpload', 'POST'), + null, + new \GuzzleHttp\Psr7\Response(), + ); + $result = ObjectMultipart::toCompleteMultipartUpload($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('"097DE458AD02B5F89F9D0530231876****"', $result->etag); + $this->assertEquals(Models\EncodeType::URL, $result->encodingType); + $this->assertEquals('oss-example', $result->bucket); + $this->assertEquals('demo/multipart.data', $result->key); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/json', 'x-oss-version-id' => 'CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', 'x-oss-hash-crc64ecma' => '1206617243528768****'], + Utils::streamFor('{"filename":"oss-obj.txt","size":"100","mimeType":"","x":"a","b":"b"}'), + new OperationInput('CompleteMultipartUpload', 'POST', ['x-oss-callback' => '{"callbackUrl":"www.aliyuncs.com", "callbackBody":"filename=${object}&size=${size}&mimeType=${mimeType}&x=${x:a}&b=${x:b}"}']), + null, + new \GuzzleHttp\Psr7\Response( + 200, ['x-oss-request-id' => '123', 'Content-Type' => 'application/json', 'x-oss-version-id' => 'CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', 'x-oss-hash-crc64ecma' => '1206617243528768****'] + ), + ); + $result = ObjectMultipart::toCompleteMultipartUpload($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(4, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertEquals('application/json', $result->headers['Content-Type']); + $this->assertEquals('CAEQMxiBgMC0vs6D0BYiIGJiZWRjOTRjNTg0NzQ1MTRiN2Y1OTYxMTdkYjQ0****', $result->versionId); + $this->assertEquals('1206617243528768****', $result->hashCrc64); + $this->assertEquals('{"filename":"oss-obj.txt","size":"100","mimeType":"","x":"a","b":"b"}', json_encode($result-> + callbackResult)); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + } + + public function testFromAbortMultipartUpload() + { + // miss required field + try { + $request = new Models\AbortMultipartUploadRequest(); + $input = ObjectMultipart::fromAbortMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\AbortMultipartUploadRequest('bucket-123'); + $input = ObjectMultipart::fromAbortMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\AbortMultipartUploadRequest('bucket-123', 'key-123'); + $input = ObjectMultipart::fromAbortMultipartUpload($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, uploadId", (string)$e); + } + + try { + $request = new Models\AbortMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****'); + $input = ObjectMultipart::fromAbortMultipartUpload($request); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\AbortMultipartUploadRequest('bucket-123', 'key-123', '0004B9895DBBB6EC9****', 'requester'); + $input = ObjectMultipart::fromAbortMultipartUpload($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('0004B9895DBBB6EC9****', $input->getParameters()['uploadId']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(false, "should not here"); + } + + } + + public function testToAbortMultipartUpload() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toAbortMultipartUpload($output); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + ); + $result = ObjectMultipart::toAbortMultipartUpload($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + } + + public function testFromListMultipartUploads() + { + try { + $request = new Models\ListMultipartUploadsRequest(); + $input = ObjectMultipart::fromListMultipartUploads($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\ListMultipartUploadsRequest('bucket-123'); + $input = ObjectMultipart::fromListMultipartUploads($request); + $this->assertEquals('bucket-123', $input->getBucket()); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\ListMultipartUploadsRequest('bucket-123', '/', Models\EncodeType::URL, '89F0105AA66942638E35300618DF5EE7', '89F0105AA66942638E35300618DF5EE7', 10, 'prefix', 'requester'); + $input = ObjectMultipart::fromListMultipartUploads($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('', $input->getParameters()['uploads']); + $this->assertEquals('/', $input->getParameters()['delimiter']); + $this->assertEquals('prefix', $input->getParameters()['prefix']); + $this->assertEquals('89F0105AA66942638E35300618DF5EE7', $input->getParameters()['key-marker']); + $this->assertEquals('89F0105AA66942638E35300618DF5EE7', $input->getParameters()['upload-id-marker']); + $this->assertEquals('10', $input->getParameters()['max-uploads']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, "should not here"); + } + + } + + public function testToListMultipartUploads() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toListMultipartUploads($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e->getMessage()); + } + + // empty xml + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + ); + $result = ObjectMultipart::toListMultipartUploads($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' +') + ); + $result = ObjectMultipart::toListMultipartUploads($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + + $this->assertNull($result->bucket); + $this->assertNull($result->prefix); + $this->assertNull($result->keyMarker); + $this->assertNull($result->uploadIdMarker); + $this->assertNull($result->maxUploads); + $this->assertNull($result->delimiter); + $this->assertNull($result->isTruncated); + $this->assertNull($result->nextKeyMarker); + $this->assertNull($result->nextUploadIdMarker); + $this->assertNull($result->uploads); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' + + oss-example + + + oss.avi + 0004B99B8E707874FC2D692FA5D77D3F + + + 1000 + false + + multipart.data + 0004B999EF518A1FE585B0C9360DC4C8 + 2012-02-23T04:18:23.000Z + + + multipart.data + 0004B999EF5A239BB9138C6227D6**** + 2012-02-23T04:18:23.000Z + + + oss.avi + 0004B99B8E707874FC2D692FA5D7**** + 2012-02-23T06:14:27.000Z + +') + ); + $result = ObjectMultipart::toListMultipartUploads($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + + $this->assertEquals('oss-example', $result->bucket); + $this->assertEquals('', $result->keyMarker); + $this->assertEquals('', $result->uploadIdMarker); + $this->assertEquals('oss.avi', $result->nextKeyMarker); + $this->assertEquals('0004B99B8E707874FC2D692FA5D77D3F', $result->nextUploadIdMarker); + $this->assertEquals('', $result->delimiter); + $this->assertEquals('', $result->prefix); + $this->assertEquals(1000, $result->maxUploads); + $this->assertEquals(false, $result->isTruncated); + $this->assertCount(3, $result->uploads); + + $this->assertEquals('multipart.data', $result->uploads[0]->key); + $this->assertEquals('0004B999EF518A1FE585B0C9360DC4C8', $result->uploads[0]->uploadId); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2012-02-23T04:18:23.000Z', + new \DateTimeZone('UTC') + ), $result->uploads[0]->initiated); + } catch (\Throwable $e) { + printf($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' + + url + oss-example + + + oss.avi + 89F0105AA66942638E35300618DF**** + + + 1000 + false + + demo%2Fgp-%0C%0A%0B + 0214A87687F040F1BA4D83AB17C9**** + 2023-11-22T05:45:57.000Z + + + demo%2Fgp-%0C%0A%0B + 3AE2ED7A60E04AFE9A5287055D37**** + 2023-11-22T05:03:33.000Z + + + demo%2Fgp-%0C%0A%0B + 47E0E90F5DCB4AD5B3C4CD886CB0**** + 2023-11-22T05:02:11.000Z + + + demo%2Fgp-%0C%0A%0B + A89E0E28E2E948A1BFF6FD5CDAFF**** + 2023-11-22T06:57:03.000Z + + + demo%2Fgp-%0C%0A%0B + B18E1DCDB6964F5CB197F5F6B26A**** + 2023-11-22T05:42:02.000Z + + + demo%2Fgp-%0C%0A%0B + D4E111D4EA834F3ABCE4877B2779**** + 2023-11-22T05:42:33.000Z + + + walker-dest.txt + 5209986C3A96486EA16B9C52C160**** + 2023-11-21T08:34:47.000Z + + + walker-dest.txt + 63B652FA2C1342DCB3CCCC86D748**** + 2023-11-21T08:28:46.000Z + + + walker-dest.txt + 6F67B34BCA3C481F887D73508A07**** + 2023-11-21T08:32:12.000Z + + + walker-dest.txt + 89F0105AA66942638E35300618D**** + 2023-11-21T08:37:53.000Z + +') + ); + $result = ObjectMultipart::toListMultipartUploads($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + + $this->assertEquals('oss-example', $result->bucket); + $this->assertEquals('', $result->keyMarker); + $this->assertEquals('', $result->uploadIdMarker); + $this->assertEquals('oss.avi', $result->nextKeyMarker); + $this->assertEquals('89F0105AA66942638E35300618DF****', $result->nextUploadIdMarker); + $this->assertEquals('', $result->delimiter); + $this->assertEquals('', $result->prefix); + $this->assertEquals(1000, $result->maxUploads); + $this->assertEquals(false, $result->isTruncated); + $this->assertCount(10, $result->uploads); + $this->assertEquals("demo/gp-\f\n\v", $result->uploads[0]->key); + $this->assertEquals('0214A87687F040F1BA4D83AB17C9****', $result->uploads[0]->uploadId); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2023-11-22T05:45:57.000Z', + new \DateTimeZone('UTC') + ), $result->uploads[0]->initiated); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + } + + public function testFromListParts() + { + try { + $request = new Models\ListPartsRequest(); + $input = ObjectMultipart::fromListParts($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, bucket", (string)$e); + } + + try { + $request = new Models\ListPartsRequest('bucket-123'); + $input = ObjectMultipart::fromListParts($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, key", (string)$e); + } + + try { + $request = new Models\ListPartsRequest('bucket-123', 'key-123'); + $input = ObjectMultipart::fromListParts($request); + $this->assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, uploadId", (string)$e); + } + + try { + $request = new Models\ListPartsRequest('bucket-123', 'key-123', 'uploadId-123'); + $input = ObjectMultipart::fromListParts($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('uploadId-123', $input->getParameters()['uploadId']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + try { + $request = new Models\ListPartsRequest('bucket-123', 'key-123', '89F0105AA66942638E35300618DF5EE7', null, null, 10, 'requester'); + $input = ObjectMultipart::fromListParts($request); + $this->assertEquals('bucket-123', $input->getBucket()); + $this->assertEquals('key-123', $input->getKey()); + $this->assertEquals('89F0105AA66942638E35300618DF5EE7', $input->getParameters()['uploadId']); + $this->assertEquals('url', $input->getParameters()['encoding-type']); + $this->assertEquals('10', $input->getParameters()['max-parts']); + $this->assertEquals('requester', $input->getHeaders()['x-oss-request-payer']); + } catch (\Throwable $e) { + $this->assertTrue(false, "should not here"); + } + + } + + public function testToListParts() + { + // empty output + try { + $output = new OperationOutput(); + $result = ObjectMultipart::toListParts($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e->getMessage()); + } + + // empty xml + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + ); + $result = ObjectMultipart::toListParts($output); + $this->assertTrue(false, 'should not here'); + } catch (\Throwable $e) { + $this->assertStringContainsString('Not found tag ', $e->getMessage()); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' +') + ); + $result = ObjectMultipart::toListParts($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + + $this->assertNull($result->bucket); + $this->assertNull($result->key); + $this->assertNull($result->uploadId); + $this->assertNull($result->nextPartNumberMarker); + $this->assertNull($result->maxParts); + $this->assertNull($result->isTruncated); + } catch (\Throwable $e) { + $this->assertTrue(false, 'should not here'); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' + + multipart_upload + multipart.data + 0004B999EF5A239BB9138C6227D6**** + 5 + 1000 + false + + 1 + 2012-02-23T07:01:34.000Z + "3349DC700140D7F86A0784842780****" + 6291456 + + + 2 + 2012-02-23T07:01:12.000Z + "3349DC700140D7F86A0784842780****" + 6291456 + + + 5 + 2012-02-23T07:02:03.000Z + "7265F4D211B56873A381D321F586****" + 1024 + +') + ); + $result = ObjectMultipart::toListParts($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + + $this->assertEquals('multipart_upload', $result->bucket); + $this->assertEquals('multipart.data', $result->key); + $this->assertNull($result->partNumberMarker); + $this->assertNull($result->encodingType); + $this->assertEquals('5', $result->nextPartNumberMarker); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals(1000, $result->maxParts); + $this->assertCount(3, $result->parts); + $this->assertEquals(1, $result->parts[0]->partNumber); + $this->assertEquals('"3349DC700140D7F86A0784842780****"', $result->parts[0]->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2012-02-23T07:01:34.000Z', + new \DateTimeZone('UTC') + ), $result->parts[0]->lastModified); + $this->assertEquals(6291456, $result->parts[0]->size); + } catch (\Throwable $e) { + printf($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + + try { + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123', 'Content-Type' => 'application/xml'], + Utils::streamFor(' + + url + oss-bucket + demo%2Fgp-%0C%0A%0B + D4E111D4EA834F3ABCE4877B2779**** + Standard + 0 + 1 + 1000 + false + + 1 + 2023-11-22T05:42:34.000Z + "CF3F46D505093571E916FCDD4967****" + 12066172435287683848 + 96316 + +') + ); + $result = ObjectMultipart::toListParts($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(2, count($result->headers)); + + $this->assertEquals('oss-bucket', $result->bucket); + $this->assertEquals(urldecode('demo%2Fgp-%0C%0A%0B'), $result->key); + $this->assertEquals('0', $result->partNumberMarker); + $this->assertEquals(Models\EncodeType::URL, $result->encodingType); + $this->assertEquals(Models\StorageClassType::STANDARD, $result->storageClass); + $this->assertEquals('1', $result->nextPartNumberMarker); + $this->assertEquals(false, $result->isTruncated); + $this->assertEquals(1000, $result->maxParts); + $this->assertCount(1, $result->parts); + $this->assertEquals(1, $result->parts[0]->partNumber); + $this->assertEquals('"CF3F46D505093571E916FCDD4967****"', $result->parts[0]->etag); + $this->assertEquals(\DateTime::createFromFormat( + 'Y-m-d\TH:i:s.000\Z', + '2023-11-22T05:42:34.000Z', + new \DateTimeZone('UTC') + ), $result->parts[0]->lastModified); + $this->assertEquals('12066172435287683848', $result->parts[0]->hashCrc64); + $this->assertEquals(96316, $result->parts[0]->size); + } catch (\Throwable $e) { + print_r($e->getMessage()); + $this->assertTrue(false, 'should not here'); + } + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/PublicAccessBlockTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/PublicAccessBlockTest.php new file mode 100644 index 0000000..999ad50 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Transform/PublicAccessBlockTest.php @@ -0,0 +1,127 @@ +assertTrue(false, "should not here"); + } catch (\InvalidArgumentException $e) { + $this->assertStringContainsString("missing required field, publicAccessBlockConfiguration", (string)$e); + } + + // demo1 + $request = new Models\PutPublicAccessBlockRequest(new Models\PublicAccessBlockConfiguration( + true + )); + $input = PublicAccessBlock::fromPutPublicAccessBlock($request); + $xml = <<true +BBB; + $this->assertEquals($xml, $this->cleanXml($input->getBody()->getContents())); + } + + public function testToPutPublicAccessBlock() + { + // empty output + $output = new OperationOutput(); + $result = PublicAccessBlock::toPutPublicAccessBlock($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'] + ); + $result = PublicAccessBlock::toPutPublicAccessBlock($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + public function testFromGetPublicAccessBlock() + { + $request = new Models\GetPublicAccessBlockRequest(); + $input = PublicAccessBlock::fromGetPublicAccessBlock($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToGetPublicAccessBlock() + { + // empty output + $output = new OperationOutput(); + $result = PublicAccessBlock::toGetPublicAccessBlock($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $body = ' + + true + '; + $output = new OperationOutput( + 'OK', + 200, + ['x-oss-request-id' => '123'], + Utils::streamFor($body) + ); + $result = PublicAccessBlock::toGetPublicAccessBlock($output); + $this->assertEquals('OK', $result->status); + $this->assertEquals(200, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + $this->assertTrue($result->publicAccessBlockConfiguration->blockPublicAccess); + } + + public function testFromDeletePublicAccessBlock() + { + $request = new Models\DeletePublicAccessBlockRequest(); + $input = PublicAccessBlock::fromDeletePublicAccessBlock($request); + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', $input->getHeaders()['content-md5']); + } + + public function testToDeletePublicAccessBlock() + { + // empty output + $output = new OperationOutput(); + $result = PublicAccessBlock::toDeletePublicAccessBlock($output); + $this->assertEquals('', $result->status); + $this->assertEquals(0, $result->statusCode); + $this->assertEquals('', $result->requestId); + $this->assertEquals(0, count($result->headers)); + + $output = new OperationOutput( + 'No Content', + 204, + ['x-oss-request-id' => '123'] + ); + $result = PublicAccessBlock::toDeletePublicAccessBlock($output); + $this->assertEquals('No Content', $result->status); + $this->assertEquals(204, $result->statusCode); + $this->assertEquals('123', $result->requestId); + $this->assertEquals(1, count($result->headers)); + $this->assertEquals('123', $result->headers['x-oss-request-id']); + } + + private function cleanXml($xml): array|string + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelA.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelA.php new file mode 100644 index 0000000..78d3ecb --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelA.php @@ -0,0 +1,30 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelPrivate.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelPrivate.php new file mode 100644 index 0000000..b7e3b2a --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelPrivate.php @@ -0,0 +1,41 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelTest.php new file mode 100644 index 0000000..e513503 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/ModelTest.php @@ -0,0 +1,112 @@ +assertNull($m->strValue); + $this->assertNull($m->intValue); + $this->assertNull($m->boolValue); + $this->assertNull($m->floatValue); + + #use getter + $this->assertNull($m->getStrValue()); + $this->assertNull($m->getIntValue()); + $this->assertNull($m->getBoolValue()); + $this->assertNull($m->getFloatValue()); + + #set from construct + # all + $m = new ModelA( + "str", + 1234, + true, + 3.14 + ); + $this->assertEquals("str", $m->strValue); + $this->assertEquals(1234, $m->intValue); + $this->assertEquals(true, $m->boolValue); + $this->assertEquals(3.14, $m->floatValue); + + $this->assertEquals("str", $m->getStrValue()); + $this->assertEquals(1234, $m->getIntValue()); + $this->assertEquals(true, $m->getBoolValue()); + $this->assertEquals(3.14, $m->getFloatValue()); + + # part + $m = new ModelA( + "str", + null, + null, + 3.14 + ); + $this->assertEquals("str", $m->strValue); + $this->assertEquals(null, $m->intValue); + $this->assertEquals(null, $m->boolValue); + $this->assertEquals(3.14, $m->floatValue); + + $this->assertEquals("str", $m->getStrValue()); + $this->assertEquals(null, $m->getIntValue()); + $this->assertEquals(null, $m->getBoolValue()); + $this->assertEquals(3.14, $m->getFloatValue()); + + #set from setter + $m = new ModelA(); + + $m->setStrValue("str-123"); + $m->setIntValue(321); + $m->setBoolValue(false); + $m->setFloatValue(1.2); + + $this->assertEquals("str-123", $m->strValue); + $this->assertEquals(321, $m->intValue); + $this->assertEquals(false, $m->boolValue); + $this->assertEquals(1.2, $m->floatValue); + + $this->assertEquals("str-123", $m->getStrValue()); + $this->assertEquals(321, $m->getIntValue()); + $this->assertEquals(false, $m->getBoolValue()); + $this->assertEquals(1.2, $m->getFloatValue()); + + # Chaining setter + $m = new ModelA(); + $m->setStrValue("str-111")->setIntValue(555)->setBoolValue(true)->setFloatValue(2.2); + $this->assertEquals("str-111", $m->getStrValue()); + $this->assertEquals(555, $m->getIntValue()); + $this->assertEquals(true, $m->getBoolValue()); + $this->assertEquals(2.2, $m->getFloatValue()); + } + + public function testModelTrait() + { + #set from construct + $m = new ModelPrivate( + "str", + 1234, + true, + 3.14, + ); + + $this->assertEquals("str", $m->getStrValue()); + $this->assertEquals(1234, $m->getIntValue()); + $this->assertEquals(true, $m->getBoolValue()); + $this->assertEquals(3.14, $m->getFloatValue()); + + $m->setStrValue('str-new')->setBoolValue(false)->setIntValue(321)->setFloatValue(1.12); + + $this->assertEquals("str-new", $m->getStrValue()); + $this->assertEquals(321, $m->getIntValue()); + $this->assertEquals(false, $m->getBoolValue()); + $this->assertEquals(1.12, $m->getFloatValue()); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/XmlModelA.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/XmlModelA.php new file mode 100644 index 0000000..db03085 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/Types/XmlModelA.php @@ -0,0 +1,44 @@ +strValue = $strValue; + $this->intValue = $intValue; + $this->boolValue = $boolValue; + $this->floatValue = $floatValue; + $this->strValueList = $strValueList; + + #print(get_defined_vars()); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/UtilsTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/UtilsTest.php new file mode 100644 index 0000000..7dc6464 --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/UtilsTest.php @@ -0,0 +1,187 @@ +assertInstanceOf(StreamInterface::class, $stream); + $this->assertEquals(11, $stream->getSize()); + $this->assertEquals(true, $stream->isSeekable()); + $got = $stream->read(20); + $this->assertEquals($data, $got); + + $got = $stream->read(20); + $this->assertEquals('', $got); + + $stream->rewind(); + $got = $stream->read(20); + $this->assertEquals($data, $got); + } + + public function testGuessContentType(): void + { + $this->assertEquals(null, Utils::guessContentType('')); + $this->assertEquals('application/octet-stream', Utils::guessContentType('', 'application/octet-stream')); + $this->assertEquals('image/jpeg', Utils::guessContentType('1.jpeg')); + $this->assertEquals('image/jpeg', Utils::guessContentType('1.jpeg', 'application/octet-stream')); + } + + public function testUrlEncode(): void + { + $this->assertEquals('123%2F123%2F%2B%20%3F%2F123', Utils::urlEncode('123/123/+ ?/123')); + $this->assertEquals('123/123/%2B%20%3F/123', Utils::urlEncode('123/123/+ ?/123', true)); + } + + public function testIsIpFormat(): void + { + $this->assertTrue(Utils::isIPFormat("10.101.160.147")); + $this->assertTrue(Utils::isIPFormat("12.12.12.34")); + $this->assertTrue(Utils::isIPFormat("12.12.12.12")); + $this->assertTrue(Utils::isIPFormat("255.255.255.255")); + $this->assertTrue(Utils::isIPFormat("0.1.1.1")); + $this->assertFalse(Utils::isIPFormat("0.1.1.x")); + $this->assertFalse(Utils::isIPFormat("0.1.1.256")); + $this->assertFalse(Utils::isIPFormat("256.1.1.1")); + $this->assertFalse(Utils::isIPFormat("0.1.1.0.1")); + $this->assertTrue(Utils::isIPFormat("10.10.10.10:123")); + } + + public function testToSimpleArray(): void + { + $this->assertEquals([], Utils::toSimpleArray([])); + $this->assertEquals([1, 2, 3], Utils::toSimpleArray([1, 2, 3])); + $this->assertEquals( + ['1' => '1-1', '2' => '2-1', '3' => '3-1'], + Utils::toSimpleArray(['1' => ['1-1', '1-2'], '2' => ['2-1', '2-2'], '3' => '3-1']) + ); + } + + public function testCalcContentMd5(): void + { + $this->assertEquals('1B2M2Y8AsgTpgAmY7PhCfg==', Utils::calcContentMd5(Utils::streamFor(''))); + $body = Utils::streamFor("hello world\n"); + $this->assertEquals('b1kCrCNwJL3QwXbLkwY9xA==', Utils::calcContentMd5($body)); + $this->assertEquals('b1kCrCNwJL3QwXbLkwY9xA==', Utils::calcContentMd5($body)); + } + + public function testEscapeXml(): void + { + $bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]; + $encstr = '� '; + $edata = Utils::escapeXml(pack("C*", ...$bytes)); + $this->assertEquals($encstr, $edata); + + $bytes = [ + 0x10, + 0x11, + 0x12, + 0x13, + 0x14, + 0x15, + 0x16, + 0x17, + 0x18, + 0x19, + 0x1a, + 0x1b, + 0x1c, + 0x1d, + 0x1e, + 0x1f, + 0x20, + 0x21, + 0xe4, + 0xbd, + 0xa0, + 0xe5, + 0xa5, + 0xbd + ]; + $encstr = ' !你好'; + $edata = Utils::escapeXml(pack("C*", ...$bytes)); + $this->assertEquals($encstr, $edata); + + $data = '<>&"'; + $encstr = '<>&"'; + $edata = Utils::escapeXml($data); + $this->assertEquals($encstr, $edata); + } + + public function testParseHttpRange(): void + { + $values = Utils::parseHttpRange('bytes=22-33'); + $this->assertCount(2, $values); + $this->assertEquals(22, $values[0]); + $this->assertEquals(33, $values[1]); + + $values = Utils::parseHttpRange('bytes=-33'); + $this->assertCount(2, $values); + $this->assertEquals(-1, $values[0]); + $this->assertEquals(33, $values[1]); + + $values = Utils::parseHttpRange('bytes=22-'); + $this->assertCount(2, $values); + $this->assertEquals(22, $values[0]); + $this->assertEquals(-1, $values[1]); + + $values = Utils::parseHttpRange('bytes=0-'); + $this->assertCount(2, $values); + $this->assertEquals(0, $values[0]); + $this->assertEquals(-1, $values[1]); + + $values = Utils::parseHttpRange('bytes=-0'); + $this->assertCount(2, $values); + $this->assertEquals(-1, $values[0]); + $this->assertEquals(0, $values[1]); + + $values = Utils::parseHttpRange('bytes=-0'); + $this->assertCount(2, $values); + $this->assertEquals(-1, $values[0]); + $this->assertEquals(0, $values[1]); + + $this->assertFalse(Utils::parseHttpRange('')); + $this->assertFalse(Utils::parseHttpRange('bytes=1-42,55-60')); + $this->assertFalse(Utils::parseHttpRange('bytes=1')); + $this->assertFalse(Utils::parseHttpRange('bytes=abc-123')); + $this->assertFalse(Utils::parseHttpRange('bytes=123-abc')); + } + + public function testParseContentRange(): void + { + $values = Utils::parseContentRange('bytes 22-33/42'); + $this->assertCount(3, $values); + $this->assertEquals(22, $values[0]); + $this->assertEquals(33, $values[1]); + $this->assertEquals(42, $values[2]); + + $values = Utils::parseContentRange('bytes 22-33/*'); + $this->assertCount(3, $values); + $this->assertEquals(22, $values[0]); + $this->assertEquals(33, $values[1]); + $this->assertEquals(-1, $values[2]); + + $this->assertFalse(Utils::parseContentRange('')); + $this->assertFalse(Utils::parseContentRange('invalid')); + $this->assertFalse(Utils::parseContentRange('bytes abc')); + $this->assertFalse(Utils::parseContentRange('bytes */42')); + $this->assertFalse(Utils::parseContentRange('bytes abc/42')); + $this->assertFalse(Utils::parseContentRange('bytes abc-33/42')); + $this->assertFalse(Utils::parseContentRange('bytes 11-abc/42')); + $this->assertFalse(Utils::parseContentRange('bytes 11-33/abc')); + } + + public function testDefaultUserAgent(): void + { + $userAgent = Utils::defaultUserAgent(); + $this->assertStringContainsString('alibabacloud-php-sdk-v2/', $userAgent); + $this->assertStringContainsString(Version::VERSION, $userAgent); + } +} diff --git a/vendor/alibabacloud/oss-v2/tests/UnitTests/ValidationTest.php b/vendor/alibabacloud/oss-v2/tests/UnitTests/ValidationTest.php new file mode 100644 index 0000000..2dc083f --- /dev/null +++ b/vendor/alibabacloud/oss-v2/tests/UnitTests/ValidationTest.php @@ -0,0 +1,44 @@ +assertTrue(Validation::isValidRegion("xxx")); + $this->assertFalse(Validation::isValidRegion("XXXqwe123")); + $this->assertFalse(Validation::isValidRegion("XX")); + $this->assertFalse(Validation::isValidRegion("/X")); + $this->assertFalse(Validation::isValidRegion("")); + } + + public function testIsValidateBucketName() + { + $this->assertTrue(Validation::isValidBucketName("xxx")); + $this->assertFalse(Validation::isValidBucketName("XXXqwe123")); + $this->assertFalse(Validation::isValidBucketName("XX")); + $this->assertFalse(Validation::isValidBucketName("/X")); + $this->assertFalse(Validation::isValidBucketName("")); + $this->assertTrue(Validation::isValidBucketName(str_repeat('a', 3))); + $this->assertTrue(Validation::isValidBucketName(str_repeat('a', 63))); + $this->assertFalse(Validation::isValidBucketName(str_repeat('a', 64))); + $this->assertFalse(Validation::isValidBucketName(str_repeat('a', 2))); + } + + public function testIsValidateObjectName() + { + $this->assertTrue(Validation::isValidObjectName("xxx")); + $this->assertTrue(Validation::isValidObjectName("xxx23")); + $this->assertTrue(Validation::isValidObjectName("12321-xxx")); + $this->assertTrue(Validation::isValidObjectName("x")); + $this->assertTrue(Validation::isValidObjectName("/aa")); + $this->assertTrue(Validation::isValidObjectName("\\aa")); + $this->assertFalse(Validation::isValidObjectName("")); + $this->assertTrue(Validation::isValidObjectName(str_repeat('a', 1))); + $this->assertTrue(Validation::isValidObjectName(str_repeat('a', 1023))); + $this->assertFalse(Validation::isValidObjectName(str_repeat('a', 1024))); + } +} diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..be87920 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,25 @@ +realpath = realpath($opened_path) ?: $opened_path; + $opened_path = $this->realpath; + $this->handle = fopen($this->realpath, $mode); + $this->position = 0; + + return (bool) $this->handle; + } + + public function stream_read($count) + { + $data = fread($this->handle, $count); + + if ($this->position === 0) { + $data = preg_replace('{^#!.*\r?\n}', '', $data); + } + + $this->position += strlen($data); + + return $data; + } + + public function stream_cast($castAs) + { + return $this->handle; + } + + public function stream_close() + { + fclose($this->handle); + } + + public function stream_lock($operation) + { + return $operation ? flock($this->handle, $operation) : true; + } + + public function stream_seek($offset, $whence) + { + if (0 === fseek($this->handle, $offset, $whence)) { + $this->position = ftell($this->handle); + return true; + } + + return false; + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return feof($this->handle); + } + + public function stream_stat() + { + return array(); + } + + public function stream_set_option($option, $arg1, $arg2) + { + return true; + } + + public function url_stat($path, $flags) + { + $path = substr($path, 17); + if (file_exists($path)) { + return stat($path); + } + + return false; + } + } + } + + if ( + (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true)) + || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) + ) { + return include("phpvfscomposer://" . __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server'); + } +} + +return include __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server'; diff --git a/vendor/bin/var-dump-server.bat b/vendor/bin/var-dump-server.bat new file mode 100644 index 0000000..94333da --- /dev/null +++ b/vendor/bin/var-dump-server.bat @@ -0,0 +1,5 @@ +@ECHO OFF +setlocal DISABLEDELAYEDEXPANSION +SET BIN_TARGET=%~dp0/var-dump-server +SET COMPOSER_RUNTIME_BIN_DIR=%~dp0 +php "%BIN_TARGET%" %* diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php new file mode 100644 index 0000000..7824d8f --- /dev/null +++ b/vendor/composer/ClassLoader.php @@ -0,0 +1,579 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..51e734a --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @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|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + 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]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @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 __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +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/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..0fb0a2c --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,10 @@ + $vendorDir . '/composer/InstalledVersions.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..0271256 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,19 @@ + $vendorDir . '/topthink/think-helper/src/helper.php', + '15ec93fa4ce4b2d53816a1a5f2c514e2' => $vendorDir . '/topthink/think-validate/src/helper.php', + '7448f3465e10b5f033e4babb31eb0b06' => $vendorDir . '/topthink/think-orm/src/helper.php', + '35fab96057f1bf5e7aba31a8a6d5fdde' => $vendorDir . '/topthink/think-orm/stubs/load_stubs.php', + '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', + '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', + '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', + 'd79a0e13e295db93891a9377e0888496' => $vendorDir . '/topthink/think-dumper/src/helper.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..c220d0e --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,10 @@ + array($baseDir . '/extend'), +); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..c6ae3a6 --- /dev/null +++ b/vendor/composer/autoload_psr4.php @@ -0,0 +1,30 @@ + array($vendorDir . '/topthink/think-view/src'), + 'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'), + 'think\\dumper\\' => array($vendorDir . '/topthink/think-dumper/src'), + 'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'), + 'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-container/src', $vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/think-validate/src'), + 'app\\' => array($baseDir . '/app'), + 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), + 'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'), + 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log/src'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), + 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), + 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), + 'League\\MimeTypeDetection\\' => array($vendorDir . '/league/mime-type-detection/src'), + 'League\\Flysystem\\Local\\' => array($vendorDir . '/league/flysystem-local'), + 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), + 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), + 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), + 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), + 'Curl\\' => array($vendorDir . '/php-curl-class/php-curl-class/src/Curl'), + 'AlibabaCloud\\Oss\\V2\\' => array($vendorDir . '/alibabacloud/oss-v2/src'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..042c175 --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,50 @@ +register(true); + + $filesToLoad = \Composer\Autoload\ComposerStaticInit118552ef2b3077b276422e248ece3c62::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); + } + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..f43226d --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,182 @@ + __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', + '15ec93fa4ce4b2d53816a1a5f2c514e2' => __DIR__ . '/..' . '/topthink/think-validate/src/helper.php', + '7448f3465e10b5f033e4babb31eb0b06' => __DIR__ . '/..' . '/topthink/think-orm/src/helper.php', + '35fab96057f1bf5e7aba31a8a6d5fdde' => __DIR__ . '/..' . '/topthink/think-orm/stubs/load_stubs.php', + '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', + '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', + '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', + 'd79a0e13e295db93891a9377e0888496' => __DIR__ . '/..' . '/topthink/think-dumper/src/helper.php', + ); + + public static $prefixLengthsPsr4 = array ( + 't' => + array ( + 'think\\view\\driver\\' => 18, + 'think\\trace\\' => 12, + 'think\\dumper\\' => 13, + 'think\\app\\' => 10, + 'think\\' => 6, + ), + 'a' => + array ( + 'app\\' => 4, + ), + 'S' => + array ( + 'Symfony\\Polyfill\\Mbstring\\' => 26, + 'Symfony\\Component\\VarDumper\\' => 28, + ), + 'P' => + array ( + 'Psr\\SimpleCache\\' => 16, + 'Psr\\Log\\' => 8, + 'Psr\\Http\\Message\\' => 17, + 'Psr\\Http\\Client\\' => 16, + 'Psr\\Container\\' => 14, + ), + 'L' => + array ( + 'League\\MimeTypeDetection\\' => 25, + 'League\\Flysystem\\Local\\' => 23, + 'League\\Flysystem\\' => 17, + ), + 'G' => + array ( + 'GuzzleHttp\\Psr7\\' => 16, + 'GuzzleHttp\\Promise\\' => 19, + 'GuzzleHttp\\' => 11, + ), + 'C' => + array ( + 'Curl\\' => 5, + ), + 'A' => + array ( + 'AlibabaCloud\\Oss\\V2\\' => 20, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'think\\view\\driver\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-view/src', + ), + 'think\\trace\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-trace/src', + ), + 'think\\dumper\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-dumper/src', + ), + 'think\\app\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-multi-app/src', + ), + 'think\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/framework/src/think', + 1 => __DIR__ . '/..' . '/topthink/think-container/src', + 2 => __DIR__ . '/..' . '/topthink/think-filesystem/src', + 3 => __DIR__ . '/..' . '/topthink/think-helper/src', + 4 => __DIR__ . '/..' . '/topthink/think-orm/src', + 5 => __DIR__ . '/..' . '/topthink/think-template/src', + 6 => __DIR__ . '/..' . '/topthink/think-validate/src', + ), + 'app\\' => + array ( + 0 => __DIR__ . '/../..' . '/app', + ), + 'Symfony\\Polyfill\\Mbstring\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', + ), + 'Symfony\\Component\\VarDumper\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/var-dumper', + ), + 'Psr\\SimpleCache\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/simple-cache/src', + ), + 'Psr\\Log\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/log/src', + ), + 'Psr\\Http\\Message\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-factory/src', + 1 => __DIR__ . '/..' . '/psr/http-message/src', + ), + 'Psr\\Http\\Client\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-client/src', + ), + 'Psr\\Container\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/container/src', + ), + 'League\\MimeTypeDetection\\' => + array ( + 0 => __DIR__ . '/..' . '/league/mime-type-detection/src', + ), + 'League\\Flysystem\\Local\\' => + array ( + 0 => __DIR__ . '/..' . '/league/flysystem-local', + ), + 'League\\Flysystem\\' => + array ( + 0 => __DIR__ . '/..' . '/league/flysystem/src', + ), + 'GuzzleHttp\\Psr7\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', + ), + 'GuzzleHttp\\Promise\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', + ), + 'GuzzleHttp\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', + ), + 'Curl\\' => + array ( + 0 => __DIR__ . '/..' . '/php-curl-class/php-curl-class/src/Curl', + ), + 'AlibabaCloud\\Oss\\V2\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/oss-v2/src', + ), + ); + + public static $fallbackDirsPsr0 = array ( + 0 => __DIR__ . '/../..' . '/extend', + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit118552ef2b3077b276422e248ece3c62::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit118552ef2b3077b276422e248ece3c62::$prefixDirsPsr4; + $loader->fallbackDirsPsr0 = ComposerStaticInit118552ef2b3077b276422e248ece3c62::$fallbackDirsPsr0; + $loader->classMap = ComposerStaticInit118552ef2b3077b276422e248ece3c62::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..fd5ffbc --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,1870 @@ +{ + "packages": [ + { + "name": "alibabacloud/oss-v2", + "version": "0.4.0", + "version_normalized": "0.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2.git", + "reference": "a65ffd843cc8429c24a091804edd3a05f43050e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/alibabacloud-oss-php-sdk-v2/zipball/a65ffd843cc8429c24a091804edd3a05f43050e4", + "reference": "a65ffd843cc8429c24a091804edd3a05f43050e4", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "guzzlehttp/promises": "^1.4.0 || ^2.0", + "guzzlehttp/psr7": "^2.7", + "php": "^7.4 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "time": "2025-12-25T08:21:31+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Oss\\V2\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud OSS SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Aliyun OSS SDK for PHP v2", + "homepage": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2", + "support": { + "issues": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/issues", + "source": "https://github.com/aliyun/alibabacloud-oss-php-sdk-v2/tree/0.4.0" + }, + "install-path": "../alibabacloud/oss-v2" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.3", + "version_normalized": "7.9.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "time": "2025-03-27T13:37:11+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/guzzle" + }, + { + "name": "guzzlehttp/promises", + "version": "2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "time": "2025-03-27T13:27:01+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/promises" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "version_normalized": "2.7.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "time": "2025-03-27T12:30:47+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/psr7" + }, + { + "name": "league/flysystem", + "version": "3.30.0", + "version_normalized": "3.30.0.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "2203e3151755d874bb2943649dae1eb8533ac93e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/2203e3151755d874bb2943649dae1eb8533ac93e", + "reference": "2203e3151755d874bb2943649dae1eb8533ac93e", + "shasum": "" + }, + "require": { + "league/flysystem-local": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "conflict": { + "async-aws/core": "<1.19.0", + "async-aws/s3": "<1.14.0", + "aws/aws-sdk-php": "3.209.31 || 3.210.0", + "guzzlehttp/guzzle": "<7.0", + "guzzlehttp/ringphp": "<1.1.1", + "phpseclib/phpseclib": "3.0.15", + "symfony/http-client": "<5.2" + }, + "require-dev": { + "async-aws/s3": "^1.5 || ^2.0", + "async-aws/simple-s3": "^1.1 || ^2.0", + "aws/aws-sdk-php": "^3.295.10", + "composer/semver": "^3.0", + "ext-fileinfo": "*", + "ext-ftp": "*", + "ext-mongodb": "^1.3|^2", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.5", + "google/cloud-storage": "^1.23", + "guzzlehttp/psr7": "^2.6", + "microsoft/azure-storage-blob": "^1.1", + "mongodb/mongodb": "^1.2|^2", + "phpseclib/phpseclib": "^3.0.36", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.11|^10.0", + "sabre/dav": "^4.6.0" + }, + "time": "2025-06-25T13:29:59+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "File storage abstraction for PHP", + "keywords": [ + "WebDAV", + "aws", + "cloud", + "file", + "files", + "filesystem", + "filesystems", + "ftp", + "s3", + "sftp", + "storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem/issues", + "source": "https://github.com/thephpleague/flysystem/tree/3.30.0" + }, + "install-path": "../league/flysystem" + }, + { + "name": "league/flysystem-local", + "version": "3.30.0", + "version_normalized": "3.30.0.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-local.git", + "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/6691915f77c7fb69adfb87dcd550052dc184ee10", + "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "league/flysystem": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "time": "2025-05-21T10:34:19+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "League\\Flysystem\\Local\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Local filesystem adapter for Flysystem.", + "keywords": [ + "Flysystem", + "file", + "files", + "filesystem", + "local" + ], + "support": { + "source": "https://github.com/thephpleague/flysystem-local/tree/3.30.0" + }, + "install-path": "../league/flysystem-local" + }, + { + "name": "league/mime-type-detection", + "version": "1.16.0", + "version_normalized": "1.16.0.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" + }, + "time": "2024-09-21T08:32:55+00:00", + "type": "library", + "installation-source": "dist", + "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" + } + ], + "install-path": "../league/mime-type-detection" + }, + { + "name": "php-curl-class/php-curl-class", + "version": "12.0.0", + "version_normalized": "12.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-curl-class/php-curl-class.git", + "reference": "7a8f05efb18bb865dbce864b8fd34d4f5d920c74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-curl-class/php-curl-class/zipball/7a8f05efb18bb865dbce864b8fd34d4f5d920c74", + "reference": "7a8f05efb18bb865dbce864b8fd34d4f5d920c74", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "*", + "ext-gd": "*", + "friendsofphp/php-cs-fixer": "*", + "phpcompatibility/php-compatibility": "dev-develop", + "phpcsstandards/phpcsutils": "@alpha", + "phpstan/phpstan": "*", + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "*" + }, + "suggest": { + "ext-mbstring": "*" + }, + "time": "2025-03-25T18:04:16+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Curl\\": "src/Curl/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Unlicense" + ], + "authors": [ + { + "name": "Zach Borboa" + }, + { + "name": "Contributors", + "homepage": "https://github.com/php-curl-class/php-curl-class/graphs/contributors" + } + ], + "description": "PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.", + "homepage": "https://github.com/php-curl-class/php-curl-class", + "keywords": [ + "API-Client", + "api", + "class", + "client", + "curl", + "framework", + "http", + "http-client", + "http-proxy", + "json", + "php", + "php-curl", + "php-curl-library", + "proxy", + "requests", + "restful", + "web-scraper", + "web-scraping ", + "web-service", + "xml" + ], + "support": { + "issues": "https://github.com/php-curl-class/php-curl-class/issues", + "source": "https://github.com/php-curl-class/php-curl-class/tree/12.0.0" + }, + "install-path": "../php-curl-class/php-curl-class" + }, + { + "name": "psr/container", + "version": "2.0.2", + "version_normalized": "2.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "time": "2021-11-05T16:47:00+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "install-path": "../psr/container" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "version_normalized": "1.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2023-09-23T14:17:50+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "install-path": "../psr/http-client" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2024-04-15T12:06:14+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "install-path": "../psr/http-factory" + }, + { + "name": "psr/http-message", + "version": "1.1", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "time": "2023-04-04T09:50:52+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/1.1" + }, + "install-path": "../psr/http-message" + }, + { + "name": "psr/log", + "version": "3.0.2", + "version_normalized": "3.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "time": "2024-09-11T13:17:53+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "install-path": "../psr/log" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "version_normalized": "3.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "time": "2021-10-29T13:26:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://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/3.0.0" + }, + "install-path": "../psr/simple-cache" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "version_normalized": "3.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "time": "2019-03-08T08:55:37+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "install-path": "../ralouphie/getallheaders" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.6.0", + "version_normalized": "3.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "time": "2024-09-25T14:21:43+00:00", + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "function.php" + ] + }, + "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": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/deprecation-contracts" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "time": "2024-12-23T08:48:59+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\\Mbstring\\": "" + } + }, + "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 for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/var-dumper", + "version": "v7.3.0", + "version_normalized": "7.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "548f6760c54197b1084e1e5c71f6d9d523f2f78e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/548f6760c54197b1084e1e5c71f6d9d523f2f78e", + "reference": "548f6760c54197b1084e1e5c71f6d9d523f2f78e", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/uid": "^6.4|^7.0", + "twig/twig": "^3.12" + }, + "time": "2025-04-27T18:39:23+00:00", + "bin": [ + "Resources/bin/var-dump-server" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "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": "Provides mechanisms for walking through any arbitrary PHP variable", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "support": { + "source": "https://github.com/symfony/var-dumper/tree/v7.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/var-dumper" + }, + { + "name": "topthink/framework", + "version": "v8.1.2", + "version_normalized": "8.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/framework.git", + "reference": "8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/framework/zipball/8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c", + "reference": "8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": ">=8.0.0", + "psr/http-message": "^1.0", + "psr/log": "^1.0|^2.0|^3.0", + "psr/simple-cache": "^1.0|^2.0|^3.0", + "topthink/think-container": "^3.0", + "topthink/think-helper": "^3.1", + "topthink/think-orm": "^3.0|^4.0", + "topthink/think-validate": "^3.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^2.1.0", + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^9.5" + }, + "time": "2025-01-14T08:04:03+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [], + "psr-4": { + "think\\": "src/think/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + }, + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP Framework.", + "homepage": "http://thinkphp.cn/", + "keywords": [ + "framework", + "orm", + "thinkphp" + ], + "support": { + "issues": "https://github.com/top-think/framework/issues", + "source": "https://github.com/top-think/framework/tree/v8.1.2" + }, + "install-path": "../topthink/framework" + }, + { + "name": "topthink/think-container", + "version": "v3.0.2", + "version_normalized": "3.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-container.git", + "reference": "b2df244be1e7399ad4c8be1ccc40ed57868f730a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-container/zipball/b2df244be1e7399ad4c8be1ccc40ed57868f730a", + "reference": "b2df244be1e7399ad4c8be1ccc40ed57868f730a", + "shasum": "" + }, + "require": { + "php": ">=8.0", + "psr/container": "^2.0", + "topthink/think-helper": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "time": "2025-04-07T03:21:51+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "PHP Container & Facade Manager", + "support": { + "issues": "https://github.com/top-think/think-container/issues", + "source": "https://github.com/top-think/think-container/tree/v3.0.2" + }, + "install-path": "../topthink/think-container" + }, + { + "name": "topthink/think-dumper", + "version": "v1.0.5", + "version_normalized": "1.0.5.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-dumper.git", + "reference": "eba662a1843d5db68059050c530f7d43287289fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-dumper/zipball/eba662a1843d5db68059050c530f7d43287289fc", + "reference": "eba662a1843d5db68059050c530f7d43287289fc", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/var-dumper": ">=6.0", + "topthink/framework": "^6.0|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.4" + }, + "time": "2025-03-21T07:15:45+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\dumper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "Dumper extend for thinkphp", + "support": { + "issues": "https://github.com/top-think/think-dumper/issues", + "source": "https://github.com/top-think/think-dumper/tree/v1.0.5" + }, + "install-path": "../topthink/think-dumper" + }, + { + "name": "topthink/think-filesystem", + "version": "v3.0.0", + "version_normalized": "3.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-filesystem.git", + "reference": "7a1231a65bca278de9b7f9236767eef9741dfe5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-filesystem/zipball/7a1231a65bca278de9b7f9236767eef9741dfe5c", + "reference": "7a1231a65bca278de9b7f9236767eef9741dfe5c", + "shasum": "" + }, + "require": { + "league/flysystem": "^3.0", + "php": "^8.2", + "topthink/framework": "^8.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^11.5" + }, + "time": "2024-12-10T06:23:28+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP6.1 Filesystem Package", + "support": { + "issues": "https://github.com/top-think/think-filesystem/issues", + "source": "https://github.com/top-think/think-filesystem/tree/v3.0.0" + }, + "install-path": "../topthink/think-filesystem" + }, + { + "name": "topthink/think-helper", + "version": "v3.1.11", + "version_normalized": "3.1.11.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-helper.git", + "reference": "1d6ada9b9f3130046bf6922fe1bd159c8d88a33c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/1d6ada9b9f3130046bf6922fe1bd159c8d88a33c", + "reference": "1d6ada9b9f3130046bf6922fe1bd159c8d88a33c", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "time": "2025-04-07T06:55:59+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP6 Helper Package", + "support": { + "issues": "https://github.com/top-think/think-helper/issues", + "source": "https://github.com/top-think/think-helper/tree/v3.1.11" + }, + "install-path": "../topthink/think-helper" + }, + { + "name": "topthink/think-multi-app", + "version": "v1.1.1", + "version_normalized": "1.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-multi-app.git", + "reference": "f93c604d5cfac2b613756273224ee2f88e457b88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/f93c604d5cfac2b613756273224ee2f88e457b88", + "reference": "f93c604d5cfac2b613756273224ee2f88e457b88", + "shasum": "" + }, + "require": { + "php": ">=7.1.0", + "topthink/framework": "^6.0|^8.0" + }, + "time": "2024-11-25T08:52:44+00:00", + "type": "library", + "extra": { + "think": { + "services": [ + "think\\app\\Service" + ] + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\app\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp multi app support", + "support": { + "issues": "https://github.com/top-think/think-multi-app/issues", + "source": "https://github.com/top-think/think-multi-app/tree/v1.1.1" + }, + "install-path": "../topthink/think-multi-app" + }, + { + "name": "topthink/think-orm", + "version": "v4.0.46", + "version_normalized": "4.0.46.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-orm.git", + "reference": "4bb0a5679a97db8de1c0eb02bbbe179cb3afd901" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-orm/zipball/4bb0a5679a97db8de1c0eb02bbbe179cb3afd901", + "reference": "4bb0a5679a97db8de1c0eb02bbbe179cb3afd901", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-pdo": "*", + "php": ">=8.0.0", + "psr/log": ">=1.0", + "psr/simple-cache": ">=1.0", + "topthink/think-helper": "^3.1", + "topthink/think-validate": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6|^10" + }, + "suggest": { + "ext-mongodb": "provide mongodb support" + }, + "time": "2025-06-26T06:05:35+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helper.php", + "stubs/load_stubs.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the PHP Database&ORM Framework", + "keywords": [ + "database", + "orm" + ], + "support": { + "issues": "https://github.com/top-think/think-orm/issues", + "source": "https://github.com/top-think/think-orm/tree/v4.0.46" + }, + "install-path": "../topthink/think-orm" + }, + { + "name": "topthink/think-template", + "version": "v3.0.2", + "version_normalized": "3.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-template.git", + "reference": "0b88bd449f0f7626dd75b05f557c8bc208c08b0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-template/zipball/0b88bd449f0f7626dd75b05f557c8bc208c08b0c", + "reference": "0b88bd449f0f7626dd75b05f557c8bc208c08b0c", + "shasum": "" + }, + "require": { + "php": ">=8.0.0", + "psr/simple-cache": ">=1.0" + }, + "time": "2024-10-16T03:41:06+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the php template engine", + "support": { + "issues": "https://github.com/top-think/think-template/issues", + "source": "https://github.com/top-think/think-template/tree/v3.0.2" + }, + "install-path": "../topthink/think-template" + }, + { + "name": "topthink/think-trace", + "version": "v1.6", + "version_normalized": "1.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-trace.git", + "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-trace/zipball/136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", + "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", + "shasum": "" + }, + "require": { + "php": ">=7.1.0", + "topthink/framework": "^6.0|^8.0" + }, + "time": "2023-02-07T08:36:32+00:00", + "type": "library", + "extra": { + "think": { + "config": { + "trace": "src/config.php" + }, + "services": [ + "think\\trace\\Service" + ] + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\trace\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp debug trace", + "support": { + "issues": "https://github.com/top-think/think-trace/issues", + "source": "https://github.com/top-think/think-trace/tree/v1.6" + }, + "install-path": "../topthink/think-trace" + }, + { + "name": "topthink/think-validate", + "version": "v3.0.7", + "version_normalized": "3.0.7.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-validate.git", + "reference": "85063f6d4ef8ed122f17a36179dc3e0949b30988" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-validate/zipball/85063f6d4ef8ed122f17a36179dc3e0949b30988", + "reference": "85063f6d4ef8ed122f17a36179dc3e0949b30988", + "shasum": "" + }, + "require": { + "php": ">=8.0", + "topthink/think-container": ">=3.0" + }, + "time": "2025-06-11T05:51:40+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "think validate", + "support": { + "issues": "https://github.com/top-think/think-validate/issues", + "source": "https://github.com/top-think/think-validate/tree/v3.0.7" + }, + "install-path": "../topthink/think-validate" + }, + { + "name": "topthink/think-view", + "version": "v2.0.5", + "version_normalized": "2.0.5.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-view.git", + "reference": "b42009b98199b5a3833d3d6fd18c8a55aa511fad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-view/zipball/b42009b98199b5a3833d3d6fd18c8a55aa511fad", + "reference": "b42009b98199b5a3833d3d6fd18c8a55aa511fad", + "shasum": "" + }, + "require": { + "php": ">=8.0.0", + "topthink/think-template": "^3.0" + }, + "time": "2025-03-19T07:04:19+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\view\\driver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp template driver", + "support": { + "issues": "https://github.com/top-think/think-view/issues", + "source": "https://github.com/top-think/think-view/tree/v2.0.5" + }, + "install-path": "../topthink/think-view" + } + ], + "dev": true, + "dev-package-names": [ + "symfony/polyfill-mbstring", + "symfony/var-dumper", + "topthink/think-dumper", + "topthink/think-trace" + ] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..c0500ae --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,302 @@ + array( + 'name' => 'topthink/think', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => NULL, + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + 'alibabacloud/oss-v2' => array( + 'pretty_version' => '0.4.0', + 'version' => '0.4.0.0', + 'reference' => 'a65ffd843cc8429c24a091804edd3a05f43050e4', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/oss-v2', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/guzzle' => array( + 'pretty_version' => '7.9.3', + 'version' => '7.9.3.0', + 'reference' => '7b2f29fe81dc4da0ca0ea7d42107a0845946ea77', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/promises' => array( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/promises', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/psr7' => array( + 'pretty_version' => '2.7.1', + 'version' => '2.7.1.0', + 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/psr7', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'league/flysystem' => array( + 'pretty_version' => '3.30.0', + 'version' => '3.30.0.0', + 'reference' => '2203e3151755d874bb2943649dae1eb8533ac93e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../league/flysystem', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'league/flysystem-local' => array( + 'pretty_version' => '3.30.0', + 'version' => '3.30.0.0', + 'reference' => '6691915f77c7fb69adfb87dcd550052dc184ee10', + 'type' => 'library', + 'install_path' => __DIR__ . '/../league/flysystem-local', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'league/mime-type-detection' => array( + 'pretty_version' => '1.16.0', + 'version' => '1.16.0.0', + 'reference' => '2d6702ff215bf922936ccc1ad31007edc76451b9', + 'type' => 'library', + 'install_path' => __DIR__ . '/../league/mime-type-detection', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'php-curl-class/php-curl-class' => array( + 'pretty_version' => '12.0.0', + 'version' => '12.0.0.0', + 'reference' => '7a8f05efb18bb865dbce864b8fd34d4f5d920c74', + 'type' => 'library', + 'install_path' => __DIR__ . '/../php-curl-class/php-curl-class', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/container' => array( + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/container', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-client' => array( + 'pretty_version' => '1.0.3', + 'version' => '1.0.3.0', + 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-client', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-client-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-factory' => array( + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', + 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-factory', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-message' => array( + 'pretty_version' => '1.1', + 'version' => '1.1.0.0', + 'reference' => 'cb6ce4845ce34a8ad9e68117c10ee90a29919eba', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-message', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-message-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/log' => array( + 'pretty_version' => '3.0.2', + 'version' => '3.0.2.0', + 'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/log', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/simple-cache' => array( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/simple-cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'ralouphie/getallheaders' => array( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ralouphie/getallheaders', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/deprecation-contracts' => array( + '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-mbstring' => array( + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '6d857f4d76bd4b343eac26d6b539585d2bc56493', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'symfony/var-dumper' => array( + 'pretty_version' => 'v7.3.0', + 'version' => '7.3.0.0', + 'reference' => '548f6760c54197b1084e1e5c71f6d9d523f2f78e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/var-dumper', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'topthink/framework' => array( + 'pretty_version' => 'v8.1.2', + 'version' => '8.1.2.0', + 'reference' => '8faec5c9b7a7f2a66ca3140a57e81bd6cd37567c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/framework', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think' => array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => NULL, + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-container' => array( + 'pretty_version' => 'v3.0.2', + 'version' => '3.0.2.0', + 'reference' => 'b2df244be1e7399ad4c8be1ccc40ed57868f730a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-container', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-dumper' => array( + 'pretty_version' => 'v1.0.5', + 'version' => '1.0.5.0', + 'reference' => 'eba662a1843d5db68059050c530f7d43287289fc', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-dumper', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'topthink/think-filesystem' => array( + 'pretty_version' => 'v3.0.0', + 'version' => '3.0.0.0', + 'reference' => '7a1231a65bca278de9b7f9236767eef9741dfe5c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-filesystem', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-helper' => array( + 'pretty_version' => 'v3.1.11', + 'version' => '3.1.11.0', + 'reference' => '1d6ada9b9f3130046bf6922fe1bd159c8d88a33c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-helper', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-multi-app' => array( + 'pretty_version' => 'v1.1.1', + 'version' => '1.1.1.0', + 'reference' => 'f93c604d5cfac2b613756273224ee2f88e457b88', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-multi-app', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-orm' => array( + 'pretty_version' => 'v4.0.46', + 'version' => '4.0.46.0', + 'reference' => '4bb0a5679a97db8de1c0eb02bbbe179cb3afd901', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-orm', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-template' => array( + 'pretty_version' => 'v3.0.2', + 'version' => '3.0.2.0', + 'reference' => '0b88bd449f0f7626dd75b05f557c8bc208c08b0c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-template', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-trace' => array( + 'pretty_version' => 'v1.6', + 'version' => '1.6.0.0', + 'reference' => '136cd5d97e8bdb780e4b5c1637c588ed7ca3e142', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-trace', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'topthink/think-validate' => array( + 'pretty_version' => 'v3.0.7', + 'version' => '3.0.7.0', + 'reference' => '85063f6d4ef8ed122f17a36179dc3e0949b30988', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-validate', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-view' => array( + 'pretty_version' => 'v2.0.5', + 'version' => '2.0.5.0', + 'reference' => 'b42009b98199b5a3833d3d6fd18c8a55aa511fad', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-view', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..d32d90c --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 80200)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + 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 + ); +} diff --git a/vendor/guzzlehttp/guzzle/CHANGELOG.md b/vendor/guzzlehttp/guzzle/CHANGELOG.md new file mode 100644 index 0000000..7600ef4 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/CHANGELOG.md @@ -0,0 +1,1672 @@ +# Change Log + +Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version. + + +## 7.9.3 - 2025-03-27 + +### Changed + +- Remove explicit content-length header for GET requests +- Improve compatibility with bad servers for boolean cookie values + + +## 7.9.2 - 2024-07-24 + +### Fixed + +- Adjusted handler selection to use cURL if its version is 7.21.2 or higher, rather than 7.34.0 + + +## 7.9.1 - 2024-07-19 + +### Fixed + +- Fix TLS 1.3 check for HTTP/2 requests + + +## 7.9.0 - 2024-07-18 + +### Changed + +- Improve protocol version checks to provide feedback around unsupported protocols +- Only select the cURL handler by default if 7.34.0 or higher is linked +- Improved `CurlMultiHandler` to avoid busy wait if possible +- Dropped support for EOL `guzzlehttp/psr7` v1 +- Improved URI user info redaction in errors + +## 7.8.2 - 2024-07-18 + +### Added + +- Support for PHP 8.4 + + +## 7.8.1 - 2023-12-03 + +### Changed + +- Updated links in docs to their canonical versions +- Replaced `call_user_func*` with native calls + + +## 7.8.0 - 2023-08-27 + +### Added + +- Support for PHP 8.3 +- Added automatic closing of handles on `CurlFactory` object destruction + + +## 7.7.1 - 2023-08-27 + +### Changed + +- Remove the need for `AllowDynamicProperties` in `CurlMultiHandler` + + +## 7.7.0 - 2023-05-21 + +### Added + +- Support `guzzlehttp/promises` v2 + + +## 7.6.1 - 2023-05-15 + +### Fixed + +- Fix `SetCookie::fromString` MaxAge deprecation warning and skip invalid MaxAge values + + +## 7.6.0 - 2023-05-14 + +### Added + +- Support for setting the minimum TLS version in a unified way +- Apply on request the version set in options parameters + + +## 7.5.2 - 2023-05-14 + +### Fixed + +- Fixed set cookie constructor validation +- Fixed handling of files with `'0'` body + +### Changed + +- Corrected docs and default connect timeout value to 300 seconds + + +## 7.5.1 - 2023-04-17 + +### Fixed + +- Fixed `NO_PROXY` settings so that setting the `proxy` option to `no` overrides the env variable + +### Changed + +- Adjusted `guzzlehttp/psr7` version constraint to `^1.9.1 || ^2.4.5` + + +## 7.5.0 - 2022-08-28 + +### Added + +- Support PHP 8.2 +- Add request to delay closure params + + +## 7.4.5 - 2022-06-20 + +### Fixed + +* Fix change in port should be considered a change in origin +* Fix `CURLOPT_HTTPAUTH` option not cleared on change of origin + + +## 7.4.4 - 2022-06-09 + +### Fixed + +* Fix failure to strip Authorization header on HTTP downgrade +* Fix failure to strip the Cookie header on change in host or HTTP downgrade + + +## 7.4.3 - 2022-05-25 + +### Fixed + +* Fix cross-domain cookie leakage + + +## 7.4.2 - 2022-03-20 + +### Fixed + +- Remove curl auth on cross-domain redirects to align with the Authorization HTTP header +- Reject non-HTTP schemes in StreamHandler +- Set a default ssl.peer_name context in StreamHandler to allow `force_ip_resolve` + + +## 7.4.1 - 2021-12-06 + +### Changed + +- Replaced implicit URI to string coercion [#2946](https://github.com/guzzle/guzzle/pull/2946) +- Allow `symfony/deprecation-contracts` version 3 [#2961](https://github.com/guzzle/guzzle/pull/2961) + +### Fixed + +- Only close curl handle if it's done [#2950](https://github.com/guzzle/guzzle/pull/2950) + + +## 7.4.0 - 2021-10-18 + +### Added + +- Support PHP 8.1 [#2929](https://github.com/guzzle/guzzle/pull/2929), [#2939](https://github.com/guzzle/guzzle/pull/2939) +- Support `psr/log` version 2 and 3 [#2943](https://github.com/guzzle/guzzle/pull/2943) + +### Fixed + +- Make sure we always call `restore_error_handler()` [#2915](https://github.com/guzzle/guzzle/pull/2915) +- Fix progress parameter type compatibility between the cURL and stream handlers [#2936](https://github.com/guzzle/guzzle/pull/2936) +- Throw `InvalidArgumentException` when an incorrect `headers` array is provided [#2916](https://github.com/guzzle/guzzle/pull/2916), [#2942](https://github.com/guzzle/guzzle/pull/2942) + +### Changed + +- Be more strict with types [#2914](https://github.com/guzzle/guzzle/pull/2914), [#2917](https://github.com/guzzle/guzzle/pull/2917), [#2919](https://github.com/guzzle/guzzle/pull/2919), [#2945](https://github.com/guzzle/guzzle/pull/2945) + + +## 7.3.0 - 2021-03-23 + +### Added + +- Support for DER and P12 certificates [#2413](https://github.com/guzzle/guzzle/pull/2413) +- Support the cURL (http://) scheme for StreamHandler proxies [#2850](https://github.com/guzzle/guzzle/pull/2850) +- Support for `guzzlehttp/psr7:^2.0` [#2878](https://github.com/guzzle/guzzle/pull/2878) + +### Fixed + +- Handle exceptions on invalid header consistently between PHP versions and handlers [#2872](https://github.com/guzzle/guzzle/pull/2872) + + +## 7.2.0 - 2020-10-10 + +### Added + +- Support for PHP 8 [#2712](https://github.com/guzzle/guzzle/pull/2712), [#2715](https://github.com/guzzle/guzzle/pull/2715), [#2789](https://github.com/guzzle/guzzle/pull/2789) +- Support passing a body summarizer to the http errors middleware [#2795](https://github.com/guzzle/guzzle/pull/2795) + +### Fixed + +- Handle exceptions during response creation [#2591](https://github.com/guzzle/guzzle/pull/2591) +- Fix CURLOPT_ENCODING not to be overwritten [#2595](https://github.com/guzzle/guzzle/pull/2595) +- Make sure the Request always has a body object [#2804](https://github.com/guzzle/guzzle/pull/2804) + +### Changed + +- The `TooManyRedirectsException` has a response [#2660](https://github.com/guzzle/guzzle/pull/2660) +- Avoid "functions" from dependencies [#2712](https://github.com/guzzle/guzzle/pull/2712) + +### Deprecated + +- Using environment variable GUZZLE_CURL_SELECT_TIMEOUT [#2786](https://github.com/guzzle/guzzle/pull/2786) + + +## 7.1.1 - 2020-09-30 + +### Fixed + +- Incorrect EOF detection for response body streams on Windows. + +### Changed + +- We dont connect curl `sink` on HEAD requests. +- Removed some PHP 5 workarounds + + +## 7.1.0 - 2020-09-22 + +### Added + +- `GuzzleHttp\MessageFormatterInterface` + +### Fixed + +- Fixed issue that caused cookies with no value not to be stored. +- On redirects, we allow all safe methods like GET, HEAD and OPTIONS. +- Fixed logging on empty responses. +- Make sure MessageFormatter::format returns string + +### Deprecated + +- All functions in `GuzzleHttp` has been deprecated. Use static methods on `Utils` instead. +- `ClientInterface::getConfig()` +- `Client::getConfig()` +- `Client::__call()` +- `Utils::defaultCaBundle()` +- `CurlFactory::LOW_CURL_VERSION_NUMBER` + + +## 7.0.1 - 2020-06-27 + +* Fix multiply defined functions fatal error [#2699](https://github.com/guzzle/guzzle/pull/2699) + + +## 7.0.0 - 2020-06-27 + +No changes since 7.0.0-rc1. + + +## 7.0.0-rc1 - 2020-06-15 + +### Changed + +* Use error level for logging errors in Middleware [#2629](https://github.com/guzzle/guzzle/pull/2629) +* Disabled IDN support by default and require ext-intl to use it [#2675](https://github.com/guzzle/guzzle/pull/2675) + + +## 7.0.0-beta2 - 2020-05-25 + +### Added + +* Using `Utils` class instead of functions in the `GuzzleHttp` namespace. [#2546](https://github.com/guzzle/guzzle/pull/2546) +* `ClientInterface::MAJOR_VERSION` [#2583](https://github.com/guzzle/guzzle/pull/2583) + +### Changed + +* Avoid the `getenv` function when unsafe [#2531](https://github.com/guzzle/guzzle/pull/2531) +* Added real client methods [#2529](https://github.com/guzzle/guzzle/pull/2529) +* Avoid functions due to global install conflicts [#2546](https://github.com/guzzle/guzzle/pull/2546) +* Use Symfony intl-idn polyfill [#2550](https://github.com/guzzle/guzzle/pull/2550) +* Adding methods for HTTP verbs like `Client::get()`, `Client::head()`, `Client::patch()` etc [#2529](https://github.com/guzzle/guzzle/pull/2529) +* `ConnectException` extends `TransferException` [#2541](https://github.com/guzzle/guzzle/pull/2541) +* Updated the default User Agent to "GuzzleHttp/7" [#2654](https://github.com/guzzle/guzzle/pull/2654) + +### Fixed + +* Various intl icu issues [#2626](https://github.com/guzzle/guzzle/pull/2626) + +### Removed + +* Pool option `pool_size` [#2528](https://github.com/guzzle/guzzle/pull/2528) + + +## 7.0.0-beta1 - 2019-12-30 + +The diff might look very big but 95% of Guzzle users will be able to upgrade without modification. +Please see [the upgrade document](UPGRADING.md) that describes all BC breaking changes. + +### Added + +* Implement PSR-18 and dropped PHP 5 support [#2421](https://github.com/guzzle/guzzle/pull/2421) [#2474](https://github.com/guzzle/guzzle/pull/2474) +* PHP 7 types [#2442](https://github.com/guzzle/guzzle/pull/2442) [#2449](https://github.com/guzzle/guzzle/pull/2449) [#2466](https://github.com/guzzle/guzzle/pull/2466) [#2497](https://github.com/guzzle/guzzle/pull/2497) [#2499](https://github.com/guzzle/guzzle/pull/2499) +* IDN support for redirects [2424](https://github.com/guzzle/guzzle/pull/2424) + +### Changed + +* Dont allow passing null as third argument to `BadResponseException::__construct()` [#2427](https://github.com/guzzle/guzzle/pull/2427) +* Use SAPI constant instead of method call [#2450](https://github.com/guzzle/guzzle/pull/2450) +* Use native function invocation [#2444](https://github.com/guzzle/guzzle/pull/2444) +* Better defaults for PHP installations with old ICU lib [2454](https://github.com/guzzle/guzzle/pull/2454) +* Added visibility to all constants [#2462](https://github.com/guzzle/guzzle/pull/2462) +* Dont allow passing `null` as URI to `Client::request()` and `Client::requestAsync()` [#2461](https://github.com/guzzle/guzzle/pull/2461) +* Widen the exception argument to throwable [#2495](https://github.com/guzzle/guzzle/pull/2495) + +### Fixed + +* Logging when Promise rejected with a string [#2311](https://github.com/guzzle/guzzle/pull/2311) + +### Removed + +* Class `SeekException` [#2162](https://github.com/guzzle/guzzle/pull/2162) +* `RequestException::getResponseBodySummary()` [#2425](https://github.com/guzzle/guzzle/pull/2425) +* `CookieJar::getCookieValue()` [#2433](https://github.com/guzzle/guzzle/pull/2433) +* `uri_template()` and `UriTemplate` [#2440](https://github.com/guzzle/guzzle/pull/2440) +* Request options `save_to` and `exceptions` [#2464](https://github.com/guzzle/guzzle/pull/2464) + + +## 6.5.2 - 2019-12-23 + +* idn_to_ascii() fix for old PHP versions [#2489](https://github.com/guzzle/guzzle/pull/2489) + + +## 6.5.1 - 2019-12-21 + +* Better defaults for PHP installations with old ICU lib [#2454](https://github.com/guzzle/guzzle/pull/2454) +* IDN support for redirects [#2424](https://github.com/guzzle/guzzle/pull/2424) + + +## 6.5.0 - 2019-12-07 + +* Improvement: Added support for reset internal queue in MockHandler. [#2143](https://github.com/guzzle/guzzle/pull/2143) +* Improvement: Added support to pass arbitrary options to `curl_multi_init`. [#2287](https://github.com/guzzle/guzzle/pull/2287) +* Fix: Gracefully handle passing `null` to the `header` option. [#2132](https://github.com/guzzle/guzzle/pull/2132) +* Fix: `RetryMiddleware` did not do exponential delay between retires due unit mismatch. [#2132](https://github.com/guzzle/guzzle/pull/2132) +* Fix: Prevent undefined offset when using array for ssl_key options. [#2348](https://github.com/guzzle/guzzle/pull/2348) +* Deprecated `ClientInterface::VERSION` + + +## 6.4.1 - 2019-10-23 + +* No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that +* Added `parent::__construct()` to `FileCookieJar` and `SessionCookieJar` + + +## 6.4.0 - 2019-10-23 + +* Improvement: Improved error messages when using curl < 7.21.2 [#2108](https://github.com/guzzle/guzzle/pull/2108) +* Fix: Test if response is readable before returning a summary in `RequestException::getResponseBodySummary()` [#2081](https://github.com/guzzle/guzzle/pull/2081) +* Fix: Add support for GUZZLE_CURL_SELECT_TIMEOUT environment variable [#2161](https://github.com/guzzle/guzzle/pull/2161) +* Improvement: Added `GuzzleHttp\Exception\InvalidArgumentException` [#2163](https://github.com/guzzle/guzzle/pull/2163) +* Improvement: Added `GuzzleHttp\_current_time()` to use `hrtime()` if that function exists. [#2242](https://github.com/guzzle/guzzle/pull/2242) +* Improvement: Added curl's `appconnect_time` in `TransferStats` [#2284](https://github.com/guzzle/guzzle/pull/2284) +* Improvement: Make GuzzleException extend Throwable wherever it's available [#2273](https://github.com/guzzle/guzzle/pull/2273) +* Fix: Prevent concurrent writes to file when saving `CookieJar` [#2335](https://github.com/guzzle/guzzle/pull/2335) +* Improvement: Update `MockHandler` so we can test transfer time [#2362](https://github.com/guzzle/guzzle/pull/2362) + + +## 6.3.3 - 2018-04-22 + +* Fix: Default headers when decode_content is specified + + +## 6.3.2 - 2018-03-26 + +* Fix: Release process + + +## 6.3.1 - 2018-03-26 + +* Bug fix: Parsing 0 epoch expiry times in cookies [#2014](https://github.com/guzzle/guzzle/pull/2014) +* Improvement: Better ConnectException detection [#2012](https://github.com/guzzle/guzzle/pull/2012) +* Bug fix: Malformed domain that contains a "/" [#1999](https://github.com/guzzle/guzzle/pull/1999) +* Bug fix: Undefined offset when a cookie has no first key-value pair [#1998](https://github.com/guzzle/guzzle/pull/1998) +* Improvement: Support PHPUnit 6 [#1953](https://github.com/guzzle/guzzle/pull/1953) +* Bug fix: Support empty headers [#1915](https://github.com/guzzle/guzzle/pull/1915) +* Bug fix: Ignore case during header modifications [#1916](https://github.com/guzzle/guzzle/pull/1916) + ++ Minor code cleanups, documentation fixes and clarifications. + + +## 6.3.0 - 2017-06-22 + +* Feature: force IP resolution (ipv4 or ipv6) [#1608](https://github.com/guzzle/guzzle/pull/1608), [#1659](https://github.com/guzzle/guzzle/pull/1659) +* Improvement: Don't include summary in exception message when body is empty [#1621](https://github.com/guzzle/guzzle/pull/1621) +* Improvement: Handle `on_headers` option in MockHandler [#1580](https://github.com/guzzle/guzzle/pull/1580) +* Improvement: Added SUSE Linux CA path [#1609](https://github.com/guzzle/guzzle/issues/1609) +* Improvement: Use class reference for getting the name of the class instead of using hardcoded strings [#1641](https://github.com/guzzle/guzzle/pull/1641) +* Feature: Added `read_timeout` option [#1611](https://github.com/guzzle/guzzle/pull/1611) +* Bug fix: PHP 7.x fixes [#1685](https://github.com/guzzle/guzzle/pull/1685), [#1686](https://github.com/guzzle/guzzle/pull/1686), [#1811](https://github.com/guzzle/guzzle/pull/1811) +* Deprecation: BadResponseException instantiation without a response [#1642](https://github.com/guzzle/guzzle/pull/1642) +* Feature: Added NTLM auth [#1569](https://github.com/guzzle/guzzle/pull/1569) +* Feature: Track redirect HTTP status codes [#1711](https://github.com/guzzle/guzzle/pull/1711) +* Improvement: Check handler type during construction [#1745](https://github.com/guzzle/guzzle/pull/1745) +* Improvement: Always include the Content-Length if there's a body [#1721](https://github.com/guzzle/guzzle/pull/1721) +* Feature: Added convenience method to access a cookie by name [#1318](https://github.com/guzzle/guzzle/pull/1318) +* Bug fix: Fill `CURLOPT_CAPATH` and `CURLOPT_CAINFO` properly [#1684](https://github.com/guzzle/guzzle/pull/1684) +* Improvement: Use `\GuzzleHttp\Promise\rejection_for` function instead of object init [#1827](https://github.com/guzzle/guzzle/pull/1827) + ++ Minor code cleanups, documentation fixes and clarifications. + + +## 6.2.3 - 2017-02-28 + +* Fix deprecations with guzzle/psr7 version 1.4 + + +## 6.2.2 - 2016-10-08 + +* Allow to pass nullable Response to delay callable +* Only add scheme when host is present +* Fix drain case where content-length is the literal string zero +* Obfuscate in-URL credentials in exceptions + + +## 6.2.1 - 2016-07-18 + +* Address HTTP_PROXY security vulnerability, CVE-2016-5385: + https://httpoxy.org/ +* Fixing timeout bug with StreamHandler: + https://github.com/guzzle/guzzle/pull/1488 +* Only read up to `Content-Length` in PHP StreamHandler to avoid timeouts when + a server does not honor `Connection: close`. +* Ignore URI fragment when sending requests. + + +## 6.2.0 - 2016-03-21 + +* Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`. + https://github.com/guzzle/guzzle/pull/1389 +* Bug fix: Fix sleep calculation when waiting for delayed requests. + https://github.com/guzzle/guzzle/pull/1324 +* Feature: More flexible history containers. + https://github.com/guzzle/guzzle/pull/1373 +* Bug fix: defer sink stream opening in StreamHandler. + https://github.com/guzzle/guzzle/pull/1377 +* Bug fix: do not attempt to escape cookie values. + https://github.com/guzzle/guzzle/pull/1406 +* Feature: report original content encoding and length on decoded responses. + https://github.com/guzzle/guzzle/pull/1409 +* Bug fix: rewind seekable request bodies before dispatching to cURL. + https://github.com/guzzle/guzzle/pull/1422 +* Bug fix: provide an empty string to `http_build_query` for HHVM workaround. + https://github.com/guzzle/guzzle/pull/1367 + + +## 6.1.1 - 2015-11-22 + +* Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler + https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4 +* Feature: HandlerStack is now more generic. + https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e +* Bug fix: setting verify to false in the StreamHandler now disables peer + verification. https://github.com/guzzle/guzzle/issues/1256 +* Feature: Middleware now uses an exception factory, including more error + context. https://github.com/guzzle/guzzle/pull/1282 +* Feature: better support for disabled functions. + https://github.com/guzzle/guzzle/pull/1287 +* Bug fix: fixed regression where MockHandler was not using `sink`. + https://github.com/guzzle/guzzle/pull/1292 + + +## 6.1.0 - 2015-09-08 + +* Feature: Added the `on_stats` request option to provide access to transfer + statistics for requests. https://github.com/guzzle/guzzle/pull/1202 +* Feature: Added the ability to persist session cookies in CookieJars. + https://github.com/guzzle/guzzle/pull/1195 +* Feature: Some compatibility updates for Google APP Engine + https://github.com/guzzle/guzzle/pull/1216 +* Feature: Added support for NO_PROXY to prevent the use of a proxy based on + a simple set of rules. https://github.com/guzzle/guzzle/pull/1197 +* Feature: Cookies can now contain square brackets. + https://github.com/guzzle/guzzle/pull/1237 +* Bug fix: Now correctly parsing `=` inside of quotes in Cookies. + https://github.com/guzzle/guzzle/pull/1232 +* Bug fix: Cusotm cURL options now correctly override curl options of the + same name. https://github.com/guzzle/guzzle/pull/1221 +* Bug fix: Content-Type header is now added when using an explicitly provided + multipart body. https://github.com/guzzle/guzzle/pull/1218 +* Bug fix: Now ignoring Set-Cookie headers that have no name. +* Bug fix: Reason phrase is no longer cast to an int in some cases in the + cURL handler. https://github.com/guzzle/guzzle/pull/1187 +* Bug fix: Remove the Authorization header when redirecting if the Host + header changes. https://github.com/guzzle/guzzle/pull/1207 +* Bug fix: Cookie path matching fixes + https://github.com/guzzle/guzzle/issues/1129 +* Bug fix: Fixing the cURL `body_as_string` setting + https://github.com/guzzle/guzzle/pull/1201 +* Bug fix: quotes are no longer stripped when parsing cookies. + https://github.com/guzzle/guzzle/issues/1172 +* Bug fix: `form_params` and `query` now always uses the `&` separator. + https://github.com/guzzle/guzzle/pull/1163 +* Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set. + https://github.com/guzzle/guzzle/pull/1189 + + +## 6.0.2 - 2015-07-04 + +* Fixed a memory leak in the curl handlers in which references to callbacks + were not being removed by `curl_reset`. +* Cookies are now extracted properly before redirects. +* Cookies now allow more character ranges. +* Decoded Content-Encoding responses are now modified to correctly reflect + their state if the encoding was automatically removed by a handler. This + means that the `Content-Encoding` header may be removed an the + `Content-Length` modified to reflect the message size after removing the + encoding. +* Added a more explicit error message when trying to use `form_params` and + `multipart` in the same request. +* Several fixes for HHVM support. +* Functions are now conditionally required using an additional level of + indirection to help with global Composer installations. + + +## 6.0.1 - 2015-05-27 + +* Fixed a bug with serializing the `query` request option where the `&` + separator was missing. +* Added a better error message for when `body` is provided as an array. Please + use `form_params` or `multipart` instead. +* Various doc fixes. + + +## 6.0.0 - 2015-05-26 + +* See the UPGRADING.md document for more information. +* Added `multipart` and `form_params` request options. +* Added `synchronous` request option. +* Added the `on_headers` request option. +* Fixed `expect` handling. +* No longer adding default middlewares in the client ctor. These need to be + present on the provided handler in order to work. +* Requests are no longer initiated when sending async requests with the + CurlMultiHandler. This prevents unexpected recursion from requests completing + while ticking the cURL loop. +* Removed the semantics of setting `default` to `true`. This is no longer + required now that the cURL loop is not ticked for async requests. +* Added request and response logging middleware. +* No longer allowing self signed certificates when using the StreamHandler. +* Ensuring that `sink` is valid if saving to a file. +* Request exceptions now include a "handler context" which provides handler + specific contextual information. +* Added `GuzzleHttp\RequestOptions` to allow request options to be applied + using constants. +* `$maxHandles` has been removed from CurlMultiHandler. +* `MultipartPostBody` is now part of the `guzzlehttp/psr7` package. + + +## 5.3.0 - 2015-05-19 + +* Mock now supports `save_to` +* Marked `AbstractRequestEvent::getTransaction()` as public. +* Fixed a bug in which multiple headers using different casing would overwrite + previous headers in the associative array. +* Added `Utils::getDefaultHandler()` +* Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated. +* URL scheme is now always lowercased. + + +## 6.0.0-beta.1 + +* Requires PHP >= 5.5 +* Updated to use PSR-7 + * Requires immutable messages, which basically means an event based system + owned by a request instance is no longer possible. + * Utilizing the [Guzzle PSR-7 package](https://github.com/guzzle/psr7). + * Removed the dependency on `guzzlehttp/streams`. These stream abstractions + are available in the `guzzlehttp/psr7` package under the `GuzzleHttp\Psr7` + namespace. +* Added middleware and handler system + * Replaced the Guzzle event and subscriber system with a middleware system. + * No longer depends on RingPHP, but rather places the HTTP handlers directly + in Guzzle, operating on PSR-7 messages. + * Retry logic is now encapsulated in `GuzzleHttp\Middleware::retry`, which + means the `guzzlehttp/retry-subscriber` is now obsolete. + * Mocking responses is now handled using `GuzzleHttp\Handler\MockHandler`. +* Asynchronous responses + * No longer supports the `future` request option to send an async request. + Instead, use one of the `*Async` methods of a client (e.g., `requestAsync`, + `getAsync`, etc.). + * Utilizing `GuzzleHttp\Promise` instead of React's promise library to avoid + recursion required by chaining and forwarding react promises. See + https://github.com/guzzle/promises + * Added `requestAsync` and `sendAsync` to send request asynchronously. + * Added magic methods for `getAsync()`, `postAsync()`, etc. to send requests + asynchronously. +* Request options + * POST and form updates + * Added the `form_fields` and `form_files` request options. + * Removed the `GuzzleHttp\Post` namespace. + * The `body` request option no longer accepts an array for POST requests. + * The `exceptions` request option has been deprecated in favor of the + `http_errors` request options. + * The `save_to` request option has been deprecated in favor of `sink` request + option. +* Clients no longer accept an array of URI template string and variables for + URI variables. You will need to expand URI templates before passing them + into a client constructor or request method. +* Client methods `get()`, `post()`, `put()`, `patch()`, `options()`, etc. are + now magic methods that will send synchronous requests. +* Replaced `Utils.php` with plain functions in `functions.php`. +* Removed `GuzzleHttp\Collection`. +* Removed `GuzzleHttp\BatchResults`. Batched pool results are now returned as + an array. +* Removed `GuzzleHttp\Query`. Query string handling is now handled using an + associative array passed into the `query` request option. The query string + is serialized using PHP's `http_build_query`. If you need more control, you + can pass the query string in as a string. +* `GuzzleHttp\QueryParser` has been replaced with the + `GuzzleHttp\Psr7\parse_query`. + + +## 5.2.0 - 2015-01-27 + +* Added `AppliesHeadersInterface` to make applying headers to a request based + on the body more generic and not specific to `PostBodyInterface`. +* Reduced the number of stack frames needed to send requests. +* Nested futures are now resolved in the client rather than the RequestFsm +* Finishing state transitions is now handled in the RequestFsm rather than the + RingBridge. +* Added a guard in the Pool class to not use recursion for request retries. + + +## 5.1.0 - 2014-12-19 + +* Pool class no longer uses recursion when a request is intercepted. +* The size of a Pool can now be dynamically adjusted using a callback. + See https://github.com/guzzle/guzzle/pull/943. +* Setting a request option to `null` when creating a request with a client will + ensure that the option is not set. This allows you to overwrite default + request options on a per-request basis. + See https://github.com/guzzle/guzzle/pull/937. +* Added the ability to limit which protocols are allowed for redirects by + specifying a `protocols` array in the `allow_redirects` request option. +* Nested futures due to retries are now resolved when waiting for synchronous + responses. See https://github.com/guzzle/guzzle/pull/947. +* `"0"` is now an allowed URI path. See + https://github.com/guzzle/guzzle/pull/935. +* `Query` no longer typehints on the `$query` argument in the constructor, + allowing for strings and arrays. +* Exceptions thrown in the `end` event are now correctly wrapped with Guzzle + specific exceptions if necessary. + + +## 5.0.3 - 2014-11-03 + +This change updates query strings so that they are treated as un-encoded values +by default where the value represents an un-encoded value to send over the +wire. A Query object then encodes the value before sending over the wire. This +means that even value query string values (e.g., ":") are url encoded. This +makes the Query class match PHP's http_build_query function. However, if you +want to send requests over the wire using valid query string characters that do +not need to be encoded, then you can provide a string to Url::setQuery() and +pass true as the second argument to specify that the query string is a raw +string that should not be parsed or encoded (unless a call to getQuery() is +subsequently made, forcing the query-string to be converted into a Query +object). + + +## 5.0.2 - 2014-10-30 + +* Added a trailing `\r\n` to multipart/form-data payloads. See + https://github.com/guzzle/guzzle/pull/871 +* Added a `GuzzleHttp\Pool::send()` convenience method to match the docs. +* Status codes are now returned as integers. See + https://github.com/guzzle/guzzle/issues/881 +* No longer overwriting an existing `application/x-www-form-urlencoded` header + when sending POST requests, allowing for customized headers. See + https://github.com/guzzle/guzzle/issues/877 +* Improved path URL serialization. + + * No longer double percent-encoding characters in the path or query string if + they are already encoded. + * Now properly encoding the supplied path to a URL object, instead of only + encoding ' ' and '?'. + * Note: This has been changed in 5.0.3 to now encode query string values by + default unless the `rawString` argument is provided when setting the query + string on a URL: Now allowing many more characters to be present in the + query string without being percent encoded. See + https://datatracker.ietf.org/doc/html/rfc3986#appendix-A + + +## 5.0.1 - 2014-10-16 + +Bugfix release. + +* Fixed an issue where connection errors still returned response object in + error and end events event though the response is unusable. This has been + corrected so that a response is not returned in the `getResponse` method of + these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867 +* Fixed an issue where transfer statistics were not being populated in the + RingBridge. https://github.com/guzzle/guzzle/issues/866 + + +## 5.0.0 - 2014-10-12 + +Adding support for non-blocking responses and some minor API cleanup. + +### New Features + +* Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`. +* Added a public API for creating a default HTTP adapter. +* Updated the redirect plugin to be non-blocking so that redirects are sent + concurrently. Other plugins like this can now be updated to be non-blocking. +* Added a "progress" event so that you can get upload and download progress + events. +* Added `GuzzleHttp\Pool` which implements FutureInterface and transfers + requests concurrently using a capped pool size as efficiently as possible. +* Added `hasListeners()` to EmitterInterface. +* Removed `GuzzleHttp\ClientInterface::sendAll` and marked + `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the + recommended way). + +### Breaking changes + +The breaking changes in this release are relatively minor. The biggest thing to +look out for is that request and response objects no longer implement fluent +interfaces. + +* Removed the fluent interfaces (i.e., `return $this`) from requests, + responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`, + `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and + `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of + why I did this: https://ocramius.github.io/blog/fluent-interfaces-are-evil/. + This also makes the Guzzle message interfaces compatible with the current + PSR-7 message proposal. +* Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except + for the HTTP request functions from function.php, these functions are now + implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode` + moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to + `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to + `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be + `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php + caused problems for many users: they aren't PSR-4 compliant, require an + explicit include, and needed an if-guard to ensure that the functions are not + declared multiple times. +* Rewrote adapter layer. + * Removing all classes from `GuzzleHttp\Adapter`, these are now + implemented as callables that are stored in `GuzzleHttp\Ring\Client`. + * Removed the concept of "parallel adapters". Sending requests serially or + concurrently is now handled using a single adapter. + * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The + Transaction object now exposes the request, response, and client as public + properties. The getters and setters have been removed. +* Removed the "headers" event. This event was only useful for changing the + body a response once the headers of the response were known. You can implement + a similar behavior in a number of ways. One example might be to use a + FnStream that has access to the transaction being sent. For example, when the + first byte is written, you could check if the response headers match your + expectations, and if so, change the actual stream body that is being + written to. +* Removed the `asArray` parameter from + `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header + value as an array, then use the newly added `getHeaderAsArray()` method of + `MessageInterface`. This change makes the Guzzle interfaces compatible with + the PSR-7 interfaces. +* `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add + custom request options using double-dispatch (this was an implementation + detail). Instead, you should now provide an associative array to the + constructor which is a mapping of the request option name mapping to a + function that applies the option value to a request. +* Removed the concept of "throwImmediately" from exceptions and error events. + This control mechanism was used to stop a transfer of concurrent requests + from completing. This can now be handled by throwing the exception or by + cancelling a pool of requests or each outstanding future request individually. +* Updated to "GuzzleHttp\Streams" 3.0. + * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a + `maxLen` parameter. This update makes the Guzzle streams project + compatible with the current PSR-7 proposal. + * `GuzzleHttp\Stream\Stream::__construct`, + `GuzzleHttp\Stream\Stream::factory`, and + `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second + argument. They now accept an associative array of options, including the + "size" key and "metadata" key which can be used to provide custom metadata. + + +## 4.2.2 - 2014-09-08 + +* Fixed a memory leak in the CurlAdapter when reusing cURL handles. +* No longer using `request_fulluri` in stream adapter proxies. +* Relative redirects are now based on the last response, not the first response. + +## 4.2.1 - 2014-08-19 + +* Ensuring that the StreamAdapter does not always add a Content-Type header +* Adding automated github releases with a phar and zip + +## 4.2.0 - 2014-08-17 + +* Now merging in default options using a case-insensitive comparison. + Closes https://github.com/guzzle/guzzle/issues/767 +* Added the ability to automatically decode `Content-Encoding` response bodies + using the `decode_content` request option. This is set to `true` by default + to decode the response body if it comes over the wire with a + `Content-Encoding`. Set this value to `false` to disable decoding the + response content, and pass a string to provide a request `Accept-Encoding` + header and turn on automatic response decoding. This feature now allows you + to pass an `Accept-Encoding` header in the headers of a request but still + disable automatic response decoding. + Closes https://github.com/guzzle/guzzle/issues/764 +* Added the ability to throw an exception immediately when transferring + requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760 +* Updating guzzlehttp/streams dependency to ~2.1 +* No longer utilizing the now deprecated namespaced methods from the stream + package. + +## 4.1.8 - 2014-08-14 + +* Fixed an issue in the CurlFactory that caused setting the `stream=false` + request option to throw an exception. + See: https://github.com/guzzle/guzzle/issues/769 +* TransactionIterator now calls rewind on the inner iterator. + See: https://github.com/guzzle/guzzle/pull/765 +* You can now set the `Content-Type` header to `multipart/form-data` + when creating POST requests to force multipart bodies. + See https://github.com/guzzle/guzzle/issues/768 + +## 4.1.7 - 2014-08-07 + +* Fixed an error in the HistoryPlugin that caused the same request and response + to be logged multiple times when an HTTP protocol error occurs. +* Ensuring that cURL does not add a default Content-Type when no Content-Type + has been supplied by the user. This prevents the adapter layer from modifying + the request that is sent over the wire after any listeners may have already + put the request in a desired state (e.g., signed the request). +* Throwing an exception when you attempt to send requests that have the + "stream" set to true in parallel using the MultiAdapter. +* Only calling curl_multi_select when there are active cURL handles. This was + previously changed and caused performance problems on some systems due to PHP + always selecting until the maximum select timeout. +* Fixed a bug where multipart/form-data POST fields were not correctly + aggregated (e.g., values with "&"). + +## 4.1.6 - 2014-08-03 + +* Added helper methods to make it easier to represent messages as strings, + including getting the start line and getting headers as a string. + +## 4.1.5 - 2014-08-02 + +* Automatically retrying cURL "Connection died, retrying a fresh connect" + errors when possible. +* cURL implementation cleanup +* Allowing multiple event subscriber listeners to be registered per event by + passing an array of arrays of listener configuration. + +## 4.1.4 - 2014-07-22 + +* Fixed a bug that caused multi-part POST requests with more than one field to + serialize incorrectly. +* Paths can now be set to "0" +* `ResponseInterface::xml` now accepts a `libxml_options` option and added a + missing default argument that was required when parsing XML response bodies. +* A `save_to` stream is now created lazily, which means that files are not + created on disk unless a request succeeds. + +## 4.1.3 - 2014-07-15 + +* Various fixes to multipart/form-data POST uploads +* Wrapping function.php in an if-statement to ensure Guzzle can be used + globally and in a Composer install +* Fixed an issue with generating and merging in events to an event array +* POST headers are only applied before sending a request to allow you to change + the query aggregator used before uploading +* Added much more robust query string parsing +* Fixed various parsing and normalization issues with URLs +* Fixing an issue where multi-valued headers were not being utilized correctly + in the StreamAdapter + +## 4.1.2 - 2014-06-18 + +* Added support for sending payloads with GET requests + +## 4.1.1 - 2014-06-08 + +* Fixed an issue related to using custom message factory options in subclasses +* Fixed an issue with nested form fields in a multi-part POST +* Fixed an issue with using the `json` request option for POST requests +* Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar` + +## 4.1.0 - 2014-05-27 + +* Added a `json` request option to easily serialize JSON payloads. +* Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON. +* Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`. +* Added the ability to provide an emitter to a client in the client constructor. +* Added the ability to persist a cookie session using $_SESSION. +* Added a trait that can be used to add event listeners to an iterator. +* Removed request method constants from RequestInterface. +* Fixed warning when invalid request start-lines are received. +* Updated MessageFactory to work with custom request option methods. +* Updated cacert bundle to latest build. + +4.0.2 (2014-04-16) +------------------ + +* Proxy requests using the StreamAdapter now properly use request_fulluri (#632) +* Added the ability to set scalars as POST fields (#628) + +## 4.0.1 - 2014-04-04 + +* The HTTP status code of a response is now set as the exception code of + RequestException objects. +* 303 redirects will now correctly switch from POST to GET requests. +* The default parallel adapter of a client now correctly uses the MultiAdapter. +* HasDataTrait now initializes the internal data array as an empty array so + that the toArray() method always returns an array. + +## 4.0.0 - 2014-03-29 + +* For information on changes and upgrading, see: + https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40 +* Added `GuzzleHttp\batch()` as a convenience function for sending requests in + parallel without needing to write asynchronous code. +* Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`. + You can now pass a callable or an array of associative arrays where each + associative array contains the "fn", "priority", and "once" keys. + +## 4.0.0.rc-2 - 2014-03-25 + +* Removed `getConfig()` and `setConfig()` from clients to avoid confusion + around whether things like base_url, message_factory, etc. should be able to + be retrieved or modified. +* Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface +* functions.php functions were renamed using snake_case to match PHP idioms +* Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and + `GUZZLE_CURL_SELECT_TIMEOUT` environment variables +* Added the ability to specify custom `sendAll()` event priorities +* Added the ability to specify custom stream context options to the stream + adapter. +* Added a functions.php function for `get_path()` and `set_path()` +* CurlAdapter and MultiAdapter now use a callable to generate curl resources +* MockAdapter now properly reads a body and emits a `headers` event +* Updated Url class to check if a scheme and host are set before adding ":" + and "//". This allows empty Url (e.g., "") to be serialized as "". +* Parsing invalid XML no longer emits warnings +* Curl classes now properly throw AdapterExceptions +* Various performance optimizations +* Streams are created with the faster `Stream\create()` function +* Marked deprecation_proxy() as internal +* Test server is now a collection of static methods on a class + +## 4.0.0-rc.1 - 2014-03-15 + +* See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40 + +## 3.8.1 - 2014-01-28 + +* Bug: Always using GET requests when redirecting from a 303 response +* Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in + `Guzzle\Http\ClientInterface::setSslVerification()` +* Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL +* Bug: The body of a request can now be set to `"0"` +* Sending PHP stream requests no longer forces `HTTP/1.0` +* Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of + each sub-exception +* Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than + clobbering everything). +* Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators) +* Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`. + For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`. +* Now properly escaping the regular expression delimiter when matching Cookie domains. +* Network access is now disabled when loading XML documents + +## 3.8.0 - 2013-12-05 + +* Added the ability to define a POST name for a file +* JSON response parsing now properly walks additionalProperties +* cURL error code 18 is now retried automatically in the BackoffPlugin +* Fixed a cURL error when URLs contain fragments +* Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were + CurlExceptions +* CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e) +* Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS` +* Fixed a bug that was encountered when parsing empty header parameters +* UriTemplate now has a `setRegex()` method to match the docs +* The `debug` request parameter now checks if it is truthy rather than if it exists +* Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin +* Added the ability to combine URLs using strict RFC 3986 compliance +* Command objects can now return the validation errors encountered by the command +* Various fixes to cache revalidation (#437 and 29797e5) +* Various fixes to the AsyncPlugin +* Cleaned up build scripts + +## 3.7.4 - 2013-10-02 + +* Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430) +* Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp + (see https://github.com/aws/aws-sdk-php/issues/147) +* Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots +* Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420) +* Updated the bundled cacert.pem (#419) +* OauthPlugin now supports adding authentication to headers or query string (#425) + +## 3.7.3 - 2013-09-08 + +* Added the ability to get the exception associated with a request/command when using `MultiTransferException` and + `CommandTransferException`. +* Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description +* Schemas are only injected into response models when explicitly configured. +* No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of + an EntityBody. +* Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator. +* Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`. +* Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody() +* Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin +* Bug fix: Visiting XML attributes first before visiting XML children when serializing requests +* Bug fix: Properly parsing headers that contain commas contained in quotes +* Bug fix: mimetype guessing based on a filename is now case-insensitive + +## 3.7.2 - 2013-08-02 + +* Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander + See https://github.com/guzzle/guzzle/issues/371 +* Bug fix: Cookie domains are now matched correctly according to RFC 6265 + See https://github.com/guzzle/guzzle/issues/377 +* Bug fix: GET parameters are now used when calculating an OAuth signature +* Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted +* `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched +* `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input. + See https://github.com/guzzle/guzzle/issues/379 +* Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See + https://github.com/guzzle/guzzle/pull/380 +* cURL multi cleanup and optimizations + +## 3.7.1 - 2013-07-05 + +* Bug fix: Setting default options on a client now works +* Bug fix: Setting options on HEAD requests now works. See #352 +* Bug fix: Moving stream factory before send event to before building the stream. See #353 +* Bug fix: Cookies no longer match on IP addresses per RFC 6265 +* Bug fix: Correctly parsing header parameters that are in `<>` and quotes +* Added `cert` and `ssl_key` as request options +* `Host` header can now diverge from the host part of a URL if the header is set manually +* `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter +* OAuth parameters are only added via the plugin if they aren't already set +* Exceptions are now thrown when a URL cannot be parsed +* Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails +* Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin + +## 3.7.0 - 2013-06-10 + +* See UPGRADING.md for more information on how to upgrade. +* Requests now support the ability to specify an array of $options when creating a request to more easily modify a + request. You can pass a 'request.options' configuration setting to a client to apply default request options to + every request created by a client (e.g. default query string variables, headers, curl options, etc.). +* Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`. + See `Guzzle\Http\StaticClient::mount`. +* Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests + created by a command (e.g. custom headers, query string variables, timeout settings, etc.). +* Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the + headers of a response +* Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key + (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`) +* ServiceBuilders now support storing and retrieving arbitrary data +* CachePlugin can now purge all resources for a given URI +* CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource +* CachePlugin now uses the Vary header to determine if a resource is a cache hit +* `Guzzle\Http\Message\Response` now implements `\Serializable` +* Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters +* `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable +* Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()` +* Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size +* `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message +* Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older + Symfony users can still use the old version of Monolog. +* Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`. + Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`. +* Several performance improvements to `Guzzle\Common\Collection` +* Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`: + createRequest, head, delete, put, patch, post, options, prepareRequest +* Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()` +* Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface` +* Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to + `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a + resource, string, or EntityBody into the $options parameter to specify the download location of the response. +* Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a + default `array()` +* Added `Guzzle\Stream\StreamInterface::isRepeatable` +* Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use + $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or + $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`. +* Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`. +* Removed `Guzzle\Http\ClientInterface::expandTemplate()` +* Removed `Guzzle\Http\ClientInterface::setRequestFactory()` +* Removed `Guzzle\Http\ClientInterface::getCurlMulti()` +* Removed `Guzzle\Http\Message\RequestInterface::canCache` +* Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect` +* Removed `Guzzle\Http\Message\RequestInterface::isRedirect` +* Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods. +* You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting + `Guzzle\Common\Version::$emitWarnings` to true. +* Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use + `$request->getResponseBody()->isRepeatable()` instead. +* Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use + `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. +* Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use + `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. +* Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead. +* Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead. +* Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated +* Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. + These will work through Guzzle 4.0 +* Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params]. +* Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client. +* Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`. +* Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. +* Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8. +* Marked `Guzzle\Common\Collection::inject()` as deprecated. +* Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');` +* CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a + CacheStorageInterface. These two objects and interface will be removed in a future version. +* Always setting X-cache headers on cached responses +* Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin +* `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface + $request, Response $response);` +* `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);` +* `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);` +* Added `CacheStorageInterface::purge($url)` +* `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin + $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache, + CanCacheStrategyInterface $canCache = null)` +* Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)` + +## 3.6.0 - 2013-05-29 + +* ServiceDescription now implements ToArrayInterface +* Added command.hidden_params to blacklist certain headers from being treated as additionalParameters +* Guzzle can now correctly parse incomplete URLs +* Mixed casing of headers are now forced to be a single consistent casing across all values for that header. +* Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution +* Removed the whole changedHeader() function system of messages because all header changes now go through addHeader(). +* Specific header implementations can be created for complex headers. When a message creates a header, it uses a + HeaderFactory which can map specific headers to specific header classes. There is now a Link header and + CacheControl header implementation. +* Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate +* Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti() +* Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in + Guzzle\Http\Curl\RequestMediator +* Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string. +* Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface +* Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders() +* Removed Guzzle\Parser\ParserRegister::get(). Use getParser() +* Removed Guzzle\Parser\ParserRegister::set(). Use registerParser(). +* All response header helper functions return a string rather than mixing Header objects and strings inconsistently +* Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle + directly via interfaces +* Removed the injecting of a request object onto a response object. The methods to get and set a request still exist + but are a no-op until removed. +* Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a + `Guzzle\Service\Command\ArrayCommandInterface`. +* Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response + on a request while the request is still being transferred +* The ability to case-insensitively search for header values +* Guzzle\Http\Message\Header::hasExactHeader +* Guzzle\Http\Message\Header::raw. Use getAll() +* Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object + instead. +* `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess +* Added the ability to cast Model objects to a string to view debug information. + +## 3.5.0 - 2013-05-13 + +* Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times +* Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove + itself from the EventDispatcher) +* Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values +* Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too +* Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a + non-existent key +* Bug: All __call() method arguments are now required (helps with mocking frameworks) +* Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference + to help with refcount based garbage collection of resources created by sending a request +* Deprecating ZF1 cache and log adapters. These will be removed in the next major version. +* Deprecating `Response::getPreviousResponse()` (method signature still exists, but it's deprecated). Use the + HistoryPlugin for a history. +* Added a `responseBody` alias for the `response_body` location +* Refactored internals to no longer rely on Response::getRequest() +* HistoryPlugin can now be cast to a string +* HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests + and responses that are sent over the wire +* Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects + +## 3.4.3 - 2013-04-30 + +* Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response +* Added a check to re-extract the temp cacert bundle from the phar before sending each request + +## 3.4.2 - 2013-04-29 + +* Bug fix: Stream objects now work correctly with "a" and "a+" modes +* Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present +* Bug fix: AsyncPlugin no longer forces HEAD requests +* Bug fix: DateTime timezones are now properly handled when using the service description schema formatter +* Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails +* Setting a response on a request will write to the custom request body from the response body if one is specified +* LogPlugin now writes to php://output when STDERR is undefined +* Added the ability to set multiple POST files for the same key in a single call +* application/x-www-form-urlencoded POSTs now use the utf-8 charset by default +* Added the ability to queue CurlExceptions to the MockPlugin +* Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send) +* Configuration loading now allows remote files + +## 3.4.1 - 2013-04-16 + +* Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti + handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost. +* Exceptions are now properly grouped when sending requests in parallel +* Redirects are now properly aggregated when a multi transaction fails +* Redirects now set the response on the original object even in the event of a failure +* Bug fix: Model names are now properly set even when using $refs +* Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax +* Added support for oauth_callback in OAuth signatures +* Added support for oauth_verifier in OAuth signatures +* Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection + +## 3.4.0 - 2013-04-11 + +* Bug fix: URLs are now resolved correctly based on https://datatracker.ietf.org/doc/html/rfc3986#section-5.2. #289 +* Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289 +* Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263 +* Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264. +* Bug fix: Added `number` type to service descriptions. +* Bug fix: empty parameters are removed from an OAuth signature +* Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header +* Bug fix: Fixed "array to string" error when validating a union of types in a service description +* Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream +* Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin. +* Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs. +* The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections. +* Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if + the Content-Type can be determined based on the entity body or the path of the request. +* Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder. +* Added support for a PSR-3 LogAdapter. +* Added a `command.after_prepare` event +* Added `oauth_callback` parameter to the OauthPlugin +* Added the ability to create a custom stream class when using a stream factory +* Added a CachingEntityBody decorator +* Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized. +* The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar. +* You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies +* POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This + means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use + POST fields or files (the latter is only used when emulating a form POST in the browser). +* Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest + +## 3.3.1 - 2013-03-10 + +* Added the ability to create PHP streaming responses from HTTP requests +* Bug fix: Running any filters when parsing response headers with service descriptions +* Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing +* Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across + response location visitors. +* Bug fix: Removed the possibility of creating configuration files with circular dependencies +* RequestFactory::create() now uses the key of a POST file when setting the POST file name +* Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set + +## 3.3.0 - 2013-03-03 + +* A large number of performance optimizations have been made +* Bug fix: Added 'wb' as a valid write mode for streams +* Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned +* Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()` +* BC: Removed `Guzzle\Http\Utils` class +* BC: Setting a service description on a client will no longer modify the client's command factories. +* BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using + the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io' +* BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to + lowercase +* Operation parameter objects are now lazy loaded internally +* Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses +* Added support for instantiating responseType=class responseClass classes. Classes must implement + `Guzzle\Service\Command\ResponseClassInterface` +* Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These + additional properties also support locations and can be used to parse JSON responses where the outermost part of the + JSON is an array +* Added support for nested renaming of JSON models (rename sentAs to name) +* CachePlugin + * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error + * Debug headers can now added to cached response in the CachePlugin + +## 3.2.0 - 2013-02-14 + +* CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients. +* URLs with no path no longer contain a "/" by default +* Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url. +* BadResponseException no longer includes the full request and response message +* Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface +* Adding getResponseBody() to Guzzle\Http\Message\RequestInterface +* Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription +* Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list +* xmlEncoding can now be customized for the XML declaration of a XML service description operation +* Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value + aggregation and no longer uses callbacks +* The URL encoding implementation of Guzzle\Http\QueryString can now be customized +* Bug fix: Filters were not always invoked for array service description parameters +* Bug fix: Redirects now use a target response body rather than a temporary response body +* Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded +* Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives + +## 3.1.2 - 2013-01-27 + +* Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the + response body. For example, the XmlVisitor now parses the XML response into an array in the before() method. +* Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent +* CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444) +* Fixed a bug where redirect responses were not chained correctly using getPreviousResponse() +* Setting default headers on a client after setting the user-agent will not erase the user-agent setting + +## 3.1.1 - 2013-01-20 + +* Adding wildcard support to Guzzle\Common\Collection::getPath() +* Adding alias support to ServiceBuilder configs +* Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface + +## 3.1.0 - 2013-01-12 + +* BC: CurlException now extends from RequestException rather than BadResponseException +* BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse() +* Added getData to ServiceDescriptionInterface +* Added context array to RequestInterface::setState() +* Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http +* Bug: Adding required content-type when JSON request visitor adds JSON to a command +* Bug: Fixing the serialization of a service description with custom data +* Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing + an array of successful and failed responses +* Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection +* Added Guzzle\Http\IoEmittingEntityBody +* Moved command filtration from validators to location visitors +* Added `extends` attributes to service description parameters +* Added getModels to ServiceDescriptionInterface + +## 3.0.7 - 2012-12-19 + +* Fixing phar detection when forcing a cacert to system if null or true +* Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()` +* Cleaning up `Guzzle\Common\Collection::inject` method +* Adding a response_body location to service descriptions + +## 3.0.6 - 2012-12-09 + +* CurlMulti performance improvements +* Adding setErrorResponses() to Operation +* composer.json tweaks + +## 3.0.5 - 2012-11-18 + +* Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin +* Bug: Response body can now be a string containing "0" +* Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert +* Bug: QueryString::fromString now properly parses query string parameters that contain equal signs +* Added support for XML attributes in service description responses +* DefaultRequestSerializer now supports array URI parameter values for URI template expansion +* Added better mimetype guessing to requests and post files + +## 3.0.4 - 2012-11-11 + +* Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value +* Bug: Cookies can now be added that have a name, domain, or value set to "0" +* Bug: Using the system cacert bundle when using the Phar +* Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures +* Enhanced cookie jar de-duplication +* Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added +* Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies +* Added the ability to create any sort of hash for a stream rather than just an MD5 hash + +## 3.0.3 - 2012-11-04 + +* Implementing redirects in PHP rather than cURL +* Added PECL URI template extension and using as default parser if available +* Bug: Fixed Content-Length parsing of Response factory +* Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams. +* Adding ToArrayInterface throughout library +* Fixing OauthPlugin to create unique nonce values per request + +## 3.0.2 - 2012-10-25 + +* Magic methods are enabled by default on clients +* Magic methods return the result of a command +* Service clients no longer require a base_url option in the factory +* Bug: Fixed an issue with URI templates where null template variables were being expanded + +## 3.0.1 - 2012-10-22 + +* Models can now be used like regular collection objects by calling filter, map, etc. +* Models no longer require a Parameter structure or initial data in the constructor +* Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator` + +## 3.0.0 - 2012-10-15 + +* Rewrote service description format to be based on Swagger + * Now based on JSON schema + * Added nested input structures and nested response models + * Support for JSON and XML input and output models + * Renamed `commands` to `operations` + * Removed dot class notation + * Removed custom types +* Broke the project into smaller top-level namespaces to be more component friendly +* Removed support for XML configs and descriptions. Use arrays or JSON files. +* Removed the Validation component and Inspector +* Moved all cookie code to Guzzle\Plugin\Cookie +* Magic methods on a Guzzle\Service\Client now return the command un-executed. +* Calling getResult() or getResponse() on a command will lazily execute the command if needed. +* Now shipping with cURL's CA certs and using it by default +* Added previousResponse() method to response objects +* No longer sending Accept and Accept-Encoding headers on every request +* Only sending an Expect header by default when a payload is greater than 1MB +* Added/moved client options: + * curl.blacklist to curl.option.blacklist + * Added ssl.certificate_authority +* Added a Guzzle\Iterator component +* Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin +* Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin) +* Added a more robust caching plugin +* Added setBody to response objects +* Updating LogPlugin to use a more flexible MessageFormatter +* Added a completely revamped build process +* Cleaning up Collection class and removing default values from the get method +* Fixed ZF2 cache adapters + +## 2.8.8 - 2012-10-15 + +* Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did + +## 2.8.7 - 2012-09-30 + +* Bug: Fixed config file aliases for JSON includes +* Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests +* Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload +* Bug: Hardening request and response parsing to account for missing parts +* Bug: Fixed PEAR packaging +* Bug: Fixed Request::getInfo +* Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail +* Adding the ability for the namespace Iterator factory to look in multiple directories +* Added more getters/setters/removers from service descriptions +* Added the ability to remove POST fields from OAuth signatures +* OAuth plugin now supports 2-legged OAuth + +## 2.8.6 - 2012-09-05 + +* Added the ability to modify and build service descriptions +* Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command +* Added a `json` parameter location +* Now allowing dot notation for classes in the CacheAdapterFactory +* Using the union of two arrays rather than an array_merge when extending service builder services and service params +* Ensuring that a service is a string before doing strpos() checks on it when substituting services for references + in service builder config files. +* Services defined in two different config files that include one another will by default replace the previously + defined service, but you can now create services that extend themselves and merge their settings over the previous +* The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like + '_default' with a default JSON configuration file. + +## 2.8.5 - 2012-08-29 + +* Bug: Suppressed empty arrays from URI templates +* Bug: Added the missing $options argument from ServiceDescription::factory to enable caching +* Added support for HTTP responses that do not contain a reason phrase in the start-line +* AbstractCommand commands are now invokable +* Added a way to get the data used when signing an Oauth request before a request is sent + +## 2.8.4 - 2012-08-15 + +* Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin +* Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable. +* Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream +* Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream +* Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5()) +* Added additional response status codes +* Removed SSL information from the default User-Agent header +* DELETE requests can now send an entity body +* Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries +* Added the ability of the MockPlugin to consume mocked request bodies +* LogPlugin now exposes request and response objects in the extras array + +## 2.8.3 - 2012-07-30 + +* Bug: Fixed a case where empty POST requests were sent as GET requests +* Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body +* Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new +* Added multiple inheritance to service description commands +* Added an ApiCommandInterface and added `getParamNames()` and `hasParam()` +* Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything +* Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles + +## 2.8.2 - 2012-07-24 + +* Bug: Query string values set to 0 are no longer dropped from the query string +* Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()` +* Bug: `+` is now treated as an encoded space when parsing query strings +* QueryString and Collection performance improvements +* Allowing dot notation for class paths in filters attribute of a service descriptions + +## 2.8.1 - 2012-07-16 + +* Loosening Event Dispatcher dependency +* POST redirects can now be customized using CURLOPT_POSTREDIR + +## 2.8.0 - 2012-07-15 + +* BC: Guzzle\Http\Query + * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl) + * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding() + * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool) + * Changed the aggregation functions of QueryString to be static methods + * Can now use fromString() with querystrings that have a leading ? +* cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters +* Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body +* Cookies are no longer URL decoded by default +* Bug: URI template variables set to null are no longer expanded + +## 2.7.2 - 2012-07-02 + +* BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser. +* BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty() +* CachePlugin now allows for a custom request parameter function to check if a request can be cached +* Bug fix: CachePlugin now only caches GET and HEAD requests by default +* Bug fix: Using header glue when transferring headers over the wire +* Allowing deeply nested arrays for composite variables in URI templates +* Batch divisors can now return iterators or arrays + +## 2.7.1 - 2012-06-26 + +* Minor patch to update version number in UA string +* Updating build process + +## 2.7.0 - 2012-06-25 + +* BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes. +* BC: Removed magic setX methods from commands +* BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method +* Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable. +* Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity) +* Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace +* Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin +* Added the ability to set POST fields and files in a service description +* Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method +* Adding a command.before_prepare event to clients +* Added BatchClosureTransfer and BatchClosureDivisor +* BatchTransferException now includes references to the batch divisor and transfer strategies +* Fixed some tests so that they pass more reliably +* Added Guzzle\Common\Log\ArrayLogAdapter + +## 2.6.6 - 2012-06-10 + +* BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin +* BC: Removing Guzzle\Service\Command\CommandSet +* Adding generic batching system (replaces the batch queue plugin and command set) +* Updating ZF cache and log adapters and now using ZF's composer repository +* Bug: Setting the name of each ApiParam when creating through an ApiCommand +* Adding result_type, result_doc, deprecated, and doc_url to service descriptions +* Bug: Changed the default cookie header casing back to 'Cookie' + +## 2.6.5 - 2012-06-03 + +* BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource() +* BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from +* BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data +* BC: Renaming methods in the CookieJarInterface +* Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations +* Making the default glue for HTTP headers ';' instead of ',' +* Adding a removeValue to Guzzle\Http\Message\Header +* Adding getCookies() to request interface. +* Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber() + +## 2.6.4 - 2012-05-30 + +* BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class. +* BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand +* Bug: Fixing magic method command calls on clients +* Bug: Email constraint only validates strings +* Bug: Aggregate POST fields when POST files are present in curl handle +* Bug: Fixing default User-Agent header +* Bug: Only appending or prepending parameters in commands if they are specified +* Bug: Not requiring response reason phrases or status codes to match a predefined list of codes +* Allowing the use of dot notation for class namespaces when using instance_of constraint +* Added any_match validation constraint +* Added an AsyncPlugin +* Passing request object to the calculateWait method of the ExponentialBackoffPlugin +* Allowing the result of a command object to be changed +* Parsing location and type sub values when instantiating a service description rather than over and over at runtime + +## 2.6.3 - 2012-05-23 + +* [BC] Guzzle\Common\FromConfigInterface no longer requires any config options. +* [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields. +* You can now use an array of data when creating PUT request bodies in the request factory. +* Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable. +* [Http] Adding support for Content-Type in multipart POST uploads per upload +* [Http] Added support for uploading multiple files using the same name (foo[0], foo[1]) +* Adding more POST data operations for easier manipulation of POST data. +* You can now set empty POST fields. +* The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files. +* Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate. +* CS updates + +## 2.6.2 - 2012-05-19 + +* [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method. + +## 2.6.1 - 2012-05-19 + +* [BC] Removing 'path' support in service descriptions. Use 'uri'. +* [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache. +* [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it. +* [BC] Removing Guzzle\Common\XmlElement. +* All commands, both dynamic and concrete, have ApiCommand objects. +* Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits. +* Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored. +* Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible. + +## 2.6.0 - 2012-05-15 + +* [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder +* [BC] Executing a Command returns the result of the command rather than the command +* [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed. +* [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args. +* [BC] Moving ResourceIterator* to Guzzle\Service\Resource +* [BC] Completely refactored ResourceIterators to iterate over a cloned command object +* [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate +* [BC] Guzzle\Guzzle is now deprecated +* Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject +* Adding Guzzle\Version class to give version information about Guzzle +* Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate() +* Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data +* ServiceDescription and ServiceBuilder are now cacheable using similar configs +* Changing the format of XML and JSON service builder configs. Backwards compatible. +* Cleaned up Cookie parsing +* Trimming the default Guzzle User-Agent header +* Adding a setOnComplete() method to Commands that is called when a command completes +* Keeping track of requests that were mocked in the MockPlugin +* Fixed a caching bug in the CacheAdapterFactory +* Inspector objects can be injected into a Command object +* Refactoring a lot of code and tests to be case insensitive when dealing with headers +* Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL +* Adding the ability to set global option overrides to service builder configs +* Adding the ability to include other service builder config files from within XML and JSON files +* Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method. + +## 2.5.0 - 2012-05-08 + +* Major performance improvements +* [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated. +* [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component. +* [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}" +* Added the ability to passed parameters to all requests created by a client +* Added callback functionality to the ExponentialBackoffPlugin +* Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies. +* Rewinding request stream bodies when retrying requests +* Exception is thrown when JSON response body cannot be decoded +* Added configurable magic method calls to clients and commands. This is off by default. +* Fixed a defect that added a hash to every parsed URL part +* Fixed duplicate none generation for OauthPlugin. +* Emitting an event each time a client is generated by a ServiceBuilder +* Using an ApiParams object instead of a Collection for parameters of an ApiCommand +* cache.* request parameters should be renamed to params.cache.* +* Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle. +* Added the ability to disable type validation of service descriptions +* ServiceDescriptions and ServiceBuilders are now Serializable diff --git a/vendor/guzzlehttp/guzzle/LICENSE b/vendor/guzzlehttp/guzzle/LICENSE new file mode 100644 index 0000000..fd2375d --- /dev/null +++ b/vendor/guzzlehttp/guzzle/LICENSE @@ -0,0 +1,27 @@ +The MIT License (MIT) + +Copyright (c) 2011 Michael Dowling +Copyright (c) 2012 Jeremy Lindblom +Copyright (c) 2014 Graham Campbell +Copyright (c) 2015 Márk Sági-Kazár +Copyright (c) 2015 Tobias Schultze +Copyright (c) 2016 Tobias Nyholm +Copyright (c) 2016 George Mponos + +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/vendor/guzzlehttp/guzzle/README.md b/vendor/guzzlehttp/guzzle/README.md new file mode 100644 index 0000000..cdaebee --- /dev/null +++ b/vendor/guzzlehttp/guzzle/README.md @@ -0,0 +1,94 @@ +![Guzzle](.github/logo.png?raw=true) + +# Guzzle, PHP HTTP client + +[![Latest Version](https://img.shields.io/github/release/guzzle/guzzle.svg?style=flat-square)](https://github.com/guzzle/guzzle/releases) +[![Build Status](https://img.shields.io/github/actions/workflow/status/guzzle/guzzle/ci.yml?label=ci%20build&style=flat-square)](https://github.com/guzzle/guzzle/actions?query=workflow%3ACI) +[![Total Downloads](https://img.shields.io/packagist/dt/guzzlehttp/guzzle.svg?style=flat-square)](https://packagist.org/packages/guzzlehttp/guzzle) + +Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and +trivial to integrate with web services. + +- Simple interface for building query strings, POST requests, streaming large + uploads, streaming large downloads, using HTTP cookies, uploading JSON data, + etc... +- Can send both synchronous and asynchronous requests using the same interface. +- Uses PSR-7 interfaces for requests, responses, and streams. This allows you + to utilize other PSR-7 compatible libraries with Guzzle. +- Supports PSR-18 allowing interoperability between other PSR-18 HTTP Clients. +- Abstracts away the underlying HTTP transport, allowing you to write + environment and transport agnostic code; i.e., no hard dependency on cURL, + PHP streams, sockets, or non-blocking event loops. +- Middleware system allows you to augment and compose client behavior. + +```php +$client = new \GuzzleHttp\Client(); +$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); + +echo $response->getStatusCode(); // 200 +echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8' +echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}' + +// Send an asynchronous request. +$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); +$promise = $client->sendAsync($request)->then(function ($response) { + echo 'I completed! ' . $response->getBody(); +}); + +$promise->wait(); +``` + +## Help and docs + +We use GitHub issues only to discuss bugs and new features. For support please refer to: + +- [Documentation](https://docs.guzzlephp.org) +- [Stack Overflow](https://stackoverflow.com/questions/tagged/guzzle) +- [#guzzle](https://app.slack.com/client/T0D2S9JCT/CE6UAAKL4) channel on [PHP-HTTP Slack](https://slack.httplug.io/) +- [Gitter](https://gitter.im/guzzle/guzzle) + + +## Installing Guzzle + +The recommended way to install Guzzle is through +[Composer](https://getcomposer.org/). + +```bash +composer require guzzlehttp/guzzle +``` + + +## Version Guidance + +| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version | +|---------|---------------------|---------------------|--------------|---------------------|---------------------|-------|--------------| +| 3.x | EOL (2016-10-31) | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >=5.3.3,<7.0 | +| 4.x | EOL (2016-10-31) | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >=5.4,<7.0 | +| 5.x | EOL (2019-10-31) | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >=5.4,<7.4 | +| 6.x | EOL (2023-10-31) | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >=5.5,<8.0 | +| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >=7.2.5,<8.5 | + +[guzzle-3-repo]: https://github.com/guzzle/guzzle3 +[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x +[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3 +[guzzle-6-repo]: https://github.com/guzzle/guzzle/tree/6.5 +[guzzle-7-repo]: https://github.com/guzzle/guzzle +[guzzle-3-docs]: https://guzzle3.readthedocs.io/ +[guzzle-5-docs]: https://docs.guzzlephp.org/en/5.3/ +[guzzle-6-docs]: https://docs.guzzlephp.org/en/6.5/ +[guzzle-7-docs]: https://docs.guzzlephp.org/en/latest/ + + +## Security + +If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/guzzle/security/policy) for more information. + +## License + +Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information. + +## For Enterprise + +Available as part of the Tidelift Subscription + +The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver 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. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-guzzle?utm_source=packagist-guzzlehttp-guzzle&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/vendor/guzzlehttp/guzzle/UPGRADING.md b/vendor/guzzlehttp/guzzle/UPGRADING.md new file mode 100644 index 0000000..4efbb59 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/UPGRADING.md @@ -0,0 +1,1253 @@ +Guzzle Upgrade Guide +==================== + +6.0 to 7.0 +---------- + +In order to take advantage of the new features of PHP, Guzzle dropped the support +of PHP 5. The minimum supported PHP version is now PHP 7.2. Type hints and return +types for functions and methods have been added wherever possible. + +Please make sure: +- You are calling a function or a method with the correct type. +- If you extend a class of Guzzle; update all signatures on methods you override. + +#### Other backwards compatibility breaking changes + +- Class `GuzzleHttp\UriTemplate` is removed. +- Class `GuzzleHttp\Exception\SeekException` is removed. +- Classes `GuzzleHttp\Exception\BadResponseException`, `GuzzleHttp\Exception\ClientException`, + `GuzzleHttp\Exception\ServerException` can no longer be initialized with an empty + Response as argument. +- Class `GuzzleHttp\Exception\ConnectException` now extends `GuzzleHttp\Exception\TransferException` + instead of `GuzzleHttp\Exception\RequestException`. +- Function `GuzzleHttp\Exception\ConnectException::getResponse()` is removed. +- Function `GuzzleHttp\Exception\ConnectException::hasResponse()` is removed. +- Constant `GuzzleHttp\ClientInterface::VERSION` is removed. Added `GuzzleHttp\ClientInterface::MAJOR_VERSION` instead. +- Function `GuzzleHttp\Exception\RequestException::getResponseBodySummary` is removed. + Use `\GuzzleHttp\Psr7\get_message_body_summary` as an alternative. +- Function `GuzzleHttp\Cookie\CookieJar::getCookieValue` is removed. +- Request option `exceptions` is removed. Please use `http_errors`. +- Request option `save_to` is removed. Please use `sink`. +- Pool option `pool_size` is removed. Please use `concurrency`. +- We now look for environment variables in the `$_SERVER` super global, due to thread safety issues with `getenv`. We continue to fallback to `getenv` in CLI environments, for maximum compatibility. +- The `get`, `head`, `put`, `post`, `patch`, `delete`, `getAsync`, `headAsync`, `putAsync`, `postAsync`, `patchAsync`, and `deleteAsync` methods are now implemented as genuine methods on `GuzzleHttp\Client`, with strong typing. The original `__call` implementation remains unchanged for now, for maximum backwards compatibility, but won't be invoked under normal operation. +- The `log` middleware will log the errors with level `error` instead of `notice` +- Support for international domain names (IDN) is now disabled by default, and enabling it requires installing ext-intl, linked against a modern version of the C library (ICU 4.6 or higher). + +#### Native functions calls + +All internal native functions calls of Guzzle are now prefixed with a slash. This +change makes it impossible for method overloading by other libraries or applications. +Example: + +```php +// Before: +curl_version(); + +// After: +\curl_version(); +``` + +For the full diff you can check [here](https://github.com/guzzle/guzzle/compare/6.5.4..master). + +5.0 to 6.0 +---------- + +Guzzle now uses [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP messages. +Due to the fact that these messages are immutable, this prompted a refactoring +of Guzzle to use a middleware based system rather than an event system. Any +HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be +updated to work with the new immutable PSR-7 request and response objects. Any +event listeners or subscribers need to be updated to become middleware +functions that wrap handlers (or are injected into a +`GuzzleHttp\HandlerStack`). + +- Removed `GuzzleHttp\BatchResults` +- Removed `GuzzleHttp\Collection` +- Removed `GuzzleHttp\HasDataTrait` +- Removed `GuzzleHttp\ToArrayInterface` +- The `guzzlehttp/streams` dependency has been removed. Stream functionality + is now present in the `GuzzleHttp\Psr7` namespace provided by the + `guzzlehttp/psr7` package. +- Guzzle no longer uses ReactPHP promises and now uses the + `guzzlehttp/promises` library. We use a custom promise library for three + significant reasons: + 1. React promises (at the time of writing this) are recursive. Promise + chaining and promise resolution will eventually blow the stack. Guzzle + promises are not recursive as they use a sort of trampolining technique. + Note: there has been movement in the React project to modify promises to + no longer utilize recursion. + 2. Guzzle needs to have the ability to synchronously block on a promise to + wait for a result. Guzzle promises allows this functionality (and does + not require the use of recursion). + 3. Because we need to be able to wait on a result, doing so using React + promises requires wrapping react promises with RingPHP futures. This + overhead is no longer needed, reducing stack sizes, reducing complexity, + and improving performance. +- `GuzzleHttp\Mimetypes` has been moved to a function in + `GuzzleHttp\Psr7\mimetype_from_extension` and + `GuzzleHttp\Psr7\mimetype_from_filename`. +- `GuzzleHttp\Query` and `GuzzleHttp\QueryParser` have been removed. Query + strings must now be passed into request objects as strings, or provided to + the `query` request option when creating requests with clients. The `query` + option uses PHP's `http_build_query` to convert an array to a string. If you + need a different serialization technique, you will need to pass the query + string in as a string. There are a couple helper functions that will make + working with query strings easier: `GuzzleHttp\Psr7\parse_query` and + `GuzzleHttp\Psr7\build_query`. +- Guzzle no longer has a dependency on RingPHP. Due to the use of a middleware + system based on PSR-7, using RingPHP and it's middleware system as well adds + more complexity than the benefits it provides. All HTTP handlers that were + present in RingPHP have been modified to work directly with PSR-7 messages + and placed in the `GuzzleHttp\Handler` namespace. This significantly reduces + complexity in Guzzle, removes a dependency, and improves performance. RingPHP + will be maintained for Guzzle 5 support, but will no longer be a part of + Guzzle 6. +- As Guzzle now uses a middleware based systems the event system and RingPHP + integration has been removed. Note: while the event system has been removed, + it is possible to add your own type of event system that is powered by the + middleware system. + - Removed the `Event` namespace. + - Removed the `Subscriber` namespace. + - Removed `Transaction` class + - Removed `RequestFsm` + - Removed `RingBridge` + - `GuzzleHttp\Subscriber\Cookie` is now provided by + `GuzzleHttp\Middleware::cookies` + - `GuzzleHttp\Subscriber\HttpError` is now provided by + `GuzzleHttp\Middleware::httpError` + - `GuzzleHttp\Subscriber\History` is now provided by + `GuzzleHttp\Middleware::history` + - `GuzzleHttp\Subscriber\Mock` is now provided by + `GuzzleHttp\Handler\MockHandler` + - `GuzzleHttp\Subscriber\Prepare` is now provided by + `GuzzleHttp\PrepareBodyMiddleware` + - `GuzzleHttp\Subscriber\Redirect` is now provided by + `GuzzleHttp\RedirectMiddleware` +- Guzzle now uses `Psr\Http\Message\UriInterface` (implements in + `GuzzleHttp\Psr7\Uri`) for URI support. `GuzzleHttp\Url` is now gone. +- Static functions in `GuzzleHttp\Utils` have been moved to namespaced + functions under the `GuzzleHttp` namespace. This requires either a Composer + based autoloader or you to include functions.php. +- `GuzzleHttp\ClientInterface::getDefaultOption` has been renamed to + `GuzzleHttp\ClientInterface::getConfig`. +- `GuzzleHttp\ClientInterface::setDefaultOption` has been removed. +- The `json` and `xml` methods of response objects has been removed. With the + migration to strictly adhering to PSR-7 as the interface for Guzzle messages, + adding methods to message interfaces would actually require Guzzle messages + to extend from PSR-7 messages rather then work with them directly. + +## Migrating to middleware + +The change to PSR-7 unfortunately required significant refactoring to Guzzle +due to the fact that PSR-7 messages are immutable. Guzzle 5 relied on an event +system from plugins. The event system relied on mutability of HTTP messages and +side effects in order to work. With immutable messages, you have to change your +workflow to become more about either returning a value (e.g., functional +middlewares) or setting a value on an object. Guzzle v6 has chosen the +functional middleware approach. + +Instead of using the event system to listen for things like the `before` event, +you now create a stack based middleware function that intercepts a request on +the way in and the promise of the response on the way out. This is a much +simpler and more predictable approach than the event system and works nicely +with PSR-7 middleware. Due to the use of promises, the middleware system is +also asynchronous. + +v5: + +```php +use GuzzleHttp\Event\BeforeEvent; +$client = new GuzzleHttp\Client(); +// Get the emitter and listen to the before event. +$client->getEmitter()->on('before', function (BeforeEvent $e) { + // Guzzle v5 events relied on mutation + $e->getRequest()->setHeader('X-Foo', 'Bar'); +}); +``` + +v6: + +In v6, you can modify the request before it is sent using the `mapRequest` +middleware. The idiomatic way in v6 to modify the request/response lifecycle is +to setup a handler middleware stack up front and inject the handler into a +client. + +```php +use GuzzleHttp\Middleware; +// Create a handler stack that has all of the default middlewares attached +$handler = GuzzleHttp\HandlerStack::create(); +// Push the handler onto the handler stack +$handler->push(Middleware::mapRequest(function (RequestInterface $request) { + // Notice that we have to return a request object + return $request->withHeader('X-Foo', 'Bar'); +})); +// Inject the handler into the client +$client = new GuzzleHttp\Client(['handler' => $handler]); +``` + +## POST Requests + +This version added the [`form_params`](https://docs.guzzlephp.org/en/latest/request-options.html#form_params) +and `multipart` request options. `form_params` is an associative array of +strings or array of strings and is used to serialize an +`application/x-www-form-urlencoded` POST request. The +[`multipart`](https://docs.guzzlephp.org/en/latest/request-options.html#multipart) +option is now used to send a multipart/form-data POST request. + +`GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add +POST files to a multipart/form-data request. + +The `body` option no longer accepts an array to send POST requests. Please use +`multipart` or `form_params` instead. + +The `base_url` option has been renamed to `base_uri`. + +4.x to 5.0 +---------- + +## Rewritten Adapter Layer + +Guzzle now uses [RingPHP](https://ringphp.readthedocs.org/en/latest) to send +HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor +is still supported, but it has now been renamed to `handler`. Instead of +passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP +`callable` that follows the RingPHP specification. + +## Removed Fluent Interfaces + +[Fluent interfaces were removed](https://ocramius.github.io/blog/fluent-interfaces-are-evil/) +from the following classes: + +- `GuzzleHttp\Collection` +- `GuzzleHttp\Url` +- `GuzzleHttp\Query` +- `GuzzleHttp\Post\PostBody` +- `GuzzleHttp\Cookie\SetCookie` + +## Removed functions.php + +Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following +functions can be used as replacements. + +- `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode` +- `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath` +- `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path` +- `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however, + deprecated in favor of using `GuzzleHttp\Pool::batch()`. + +The "procedural" global client has been removed with no replacement (e.g., +`GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client` +object as a replacement. + +## `throwImmediately` has been removed + +The concept of "throwImmediately" has been removed from exceptions and error +events. This control mechanism was used to stop a transfer of concurrent +requests from completing. This can now be handled by throwing the exception or +by cancelling a pool of requests or each outstanding future request +individually. + +## headers event has been removed + +Removed the "headers" event. This event was only useful for changing the +body a response once the headers of the response were known. You can implement +a similar behavior in a number of ways. One example might be to use a +FnStream that has access to the transaction being sent. For example, when the +first byte is written, you could check if the response headers match your +expectations, and if so, change the actual stream body that is being +written to. + +## Updates to HTTP Messages + +Removed the `asArray` parameter from +`GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header +value as an array, then use the newly added `getHeaderAsArray()` method of +`MessageInterface`. This change makes the Guzzle interfaces compatible with +the PSR-7 interfaces. + +3.x to 4.0 +---------- + +## Overarching changes: + +- Now requires PHP 5.4 or greater. +- No longer requires cURL to send requests. +- Guzzle no longer wraps every exception it throws. Only exceptions that are + recoverable are now wrapped by Guzzle. +- Various namespaces have been removed or renamed. +- No longer requiring the Symfony EventDispatcher. A custom event dispatcher + based on the Symfony EventDispatcher is + now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant + speed and functionality improvements). + +Changes per Guzzle 3.x namespace are described below. + +## Batch + +The `Guzzle\Batch` namespace has been removed. This is best left to +third-parties to implement on top of Guzzle's core HTTP library. + +## Cache + +The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement +has been implemented yet, but hoping to utilize a PSR cache interface). + +## Common + +- Removed all of the wrapped exceptions. It's better to use the standard PHP + library for unrecoverable exceptions. +- `FromConfigInterface` has been removed. +- `Guzzle\Common\Version` has been removed. The VERSION constant can be found + at `GuzzleHttp\ClientInterface::VERSION`. + +### Collection + +- `getAll` has been removed. Use `toArray` to convert a collection to an array. +- `inject` has been removed. +- `keySearch` has been removed. +- `getPath` no longer supports wildcard expressions. Use something better like + JMESPath for this. +- `setPath` now supports appending to an existing array via the `[]` notation. + +### Events + +Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses +`GuzzleHttp\Event\Emitter`. + +- `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by + `GuzzleHttp\Event\EmitterInterface`. +- `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by + `GuzzleHttp\Event\Emitter`. +- `Symfony\Component\EventDispatcher\Event` is replaced by + `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in + `GuzzleHttp\Event\EventInterface`. +- `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and + `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the + event emitter of a request, client, etc. now uses the `getEmitter` method + rather than the `getDispatcher` method. + +#### Emitter + +- Use the `once()` method to add a listener that automatically removes itself + the first time it is invoked. +- Use the `listeners()` method to retrieve a list of event listeners rather than + the `getListeners()` method. +- Use `emit()` instead of `dispatch()` to emit an event from an emitter. +- Use `attach()` instead of `addSubscriber()` and `detach()` instead of + `removeSubscriber()`. + +```php +$mock = new Mock(); +// 3.x +$request->getEventDispatcher()->addSubscriber($mock); +$request->getEventDispatcher()->removeSubscriber($mock); +// 4.x +$request->getEmitter()->attach($mock); +$request->getEmitter()->detach($mock); +``` + +Use the `on()` method to add a listener rather than the `addListener()` method. + +```php +// 3.x +$request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } ); +// 4.x +$request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } ); +``` + +## Http + +### General changes + +- The cacert.pem certificate has been moved to `src/cacert.pem`. +- Added the concept of adapters that are used to transfer requests over the + wire. +- Simplified the event system. +- Sending requests in parallel is still possible, but batching is no longer a + concept of the HTTP layer. Instead, you must use the `complete` and `error` + events to asynchronously manage parallel request transfers. +- `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`. +- `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`. +- QueryAggregators have been rewritten so that they are simply callable + functions. +- `GuzzleHttp\StaticClient` has been removed. Use the functions provided in + `functions.php` for an easy to use static client instance. +- Exceptions in `GuzzleHttp\Exception` have been updated to all extend from + `GuzzleHttp\Exception\TransferException`. + +### Client + +Calling methods like `get()`, `post()`, `head()`, etc. no longer create and +return a request, but rather creates a request, sends the request, and returns +the response. + +```php +// 3.0 +$request = $client->get('/'); +$response = $request->send(); + +// 4.0 +$response = $client->get('/'); + +// or, to mirror the previous behavior +$request = $client->createRequest('GET', '/'); +$response = $client->send($request); +``` + +`GuzzleHttp\ClientInterface` has changed. + +- The `send` method no longer accepts more than one request. Use `sendAll` to + send multiple requests in parallel. +- `setUserAgent()` has been removed. Use a default request option instead. You + could, for example, do something like: + `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`. +- `setSslVerification()` has been removed. Use default request options instead, + like `$client->setConfig('defaults/verify', true)`. + +`GuzzleHttp\Client` has changed. + +- The constructor now accepts only an associative array. You can include a + `base_url` string or array to use a URI template as the base URL of a client. + You can also specify a `defaults` key that is an associative array of default + request options. You can pass an `adapter` to use a custom adapter, + `batch_adapter` to use a custom adapter for sending requests in parallel, or + a `message_factory` to change the factory used to create HTTP requests and + responses. +- The client no longer emits a `client.create_request` event. +- Creating requests with a client no longer automatically utilize a URI + template. You must pass an array into a creational method (e.g., + `createRequest`, `get`, `put`, etc.) in order to expand a URI template. + +### Messages + +Messages no longer have references to their counterparts (i.e., a request no +longer has a reference to it's response, and a response no loger has a +reference to its request). This association is now managed through a +`GuzzleHttp\Adapter\TransactionInterface` object. You can get references to +these transaction objects using request events that are emitted over the +lifecycle of a request. + +#### Requests with a body + +- `GuzzleHttp\Message\EntityEnclosingRequest` and + `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The + separation between requests that contain a body and requests that do not + contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface` + handles both use cases. +- Any method that previously accepts a `GuzzleHttp\Response` object now accept a + `GuzzleHttp\Message\ResponseInterface`. +- `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to + `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create + both requests and responses and is implemented in + `GuzzleHttp\Message\MessageFactory`. +- POST field and file methods have been removed from the request object. You + must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface` + to control the format of a POST body. Requests that are created using a + standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use + a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if + the method is POST and no body is provided. + +```php +$request = $client->createRequest('POST', '/'); +$request->getBody()->setField('foo', 'bar'); +$request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r'))); +``` + +#### Headers + +- `GuzzleHttp\Message\Header` has been removed. Header values are now simply + represented by an array of values or as a string. Header values are returned + as a string by default when retrieving a header value from a message. You can + pass an optional argument of `true` to retrieve a header value as an array + of strings instead of a single concatenated string. +- `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to + `GuzzleHttp\Post`. This interface has been simplified and now allows the + addition of arbitrary headers. +- Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most + of the custom headers are now handled separately in specific + subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has + been updated to properly handle headers that contain parameters (like the + `Link` header). + +#### Responses + +- `GuzzleHttp\Message\Response::getInfo()` and + `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event + system to retrieve this type of information. +- `GuzzleHttp\Message\Response::getRawHeaders()` has been removed. +- `GuzzleHttp\Message\Response::getMessage()` has been removed. +- `GuzzleHttp\Message\Response::calculateAge()` and other cache specific + methods have moved to the CacheSubscriber. +- Header specific helper functions like `getContentMd5()` have been removed. + Just use `getHeader('Content-MD5')` instead. +- `GuzzleHttp\Message\Response::setRequest()` and + `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event + system to work with request and response objects as a transaction. +- `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the + Redirect subscriber instead. +- `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have + been removed. Use `getStatusCode()` instead. + +#### Streaming responses + +Streaming requests can now be created by a client directly, returning a +`GuzzleHttp\Message\ResponseInterface` object that contains a body stream +referencing an open PHP HTTP stream. + +```php +// 3.0 +use Guzzle\Stream\PhpStreamRequestFactory; +$request = $client->get('/'); +$factory = new PhpStreamRequestFactory(); +$stream = $factory->fromRequest($request); +$data = $stream->read(1024); + +// 4.0 +$response = $client->get('/', ['stream' => true]); +// Read some data off of the stream in the response body +$data = $response->getBody()->read(1024); +``` + +#### Redirects + +The `configureRedirects()` method has been removed in favor of a +`allow_redirects` request option. + +```php +// Standard redirects with a default of a max of 5 redirects +$request = $client->createRequest('GET', '/', ['allow_redirects' => true]); + +// Strict redirects with a custom number of redirects +$request = $client->createRequest('GET', '/', [ + 'allow_redirects' => ['max' => 5, 'strict' => true] +]); +``` + +#### EntityBody + +EntityBody interfaces and classes have been removed or moved to +`GuzzleHttp\Stream`. All classes and interfaces that once required +`GuzzleHttp\EntityBodyInterface` now require +`GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no +longer uses `GuzzleHttp\EntityBody::factory` but now uses +`GuzzleHttp\Stream\Stream::factory` or even better: +`GuzzleHttp\Stream\create()`. + +- `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface` +- `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream` +- `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream` +- `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream` +- `Guzzle\Http\IoEmittyinEntityBody` has been removed. + +#### Request lifecycle events + +Requests previously submitted a large number of requests. The number of events +emitted over the lifecycle of a request has been significantly reduced to make +it easier to understand how to extend the behavior of a request. All events +emitted during the lifecycle of a request now emit a custom +`GuzzleHttp\Event\EventInterface` object that contains context providing +methods and a way in which to modify the transaction at that specific point in +time (e.g., intercept the request and set a response on the transaction). + +- `request.before_send` has been renamed to `before` and now emits a + `GuzzleHttp\Event\BeforeEvent` +- `request.complete` has been renamed to `complete` and now emits a + `GuzzleHttp\Event\CompleteEvent`. +- `request.sent` has been removed. Use `complete`. +- `request.success` has been removed. Use `complete`. +- `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`. +- `request.exception` has been removed. Use `error`. +- `request.receive.status_line` has been removed. +- `curl.callback.progress` has been removed. Use a custom `StreamInterface` to + maintain a status update. +- `curl.callback.write` has been removed. Use a custom `StreamInterface` to + intercept writes. +- `curl.callback.read` has been removed. Use a custom `StreamInterface` to + intercept reads. + +`headers` is a new event that is emitted after the response headers of a +request have been received before the body of the response is downloaded. This +event emits a `GuzzleHttp\Event\HeadersEvent`. + +You can intercept a request and inject a response using the `intercept()` event +of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and +`GuzzleHttp\Event\ErrorEvent` event. + +See: https://docs.guzzlephp.org/en/latest/events.html + +## Inflection + +The `Guzzle\Inflection` namespace has been removed. This is not a core concern +of Guzzle. + +## Iterator + +The `Guzzle\Iterator` namespace has been removed. + +- `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and + `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of + Guzzle itself. +- `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent + class is shipped with PHP 5.4. +- `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because + it's easier to just wrap an iterator in a generator that maps values. + +For a replacement of these iterators, see https://github.com/nikic/iter + +## Log + +The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The +`Guzzle\Log` namespace has been removed. Guzzle now relies on +`Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been +moved to `GuzzleHttp\Subscriber\Log\Formatter`. + +## Parser + +The `Guzzle\Parser` namespace has been removed. This was previously used to +make it possible to plug in custom parsers for cookies, messages, URI +templates, and URLs; however, this level of complexity is not needed in Guzzle +so it has been removed. + +- Cookie: Cookie parsing logic has been moved to + `GuzzleHttp\Cookie\SetCookie::fromString`. +- Message: Message parsing logic for both requests and responses has been moved + to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only + used in debugging or deserializing messages, so it doesn't make sense for + Guzzle as a library to add this level of complexity to parsing messages. +- UriTemplate: URI template parsing has been moved to + `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL + URI template library if it is installed. +- Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously + it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary, + then developers are free to subclass `GuzzleHttp\Url`. + +## Plugin + +The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`. +Several plugins are shipping with the core Guzzle library under this namespace. + +- `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar + code has moved to `GuzzleHttp\Cookie`. +- `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin. +- `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is + received. +- `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin. +- `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before + sending. This subscriber is attached to all requests by default. +- `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin. + +The following plugins have been removed (third-parties are free to re-implement +these if needed): + +- `GuzzleHttp\Plugin\Async` has been removed. +- `GuzzleHttp\Plugin\CurlAuth` has been removed. +- `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This + functionality should instead be implemented with event listeners that occur + after normal response parsing occurs in the guzzle/command package. + +The following plugins are not part of the core Guzzle package, but are provided +in separate repositories: + +- `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be much simpler + to build custom retry policies using simple functions rather than various + chained classes. See: https://github.com/guzzle/retry-subscriber +- `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to + https://github.com/guzzle/cache-subscriber +- `Guzzle\Http\Plugin\Log\LogPlugin` has moved to + https://github.com/guzzle/log-subscriber +- `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to + https://github.com/guzzle/message-integrity-subscriber +- `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to + `GuzzleHttp\Subscriber\MockSubscriber`. +- `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to + https://github.com/guzzle/oauth-subscriber + +## Service + +The service description layer of Guzzle has moved into two separate packages: + +- https://github.com/guzzle/command Provides a high level abstraction over web + services by representing web service operations using commands. +- https://github.com/guzzle/guzzle-services Provides an implementation of + guzzle/command that provides request serialization and response parsing using + Guzzle service descriptions. + +## Stream + +Stream have moved to a separate package available at +https://github.com/guzzle/streams. + +`Guzzle\Stream\StreamInterface` has been given a large update to cleanly take +on the responsibilities of `Guzzle\Http\EntityBody` and +`Guzzle\Http\EntityBodyInterface` now that they have been removed. The number +of methods implemented by the `StreamInterface` has been drastically reduced to +allow developers to more easily extend and decorate stream behavior. + +## Removed methods from StreamInterface + +- `getStream` and `setStream` have been removed to better encapsulate streams. +- `getMetadata` and `setMetadata` have been removed in favor of + `GuzzleHttp\Stream\MetadataStreamInterface`. +- `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been + removed. This data is accessible when + using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`. +- `rewind` has been removed. Use `seek(0)` for a similar behavior. + +## Renamed methods + +- `detachStream` has been renamed to `detach`. +- `feof` has been renamed to `eof`. +- `ftell` has been renamed to `tell`. +- `readLine` has moved from an instance method to a static class method of + `GuzzleHttp\Stream\Stream`. + +## Metadata streams + +`GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams +that contain additional metadata accessible via `getMetadata()`. +`GuzzleHttp\Stream\StreamInterface::getMetadata` and +`GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed. + +## StreamRequestFactory + +The entire concept of the StreamRequestFactory has been removed. The way this +was used in Guzzle 3 broke the actual interface of sending streaming requests +(instead of getting back a Response, you got a StreamInterface). Streaming +PHP requests are now implemented through the `GuzzleHttp\Adapter\StreamAdapter`. + +3.6 to 3.7 +---------- + +### Deprecations + +- You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.: + +```php +\Guzzle\Common\Version::$emitWarnings = true; +``` + +The following APIs and options have been marked as deprecated: + +- Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead. +- Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. +- Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. +- Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead. +- Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead. +- Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated +- Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client. +- Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8. +- Marked `Guzzle\Common\Collection::inject()` as deprecated. +- Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use + `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or + `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` + +3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational +request methods. When paired with a client's configuration settings, these options allow you to specify default settings +for various aspects of a request. Because these options make other previous configuration options redundant, several +configuration options and methods of a client and AbstractCommand have been deprecated. + +- Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`. +- Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`. +- Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')` +- Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0 + + $command = $client->getCommand('foo', array( + 'command.headers' => array('Test' => '123'), + 'command.response_body' => '/path/to/file' + )); + + // Should be changed to: + + $command = $client->getCommand('foo', array( + 'command.request_options' => array( + 'headers' => array('Test' => '123'), + 'save_as' => '/path/to/file' + ) + )); + +### Interface changes + +Additions and changes (you will need to update any implementations or subclasses you may have created): + +- Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`: + createRequest, head, delete, put, patch, post, options, prepareRequest +- Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()` +- Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface` +- Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to + `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a + resource, string, or EntityBody into the $options parameter to specify the download location of the response. +- Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a + default `array()` +- Added `Guzzle\Stream\StreamInterface::isRepeatable` +- Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods. + +The following methods were removed from interfaces. All of these methods are still available in the concrete classes +that implement them, but you should update your code to use alternative methods: + +- Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use + `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or + `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or + `$client->setDefaultOption('headers/{header_name}', 'value')`. or + `$client->setDefaultOption('headers', array('header_name' => 'value'))`. +- Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`. +- Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail. +- Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail. +- Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail. +- Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin. +- Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin. +- Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin. + +### Cache plugin breaking changes + +- CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a + CacheStorageInterface. These two objects and interface will be removed in a future version. +- Always setting X-cache headers on cached responses +- Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin +- `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface + $request, Response $response);` +- `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);` +- `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);` +- Added `CacheStorageInterface::purge($url)` +- `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin + $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache, + CanCacheStrategyInterface $canCache = null)` +- Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)` + +3.5 to 3.6 +---------- + +* Mixed casing of headers are now forced to be a single consistent casing across all values for that header. +* Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution +* Removed the whole changedHeader() function system of messages because all header changes now go through addHeader(). + For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader(). + Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request. +* Specific header implementations can be created for complex headers. When a message creates a header, it uses a + HeaderFactory which can map specific headers to specific header classes. There is now a Link header and + CacheControl header implementation. +* Moved getLinks() from Response to just be used on a Link header object. + +If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the +HeaderInterface (e.g. toArray(), getAll(), etc.). + +### Interface changes + +* Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate +* Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti() +* Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in + Guzzle\Http\Curl\RequestMediator +* Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string. +* Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface +* Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders() + +### Removed deprecated functions + +* Removed Guzzle\Parser\ParserRegister::get(). Use getParser() +* Removed Guzzle\Parser\ParserRegister::set(). Use registerParser(). + +### Deprecations + +* The ability to case-insensitively search for header values +* Guzzle\Http\Message\Header::hasExactHeader +* Guzzle\Http\Message\Header::raw. Use getAll() +* Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object + instead. + +### Other changes + +* All response header helper functions return a string rather than mixing Header objects and strings inconsistently +* Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle + directly via interfaces +* Removed the injecting of a request object onto a response object. The methods to get and set a request still exist + but are a no-op until removed. +* Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a + `Guzzle\Service\Command\ArrayCommandInterface`. +* Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response + on a request while the request is still being transferred +* `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess + +3.3 to 3.4 +---------- + +Base URLs of a client now follow the rules of https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2 when merging URLs. + +3.2 to 3.3 +---------- + +### Response::getEtag() quote stripping removed + +`Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header + +### Removed `Guzzle\Http\Utils` + +The `Guzzle\Http\Utils` class was removed. This class was only used for testing. + +### Stream wrapper and type + +`Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase. + +### curl.emit_io became emit_io + +Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the +'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io' + +3.1 to 3.2 +---------- + +### CurlMulti is no longer reused globally + +Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added +to a single client can pollute requests dispatched from other clients. + +If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the +ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is +created. + +```php +$multi = new Guzzle\Http\Curl\CurlMulti(); +$builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json'); +$builder->addListener('service_builder.create_client', function ($event) use ($multi) { + $event['client']->setCurlMulti($multi); +} +}); +``` + +### No default path + +URLs no longer have a default path value of '/' if no path was specified. + +Before: + +```php +$request = $client->get('http://www.foo.com'); +echo $request->getUrl(); +// >> http://www.foo.com/ +``` + +After: + +```php +$request = $client->get('http://www.foo.com'); +echo $request->getUrl(); +// >> http://www.foo.com +``` + +### Less verbose BadResponseException + +The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and +response information. You can, however, get access to the request and response object by calling `getRequest()` or +`getResponse()` on the exception object. + +### Query parameter aggregation + +Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a +setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is +responsible for handling the aggregation of multi-valued query string variables into a flattened hash. + +2.8 to 3.x +---------- + +### Guzzle\Service\Inspector + +Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig` + +**Before** + +```php +use Guzzle\Service\Inspector; + +class YourClient extends \Guzzle\Service\Client +{ + public static function factory($config = array()) + { + $default = array(); + $required = array('base_url', 'username', 'api_key'); + $config = Inspector::fromConfig($config, $default, $required); + + $client = new self( + $config->get('base_url'), + $config->get('username'), + $config->get('api_key') + ); + $client->setConfig($config); + + $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); + + return $client; + } +``` + +**After** + +```php +use Guzzle\Common\Collection; + +class YourClient extends \Guzzle\Service\Client +{ + public static function factory($config = array()) + { + $default = array(); + $required = array('base_url', 'username', 'api_key'); + $config = Collection::fromConfig($config, $default, $required); + + $client = new self( + $config->get('base_url'), + $config->get('username'), + $config->get('api_key') + ); + $client->setConfig($config); + + $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); + + return $client; + } +``` + +### Convert XML Service Descriptions to JSON + +**Before** + +```xml + + + + + + Get a list of groups + + + Uses a search query to get a list of groups + + + + Create a group + + + + + Delete a group by ID + + + + + + + Update a group + + + + + + +``` + +**After** + +```json +{ + "name": "Zendesk REST API v2", + "apiVersion": "2012-12-31", + "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users", + "operations": { + "list_groups": { + "httpMethod":"GET", + "uri": "groups.json", + "summary": "Get a list of groups" + }, + "search_groups":{ + "httpMethod":"GET", + "uri": "search.json?query=\"{query} type:group\"", + "summary": "Uses a search query to get a list of groups", + "parameters":{ + "query":{ + "location": "uri", + "description":"Zendesk Search Query", + "type": "string", + "required": true + } + } + }, + "create_group": { + "httpMethod":"POST", + "uri": "groups.json", + "summary": "Create a group", + "parameters":{ + "data": { + "type": "array", + "location": "body", + "description":"Group JSON", + "filters": "json_encode", + "required": true + }, + "Content-Type":{ + "type": "string", + "location":"header", + "static": "application/json" + } + } + }, + "delete_group": { + "httpMethod":"DELETE", + "uri": "groups/{id}.json", + "summary": "Delete a group", + "parameters":{ + "id":{ + "location": "uri", + "description":"Group to delete by ID", + "type": "integer", + "required": true + } + } + }, + "get_group": { + "httpMethod":"GET", + "uri": "groups/{id}.json", + "summary": "Get a ticket", + "parameters":{ + "id":{ + "location": "uri", + "description":"Group to get by ID", + "type": "integer", + "required": true + } + } + }, + "update_group": { + "httpMethod":"PUT", + "uri": "groups/{id}.json", + "summary": "Update a group", + "parameters":{ + "id": { + "location": "uri", + "description":"Group to update by ID", + "type": "integer", + "required": true + }, + "data": { + "type": "array", + "location": "body", + "description":"Group JSON", + "filters": "json_encode", + "required": true + }, + "Content-Type":{ + "type": "string", + "location":"header", + "static": "application/json" + } + } + } +} +``` + +### Guzzle\Service\Description\ServiceDescription + +Commands are now called Operations + +**Before** + +```php +use Guzzle\Service\Description\ServiceDescription; + +$sd = new ServiceDescription(); +$sd->getCommands(); // @returns ApiCommandInterface[] +$sd->hasCommand($name); +$sd->getCommand($name); // @returns ApiCommandInterface|null +$sd->addCommand($command); // @param ApiCommandInterface $command +``` + +**After** + +```php +use Guzzle\Service\Description\ServiceDescription; + +$sd = new ServiceDescription(); +$sd->getOperations(); // @returns OperationInterface[] +$sd->hasOperation($name); +$sd->getOperation($name); // @returns OperationInterface|null +$sd->addOperation($operation); // @param OperationInterface $operation +``` + +### Guzzle\Common\Inflection\Inflector + +Namespace is now `Guzzle\Inflection\Inflector` + +### Guzzle\Http\Plugin + +Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below. + +### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log + +Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively. + +**Before** + +```php +use Guzzle\Common\Log\ClosureLogAdapter; +use Guzzle\Http\Plugin\LogPlugin; + +/** @var \Guzzle\Http\Client */ +$client; + +// $verbosity is an integer indicating desired message verbosity level +$client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE); +``` + +**After** + +```php +use Guzzle\Log\ClosureLogAdapter; +use Guzzle\Log\MessageFormatter; +use Guzzle\Plugin\Log\LogPlugin; + +/** @var \Guzzle\Http\Client */ +$client; + +// $format is a string indicating desired message format -- @see MessageFormatter +$client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT); +``` + +### Guzzle\Http\Plugin\CurlAuthPlugin + +Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`. + +### Guzzle\Http\Plugin\ExponentialBackoffPlugin + +Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes. + +**Before** + +```php +use Guzzle\Http\Plugin\ExponentialBackoffPlugin; + +$backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge( + ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429) + )); + +$client->addSubscriber($backoffPlugin); +``` + +**After** + +```php +use Guzzle\Plugin\Backoff\BackoffPlugin; +use Guzzle\Plugin\Backoff\HttpBackoffStrategy; + +// Use convenient factory method instead -- see implementation for ideas of what +// you can do with chaining backoff strategies +$backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge( + HttpBackoffStrategy::getDefaultFailureCodes(), array(429) + )); +$client->addSubscriber($backoffPlugin); +``` + +### Known Issues + +#### [BUG] Accept-Encoding header behavior changed unintentionally. + +(See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e) + +In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to +properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen. +See issue #217 for a workaround, or use a version containing the fix. diff --git a/vendor/guzzlehttp/guzzle/composer.json b/vendor/guzzlehttp/guzzle/composer.json new file mode 100644 index 0000000..cbede14 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/composer.json @@ -0,0 +1,131 @@ +{ + "name": "guzzlehttp/guzzle", + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "framework", + "http", + "rest", + "web service", + "curl", + "client", + "HTTP client", + "PSR-7", + "PSR-18" + ], + "license": "MIT", + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "repositories": [ + { + "type": "package", + "package": { + "name": "guzzle/client-integration-tests", + "version": "v3.0.2", + "dist": { + "url": "https://codeload.github.com/guzzle/client-integration-tests/zip/2c025848417c1135031fdf9c728ee53d0a7ceaee", + "type": "zip" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.11", + "php-http/message": "^1.0 || ^2.0", + "guzzlehttp/psr7": "^1.7 || ^2.0", + "th3n3rd/cartesian-product": "^0.3" + }, + "autoload": { + "psr-4": { + "Http\\Client\\Tests\\": "src/" + } + }, + "bin": [ + "bin/http_test_server" + ] + } + } + ], + "require": { + "php": "^7.2.5 || ^8.0", + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "ext-curl": "*", + "bamarni/composer-bin-plugin": "^1.8.2", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "autoload-dev": { + "psr-4": { + "GuzzleHttp\\Tests\\": "tests/" + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/BodySummarizer.php b/vendor/guzzlehttp/guzzle/src/BodySummarizer.php new file mode 100644 index 0000000..761506d --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/BodySummarizer.php @@ -0,0 +1,28 @@ +truncateAt = $truncateAt; + } + + /** + * Returns a summarized message body. + */ + public function summarize(MessageInterface $message): ?string + { + return $this->truncateAt === null + ? Psr7\Message::bodySummary($message) + : Psr7\Message::bodySummary($message, $this->truncateAt); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php b/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php new file mode 100644 index 0000000..3e02e03 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php @@ -0,0 +1,13 @@ + 'http://www.foo.com/1.0/', + * 'timeout' => 0, + * 'allow_redirects' => false, + * 'proxy' => '192.168.16.1:10' + * ]); + * + * Client configuration settings include the following options: + * + * - handler: (callable) Function that transfers HTTP requests over the + * wire. The function is called with a Psr7\Http\Message\RequestInterface + * and array of transfer options, and must return a + * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a + * Psr7\Http\Message\ResponseInterface on success. + * If no handler is provided, a default handler will be created + * that enables all of the request options below by attaching all of the + * default middleware to the handler. + * - base_uri: (string|UriInterface) Base URI of the client that is merged + * into relative URIs. Can be a string or instance of UriInterface. + * - **: any request option + * + * @param array $config Client configuration settings. + * + * @see RequestOptions for a list of available request options. + */ + public function __construct(array $config = []) + { + if (!isset($config['handler'])) { + $config['handler'] = HandlerStack::create(); + } elseif (!\is_callable($config['handler'])) { + throw new InvalidArgumentException('handler must be a callable'); + } + + // Convert the base_uri to a UriInterface + if (isset($config['base_uri'])) { + $config['base_uri'] = Psr7\Utils::uriFor($config['base_uri']); + } + + $this->configureDefaults($config); + } + + /** + * @param string $method + * @param array $args + * + * @return PromiseInterface|ResponseInterface + * + * @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0. + */ + public function __call($method, $args) + { + if (\count($args) < 1) { + throw new InvalidArgumentException('Magic request methods require a URI and optional options array'); + } + + $uri = $args[0]; + $opts = $args[1] ?? []; + + return \substr($method, -5) === 'Async' + ? $this->requestAsync(\substr($method, 0, -5), $uri, $opts) + : $this->request($method, $uri, $opts); + } + + /** + * Asynchronously send an HTTP request. + * + * @param array $options Request options to apply to the given + * request and to the transfer. See \GuzzleHttp\RequestOptions. + */ + public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface + { + // Merge the base URI into the request URI if needed. + $options = $this->prepareDefaults($options); + + return $this->transfer( + $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), + $options + ); + } + + /** + * Send an HTTP request. + * + * @param array $options Request options to apply to the given + * request and to the transfer. See \GuzzleHttp\RequestOptions. + * + * @throws GuzzleException + */ + public function send(RequestInterface $request, array $options = []): ResponseInterface + { + $options[RequestOptions::SYNCHRONOUS] = true; + + return $this->sendAsync($request, $options)->wait(); + } + + /** + * The HttpClient PSR (PSR-18) specify this method. + * + * {@inheritDoc} + */ + public function sendRequest(RequestInterface $request): ResponseInterface + { + $options[RequestOptions::SYNCHRONOUS] = true; + $options[RequestOptions::ALLOW_REDIRECTS] = false; + $options[RequestOptions::HTTP_ERRORS] = false; + + return $this->sendAsync($request, $options)->wait(); + } + + /** + * Create and send an asynchronous HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string $method HTTP method + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. + */ + public function requestAsync(string $method, $uri = '', array $options = []): PromiseInterface + { + $options = $this->prepareDefaults($options); + // Remove request modifying parameter because it can be done up-front. + $headers = $options['headers'] ?? []; + $body = $options['body'] ?? null; + $version = $options['version'] ?? '1.1'; + // Merge the URI into the base URI. + $uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options); + if (\is_array($body)) { + throw $this->invalidBody(); + } + $request = new Psr7\Request($method, $uri, $headers, $body, $version); + // Remove the option so that they are not doubly-applied. + unset($options['headers'], $options['body'], $options['version']); + + return $this->transfer($request, $options); + } + + /** + * Create and send an HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string $method HTTP method. + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. + * + * @throws GuzzleException + */ + public function request(string $method, $uri = '', array $options = []): ResponseInterface + { + $options[RequestOptions::SYNCHRONOUS] = true; + + return $this->requestAsync($method, $uri, $options)->wait(); + } + + /** + * Get a client configuration option. + * + * These options include default request options of the client, a "handler" + * (if utilized by the concrete client), and a "base_uri" if utilized by + * the concrete client. + * + * @param string|null $option The config option to retrieve. + * + * @return mixed + * + * @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0. + */ + public function getConfig(?string $option = null) + { + return $option === null + ? $this->config + : ($this->config[$option] ?? null); + } + + private function buildUri(UriInterface $uri, array $config): UriInterface + { + if (isset($config['base_uri'])) { + $uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri); + } + + if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) { + $idnOptions = ($config['idn_conversion'] === true) ? \IDNA_DEFAULT : $config['idn_conversion']; + $uri = Utils::idnUriConvert($uri, $idnOptions); + } + + return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri; + } + + /** + * Configures the default options for a client. + */ + private function configureDefaults(array $config): void + { + $defaults = [ + 'allow_redirects' => RedirectMiddleware::$defaultSettings, + 'http_errors' => true, + 'decode_content' => true, + 'verify' => true, + 'cookies' => false, + 'idn_conversion' => false, + ]; + + // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. + + // We can only trust the HTTP_PROXY environment variable in a CLI + // process due to the fact that PHP has no reliable mechanism to + // get environment variables that start with "HTTP_". + if (\PHP_SAPI === 'cli' && ($proxy = Utils::getenv('HTTP_PROXY'))) { + $defaults['proxy']['http'] = $proxy; + } + + if ($proxy = Utils::getenv('HTTPS_PROXY')) { + $defaults['proxy']['https'] = $proxy; + } + + if ($noProxy = Utils::getenv('NO_PROXY')) { + $cleanedNoProxy = \str_replace(' ', '', $noProxy); + $defaults['proxy']['no'] = \explode(',', $cleanedNoProxy); + } + + $this->config = $config + $defaults; + + if (!empty($config['cookies']) && $config['cookies'] === true) { + $this->config['cookies'] = new CookieJar(); + } + + // Add the default user-agent header. + if (!isset($this->config['headers'])) { + $this->config['headers'] = ['User-Agent' => Utils::defaultUserAgent()]; + } else { + // Add the User-Agent header if one was not already set. + foreach (\array_keys($this->config['headers']) as $name) { + if (\strtolower($name) === 'user-agent') { + return; + } + } + $this->config['headers']['User-Agent'] = Utils::defaultUserAgent(); + } + } + + /** + * Merges default options into the array. + * + * @param array $options Options to modify by reference + */ + private function prepareDefaults(array $options): array + { + $defaults = $this->config; + + if (!empty($defaults['headers'])) { + // Default headers are only added if they are not present. + $defaults['_conditional'] = $defaults['headers']; + unset($defaults['headers']); + } + + // Special handling for headers is required as they are added as + // conditional headers and as headers passed to a request ctor. + if (\array_key_exists('headers', $options)) { + // Allows default headers to be unset. + if ($options['headers'] === null) { + $defaults['_conditional'] = []; + unset($options['headers']); + } elseif (!\is_array($options['headers'])) { + throw new InvalidArgumentException('headers must be an array'); + } + } + + // Shallow merge defaults underneath options. + $result = $options + $defaults; + + // Remove null values. + foreach ($result as $k => $v) { + if ($v === null) { + unset($result[$k]); + } + } + + return $result; + } + + /** + * Transfers the given request and applies request options. + * + * The URI of the request is not modified and the request options are used + * as-is without merging in default options. + * + * @param array $options See \GuzzleHttp\RequestOptions. + */ + private function transfer(RequestInterface $request, array $options): PromiseInterface + { + $request = $this->applyOptions($request, $options); + /** @var HandlerStack $handler */ + $handler = $options['handler']; + + try { + return P\Create::promiseFor($handler($request, $options)); + } catch (\Exception $e) { + return P\Create::rejectionFor($e); + } + } + + /** + * Applies the array of request options to a request. + */ + private function applyOptions(RequestInterface $request, array &$options): RequestInterface + { + $modify = [ + 'set_headers' => [], + ]; + + if (isset($options['headers'])) { + if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) { + throw new InvalidArgumentException('The headers array must have header name as keys.'); + } + $modify['set_headers'] = $options['headers']; + unset($options['headers']); + } + + if (isset($options['form_params'])) { + if (isset($options['multipart'])) { + throw new InvalidArgumentException('You cannot use ' + .'form_params and multipart at the same time. Use the ' + .'form_params option if you want to send application/' + .'x-www-form-urlencoded requests, and the multipart ' + .'option to send multipart/form-data requests.'); + } + $options['body'] = \http_build_query($options['form_params'], '', '&'); + unset($options['form_params']); + // Ensure that we don't have the header in different case and set the new value. + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); + $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded'; + } + + if (isset($options['multipart'])) { + $options['body'] = new Psr7\MultipartStream($options['multipart']); + unset($options['multipart']); + } + + if (isset($options['json'])) { + $options['body'] = Utils::jsonEncode($options['json']); + unset($options['json']); + // Ensure that we don't have the header in different case and set the new value. + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); + $options['_conditional']['Content-Type'] = 'application/json'; + } + + if (!empty($options['decode_content']) + && $options['decode_content'] !== true + ) { + // Ensure that we don't have the header in different case and set the new value. + $options['_conditional'] = Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']); + $modify['set_headers']['Accept-Encoding'] = $options['decode_content']; + } + + if (isset($options['body'])) { + if (\is_array($options['body'])) { + throw $this->invalidBody(); + } + $modify['body'] = Psr7\Utils::streamFor($options['body']); + unset($options['body']); + } + + if (!empty($options['auth']) && \is_array($options['auth'])) { + $value = $options['auth']; + $type = isset($value[2]) ? \strtolower($value[2]) : 'basic'; + switch ($type) { + case 'basic': + // Ensure that we don't have the header in different case and set the new value. + $modify['set_headers'] = Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']); + $modify['set_headers']['Authorization'] = 'Basic ' + .\base64_encode("$value[0]:$value[1]"); + break; + case 'digest': + // @todo: Do not rely on curl + $options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_DIGEST; + $options['curl'][\CURLOPT_USERPWD] = "$value[0]:$value[1]"; + break; + case 'ntlm': + $options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM; + $options['curl'][\CURLOPT_USERPWD] = "$value[0]:$value[1]"; + break; + } + } + + if (isset($options['query'])) { + $value = $options['query']; + if (\is_array($value)) { + $value = \http_build_query($value, '', '&', \PHP_QUERY_RFC3986); + } + if (!\is_string($value)) { + throw new InvalidArgumentException('query must be a string or array'); + } + $modify['query'] = $value; + unset($options['query']); + } + + // Ensure that sink is not an invalid value. + if (isset($options['sink'])) { + // TODO: Add more sink validation? + if (\is_bool($options['sink'])) { + throw new InvalidArgumentException('sink must not be a boolean'); + } + } + + if (isset($options['version'])) { + $modify['version'] = $options['version']; + } + + $request = Psr7\Utils::modifyRequest($request, $modify); + if ($request->getBody() instanceof Psr7\MultipartStream) { + // Use a multipart/form-data POST if a Content-Type is not set. + // Ensure that we don't have the header in different case and set the new value. + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); + $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' + .$request->getBody()->getBoundary(); + } + + // Merge in conditional headers if they are not present. + if (isset($options['_conditional'])) { + // Build up the changes so it's in a single clone of the message. + $modify = []; + foreach ($options['_conditional'] as $k => $v) { + if (!$request->hasHeader($k)) { + $modify['set_headers'][$k] = $v; + } + } + $request = Psr7\Utils::modifyRequest($request, $modify); + // Don't pass this internal value along to middleware/handlers. + unset($options['_conditional']); + } + + return $request; + } + + /** + * Return an InvalidArgumentException with pre-set message. + */ + private function invalidBody(): InvalidArgumentException + { + return new InvalidArgumentException('Passing in the "body" request ' + .'option as an array to send a request is not supported. ' + .'Please use the "form_params" request option to send a ' + .'application/x-www-form-urlencoded request, or the "multipart" ' + .'request option to send a multipart/form-data request.'); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/vendor/guzzlehttp/guzzle/src/ClientInterface.php new file mode 100644 index 0000000..6aaee61 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/ClientInterface.php @@ -0,0 +1,84 @@ +request('GET', $uri, $options); + } + + /** + * Create and send an HTTP HEAD request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + * + * @throws GuzzleException + */ + public function head($uri, array $options = []): ResponseInterface + { + return $this->request('HEAD', $uri, $options); + } + + /** + * Create and send an HTTP PUT request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + * + * @throws GuzzleException + */ + public function put($uri, array $options = []): ResponseInterface + { + return $this->request('PUT', $uri, $options); + } + + /** + * Create and send an HTTP POST request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + * + * @throws GuzzleException + */ + public function post($uri, array $options = []): ResponseInterface + { + return $this->request('POST', $uri, $options); + } + + /** + * Create and send an HTTP PATCH request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + * + * @throws GuzzleException + */ + public function patch($uri, array $options = []): ResponseInterface + { + return $this->request('PATCH', $uri, $options); + } + + /** + * Create and send an HTTP DELETE request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + * + * @throws GuzzleException + */ + public function delete($uri, array $options = []): ResponseInterface + { + return $this->request('DELETE', $uri, $options); + } + + /** + * Create and send an asynchronous HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string $method HTTP method + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + abstract public function requestAsync(string $method, $uri, array $options = []): PromiseInterface; + + /** + * Create and send an asynchronous HTTP GET request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + public function getAsync($uri, array $options = []): PromiseInterface + { + return $this->requestAsync('GET', $uri, $options); + } + + /** + * Create and send an asynchronous HTTP HEAD request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + public function headAsync($uri, array $options = []): PromiseInterface + { + return $this->requestAsync('HEAD', $uri, $options); + } + + /** + * Create and send an asynchronous HTTP PUT request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + public function putAsync($uri, array $options = []): PromiseInterface + { + return $this->requestAsync('PUT', $uri, $options); + } + + /** + * Create and send an asynchronous HTTP POST request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + public function postAsync($uri, array $options = []): PromiseInterface + { + return $this->requestAsync('POST', $uri, $options); + } + + /** + * Create and send an asynchronous HTTP PATCH request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + public function patchAsync($uri, array $options = []): PromiseInterface + { + return $this->requestAsync('PATCH', $uri, $options); + } + + /** + * Create and send an asynchronous HTTP DELETE request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. + */ + public function deleteAsync($uri, array $options = []): PromiseInterface + { + return $this->requestAsync('DELETE', $uri, $options); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php new file mode 100644 index 0000000..b616cf2 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php @@ -0,0 +1,307 @@ +strictMode = $strictMode; + + foreach ($cookieArray as $cookie) { + if (!($cookie instanceof SetCookie)) { + $cookie = new SetCookie($cookie); + } + $this->setCookie($cookie); + } + } + + /** + * Create a new Cookie jar from an associative array and domain. + * + * @param array $cookies Cookies to create the jar from + * @param string $domain Domain to set the cookies to + */ + public static function fromArray(array $cookies, string $domain): self + { + $cookieJar = new self(); + foreach ($cookies as $name => $value) { + $cookieJar->setCookie(new SetCookie([ + 'Domain' => $domain, + 'Name' => $name, + 'Value' => $value, + 'Discard' => true, + ])); + } + + return $cookieJar; + } + + /** + * Evaluate if this cookie should be persisted to storage + * that survives between requests. + * + * @param SetCookie $cookie Being evaluated. + * @param bool $allowSessionCookies If we should persist session cookies + */ + public static function shouldPersist(SetCookie $cookie, bool $allowSessionCookies = false): bool + { + if ($cookie->getExpires() || $allowSessionCookies) { + if (!$cookie->getDiscard()) { + return true; + } + } + + return false; + } + + /** + * Finds and returns the cookie based on the name + * + * @param string $name cookie name to search for + * + * @return SetCookie|null cookie that was found or null if not found + */ + public function getCookieByName(string $name): ?SetCookie + { + foreach ($this->cookies as $cookie) { + if ($cookie->getName() !== null && \strcasecmp($cookie->getName(), $name) === 0) { + return $cookie; + } + } + + return null; + } + + public function toArray(): array + { + return \array_map(static function (SetCookie $cookie): array { + return $cookie->toArray(); + }, $this->getIterator()->getArrayCopy()); + } + + public function clear(?string $domain = null, ?string $path = null, ?string $name = null): void + { + if (!$domain) { + $this->cookies = []; + + return; + } elseif (!$path) { + $this->cookies = \array_filter( + $this->cookies, + static function (SetCookie $cookie) use ($domain): bool { + return !$cookie->matchesDomain($domain); + } + ); + } elseif (!$name) { + $this->cookies = \array_filter( + $this->cookies, + static function (SetCookie $cookie) use ($path, $domain): bool { + return !($cookie->matchesPath($path) + && $cookie->matchesDomain($domain)); + } + ); + } else { + $this->cookies = \array_filter( + $this->cookies, + static function (SetCookie $cookie) use ($path, $domain, $name) { + return !($cookie->getName() == $name + && $cookie->matchesPath($path) + && $cookie->matchesDomain($domain)); + } + ); + } + } + + public function clearSessionCookies(): void + { + $this->cookies = \array_filter( + $this->cookies, + static function (SetCookie $cookie): bool { + return !$cookie->getDiscard() && $cookie->getExpires(); + } + ); + } + + public function setCookie(SetCookie $cookie): bool + { + // If the name string is empty (but not 0), ignore the set-cookie + // string entirely. + $name = $cookie->getName(); + if (!$name && $name !== '0') { + return false; + } + + // Only allow cookies with set and valid domain, name, value + $result = $cookie->validate(); + if ($result !== true) { + if ($this->strictMode) { + throw new \RuntimeException('Invalid cookie: '.$result); + } + $this->removeCookieIfEmpty($cookie); + + return false; + } + + // Resolve conflicts with previously set cookies + foreach ($this->cookies as $i => $c) { + // Two cookies are identical, when their path, and domain are + // identical. + if ($c->getPath() != $cookie->getPath() + || $c->getDomain() != $cookie->getDomain() + || $c->getName() != $cookie->getName() + ) { + continue; + } + + // The previously set cookie is a discard cookie and this one is + // not so allow the new cookie to be set + if (!$cookie->getDiscard() && $c->getDiscard()) { + unset($this->cookies[$i]); + continue; + } + + // If the new cookie's expiration is further into the future, then + // replace the old cookie + if ($cookie->getExpires() > $c->getExpires()) { + unset($this->cookies[$i]); + continue; + } + + // If the value has changed, we better change it + if ($cookie->getValue() !== $c->getValue()) { + unset($this->cookies[$i]); + continue; + } + + // The cookie exists, so no need to continue + return false; + } + + $this->cookies[] = $cookie; + + return true; + } + + public function count(): int + { + return \count($this->cookies); + } + + /** + * @return \ArrayIterator + */ + public function getIterator(): \ArrayIterator + { + return new \ArrayIterator(\array_values($this->cookies)); + } + + public function extractCookies(RequestInterface $request, ResponseInterface $response): void + { + if ($cookieHeader = $response->getHeader('Set-Cookie')) { + foreach ($cookieHeader as $cookie) { + $sc = SetCookie::fromString($cookie); + if (!$sc->getDomain()) { + $sc->setDomain($request->getUri()->getHost()); + } + if (0 !== \strpos($sc->getPath(), '/')) { + $sc->setPath($this->getCookiePathFromRequest($request)); + } + if (!$sc->matchesDomain($request->getUri()->getHost())) { + continue; + } + // Note: At this point `$sc->getDomain()` being a public suffix should + // be rejected, but we don't want to pull in the full PSL dependency. + $this->setCookie($sc); + } + } + } + + /** + * Computes cookie path following RFC 6265 section 5.1.4 + * + * @see https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4 + */ + private function getCookiePathFromRequest(RequestInterface $request): string + { + $uriPath = $request->getUri()->getPath(); + if ('' === $uriPath) { + return '/'; + } + if (0 !== \strpos($uriPath, '/')) { + return '/'; + } + if ('/' === $uriPath) { + return '/'; + } + $lastSlashPos = \strrpos($uriPath, '/'); + if (0 === $lastSlashPos || false === $lastSlashPos) { + return '/'; + } + + return \substr($uriPath, 0, $lastSlashPos); + } + + public function withCookieHeader(RequestInterface $request): RequestInterface + { + $values = []; + $uri = $request->getUri(); + $scheme = $uri->getScheme(); + $host = $uri->getHost(); + $path = $uri->getPath() ?: '/'; + + foreach ($this->cookies as $cookie) { + if ($cookie->matchesPath($path) + && $cookie->matchesDomain($host) + && !$cookie->isExpired() + && (!$cookie->getSecure() || $scheme === 'https') + ) { + $values[] = $cookie->getName().'=' + .$cookie->getValue(); + } + } + + return $values + ? $request->withHeader('Cookie', \implode('; ', $values)) + : $request; + } + + /** + * If a cookie already exists and the server asks to set it again with a + * null value, the cookie must be deleted. + */ + private function removeCookieIfEmpty(SetCookie $cookie): void + { + $cookieValue = $cookie->getValue(); + if ($cookieValue === null || $cookieValue === '') { + $this->clear( + $cookie->getDomain(), + $cookie->getPath(), + $cookie->getName() + ); + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php new file mode 100644 index 0000000..93ada58 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php @@ -0,0 +1,80 @@ + + */ +interface CookieJarInterface extends \Countable, \IteratorAggregate +{ + /** + * Create a request with added cookie headers. + * + * If no matching cookies are found in the cookie jar, then no Cookie + * header is added to the request and the same request is returned. + * + * @param RequestInterface $request Request object to modify. + * + * @return RequestInterface returns the modified request. + */ + public function withCookieHeader(RequestInterface $request): RequestInterface; + + /** + * Extract cookies from an HTTP response and store them in the CookieJar. + * + * @param RequestInterface $request Request that was sent + * @param ResponseInterface $response Response that was received + */ + public function extractCookies(RequestInterface $request, ResponseInterface $response): void; + + /** + * Sets a cookie in the cookie jar. + * + * @param SetCookie $cookie Cookie to set. + * + * @return bool Returns true on success or false on failure + */ + public function setCookie(SetCookie $cookie): bool; + + /** + * Remove cookies currently held in the cookie jar. + * + * Invoking this method without arguments will empty the whole cookie jar. + * If given a $domain argument only cookies belonging to that domain will + * be removed. If given a $domain and $path argument, cookies belonging to + * the specified path within that domain are removed. If given all three + * arguments, then the cookie with the specified name, path and domain is + * removed. + * + * @param string|null $domain Clears cookies matching a domain + * @param string|null $path Clears cookies matching a domain and path + * @param string|null $name Clears cookies matching a domain, path, and name + */ + public function clear(?string $domain = null, ?string $path = null, ?string $name = null): void; + + /** + * Discard all sessions cookies. + * + * Removes cookies that don't have an expire field or a have a discard + * field set to true. To be called when the user agent shuts down according + * to RFC 2965. + */ + public function clearSessionCookies(): void; + + /** + * Converts the cookie jar to an array. + */ + public function toArray(): array; +} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php new file mode 100644 index 0000000..290236d --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php @@ -0,0 +1,101 @@ +filename = $cookieFile; + $this->storeSessionCookies = $storeSessionCookies; + + if (\file_exists($cookieFile)) { + $this->load($cookieFile); + } + } + + /** + * Saves the file when shutting down + */ + public function __destruct() + { + $this->save($this->filename); + } + + /** + * Saves the cookies to a file. + * + * @param string $filename File to save + * + * @throws \RuntimeException if the file cannot be found or created + */ + public function save(string $filename): void + { + $json = []; + /** @var SetCookie $cookie */ + foreach ($this as $cookie) { + if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { + $json[] = $cookie->toArray(); + } + } + + $jsonStr = Utils::jsonEncode($json); + if (false === \file_put_contents($filename, $jsonStr, \LOCK_EX)) { + throw new \RuntimeException("Unable to save file {$filename}"); + } + } + + /** + * Load cookies from a JSON formatted file. + * + * Old cookies are kept unless overwritten by newly loaded ones. + * + * @param string $filename Cookie file to load. + * + * @throws \RuntimeException if the file cannot be loaded. + */ + public function load(string $filename): void + { + $json = \file_get_contents($filename); + if (false === $json) { + throw new \RuntimeException("Unable to load file {$filename}"); + } + if ($json === '') { + return; + } + + $data = Utils::jsonDecode($json, true); + if (\is_array($data)) { + foreach ($data as $cookie) { + $this->setCookie(new SetCookie($cookie)); + } + } elseif (\is_scalar($data) && !empty($data)) { + throw new \RuntimeException("Invalid cookie file: {$filename}"); + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php new file mode 100644 index 0000000..cb3e67c --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php @@ -0,0 +1,77 @@ +sessionKey = $sessionKey; + $this->storeSessionCookies = $storeSessionCookies; + $this->load(); + } + + /** + * Saves cookies to session when shutting down + */ + public function __destruct() + { + $this->save(); + } + + /** + * Save cookies to the client session + */ + public function save(): void + { + $json = []; + /** @var SetCookie $cookie */ + foreach ($this as $cookie) { + if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { + $json[] = $cookie->toArray(); + } + } + + $_SESSION[$this->sessionKey] = \json_encode($json); + } + + /** + * Load the contents of the client session into the data array + */ + protected function load(): void + { + if (!isset($_SESSION[$this->sessionKey])) { + return; + } + $data = \json_decode($_SESSION[$this->sessionKey], true); + if (\is_array($data)) { + foreach ($data as $cookie) { + $this->setCookie(new SetCookie($cookie)); + } + } elseif (\strlen($data)) { + throw new \RuntimeException('Invalid cookie data'); + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php new file mode 100644 index 0000000..47c4d10 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php @@ -0,0 +1,492 @@ + null, + 'Value' => null, + 'Domain' => null, + 'Path' => '/', + 'Max-Age' => null, + 'Expires' => null, + 'Secure' => false, + 'Discard' => false, + 'HttpOnly' => false, + ]; + + /** + * @var array Cookie data + */ + private $data; + + /** + * Create a new SetCookie object from a string. + * + * @param string $cookie Set-Cookie header string + */ + public static function fromString(string $cookie): self + { + // Create the default return array + $data = self::$defaults; + // Explode the cookie string using a series of semicolons + $pieces = \array_filter(\array_map('trim', \explode(';', $cookie))); + // The name of the cookie (first kvp) must exist and include an equal sign. + if (!isset($pieces[0]) || \strpos($pieces[0], '=') === false) { + return new self($data); + } + + // Add the cookie pieces into the parsed data array + foreach ($pieces as $part) { + $cookieParts = \explode('=', $part, 2); + $key = \trim($cookieParts[0]); + $value = isset($cookieParts[1]) + ? \trim($cookieParts[1], " \n\r\t\0\x0B") + : true; + + // Only check for non-cookies when cookies have been found + if (!isset($data['Name'])) { + $data['Name'] = $key; + $data['Value'] = $value; + } else { + foreach (\array_keys(self::$defaults) as $search) { + if (!\strcasecmp($search, $key)) { + if ($search === 'Max-Age') { + if (is_numeric($value)) { + $data[$search] = (int) $value; + } + } elseif ($search === 'Secure' || $search === 'Discard' || $search === 'HttpOnly') { + if ($value) { + $data[$search] = true; + } + } else { + $data[$search] = $value; + } + continue 2; + } + } + $data[$key] = $value; + } + } + + return new self($data); + } + + /** + * @param array $data Array of cookie data provided by a Cookie parser + */ + public function __construct(array $data = []) + { + $this->data = self::$defaults; + + if (isset($data['Name'])) { + $this->setName($data['Name']); + } + + if (isset($data['Value'])) { + $this->setValue($data['Value']); + } + + if (isset($data['Domain'])) { + $this->setDomain($data['Domain']); + } + + if (isset($data['Path'])) { + $this->setPath($data['Path']); + } + + if (isset($data['Max-Age'])) { + $this->setMaxAge($data['Max-Age']); + } + + if (isset($data['Expires'])) { + $this->setExpires($data['Expires']); + } + + if (isset($data['Secure'])) { + $this->setSecure($data['Secure']); + } + + if (isset($data['Discard'])) { + $this->setDiscard($data['Discard']); + } + + if (isset($data['HttpOnly'])) { + $this->setHttpOnly($data['HttpOnly']); + } + + // Set the remaining values that don't have extra validation logic + foreach (array_diff(array_keys($data), array_keys(self::$defaults)) as $key) { + $this->data[$key] = $data[$key]; + } + + // Extract the Expires value and turn it into a UNIX timestamp if needed + if (!$this->getExpires() && $this->getMaxAge()) { + // Calculate the Expires date + $this->setExpires(\time() + $this->getMaxAge()); + } elseif (null !== ($expires = $this->getExpires()) && !\is_numeric($expires)) { + $this->setExpires($expires); + } + } + + public function __toString() + { + $str = $this->data['Name'].'='.($this->data['Value'] ?? '').'; '; + foreach ($this->data as $k => $v) { + if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) { + if ($k === 'Expires') { + $str .= 'Expires='.\gmdate('D, d M Y H:i:s \G\M\T', $v).'; '; + } else { + $str .= ($v === true ? $k : "{$k}={$v}").'; '; + } + } + } + + return \rtrim($str, '; '); + } + + public function toArray(): array + { + return $this->data; + } + + /** + * Get the cookie name. + * + * @return string + */ + public function getName() + { + return $this->data['Name']; + } + + /** + * Set the cookie name. + * + * @param string $name Cookie name + */ + public function setName($name): void + { + if (!is_string($name)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Name'] = (string) $name; + } + + /** + * Get the cookie value. + * + * @return string|null + */ + public function getValue() + { + return $this->data['Value']; + } + + /** + * Set the cookie value. + * + * @param string $value Cookie value + */ + public function setValue($value): void + { + if (!is_string($value)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Value'] = (string) $value; + } + + /** + * Get the domain. + * + * @return string|null + */ + public function getDomain() + { + return $this->data['Domain']; + } + + /** + * Set the domain of the cookie. + * + * @param string|null $domain + */ + public function setDomain($domain): void + { + if (!is_string($domain) && null !== $domain) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Domain'] = null === $domain ? null : (string) $domain; + } + + /** + * Get the path. + * + * @return string + */ + public function getPath() + { + return $this->data['Path']; + } + + /** + * Set the path of the cookie. + * + * @param string $path Path of the cookie + */ + public function setPath($path): void + { + if (!is_string($path)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Path'] = (string) $path; + } + + /** + * Maximum lifetime of the cookie in seconds. + * + * @return int|null + */ + public function getMaxAge() + { + return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age']; + } + + /** + * Set the max-age of the cookie. + * + * @param int|null $maxAge Max age of the cookie in seconds + */ + public function setMaxAge($maxAge): void + { + if (!is_int($maxAge) && null !== $maxAge) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Max-Age'] = $maxAge === null ? null : (int) $maxAge; + } + + /** + * The UNIX timestamp when the cookie Expires. + * + * @return string|int|null + */ + public function getExpires() + { + return $this->data['Expires']; + } + + /** + * Set the unix timestamp for which the cookie will expire. + * + * @param int|string|null $timestamp Unix timestamp or any English textual datetime description. + */ + public function setExpires($timestamp): void + { + if (!is_int($timestamp) && !is_string($timestamp) && null !== $timestamp) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int, string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Expires'] = null === $timestamp ? null : (\is_numeric($timestamp) ? (int) $timestamp : \strtotime((string) $timestamp)); + } + + /** + * Get whether or not this is a secure cookie. + * + * @return bool + */ + public function getSecure() + { + return $this->data['Secure']; + } + + /** + * Set whether or not the cookie is secure. + * + * @param bool $secure Set to true or false if secure + */ + public function setSecure($secure): void + { + if (!is_bool($secure)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Secure'] = (bool) $secure; + } + + /** + * Get whether or not this is a session cookie. + * + * @return bool|null + */ + public function getDiscard() + { + return $this->data['Discard']; + } + + /** + * Set whether or not this is a session cookie. + * + * @param bool $discard Set to true or false if this is a session cookie + */ + public function setDiscard($discard): void + { + if (!is_bool($discard)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Discard'] = (bool) $discard; + } + + /** + * Get whether or not this is an HTTP only cookie. + * + * @return bool + */ + public function getHttpOnly() + { + return $this->data['HttpOnly']; + } + + /** + * Set whether or not this is an HTTP only cookie. + * + * @param bool $httpOnly Set to true or false if this is HTTP only + */ + public function setHttpOnly($httpOnly): void + { + if (!is_bool($httpOnly)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['HttpOnly'] = (bool) $httpOnly; + } + + /** + * Check if the cookie matches a path value. + * + * A request-path path-matches a given cookie-path if at least one of + * the following conditions holds: + * + * - The cookie-path and the request-path are identical. + * - The cookie-path is a prefix of the request-path, and the last + * character of the cookie-path is %x2F ("/"). + * - The cookie-path is a prefix of the request-path, and the first + * character of the request-path that is not included in the cookie- + * path is a %x2F ("/") character. + * + * @param string $requestPath Path to check against + */ + public function matchesPath(string $requestPath): bool + { + $cookiePath = $this->getPath(); + + // Match on exact matches or when path is the default empty "/" + if ($cookiePath === '/' || $cookiePath == $requestPath) { + return true; + } + + // Ensure that the cookie-path is a prefix of the request path. + if (0 !== \strpos($requestPath, $cookiePath)) { + return false; + } + + // Match if the last character of the cookie-path is "/" + if (\substr($cookiePath, -1, 1) === '/') { + return true; + } + + // Match if the first character not included in cookie path is "/" + return \substr($requestPath, \strlen($cookiePath), 1) === '/'; + } + + /** + * Check if the cookie matches a domain value. + * + * @param string $domain Domain to check against + */ + public function matchesDomain(string $domain): bool + { + $cookieDomain = $this->getDomain(); + if (null === $cookieDomain) { + return true; + } + + // Remove the leading '.' as per spec in RFC 6265. + // https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3 + $cookieDomain = \ltrim(\strtolower($cookieDomain), '.'); + + $domain = \strtolower($domain); + + // Domain not set or exact match. + if ('' === $cookieDomain || $domain === $cookieDomain) { + return true; + } + + // Matching the subdomain according to RFC 6265. + // https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.3 + if (\filter_var($domain, \FILTER_VALIDATE_IP)) { + return false; + } + + return (bool) \preg_match('/\.'.\preg_quote($cookieDomain, '/').'$/', $domain); + } + + /** + * Check if the cookie is expired. + */ + public function isExpired(): bool + { + return $this->getExpires() !== null && \time() > $this->getExpires(); + } + + /** + * Check if the cookie is valid according to RFC 6265. + * + * @return bool|string Returns true if valid or an error message if invalid + */ + public function validate() + { + $name = $this->getName(); + if ($name === '') { + return 'The cookie name must not be empty'; + } + + // Check if any of the invalid characters are present in the cookie name + if (\preg_match( + '/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/', + $name + )) { + return 'Cookie name must not contain invalid characters: ASCII ' + .'Control characters (0-31;127), space, tab and the ' + .'following characters: ()<>@,;:\"/?={}'; + } + + // Value must not be null. 0 and empty string are valid. Empty strings + // are technically against RFC 6265, but known to happen in the wild. + $value = $this->getValue(); + if ($value === null) { + return 'The cookie value must not be empty'; + } + + // Domains must not be empty, but can be 0. "0" is not a valid internet + // domain, but may be used as server name in a private network. + $domain = $this->getDomain(); + if ($domain === null || $domain === '') { + return 'The cookie domain must not be empty'; + } + + return true; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php b/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php new file mode 100644 index 0000000..ba67ad4 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php @@ -0,0 +1,39 @@ +request = $request; + $this->handlerContext = $handlerContext; + } + + /** + * Get the request that caused the exception + */ + public function getRequest(): RequestInterface + { + return $this->request; + } + + /** + * Get contextual information about the error from the underlying handler. + * + * The contents of this array will vary depending on which handler you are + * using. It may also be just an empty array. Relying on this data will + * couple you to a specific handler, but can give more debug information + * when needed. + */ + public function getHandlerContext(): array + { + return $this->handlerContext; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php b/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php new file mode 100644 index 0000000..fa3ed69 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php @@ -0,0 +1,9 @@ +getStatusCode() : 0; + parent::__construct($message, $code, $previous); + $this->request = $request; + $this->response = $response; + $this->handlerContext = $handlerContext; + } + + /** + * Wrap non-RequestExceptions with a RequestException + */ + public static function wrapException(RequestInterface $request, \Throwable $e): RequestException + { + return $e instanceof RequestException ? $e : new RequestException($e->getMessage(), $request, null, $e); + } + + /** + * Factory method to create a new exception with a normalized error message + * + * @param RequestInterface $request Request sent + * @param ResponseInterface $response Response received + * @param \Throwable|null $previous Previous exception + * @param array $handlerContext Optional handler context + * @param BodySummarizerInterface|null $bodySummarizer Optional body summarizer + */ + public static function create( + RequestInterface $request, + ?ResponseInterface $response = null, + ?\Throwable $previous = null, + array $handlerContext = [], + ?BodySummarizerInterface $bodySummarizer = null + ): self { + if (!$response) { + return new self( + 'Error completing request', + $request, + null, + $previous, + $handlerContext + ); + } + + $level = (int) \floor($response->getStatusCode() / 100); + if ($level === 4) { + $label = 'Client error'; + $className = ClientException::class; + } elseif ($level === 5) { + $label = 'Server error'; + $className = ServerException::class; + } else { + $label = 'Unsuccessful request'; + $className = __CLASS__; + } + + $uri = \GuzzleHttp\Psr7\Utils::redactUserInfo($request->getUri()); + + // Client Error: `GET /` resulted in a `404 Not Found` response: + // ... (truncated) + $message = \sprintf( + '%s: `%s %s` resulted in a `%s %s` response', + $label, + $request->getMethod(), + $uri->__toString(), + $response->getStatusCode(), + $response->getReasonPhrase() + ); + + $summary = ($bodySummarizer ?? new BodySummarizer())->summarize($response); + + if ($summary !== null) { + $message .= ":\n{$summary}\n"; + } + + return new $className($message, $request, $response, $previous, $handlerContext); + } + + /** + * Get the request that caused the exception + */ + public function getRequest(): RequestInterface + { + return $this->request; + } + + /** + * Get the associated response + */ + public function getResponse(): ?ResponseInterface + { + return $this->response; + } + + /** + * Check if a response was received + */ + public function hasResponse(): bool + { + return $this->response !== null; + } + + /** + * Get contextual information about the error from the underlying handler. + * + * The contents of this array will vary depending on which handler you are + * using. It may also be just an empty array. Relying on this data will + * couple you to a specific handler, but can give more debug information + * when needed. + */ + public function getHandlerContext(): array + { + return $this->handlerContext; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php b/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php new file mode 100644 index 0000000..8055e06 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php @@ -0,0 +1,10 @@ +maxHandles = $maxHandles; + } + + public function create(RequestInterface $request, array $options): EasyHandle + { + $protocolVersion = $request->getProtocolVersion(); + + if ('2' === $protocolVersion || '2.0' === $protocolVersion) { + if (!self::supportsHttp2()) { + throw new ConnectException('HTTP/2 is supported by the cURL handler, however libcurl is built without HTTP/2 support.', $request); + } + } elseif ('1.0' !== $protocolVersion && '1.1' !== $protocolVersion) { + throw new ConnectException(sprintf('HTTP/%s is not supported by the cURL handler.', $protocolVersion), $request); + } + + if (isset($options['curl']['body_as_string'])) { + $options['_body_as_string'] = $options['curl']['body_as_string']; + unset($options['curl']['body_as_string']); + } + + $easy = new EasyHandle(); + $easy->request = $request; + $easy->options = $options; + $conf = $this->getDefaultConf($easy); + $this->applyMethod($easy, $conf); + $this->applyHandlerOptions($easy, $conf); + $this->applyHeaders($easy, $conf); + unset($conf['_headers']); + + // Add handler options from the request configuration options + if (isset($options['curl'])) { + $conf = \array_replace($conf, $options['curl']); + } + + $conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy); + $easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init(); + curl_setopt_array($easy->handle, $conf); + + return $easy; + } + + private static function supportsHttp2(): bool + { + static $supportsHttp2 = null; + + if (null === $supportsHttp2) { + $supportsHttp2 = self::supportsTls12() + && defined('CURL_VERSION_HTTP2') + && (\CURL_VERSION_HTTP2 & \curl_version()['features']); + } + + return $supportsHttp2; + } + + private static function supportsTls12(): bool + { + static $supportsTls12 = null; + + if (null === $supportsTls12) { + $supportsTls12 = \CURL_SSLVERSION_TLSv1_2 & \curl_version()['features']; + } + + return $supportsTls12; + } + + private static function supportsTls13(): bool + { + static $supportsTls13 = null; + + if (null === $supportsTls13) { + $supportsTls13 = defined('CURL_SSLVERSION_TLSv1_3') + && (\CURL_SSLVERSION_TLSv1_3 & \curl_version()['features']); + } + + return $supportsTls13; + } + + public function release(EasyHandle $easy): void + { + $resource = $easy->handle; + unset($easy->handle); + + if (\count($this->handles) >= $this->maxHandles) { + \curl_close($resource); + } else { + // Remove all callback functions as they can hold onto references + // and are not cleaned up by curl_reset. Using curl_setopt_array + // does not work for some reason, so removing each one + // individually. + \curl_setopt($resource, \CURLOPT_HEADERFUNCTION, null); + \curl_setopt($resource, \CURLOPT_READFUNCTION, null); + \curl_setopt($resource, \CURLOPT_WRITEFUNCTION, null); + \curl_setopt($resource, \CURLOPT_PROGRESSFUNCTION, null); + \curl_reset($resource); + $this->handles[] = $resource; + } + } + + /** + * Completes a cURL transaction, either returning a response promise or a + * rejected promise. + * + * @param callable(RequestInterface, array): PromiseInterface $handler + * @param CurlFactoryInterface $factory Dictates how the handle is released + */ + public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface + { + if (isset($easy->options['on_stats'])) { + self::invokeStats($easy); + } + + if (!$easy->response || $easy->errno) { + return self::finishError($handler, $easy, $factory); + } + + // Return the response if it is present and there is no error. + $factory->release($easy); + + // Rewind the body of the response if possible. + $body = $easy->response->getBody(); + if ($body->isSeekable()) { + $body->rewind(); + } + + return new FulfilledPromise($easy->response); + } + + private static function invokeStats(EasyHandle $easy): void + { + $curlStats = \curl_getinfo($easy->handle); + $curlStats['appconnect_time'] = \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME); + $stats = new TransferStats( + $easy->request, + $easy->response, + $curlStats['total_time'], + $easy->errno, + $curlStats + ); + ($easy->options['on_stats'])($stats); + } + + /** + * @param callable(RequestInterface, array): PromiseInterface $handler + */ + private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface + { + // Get error information and release the handle to the factory. + $ctx = [ + 'errno' => $easy->errno, + 'error' => \curl_error($easy->handle), + 'appconnect_time' => \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME), + ] + \curl_getinfo($easy->handle); + $ctx[self::CURL_VERSION_STR] = self::getCurlVersion(); + $factory->release($easy); + + // Retry when nothing is present or when curl failed to rewind. + if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) { + return self::retryFailedRewind($handler, $easy, $ctx); + } + + return self::createRejection($easy, $ctx); + } + + private static function getCurlVersion(): string + { + static $curlVersion = null; + + if (null === $curlVersion) { + $curlVersion = \curl_version()['version']; + } + + return $curlVersion; + } + + private static function createRejection(EasyHandle $easy, array $ctx): PromiseInterface + { + static $connectionErrors = [ + \CURLE_OPERATION_TIMEOUTED => true, + \CURLE_COULDNT_RESOLVE_HOST => true, + \CURLE_COULDNT_CONNECT => true, + \CURLE_SSL_CONNECT_ERROR => true, + \CURLE_GOT_NOTHING => true, + ]; + + if ($easy->createResponseException) { + return P\Create::rejectionFor( + new RequestException( + 'An error was encountered while creating the response', + $easy->request, + $easy->response, + $easy->createResponseException, + $ctx + ) + ); + } + + // If an exception was encountered during the onHeaders event, then + // return a rejected promise that wraps that exception. + if ($easy->onHeadersException) { + return P\Create::rejectionFor( + new RequestException( + 'An error was encountered during the on_headers event', + $easy->request, + $easy->response, + $easy->onHeadersException, + $ctx + ) + ); + } + + $uri = $easy->request->getUri(); + + $sanitizedError = self::sanitizeCurlError($ctx['error'] ?? '', $uri); + + $message = \sprintf( + 'cURL error %s: %s (%s)', + $ctx['errno'], + $sanitizedError, + 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html' + ); + + if ('' !== $sanitizedError) { + $redactedUriString = \GuzzleHttp\Psr7\Utils::redactUserInfo($uri)->__toString(); + if ($redactedUriString !== '' && false === \strpos($sanitizedError, $redactedUriString)) { + $message .= \sprintf(' for %s', $redactedUriString); + } + } + + // Create a connection exception if it was a specific error code. + $error = isset($connectionErrors[$easy->errno]) + ? new ConnectException($message, $easy->request, null, $ctx) + : new RequestException($message, $easy->request, $easy->response, null, $ctx); + + return P\Create::rejectionFor($error); + } + + private static function sanitizeCurlError(string $error, UriInterface $uri): string + { + if ('' === $error) { + return $error; + } + + $baseUri = $uri->withQuery('')->withFragment(''); + $baseUriString = $baseUri->__toString(); + + if ('' === $baseUriString) { + return $error; + } + + $redactedUriString = \GuzzleHttp\Psr7\Utils::redactUserInfo($baseUri)->__toString(); + + return str_replace($baseUriString, $redactedUriString, $error); + } + + /** + * @return array + */ + private function getDefaultConf(EasyHandle $easy): array + { + $conf = [ + '_headers' => $easy->request->getHeaders(), + \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), + \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), + \CURLOPT_RETURNTRANSFER => false, + \CURLOPT_HEADER => false, + \CURLOPT_CONNECTTIMEOUT => 300, + ]; + + if (\defined('CURLOPT_PROTOCOLS')) { + $conf[\CURLOPT_PROTOCOLS] = \CURLPROTO_HTTP | \CURLPROTO_HTTPS; + } + + $version = $easy->request->getProtocolVersion(); + + if ('2' === $version || '2.0' === $version) { + $conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_2_0; + } elseif ('1.1' === $version) { + $conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_1; + } else { + $conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_0; + } + + return $conf; + } + + private function applyMethod(EasyHandle $easy, array &$conf): void + { + $body = $easy->request->getBody(); + $size = $body->getSize(); + + if ($size === null || $size > 0) { + $this->applyBody($easy->request, $easy->options, $conf); + + return; + } + + $method = $easy->request->getMethod(); + if ($method === 'PUT' || $method === 'POST') { + // See https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2 + if (!$easy->request->hasHeader('Content-Length')) { + $conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0'; + } + } elseif ($method === 'HEAD') { + $conf[\CURLOPT_NOBODY] = true; + unset( + $conf[\CURLOPT_WRITEFUNCTION], + $conf[\CURLOPT_READFUNCTION], + $conf[\CURLOPT_FILE], + $conf[\CURLOPT_INFILE] + ); + } + } + + private function applyBody(RequestInterface $request, array $options, array &$conf): void + { + $size = $request->hasHeader('Content-Length') + ? (int) $request->getHeaderLine('Content-Length') + : null; + + // Send the body as a string if the size is less than 1MB OR if the + // [curl][body_as_string] request value is set. + if (($size !== null && $size < 1000000) || !empty($options['_body_as_string'])) { + $conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody(); + // Don't duplicate the Content-Length header + $this->removeHeader('Content-Length', $conf); + $this->removeHeader('Transfer-Encoding', $conf); + } else { + $conf[\CURLOPT_UPLOAD] = true; + if ($size !== null) { + $conf[\CURLOPT_INFILESIZE] = $size; + $this->removeHeader('Content-Length', $conf); + } + $body = $request->getBody(); + if ($body->isSeekable()) { + $body->rewind(); + } + $conf[\CURLOPT_READFUNCTION] = static function ($ch, $fd, $length) use ($body) { + return $body->read($length); + }; + } + + // If the Expect header is not present, prevent curl from adding it + if (!$request->hasHeader('Expect')) { + $conf[\CURLOPT_HTTPHEADER][] = 'Expect:'; + } + + // cURL sometimes adds a content-type by default. Prevent this. + if (!$request->hasHeader('Content-Type')) { + $conf[\CURLOPT_HTTPHEADER][] = 'Content-Type:'; + } + } + + private function applyHeaders(EasyHandle $easy, array &$conf): void + { + foreach ($conf['_headers'] as $name => $values) { + foreach ($values as $value) { + $value = (string) $value; + if ($value === '') { + // cURL requires a special format for empty headers. + // See https://github.com/guzzle/guzzle/issues/1882 for more details. + $conf[\CURLOPT_HTTPHEADER][] = "$name;"; + } else { + $conf[\CURLOPT_HTTPHEADER][] = "$name: $value"; + } + } + } + + // Remove the Accept header if one was not set + if (!$easy->request->hasHeader('Accept')) { + $conf[\CURLOPT_HTTPHEADER][] = 'Accept:'; + } + } + + /** + * Remove a header from the options array. + * + * @param string $name Case-insensitive header to remove + * @param array $options Array of options to modify + */ + private function removeHeader(string $name, array &$options): void + { + foreach (\array_keys($options['_headers']) as $key) { + if (!\strcasecmp($key, $name)) { + unset($options['_headers'][$key]); + + return; + } + } + } + + private function applyHandlerOptions(EasyHandle $easy, array &$conf): void + { + $options = $easy->options; + if (isset($options['verify'])) { + if ($options['verify'] === false) { + unset($conf[\CURLOPT_CAINFO]); + $conf[\CURLOPT_SSL_VERIFYHOST] = 0; + $conf[\CURLOPT_SSL_VERIFYPEER] = false; + } else { + $conf[\CURLOPT_SSL_VERIFYHOST] = 2; + $conf[\CURLOPT_SSL_VERIFYPEER] = true; + if (\is_string($options['verify'])) { + // Throw an error if the file/folder/link path is not valid or doesn't exist. + if (!\file_exists($options['verify'])) { + throw new \InvalidArgumentException("SSL CA bundle not found: {$options['verify']}"); + } + // If it's a directory or a link to a directory use CURLOPT_CAPATH. + // If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO. + if ( + \is_dir($options['verify']) + || ( + \is_link($options['verify']) === true + && ($verifyLink = \readlink($options['verify'])) !== false + && \is_dir($verifyLink) + ) + ) { + $conf[\CURLOPT_CAPATH] = $options['verify']; + } else { + $conf[\CURLOPT_CAINFO] = $options['verify']; + } + } + } + } + + if (!isset($options['curl'][\CURLOPT_ENCODING]) && !empty($options['decode_content'])) { + $accept = $easy->request->getHeaderLine('Accept-Encoding'); + if ($accept) { + $conf[\CURLOPT_ENCODING] = $accept; + } else { + // The empty string enables all available decoders and implicitly + // sets a matching 'Accept-Encoding' header. + $conf[\CURLOPT_ENCODING] = ''; + // But as the user did not specify any encoding preference, + // let's leave it up to server by preventing curl from sending + // the header, which will be interpreted as 'Accept-Encoding: *'. + // https://www.rfc-editor.org/rfc/rfc9110#field.accept-encoding + $conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:'; + } + } + + if (!isset($options['sink'])) { + // Use a default temp stream if no sink was set. + $options['sink'] = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+'); + } + $sink = $options['sink']; + if (!\is_string($sink)) { + $sink = \GuzzleHttp\Psr7\Utils::streamFor($sink); + } elseif (!\is_dir(\dirname($sink))) { + // Ensure that the directory exists before failing in curl. + throw new \RuntimeException(\sprintf('Directory %s does not exist for sink value of %s', \dirname($sink), $sink)); + } else { + $sink = new LazyOpenStream($sink, 'w+'); + } + $easy->sink = $sink; + $conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int { + return $sink->write($write); + }; + + $timeoutRequiresNoSignal = false; + if (isset($options['timeout'])) { + $timeoutRequiresNoSignal |= $options['timeout'] < 1; + $conf[\CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000; + } + + // CURL default value is CURL_IPRESOLVE_WHATEVER + if (isset($options['force_ip_resolve'])) { + if ('v4' === $options['force_ip_resolve']) { + $conf[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V4; + } elseif ('v6' === $options['force_ip_resolve']) { + $conf[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V6; + } + } + + if (isset($options['connect_timeout'])) { + $timeoutRequiresNoSignal |= $options['connect_timeout'] < 1; + $conf[\CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000; + } + + if ($timeoutRequiresNoSignal && \strtoupper(\substr(\PHP_OS, 0, 3)) !== 'WIN') { + $conf[\CURLOPT_NOSIGNAL] = true; + } + + if (isset($options['proxy'])) { + if (!\is_array($options['proxy'])) { + $conf[\CURLOPT_PROXY] = $options['proxy']; + } else { + $scheme = $easy->request->getUri()->getScheme(); + if (isset($options['proxy'][$scheme])) { + $host = $easy->request->getUri()->getHost(); + if (isset($options['proxy']['no']) && Utils::isHostInNoProxy($host, $options['proxy']['no'])) { + unset($conf[\CURLOPT_PROXY]); + } else { + $conf[\CURLOPT_PROXY] = $options['proxy'][$scheme]; + } + } + } + } + + if (isset($options['crypto_method'])) { + $protocolVersion = $easy->request->getProtocolVersion(); + + // If HTTP/2, upgrade TLS 1.0 and 1.1 to 1.2 + if ('2' === $protocolVersion || '2.0' === $protocolVersion) { + if ( + \STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method'] + || \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method'] + || \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method'] + ) { + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2; + } elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) { + if (!self::supportsTls13()) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3; + } else { + throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided'); + } + } elseif (\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method']) { + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_0; + } elseif (\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method']) { + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_1; + } elseif (\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method']) { + if (!self::supportsTls12()) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.2 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2; + } elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) { + if (!self::supportsTls13()) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3; + } else { + throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided'); + } + } + + if (isset($options['cert'])) { + $cert = $options['cert']; + if (\is_array($cert)) { + $conf[\CURLOPT_SSLCERTPASSWD] = $cert[1]; + $cert = $cert[0]; + } + if (!\file_exists($cert)) { + throw new \InvalidArgumentException("SSL certificate not found: {$cert}"); + } + // OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files. + // see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html + $ext = pathinfo($cert, \PATHINFO_EXTENSION); + if (preg_match('#^(der|p12)$#i', $ext)) { + $conf[\CURLOPT_SSLCERTTYPE] = strtoupper($ext); + } + $conf[\CURLOPT_SSLCERT] = $cert; + } + + if (isset($options['ssl_key'])) { + if (\is_array($options['ssl_key'])) { + if (\count($options['ssl_key']) === 2) { + [$sslKey, $conf[\CURLOPT_SSLKEYPASSWD]] = $options['ssl_key']; + } else { + [$sslKey] = $options['ssl_key']; + } + } + + $sslKey = $sslKey ?? $options['ssl_key']; + + if (!\file_exists($sslKey)) { + throw new \InvalidArgumentException("SSL private key not found: {$sslKey}"); + } + $conf[\CURLOPT_SSLKEY] = $sslKey; + } + + if (isset($options['progress'])) { + $progress = $options['progress']; + if (!\is_callable($progress)) { + throw new \InvalidArgumentException('progress client option must be callable'); + } + $conf[\CURLOPT_NOPROGRESS] = false; + $conf[\CURLOPT_PROGRESSFUNCTION] = static function ($resource, int $downloadSize, int $downloaded, int $uploadSize, int $uploaded) use ($progress) { + $progress($downloadSize, $downloaded, $uploadSize, $uploaded); + }; + } + + if (!empty($options['debug'])) { + $conf[\CURLOPT_STDERR] = Utils::debugResource($options['debug']); + $conf[\CURLOPT_VERBOSE] = true; + } + } + + /** + * This function ensures that a response was set on a transaction. If one + * was not set, then the request is retried if possible. This error + * typically means you are sending a payload, curl encountered a + * "Connection died, retrying a fresh connect" error, tried to rewind the + * stream, and then encountered a "necessary data rewind wasn't possible" + * error, causing the request to be sent through curl_multi_info_read() + * without an error status. + * + * @param callable(RequestInterface, array): PromiseInterface $handler + */ + private static function retryFailedRewind(callable $handler, EasyHandle $easy, array $ctx): PromiseInterface + { + try { + // Only rewind if the body has been read from. + $body = $easy->request->getBody(); + if ($body->tell() > 0) { + $body->rewind(); + } + } catch (\RuntimeException $e) { + $ctx['error'] = 'The connection unexpectedly failed without ' + .'providing an error. The request would have been retried, ' + .'but attempting to rewind the request body failed. ' + .'Exception: '.$e; + + return self::createRejection($easy, $ctx); + } + + // Retry no more than 3 times before giving up. + if (!isset($easy->options['_curl_retries'])) { + $easy->options['_curl_retries'] = 1; + } elseif ($easy->options['_curl_retries'] == 2) { + $ctx['error'] = 'The cURL request was retried 3 times ' + .'and did not succeed. The most likely reason for the failure ' + .'is that cURL was unable to rewind the body of the request ' + .'and subsequent retries resulted in the same error. Turn on ' + .'the debug option to see what went wrong. See ' + .'https://bugs.php.net/bug.php?id=47204 for more information.'; + + return self::createRejection($easy, $ctx); + } else { + ++$easy->options['_curl_retries']; + } + + return $handler($easy->request, $easy->options); + } + + private function createHeaderFn(EasyHandle $easy): callable + { + if (isset($easy->options['on_headers'])) { + $onHeaders = $easy->options['on_headers']; + + if (!\is_callable($onHeaders)) { + throw new \InvalidArgumentException('on_headers must be callable'); + } + } else { + $onHeaders = null; + } + + return static function ($ch, $h) use ( + $onHeaders, + $easy, + &$startingResponse + ) { + $value = \trim($h); + if ($value === '') { + $startingResponse = true; + try { + $easy->createResponse(); + } catch (\Exception $e) { + $easy->createResponseException = $e; + + return -1; + } + if ($onHeaders !== null) { + try { + $onHeaders($easy->response); + } catch (\Exception $e) { + // Associate the exception with the handle and trigger + // a curl header write error by returning 0. + $easy->onHeadersException = $e; + + return -1; + } + } + } elseif ($startingResponse) { + $startingResponse = false; + $easy->headers = [$value]; + } else { + $easy->headers[] = $value; + } + + return \strlen($h); + }; + } + + public function __destruct() + { + foreach ($this->handles as $id => $handle) { + \curl_close($handle); + unset($this->handles[$id]); + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php new file mode 100644 index 0000000..fe57ed5 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php @@ -0,0 +1,25 @@ +factory = $options['handle_factory'] + ?? new CurlFactory(3); + } + + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + if (isset($options['delay'])) { + \usleep($options['delay'] * 1000); + } + + $easy = $this->factory->create($request, $options); + \curl_exec($easy->handle); + $easy->errno = \curl_errno($easy->handle); + + return CurlFactory::finish($this, $easy, $this->factory); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php new file mode 100644 index 0000000..73a6abe --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php @@ -0,0 +1,284 @@ + An array of delay times, indexed by handle id in `addRequest`. + * + * @see CurlMultiHandler::addRequest + */ + private $delays = []; + + /** + * @var array An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt() + */ + private $options = []; + + /** @var resource|\CurlMultiHandle */ + private $_mh; + + /** + * This handler accepts the following options: + * + * - handle_factory: An optional factory used to create curl handles + * - select_timeout: Optional timeout (in seconds) to block before timing + * out while selecting curl handles. Defaults to 1 second. + * - options: An associative array of CURLMOPT_* options and + * corresponding values for curl_multi_setopt() + */ + public function __construct(array $options = []) + { + $this->factory = $options['handle_factory'] ?? new CurlFactory(50); + + if (isset($options['select_timeout'])) { + $this->selectTimeout = $options['select_timeout']; + } elseif ($selectTimeout = Utils::getenv('GUZZLE_CURL_SELECT_TIMEOUT')) { + @trigger_error('Since guzzlehttp/guzzle 7.2.0: Using environment variable GUZZLE_CURL_SELECT_TIMEOUT is deprecated. Use option "select_timeout" instead.', \E_USER_DEPRECATED); + $this->selectTimeout = (int) $selectTimeout; + } else { + $this->selectTimeout = 1; + } + + $this->options = $options['options'] ?? []; + + // unsetting the property forces the first access to go through + // __get(). + unset($this->_mh); + } + + /** + * @param string $name + * + * @return resource|\CurlMultiHandle + * + * @throws \BadMethodCallException when another field as `_mh` will be gotten + * @throws \RuntimeException when curl can not initialize a multi handle + */ + public function __get($name) + { + if ($name !== '_mh') { + throw new \BadMethodCallException("Can not get other property as '_mh'."); + } + + $multiHandle = \curl_multi_init(); + + if (false === $multiHandle) { + throw new \RuntimeException('Can not initialize curl multi handle.'); + } + + $this->_mh = $multiHandle; + + foreach ($this->options as $option => $value) { + // A warning is raised in case of a wrong option. + curl_multi_setopt($this->_mh, $option, $value); + } + + return $this->_mh; + } + + public function __destruct() + { + if (isset($this->_mh)) { + \curl_multi_close($this->_mh); + unset($this->_mh); + } + } + + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + $easy = $this->factory->create($request, $options); + $id = (int) $easy->handle; + + $promise = new Promise( + [$this, 'execute'], + function () use ($id) { + return $this->cancel($id); + } + ); + + $this->addRequest(['easy' => $easy, 'deferred' => $promise]); + + return $promise; + } + + /** + * Ticks the curl event loop. + */ + public function tick(): void + { + // Add any delayed handles if needed. + if ($this->delays) { + $currentTime = Utils::currentTime(); + foreach ($this->delays as $id => $delay) { + if ($currentTime >= $delay) { + unset($this->delays[$id]); + \curl_multi_add_handle( + $this->_mh, + $this->handles[$id]['easy']->handle + ); + } + } + } + + // Run curl_multi_exec in the queue to enable other async tasks to run + P\Utils::queue()->add(Closure::fromCallable([$this, 'tickInQueue'])); + + // Step through the task queue which may add additional requests. + P\Utils::queue()->run(); + + if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) { + // Perform a usleep if a select returns -1. + // See: https://bugs.php.net/bug.php?id=61141 + \usleep(250); + } + + while (\curl_multi_exec($this->_mh, $this->active) === \CURLM_CALL_MULTI_PERFORM) { + // Prevent busy looping for slow HTTP requests. + \curl_multi_select($this->_mh, $this->selectTimeout); + } + + $this->processMessages(); + } + + /** + * Runs \curl_multi_exec() inside the event loop, to prevent busy looping + */ + private function tickInQueue(): void + { + if (\curl_multi_exec($this->_mh, $this->active) === \CURLM_CALL_MULTI_PERFORM) { + \curl_multi_select($this->_mh, 0); + P\Utils::queue()->add(Closure::fromCallable([$this, 'tickInQueue'])); + } + } + + /** + * Runs until all outstanding connections have completed. + */ + public function execute(): void + { + $queue = P\Utils::queue(); + + while ($this->handles || !$queue->isEmpty()) { + // If there are no transfers, then sleep for the next delay + if (!$this->active && $this->delays) { + \usleep($this->timeToNext()); + } + $this->tick(); + } + } + + private function addRequest(array $entry): void + { + $easy = $entry['easy']; + $id = (int) $easy->handle; + $this->handles[$id] = $entry; + if (empty($easy->options['delay'])) { + \curl_multi_add_handle($this->_mh, $easy->handle); + } else { + $this->delays[$id] = Utils::currentTime() + ($easy->options['delay'] / 1000); + } + } + + /** + * Cancels a handle from sending and removes references to it. + * + * @param int $id Handle ID to cancel and remove. + * + * @return bool True on success, false on failure. + */ + private function cancel($id): bool + { + if (!is_int($id)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + // Cannot cancel if it has been processed. + if (!isset($this->handles[$id])) { + return false; + } + + $handle = $this->handles[$id]['easy']->handle; + unset($this->delays[$id], $this->handles[$id]); + \curl_multi_remove_handle($this->_mh, $handle); + \curl_close($handle); + + return true; + } + + private function processMessages(): void + { + while ($done = \curl_multi_info_read($this->_mh)) { + if ($done['msg'] !== \CURLMSG_DONE) { + // if it's not done, then it would be premature to remove the handle. ref https://github.com/guzzle/guzzle/pull/2892#issuecomment-945150216 + continue; + } + $id = (int) $done['handle']; + \curl_multi_remove_handle($this->_mh, $done['handle']); + + if (!isset($this->handles[$id])) { + // Probably was cancelled. + continue; + } + + $entry = $this->handles[$id]; + unset($this->handles[$id], $this->delays[$id]); + $entry['easy']->errno = $done['result']; + $entry['deferred']->resolve( + CurlFactory::finish($this, $entry['easy'], $this->factory) + ); + } + } + + private function timeToNext(): int + { + $currentTime = Utils::currentTime(); + $nextTime = \PHP_INT_MAX; + foreach ($this->delays as $time) { + if ($time < $nextTime) { + $nextTime = $time; + } + } + + return ((int) \max(0, $nextTime - $currentTime)) * 1000000; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php new file mode 100644 index 0000000..1bc39f4 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php @@ -0,0 +1,112 @@ +headers); + + $normalizedKeys = Utils::normalizeHeaderKeys($headers); + + if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) { + $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']]; + unset($headers[$normalizedKeys['content-encoding']]); + if (isset($normalizedKeys['content-length'])) { + $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']]; + + $bodyLength = (int) $this->sink->getSize(); + if ($bodyLength) { + $headers[$normalizedKeys['content-length']] = $bodyLength; + } else { + unset($headers[$normalizedKeys['content-length']]); + } + } + } + + // Attach a response to the easy handle with the parsed headers. + $this->response = new Response( + $status, + $headers, + $this->sink, + $ver, + $reason + ); + } + + /** + * @param string $name + * + * @return void + * + * @throws \BadMethodCallException + */ + public function __get($name) + { + $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: '.$name; + throw new \BadMethodCallException($msg); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php b/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php new file mode 100644 index 0000000..5554b8f --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php @@ -0,0 +1,42 @@ +|null $queue The parameters to be passed to the append function, as an indexed array. + * @param callable|null $onFulfilled Callback to invoke when the return value is fulfilled. + * @param callable|null $onRejected Callback to invoke when the return value is rejected. + */ + public function __construct(?array $queue = null, ?callable $onFulfilled = null, ?callable $onRejected = null) + { + $this->onFulfilled = $onFulfilled; + $this->onRejected = $onRejected; + + if ($queue) { + // array_values included for BC + $this->append(...array_values($queue)); + } + } + + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + if (!$this->queue) { + throw new \OutOfBoundsException('Mock queue is empty'); + } + + if (isset($options['delay']) && \is_numeric($options['delay'])) { + \usleep((int) $options['delay'] * 1000); + } + + $this->lastRequest = $request; + $this->lastOptions = $options; + $response = \array_shift($this->queue); + + if (isset($options['on_headers'])) { + if (!\is_callable($options['on_headers'])) { + throw new \InvalidArgumentException('on_headers must be callable'); + } + try { + $options['on_headers']($response); + } catch (\Exception $e) { + $msg = 'An error was encountered during the on_headers event'; + $response = new RequestException($msg, $request, $response, $e); + } + } + + if (\is_callable($response)) { + $response = $response($request, $options); + } + + $response = $response instanceof \Throwable + ? P\Create::rejectionFor($response) + : P\Create::promiseFor($response); + + return $response->then( + function (?ResponseInterface $value) use ($request, $options) { + $this->invokeStats($request, $options, $value); + if ($this->onFulfilled) { + ($this->onFulfilled)($value); + } + + if ($value !== null && isset($options['sink'])) { + $contents = (string) $value->getBody(); + $sink = $options['sink']; + + if (\is_resource($sink)) { + \fwrite($sink, $contents); + } elseif (\is_string($sink)) { + \file_put_contents($sink, $contents); + } elseif ($sink instanceof StreamInterface) { + $sink->write($contents); + } + } + + return $value; + }, + function ($reason) use ($request, $options) { + $this->invokeStats($request, $options, null, $reason); + if ($this->onRejected) { + ($this->onRejected)($reason); + } + + return P\Create::rejectionFor($reason); + } + ); + } + + /** + * Adds one or more variadic requests, exceptions, callables, or promises + * to the queue. + * + * @param mixed ...$values + */ + public function append(...$values): void + { + foreach ($values as $value) { + if ($value instanceof ResponseInterface + || $value instanceof \Throwable + || $value instanceof PromiseInterface + || \is_callable($value) + ) { + $this->queue[] = $value; + } else { + throw new \TypeError('Expected a Response, Promise, Throwable or callable. Found '.Utils::describeType($value)); + } + } + } + + /** + * Get the last received request. + */ + public function getLastRequest(): ?RequestInterface + { + return $this->lastRequest; + } + + /** + * Get the last received request options. + */ + public function getLastOptions(): array + { + return $this->lastOptions; + } + + /** + * Returns the number of remaining items in the queue. + */ + public function count(): int + { + return \count($this->queue); + } + + public function reset(): void + { + $this->queue = []; + } + + /** + * @param mixed $reason Promise or reason. + */ + private function invokeStats( + RequestInterface $request, + array $options, + ?ResponseInterface $response = null, + $reason = null + ): void { + if (isset($options['on_stats'])) { + $transferTime = $options['transfer_time'] ?? 0; + $stats = new TransferStats($request, $response, $transferTime, $reason); + ($options['on_stats'])($stats); + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php new file mode 100644 index 0000000..9df70cf --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php @@ -0,0 +1,51 @@ +getProtocolVersion(); + + if ('1.0' !== $protocolVersion && '1.1' !== $protocolVersion) { + throw new ConnectException(sprintf('HTTP/%s is not supported by the stream handler.', $protocolVersion), $request); + } + + $startTime = isset($options['on_stats']) ? Utils::currentTime() : null; + + try { + // Does not support the expect header. + $request = $request->withoutHeader('Expect'); + + // Append a content-length header if body size is zero to match + // the behavior of `CurlHandler` + if ( + ( + 0 === \strcasecmp('PUT', $request->getMethod()) + || 0 === \strcasecmp('POST', $request->getMethod()) + ) + && 0 === $request->getBody()->getSize() + ) { + $request = $request->withHeader('Content-Length', '0'); + } + + return $this->createResponse( + $request, + $options, + $this->createStream($request, $options), + $startTime + ); + } catch (\InvalidArgumentException $e) { + throw $e; + } catch (\Exception $e) { + // Determine if the error was a networking error. + $message = $e->getMessage(); + // This list can probably get more comprehensive. + if (false !== \strpos($message, 'getaddrinfo') // DNS lookup failed + || false !== \strpos($message, 'Connection refused') + || false !== \strpos($message, "couldn't connect to host") // error on HHVM + || false !== \strpos($message, 'connection attempt failed') + ) { + $e = new ConnectException($e->getMessage(), $request, $e); + } else { + $e = RequestException::wrapException($request, $e); + } + $this->invokeStats($options, $request, $startTime, null, $e); + + return P\Create::rejectionFor($e); + } + } + + private function invokeStats( + array $options, + RequestInterface $request, + ?float $startTime, + ?ResponseInterface $response = null, + ?\Throwable $error = null + ): void { + if (isset($options['on_stats'])) { + $stats = new TransferStats($request, $response, Utils::currentTime() - $startTime, $error, []); + ($options['on_stats'])($stats); + } + } + + /** + * @param resource $stream + */ + private function createResponse(RequestInterface $request, array $options, $stream, ?float $startTime): PromiseInterface + { + $hdrs = $this->lastHeaders; + $this->lastHeaders = []; + + try { + [$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($hdrs); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered while creating the response', $request, null, $e) + ); + } + + [$stream, $headers] = $this->checkDecode($options, $headers, $stream); + $stream = Psr7\Utils::streamFor($stream); + $sink = $stream; + + if (\strcasecmp('HEAD', $request->getMethod())) { + $sink = $this->createSink($stream, $options); + } + + try { + $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered while creating the response', $request, null, $e) + ); + } + + if (isset($options['on_headers'])) { + try { + $options['on_headers']($response); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered during the on_headers event', $request, $response, $e) + ); + } + } + + // Do not drain when the request is a HEAD request because they have + // no body. + if ($sink !== $stream) { + $this->drain($stream, $sink, $response->getHeaderLine('Content-Length')); + } + + $this->invokeStats($options, $request, $startTime, $response, null); + + return new FulfilledPromise($response); + } + + private function createSink(StreamInterface $stream, array $options): StreamInterface + { + if (!empty($options['stream'])) { + return $stream; + } + + $sink = $options['sink'] ?? Psr7\Utils::tryFopen('php://temp', 'r+'); + + return \is_string($sink) ? new Psr7\LazyOpenStream($sink, 'w+') : Psr7\Utils::streamFor($sink); + } + + /** + * @param resource $stream + */ + private function checkDecode(array $options, array $headers, $stream): array + { + // Automatically decode responses when instructed. + if (!empty($options['decode_content'])) { + $normalizedKeys = Utils::normalizeHeaderKeys($headers); + if (isset($normalizedKeys['content-encoding'])) { + $encoding = $headers[$normalizedKeys['content-encoding']]; + if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') { + $stream = new Psr7\InflateStream(Psr7\Utils::streamFor($stream)); + $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']]; + + // Remove content-encoding header + unset($headers[$normalizedKeys['content-encoding']]); + + // Fix content-length header + if (isset($normalizedKeys['content-length'])) { + $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']]; + $length = (int) $stream->getSize(); + if ($length === 0) { + unset($headers[$normalizedKeys['content-length']]); + } else { + $headers[$normalizedKeys['content-length']] = [$length]; + } + } + } + } + } + + return [$stream, $headers]; + } + + /** + * Drains the source stream into the "sink" client option. + * + * @param string $contentLength Header specifying the amount of + * data to read. + * + * @throws \RuntimeException when the sink option is invalid. + */ + private function drain(StreamInterface $source, StreamInterface $sink, string $contentLength): StreamInterface + { + // If a content-length header is provided, then stop reading once + // that number of bytes has been read. This can prevent infinitely + // reading from a stream when dealing with servers that do not honor + // Connection: Close headers. + Psr7\Utils::copyToStream( + $source, + $sink, + (\strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1 + ); + + $sink->seek(0); + $source->close(); + + return $sink; + } + + /** + * Create a resource and check to ensure it was created successfully + * + * @param callable $callback Callable that returns stream resource + * + * @return resource + * + * @throws \RuntimeException on error + */ + private function createResource(callable $callback) + { + $errors = []; + \set_error_handler(static function ($_, $msg, $file, $line) use (&$errors): bool { + $errors[] = [ + 'message' => $msg, + 'file' => $file, + 'line' => $line, + ]; + + return true; + }); + + try { + $resource = $callback(); + } finally { + \restore_error_handler(); + } + + if (!$resource) { + $message = 'Error creating resource: '; + foreach ($errors as $err) { + foreach ($err as $key => $value) { + $message .= "[$key] $value".\PHP_EOL; + } + } + throw new \RuntimeException(\trim($message)); + } + + return $resource; + } + + /** + * @return resource + */ + private function createStream(RequestInterface $request, array $options) + { + static $methods; + if (!$methods) { + $methods = \array_flip(\get_class_methods(__CLASS__)); + } + + if (!\in_array($request->getUri()->getScheme(), ['http', 'https'])) { + throw new RequestException(\sprintf("The scheme '%s' is not supported.", $request->getUri()->getScheme()), $request); + } + + // HTTP/1.1 streams using the PHP stream wrapper require a + // Connection: close header + if ($request->getProtocolVersion() === '1.1' + && !$request->hasHeader('Connection') + ) { + $request = $request->withHeader('Connection', 'close'); + } + + // Ensure SSL is verified by default + if (!isset($options['verify'])) { + $options['verify'] = true; + } + + $params = []; + $context = $this->getDefaultContext($request); + + if (isset($options['on_headers']) && !\is_callable($options['on_headers'])) { + throw new \InvalidArgumentException('on_headers must be callable'); + } + + if (!empty($options)) { + foreach ($options as $key => $value) { + $method = "add_{$key}"; + if (isset($methods[$method])) { + $this->{$method}($request, $context, $value, $params); + } + } + } + + if (isset($options['stream_context'])) { + if (!\is_array($options['stream_context'])) { + throw new \InvalidArgumentException('stream_context must be an array'); + } + $context = \array_replace_recursive($context, $options['stream_context']); + } + + // Microsoft NTLM authentication only supported with curl handler + if (isset($options['auth'][2]) && 'ntlm' === $options['auth'][2]) { + throw new \InvalidArgumentException('Microsoft NTLM authentication only supported with curl handler'); + } + + $uri = $this->resolveHost($request, $options); + + $contextResource = $this->createResource( + static function () use ($context, $params) { + return \stream_context_create($context, $params); + } + ); + + return $this->createResource( + function () use ($uri, &$http_response_header, $contextResource, $context, $options, $request) { + $resource = @\fopen((string) $uri, 'r', false, $contextResource); + $this->lastHeaders = $http_response_header ?? []; + + if (false === $resource) { + throw new ConnectException(sprintf('Connection refused for URI %s', $uri), $request, null, $context); + } + + if (isset($options['read_timeout'])) { + $readTimeout = $options['read_timeout']; + $sec = (int) $readTimeout; + $usec = ($readTimeout - $sec) * 100000; + \stream_set_timeout($resource, $sec, $usec); + } + + return $resource; + } + ); + } + + private function resolveHost(RequestInterface $request, array $options): UriInterface + { + $uri = $request->getUri(); + + if (isset($options['force_ip_resolve']) && !\filter_var($uri->getHost(), \FILTER_VALIDATE_IP)) { + if ('v4' === $options['force_ip_resolve']) { + $records = \dns_get_record($uri->getHost(), \DNS_A); + if (false === $records || !isset($records[0]['ip'])) { + throw new ConnectException(\sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request); + } + + return $uri->withHost($records[0]['ip']); + } + if ('v6' === $options['force_ip_resolve']) { + $records = \dns_get_record($uri->getHost(), \DNS_AAAA); + if (false === $records || !isset($records[0]['ipv6'])) { + throw new ConnectException(\sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request); + } + + return $uri->withHost('['.$records[0]['ipv6'].']'); + } + } + + return $uri; + } + + private function getDefaultContext(RequestInterface $request): array + { + $headers = ''; + foreach ($request->getHeaders() as $name => $value) { + foreach ($value as $val) { + $headers .= "$name: $val\r\n"; + } + } + + $context = [ + 'http' => [ + 'method' => $request->getMethod(), + 'header' => $headers, + 'protocol_version' => $request->getProtocolVersion(), + 'ignore_errors' => true, + 'follow_location' => 0, + ], + 'ssl' => [ + 'peer_name' => $request->getUri()->getHost(), + ], + ]; + + $body = (string) $request->getBody(); + + if ('' !== $body) { + $context['http']['content'] = $body; + // Prevent the HTTP handler from adding a Content-Type header. + if (!$request->hasHeader('Content-Type')) { + $context['http']['header'] .= "Content-Type:\r\n"; + } + } + + $context['http']['header'] = \rtrim($context['http']['header']); + + return $context; + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_proxy(RequestInterface $request, array &$options, $value, array &$params): void + { + $uri = null; + + if (!\is_array($value)) { + $uri = $value; + } else { + $scheme = $request->getUri()->getScheme(); + if (isset($value[$scheme])) { + if (!isset($value['no']) || !Utils::isHostInNoProxy($request->getUri()->getHost(), $value['no'])) { + $uri = $value[$scheme]; + } + } + } + + if (!$uri) { + return; + } + + $parsed = $this->parse_proxy($uri); + $options['http']['proxy'] = $parsed['proxy']; + + if ($parsed['auth']) { + if (!isset($options['http']['header'])) { + $options['http']['header'] = []; + } + $options['http']['header'] .= "\r\nProxy-Authorization: {$parsed['auth']}"; + } + } + + /** + * Parses the given proxy URL to make it compatible with the format PHP's stream context expects. + */ + private function parse_proxy(string $url): array + { + $parsed = \parse_url($url); + + if ($parsed !== false && isset($parsed['scheme']) && $parsed['scheme'] === 'http') { + if (isset($parsed['host']) && isset($parsed['port'])) { + $auth = null; + if (isset($parsed['user']) && isset($parsed['pass'])) { + $auth = \base64_encode("{$parsed['user']}:{$parsed['pass']}"); + } + + return [ + 'proxy' => "tcp://{$parsed['host']}:{$parsed['port']}", + 'auth' => $auth ? "Basic {$auth}" : null, + ]; + } + } + + // Return proxy as-is. + return [ + 'proxy' => $url, + 'auth' => null, + ]; + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_timeout(RequestInterface $request, array &$options, $value, array &$params): void + { + if ($value > 0) { + $options['http']['timeout'] = $value; + } + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_crypto_method(RequestInterface $request, array &$options, $value, array &$params): void + { + if ( + $value === \STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT + || $value === \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT + || $value === \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + || (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && $value === \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT) + ) { + $options['http']['crypto_method'] = $value; + + return; + } + + throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided'); + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_verify(RequestInterface $request, array &$options, $value, array &$params): void + { + if ($value === false) { + $options['ssl']['verify_peer'] = false; + $options['ssl']['verify_peer_name'] = false; + + return; + } + + if (\is_string($value)) { + $options['ssl']['cafile'] = $value; + if (!\file_exists($value)) { + throw new \RuntimeException("SSL CA bundle not found: $value"); + } + } elseif ($value !== true) { + throw new \InvalidArgumentException('Invalid verify request option'); + } + + $options['ssl']['verify_peer'] = true; + $options['ssl']['verify_peer_name'] = true; + $options['ssl']['allow_self_signed'] = false; + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_cert(RequestInterface $request, array &$options, $value, array &$params): void + { + if (\is_array($value)) { + $options['ssl']['passphrase'] = $value[1]; + $value = $value[0]; + } + + if (!\file_exists($value)) { + throw new \RuntimeException("SSL certificate not found: {$value}"); + } + + $options['ssl']['local_cert'] = $value; + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_progress(RequestInterface $request, array &$options, $value, array &$params): void + { + self::addNotification( + $params, + static function ($code, $a, $b, $c, $transferred, $total) use ($value) { + if ($code == \STREAM_NOTIFY_PROGRESS) { + // The upload progress cannot be determined. Use 0 for cURL compatibility: + // https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html + $value($total, $transferred, 0, 0); + } + } + ); + } + + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_debug(RequestInterface $request, array &$options, $value, array &$params): void + { + if ($value === false) { + return; + } + + static $map = [ + \STREAM_NOTIFY_CONNECT => 'CONNECT', + \STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED', + \STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', + \STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', + \STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', + \STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', + \STREAM_NOTIFY_PROGRESS => 'PROGRESS', + \STREAM_NOTIFY_FAILURE => 'FAILURE', + \STREAM_NOTIFY_COMPLETED => 'COMPLETED', + \STREAM_NOTIFY_RESOLVE => 'RESOLVE', + ]; + static $args = ['severity', 'message', 'message_code', 'bytes_transferred', 'bytes_max']; + + $value = Utils::debugResource($value); + $ident = $request->getMethod().' '.$request->getUri()->withFragment(''); + self::addNotification( + $params, + static function (int $code, ...$passed) use ($ident, $value, $map, $args): void { + \fprintf($value, '<%s> [%s] ', $ident, $map[$code]); + foreach (\array_filter($passed) as $i => $v) { + \fwrite($value, $args[$i].': "'.$v.'" '); + } + \fwrite($value, "\n"); + } + ); + } + + private static function addNotification(array &$params, callable $notify): void + { + // Wrap the existing function if needed. + if (!isset($params['notification'])) { + $params['notification'] = $notify; + } else { + $params['notification'] = self::callArray([ + $params['notification'], + $notify, + ]); + } + } + + private static function callArray(array $functions): callable + { + return static function (...$args) use ($functions) { + foreach ($functions as $fn) { + $fn(...$args); + } + }; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/HandlerStack.php b/vendor/guzzlehttp/guzzle/src/HandlerStack.php new file mode 100644 index 0000000..03f9a18 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/HandlerStack.php @@ -0,0 +1,275 @@ +push(Middleware::httpErrors(), 'http_errors'); + $stack->push(Middleware::redirect(), 'allow_redirects'); + $stack->push(Middleware::cookies(), 'cookies'); + $stack->push(Middleware::prepareBody(), 'prepare_body'); + + return $stack; + } + + /** + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler Underlying HTTP handler. + */ + public function __construct(?callable $handler = null) + { + $this->handler = $handler; + } + + /** + * Invokes the handler stack as a composed handler + * + * @return ResponseInterface|PromiseInterface + */ + public function __invoke(RequestInterface $request, array $options) + { + $handler = $this->resolve(); + + return $handler($request, $options); + } + + /** + * Dumps a string representation of the stack. + * + * @return string + */ + public function __toString() + { + $depth = 0; + $stack = []; + + if ($this->handler !== null) { + $stack[] = '0) Handler: '.$this->debugCallable($this->handler); + } + + $result = ''; + foreach (\array_reverse($this->stack) as $tuple) { + ++$depth; + $str = "{$depth}) Name: '{$tuple[1]}', "; + $str .= 'Function: '.$this->debugCallable($tuple[0]); + $result = "> {$str}\n{$result}"; + $stack[] = $str; + } + + foreach (\array_keys($stack) as $k) { + $result .= "< {$stack[$k]}\n"; + } + + return $result; + } + + /** + * Set the HTTP handler that actually returns a promise. + * + * @param callable(RequestInterface, array): PromiseInterface $handler Accepts a request and array of options and + * returns a Promise. + */ + public function setHandler(callable $handler): void + { + $this->handler = $handler; + $this->cached = null; + } + + /** + * Returns true if the builder has a handler. + */ + public function hasHandler(): bool + { + return $this->handler !== null; + } + + /** + * Unshift a middleware to the bottom of the stack. + * + * @param callable(callable): callable $middleware Middleware function + * @param string $name Name to register for this middleware. + */ + public function unshift(callable $middleware, ?string $name = null): void + { + \array_unshift($this->stack, [$middleware, $name]); + $this->cached = null; + } + + /** + * Push a middleware to the top of the stack. + * + * @param callable(callable): callable $middleware Middleware function + * @param string $name Name to register for this middleware. + */ + public function push(callable $middleware, string $name = ''): void + { + $this->stack[] = [$middleware, $name]; + $this->cached = null; + } + + /** + * Add a middleware before another middleware by name. + * + * @param string $findName Middleware to find + * @param callable(callable): callable $middleware Middleware function + * @param string $withName Name to register for this middleware. + */ + public function before(string $findName, callable $middleware, string $withName = ''): void + { + $this->splice($findName, $withName, $middleware, true); + } + + /** + * Add a middleware after another middleware by name. + * + * @param string $findName Middleware to find + * @param callable(callable): callable $middleware Middleware function + * @param string $withName Name to register for this middleware. + */ + public function after(string $findName, callable $middleware, string $withName = ''): void + { + $this->splice($findName, $withName, $middleware, false); + } + + /** + * Remove a middleware by instance or name from the stack. + * + * @param callable|string $remove Middleware to remove by instance or name. + */ + public function remove($remove): void + { + if (!is_string($remove) && !is_callable($remove)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a callable or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->cached = null; + $idx = \is_callable($remove) ? 0 : 1; + $this->stack = \array_values(\array_filter( + $this->stack, + static function ($tuple) use ($idx, $remove) { + return $tuple[$idx] !== $remove; + } + )); + } + + /** + * Compose the middleware and handler into a single callable function. + * + * @return callable(RequestInterface, array): PromiseInterface + */ + public function resolve(): callable + { + if ($this->cached === null) { + if (($prev = $this->handler) === null) { + throw new \LogicException('No handler has been specified'); + } + + foreach (\array_reverse($this->stack) as $fn) { + /** @var callable(RequestInterface, array): PromiseInterface $prev */ + $prev = $fn[0]($prev); + } + + $this->cached = $prev; + } + + return $this->cached; + } + + private function findByName(string $name): int + { + foreach ($this->stack as $k => $v) { + if ($v[1] === $name) { + return $k; + } + } + + throw new \InvalidArgumentException("Middleware not found: $name"); + } + + /** + * Splices a function into the middleware list at a specific position. + */ + private function splice(string $findName, string $withName, callable $middleware, bool $before): void + { + $this->cached = null; + $idx = $this->findByName($findName); + $tuple = [$middleware, $withName]; + + if ($before) { + if ($idx === 0) { + \array_unshift($this->stack, $tuple); + } else { + $replacement = [$tuple, $this->stack[$idx]]; + \array_splice($this->stack, $idx, 1, $replacement); + } + } elseif ($idx === \count($this->stack) - 1) { + $this->stack[] = $tuple; + } else { + $replacement = [$this->stack[$idx], $tuple]; + \array_splice($this->stack, $idx, 1, $replacement); + } + } + + /** + * Provides a debug string for a given callable. + * + * @param callable|string $fn Function to write as a string. + */ + private function debugCallable($fn): string + { + if (\is_string($fn)) { + return "callable({$fn})"; + } + + if (\is_array($fn)) { + return \is_string($fn[0]) + ? "callable({$fn[0]}::{$fn[1]})" + : "callable(['".\get_class($fn[0])."', '{$fn[1]}'])"; + } + + /** @var object $fn */ + return 'callable('.\spl_object_hash($fn).')'; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php new file mode 100644 index 0000000..9b77eee --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php @@ -0,0 +1,199 @@ +>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"; + public const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'; + + /** + * @var string Template used to format log messages + */ + private $template; + + /** + * @param string $template Log message template + */ + public function __construct(?string $template = self::CLF) + { + $this->template = $template ?: self::CLF; + } + + /** + * Returns a formatted message string. + * + * @param RequestInterface $request Request that was sent + * @param ResponseInterface|null $response Response that was received + * @param \Throwable|null $error Exception that was received + */ + public function format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null): string + { + $cache = []; + + /** @var string */ + return \preg_replace_callback( + '/{\s*([A-Za-z_\-\.0-9]+)\s*}/', + function (array $matches) use ($request, $response, $error, &$cache) { + if (isset($cache[$matches[1]])) { + return $cache[$matches[1]]; + } + + $result = ''; + switch ($matches[1]) { + case 'request': + $result = Psr7\Message::toString($request); + break; + case 'response': + $result = $response ? Psr7\Message::toString($response) : ''; + break; + case 'req_headers': + $result = \trim($request->getMethod() + .' '.$request->getRequestTarget()) + .' HTTP/'.$request->getProtocolVersion()."\r\n" + .$this->headers($request); + break; + case 'res_headers': + $result = $response ? + \sprintf( + 'HTTP/%s %d %s', + $response->getProtocolVersion(), + $response->getStatusCode(), + $response->getReasonPhrase() + )."\r\n".$this->headers($response) + : 'NULL'; + break; + case 'req_body': + $result = $request->getBody()->__toString(); + break; + case 'res_body': + if (!$response instanceof ResponseInterface) { + $result = 'NULL'; + break; + } + + $body = $response->getBody(); + + if (!$body->isSeekable()) { + $result = 'RESPONSE_NOT_LOGGEABLE'; + break; + } + + $result = $response->getBody()->__toString(); + break; + case 'ts': + case 'date_iso_8601': + $result = \gmdate('c'); + break; + case 'date_common_log': + $result = \date('d/M/Y:H:i:s O'); + break; + case 'method': + $result = $request->getMethod(); + break; + case 'version': + $result = $request->getProtocolVersion(); + break; + case 'uri': + case 'url': + $result = $request->getUri()->__toString(); + break; + case 'target': + $result = $request->getRequestTarget(); + break; + case 'req_version': + $result = $request->getProtocolVersion(); + break; + case 'res_version': + $result = $response + ? $response->getProtocolVersion() + : 'NULL'; + break; + case 'host': + $result = $request->getHeaderLine('Host'); + break; + case 'hostname': + $result = \gethostname(); + break; + case 'code': + $result = $response ? $response->getStatusCode() : 'NULL'; + break; + case 'phrase': + $result = $response ? $response->getReasonPhrase() : 'NULL'; + break; + case 'error': + $result = $error ? $error->getMessage() : 'NULL'; + break; + default: + // handle prefixed dynamic headers + if (\strpos($matches[1], 'req_header_') === 0) { + $result = $request->getHeaderLine(\substr($matches[1], 11)); + } elseif (\strpos($matches[1], 'res_header_') === 0) { + $result = $response + ? $response->getHeaderLine(\substr($matches[1], 11)) + : 'NULL'; + } + } + + $cache[$matches[1]] = $result; + + return $result; + }, + $this->template + ); + } + + /** + * Get headers from message as string + */ + private function headers(MessageInterface $message): string + { + $result = ''; + foreach ($message->getHeaders() as $name => $values) { + $result .= $name.': '.\implode(', ', $values)."\r\n"; + } + + return \trim($result); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php b/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php new file mode 100644 index 0000000..a39ac24 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php @@ -0,0 +1,18 @@ +withCookieHeader($request); + + return $handler($request, $options) + ->then( + static function (ResponseInterface $response) use ($cookieJar, $request): ResponseInterface { + $cookieJar->extractCookies($request, $response); + + return $response; + } + ); + }; + }; + } + + /** + * Middleware that throws exceptions for 4xx or 5xx responses when the + * "http_errors" request option is set to true. + * + * @param BodySummarizerInterface|null $bodySummarizer The body summarizer to use in exception messages. + * + * @return callable(callable): callable Returns a function that accepts the next handler. + */ + public static function httpErrors(?BodySummarizerInterface $bodySummarizer = null): callable + { + return static function (callable $handler) use ($bodySummarizer): callable { + return static function ($request, array $options) use ($handler, $bodySummarizer) { + if (empty($options['http_errors'])) { + return $handler($request, $options); + } + + return $handler($request, $options)->then( + static function (ResponseInterface $response) use ($request, $bodySummarizer) { + $code = $response->getStatusCode(); + if ($code < 400) { + return $response; + } + throw RequestException::create($request, $response, null, [], $bodySummarizer); + } + ); + }; + }; + } + + /** + * Middleware that pushes history data to an ArrayAccess container. + * + * @param array|\ArrayAccess $container Container to hold the history (by reference). + * + * @return callable(callable): callable Returns a function that accepts the next handler. + * + * @throws \InvalidArgumentException if container is not an array or ArrayAccess. + */ + public static function history(&$container): callable + { + if (!\is_array($container) && !$container instanceof \ArrayAccess) { + throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess'); + } + + return static function (callable $handler) use (&$container): callable { + return static function (RequestInterface $request, array $options) use ($handler, &$container) { + return $handler($request, $options)->then( + static function ($value) use ($request, &$container, $options) { + $container[] = [ + 'request' => $request, + 'response' => $value, + 'error' => null, + 'options' => $options, + ]; + + return $value; + }, + static function ($reason) use ($request, &$container, $options) { + $container[] = [ + 'request' => $request, + 'response' => null, + 'error' => $reason, + 'options' => $options, + ]; + + return P\Create::rejectionFor($reason); + } + ); + }; + }; + } + + /** + * Middleware that invokes a callback before and after sending a request. + * + * The provided listener cannot modify or alter the response. It simply + * "taps" into the chain to be notified before returning the promise. The + * before listener accepts a request and options array, and the after + * listener accepts a request, options array, and response promise. + * + * @param callable $before Function to invoke before forwarding the request. + * @param callable $after Function invoked after forwarding. + * + * @return callable Returns a function that accepts the next handler. + */ + public static function tap(?callable $before = null, ?callable $after = null): callable + { + return static function (callable $handler) use ($before, $after): callable { + return static function (RequestInterface $request, array $options) use ($handler, $before, $after) { + if ($before) { + $before($request, $options); + } + $response = $handler($request, $options); + if ($after) { + $after($request, $options, $response); + } + + return $response; + }; + }; + } + + /** + * Middleware that handles request redirects. + * + * @return callable Returns a function that accepts the next handler. + */ + public static function redirect(): callable + { + return static function (callable $handler): RedirectMiddleware { + return new RedirectMiddleware($handler); + }; + } + + /** + * Middleware that retries requests based on the boolean result of + * invoking the provided "decider" function. + * + * If no delay function is provided, a simple implementation of exponential + * backoff will be utilized. + * + * @param callable $decider Function that accepts the number of retries, + * a request, [response], and [exception] and + * returns true if the request is to be retried. + * @param callable $delay Function that accepts the number of retries and + * returns the number of milliseconds to delay. + * + * @return callable Returns a function that accepts the next handler. + */ + public static function retry(callable $decider, ?callable $delay = null): callable + { + return static function (callable $handler) use ($decider, $delay): RetryMiddleware { + return new RetryMiddleware($decider, $handler, $delay); + }; + } + + /** + * Middleware that logs requests, responses, and errors using a message + * formatter. + * + * @phpstan-param \Psr\Log\LogLevel::* $logLevel Level at which to log requests. + * + * @param LoggerInterface $logger Logs messages. + * @param MessageFormatterInterface|MessageFormatter $formatter Formatter used to create message strings. + * @param string $logLevel Level at which to log requests. + * + * @return callable Returns a function that accepts the next handler. + */ + public static function log(LoggerInterface $logger, $formatter, string $logLevel = 'info'): callable + { + // To be compatible with Guzzle 7.1.x we need to allow users to pass a MessageFormatter + if (!$formatter instanceof MessageFormatter && !$formatter instanceof MessageFormatterInterface) { + throw new \LogicException(sprintf('Argument 2 to %s::log() must be of type %s', self::class, MessageFormatterInterface::class)); + } + + return static function (callable $handler) use ($logger, $formatter, $logLevel): callable { + return static function (RequestInterface $request, array $options = []) use ($handler, $logger, $formatter, $logLevel) { + return $handler($request, $options)->then( + static function ($response) use ($logger, $request, $formatter, $logLevel): ResponseInterface { + $message = $formatter->format($request, $response); + $logger->log($logLevel, $message); + + return $response; + }, + static function ($reason) use ($logger, $request, $formatter): PromiseInterface { + $response = $reason instanceof RequestException ? $reason->getResponse() : null; + $message = $formatter->format($request, $response, P\Create::exceptionFor($reason)); + $logger->error($message); + + return P\Create::rejectionFor($reason); + } + ); + }; + }; + } + + /** + * This middleware adds a default content-type if possible, a default + * content-length or transfer-encoding header, and the expect header. + */ + public static function prepareBody(): callable + { + return static function (callable $handler): PrepareBodyMiddleware { + return new PrepareBodyMiddleware($handler); + }; + } + + /** + * Middleware that applies a map function to the request before passing to + * the next handler. + * + * @param callable $fn Function that accepts a RequestInterface and returns + * a RequestInterface. + */ + public static function mapRequest(callable $fn): callable + { + return static function (callable $handler) use ($fn): callable { + return static function (RequestInterface $request, array $options) use ($handler, $fn) { + return $handler($fn($request), $options); + }; + }; + } + + /** + * Middleware that applies a map function to the resolved promise's + * response. + * + * @param callable $fn Function that accepts a ResponseInterface and + * returns a ResponseInterface. + */ + public static function mapResponse(callable $fn): callable + { + return static function (callable $handler) use ($fn): callable { + return static function (RequestInterface $request, array $options) use ($handler, $fn) { + return $handler($request, $options)->then($fn); + }; + }; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Pool.php b/vendor/guzzlehttp/guzzle/src/Pool.php new file mode 100644 index 0000000..ddc304b --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Pool.php @@ -0,0 +1,125 @@ + $rfn) { + if ($rfn instanceof RequestInterface) { + yield $key => $client->sendAsync($rfn, $opts); + } elseif (\is_callable($rfn)) { + yield $key => $rfn($opts); + } else { + throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7\Http\Message\RequestInterface or a callable that returns a promise that fulfills with a Psr7\Message\Http\ResponseInterface object.'); + } + } + }; + + $this->each = new EachPromise($requests(), $config); + } + + /** + * Get promise + */ + public function promise(): PromiseInterface + { + return $this->each->promise(); + } + + /** + * Sends multiple requests concurrently and returns an array of responses + * and exceptions that uses the same ordering as the provided requests. + * + * IMPORTANT: This method keeps every request and response in memory, and + * as such, is NOT recommended when sending a large number or an + * indeterminate number of requests concurrently. + * + * @param ClientInterface $client Client used to send the requests + * @param array|\Iterator $requests Requests to send concurrently. + * @param array $options Passes through the options available in + * {@see Pool::__construct} + * + * @return array Returns an array containing the response or an exception + * in the same order that the requests were sent. + * + * @throws \InvalidArgumentException if the event format is incorrect. + */ + public static function batch(ClientInterface $client, $requests, array $options = []): array + { + $res = []; + self::cmpCallback($options, 'fulfilled', $res); + self::cmpCallback($options, 'rejected', $res); + $pool = new static($client, $requests, $options); + $pool->promise()->wait(); + \ksort($res); + + return $res; + } + + /** + * Execute callback(s) + */ + private static function cmpCallback(array &$options, string $name, array &$results): void + { + if (!isset($options[$name])) { + $options[$name] = static function ($v, $k) use (&$results) { + $results[$k] = $v; + }; + } else { + $currentFn = $options[$name]; + $options[$name] = static function ($v, $k) use (&$results, $currentFn) { + $currentFn($v, $k); + $results[$k] = $v; + }; + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php new file mode 100644 index 0000000..7dde6c5 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php @@ -0,0 +1,105 @@ +nextHandler = $nextHandler; + } + + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + $fn = $this->nextHandler; + + // Don't do anything if the request has no body. + if ($request->getBody()->getSize() === 0) { + return $fn($request, $options); + } + + $modify = []; + + // Add a default content-type if possible. + if (!$request->hasHeader('Content-Type')) { + if ($uri = $request->getBody()->getMetadata('uri')) { + if (is_string($uri) && $type = Psr7\MimeType::fromFilename($uri)) { + $modify['set_headers']['Content-Type'] = $type; + } + } + } + + // Add a default content-length or transfer-encoding header. + if (!$request->hasHeader('Content-Length') + && !$request->hasHeader('Transfer-Encoding') + ) { + $size = $request->getBody()->getSize(); + if ($size !== null) { + $modify['set_headers']['Content-Length'] = $size; + } else { + $modify['set_headers']['Transfer-Encoding'] = 'chunked'; + } + } + + // Add the expect header if needed. + $this->addExpectHeader($request, $options, $modify); + + return $fn(Psr7\Utils::modifyRequest($request, $modify), $options); + } + + /** + * Add expect header + */ + private function addExpectHeader(RequestInterface $request, array $options, array &$modify): void + { + // Determine if the Expect header should be used + if ($request->hasHeader('Expect')) { + return; + } + + $expect = $options['expect'] ?? null; + + // Return if disabled or using HTTP/1.0 + if ($expect === false || $request->getProtocolVersion() === '1.0') { + return; + } + + // The expect header is unconditionally enabled + if ($expect === true) { + $modify['set_headers']['Expect'] = '100-Continue'; + + return; + } + + // By default, send the expect header when the payload is > 1mb + if ($expect === null) { + $expect = 1048576; + } + + // Always add if the body cannot be rewound, the size cannot be + // determined, or the size is greater than the cutoff threshold + $body = $request->getBody(); + $size = $body->getSize(); + + if ($size === null || $size >= (int) $expect || !$body->isSeekable()) { + $modify['set_headers']['Expect'] = '100-Continue'; + } + } +} diff --git a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php new file mode 100644 index 0000000..7aa21a6 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php @@ -0,0 +1,228 @@ + 5, + 'protocols' => ['http', 'https'], + 'strict' => false, + 'referer' => false, + 'track_redirects' => false, + ]; + + /** + * @var callable(RequestInterface, array): PromiseInterface + */ + private $nextHandler; + + /** + * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke. + */ + public function __construct(callable $nextHandler) + { + $this->nextHandler = $nextHandler; + } + + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + $fn = $this->nextHandler; + + if (empty($options['allow_redirects'])) { + return $fn($request, $options); + } + + if ($options['allow_redirects'] === true) { + $options['allow_redirects'] = self::$defaultSettings; + } elseif (!\is_array($options['allow_redirects'])) { + throw new \InvalidArgumentException('allow_redirects must be true, false, or array'); + } else { + // Merge the default settings with the provided settings + $options['allow_redirects'] += self::$defaultSettings; + } + + if (empty($options['allow_redirects']['max'])) { + return $fn($request, $options); + } + + return $fn($request, $options) + ->then(function (ResponseInterface $response) use ($request, $options) { + return $this->checkRedirect($request, $options, $response); + }); + } + + /** + * @return ResponseInterface|PromiseInterface + */ + public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response) + { + if (\strpos((string) $response->getStatusCode(), '3') !== 0 + || !$response->hasHeader('Location') + ) { + return $response; + } + + $this->guardMax($request, $response, $options); + $nextRequest = $this->modifyRequest($request, $options, $response); + + // If authorization is handled by curl, unset it if URI is cross-origin. + if (Psr7\UriComparator::isCrossOrigin($request->getUri(), $nextRequest->getUri()) && defined('\CURLOPT_HTTPAUTH')) { + unset( + $options['curl'][\CURLOPT_HTTPAUTH], + $options['curl'][\CURLOPT_USERPWD] + ); + } + + if (isset($options['allow_redirects']['on_redirect'])) { + ($options['allow_redirects']['on_redirect'])( + $request, + $response, + $nextRequest->getUri() + ); + } + + $promise = $this($nextRequest, $options); + + // Add headers to be able to track history of redirects. + if (!empty($options['allow_redirects']['track_redirects'])) { + return $this->withTracking( + $promise, + (string) $nextRequest->getUri(), + $response->getStatusCode() + ); + } + + return $promise; + } + + /** + * Enable tracking on promise. + */ + private function withTracking(PromiseInterface $promise, string $uri, int $statusCode): PromiseInterface + { + return $promise->then( + static function (ResponseInterface $response) use ($uri, $statusCode) { + // Note that we are pushing to the front of the list as this + // would be an earlier response than what is currently present + // in the history header. + $historyHeader = $response->getHeader(self::HISTORY_HEADER); + $statusHeader = $response->getHeader(self::STATUS_HISTORY_HEADER); + \array_unshift($historyHeader, $uri); + \array_unshift($statusHeader, (string) $statusCode); + + return $response->withHeader(self::HISTORY_HEADER, $historyHeader) + ->withHeader(self::STATUS_HISTORY_HEADER, $statusHeader); + } + ); + } + + /** + * Check for too many redirects. + * + * @throws TooManyRedirectsException Too many redirects. + */ + private function guardMax(RequestInterface $request, ResponseInterface $response, array &$options): void + { + $current = $options['__redirect_count'] + ?? 0; + $options['__redirect_count'] = $current + 1; + $max = $options['allow_redirects']['max']; + + if ($options['__redirect_count'] > $max) { + throw new TooManyRedirectsException("Will not follow more than {$max} redirects", $request, $response); + } + } + + public function modifyRequest(RequestInterface $request, array $options, ResponseInterface $response): RequestInterface + { + // Request modifications to apply. + $modify = []; + $protocols = $options['allow_redirects']['protocols']; + + // Use a GET request if this is an entity enclosing request and we are + // not forcing RFC compliance, but rather emulating what all browsers + // would do. + $statusCode = $response->getStatusCode(); + if ($statusCode == 303 + || ($statusCode <= 302 && !$options['allow_redirects']['strict']) + ) { + $safeMethods = ['GET', 'HEAD', 'OPTIONS']; + $requestMethod = $request->getMethod(); + + $modify['method'] = in_array($requestMethod, $safeMethods) ? $requestMethod : 'GET'; + $modify['body'] = ''; + } + + $uri = self::redirectUri($request, $response, $protocols); + if (isset($options['idn_conversion']) && ($options['idn_conversion'] !== false)) { + $idnOptions = ($options['idn_conversion'] === true) ? \IDNA_DEFAULT : $options['idn_conversion']; + $uri = Utils::idnUriConvert($uri, $idnOptions); + } + + $modify['uri'] = $uri; + Psr7\Message::rewindBody($request); + + // Add the Referer header if it is told to do so and only + // add the header if we are not redirecting from https to http. + if ($options['allow_redirects']['referer'] + && $modify['uri']->getScheme() === $request->getUri()->getScheme() + ) { + $uri = $request->getUri()->withUserInfo(''); + $modify['set_headers']['Referer'] = (string) $uri; + } else { + $modify['remove_headers'][] = 'Referer'; + } + + // Remove Authorization and Cookie headers if URI is cross-origin. + if (Psr7\UriComparator::isCrossOrigin($request->getUri(), $modify['uri'])) { + $modify['remove_headers'][] = 'Authorization'; + $modify['remove_headers'][] = 'Cookie'; + } + + return Psr7\Utils::modifyRequest($request, $modify); + } + + /** + * Set the appropriate URL on the request based on the location header. + */ + private static function redirectUri( + RequestInterface $request, + ResponseInterface $response, + array $protocols + ): UriInterface { + $location = Psr7\UriResolver::resolve( + $request->getUri(), + new Psr7\Uri($response->getHeaderLine('Location')) + ); + + // Ensure that the redirect URI is allowed based on the protocols. + if (!\in_array($location->getScheme(), $protocols)) { + throw new BadResponseException(\sprintf('Redirect URI, %s, does not use one of the allowed redirect protocols: %s', $location, \implode(', ', $protocols)), $request, $response); + } + + return $location; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/RequestOptions.php b/vendor/guzzlehttp/guzzle/src/RequestOptions.php new file mode 100644 index 0000000..84a3500 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/RequestOptions.php @@ -0,0 +1,274 @@ +decider = $decider; + $this->nextHandler = $nextHandler; + $this->delay = $delay ?: __CLASS__.'::exponentialDelay'; + } + + /** + * Default exponential backoff delay function. + * + * @return int milliseconds. + */ + public static function exponentialDelay(int $retries): int + { + return (int) 2 ** ($retries - 1) * 1000; + } + + public function __invoke(RequestInterface $request, array $options): PromiseInterface + { + if (!isset($options['retries'])) { + $options['retries'] = 0; + } + + $fn = $this->nextHandler; + + return $fn($request, $options) + ->then( + $this->onFulfilled($request, $options), + $this->onRejected($request, $options) + ); + } + + /** + * Execute fulfilled closure + */ + private function onFulfilled(RequestInterface $request, array $options): callable + { + return function ($value) use ($request, $options) { + if (!($this->decider)( + $options['retries'], + $request, + $value, + null + )) { + return $value; + } + + return $this->doRetry($request, $options, $value); + }; + } + + /** + * Execute rejected closure + */ + private function onRejected(RequestInterface $req, array $options): callable + { + return function ($reason) use ($req, $options) { + if (!($this->decider)( + $options['retries'], + $req, + null, + $reason + )) { + return P\Create::rejectionFor($reason); + } + + return $this->doRetry($req, $options); + }; + } + + private function doRetry(RequestInterface $request, array $options, ?ResponseInterface $response = null): PromiseInterface + { + $options['delay'] = ($this->delay)(++$options['retries'], $response, $request); + + return $this($request, $options); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/TransferStats.php b/vendor/guzzlehttp/guzzle/src/TransferStats.php new file mode 100644 index 0000000..93fa334 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/TransferStats.php @@ -0,0 +1,133 @@ +request = $request; + $this->response = $response; + $this->transferTime = $transferTime; + $this->handlerErrorData = $handlerErrorData; + $this->handlerStats = $handlerStats; + } + + public function getRequest(): RequestInterface + { + return $this->request; + } + + /** + * Returns the response that was received (if any). + */ + public function getResponse(): ?ResponseInterface + { + return $this->response; + } + + /** + * Returns true if a response was received. + */ + public function hasResponse(): bool + { + return $this->response !== null; + } + + /** + * Gets handler specific error data. + * + * This might be an exception, a integer representing an error code, or + * anything else. Relying on this value assumes that you know what handler + * you are using. + * + * @return mixed + */ + public function getHandlerErrorData() + { + return $this->handlerErrorData; + } + + /** + * Get the effective URI the request was sent to. + */ + public function getEffectiveUri(): UriInterface + { + return $this->request->getUri(); + } + + /** + * Get the estimated time the request was being transferred by the handler. + * + * @return float|null Time in seconds. + */ + public function getTransferTime(): ?float + { + return $this->transferTime; + } + + /** + * Gets an array of all of the handler specific transfer data. + */ + public function getHandlerStats(): array + { + return $this->handlerStats; + } + + /** + * Get a specific handler statistic from the handler by name. + * + * @param string $stat Handler specific transfer stat to retrieve. + * + * @return mixed|null + */ + public function getHandlerStat(string $stat) + { + return $this->handlerStats[$stat] ?? null; + } +} diff --git a/vendor/guzzlehttp/guzzle/src/Utils.php b/vendor/guzzlehttp/guzzle/src/Utils.php new file mode 100644 index 0000000..c6a5893 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Utils.php @@ -0,0 +1,384 @@ += 0) { + if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) { + $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler()); + } elseif (\function_exists('curl_exec')) { + $handler = new CurlHandler(); + } elseif (\function_exists('curl_multi_exec')) { + $handler = new CurlMultiHandler(); + } + } + + if (\ini_get('allow_url_fopen')) { + $handler = $handler + ? Proxy::wrapStreaming($handler, new StreamHandler()) + : new StreamHandler(); + } elseif (!$handler) { + throw new \RuntimeException('GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.'); + } + + return $handler; + } + + /** + * Get the default User-Agent string to use with Guzzle. + */ + public static function defaultUserAgent(): string + { + return sprintf('GuzzleHttp/%d', ClientInterface::MAJOR_VERSION); + } + + /** + * Returns the default cacert bundle for the current system. + * + * First, the openssl.cafile and curl.cainfo php.ini settings are checked. + * If those settings are not configured, then the common locations for + * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X + * and Windows are checked. If any of these file locations are found on + * disk, they will be utilized. + * + * Note: the result of this function is cached for subsequent calls. + * + * @throws \RuntimeException if no bundle can be found. + * + * @deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+. + */ + public static function defaultCaBundle(): string + { + static $cached = null; + static $cafiles = [ + // Red Hat, CentOS, Fedora (provided by the ca-certificates package) + '/etc/pki/tls/certs/ca-bundle.crt', + // Ubuntu, Debian (provided by the ca-certificates package) + '/etc/ssl/certs/ca-certificates.crt', + // FreeBSD (provided by the ca_root_nss package) + '/usr/local/share/certs/ca-root-nss.crt', + // SLES 12 (provided by the ca-certificates package) + '/var/lib/ca-certificates/ca-bundle.pem', + // OS X provided by homebrew (using the default path) + '/usr/local/etc/openssl/cert.pem', + // Google app engine + '/etc/ca-certificates.crt', + // Windows? + 'C:\\windows\\system32\\curl-ca-bundle.crt', + 'C:\\windows\\curl-ca-bundle.crt', + ]; + + if ($cached) { + return $cached; + } + + if ($ca = \ini_get('openssl.cafile')) { + return $cached = $ca; + } + + if ($ca = \ini_get('curl.cainfo')) { + return $cached = $ca; + } + + foreach ($cafiles as $filename) { + if (\file_exists($filename)) { + return $cached = $filename; + } + } + + throw new \RuntimeException( + <<< EOT +No system CA bundle could be found in any of the the common system locations. +PHP versions earlier than 5.6 are not properly configured to use the system's +CA bundle by default. In order to verify peer certificates, you will need to +supply the path on disk to a certificate bundle to the 'verify' request +option: https://docs.guzzlephp.org/en/latest/request-options.html#verify. If +you do not need a specific certificate bundle, then Mozilla provides a commonly +used CA bundle which can be downloaded here (provided by the maintainer of +cURL): https://curl.haxx.se/ca/cacert.pem. Once you have a CA bundle available +on disk, you can set the 'openssl.cafile' PHP ini setting to point to the path +to the file, allowing you to omit the 'verify' request option. See +https://curl.haxx.se/docs/sslcerts.html for more information. +EOT + ); + } + + /** + * Creates an associative array of lowercase header names to the actual + * header casing. + */ + public static function normalizeHeaderKeys(array $headers): array + { + $result = []; + foreach (\array_keys($headers) as $key) { + $result[\strtolower($key)] = $key; + } + + return $result; + } + + /** + * Returns true if the provided host matches any of the no proxy areas. + * + * This method will strip a port from the host if it is present. Each pattern + * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a + * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == + * "baz.foo.com", but ".foo.com" != "foo.com"). + * + * Areas are matched in the following cases: + * 1. "*" (without quotes) always matches any hosts. + * 2. An exact match. + * 3. The area starts with "." and the area is the last part of the host. e.g. + * '.mit.edu' will match any host that ends with '.mit.edu'. + * + * @param string $host Host to check against the patterns. + * @param string[] $noProxyArray An array of host patterns. + * + * @throws InvalidArgumentException + */ + public static function isHostInNoProxy(string $host, array $noProxyArray): bool + { + if (\strlen($host) === 0) { + throw new InvalidArgumentException('Empty host provided'); + } + + // Strip port if present. + [$host] = \explode(':', $host, 2); + + foreach ($noProxyArray as $area) { + // Always match on wildcards. + if ($area === '*') { + return true; + } + + if (empty($area)) { + // Don't match on empty values. + continue; + } + + if ($area === $host) { + // Exact matches. + return true; + } + // Special match if the area when prefixed with ".". Remove any + // existing leading "." and add a new leading ".". + $area = '.'.\ltrim($area, '.'); + if (\substr($host, -\strlen($area)) === $area) { + return true; + } + } + + return false; + } + + /** + * Wrapper for json_decode that throws when an error occurs. + * + * @param string $json JSON data to parse + * @param bool $assoc When true, returned objects will be converted + * into associative arrays. + * @param int $depth User specified recursion depth. + * @param int $options Bitmask of JSON decode options. + * + * @return object|array|string|int|float|bool|null + * + * @throws InvalidArgumentException if the JSON cannot be decoded. + * + * @see https://www.php.net/manual/en/function.json-decode.php + */ + public static function jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0) + { + $data = \json_decode($json, $assoc, $depth, $options); + if (\JSON_ERROR_NONE !== \json_last_error()) { + throw new InvalidArgumentException('json_decode error: '.\json_last_error_msg()); + } + + return $data; + } + + /** + * Wrapper for JSON encoding that throws when an error occurs. + * + * @param mixed $value The value being encoded + * @param int $options JSON encode option bitmask + * @param int $depth Set the maximum depth. Must be greater than zero. + * + * @throws InvalidArgumentException if the JSON cannot be encoded. + * + * @see https://www.php.net/manual/en/function.json-encode.php + */ + public static function jsonEncode($value, int $options = 0, int $depth = 512): string + { + $json = \json_encode($value, $options, $depth); + if (\JSON_ERROR_NONE !== \json_last_error()) { + throw new InvalidArgumentException('json_encode error: '.\json_last_error_msg()); + } + + /** @var string */ + return $json; + } + + /** + * Wrapper for the hrtime() or microtime() functions + * (depending on the PHP version, one of the two is used) + * + * @return float UNIX timestamp + * + * @internal + */ + public static function currentTime(): float + { + return (float) \function_exists('hrtime') ? \hrtime(true) / 1e9 : \microtime(true); + } + + /** + * @throws InvalidArgumentException + * + * @internal + */ + public static function idnUriConvert(UriInterface $uri, int $options = 0): UriInterface + { + if ($uri->getHost()) { + $asciiHost = self::idnToAsci($uri->getHost(), $options, $info); + if ($asciiHost === false) { + $errorBitSet = $info['errors'] ?? 0; + + $errorConstants = array_filter(array_keys(get_defined_constants()), static function (string $name): bool { + return substr($name, 0, 11) === 'IDNA_ERROR_'; + }); + + $errors = []; + foreach ($errorConstants as $errorConstant) { + if ($errorBitSet & constant($errorConstant)) { + $errors[] = $errorConstant; + } + } + + $errorMessage = 'IDN conversion failed'; + if ($errors) { + $errorMessage .= ' (errors: '.implode(', ', $errors).')'; + } + + throw new InvalidArgumentException($errorMessage); + } + if ($uri->getHost() !== $asciiHost) { + // Replace URI only if the ASCII version is different + $uri = $uri->withHost($asciiHost); + } + } + + return $uri; + } + + /** + * @internal + */ + public static function getenv(string $name): ?string + { + if (isset($_SERVER[$name])) { + return (string) $_SERVER[$name]; + } + + if (\PHP_SAPI === 'cli' && ($value = \getenv($name)) !== false && $value !== null) { + return (string) $value; + } + + return null; + } + + /** + * @return string|false + */ + private static function idnToAsci(string $domain, int $options, ?array &$info = []) + { + if (\function_exists('idn_to_ascii') && \defined('INTL_IDNA_VARIANT_UTS46')) { + return \idn_to_ascii($domain, $options, \INTL_IDNA_VARIANT_UTS46, $info); + } + + throw new \Error('ext-idn or symfony/polyfill-intl-idn not loaded or too old'); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php new file mode 100644 index 0000000..9ab4b96 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/functions.php @@ -0,0 +1,167 @@ + +Copyright (c) 2015 Graham Campbell +Copyright (c) 2017 Tobias Schultze +Copyright (c) 2020 Tobias Nyholm + +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/vendor/guzzlehttp/promises/README.md b/vendor/guzzlehttp/promises/README.md new file mode 100644 index 0000000..d1c814f --- /dev/null +++ b/vendor/guzzlehttp/promises/README.md @@ -0,0 +1,559 @@ +# Guzzle Promises + +[Promises/A+](https://promisesaplus.com/) implementation that handles promise +chaining and resolution iteratively, allowing for "infinite" promise chaining +while keeping the stack size constant. Read [this blog post](https://blog.domenic.me/youre-missing-the-point-of-promises/) +for a general introduction to promises. + +- [Features](#features) +- [Quick start](#quick-start) +- [Synchronous wait](#synchronous-wait) +- [Cancellation](#cancellation) +- [API](#api) + - [Promise](#promise) + - [FulfilledPromise](#fulfilledpromise) + - [RejectedPromise](#rejectedpromise) +- [Promise interop](#promise-interop) +- [Implementation notes](#implementation-notes) + + +## Features + +- [Promises/A+](https://promisesaplus.com/) implementation. +- Promise resolution and chaining is handled iteratively, allowing for + "infinite" promise chaining. +- Promises have a synchronous `wait` method. +- Promises can be cancelled. +- Works with any object that has a `then` function. +- C# style async/await coroutine promises using + `GuzzleHttp\Promise\Coroutine::of()`. + + +## Installation + +```shell +composer require guzzlehttp/promises +``` + + +## Version Guidance + +| Version | Status | PHP Version | +|---------|---------------------|--------------| +| 1.x | Security fixes only | >=5.5,<8.3 | +| 2.x | Latest | >=7.2.5,<8.5 | + + +## Quick Start + +A *promise* represents the eventual result of an asynchronous operation. The +primary way of interacting with a promise is through its `then` method, which +registers callbacks to receive either a promise's eventual value or the reason +why the promise cannot be fulfilled. + +### Callbacks + +Callbacks are registered with the `then` method by providing an optional +`$onFulfilled` followed by an optional `$onRejected` function. + + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise(); +$promise->then( + // $onFulfilled + function ($value) { + echo 'The promise was fulfilled.'; + }, + // $onRejected + function ($reason) { + echo 'The promise was rejected.'; + } +); +``` + +*Resolving* a promise means that you either fulfill a promise with a *value* or +reject a promise with a *reason*. Resolving a promise triggers callbacks +registered with the promise's `then` method. These callbacks are triggered +only once and in the order in which they were added. + +### Resolving a Promise + +Promises are fulfilled using the `resolve($value)` method. Resolving a promise +with any value other than a `GuzzleHttp\Promise\RejectedPromise` will trigger +all of the onFulfilled callbacks (resolving a promise with a rejected promise +will reject the promise and trigger the `$onRejected` callbacks). + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise(); +$promise + ->then(function ($value) { + // Return a value and don't break the chain + return "Hello, " . $value; + }) + // This then is executed after the first then and receives the value + // returned from the first then. + ->then(function ($value) { + echo $value; + }); + +// Resolving the promise triggers the $onFulfilled callbacks and outputs +// "Hello, reader." +$promise->resolve('reader.'); +``` + +### Promise Forwarding + +Promises can be chained one after the other. Each then in the chain is a new +promise. The return value of a promise is what's forwarded to the next +promise in the chain. Returning a promise in a `then` callback will cause the +subsequent promises in the chain to only be fulfilled when the returned promise +has been fulfilled. The next promise in the chain will be invoked with the +resolved value of the promise. + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise(); +$nextPromise = new Promise(); + +$promise + ->then(function ($value) use ($nextPromise) { + echo $value; + return $nextPromise; + }) + ->then(function ($value) { + echo $value; + }); + +// Triggers the first callback and outputs "A" +$promise->resolve('A'); +// Triggers the second callback and outputs "B" +$nextPromise->resolve('B'); +``` + +### Promise Rejection + +When a promise is rejected, the `$onRejected` callbacks are invoked with the +rejection reason. + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise(); +$promise->then(null, function ($reason) { + echo $reason; +}); + +$promise->reject('Error!'); +// Outputs "Error!" +``` + +### Rejection Forwarding + +If an exception is thrown in an `$onRejected` callback, subsequent +`$onRejected` callbacks are invoked with the thrown exception as the reason. + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise(); +$promise->then(null, function ($reason) { + throw new Exception($reason); +})->then(null, function ($reason) { + assert($reason->getMessage() === 'Error!'); +}); + +$promise->reject('Error!'); +``` + +You can also forward a rejection down the promise chain by returning a +`GuzzleHttp\Promise\RejectedPromise` in either an `$onFulfilled` or +`$onRejected` callback. + +```php +use GuzzleHttp\Promise\Promise; +use GuzzleHttp\Promise\RejectedPromise; + +$promise = new Promise(); +$promise->then(null, function ($reason) { + return new RejectedPromise($reason); +})->then(null, function ($reason) { + assert($reason === 'Error!'); +}); + +$promise->reject('Error!'); +``` + +If an exception is not thrown in a `$onRejected` callback and the callback +does not return a rejected promise, downstream `$onFulfilled` callbacks are +invoked using the value returned from the `$onRejected` callback. + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise(); +$promise + ->then(null, function ($reason) { + return "It's ok"; + }) + ->then(function ($value) { + assert($value === "It's ok"); + }); + +$promise->reject('Error!'); +``` + + +## Synchronous Wait + +You can synchronously force promises to complete using a promise's `wait` +method. When creating a promise, you can provide a wait function that is used +to synchronously force a promise to complete. When a wait function is invoked +it is expected to deliver a value to the promise or reject the promise. If the +wait function does not deliver a value, then an exception is thrown. The wait +function provided to a promise constructor is invoked when the `wait` function +of the promise is called. + +```php +$promise = new Promise(function () use (&$promise) { + $promise->resolve('foo'); +}); + +// Calling wait will return the value of the promise. +echo $promise->wait(); // outputs "foo" +``` + +If an exception is encountered while invoking the wait function of a promise, +the promise is rejected with the exception and the exception is thrown. + +```php +$promise = new Promise(function () use (&$promise) { + throw new Exception('foo'); +}); + +$promise->wait(); // throws the exception. +``` + +Calling `wait` on a promise that has been fulfilled will not trigger the wait +function. It will simply return the previously resolved value. + +```php +$promise = new Promise(function () { die('this is not called!'); }); +$promise->resolve('foo'); +echo $promise->wait(); // outputs "foo" +``` + +Calling `wait` on a promise that has been rejected will throw an exception. If +the rejection reason is an instance of `\Exception` the reason is thrown. +Otherwise, a `GuzzleHttp\Promise\RejectionException` is thrown and the reason +can be obtained by calling the `getReason` method of the exception. + +```php +$promise = new Promise(); +$promise->reject('foo'); +$promise->wait(); +``` + +> PHP Fatal error: Uncaught exception 'GuzzleHttp\Promise\RejectionException' with message 'The promise was rejected with value: foo' + +### Unwrapping a Promise + +When synchronously waiting on a promise, you are joining the state of the +promise into the current state of execution (i.e., return the value of the +promise if it was fulfilled or throw an exception if it was rejected). This is +called "unwrapping" the promise. Waiting on a promise will by default unwrap +the promise state. + +You can force a promise to resolve and *not* unwrap the state of the promise +by passing `false` to the first argument of the `wait` function: + +```php +$promise = new Promise(); +$promise->reject('foo'); +// This will not throw an exception. It simply ensures the promise has +// been resolved. +$promise->wait(false); +``` + +When unwrapping a promise, the resolved value of the promise will be waited +upon until the unwrapped value is not a promise. This means that if you resolve +promise A with a promise B and unwrap promise A, the value returned by the +wait function will be the value delivered to promise B. + +**Note**: when you do not unwrap the promise, no value is returned. + + +## Cancellation + +You can cancel a promise that has not yet been fulfilled using the `cancel()` +method of a promise. When creating a promise you can provide an optional +cancel function that when invoked cancels the action of computing a resolution +of the promise. + + +## API + +### Promise + +When creating a promise object, you can provide an optional `$waitFn` and +`$cancelFn`. `$waitFn` is a function that is invoked with no arguments and is +expected to resolve the promise. `$cancelFn` is a function with no arguments +that is expected to cancel the computation of a promise. It is invoked when the +`cancel()` method of a promise is called. + +```php +use GuzzleHttp\Promise\Promise; + +$promise = new Promise( + function () use (&$promise) { + $promise->resolve('waited'); + }, + function () { + // do something that will cancel the promise computation (e.g., close + // a socket, cancel a database query, etc...) + } +); + +assert('waited' === $promise->wait()); +``` + +A promise has the following methods: + +- `then(callable $onFulfilled, callable $onRejected) : PromiseInterface` + + Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler. + +- `otherwise(callable $onRejected) : PromiseInterface` + + Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled. + +- `wait($unwrap = true) : mixed` + + Synchronously waits on the promise to complete. + + `$unwrap` controls whether or not the value of the promise is returned for a + fulfilled promise or if an exception is thrown if the promise is rejected. + This is set to `true` by default. + +- `cancel()` + + Attempts to cancel the promise if possible. The promise being cancelled and + the parent most ancestor that has not yet been resolved will also be + cancelled. Any promises waiting on the cancelled promise to resolve will also + be cancelled. + +- `getState() : string` + + Returns the state of the promise. One of `pending`, `fulfilled`, or + `rejected`. + +- `resolve($value)` + + Fulfills the promise with the given `$value`. + +- `reject($reason)` + + Rejects the promise with the given `$reason`. + + +### FulfilledPromise + +A fulfilled promise can be created to represent a promise that has been +fulfilled. + +```php +use GuzzleHttp\Promise\FulfilledPromise; + +$promise = new FulfilledPromise('value'); + +// Fulfilled callbacks are immediately invoked. +$promise->then(function ($value) { + echo $value; +}); +``` + + +### RejectedPromise + +A rejected promise can be created to represent a promise that has been +rejected. + +```php +use GuzzleHttp\Promise\RejectedPromise; + +$promise = new RejectedPromise('Error'); + +// Rejected callbacks are immediately invoked. +$promise->then(null, function ($reason) { + echo $reason; +}); +``` + + +## Promise Interoperability + +This library works with foreign promises that have a `then` method. This means +you can use Guzzle promises with [React promises](https://github.com/reactphp/promise) +for example. When a foreign promise is returned inside of a then method +callback, promise resolution will occur recursively. + +```php +// Create a React promise +$deferred = new React\Promise\Deferred(); +$reactPromise = $deferred->promise(); + +// Create a Guzzle promise that is fulfilled with a React promise. +$guzzlePromise = new GuzzleHttp\Promise\Promise(); +$guzzlePromise->then(function ($value) use ($reactPromise) { + // Do something something with the value... + // Return the React promise + return $reactPromise; +}); +``` + +Please note that wait and cancel chaining is no longer possible when forwarding +a foreign promise. You will need to wrap a third-party promise with a Guzzle +promise in order to utilize wait and cancel functions with foreign promises. + + +### Event Loop Integration + +In order to keep the stack size constant, Guzzle promises are resolved +asynchronously using a task queue. When waiting on promises synchronously, the +task queue will be automatically run to ensure that the blocking promise and +any forwarded promises are resolved. When using promises asynchronously in an +event loop, you will need to run the task queue on each tick of the loop. If +you do not run the task queue, then promises will not be resolved. + +You can run the task queue using the `run()` method of the global task queue +instance. + +```php +// Get the global task queue +$queue = GuzzleHttp\Promise\Utils::queue(); +$queue->run(); +``` + +For example, you could use Guzzle promises with React using a periodic timer: + +```php +$loop = React\EventLoop\Factory::create(); +$loop->addPeriodicTimer(0, [$queue, 'run']); +``` + + +## Implementation Notes + +### Promise Resolution and Chaining is Handled Iteratively + +By shuffling pending handlers from one owner to another, promises are +resolved iteratively, allowing for "infinite" then chaining. + +```php +then(function ($v) { + // The stack size remains constant (a good thing) + echo xdebug_get_stack_depth() . ', '; + return $v + 1; + }); +} + +$parent->resolve(0); +var_dump($p->wait()); // int(1000) + +``` + +When a promise is fulfilled or rejected with a non-promise value, the promise +then takes ownership of the handlers of each child promise and delivers values +down the chain without using recursion. + +When a promise is resolved with another promise, the original promise transfers +all of its pending handlers to the new promise. When the new promise is +eventually resolved, all of the pending handlers are delivered the forwarded +value. + +### A Promise is the Deferred + +Some promise libraries implement promises using a deferred object to represent +a computation and a promise object to represent the delivery of the result of +the computation. This is a nice separation of computation and delivery because +consumers of the promise cannot modify the value that will be eventually +delivered. + +One side effect of being able to implement promise resolution and chaining +iteratively is that you need to be able for one promise to reach into the state +of another promise to shuffle around ownership of handlers. In order to achieve +this without making the handlers of a promise publicly mutable, a promise is +also the deferred value, allowing promises of the same parent class to reach +into and modify the private properties of promises of the same type. While this +does allow consumers of the value to modify the resolution or rejection of the +deferred, it is a small price to pay for keeping the stack size constant. + +```php +$promise = new Promise(); +$promise->then(function ($value) { echo $value; }); +// The promise is the deferred value, so you can deliver a value to it. +$promise->resolve('foo'); +// prints "foo" +``` + + +## Upgrading from Function API + +A static API was first introduced in 1.4.0, in order to mitigate problems with +functions conflicting between global and local copies of the package. The +function API was removed in 2.0.0. A migration table has been provided here for +your convenience: + +| Original Function | Replacement Method | +|----------------|----------------| +| `queue` | `Utils::queue` | +| `task` | `Utils::task` | +| `promise_for` | `Create::promiseFor` | +| `rejection_for` | `Create::rejectionFor` | +| `exception_for` | `Create::exceptionFor` | +| `iter_for` | `Create::iterFor` | +| `inspect` | `Utils::inspect` | +| `inspect_all` | `Utils::inspectAll` | +| `unwrap` | `Utils::unwrap` | +| `all` | `Utils::all` | +| `some` | `Utils::some` | +| `any` | `Utils::any` | +| `settle` | `Utils::settle` | +| `each` | `Each::of` | +| `each_limit` | `Each::ofLimit` | +| `each_limit_all` | `Each::ofLimitAll` | +| `!is_fulfilled` | `Is::pending` | +| `is_fulfilled` | `Is::fulfilled` | +| `is_rejected` | `Is::rejected` | +| `is_settled` | `Is::settled` | +| `coroutine` | `Coroutine::of` | + + +## Security + +If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/promises/security/policy) for more information. + + +## License + +Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information. + + +## For Enterprise + +Available as part of the Tidelift Subscription + +The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver 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. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-promises?utm_source=packagist-guzzlehttp-promises&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/vendor/guzzlehttp/promises/composer.json b/vendor/guzzlehttp/promises/composer.json new file mode 100644 index 0000000..f64ed77 --- /dev/null +++ b/vendor/guzzlehttp/promises/composer.json @@ -0,0 +1,58 @@ +{ + "name": "guzzlehttp/promises", + "description": "Guzzle promises library", + "keywords": ["promise"], + "license": "MIT", + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "GuzzleHttp\\Promise\\Tests\\": "tests/" + } + }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, + "preferred-install": "dist", + "sort-packages": true + } +} diff --git a/vendor/guzzlehttp/promises/src/AggregateException.php b/vendor/guzzlehttp/promises/src/AggregateException.php new file mode 100644 index 0000000..40ffdbc --- /dev/null +++ b/vendor/guzzlehttp/promises/src/AggregateException.php @@ -0,0 +1,19 @@ +then(function ($v) { echo $v; }); + * + * @param callable $generatorFn Generator function to wrap into a promise. + * + * @return Promise + * + * @see https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration + */ +final class Coroutine implements PromiseInterface +{ + /** + * @var PromiseInterface|null + */ + private $currentPromise; + + /** + * @var Generator + */ + private $generator; + + /** + * @var Promise + */ + private $result; + + public function __construct(callable $generatorFn) + { + $this->generator = $generatorFn(); + $this->result = new Promise(function (): void { + while (isset($this->currentPromise)) { + $this->currentPromise->wait(); + } + }); + try { + $this->nextCoroutine($this->generator->current()); + } catch (Throwable $throwable) { + $this->result->reject($throwable); + } + } + + /** + * Create a new coroutine. + */ + public static function of(callable $generatorFn): self + { + return new self($generatorFn); + } + + public function then( + ?callable $onFulfilled = null, + ?callable $onRejected = null + ): PromiseInterface { + return $this->result->then($onFulfilled, $onRejected); + } + + public function otherwise(callable $onRejected): PromiseInterface + { + return $this->result->otherwise($onRejected); + } + + public function wait(bool $unwrap = true) + { + return $this->result->wait($unwrap); + } + + public function getState(): string + { + return $this->result->getState(); + } + + public function resolve($value): void + { + $this->result->resolve($value); + } + + public function reject($reason): void + { + $this->result->reject($reason); + } + + public function cancel(): void + { + $this->currentPromise->cancel(); + $this->result->cancel(); + } + + private function nextCoroutine($yielded): void + { + $this->currentPromise = Create::promiseFor($yielded) + ->then([$this, '_handleSuccess'], [$this, '_handleFailure']); + } + + /** + * @internal + */ + public function _handleSuccess($value): void + { + unset($this->currentPromise); + try { + $next = $this->generator->send($value); + if ($this->generator->valid()) { + $this->nextCoroutine($next); + } else { + $this->result->resolve($value); + } + } catch (Throwable $throwable) { + $this->result->reject($throwable); + } + } + + /** + * @internal + */ + public function _handleFailure($reason): void + { + unset($this->currentPromise); + try { + $nextYield = $this->generator->throw(Create::exceptionFor($reason)); + // The throw was caught, so keep iterating on the coroutine + $this->nextCoroutine($nextYield); + } catch (Throwable $throwable) { + $this->result->reject($throwable); + } + } +} diff --git a/vendor/guzzlehttp/promises/src/Create.php b/vendor/guzzlehttp/promises/src/Create.php new file mode 100644 index 0000000..9d3fc4a --- /dev/null +++ b/vendor/guzzlehttp/promises/src/Create.php @@ -0,0 +1,79 @@ +then([$promise, 'resolve'], [$promise, 'reject']); + + return $promise; + } + + return new FulfilledPromise($value); + } + + /** + * Creates a rejected promise for a reason if the reason is not a promise. + * If the provided reason is a promise, then it is returned as-is. + * + * @param mixed $reason Promise or reason. + */ + public static function rejectionFor($reason): PromiseInterface + { + if ($reason instanceof PromiseInterface) { + return $reason; + } + + return new RejectedPromise($reason); + } + + /** + * Create an exception for a rejected promise value. + * + * @param mixed $reason + */ + public static function exceptionFor($reason): \Throwable + { + if ($reason instanceof \Throwable) { + return $reason; + } + + return new RejectionException($reason); + } + + /** + * Returns an iterator for the given value. + * + * @param mixed $value + */ + public static function iterFor($value): \Iterator + { + if ($value instanceof \Iterator) { + return $value; + } + + if (is_array($value)) { + return new \ArrayIterator($value); + } + + return new \ArrayIterator([$value]); + } +} diff --git a/vendor/guzzlehttp/promises/src/Each.php b/vendor/guzzlehttp/promises/src/Each.php new file mode 100644 index 0000000..dd72c83 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/Each.php @@ -0,0 +1,81 @@ + $onFulfilled, + 'rejected' => $onRejected, + ]))->promise(); + } + + /** + * Like of, but only allows a certain number of outstanding promises at any + * given time. + * + * $concurrency may be an integer or a function that accepts the number of + * pending promises and returns a numeric concurrency limit value to allow + * for dynamic a concurrency size. + * + * @param mixed $iterable + * @param int|callable $concurrency + */ + public static function ofLimit( + $iterable, + $concurrency, + ?callable $onFulfilled = null, + ?callable $onRejected = null + ): PromiseInterface { + return (new EachPromise($iterable, [ + 'fulfilled' => $onFulfilled, + 'rejected' => $onRejected, + 'concurrency' => $concurrency, + ]))->promise(); + } + + /** + * Like limit, but ensures that no promise in the given $iterable argument + * is rejected. If any promise is rejected, then the aggregate promise is + * rejected with the encountered rejection. + * + * @param mixed $iterable + * @param int|callable $concurrency + */ + public static function ofLimitAll( + $iterable, + $concurrency, + ?callable $onFulfilled = null + ): PromiseInterface { + return self::ofLimit( + $iterable, + $concurrency, + $onFulfilled, + function ($reason, $idx, PromiseInterface $aggregate): void { + $aggregate->reject($reason); + } + ); + } +} diff --git a/vendor/guzzlehttp/promises/src/EachPromise.php b/vendor/guzzlehttp/promises/src/EachPromise.php new file mode 100644 index 0000000..e123898 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/EachPromise.php @@ -0,0 +1,248 @@ +iterable = Create::iterFor($iterable); + + if (isset($config['concurrency'])) { + $this->concurrency = $config['concurrency']; + } + + if (isset($config['fulfilled'])) { + $this->onFulfilled = $config['fulfilled']; + } + + if (isset($config['rejected'])) { + $this->onRejected = $config['rejected']; + } + } + + /** @psalm-suppress InvalidNullableReturnType */ + public function promise(): PromiseInterface + { + if ($this->aggregate) { + return $this->aggregate; + } + + try { + $this->createPromise(); + /** @psalm-assert Promise $this->aggregate */ + $this->iterable->rewind(); + $this->refillPending(); + } catch (\Throwable $e) { + $this->aggregate->reject($e); + } + + /** + * @psalm-suppress NullableReturnStatement + */ + return $this->aggregate; + } + + private function createPromise(): void + { + $this->mutex = false; + $this->aggregate = new Promise(function (): void { + if ($this->checkIfFinished()) { + return; + } + reset($this->pending); + // Consume a potentially fluctuating list of promises while + // ensuring that indexes are maintained (precluding array_shift). + while ($promise = current($this->pending)) { + next($this->pending); + $promise->wait(); + if (Is::settled($this->aggregate)) { + return; + } + } + }); + + // Clear the references when the promise is resolved. + $clearFn = function (): void { + $this->iterable = $this->concurrency = $this->pending = null; + $this->onFulfilled = $this->onRejected = null; + $this->nextPendingIndex = 0; + }; + + $this->aggregate->then($clearFn, $clearFn); + } + + private function refillPending(): void + { + if (!$this->concurrency) { + // Add all pending promises. + while ($this->addPending() && $this->advanceIterator()) { + } + + return; + } + + // Add only up to N pending promises. + $concurrency = is_callable($this->concurrency) + ? ($this->concurrency)(count($this->pending)) + : $this->concurrency; + $concurrency = max($concurrency - count($this->pending), 0); + // Concurrency may be set to 0 to disallow new promises. + if (!$concurrency) { + return; + } + // Add the first pending promise. + $this->addPending(); + // Note this is special handling for concurrency=1 so that we do + // not advance the iterator after adding the first promise. This + // helps work around issues with generators that might not have the + // next value to yield until promise callbacks are called. + while (--$concurrency + && $this->advanceIterator() + && $this->addPending()) { + } + } + + private function addPending(): bool + { + if (!$this->iterable || !$this->iterable->valid()) { + return false; + } + + $promise = Create::promiseFor($this->iterable->current()); + $key = $this->iterable->key(); + + // Iterable keys may not be unique, so we use a counter to + // guarantee uniqueness + $idx = $this->nextPendingIndex++; + + $this->pending[$idx] = $promise->then( + function ($value) use ($idx, $key): void { + if ($this->onFulfilled) { + ($this->onFulfilled)( + $value, + $key, + $this->aggregate + ); + } + $this->step($idx); + }, + function ($reason) use ($idx, $key): void { + if ($this->onRejected) { + ($this->onRejected)( + $reason, + $key, + $this->aggregate + ); + } + $this->step($idx); + } + ); + + return true; + } + + private function advanceIterator(): bool + { + // Place a lock on the iterator so that we ensure to not recurse, + // preventing fatal generator errors. + if ($this->mutex) { + return false; + } + + $this->mutex = true; + + try { + $this->iterable->next(); + $this->mutex = false; + + return true; + } catch (\Throwable $e) { + $this->aggregate->reject($e); + $this->mutex = false; + + return false; + } + } + + private function step(int $idx): void + { + // If the promise was already resolved, then ignore this step. + if (Is::settled($this->aggregate)) { + return; + } + + unset($this->pending[$idx]); + + // Only refill pending promises if we are not locked, preventing the + // EachPromise to recursively invoke the provided iterator, which + // cause a fatal error: "Cannot resume an already running generator" + if ($this->advanceIterator() && !$this->checkIfFinished()) { + // Add more pending promises if possible. + $this->refillPending(); + } + } + + private function checkIfFinished(): bool + { + if (!$this->pending && !$this->iterable->valid()) { + // Resolve the promise if there's nothing left to do. + $this->aggregate->resolve(null); + + return true; + } + + return false; + } +} diff --git a/vendor/guzzlehttp/promises/src/FulfilledPromise.php b/vendor/guzzlehttp/promises/src/FulfilledPromise.php new file mode 100644 index 0000000..727ec31 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/FulfilledPromise.php @@ -0,0 +1,89 @@ +value = $value; + } + + public function then( + ?callable $onFulfilled = null, + ?callable $onRejected = null + ): PromiseInterface { + // Return itself if there is no onFulfilled function. + if (!$onFulfilled) { + return $this; + } + + $queue = Utils::queue(); + $p = new Promise([$queue, 'run']); + $value = $this->value; + $queue->add(static function () use ($p, $value, $onFulfilled): void { + if (Is::pending($p)) { + try { + $p->resolve($onFulfilled($value)); + } catch (\Throwable $e) { + $p->reject($e); + } + } + }); + + return $p; + } + + public function otherwise(callable $onRejected): PromiseInterface + { + return $this->then(null, $onRejected); + } + + public function wait(bool $unwrap = true) + { + return $unwrap ? $this->value : null; + } + + public function getState(): string + { + return self::FULFILLED; + } + + public function resolve($value): void + { + if ($value !== $this->value) { + throw new \LogicException('Cannot resolve a fulfilled promise'); + } + } + + public function reject($reason): void + { + throw new \LogicException('Cannot reject a fulfilled promise'); + } + + public function cancel(): void + { + // pass + } +} diff --git a/vendor/guzzlehttp/promises/src/Is.php b/vendor/guzzlehttp/promises/src/Is.php new file mode 100644 index 0000000..f3f0503 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/Is.php @@ -0,0 +1,40 @@ +getState() === PromiseInterface::PENDING; + } + + /** + * Returns true if a promise is fulfilled or rejected. + */ + public static function settled(PromiseInterface $promise): bool + { + return $promise->getState() !== PromiseInterface::PENDING; + } + + /** + * Returns true if a promise is fulfilled. + */ + public static function fulfilled(PromiseInterface $promise): bool + { + return $promise->getState() === PromiseInterface::FULFILLED; + } + + /** + * Returns true if a promise is rejected. + */ + public static function rejected(PromiseInterface $promise): bool + { + return $promise->getState() === PromiseInterface::REJECTED; + } +} diff --git a/vendor/guzzlehttp/promises/src/Promise.php b/vendor/guzzlehttp/promises/src/Promise.php new file mode 100644 index 0000000..c0c5be2 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/Promise.php @@ -0,0 +1,281 @@ +waitFn = $waitFn; + $this->cancelFn = $cancelFn; + } + + public function then( + ?callable $onFulfilled = null, + ?callable $onRejected = null + ): PromiseInterface { + if ($this->state === self::PENDING) { + $p = new Promise(null, [$this, 'cancel']); + $this->handlers[] = [$p, $onFulfilled, $onRejected]; + $p->waitList = $this->waitList; + $p->waitList[] = $this; + + return $p; + } + + // Return a fulfilled promise and immediately invoke any callbacks. + if ($this->state === self::FULFILLED) { + $promise = Create::promiseFor($this->result); + + return $onFulfilled ? $promise->then($onFulfilled) : $promise; + } + + // It's either cancelled or rejected, so return a rejected promise + // and immediately invoke any callbacks. + $rejection = Create::rejectionFor($this->result); + + return $onRejected ? $rejection->then(null, $onRejected) : $rejection; + } + + public function otherwise(callable $onRejected): PromiseInterface + { + return $this->then(null, $onRejected); + } + + public function wait(bool $unwrap = true) + { + $this->waitIfPending(); + + if ($this->result instanceof PromiseInterface) { + return $this->result->wait($unwrap); + } + if ($unwrap) { + if ($this->state === self::FULFILLED) { + return $this->result; + } + // It's rejected so "unwrap" and throw an exception. + throw Create::exceptionFor($this->result); + } + } + + public function getState(): string + { + return $this->state; + } + + public function cancel(): void + { + if ($this->state !== self::PENDING) { + return; + } + + $this->waitFn = $this->waitList = null; + + if ($this->cancelFn) { + $fn = $this->cancelFn; + $this->cancelFn = null; + try { + $fn(); + } catch (\Throwable $e) { + $this->reject($e); + } + } + + // Reject the promise only if it wasn't rejected in a then callback. + /** @psalm-suppress RedundantCondition */ + if ($this->state === self::PENDING) { + $this->reject(new CancellationException('Promise has been cancelled')); + } + } + + public function resolve($value): void + { + $this->settle(self::FULFILLED, $value); + } + + public function reject($reason): void + { + $this->settle(self::REJECTED, $reason); + } + + private function settle(string $state, $value): void + { + if ($this->state !== self::PENDING) { + // Ignore calls with the same resolution. + if ($state === $this->state && $value === $this->result) { + return; + } + throw $this->state === $state + ? new \LogicException("The promise is already {$state}.") + : new \LogicException("Cannot change a {$this->state} promise to {$state}"); + } + + if ($value === $this) { + throw new \LogicException('Cannot fulfill or reject a promise with itself'); + } + + // Clear out the state of the promise but stash the handlers. + $this->state = $state; + $this->result = $value; + $handlers = $this->handlers; + $this->handlers = null; + $this->waitList = $this->waitFn = null; + $this->cancelFn = null; + + if (!$handlers) { + return; + } + + // If the value was not a settled promise or a thenable, then resolve + // it in the task queue using the correct ID. + if (!is_object($value) || !method_exists($value, 'then')) { + $id = $state === self::FULFILLED ? 1 : 2; + // It's a success, so resolve the handlers in the queue. + Utils::queue()->add(static function () use ($id, $value, $handlers): void { + foreach ($handlers as $handler) { + self::callHandler($id, $value, $handler); + } + }); + } elseif ($value instanceof Promise && Is::pending($value)) { + // We can just merge our handlers onto the next promise. + $value->handlers = array_merge($value->handlers, $handlers); + } else { + // Resolve the handlers when the forwarded promise is resolved. + $value->then( + static function ($value) use ($handlers): void { + foreach ($handlers as $handler) { + self::callHandler(1, $value, $handler); + } + }, + static function ($reason) use ($handlers): void { + foreach ($handlers as $handler) { + self::callHandler(2, $reason, $handler); + } + } + ); + } + } + + /** + * Call a stack of handlers using a specific callback index and value. + * + * @param int $index 1 (resolve) or 2 (reject). + * @param mixed $value Value to pass to the callback. + * @param array $handler Array of handler data (promise and callbacks). + */ + private static function callHandler(int $index, $value, array $handler): void + { + /** @var PromiseInterface $promise */ + $promise = $handler[0]; + + // The promise may have been cancelled or resolved before placing + // this thunk in the queue. + if (Is::settled($promise)) { + return; + } + + try { + if (isset($handler[$index])) { + /* + * If $f throws an exception, then $handler will be in the exception + * stack trace. Since $handler contains a reference to the callable + * itself we get a circular reference. We clear the $handler + * here to avoid that memory leak. + */ + $f = $handler[$index]; + unset($handler); + $promise->resolve($f($value)); + } elseif ($index === 1) { + // Forward resolution values as-is. + $promise->resolve($value); + } else { + // Forward rejections down the chain. + $promise->reject($value); + } + } catch (\Throwable $reason) { + $promise->reject($reason); + } + } + + private function waitIfPending(): void + { + if ($this->state !== self::PENDING) { + return; + } elseif ($this->waitFn) { + $this->invokeWaitFn(); + } elseif ($this->waitList) { + $this->invokeWaitList(); + } else { + // If there's no wait function, then reject the promise. + $this->reject('Cannot wait on a promise that has ' + .'no internal wait function. You must provide a wait ' + .'function when constructing the promise to be able to ' + .'wait on a promise.'); + } + + Utils::queue()->run(); + + /** @psalm-suppress RedundantCondition */ + if ($this->state === self::PENDING) { + $this->reject('Invoking the wait callback did not resolve the promise'); + } + } + + private function invokeWaitFn(): void + { + try { + $wfn = $this->waitFn; + $this->waitFn = null; + $wfn(true); + } catch (\Throwable $reason) { + if ($this->state === self::PENDING) { + // The promise has not been resolved yet, so reject the promise + // with the exception. + $this->reject($reason); + } else { + // The promise was already resolved, so there's a problem in + // the application. + throw $reason; + } + } + } + + private function invokeWaitList(): void + { + $waitList = $this->waitList; + $this->waitList = null; + + foreach ($waitList as $result) { + do { + $result->waitIfPending(); + $result = $result->result; + } while ($result instanceof Promise); + + if ($result instanceof PromiseInterface) { + $result->wait(false); + } + } + } +} diff --git a/vendor/guzzlehttp/promises/src/PromiseInterface.php b/vendor/guzzlehttp/promises/src/PromiseInterface.php new file mode 100644 index 0000000..c11721e --- /dev/null +++ b/vendor/guzzlehttp/promises/src/PromiseInterface.php @@ -0,0 +1,91 @@ +reason = $reason; + } + + public function then( + ?callable $onFulfilled = null, + ?callable $onRejected = null + ): PromiseInterface { + // If there's no onRejected callback then just return self. + if (!$onRejected) { + return $this; + } + + $queue = Utils::queue(); + $reason = $this->reason; + $p = new Promise([$queue, 'run']); + $queue->add(static function () use ($p, $reason, $onRejected): void { + if (Is::pending($p)) { + try { + // Return a resolved promise if onRejected does not throw. + $p->resolve($onRejected($reason)); + } catch (\Throwable $e) { + // onRejected threw, so return a rejected promise. + $p->reject($e); + } + } + }); + + return $p; + } + + public function otherwise(callable $onRejected): PromiseInterface + { + return $this->then(null, $onRejected); + } + + public function wait(bool $unwrap = true) + { + if ($unwrap) { + throw Create::exceptionFor($this->reason); + } + + return null; + } + + public function getState(): string + { + return self::REJECTED; + } + + public function resolve($value): void + { + throw new \LogicException('Cannot resolve a rejected promise'); + } + + public function reject($reason): void + { + if ($reason !== $this->reason) { + throw new \LogicException('Cannot reject a rejected promise'); + } + } + + public function cancel(): void + { + // pass + } +} diff --git a/vendor/guzzlehttp/promises/src/RejectionException.php b/vendor/guzzlehttp/promises/src/RejectionException.php new file mode 100644 index 0000000..47dca86 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/RejectionException.php @@ -0,0 +1,49 @@ +reason = $reason; + + $message = 'The promise was rejected'; + + if ($description) { + $message .= ' with reason: '.$description; + } elseif (is_string($reason) + || (is_object($reason) && method_exists($reason, '__toString')) + ) { + $message .= ' with reason: '.$this->reason; + } elseif ($reason instanceof \JsonSerializable) { + $message .= ' with reason: '.json_encode($this->reason, JSON_PRETTY_PRINT); + } + + parent::__construct($message); + } + + /** + * Returns the rejection reason. + * + * @return mixed + */ + public function getReason() + { + return $this->reason; + } +} diff --git a/vendor/guzzlehttp/promises/src/TaskQueue.php b/vendor/guzzlehttp/promises/src/TaskQueue.php new file mode 100644 index 0000000..503e0b2 --- /dev/null +++ b/vendor/guzzlehttp/promises/src/TaskQueue.php @@ -0,0 +1,71 @@ +run(); + * + * @final + */ +class TaskQueue implements TaskQueueInterface +{ + private $enableShutdown = true; + private $queue = []; + + public function __construct(bool $withShutdown = true) + { + if ($withShutdown) { + register_shutdown_function(function (): void { + if ($this->enableShutdown) { + // Only run the tasks if an E_ERROR didn't occur. + $err = error_get_last(); + if (!$err || ($err['type'] ^ E_ERROR)) { + $this->run(); + } + } + }); + } + } + + public function isEmpty(): bool + { + return !$this->queue; + } + + public function add(callable $task): void + { + $this->queue[] = $task; + } + + public function run(): void + { + while ($task = array_shift($this->queue)) { + /** @var callable $task */ + $task(); + } + } + + /** + * The task queue will be run and exhausted by default when the process + * exits IFF the exit is not the result of a PHP E_ERROR error. + * + * You can disable running the automatic shutdown of the queue by calling + * this function. If you disable the task queue shutdown process, then you + * MUST either run the task queue (as a result of running your event loop + * or manually using the run() method) or wait on each outstanding promise. + * + * Note: This shutdown will occur before any destructors are triggered. + */ + public function disableShutdown(): void + { + $this->enableShutdown = false; + } +} diff --git a/vendor/guzzlehttp/promises/src/TaskQueueInterface.php b/vendor/guzzlehttp/promises/src/TaskQueueInterface.php new file mode 100644 index 0000000..34c561a --- /dev/null +++ b/vendor/guzzlehttp/promises/src/TaskQueueInterface.php @@ -0,0 +1,24 @@ + + * while ($eventLoop->isRunning()) { + * GuzzleHttp\Promise\Utils::queue()->run(); + * } + * + * + * @param TaskQueueInterface|null $assign Optionally specify a new queue instance. + */ + public static function queue(?TaskQueueInterface $assign = null): TaskQueueInterface + { + static $queue; + + if ($assign) { + $queue = $assign; + } elseif (!$queue) { + $queue = new TaskQueue(); + } + + return $queue; + } + + /** + * Adds a function to run in the task queue when it is next `run()` and + * returns a promise that is fulfilled or rejected with the result. + * + * @param callable $task Task function to run. + */ + public static function task(callable $task): PromiseInterface + { + $queue = self::queue(); + $promise = new Promise([$queue, 'run']); + $queue->add(function () use ($task, $promise): void { + try { + if (Is::pending($promise)) { + $promise->resolve($task()); + } + } catch (\Throwable $e) { + $promise->reject($e); + } + }); + + return $promise; + } + + /** + * Synchronously waits on a promise to resolve and returns an inspection + * state array. + * + * Returns a state associative array containing a "state" key mapping to a + * valid promise state. If the state of the promise is "fulfilled", the + * array will contain a "value" key mapping to the fulfilled value of the + * promise. If the promise is rejected, the array will contain a "reason" + * key mapping to the rejection reason of the promise. + * + * @param PromiseInterface $promise Promise or value. + */ + public static function inspect(PromiseInterface $promise): array + { + try { + return [ + 'state' => PromiseInterface::FULFILLED, + 'value' => $promise->wait(), + ]; + } catch (RejectionException $e) { + return ['state' => PromiseInterface::REJECTED, 'reason' => $e->getReason()]; + } catch (\Throwable $e) { + return ['state' => PromiseInterface::REJECTED, 'reason' => $e]; + } + } + + /** + * Waits on all of the provided promises, but does not unwrap rejected + * promises as thrown exception. + * + * Returns an array of inspection state arrays. + * + * @see inspect for the inspection state array format. + * + * @param PromiseInterface[] $promises Traversable of promises to wait upon. + */ + public static function inspectAll($promises): array + { + $results = []; + foreach ($promises as $key => $promise) { + $results[$key] = self::inspect($promise); + } + + return $results; + } + + /** + * Waits on all of the provided promises and returns the fulfilled values. + * + * Returns an array that contains the value of each promise (in the same + * order the promises were provided). An exception is thrown if any of the + * promises are rejected. + * + * @param iterable $promises Iterable of PromiseInterface objects to wait on. + * + * @throws \Throwable on error + */ + public static function unwrap($promises): array + { + $results = []; + foreach ($promises as $key => $promise) { + $results[$key] = $promise->wait(); + } + + return $results; + } + + /** + * Given an array of promises, return a promise that is fulfilled when all + * the items in the array are fulfilled. + * + * The promise's fulfillment value is an array with fulfillment values at + * respective positions to the original array. If any promise in the array + * rejects, the returned promise is rejected with the rejection reason. + * + * @param mixed $promises Promises or values. + * @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution. + */ + public static function all($promises, bool $recursive = false): PromiseInterface + { + $results = []; + $promise = Each::of( + $promises, + function ($value, $idx) use (&$results): void { + $results[$idx] = $value; + }, + function ($reason, $idx, Promise $aggregate): void { + if (Is::pending($aggregate)) { + $aggregate->reject($reason); + } + } + )->then(function () use (&$results) { + ksort($results); + + return $results; + }); + + if (true === $recursive) { + $promise = $promise->then(function ($results) use ($recursive, &$promises) { + foreach ($promises as $promise) { + if (Is::pending($promise)) { + return self::all($promises, $recursive); + } + } + + return $results; + }); + } + + return $promise; + } + + /** + * Initiate a competitive race between multiple promises or values (values + * will become immediately fulfilled promises). + * + * When count amount of promises have been fulfilled, the returned promise + * is fulfilled with an array that contains the fulfillment values of the + * winners in order of resolution. + * + * This promise is rejected with a {@see AggregateException} if the number + * of fulfilled promises is less than the desired $count. + * + * @param int $count Total number of promises. + * @param mixed $promises Promises or values. + */ + public static function some(int $count, $promises): PromiseInterface + { + $results = []; + $rejections = []; + + return Each::of( + $promises, + function ($value, $idx, PromiseInterface $p) use (&$results, $count): void { + if (Is::settled($p)) { + return; + } + $results[$idx] = $value; + if (count($results) >= $count) { + $p->resolve(null); + } + }, + function ($reason) use (&$rejections): void { + $rejections[] = $reason; + } + )->then( + function () use (&$results, &$rejections, $count) { + if (count($results) !== $count) { + throw new AggregateException( + 'Not enough promises to fulfill count', + $rejections + ); + } + ksort($results); + + return array_values($results); + } + ); + } + + /** + * Like some(), with 1 as count. However, if the promise fulfills, the + * fulfillment value is not an array of 1 but the value directly. + * + * @param mixed $promises Promises or values. + */ + public static function any($promises): PromiseInterface + { + return self::some(1, $promises)->then(function ($values) { + return $values[0]; + }); + } + + /** + * Returns a promise that is fulfilled when all of the provided promises have + * been fulfilled or rejected. + * + * The returned promise is fulfilled with an array of inspection state arrays. + * + * @see inspect for the inspection state array format. + * + * @param mixed $promises Promises or values. + */ + public static function settle($promises): PromiseInterface + { + $results = []; + + return Each::of( + $promises, + function ($value, $idx) use (&$results): void { + $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value]; + }, + function ($reason, $idx) use (&$results): void { + $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason]; + } + )->then(function () use (&$results) { + ksort($results); + + return $results; + }); + } +} diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md new file mode 100644 index 0000000..a859295 --- /dev/null +++ b/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -0,0 +1,475 @@ +# Change Log + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 2.7.1 - 2025-03-27 + +### Fixed + +- Fixed uppercase IPv6 addresses in URI + +### Changed + +- Improve uploaded file error message + +## 2.7.0 - 2024-07-18 + +### Added + +- Add `Utils::redactUserInfo()` method +- Add ability to encode bools as ints in `Query::build` + +## 2.6.3 - 2024-07-18 + +### Fixed + +- Make `StreamWrapper::stream_stat()` return `false` if inner stream's size is `null` + +### Changed + +- PHP 8.4 support + +## 2.6.2 - 2023-12-03 + +### Fixed + +- Fixed another issue with the fact that PHP transforms numeric strings in array keys to ints + +### Changed + +- Updated links in docs to their canonical versions +- Replaced `call_user_func*` with native calls + +## 2.6.1 - 2023-08-27 + +### Fixed + +- Properly handle the fact that PHP transforms numeric strings in array keys to ints + +## 2.6.0 - 2023-08-03 + +### Changed + +- Updated the mime type map to add some new entries, fix a couple of invalid entries, and remove an invalid entry +- Fallback to `application/octet-stream` if we are unable to guess the content type for a multipart file upload + +## 2.5.1 - 2023-08-03 + +### Fixed + +- Corrected mime type for `.acc` files to `audio/aac` + +### Changed + +- PHP 8.3 support + +## 2.5.0 - 2023-04-17 + +### Changed + +- Adjusted `psr/http-message` version constraint to `^1.1 || ^2.0` + +## 2.4.5 - 2023-04-17 + +### Fixed + +- Prevent possible warnings on unset variables in `ServerRequest::normalizeNestedFileSpec` +- Fixed `Message::bodySummary` when `preg_match` fails +- Fixed header validation issue + +## 2.4.4 - 2023-03-09 + +### Changed + +- Removed the need for `AllowDynamicProperties` in `LazyOpenStream` + +## 2.4.3 - 2022-10-26 + +### Changed + +- Replaced `sha1(uniqid())` by `bin2hex(random_bytes(20))` + +## 2.4.2 - 2022-10-25 + +### Fixed + +- Fixed erroneous behaviour when combining host and relative path + +## 2.4.1 - 2022-08-28 + +### Fixed + +- Rewind body before reading in `Message::bodySummary` + +## 2.4.0 - 2022-06-20 + +### Added + +- Added provisional PHP 8.2 support +- Added `UriComparator::isCrossOrigin` method + +## 2.3.0 - 2022-06-09 + +### Fixed + +- Added `Header::splitList` method +- Added `Utils::tryGetContents` method +- Improved `Stream::getContents` method +- Updated mimetype mappings + +## 2.2.2 - 2022-06-08 + +### Fixed + +- Fix `Message::parseRequestUri` for numeric headers +- Re-wrap exceptions thrown in `fread` into runtime exceptions +- Throw an exception when multipart options is misformatted + +## 2.2.1 - 2022-03-20 + +### Fixed + +- Correct header value validation + +## 2.2.0 - 2022-03-20 + +### Added + +- A more compressive list of mime types +- Add JsonSerializable to Uri +- Missing return types + +### Fixed + +- Bug MultipartStream no `uri` metadata +- Bug MultipartStream with filename for `data://` streams +- Fixed new line handling in MultipartStream +- Reduced RAM usage when copying streams +- Updated parsing in `Header::normalize()` + +## 2.1.1 - 2022-03-20 + +### Fixed + +- Validate header values properly + +## 2.1.0 - 2021-10-06 + +### Changed + +- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic + `InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former + for backwards compatibility. Callers relying on the exception being thrown to detect invalid + URIs should catch the new exception. + +### Fixed + +- Return `null` in caching stream size if remote size is `null` + +## 2.0.0 - 2021-06-30 + +Identical to the RC release. + +## 2.0.0@RC-1 - 2021-04-29 + +### Fixed + +- Handle possibly unset `url` in `stream_get_meta_data` + +## 2.0.0@beta-1 - 2021-03-21 + +### Added + +- PSR-17 factories +- Made classes final +- PHP7 type hints + +### Changed + +- When building a query string, booleans are represented as 1 and 0. + +### Removed + +- PHP < 7.2 support +- All functions in the `GuzzleHttp\Psr7` namespace + +## 1.8.1 - 2021-03-21 + +### Fixed + +- Issue parsing IPv6 URLs +- Issue modifying ServerRequest lost all its attributes + +## 1.8.0 - 2021-03-21 + +### Added + +- Locale independent URL parsing +- Most classes got a `@final` annotation to prepare for 2.0 + +### Fixed + +- Issue when creating stream from `php://input` and curl-ext is not installed +- Broken `Utils::tryFopen()` on PHP 8 + +## 1.7.0 - 2020-09-30 + +### Added + +- Replaced functions by static methods + +### Fixed + +- Converting a non-seekable stream to a string +- Handle multiple Set-Cookie correctly +- Ignore array keys in header values when merging +- Allow multibyte characters to be parsed in `Message:bodySummary()` + +### Changed + +- Restored partial HHVM 3 support + + +## [1.6.1] - 2019-07-02 + +### Fixed + +- Accept null and bool header values again + + +## [1.6.0] - 2019-06-30 + +### Added + +- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244) +- Added MIME type for WEBP image format (#246) +- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272) + +### Changed + +- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262) +- Accept port number 0 to be valid (#270) + +### Fixed + +- Fixed subsequent reads from `php://input` in ServerRequest (#247) +- Fixed readable/writable detection for certain stream modes (#248) +- Fixed encoding of special characters in the `userInfo` component of an URI (#253) + + +## [1.5.2] - 2018-12-04 + +### Fixed + +- Check body size when getting the message summary + + +## [1.5.1] - 2018-12-04 + +### Fixed + +- Get the summary of a body only if it is readable + + +## [1.5.0] - 2018-12-03 + +### Added + +- Response first-line to response string exception (fixes #145) +- A test for #129 behavior +- `get_message_body_summary` function in order to get the message summary +- `3gp` and `mkv` mime types + +### Changed + +- Clarify exception message when stream is detached + +### Deprecated + +- Deprecated parsing folded header lines as per RFC 7230 + +### Fixed + +- Fix `AppendStream::detach` to not close streams +- `InflateStream` preserves `isSeekable` attribute of the underlying stream +- `ServerRequest::getUriFromGlobals` to support URLs in query parameters + + +Several other fixes and improvements. + + +## [1.4.2] - 2017-03-20 + +### Fixed + +- Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing + calls to `trigger_error` when deprecated methods are invoked. + + +## [1.4.1] - 2017-02-27 + +### Added + +- Rriggering of silenced deprecation warnings. + +### Fixed + +- Reverted BC break by reintroducing behavior to automagically fix a URI with a + relative path and an authority by adding a leading slash to the path. It's only + deprecated now. + + +## [1.4.0] - 2017-02-21 + +### Added + +- Added common URI utility methods based on RFC 3986 (see documentation in the readme): + - `Uri::isDefaultPort` + - `Uri::isAbsolute` + - `Uri::isNetworkPathReference` + - `Uri::isAbsolutePathReference` + - `Uri::isRelativePathReference` + - `Uri::isSameDocumentReference` + - `Uri::composeComponents` + - `UriNormalizer::normalize` + - `UriNormalizer::isEquivalent` + - `UriResolver::relativize` + +### Changed + +- Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form. +- Allow `parse_response` to parse a response without delimiting space and reason. +- Ensure each URI modification results in a valid URI according to PSR-7 discussions. + Invalid modifications will throw an exception instead of returning a wrong URI or + doing some magic. + - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception + because the path of a URI with an authority must start with a slash "/" or be empty + - `(new Uri())->withScheme('http')` will return `'http://localhost'` + +### Deprecated + +- `Uri::resolve` in favor of `UriResolver::resolve` +- `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments` + +### Fixed + +- `Stream::read` when length parameter <= 0. +- `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory. +- `ServerRequest::getUriFromGlobals` when `Host` header contains port. +- Compatibility of URIs with `file` scheme and empty host. + + +## [1.3.1] - 2016-06-25 + +### Fixed + +- `Uri::__toString` for network path references, e.g. `//example.org`. +- Missing lowercase normalization for host. +- Handling of URI components in case they are `'0'` in a lot of places, + e.g. as a user info password. +- `Uri::withAddedHeader` to correctly merge headers with different case. +- Trimming of header values in `Uri::withAddedHeader`. Header values may + be surrounded by whitespace which should be ignored according to RFC 7230 + Section 3.2.4. This does not apply to header names. +- `Uri::withAddedHeader` with an array of header values. +- `Uri::resolve` when base path has no slash and handling of fragment. +- Handling of encoding in `Uri::with(out)QueryValue` so one can pass the + key/value both in encoded as well as decoded form to those methods. This is + consistent with withPath, withQuery etc. +- `ServerRequest::withoutAttribute` when attribute value is null. + + +## [1.3.0] - 2016-04-13 + +### Added + +- Remaining interfaces needed for full PSR7 compatibility + (ServerRequestInterface, UploadedFileInterface, etc.). +- Support for stream_for from scalars. + +### Changed + +- Can now extend Uri. + +### Fixed +- A bug in validating request methods by making it more permissive. + + +## [1.2.3] - 2016-02-18 + +### Fixed + +- Support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote + streams, which can sometimes return fewer bytes than requested with `fread`. +- Handling of gzipped responses with FNAME headers. + + +## [1.2.2] - 2016-01-22 + +### Added + +- Support for URIs without any authority. +- Support for HTTP 451 'Unavailable For Legal Reasons.' +- Support for using '0' as a filename. +- Support for including non-standard ports in Host headers. + + +## [1.2.1] - 2015-11-02 + +### Changes + +- Now supporting negative offsets when seeking to SEEK_END. + + +## [1.2.0] - 2015-08-15 + +### Changed + +- Body as `"0"` is now properly added to a response. +- Now allowing forward seeking in CachingStream. +- Now properly parsing HTTP requests that contain proxy targets in + `parse_request`. +- functions.php is now conditionally required. +- user-info is no longer dropped when resolving URIs. + + +## [1.1.0] - 2015-06-24 + +### Changed + +- URIs can now be relative. +- `multipart/form-data` headers are now overridden case-insensitively. +- URI paths no longer encode the following characters because they are allowed + in URIs: "(", ")", "*", "!", "'" +- A port is no longer added to a URI when the scheme is missing and no port is + present. + + +## 1.0.0 - 2015-05-19 + +Initial release. + +Currently unsupported: + +- `Psr\Http\Message\ServerRequestInterface` +- `Psr\Http\Message\UploadedFileInterface` + + + +[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0 +[1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2 +[1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1 +[1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0 +[1.4.2]: https://github.com/guzzle/psr7/compare/1.4.1...1.4.2 +[1.4.1]: https://github.com/guzzle/psr7/compare/1.4.0...1.4.1 +[1.4.0]: https://github.com/guzzle/psr7/compare/1.3.1...1.4.0 +[1.3.1]: https://github.com/guzzle/psr7/compare/1.3.0...1.3.1 +[1.3.0]: https://github.com/guzzle/psr7/compare/1.2.3...1.3.0 +[1.2.3]: https://github.com/guzzle/psr7/compare/1.2.2...1.2.3 +[1.2.2]: https://github.com/guzzle/psr7/compare/1.2.1...1.2.2 +[1.2.1]: https://github.com/guzzle/psr7/compare/1.2.0...1.2.1 +[1.2.0]: https://github.com/guzzle/psr7/compare/1.1.0...1.2.0 +[1.1.0]: https://github.com/guzzle/psr7/compare/1.0.0...1.1.0 diff --git a/vendor/guzzlehttp/psr7/LICENSE b/vendor/guzzlehttp/psr7/LICENSE new file mode 100644 index 0000000..51c7ec8 --- /dev/null +++ b/vendor/guzzlehttp/psr7/LICENSE @@ -0,0 +1,26 @@ +The MIT License (MIT) + +Copyright (c) 2015 Michael Dowling +Copyright (c) 2015 Márk Sági-Kazár +Copyright (c) 2015 Graham Campbell +Copyright (c) 2016 Tobias Schultze +Copyright (c) 2016 George Mponos +Copyright (c) 2018 Tobias Nyholm + +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/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md new file mode 100644 index 0000000..2e9bb0b --- /dev/null +++ b/vendor/guzzlehttp/psr7/README.md @@ -0,0 +1,887 @@ +# PSR-7 Message Implementation + +This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/) +message implementation, several stream decorators, and some helpful +functionality like query string parsing. + +![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg) +![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg) + + +## Features + +This package comes with a number of stream implementations and stream +decorators. + + +## Installation + +```shell +composer require guzzlehttp/psr7 +``` + +## Version Guidance + +| Version | Status | PHP Version | +|---------|---------------------|--------------| +| 1.x | EOL (2024-06-30) | >=5.4,<8.2 | +| 2.x | Latest | >=7.2.5,<8.5 | + + +## AppendStream + +`GuzzleHttp\Psr7\AppendStream` + +Reads from multiple streams, one after the other. + +```php +use GuzzleHttp\Psr7; + +$a = Psr7\Utils::streamFor('abc, '); +$b = Psr7\Utils::streamFor('123.'); +$composed = new Psr7\AppendStream([$a, $b]); + +$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me')); + +echo $composed; // abc, 123. Above all listen to me. +``` + + +## BufferStream + +`GuzzleHttp\Psr7\BufferStream` + +Provides a buffer stream that can be written to fill a buffer, and read +from to remove bytes from the buffer. + +This stream returns a "hwm" metadata value that tells upstream consumers +what the configured high water mark of the stream is, or the maximum +preferred size of the buffer. + +```php +use GuzzleHttp\Psr7; + +// When more than 1024 bytes are in the buffer, it will begin returning +// false to writes. This is an indication that writers should slow down. +$buffer = new Psr7\BufferStream(1024); +``` + + +## CachingStream + +The CachingStream is used to allow seeking over previously read bytes on +non-seekable streams. This can be useful when transferring a non-seekable +entity body fails due to needing to rewind the stream (for example, resulting +from a redirect). Data that is read from the remote stream will be buffered in +a PHP temp stream so that previously read bytes are cached first in memory, +then on disk. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r')); +$stream = new Psr7\CachingStream($original); + +$stream->read(1024); +echo $stream->tell(); +// 1024 + +$stream->seek(0); +echo $stream->tell(); +// 0 +``` + + +## DroppingStream + +`GuzzleHttp\Psr7\DroppingStream` + +Stream decorator that begins dropping data once the size of the underlying +stream becomes too full. + +```php +use GuzzleHttp\Psr7; + +// Create an empty stream +$stream = Psr7\Utils::streamFor(); + +// Start dropping data when the stream has more than 10 bytes +$dropping = new Psr7\DroppingStream($stream, 10); + +$dropping->write('01234567890123456789'); +echo $stream; // 0123456789 +``` + + +## FnStream + +`GuzzleHttp\Psr7\FnStream` + +Compose stream implementations based on a hash of functions. + +Allows for easy testing and extension of a provided stream without needing +to create a concrete class for a simple extension point. + +```php + +use GuzzleHttp\Psr7; + +$stream = Psr7\Utils::streamFor('hi'); +$fnStream = Psr7\FnStream::decorate($stream, [ + 'rewind' => function () use ($stream) { + echo 'About to rewind - '; + $stream->rewind(); + echo 'rewound!'; + } +]); + +$fnStream->rewind(); +// Outputs: About to rewind - rewound! +``` + + +## InflateStream + +`GuzzleHttp\Psr7\InflateStream` + +Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content. + +This stream decorator converts the provided stream to a PHP stream resource, +then appends the zlib.inflate filter. The stream is then converted back +to a Guzzle stream resource to be used as a Guzzle stream. + + +## LazyOpenStream + +`GuzzleHttp\Psr7\LazyOpenStream` + +Lazily reads or writes to a file that is opened only after an IO operation +take place on the stream. + +```php +use GuzzleHttp\Psr7; + +$stream = new Psr7\LazyOpenStream('/path/to/file', 'r'); +// The file has not yet been opened... + +echo $stream->read(10); +// The file is opened and read from only when needed. +``` + + +## LimitStream + +`GuzzleHttp\Psr7\LimitStream` + +LimitStream can be used to read a subset or slice of an existing stream object. +This can be useful for breaking a large file into smaller pieces to be sent in +chunks (e.g. Amazon S3's multipart upload API). + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+')); +echo $original->getSize(); +// >>> 1048576 + +// Limit the size of the body to 1024 bytes and start reading from byte 2048 +$stream = new Psr7\LimitStream($original, 1024, 2048); +echo $stream->getSize(); +// >>> 1024 +echo $stream->tell(); +// >>> 0 +``` + + +## MultipartStream + +`GuzzleHttp\Psr7\MultipartStream` + +Stream that when read returns bytes for a streaming multipart or +multipart/form-data stream. + + +## NoSeekStream + +`GuzzleHttp\Psr7\NoSeekStream` + +NoSeekStream wraps a stream and does not allow seeking. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor('foo'); +$noSeek = new Psr7\NoSeekStream($original); + +echo $noSeek->read(3); +// foo +var_export($noSeek->isSeekable()); +// false +$noSeek->seek(0); +var_export($noSeek->read(3)); +// NULL +``` + + +## PumpStream + +`GuzzleHttp\Psr7\PumpStream` + +Provides a read only stream that pumps data from a PHP callable. + +When invoking the provided callable, the PumpStream will pass the amount of +data requested to read to the callable. The callable can choose to ignore +this value and return fewer or more bytes than requested. Any extra data +returned by the provided callable is buffered internally until drained using +the read() function of the PumpStream. The provided callable MUST return +false when there is no more data to read. + + +## Implementing stream decorators + +Creating a stream decorator is very easy thanks to the +`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that +implement `Psr\Http\Message\StreamInterface` by proxying to an underlying +stream. Just `use` the `StreamDecoratorTrait` and implement your custom +methods. + +For example, let's say we wanted to call a specific function each time the last +byte is read from a stream. This could be implemented by overriding the +`read()` method. + +```php +use Psr\Http\Message\StreamInterface; +use GuzzleHttp\Psr7\StreamDecoratorTrait; + +class EofCallbackStream implements StreamInterface +{ + use StreamDecoratorTrait; + + private $callback; + + private $stream; + + public function __construct(StreamInterface $stream, callable $cb) + { + $this->stream = $stream; + $this->callback = $cb; + } + + public function read($length) + { + $result = $this->stream->read($length); + + // Invoke the callback when EOF is hit. + if ($this->eof()) { + ($this->callback)(); + } + + return $result; + } +} +``` + +This decorator could be added to any existing stream and used like so: + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\Utils::streamFor('foo'); + +$eofStream = new EofCallbackStream($original, function () { + echo 'EOF!'; +}); + +$eofStream->read(2); +$eofStream->read(1); +// echoes "EOF!" +$eofStream->seek(0); +$eofStream->read(3); +// echoes "EOF!" +``` + + +## PHP StreamWrapper + +You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a +PSR-7 stream as a PHP stream resource. + +Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP +stream from a PSR-7 stream. + +```php +use GuzzleHttp\Psr7\StreamWrapper; + +$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!'); +$resource = StreamWrapper::getResource($stream); +echo fread($resource, 6); // outputs hello! +``` + + +# Static API + +There are various static methods available under the `GuzzleHttp\Psr7` namespace. + + +## `GuzzleHttp\Psr7\Message::toString` + +`public static function toString(MessageInterface $message): string` + +Returns the string representation of an HTTP message. + +```php +$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); +echo GuzzleHttp\Psr7\Message::toString($request); +``` + + +## `GuzzleHttp\Psr7\Message::bodySummary` + +`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null` + +Get a short summary of the message body. + +Will return `null` if the response is not printable. + + +## `GuzzleHttp\Psr7\Message::rewindBody` + +`public static function rewindBody(MessageInterface $message): void` + +Attempts to rewind a message body and throws an exception on failure. + +The body of the message will only be rewound if a call to `tell()` +returns a value other than `0`. + + +## `GuzzleHttp\Psr7\Message::parseMessage` + +`public static function parseMessage(string $message): array` + +Parses an HTTP message into an associative array. + +The array contains the "start-line" key containing the start line of +the message, "headers" key containing an associative array of header +array values, and a "body" key containing the body of the message. + + +## `GuzzleHttp\Psr7\Message::parseRequestUri` + +`public static function parseRequestUri(string $path, array $headers): string` + +Constructs a URI for an HTTP request message. + + +## `GuzzleHttp\Psr7\Message::parseRequest` + +`public static function parseRequest(string $message): Request` + +Parses a request message string into a request object. + + +## `GuzzleHttp\Psr7\Message::parseResponse` + +`public static function parseResponse(string $message): Response` + +Parses a response message string into a response object. + + +## `GuzzleHttp\Psr7\Header::parse` + +`public static function parse(string|array $header): array` + +Parse an array of header values containing ";" separated data into an +array of associative arrays representing the header key value pair data +of the header. When a parameter does not contain a value, but just +contains a key, this function will inject a key with a '' string value. + + +## `GuzzleHttp\Psr7\Header::splitList` + +`public static function splitList(string|string[] $header): string[]` + +Splits a HTTP header defined to contain a comma-separated list into +each individual value: + +``` +$knownEtags = Header::splitList($request->getHeader('if-none-match')); +``` + +Example headers include `accept`, `cache-control` and `if-none-match`. + + +## `GuzzleHttp\Psr7\Header::normalize` (deprecated) + +`public static function normalize(string|array $header): array` + +`Header::normalize()` is deprecated in favor of [`Header::splitList()`](README.md#guzzlehttppsr7headersplitlist) +which performs the same operation with a cleaned up API and improved +documentation. + +Converts an array of header values that may contain comma separated +headers into an array of headers with no comma separated values. + + +## `GuzzleHttp\Psr7\Query::parse` + +`public static function parse(string $str, int|bool $urlEncoding = true): array` + +Parse a query string into an associative array. + +If multiple values are found for the same key, the value of that key +value pair will become an array. This function does not parse nested +PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2` +will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`. + + +## `GuzzleHttp\Psr7\Query::build` + +`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986, bool $treatBoolsAsInts = true): string` + +Build a query string from an array of key value pairs. + +This function can use the return value of `parse()` to build a query +string. This function does not modify the provided keys when an array is +encountered (like `http_build_query()` would). + + +## `GuzzleHttp\Psr7\Utils::caselessRemove` + +`public static function caselessRemove(iterable $keys, $keys, array $data): array` + +Remove the items given by the keys, case insensitively from the data. + + +## `GuzzleHttp\Psr7\Utils::copyToStream` + +`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void` + +Copy the contents of a stream into another stream until the given number +of bytes have been read. + + +## `GuzzleHttp\Psr7\Utils::copyToString` + +`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string` + +Copy the contents of a stream into a string until the given number of +bytes have been read. + + +## `GuzzleHttp\Psr7\Utils::hash` + +`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string` + +Calculate a hash of a stream. + +This method reads the entire stream to calculate a rolling hash, based on +PHP's `hash_init` functions. + + +## `GuzzleHttp\Psr7\Utils::modifyRequest` + +`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface` + +Clone and modify a request with the given changes. + +This method is useful for reducing the number of clones needed to mutate +a message. + +- method: (string) Changes the HTTP method. +- set_headers: (array) Sets the given headers. +- remove_headers: (array) Remove the given headers. +- body: (mixed) Sets the given body. +- uri: (UriInterface) Set the URI. +- query: (string) Set the query string value of the URI. +- version: (string) Set the protocol version. + + +## `GuzzleHttp\Psr7\Utils::readLine` + +`public static function readLine(StreamInterface $stream, ?int $maxLength = null): string` + +Read a line from the stream up to the maximum allowed buffer length. + + +## `GuzzleHttp\Psr7\Utils::redactUserInfo` + +`public static function redactUserInfo(UriInterface $uri): UriInterface` + +Redact the password in the user info part of a URI. + + +## `GuzzleHttp\Psr7\Utils::streamFor` + +`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface` + +Create a new stream based on the input type. + +Options is an associative array that can contain the following keys: + +- metadata: Array of custom metadata. +- size: Size of the stream. + +This method accepts the following `$resource` types: + +- `Psr\Http\Message\StreamInterface`: Returns the value as-is. +- `string`: Creates a stream object that uses the given string as the contents. +- `resource`: Creates a stream object that wraps the given PHP stream resource. +- `Iterator`: If the provided value implements `Iterator`, then a read-only + stream object will be created that wraps the given iterable. Each time the + stream is read from, data from the iterator will fill a buffer and will be + continuously called until the buffer is equal to the requested read size. + Subsequent read calls will first read from the buffer and then call `next` + on the underlying iterator until it is exhausted. +- `object` with `__toString()`: If the object has the `__toString()` method, + the object will be cast to a string and then a stream will be returned that + uses the string value. +- `NULL`: When `null` is passed, an empty stream object is returned. +- `callable` When a callable is passed, a read-only stream object will be + created that invokes the given callable. The callable is invoked with the + number of suggested bytes to read. The callable can return any number of + bytes, but MUST return `false` when there is no more data to return. The + stream object that wraps the callable will invoke the callable until the + number of requested bytes are available. Any additional bytes will be + buffered and used in subsequent reads. + +```php +$stream = GuzzleHttp\Psr7\Utils::streamFor('foo'); +$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r')); + +$generator = function ($bytes) { + for ($i = 0; $i < $bytes; $i++) { + yield ' '; + } +} + +$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100)); +``` + + +## `GuzzleHttp\Psr7\Utils::tryFopen` + +`public static function tryFopen(string $filename, string $mode): resource` + +Safely opens a PHP stream resource using a filename. + +When fopen fails, PHP normally raises a warning. This function adds an +error handler that checks for errors and throws an exception instead. + + +## `GuzzleHttp\Psr7\Utils::tryGetContents` + +`public static function tryGetContents(resource $stream): string` + +Safely gets the contents of a given stream. + +When stream_get_contents fails, PHP normally raises a warning. This +function adds an error handler that checks for errors and throws an +exception instead. + + +## `GuzzleHttp\Psr7\Utils::uriFor` + +`public static function uriFor(string|UriInterface $uri): UriInterface` + +Returns a UriInterface for the given value. + +This function accepts a string or UriInterface and returns a +UriInterface for the given value. If the value is already a +UriInterface, it is returned as-is. + + +## `GuzzleHttp\Psr7\MimeType::fromFilename` + +`public static function fromFilename(string $filename): string|null` + +Determines the mimetype of a file by looking at its extension. + + +## `GuzzleHttp\Psr7\MimeType::fromExtension` + +`public static function fromExtension(string $extension): string|null` + +Maps a file extensions to a mimetype. + + +## Upgrading from Function API + +The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience: + +| Original Function | Replacement Method | +|----------------|----------------| +| `str` | `Message::toString` | +| `uri_for` | `Utils::uriFor` | +| `stream_for` | `Utils::streamFor` | +| `parse_header` | `Header::parse` | +| `normalize_header` | `Header::normalize` | +| `modify_request` | `Utils::modifyRequest` | +| `rewind_body` | `Message::rewindBody` | +| `try_fopen` | `Utils::tryFopen` | +| `copy_to_string` | `Utils::copyToString` | +| `copy_to_stream` | `Utils::copyToStream` | +| `hash` | `Utils::hash` | +| `readline` | `Utils::readLine` | +| `parse_request` | `Message::parseRequest` | +| `parse_response` | `Message::parseResponse` | +| `parse_query` | `Query::parse` | +| `build_query` | `Query::build` | +| `mimetype_from_filename` | `MimeType::fromFilename` | +| `mimetype_from_extension` | `MimeType::fromExtension` | +| `_parse_message` | `Message::parseMessage` | +| `_parse_request_uri` | `Message::parseRequestUri` | +| `get_message_body_summary` | `Message::bodySummary` | +| `_caseless_remove` | `Utils::caselessRemove` | + + +# Additional URI Methods + +Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class, +this library also provides additional functionality when working with URIs as static methods. + +## URI Types + +An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference. +An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, +the base URI. Relative references can be divided into several forms according to +[RFC 3986 Section 4.2](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2): + +- network-path references, e.g. `//example.com/path` +- absolute-path references, e.g. `/path` +- relative-path references, e.g. `subpath` + +The following methods can be used to identify the type of the URI. + +### `GuzzleHttp\Psr7\Uri::isAbsolute` + +`public static function isAbsolute(UriInterface $uri): bool` + +Whether the URI is absolute, i.e. it has a scheme. + +### `GuzzleHttp\Psr7\Uri::isNetworkPathReference` + +`public static function isNetworkPathReference(UriInterface $uri): bool` + +Whether the URI is a network-path reference. A relative reference that begins with two slash characters is +termed an network-path reference. + +### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference` + +`public static function isAbsolutePathReference(UriInterface $uri): bool` + +Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is +termed an absolute-path reference. + +### `GuzzleHttp\Psr7\Uri::isRelativePathReference` + +`public static function isRelativePathReference(UriInterface $uri): bool` + +Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is +termed a relative-path reference. + +### `GuzzleHttp\Psr7\Uri::isSameDocumentReference` + +`public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool` + +Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its +fragment component, identical to the base URI. When no base URI is given, only an empty URI reference +(apart from its fragment) is considered a same-document reference. + +## URI Components + +Additional methods to work with URI components. + +### `GuzzleHttp\Psr7\Uri::isDefaultPort` + +`public static function isDefaultPort(UriInterface $uri): bool` + +Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null +or the standard port. This method can be used independently of the implementation. + +### `GuzzleHttp\Psr7\Uri::composeComponents` + +`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string` + +Composes a URI reference string from its various components according to +[RFC 3986 Section 5.3](https://datatracker.ietf.org/doc/html/rfc3986#section-5.3). Usually this method does not need +to be called manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`. + +### `GuzzleHttp\Psr7\Uri::fromParts` + +`public static function fromParts(array $parts): UriInterface` + +Creates a URI from a hash of [`parse_url`](https://www.php.net/manual/en/function.parse-url.php) components. + + +### `GuzzleHttp\Psr7\Uri::withQueryValue` + +`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface` + +Creates a new URI with a specific query string value. Any existing query string values that exactly match the +provided key are removed and replaced with the given key value pair. A value of null will set the query string +key without a value, e.g. "key" instead of "key=value". + +### `GuzzleHttp\Psr7\Uri::withQueryValues` + +`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface` + +Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an +associative array of key => value. + +### `GuzzleHttp\Psr7\Uri::withoutQueryValue` + +`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface` + +Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the +provided key are removed. + +## Cross-Origin Detection + +`GuzzleHttp\Psr7\UriComparator` provides methods to determine if a modified URL should be considered cross-origin. + +### `GuzzleHttp\Psr7\UriComparator::isCrossOrigin` + +`public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool` + +Determines if a modified URL should be considered cross-origin with respect to an original URL. + +## Reference Resolution + +`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according +to [RFC 3986 Section 5](https://datatracker.ietf.org/doc/html/rfc3986#section-5). This is for example also what web +browsers do when resolving a link in a website based on the current request URI. + +### `GuzzleHttp\Psr7\UriResolver::resolve` + +`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface` + +Converts the relative URI into a new URI that is resolved against the base URI. + +### `GuzzleHttp\Psr7\UriResolver::removeDotSegments` + +`public static function removeDotSegments(string $path): string` + +Removes dot segments from a path and returns the new path according to +[RFC 3986 Section 5.2.4](https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4). + +### `GuzzleHttp\Psr7\UriResolver::relativize` + +`public static function relativize(UriInterface $base, UriInterface $target): UriInterface` + +Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve(): + +```php +(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) +``` + +One use-case is to use the current request URI as base URI and then generate relative links in your documents +to reduce the document size or offer self-contained downloadable document archives. + +```php +$base = new Uri('http://example.com/a/b/'); +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. +echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. +``` + +## Normalization and Comparison + +`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to +[RFC 3986 Section 6](https://datatracker.ietf.org/doc/html/rfc3986#section-6). + +### `GuzzleHttp\Psr7\UriNormalizer::normalize` + +`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface` + +Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. +This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask +of normalizations to apply. The following normalizations are available: + +- `UriNormalizer::PRESERVING_NORMALIZATIONS` + + Default normalizations which only include the ones that preserve semantics. + +- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING` + + All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. + + Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b` + +- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS` + + Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of + ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should + not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved + characters by URI normalizers. + + Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/` + +- `UriNormalizer::CONVERT_EMPTY_PATH` + + Converts the empty path to "/" for http and https URIs. + + Example: `http://example.org` → `http://example.org/` + +- `UriNormalizer::REMOVE_DEFAULT_HOST` + + Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host + "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to + RFC 3986. + + Example: `file://localhost/myfile` → `file:///myfile` + +- `UriNormalizer::REMOVE_DEFAULT_PORT` + + Removes the default port of the given URI scheme from the URI. + + Example: `http://example.org:80/` → `http://example.org/` + +- `UriNormalizer::REMOVE_DOT_SEGMENTS` + + Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would + change the semantics of the URI reference. + + Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html` + +- `UriNormalizer::REMOVE_DUPLICATE_SLASHES` + + Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes + and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization + may change the semantics. Encoded slashes (%2F) are not removed. + + Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html` + +- `UriNormalizer::SORT_QUERY_PARAMETERS` + + Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be + significant (this is not defined by the standard). So this normalization is not safe and may change the semantics + of the URI. + + Example: `?lang=en&article=fred` → `?article=fred&lang=en` + +### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent` + +`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool` + +Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given +`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent. +This of course assumes they will be resolved against the same base URI. If this is not the case, determination of +equivalence or difference of relative references does not mean anything. + + +## Security + +If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information. + + +## License + +Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information. + + +## For Enterprise + +Available as part of the Tidelift Subscription + +The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver 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. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-psr7?utm_source=packagist-guzzlehttp-psr7&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json new file mode 100644 index 0000000..28d15f5 --- /dev/null +++ b/vendor/guzzlehttp/psr7/composer.json @@ -0,0 +1,93 @@ +{ + "name": "guzzlehttp/psr7", + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "request", + "response", + "message", + "stream", + "http", + "uri", + "url", + "psr-7" + ], + "license": "MIT", + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "GuzzleHttp\\Tests\\Psr7\\": "tests/" + } + }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, + "preferred-install": "dist", + "sort-packages": true + } +} diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php new file mode 100644 index 0000000..ee8f378 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/AppendStream.php @@ -0,0 +1,248 @@ +addStream($stream); + } + } + + public function __toString(): string + { + try { + $this->rewind(); + + return $this->getContents(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + /** + * Add a stream to the AppendStream + * + * @param StreamInterface $stream Stream to append. Must be readable. + * + * @throws \InvalidArgumentException if the stream is not readable + */ + public function addStream(StreamInterface $stream): void + { + if (!$stream->isReadable()) { + throw new \InvalidArgumentException('Each stream must be readable'); + } + + // The stream is only seekable if all streams are seekable + if (!$stream->isSeekable()) { + $this->seekable = false; + } + + $this->streams[] = $stream; + } + + public function getContents(): string + { + return Utils::copyToString($this); + } + + /** + * Closes each attached stream. + */ + public function close(): void + { + $this->pos = $this->current = 0; + $this->seekable = true; + + foreach ($this->streams as $stream) { + $stream->close(); + } + + $this->streams = []; + } + + /** + * Detaches each attached stream. + * + * Returns null as it's not clear which underlying stream resource to return. + */ + public function detach() + { + $this->pos = $this->current = 0; + $this->seekable = true; + + foreach ($this->streams as $stream) { + $stream->detach(); + } + + $this->streams = []; + + return null; + } + + public function tell(): int + { + return $this->pos; + } + + /** + * Tries to calculate the size by adding the size of each stream. + * + * If any of the streams do not return a valid number, then the size of the + * append stream cannot be determined and null is returned. + */ + public function getSize(): ?int + { + $size = 0; + + foreach ($this->streams as $stream) { + $s = $stream->getSize(); + if ($s === null) { + return null; + } + $size += $s; + } + + return $size; + } + + public function eof(): bool + { + return !$this->streams + || ($this->current >= count($this->streams) - 1 + && $this->streams[$this->current]->eof()); + } + + public function rewind(): void + { + $this->seek(0); + } + + /** + * Attempts to seek to the given position. Only supports SEEK_SET. + */ + public function seek($offset, $whence = SEEK_SET): void + { + if (!$this->seekable) { + throw new \RuntimeException('This AppendStream is not seekable'); + } elseif ($whence !== SEEK_SET) { + throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); + } + + $this->pos = $this->current = 0; + + // Rewind each stream + foreach ($this->streams as $i => $stream) { + try { + $stream->rewind(); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to seek stream ' + .$i.' of the AppendStream', 0, $e); + } + } + + // Seek to the actual position by reading from each stream + while ($this->pos < $offset && !$this->eof()) { + $result = $this->read(min(8096, $offset - $this->pos)); + if ($result === '') { + break; + } + } + } + + /** + * Reads from all of the appended streams until the length is met or EOF. + */ + public function read($length): string + { + $buffer = ''; + $total = count($this->streams) - 1; + $remaining = $length; + $progressToNext = false; + + while ($remaining > 0) { + // Progress to the next stream if needed. + if ($progressToNext || $this->streams[$this->current]->eof()) { + $progressToNext = false; + if ($this->current === $total) { + break; + } + ++$this->current; + } + + $result = $this->streams[$this->current]->read($remaining); + + if ($result === '') { + $progressToNext = true; + continue; + } + + $buffer .= $result; + $remaining = $length - strlen($buffer); + } + + $this->pos += strlen($buffer); + + return $buffer; + } + + public function isReadable(): bool + { + return true; + } + + public function isWritable(): bool + { + return false; + } + + public function isSeekable(): bool + { + return $this->seekable; + } + + public function write($string): int + { + throw new \RuntimeException('Cannot write to an AppendStream'); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + return $key ? null : []; + } +} diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php new file mode 100644 index 0000000..2b0eb77 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/BufferStream.php @@ -0,0 +1,147 @@ +hwm = $hwm; + } + + public function __toString(): string + { + return $this->getContents(); + } + + public function getContents(): string + { + $buffer = $this->buffer; + $this->buffer = ''; + + return $buffer; + } + + public function close(): void + { + $this->buffer = ''; + } + + public function detach() + { + $this->close(); + + return null; + } + + public function getSize(): ?int + { + return strlen($this->buffer); + } + + public function isReadable(): bool + { + return true; + } + + public function isWritable(): bool + { + return true; + } + + public function isSeekable(): bool + { + return false; + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + throw new \RuntimeException('Cannot seek a BufferStream'); + } + + public function eof(): bool + { + return strlen($this->buffer) === 0; + } + + public function tell(): int + { + throw new \RuntimeException('Cannot determine the position of a BufferStream'); + } + + /** + * Reads data from the buffer. + */ + public function read($length): string + { + $currentLength = strlen($this->buffer); + + if ($length >= $currentLength) { + // No need to slice the buffer because we don't have enough data. + $result = $this->buffer; + $this->buffer = ''; + } else { + // Slice up the result to provide a subset of the buffer. + $result = substr($this->buffer, 0, $length); + $this->buffer = substr($this->buffer, $length); + } + + return $result; + } + + /** + * Writes data to the buffer. + */ + public function write($string): int + { + $this->buffer .= $string; + + if (strlen($this->buffer) >= $this->hwm) { + return 0; + } + + return strlen($string); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + if ($key === 'hwm') { + return $this->hwm; + } + + return $key ? null : []; + } +} diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php new file mode 100644 index 0000000..7e4554d --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -0,0 +1,153 @@ +remoteStream = $stream; + $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+')); + } + + public function getSize(): ?int + { + $remoteSize = $this->remoteStream->getSize(); + + if (null === $remoteSize) { + return null; + } + + return max($this->stream->getSize(), $remoteSize); + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + if ($whence === SEEK_SET) { + $byte = $offset; + } elseif ($whence === SEEK_CUR) { + $byte = $offset + $this->tell(); + } elseif ($whence === SEEK_END) { + $size = $this->remoteStream->getSize(); + if ($size === null) { + $size = $this->cacheEntireStream(); + } + $byte = $size + $offset; + } else { + throw new \InvalidArgumentException('Invalid whence'); + } + + $diff = $byte - $this->stream->getSize(); + + if ($diff > 0) { + // Read the remoteStream until we have read in at least the amount + // of bytes requested, or we reach the end of the file. + while ($diff > 0 && !$this->remoteStream->eof()) { + $this->read($diff); + $diff = $byte - $this->stream->getSize(); + } + } else { + // We can just do a normal seek since we've already seen this byte. + $this->stream->seek($byte); + } + } + + public function read($length): string + { + // Perform a regular read on any previously read data from the buffer + $data = $this->stream->read($length); + $remaining = $length - strlen($data); + + // More data was requested so read from the remote stream + if ($remaining) { + // If data was written to the buffer in a position that would have + // been filled from the remote stream, then we must skip bytes on + // the remote stream to emulate overwriting bytes from that + // position. This mimics the behavior of other PHP stream wrappers. + $remoteData = $this->remoteStream->read( + $remaining + $this->skipReadBytes + ); + + if ($this->skipReadBytes) { + $len = strlen($remoteData); + $remoteData = substr($remoteData, $this->skipReadBytes); + $this->skipReadBytes = max(0, $this->skipReadBytes - $len); + } + + $data .= $remoteData; + $this->stream->write($remoteData); + } + + return $data; + } + + public function write($string): int + { + // When appending to the end of the currently read stream, you'll want + // to skip bytes from being read from the remote stream to emulate + // other stream wrappers. Basically replacing bytes of data of a fixed + // length. + $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); + if ($overflow > 0) { + $this->skipReadBytes += $overflow; + } + + return $this->stream->write($string); + } + + public function eof(): bool + { + return $this->stream->eof() && $this->remoteStream->eof(); + } + + /** + * Close both the remote stream and buffer stream + */ + public function close(): void + { + $this->remoteStream->close(); + $this->stream->close(); + } + + private function cacheEntireStream(): int + { + $target = new FnStream(['write' => 'strlen']); + Utils::copyToStream($this, $target); + + return $this->tell(); + } +} diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php new file mode 100644 index 0000000..6e3d209 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/DroppingStream.php @@ -0,0 +1,49 @@ +stream = $stream; + $this->maxLength = $maxLength; + } + + public function write($string): int + { + $diff = $this->maxLength - $this->stream->getSize(); + + // Begin returning 0 when the underlying stream is too large. + if ($diff <= 0) { + return 0; + } + + // Write the stream or a subset of the stream if needed. + if (strlen($string) < $diff) { + return $this->stream->write($string); + } + + return $this->stream->write(substr($string, 0, $diff)); + } +} diff --git a/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php new file mode 100644 index 0000000..3a08477 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php @@ -0,0 +1,14 @@ + */ + private $methods; + + /** + * @param array $methods Hash of method name to a callable. + */ + public function __construct(array $methods) + { + $this->methods = $methods; + + // Create the functions on the class + foreach ($methods as $name => $fn) { + $this->{'_fn_'.$name} = $fn; + } + } + + /** + * Lazily determine which methods are not implemented. + * + * @throws \BadMethodCallException + */ + public function __get(string $name): void + { + throw new \BadMethodCallException(str_replace('_fn_', '', $name) + .'() is not implemented in the FnStream'); + } + + /** + * The close method is called on the underlying stream only if possible. + */ + public function __destruct() + { + if (isset($this->_fn_close)) { + ($this->_fn_close)(); + } + } + + /** + * An unserialize would allow the __destruct to run when the unserialized value goes out of scope. + * + * @throws \LogicException + */ + public function __wakeup(): void + { + throw new \LogicException('FnStream should never be unserialized'); + } + + /** + * Adds custom functionality to an underlying stream by intercepting + * specific method calls. + * + * @param StreamInterface $stream Stream to decorate + * @param array $methods Hash of method name to a closure + * + * @return FnStream + */ + public static function decorate(StreamInterface $stream, array $methods) + { + // If any of the required methods were not provided, then simply + // proxy to the decorated stream. + foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) { + /** @var callable $callable */ + $callable = [$stream, $diff]; + $methods[$diff] = $callable; + } + + return new self($methods); + } + + public function __toString(): string + { + try { + /** @var string */ + return ($this->_fn___toString)(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function close(): void + { + ($this->_fn_close)(); + } + + public function detach() + { + return ($this->_fn_detach)(); + } + + public function getSize(): ?int + { + return ($this->_fn_getSize)(); + } + + public function tell(): int + { + return ($this->_fn_tell)(); + } + + public function eof(): bool + { + return ($this->_fn_eof)(); + } + + public function isSeekable(): bool + { + return ($this->_fn_isSeekable)(); + } + + public function rewind(): void + { + ($this->_fn_rewind)(); + } + + public function seek($offset, $whence = SEEK_SET): void + { + ($this->_fn_seek)($offset, $whence); + } + + public function isWritable(): bool + { + return ($this->_fn_isWritable)(); + } + + public function write($string): int + { + return ($this->_fn_write)($string); + } + + public function isReadable(): bool + { + return ($this->_fn_isReadable)(); + } + + public function read($length): string + { + return ($this->_fn_read)($length); + } + + public function getContents(): string + { + return ($this->_fn_getContents)(); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + return ($this->_fn_getMetadata)($key); + } +} diff --git a/vendor/guzzlehttp/psr7/src/Header.php b/vendor/guzzlehttp/psr7/src/Header.php new file mode 100644 index 0000000..bbce8b0 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Header.php @@ -0,0 +1,134 @@ +]+>|[^=]+/', $kvp, $matches)) { + $m = $matches[0]; + if (isset($m[1])) { + $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); + } else { + $part[] = trim($m[0], $trimmed); + } + } + } + if ($part) { + $params[] = $part; + } + } + } + + return $params; + } + + /** + * Converts an array of header values that may contain comma separated + * headers into an array of headers with no comma separated values. + * + * @param string|array $header Header to normalize. + * + * @deprecated Use self::splitList() instead. + */ + public static function normalize($header): array + { + $result = []; + foreach ((array) $header as $value) { + foreach (self::splitList($value) as $parsed) { + $result[] = $parsed; + } + } + + return $result; + } + + /** + * Splits a HTTP header defined to contain a comma-separated list into + * each individual value. Empty values will be removed. + * + * Example headers include 'accept', 'cache-control' and 'if-none-match'. + * + * This method must not be used to parse headers that are not defined as + * a list, such as 'user-agent' or 'set-cookie'. + * + * @param string|string[] $values Header value as returned by MessageInterface::getHeader() + * + * @return string[] + */ + public static function splitList($values): array + { + if (!\is_array($values)) { + $values = [$values]; + } + + $result = []; + foreach ($values as $value) { + if (!\is_string($value)) { + throw new \TypeError('$header must either be a string or an array containing strings.'); + } + + $v = ''; + $isQuoted = false; + $isEscaped = false; + for ($i = 0, $max = \strlen($value); $i < $max; ++$i) { + if ($isEscaped) { + $v .= $value[$i]; + $isEscaped = false; + + continue; + } + + if (!$isQuoted && $value[$i] === ',') { + $v = \trim($v); + if ($v !== '') { + $result[] = $v; + } + + $v = ''; + continue; + } + + if ($isQuoted && $value[$i] === '\\') { + $isEscaped = true; + $v .= $value[$i]; + + continue; + } + if ($value[$i] === '"') { + $isQuoted = !$isQuoted; + $v .= $value[$i]; + + continue; + } + + $v .= $value[$i]; + } + + $v = \trim($v); + if ($v !== '') { + $result[] = $v; + } + } + + return $result; + } +} diff --git a/vendor/guzzlehttp/psr7/src/HttpFactory.php b/vendor/guzzlehttp/psr7/src/HttpFactory.php new file mode 100644 index 0000000..3ef1510 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/HttpFactory.php @@ -0,0 +1,94 @@ +getSize(); + } + + return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType); + } + + public function createStream(string $content = ''): StreamInterface + { + return Utils::streamFor($content); + } + + public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface + { + try { + $resource = Utils::tryFopen($file, $mode); + } catch (\RuntimeException $e) { + if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) { + throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e); + } + + throw $e; + } + + return Utils::streamFor($resource); + } + + public function createStreamFromResource($resource): StreamInterface + { + return Utils::streamFor($resource); + } + + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface + { + if (empty($method)) { + if (!empty($serverParams['REQUEST_METHOD'])) { + $method = $serverParams['REQUEST_METHOD']; + } else { + throw new \InvalidArgumentException('Cannot determine HTTP method'); + } + } + + return new ServerRequest($method, $uri, [], null, '1.1', $serverParams); + } + + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { + return new Response($code, [], null, '1.1', $reasonPhrase); + } + + public function createRequest(string $method, $uri): RequestInterface + { + return new Request($method, $uri); + } + + public function createUri(string $uri = ''): UriInterface + { + return new Uri($uri); + } +} diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php new file mode 100644 index 0000000..e674c9a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/InflateStream.php @@ -0,0 +1,37 @@ + 15 + 32]); + $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); + } +} diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php new file mode 100644 index 0000000..f6c8490 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php @@ -0,0 +1,49 @@ +filename = $filename; + $this->mode = $mode; + + // unsetting the property forces the first access to go through + // __get(). + unset($this->stream); + } + + /** + * Creates the underlying stream lazily when required. + */ + protected function createStream(): StreamInterface + { + return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode)); + } +} diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php new file mode 100644 index 0000000..fb22325 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -0,0 +1,157 @@ +stream = $stream; + $this->setLimit($limit); + $this->setOffset($offset); + } + + public function eof(): bool + { + // Always return true if the underlying stream is EOF + if ($this->stream->eof()) { + return true; + } + + // No limit and the underlying stream is not at EOF + if ($this->limit === -1) { + return false; + } + + return $this->stream->tell() >= $this->offset + $this->limit; + } + + /** + * Returns the size of the limited subset of data + */ + public function getSize(): ?int + { + if (null === ($length = $this->stream->getSize())) { + return null; + } elseif ($this->limit === -1) { + return $length - $this->offset; + } else { + return min($this->limit, $length - $this->offset); + } + } + + /** + * Allow for a bounded seek on the read limited stream + */ + public function seek($offset, $whence = SEEK_SET): void + { + if ($whence !== SEEK_SET || $offset < 0) { + throw new \RuntimeException(sprintf( + 'Cannot seek to offset %s with whence %s', + $offset, + $whence + )); + } + + $offset += $this->offset; + + if ($this->limit !== -1) { + if ($offset > $this->offset + $this->limit) { + $offset = $this->offset + $this->limit; + } + } + + $this->stream->seek($offset); + } + + /** + * Give a relative tell() + */ + public function tell(): int + { + return $this->stream->tell() - $this->offset; + } + + /** + * Set the offset to start limiting from + * + * @param int $offset Offset to seek to and begin byte limiting from + * + * @throws \RuntimeException if the stream cannot be seeked. + */ + public function setOffset(int $offset): void + { + $current = $this->stream->tell(); + + if ($current !== $offset) { + // If the stream cannot seek to the offset position, then read to it + if ($this->stream->isSeekable()) { + $this->stream->seek($offset); + } elseif ($current > $offset) { + throw new \RuntimeException("Could not seek to stream offset $offset"); + } else { + $this->stream->read($offset - $current); + } + } + + $this->offset = $offset; + } + + /** + * Set the limit of bytes that the decorator allows to be read from the + * stream. + * + * @param int $limit Number of bytes to allow to be read from the stream. + * Use -1 for no limit. + */ + public function setLimit(int $limit): void + { + $this->limit = $limit; + } + + public function read($length): string + { + if ($this->limit === -1) { + return $this->stream->read($length); + } + + // Check if the current position is less than the total allowed + // bytes + original offset + $remaining = ($this->offset + $this->limit) - $this->stream->tell(); + if ($remaining > 0) { + // Only return the amount of requested data, ensuring that the byte + // limit is not exceeded + return $this->stream->read(min($remaining, $length)); + } + + return ''; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Message.php b/vendor/guzzlehttp/psr7/src/Message.php new file mode 100644 index 0000000..5561a51 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Message.php @@ -0,0 +1,246 @@ +getMethod().' ' + .$message->getRequestTarget()) + .' HTTP/'.$message->getProtocolVersion(); + if (!$message->hasHeader('host')) { + $msg .= "\r\nHost: ".$message->getUri()->getHost(); + } + } elseif ($message instanceof ResponseInterface) { + $msg = 'HTTP/'.$message->getProtocolVersion().' ' + .$message->getStatusCode().' ' + .$message->getReasonPhrase(); + } else { + throw new \InvalidArgumentException('Unknown message type'); + } + + foreach ($message->getHeaders() as $name => $values) { + if (is_string($name) && strtolower($name) === 'set-cookie') { + foreach ($values as $value) { + $msg .= "\r\n{$name}: ".$value; + } + } else { + $msg .= "\r\n{$name}: ".implode(', ', $values); + } + } + + return "{$msg}\r\n\r\n".$message->getBody(); + } + + /** + * Get a short summary of the message body. + * + * Will return `null` if the response is not printable. + * + * @param MessageInterface $message The message to get the body summary + * @param int $truncateAt The maximum allowed size of the summary + */ + public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string + { + $body = $message->getBody(); + + if (!$body->isSeekable() || !$body->isReadable()) { + return null; + } + + $size = $body->getSize(); + + if ($size === 0) { + return null; + } + + $body->rewind(); + $summary = $body->read($truncateAt); + $body->rewind(); + + if ($size > $truncateAt) { + $summary .= ' (truncated...)'; + } + + // Matches any printable character, including unicode characters: + // letters, marks, numbers, punctuation, spacing, and separators. + if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) { + return null; + } + + return $summary; + } + + /** + * Attempts to rewind a message body and throws an exception on failure. + * + * The body of the message will only be rewound if a call to `tell()` + * returns a value other than `0`. + * + * @param MessageInterface $message Message to rewind + * + * @throws \RuntimeException + */ + public static function rewindBody(MessageInterface $message): void + { + $body = $message->getBody(); + + if ($body->tell()) { + $body->rewind(); + } + } + + /** + * Parses an HTTP message into an associative array. + * + * The array contains the "start-line" key containing the start line of + * the message, "headers" key containing an associative array of header + * array values, and a "body" key containing the body of the message. + * + * @param string $message HTTP request or response to parse. + */ + public static function parseMessage(string $message): array + { + if (!$message) { + throw new \InvalidArgumentException('Invalid message'); + } + + $message = ltrim($message, "\r\n"); + + $messageParts = preg_split("/\r?\n\r?\n/", $message, 2); + + if ($messageParts === false || count($messageParts) !== 2) { + throw new \InvalidArgumentException('Invalid message: Missing header delimiter'); + } + + [$rawHeaders, $body] = $messageParts; + $rawHeaders .= "\r\n"; // Put back the delimiter we split previously + $headerParts = preg_split("/\r?\n/", $rawHeaders, 2); + + if ($headerParts === false || count($headerParts) !== 2) { + throw new \InvalidArgumentException('Invalid message: Missing status line'); + } + + [$startLine, $rawHeaders] = $headerParts; + + if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') { + // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0 + $rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders); + } + + /** @var array[] $headerLines */ + $count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER); + + // If these aren't the same, then one line didn't match and there's an invalid header. + if ($count !== substr_count($rawHeaders, "\n")) { + // Folding is deprecated, see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4 + if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) { + throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding'); + } + + throw new \InvalidArgumentException('Invalid header syntax'); + } + + $headers = []; + + foreach ($headerLines as $headerLine) { + $headers[$headerLine[1]][] = $headerLine[2]; + } + + return [ + 'start-line' => $startLine, + 'headers' => $headers, + 'body' => $body, + ]; + } + + /** + * Constructs a URI for an HTTP request message. + * + * @param string $path Path from the start-line + * @param array $headers Array of headers (each value an array). + */ + public static function parseRequestUri(string $path, array $headers): string + { + $hostKey = array_filter(array_keys($headers), function ($k) { + // Numeric array keys are converted to int by PHP. + $k = (string) $k; + + return strtolower($k) === 'host'; + }); + + // If no host is found, then a full URI cannot be constructed. + if (!$hostKey) { + return $path; + } + + $host = $headers[reset($hostKey)][0]; + $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; + + return $scheme.'://'.$host.'/'.ltrim($path, '/'); + } + + /** + * Parses a request message string into a request object. + * + * @param string $message Request message string. + */ + public static function parseRequest(string $message): RequestInterface + { + $data = self::parseMessage($message); + $matches = []; + if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { + throw new \InvalidArgumentException('Invalid request string'); + } + $parts = explode(' ', $data['start-line'], 3); + $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; + + $request = new Request( + $parts[0], + $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1], + $data['headers'], + $data['body'], + $version + ); + + return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); + } + + /** + * Parses a response message string into a response object. + * + * @param string $message Response message string. + */ + public static function parseResponse(string $message): ResponseInterface + { + $data = self::parseMessage($message); + // According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2 + // the space between status-code and reason-phrase is required. But + // browsers accept responses without space and reason as well. + if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) { + throw new \InvalidArgumentException('Invalid response string: '.$data['start-line']); + } + $parts = explode(' ', $data['start-line'], 3); + + return new Response( + (int) $parts[1], + $data['headers'], + $data['body'], + explode('/', $parts[0])[1], + $parts[2] ?? null + ); + } +} diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php new file mode 100644 index 0000000..65dbc4b --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -0,0 +1,265 @@ + array of values */ + private $headers = []; + + /** @var string[] Map of lowercase header name => original name at registration */ + private $headerNames = []; + + /** @var string */ + private $protocol = '1.1'; + + /** @var StreamInterface|null */ + private $stream; + + public function getProtocolVersion(): string + { + return $this->protocol; + } + + public function withProtocolVersion($version): MessageInterface + { + if ($this->protocol === $version) { + return $this; + } + + $new = clone $this; + $new->protocol = $version; + + return $new; + } + + public function getHeaders(): array + { + return $this->headers; + } + + public function hasHeader($header): bool + { + return isset($this->headerNames[strtolower($header)]); + } + + public function getHeader($header): array + { + $header = strtolower($header); + + if (!isset($this->headerNames[$header])) { + return []; + } + + $header = $this->headerNames[$header]; + + return $this->headers[$header]; + } + + public function getHeaderLine($header): string + { + return implode(', ', $this->getHeader($header)); + } + + public function withHeader($header, $value): MessageInterface + { + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + unset($new->headers[$new->headerNames[$normalized]]); + } + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + + return $new; + } + + public function withAddedHeader($header, $value): MessageInterface + { + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $new->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + } + + return $new; + } + + public function withoutHeader($header): MessageInterface + { + $normalized = strtolower($header); + + if (!isset($this->headerNames[$normalized])) { + return $this; + } + + $header = $this->headerNames[$normalized]; + + $new = clone $this; + unset($new->headers[$header], $new->headerNames[$normalized]); + + return $new; + } + + public function getBody(): StreamInterface + { + if (!$this->stream) { + $this->stream = Utils::streamFor(''); + } + + return $this->stream; + } + + public function withBody(StreamInterface $body): MessageInterface + { + if ($body === $this->stream) { + return $this; + } + + $new = clone $this; + $new->stream = $body; + + return $new; + } + + /** + * @param (string|string[])[] $headers + */ + private function setHeaders(array $headers): void + { + $this->headerNames = $this->headers = []; + foreach ($headers as $header => $value) { + // Numeric array keys are converted to int by PHP. + $header = (string) $header; + + $this->assertHeader($header); + $value = $this->normalizeHeaderValue($value); + $normalized = strtolower($header); + if (isset($this->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $this->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $this->headerNames[$normalized] = $header; + $this->headers[$header] = $value; + } + } + } + + /** + * @param mixed $value + * + * @return string[] + */ + private function normalizeHeaderValue($value): array + { + if (!is_array($value)) { + return $this->trimAndValidateHeaderValues([$value]); + } + + if (count($value) === 0) { + throw new \InvalidArgumentException('Header value can not be an empty array.'); + } + + return $this->trimAndValidateHeaderValues($value); + } + + /** + * Trims whitespace from the header values. + * + * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. + * + * header-field = field-name ":" OWS field-value OWS + * OWS = *( SP / HTAB ) + * + * @param mixed[] $values Header values + * + * @return string[] Trimmed header values + * + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4 + */ + private function trimAndValidateHeaderValues(array $values): array + { + return array_map(function ($value) { + if (!is_scalar($value) && null !== $value) { + throw new \InvalidArgumentException(sprintf( + 'Header value must be scalar or null but %s provided.', + is_object($value) ? get_class($value) : gettype($value) + )); + } + + $trimmed = trim((string) $value, " \t"); + $this->assertValue($trimmed); + + return $trimmed; + }, array_values($values)); + } + + /** + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 + * + * @param mixed $header + */ + private function assertHeader($header): void + { + if (!is_string($header)) { + throw new \InvalidArgumentException(sprintf( + 'Header name must be a string but %s provided.', + is_object($header) ? get_class($header) : gettype($header) + )); + } + + if (!preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { + throw new \InvalidArgumentException( + sprintf('"%s" is not valid header name.', $header) + ); + } + } + + /** + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 + * + * field-value = *( field-content / obs-fold ) + * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] + * field-vchar = VCHAR / obs-text + * VCHAR = %x21-7E + * obs-text = %x80-FF + * obs-fold = CRLF 1*( SP / HTAB ) + */ + private function assertValue(string $value): void + { + // The regular expression intentionally does not support the obs-fold production, because as + // per RFC 7230#3.2.4: + // + // A sender MUST NOT generate a message that includes + // line folding (i.e., that has any field-value that contains a match to + // the obs-fold rule) unless the message is intended for packaging + // within the message/http media type. + // + // Clients must not send a request with line folding and a server sending folded headers is + // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting + // folding is not likely to break any legitimate use case. + if (!preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) { + throw new \InvalidArgumentException( + sprintf('"%s" is not valid header value.', $value) + ); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/MimeType.php b/vendor/guzzlehttp/psr7/src/MimeType.php new file mode 100644 index 0000000..b131bdb --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/MimeType.php @@ -0,0 +1,1259 @@ + 'application/vnd.1000minds.decision-model+xml', + '3dml' => 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gp', + '3gpp' => 'video/3gpp', + '3mf' => 'model/3mf', + '7z' => 'application/x-7z-compressed', + '7zip' => 'application/x-7z-compressed', + '123' => 'application/vnd.lotus-1-2-3', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/aac', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/vnd.nokia.n-gage.ac+xml', + 'ac3' => 'audio/ac3', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'adts' => 'audio/aac', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'age' => 'application/vnd.age', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/pdf', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'aml' => 'application/automationml-aml+xml', + 'amlx' => 'application/automationml-amlx+zip', + 'amr' => 'audio/amr', + 'apk' => 'application/vnd.android.package-archive', + 'apng' => 'image/apng', + 'appcache' => 'text/cache-manifest', + 'appinstaller' => 'application/appinstaller', + 'application' => 'application/x-ms-application', + 'appx' => 'application/appx', + 'appxbundle' => 'application/appxbundle', + 'apr' => 'application/vnd.lotus-approach', + 'arc' => 'application/x-freearc', + 'arj' => 'application/x-arj', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomdeleted' => 'application/atomdeleted+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/x-au', + 'avci' => 'image/avci', + 'avcs' => 'image/avcs', + 'avi' => 'video/x-msvideo', + 'avif' => 'image/avif', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azv' => 'image/vnd.airzip.accelerator.azv', + 'azw' => 'application/vnd.amazon.ebook', + 'b16' => 'image/vnd.pco.b16', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bdoc' => 'application/x-bdoc', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmml' => 'application/vnd.balsamiq.bmml+xml', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'bpmn' => 'application/octet-stream', + 'bsp' => 'model/vnd.valve.source.compiled-map', + 'btf' => 'image/prs.btif', + 'btif' => 'image/prs.btif', + 'buffer' => 'application/octet-stream', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cco' => 'application/x-cocoa', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdfx' => 'application/cdfx+xml', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdr' => 'application/cdr', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cjs' => 'application/node', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/octet-stream', + 'cld' => 'model/vnd.cld', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'coffee' => 'text/coffeescript', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpl' => 'application/cpl+xml', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'crx' => 'application/x-chrome-extension', + 'cryptonote' => 'application/vnd.rig.cryptonote', + 'csh' => 'application/x-csh', + 'csl' => 'application/vnd.citationstyles.style+xml', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'csr' => 'application/octet-stream', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cwl' => 'application/cwl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbf' => 'application/vnd.dbf', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'ddf' => 'application/vnd.syncml.dmddf+xml', + 'dds' => 'image/vnd.ms-dds', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dib' => 'image/bmp', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'disposition-notification' => 'message/disposition-notification', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/octet-stream', + 'dmg' => 'application/x-apple-diskimage', + 'dmn' => 'application/octet-stream', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dpx' => 'image/dpx', + 'dra' => 'audio/vnd.dra', + 'drle' => 'image/dicom-rle', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwd' => 'application/atsc-dwd+xml', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ear' => 'application/java-archive', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'image/emf', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emotionml' => 'application/emotionml+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/octet-stream', + 'exi' => 'application/exi', + 'exp' => 'application/express', + 'exr' => 'image/aces', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/mp4', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fdt' => 'application/fdt+xml', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'fits' => 'image/fits', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'fo' => 'application/vnd.software602.filler.form+xml', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'gdoc' => 'application/vnd.google-apps.document', + 'ged' => 'text/vnd.familysearch.gedcom', + 'geo' => 'application/vnd.dynageo', + 'geojson' => 'application/geo+json', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'glb' => 'model/gltf-binary', + 'gltf' => 'model/gltf+json', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gpg' => 'application/gpg-keys', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gsheet' => 'application/vnd.google-apps.spreadsheet', + 'gslides' => 'application/vnd.google-apps.presentation', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/gzip', + 'gzip' => 'application/gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hbs' => 'text/x-handlebars-template', + 'hdd' => 'application/x-virtualbox-hdd', + 'hdf' => 'application/x-hdf', + 'heic' => 'image/heic', + 'heics' => 'image/heic-sequence', + 'heif' => 'image/heif', + 'heifs' => 'image/heif-sequence', + 'hej2' => 'image/hej2k', + 'held' => 'application/atsc-held+xml', + 'hh' => 'text/x-c', + 'hjson' => 'application/hjson', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'hsj2' => 'image/hsj2', + 'htc' => 'text/x-component', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'img' => 'application/octet-stream', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ini' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'its' => 'application/its+xml', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jade' => 'text/jade', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'jardiff' => 'application/x-java-archive-diff', + 'java' => 'text/x-java-source', + 'jhc' => 'image/jphc', + 'jisp' => 'application/vnd.jisp', + 'jls' => 'image/jls', + 'jlt' => 'application/vnd.hp-jlyt', + 'jng' => 'image/x-jng', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jp2' => 'image/jp2', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpf' => 'image/jpx', + 'jpg' => 'image/jpeg', + 'jpg2' => 'image/jp2', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jph' => 'image/jph', + 'jpm' => 'video/jpm', + 'jpx' => 'image/jpx', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'json5' => 'application/json5', + 'jsonld' => 'application/ld+json', + 'jsonml' => 'application/jsonml+json', + 'jsx' => 'text/jsx', + 'jt' => 'model/jt', + 'jxr' => 'image/jxr', + 'jxra' => 'image/jxra', + 'jxrs' => 'image/jxrs', + 'jxs' => 'image/jxs', + 'jxsc' => 'image/jxsc', + 'jxsi' => 'image/jxsi', + 'jxss' => 'image/jxss', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kdb' => 'application/octet-stream', + 'kdbx' => 'application/x-keepass2', + 'key' => 'application/x-iwork-keynote-sffkey', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktx2' => 'image/ktx2', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'less' => 'text/less', + 'lgr' => 'application/lgr+xml', + 'lha' => 'application/octet-stream', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'litcoffee' => 'text/coffeescript', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lua' => 'text/x-lua', + 'luac' => 'application/x-lua-bytecode', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/octet-stream', + 'm1v' => 'video/mpeg', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'text/plain', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/x-m4a', + 'm4p' => 'application/mp4', + 'm4s' => 'video/iso.segment', + 'm4u' => 'application/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm21' => 'application/mp21', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'maei' => 'application/mmt-aei+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'manifest' => 'text/cache-manifest', + 'map' => 'application/json', + 'mar' => 'application/octet-stream', + 'markdown' => 'text/markdown', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'md' => 'text/markdown', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'mdx' => 'text/mdx', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mjs' => 'text/javascript', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mkd' => 'text/x-markdown', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mml' => 'text/mathml', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mp21' => 'application/mp21', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpd' => 'application/dash+xml', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpf' => 'application/media-policy-dataset+xml', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msg' => 'application/vnd.ms-outlook', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msix' => 'application/msix', + 'msixbundle' => 'application/msixbundle', + 'msl' => 'application/vnd.mobius.msl', + 'msm' => 'application/octet-stream', + 'msp' => 'application/octet-stream', + 'msty' => 'application/vnd.muvee.style', + 'mtl' => 'model/mtl', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musd' => 'application/mmt-usd+xml', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mvt' => 'application/vnd.mapbox-vector-tile', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxmf' => 'audio/mobile-xmf', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nq' => 'application/n-quads', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'nt' => 'application/n-triples', + 'ntf' => 'application/vnd.nitf', + 'numbers' => 'application/x-iwork-numbers-sffnumbers', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obgx' => 'application/vnd.openblox.game+xml', + 'obj' => 'model/obj', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogex' => 'model/vnd.opengex', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'opus' => 'audio/ogg', + 'org' => 'text/x-org', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'osm' => 'application/vnd.openstreetmap.data+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'font/otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'ova' => 'application/x-virtualbox-ova', + 'ovf' => 'application/x-virtualbox-ovf', + 'owl' => 'application/rdf+xml', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p7a' => 'application/x-pkcs7-signature', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'p10' => 'application/x-pkcs10', + 'p12' => 'application/x-pkcs12', + 'pac' => 'application/x-ns-proxy-autoconfig', + 'pages' => 'application/x-iwork-pages-sffpages', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/x-pilot', + 'pde' => 'text/x-processing', + 'pdf' => 'application/pdf', + 'pem' => 'application/x-x509-user-cert', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp', + 'phar' => 'application/octet-stream', + 'php' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'phtml' => 'application/x-httpd-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'pkpass' => 'application/vnd.apple.pkpass', + 'pl' => 'application/x-perl', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pm' => 'application/x-perl', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppa' => 'application/vnd.ms-powerpoint', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'model/prc', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'provx' => 'application/provenance+xml', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'application/x-photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'pti' => 'image/prs.pti', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyo' => 'model/vnd.pytha.pyox', + 'pyox' => 'model/vnd.pytha.pyox', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'raml' => 'application/raml+yaml', + 'rapd' => 'application/route-apd+xml', + 'rar' => 'application/x-rar', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'relo' => 'application/p2p-overlay+xml', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'audio/x-pn-realaudio', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'rng' => 'application/xml', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsa' => 'application/x-pkcs7', + 'rsat' => 'application/atsc-rsat+xml', + 'rsd' => 'application/rsd+xml', + 'rsheet' => 'application/urc-ressheet+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'text/rtf', + 'rtx' => 'text/richtext', + 'run' => 'application/x-makeself', + 'rusd' => 'application/route-usd+xml', + 'rv' => 'video/vnd.rn-realvideo', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sass' => 'text/x-sass', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scss' => 'text/x-scss', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'sea' => 'application/octet-stream', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'senmlx' => 'application/senml+xml', + 'sensmlx' => 'application/sensml+xml', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shex' => 'text/shex', + 'shf' => 'application/shf+xml', + 'shtml' => 'text/html', + 'sid' => 'image/x-mrsid-image', + 'sieve' => 'application/sieve', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'siv' => 'application/sieve', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slim' => 'text/slim', + 'slm' => 'text/slim', + 'sls' => 'application/route-s-tsid+xml', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spdx' => 'text/spdx', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'sst' => 'application/octet-stream', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'step' => 'application/STEP', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'model/stl', + 'stp' => 'application/STEP', + 'stpx' => 'model/step+xml', + 'stpxz' => 'model/step-xml+zip', + 'stpz' => 'model/step+zip', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'styl' => 'text/stylus', + 'stylus' => 'text/stylus', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'swidtag' => 'application/swid+xml', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 't38' => 'image/t38', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tap' => 'image/vnd.tencent.tap', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'td' => 'application/urc-targetdesc+xml', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tfx' => 'image/tiff-fx', + 'tga' => 'image/x-tga', + 'tgz' => 'application/x-tar', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tk' => 'application/x-tcl', + 'tmo' => 'application/vnd.tmobile-livetv', + 'toml' => 'application/toml', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trig' => 'application/trig', + 'trm' => 'application/x-msterminal', + 'ts' => 'video/mp2t', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'font/collection', + 'ttf' => 'font/ttf', + 'ttl' => 'text/turtle', + 'ttml' => 'application/ttml+xml', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u3d' => 'model/u3d', + 'u8dsn' => 'message/global-delivery-status', + 'u8hdr' => 'message/global-headers', + 'u8mdn' => 'message/global-disposition-notification', + 'u8msg' => 'message/global', + 'u32' => 'application/x-authorware-bin', + 'ubj' => 'application/ubjson', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uo' => 'application/vnd.uoml+xml', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'usda' => 'model/vnd.usda', + 'usdz' => 'model/vnd.usdz+zip', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vbox' => 'application/x-virtualbox-vbox', + 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vdi' => 'application/x-virtualbox-vdi', + 'vds' => 'model/vnd.sap.vds', + 'vhd' => 'application/x-virtualbox-vhd', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vlc' => 'application/videolan', + 'vmdk' => 'application/x-virtualbox-vmdk', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtf' => 'image/vnd.valve.source.texture', + 'vtt' => 'text/vtt', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wadl' => 'application/vnd.sun.wadl+xml', + 'war' => 'application/java-archive', + 'wasm' => 'application/wasm', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webapp' => 'application/x-web-app-manifest+json', + 'webm' => 'video/webm', + 'webmanifest' => 'application/manifest+json', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgsl' => 'text/wgsl', + 'wgt' => 'application/widget', + 'wif' => 'application/watcherinfo+xml', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'image/wmf', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'font/woff', + 'woff2' => 'font/woff2', + 'word' => 'application/msword', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsc' => 'message/vnd.wfa.wsc', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+fastinfoset', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d-vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'x32' => 'application/x-authorware-bin', + 'x_b' => 'model/vnd.parasolid.transmit.binary', + 'x_t' => 'model/vnd.parasolid.transmit.text', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xav' => 'application/xcap-att+xml', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xca' => 'application/xcap-caps+xml', + 'xcs' => 'application/calendar+xml', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xel' => 'application/xcap-el+xml', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtm' => 'application/vnd.pwg-xhtml-print+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xl' => 'application/excel', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xns' => 'application/xcap-ns+xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsd' => 'application/xml', + 'xsf' => 'application/prs.xsf+xml', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yaml' => 'text/yaml', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'yml' => 'text/yaml', + 'ymp' => 'text/x-suse-ymp', + 'z' => 'application/x-compress', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + 'zsh' => 'text/x-scriptzsh', + ]; + + /** + * Determines the mimetype of a file by looking at its extension. + * + * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json + */ + public static function fromFilename(string $filename): ?string + { + return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION)); + } + + /** + * Maps a file extensions to a mimetype. + * + * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json + */ + public static function fromExtension(string $extension): ?string + { + return self::MIME_TYPES[strtolower($extension)] ?? null; + } +} diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php new file mode 100644 index 0000000..43d718f --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/MultipartStream.php @@ -0,0 +1,165 @@ +boundary = $boundary ?: bin2hex(random_bytes(20)); + $this->stream = $this->createStream($elements); + } + + public function getBoundary(): string + { + return $this->boundary; + } + + public function isWritable(): bool + { + return false; + } + + /** + * Get the headers needed before transferring the content of a POST file + * + * @param string[] $headers + */ + private function getHeaders(array $headers): string + { + $str = ''; + foreach ($headers as $key => $value) { + $str .= "{$key}: {$value}\r\n"; + } + + return "--{$this->boundary}\r\n".trim($str)."\r\n\r\n"; + } + + /** + * Create the aggregate stream that will be used to upload the POST data + */ + protected function createStream(array $elements = []): StreamInterface + { + $stream = new AppendStream(); + + foreach ($elements as $element) { + if (!is_array($element)) { + throw new \UnexpectedValueException('An array is expected'); + } + $this->addElement($stream, $element); + } + + // Add the trailing boundary with CRLF + $stream->addStream(Utils::streamFor("--{$this->boundary}--\r\n")); + + return $stream; + } + + private function addElement(AppendStream $stream, array $element): void + { + foreach (['contents', 'name'] as $key) { + if (!array_key_exists($key, $element)) { + throw new \InvalidArgumentException("A '{$key}' key is required"); + } + } + + $element['contents'] = Utils::streamFor($element['contents']); + + if (empty($element['filename'])) { + $uri = $element['contents']->getMetadata('uri'); + if ($uri && \is_string($uri) && \substr($uri, 0, 6) !== 'php://' && \substr($uri, 0, 7) !== 'data://') { + $element['filename'] = $uri; + } + } + + [$body, $headers] = $this->createElement( + $element['name'], + $element['contents'], + $element['filename'] ?? null, + $element['headers'] ?? [] + ); + + $stream->addStream(Utils::streamFor($this->getHeaders($headers))); + $stream->addStream($body); + $stream->addStream(Utils::streamFor("\r\n")); + } + + /** + * @param string[] $headers + * + * @return array{0: StreamInterface, 1: string[]} + */ + private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array + { + // Set a default content-disposition header if one was no provided + $disposition = self::getHeader($headers, 'content-disposition'); + if (!$disposition) { + $headers['Content-Disposition'] = ($filename === '0' || $filename) + ? sprintf( + 'form-data; name="%s"; filename="%s"', + $name, + basename($filename) + ) + : "form-data; name=\"{$name}\""; + } + + // Set a default content-length header if one was no provided + $length = self::getHeader($headers, 'content-length'); + if (!$length) { + if ($length = $stream->getSize()) { + $headers['Content-Length'] = (string) $length; + } + } + + // Set a default Content-Type if one was not supplied + $type = self::getHeader($headers, 'content-type'); + if (!$type && ($filename === '0' || $filename)) { + $headers['Content-Type'] = MimeType::fromFilename($filename) ?? 'application/octet-stream'; + } + + return [$stream, $headers]; + } + + /** + * @param string[] $headers + */ + private static function getHeader(array $headers, string $key): ?string + { + $lowercaseHeader = strtolower($key); + foreach ($headers as $k => $v) { + if (strtolower((string) $k) === $lowercaseHeader) { + return $v; + } + } + + return null; + } +} diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php new file mode 100644 index 0000000..161a224 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/NoSeekStream.php @@ -0,0 +1,28 @@ +source = $source; + $this->size = $options['size'] ?? null; + $this->metadata = $options['metadata'] ?? []; + $this->buffer = new BufferStream(); + } + + public function __toString(): string + { + try { + return Utils::copyToString($this); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function close(): void + { + $this->detach(); + } + + public function detach() + { + $this->tellPos = 0; + $this->source = null; + + return null; + } + + public function getSize(): ?int + { + return $this->size; + } + + public function tell(): int + { + return $this->tellPos; + } + + public function eof(): bool + { + return $this->source === null; + } + + public function isSeekable(): bool + { + return false; + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + throw new \RuntimeException('Cannot seek a PumpStream'); + } + + public function isWritable(): bool + { + return false; + } + + public function write($string): int + { + throw new \RuntimeException('Cannot write to a PumpStream'); + } + + public function isReadable(): bool + { + return true; + } + + public function read($length): string + { + $data = $this->buffer->read($length); + $readLen = strlen($data); + $this->tellPos += $readLen; + $remaining = $length - $readLen; + + if ($remaining) { + $this->pump($remaining); + $data .= $this->buffer->read($remaining); + $this->tellPos += strlen($data) - $readLen; + } + + return $data; + } + + public function getContents(): string + { + $result = ''; + while (!$this->eof()) { + $result .= $this->read(1000000); + } + + return $result; + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + if (!$key) { + return $this->metadata; + } + + return $this->metadata[$key] ?? null; + } + + private function pump(int $length): void + { + if ($this->source !== null) { + do { + $data = ($this->source)($length); + if ($data === false || $data === null) { + $this->source = null; + + return; + } + $this->buffer->write($data); + $length -= strlen($data); + } while ($length > 0); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/Query.php b/vendor/guzzlehttp/psr7/src/Query.php new file mode 100644 index 0000000..ccf867a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Query.php @@ -0,0 +1,118 @@ + '1', 'foo[b]' => '2'])`. + * + * @param string $str Query string to parse + * @param int|bool $urlEncoding How the query string is encoded + */ + public static function parse(string $str, $urlEncoding = true): array + { + $result = []; + + if ($str === '') { + return $result; + } + + if ($urlEncoding === true) { + $decoder = function ($value) { + return rawurldecode(str_replace('+', ' ', (string) $value)); + }; + } elseif ($urlEncoding === PHP_QUERY_RFC3986) { + $decoder = 'rawurldecode'; + } elseif ($urlEncoding === PHP_QUERY_RFC1738) { + $decoder = 'urldecode'; + } else { + $decoder = function ($str) { + return $str; + }; + } + + foreach (explode('&', $str) as $kvp) { + $parts = explode('=', $kvp, 2); + $key = $decoder($parts[0]); + $value = isset($parts[1]) ? $decoder($parts[1]) : null; + if (!array_key_exists($key, $result)) { + $result[$key] = $value; + } else { + if (!is_array($result[$key])) { + $result[$key] = [$result[$key]]; + } + $result[$key][] = $value; + } + } + + return $result; + } + + /** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of `parse()` to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like `http_build_query()` would). + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, + * PHP_QUERY_RFC3986 to encode using + * RFC3986, or PHP_QUERY_RFC1738 to + * encode using RFC1738. + * @param bool $treatBoolsAsInts Set to true to encode as 0/1, and + * false as false/true. + */ + public static function build(array $params, $encoding = PHP_QUERY_RFC3986, bool $treatBoolsAsInts = true): string + { + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function (string $str): string { + return $str; + }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $castBool = $treatBoolsAsInts ? static function ($v) { return (int) $v; } : static function ($v) { return $v ? 'true' : 'false'; }; + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder((string) $k); + if (!is_array($v)) { + $qs .= $k; + $v = is_bool($v) ? $castBool($v) : $v; + if ($v !== null) { + $qs .= '='.$encoder((string) $v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + $vv = is_bool($vv) ? $castBool($vv) : $vv; + if ($vv !== null) { + $qs .= '='.$encoder((string) $vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php new file mode 100644 index 0000000..faafe1a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Request.php @@ -0,0 +1,159 @@ +assertMethod($method); + if (!($uri instanceof UriInterface)) { + $uri = new Uri($uri); + } + + $this->method = strtoupper($method); + $this->uri = $uri; + $this->setHeaders($headers); + $this->protocol = $version; + + if (!isset($this->headerNames['host'])) { + $this->updateHostFromUri(); + } + + if ($body !== '' && $body !== null) { + $this->stream = Utils::streamFor($body); + } + } + + public function getRequestTarget(): string + { + if ($this->requestTarget !== null) { + return $this->requestTarget; + } + + $target = $this->uri->getPath(); + if ($target === '') { + $target = '/'; + } + if ($this->uri->getQuery() != '') { + $target .= '?'.$this->uri->getQuery(); + } + + return $target; + } + + public function withRequestTarget($requestTarget): RequestInterface + { + if (preg_match('#\s#', $requestTarget)) { + throw new InvalidArgumentException( + 'Invalid request target provided; cannot contain whitespace' + ); + } + + $new = clone $this; + $new->requestTarget = $requestTarget; + + return $new; + } + + public function getMethod(): string + { + return $this->method; + } + + public function withMethod($method): RequestInterface + { + $this->assertMethod($method); + $new = clone $this; + $new->method = strtoupper($method); + + return $new; + } + + public function getUri(): UriInterface + { + return $this->uri; + } + + public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface + { + if ($uri === $this->uri) { + return $this; + } + + $new = clone $this; + $new->uri = $uri; + + if (!$preserveHost || !isset($this->headerNames['host'])) { + $new->updateHostFromUri(); + } + + return $new; + } + + private function updateHostFromUri(): void + { + $host = $this->uri->getHost(); + + if ($host == '') { + return; + } + + if (($port = $this->uri->getPort()) !== null) { + $host .= ':'.$port; + } + + if (isset($this->headerNames['host'])) { + $header = $this->headerNames['host']; + } else { + $header = 'Host'; + $this->headerNames['host'] = 'Host'; + } + // Ensure Host is the first header. + // See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4 + $this->headers = [$header => [$host]] + $this->headers; + } + + /** + * @param mixed $method + */ + private function assertMethod($method): void + { + if (!is_string($method) || $method === '') { + throw new InvalidArgumentException('Method must be a non-empty string.'); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php new file mode 100644 index 0000000..34e612f --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Response.php @@ -0,0 +1,161 @@ + 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-status', + 208 => 'Already Reported', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 306 => 'Switch Proxy', + 307 => 'Temporary Redirect', + 308 => 'Permanent Redirect', + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Time-out', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Large', + 415 => 'Unsupported Media Type', + 416 => 'Requested range not satisfiable', + 417 => 'Expectation Failed', + 418 => 'I\'m a teapot', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 425 => 'Unordered Collection', + 426 => 'Upgrade Required', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + 431 => 'Request Header Fields Too Large', + 451 => 'Unavailable For Legal Reasons', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Time-out', + 505 => 'HTTP Version not supported', + 506 => 'Variant Also Negotiates', + 507 => 'Insufficient Storage', + 508 => 'Loop Detected', + 510 => 'Not Extended', + 511 => 'Network Authentication Required', + ]; + + /** @var string */ + private $reasonPhrase; + + /** @var int */ + private $statusCode; + + /** + * @param int $status Status code + * @param (string|string[])[] $headers Response headers + * @param string|resource|StreamInterface|null $body Response body + * @param string $version Protocol version + * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) + */ + public function __construct( + int $status = 200, + array $headers = [], + $body = null, + string $version = '1.1', + ?string $reason = null + ) { + $this->assertStatusCodeRange($status); + + $this->statusCode = $status; + + if ($body !== '' && $body !== null) { + $this->stream = Utils::streamFor($body); + } + + $this->setHeaders($headers); + if ($reason == '' && isset(self::PHRASES[$this->statusCode])) { + $this->reasonPhrase = self::PHRASES[$this->statusCode]; + } else { + $this->reasonPhrase = (string) $reason; + } + + $this->protocol = $version; + } + + public function getStatusCode(): int + { + return $this->statusCode; + } + + public function getReasonPhrase(): string + { + return $this->reasonPhrase; + } + + public function withStatus($code, $reasonPhrase = ''): ResponseInterface + { + $this->assertStatusCodeIsInteger($code); + $code = (int) $code; + $this->assertStatusCodeRange($code); + + $new = clone $this; + $new->statusCode = $code; + if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) { + $reasonPhrase = self::PHRASES[$new->statusCode]; + } + $new->reasonPhrase = (string) $reasonPhrase; + + return $new; + } + + /** + * @param mixed $statusCode + */ + private function assertStatusCodeIsInteger($statusCode): void + { + if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) { + throw new \InvalidArgumentException('Status code must be an integer value.'); + } + } + + private function assertStatusCodeRange(int $statusCode): void + { + if ($statusCode < 100 || $statusCode >= 600) { + throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.'); + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/Rfc7230.php b/vendor/guzzlehttp/psr7/src/Rfc7230.php new file mode 100644 index 0000000..8219dba --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Rfc7230.php @@ -0,0 +1,23 @@ +@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m"; + public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)"; +} diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php new file mode 100644 index 0000000..3cc9534 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -0,0 +1,340 @@ +serverParams = $serverParams; + + parent::__construct($method, $uri, $headers, $body, $version); + } + + /** + * Return an UploadedFile instance array. + * + * @param array $files An array which respect $_FILES structure + * + * @throws InvalidArgumentException for unrecognized values + */ + public static function normalizeFiles(array $files): array + { + $normalized = []; + + foreach ($files as $key => $value) { + if ($value instanceof UploadedFileInterface) { + $normalized[$key] = $value; + } elseif (is_array($value) && isset($value['tmp_name'])) { + $normalized[$key] = self::createUploadedFileFromSpec($value); + } elseif (is_array($value)) { + $normalized[$key] = self::normalizeFiles($value); + continue; + } else { + throw new InvalidArgumentException('Invalid value in files specification'); + } + } + + return $normalized; + } + + /** + * Create and return an UploadedFile instance from a $_FILES specification. + * + * If the specification represents an array of values, this method will + * delegate to normalizeNestedFileSpec() and return that return value. + * + * @param array $value $_FILES struct + * + * @return UploadedFileInterface|UploadedFileInterface[] + */ + private static function createUploadedFileFromSpec(array $value) + { + if (is_array($value['tmp_name'])) { + return self::normalizeNestedFileSpec($value); + } + + return new UploadedFile( + $value['tmp_name'], + (int) $value['size'], + (int) $value['error'], + $value['name'], + $value['type'] + ); + } + + /** + * Normalize an array of file specifications. + * + * Loops through all nested files and returns a normalized array of + * UploadedFileInterface instances. + * + * @return UploadedFileInterface[] + */ + private static function normalizeNestedFileSpec(array $files = []): array + { + $normalizedFiles = []; + + foreach (array_keys($files['tmp_name']) as $key) { + $spec = [ + 'tmp_name' => $files['tmp_name'][$key], + 'size' => $files['size'][$key] ?? null, + 'error' => $files['error'][$key] ?? null, + 'name' => $files['name'][$key] ?? null, + 'type' => $files['type'][$key] ?? null, + ]; + $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); + } + + return $normalizedFiles; + } + + /** + * Return a ServerRequest populated with superglobals: + * $_GET + * $_POST + * $_COOKIE + * $_FILES + * $_SERVER + */ + public static function fromGlobals(): ServerRequestInterface + { + $method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; + $headers = getallheaders(); + $uri = self::getUriFromGlobals(); + $body = new CachingStream(new LazyOpenStream('php://input', 'r+')); + $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; + + $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); + + return $serverRequest + ->withCookieParams($_COOKIE) + ->withQueryParams($_GET) + ->withParsedBody($_POST) + ->withUploadedFiles(self::normalizeFiles($_FILES)); + } + + private static function extractHostAndPortFromAuthority(string $authority): array + { + $uri = 'http://'.$authority; + $parts = parse_url($uri); + if (false === $parts) { + return [null, null]; + } + + $host = $parts['host'] ?? null; + $port = $parts['port'] ?? null; + + return [$host, $port]; + } + + /** + * Get a Uri populated with values from $_SERVER. + */ + public static function getUriFromGlobals(): UriInterface + { + $uri = new Uri(''); + + $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http'); + + $hasPort = false; + if (isset($_SERVER['HTTP_HOST'])) { + [$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']); + if ($host !== null) { + $uri = $uri->withHost($host); + } + + if ($port !== null) { + $hasPort = true; + $uri = $uri->withPort($port); + } + } elseif (isset($_SERVER['SERVER_NAME'])) { + $uri = $uri->withHost($_SERVER['SERVER_NAME']); + } elseif (isset($_SERVER['SERVER_ADDR'])) { + $uri = $uri->withHost($_SERVER['SERVER_ADDR']); + } + + if (!$hasPort && isset($_SERVER['SERVER_PORT'])) { + $uri = $uri->withPort($_SERVER['SERVER_PORT']); + } + + $hasQuery = false; + if (isset($_SERVER['REQUEST_URI'])) { + $requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2); + $uri = $uri->withPath($requestUriParts[0]); + if (isset($requestUriParts[1])) { + $hasQuery = true; + $uri = $uri->withQuery($requestUriParts[1]); + } + } + + if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) { + $uri = $uri->withQuery($_SERVER['QUERY_STRING']); + } + + return $uri; + } + + public function getServerParams(): array + { + return $this->serverParams; + } + + public function getUploadedFiles(): array + { + return $this->uploadedFiles; + } + + public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface + { + $new = clone $this; + $new->uploadedFiles = $uploadedFiles; + + return $new; + } + + public function getCookieParams(): array + { + return $this->cookieParams; + } + + public function withCookieParams(array $cookies): ServerRequestInterface + { + $new = clone $this; + $new->cookieParams = $cookies; + + return $new; + } + + public function getQueryParams(): array + { + return $this->queryParams; + } + + public function withQueryParams(array $query): ServerRequestInterface + { + $new = clone $this; + $new->queryParams = $query; + + return $new; + } + + /** + * @return array|object|null + */ + public function getParsedBody() + { + return $this->parsedBody; + } + + public function withParsedBody($data): ServerRequestInterface + { + $new = clone $this; + $new->parsedBody = $data; + + return $new; + } + + public function getAttributes(): array + { + return $this->attributes; + } + + /** + * @return mixed + */ + public function getAttribute($attribute, $default = null) + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $default; + } + + return $this->attributes[$attribute]; + } + + public function withAttribute($attribute, $value): ServerRequestInterface + { + $new = clone $this; + $new->attributes[$attribute] = $value; + + return $new; + } + + public function withoutAttribute($attribute): ServerRequestInterface + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $this; + } + + $new = clone $this; + unset($new->attributes[$attribute]); + + return $new; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php new file mode 100644 index 0000000..0aff9b2 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Stream.php @@ -0,0 +1,283 @@ +size = $options['size']; + } + + $this->customMetadata = $options['metadata'] ?? []; + $this->stream = $stream; + $meta = stream_get_meta_data($this->stream); + $this->seekable = $meta['seekable']; + $this->readable = (bool) preg_match(self::READABLE_MODES, $meta['mode']); + $this->writable = (bool) preg_match(self::WRITABLE_MODES, $meta['mode']); + $this->uri = $this->getMetadata('uri'); + } + + /** + * Closes the stream when the destructed + */ + public function __destruct() + { + $this->close(); + } + + public function __toString(): string + { + try { + if ($this->isSeekable()) { + $this->seek(0); + } + + return $this->getContents(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function getContents(): string + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); + } + + return Utils::tryGetContents($this->stream); + } + + public function close(): void + { + if (isset($this->stream)) { + if (is_resource($this->stream)) { + fclose($this->stream); + } + $this->detach(); + } + } + + public function detach() + { + if (!isset($this->stream)) { + return null; + } + + $result = $this->stream; + unset($this->stream); + $this->size = $this->uri = null; + $this->readable = $this->writable = $this->seekable = false; + + return $result; + } + + public function getSize(): ?int + { + if ($this->size !== null) { + return $this->size; + } + + if (!isset($this->stream)) { + return null; + } + + // Clear the stat cache if the stream has a URI + if ($this->uri) { + clearstatcache(true, $this->uri); + } + + $stats = fstat($this->stream); + if (is_array($stats) && isset($stats['size'])) { + $this->size = $stats['size']; + + return $this->size; + } + + return null; + } + + public function isReadable(): bool + { + return $this->readable; + } + + public function isWritable(): bool + { + return $this->writable; + } + + public function isSeekable(): bool + { + return $this->seekable; + } + + public function eof(): bool + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + + return feof($this->stream); + } + + public function tell(): int + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + + $result = ftell($this->stream); + + if ($result === false) { + throw new \RuntimeException('Unable to determine stream position'); + } + + return $result; + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + $whence = (int) $whence; + + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + if (!$this->seekable) { + throw new \RuntimeException('Stream is not seekable'); + } + if (fseek($this->stream, $offset, $whence) === -1) { + throw new \RuntimeException('Unable to seek to stream position ' + .$offset.' with whence '.var_export($whence, true)); + } + } + + public function read($length): string + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); + } + if ($length < 0) { + throw new \RuntimeException('Length parameter cannot be negative'); + } + + if (0 === $length) { + return ''; + } + + try { + $string = fread($this->stream, $length); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to read from stream', 0, $e); + } + + if (false === $string) { + throw new \RuntimeException('Unable to read from stream'); + } + + return $string; + } + + public function write($string): int + { + if (!isset($this->stream)) { + throw new \RuntimeException('Stream is detached'); + } + if (!$this->writable) { + throw new \RuntimeException('Cannot write to a non-writable stream'); + } + + // We can't know the size after writing anything + $this->size = null; + $result = fwrite($this->stream, $string); + + if ($result === false) { + throw new \RuntimeException('Unable to write to stream'); + } + + return $result; + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + if (!isset($this->stream)) { + return $key ? null : []; + } elseif (!$key) { + return $this->customMetadata + stream_get_meta_data($this->stream); + } elseif (isset($this->customMetadata[$key])) { + return $this->customMetadata[$key]; + } + + $meta = stream_get_meta_data($this->stream); + + return $meta[$key] ?? null; + } +} diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php new file mode 100644 index 0000000..601c13a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php @@ -0,0 +1,156 @@ +stream = $stream; + } + + /** + * Magic method used to create a new stream if streams are not added in + * the constructor of a decorator (e.g., LazyOpenStream). + * + * @return StreamInterface + */ + public function __get(string $name) + { + if ($name === 'stream') { + $this->stream = $this->createStream(); + + return $this->stream; + } + + throw new \UnexpectedValueException("$name not found on class"); + } + + public function __toString(): string + { + try { + if ($this->isSeekable()) { + $this->seek(0); + } + + return $this->getContents(); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + + return ''; + } + } + + public function getContents(): string + { + return Utils::copyToString($this); + } + + /** + * Allow decorators to implement custom methods + * + * @return mixed + */ + public function __call(string $method, array $args) + { + /** @var callable $callable */ + $callable = [$this->stream, $method]; + $result = ($callable)(...$args); + + // Always return the wrapped object if the result is a return $this + return $result === $this->stream ? $this : $result; + } + + public function close(): void + { + $this->stream->close(); + } + + /** + * @return mixed + */ + public function getMetadata($key = null) + { + return $this->stream->getMetadata($key); + } + + public function detach() + { + return $this->stream->detach(); + } + + public function getSize(): ?int + { + return $this->stream->getSize(); + } + + public function eof(): bool + { + return $this->stream->eof(); + } + + public function tell(): int + { + return $this->stream->tell(); + } + + public function isReadable(): bool + { + return $this->stream->isReadable(); + } + + public function isWritable(): bool + { + return $this->stream->isWritable(); + } + + public function isSeekable(): bool + { + return $this->stream->isSeekable(); + } + + public function rewind(): void + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET): void + { + $this->stream->seek($offset, $whence); + } + + public function read($length): string + { + return $this->stream->read($length); + } + + public function write($string): int + { + return $this->stream->write($string); + } + + /** + * Implement in subclasses to dynamically create streams when requested. + * + * @throws \BadMethodCallException + */ + protected function createStream(): StreamInterface + { + throw new \BadMethodCallException('Not implemented'); + } +} diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php new file mode 100644 index 0000000..77b04d7 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/StreamWrapper.php @@ -0,0 +1,207 @@ +isReadable()) { + $mode = $stream->isWritable() ? 'r+' : 'r'; + } elseif ($stream->isWritable()) { + $mode = 'w'; + } else { + throw new \InvalidArgumentException('The stream must be readable, ' + .'writable, or both.'); + } + + return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream)); + } + + /** + * Creates a stream context that can be used to open a stream as a php stream resource. + * + * @return resource + */ + public static function createStreamContext(StreamInterface $stream) + { + return stream_context_create([ + 'guzzle' => ['stream' => $stream], + ]); + } + + /** + * Registers the stream wrapper if needed + */ + public static function register(): void + { + if (!in_array('guzzle', stream_get_wrappers())) { + stream_wrapper_register('guzzle', __CLASS__); + } + } + + public function stream_open(string $path, string $mode, int $options, ?string &$opened_path = null): bool + { + $options = stream_context_get_options($this->context); + + if (!isset($options['guzzle']['stream'])) { + return false; + } + + $this->mode = $mode; + $this->stream = $options['guzzle']['stream']; + + return true; + } + + public function stream_read(int $count): string + { + return $this->stream->read($count); + } + + public function stream_write(string $data): int + { + return $this->stream->write($data); + } + + public function stream_tell(): int + { + return $this->stream->tell(); + } + + public function stream_eof(): bool + { + return $this->stream->eof(); + } + + public function stream_seek(int $offset, int $whence): bool + { + $this->stream->seek($offset, $whence); + + return true; + } + + /** + * @return resource|false + */ + public function stream_cast(int $cast_as) + { + $stream = clone $this->stream; + $resource = $stream->detach(); + + return $resource ?? false; + } + + /** + * @return array{ + * dev: int, + * ino: int, + * mode: int, + * nlink: int, + * uid: int, + * gid: int, + * rdev: int, + * size: int, + * atime: int, + * mtime: int, + * ctime: int, + * blksize: int, + * blocks: int + * }|false + */ + public function stream_stat() + { + if ($this->stream->getSize() === null) { + return false; + } + + static $modeMap = [ + 'r' => 33060, + 'rb' => 33060, + 'r+' => 33206, + 'w' => 33188, + 'wb' => 33188, + ]; + + return [ + 'dev' => 0, + 'ino' => 0, + 'mode' => $modeMap[$this->mode], + 'nlink' => 0, + 'uid' => 0, + 'gid' => 0, + 'rdev' => 0, + 'size' => $this->stream->getSize() ?: 0, + 'atime' => 0, + 'mtime' => 0, + 'ctime' => 0, + 'blksize' => 0, + 'blocks' => 0, + ]; + } + + /** + * @return array{ + * dev: int, + * ino: int, + * mode: int, + * nlink: int, + * uid: int, + * gid: int, + * rdev: int, + * size: int, + * atime: int, + * mtime: int, + * ctime: int, + * blksize: int, + * blocks: int + * } + */ + public function url_stat(string $path, int $flags): array + { + return [ + 'dev' => 0, + 'ino' => 0, + 'mode' => 0, + 'nlink' => 0, + 'uid' => 0, + 'gid' => 0, + 'rdev' => 0, + 'size' => 0, + 'atime' => 0, + 'mtime' => 0, + 'ctime' => 0, + 'blksize' => 0, + 'blocks' => 0, + ]; + } +} diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php new file mode 100644 index 0000000..d9b779f --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -0,0 +1,211 @@ + 'UPLOAD_ERR_OK', + UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE', + UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE', + UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL', + UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE', + UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR', + UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE', + UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION', + ]; + + /** + * @var string|null + */ + private $clientFilename; + + /** + * @var string|null + */ + private $clientMediaType; + + /** + * @var int + */ + private $error; + + /** + * @var string|null + */ + private $file; + + /** + * @var bool + */ + private $moved = false; + + /** + * @var int|null + */ + private $size; + + /** + * @var StreamInterface|null + */ + private $stream; + + /** + * @param StreamInterface|string|resource $streamOrFile + */ + public function __construct( + $streamOrFile, + ?int $size, + int $errorStatus, + ?string $clientFilename = null, + ?string $clientMediaType = null + ) { + $this->setError($errorStatus); + $this->size = $size; + $this->clientFilename = $clientFilename; + $this->clientMediaType = $clientMediaType; + + if ($this->isOk()) { + $this->setStreamOrFile($streamOrFile); + } + } + + /** + * Depending on the value set file or stream variable + * + * @param StreamInterface|string|resource $streamOrFile + * + * @throws InvalidArgumentException + */ + private function setStreamOrFile($streamOrFile): void + { + if (is_string($streamOrFile)) { + $this->file = $streamOrFile; + } elseif (is_resource($streamOrFile)) { + $this->stream = new Stream($streamOrFile); + } elseif ($streamOrFile instanceof StreamInterface) { + $this->stream = $streamOrFile; + } else { + throw new InvalidArgumentException( + 'Invalid stream or file provided for UploadedFile' + ); + } + } + + /** + * @throws InvalidArgumentException + */ + private function setError(int $error): void + { + if (!isset(UploadedFile::ERROR_MAP[$error])) { + throw new InvalidArgumentException( + 'Invalid error status for UploadedFile' + ); + } + + $this->error = $error; + } + + private static function isStringNotEmpty($param): bool + { + return is_string($param) && false === empty($param); + } + + /** + * Return true if there is no upload error + */ + private function isOk(): bool + { + return $this->error === UPLOAD_ERR_OK; + } + + public function isMoved(): bool + { + return $this->moved; + } + + /** + * @throws RuntimeException if is moved or not ok + */ + private function validateActive(): void + { + if (false === $this->isOk()) { + throw new RuntimeException(\sprintf('Cannot retrieve stream due to upload error (%s)', self::ERROR_MAP[$this->error])); + } + + if ($this->isMoved()) { + throw new RuntimeException('Cannot retrieve stream after it has already been moved'); + } + } + + public function getStream(): StreamInterface + { + $this->validateActive(); + + if ($this->stream instanceof StreamInterface) { + return $this->stream; + } + + /** @var string $file */ + $file = $this->file; + + return new LazyOpenStream($file, 'r+'); + } + + public function moveTo($targetPath): void + { + $this->validateActive(); + + if (false === self::isStringNotEmpty($targetPath)) { + throw new InvalidArgumentException( + 'Invalid path provided for move operation; must be a non-empty string' + ); + } + + if ($this->file) { + $this->moved = PHP_SAPI === 'cli' + ? rename($this->file, $targetPath) + : move_uploaded_file($this->file, $targetPath); + } else { + Utils::copyToStream( + $this->getStream(), + new LazyOpenStream($targetPath, 'w') + ); + + $this->moved = true; + } + + if (false === $this->moved) { + throw new RuntimeException( + sprintf('Uploaded file could not be moved to %s', $targetPath) + ); + } + } + + public function getSize(): ?int + { + return $this->size; + } + + public function getError(): int + { + return $this->error; + } + + public function getClientFilename(): ?string + { + return $this->clientFilename; + } + + public function getClientMediaType(): ?string + { + return $this->clientMediaType; + } +} diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php new file mode 100644 index 0000000..a7cdfb0 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Uri.php @@ -0,0 +1,743 @@ + 80, + 'https' => 443, + 'ftp' => 21, + 'gopher' => 70, + 'nntp' => 119, + 'news' => 119, + 'telnet' => 23, + 'tn3270' => 23, + 'imap' => 143, + 'pop' => 110, + 'ldap' => 389, + ]; + + /** + * Unreserved characters for use in a regex. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3 + */ + private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~'; + + /** + * Sub-delims for use in a regex. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 + */ + private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;='; + private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26']; + + /** @var string Uri scheme. */ + private $scheme = ''; + + /** @var string Uri user info. */ + private $userInfo = ''; + + /** @var string Uri host. */ + private $host = ''; + + /** @var int|null Uri port. */ + private $port; + + /** @var string Uri path. */ + private $path = ''; + + /** @var string Uri query string. */ + private $query = ''; + + /** @var string Uri fragment. */ + private $fragment = ''; + + /** @var string|null String representation */ + private $composedComponents; + + public function __construct(string $uri = '') + { + if ($uri !== '') { + $parts = self::parse($uri); + if ($parts === false) { + throw new MalformedUriException("Unable to parse URI: $uri"); + } + $this->applyParts($parts); + } + } + + /** + * UTF-8 aware \parse_url() replacement. + * + * The internal function produces broken output for non ASCII domain names + * (IDN) when used with locales other than "C". + * + * On the other hand, cURL understands IDN correctly only when UTF-8 locale + * is configured ("C.UTF-8", "en_US.UTF-8", etc.). + * + * @see https://bugs.php.net/bug.php?id=52923 + * @see https://www.php.net/manual/en/function.parse-url.php#114817 + * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING + * + * @return array|false + */ + private static function parse(string $url) + { + // If IPv6 + $prefix = ''; + if (preg_match('%^(.*://\[[0-9:a-fA-F]+\])(.*?)$%', $url, $matches)) { + /** @var array{0:string, 1:string, 2:string} $matches */ + $prefix = $matches[1]; + $url = $matches[2]; + } + + /** @var string */ + $encodedUrl = preg_replace_callback( + '%[^:/@?&=#]+%usD', + static function ($matches) { + return urlencode($matches[0]); + }, + $url + ); + + $result = parse_url($prefix.$encodedUrl); + + if ($result === false) { + return false; + } + + return array_map('urldecode', $result); + } + + public function __toString(): string + { + if ($this->composedComponents === null) { + $this->composedComponents = self::composeComponents( + $this->scheme, + $this->getAuthority(), + $this->path, + $this->query, + $this->fragment + ); + } + + return $this->composedComponents; + } + + /** + * Composes a URI reference string from its various components. + * + * Usually this method does not need to be called manually but instead is used indirectly via + * `Psr\Http\Message\UriInterface::__toString`. + * + * PSR-7 UriInterface treats an empty component the same as a missing component as + * getQuery(), getFragment() etc. always return a string. This explains the slight + * difference to RFC 3986 Section 5.3. + * + * Another adjustment is that the authority separator is added even when the authority is missing/empty + * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with + * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But + * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to + * that format). + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3 + */ + public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string + { + $uri = ''; + + // weak type checks to also accept null until we can add scalar type hints + if ($scheme != '') { + $uri .= $scheme.':'; + } + + if ($authority != '' || $scheme === 'file') { + $uri .= '//'.$authority; + } + + if ($authority != '' && $path != '' && $path[0] != '/') { + $path = '/'.$path; + } + + $uri .= $path; + + if ($query != '') { + $uri .= '?'.$query; + } + + if ($fragment != '') { + $uri .= '#'.$fragment; + } + + return $uri; + } + + /** + * Whether the URI has the default port of the current scheme. + * + * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used + * independently of the implementation. + */ + public static function isDefaultPort(UriInterface $uri): bool + { + return $uri->getPort() === null + || (isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]); + } + + /** + * Whether the URI is absolute, i.e. it has a scheme. + * + * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true + * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative + * to another URI, the base URI. Relative references can be divided into several forms: + * - network-path references, e.g. '//example.com/path' + * - absolute-path references, e.g. '/path' + * - relative-path references, e.g. 'subpath' + * + * @see Uri::isNetworkPathReference + * @see Uri::isAbsolutePathReference + * @see Uri::isRelativePathReference + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4 + */ + public static function isAbsolute(UriInterface $uri): bool + { + return $uri->getScheme() !== ''; + } + + /** + * Whether the URI is a network-path reference. + * + * A relative reference that begins with two slash characters is termed an network-path reference. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 + */ + public static function isNetworkPathReference(UriInterface $uri): bool + { + return $uri->getScheme() === '' && $uri->getAuthority() !== ''; + } + + /** + * Whether the URI is a absolute-path reference. + * + * A relative reference that begins with a single slash character is termed an absolute-path reference. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 + */ + public static function isAbsolutePathReference(UriInterface $uri): bool + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && isset($uri->getPath()[0]) + && $uri->getPath()[0] === '/'; + } + + /** + * Whether the URI is a relative-path reference. + * + * A relative reference that does not begin with a slash character is termed a relative-path reference. + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 + */ + public static function isRelativePathReference(UriInterface $uri): bool + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); + } + + /** + * Whether the URI is a same-document reference. + * + * A same-document reference refers to a URI that is, aside from its fragment + * component, identical to the base URI. When no base URI is given, only an empty + * URI reference (apart from its fragment) is considered a same-document reference. + * + * @param UriInterface $uri The URI to check + * @param UriInterface|null $base An optional base URI to compare against + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4 + */ + public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool + { + if ($base !== null) { + $uri = UriResolver::resolve($base, $uri); + + return ($uri->getScheme() === $base->getScheme()) + && ($uri->getAuthority() === $base->getAuthority()) + && ($uri->getPath() === $base->getPath()) + && ($uri->getQuery() === $base->getQuery()); + } + + return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; + } + + /** + * Creates a new URI with a specific query string value removed. + * + * Any existing query string values that exactly match the provided key are + * removed. + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Query string key to remove. + */ + public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface + { + $result = self::getFilteredQueryString($uri, [$key]); + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a new URI with a specific query string value. + * + * Any existing query string values that exactly match the provided key are + * removed and replaced with the given key value pair. + * + * A value of null will set the query string key without a value, e.g. "key" + * instead of "key=value". + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Key to set. + * @param string|null $value Value to set + */ + public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface + { + $result = self::getFilteredQueryString($uri, [$key]); + + $result[] = self::generateQueryString($key, $value); + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a new URI with multiple specific query string values. + * + * It has the same behavior as withQueryValue() but for an associative array of key => value. + * + * @param UriInterface $uri URI to use as a base. + * @param (string|null)[] $keyValueArray Associative array of key and values + */ + public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface + { + $result = self::getFilteredQueryString($uri, array_keys($keyValueArray)); + + foreach ($keyValueArray as $key => $value) { + $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); + } + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a URI from a hash of `parse_url` components. + * + * @see https://www.php.net/manual/en/function.parse-url.php + * + * @throws MalformedUriException If the components do not form a valid URI. + */ + public static function fromParts(array $parts): UriInterface + { + $uri = new self(); + $uri->applyParts($parts); + $uri->validateState(); + + return $uri; + } + + public function getScheme(): string + { + return $this->scheme; + } + + public function getAuthority(): string + { + $authority = $this->host; + if ($this->userInfo !== '') { + $authority = $this->userInfo.'@'.$authority; + } + + if ($this->port !== null) { + $authority .= ':'.$this->port; + } + + return $authority; + } + + public function getUserInfo(): string + { + return $this->userInfo; + } + + public function getHost(): string + { + return $this->host; + } + + public function getPort(): ?int + { + return $this->port; + } + + public function getPath(): string + { + return $this->path; + } + + public function getQuery(): string + { + return $this->query; + } + + public function getFragment(): string + { + return $this->fragment; + } + + public function withScheme($scheme): UriInterface + { + $scheme = $this->filterScheme($scheme); + + if ($this->scheme === $scheme) { + return $this; + } + + $new = clone $this; + $new->scheme = $scheme; + $new->composedComponents = null; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withUserInfo($user, $password = null): UriInterface + { + $info = $this->filterUserInfoComponent($user); + if ($password !== null) { + $info .= ':'.$this->filterUserInfoComponent($password); + } + + if ($this->userInfo === $info) { + return $this; + } + + $new = clone $this; + $new->userInfo = $info; + $new->composedComponents = null; + $new->validateState(); + + return $new; + } + + public function withHost($host): UriInterface + { + $host = $this->filterHost($host); + + if ($this->host === $host) { + return $this; + } + + $new = clone $this; + $new->host = $host; + $new->composedComponents = null; + $new->validateState(); + + return $new; + } + + public function withPort($port): UriInterface + { + $port = $this->filterPort($port); + + if ($this->port === $port) { + return $this; + } + + $new = clone $this; + $new->port = $port; + $new->composedComponents = null; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withPath($path): UriInterface + { + $path = $this->filterPath($path); + + if ($this->path === $path) { + return $this; + } + + $new = clone $this; + $new->path = $path; + $new->composedComponents = null; + $new->validateState(); + + return $new; + } + + public function withQuery($query): UriInterface + { + $query = $this->filterQueryAndFragment($query); + + if ($this->query === $query) { + return $this; + } + + $new = clone $this; + $new->query = $query; + $new->composedComponents = null; + + return $new; + } + + public function withFragment($fragment): UriInterface + { + $fragment = $this->filterQueryAndFragment($fragment); + + if ($this->fragment === $fragment) { + return $this; + } + + $new = clone $this; + $new->fragment = $fragment; + $new->composedComponents = null; + + return $new; + } + + public function jsonSerialize(): string + { + return $this->__toString(); + } + + /** + * Apply parse_url parts to a URI. + * + * @param array $parts Array of parse_url parts to apply. + */ + private function applyParts(array $parts): void + { + $this->scheme = isset($parts['scheme']) + ? $this->filterScheme($parts['scheme']) + : ''; + $this->userInfo = isset($parts['user']) + ? $this->filterUserInfoComponent($parts['user']) + : ''; + $this->host = isset($parts['host']) + ? $this->filterHost($parts['host']) + : ''; + $this->port = isset($parts['port']) + ? $this->filterPort($parts['port']) + : null; + $this->path = isset($parts['path']) + ? $this->filterPath($parts['path']) + : ''; + $this->query = isset($parts['query']) + ? $this->filterQueryAndFragment($parts['query']) + : ''; + $this->fragment = isset($parts['fragment']) + ? $this->filterQueryAndFragment($parts['fragment']) + : ''; + if (isset($parts['pass'])) { + $this->userInfo .= ':'.$this->filterUserInfoComponent($parts['pass']); + } + + $this->removeDefaultPort(); + } + + /** + * @param mixed $scheme + * + * @throws \InvalidArgumentException If the scheme is invalid. + */ + private function filterScheme($scheme): string + { + if (!is_string($scheme)) { + throw new \InvalidArgumentException('Scheme must be a string'); + } + + return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); + } + + /** + * @param mixed $component + * + * @throws \InvalidArgumentException If the user info is invalid. + */ + private function filterUserInfoComponent($component): string + { + if (!is_string($component)) { + throw new \InvalidArgumentException('User info must be a string'); + } + + return preg_replace_callback( + '/(?:[^%'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.']+|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $component + ); + } + + /** + * @param mixed $host + * + * @throws \InvalidArgumentException If the host is invalid. + */ + private function filterHost($host): string + { + if (!is_string($host)) { + throw new \InvalidArgumentException('Host must be a string'); + } + + return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); + } + + /** + * @param mixed $port + * + * @throws \InvalidArgumentException If the port is invalid. + */ + private function filterPort($port): ?int + { + if ($port === null) { + return null; + } + + $port = (int) $port; + if (0 > $port || 0xFFFF < $port) { + throw new \InvalidArgumentException( + sprintf('Invalid port: %d. Must be between 0 and 65535', $port) + ); + } + + return $port; + } + + /** + * @param (string|int)[] $keys + * + * @return string[] + */ + private static function getFilteredQueryString(UriInterface $uri, array $keys): array + { + $current = $uri->getQuery(); + + if ($current === '') { + return []; + } + + $decodedKeys = array_map(function ($k): string { + return rawurldecode((string) $k); + }, $keys); + + return array_filter(explode('&', $current), function ($part) use ($decodedKeys) { + return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true); + }); + } + + private static function generateQueryString(string $key, ?string $value): string + { + // Query string separators ("=", "&") within the key or value need to be encoded + // (while preventing double-encoding) before setting the query string. All other + // chars that need percent-encoding will be encoded by withQuery(). + $queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); + + if ($value !== null) { + $queryString .= '='.strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); + } + + return $queryString; + } + + private function removeDefaultPort(): void + { + if ($this->port !== null && self::isDefaultPort($this)) { + $this->port = null; + } + } + + /** + * Filters the path of a URI + * + * @param mixed $path + * + * @throws \InvalidArgumentException If the path is invalid. + */ + private function filterPath($path): string + { + if (!is_string($path)) { + throw new \InvalidArgumentException('Path must be a string'); + } + + return preg_replace_callback( + '/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $path + ); + } + + /** + * Filters the query string or fragment of a URI. + * + * @param mixed $str + * + * @throws \InvalidArgumentException If the query or fragment is invalid. + */ + private function filterQueryAndFragment($str): string + { + if (!is_string($str)) { + throw new \InvalidArgumentException('Query and fragment must be a string'); + } + + return preg_replace_callback( + '/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $str + ); + } + + private function rawurlencodeMatchZero(array $match): string + { + return rawurlencode($match[0]); + } + + private function validateState(): void + { + if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { + $this->host = self::HTTP_DEFAULT_HOST; + } + + if ($this->getAuthority() === '') { + if (0 === strpos($this->path, '//')) { + throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"'); + } + if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { + throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon'); + } + } + } +} diff --git a/vendor/guzzlehttp/psr7/src/UriComparator.php b/vendor/guzzlehttp/psr7/src/UriComparator.php new file mode 100644 index 0000000..70c582a --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UriComparator.php @@ -0,0 +1,52 @@ +getHost(), $modified->getHost()) !== 0) { + return true; + } + + if ($original->getScheme() !== $modified->getScheme()) { + return true; + } + + if (self::computePort($original) !== self::computePort($modified)) { + return true; + } + + return false; + } + + private static function computePort(UriInterface $uri): int + { + $port = $uri->getPort(); + + if (null !== $port) { + return $port; + } + + return 'https' === $uri->getScheme() ? 443 : 80; + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/vendor/guzzlehttp/psr7/src/UriNormalizer.php new file mode 100644 index 0000000..e174557 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UriNormalizer.php @@ -0,0 +1,220 @@ +getPath() === '' + && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https') + ) { + $uri = $uri->withPath('/'); + } + + if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') { + $uri = $uri->withHost(''); + } + + if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) { + $uri = $uri->withPort(null); + } + + if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) { + $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath())); + } + + if ($flags & self::REMOVE_DUPLICATE_SLASHES) { + $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath())); + } + + if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') { + $queryKeyValues = explode('&', $uri->getQuery()); + sort($queryKeyValues); + $uri = $uri->withQuery(implode('&', $queryKeyValues)); + } + + return $uri; + } + + /** + * Whether two URIs can be considered equivalent. + * + * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also + * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be + * resolved against the same base URI. If this is not the case, determination of equivalence or difference of + * relative references does not mean anything. + * + * @param UriInterface $uri1 An URI to compare + * @param UriInterface $uri2 An URI to compare + * @param int $normalizations A bitmask of normalizations to apply, see constants + * + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1 + */ + public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS): bool + { + return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations); + } + + private static function capitalizePercentEncoding(UriInterface $uri): UriInterface + { + $regex = '/(?:%[A-Fa-f0-9]{2})++/'; + + $callback = function (array $match): string { + return strtoupper($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private static function decodeUnreservedCharacters(UriInterface $uri): UriInterface + { + $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; + + $callback = function (array $match): string { + return rawurldecode($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/vendor/guzzlehttp/psr7/src/UriResolver.php b/vendor/guzzlehttp/psr7/src/UriResolver.php new file mode 100644 index 0000000..3737be1 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/UriResolver.php @@ -0,0 +1,211 @@ +getScheme() != '') { + return $rel->withPath(self::removeDotSegments($rel->getPath())); + } + + if ($rel->getAuthority() != '') { + $targetAuthority = $rel->getAuthority(); + $targetPath = self::removeDotSegments($rel->getPath()); + $targetQuery = $rel->getQuery(); + } else { + $targetAuthority = $base->getAuthority(); + if ($rel->getPath() === '') { + $targetPath = $base->getPath(); + $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); + } else { + if ($rel->getPath()[0] === '/') { + $targetPath = $rel->getPath(); + } else { + if ($targetAuthority != '' && $base->getPath() === '') { + $targetPath = '/'.$rel->getPath(); + } else { + $lastSlashPos = strrpos($base->getPath(), '/'); + if ($lastSlashPos === false) { + $targetPath = $rel->getPath(); + } else { + $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1).$rel->getPath(); + } + } + } + $targetPath = self::removeDotSegments($targetPath); + $targetQuery = $rel->getQuery(); + } + } + + return new Uri(Uri::composeComponents( + $base->getScheme(), + $targetAuthority, + $targetPath, + $targetQuery, + $rel->getFragment() + )); + } + + /** + * Returns the target URI as a relative reference from the base URI. + * + * This method is the counterpart to resolve(): + * + * (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) + * + * One use-case is to use the current request URI as base URI and then generate relative links in your documents + * to reduce the document size or offer self-contained downloadable document archives. + * + * $base = new Uri('http://example.com/a/b/'); + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. + * echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. + * + * This method also accepts a target that is already relative and will try to relativize it further. Only a + * relative-path reference will be returned as-is. + * + * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well + */ + public static function relativize(UriInterface $base, UriInterface $target): UriInterface + { + if ($target->getScheme() !== '' + && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') + ) { + return $target; + } + + if (Uri::isRelativePathReference($target)) { + // As the target is already highly relative we return it as-is. It would be possible to resolve + // the target with `$target = self::resolve($base, $target);` and then try make it more relative + // by removing a duplicate query. But let's not do that automatically. + return $target; + } + + if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) { + return $target->withScheme(''); + } + + // We must remove the path before removing the authority because if the path starts with two slashes, the URI + // would turn invalid. And we also cannot set a relative path before removing the authority, as that is also + // invalid. + $emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost(''); + + if ($base->getPath() !== $target->getPath()) { + return $emptyPathUri->withPath(self::getRelativePath($base, $target)); + } + + if ($base->getQuery() === $target->getQuery()) { + // Only the target fragment is left. And it must be returned even if base and target fragment are the same. + return $emptyPathUri->withQuery(''); + } + + // If the base URI has a query but the target has none, we cannot return an empty path reference as it would + // inherit the base query component when resolving. + if ($target->getQuery() === '') { + $segments = explode('/', $target->getPath()); + /** @var string $lastSegment */ + $lastSegment = end($segments); + + return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); + } + + return $emptyPathUri; + } + + private static function getRelativePath(UriInterface $base, UriInterface $target): string + { + $sourceSegments = explode('/', $base->getPath()); + $targetSegments = explode('/', $target->getPath()); + array_pop($sourceSegments); + $targetLastSegment = array_pop($targetSegments); + foreach ($sourceSegments as $i => $segment) { + if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) { + unset($sourceSegments[$i], $targetSegments[$i]); + } else { + break; + } + } + $targetSegments[] = $targetLastSegment; + $relativePath = str_repeat('../', count($sourceSegments)).implode('/', $targetSegments); + + // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./". + // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used + // as the first segment of a relative-path reference, as it would be mistaken for a scheme name. + if ('' === $relativePath || false !== strpos(explode('/', $relativePath, 2)[0], ':')) { + $relativePath = "./$relativePath"; + } elseif ('/' === $relativePath[0]) { + if ($base->getAuthority() != '' && $base->getPath() === '') { + // In this case an extra slash is added by resolve() automatically. So we must not add one here. + $relativePath = ".$relativePath"; + } else { + $relativePath = "./$relativePath"; + } + } + + return $relativePath; + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/vendor/guzzlehttp/psr7/src/Utils.php b/vendor/guzzlehttp/psr7/src/Utils.php new file mode 100644 index 0000000..7682d2c --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Utils.php @@ -0,0 +1,477 @@ + $v) { + if (!in_array(strtolower((string) $k), $keys)) { + $result[$k] = $v; + } + } + + return $result; + } + + /** + * Copy the contents of a stream into another stream until the given number + * of bytes have been read. + * + * @param StreamInterface $source Stream to read from + * @param StreamInterface $dest Stream to write to + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * + * @throws \RuntimeException on error. + */ + public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void + { + $bufferSize = 8192; + + if ($maxLen === -1) { + while (!$source->eof()) { + if (!$dest->write($source->read($bufferSize))) { + break; + } + } + } else { + $remaining = $maxLen; + while ($remaining > 0 && !$source->eof()) { + $buf = $source->read(min($bufferSize, $remaining)); + $len = strlen($buf); + if (!$len) { + break; + } + $remaining -= $len; + $dest->write($buf); + } + } + } + + /** + * Copy the contents of a stream into a string until the given number of + * bytes have been read. + * + * @param StreamInterface $stream Stream to read + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * + * @throws \RuntimeException on error. + */ + public static function copyToString(StreamInterface $stream, int $maxLen = -1): string + { + $buffer = ''; + + if ($maxLen === -1) { + while (!$stream->eof()) { + $buf = $stream->read(1048576); + if ($buf === '') { + break; + } + $buffer .= $buf; + } + + return $buffer; + } + + $len = 0; + while (!$stream->eof() && $len < $maxLen) { + $buf = $stream->read($maxLen - $len); + if ($buf === '') { + break; + } + $buffer .= $buf; + $len = strlen($buffer); + } + + return $buffer; + } + + /** + * Calculate a hash of a stream. + * + * This method reads the entire stream to calculate a rolling hash, based + * on PHP's `hash_init` functions. + * + * @param StreamInterface $stream Stream to calculate the hash for + * @param string $algo Hash algorithm (e.g. md5, crc32, etc) + * @param bool $rawOutput Whether or not to use raw output + * + * @throws \RuntimeException on error. + */ + public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string + { + $pos = $stream->tell(); + + if ($pos > 0) { + $stream->rewind(); + } + + $ctx = hash_init($algo); + while (!$stream->eof()) { + hash_update($ctx, $stream->read(1048576)); + } + + $out = hash_final($ctx, $rawOutput); + $stream->seek($pos); + + return $out; + } + + /** + * Clone and modify a request with the given changes. + * + * This method is useful for reducing the number of clones needed to mutate + * a message. + * + * The changes can be one of: + * - method: (string) Changes the HTTP method. + * - set_headers: (array) Sets the given headers. + * - remove_headers: (array) Remove the given headers. + * - body: (mixed) Sets the given body. + * - uri: (UriInterface) Set the URI. + * - query: (string) Set the query string value of the URI. + * - version: (string) Set the protocol version. + * + * @param RequestInterface $request Request to clone and modify. + * @param array $changes Changes to apply. + */ + public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface + { + if (!$changes) { + return $request; + } + + $headers = $request->getHeaders(); + + if (!isset($changes['uri'])) { + $uri = $request->getUri(); + } else { + // Remove the host header if one is on the URI + if ($host = $changes['uri']->getHost()) { + $changes['set_headers']['Host'] = $host; + + if ($port = $changes['uri']->getPort()) { + $standardPorts = ['http' => 80, 'https' => 443]; + $scheme = $changes['uri']->getScheme(); + if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) { + $changes['set_headers']['Host'] .= ':'.$port; + } + } + } + $uri = $changes['uri']; + } + + if (!empty($changes['remove_headers'])) { + $headers = self::caselessRemove($changes['remove_headers'], $headers); + } + + if (!empty($changes['set_headers'])) { + $headers = self::caselessRemove(array_keys($changes['set_headers']), $headers); + $headers = $changes['set_headers'] + $headers; + } + + if (isset($changes['query'])) { + $uri = $uri->withQuery($changes['query']); + } + + if ($request instanceof ServerRequestInterface) { + $new = (new ServerRequest( + $changes['method'] ?? $request->getMethod(), + $uri, + $headers, + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion(), + $request->getServerParams() + )) + ->withParsedBody($request->getParsedBody()) + ->withQueryParams($request->getQueryParams()) + ->withCookieParams($request->getCookieParams()) + ->withUploadedFiles($request->getUploadedFiles()); + + foreach ($request->getAttributes() as $key => $value) { + $new = $new->withAttribute($key, $value); + } + + return $new; + } + + return new Request( + $changes['method'] ?? $request->getMethod(), + $uri, + $headers, + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion() + ); + } + + /** + * Read a line from the stream up to the maximum allowed buffer length. + * + * @param StreamInterface $stream Stream to read from + * @param int|null $maxLength Maximum buffer length + */ + public static function readLine(StreamInterface $stream, ?int $maxLength = null): string + { + $buffer = ''; + $size = 0; + + while (!$stream->eof()) { + if ('' === ($byte = $stream->read(1))) { + return $buffer; + } + $buffer .= $byte; + // Break when a new line is found or the max length - 1 is reached + if ($byte === "\n" || ++$size === $maxLength - 1) { + break; + } + } + + return $buffer; + } + + /** + * Redact the password in the user info part of a URI. + */ + public static function redactUserInfo(UriInterface $uri): UriInterface + { + $userInfo = $uri->getUserInfo(); + + if (false !== ($pos = \strpos($userInfo, ':'))) { + return $uri->withUserInfo(\substr($userInfo, 0, $pos), '***'); + } + + return $uri; + } + + /** + * Create a new stream based on the input type. + * + * Options is an associative array that can contain the following keys: + * - metadata: Array of custom metadata. + * - size: Size of the stream. + * + * This method accepts the following `$resource` types: + * - `Psr\Http\Message\StreamInterface`: Returns the value as-is. + * - `string`: Creates a stream object that uses the given string as the contents. + * - `resource`: Creates a stream object that wraps the given PHP stream resource. + * - `Iterator`: If the provided value implements `Iterator`, then a read-only + * stream object will be created that wraps the given iterable. Each time the + * stream is read from, data from the iterator will fill a buffer and will be + * continuously called until the buffer is equal to the requested read size. + * Subsequent read calls will first read from the buffer and then call `next` + * on the underlying iterator until it is exhausted. + * - `object` with `__toString()`: If the object has the `__toString()` method, + * the object will be cast to a string and then a stream will be returned that + * uses the string value. + * - `NULL`: When `null` is passed, an empty stream object is returned. + * - `callable` When a callable is passed, a read-only stream object will be + * created that invokes the given callable. The callable is invoked with the + * number of suggested bytes to read. The callable can return any number of + * bytes, but MUST return `false` when there is no more data to return. The + * stream object that wraps the callable will invoke the callable until the + * number of requested bytes are available. Any additional bytes will be + * buffered and used in subsequent reads. + * + * @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data + * @param array{size?: int, metadata?: array} $options Additional options + * + * @throws \InvalidArgumentException if the $resource arg is not valid. + */ + public static function streamFor($resource = '', array $options = []): StreamInterface + { + if (is_scalar($resource)) { + $stream = self::tryFopen('php://temp', 'r+'); + if ($resource !== '') { + fwrite($stream, (string) $resource); + fseek($stream, 0); + } + + return new Stream($stream, $options); + } + + switch (gettype($resource)) { + case 'resource': + /* + * The 'php://input' is a special stream with quirks and inconsistencies. + * We avoid using that stream by reading it into php://temp + */ + + /** @var resource $resource */ + if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') { + $stream = self::tryFopen('php://temp', 'w+'); + stream_copy_to_stream($resource, $stream); + fseek($stream, 0); + $resource = $stream; + } + + return new Stream($resource, $options); + case 'object': + /** @var object $resource */ + if ($resource instanceof StreamInterface) { + return $resource; + } elseif ($resource instanceof \Iterator) { + return new PumpStream(function () use ($resource) { + if (!$resource->valid()) { + return false; + } + $result = $resource->current(); + $resource->next(); + + return $result; + }, $options); + } elseif (method_exists($resource, '__toString')) { + return self::streamFor((string) $resource, $options); + } + break; + case 'NULL': + return new Stream(self::tryFopen('php://temp', 'r+'), $options); + } + + if (is_callable($resource)) { + return new PumpStream($resource, $options); + } + + throw new \InvalidArgumentException('Invalid resource type: '.gettype($resource)); + } + + /** + * Safely opens a PHP stream resource using a filename. + * + * When fopen fails, PHP normally raises a warning. This function adds an + * error handler that checks for errors and throws an exception instead. + * + * @param string $filename File to open + * @param string $mode Mode used to open the file + * + * @return resource + * + * @throws \RuntimeException if the file cannot be opened + */ + public static function tryFopen(string $filename, string $mode) + { + $ex = null; + set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool { + $ex = new \RuntimeException(sprintf( + 'Unable to open "%s" using mode "%s": %s', + $filename, + $mode, + $errstr + )); + + return true; + }); + + try { + /** @var resource $handle */ + $handle = fopen($filename, $mode); + } catch (\Throwable $e) { + $ex = new \RuntimeException(sprintf( + 'Unable to open "%s" using mode "%s": %s', + $filename, + $mode, + $e->getMessage() + ), 0, $e); + } + + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $handle; + } + + /** + * Safely gets the contents of a given stream. + * + * When stream_get_contents fails, PHP normally raises a warning. This + * function adds an error handler that checks for errors and throws an + * exception instead. + * + * @param resource $stream + * + * @throws \RuntimeException if the stream cannot be read + */ + public static function tryGetContents($stream): string + { + $ex = null; + set_error_handler(static function (int $errno, string $errstr) use (&$ex): bool { + $ex = new \RuntimeException(sprintf( + 'Unable to read stream contents: %s', + $errstr + )); + + return true; + }); + + try { + /** @var string|false $contents */ + $contents = stream_get_contents($stream); + + if ($contents === false) { + $ex = new \RuntimeException('Unable to read stream contents'); + } + } catch (\Throwable $e) { + $ex = new \RuntimeException(sprintf( + 'Unable to read stream contents: %s', + $e->getMessage() + ), 0, $e); + } + + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $contents; + } + + /** + * Returns a UriInterface for the given value. + * + * This function accepts a string or UriInterface and returns a + * UriInterface for the given value. If the value is already a + * UriInterface, it is returned as-is. + * + * @param string|UriInterface $uri + * + * @throws \InvalidArgumentException + */ + public static function uriFor($uri): UriInterface + { + if ($uri instanceof UriInterface) { + return $uri; + } + + if (is_string($uri)) { + return new Uri($uri); + } + + throw new \InvalidArgumentException('URI must be a string or UriInterface'); + } +} diff --git a/vendor/league/flysystem-local/FallbackMimeTypeDetector.php b/vendor/league/flysystem-local/FallbackMimeTypeDetector.php new file mode 100644 index 0000000..382ecef --- /dev/null +++ b/vendor/league/flysystem-local/FallbackMimeTypeDetector.php @@ -0,0 +1,52 @@ +detector->detectMimeType($path, $contents); + } + + public function detectMimeTypeFromBuffer(string $contents): ?string + { + return $this->detector->detectMimeTypeFromBuffer($contents); + } + + public function detectMimeTypeFromPath(string $path): ?string + { + return $this->detector->detectMimeTypeFromPath($path); + } + + public function detectMimeTypeFromFile(string $path): ?string + { + $mimeType = $this->detector->detectMimeTypeFromFile($path); + + if ($mimeType !== null && ! in_array($mimeType, $this->inconclusiveMimetypes)) { + return $mimeType; + } + + return $this->detector->detectMimeTypeFromPath($path) ?? ($this->useInconclusiveMimeTypeFallback ? $mimeType : null); + } +} diff --git a/vendor/league/flysystem-local/LICENSE b/vendor/league/flysystem-local/LICENSE new file mode 100644 index 0000000..0c5fa23 --- /dev/null +++ b/vendor/league/flysystem-local/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013-2024 Frank de Jonge + +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/vendor/league/flysystem-local/LocalFilesystemAdapter.php b/vendor/league/flysystem-local/LocalFilesystemAdapter.php new file mode 100644 index 0000000..f01c2c5 --- /dev/null +++ b/vendor/league/flysystem-local/LocalFilesystemAdapter.php @@ -0,0 +1,485 @@ +prefixer = new PathPrefixer($location, DIRECTORY_SEPARATOR); + $visibility ??= new PortableVisibilityConverter(); + $this->visibility = $visibility; + $this->rootLocation = $location; + $this->mimeTypeDetector = $mimeTypeDetector ?? new FallbackMimeTypeDetector( + detector: new FinfoMimeTypeDetector(), + useInconclusiveMimeTypeFallback: $useInconclusiveMimeTypeFallback, + ); + + if ( ! $lazyRootCreation) { + $this->ensureRootDirectoryExists(); + } + } + + private function ensureRootDirectoryExists(): void + { + if ($this->rootLocationIsSetup) { + return; + } + + $this->ensureDirectoryExists($this->rootLocation, $this->visibility->defaultForDirectories()); + $this->rootLocationIsSetup = true; + } + + public function write(string $path, string $contents, Config $config): void + { + $this->writeToFile($path, $contents, $config); + } + + public function writeStream(string $path, $contents, Config $config): void + { + $this->writeToFile($path, $contents, $config); + } + + /** + * @param resource|string $contents + */ + private function writeToFile(string $path, $contents, Config $config): void + { + $prefixedLocation = $this->prefixer->prefixPath($path); + $this->ensureRootDirectoryExists(); + $this->ensureDirectoryExists( + dirname($prefixedLocation), + $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY)) + ); + error_clear_last(); + + if (@file_put_contents($prefixedLocation, $contents, $this->writeFlags) === false) { + throw UnableToWriteFile::atLocation($path, error_get_last()['message'] ?? ''); + } + + if ($visibility = $config->get(Config::OPTION_VISIBILITY)) { + $this->setVisibility($path, (string) $visibility); + } + } + + public function delete(string $path): void + { + $location = $this->prefixer->prefixPath($path); + + if ( ! file_exists($location)) { + return; + } + + error_clear_last(); + + if ( ! @unlink($location)) { + throw UnableToDeleteFile::atLocation($location, error_get_last()['message'] ?? ''); + } + } + + public function deleteDirectory(string $prefix): void + { + $location = $this->prefixer->prefixPath($prefix); + + if ( ! is_dir($location)) { + return; + } + + $contents = $this->listDirectoryRecursively($location, RecursiveIteratorIterator::CHILD_FIRST); + + /** @var SplFileInfo $file */ + foreach ($contents as $file) { + if ( ! $this->deleteFileInfoObject($file)) { + throw UnableToDeleteDirectory::atLocation($prefix, "Unable to delete file at " . $file->getPathname()); + } + } + + unset($contents); + + if ( ! @rmdir($location)) { + throw UnableToDeleteDirectory::atLocation($prefix, error_get_last()['message'] ?? ''); + } + } + + private function listDirectoryRecursively( + string $path, + int $mode = RecursiveIteratorIterator::SELF_FIRST + ): Generator { + if ( ! is_dir($path)) { + return; + } + + yield from new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), + $mode + ); + } + + protected function deleteFileInfoObject(SplFileInfo $file): bool + { + switch ($file->getType()) { + case 'dir': + return @rmdir((string) $file->getRealPath()); + case 'link': + return @unlink((string) $file->getPathname()); + default: + return @unlink((string) $file->getRealPath()); + } + } + + public function listContents(string $path, bool $deep): iterable + { + $location = $this->prefixer->prefixPath($path); + + if ( ! is_dir($location)) { + return; + } + + /** @var SplFileInfo[] $iterator */ + $iterator = $deep ? $this->listDirectoryRecursively($location) : $this->listDirectory($location); + + foreach ($iterator as $fileInfo) { + $pathName = $fileInfo->getPathname(); + + try { + if ($fileInfo->isLink()) { + if ($this->linkHandling & self::SKIP_LINKS) { + continue; + } + throw SymbolicLinkEncountered::atLocation($pathName); + } + + $path = $this->prefixer->stripPrefix($pathName); + $lastModified = $fileInfo->getMTime(); + $isDirectory = $fileInfo->isDir(); + $permissions = octdec(substr(sprintf('%o', $fileInfo->getPerms()), -4)); + $visibility = $isDirectory ? $this->visibility->inverseForDirectory($permissions) : $this->visibility->inverseForFile($permissions); + + yield $isDirectory ? new DirectoryAttributes(str_replace('\\', '/', $path), $visibility, $lastModified) : new FileAttributes( + str_replace('\\', '/', $path), + $fileInfo->getSize(), + $visibility, + $lastModified + ); + } catch (Throwable $exception) { + if (file_exists($pathName)) { + throw $exception; + } + } + } + } + + public function move(string $source, string $destination, Config $config): void + { + $sourcePath = $this->prefixer->prefixPath($source); + $destinationPath = $this->prefixer->prefixPath($destination); + + $this->ensureRootDirectoryExists(); + $this->ensureDirectoryExists( + dirname($destinationPath), + $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY)) + ); + + if ( ! @rename($sourcePath, $destinationPath)) { + throw UnableToMoveFile::because(error_get_last()['message'] ?? 'unknown reason', $source, $destination); + } + + if ($visibility = $config->get(Config::OPTION_VISIBILITY)) { + $this->setVisibility($destination, (string) $visibility); + } + } + + public function copy(string $source, string $destination, Config $config): void + { + $sourcePath = $this->prefixer->prefixPath($source); + $destinationPath = $this->prefixer->prefixPath($destination); + $this->ensureRootDirectoryExists(); + $this->ensureDirectoryExists( + dirname($destinationPath), + $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY)) + ); + + if ($sourcePath !== $destinationPath && ! @copy($sourcePath, $destinationPath)) { + throw UnableToCopyFile::because(error_get_last()['message'] ?? 'unknown', $source, $destination); + } + + $visibility = $config->get( + Config::OPTION_VISIBILITY, + $config->get(Config::OPTION_RETAIN_VISIBILITY, true) + ? $this->visibility($source)->visibility() + : null, + ); + + if ($visibility) { + $this->setVisibility($destination, (string) $visibility); + } + } + + public function read(string $path): string + { + $location = $this->prefixer->prefixPath($path); + error_clear_last(); + $contents = @file_get_contents($location); + + if ($contents === false) { + throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? ''); + } + + return $contents; + } + + public function readStream(string $path) + { + $location = $this->prefixer->prefixPath($path); + error_clear_last(); + $contents = @fopen($location, 'rb'); + + if ($contents === false) { + throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? ''); + } + + return $contents; + } + + protected function ensureDirectoryExists(string $dirname, int $visibility): void + { + if (is_dir($dirname)) { + return; + } + + error_clear_last(); + + if ( ! @mkdir($dirname, $visibility, true)) { + $mkdirError = error_get_last(); + } + + clearstatcache(true, $dirname); + + if ( ! is_dir($dirname)) { + $errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : ''; + + throw UnableToCreateDirectory::atLocation($dirname, $errorMessage); + } + } + + public function fileExists(string $location): bool + { + $location = $this->prefixer->prefixPath($location); + clearstatcache(); + return is_file($location); + } + + public function directoryExists(string $location): bool + { + $location = $this->prefixer->prefixPath($location); + clearstatcache(); + return is_dir($location); + } + + public function createDirectory(string $path, Config $config): void + { + $this->ensureRootDirectoryExists(); + $location = $this->prefixer->prefixPath($path); + $visibility = $config->get(Config::OPTION_VISIBILITY, $config->get(Config::OPTION_DIRECTORY_VISIBILITY)); + $permissions = $this->resolveDirectoryVisibility($visibility); + + if (is_dir($location)) { + $this->setPermissions($location, $permissions); + + return; + } + + error_clear_last(); + + if ( ! @mkdir($location, $permissions, true)) { + throw UnableToCreateDirectory::atLocation($path, error_get_last()['message'] ?? ''); + } + } + + public function setVisibility(string $path, string $visibility): void + { + $path = $this->prefixer->prefixPath($path); + $visibility = is_dir($path) ? $this->visibility->forDirectory($visibility) : $this->visibility->forFile( + $visibility + ); + + $this->setPermissions($path, $visibility); + } + + public function visibility(string $path): FileAttributes + { + $location = $this->prefixer->prefixPath($path); + clearstatcache(false, $location); + error_clear_last(); + $fileperms = @fileperms($location); + + if ($fileperms === false) { + throw UnableToRetrieveMetadata::visibility($path, error_get_last()['message'] ?? ''); + } + + $permissions = $fileperms & 0777; + $visibility = $this->visibility->inverseForFile($permissions); + + return new FileAttributes($path, null, $visibility); + } + + private function resolveDirectoryVisibility(?string $visibility): int + { + return $visibility === null ? $this->visibility->defaultForDirectories() : $this->visibility->forDirectory( + $visibility + ); + } + + public function mimeType(string $path): FileAttributes + { + $location = $this->prefixer->prefixPath($path); + error_clear_last(); + + if ( ! is_file($location)) { + throw UnableToRetrieveMetadata::mimeType($location, 'No such file exists.'); + } + + $mimeType = $this->mimeTypeDetector->detectMimeTypeFromFile($location); + + if ($mimeType === null) { + throw UnableToRetrieveMetadata::mimeType($path, error_get_last()['message'] ?? ''); + } + + return new FileAttributes($path, null, null, null, $mimeType); + } + + public function lastModified(string $path): FileAttributes + { + $location = $this->prefixer->prefixPath($path); + clearstatcache(); + error_clear_last(); + $lastModified = @filemtime($location); + + if ($lastModified === false) { + throw UnableToRetrieveMetadata::lastModified($path, error_get_last()['message'] ?? ''); + } + + return new FileAttributes($path, null, null, $lastModified); + } + + public function fileSize(string $path): FileAttributes + { + $location = $this->prefixer->prefixPath($path); + clearstatcache(); + error_clear_last(); + + if (is_file($location) && ($fileSize = @filesize($location)) !== false) { + return new FileAttributes($path, $fileSize); + } + + throw UnableToRetrieveMetadata::fileSize($path, error_get_last()['message'] ?? ''); + } + + public function checksum(string $path, Config $config): string + { + $algo = $config->get('checksum_algo', 'md5'); + $location = $this->prefixer->prefixPath($path); + error_clear_last(); + $checksum = @hash_file($algo, $location); + + if ($checksum === false) { + throw new UnableToProvideChecksum(error_get_last()['message'] ?? '', $path); + } + + return $checksum; + } + + private function listDirectory(string $location): Generator + { + $iterator = new DirectoryIterator($location); + + foreach ($iterator as $item) { + if ($item->isDot()) { + continue; + } + + yield $item; + } + } + + private function setPermissions(string $location, int $visibility): void + { + error_clear_last(); + if ( ! @chmod($location, $visibility)) { + $extraMessage = error_get_last()['message'] ?? ''; + throw UnableToSetVisibility::atLocation($this->prefixer->stripPrefix($location), $extraMessage); + } + } +} diff --git a/vendor/league/flysystem-local/composer.json b/vendor/league/flysystem-local/composer.json new file mode 100644 index 0000000..cd9ef25 --- /dev/null +++ b/vendor/league/flysystem-local/composer.json @@ -0,0 +1,25 @@ +{ + "name": "league/flysystem-local", + "description": "Local filesystem adapter for Flysystem.", + "keywords": ["flysystem", "filesystem", "local", "file", "files"], + "type": "library", + "prefer-stable": true, + "autoload": { + "psr-4": { + "League\\Flysystem\\Local\\": "" + } + }, + "require": { + "php": "^8.0.2", + "ext-fileinfo": "*", + "league/flysystem": "^3.0.0", + "league/mime-type-detection": "^1.0.0" + }, + "license": "MIT", + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ] +} diff --git a/vendor/league/flysystem/INFO.md b/vendor/league/flysystem/INFO.md new file mode 100644 index 0000000..70c07b4 --- /dev/null +++ b/vendor/league/flysystem/INFO.md @@ -0,0 +1,2 @@ +View the docs at: https://flysystem.thephpleague.com/docs/ +Changelog at: https://github.com/thephpleague/flysystem/blob/3.x/CHANGELOG.md diff --git a/vendor/league/flysystem/LICENSE b/vendor/league/flysystem/LICENSE new file mode 100644 index 0000000..0c5fa23 --- /dev/null +++ b/vendor/league/flysystem/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013-2024 Frank de Jonge + +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/vendor/league/flysystem/composer.json b/vendor/league/flysystem/composer.json new file mode 100644 index 0000000..700b0ff --- /dev/null +++ b/vendor/league/flysystem/composer.json @@ -0,0 +1,72 @@ +{ + "name": "league/flysystem", + "description": "File storage abstraction for PHP", + "keywords": [ + "filesystem", "filesystems", "files", "storage", "aws", + "s3", "ftp", "sftp", "webdav", "file", "cloud" + ], + "scripts": { + "phpstan": "vendor/bin/phpstan analyse -l 6 src" + }, + "type": "library", + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src" + } + }, + "require": { + "php": "^8.0.2", + "league/flysystem-local": "^3.0.0", + "league/mime-type-detection": "^1.0.0" + }, + "require-dev": { + "ext-zip": "*", + "ext-fileinfo": "*", + "ext-ftp": "*", + "ext-mongodb": "^1.3|^2", + "microsoft/azure-storage-blob": "^1.1", + "phpunit/phpunit": "^9.5.11|^10.0", + "phpstan/phpstan": "^1.10", + "phpseclib/phpseclib": "^3.0.36", + "aws/aws-sdk-php": "^3.295.10", + "composer/semver": "^3.0", + "friendsofphp/php-cs-fixer": "^3.5", + "google/cloud-storage": "^1.23", + "async-aws/s3": "^1.5 || ^2.0", + "async-aws/simple-s3": "^1.1 || ^2.0", + "mongodb/mongodb": "^1.2|^2", + "sabre/dav": "^4.6.0", + "guzzlehttp/psr7": "^2.6" + }, + "conflict": { + "async-aws/core": "<1.19.0", + "async-aws/s3": "<1.14.0", + "symfony/http-client": "<5.2", + "guzzlehttp/ringphp": "<1.1.1", + "guzzlehttp/guzzle": "<7.0", + "aws/aws-sdk-php": "3.209.31 || 3.210.0", + "phpseclib/phpseclib": "3.0.15" + }, + "license": "MIT", + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "repositories": [ + { + "type": "package", + "package": { + "name": "league/flysystem-local", + "version": "3.0.0", + "dist": { + "type": "path", + "url": "src/Local" + } + } + } + ] +} diff --git a/vendor/league/flysystem/readme.md b/vendor/league/flysystem/readme.md new file mode 100644 index 0000000..15c1cb6 --- /dev/null +++ b/vendor/league/flysystem/readme.md @@ -0,0 +1,61 @@ +# League\Flysystem + +[![Author](https://img.shields.io/badge/author-@frankdejonge-blue.svg)](https://twitter.com/frankdejonge) +[![Source Code](https://img.shields.io/badge/source-thephpleague/flysystem-blue.svg)](https://github.com/thephpleague/flysystem) +[![Latest Version](https://img.shields.io/github/tag/thephpleague/flysystem.svg)](https://github.com/thephpleague/flysystem/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/thephpleague/flysystem/blob/master/LICENSE) +[![Quality Assurance](https://github.com/thephpleague/flysystem/workflows/Quality%20Assurance/badge.svg?branch=2.x)](https://github.com/thephpleague/flysystem/actions?query=workflow%3A%22Quality+Assurance%22) +[![Total Downloads](https://img.shields.io/packagist/dt/league/flysystem.svg)](https://packagist.org/packages/league/flysystem) +![php 7.2+](https://img.shields.io/badge/php-min%208.0.2-red.svg) + +## About Flysystem + +Flysystem is a file storage library for PHP. It provides one interface to +interact with many types of filesystems. When you use Flysystem, you're +not only protected from vendor lock-in, you'll also have a consistent experience +for which ever storage is right for you. + +## Getting Started + +* **[New in V3](https://flysystem.thephpleague.com/docs/what-is-new/)**: What is new in Flysystem V2/V3? +* **[Architecture](https://flysystem.thephpleague.com/docs/architecture/)**: Flysystem's internal architecture +* **[Flysystem API](https://flysystem.thephpleague.com/docs/usage/filesystem-api/)**: How to interact with your Flysystem instance +* **[Upgrade from 1x](https://flysystem.thephpleague.com/docs/upgrade-from-1.x/)**: How to upgrade from 1.x/2.x + +### Officially supported adapters + +* **[Local](https://flysystem.thephpleague.com/docs/adapter/local/)** +* **[FTP](https://flysystem.thephpleague.com/docs/adapter/ftp/)** +* **[SFTP](https://flysystem.thephpleague.com/docs/adapter/sftp-v3/)** +* **[Memory](https://flysystem.thephpleague.com/docs/adapter/in-memory/)** +* **[AWS S3](https://flysystem.thephpleague.com/docs/adapter/aws-s3-v3/)** +* **[AsyncAws S3](https://flysystem.thephpleague.com/docs/adapter/async-aws-s3/)** +* **[Google Cloud Storage](https://flysystem.thephpleague.com/docs/adapter/google-cloud-storage/)** +* **[MongoDB GridFS](https://flysystem.thephpleague.com/docs/adapter/gridfs/)** +* **[WebDAV](https://flysystem.thephpleague.com/docs/adapter/webdav/)** +* **[ZipArchive](https://flysystem.thephpleague.com/docs/adapter/zip-archive/)** + +### Third party Adapters + +* **[Azure Blob Storage](https://github.com/Azure-OSS/azure-storage-php-adapter-flysystem)** +* **[Gitlab](https://github.com/RoyVoetman/flysystem-gitlab-storage)** +* **[Google Drive (using regular paths)](https://github.com/masbug/flysystem-google-drive-ext)** +* **[bunny.net / BunnyCDN](https://github.com/PlatformCommunity/flysystem-bunnycdn/tree/v3)** +* **[Sharepoint 365 / One Drive (Using MS Graph)](https://github.com/shitware-ltd/flysystem-msgraph)** +* **[OneDrive](https://github.com/doerffler/flysystem-onedrive)** +* **[Dropbox](https://github.com/spatie/flysystem-dropbox)** +* **[ReplicateAdapter](https://github.com/ajgarlag/flysystem-replicate)** +* **[Uploadcare](https://github.com/vormkracht10/flysystem-uploadcare)** +* **[Useful adapters (FallbackAdapter, LogAdapter, ReadWriteAdapter, RetryAdapter)](https://github.com/ElGigi/FlysystemUsefulAdapters)** +* **[Metadata Cache](https://github.com/jgivoni/flysystem-cache-adapter)** + + +You can always [create an adapter](https://flysystem.thephpleague.com/docs/advanced/creating-an-adapter/) yourself. + +## Security + +If you discover any security related issues, please email info@frankdejonge.nl instead of using the issue tracker. + +## Enjoy + +Oh, and if you've come down this far, you might as well follow me on [twitter](https://twitter.com/frankdejonge). diff --git a/vendor/league/flysystem/src/CalculateChecksumFromStream.php b/vendor/league/flysystem/src/CalculateChecksumFromStream.php new file mode 100644 index 0000000..61b1fa1 --- /dev/null +++ b/vendor/league/flysystem/src/CalculateChecksumFromStream.php @@ -0,0 +1,30 @@ +readStream($path); + $algo = (string) $config->get('checksum_algo', 'md5'); + $context = hash_init($algo); + hash_update_stream($context, $stream); + + return hash_final($context); + } catch (FilesystemException $exception) { + throw new UnableToProvideChecksum($exception->getMessage(), $path, $exception); + } + } + + /** + * @return resource + */ + abstract public function readStream(string $path); +} diff --git a/vendor/league/flysystem/src/ChecksumAlgoIsNotSupported.php b/vendor/league/flysystem/src/ChecksumAlgoIsNotSupported.php new file mode 100644 index 0000000..5d33c0c --- /dev/null +++ b/vendor/league/flysystem/src/ChecksumAlgoIsNotSupported.php @@ -0,0 +1,11 @@ +options[$property] ?? $default; + } + + public function extend(array $options): Config + { + return new Config(array_merge($this->options, $options)); + } + + public function withDefaults(array $defaults): Config + { + return new Config($this->options + $defaults); + } + + public function toArray(): array + { + return $this->options; + } + + public function withSetting(string $property, mixed $setting): Config + { + return $this->extend([$property => $setting]); + } + + public function withoutSettings(string ...$settings): Config + { + return new Config(array_diff_key($this->options, array_flip($settings))); + } +} diff --git a/vendor/league/flysystem/src/CorruptedPathDetected.php b/vendor/league/flysystem/src/CorruptedPathDetected.php new file mode 100644 index 0000000..70631cc --- /dev/null +++ b/vendor/league/flysystem/src/CorruptedPathDetected.php @@ -0,0 +1,13 @@ +adapter->fileExists($path); + } + + public function directoryExists(string $path): bool + { + return $this->adapter->directoryExists($path); + } + + public function write(string $path, string $contents, Config $config): void + { + $this->adapter->write($path, $contents, $config); + } + + public function writeStream(string $path, $contents, Config $config): void + { + $this->adapter->writeStream($path, $contents, $config); + } + + public function read(string $path): string + { + return $this->adapter->read($path); + } + + public function readStream(string $path) + { + return $this->adapter->readStream($path); + } + + public function delete(string $path): void + { + $this->adapter->delete($path); + } + + public function deleteDirectory(string $path): void + { + $this->adapter->deleteDirectory($path); + } + + public function createDirectory(string $path, Config $config): void + { + $this->adapter->createDirectory($path, $config); + } + + public function setVisibility(string $path, string $visibility): void + { + $this->adapter->setVisibility($path, $visibility); + } + + public function visibility(string $path): FileAttributes + { + return $this->adapter->visibility($path); + } + + public function mimeType(string $path): FileAttributes + { + return $this->adapter->mimeType($path); + } + + public function lastModified(string $path): FileAttributes + { + return $this->adapter->lastModified($path); + } + + public function fileSize(string $path): FileAttributes + { + return $this->adapter->fileSize($path); + } + + public function listContents(string $path, bool $deep): iterable + { + return $this->adapter->listContents($path, $deep); + } + + public function move(string $source, string $destination, Config $config): void + { + $this->adapter->move($source, $destination, $config); + } + + public function copy(string $source, string $destination, Config $config): void + { + $this->adapter->copy($source, $destination, $config); + } +} diff --git a/vendor/league/flysystem/src/DirectoryAttributes.php b/vendor/league/flysystem/src/DirectoryAttributes.php new file mode 100644 index 0000000..3fe44c1 --- /dev/null +++ b/vendor/league/flysystem/src/DirectoryAttributes.php @@ -0,0 +1,87 @@ +path = trim($this->path, '/'); + } + + public function path(): string + { + return $this->path; + } + + public function type(): string + { + return $this->type; + } + + public function visibility(): ?string + { + return $this->visibility; + } + + public function lastModified(): ?int + { + return $this->lastModified; + } + + public function extraMetadata(): array + { + return $this->extraMetadata; + } + + public function isFile(): bool + { + return false; + } + + public function isDir(): bool + { + return true; + } + + public function withPath(string $path): self + { + $clone = clone $this; + $clone->path = $path; + + return $clone; + } + + public static function fromArray(array $attributes): self + { + return new DirectoryAttributes( + $attributes[StorageAttributes::ATTRIBUTE_PATH], + $attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null, + $attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null, + $attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? [] + ); + } + + /** + * @inheritDoc + */ + public function jsonSerialize(): array + { + return [ + StorageAttributes::ATTRIBUTE_TYPE => $this->type, + StorageAttributes::ATTRIBUTE_PATH => $this->path, + StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility, + StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified, + StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata, + ]; + } +} diff --git a/vendor/league/flysystem/src/DirectoryListing.php b/vendor/league/flysystem/src/DirectoryListing.php new file mode 100644 index 0000000..7b1a1f5 --- /dev/null +++ b/vendor/league/flysystem/src/DirectoryListing.php @@ -0,0 +1,93 @@ + $listing + */ + public function __construct(private iterable $listing) + { + } + + /** + * @param callable(T): bool $filter + * + * @return DirectoryListing + */ + public function filter(callable $filter): DirectoryListing + { + $generator = (static function (iterable $listing) use ($filter): Generator { + foreach ($listing as $item) { + if ($filter($item)) { + yield $item; + } + } + })($this->listing); + + return new DirectoryListing($generator); + } + + /** + * @template R + * + * @param callable(T): R $mapper + * + * @return DirectoryListing + */ + public function map(callable $mapper): DirectoryListing + { + $generator = (static function (iterable $listing) use ($mapper): Generator { + foreach ($listing as $item) { + yield $mapper($item); + } + })($this->listing); + + return new DirectoryListing($generator); + } + + /** + * @return DirectoryListing + */ + public function sortByPath(): DirectoryListing + { + $listing = $this->toArray(); + + usort($listing, function (StorageAttributes $a, StorageAttributes $b) { + return $a->path() <=> $b->path(); + }); + + return new DirectoryListing($listing); + } + + /** + * @return Traversable + */ + public function getIterator(): Traversable + { + return $this->listing instanceof Traversable + ? $this->listing + : new ArrayIterator($this->listing); + } + + /** + * @return T[] + */ + public function toArray(): array + { + return $this->listing instanceof Traversable + ? iterator_to_array($this->listing, false) + : (array) $this->listing; + } +} diff --git a/vendor/league/flysystem/src/FileAttributes.php b/vendor/league/flysystem/src/FileAttributes.php new file mode 100644 index 0000000..42172f8 --- /dev/null +++ b/vendor/league/flysystem/src/FileAttributes.php @@ -0,0 +1,100 @@ +path = ltrim($this->path, '/'); + } + + public function type(): string + { + return $this->type; + } + + public function path(): string + { + return $this->path; + } + + public function fileSize(): ?int + { + return $this->fileSize; + } + + public function visibility(): ?string + { + return $this->visibility; + } + + public function lastModified(): ?int + { + return $this->lastModified; + } + + public function mimeType(): ?string + { + return $this->mimeType; + } + + public function extraMetadata(): array + { + return $this->extraMetadata; + } + + public function isFile(): bool + { + return true; + } + + public function isDir(): bool + { + return false; + } + + public function withPath(string $path): self + { + $clone = clone $this; + $clone->path = $path; + + return $clone; + } + + public static function fromArray(array $attributes): self + { + return new FileAttributes( + $attributes[StorageAttributes::ATTRIBUTE_PATH], + $attributes[StorageAttributes::ATTRIBUTE_FILE_SIZE] ?? null, + $attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null, + $attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null, + $attributes[StorageAttributes::ATTRIBUTE_MIME_TYPE] ?? null, + $attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? [] + ); + } + + public function jsonSerialize(): array + { + return [ + StorageAttributes::ATTRIBUTE_TYPE => self::TYPE_FILE, + StorageAttributes::ATTRIBUTE_PATH => $this->path, + StorageAttributes::ATTRIBUTE_FILE_SIZE => $this->fileSize, + StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility, + StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified, + StorageAttributes::ATTRIBUTE_MIME_TYPE => $this->mimeType, + StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata, + ]; + } +} diff --git a/vendor/league/flysystem/src/Filesystem.php b/vendor/league/flysystem/src/Filesystem.php new file mode 100644 index 0000000..4fb30cc --- /dev/null +++ b/vendor/league/flysystem/src/Filesystem.php @@ -0,0 +1,290 @@ +config = new Config($config); + $this->pathNormalizer = $pathNormalizer ?? new WhitespacePathNormalizer(); + } + + public function fileExists(string $location): bool + { + return $this->adapter->fileExists($this->pathNormalizer->normalizePath($location)); + } + + public function directoryExists(string $location): bool + { + return $this->adapter->directoryExists($this->pathNormalizer->normalizePath($location)); + } + + public function has(string $location): bool + { + $path = $this->pathNormalizer->normalizePath($location); + + return $this->adapter->fileExists($path) || $this->adapter->directoryExists($path); + } + + public function write(string $location, string $contents, array $config = []): void + { + $this->adapter->write( + $this->pathNormalizer->normalizePath($location), + $contents, + $this->config->extend($config) + ); + } + + public function writeStream(string $location, $contents, array $config = []): void + { + /* @var resource $contents */ + $this->assertIsResource($contents); + $this->rewindStream($contents); + $this->adapter->writeStream( + $this->pathNormalizer->normalizePath($location), + $contents, + $this->config->extend($config) + ); + } + + public function read(string $location): string + { + return $this->adapter->read($this->pathNormalizer->normalizePath($location)); + } + + public function readStream(string $location) + { + return $this->adapter->readStream($this->pathNormalizer->normalizePath($location)); + } + + public function delete(string $location): void + { + $this->adapter->delete($this->pathNormalizer->normalizePath($location)); + } + + public function deleteDirectory(string $location): void + { + $this->adapter->deleteDirectory($this->pathNormalizer->normalizePath($location)); + } + + public function createDirectory(string $location, array $config = []): void + { + $this->adapter->createDirectory( + $this->pathNormalizer->normalizePath($location), + $this->config->extend($config) + ); + } + + public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing + { + $path = $this->pathNormalizer->normalizePath($location); + $listing = $this->adapter->listContents($path, $deep); + + return new DirectoryListing($this->pipeListing($location, $deep, $listing)); + } + + private function pipeListing(string $location, bool $deep, iterable $listing): Generator + { + try { + foreach ($listing as $item) { + yield $item; + } + } catch (Throwable $exception) { + throw UnableToListContents::atLocation($location, $deep, $exception); + } + } + + public function move(string $source, string $destination, array $config = []): void + { + $config = $this->resolveConfigForMoveAndCopy($config); + $from = $this->pathNormalizer->normalizePath($source); + $to = $this->pathNormalizer->normalizePath($destination); + + if ($from === $to) { + $resolutionStrategy = $config->get(Config::OPTION_MOVE_IDENTICAL_PATH, ResolveIdenticalPathConflict::TRY); + + if ($resolutionStrategy === ResolveIdenticalPathConflict::FAIL) { + throw UnableToMoveFile::sourceAndDestinationAreTheSame($source, $destination); + } elseif ($resolutionStrategy === ResolveIdenticalPathConflict::IGNORE) { + return; + } + } + + $this->adapter->move($from, $to, $config); + } + + public function copy(string $source, string $destination, array $config = []): void + { + $config = $this->resolveConfigForMoveAndCopy($config); + $from = $this->pathNormalizer->normalizePath($source); + $to = $this->pathNormalizer->normalizePath($destination); + + if ($from === $to) { + $resolutionStrategy = $config->get(Config::OPTION_COPY_IDENTICAL_PATH, ResolveIdenticalPathConflict::TRY); + + if ($resolutionStrategy === ResolveIdenticalPathConflict::FAIL) { + throw UnableToCopyFile::sourceAndDestinationAreTheSame($source, $destination); + } elseif ($resolutionStrategy === ResolveIdenticalPathConflict::IGNORE) { + return; + } + } + + $this->adapter->copy($from, $to, $config); + } + + public function lastModified(string $path): int + { + return $this->adapter->lastModified($this->pathNormalizer->normalizePath($path))->lastModified(); + } + + public function fileSize(string $path): int + { + return $this->adapter->fileSize($this->pathNormalizer->normalizePath($path))->fileSize(); + } + + public function mimeType(string $path): string + { + return $this->adapter->mimeType($this->pathNormalizer->normalizePath($path))->mimeType(); + } + + public function setVisibility(string $path, string $visibility): void + { + $this->adapter->setVisibility($this->pathNormalizer->normalizePath($path), $visibility); + } + + public function visibility(string $path): string + { + return $this->adapter->visibility($this->pathNormalizer->normalizePath($path))->visibility(); + } + + public function publicUrl(string $path, array $config = []): string + { + $this->publicUrlGenerator ??= $this->resolvePublicUrlGenerator() + ?? throw UnableToGeneratePublicUrl::noGeneratorConfigured($path); + $config = $this->config->extend($config); + + return $this->publicUrlGenerator->publicUrl( + $this->pathNormalizer->normalizePath($path), + $config, + ); + } + + public function temporaryUrl(string $path, DateTimeInterface $expiresAt, array $config = []): string + { + $generator = $this->temporaryUrlGenerator ?? $this->adapter; + + if ($generator instanceof TemporaryUrlGenerator) { + return $generator->temporaryUrl( + $this->pathNormalizer->normalizePath($path), + $expiresAt, + $this->config->extend($config) + ); + } + + throw UnableToGenerateTemporaryUrl::noGeneratorConfigured($path); + } + + public function checksum(string $path, array $config = []): string + { + $config = $this->config->extend($config); + + if ( ! $this->adapter instanceof ChecksumProvider) { + return $this->calculateChecksumFromStream($path, $config); + } + + try { + return $this->adapter->checksum( + $this->pathNormalizer->normalizePath($path), + $config, + ); + } catch (ChecksumAlgoIsNotSupported) { + return $this->calculateChecksumFromStream( + $this->pathNormalizer->normalizePath($path), + $config, + ); + } + } + + private function resolvePublicUrlGenerator(): ?PublicUrlGenerator + { + if ($publicUrl = $this->config->get('public_url')) { + return match (true) { + is_array($publicUrl) => new ShardedPrefixPublicUrlGenerator($publicUrl), + default => new PrefixPublicUrlGenerator($publicUrl), + }; + } + + if ($this->adapter instanceof PublicUrlGenerator) { + return $this->adapter; + } + + return null; + } + + /** + * @param mixed $contents + */ + private function assertIsResource($contents): void + { + if (is_resource($contents) === false) { + throw new InvalidStreamProvided( + "Invalid stream provided, expected stream resource, received " . gettype($contents) + ); + } elseif ($type = get_resource_type($contents) !== 'stream') { + throw new InvalidStreamProvided( + "Invalid stream provided, expected stream resource, received resource of type " . $type + ); + } + } + + /** + * @param resource $resource + */ + private function rewindStream($resource): void + { + if (ftell($resource) !== 0 && stream_get_meta_data($resource)['seekable']) { + rewind($resource); + } + } + + private function resolveConfigForMoveAndCopy(array $config): Config + { + $retainVisibility = $this->config->get(Config::OPTION_RETAIN_VISIBILITY, $config[Config::OPTION_RETAIN_VISIBILITY] ?? true); + $fullConfig = $this->config->extend($config); + + /* + * By default, we retain visibility. When we do not retain visibility, the visibility setting + * from the default configuration is ignored. Only when it is set explicitly, we propagate the + * setting. + */ + if ($retainVisibility && ! array_key_exists(Config::OPTION_VISIBILITY, $config)) { + $fullConfig = $fullConfig->withoutSettings(Config::OPTION_VISIBILITY)->extend($config); + } + + return $fullConfig; + } +} diff --git a/vendor/league/flysystem/src/FilesystemAdapter.php b/vendor/league/flysystem/src/FilesystemAdapter.php new file mode 100644 index 0000000..714309f --- /dev/null +++ b/vendor/league/flysystem/src/FilesystemAdapter.php @@ -0,0 +1,115 @@ + + * + * @throws FilesystemException + */ + public function listContents(string $path, bool $deep): iterable; + + /** + * @throws UnableToMoveFile + * @throws FilesystemException + */ + public function move(string $source, string $destination, Config $config): void; + + /** + * @throws UnableToCopyFile + * @throws FilesystemException + */ + public function copy(string $source, string $destination, Config $config): void; +} diff --git a/vendor/league/flysystem/src/FilesystemException.php b/vendor/league/flysystem/src/FilesystemException.php new file mode 100644 index 0000000..f9d6018 --- /dev/null +++ b/vendor/league/flysystem/src/FilesystemException.php @@ -0,0 +1,11 @@ + + * + * @throws FilesystemException + * @throws UnableToListContents + */ + public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing; + + /** + * @throws UnableToRetrieveMetadata + * @throws FilesystemException + */ + public function lastModified(string $path): int; + + /** + * @throws UnableToRetrieveMetadata + * @throws FilesystemException + */ + public function fileSize(string $path): int; + + /** + * @throws UnableToRetrieveMetadata + * @throws FilesystemException + */ + public function mimeType(string $path): string; + + /** + * @throws UnableToRetrieveMetadata + * @throws FilesystemException + */ + public function visibility(string $path): string; +} diff --git a/vendor/league/flysystem/src/FilesystemWriter.php b/vendor/league/flysystem/src/FilesystemWriter.php new file mode 100644 index 0000000..a24bb0f --- /dev/null +++ b/vendor/league/flysystem/src/FilesystemWriter.php @@ -0,0 +1,58 @@ + + */ + private $filesystems = []; + + /** + * @var Config + */ + private $config; + + /** + * MountManager constructor. + * + * @param array $filesystems + */ + public function __construct(array $filesystems = [], array $config = []) + { + $this->mountFilesystems($filesystems); + $this->config = new Config($config); + } + + /** + * It is not recommended to mount filesystems after creation because interacting + * with the Mount Manager becomes unpredictable. Use this as an escape hatch. + */ + public function dangerouslyMountFilesystems(string $key, FilesystemOperator $filesystem): void + { + $this->mountFilesystem($key, $filesystem); + } + + /** + * @param array $filesystems + */ + public function extend(array $filesystems, array $config = []): MountManager + { + $clone = clone $this; + $clone->config = $this->config->extend($config); + $clone->mountFilesystems($filesystems); + + return $clone; + } + + public function fileExists(string $location): bool + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->fileExists($path); + } catch (Throwable $exception) { + throw UnableToCheckFileExistence::forLocation($location, $exception); + } + } + + public function has(string $location): bool + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->fileExists($path) || $filesystem->directoryExists($path); + } catch (Throwable $exception) { + throw UnableToCheckExistence::forLocation($location, $exception); + } + } + + public function directoryExists(string $location): bool + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->directoryExists($path); + } catch (Throwable $exception) { + throw UnableToCheckDirectoryExistence::forLocation($location, $exception); + } + } + + public function read(string $location): string + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->read($path); + } catch (UnableToReadFile $exception) { + throw UnableToReadFile::fromLocation($location, $exception->reason(), $exception); + } + } + + public function readStream(string $location) + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->readStream($path); + } catch (UnableToReadFile $exception) { + throw UnableToReadFile::fromLocation($location, $exception->reason(), $exception); + } + } + + public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path, $mountIdentifier] = $this->determineFilesystemAndPath($location); + + return + $filesystem + ->listContents($path, $deep) + ->map( + function (StorageAttributes $attributes) use ($mountIdentifier) { + return $attributes->withPath(sprintf('%s://%s', $mountIdentifier, $attributes->path())); + } + ); + } + + public function lastModified(string $location): int + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->lastModified($path); + } catch (UnableToRetrieveMetadata $exception) { + throw UnableToRetrieveMetadata::lastModified($location, $exception->reason(), $exception); + } + } + + public function fileSize(string $location): int + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->fileSize($path); + } catch (UnableToRetrieveMetadata $exception) { + throw UnableToRetrieveMetadata::fileSize($location, $exception->reason(), $exception); + } + } + + public function mimeType(string $location): string + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + return $filesystem->mimeType($path); + } catch (UnableToRetrieveMetadata $exception) { + throw UnableToRetrieveMetadata::mimeType($location, $exception->reason(), $exception); + } + } + + public function visibility(string $path): string + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $location] = $this->determineFilesystemAndPath($path); + + try { + return $filesystem->visibility($location); + } catch (UnableToRetrieveMetadata $exception) { + throw UnableToRetrieveMetadata::visibility($path, $exception->reason(), $exception); + } + } + + public function write(string $location, string $contents, array $config = []): void + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + $filesystem->write($path, $contents, $this->config->extend($config)->toArray()); + } catch (UnableToWriteFile $exception) { + throw UnableToWriteFile::atLocation($location, $exception->reason(), $exception); + } + } + + public function writeStream(string $location, $contents, array $config = []): void + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + $filesystem->writeStream($path, $contents, $this->config->extend($config)->toArray()); + } + + public function setVisibility(string $path, string $visibility): void + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($path); + $filesystem->setVisibility($path, $visibility); + } + + public function delete(string $location): void + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + $filesystem->delete($path); + } catch (UnableToDeleteFile $exception) { + throw UnableToDeleteFile::atLocation($location, $exception->reason(), $exception); + } + } + + public function deleteDirectory(string $location): void + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + $filesystem->deleteDirectory($path); + } catch (UnableToDeleteDirectory $exception) { + throw UnableToDeleteDirectory::atLocation($location, $exception->reason(), $exception); + } + } + + public function createDirectory(string $location, array $config = []): void + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($location); + + try { + $filesystem->createDirectory($path, $this->config->extend($config)->toArray()); + } catch (UnableToCreateDirectory $exception) { + throw UnableToCreateDirectory::dueToFailure($location, $exception); + } + } + + public function move(string $source, string $destination, array $config = []): void + { + /** @var FilesystemOperator $sourceFilesystem */ + /* @var FilesystemOperator $destinationFilesystem */ + [$sourceFilesystem, $sourcePath] = $this->determineFilesystemAndPath($source); + [$destinationFilesystem, $destinationPath] = $this->determineFilesystemAndPath($destination); + + $sourceFilesystem === $destinationFilesystem ? $this->moveInTheSameFilesystem( + $sourceFilesystem, + $sourcePath, + $destinationPath, + $source, + $destination, + $config, + ) : $this->moveAcrossFilesystems($source, $destination, $config); + } + + public function copy(string $source, string $destination, array $config = []): void + { + /** @var FilesystemOperator $sourceFilesystem */ + /* @var FilesystemOperator $destinationFilesystem */ + [$sourceFilesystem, $sourcePath] = $this->determineFilesystemAndPath($source); + [$destinationFilesystem, $destinationPath] = $this->determineFilesystemAndPath($destination); + + $sourceFilesystem === $destinationFilesystem ? $this->copyInSameFilesystem( + $sourceFilesystem, + $sourcePath, + $destinationPath, + $source, + $destination, + $config, + ) : $this->copyAcrossFilesystem( + $sourceFilesystem, + $sourcePath, + $destinationFilesystem, + $destinationPath, + $source, + $destination, + $config, + ); + } + + public function publicUrl(string $path, array $config = []): string + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($path); + + if ( ! method_exists($filesystem, 'publicUrl')) { + throw new UnableToGeneratePublicUrl(sprintf('%s does not support generating public urls.', $filesystem::class), $path); + } + + return $filesystem->publicUrl($path, $config); + } + + public function temporaryUrl(string $path, DateTimeInterface $expiresAt, array $config = []): string + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($path); + + if ( ! method_exists($filesystem, 'temporaryUrl')) { + throw new UnableToGenerateTemporaryUrl(sprintf('%s does not support generating public urls.', $filesystem::class), $path); + } + + return $filesystem->temporaryUrl($path, $expiresAt, $this->config->extend($config)->toArray()); + } + + public function checksum(string $path, array $config = []): string + { + /** @var FilesystemOperator $filesystem */ + [$filesystem, $path] = $this->determineFilesystemAndPath($path); + + if ( ! method_exists($filesystem, 'checksum')) { + throw new UnableToProvideChecksum(sprintf('%s does not support providing checksums.', $filesystem::class), $path); + } + + return $filesystem->checksum($path, $this->config->extend($config)->toArray()); + } + + private function mountFilesystems(array $filesystems): void + { + foreach ($filesystems as $key => $filesystem) { + $this->guardAgainstInvalidMount($key, $filesystem); + /* @var string $key */ + /* @var FilesystemOperator $filesystem */ + $this->mountFilesystem($key, $filesystem); + } + } + + private function guardAgainstInvalidMount(mixed $key, mixed $filesystem): void + { + if ( ! is_string($key)) { + throw UnableToMountFilesystem::becauseTheKeyIsNotValid($key); + } + + if ( ! $filesystem instanceof FilesystemOperator) { + throw UnableToMountFilesystem::becauseTheFilesystemWasNotValid($filesystem); + } + } + + private function mountFilesystem(string $key, FilesystemOperator $filesystem): void + { + $this->filesystems[$key] = $filesystem; + } + + /** + * @param string $path + * + * @return array{0:FilesystemOperator, 1:string, 2:string} + */ + private function determineFilesystemAndPath(string $path): array + { + if (strpos($path, '://') < 1) { + throw UnableToResolveFilesystemMount::becauseTheSeparatorIsMissing($path); + } + + /** @var string $mountIdentifier */ + /** @var string $mountPath */ + [$mountIdentifier, $mountPath] = explode('://', $path, 2); + + if ( ! array_key_exists($mountIdentifier, $this->filesystems)) { + throw UnableToResolveFilesystemMount::becauseTheMountWasNotRegistered($mountIdentifier); + } + + return [$this->filesystems[$mountIdentifier], $mountPath, $mountIdentifier]; + } + + private function copyInSameFilesystem( + FilesystemOperator $sourceFilesystem, + string $sourcePath, + string $destinationPath, + string $source, + string $destination, + array $config, + ): void { + try { + $sourceFilesystem->copy($sourcePath, $destinationPath, $this->config->extend($config)->toArray()); + } catch (UnableToCopyFile $exception) { + throw UnableToCopyFile::fromLocationTo($source, $destination, $exception); + } + } + + private function copyAcrossFilesystem( + FilesystemOperator $sourceFilesystem, + string $sourcePath, + FilesystemOperator $destinationFilesystem, + string $destinationPath, + string $source, + string $destination, + array $config, + ): void { + $config = $this->config->extend($config); + $retainVisibility = (bool) $config->get(Config::OPTION_RETAIN_VISIBILITY, true); + $visibility = $config->get(Config::OPTION_VISIBILITY); + + try { + if ($visibility == null && $retainVisibility) { + $visibility = $sourceFilesystem->visibility($sourcePath); + $config = $config->extend(compact('visibility')); + } + + $stream = $sourceFilesystem->readStream($sourcePath); + $destinationFilesystem->writeStream($destinationPath, $stream, $config->toArray()); + } catch (UnableToRetrieveMetadata | UnableToReadFile | UnableToWriteFile $exception) { + throw UnableToCopyFile::fromLocationTo($source, $destination, $exception); + } + } + + private function moveInTheSameFilesystem( + FilesystemOperator $sourceFilesystem, + string $sourcePath, + string $destinationPath, + string $source, + string $destination, + array $config, + ): void { + try { + $sourceFilesystem->move($sourcePath, $destinationPath, $this->config->extend($config)->toArray()); + } catch (UnableToMoveFile $exception) { + throw UnableToMoveFile::fromLocationTo($source, $destination, $exception); + } + } + + private function moveAcrossFilesystems(string $source, string $destination, array $config = []): void + { + try { + $this->copy($source, $destination, $config); + $this->delete($source); + } catch (UnableToCopyFile | UnableToDeleteFile $exception) { + throw UnableToMoveFile::fromLocationTo($source, $destination, $exception); + } + } +} diff --git a/vendor/league/flysystem/src/PathNormalizer.php b/vendor/league/flysystem/src/PathNormalizer.php new file mode 100644 index 0000000..54da201 --- /dev/null +++ b/vendor/league/flysystem/src/PathNormalizer.php @@ -0,0 +1,10 @@ +prefix = rtrim($prefix, '\\/'); + + if ($this->prefix !== '' || $prefix === $separator) { + $this->prefix .= $separator; + } + } + + public function prefixPath(string $path): string + { + return $this->prefix . ltrim($path, '\\/'); + } + + public function stripPrefix(string $path): string + { + /* @var string */ + return substr($path, strlen($this->prefix)); + } + + public function stripDirectoryPrefix(string $path): string + { + return rtrim($this->stripPrefix($path), '\\/'); + } + + public function prefixDirectoryPath(string $path): string + { + $prefixedPath = $this->prefixPath(rtrim($path, '\\/')); + + if ($prefixedPath === '' || substr($prefixedPath, -1) === $this->separator) { + return $prefixedPath; + } + + return $prefixedPath . $this->separator; + } +} diff --git a/vendor/league/flysystem/src/PathTraversalDetected.php b/vendor/league/flysystem/src/PathTraversalDetected.php new file mode 100644 index 0000000..fef3edf --- /dev/null +++ b/vendor/league/flysystem/src/PathTraversalDetected.php @@ -0,0 +1,25 @@ +path; + } + + public static function forPath(string $path): PathTraversalDetected + { + $e = new PathTraversalDetected("Path traversal detected: {$path}"); + $e->path = $path; + + return $e; + } +} diff --git a/vendor/league/flysystem/src/PortableVisibilityGuard.php b/vendor/league/flysystem/src/PortableVisibilityGuard.php new file mode 100644 index 0000000..6e2498b --- /dev/null +++ b/vendor/league/flysystem/src/PortableVisibilityGuard.php @@ -0,0 +1,19 @@ +formatPropertyName((string) $offset); + + return isset($this->{$property}); + } + + /** + * @param mixed $offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + $property = $this->formatPropertyName((string) $offset); + + return $this->{$property}; + } + + /** + * @param mixed $offset + * @param mixed $value + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value): void + { + throw new RuntimeException('Properties can not be manipulated'); + } + + /** + * @param mixed $offset + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset): void + { + throw new RuntimeException('Properties can not be manipulated'); + } +} diff --git a/vendor/league/flysystem/src/ResolveIdenticalPathConflict.php b/vendor/league/flysystem/src/ResolveIdenticalPathConflict.php new file mode 100644 index 0000000..849659b --- /dev/null +++ b/vendor/league/flysystem/src/ResolveIdenticalPathConflict.php @@ -0,0 +1,11 @@ +location; + } + + public static function atLocation(string $pathName): SymbolicLinkEncountered + { + $e = new static("Unsupported symbolic link encountered at location $pathName"); + $e->location = $pathName; + + return $e; + } +} diff --git a/vendor/league/flysystem/src/UnableToCheckDirectoryExistence.php b/vendor/league/flysystem/src/UnableToCheckDirectoryExistence.php new file mode 100644 index 0000000..73ce858 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToCheckDirectoryExistence.php @@ -0,0 +1,13 @@ +source; + } + + public function destination(): string + { + return $this->destination; + } + + public static function fromLocationTo( + string $sourcePath, + string $destinationPath, + ?Throwable $previous = null + ): UnableToCopyFile { + $e = new static("Unable to copy file from $sourcePath to $destinationPath", 0 , $previous); + $e->source = $sourcePath; + $e->destination = $destinationPath; + + return $e; + } + + public static function sourceAndDestinationAreTheSame(string $source, string $destination): UnableToCopyFile + { + return UnableToCopyFile::because('Source and destination are the same', $source, $destination); + } + + public static function because(string $reason, string $sourcePath, string $destinationPath): UnableToCopyFile + { + $e = new static("Unable to copy file from $sourcePath to $destinationPath, because $reason"); + $e->source = $sourcePath; + $e->destination = $destinationPath; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_COPY; + } +} diff --git a/vendor/league/flysystem/src/UnableToCreateDirectory.php b/vendor/league/flysystem/src/UnableToCreateDirectory.php new file mode 100644 index 0000000..f4eead0 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToCreateDirectory.php @@ -0,0 +1,50 @@ +location = $dirname; + $e->reason = $errorMessage; + + return $e; + } + + public static function dueToFailure(string $dirname, Throwable $previous): UnableToCreateDirectory + { + $reason = $previous instanceof UnableToCreateDirectory ? $previous->reason() : ''; + $message = "Unable to create a directory at $dirname. $reason"; + $e = new static(rtrim($message), 0, $previous); + $e->location = $dirname; + $e->reason = $reason ?: $message; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_CREATE_DIRECTORY; + } + + public function reason(): string + { + return $this->reason; + } + + public function location(): string + { + return $this->location; + } +} diff --git a/vendor/league/flysystem/src/UnableToDeleteDirectory.php b/vendor/league/flysystem/src/UnableToDeleteDirectory.php new file mode 100644 index 0000000..bf6cf3b --- /dev/null +++ b/vendor/league/flysystem/src/UnableToDeleteDirectory.php @@ -0,0 +1,48 @@ +location = $location; + $e->reason = $reason; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_DELETE_DIRECTORY; + } + + public function reason(): string + { + return $this->reason; + } + + public function location(): string + { + return $this->location; + } +} diff --git a/vendor/league/flysystem/src/UnableToDeleteFile.php b/vendor/league/flysystem/src/UnableToDeleteFile.php new file mode 100644 index 0000000..e388f33 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToDeleteFile.php @@ -0,0 +1,45 @@ +location = $location; + $e->reason = $reason; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_DELETE; + } + + public function reason(): string + { + return $this->reason; + } + + public function location(): string + { + return $this->location; + } +} diff --git a/vendor/league/flysystem/src/UnableToGeneratePublicUrl.php b/vendor/league/flysystem/src/UnableToGeneratePublicUrl.php new file mode 100644 index 0000000..e3648c7 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToGeneratePublicUrl.php @@ -0,0 +1,26 @@ +getMessage(), $path, $exception); + } + + public static function noGeneratorConfigured(string $path, string $extraReason = ''): static + { + return new static('No generator was configured ' . $extraReason, $path); + } +} diff --git a/vendor/league/flysystem/src/UnableToGenerateTemporaryUrl.php b/vendor/league/flysystem/src/UnableToGenerateTemporaryUrl.php new file mode 100644 index 0000000..338601c --- /dev/null +++ b/vendor/league/flysystem/src/UnableToGenerateTemporaryUrl.php @@ -0,0 +1,26 @@ +getMessage(), $path, $exception); + } + + public static function noGeneratorConfigured(string $path, string $extraReason = ''): static + { + return new static('No generator was configured ' . $extraReason, $path); + } +} diff --git a/vendor/league/flysystem/src/UnableToListContents.php b/vendor/league/flysystem/src/UnableToListContents.php new file mode 100644 index 0000000..4f7961d --- /dev/null +++ b/vendor/league/flysystem/src/UnableToListContents.php @@ -0,0 +1,24 @@ +getMessage(); + + return new UnableToListContents($message, 0, $previous); + } + + public function operation(): string + { + return self::OPERATION_LIST_CONTENTS; + } +} diff --git a/vendor/league/flysystem/src/UnableToMountFilesystem.php b/vendor/league/flysystem/src/UnableToMountFilesystem.php new file mode 100644 index 0000000..bd41bc9 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToMountFilesystem.php @@ -0,0 +1,32 @@ +source; + } + + public function destination(): string + { + return $this->destination; + } + + public static function fromLocationTo( + string $sourcePath, + string $destinationPath, + ?Throwable $previous = null + ): UnableToMoveFile { + $message = $previous?->getMessage() ?? "Unable to move file from $sourcePath to $destinationPath"; + $e = new static($message, 0, $previous); + $e->source = $sourcePath; + $e->destination = $destinationPath; + + return $e; + } + + public static function because( + string $reason, + string $sourcePath, + string $destinationPath, + ): UnableToMoveFile { + $message = "Unable to move file from $sourcePath to $destinationPath, because $reason"; + $e = new static($message); + $e->source = $sourcePath; + $e->destination = $destinationPath; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_MOVE; + } +} diff --git a/vendor/league/flysystem/src/UnableToProvideChecksum.php b/vendor/league/flysystem/src/UnableToProvideChecksum.php new file mode 100644 index 0000000..35e0502 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToProvideChecksum.php @@ -0,0 +1,16 @@ +location = $location; + $e->reason = $reason; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_READ; + } + + public function reason(): string + { + return $this->reason; + } + + public function location(): string + { + return $this->location; + } +} diff --git a/vendor/league/flysystem/src/UnableToResolveFilesystemMount.php b/vendor/league/flysystem/src/UnableToResolveFilesystemMount.php new file mode 100644 index 0000000..91a9ee3 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToResolveFilesystemMount.php @@ -0,0 +1,20 @@ +reason = $reason; + $e->location = $location; + $e->metadataType = $type; + + return $e; + } + + public function reason(): string + { + return $this->reason; + } + + public function location(): string + { + return $this->location; + } + + public function metadataType(): string + { + return $this->metadataType; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_RETRIEVE_METADATA; + } +} diff --git a/vendor/league/flysystem/src/UnableToSetVisibility.php b/vendor/league/flysystem/src/UnableToSetVisibility.php new file mode 100644 index 0000000..d012609 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToSetVisibility.php @@ -0,0 +1,49 @@ +reason; + } + + public static function atLocation(string $filename, string $extraMessage = '', ?Throwable $previous = null): self + { + $message = "Unable to set visibility for file {$filename}. $extraMessage"; + $e = new static(rtrim($message), 0, $previous); + $e->reason = $extraMessage; + $e->location = $filename; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_SET_VISIBILITY; + } + + public function location(): string + { + return $this->location; + } +} diff --git a/vendor/league/flysystem/src/UnableToWriteFile.php b/vendor/league/flysystem/src/UnableToWriteFile.php new file mode 100644 index 0000000..fb9a100 --- /dev/null +++ b/vendor/league/flysystem/src/UnableToWriteFile.php @@ -0,0 +1,45 @@ +location = $location; + $e->reason = $reason; + + return $e; + } + + public function operation(): string + { + return FilesystemOperationFailed::OPERATION_WRITE; + } + + public function reason(): string + { + return $this->reason; + } + + public function location(): string + { + return $this->location; + } +} diff --git a/vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php b/vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php new file mode 100644 index 0000000..117b4d9 --- /dev/null +++ b/vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php @@ -0,0 +1,79 @@ +filePublic + : $this->filePrivate; + } + + public function forDirectory(string $visibility): int + { + PortableVisibilityGuard::guardAgainstInvalidInput($visibility); + + return $visibility === Visibility::PUBLIC + ? $this->directoryPublic + : $this->directoryPrivate; + } + + public function inverseForFile(int $visibility): string + { + if ($visibility === $this->filePublic) { + return Visibility::PUBLIC; + } elseif ($visibility === $this->filePrivate) { + return Visibility::PRIVATE; + } + + return Visibility::PUBLIC; // default + } + + public function inverseForDirectory(int $visibility): string + { + if ($visibility === $this->directoryPublic) { + return Visibility::PUBLIC; + } elseif ($visibility === $this->directoryPrivate) { + return Visibility::PRIVATE; + } + + return Visibility::PUBLIC; // default + } + + public function defaultForDirectories(): int + { + return $this->defaultForDirectories === Visibility::PUBLIC ? $this->directoryPublic : $this->directoryPrivate; + } + + /** + * @param array $permissionMap + */ + public static function fromArray(array $permissionMap, string $defaultForDirectories = Visibility::PRIVATE): PortableVisibilityConverter + { + return new PortableVisibilityConverter( + $permissionMap['file']['public'] ?? 0644, + $permissionMap['file']['private'] ?? 0600, + $permissionMap['dir']['public'] ?? 0755, + $permissionMap['dir']['private'] ?? 0700, + $defaultForDirectories + ); + } +} diff --git a/vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php b/vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php new file mode 100644 index 0000000..64af86a --- /dev/null +++ b/vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php @@ -0,0 +1,14 @@ +location; + } + + public static function atLocation(string $location): UnreadableFileEncountered + { + $e = new static("Unreadable file encountered at location {$location}."); + $e->location = $location; + + return $e; + } +} diff --git a/vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php b/vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php new file mode 100644 index 0000000..079375a --- /dev/null +++ b/vendor/league/flysystem/src/UrlGeneration/ChainedPublicUrlGenerator.php @@ -0,0 +1,30 @@ +generators as $generator) { + try { + return $generator->publicUrl($path, $config); + } catch (UnableToGeneratePublicUrl) { + } + } + + throw new UnableToGeneratePublicUrl('No supported public url generator found.', $path); + } +} diff --git a/vendor/league/flysystem/src/UrlGeneration/PrefixPublicUrlGenerator.php b/vendor/league/flysystem/src/UrlGeneration/PrefixPublicUrlGenerator.php new file mode 100644 index 0000000..7921715 --- /dev/null +++ b/vendor/league/flysystem/src/UrlGeneration/PrefixPublicUrlGenerator.php @@ -0,0 +1,23 @@ +prefixer = new PathPrefixer($urlPrefix, '/'); + } + + public function publicUrl(string $path, Config $config): string + { + return $this->prefixer->prefixPath($path); + } +} diff --git a/vendor/league/flysystem/src/UrlGeneration/PublicUrlGenerator.php b/vendor/league/flysystem/src/UrlGeneration/PublicUrlGenerator.php new file mode 100644 index 0000000..08c987f --- /dev/null +++ b/vendor/league/flysystem/src/UrlGeneration/PublicUrlGenerator.php @@ -0,0 +1,16 @@ +count = count($prefixes); + + if ($this->count === 0) { + throw new InvalidArgumentException('At least one prefix is required.'); + } + + $this->prefixes = array_map(static fn (string $prefix) => new PathPrefixer($prefix, '/'), $prefixes); + } + + public function publicUrl(string $path, Config $config): string + { + $index = abs(crc32($path)) % $this->count; + + return $this->prefixes[$index]->prefixPath($path); + } +} diff --git a/vendor/league/flysystem/src/UrlGeneration/TemporaryUrlGenerator.php b/vendor/league/flysystem/src/UrlGeneration/TemporaryUrlGenerator.php new file mode 100644 index 0000000..87074f7 --- /dev/null +++ b/vendor/league/flysystem/src/UrlGeneration/TemporaryUrlGenerator.php @@ -0,0 +1,16 @@ +rejectFunkyWhiteSpace($path); + + return $this->normalizeRelativePath($path); + } + + private function rejectFunkyWhiteSpace(string $path): void + { + if (preg_match('#\p{C}+#u', $path)) { + throw CorruptedPathDetected::forPath($path); + } + } + + private function normalizeRelativePath(string $path): string + { + $parts = []; + + foreach (explode('/', $path) as $part) { + switch ($part) { + case '': + case '.': + break; + + case '..': + if (empty($parts)) { + throw PathTraversalDetected::forPath($path); + } + array_pop($parts); + break; + + default: + $parts[] = $part; + break; + } + } + + return implode('/', $parts); + } +} diff --git a/vendor/league/mime-type-detection/CHANGELOG.md b/vendor/league/mime-type-detection/CHANGELOG.md new file mode 100644 index 0000000..eb13863 --- /dev/null +++ b/vendor/league/mime-type-detection/CHANGELOG.md @@ -0,0 +1,64 @@ +# Changelog + +## 1.16.0 - 2025-09-21 + +- Updated lookup +- Prepped for 8.4 implicit nullable deprecation + +## 1.15.0 - 2024-01-28 + +- Updated lookup + +## 1.14.0 - 2022-10-17 + +### Updated + +- Updated lookup + +## 1.13.0 - 2023-08-05 + +### Added + +- A reverse lookup mechanism to fetch one or all extensions for a given mimetype + +## 1.12.0 - 2023-08-03 + +### Updated + +- Updated lookup + +## 1.11.0 - 2023-04-17 + +### Updated + +- Updated lookup + +## 1.10.0 - 2022-04-11 + +### Fixed + +- Added Flysystem v1 inconclusive mime-types and made it configurable as a constructor parameter. + +## 1.9.0 - 2021-11-21 + +### Updated + +- Updated lookup + +## 1.8.0 - 2021-09-25 + +### Added + +- Added the decorator `OverridingExtensionToMimeTypeMap` which allows you to override values. + +## 1.7.0 - 2021-01-18 + +### Added + +- Added a `bufferSampleSize` parameter to the `FinfoMimeTypeDetector` class that allows you to send a reduced content sample which costs less memory. + +## 1.6.0 - 2021-01-18 + +### Changes + +- Updated generated mime-type map diff --git a/vendor/league/mime-type-detection/LICENSE b/vendor/league/mime-type-detection/LICENSE new file mode 100644 index 0000000..39d50b5 --- /dev/null +++ b/vendor/league/mime-type-detection/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013-2023 Frank de Jonge + +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/vendor/league/mime-type-detection/composer.json b/vendor/league/mime-type-detection/composer.json new file mode 100644 index 0000000..cd75bee --- /dev/null +++ b/vendor/league/mime-type-detection/composer.json @@ -0,0 +1,34 @@ +{ + "name": "league/mime-type-detection", + "description": "Mime-type detection for Flysystem", + "license": "MIT", + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "scripts": { + "test": "vendor/bin/phpunit", + "phpstan": "vendor/bin/phpstan analyse -l 6 src" + }, + "require": { + "php": "^7.4 || ^8.0", + "ext-fileinfo": "*" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0", + "phpstan/phpstan": "^0.12.68", + "friendsofphp/php-cs-fixer": "^3.2" + }, + "autoload": { + "psr-4": { + "League\\MimeTypeDetection\\": "src" + } + }, + "config": { + "platform": { + "php": "7.4.0" + } + } +} diff --git a/vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php b/vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php new file mode 100644 index 0000000..fc04241 --- /dev/null +++ b/vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php @@ -0,0 +1,13 @@ +extensions = $extensions ?: new GeneratedExtensionToMimeTypeMap(); + } + + public function detectMimeType(string $path, $contents): ?string + { + return $this->detectMimeTypeFromPath($path); + } + + public function detectMimeTypeFromPath(string $path): ?string + { + $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + + return $this->extensions->lookupMimeType($extension); + } + + public function detectMimeTypeFromFile(string $path): ?string + { + return $this->detectMimeTypeFromPath($path); + } + + public function detectMimeTypeFromBuffer(string $contents): ?string + { + return null; + } + + public function lookupExtension(string $mimetype): ?string + { + return $this->extensions instanceof ExtensionLookup + ? $this->extensions->lookupExtension($mimetype) + : null; + } + + public function lookupAllExtensions(string $mimetype): array + { + return $this->extensions instanceof ExtensionLookup + ? $this->extensions->lookupAllExtensions($mimetype) + : []; + } +} diff --git a/vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php b/vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php new file mode 100644 index 0000000..1dad7bc --- /dev/null +++ b/vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php @@ -0,0 +1,10 @@ + + */ + private $inconclusiveMimetypes; + + public function __construct( + string $magicFile = '', + ?ExtensionToMimeTypeMap $extensionMap = null, + ?int $bufferSampleSize = null, + array $inconclusiveMimetypes = self::INCONCLUSIVE_MIME_TYPES + ) { + $this->finfo = new finfo(FILEINFO_MIME_TYPE, $magicFile); + $this->extensionMap = $extensionMap ?: new GeneratedExtensionToMimeTypeMap(); + $this->bufferSampleSize = $bufferSampleSize; + $this->inconclusiveMimetypes = $inconclusiveMimetypes; + } + + public function detectMimeType(string $path, $contents): ?string + { + $mimeType = is_string($contents) + ? (@$this->finfo->buffer($this->takeSample($contents)) ?: null) + : null; + + if ($mimeType !== null && ! in_array($mimeType, $this->inconclusiveMimetypes)) { + return $mimeType; + } + + return $this->detectMimeTypeFromPath($path); + } + + public function detectMimeTypeFromPath(string $path): ?string + { + $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + + return $this->extensionMap->lookupMimeType($extension); + } + + public function detectMimeTypeFromFile(string $path): ?string + { + return @$this->finfo->file($path) ?: null; + } + + public function detectMimeTypeFromBuffer(string $contents): ?string + { + return @$this->finfo->buffer($this->takeSample($contents)) ?: null; + } + + private function takeSample(string $contents): string + { + if ($this->bufferSampleSize === null) { + return $contents; + } + + return (string) substr($contents, 0, $this->bufferSampleSize); + } + + public function lookupExtension(string $mimetype): ?string + { + return $this->extensionMap instanceof ExtensionLookup + ? $this->extensionMap->lookupExtension($mimetype) + : null; + } + + public function lookupAllExtensions(string $mimetype): array + { + return $this->extensionMap instanceof ExtensionLookup + ? $this->extensionMap->lookupAllExtensions($mimetype) + : []; + } +} diff --git a/vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php b/vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php new file mode 100644 index 0000000..65e986a --- /dev/null +++ b/vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php @@ -0,0 +1,2310 @@ + + * + * @internal + */ + public const MIME_TYPES_FOR_EXTENSIONS = [ + '1km' => 'application/vnd.1000minds.decision-model+xml', + '3dml' => 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gp', + '3gpp' => 'video/3gpp', + '3mf' => 'model/3mf', + '7z' => 'application/x-7z-compressed', + '7zip' => 'application/x-7z-compressed', + '123' => 'application/vnd.lotus-1-2-3', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/acc', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/vnd.nokia.n-gage.ac+xml', + 'ac3' => 'audio/ac3', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'adts' => 'audio/aac', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'age' => 'application/vnd.age', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/pdf', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'aml' => 'application/automationml-aml+xml', + 'amlx' => 'application/automationml-amlx+zip', + 'amr' => 'audio/amr', + 'apk' => 'application/vnd.android.package-archive', + 'apng' => 'image/apng', + 'appcache' => 'text/cache-manifest', + 'appinstaller' => 'application/appinstaller', + 'application' => 'application/x-ms-application', + 'appx' => 'application/appx', + 'appxbundle' => 'application/appxbundle', + 'apr' => 'application/vnd.lotus-approach', + 'arc' => 'application/x-freearc', + 'arj' => 'application/x-arj', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomdeleted' => 'application/atomdeleted+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/x-au', + 'avci' => 'image/avci', + 'avcs' => 'image/avcs', + 'avi' => 'video/x-msvideo', + 'avif' => 'image/avif', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azv' => 'image/vnd.airzip.accelerator.azv', + 'azw' => 'application/vnd.amazon.ebook', + 'b16' => 'image/vnd.pco.b16', + 'bary' => 'model/vnd.bary', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bdo' => 'application/vnd.nato.bindingdataobject+xml', + 'bdoc' => 'application/x-bdoc', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmml' => 'application/vnd.balsamiq.bmml+xml', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'bpmn' => 'application/octet-stream', + 'brf' => 'application/braille', + 'bsp' => 'model/vnd.valve.source.compiled-map', + 'btf' => 'image/prs.btif', + 'btif' => 'image/prs.btif', + 'buffer' => 'application/octet-stream', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cco' => 'application/x-cocoa', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdfx' => 'application/cdfx+xml', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdr' => 'application/cdr', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cjs' => 'application/node', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/octet-stream', + 'cld' => 'model/vnd.cld', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'coffee' => 'text/coffeescript', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpl' => 'application/cpl+xml', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'crx' => 'application/x-chrome-extension', + 'cryptonote' => 'application/vnd.rig.cryptonote', + 'csh' => 'application/x-csh', + 'csl' => 'application/vnd.citationstyles.style+xml', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'csr' => 'application/octet-stream', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cwl' => 'application/cwl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbf' => 'application/vnd.dbf', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'ddf' => 'application/vnd.syncml.dmddf+xml', + 'dds' => 'image/vnd.ms-dds', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dib' => 'image/bmp', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'disposition-notification' => 'message/disposition-notification', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/octet-stream', + 'dmg' => 'application/x-apple-diskimage', + 'dmn' => 'application/octet-stream', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dpx' => 'image/dpx', + 'dra' => 'audio/vnd.dra', + 'drle' => 'image/dicom-rle', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dst' => 'application/octet-stream', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwd' => 'application/atsc-dwd+xml', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ear' => 'application/java-archive', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'image/emf', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emotionml' => 'application/emotionml+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/octet-stream', + 'exi' => 'application/exi', + 'exp' => 'application/express', + 'exr' => 'image/aces', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/mp4', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fdt' => 'application/fdt+xml', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'fits' => 'image/fits', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'fo' => 'application/vnd.software602.filler.form+xml', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'gdoc' => 'application/vnd.google-apps.document', + 'ged' => 'text/vnd.familysearch.gedcom', + 'geo' => 'application/vnd.dynageo', + 'geojson' => 'application/geo+json', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggs' => 'application/vnd.geogebra.slides', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'glb' => 'model/gltf-binary', + 'gltf' => 'model/gltf+json', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gpg' => 'application/gpg-keys', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gsheet' => 'application/vnd.google-apps.spreadsheet', + 'gslides' => 'application/vnd.google-apps.presentation', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/gzip', + 'gzip' => 'application/gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hbs' => 'text/x-handlebars-template', + 'hdd' => 'application/x-virtualbox-hdd', + 'hdf' => 'application/x-hdf', + 'heic' => 'image/heic', + 'heics' => 'image/heic-sequence', + 'heif' => 'image/heif', + 'heifs' => 'image/heif-sequence', + 'hej2' => 'image/hej2k', + 'held' => 'application/atsc-held+xml', + 'hh' => 'text/x-c', + 'hjson' => 'application/hjson', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'hsj2' => 'image/hsj2', + 'htc' => 'text/x-component', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'img' => 'application/octet-stream', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ini' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'its' => 'application/its+xml', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jade' => 'text/jade', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'jardiff' => 'application/x-java-archive-diff', + 'java' => 'text/x-java-source', + 'jhc' => 'image/jphc', + 'jisp' => 'application/vnd.jisp', + 'jls' => 'image/jls', + 'jlt' => 'application/vnd.hp-jlyt', + 'jng' => 'image/x-jng', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jp2' => 'image/jp2', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpf' => 'image/jpx', + 'jpg' => 'image/jpeg', + 'jpg2' => 'image/jp2', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jph' => 'image/jph', + 'jpm' => 'video/jpm', + 'jpx' => 'image/jpx', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'json5' => 'application/json5', + 'jsonld' => 'application/ld+json', + 'jsonml' => 'application/jsonml+json', + 'jsx' => 'text/jsx', + 'jt' => 'model/jt', + 'jxl' => 'image/jxl', + 'jxr' => 'image/jxr', + 'jxra' => 'image/jxra', + 'jxrs' => 'image/jxrs', + 'jxs' => 'image/jxs', + 'jxsc' => 'image/jxsc', + 'jxsi' => 'image/jxsi', + 'jxss' => 'image/jxss', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kdb' => 'application/octet-stream', + 'kdbx' => 'application/x-keepass2', + 'key' => 'application/x-iwork-keynote-sffkey', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktx2' => 'image/ktx2', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'less' => 'text/less', + 'lgr' => 'application/lgr+xml', + 'lha' => 'application/octet-stream', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'litcoffee' => 'text/coffeescript', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lua' => 'text/x-lua', + 'luac' => 'application/x-lua-bytecode', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/octet-stream', + 'm1v' => 'video/mpeg', + 'm2a' => 'audio/mpeg', + 'm2t' => 'video/mp2t', + 'm2ts' => 'video/mp2t', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'text/plain', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/x-m4a', + 'm4p' => 'application/mp4', + 'm4s' => 'video/iso.segment', + 'm4u' => 'application/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm21' => 'application/mp21', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'maei' => 'application/mmt-aei+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'manifest' => 'text/cache-manifest', + 'map' => 'application/json', + 'mar' => 'application/octet-stream', + 'markdown' => 'text/markdown', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'md' => 'text/markdown', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'mdx' => 'text/mdx', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mjs' => 'text/javascript', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mkd' => 'text/x-markdown', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mml' => 'text/mathml', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mp21' => 'application/mp21', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpd' => 'application/dash+xml', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpf' => 'application/media-policy-dataset+xml', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msg' => 'application/vnd.ms-outlook', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msix' => 'application/msix', + 'msixbundle' => 'application/msixbundle', + 'msl' => 'application/vnd.mobius.msl', + 'msm' => 'application/octet-stream', + 'msp' => 'application/octet-stream', + 'msty' => 'application/vnd.muvee.style', + 'mtl' => 'model/mtl', + 'mts' => 'video/mp2t', + 'mus' => 'application/vnd.musician', + 'musd' => 'application/mmt-usd+xml', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mvt' => 'application/vnd.mapbox-vector-tile', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxmf' => 'audio/mobile-xmf', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'ndjson' => 'application/x-ndjson', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nq' => 'application/n-quads', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'nt' => 'application/n-triples', + 'ntf' => 'application/vnd.nitf', + 'numbers' => 'application/x-iwork-numbers-sffnumbers', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obgx' => 'application/vnd.openblox.game+xml', + 'obj' => 'model/obj', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogex' => 'model/vnd.opengex', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'opus' => 'audio/ogg', + 'org' => 'text/x-org', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'osm' => 'application/vnd.openstreetmap.data+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'font/otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'ova' => 'application/x-virtualbox-ova', + 'ovf' => 'application/x-virtualbox-ovf', + 'owl' => 'application/rdf+xml', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p7a' => 'application/x-pkcs7-signature', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'p10' => 'application/x-pkcs10', + 'p12' => 'application/x-pkcs12', + 'pac' => 'application/x-ns-proxy-autoconfig', + 'pages' => 'application/x-iwork-pages-sffpages', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/x-pilot', + 'pde' => 'text/x-processing', + 'pdf' => 'application/pdf', + 'pem' => 'application/x-x509-user-cert', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp', + 'phar' => 'application/octet-stream', + 'php' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'phtml' => 'application/x-httpd-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'pkpass' => 'application/vnd.apple.pkpass', + 'pl' => 'application/x-perl', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pm' => 'application/x-perl', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppa' => 'application/vnd.ms-powerpoint', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'model/prc', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'provx' => 'application/provenance+xml', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'application/x-photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'pti' => 'image/prs.pti', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pv' => 'application/octet-stream', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pxf' => 'application/octet-stream', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyo' => 'model/vnd.pytha.pyox', + 'pyox' => 'model/vnd.pytha.pyox', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'raml' => 'application/raml+yaml', + 'rapd' => 'application/route-apd+xml', + 'rar' => 'application/x-rar', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'relo' => 'application/p2p-overlay+xml', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'audio/x-pn-realaudio', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'rng' => 'application/xml', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsa' => 'application/x-pkcs7', + 'rsat' => 'application/atsc-rsat+xml', + 'rsd' => 'application/rsd+xml', + 'rsheet' => 'application/urc-ressheet+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'text/rtf', + 'rtx' => 'text/richtext', + 'run' => 'application/x-makeself', + 'rusd' => 'application/route-usd+xml', + 'rv' => 'video/vnd.rn-realvideo', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sass' => 'text/x-sass', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scss' => 'text/x-scss', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'sea' => 'application/octet-stream', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'senmlx' => 'application/senml+xml', + 'sensmlx' => 'application/sensml+xml', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shex' => 'text/shex', + 'shf' => 'application/shf+xml', + 'shtml' => 'text/html', + 'sid' => 'image/x-mrsid-image', + 'sieve' => 'application/sieve', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'siv' => 'application/sieve', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slim' => 'text/slim', + 'slm' => 'text/slim', + 'sls' => 'application/route-s-tsid+xml', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spdx' => 'text/spdx', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'sst' => 'application/octet-stream', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'step' => 'application/STEP', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'model/stl', + 'stp' => 'application/STEP', + 'stpx' => 'model/step+xml', + 'stpxz' => 'model/step-xml+zip', + 'stpz' => 'model/step+zip', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'styl' => 'text/stylus', + 'stylus' => 'text/stylus', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'swidtag' => 'application/swid+xml', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 't38' => 'image/t38', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tap' => 'image/vnd.tencent.tap', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'td' => 'application/urc-targetdesc+xml', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tfx' => 'image/tiff-fx', + 'tga' => 'image/x-tga', + 'tgz' => 'application/x-tar', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tk' => 'application/x-tcl', + 'tmo' => 'application/vnd.tmobile-livetv', + 'toml' => 'application/toml', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trig' => 'application/trig', + 'trm' => 'application/x-msterminal', + 'ts' => 'video/mp2t', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'font/collection', + 'ttf' => 'font/ttf', + 'ttl' => 'text/turtle', + 'ttml' => 'application/ttml+xml', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u3d' => 'model/u3d', + 'u8dsn' => 'message/global-delivery-status', + 'u8hdr' => 'message/global-headers', + 'u8mdn' => 'message/global-disposition-notification', + 'u8msg' => 'message/global', + 'u32' => 'application/x-authorware-bin', + 'ubj' => 'application/ubjson', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uo' => 'application/vnd.uoml+xml', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'usda' => 'model/vnd.usda', + 'usdz' => 'model/vnd.usdz+zip', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vbox' => 'application/x-virtualbox-vbox', + 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vdi' => 'application/x-virtualbox-vdi', + 'vds' => 'model/vnd.sap.vds', + 'vhd' => 'application/x-virtualbox-vhd', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vlc' => 'application/videolan', + 'vmdk' => 'application/x-virtualbox-vmdk', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtf' => 'image/vnd.valve.source.texture', + 'vtt' => 'text/vtt', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wadl' => 'application/vnd.sun.wadl+xml', + 'war' => 'application/java-archive', + 'wasm' => 'application/wasm', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webapp' => 'application/x-web-app-manifest+json', + 'webm' => 'video/webm', + 'webmanifest' => 'application/manifest+json', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgsl' => 'text/wgsl', + 'wgt' => 'application/widget', + 'wif' => 'application/watcherinfo+xml', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'image/wmf', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'font/woff', + 'woff2' => 'font/woff2', + 'word' => 'application/msword', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsc' => 'message/vnd.wfa.wsc', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+fastinfoset', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d-vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'x32' => 'application/x-authorware-bin', + 'x_b' => 'model/vnd.parasolid.transmit.binary', + 'x_t' => 'model/vnd.parasolid.transmit.text', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xav' => 'application/xcap-att+xml', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xca' => 'application/xcap-caps+xml', + 'xcs' => 'application/calendar+xml', + 'xdcf' => 'application/vnd.gov.sk.xmldatacontainer+xml', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xel' => 'application/xcap-el+xml', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtm' => 'application/vnd.pwg-xhtml-print+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xl' => 'application/excel', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xns' => 'application/xcap-ns+xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsd' => 'application/xml', + 'xsf' => 'application/prs.xsf+xml', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yaml' => 'text/yaml', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'yml' => 'text/yaml', + 'ymp' => 'text/x-suse-ymp', + 'z' => 'application/x-compress', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + 'zsh' => 'text/x-scriptzsh', + ]; + + /** + * @var array + * + * @internal + */ + public const EXTENSIONS_FOR_MIME_TIMES = [ + 'application/andrew-inset' => ['ez'], + 'application/appinstaller' => ['appinstaller'], + 'application/applixware' => ['aw'], + 'application/appx' => ['appx'], + 'application/appxbundle' => ['appxbundle'], + 'application/atom+xml' => ['atom'], + 'application/atomcat+xml' => ['atomcat'], + 'application/atomdeleted+xml' => ['atomdeleted'], + 'application/atomsvc+xml' => ['atomsvc'], + 'application/atsc-dwd+xml' => ['dwd'], + 'application/atsc-held+xml' => ['held'], + 'application/atsc-rsat+xml' => ['rsat'], + 'application/automationml-aml+xml' => ['aml'], + 'application/automationml-amlx+zip' => ['amlx'], + 'application/bdoc' => ['bdoc'], + 'application/calendar+xml' => ['xcs'], + 'application/ccxml+xml' => ['ccxml'], + 'application/cdfx+xml' => ['cdfx'], + 'application/cdmi-capability' => ['cdmia'], + 'application/cdmi-container' => ['cdmic'], + 'application/cdmi-domain' => ['cdmid'], + 'application/cdmi-object' => ['cdmio'], + 'application/cdmi-queue' => ['cdmiq'], + 'application/cpl+xml' => ['cpl'], + 'application/cu-seeme' => ['cu'], + 'application/cwl' => ['cwl'], + 'application/dash+xml' => ['mpd'], + 'application/dash-patch+xml' => ['mpp'], + 'application/davmount+xml' => ['davmount'], + 'application/docbook+xml' => ['dbk'], + 'application/dssc+der' => ['dssc'], + 'application/dssc+xml' => ['xdssc'], + 'application/ecmascript' => ['ecma'], + 'application/emma+xml' => ['emma'], + 'application/emotionml+xml' => ['emotionml'], + 'application/epub+zip' => ['epub'], + 'application/exi' => ['exi'], + 'application/express' => ['exp'], + 'application/fdf' => ['fdf'], + 'application/fdt+xml' => ['fdt'], + 'application/font-tdpfr' => ['pfr'], + 'application/geo+json' => ['geojson'], + 'application/gml+xml' => ['gml'], + 'application/gpx+xml' => ['gpx'], + 'application/gxf' => ['gxf'], + 'application/gzip' => ['gz', 'gzip'], + 'application/hjson' => ['hjson'], + 'application/hyperstudio' => ['stk'], + 'application/inkml+xml' => ['ink', 'inkml'], + 'application/ipfix' => ['ipfix'], + 'application/its+xml' => ['its'], + 'application/java-archive' => ['jar', 'war', 'ear'], + 'application/java-serialized-object' => ['ser'], + 'application/java-vm' => ['class'], + 'application/javascript' => ['js'], + 'application/json' => ['json', 'map'], + 'application/json5' => ['json5'], + 'application/jsonml+json' => ['jsonml'], + 'application/ld+json' => ['jsonld'], + 'application/lgr+xml' => ['lgr'], + 'application/lost+xml' => ['lostxml'], + 'application/mac-binhex40' => ['hqx'], + 'application/mac-compactpro' => ['cpt'], + 'application/mads+xml' => ['mads'], + 'application/manifest+json' => ['webmanifest'], + 'application/marc' => ['mrc'], + 'application/marcxml+xml' => ['mrcx'], + 'application/mathematica' => ['ma', 'nb', 'mb'], + 'application/mathml+xml' => ['mathml'], + 'application/mbox' => ['mbox'], + 'application/media-policy-dataset+xml' => ['mpf'], + 'application/mediaservercontrol+xml' => ['mscml'], + 'application/metalink+xml' => ['metalink'], + 'application/metalink4+xml' => ['meta4'], + 'application/mets+xml' => ['mets'], + 'application/mmt-aei+xml' => ['maei'], + 'application/mmt-usd+xml' => ['musd'], + 'application/mods+xml' => ['mods'], + 'application/mp21' => ['m21', 'mp21'], + 'application/mp4' => ['mp4', 'mpg4', 'mp4s', 'm4p'], + 'application/msix' => ['msix'], + 'application/msixbundle' => ['msixbundle'], + 'application/msword' => ['doc', 'dot', 'word'], + 'application/mxf' => ['mxf'], + 'application/n-quads' => ['nq'], + 'application/n-triples' => ['nt'], + 'application/node' => ['cjs'], + 'application/octet-stream' => ['bin', 'dms', 'lrf', 'mar', 'so', 'dist', 'distz', 'pkg', 'bpk', 'dump', 'elc', 'deploy', 'exe', 'dll', 'deb', 'dmg', 'iso', 'img', 'msi', 'msp', 'msm', 'buffer', 'phar', 'lha', 'lzh', 'class', 'sea', 'dmn', 'bpmn', 'kdb', 'sst', 'csr', 'dst', 'pv', 'pxf'], + 'application/oda' => ['oda'], + 'application/oebps-package+xml' => ['opf'], + 'application/ogg' => ['ogx'], + 'application/omdoc+xml' => ['omdoc'], + 'application/onenote' => ['onetoc', 'onetoc2', 'onetmp', 'onepkg'], + 'application/oxps' => ['oxps'], + 'application/p2p-overlay+xml' => ['relo'], + 'application/patch-ops-error+xml' => ['xer'], + 'application/pdf' => ['pdf', 'ai'], + 'application/pgp-encrypted' => ['pgp'], + 'application/pgp-keys' => ['asc'], + 'application/pgp-signature' => ['sig', 'asc'], + 'application/pics-rules' => ['prf'], + 'application/pkcs10' => ['p10'], + 'application/pkcs7-mime' => ['p7m', 'p7c'], + 'application/pkcs7-signature' => ['p7s'], + 'application/pkcs8' => ['p8'], + 'application/pkix-attr-cert' => ['ac'], + 'application/pkix-cert' => ['cer'], + 'application/pkix-crl' => ['crl'], + 'application/pkix-pkipath' => ['pkipath'], + 'application/pkixcmp' => ['pki'], + 'application/pls+xml' => ['pls'], + 'application/postscript' => ['ai', 'eps', 'ps'], + 'application/provenance+xml' => ['provx'], + 'application/prs.cww' => ['cww'], + 'application/prs.xsf+xml' => ['xsf'], + 'application/pskc+xml' => ['pskcxml'], + 'application/raml+yaml' => ['raml'], + 'application/rdf+xml' => ['rdf', 'owl'], + 'application/reginfo+xml' => ['rif'], + 'application/relax-ng-compact-syntax' => ['rnc'], + 'application/resource-lists+xml' => ['rl'], + 'application/resource-lists-diff+xml' => ['rld'], + 'application/rls-services+xml' => ['rs'], + 'application/route-apd+xml' => ['rapd'], + 'application/route-s-tsid+xml' => ['sls'], + 'application/route-usd+xml' => ['rusd'], + 'application/rpki-ghostbusters' => ['gbr'], + 'application/rpki-manifest' => ['mft'], + 'application/rpki-roa' => ['roa'], + 'application/rsd+xml' => ['rsd'], + 'application/rss+xml' => ['rss'], + 'application/rtf' => ['rtf'], + 'application/sbml+xml' => ['sbml'], + 'application/scvp-cv-request' => ['scq'], + 'application/scvp-cv-response' => ['scs'], + 'application/scvp-vp-request' => ['spq'], + 'application/scvp-vp-response' => ['spp'], + 'application/sdp' => ['sdp'], + 'application/senml+xml' => ['senmlx'], + 'application/sensml+xml' => ['sensmlx'], + 'application/set-payment-initiation' => ['setpay'], + 'application/set-registration-initiation' => ['setreg'], + 'application/shf+xml' => ['shf'], + 'application/sieve' => ['siv', 'sieve'], + 'application/smil+xml' => ['smi', 'smil'], + 'application/sparql-query' => ['rq'], + 'application/sparql-results+xml' => ['srx'], + 'application/sql' => ['sql'], + 'application/srgs' => ['gram'], + 'application/srgs+xml' => ['grxml'], + 'application/sru+xml' => ['sru'], + 'application/ssdl+xml' => ['ssdl'], + 'application/ssml+xml' => ['ssml'], + 'application/swid+xml' => ['swidtag'], + 'application/tei+xml' => ['tei', 'teicorpus'], + 'application/thraud+xml' => ['tfi'], + 'application/timestamped-data' => ['tsd'], + 'application/toml' => ['toml'], + 'application/trig' => ['trig'], + 'application/ttml+xml' => ['ttml'], + 'application/ubjson' => ['ubj'], + 'application/urc-ressheet+xml' => ['rsheet'], + 'application/urc-targetdesc+xml' => ['td'], + 'application/vnd.1000minds.decision-model+xml' => ['1km'], + 'application/vnd.3gpp.pic-bw-large' => ['plb'], + 'application/vnd.3gpp.pic-bw-small' => ['psb'], + 'application/vnd.3gpp.pic-bw-var' => ['pvb'], + 'application/vnd.3gpp2.tcap' => ['tcap'], + 'application/vnd.3m.post-it-notes' => ['pwn'], + 'application/vnd.accpac.simply.aso' => ['aso'], + 'application/vnd.accpac.simply.imp' => ['imp'], + 'application/vnd.acucobol' => ['acu'], + 'application/vnd.acucorp' => ['atc', 'acutc'], + 'application/vnd.adobe.air-application-installer-package+zip' => ['air'], + 'application/vnd.adobe.formscentral.fcdt' => ['fcdt'], + 'application/vnd.adobe.fxp' => ['fxp', 'fxpl'], + 'application/vnd.adobe.xdp+xml' => ['xdp'], + 'application/vnd.adobe.xfdf' => ['xfdf'], + 'application/vnd.age' => ['age'], + 'application/vnd.ahead.space' => ['ahead'], + 'application/vnd.airzip.filesecure.azf' => ['azf'], + 'application/vnd.airzip.filesecure.azs' => ['azs'], + 'application/vnd.amazon.ebook' => ['azw'], + 'application/vnd.americandynamics.acc' => ['acc'], + 'application/vnd.amiga.ami' => ['ami'], + 'application/vnd.android.package-archive' => ['apk'], + 'application/vnd.anser-web-certificate-issue-initiation' => ['cii'], + 'application/vnd.anser-web-funds-transfer-initiation' => ['fti'], + 'application/vnd.antix.game-component' => ['atx'], + 'application/vnd.apple.installer+xml' => ['mpkg'], + 'application/vnd.apple.keynote' => ['key'], + 'application/vnd.apple.mpegurl' => ['m3u8'], + 'application/vnd.apple.numbers' => ['numbers'], + 'application/vnd.apple.pages' => ['pages'], + 'application/vnd.apple.pkpass' => ['pkpass'], + 'application/vnd.aristanetworks.swi' => ['swi'], + 'application/vnd.astraea-software.iota' => ['iota'], + 'application/vnd.audiograph' => ['aep'], + 'application/vnd.balsamiq.bmml+xml' => ['bmml'], + 'application/vnd.blueice.multipass' => ['mpm'], + 'application/vnd.bmi' => ['bmi'], + 'application/vnd.businessobjects' => ['rep'], + 'application/vnd.chemdraw+xml' => ['cdxml'], + 'application/vnd.chipnuts.karaoke-mmd' => ['mmd'], + 'application/vnd.cinderella' => ['cdy'], + 'application/vnd.citationstyles.style+xml' => ['csl'], + 'application/vnd.claymore' => ['cla'], + 'application/vnd.cloanto.rp9' => ['rp9'], + 'application/vnd.clonk.c4group' => ['c4g', 'c4d', 'c4f', 'c4p', 'c4u'], + 'application/vnd.cluetrust.cartomobile-config' => ['c11amc'], + 'application/vnd.cluetrust.cartomobile-config-pkg' => ['c11amz'], + 'application/vnd.commonspace' => ['csp'], + 'application/vnd.contact.cmsg' => ['cdbcmsg'], + 'application/vnd.cosmocaller' => ['cmc'], + 'application/vnd.crick.clicker' => ['clkx'], + 'application/vnd.crick.clicker.keyboard' => ['clkk'], + 'application/vnd.crick.clicker.palette' => ['clkp'], + 'application/vnd.crick.clicker.template' => ['clkt'], + 'application/vnd.crick.clicker.wordbank' => ['clkw'], + 'application/vnd.criticaltools.wbs+xml' => ['wbs'], + 'application/vnd.ctc-posml' => ['pml'], + 'application/vnd.cups-ppd' => ['ppd'], + 'application/vnd.curl.car' => ['car'], + 'application/vnd.curl.pcurl' => ['pcurl'], + 'application/vnd.dart' => ['dart'], + 'application/vnd.data-vision.rdz' => ['rdz'], + 'application/vnd.dbf' => ['dbf'], + 'application/vnd.dece.data' => ['uvf', 'uvvf', 'uvd', 'uvvd'], + 'application/vnd.dece.ttml+xml' => ['uvt', 'uvvt'], + 'application/vnd.dece.unspecified' => ['uvx', 'uvvx'], + 'application/vnd.dece.zip' => ['uvz', 'uvvz'], + 'application/vnd.denovo.fcselayout-link' => ['fe_launch'], + 'application/vnd.dna' => ['dna'], + 'application/vnd.dolby.mlp' => ['mlp'], + 'application/vnd.dpgraph' => ['dpg'], + 'application/vnd.dreamfactory' => ['dfac'], + 'application/vnd.ds-keypoint' => ['kpxx'], + 'application/vnd.dvb.ait' => ['ait'], + 'application/vnd.dvb.service' => ['svc'], + 'application/vnd.dynageo' => ['geo'], + 'application/vnd.ecowin.chart' => ['mag'], + 'application/vnd.enliven' => ['nml'], + 'application/vnd.epson.esf' => ['esf'], + 'application/vnd.epson.msf' => ['msf'], + 'application/vnd.epson.quickanime' => ['qam'], + 'application/vnd.epson.salt' => ['slt'], + 'application/vnd.epson.ssf' => ['ssf'], + 'application/vnd.eszigno3+xml' => ['es3', 'et3'], + 'application/vnd.ezpix-album' => ['ez2'], + 'application/vnd.ezpix-package' => ['ez3'], + 'application/vnd.fdf' => ['fdf'], + 'application/vnd.fdsn.mseed' => ['mseed'], + 'application/vnd.fdsn.seed' => ['seed', 'dataless'], + 'application/vnd.flographit' => ['gph'], + 'application/vnd.fluxtime.clip' => ['ftc'], + 'application/vnd.framemaker' => ['fm', 'frame', 'maker', 'book'], + 'application/vnd.frogans.fnc' => ['fnc'], + 'application/vnd.frogans.ltf' => ['ltf'], + 'application/vnd.fsc.weblaunch' => ['fsc'], + 'application/vnd.fujitsu.oasys' => ['oas'], + 'application/vnd.fujitsu.oasys2' => ['oa2'], + 'application/vnd.fujitsu.oasys3' => ['oa3'], + 'application/vnd.fujitsu.oasysgp' => ['fg5'], + 'application/vnd.fujitsu.oasysprs' => ['bh2'], + 'application/vnd.fujixerox.ddd' => ['ddd'], + 'application/vnd.fujixerox.docuworks' => ['xdw'], + 'application/vnd.fujixerox.docuworks.binder' => ['xbd'], + 'application/vnd.fuzzysheet' => ['fzs'], + 'application/vnd.genomatix.tuxedo' => ['txd'], + 'application/vnd.geogebra.file' => ['ggb'], + 'application/vnd.geogebra.slides' => ['ggs'], + 'application/vnd.geogebra.tool' => ['ggt'], + 'application/vnd.geometry-explorer' => ['gex', 'gre'], + 'application/vnd.geonext' => ['gxt'], + 'application/vnd.geoplan' => ['g2w'], + 'application/vnd.geospace' => ['g3w'], + 'application/vnd.gmx' => ['gmx'], + 'application/vnd.google-apps.document' => ['gdoc'], + 'application/vnd.google-apps.presentation' => ['gslides'], + 'application/vnd.google-apps.spreadsheet' => ['gsheet'], + 'application/vnd.google-earth.kml+xml' => ['kml'], + 'application/vnd.google-earth.kmz' => ['kmz'], + 'application/vnd.gov.sk.xmldatacontainer+xml' => ['xdcf'], + 'application/vnd.grafeq' => ['gqf', 'gqs'], + 'application/vnd.groove-account' => ['gac'], + 'application/vnd.groove-help' => ['ghf'], + 'application/vnd.groove-identity-message' => ['gim'], + 'application/vnd.groove-injector' => ['grv'], + 'application/vnd.groove-tool-message' => ['gtm'], + 'application/vnd.groove-tool-template' => ['tpl'], + 'application/vnd.groove-vcard' => ['vcg'], + 'application/vnd.hal+xml' => ['hal'], + 'application/vnd.handheld-entertainment+xml' => ['zmm'], + 'application/vnd.hbci' => ['hbci'], + 'application/vnd.hhe.lesson-player' => ['les'], + 'application/vnd.hp-hpgl' => ['hpgl'], + 'application/vnd.hp-hpid' => ['hpid'], + 'application/vnd.hp-hps' => ['hps'], + 'application/vnd.hp-jlyt' => ['jlt'], + 'application/vnd.hp-pcl' => ['pcl'], + 'application/vnd.hp-pclxl' => ['pclxl'], + 'application/vnd.hydrostatix.sof-data' => ['sfd-hdstx'], + 'application/vnd.ibm.minipay' => ['mpy'], + 'application/vnd.ibm.modcap' => ['afp', 'listafp', 'list3820'], + 'application/vnd.ibm.rights-management' => ['irm'], + 'application/vnd.ibm.secure-container' => ['sc'], + 'application/vnd.iccprofile' => ['icc', 'icm'], + 'application/vnd.igloader' => ['igl'], + 'application/vnd.immervision-ivp' => ['ivp'], + 'application/vnd.immervision-ivu' => ['ivu'], + 'application/vnd.insors.igm' => ['igm'], + 'application/vnd.intercon.formnet' => ['xpw', 'xpx'], + 'application/vnd.intergeo' => ['i2g'], + 'application/vnd.intu.qbo' => ['qbo'], + 'application/vnd.intu.qfx' => ['qfx'], + 'application/vnd.ipunplugged.rcprofile' => ['rcprofile'], + 'application/vnd.irepository.package+xml' => ['irp'], + 'application/vnd.is-xpr' => ['xpr'], + 'application/vnd.isac.fcs' => ['fcs'], + 'application/vnd.jam' => ['jam'], + 'application/vnd.jcp.javame.midlet-rms' => ['rms'], + 'application/vnd.jisp' => ['jisp'], + 'application/vnd.joost.joda-archive' => ['joda'], + 'application/vnd.kahootz' => ['ktz', 'ktr'], + 'application/vnd.kde.karbon' => ['karbon'], + 'application/vnd.kde.kchart' => ['chrt'], + 'application/vnd.kde.kformula' => ['kfo'], + 'application/vnd.kde.kivio' => ['flw'], + 'application/vnd.kde.kontour' => ['kon'], + 'application/vnd.kde.kpresenter' => ['kpr', 'kpt'], + 'application/vnd.kde.kspread' => ['ksp'], + 'application/vnd.kde.kword' => ['kwd', 'kwt'], + 'application/vnd.kenameaapp' => ['htke'], + 'application/vnd.kidspiration' => ['kia'], + 'application/vnd.kinar' => ['kne', 'knp'], + 'application/vnd.koan' => ['skp', 'skd', 'skt', 'skm'], + 'application/vnd.kodak-descriptor' => ['sse'], + 'application/vnd.las.las+xml' => ['lasxml'], + 'application/vnd.llamagraphics.life-balance.desktop' => ['lbd'], + 'application/vnd.llamagraphics.life-balance.exchange+xml' => ['lbe'], + 'application/vnd.lotus-1-2-3' => ['123'], + 'application/vnd.lotus-approach' => ['apr'], + 'application/vnd.lotus-freelance' => ['pre'], + 'application/vnd.lotus-notes' => ['nsf'], + 'application/vnd.lotus-organizer' => ['org'], + 'application/vnd.lotus-screencam' => ['scm'], + 'application/vnd.lotus-wordpro' => ['lwp'], + 'application/vnd.macports.portpkg' => ['portpkg'], + 'application/vnd.mapbox-vector-tile' => ['mvt'], + 'application/vnd.mcd' => ['mcd'], + 'application/vnd.medcalcdata' => ['mc1'], + 'application/vnd.mediastation.cdkey' => ['cdkey'], + 'application/vnd.mfer' => ['mwf'], + 'application/vnd.mfmp' => ['mfm'], + 'application/vnd.micrografx.flo' => ['flo'], + 'application/vnd.micrografx.igx' => ['igx'], + 'application/vnd.mif' => ['mif'], + 'application/vnd.mobius.daf' => ['daf'], + 'application/vnd.mobius.dis' => ['dis'], + 'application/vnd.mobius.mbk' => ['mbk'], + 'application/vnd.mobius.mqy' => ['mqy'], + 'application/vnd.mobius.msl' => ['msl'], + 'application/vnd.mobius.plc' => ['plc'], + 'application/vnd.mobius.txf' => ['txf'], + 'application/vnd.mophun.application' => ['mpn'], + 'application/vnd.mophun.certificate' => ['mpc'], + 'application/vnd.mozilla.xul+xml' => ['xul'], + 'application/vnd.ms-artgalry' => ['cil'], + 'application/vnd.ms-cab-compressed' => ['cab'], + 'application/vnd.ms-excel' => ['xls', 'xlm', 'xla', 'xlc', 'xlt', 'xlw'], + 'application/vnd.ms-excel.addin.macroenabled.12' => ['xlam'], + 'application/vnd.ms-excel.sheet.binary.macroenabled.12' => ['xlsb'], + 'application/vnd.ms-excel.sheet.macroenabled.12' => ['xlsm'], + 'application/vnd.ms-excel.template.macroenabled.12' => ['xltm'], + 'application/vnd.ms-fontobject' => ['eot'], + 'application/vnd.ms-htmlhelp' => ['chm'], + 'application/vnd.ms-ims' => ['ims'], + 'application/vnd.ms-lrm' => ['lrm'], + 'application/vnd.ms-officetheme' => ['thmx'], + 'application/vnd.ms-outlook' => ['msg'], + 'application/vnd.ms-pki.seccat' => ['cat'], + 'application/vnd.ms-pki.stl' => ['stl'], + 'application/vnd.ms-powerpoint' => ['ppt', 'pps', 'pot', 'ppa'], + 'application/vnd.ms-powerpoint.addin.macroenabled.12' => ['ppam'], + 'application/vnd.ms-powerpoint.presentation.macroenabled.12' => ['pptm'], + 'application/vnd.ms-powerpoint.slide.macroenabled.12' => ['sldm'], + 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => ['ppsm'], + 'application/vnd.ms-powerpoint.template.macroenabled.12' => ['potm'], + 'application/vnd.ms-project' => ['mpp', 'mpt'], + 'application/vnd.ms-word.document.macroenabled.12' => ['docm'], + 'application/vnd.ms-word.template.macroenabled.12' => ['dotm'], + 'application/vnd.ms-works' => ['wps', 'wks', 'wcm', 'wdb'], + 'application/vnd.ms-wpl' => ['wpl'], + 'application/vnd.ms-xpsdocument' => ['xps'], + 'application/vnd.mseq' => ['mseq'], + 'application/vnd.musician' => ['mus'], + 'application/vnd.muvee.style' => ['msty'], + 'application/vnd.mynfc' => ['taglet'], + 'application/vnd.nato.bindingdataobject+xml' => ['bdo'], + 'application/vnd.neurolanguage.nlu' => ['nlu'], + 'application/vnd.nitf' => ['ntf', 'nitf'], + 'application/vnd.noblenet-directory' => ['nnd'], + 'application/vnd.noblenet-sealer' => ['nns'], + 'application/vnd.noblenet-web' => ['nnw'], + 'application/vnd.nokia.n-gage.ac+xml' => ['ac'], + 'application/vnd.nokia.n-gage.data' => ['ngdat'], + 'application/vnd.nokia.n-gage.symbian.install' => ['n-gage'], + 'application/vnd.nokia.radio-preset' => ['rpst'], + 'application/vnd.nokia.radio-presets' => ['rpss'], + 'application/vnd.novadigm.edm' => ['edm'], + 'application/vnd.novadigm.edx' => ['edx'], + 'application/vnd.novadigm.ext' => ['ext'], + 'application/vnd.oasis.opendocument.chart' => ['odc'], + 'application/vnd.oasis.opendocument.chart-template' => ['otc'], + 'application/vnd.oasis.opendocument.database' => ['odb'], + 'application/vnd.oasis.opendocument.formula' => ['odf'], + 'application/vnd.oasis.opendocument.formula-template' => ['odft'], + 'application/vnd.oasis.opendocument.graphics' => ['odg'], + 'application/vnd.oasis.opendocument.graphics-template' => ['otg'], + 'application/vnd.oasis.opendocument.image' => ['odi'], + 'application/vnd.oasis.opendocument.image-template' => ['oti'], + 'application/vnd.oasis.opendocument.presentation' => ['odp'], + 'application/vnd.oasis.opendocument.presentation-template' => ['otp'], + 'application/vnd.oasis.opendocument.spreadsheet' => ['ods'], + 'application/vnd.oasis.opendocument.spreadsheet-template' => ['ots'], + 'application/vnd.oasis.opendocument.text' => ['odt'], + 'application/vnd.oasis.opendocument.text-master' => ['odm'], + 'application/vnd.oasis.opendocument.text-template' => ['ott'], + 'application/vnd.oasis.opendocument.text-web' => ['oth'], + 'application/vnd.olpc-sugar' => ['xo'], + 'application/vnd.oma.dd2+xml' => ['dd2'], + 'application/vnd.openblox.game+xml' => ['obgx'], + 'application/vnd.openofficeorg.extension' => ['oxt'], + 'application/vnd.openstreetmap.data+xml' => ['osm'], + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => ['pptx'], + 'application/vnd.openxmlformats-officedocument.presentationml.slide' => ['sldx'], + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => ['ppsx'], + 'application/vnd.openxmlformats-officedocument.presentationml.template' => ['potx'], + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => ['xlsx'], + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => ['xltx'], + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => ['docx'], + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => ['dotx'], + 'application/vnd.osgeo.mapguide.package' => ['mgp'], + 'application/vnd.osgi.dp' => ['dp'], + 'application/vnd.osgi.subsystem' => ['esa'], + 'application/vnd.palm' => ['pdb', 'pqa', 'oprc'], + 'application/vnd.pawaafile' => ['paw'], + 'application/vnd.pg.format' => ['str'], + 'application/vnd.pg.osasli' => ['ei6'], + 'application/vnd.picsel' => ['efif'], + 'application/vnd.pmi.widget' => ['wg'], + 'application/vnd.pocketlearn' => ['plf'], + 'application/vnd.powerbuilder6' => ['pbd'], + 'application/vnd.previewsystems.box' => ['box'], + 'application/vnd.proteus.magazine' => ['mgz'], + 'application/vnd.publishare-delta-tree' => ['qps'], + 'application/vnd.pvi.ptid1' => ['ptid'], + 'application/vnd.pwg-xhtml-print+xml' => ['xhtm'], + 'application/vnd.quark.quarkxpress' => ['qxd', 'qxt', 'qwd', 'qwt', 'qxl', 'qxb'], + 'application/vnd.rar' => ['rar'], + 'application/vnd.realvnc.bed' => ['bed'], + 'application/vnd.recordare.musicxml' => ['mxl'], + 'application/vnd.recordare.musicxml+xml' => ['musicxml'], + 'application/vnd.rig.cryptonote' => ['cryptonote'], + 'application/vnd.rim.cod' => ['cod'], + 'application/vnd.rn-realmedia' => ['rm'], + 'application/vnd.rn-realmedia-vbr' => ['rmvb'], + 'application/vnd.route66.link66+xml' => ['link66'], + 'application/vnd.sailingtracker.track' => ['st'], + 'application/vnd.seemail' => ['see'], + 'application/vnd.sema' => ['sema'], + 'application/vnd.semd' => ['semd'], + 'application/vnd.semf' => ['semf'], + 'application/vnd.shana.informed.formdata' => ['ifm'], + 'application/vnd.shana.informed.formtemplate' => ['itp'], + 'application/vnd.shana.informed.interchange' => ['iif'], + 'application/vnd.shana.informed.package' => ['ipk'], + 'application/vnd.simtech-mindmapper' => ['twd', 'twds'], + 'application/vnd.smaf' => ['mmf'], + 'application/vnd.smart.teacher' => ['teacher'], + 'application/vnd.software602.filler.form+xml' => ['fo'], + 'application/vnd.solent.sdkm+xml' => ['sdkm', 'sdkd'], + 'application/vnd.spotfire.dxp' => ['dxp'], + 'application/vnd.spotfire.sfs' => ['sfs'], + 'application/vnd.stardivision.calc' => ['sdc'], + 'application/vnd.stardivision.draw' => ['sda'], + 'application/vnd.stardivision.impress' => ['sdd'], + 'application/vnd.stardivision.math' => ['smf'], + 'application/vnd.stardivision.writer' => ['sdw', 'vor'], + 'application/vnd.stardivision.writer-global' => ['sgl'], + 'application/vnd.stepmania.package' => ['smzip'], + 'application/vnd.stepmania.stepchart' => ['sm'], + 'application/vnd.sun.wadl+xml' => ['wadl'], + 'application/vnd.sun.xml.calc' => ['sxc'], + 'application/vnd.sun.xml.calc.template' => ['stc'], + 'application/vnd.sun.xml.draw' => ['sxd'], + 'application/vnd.sun.xml.draw.template' => ['std'], + 'application/vnd.sun.xml.impress' => ['sxi'], + 'application/vnd.sun.xml.impress.template' => ['sti'], + 'application/vnd.sun.xml.math' => ['sxm'], + 'application/vnd.sun.xml.writer' => ['sxw'], + 'application/vnd.sun.xml.writer.global' => ['sxg'], + 'application/vnd.sun.xml.writer.template' => ['stw'], + 'application/vnd.sus-calendar' => ['sus', 'susp'], + 'application/vnd.svd' => ['svd'], + 'application/vnd.symbian.install' => ['sis', 'sisx'], + 'application/vnd.syncml+xml' => ['xsm'], + 'application/vnd.syncml.dm+wbxml' => ['bdm'], + 'application/vnd.syncml.dm+xml' => ['xdm'], + 'application/vnd.syncml.dmddf+xml' => ['ddf'], + 'application/vnd.tao.intent-module-archive' => ['tao'], + 'application/vnd.tcpdump.pcap' => ['pcap', 'cap', 'dmp'], + 'application/vnd.tmobile-livetv' => ['tmo'], + 'application/vnd.trid.tpt' => ['tpt'], + 'application/vnd.triscape.mxs' => ['mxs'], + 'application/vnd.trueapp' => ['tra'], + 'application/vnd.ufdl' => ['ufd', 'ufdl'], + 'application/vnd.uiq.theme' => ['utz'], + 'application/vnd.umajin' => ['umj'], + 'application/vnd.unity' => ['unityweb'], + 'application/vnd.uoml+xml' => ['uoml', 'uo'], + 'application/vnd.vcx' => ['vcx'], + 'application/vnd.visio' => ['vsd', 'vst', 'vss', 'vsw'], + 'application/vnd.visionary' => ['vis'], + 'application/vnd.vsf' => ['vsf'], + 'application/vnd.wap.wbxml' => ['wbxml'], + 'application/vnd.wap.wmlc' => ['wmlc'], + 'application/vnd.wap.wmlscriptc' => ['wmlsc'], + 'application/vnd.webturbo' => ['wtb'], + 'application/vnd.wolfram.player' => ['nbp'], + 'application/vnd.wordperfect' => ['wpd'], + 'application/vnd.wqd' => ['wqd'], + 'application/vnd.wt.stf' => ['stf'], + 'application/vnd.xara' => ['xar'], + 'application/vnd.xfdl' => ['xfdl'], + 'application/vnd.yamaha.hv-dic' => ['hvd'], + 'application/vnd.yamaha.hv-script' => ['hvs'], + 'application/vnd.yamaha.hv-voice' => ['hvp'], + 'application/vnd.yamaha.openscoreformat' => ['osf'], + 'application/vnd.yamaha.openscoreformat.osfpvg+xml' => ['osfpvg'], + 'application/vnd.yamaha.smaf-audio' => ['saf'], + 'application/vnd.yamaha.smaf-phrase' => ['spf'], + 'application/vnd.yellowriver-custom-menu' => ['cmp'], + 'application/vnd.zul' => ['zir', 'zirz'], + 'application/vnd.zzazz.deck+xml' => ['zaz'], + 'application/voicexml+xml' => ['vxml'], + 'application/wasm' => ['wasm'], + 'application/watcherinfo+xml' => ['wif'], + 'application/widget' => ['wgt'], + 'application/winhlp' => ['hlp'], + 'application/wsdl+xml' => ['wsdl'], + 'application/wspolicy+xml' => ['wspolicy'], + 'application/x-7z-compressed' => ['7z', '7zip'], + 'application/x-abiword' => ['abw'], + 'application/x-ace-compressed' => ['ace'], + 'application/x-apple-diskimage' => ['dmg'], + 'application/x-arj' => ['arj'], + 'application/x-authorware-bin' => ['aab', 'x32', 'u32', 'vox'], + 'application/x-authorware-map' => ['aam'], + 'application/x-authorware-seg' => ['aas'], + 'application/x-bcpio' => ['bcpio'], + 'application/x-bdoc' => ['bdoc'], + 'application/x-bittorrent' => ['torrent'], + 'application/x-blorb' => ['blb', 'blorb'], + 'application/x-bzip' => ['bz'], + 'application/x-bzip2' => ['bz2', 'boz'], + 'application/x-cbr' => ['cbr', 'cba', 'cbt', 'cbz', 'cb7'], + 'application/x-cdlink' => ['vcd'], + 'application/x-cfs-compressed' => ['cfs'], + 'application/x-chat' => ['chat'], + 'application/x-chess-pgn' => ['pgn'], + 'application/x-chrome-extension' => ['crx'], + 'application/x-cocoa' => ['cco'], + 'application/x-conference' => ['nsc'], + 'application/x-cpio' => ['cpio'], + 'application/x-csh' => ['csh'], + 'application/x-debian-package' => ['deb', 'udeb'], + 'application/x-dgc-compressed' => ['dgc'], + 'application/x-director' => ['dir', 'dcr', 'dxr', 'cst', 'cct', 'cxt', 'w3d', 'fgd', 'swa'], + 'application/x-doom' => ['wad'], + 'application/x-dtbncx+xml' => ['ncx'], + 'application/x-dtbook+xml' => ['dtb'], + 'application/x-dtbresource+xml' => ['res'], + 'application/x-dvi' => ['dvi'], + 'application/x-envoy' => ['evy'], + 'application/x-eva' => ['eva'], + 'application/x-font-bdf' => ['bdf'], + 'application/x-font-ghostscript' => ['gsf'], + 'application/x-font-linux-psf' => ['psf'], + 'application/x-font-pcf' => ['pcf'], + 'application/x-font-snf' => ['snf'], + 'application/x-font-type1' => ['pfa', 'pfb', 'pfm', 'afm'], + 'application/x-freearc' => ['arc'], + 'application/x-futuresplash' => ['spl'], + 'application/x-gca-compressed' => ['gca'], + 'application/x-glulx' => ['ulx'], + 'application/x-gnumeric' => ['gnumeric'], + 'application/x-gramps-xml' => ['gramps'], + 'application/x-gtar' => ['gtar'], + 'application/x-hdf' => ['hdf'], + 'application/x-httpd-php' => ['php', 'php4', 'php3', 'phtml'], + 'application/x-install-instructions' => ['install'], + 'application/x-iso9660-image' => ['iso'], + 'application/x-iwork-keynote-sffkey' => ['key'], + 'application/x-iwork-numbers-sffnumbers' => ['numbers'], + 'application/x-iwork-pages-sffpages' => ['pages'], + 'application/x-java-archive-diff' => ['jardiff'], + 'application/x-java-jnlp-file' => ['jnlp'], + 'application/x-keepass2' => ['kdbx'], + 'application/x-latex' => ['latex'], + 'application/x-lua-bytecode' => ['luac'], + 'application/x-lzh-compressed' => ['lzh', 'lha'], + 'application/x-makeself' => ['run'], + 'application/x-mie' => ['mie'], + 'application/x-mobipocket-ebook' => ['prc', 'mobi'], + 'application/x-ms-application' => ['application'], + 'application/x-ms-shortcut' => ['lnk'], + 'application/x-ms-wmd' => ['wmd'], + 'application/x-ms-wmz' => ['wmz'], + 'application/x-ms-xbap' => ['xbap'], + 'application/x-msaccess' => ['mdb'], + 'application/x-msbinder' => ['obd'], + 'application/x-mscardfile' => ['crd'], + 'application/x-msclip' => ['clp'], + 'application/x-msdos-program' => ['exe'], + 'application/x-msdownload' => ['exe', 'dll', 'com', 'bat', 'msi'], + 'application/x-msmediaview' => ['mvb', 'm13', 'm14'], + 'application/x-msmetafile' => ['wmf', 'wmz', 'emf', 'emz'], + 'application/x-msmoney' => ['mny'], + 'application/x-mspublisher' => ['pub'], + 'application/x-msschedule' => ['scd'], + 'application/x-msterminal' => ['trm'], + 'application/x-mswrite' => ['wri'], + 'application/x-netcdf' => ['nc', 'cdf'], + 'application/x-ns-proxy-autoconfig' => ['pac'], + 'application/x-nzb' => ['nzb'], + 'application/x-perl' => ['pl', 'pm'], + 'application/x-pilot' => ['prc', 'pdb'], + 'application/x-pkcs12' => ['p12', 'pfx'], + 'application/x-pkcs7-certificates' => ['p7b', 'spc'], + 'application/x-pkcs7-certreqresp' => ['p7r'], + 'application/x-rar-compressed' => ['rar'], + 'application/x-redhat-package-manager' => ['rpm'], + 'application/x-research-info-systems' => ['ris'], + 'application/x-sea' => ['sea'], + 'application/x-sh' => ['sh'], + 'application/x-shar' => ['shar'], + 'application/x-shockwave-flash' => ['swf'], + 'application/x-silverlight-app' => ['xap'], + 'application/x-sql' => ['sql'], + 'application/x-stuffit' => ['sit'], + 'application/x-stuffitx' => ['sitx'], + 'application/x-subrip' => ['srt'], + 'application/x-sv4cpio' => ['sv4cpio'], + 'application/x-sv4crc' => ['sv4crc'], + 'application/x-t3vm-image' => ['t3'], + 'application/x-tads' => ['gam'], + 'application/x-tar' => ['tar', 'tgz'], + 'application/x-tcl' => ['tcl', 'tk'], + 'application/x-tex' => ['tex'], + 'application/x-tex-tfm' => ['tfm'], + 'application/x-texinfo' => ['texinfo', 'texi'], + 'application/x-tgif' => ['obj'], + 'application/x-ustar' => ['ustar'], + 'application/x-virtualbox-hdd' => ['hdd'], + 'application/x-virtualbox-ova' => ['ova'], + 'application/x-virtualbox-ovf' => ['ovf'], + 'application/x-virtualbox-vbox' => ['vbox'], + 'application/x-virtualbox-vbox-extpack' => ['vbox-extpack'], + 'application/x-virtualbox-vdi' => ['vdi'], + 'application/x-virtualbox-vhd' => ['vhd'], + 'application/x-virtualbox-vmdk' => ['vmdk'], + 'application/x-wais-source' => ['src'], + 'application/x-web-app-manifest+json' => ['webapp'], + 'application/x-x509-ca-cert' => ['der', 'crt', 'pem'], + 'application/x-xfig' => ['fig'], + 'application/x-xliff+xml' => ['xlf'], + 'application/x-xpinstall' => ['xpi'], + 'application/x-xz' => ['xz'], + 'application/x-zmachine' => ['z1', 'z2', 'z3', 'z4', 'z5', 'z6', 'z7', 'z8'], + 'application/xaml+xml' => ['xaml'], + 'application/xcap-att+xml' => ['xav'], + 'application/xcap-caps+xml' => ['xca'], + 'application/xcap-diff+xml' => ['xdf'], + 'application/xcap-el+xml' => ['xel'], + 'application/xcap-ns+xml' => ['xns'], + 'application/xenc+xml' => ['xenc'], + 'application/xfdf' => ['xfdf'], + 'application/xhtml+xml' => ['xhtml', 'xht'], + 'application/xliff+xml' => ['xlf'], + 'application/xml' => ['xml', 'xsl', 'xsd', 'rng'], + 'application/xml-dtd' => ['dtd'], + 'application/xop+xml' => ['xop'], + 'application/xproc+xml' => ['xpl'], + 'application/xslt+xml' => ['xsl', 'xslt'], + 'application/xspf+xml' => ['xspf'], + 'application/xv+xml' => ['mxml', 'xhvml', 'xvml', 'xvm'], + 'application/yang' => ['yang'], + 'application/yin+xml' => ['yin'], + 'application/zip' => ['zip'], + 'audio/3gpp' => ['3gpp'], + 'audio/aac' => ['adts', 'aac'], + 'audio/adpcm' => ['adp'], + 'audio/amr' => ['amr'], + 'audio/basic' => ['au', 'snd'], + 'audio/midi' => ['mid', 'midi', 'kar', 'rmi'], + 'audio/mobile-xmf' => ['mxmf'], + 'audio/mp3' => ['mp3'], + 'audio/mp4' => ['m4a', 'mp4a'], + 'audio/mpeg' => ['mpga', 'mp2', 'mp2a', 'mp3', 'm2a', 'm3a'], + 'audio/ogg' => ['oga', 'ogg', 'spx', 'opus'], + 'audio/s3m' => ['s3m'], + 'audio/silk' => ['sil'], + 'audio/vnd.dece.audio' => ['uva', 'uvva'], + 'audio/vnd.digital-winds' => ['eol'], + 'audio/vnd.dra' => ['dra'], + 'audio/vnd.dts' => ['dts'], + 'audio/vnd.dts.hd' => ['dtshd'], + 'audio/vnd.lucent.voice' => ['lvp'], + 'audio/vnd.ms-playready.media.pya' => ['pya'], + 'audio/vnd.nuera.ecelp4800' => ['ecelp4800'], + 'audio/vnd.nuera.ecelp7470' => ['ecelp7470'], + 'audio/vnd.nuera.ecelp9600' => ['ecelp9600'], + 'audio/vnd.rip' => ['rip'], + 'audio/wav' => ['wav'], + 'audio/wave' => ['wav'], + 'audio/webm' => ['weba'], + 'audio/x-aac' => ['aac'], + 'audio/x-aiff' => ['aif', 'aiff', 'aifc'], + 'audio/x-caf' => ['caf'], + 'audio/x-flac' => ['flac'], + 'audio/x-m4a' => ['m4a'], + 'audio/x-matroska' => ['mka'], + 'audio/x-mpegurl' => ['m3u'], + 'audio/x-ms-wax' => ['wax'], + 'audio/x-ms-wma' => ['wma'], + 'audio/x-pn-realaudio' => ['ram', 'ra', 'rm'], + 'audio/x-pn-realaudio-plugin' => ['rmp', 'rpm'], + 'audio/x-realaudio' => ['ra'], + 'audio/x-wav' => ['wav'], + 'audio/xm' => ['xm'], + 'chemical/x-cdx' => ['cdx'], + 'chemical/x-cif' => ['cif'], + 'chemical/x-cmdf' => ['cmdf'], + 'chemical/x-cml' => ['cml'], + 'chemical/x-csml' => ['csml'], + 'chemical/x-xyz' => ['xyz'], + 'font/collection' => ['ttc'], + 'font/otf' => ['otf'], + 'font/ttf' => ['ttf'], + 'font/woff' => ['woff'], + 'font/woff2' => ['woff2'], + 'image/aces' => ['exr'], + 'image/apng' => ['apng'], + 'image/avci' => ['avci'], + 'image/avcs' => ['avcs'], + 'image/avif' => ['avif'], + 'image/bmp' => ['bmp', 'dib'], + 'image/cgm' => ['cgm'], + 'image/dicom-rle' => ['drle'], + 'image/dpx' => ['dpx'], + 'image/emf' => ['emf'], + 'image/fits' => ['fits'], + 'image/g3fax' => ['g3'], + 'image/gif' => ['gif'], + 'image/heic' => ['heic'], + 'image/heic-sequence' => ['heics'], + 'image/heif' => ['heif'], + 'image/heif-sequence' => ['heifs'], + 'image/hej2k' => ['hej2'], + 'image/hsj2' => ['hsj2'], + 'image/ief' => ['ief'], + 'image/jls' => ['jls'], + 'image/jp2' => ['jp2', 'jpg2'], + 'image/jpeg' => ['jpeg', 'jpg', 'jpe'], + 'image/jph' => ['jph'], + 'image/jphc' => ['jhc'], + 'image/jpm' => ['jpm', 'jpgm'], + 'image/jpx' => ['jpx', 'jpf'], + 'image/jxl' => ['jxl'], + 'image/jxr' => ['jxr'], + 'image/jxra' => ['jxra'], + 'image/jxrs' => ['jxrs'], + 'image/jxs' => ['jxs'], + 'image/jxsc' => ['jxsc'], + 'image/jxsi' => ['jxsi'], + 'image/jxss' => ['jxss'], + 'image/ktx' => ['ktx'], + 'image/ktx2' => ['ktx2'], + 'image/png' => ['png'], + 'image/prs.btif' => ['btif', 'btf'], + 'image/prs.pti' => ['pti'], + 'image/sgi' => ['sgi'], + 'image/svg+xml' => ['svg', 'svgz'], + 'image/t38' => ['t38'], + 'image/tiff' => ['tif', 'tiff'], + 'image/tiff-fx' => ['tfx'], + 'image/vnd.adobe.photoshop' => ['psd'], + 'image/vnd.airzip.accelerator.azv' => ['azv'], + 'image/vnd.dece.graphic' => ['uvi', 'uvvi', 'uvg', 'uvvg'], + 'image/vnd.djvu' => ['djvu', 'djv'], + 'image/vnd.dvb.subtitle' => ['sub'], + 'image/vnd.dwg' => ['dwg'], + 'image/vnd.dxf' => ['dxf'], + 'image/vnd.fastbidsheet' => ['fbs'], + 'image/vnd.fpx' => ['fpx'], + 'image/vnd.fst' => ['fst'], + 'image/vnd.fujixerox.edmics-mmr' => ['mmr'], + 'image/vnd.fujixerox.edmics-rlc' => ['rlc'], + 'image/vnd.microsoft.icon' => ['ico'], + 'image/vnd.ms-dds' => ['dds'], + 'image/vnd.ms-modi' => ['mdi'], + 'image/vnd.ms-photo' => ['wdp'], + 'image/vnd.net-fpx' => ['npx'], + 'image/vnd.pco.b16' => ['b16'], + 'image/vnd.tencent.tap' => ['tap'], + 'image/vnd.valve.source.texture' => ['vtf'], + 'image/vnd.wap.wbmp' => ['wbmp'], + 'image/vnd.xiff' => ['xif'], + 'image/vnd.zbrush.pcx' => ['pcx'], + 'image/webp' => ['webp'], + 'image/wmf' => ['wmf'], + 'image/x-3ds' => ['3ds'], + 'image/x-cmu-raster' => ['ras'], + 'image/x-cmx' => ['cmx'], + 'image/x-freehand' => ['fh', 'fhc', 'fh4', 'fh5', 'fh7'], + 'image/x-icon' => ['ico'], + 'image/x-jng' => ['jng'], + 'image/x-mrsid-image' => ['sid'], + 'image/x-ms-bmp' => ['bmp'], + 'image/x-pcx' => ['pcx'], + 'image/x-pict' => ['pic', 'pct'], + 'image/x-portable-anymap' => ['pnm'], + 'image/x-portable-bitmap' => ['pbm'], + 'image/x-portable-graymap' => ['pgm'], + 'image/x-portable-pixmap' => ['ppm'], + 'image/x-rgb' => ['rgb'], + 'image/x-tga' => ['tga'], + 'image/x-xbitmap' => ['xbm'], + 'image/x-xpixmap' => ['xpm'], + 'image/x-xwindowdump' => ['xwd'], + 'message/disposition-notification' => ['disposition-notification'], + 'message/global' => ['u8msg'], + 'message/global-delivery-status' => ['u8dsn'], + 'message/global-disposition-notification' => ['u8mdn'], + 'message/global-headers' => ['u8hdr'], + 'message/rfc822' => ['eml', 'mime'], + 'message/vnd.wfa.wsc' => ['wsc'], + 'model/3mf' => ['3mf'], + 'model/gltf+json' => ['gltf'], + 'model/gltf-binary' => ['glb'], + 'model/iges' => ['igs', 'iges'], + 'model/jt' => ['jt'], + 'model/mesh' => ['msh', 'mesh', 'silo'], + 'model/mtl' => ['mtl'], + 'model/obj' => ['obj'], + 'model/prc' => ['prc'], + 'model/step+xml' => ['stpx'], + 'model/step+zip' => ['stpz'], + 'model/step-xml+zip' => ['stpxz'], + 'model/stl' => ['stl'], + 'model/u3d' => ['u3d'], + 'model/vnd.bary' => ['bary'], + 'model/vnd.cld' => ['cld'], + 'model/vnd.collada+xml' => ['dae'], + 'model/vnd.dwf' => ['dwf'], + 'model/vnd.gdl' => ['gdl'], + 'model/vnd.gtw' => ['gtw'], + 'model/vnd.mts' => ['mts'], + 'model/vnd.opengex' => ['ogex'], + 'model/vnd.parasolid.transmit.binary' => ['x_b'], + 'model/vnd.parasolid.transmit.text' => ['x_t'], + 'model/vnd.pytha.pyox' => ['pyo', 'pyox'], + 'model/vnd.sap.vds' => ['vds'], + 'model/vnd.usda' => ['usda'], + 'model/vnd.usdz+zip' => ['usdz'], + 'model/vnd.valve.source.compiled-map' => ['bsp'], + 'model/vnd.vtu' => ['vtu'], + 'model/vrml' => ['wrl', 'vrml'], + 'model/x3d+binary' => ['x3db', 'x3dbz'], + 'model/x3d+fastinfoset' => ['x3db'], + 'model/x3d+vrml' => ['x3dv', 'x3dvz'], + 'model/x3d+xml' => ['x3d', 'x3dz'], + 'model/x3d-vrml' => ['x3dv'], + 'text/cache-manifest' => ['appcache', 'manifest'], + 'text/calendar' => ['ics', 'ifb'], + 'text/coffeescript' => ['coffee', 'litcoffee'], + 'text/css' => ['css'], + 'text/csv' => ['csv'], + 'text/html' => ['html', 'htm', 'shtml'], + 'text/jade' => ['jade'], + 'text/javascript' => ['js', 'mjs'], + 'text/jsx' => ['jsx'], + 'text/less' => ['less'], + 'text/markdown' => ['md', 'markdown'], + 'text/mathml' => ['mml'], + 'text/mdx' => ['mdx'], + 'text/n3' => ['n3'], + 'text/plain' => ['txt', 'text', 'conf', 'def', 'list', 'log', 'in', 'ini', 'm3u'], + 'text/prs.lines.tag' => ['dsc'], + 'text/richtext' => ['rtx'], + 'text/rtf' => ['rtf'], + 'text/sgml' => ['sgml', 'sgm'], + 'text/shex' => ['shex'], + 'text/slim' => ['slim', 'slm'], + 'text/spdx' => ['spdx'], + 'text/stylus' => ['stylus', 'styl'], + 'text/tab-separated-values' => ['tsv'], + 'text/troff' => ['t', 'tr', 'roff', 'man', 'me', 'ms'], + 'text/turtle' => ['ttl'], + 'text/uri-list' => ['uri', 'uris', 'urls'], + 'text/vcard' => ['vcard'], + 'text/vnd.curl' => ['curl'], + 'text/vnd.curl.dcurl' => ['dcurl'], + 'text/vnd.curl.mcurl' => ['mcurl'], + 'text/vnd.curl.scurl' => ['scurl'], + 'text/vnd.dvb.subtitle' => ['sub'], + 'text/vnd.familysearch.gedcom' => ['ged'], + 'text/vnd.fly' => ['fly'], + 'text/vnd.fmi.flexstor' => ['flx'], + 'text/vnd.graphviz' => ['gv'], + 'text/vnd.in3d.3dml' => ['3dml'], + 'text/vnd.in3d.spot' => ['spot'], + 'text/vnd.sun.j2me.app-descriptor' => ['jad'], + 'text/vnd.wap.wml' => ['wml'], + 'text/vnd.wap.wmlscript' => ['wmls'], + 'text/vtt' => ['vtt'], + 'text/wgsl' => ['wgsl'], + 'text/x-asm' => ['s', 'asm'], + 'text/x-c' => ['c', 'cc', 'cxx', 'cpp', 'h', 'hh', 'dic'], + 'text/x-component' => ['htc'], + 'text/x-fortran' => ['f', 'for', 'f77', 'f90'], + 'text/x-handlebars-template' => ['hbs'], + 'text/x-java-source' => ['java'], + 'text/x-lua' => ['lua'], + 'text/x-markdown' => ['mkd'], + 'text/x-nfo' => ['nfo'], + 'text/x-opml' => ['opml'], + 'text/x-org' => ['org'], + 'text/x-pascal' => ['p', 'pas'], + 'text/x-processing' => ['pde'], + 'text/x-sass' => ['sass'], + 'text/x-scss' => ['scss'], + 'text/x-setext' => ['etx'], + 'text/x-sfv' => ['sfv'], + 'text/x-suse-ymp' => ['ymp'], + 'text/x-uuencode' => ['uu'], + 'text/x-vcalendar' => ['vcs'], + 'text/x-vcard' => ['vcf'], + 'text/xml' => ['xml'], + 'text/yaml' => ['yaml', 'yml'], + 'video/3gpp' => ['3gp', '3gpp'], + 'video/3gpp2' => ['3g2'], + 'video/h261' => ['h261'], + 'video/h263' => ['h263'], + 'video/h264' => ['h264'], + 'video/iso.segment' => ['m4s'], + 'video/jpeg' => ['jpgv'], + 'video/jpm' => ['jpm', 'jpgm'], + 'video/mj2' => ['mj2', 'mjp2'], + 'video/mp2t' => ['ts', 'm2t', 'm2ts', 'mts'], + 'video/mp4' => ['mp4', 'mp4v', 'mpg4', 'f4v'], + 'video/mpeg' => ['mpeg', 'mpg', 'mpe', 'm1v', 'm2v'], + 'video/ogg' => ['ogv'], + 'video/quicktime' => ['qt', 'mov'], + 'video/vnd.dece.hd' => ['uvh', 'uvvh'], + 'video/vnd.dece.mobile' => ['uvm', 'uvvm'], + 'video/vnd.dece.pd' => ['uvp', 'uvvp'], + 'video/vnd.dece.sd' => ['uvs', 'uvvs'], + 'video/vnd.dece.video' => ['uvv', 'uvvv'], + 'video/vnd.dvb.file' => ['dvb'], + 'video/vnd.fvt' => ['fvt'], + 'video/vnd.mpegurl' => ['mxu', 'm4u'], + 'video/vnd.ms-playready.media.pyv' => ['pyv'], + 'video/vnd.uvvu.mp4' => ['uvu', 'uvvu'], + 'video/vnd.vivo' => ['viv'], + 'video/webm' => ['webm'], + 'video/x-f4v' => ['f4v'], + 'video/x-fli' => ['fli'], + 'video/x-flv' => ['flv'], + 'video/x-m4v' => ['m4v'], + 'video/x-matroska' => ['mkv', 'mk3d', 'mks'], + 'video/x-mng' => ['mng'], + 'video/x-ms-asf' => ['asf', 'asx'], + 'video/x-ms-vob' => ['vob'], + 'video/x-ms-wm' => ['wm'], + 'video/x-ms-wmv' => ['wmv'], + 'video/x-ms-wmx' => ['wmx'], + 'video/x-ms-wvx' => ['wvx'], + 'video/x-msvideo' => ['avi'], + 'video/x-sgi-movie' => ['movie'], + 'video/x-smv' => ['smv'], + 'x-conference/x-cooltalk' => ['ice'], + 'application/x-photoshop' => ['psd'], + 'application/smil' => ['smi', 'smil'], + 'application/powerpoint' => ['ppt'], + 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => ['ppam'], + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => ['pptm', 'potm'], + 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => ['ppsm'], + 'application/wbxml' => ['wbxml'], + 'application/wmlc' => ['wmlc'], + 'application/x-httpd-php-source' => ['phps'], + 'application/x-compress' => ['z'], + 'application/x-rar' => ['rar'], + 'video/vnd.rn-realvideo' => ['rv'], + 'application/vnd.ms-word.template.macroEnabled.12' => ['docm', 'dotm'], + 'application/vnd.ms-excel.sheet.macroEnabled.12' => ['xlsm'], + 'application/vnd.ms-excel.template.macroEnabled.12' => ['xltm'], + 'application/vnd.ms-excel.addin.macroEnabled.12' => ['xlam'], + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => ['xlsb'], + 'application/excel' => ['xl'], + 'application/x-x509-user-cert' => ['pem'], + 'application/x-pkcs10' => ['p10'], + 'application/x-pkcs7-signature' => ['p7a'], + 'application/pgp' => ['pgp'], + 'application/gpg-keys' => ['gpg'], + 'application/x-pkcs7' => ['rsa'], + 'video/3gp' => ['3gp'], + 'audio/acc' => ['aac'], + 'application/vnd.mpegurl' => ['m4u'], + 'application/videolan' => ['vlc'], + 'audio/x-au' => ['au'], + 'audio/ac3' => ['ac3'], + 'text/x-scriptzsh' => ['zsh'], + 'application/cdr' => ['cdr'], + 'application/STEP' => ['step', 'stp'], + 'application/x-ndjson' => ['ndjson'], + 'application/braille' => ['brf'], + ]; + + public function lookupMimeType(string $extension): ?string + { + return self::MIME_TYPES_FOR_EXTENSIONS[$extension] ?? null; + } + + public function lookupExtension(string $mimetype): ?string + { + return self::EXTENSIONS_FOR_MIME_TIMES[$mimetype][0] ?? null; + } + + /** + * @return string[] + */ + public function lookupAllExtensions(string $mimetype): array + { + return self::EXTENSIONS_FOR_MIME_TIMES[$mimetype] ?? []; + } +} diff --git a/vendor/league/mime-type-detection/src/MimeTypeDetector.php b/vendor/league/mime-type-detection/src/MimeTypeDetector.php new file mode 100644 index 0000000..5d799d2 --- /dev/null +++ b/vendor/league/mime-type-detection/src/MimeTypeDetector.php @@ -0,0 +1,19 @@ + $overrides + */ + public function __construct(ExtensionToMimeTypeMap $innerMap, array $overrides) + { + $this->innerMap = $innerMap; + $this->overrides = $overrides; + } + + public function lookupMimeType(string $extension): ?string + { + return $this->overrides[$extension] ?? $this->innerMap->lookupMimeType($extension); + } +} diff --git a/vendor/php-curl-class/php-curl-class/CHANGELOG.md b/vendor/php-curl-class/php-curl-class/CHANGELOG.md new file mode 100644 index 0000000..f644ef0 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/CHANGELOG.md @@ -0,0 +1,350 @@ +# Change Log + +PHP Curl Class uses semantic versioning with version numbers written as `MAJOR.MINOR.PATCH`. You may safely update +`MINOR` and `PATCH` version changes. It is recommended to review `MAJOR` changes prior to upgrade as there may be +backwards-incompatible changes that will affect existing usage. + + + +## 12.0.0 - 2025-03-25 + +- Drop support for PHP 7.4 ([#937](https://github.com/php-curl-class/php-curl-class/pull/937)) + +## 11.1.0 - 2025-03-24 + +- Add methods like Curl::setGet() for each HTTP request method ([#936](https://github.com/php-curl-class/php-curl-class/pull/936)) + +## 11.0.5 - 2025-03-11 + +- Fix PHPStan static analysis errors ([#929](https://github.com/php-curl-class/php-curl-class/pull/929)) + +## 11.0.4 - 2025-02-20 + +- Increase psalm strictness ([#925](https://github.com/php-curl-class/php-curl-class/pull/925)) + +## 11.0.3 - 2025-02-19 + +- Use default for Psalm ensureOverrideAttribute ([#923](https://github.com/php-curl-class/php-curl-class/pull/923)) + +## 11.0.2 - 2025-02-18 + +- Fix CI (PHPUnit) ([#918](https://github.com/php-curl-class/php-curl-class/pull/918)) + +## 11.0.1 - 2025-01-13 + +- Increase Psalm strictness ([#909](https://github.com/php-curl-class/php-curl-class/pull/909)) +- Increase PHPStan strictness ([#908](https://github.com/php-curl-class/php-curl-class/pull/908)) + +## 11.0.0 - 2024-08-22 + +- Drop support for PHP 7.3 ([#889](https://github.com/php-curl-class/php-curl-class/pull/889)) +- Drop support for PHP 7.2 ([#888](https://github.com/php-curl-class/php-curl-class/pull/888)) +- Drop support for PHP 7.1 ([#887](https://github.com/php-curl-class/php-curl-class/pull/887)) + +## 10.0.1 - 2024-08-21 + +- Use nullable type declaration ([#882](https://github.com/php-curl-class/php-curl-class/pull/882)) + +## 10.0.0 - 2024-08-20 + +- Drop support for PHP 7.0 ([#880](https://github.com/php-curl-class/php-curl-class/pull/880)) +- Add public method getActiveCurls ([#871](https://github.com/php-curl-class/php-curl-class/pull/871)) + +## 9.19.2 - 2024-04-09 + +- Fix CI: Use nullable type declaration ([#859](https://github.com/php-curl-class/php-curl-class/pull/859)) + +## 9.19.1 - 2024-02-27 + +- Fix afterSend not being called ([#848](https://github.com/php-curl-class/php-curl-class/pull/848)) + +## 9.19.0 - 2024-01-18 + +- Allow displaying curl option value without specifying value ([#837](https://github.com/php-curl-class/php-curl-class/pull/837)) + +## 9.18.2 - 2023-09-11 + +- Fix use of mb_strpos() causing error when polyfill is used ([#813](https://github.com/php-curl-class/php-curl-class/pull/813)) + +## 9.18.1 - 2023-08-29 + +- Add additional check for decoding gzip-encoded responses ([#808](https://github.com/php-curl-class/php-curl-class/pull/808)) + +## 9.18.0 - 2023-08-28 + +- Implement Curl::setError() and MultiCurl::setError() ([#805](https://github.com/php-curl-class/php-curl-class/pull/805)) +- Rename ::setError() to ::afterSend() ([#807](https://github.com/php-curl-class/php-curl-class/pull/807)) + +## 9.17.4 - 2023-07-10 + +- Add coding standards rule to use the null coalescing operator ?? where possible ([#801](https://github.com/php-curl-class/php-curl-class/pull/801)) +- Replace isset with null coalescing operator ([#800](https://github.com/php-curl-class/php-curl-class/pull/800)) + +## 9.17.3 - 2023-07-04 + +- Update PHP_CodeSniffer ruleset: PSR2 → PSR12 ([#797](https://github.com/php-curl-class/php-curl-class/pull/797)) +- Add additional coding standard checks ([#796](https://github.com/php-curl-class/php-curl-class/pull/796)) + +## 9.17.2 - 2023-06-27 + +- Use short array syntax ([#793](https://github.com/php-curl-class/php-curl-class/pull/793)) +- Add PHP-CS-Fixer to check for unused imports ([#794](https://github.com/php-curl-class/php-curl-class/pull/794)) +- Replace `uniqid` by `random_bytes` ([#792](https://github.com/php-curl-class/php-curl-class/pull/792)) + +## 9.17.1 - 2023-06-14 + +- Improve and add tests for Curl::fastDownload() ([#791](https://github.com/php-curl-class/php-curl-class/pull/791)) + +## 9.17.0 - 2023-06-13 + +- Make method to display curl option value public ([#790](https://github.com/php-curl-class/php-curl-class/pull/790)) + +## 9.16.1 - 2023-06-12 + +- Differentiate between internal options and user-set options ([#788](https://github.com/php-curl-class/php-curl-class/pull/788)) +- Create method to display a curl option value ([#785](https://github.com/php-curl-class/php-curl-class/pull/785)) +- Fix existing header overwritten after using MultiCurl::addCurl() ([#787](https://github.com/php-curl-class/php-curl-class/pull/787)) + +## 9.16.0 - 2023-05-25 + +- Graduate Curl::fastDownload() ([#783](https://github.com/php-curl-class/php-curl-class/pull/783)) + +## 9.15.1 - 2023-05-24 + +- Fix PHP CodeSniffer errors ([#782](https://github.com/php-curl-class/php-curl-class/pull/782)) + +## 9.15.0 - 2023-05-22 + +- Update Curl::diagnose() to detect bit flags with negative values ([#781](https://github.com/php-curl-class/php-curl-class/pull/781)) +- Display bit flags in use when calling Curl::diagnose() ([#779](https://github.com/php-curl-class/php-curl-class/pull/779)) + +## 9.14.5 - 2023-05-16 + +- Handle missing content-type response header in Curl::diagnose() ([#778](https://github.com/php-curl-class/php-curl-class/pull/778)) + +## 9.14.4 - 2023-05-08 + +- Update article in Curl::diagnose() Allow header warning ([#776](https://github.com/php-curl-class/php-curl-class/pull/776)) + +## 9.14.3 - 2023-03-13 + +- Remove use of array_merge() inside loop ([#774](https://github.com/php-curl-class/php-curl-class/pull/774)) + +## 9.14.2 - 2023-03-09 + +- Clean up: Reduce nesting ([#771](https://github.com/php-curl-class/php-curl-class/pull/771)) + +## 9.14.1 - 2023-02-27 + +- Remove coding standard ruleset exclusion ([#768](https://github.com/php-curl-class/php-curl-class/pull/768)) + +## 9.14.0 - 2023-02-26 + +- Make https:// and http:// the allowed request protocols by default ([#767](https://github.com/php-curl-class/php-curl-class/pull/767)) + +## 9.13.1 - 2023-01-16 + +- Allow uploads with CURLStringFile type ([#762](https://github.com/php-curl-class/php-curl-class/pull/762)) + +## 9.13.0 - 2023-01-13 + +- Implement abstract class BaseCurl for Curl and MultiCurl ([#759](https://github.com/php-curl-class/php-curl-class/pull/759)) +- Display error messages found in Curl::diagnose() ([#758](https://github.com/php-curl-class/php-curl-class/pull/758)) +- Fix Curl::diagnose() request type output for POST requests ([#757](https://github.com/php-curl-class/php-curl-class/pull/757)) + +## 9.12.6 - 2023-01-11 + +- Replace use of #[\AllowDynamicProperties] ([#756](https://github.com/php-curl-class/php-curl-class/pull/756)) +- silence PHP 8.2 deprecation notices ([#754](https://github.com/php-curl-class/php-curl-class/pull/754)) + +## 9.12.5 - 2022-12-20 + +- Fix static analysis error ([#752](https://github.com/php-curl-class/php-curl-class/pull/752)) + +## 9.12.4 - 2022-12-17 + +- Exclude additional files from git archive ([#751](https://github.com/php-curl-class/php-curl-class/pull/751)) + +## 9.12.3 - 2022-12-13 + +- Ensure string response before gzip decode ([#749](https://github.com/php-curl-class/php-curl-class/pull/749)) + +## 9.12.2 - 2022-12-11 + +- Disable warning when gzip-decoding response errors ([#748](https://github.com/php-curl-class/php-curl-class/pull/748)) + +## 9.12.1 - 2022-12-08 + +- Include option constant that uses the CURLINFO_ prefix ([#745](https://github.com/php-curl-class/php-curl-class/pull/745)) + +## 9.12.0 - 2022-12-07 + +- Add automatic gzip decoding of response ([#744](https://github.com/php-curl-class/php-curl-class/pull/744)) + +## 9.11.1 - 2022-12-06 + +- change: remove unused namespace import ([#743](https://github.com/php-curl-class/php-curl-class/pull/743)) + +## 9.11.0 - 2022-12-05 + +- Add Curl::diagnose() HTTP method check matches methods allowed ([#741](https://github.com/php-curl-class/php-curl-class/pull/741)) +- Add temporary fix missing template params ([#742](https://github.com/php-curl-class/php-curl-class/pull/742)) + +## 9.10.0 - 2022-11-07 + +- Display request options in Curl::diagnose() output ([#739](https://github.com/php-curl-class/php-curl-class/pull/739)) + +## 9.9.0 - 2022-11-06 + +- Fix MultiCurl::setCookieString() ([#738](https://github.com/php-curl-class/php-curl-class/pull/738)) +- Pass MultiCurl options to new Curl instances earlier ([#737](https://github.com/php-curl-class/php-curl-class/pull/737)) +- Add deferred constant curlErrorCodeConstants ([#736](https://github.com/php-curl-class/php-curl-class/pull/736)) + +## 9.8.0 - 2022-10-01 + +- Include curl error code constant in curl error message ([#733](https://github.com/php-curl-class/php-curl-class/pull/733)) + +## 9.7.0 - 2022-09-29 + +- Implement ArrayUtil::arrayRandomIndex() ([#732](https://github.com/php-curl-class/php-curl-class/pull/732)) + +## 9.6.3 - 2022-09-24 + +- Remove filter flag constants deprecated as of PHP 7.3 ([#730](https://github.com/php-curl-class/php-curl-class/pull/730)) + +## 9.6.2 - 2022-09-24 + +- Call MultiCurl::beforeSend() before each request is made ([#723](https://github.com/php-curl-class/php-curl-class/pull/723)) +- Encode keys for post data with numeric keys ([#726](https://github.com/php-curl-class/php-curl-class/pull/726)) +- Fix building post data with object ([#728](https://github.com/php-curl-class/php-curl-class/pull/728)) + +## 9.6.1 - 2022-06-30 + +### Fixed + +- Attempt to stop active requests when `MultiCurl::stop()` is called + [#714](https://github.com/php-curl-class/php-curl-class/issues/714) + [#718](https://github.com/php-curl-class/php-curl-class/issues/718) +- Retain keys for arrays with null values when building post data + [#712](https://github.com/php-curl-class/php-curl-class/issues/712) + +## 9.6.0 - 2022-03-17 + +### Added + +- Method `MultiCurl::stop()` for stopping subsequent requests + [#708](https://github.com/php-curl-class/php-curl-class/issues/708) + +## 9.5.1 - 2021-12-14 + +### Fixed + +- Silence PHP 8.1 deprecations [#691](https://github.com/php-curl-class/php-curl-class/issues/691) +- Remove data parameter from additional request types + [#689](https://github.com/php-curl-class/php-curl-class/issues/689) + +## 9.5.0 - 2021-11-21 + +### Added + +- Method `Curl::setStop()` for stopping requests early without downloading the full response body + [#681](https://github.com/php-curl-class/php-curl-class/issues/681) + +### Fixed + +- Fixed constructing request url when using `MultiCurl::addPost()` + [#686](https://github.com/php-curl-class/php-curl-class/issues/686) + +## 9.4.0 - 2021-09-04 + +### Changed + +- Method `Url::parseUrl()` is now public + +### Fixed + +- Fix parsing schemeless urls [#679](https://github.com/php-curl-class/php-curl-class/issues/679) + +## 9.3.1 - 2021-08-05 + +### Changed + +- Enabled strict types (`declare(strict_types=1);`) + +### Fixed + +- Fixed `Curl::downloadFileName` not being set correctly + +## 9.3.0 - 2021-07-23 + +### Added + +- Method `Curl::diagnose()` for troubleshooting requests + +## 9.2.0 - 2021-06-23 + +### Added + +- Additional Curl::set\* and MultiCurl::set\* helper methods + + ``` + Curl::setAutoReferer() + Curl::setAutoReferrer() + Curl::setFollowLocation() + Curl::setForbidReuse() + Curl::setMaximumRedirects() + MultiCurl::setAutoReferer() + MultiCurl::setAutoReferrer() + MultiCurl::setFollowLocation() + MultiCurl::setForbidReuse() + MultiCurl::setMaximumRedirects() + ``` + +### Fixed + +- Closing curl handles [#670](https://github.com/php-curl-class/php-curl-class/issues/670) +- Use of "$this" in non-object context [#671](https://github.com/php-curl-class/php-curl-class/pull/671) + +## 9.1.0 - 2021-03-24 + +### Added + +- Support for using relative urls with MultiCurl::add\*() methods [#628](https://github.com/php-curl-class/php-curl-class/issues/628) + +## 9.0.0 - 2021-03-19 + +### Changed + +- Use short array syntax + +### Removed + +- Support for PHP 5.3, 5.4, 5.5, and 5.6 [#380](https://github.com/php-curl-class/php-curl-class/issues/380) + +## Manual Review + +A manual review of changes is possible using the +[comparison page](https://github.com/php-curl-class/php-curl-class/compare/). For example, visit +[7.4.0...8.0.0](https://github.com/php-curl-class/php-curl-class/compare/7.4.0...8.0.0) to compare the changes for +the `MAJOR` upgrade from 7.4.0 to 8.0.0. Comparing against `HEAD` is also possible using the `tag...HEAD` syntax +([8.3.0...HEAD](https://github.com/php-curl-class/php-curl-class/compare/8.3.0...HEAD)). + +View the log between releases: + + $ git fetch --tags + $ git log 7.4.0...8.0.0 + +View the code changes between releases: + + $ git fetch --tags + $ git diff 7.4.0...8.0.0 + +View only the source log and code changes between releases: + + $ git log 7.4.0...8.0.0 "src/" + $ git diff 7.4.0...8.0.0 "src/" + +View only the source log and code changes between a release and the current checked-out commit: + + $ git log 8.0.0...head "src/" + $ git diff 8.0.0...head "src/" diff --git a/vendor/php-curl-class/php-curl-class/LICENSE b/vendor/php-curl-class/php-curl-class/LICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +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 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. + +For more information, please refer to diff --git a/vendor/php-curl-class/php-curl-class/README.md b/vendor/php-curl-class/php-curl-class/README.md new file mode 100644 index 0000000..159e7b5 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/README.md @@ -0,0 +1,408 @@ +# PHP Curl Class: HTTP requests made easy + +[![](https://img.shields.io/github/release/php-curl-class/php-curl-class.svg?style=for-the-badge&sort=semver)](https://github.com/php-curl-class/php-curl-class/releases/) +[![](https://img.shields.io/github/license/php-curl-class/php-curl-class.svg?style=for-the-badge)](https://github.com/php-curl-class/php-curl-class/blob/master/LICENSE) +[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/ci.yml?style=for-the-badge&label=build&branch=master)](https://github.com/php-curl-class/php-curl-class/actions/workflows/ci.yml) +[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/release.yml?style=for-the-badge&label=release&branch=master)](https://github.com/php-curl-class/php-curl-class/releases/) +[![](https://img.shields.io/github/actions/workflow/status/php-curl-class/php-curl-class/dependabot/dependabot-updates?style=for-the-badge&label=Dependabot&branch=master)](https://github.com/php-curl-class/php-curl-class/actions/workflows/dependabot/dependabot-updates) +[![](https://img.shields.io/packagist/dt/php-curl-class/php-curl-class.svg?style=for-the-badge)](https://github.com/php-curl-class/php-curl-class/releases/) + +PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs. + +![PHP Curl Class screencast](www/img/screencast.gif) + +--- + +- [⚙️ Installation](#%EF%B8%8F-installation) +- [📋 Requirements](#-requirements) +- [🚀 Quick Start and Examples](#-quick-start-and-examples) +- [📖 Available Methods](#-available-methods) +- [🔒 Security](#-security) +- [🛠️ Troubleshooting](#%EF%B8%8F-troubleshooting) +- [🧪 Testing](#-testing) +- [🤝 Contributing](#-contributing) + +--- + +### ⚙️ Installation + +To install PHP Curl Class, run the following command: + + composer require php-curl-class/php-curl-class + +To install the latest commit version: + + composer require php-curl-class/php-curl-class @dev + +Installation instructions to use the `composer` command can be found on https://github.com/composer/composer. + +### 📋 Requirements + +PHP Curl Class works with PHP 8.4, 8.3, 8.2, 8.1, and 8.0. + +### 🚀 Quick Start and Examples + +More examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples). + +```php +require __DIR__ . '/vendor/autoload.php'; + +use Curl\Curl; + +$curl = new Curl(); +$curl->get('https://www.example.com/'); + +if ($curl->error) { + echo 'Error: ' . $curl->errorMessage . "\n"; + $curl->diagnose(); +} else { + echo 'Response:' . "\n"; + var_dump($curl->response); +} +``` + +```php +// https://www.example.com/search?q=keyword +$curl = new Curl(); +$curl->get('https://www.example.com/search', [ + 'q' => 'keyword', +]); +``` + +```php +$curl = new Curl(); +$curl->post('https://www.example.com/login/', [ + 'username' => 'myusername', + 'password' => 'mypassword', +]); +``` + +```php +$curl = new Curl(); +$curl->setBasicAuthentication('username', 'password'); +$curl->setUserAgent('MyUserAgent/0.0.1 (+https://www.example.com/bot.html)'); +$curl->setReferrer('https://www.example.com/url?url=https%3A%2F%2Fwww.example.com%2F'); +$curl->setHeader('X-Requested-With', 'XMLHttpRequest'); +$curl->setCookie('key', 'value'); +$curl->get('https://www.example.com/'); + +if ($curl->error) { + echo 'Error: ' . $curl->errorMessage . "\n"; +} else { + echo 'Response:' . "\n"; + var_dump($curl->response); +} + +var_dump($curl->requestHeaders); +var_dump($curl->responseHeaders); +``` + +```php +$curl = new Curl(); +$curl->setFollowLocation(); +$curl->get('https://shortn.example.com/bHbVsP'); +``` + +```php +$curl = new Curl(); +$curl->put('https://api.example.com/user/', [ + 'first_name' => 'Zach', + 'last_name' => 'Borboa', +]); +``` + +```php +$curl = new Curl(); +$curl->patch('https://api.example.com/profile/', [ + 'image' => '@path/to/file.jpg', +]); +``` + +```php +$curl = new Curl(); +$curl->patch('https://api.example.com/profile/', [ + 'image' => new CURLFile('path/to/file.jpg'), +]); +``` + +```php +$curl = new Curl(); +$curl->delete('https://api.example.com/user/', [ + 'id' => '1234', +]); +``` + +```php +// Enable all supported encoding types and download a file. +$curl = new Curl(); +$curl->setOpt(CURLOPT_ENCODING , ''); +$curl->download('https://www.example.com/file.bin', '/tmp/myfile.bin'); +``` + +```php +// Case-insensitive access to headers. +$curl = new Curl(); +$curl->download('https://www.example.com/image.png', '/tmp/myimage.png'); +echo $curl->responseHeaders['Content-Type'] . "\n"; // image/png +echo $curl->responseHeaders['CoNTeNT-TyPE'] . "\n"; // image/png +``` + +```php +// Manual clean up. +$curl->close(); +``` + +```php +// Example access to curl object. +curl_set_opt($curl->curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1'); +curl_close($curl->curl); +``` + +```php +require __DIR__ . '/vendor/autoload.php'; + +use Curl\MultiCurl; + +// Requests in parallel with callback functions. +$multi_curl = new MultiCurl(); + +$multi_curl->success(function($instance) { + echo 'call to "' . $instance->url . '" was successful.' . "\n"; + echo 'response:' . "\n"; + var_dump($instance->response); +}); +$multi_curl->error(function($instance) { + echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n"; + echo 'error code: ' . $instance->errorCode . "\n"; + echo 'error message: ' . $instance->errorMessage . "\n"; +}); +$multi_curl->complete(function($instance) { + echo 'call completed' . "\n"; +}); + +$multi_curl->addGet('https://www.google.com/search', [ + 'q' => 'hello world', +]); +$multi_curl->addGet('https://duckduckgo.com/', [ + 'q' => 'hello world', +]); +$multi_curl->addGet('https://www.bing.com/search', [ + 'q' => 'hello world', +]); + +$multi_curl->start(); // Blocks until all items in the queue have been processed. +``` + +More examples are available under [/examples](https://github.com/php-curl-class/php-curl-class/tree/master/examples). + +### 📖 Available Methods +```php +Curl::__construct($base_url = null, $options = []) +Curl::__destruct() +Curl::__get($name) +Curl::__isset($name) +Curl::afterSend($callback) +Curl::attemptRetry() +Curl::beforeSend($callback) +Curl::buildPostData($data) +Curl::call() +Curl::close() +Curl::complete($callback) +Curl::delete($url, $query_parameters = [], $data = []) +Curl::diagnose($return = false) +Curl::disableTimeout() +Curl::displayCurlOptionValue($option, $value = null) +Curl::download($url, $mixed_filename) +Curl::error($callback) +Curl::exec($ch = null) +Curl::execDone() +Curl::fastDownload($url, $filename, $connections = 4) +Curl::get($url, $data = []) +Curl::getAttempts() +Curl::getBeforeSendCallback() +Curl::getCompleteCallback() +Curl::getCookie($key) +Curl::getCurl() +Curl::getCurlErrorCode() +Curl::getCurlErrorMessage() +Curl::getDownloadCompleteCallback() +Curl::getDownloadFileName() +Curl::getErrorCallback() +Curl::getErrorCode() +Curl::getErrorMessage() +Curl::getFileHandle() +Curl::getHttpErrorMessage() +Curl::getHttpStatusCode() +Curl::getId() +Curl::getInfo($opt = null) +Curl::getJsonDecoder() +Curl::getOpt($option) +Curl::getOptions() +Curl::getRawResponse() +Curl::getRawResponseHeaders() +Curl::getRemainingRetries() +Curl::getRequestHeaders() +Curl::getResponse() +Curl::getResponseCookie($key) +Curl::getResponseCookies() +Curl::getResponseHeaders() +Curl::getRetries() +Curl::getRetryDecider() +Curl::getSuccessCallback() +Curl::getUrl() +Curl::getUserSetOptions() +Curl::getXmlDecoder() +Curl::head($url, $data = []) +Curl::isChildOfMultiCurl() +Curl::isCurlError() +Curl::isError() +Curl::isHttpError() +Curl::options($url, $data = []) +Curl::patch($url, $data = []) +Curl::post($url, $data = '', $follow_303_with_post = false) +Curl::progress($callback) +Curl::put($url, $data = []) +Curl::removeHeader($key) +Curl::reset() +Curl::search($url, $data = []) +Curl::setAutoReferer($auto_referer = true) +Curl::setAutoReferrer($auto_referrer = true) +Curl::setBasicAuthentication($username, $password = '') +Curl::setConnectTimeout($seconds) +Curl::setCookie($key, $value) +Curl::setCookieFile($cookie_file) +Curl::setCookieJar($cookie_jar) +Curl::setCookieString($string) +Curl::setCookies($cookies) +Curl::setDefaultDecoder($mixed = 'json') +Curl::setDefaultHeaderOut() +Curl::setDefaultJsonDecoder() +Curl::setDefaultTimeout() +Curl::setDefaultUserAgent() +Curl::setDefaultXmlDecoder() +Curl::setDelete($url, $query_parameters = [], $data = []) +Curl::setDigestAuthentication($username, $password = '') +Curl::setFile($file) +Curl::setFollowLocation($follow_location = true) +Curl::setForbidReuse($forbid_reuse = true) +Curl::setGet($url, $data = []) +Curl::setHead($url, $data = []) +Curl::setHeader($key, $value) +Curl::setHeaders($headers) +Curl::setInterface($interface) +Curl::setJsonDecoder($mixed) +Curl::setMaxFilesize($bytes) +Curl::setMaximumRedirects($maximum_redirects) +Curl::setOpt($option, $value) +Curl::setOptions($url, $data = []) +Curl::setOpts($options) +Curl::setPatch($url, $data = []) +Curl::setPort($port) +Curl::setPost($url, $data = '', $follow_303_with_post = false) +Curl::setProtocols($protocols) +Curl::setProxy($proxy, $port = null, $username = null, $password = null) +Curl::setProxyAuth($auth) +Curl::setProxyTunnel($tunnel = true) +Curl::setProxyType($type) +Curl::setPut($url, $data = []) +Curl::setRange($range) +Curl::setRedirectProtocols($redirect_protocols) +Curl::setReferer($referer) +Curl::setReferrer($referrer) +Curl::setRetry($mixed) +Curl::setSearch($url, $data = []) +Curl::setStop($callback = null) +Curl::setTimeout($seconds) +Curl::setUrl($url, $mixed_data = '') +Curl::setUserAgent($user_agent) +Curl::setXmlDecoder($mixed) +Curl::stop() +Curl::success($callback) +Curl::unsetHeader($key) +Curl::unsetProxy() +Curl::verbose($on = true, $output = 'STDERR') +MultiCurl::__construct($base_url = null) +MultiCurl::__destruct() +MultiCurl::addCurl(Curl $curl) +MultiCurl::addDelete($url, $query_parameters = [], $data = []) +MultiCurl::addDownload($url, $mixed_filename) +MultiCurl::addGet($url, $data = []) +MultiCurl::addHead($url, $data = []) +MultiCurl::addOptions($url, $data = []) +MultiCurl::addPatch($url, $data = []) +MultiCurl::addPost($url, $data = '', $follow_303_with_post = false) +MultiCurl::addPut($url, $data = []) +MultiCurl::addSearch($url, $data = []) +MultiCurl::afterSend($callback) +MultiCurl::beforeSend($callback) +MultiCurl::close() +MultiCurl::complete($callback) +MultiCurl::disableTimeout() +MultiCurl::error($callback) +MultiCurl::getActiveCurls() +MultiCurl::getOpt($option) +MultiCurl::removeHeader($key) +MultiCurl::setAutoReferer($auto_referer = true) +MultiCurl::setAutoReferrer($auto_referrer = true) +MultiCurl::setBasicAuthentication($username, $password = '') +MultiCurl::setConcurrency($concurrency) +MultiCurl::setConnectTimeout($seconds) +MultiCurl::setCookie($key, $value) +MultiCurl::setCookieFile($cookie_file) +MultiCurl::setCookieJar($cookie_jar) +MultiCurl::setCookieString($string) +MultiCurl::setCookies($cookies) +MultiCurl::setDigestAuthentication($username, $password = '') +MultiCurl::setFile($file) +MultiCurl::setFollowLocation($follow_location = true) +MultiCurl::setForbidReuse($forbid_reuse = true) +MultiCurl::setHeader($key, $value) +MultiCurl::setHeaders($headers) +MultiCurl::setInterface($interface) +MultiCurl::setJsonDecoder($mixed) +MultiCurl::setMaximumRedirects($maximum_redirects) +MultiCurl::setOpt($option, $value) +MultiCurl::setOpts($options) +MultiCurl::setPort($port) +MultiCurl::setProxies($proxies) +MultiCurl::setProxy($proxy, $port = null, $username = null, $password = null) +MultiCurl::setProxyAuth($auth) +MultiCurl::setProxyTunnel($tunnel = true) +MultiCurl::setProxyType($type) +MultiCurl::setRange($range) +MultiCurl::setRateLimit($rate_limit) +MultiCurl::setReferer($referer) +MultiCurl::setReferrer($referrer) +MultiCurl::setRequestTimeAccuracy() +MultiCurl::setRetry($mixed) +MultiCurl::setTimeout($seconds) +MultiCurl::setUrl($url, $mixed_data = '') +MultiCurl::setUserAgent($user_agent) +MultiCurl::setXmlDecoder($mixed) +MultiCurl::start() +MultiCurl::stop() +MultiCurl::success($callback) +MultiCurl::unsetHeader($key) +MultiCurl::unsetProxy() +MultiCurl::verbose($on = true, $output = 'STDERR') +``` + +### 🔒 Security + +See [SECURITY](https://github.com/php-curl-class/php-curl-class/blob/master/SECURITY.md) for security considerations. + +### 🛠️ Troubleshooting + +See [TROUBLESHOOTING](https://github.com/php-curl-class/php-curl-class/blob/master/TROUBLESHOOTING.md) for help troubleshooting. + +### 🧪 Testing + +See [TESTING](https://github.com/php-curl-class/php-curl-class/blob/master/TESTING.md) for testing information. + +### 🤝 Contributing + +1. Check for open issues or open a new issue to start a discussion around a bug or feature. +1. Fork the repository on GitHub to start making your changes. +1. Write one or more tests for the new feature or that expose the bug. +1. Make code changes to implement the feature or fix the bug. +1. Send a pull request to get your changes merged and published. diff --git a/vendor/php-curl-class/php-curl-class/SECURITY.md b/vendor/php-curl-class/php-curl-class/SECURITY.md new file mode 100644 index 0000000..08628a7 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/SECURITY.md @@ -0,0 +1,127 @@ +# Security Considerations + +### Url may point to system files + +* Don't blindly accept urls from users as they may point to system files. Curl supports many protocols including `FILE`. + The following would show the contents of `file:///etc/passwd`. + +```bash +# Attacker. +$ curl https://www.example.com/display_webpage.php?url=file%3A%2F%2F%2Fetc%2Fpasswd +``` + +```php +// display_webpage.php +$url = $_GET['url']; // DANGER! +$curl = new Curl(); +$curl->get($url); +echo $curl->response; +``` + +Safer: + +```php +function is_allowed_url($url, $allowed_url_schemes = ['http', 'https']) { + $valid_url = filter_var($url, FILTER_VALIDATE_URL) !== false; + if ($valid_url) { + $scheme = parse_url($url, PHP_URL_SCHEME); + return in_array($scheme, $allowed_url_schemes, true); + } + $valid_ip = filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false; + return $valid_ip; +} + +$url = $_GET['url']; +if (!is_allowed_url($url)) { + die('Unsafe url detected.'); +} + +$curl = new Curl(); +$curl->setProtocols(CURLPROTO_HTTPS); +$curl->setRedirectProtocols(CURLPROTO_HTTPS); +$curl->get($url); +``` + +### Url may point to internal urls + +* Url may point to internal urls including those behind a firewall (e.g. http://192.168.0.1/ or ftp://192.168.0.1/). Use + a whitelist to allow certain urls rather than a blacklist. + +* Use `Curl::setProtocols()` and `Curl::setRedirectProtocols()` to restrict allowed protocols. + +```php +// Allow only HTTPS protocols. +$curl->setProtocols(CURLPROTO_HTTPS); +$curl->setRedirectProtocols(CURLPROTO_HTTPS); +``` + +```php +// Allow HTTPS and HTTP protocols. +$curl->setProtocols(CURLPROTO_HTTPS | CURLPROTO_HTTP); +$curl->setRedirectProtocols(CURLPROTO_HTTPS | CURLPROTO_HTTP); +``` + +### Request data may refer to system files + +* Request data prefixed with the `@` character may have special interpretation and read from system files. + +```bash +# Attacker. +$ curl https://www.example.com/upload_photo.php --data "photo=@/etc/passwd" +``` + +```php +// upload_photo.php +$curl = new Curl(); +$curl->post('http://www.anotherwebsite.com/', [ + 'photo' => $_POST['photo'], // DANGER! +]); +``` + +### Unsafe response with redirection enabled + +* Requests with redirection enabled may return responses from unexpected sources. + Downloading https://www.example.com/image.png may redirect and download https://www.evil.com/virus.exe + +```php +$curl = new Curl(); +$curl->setOpt(CURLOPT_FOLLOWLOCATION, true); // DANGER! +$curl->download('https://www.example.com/image.png', 'my_image.png'); +``` + +```php +$curl = new Curl(); +$curl->setOpt(CURLOPT_FOLLOWLOCATION, true); // DANGER! +$curl->get('https://www.example.com/image.png'); +``` + +### Keep SSL protections enabled + +* Do not disable SSL protections. + +```php +curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // DANGER! +curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // DANGER! +``` + +### Prevent XML External Entity injection + +* Set the following when using the default PHP XML parser to prevent XML external entity injection. + +```php +libxml_disable_entity_loader(true); +``` + +### Prevent PHP execution of library files + +PHP files in this library are not intended to be accessible by users browsing websites. Prevent direct access to library files by moving the library folder at least one level higher than the web root directory. Alternatively, configure the server to disable php file execution for all library files. + +#### For WordPress plugin developers + +WordPress plugin developers that wish to incorporate the PHP Curl Class library into their plugin, should take special care to include only the "core" library files. + +Do one of the following: + +Option 1. Download an official release from the [releases page](https://github.com/php-curl-class/php-curl-class/releases) and incorporate the files contained in the compressed file into the plugin. The releases include only the necessary php files for the library to function. + +Option 2. Manually copy only the [src/](https://github.com/php-curl-class/php-curl-class/tree/master/src) directory into your plugin. Be sure not to copy any other php files as they may be executable by users visiting the php files directly. diff --git a/vendor/php-curl-class/php-curl-class/composer.json b/vendor/php-curl-class/php-curl-class/composer.json new file mode 100644 index 0000000..37e5689 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/composer.json @@ -0,0 +1,53 @@ +{ + "name": "php-curl-class/php-curl-class", + "description": "PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.", + "homepage": "https://github.com/php-curl-class/php-curl-class", + "license": "Unlicense", + "keywords": [ + "php", "curl", "class", "api", "api-client", "client", "framework", "http", "http-client", "http-proxy", "json", + "php-curl", "php-curl-library", "proxy", "requests", "restful", "web-scraper", "web-scraping", "web-service", + "xml" + ], + "authors": [ + { + "name": "Zach Borboa" + }, + { + "name": "Contributors", + "homepage": "https://github.com/php-curl-class/php-curl-class/graphs/contributors" + } + ], + "require": { + "php": ">=8.0", + "ext-curl": "*" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "*", + "ext-gd": "*", + "friendsofphp/php-cs-fixer": "*", + "phpcompatibility/php-compatibility": "dev-develop", + "phpcsstandards/phpcsutils": "@alpha", + "phpstan/phpstan": "*", + "phpunit/phpunit": "*", + "squizlabs/php_codesniffer": "*" + }, + "suggest": { + "ext-mbstring": "*" + }, + "autoload": { + "psr-4": { + "Curl\\": "src/Curl/" + } + }, + "autoload-dev": { + "files": [ + "./tests/Helper.php", + "./tests/User.php" + ] + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/vendor/php-curl-class/php-curl-class/src/Curl/ArrayUtil.php b/vendor/php-curl-class/php-curl-class/src/Curl/ArrayUtil.php new file mode 100644 index 0000000..20a83c8 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/src/Curl/ArrayUtil.php @@ -0,0 +1,159 @@ + $value) { + if (is_scalar($value)) { + if ($prefix) { + $arrays_to_merge[] = [ + $prefix . '[' . $key . ']' => $value, + ]; + } else { + $arrays_to_merge[] = [ + $key => $value, + ]; + } + } elseif ($value instanceof \CURLFile) { + $arrays_to_merge[] = [ + $key => $value, + ]; + } elseif ($value instanceof \CURLStringFile) { + $arrays_to_merge[] = [ + $key => $value, + ]; + } else { + $arrays_to_merge[] = self::arrayFlattenMultidim( + $value, + $prefix ? $prefix . '[' . $key . ']' : $key + ); + } + } + + $return = array_merge($return, ...$arrays_to_merge); + } + } elseif ($array === null) { + $return[$prefix] = $array; + } + return $return; + } + + /** + * Array Flatten Multidim + * + * @deprecated Use ArrayUtil::arrayFlattenMultidim(). + * @param $array + * @param $prefix + * @return array + */ + public static function array_flatten_multidim($array, $prefix = false) + { + return static::arrayFlattenMultidim($array, $prefix); + } + + /** + * Array Random + * + * @param $array + * @return mixed + */ + public static function arrayRandom($array) + { + return $array[static::arrayRandomIndex($array)]; + } + + /** + * Array Random Index + * + * @param $array + * @return int + */ + public static function arrayRandomIndex($array) + { + return mt_rand(0, count($array) - 1); + } + + /** + * Array Random + * + * @deprecated Use ArrayUtil::arrayRandom(). + * @param $array + * @return mixed + */ + public static function array_random($array) + { + return static::arrayRandom($array); + } +} diff --git a/vendor/php-curl-class/php-curl-class/src/Curl/BaseCurl.php b/vendor/php-curl-class/php-curl-class/src/Curl/BaseCurl.php new file mode 100644 index 0000000..54d4a50 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/src/Curl/BaseCurl.php @@ -0,0 +1,422 @@ +beforeSendCallback = $callback; + } + + abstract public function close(); + + /** + * Complete + * + * @param $callback callable|null + */ + public function complete($callback) + { + $this->completeCallback = $callback; + } + + /** + * Disable Timeout + */ + public function disableTimeout() + { + $this->setTimeout(null); + } + + /** + * Error + * + * @param $callback callable|null + */ + public function error($callback) + { + $this->errorCallback = $callback; + } + + /** + * Get Opt + * + * @param $option + * @return mixed + */ + public function getOpt($option) + { + return $this->options[$option] ?? null; + } + + /** + * Remove Header + * + * Remove an internal header from the request. + * Using `curl -H "Host:" ...' is equivalent to $curl->removeHeader('Host');. + * + * @param $key + */ + public function removeHeader($key) + { + $this->setHeader($key, ''); + } + + /** + * Set auto referer + * + * @param mixed $auto_referer + */ + public function setAutoReferer($auto_referer = true) + { + $this->setAutoReferrer($auto_referer); + } + + /** + * Set auto referrer + * + * @param mixed $auto_referrer + */ + public function setAutoReferrer($auto_referrer = true) + { + $this->setOpt(CURLOPT_AUTOREFERER, $auto_referrer); + } + + /** + * Set Basic Authentication + * + * @param $username + * @param $password + */ + public function setBasicAuthentication($username, $password = '') + { + $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + $this->setOpt(CURLOPT_USERPWD, $username . ':' . $password); + } + + /** + * Set Connect Timeout + * + * @param $seconds + */ + public function setConnectTimeout($seconds) + { + $this->setOpt(CURLOPT_CONNECTTIMEOUT, $seconds); + } + + abstract public function setCookie($key, $value); + abstract public function setCookieFile($cookie_file); + abstract public function setCookieJar($cookie_jar); + abstract public function setCookieString($string); + abstract public function setCookies($cookies); + + /** + * Set Digest Authentication + * + * @param $username + * @param $password + */ + public function setDigestAuthentication($username, $password = '') + { + $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + $this->setOpt(CURLOPT_USERPWD, $username . ':' . $password); + } + + /** + * After Send + * + * This function is called after the request has been sent. + * + * It can be used to override whether or not the request errored. The + * instance is passed as the first argument to the function and the instance + * has attributes like $instance->httpStatusCode and $instance->response to + * help decide if the request errored. Set $instance->error to true or false + * within the function. + * + * When $instance->error is true indicating a request error, the error + * callback set by Curl::error() is called. When $instance->error is false, + * the success callback set by Curl::success() is called. + * + * @param $callback callable|null + */ + public function afterSend($callback) + { + $this->afterSendCallback = $callback; + } + + /** + * Set File + * + * @param $file + */ + public function setFile($file) + { + $this->setOpt(CURLOPT_FILE, $file); + } + + protected function setFileInternal($file) + { + $this->setOptInternal(CURLOPT_FILE, $file); + } + + /** + * Set follow location + * + * @param mixed $follow_location + * @see Curl::setMaximumRedirects() + */ + public function setFollowLocation($follow_location = true) + { + $this->setOpt(CURLOPT_FOLLOWLOCATION, $follow_location); + } + + /** + * Set forbid reuse + * + * @param mixed $forbid_reuse + */ + public function setForbidReuse($forbid_reuse = true) + { + $this->setOpt(CURLOPT_FORBID_REUSE, $forbid_reuse); + } + + abstract public function setHeader($key, $value); + abstract public function setHeaders($headers); + + /** + * Set Interface + * + * The name of the outgoing network interface to use. + * This can be an interface name, an IP address or a host name. + * + * @param $interface + */ + public function setInterface($interface) + { + $this->setOpt(CURLOPT_INTERFACE, $interface); + } + + abstract public function setJsonDecoder($mixed); + + /** + * Set maximum redirects + * + * @param mixed $maximum_redirects + * @see Curl::setFollowLocation() + */ + public function setMaximumRedirects($maximum_redirects) + { + $this->setOpt(CURLOPT_MAXREDIRS, $maximum_redirects); + } + + abstract public function setOpt($option, $value); + + protected function setOptInternal($option, $value) + { + } + + abstract public function setOpts($options); + + /** + * Set Port + * + * @param $port + */ + public function setPort($port) + { + $this->setOpt(CURLOPT_PORT, (int) $port); + } + + /** + * Set Proxy + * + * Set an HTTP proxy to tunnel requests through. + * + * @param $proxy - The HTTP proxy to tunnel requests through. May include port number. + * @param $port - The port number of the proxy to connect to. This port number can also be set in $proxy. + * @param $username - The username to use for the connection to the proxy. + * @param $password - The password to use for the connection to the proxy. + */ + public function setProxy($proxy, $port = null, $username = null, $password = null) + { + $this->setOpt(CURLOPT_PROXY, $proxy); + if ($port !== null) { + $this->setOpt(CURLOPT_PROXYPORT, $port); + } + if ($username !== null && $password !== null) { + $this->setOpt(CURLOPT_PROXYUSERPWD, $username . ':' . $password); + } + } + + /** + * Set Proxy Auth + * + * Set the HTTP authentication method(s) to use for the proxy connection. + * + * @param $auth + */ + public function setProxyAuth($auth) + { + $this->setOpt(CURLOPT_PROXYAUTH, $auth); + } + + /** + * Set Proxy Tunnel + * + * Set the proxy to tunnel through HTTP proxy. + * + * @param $tunnel boolean + */ + public function setProxyTunnel($tunnel = true) + { + $this->setOpt(CURLOPT_HTTPPROXYTUNNEL, $tunnel); + } + + /** + * Set Proxy Type + * + * Set the proxy protocol type. + * + * @param $type + */ + public function setProxyType($type) + { + $this->setOpt(CURLOPT_PROXYTYPE, $type); + } + + /** + * Set Range + * + * @param $range + */ + public function setRange($range) + { + $this->setOpt(CURLOPT_RANGE, $range); + } + + protected function setRangeInternal($range) + { + $this->setOptInternal(CURLOPT_RANGE, $range); + } + + /** + * Set Referer + * + * @param $referer + */ + public function setReferer($referer) + { + $this->setReferrer($referer); + } + + /** + * Set Referrer + * + * @param $referrer + */ + public function setReferrer($referrer) + { + $this->setOpt(CURLOPT_REFERER, $referrer); + } + + abstract public function setRetry($mixed); + + /** + * Set Timeout + * + * @param $seconds + */ + public function setTimeout($seconds) + { + $this->setOpt(CURLOPT_TIMEOUT, $seconds); + } + + protected function setTimeoutInternal($seconds) + { + $this->setOptInternal(CURLOPT_TIMEOUT, $seconds); + } + + abstract public function setUrl($url, $mixed_data = ''); + + /** + * Set User Agent + * + * @param $user_agent + */ + public function setUserAgent($user_agent) + { + $this->setOpt(CURLOPT_USERAGENT, $user_agent); + } + + protected function setUserAgentInternal($user_agent) + { + $this->setOptInternal(CURLOPT_USERAGENT, $user_agent); + } + + abstract public function setXmlDecoder($mixed); + abstract public function stop(); + + /** + * Success + * + * @param $callback callable|null + */ + public function success($callback) + { + $this->successCallback = $callback; + } + + abstract public function unsetHeader($key); + + /** + * Unset Proxy + * + * Disable use of the proxy. + */ + public function unsetProxy() + { + $this->setOpt(CURLOPT_PROXY, null); + } + + /** + * Verbose + * + * @param bool $on + * @param resource|string $output + */ + public function verbose($on = true, $output = 'STDERR') + { + if ($output === 'STDERR') { + if (defined('STDERR')) { + $output = STDERR; + } else { + $output = fopen('php://stderr', 'wb'); + } + } + + // Turn off CURLINFO_HEADER_OUT for verbose to work. This has the side + // effect of causing Curl::requestHeaders to be empty. + if ($on) { + $this->setOpt(CURLINFO_HEADER_OUT, false); + } + $this->setOpt(CURLOPT_VERBOSE, $on); + $this->setOpt(CURLOPT_STDERR, $output); + } +} diff --git a/vendor/php-curl-class/php-curl-class/src/Curl/CaseInsensitiveArray.php b/vendor/php-curl-class/php-curl-class/src/Curl/CaseInsensitiveArray.php new file mode 100644 index 0000000..bc2daca --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/src/Curl/CaseInsensitiveArray.php @@ -0,0 +1,211 @@ + $value) { + $this->offsetSet($key, $value); + } + } + } + + /** + * Offset Set + * + * Set data at a specified offset. Converts the offset to lowercase, and + * stores the case-sensitive offset and the data at the lowercase indexes in + * $this->keys and @this->data. + * + * @param string $offset The offset to store the data at (case-insensitive). + * @param mixed $value The data to store at the specified offset. + * @return void + * @see https://secure.php.net/manual/en/arrayaccess.offsetset.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if ($offset === null) { + $this->data[] = $value; + } else { + $offsetlower = strtolower($offset); + $this->data[$offsetlower] = $value; + $this->keys[$offsetlower] = $offset; + } + } + + /** + * Offset Exists + * + * Checks if the offset exists in data storage. The index is looked up with + * the lowercase version of the provided offset. + * + * @param string $offset Offset to check + * @return bool If the offset exists. + * @see https://secure.php.net/manual/en/arrayaccess.offsetexists.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return array_key_exists(strtolower($offset), $this->data); + } + + /** + * Offset Unset + * + * Unsets the specified offset. Converts the provided offset to lowercase, + * and unsets the case-sensitive key, as well as the stored data. + * + * @param string $offset The offset to unset. + * @return void + * @see https://secure.php.net/manual/en/arrayaccess.offsetunset.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + $offsetlower = strtolower($offset); + unset($this->data[$offsetlower]); + unset($this->keys[$offsetlower]); + } + + /** + * Offset Get + * + * Return the stored data at the provided offset. The offset is converted to + * lowercase and the lookup is done on the data store directly. + * + * @param string $offset Offset to lookup. + * @return mixed The data stored at the offset. + * @see https://secure.php.net/manual/en/arrayaccess.offsetget.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + $offsetlower = strtolower($offset); + return $this->data[$offsetlower] ?? null; + } + + /** + * Count + * + * @return int The number of elements stored in the array. + * @see https://secure.php.net/manual/en/countable.count.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function count() + { + return count($this->data); + } + + /** + * Current + * + * @return mixed Data at the current position. + * @see https://secure.php.net/manual/en/iterator.current.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function current() + { + return current($this->data); + } + + /** + * Next + * + * @return void + * @see https://secure.php.net/manual/en/iterator.next.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function next() + { + next($this->data); + } + + /** + * Key + * + * @return mixed Case-sensitive key at current position. + * @see https://secure.php.net/manual/en/iterator.key.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function key() + { + $key = key($this->data); + return $this->keys[$key] ?? $key; + } + + /** + * Valid + * + * @return bool If the current position is valid. + * @see https://secure.php.net/manual/en/iterator.valid.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function valid() + { + return (key($this->data) !== null); + } + + /** + * Rewind + * + * @return void + * @see https://secure.php.net/manual/en/iterator.rewind.php + */ + #[\Override] + #[\ReturnTypeWillChange] + public function rewind() + { + reset($this->data); + } +} diff --git a/vendor/php-curl-class/php-curl-class/src/Curl/Curl.php b/vendor/php-curl-class/php-curl-class/src/Curl/Curl.php new file mode 100644 index 0000000..5959472 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/src/Curl/Curl.php @@ -0,0 +1,2275 @@ + + // CTL = + // separators = "(" | ")" | "<" | ">" | "@" + // | "," | ";" | ":" | "\" | <"> + // | "/" | "[" | "]" | "?" | "=" + // | "{" | "}" | SP | HT + // SP = + // HT = + // <"> = + '!', '#', '$', '%', '&', "'", '*', '+', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', + 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '|', '~', + ]; + public static $RFC6265 = [ + // RFC 6265: "US-ASCII characters excluding CTLs, whitespace DQUOTE, comma, semicolon, and backslash". + // %x21 + '!', + // %x23-2B + '#', '$', '%', '&', "'", '(', ')', '*', '+', + // %x2D-3A + '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', + // %x3C-5B + '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', + // %x5D-7E + ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', + 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', + ]; + + public $curlErrorCodeConstant; + public $curlErrorCodeConstants; + + private static $deferredProperties = [ + 'curlErrorCodeConstant', + 'curlErrorCodeConstants', + 'curlOptionCodeConstants', + 'effectiveUrl', + 'rfc2616', + 'rfc6265', + 'totalTime', + ]; + private array $deferredValues = []; + + /** + * Construct + * + * @param $base_url + * @param mixed $options + * @throws \ErrorException + */ + public function __construct($base_url = null, $options = []) + { + if (!extension_loaded('curl')) { + throw new \ErrorException('cURL library is not loaded'); + } + + unset($this->deferredValues['curlErrorCodeConstant']); + unset($this->deferredValues['curlErrorCodeConstants']); + unset($this->deferredValues['curlOptionCodeConstants']); + unset($this->deferredValues['effectiveUrl']); + unset($this->deferredValues['rfc2616']); + unset($this->deferredValues['rfc6265']); + unset($this->deferredValues['totalTime']); + + $this->curl = curl_init(); + $this->initialize($base_url, $options); + } + + /** + * Build Post Data + * + * @param $data + * @return array|string + * @throws \ErrorException + */ + public function buildPostData($data) + { + $binary_data = false; + + // Return JSON-encoded string when the request's content-type is JSON and the data is serializable. + if ( + isset($this->headers['Content-Type']) && + preg_match($this->jsonPattern, $this->headers['Content-Type']) && + ( + is_array($data) || + ( + is_object($data) && + interface_exists('JsonSerializable', false) && + $data instanceof \JsonSerializable + ) + ) + ) { + $data = \Curl\Encoder::encodeJson($data); + } elseif (is_array($data)) { + // Manually build a single-dimensional array from a multi-dimensional array as using curl_setopt($ch, + // CURLOPT_POSTFIELDS, $data) doesn't correctly handle multi-dimensional arrays when files are + // referenced. + if (ArrayUtil::isArrayMultidim($data)) { + $data = ArrayUtil::arrayFlattenMultidim($data); + } + + // Modify array values to ensure any referenced files are properly handled depending on the support of + // the @filename API or CURLFile usage. This also fixes the warning "curl_setopt(): The usage of the + // @filename API for file uploading is deprecated. Please use the CURLFile class instead". Ignore + // non-file values prefixed with the @ character. + foreach ($data as $key => $value) { + if (is_string($value) && strpos($value, '@') === 0 && is_file(substr($value, 1))) { + $binary_data = true; + if (class_exists('CURLFile')) { + $data[$key] = new \CURLFile(substr($value, 1)); + } + } elseif ($value instanceof \CURLFile) { + $binary_data = true; + } elseif ($value instanceof \CURLStringFile) { + $binary_data = true; + } + } + } + + if ( + !$binary_data && + (is_array($data) || is_object($data)) && + ( + !isset($this->headers['Content-Type']) || + !preg_match('/^multipart\/form-data/', $this->headers['Content-Type']) + ) + ) { + // Avoid using http_build_query() as keys with null values are + // unexpectedly excluded from the resulting string. + // + // $ php -a + // php > echo http_build_query(['a' => '1', 'b' => null, 'c' => '3']); + // a=1&c=3 + // php > echo http_build_query(['a' => '1', 'b' => '', 'c' => '3']); + // a=1&b=&c=3 + // + // $data = http_build_query($data, '', '&'); + $data = implode('&', array_map(function ($k, $v) { + // Encode keys and values using urlencode() to match the default + // behavior http_build_query() where $encoding_type is + // PHP_QUERY_RFC1738. + // + // Use strval() as urlencode() expects a string parameter: + // TypeError: urlencode() expects parameter 1 to be string, integer given + // TypeError: urlencode() expects parameter 1 to be string, null given + // + // php_raw_url_encode() + // php_url_encode() + // https://github.com/php/php-src/blob/master/ext/standard/http.c + return urlencode(strval($k)) . '=' . urlencode(strval($v)); + }, array_keys((array)$data), array_values((array)$data))); + } + + return $data; + } + + /** + * Call + */ + public function call() + { + $args = func_get_args(); + $function = array_shift($args); + if (is_callable($function)) { + array_unshift($args, $this); + call_user_func_array($function, $args); + } + } + + /** + * Close + */ + #[\Override] + public function close() + { + if (is_resource($this->curl) || $this->curl instanceof \CurlHandle) { + curl_close($this->curl); + } + $this->curl = null; + $this->options = null; + $this->userSetOptions = null; + $this->jsonDecoder = null; + $this->jsonDecoderArgs = null; + $this->xmlDecoder = null; + $this->xmlDecoderArgs = null; + $this->headerCallbackData = null; + $this->defaultDecoder = null; + } + + /** + * Progress + * + * @param $callback callable|null + */ + public function progress($callback) + { + $this->setOpt(CURLOPT_PROGRESSFUNCTION, $callback); + $this->setOpt(CURLOPT_NOPROGRESS, false); + } + + private function progressInternal($callback) + { + $this->setOptInternal(CURLOPT_PROGRESSFUNCTION, $callback); + $this->setOptInternal(CURLOPT_NOPROGRESS, false); + } + + /** + * Delete + * + * @param $url + * @param $query_parameters + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function delete($url, $query_parameters = [], $data = []) + { + $this->setDelete($url, $query_parameters, $data); + return $this->exec(); + } + + public function setDelete($url, $query_parameters = [], $data = []) + { + if (is_array($url)) { + $data = $query_parameters; + $query_parameters = $url; + $url = (string)$this->url; + } + + $this->setUrl($url, $query_parameters); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE'); + + // Avoid including a content-length header in DELETE requests unless there is a message body. The following + // would include "Content-Length: 0" in the request header: + // curl_setopt($ch, CURLOPT_POSTFIELDS, []); + // RFC 2616 4.3 Message Body: + // The presence of a message-body in a request is signaled by the + // inclusion of a Content-Length or Transfer-Encoding header field in + // the request's message-headers. + if (!empty($data)) { + $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); + } + } + + /** + * Download + * + * @param $url + * @param $mixed_filename + * @return bool + */ + public function download($url, $mixed_filename) + { + // Use tmpfile() or php://temp to avoid "Too many open files" error. + if (is_callable($mixed_filename)) { + $this->downloadCompleteCallback = $mixed_filename; + $this->downloadFileName = null; + $this->fileHandle = tmpfile(); + } else { + $filename = $mixed_filename; + + // Use a temporary file when downloading. Not using a temporary file can cause an error when an existing + // file has already fully completed downloading and a new download is started with the same destination save + // path. The download request will include header "Range: bytes=$filesize-" which is syntactically valid, + // but unsatisfiable. + $download_filename = $filename . '.pccdownload'; + $this->downloadFileName = $download_filename; + + // Attempt to resume download only when a temporary download file exists and is not empty. + if (is_file($download_filename) && $filesize = filesize($download_filename)) { + $first_byte_position = $filesize; + $range = (string)$first_byte_position . '-'; + $this->setRange($range); + $this->fileHandle = fopen($download_filename, 'ab'); + } else { + $this->fileHandle = fopen($download_filename, 'wb'); + } + + // Move the downloaded temporary file to the destination save path. + $this->downloadCompleteCallback = function ($instance, $fh) use ($download_filename, $filename) { + // Close the open file handle before renaming the file. + if (is_resource($fh)) { + fclose($fh); + } + + rename($download_filename, $filename); + }; + } + + $this->setFile($this->fileHandle); + $this->get($url); + + return ! $this->error; + } + + /** + * Fast download + * + * @param $url + * @param $filename + * @param $connections + * @return bool + */ + public function fastDownload($url, $filename, $connections = 4) + { + // Retrieve content length from the "Content-Length" header from the url + // to download. Use an HTTP GET request without a body instead of a HEAD + // request because not all hosts support HEAD requests. + $curl = new Curl(); + $curl->setOptInternal(CURLOPT_NOBODY, true); + + // Pass user-specified options to the instance checking for content-length. + $curl->setOpts($this->userSetOptions); + $curl->get($url); + + // Exit early when an error occurred. + if ($curl->error) { + return false; + } + + $content_length = $curl->responseHeaders['Content-Length'] ?? null; + + // Use a regular download when content length could not be determined. + if (!$content_length) { + return $this->download($url, $filename); + } + + // Divide chunk_size across the number of connections. + $chunk_size = (int)ceil($content_length / $connections); + + // Keep track of file name parts. + $part_file_names = []; + + $multi_curl = new MultiCurl(); + $multi_curl->setConcurrency($connections); + + for ($part_number = 1; $part_number <= $connections; $part_number++) { + $range_start = ($part_number - 1) * $chunk_size; + $range_end = $range_start + $chunk_size - 1; + if ($part_number === $connections) { + $range_end = ''; + } + $range = (string)$range_start . '-' . (string)$range_end; + + $part_file_name = $filename . '.part' . (string)$part_number; + + // Save the file name of this part. + $part_file_names[] = $part_file_name; + + // Remove any existing file part. + if (is_file($part_file_name)) { + unlink($part_file_name); + } + + // Create file part. + $file_handle = tmpfile(); + + // Setup the instance downloading a part. + $curl = new Curl(); + $curl->setUrl($url); + + // Pass user-specified options to the instance downloading a part. + $curl->setOpts($this->userSetOptions); + + $curl->setOptInternal(CURLOPT_CUSTOMREQUEST, 'GET'); + $curl->setOptInternal(CURLOPT_HTTPGET, true); + $curl->setRangeInternal($range); + $curl->setFileInternal($file_handle); + $curl->fileHandle = $file_handle; + + $curl->downloadCompleteCallback = function ($instance, $tmpfile) use ($part_file_name) { + $fh = fopen($part_file_name, 'wb'); + if ($fh !== false) { + stream_copy_to_stream($tmpfile, $fh); + fclose($fh); + } + }; + + $multi_curl->addCurl($curl); + } + + // Start the simultaneous downloads for each of the ranges in parallel. + $multi_curl->start(); + + // Remove existing download file name at destination. + if (is_file($filename)) { + unlink($filename); + } + + // Combine downloaded chunks into a single file. + $main_file_handle = fopen($filename, 'w'); + if ($main_file_handle === false) { + return false; + } + + foreach ($part_file_names as $part_file_name) { + if (!is_file($part_file_name)) { + return false; + } + + $file_handle = fopen($part_file_name, 'r'); + if ($file_handle === false) { + return false; + } + + stream_copy_to_stream($file_handle, $main_file_handle); + fclose($file_handle); + unlink($part_file_name); + } + + fclose($main_file_handle); + + return true; + } + + /** + * Exec + * + * @param $ch + * @return mixed Returns the value provided by parseResponse. + */ + public function exec($ch = null) + { + $this->attempts += 1; + + if ($this->jsonDecoder === null) { + $this->setDefaultJsonDecoder(); + } + if ($this->xmlDecoder === null) { + $this->setDefaultXmlDecoder(); + } + + if ($ch === null) { + $this->responseCookies = []; + $this->call($this->beforeSendCallback); + $this->rawResponse = curl_exec($this->curl); + $this->curlErrorCode = curl_errno($this->curl); + $this->curlErrorMessage = curl_error($this->curl); + } else { + $this->rawResponse = curl_multi_getcontent($ch); + $this->curlErrorMessage = curl_error($ch); + } + $this->curlError = $this->curlErrorCode !== 0; + + // Ensure Curl::rawResponse is a string as curl_exec() can return false. + // Without this, calling strlen($curl->rawResponse) will error when the + // strict types setting is enabled. + if (!is_string($this->rawResponse)) { + $this->rawResponse = ''; + } + + // Transfer the header callback data and release the temporary store to avoid memory leak. + $this->rawResponseHeaders = $this->headerCallbackData->rawResponseHeaders; + $this->responseCookies = $this->headerCallbackData->responseCookies; + $this->headerCallbackData->rawResponseHeaders = ''; + $this->headerCallbackData->responseCookies = []; + $this->headerCallbackData->stopRequestDecider = null; + $this->headerCallbackData->stopRequest = false; + + // Include additional error code information in error message when possible. + if ($this->curlError) { + $curl_error_message = curl_strerror($this->curlErrorCode); + + if (isset($this->curlErrorCodeConstant)) { + $curl_error_message .= ' (' . $this->curlErrorCodeConstant . ')'; + } + + if (!empty($this->curlErrorMessage)) { + $curl_error_message .= ': ' . $this->curlErrorMessage; + } + + $this->curlErrorMessage = $curl_error_message; + } + + // NOTE: CURLINFO_HEADER_OUT set to true is required for requestHeaders + // to not be empty (e.g. $curl->setOpt(CURLINFO_HEADER_OUT, true);). + if ($this->getOpt(CURLINFO_HEADER_OUT) === true) { + $this->requestHeaders = $this->parseRequestHeaders($this->getInfo(CURLINFO_HEADER_OUT)); + } + $this->responseHeaders = $this->parseResponseHeaders($this->rawResponseHeaders); + $this->response = $this->parseResponse($this->responseHeaders, $this->rawResponse); + + $this->httpStatusCode = $this->getInfo(CURLINFO_HTTP_CODE); + $this->httpError = in_array((int) floor($this->httpStatusCode / 100), [4, 5], true); + $this->error = $this->curlError || $this->httpError; + + $this->call($this->afterSendCallback); + + if (!in_array($this->error, [true, false], true)) { + trigger_error('$instance->error MUST be set to true or false', E_USER_WARNING); + } + + $this->errorCode = $this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0; + + $this->httpErrorMessage = ''; + if ($this->error) { + if (isset($this->responseHeaders['Status-Line'])) { + $this->httpErrorMessage = $this->responseHeaders['Status-Line']; + } + } + $this->errorMessage = $this->curlError ? $this->curlErrorMessage : $this->httpErrorMessage; + + // Reset select deferred properties so that they may be recalculated. + unset($this->deferredValues['curlErrorCodeConstant']); + unset($this->deferredValues['effectiveUrl']); + unset($this->deferredValues['totalTime']); + + // Reset content-length header possibly set from a PUT or SEARCH request. + $this->unsetHeader('Content-Length'); + + // Reset nobody setting possibly set from a HEAD request. + $this->setOptInternal(CURLOPT_NOBODY, false); + + // Allow multicurl to attempt retry as needed. + if ($this->isChildOfMultiCurl()) { + return; + } + + if ($this->attemptRetry()) { + return $this->exec($ch); + } + + $this->execDone(); + + return $this->response; + } + + public function execDone() + { + if ($this->error) { + $this->call($this->errorCallback); + } else { + $this->call($this->successCallback); + } + + $this->call($this->completeCallback); + + // Close open file handles and reset the curl instance. + if ($this->fileHandle !== null) { + $this->downloadComplete($this->fileHandle); + } + } + + /** + * Get + * + * @param $url + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function get($url, $data = []) + { + $this->setGet($url, $data); + return $this->exec(); + } + + public function setGet($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = (string)$this->url; + } + $this->setUrl($url, $data); + $this->setOptInternal(CURLOPT_CUSTOMREQUEST, 'GET'); + $this->setOptInternal(CURLOPT_HTTPGET, true); + } + + /** + * Get Info + * + * @param $opt + * @return mixed + */ + public function getInfo($opt = null) + { + $args = []; + $args[] = $this->curl; + + if (func_num_args()) { + $args[] = $opt; + } + + return call_user_func_array('curl_getinfo', $args); + } + + /** + * Head + * + * @param $url + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function head($url, $data = []) + { + $this->setHead($url, $data); + return $this->exec(); + } + + public function setHead($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = (string)$this->url; + } + $this->setUrl($url, $data); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'HEAD'); + $this->setOpt(CURLOPT_NOBODY, true); + } + + /** + * Options + * + * @param $url + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function options($url, $data = []) + { + $this->setOptions($url, $data); + return $this->exec(); + } + + public function setOptions($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = (string)$this->url; + } + $this->setUrl($url, $data); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'OPTIONS'); + } + + /** + * Patch + * + * @param $url + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function patch($url, $data = []) + { + $this->setPatch($url, $data); + return $this->exec(); + } + + public function setPatch($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = (string)$this->url; + } + + if (is_array($data) && empty($data)) { + $this->removeHeader('Content-Length'); + } + + $this->setUrl($url); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PATCH'); + $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); + } + + /** + * Post + * + * @param $url + * @param $data + * @param $follow_303_with_post + * If true, will cause 303 redirections to be followed using a POST request + * (default: false). + * Notes: + * - Redirections are only followed if the CURLOPT_FOLLOWLOCATION option is set + * to true. + * - According to the HTTP specs (see [1]), a 303 redirection should be followed + * using the GET method. 301 and 302 must not. + * - In order to force a 303 redirection to be performed using the same method, + * the underlying cURL object must be set in a special state (the + * CURLOPT_CUSTOMREQUEST option must be set to the method to use after the + * redirection). Due to a limitation of the cURL extension of PHP < 5.5.11 ([2], + * [3]), it is not possible to reset this option. Using these PHP engines, it is + * therefore impossible to restore this behavior on an existing php-curl-class + * Curl object. + * @return mixed Returns the value provided by exec. + * + * [1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2 + * [2] https://github.com/php/php-src/pull/531 + * [3] http://php.net/ChangeLog-5.php#5.5.11 + */ + public function post($url, $data = '', $follow_303_with_post = false) + { + $this->setPost($url, $data, $follow_303_with_post); + return $this->exec(); + } + + public function setPost($url, $data = '', $follow_303_with_post = false) + { + if (is_array($url)) { + $follow_303_with_post = (bool)$data; + $data = $url; + $url = (string)$this->url; + } + + $this->setUrl($url); + + // Set the request method to "POST" when following a 303 redirect with + // an additional POST request is desired. This is equivalent to setting + // the -X, --request command line option where curl won't change the + // request method according to the HTTP 30x response code. + if ($follow_303_with_post) { + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'POST'); + } elseif (isset($this->options[CURLOPT_CUSTOMREQUEST])) { + // Unset the CURLOPT_CUSTOMREQUEST option so that curl does not use + // a POST request after a post/redirect/get redirection. Without + // this, curl will use the method string specified for all requests. + $this->setOpt(CURLOPT_CUSTOMREQUEST, null); + } + + $this->setOpt(CURLOPT_POST, true); + $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); + } + + /** + * Put + * + * @param $url + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function put($url, $data = []) + { + $this->setPut($url, $data); + return $this->exec(); + } + + public function setPut($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = (string)$this->url; + } + $this->setUrl($url); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PUT'); + $put_data = $this->buildPostData($data); + if (empty($this->options[CURLOPT_INFILE]) && empty($this->options[CURLOPT_INFILESIZE])) { + if (is_string($put_data)) { + $this->setHeader('Content-Length', strlen($put_data)); + } + } + if (!empty($put_data)) { + $this->setOpt(CURLOPT_POSTFIELDS, $put_data); + } + } + + /** + * Search + * + * @param $url + * @param $data + * @return mixed Returns the value provided by exec. + */ + public function search($url, $data = []) + { + $this->setSearch($url, $data); + return $this->exec(); + } + + public function setSearch($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = (string)$this->url; + } + $this->setUrl($url); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'SEARCH'); + $put_data = $this->buildPostData($data); + if (empty($this->options[CURLOPT_INFILE]) && empty($this->options[CURLOPT_INFILESIZE])) { + if (is_string($put_data)) { + $this->setHeader('Content-Length', strlen($put_data)); + } + } + if (!empty($put_data)) { + $this->setOpt(CURLOPT_POSTFIELDS, $put_data); + } + } + + /** + * Set Cookie + * + * @param $key + * @param $value + */ + #[\Override] + public function setCookie($key, $value) + { + $this->setEncodedCookie($key, $value); + $this->buildCookies(); + } + + /** + * Set Cookies + * + * @param $cookies + */ + #[\Override] + public function setCookies($cookies) + { + foreach ($cookies as $key => $value) { + $this->setEncodedCookie($key, $value); + } + $this->buildCookies(); + } + + /** + * Get Cookie + * + * @param $key + * @return mixed + */ + public function getCookie($key) + { + return $this->getResponseCookie($key); + } + + /** + * Get Response Cookie + * + * @param $key + * @return mixed + */ + public function getResponseCookie($key) + { + return $this->responseCookies[$key] ?? null; + } + + /** + * Set Max Filesize + * + * @param $bytes + */ + public function setMaxFilesize($bytes) + { + $callback = function ($resource, $download_size, $downloaded, $upload_size, $uploaded) use ($bytes) { + // Abort the transfer when $downloaded bytes exceeds maximum $bytes by returning a non-zero value. + return $downloaded > $bytes ? 1 : 0; + }; + $this->progress($callback); + } + + /** + * Set Cookie String + * + * @param $string + * @return bool + */ + #[\Override] + public function setCookieString($string) + { + return $this->setOpt(CURLOPT_COOKIE, $string); + } + + /** + * Set Cookie File + * + * @param $cookie_file + * @return bool + */ + #[\Override] + public function setCookieFile($cookie_file) + { + return $this->setOpt(CURLOPT_COOKIEFILE, $cookie_file); + } + + /** + * Set Cookie Jar + * + * @param $cookie_jar + * @return bool + */ + #[\Override] + public function setCookieJar($cookie_jar) + { + return $this->setOpt(CURLOPT_COOKIEJAR, $cookie_jar); + } + + /** + * Set Default JSON Decoder + * + * @param $assoc + * @param $depth + * @param $options + */ + public function setDefaultJsonDecoder() + { + $this->jsonDecoder = '\Curl\Decoder::decodeJson'; + $this->jsonDecoderArgs = func_get_args(); + } + + /** + * Set Default XML Decoder + * + * @param $class_name + * @param $options + * @param $ns + * @param $is_prefix + */ + public function setDefaultXmlDecoder() + { + $this->xmlDecoder = '\Curl\Decoder::decodeXml'; + $this->xmlDecoderArgs = func_get_args(); + } + + /** + * Set Default Decoder + * + * @param $mixed boolean|callable|string + */ + public function setDefaultDecoder($mixed = 'json') + { + if ($mixed === false) { + $this->defaultDecoder = false; + } elseif ($mixed === 'json') { + $this->defaultDecoder = '\Curl\Decoder::decodeJson'; + } elseif ($mixed === 'xml') { + $this->defaultDecoder = '\Curl\Decoder::decodeXml'; + } elseif (is_callable($mixed)) { + $this->defaultDecoder = $mixed; + } + } + + /** + * Set Default Header Out + */ + public function setDefaultHeaderOut() + { + $this->setOpt(CURLINFO_HEADER_OUT, true); + } + + private function setDefaultHeaderOutInternal() + { + $this->setOptInternal(CURLINFO_HEADER_OUT, true); + } + + /** + * Set Default Timeout + */ + public function setDefaultTimeout() + { + $this->setTimeout(self::DEFAULT_TIMEOUT); + } + + private function setDefaultTimeoutInternal() + { + $this->setTimeoutInternal(self::DEFAULT_TIMEOUT); + } + + /** + * Set Default User Agent + */ + public function setDefaultUserAgent() + { + $this->setUserAgent($this->getDefaultUserAgent()); + } + + private function setDefaultUserAgentInternal() + { + $this->setUserAgentInternal($this->getDefaultUserAgent()); + } + + private function getDefaultUserAgent() + { + $user_agent = 'PHP-Curl-Class/' . self::VERSION . ' (+https://github.com/php-curl-class/php-curl-class)'; + $user_agent .= ' PHP/' . PHP_VERSION; + $curl_version = curl_version(); + $user_agent .= ' curl/' . $curl_version['version']; + return $user_agent; + } + + /** + * Set Header + * + * Add extra header to include in the request. + * + * @param $key + * @param $value + */ + #[\Override] + public function setHeader($key, $value) + { + $this->headers[$key] = $value; + $headers = []; + foreach ($this->headers as $key => $value) { + $headers[] = $key . ': ' . $value; + } + $this->setOpt(CURLOPT_HTTPHEADER, $headers); + } + + /** + * Set Headers + * + * Add extra headers to include in the request. + * + * @param $headers + */ + #[\Override] + public function setHeaders($headers) + { + if (ArrayUtil::isArrayAssoc($headers)) { + foreach ($headers as $key => $value) { + $key = trim($key); + $value = trim($value); + $this->headers[$key] = $value; + } + } else { + foreach ($headers as $header) { + list($key, $value) = array_pad(explode(':', $header, 2), 2, ''); + $key = trim($key); + $value = trim($value); + $this->headers[$key] = $value; + } + } + + $headers = []; + foreach ($this->headers as $key => $value) { + $headers[] = $key . ': ' . $value; + } + + $this->setOpt(CURLOPT_HTTPHEADER, $headers); + } + + /** + * Set JSON Decoder + * + * @param $mixed boolean|callable + */ + #[\Override] + public function setJsonDecoder($mixed) + { + if ($mixed === false || is_callable($mixed)) { + $this->jsonDecoder = $mixed; + $this->jsonDecoderArgs = []; + } + } + + /** + * Set XML Decoder + * + * @param $mixed boolean|callable + */ + #[\Override] + public function setXmlDecoder($mixed) + { + if ($mixed === false || is_callable($mixed)) { + $this->xmlDecoder = $mixed; + $this->xmlDecoderArgs = []; + } + } + + /** + * Set Opt + * + * @param $option + * @param $value + * @return bool + */ + #[\Override] + public function setOpt($option, $value) + { + $required_options = [ + CURLOPT_RETURNTRANSFER => 'CURLOPT_RETURNTRANSFER', + ]; + + if (in_array($option, array_keys($required_options), true) && $value !== true) { + trigger_error($required_options[$option] . ' is a required option', E_USER_WARNING); + } + + $success = curl_setopt($this->curl, $option, $value); + if ($success) { + $this->options[$option] = $value; + $this->userSetOptions[$option] = $value; + } + return $success; + } + + /** + * Set Opt Internal + * + * @param $option + * @param $value + * @return bool + */ + #[\Override] + protected function setOptInternal($option, $value) + { + $success = curl_setopt($this->curl, $option, $value); + if ($success) { + $this->options[$option] = $value; + } + return $success; + } + + /** + * Set Opts + * + * @param $options + * @return bool + * Returns true if all options were successfully set. If an + * option could not be successfully set, false is immediately + * returned, ignoring any future options in the options array. + * Similar to curl_setopt_array(). + */ + #[\Override] + public function setOpts($options) + { + if (!count($options)) { + return true; + } + foreach ($options as $option => $value) { + if (!$this->setOpt($option, $value)) { + return false; + } + } + return true; + } + + /** + * Set Protocols + * + * Limit what protocols libcurl will accept for a request. + * + * @param $protocols + * @see Curl::setRedirectProtocols() + */ + public function setProtocols($protocols) + { + $this->setOpt(CURLOPT_PROTOCOLS, $protocols); + } + + private function setProtocolsInternal($protocols) + { + $this->setOptInternal(CURLOPT_PROTOCOLS, $protocols); + } + + /** + * Set Retry + * + * Number of retries to attempt or decider callable. + * + * When using a number of retries to attempt, the maximum number of attempts + * for the request is $maximum_number_of_retries + 1. + * + * When using a callable decider, the request will be retried until the + * function returns a value which evaluates to false. + * + * @param $mixed + */ + #[\Override] + public function setRetry($mixed) + { + if (is_callable($mixed)) { + $this->retryDecider = $mixed; + } elseif (is_int($mixed)) { + $maximum_number_of_retries = $mixed; + $this->remainingRetries = $maximum_number_of_retries; + } + } + + /** + * Set Redirect Protocols + * + * Limit what protocols libcurl will accept when following a redirect. + * + * @param $redirect_protocols + * @see Curl::setProtocols() + */ + public function setRedirectProtocols($redirect_protocols) + { + $this->setOpt(CURLOPT_REDIR_PROTOCOLS, $redirect_protocols); + } + + private function setRedirectProtocolsInternal($redirect_protocols) + { + $this->setOptInternal(CURLOPT_REDIR_PROTOCOLS, $redirect_protocols); + } + + /** + * Set Url + * + * @param $url + * @param $mixed_data + */ + #[\Override] + public function setUrl($url, $mixed_data = '') + { + $built_url = Url::buildUrl($url, $mixed_data); + + if ($this->url === null) { + $this->url = (string)new Url($built_url); + } else { + $this->url = (string)new Url($this->url, $built_url); + } + + $this->setOpt(CURLOPT_URL, $this->url); + } + + /** + * Attempt Retry + */ + public function attemptRetry() + { + $attempt_retry = false; + if ($this->error) { + if ($this->retryDecider === null) { + $attempt_retry = $this->remainingRetries >= 1; + } else { + $attempt_retry = call_user_func($this->retryDecider, $this); + } + if ($attempt_retry) { + $this->retries += 1; + if ($this->remainingRetries) { + $this->remainingRetries -= 1; + } + } + } + return $attempt_retry; + } + + /** + * Unset Header + * + * Remove extra header previously set using Curl::setHeader(). + * + * @param $key + */ + #[\Override] + public function unsetHeader($key) + { + unset($this->headers[$key]); + $headers = []; + foreach ($this->headers as $key => $value) { + $headers[] = $key . ': ' . $value; + } + $this->setOpt(CURLOPT_HTTPHEADER, $headers); + } + + /** + * Diagnose + * + * @param bool $return + */ + public function diagnose($return = false) + { + if ($return) { + ob_start(); + } + + echo "\n"; + echo '--- Begin PHP Curl Class diagnostic output ---' . "\n"; + echo 'PHP Curl Class version: ' . self::VERSION . "\n"; + echo 'PHP version: ' . PHP_VERSION . "\n"; + + $curl_version = curl_version(); + echo 'Curl version: ' . $curl_version['version'] . "\n"; + + if ($this->attempts === 0) { + echo 'No HTTP requests have been made.' . "\n"; + } else { + $request_types = [ + 'DELETE' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'DELETE', + 'GET' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'GET' || $this->getOpt(CURLOPT_HTTPGET), + 'HEAD' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'HEAD', + 'OPTIONS' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'OPTIONS', + 'PATCH' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'PATCH', + 'POST' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'POST' || $this->getOpt(CURLOPT_POST), + 'PUT' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'PUT', + 'SEARCH' => $this->getOpt(CURLOPT_CUSTOMREQUEST) === 'SEARCH', + ]; + $request_method = ''; + foreach ($request_types as $http_method_name => $http_method_used) { + if ($http_method_used) { + $request_method = $http_method_name; + break; + } + } + $request_url = $this->getOpt(CURLOPT_URL); + $request_options_count = count($this->options); + $request_headers_count = count($this->requestHeaders); + $request_body_empty = empty($this->getOpt(CURLOPT_POSTFIELDS)); + $response_header_length = $this->responseHeaders['Content-Length'] ?? '(not specified in response header)'; + $response_calculated_length = is_string($this->rawResponse) ? + strlen($this->rawResponse) : '(' . var_export($this->rawResponse, true) . ')'; + $response_headers_count = count($this->responseHeaders); + + echo + 'Request contained ' . (string)$request_options_count . ' ' . ( + $request_options_count === 1 ? 'option:' : 'options:' + ) . "\n"; + if ($request_options_count) { + $i = 1; + foreach ($this->options as $option => $value) { + echo ' ' . (string)$i . ' '; + $this->displayCurlOptionValue($option, $value); + $i += 1; + } + } + + echo + 'Sent an HTTP ' . $request_method . ' request to "' . $request_url . '".' . "\n" . + 'Request contained ' . (string)$request_headers_count . ' ' . ( + $request_headers_count === 1 ? 'header:' : 'headers:' + ) . "\n"; + if ($request_headers_count) { + $i = 1; + foreach ($this->requestHeaders as $key => $value) { + echo ' ' . (string)$i . ' ' . $key . ': ' . $value . "\n"; + $i += 1; + } + } + + echo 'Request contained ' . ($request_body_empty ? 'no body' : 'a body') . '.' . "\n"; + + if ( + $request_headers_count === 0 && ( + $this->getOpt(CURLOPT_VERBOSE) || + !$this->getOpt(CURLINFO_HEADER_OUT) + ) + ) { + echo + 'Warning: Request headers (Curl::requestHeaders) are expected to be empty ' . + '(CURLOPT_VERBOSE was enabled or CURLINFO_HEADER_OUT was disabled).' . "\n"; + } + + if (isset($this->responseHeaders['allow'])) { + $allowed_request_types = array_map(function ($v) { + return trim($v); + }, explode(',', strtoupper($this->responseHeaders['allow']))); + foreach ($request_types as $http_method_name => $http_method_used) { + if ($http_method_used && !in_array($http_method_name, $allowed_request_types, true)) { + echo + 'Warning: An HTTP ' . $http_method_name . ' request was made, but only the following ' . + 'request types are allowed: ' . implode(', ', $allowed_request_types) . "\n"; + } + } + } + + echo + 'Response contains ' . (string)$response_headers_count . ' ' . ( + $response_headers_count === 1 ? 'header:' : 'headers:' + ) . "\n"; + if ($this->responseHeaders !== null) { + $i = 1; + foreach ($this->responseHeaders as $key => $value) { + echo ' ' . (string)$i . ' ' . $key . ': ' . $value . "\n"; + $i += 1; + } + } + + if (!isset($this->responseHeaders['Content-Type'])) { + echo 'Response did not set a content type.' . "\n"; + } elseif (preg_match($this->jsonPattern, $this->responseHeaders['Content-Type'])) { + echo 'Response appears to be JSON.' . "\n"; + } elseif (preg_match($this->xmlPattern, $this->responseHeaders['Content-Type'])) { + echo 'Response appears to be XML.' . "\n"; + } + + if ($this->curlError) { + echo + 'A curl error (' . $this->curlErrorCode . ') occurred ' . + 'with message "' . $this->curlErrorMessage . '".' . "\n"; + } + if (!empty($this->httpStatusCode)) { + echo 'Received an HTTP status code of ' . $this->httpStatusCode . '.' . "\n"; + } + if ($this->httpError) { + echo + 'Received an HTTP ' . $this->httpStatusCode . ' error response ' . + 'with message "' . $this->httpErrorMessage . '".' . "\n"; + } + + if ($this->rawResponse === null) { + echo 'Received no response body (response=null).' . "\n"; + } elseif ($this->rawResponse === '') { + echo 'Received an empty response body (response="").' . "\n"; + } else { + echo 'Received a non-empty response body.' . "\n"; + if (isset($this->responseHeaders['Content-Length'])) { + echo 'Response content length (from content-length header): ' . $response_header_length . "\n"; + } else { + echo 'Response content length (calculated): ' . (string)$response_calculated_length . "\n"; + } + + if ( + isset($this->responseHeaders['Content-Type']) && + preg_match($this->jsonPattern, $this->responseHeaders['Content-Type']) + ) { + $parsed_response = json_decode($this->rawResponse, true); + if ($parsed_response !== null) { + $messages = []; + array_walk_recursive($parsed_response, function ($value, $key) use (&$messages) { + if (in_array($key, ['code', 'error', 'message'], true)) { + $message = $key . ': ' . $value; + $messages[] = $message; + } + }); + $messages = array_unique($messages); + + $messages_count = count($messages); + if ($messages_count) { + echo + 'Found ' . (string)$messages_count . ' ' . + ($messages_count === 1 ? 'message' : 'messages') . + ' in response:' . "\n"; + + $i = 1; + foreach ($messages as $message) { + echo ' ' . (string)$i . ' ' . $message . "\n"; + $i += 1; + } + } + } + } + } + } + + echo '--- End PHP Curl Class diagnostic output ---' . "\n"; + echo "\n"; + + if ($return) { + $output = ob_get_contents(); + ob_end_clean(); + return $output; + } + } + + /** + * Reset + */ + public function reset() + { + if (is_resource($this->curl) || $this->curl instanceof \CurlHandle) { + curl_reset($this->curl); + } else { + $this->curl = curl_init(); + } + + $this->setDefaultUserAgentInternal(); + $this->setDefaultTimeoutInternal(); + $this->setDefaultHeaderOutInternal(); + + $this->initialize(); + } + + public function getCurl() + { + return $this->curl; + } + + public function getId() + { + return $this->id; + } + + public function isError() + { + return $this->error; + } + + public function getErrorCode() + { + return $this->errorCode; + } + + public function getErrorMessage() + { + return $this->errorMessage; + } + + public function isCurlError() + { + return $this->curlError; + } + + public function getCurlErrorCode() + { + return $this->curlErrorCode; + } + + public function getCurlErrorMessage() + { + return $this->curlErrorMessage; + } + + public function isHttpError() + { + return $this->httpError; + } + + public function getHttpStatusCode() + { + return $this->httpStatusCode; + } + + public function getHttpErrorMessage() + { + return $this->httpErrorMessage; + } + + public function getUrl() + { + return $this->url; + } + + public function getOptions() + { + return $this->options; + } + + public function getUserSetOptions() + { + return $this->userSetOptions; + } + + public function getRequestHeaders() + { + return $this->requestHeaders; + } + + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + public function getRawResponseHeaders() + { + return $this->rawResponseHeaders; + } + + public function getResponseCookies() + { + return $this->responseCookies; + } + + public function getResponse() + { + return $this->response; + } + + public function getRawResponse() + { + return $this->rawResponse; + } + + public function getBeforeSendCallback() + { + return $this->beforeSendCallback; + } + + public function getDownloadCompleteCallback() + { + return $this->downloadCompleteCallback; + } + + public function getDownloadFileName() + { + return $this->downloadFileName; + } + + public function getSuccessCallback() + { + return $this->successCallback; + } + + public function getErrorCallback() + { + return $this->errorCallback; + } + + public function getCompleteCallback() + { + return $this->completeCallback; + } + + public function getFileHandle() + { + return $this->fileHandle; + } + + public function getAttempts() + { + return $this->attempts; + } + + public function getRetries() + { + return $this->retries; + } + + public function isChildOfMultiCurl() + { + return $this->childOfMultiCurl; + } + + public function getRemainingRetries() + { + return $this->remainingRetries; + } + + public function getRetryDecider() + { + return $this->retryDecider; + } + + public function getJsonDecoder() + { + return $this->jsonDecoder; + } + + public function getXmlDecoder() + { + return $this->xmlDecoder; + } + + /** + * Destruct + */ + public function __destruct() + { + $this->close(); + } + + public function __get($name) + { + if (in_array($name, self::$deferredProperties, true)) { + if (isset($this->deferredValues[$name])) { + return $this->deferredValues[$name]; + } elseif (is_callable([$this, $getter = 'get' . ucfirst($name)])) { + $this->deferredValues[$name] = $this->$getter(); + return $this->deferredValues[$name]; + } + } + + return null; + } + + public function __isset($name) + { + if (in_array($name, self::$deferredProperties, true)) { + if (isset($this->deferredValues[$name])) { + return true; + } elseif (is_callable([$this, $getter = 'get' . ucfirst($name)])) { + $this->deferredValues[$name] = $this->$getter(); + return true; + } else { + return false; + } + } + + return isset($this->$name); + } + + /** + * Get Curl Error Code Constants + */ + private function getCurlErrorCodeConstants() + { + $constants = get_defined_constants(true); + $filtered_array = array_filter( + $constants['curl'], + function ($key) { + return strpos($key, 'CURLE_') !== false; + }, + ARRAY_FILTER_USE_KEY + ); + $curl_const_by_code = array_flip($filtered_array); + return $curl_const_by_code; + } + + /** + * Get Curl Error Code Constant + */ + private function getCurlErrorCodeConstant() + { + $curl_const_by_code = $this->curlErrorCodeConstants ?? []; + if (isset($curl_const_by_code[$this->curlErrorCode])) { + return $curl_const_by_code[$this->curlErrorCode]; + } + return ''; + } + + /** + * Get Curl Option Code Constants + */ + private function getCurlOptionCodeConstants() + { + $constants = get_defined_constants(true); + $filtered_array = array_filter( + $constants['curl'], + function ($key) { + return strpos($key, 'CURLOPT_') !== false; + }, + ARRAY_FILTER_USE_KEY + ); + $curl_const_by_code = array_flip($filtered_array); + + if (!isset($curl_const_by_code[CURLINFO_HEADER_OUT])) { + $curl_const_by_code[CURLINFO_HEADER_OUT] = 'CURLINFO_HEADER_OUT'; + } + + return $curl_const_by_code; + } + + /** + * Display Curl Option Value. + * + * @param $option + * @param $value + */ + public function displayCurlOptionValue($option, $value = null) + { + if ($value === null) { + $value = $this->getOpt($option); + } + + if (isset($this->curlOptionCodeConstants[$option])) { + echo $this->curlOptionCodeConstants[$option] . ':'; + } else { + echo $option . ':'; + } + + if (is_string($value)) { + echo ' "' . $value . '"' . "\n"; + } elseif (is_int($value)) { + echo ' ' . (string)$value; + + $bit_flag_lookups = [ + 'CURLOPT_HTTPAUTH' => 'CURLAUTH_', + 'CURLOPT_PROTOCOLS' => 'CURLPROTO_', + 'CURLOPT_PROXYAUTH' => 'CURLAUTH_', + 'CURLOPT_PROXY_SSL_OPTIONS' => 'CURLSSLOPT_', + 'CURLOPT_REDIR_PROTOCOLS' => 'CURLPROTO_', + 'CURLOPT_SSH_AUTH_TYPES' => 'CURLSSH_AUTH_', + 'CURLOPT_SSL_OPTIONS' => 'CURLSSLOPT_', + ]; + if (isset($this->curlOptionCodeConstants[$option])) { + $option_name = $this->curlOptionCodeConstants[$option]; + if (in_array($option_name, array_keys($bit_flag_lookups), true)) { + $curl_const_prefix = $bit_flag_lookups[$option_name]; + $constants = get_defined_constants(true); + $curl_constants = array_filter( + $constants['curl'], + function ($key) use ($curl_const_prefix) { + return strpos($key, $curl_const_prefix) !== false; + }, + ARRAY_FILTER_USE_KEY + ); + + $bit_flags = []; + foreach ($curl_constants as $const_name => $const_value) { + // Attempt to detect bit flags in use that use constants with negative values (e.g. + // CURLAUTH_ANY, CURLAUTH_ANYSAFE, CURLPROTO_ALL, CURLSSH_AUTH_ANY, + // CURLSSH_AUTH_DEFAULT, etc.) + if ($value < 0 && $value === $const_value) { + $bit_flags[] = $const_name; + break; + } elseif ($value >= 0 && $const_value >= 0 && ($value & $const_value)) { + $bit_flags[] = $const_name; + } + } + + if (count($bit_flags)) { + asort($bit_flags); + echo ' (' . implode(' | ', $bit_flags) . ')'; + } + } + } + + echo "\n"; + } elseif (is_bool($value)) { + echo ' ' . ($value ? 'true' : 'false') . "\n"; + } elseif (is_array($value)) { + echo ' '; + var_dump($value); + } elseif (is_callable($value)) { + echo ' (callable)' . "\n"; + } else { + echo ' ' . gettype($value) . ':' . "\n"; + var_dump($value); + } + } + + /** + * Get Effective Url + */ + private function getEffectiveUrl() + { + return $this->getInfo(CURLINFO_EFFECTIVE_URL); + } + + /** + * Get RFC 2616 + */ + private function getRfc2616() + { + return array_fill_keys(self::$RFC2616, true); + } + + /** + * Get RFC 6265 + */ + private function getRfc6265() + { + return array_fill_keys(self::$RFC6265, true); + } + + /** + * Get Total Time + */ + private function getTotalTime() + { + return $this->getInfo(CURLINFO_TOTAL_TIME); + } + + /** + * Build Cookies + */ + private function buildCookies() + { + // Avoid changing CURLOPT_COOKIE if there are no cookies set. + if (count($this->cookies)) { + // Avoid using http_build_query() as unnecessary encoding is performed. + // http_build_query($this->cookies, '', '; '); + $cookies = []; + foreach ($this->cookies as $key => $value) { + $cookies[] = $key . '=' . $value; + } + $this->setOpt(CURLOPT_COOKIE, implode('; ', $cookies)); + } + } + + /** + * Download Complete + * + * @param $fh + */ + private function downloadComplete($fh) + { + if ($this->error && is_file((string) $this->downloadFileName)) { + @unlink($this->downloadFileName); + } elseif (!$this->error && $this->downloadCompleteCallback) { + rewind($fh); + $this->call($this->downloadCompleteCallback, $fh); + $this->downloadCompleteCallback = null; + } + + if (is_resource($fh)) { + fclose($fh); + } + + // Fix "PHP Notice: Use of undefined constant STDOUT" when reading the + // PHP script from stdin. Using null causes "Warning: curl_setopt(): + // supplied argument is not a valid File-Handle resource". + if (defined('STDOUT')) { + $output = STDOUT; + } else { + $output = fopen('php://stdout', 'w'); + } + + // Reset CURLOPT_FILE with STDOUT to avoid: "curl_exec(): CURLOPT_FILE + // resource has gone away, resetting to default". + $this->setFile($output); + + // Reset CURLOPT_RETURNTRANSFER to tell cURL to return subsequent + // responses as the return value of curl_exec(). Without this, + // curl_exec() will revert to returning boolean values. + $this->setOpt(CURLOPT_RETURNTRANSFER, true); + } + + /** + * Parse Headers + * + * @param $raw_headers + * @return array + */ + private function parseHeaders($raw_headers) + { + $http_headers = new CaseInsensitiveArray(); + $raw_headers = preg_split('/\r\n/', (string) $raw_headers, -1, PREG_SPLIT_NO_EMPTY); + if ($raw_headers === false) { + return ['', $http_headers]; + } + + $raw_headers_count = count($raw_headers); + for ($i = 1; $i < $raw_headers_count; $i++) { + if (strpos($raw_headers[$i], ':') !== false) { + list($key, $value) = array_pad(explode(':', $raw_headers[$i], 2), 2, ''); + $key = trim($key); + $value = trim($value); + // Use isset() as array_key_exists() and ArrayAccess are not compatible. + if (isset($http_headers[$key])) { + $http_headers[$key] .= ',' . $value; + } else { + $http_headers[$key] = $value; + } + } + } + + return [$raw_headers['0'] ?? '', $http_headers]; + } + + /** + * Parse Request Headers + * + * @param $raw_headers + * @return \Curl\CaseInsensitiveArray + */ + private function parseRequestHeaders($raw_headers) + { + $request_headers = new CaseInsensitiveArray(); + list($first_line, $headers) = $this->parseHeaders($raw_headers); + $request_headers['Request-Line'] = $first_line; + foreach ($headers as $key => $value) { + $request_headers[$key] = $value; + } + return $request_headers; + } + + /** + * Parse Response + * + * @param $response_headers + * @param $raw_response + * @return mixed + * If the response content-type is json: Returns the json decoder's return value: A stdClass object + * when the default json decoder is used. + * + * If the response content-type is xml: Returns the xml decoder's return value: A SimpleXMLElement + * object when the default xml decoder is used. + * + * If the response content-type is something else: Returns the original raw response unless a default + * decoder has been set. + * + * If the response content-type cannot be determined: Returns the original raw response. + * + * If the response content-encoding is gzip: Returns the response gzip-decoded. + */ + private function parseResponse($response_headers, $raw_response) + { + $response = $raw_response; + if (isset($response_headers['Content-Type'])) { + if (preg_match($this->jsonPattern, $response_headers['Content-Type'])) { + if ($this->jsonDecoder) { + $args = $this->jsonDecoderArgs; + array_unshift($args, $response); + $response = call_user_func_array($this->jsonDecoder, $args); + } + } elseif (preg_match($this->xmlPattern, $response_headers['Content-Type'])) { + if ($this->xmlDecoder) { + $args = $this->xmlDecoderArgs; + array_unshift($args, $response); + $response = call_user_func_array($this->xmlDecoder, $args); + } + } else { + if ($this->defaultDecoder) { + $response = call_user_func($this->defaultDecoder, $response); + } + } + } + + if ( + ( + // Ensure that the server says the response is compressed with + // gzip and the response has not already been decoded. Use + // is_string() to ensure that $response is a string being passed + // to mb_strpos() and gzdecode(). Use extension_loaded() to + // ensure that mb_strpos() uses the mbstring extension and not a + // polyfill. + isset($response_headers['Content-Encoding']) && + $response_headers['Content-Encoding'] === 'gzip' && + is_string($response) && + ( + ( + extension_loaded('mbstring') && + mb_strpos($response, "\x1f" . "\x8b" . "\x08", 0, 'US-ASCII') === 0 + ) || + !extension_loaded('mbstring') + ) + ) || ( + // Or ensure that the response looks like it is compressed with + // gzip. Use is_string() to ensure that $response is a string + // being passed to mb_strpos() and gzdecode(). Use + // extension_loaded() to ensure that mb_strpos() uses the + // mbstring extension and not a polyfill. + is_string($response) && + extension_loaded('mbstring') && + mb_strpos($response, "\x1f" . "\x8b" . "\x08", 0, 'US-ASCII') === 0 + ) + ) { + // Use @ to suppress message "Warning gzdecode(): data error". + $decoded_response = @gzdecode($response); + if ($decoded_response !== false) { + $response = $decoded_response; + } + } + + return $response; + } + + /** + * Parse Response Headers + * + * @param $raw_response_headers + * @return \Curl\CaseInsensitiveArray + */ + private function parseResponseHeaders($raw_response_headers) + { + $response_header_array = explode("\r\n\r\n", $raw_response_headers); + $response_header = ''; + for ($i = count($response_header_array) - 1; $i >= 0; $i--) { + if (isset($response_header_array[$i]) && stripos($response_header_array[$i], 'HTTP/') === 0) { + $response_header = $response_header_array[$i]; + break; + } + } + + $response_headers = new CaseInsensitiveArray(); + list($first_line, $headers) = $this->parseHeaders($response_header); + $response_headers['Status-Line'] = $first_line; + foreach ($headers as $key => $value) { + $response_headers[$key] = $value; + } + return $response_headers; + } + + /** + * Set Encoded Cookie + * + * @param $key + * @param $value + */ + private function setEncodedCookie($key, $value) + { + $name_chars = []; + foreach (str_split($key) as $name_char) { + if (isset($this->rfc2616[$name_char])) { + $name_chars[] = $name_char; + } else { + $name_chars[] = rawurlencode($name_char); + } + } + + $value_chars = []; + foreach (str_split($value) as $value_char) { + if (isset($this->rfc6265[$value_char])) { + $value_chars[] = $value_char; + } else { + $value_chars[] = rawurlencode($value_char); + } + } + + $this->cookies[implode('', $name_chars)] = implode('', $value_chars); + } + + /** + * Initialize + * + * @param $base_url + * @param mixed $options + */ + private function initialize($base_url = null, $options = []) + { + $this->setProtocolsInternal(CURLPROTO_HTTPS | CURLPROTO_HTTP); + $this->setRedirectProtocolsInternal(CURLPROTO_HTTPS | CURLPROTO_HTTP); + + if (isset($options)) { + $this->setOpts($options); + } + + $this->id = bin2hex(random_bytes(16)); + + // Only set default user agent if not already set. + if (!array_key_exists(CURLOPT_USERAGENT, $this->options)) { + $this->setDefaultUserAgentInternal(); + } + + // Only set default timeout if not already set. + if (!array_key_exists(CURLOPT_TIMEOUT, $this->options)) { + $this->setDefaultTimeoutInternal(); + } + + if (!array_key_exists(CURLINFO_HEADER_OUT, $this->options)) { + $this->setDefaultHeaderOutInternal(); + } + + // Create a placeholder to temporarily store the header callback data. + $header_callback_data = new \stdClass(); + $header_callback_data->rawResponseHeaders = ''; + $header_callback_data->responseCookies = []; + $header_callback_data->stopRequestDecider = null; + $header_callback_data->stopRequest = false; + $this->headerCallbackData = $header_callback_data; + $this->setStopInternal(); + $this->setOptInternal(CURLOPT_HEADERFUNCTION, createHeaderCallback($header_callback_data)); + + $this->setOptInternal(CURLOPT_RETURNTRANSFER, true); + $this->headers = new CaseInsensitiveArray(); + + if ($base_url !== null) { + $this->setUrl($base_url); + } + } + + /** + * Set Stop + * + * Specify a callable decider to stop the request early without waiting for + * the full response to be received. + * + * The callable is passed two parameters. The first is the cURL resource, + * the second is a string with header data. Both parameters match the + * parameters in the CURLOPT_HEADERFUNCTION callback. + * + * The callable must return a truthy value for the request to be stopped + * early. + * + * The callable may be set to null to avoid calling the stop request decider + * callback and instead just check the value of stopRequest for attempting + * to stop the request as used by Curl::stop(). + * + * @param $callback callable|null + */ + public function setStop($callback = null) + { + $this->headerCallbackData->stopRequestDecider = $callback; + $this->headerCallbackData->stopRequest = false; + + $header_callback_data = $this->headerCallbackData; + $this->progress(createStopRequestFunction($header_callback_data)); + } + + private function setStopInternal($callback = null) + { + $this->headerCallbackData->stopRequestDecider = $callback; + $this->headerCallbackData->stopRequest = false; + + $header_callback_data = $this->headerCallbackData; + $this->progressInternal(createStopRequestFunction($header_callback_data)); + } + + /** + * Stop + * + * Attempt to stop request. + * + * Used by MultiCurl::stop() when making multiple parallel requests. + */ + #[\Override] + public function stop() + { + $this->headerCallbackData->stopRequest = true; + } +} + +/** + * Create Header Callback + * + * Gather headers and parse cookies as response headers are received. Keep this function separate from the class so that + * unset($curl) automatically calls __destruct() as expected. Otherwise, manually calling $curl->close() will be + * necessary to prevent a memory leak. + * + * @param $header_callback_data + * @return callable + */ +function createHeaderCallback($header_callback_data) +{ + return function ($ch, $header) use ($header_callback_data) { + if (preg_match('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi', $header, $cookie) === 1) { + $header_callback_data->responseCookies[$cookie[1]] = trim($cookie[2], " \n\r\t\0\x0B"); + } + + if ($header_callback_data->stopRequestDecider !== null) { + $stop_request_decider = $header_callback_data->stopRequestDecider; + if ($stop_request_decider($ch, $header)) { + $header_callback_data->stopRequest = true; + } + } + + $header_callback_data->rawResponseHeaders .= $header; + return strlen($header); + }; +} + +/** + * Create Stop Request Function + * + * Create a function for Curl::progress() that stops a request early when the + * stopRequest flag is on. Keep this function separate from the class to prevent + * a memory leak. + * + * @param $header_callback_data + * @return callable + */ +function createStopRequestFunction($header_callback_data) +{ + return function ( + $resource, + $download_size, + $downloaded, + $upload_size, + $uploaded + ) use ( + $header_callback_data + ) { + // Abort the transfer when the stop request flag has been set by returning a non-zero value. + return $header_callback_data->stopRequest ? 1 : 0; + }; +} diff --git a/vendor/php-curl-class/php-curl-class/src/Curl/Decoder.php b/vendor/php-curl-class/php-curl-class/src/Curl/Decoder.php new file mode 100644 index 0000000..b2aa041 --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/src/Curl/Decoder.php @@ -0,0 +1,45 @@ +multiCurl = curl_multi_init(); + $this->headers = new CaseInsensitiveArray(); + + if ($base_url !== null) { + $this->setUrl($base_url); + } + } + + /** + * Add Delete + * + * @param $url + * @param $query_parameters + * @param $data + * @return object + */ + public function addDelete($url, $query_parameters = [], $data = []) + { + if (is_array($url)) { + $data = $query_parameters; + $query_parameters = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url, $query_parameters); + $curl->setUrl($url, $query_parameters); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE'); + $curl->setOpt(CURLOPT_POSTFIELDS, $curl->buildPostData($data)); + return $curl; + } + + /** + * Add Download + * + * @param $url + * @param $mixed_filename + * @return object + */ + public function addDownload($url, $mixed_filename) + { + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url); + $curl->setUrl($url); + + // Use tmpfile() or php://temp to avoid "Too many open files" error. + if (is_callable($mixed_filename)) { + $curl->downloadCompleteCallback = $mixed_filename; + $curl->downloadFileName = null; + $curl->fileHandle = tmpfile(); + } else { + $filename = $mixed_filename; + + // Use a temporary file when downloading. Not using a temporary file can cause an error when an existing + // file has already fully completed downloading and a new download is started with the same destination save + // path. The download request will include header "Range: bytes=$filesize-" which is syntactically valid, + // but unsatisfiable. + $download_filename = $filename . '.pccdownload'; + $curl->downloadFileName = $download_filename; + + // Attempt to resume download only when a temporary download file exists and is not empty. + if (is_file($download_filename) && $filesize = filesize($download_filename)) { + $first_byte_position = $filesize; + $range = (string)$first_byte_position . '-'; + $curl->setRange($range); + $curl->fileHandle = fopen($download_filename, 'ab'); + + // Move the downloaded temporary file to the destination save path. + $curl->downloadCompleteCallback = function ($instance, $fh) use ($download_filename, $filename) { + // Close the open file handle before renaming the file. + if (is_resource($fh)) { + fclose($fh); + } + + rename($download_filename, $filename); + }; + } else { + $curl->fileHandle = fopen('php://temp', 'wb'); + $curl->downloadCompleteCallback = function ($instance, $fh) use ($filename) { + $contents = stream_get_contents($fh); + if ($contents !== false) { + file_put_contents($filename, $contents); + } + }; + } + } + + $curl->setFile($curl->fileHandle); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET'); + $curl->setOpt(CURLOPT_HTTPGET, true); + return $curl; + } + + /** + * Add Get + * + * @param $url + * @param $data + * @return object + */ + public function addGet($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url, $data); + $curl->setUrl($url, $data); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET'); + $curl->setOpt(CURLOPT_HTTPGET, true); + return $curl; + } + + /** + * Add Head + * + * @param $url + * @param $data + * @return object + */ + public function addHead($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url, $data); + $curl->setUrl($url, $data); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'HEAD'); + $curl->setOpt(CURLOPT_NOBODY, true); + return $curl; + } + + /** + * Add Options + * + * @param $url + * @param $data + * @return object + */ + public function addOptions($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url, $data); + $curl->setUrl($url, $data); + $curl->removeHeader('Content-Length'); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'OPTIONS'); + return $curl; + } + + /** + * Add Patch + * + * @param $url + * @param $data + * @return object + */ + public function addPatch($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + + if (is_array($data) && empty($data)) { + $curl->removeHeader('Content-Length'); + } + + $this->queueHandle($curl); + $this->setUrl($url); + $curl->setUrl($url); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'PATCH'); + $curl->setOpt(CURLOPT_POSTFIELDS, $curl->buildPostData($data)); + return $curl; + } + + /** + * Add Post + * + * @param $url + * @param $data + * @param $follow_303_with_post + * If true, will cause 303 redirections to be followed using a POST request + * (default: false). Note: Redirections are only followed if the + * CURLOPT_FOLLOWLOCATION option is set to true. + * @return object + */ + public function addPost($url, $data = '', $follow_303_with_post = false) + { + if (is_array($url)) { + $follow_303_with_post = (bool)$data; + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url); + + if (is_array($data) && empty($data)) { + $curl->removeHeader('Content-Length'); + } + + $curl->setUrl($url); + + // Set the request method to "POST" when following a 303 redirect with + // an additional POST request is desired. This is equivalent to setting + // the -X, --request command line option where curl won't change the + // request method according to the HTTP 30x response code. + if ($follow_303_with_post) { + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'POST'); + } + + $curl->setOpt(CURLOPT_POST, true); + $curl->setOpt(CURLOPT_POSTFIELDS, $curl->buildPostData($data)); + return $curl; + } + + /** + * Add Put + * + * @param $url + * @param $data + * @return object + */ + public function addPut($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url); + $curl->setUrl($url); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'PUT'); + $put_data = $curl->buildPostData($data); + if (is_string($put_data)) { + $curl->setHeader('Content-Length', strlen($put_data)); + } + $curl->setOpt(CURLOPT_POSTFIELDS, $put_data); + return $curl; + } + + /** + * Add Search + * + * @param $url + * @param $data + * @return object + */ + public function addSearch($url, $data = []) + { + if (is_array($url)) { + $data = $url; + $url = $this->baseUrl; + } + + $curl = new Curl($this->baseUrl, $this->options); + $this->queueHandle($curl); + $this->setUrl($url); + $curl->setUrl($url); + $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'SEARCH'); + $put_data = $curl->buildPostData($data); + if (is_string($put_data)) { + $curl->setHeader('Content-Length', strlen($put_data)); + } + $curl->setOpt(CURLOPT_POSTFIELDS, $put_data); + return $curl; + } + + /** + * Add Curl + * + * Add a Curl instance to the handle queue. + * + * @param $curl + * @return object + */ + public function addCurl(Curl $curl) + { + $this->queueHandle($curl); + return $curl; + } + + /** + * Close + */ + #[\Override] + public function close() + { + foreach ($this->queuedCurls as $curl) { + $curl->close(); + } + + if (is_resource($this->multiCurl) || $this->multiCurl instanceof \CurlMultiHandle) { + curl_multi_close($this->multiCurl); + } + $this->multiCurl = null; + } + + /** + * Set Concurrency + * + * @param $concurrency + */ + public function setConcurrency($concurrency) + { + $this->concurrency = $concurrency; + } + + /** + * Set Cookie + * + * @param $key + * @param $value + */ + #[\Override] + public function setCookie($key, $value) + { + $this->cookies[$key] = $value; + } + + /** + * Set Cookies + * + * @param $cookies + */ + #[\Override] + public function setCookies($cookies) + { + foreach ($cookies as $key => $value) { + $this->cookies[$key] = $value; + } + } + + /** + * Set Cookie String + * + * @param $string + */ + #[\Override] + public function setCookieString($string) + { + $this->setOpt(CURLOPT_COOKIE, $string); + } + + /** + * Set Cookie File + * + * @param $cookie_file + */ + #[\Override] + public function setCookieFile($cookie_file) + { + $this->setOpt(CURLOPT_COOKIEFILE, $cookie_file); + } + + /** + * Set Cookie Jar + * + * @param $cookie_jar + */ + #[\Override] + public function setCookieJar($cookie_jar) + { + $this->setOpt(CURLOPT_COOKIEJAR, $cookie_jar); + } + + /** + * Set Header + * + * Add extra header to include in the request. + * + * @param $key + * @param $value + */ + #[\Override] + public function setHeader($key, $value) + { + $this->headers[$key] = $value; + $this->updateHeaders(); + } + + /** + * Set Headers + * + * Add extra headers to include in the request. + * + * @param $headers + */ + #[\Override] + public function setHeaders($headers) + { + if (ArrayUtil::isArrayAssoc($headers)) { + foreach ($headers as $key => $value) { + $key = trim($key); + $value = trim($value); + $this->headers[$key] = $value; + } + } else { + foreach ($headers as $header) { + list($key, $value) = array_pad(explode(':', $header, 2), 2, ''); + $key = trim($key); + $value = trim($value); + $this->headers[$key] = $value; + } + } + + $this->updateHeaders(); + } + + /** + * Set JSON Decoder + * + * @param $mixed boolean|callable + */ + #[\Override] + public function setJsonDecoder($mixed) + { + if ($mixed === false) { + $this->jsonDecoder = false; + } elseif (is_callable($mixed)) { + $this->jsonDecoder = $mixed; + } + } + + /** + * Set XML Decoder + * + * @param $mixed boolean|callable + */ + #[\Override] + public function setXmlDecoder($mixed) + { + if ($mixed === false) { + $this->xmlDecoder = false; + } elseif (is_callable($mixed)) { + $this->xmlDecoder = $mixed; + } + } + + /** + * Set Proxies + * + * Set proxies to tunnel requests through. When set, a random proxy will be + * used for the request. + * + * @param $proxies array - A list of HTTP proxies to tunnel requests + * through. May include port number. + */ + public function setProxies($proxies) + { + $this->proxies = $proxies; + } + + /** + * Set Opt + * + * @param $option + * @param $value + */ + #[\Override] + public function setOpt($option, $value) + { + $this->options[$option] = $value; + + // Make changing the url an instance-specific option. Set the value of + // existing instances when they have not already been set to avoid + // unexpectedly changing the request url after is has been specified. + if ($option === CURLOPT_URL) { + foreach ($this->queuedCurls as $curl_id => $curl) { + if ( + !isset($this->instanceSpecificOptions[$curl_id][$option]) || + $this->instanceSpecificOptions[$curl_id][$option] === null + ) { + $this->instanceSpecificOptions[$curl_id][$option] = $value; + } + } + } + } + + /** + * Set Opts + * + * @param $options + */ + #[\Override] + public function setOpts($options) + { + foreach ($options as $option => $value) { + $this->setOpt($option, $value); + } + } + + /** + * Set Rate Limit + * + * @param $rate_limit string (e.g. "60/1m"). + * @throws \UnexpectedValueException + */ + public function setRateLimit($rate_limit) + { + $rate_limit_pattern = + '/' . // delimiter + '^' . // assert start + '(\d+)' . // digit(s) + '\/' . // slash + '(\d+)?' . // digit(s), optional + '(s|m|h)' . // unit, s for seconds, m for minutes, h for hours + '$' . // assert end + '/' . // delimiter + 'i' . // case-insensitive matches + ''; + if (!preg_match($rate_limit_pattern, $rate_limit, $matches)) { + throw new \UnexpectedValueException( + 'rate limit must be formatted as $max_requests/$interval(s|m|h) ' . + '(e.g. "60/1m" for a maximum of 60 requests per 1 minute)' + ); + } + + $max_requests = (int)$matches['1']; + if ($matches['2'] === '') { + $interval = 1; + } else { + $interval = (int)$matches['2']; + } + $unit = strtolower($matches['3']); + + // Convert interval to seconds based on unit. + $interval_seconds = ''; + if ($unit === 's') { + $interval_seconds = $interval * 1; + } elseif ($unit === 'm') { + $interval_seconds = $interval * 60; + } elseif ($unit === 'h') { + $interval_seconds = $interval * 3600; + } + + $this->rateLimit = (string)$max_requests . '/' . (string)$interval . $unit; + $this->rateLimitEnabled = true; + $this->maxRequests = $max_requests; + $this->interval = $interval; + $this->intervalSeconds = $interval_seconds; + $this->unit = $unit; + } + + /** + * Set Retry + * + * Number of retries to attempt or decider callable. + * + * When using a number of retries to attempt, the maximum number of attempts + * for the request is $maximum_number_of_retries + 1. + * + * When using a callable decider, the request will be retried until the + * function returns a value which evaluates to false. + * + * @param $mixed + */ + #[\Override] + public function setRetry($mixed) + { + $this->retry = $mixed; + } + + /** + * Set Url + * + * @param $url + * @param $mixed_data + */ + #[\Override] + public function setUrl($url, $mixed_data = '') + { + $built_url = Url::buildUrl($url, $mixed_data); + + if ($this->baseUrl === null) { + $this->baseUrl = (string)new Url($built_url); + } else { + $this->baseUrl = (string)new Url($this->baseUrl, $built_url); + } + + $this->setOpt(CURLOPT_URL, $this->baseUrl); + } + + /** + * Start + * + * @throws \ErrorException + */ + public function start() + { + if ($this->isStarted) { + return; + } + + $this->isStarted = true; + $this->startTime = microtime(true); + $this->currentStartTime = microtime(true); + $this->currentRequestCount = 0; + + do { + while ( + count($this->queuedCurls) && + count($this->activeCurls) < $this->concurrency && + (!$this->rateLimitEnabled || $this->hasRequestQuota()) + ) { + $this->initHandle(); + } + + if ($this->rateLimitEnabled && !count($this->activeCurls) && !$this->hasRequestQuota()) { + $this->waitUntilRequestQuotaAvailable(); + } + + if ($this->preferRequestTimeAccuracy) { + // Wait for activity on any curl_multi connection when curl_multi_select (libcurl) fails to correctly + // block. + // https://bugs.php.net/bug.php?id=63411 + // + // Also, use a shorter curl_multi_select() timeout instead the default of one second. This allows + // pending requests to have more accurate start times. Without a shorter timeout, it can be nearly a + // full second before available request quota is rechecked and pending requests can be initialized. + if (curl_multi_select($this->multiCurl, 0.2) === -1) { + usleep(100000); + } + + curl_multi_exec($this->multiCurl, $active); + } else { + // Use multiple loops to get data off of the multi handler. Without this, the following error may appear + // intermittently on certain versions of PHP: + // curl_multi_exec(): supplied resource is not a valid cURL handle resource + + // Clear out the curl buffer. + do { + $status = curl_multi_exec($this->multiCurl, $active); + } while ($status === CURLM_CALL_MULTI_PERFORM); + + // Wait for more information and then get that information. + while ($active && $status === CURLM_OK) { + // Check if the network socket has some data. + if (curl_multi_select($this->multiCurl) !== -1) { + // Process the data for as long as the system tells us to keep getting it. + do { + $status = curl_multi_exec($this->multiCurl, $active); + } while ($status === CURLM_CALL_MULTI_PERFORM); + } + } + } + + while ( + (is_resource($this->multiCurl) || $this->multiCurl instanceof \CurlMultiHandle) && + (($info_array = curl_multi_info_read($this->multiCurl)) !== false) + ) { + if ($info_array['msg'] === CURLMSG_DONE) { + foreach ($this->activeCurls as $key => $curl) { + if ($curl->curl === $info_array['handle']) { + // Set the error code for multi handles using the "result" key in the array returned by + // curl_multi_info_read(). Using curl_errno() on a multi handle will incorrectly return 0 + // for errors. + $curl->curlErrorCode = $info_array['result']; + $curl->exec($curl->curl); + + if ($curl->attemptRetry()) { + // Remove completed handle before adding again in order to retry request. + curl_multi_remove_handle($this->multiCurl, $curl->curl); + + $curlm_error_code = curl_multi_add_handle($this->multiCurl, $curl->curl); + if ($curlm_error_code !== CURLM_OK) { + throw new \ErrorException( + 'cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code) + ); + } + + $curl->call($curl->beforeSendCallback); + } else { + $curl->execDone(); + + // Remove completed instance from active curls. + unset($this->activeCurls[$key]); + + // Remove handle of the completed instance. + curl_multi_remove_handle($this->multiCurl, $curl->curl); + + // Clean up completed instance. + $curl->close(); + } + + break; + } + } + } + } + } while ($active || count($this->activeCurls) || count($this->queuedCurls)); + + $this->isStarted = false; + $this->stopTime = microtime(true); + } + + /** + * Stop + */ + #[\Override] + public function stop() + { + // Remove any queued curl requests. + while (count($this->queuedCurls)) { + $curl = array_pop($this->queuedCurls); + $curl->close(); + } + + // Attempt to stop active curl requests. + while (count($this->activeCurls)) { + // Remove instance from active curls. + $curl = array_pop($this->activeCurls); + + // Remove active curl handle. + curl_multi_remove_handle($this->multiCurl, $curl->curl); + + $curl->stop(); + } + } + + /** + * Unset Header + * + * Remove extra header previously set using Curl::setHeader(). + * + * @param $key + */ + #[\Override] + public function unsetHeader($key) + { + unset($this->headers[$key]); + } + + /** + * Set request time accuracy + */ + public function setRequestTimeAccuracy() + { + $this->preferRequestTimeAccuracy = true; + } + + /** + * Destruct + */ + public function __destruct() + { + $this->close(); + } + + /** + * Update Headers + */ + private function updateHeaders() + { + foreach ($this->queuedCurls as $curl) { + $curl->setHeaders($this->headers); + } + } + + /** + * Queue Handle + * + * @param $curl + */ + private function queueHandle($curl) + { + // Use sequential ids to allow for ordered post processing. + $curl->id = $this->nextCurlId++; + $curl->childOfMultiCurl = true; + $this->queuedCurls[$curl->id] = $curl; + + // Avoid overwriting any existing header. + if ($curl->getOpt(CURLOPT_HTTPHEADER) === null) { + $curl->setHeaders($this->headers); + } + } + + /** + * Init Handle + * + * @param $curl + * @throws \ErrorException + */ + private function initHandle() + { + $curl = array_shift($this->queuedCurls); + if ($curl === null) { + return; + } + + // Add instance to list of active curls. + $this->currentRequestCount += 1; + $this->activeCurls[$curl->id] = $curl; + + // Set callbacks if not already individually set. + if ($curl->beforeSendCallback === null) { + $curl->beforeSend($this->beforeSendCallback); + } + if ($curl->afterSendCallback === null) { + $curl->afterSend($this->afterSendCallback); + } + if ($curl->successCallback === null) { + $curl->success($this->successCallback); + } + if ($curl->errorCallback === null) { + $curl->error($this->errorCallback); + } + if ($curl->completeCallback === null) { + $curl->complete($this->completeCallback); + } + + // Set decoders if not already individually set. + if ($curl->jsonDecoder === null) { + $curl->setJsonDecoder($this->jsonDecoder); + } + if ($curl->xmlDecoder === null) { + $curl->setXmlDecoder($this->xmlDecoder); + } + + // Set instance-specific options on the Curl instance when present. + if (isset($this->instanceSpecificOptions[$curl->id])) { + $curl->setOpts($this->instanceSpecificOptions[$curl->id]); + } + + $curl->setRetry($this->retry); + $curl->setCookies($this->cookies); + + // Use a random proxy for the curl instance when proxies have been set + // and the curl instance doesn't already have a proxy set. + if (is_array($this->proxies) && $curl->getOpt(CURLOPT_PROXY) === null) { + $random_proxy = ArrayUtil::arrayRandom($this->proxies); + $curl->setProxy($random_proxy); + } + + $curlm_error_code = curl_multi_add_handle($this->multiCurl, $curl->curl); + if ($curlm_error_code !== CURLM_OK) { + throw new \ErrorException('cURL multi add handle error: ' . curl_multi_strerror($curlm_error_code)); + } + + $curl->call($curl->beforeSendCallback); + } + + /** + * Has Request Quota + * + * Checks if there is any available quota to make additional requests while + * rate limiting is enabled. + */ + private function hasRequestQuota() + { + // Calculate if there's request quota since ratelimiting is enabled. + if ($this->rateLimitEnabled) { + // Determine if the limit of requests per interval has been reached. + if ($this->currentRequestCount >= $this->maxRequests) { + $micro_time = microtime(true); + $elapsed_seconds = $micro_time - $this->currentStartTime; + if ($elapsed_seconds <= $this->intervalSeconds) { + $this->rateLimitReached = true; + return false; + } elseif ($this->rateLimitReached) { + $this->rateLimitReached = false; + $this->currentStartTime = $micro_time; + $this->currentRequestCount = 0; + } + } + + return true; + } else { + return true; + } + } + + /** + * Wait Until Request Quota Available + * + * Waits until there is available request quota available based on the rate limit. + */ + private function waitUntilRequestQuotaAvailable() + { + $sleep_until = (float)($this->currentStartTime + $this->intervalSeconds); + $sleep_seconds = $sleep_until - microtime(true); + + // Avoid using time_sleep_until() as it appears to be less precise and not sleep long enough. + // Avoid using usleep(): "Values larger than 1000000 (i.e. sleeping for + // more than a second) may not be supported by the operating system. + // Use sleep() instead." + $sleep_seconds_int = (int)$sleep_seconds; + if ($sleep_seconds_int >= 1) { + sleep($sleep_seconds_int); + } + + // Ensure that enough time has passed as usleep() may not have waited long enough. + $this->currentStartTime = microtime(true); + if ($this->currentStartTime < $sleep_until) { + do { + usleep(1000000 / 4); + $this->currentStartTime = microtime(true); + } while ($this->currentStartTime < $sleep_until); + } + + $this->currentRequestCount = 0; + } + + public function getActiveCurls() + { + return $this->activeCurls; + } +} diff --git a/vendor/php-curl-class/php-curl-class/src/Curl/StringUtil.php b/vendor/php-curl-class/php-curl-class/src/Curl/StringUtil.php new file mode 100644 index 0000000..cc7c68b --- /dev/null +++ b/vendor/php-curl-class/php-curl-class/src/Curl/StringUtil.php @@ -0,0 +1,65 @@ +baseUrl = $base_url; + $this->relativeUrl = $relative_url; + } + + public function __toString(): string + { + return $this->absolutizeUrl(); + } + + /** + * Remove dot segments. + * + * Interpret and remove the special "." and ".." path segments from a referenced path. + * + * @param mixed $input + */ + public static function removeDotSegments($input) + { + // 1. The input buffer is initialized with the now-appended path + // components and the output buffer is initialized to the empty + // string. + $output = ''; + + // 2. While the input buffer is not empty, loop as follows: + while (!empty($input)) { + // A. If the input buffer begins with a prefix of "../" or "./", + // then remove that prefix from the input buffer; otherwise, + if (StringUtil::startsWith($input, '../')) { + $input = substr($input, 3); + } elseif (StringUtil::startsWith($input, './')) { + $input = substr($input, 2); + + // B. if the input buffer begins with a prefix of "/./" or "/.", + // where "." is a complete path segment, then replace that + // prefix with "/" in the input buffer; otherwise, + } elseif (StringUtil::startsWith($input, '/./')) { + $input = substr($input, 2); + } elseif ($input === '/.') { + $input = '/'; + + // C. if the input buffer begins with a prefix of "/../" or "/..", + // where ".." is a complete path segment, then replace that + // prefix with "/" in the input buffer and remove the last + // segment and its preceding "/" (if any) from the output + // buffer; otherwise, + } elseif (StringUtil::startsWith($input, '/../')) { + $input = substr($input, 3); + $output = substr_replace($output, '', StringUtil::reversePosition($output, '/')); + } elseif ($input === '/..') { + $input = '/'; + $output = substr_replace($output, '', StringUtil::reversePosition($output, '/')); + + // D. if the input buffer consists only of "." or "..", then remove + // that from the input buffer; otherwise, + } elseif ($input === '.' || $input === '..') { + $input = ''; + + // E. move the first path segment in the input buffer to the end of + // the output buffer, including the initial "/" character (if + // any) and any subsequent characters up to, but not including, + // the next "/" character or the end of the input buffer. + } elseif (!(($pos = StringUtil::position($input, '/', 1)) === false)) { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } else { + $output .= $input; + $input = ''; + } + } + + // 3. Finally, the output buffer is returned as the result of + // remove_dot_segments. + return $output . $input; + } + + /** + * Build Url + * + * @param $url + * @param $mixed_data + * @return string + */ + public static function buildUrl($url, $mixed_data = '') + { + $query_string = ''; + if (!empty($mixed_data)) { + $query_mark = strpos($url, '?') > 0 ? '&' : '?'; + if (is_string($mixed_data)) { + $query_string .= $query_mark . $mixed_data; + } elseif (is_array($mixed_data)) { + $query_string .= $query_mark . http_build_query($mixed_data, '', '&'); + } + } + return $url . $query_string; + } + + /** + * Absolutize url. + * + * Combine the base and relative url into an absolute url. + */ + private function absolutizeUrl() + { + $b = self::parseUrl($this->baseUrl); + if (!isset($b['path'])) { + $b['path'] = '/'; + } + if ($this->relativeUrl === null) { + return $this->unparseUrl($b); + } + $r = self::parseUrl($this->relativeUrl); + $r['authorized'] = isset($r['scheme']) || isset($r['host']) || isset($r['port']) + || isset($r['user']) || isset($r['pass']); + $target = []; + if (isset($r['scheme'])) { + $target['scheme'] = $r['scheme']; + $target['host'] = $r['host'] ?? null; + $target['port'] = $r['port'] ?? null; + $target['user'] = $r['user'] ?? null; + $target['pass'] = $r['pass'] ?? null; + $target['path'] = isset($r['path']) ? self::removeDotSegments($r['path']) : null; + $target['query'] = $r['query'] ?? null; + } else { + $target['scheme'] = $b['scheme'] ?? null; + if ($r['authorized']) { + $target['host'] = $r['host'] ?? null; + $target['port'] = $r['port'] ?? null; + $target['user'] = $r['user'] ?? null; + $target['pass'] = $r['pass'] ?? null; + $target['path'] = isset($r['path']) ? self::removeDotSegments($r['path']) : null; + $target['query'] = $r['query'] ?? null; + } else { + $target['host'] = $b['host'] ?? null; + $target['port'] = $b['port'] ?? null; + $target['user'] = $b['user'] ?? null; + $target['pass'] = $b['pass'] ?? null; + if (!isset($r['path']) || $r['path'] === '') { + $target['path'] = $b['path']; + $target['query'] = $r['query'] ?? $b['query'] ?? null; + } else { + if (StringUtil::startsWith($r['path'], '/')) { + $target['path'] = self::removeDotSegments($r['path']); + } else { + $base = StringUtil::characterReversePosition($b['path'], '/', true); + if ($base === false) { + $base = ''; + } + $target['path'] = self::removeDotSegments($base . '/' . $r['path']); + } + $target['query'] = $r['query'] ?? null; + } + } + } + if ($this->relativeUrl === '') { + $target['fragment'] = $b['fragment'] ?? null; + } else { + $target['fragment'] = $r['fragment'] ?? null; + } + $absolutized_url = $this->unparseUrl($target); + return $absolutized_url; + } + + /** + * Parse url. + * + * Parse url into components of a URI as specified by RFC 3986. + * + * @param mixed $url + */ + public static function parseUrl($url) + { + $parts = parse_url((string) $url); + if (isset($parts['path'])) { + $parts['path'] = self::percentEncodeChars($parts['path']); + } + return $parts; + } + + /** + * Percent-encode characters. + * + * Percent-encode characters to represent a data octet in a component when + * that octet's corresponding character is outside the allowed set. + * + * @param mixed $chars + */ + private static function percentEncodeChars($chars) + { + // ALPHA = A-Z / a-z + $alpha = 'A-Za-z'; + + // DIGIT = 0-9 + $digit = '0-9'; + + // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + $unreserved = $alpha . $digit . preg_quote('-._~'); + + // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" + // / "*" / "+" / "," / ";" / "=" / "#" + $sub_delims = preg_quote('!$&\'()*+,;=#'); + + // HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + $hexdig = $digit . 'A-F'; + // "The uppercase hexadecimal digits 'A' through 'F' are equivalent to + // the lowercase digits 'a' through 'f', respectively." + $hexdig .= 'a-f'; + + $pattern = '/(?:[^' . $unreserved . $sub_delims . preg_quote(':@%/?', '/') . ']++|%(?![' . $hexdig . ']{2}))/'; + $percent_encoded_chars = preg_replace_callback( + $pattern, + function ($matches) { + return rawurlencode($matches[0]); + }, + $chars + ); + return $percent_encoded_chars; + } + + /** + * Unparse url. + * + * Combine url components into a url. + * + * @param mixed $parsed_url + */ + private function unparseUrl($parsed_url) + { + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $user = $parsed_url['user'] ?? ''; + $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; + $pass = ($user || $pass) ? $pass . '@' : ''; + $host = $parsed_url['host'] ?? ''; + $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $path = $parsed_url['path'] ?? ''; + $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; + $unparsed_url = $scheme . $user . $pass . $host . $port . $path . $query . $fragment; + return $unparsed_url; + } +} diff --git a/vendor/psr/container/LICENSE b/vendor/psr/container/LICENSE new file mode 100644 index 0000000..2877a48 --- /dev/null +++ b/vendor/psr/container/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2016 container-interop +Copyright (c) 2016 PHP Framework Interoperability Group + +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/vendor/psr/container/README.md b/vendor/psr/container/README.md new file mode 100644 index 0000000..1b9d9e5 --- /dev/null +++ b/vendor/psr/container/README.md @@ -0,0 +1,13 @@ +Container interface +============== + +This repository holds all interfaces related to [PSR-11 (Container Interface)][psr-url]. + +Note that this is not a Container implementation of its own. It is merely abstractions that describe the components of a Dependency Injection Container. + +The installable [package][package-url] and [implementations][implementation-url] are listed on Packagist. + +[psr-url]: https://www.php-fig.org/psr/psr-11/ +[package-url]: https://packagist.org/packages/psr/container +[implementation-url]: https://packagist.org/providers/psr/container-implementation + diff --git a/vendor/psr/container/composer.json b/vendor/psr/container/composer.json new file mode 100644 index 0000000..baf6cd1 --- /dev/null +++ b/vendor/psr/container/composer.json @@ -0,0 +1,27 @@ +{ + "name": "psr/container", + "type": "library", + "description": "Common Container Interface (PHP FIG PSR-11)", + "keywords": ["psr", "psr-11", "container", "container-interop", "container-interface"], + "homepage": "https://github.com/php-fig/container", + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "require": { + "php": ">=7.4.0" + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + } +} diff --git a/vendor/psr/container/src/ContainerExceptionInterface.php b/vendor/psr/container/src/ContainerExceptionInterface.php new file mode 100644 index 0000000..0f213f2 --- /dev/null +++ b/vendor/psr/container/src/ContainerExceptionInterface.php @@ -0,0 +1,12 @@ +=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/vendor/psr/http-factory/src/RequestFactoryInterface.php b/vendor/psr/http-factory/src/RequestFactoryInterface.php new file mode 100644 index 0000000..cb39a08 --- /dev/null +++ b/vendor/psr/http-factory/src/RequestFactoryInterface.php @@ -0,0 +1,18 @@ + `RequestInterface`, `ServerRequestInterface`, `ResponseInterface` extend `MessageInterface` because the `Request` and the `Response` are `HTTP Messages`. +> When using `ServerRequestInterface`, both `RequestInterface` and `Psr\Http\Message\MessageInterface` methods are considered. + diff --git a/vendor/psr/http-message/docs/PSR7-Usage.md b/vendor/psr/http-message/docs/PSR7-Usage.md new file mode 100644 index 0000000..b6d048a --- /dev/null +++ b/vendor/psr/http-message/docs/PSR7-Usage.md @@ -0,0 +1,159 @@ +### PSR-7 Usage + +All PSR-7 applications comply with these interfaces +They were created to establish a standard between middleware implementations. + +> `RequestInterface`, `ServerRequestInterface`, `ResponseInterface` extend `MessageInterface` because the `Request` and the `Response` are `HTTP Messages`. +> When using `ServerRequestInterface`, both `RequestInterface` and `Psr\Http\Message\MessageInterface` methods are considered. + + +The following examples will illustrate how basic operations are done in PSR-7. + +##### Examples + + +For this examples to work (at least) a PSR-7 implementation package is required. (eg: zendframework/zend-diactoros, guzzlehttp/psr7, slim/slim, etc) +All PSR-7 implementations should have the same behaviour. + +The following will be assumed: +`$request` is an object of `Psr\Http\Message\RequestInterface` and + +`$response` is an object implementing `Psr\Http\Message\RequestInterface` + + +### Working with HTTP Headers + +#### Adding headers to response: + +```php +$response->withHeader('My-Custom-Header', 'My Custom Message'); +``` + +#### Appending values to headers + +```php +$response->withAddedHeader('My-Custom-Header', 'The second message'); +``` + +#### Checking if header exists: + +```php +$request->hasHeader('My-Custom-Header'); // will return false +$response->hasHeader('My-Custom-Header'); // will return true +``` + +> Note: My-Custom-Header was only added in the Response + +#### Getting comma-separated values from a header (also applies to request) + +```php +// getting value from request headers +$request->getHeaderLine('Content-Type'); // will return: "text/html; charset=UTF-8" +// getting value from response headers +$response->getHeaderLine('My-Custom-Header'); // will return: "My Custom Message; The second message" +``` + +#### Getting array of value from a header (also applies to request) +```php +// getting value from request headers +$request->getHeader('Content-Type'); // will return: ["text/html", "charset=UTF-8"] +// getting value from response headers +$response->getHeader('My-Custom-Header'); // will return: ["My Custom Message", "The second message"] +``` + +#### Removing headers from HTTP Messages +```php +// removing a header from Request, removing deprecated "Content-MD5" header +$request->withoutHeader('Content-MD5'); + +// removing a header from Response +// effect: the browser won't know the size of the stream +// the browser will download the stream till it ends +$response->withoutHeader('Content-Length'); +``` + +### Working with HTTP Message Body + +When working with the PSR-7 there are two methods of implementation: +#### 1. Getting the body separately + +> This method makes the body handling easier to understand and is useful when repeatedly calling body methods. (You only call `getBody()` once). Using this method mistakes like `$response->write()` are also prevented. + +```php +$body = $response->getBody(); +// operations on body, eg. read, write, seek +// ... +// replacing the old body +$response->withBody($body); +// this last statement is optional as we working with objects +// in this case the "new" body is same with the "old" one +// the $body variable has the same value as the one in $request, only the reference is passed +``` + +#### 2. Working directly on response + +> This method is useful when only performing few operations as the `$request->getBody()` statement fragment is required + +```php +$response->getBody()->write('hello'); +``` + +### Getting the body contents + +The following snippet gets the contents of a stream contents. +> Note: Streams must be rewinded, if content was written into streams, it will be ignored when calling `getContents()` because the stream pointer is set to the last character, which is `\0` - meaning end of stream. +```php +$body = $response->getBody(); +$body->rewind(); // or $body->seek(0); +$bodyText = $body->getContents(); +``` +> Note: If `$body->seek(1)` is called before `$body->getContents()`, the first character will be ommited as the starting pointer is set to `1`, not `0`. This is why using `$body->rewind()` is recommended. + +### Append to body + +```php +$response->getBody()->write('Hello'); // writing directly +$body = $request->getBody(); // which is a `StreamInterface` +$body->write('xxxxx'); +``` + +### Prepend to body +Prepending is different when it comes to streams. The content must be copied before writing the content to be prepended. +The following example will explain the behaviour of streams. + +```php +// assuming our response is initially empty +$body = $repsonse->getBody(); +// writing the string "abcd" +$body->write('abcd'); + +// seeking to start of stream +$body->seek(0); +// writing 'ef' +$body->write('ef'); // at this point the stream contains "efcd" +``` + +#### Prepending by rewriting separately + +```php +// assuming our response body stream only contains: "abcd" +$body = $response->getBody(); +$body->rewind(); +$contents = $body->getContents(); // abcd +// seeking the stream to beginning +$body->rewind(); +$body->write('ef'); // stream contains "efcd" +$body->write($contents); // stream contains "efabcd" +``` + +> Note: `getContents()` seeks the stream while reading it, therefore if the second `rewind()` method call was not present the stream would have resulted in `abcdefabcd` because the `write()` method appends to stream if not preceeded by `rewind()` or `seek(0)`. + +#### Prepending by using contents as a string +```php +$body = $response->getBody(); +$body->rewind(); +$contents = $body->getContents(); // efabcd +$contents = 'ef'.$contents; +$body->rewind(); +$body->write($contents); +``` diff --git a/vendor/psr/http-message/src/MessageInterface.php b/vendor/psr/http-message/src/MessageInterface.php new file mode 100644 index 0000000..8cdb4ed --- /dev/null +++ b/vendor/psr/http-message/src/MessageInterface.php @@ -0,0 +1,189 @@ +getHeaders() as $name => $values) { + * echo $name . ": " . implode(", ", $values); + * } + * + * // Emit headers iteratively: + * foreach ($message->getHeaders() as $name => $values) { + * foreach ($values as $value) { + * header(sprintf('%s: %s', $name, $value), false); + * } + * } + * + * While header names are not case-sensitive, getHeaders() will preserve the + * exact case in which headers were originally specified. + * + * @return string[][] Returns an associative array of the message's headers. Each + * key MUST be a header name, and each value MUST be an array of strings + * for that header. + */ + public function getHeaders(); + + /** + * Checks if a header exists by the given case-insensitive name. + * + * @param string $name Case-insensitive header field name. + * @return bool Returns true if any header names match the given header + * name using a case-insensitive string comparison. Returns false if + * no matching header name is found in the message. + */ + public function hasHeader(string $name); + + /** + * Retrieves a message header value by the given case-insensitive name. + * + * This method returns an array of all the header values of the given + * case-insensitive header name. + * + * If the header does not appear in the message, this method MUST return an + * empty array. + * + * @param string $name Case-insensitive header field name. + * @return string[] An array of string values as provided for the given + * header. If the header does not appear in the message, this method MUST + * return an empty array. + */ + public function getHeader(string $name); + + /** + * Retrieves a comma-separated string of the values for a single header. + * + * This method returns all of the header values of the given + * case-insensitive header name as a string concatenated together using + * a comma. + * + * NOTE: Not all header values may be appropriately represented using + * comma concatenation. For such headers, use getHeader() instead + * and supply your own delimiter when concatenating. + * + * If the header does not appear in the message, this method MUST return + * an empty string. + * + * @param string $name Case-insensitive header field name. + * @return string A string of values as provided for the given header + * concatenated together using a comma. If the header does not appear in + * the message, this method MUST return an empty string. + */ + public function getHeaderLine(string $name); + + /** + * Return an instance with the provided value replacing the specified header. + * + * While header names are case-insensitive, the casing of the header will + * be preserved by this function, and returned from getHeaders(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new and/or updated header and value. + * + * @param string $name Case-insensitive header field name. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withHeader(string $name, $value); + + /** + * Return an instance with the specified header appended with the given value. + * + * Existing values for the specified header will be maintained. The new + * value(s) will be appended to the existing list. If the header did not + * exist previously, it will be added. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new header and/or value. + * + * @param string $name Case-insensitive header field name to add. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withAddedHeader(string $name, $value); + + /** + * Return an instance without the specified header. + * + * Header resolution MUST be done without case-sensitivity. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the named header. + * + * @param string $name Case-insensitive header field name to remove. + * @return static + */ + public function withoutHeader(string $name); + + /** + * Gets the body of the message. + * + * @return StreamInterface Returns the body as a stream. + */ + public function getBody(); + + /** + * Return an instance with the specified message body. + * + * The body MUST be a StreamInterface object. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return a new instance that has the + * new body stream. + * + * @param StreamInterface $body Body. + * @return static + * @throws \InvalidArgumentException When the body is not valid. + */ + public function withBody(StreamInterface $body); +} diff --git a/vendor/psr/http-message/src/RequestInterface.php b/vendor/psr/http-message/src/RequestInterface.php new file mode 100644 index 0000000..38066df --- /dev/null +++ b/vendor/psr/http-message/src/RequestInterface.php @@ -0,0 +1,131 @@ +getQuery()` + * or from the `QUERY_STRING` server param. + * + * @return array + */ + public function getQueryParams(); + + /** + * Return an instance with the specified query string arguments. + * + * These values SHOULD remain immutable over the course of the incoming + * request. They MAY be injected during instantiation, such as from PHP's + * $_GET superglobal, or MAY be derived from some other value such as the + * URI. In cases where the arguments are parsed from the URI, the data + * MUST be compatible with what PHP's parse_str() would return for + * purposes of how duplicate query parameters are handled, and how nested + * sets are handled. + * + * Setting query string arguments MUST NOT change the URI stored by the + * request, nor the values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated query string arguments. + * + * @param array $query Array of query string arguments, typically from + * $_GET. + * @return static + */ + public function withQueryParams(array $query); + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @return array An array tree of UploadedFileInterface instances; an empty + * array MUST be returned if no data is present. + */ + public function getUploadedFiles(); + + /** + * Create a new instance with the specified uploaded files. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array $uploadedFiles An array tree of UploadedFileInterface instances. + * @return static + * @throws \InvalidArgumentException if an invalid structure is provided. + */ + public function withUploadedFiles(array $uploadedFiles); + + /** + * Retrieve any parameters provided in the request body. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, this method MUST + * return the contents of $_POST. + * + * Otherwise, this method may return any results of deserializing + * the request body content; as parsing returns structured content, the + * potential types MUST be arrays or objects only. A null value indicates + * the absence of body content. + * + * @return null|array|object The deserialized body parameters, if any. + * These will typically be an array or object. + */ + public function getParsedBody(); + + /** + * Return an instance with the specified body parameters. + * + * These MAY be injected during instantiation. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, use this method + * ONLY to inject the contents of $_POST. + * + * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of + * deserializing the request body content. Deserialization/parsing returns + * structured data, and, as such, this method ONLY accepts arrays or objects, + * or a null value if nothing was available to parse. + * + * As an example, if content negotiation determines that the request data + * is a JSON payload, this method could be used to create a request + * instance with the deserialized parameters. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param null|array|object $data The deserialized body data. This will + * typically be in an array or object. + * @return static + * @throws \InvalidArgumentException if an unsupported argument type is + * provided. + */ + public function withParsedBody($data); + + /** + * Retrieve attributes derived from the request. + * + * The request "attributes" may be used to allow injection of any + * parameters derived from the request: e.g., the results of path + * match operations; the results of decrypting cookies; the results of + * deserializing non-form-encoded message bodies; etc. Attributes + * will be application and request specific, and CAN be mutable. + * + * @return array Attributes derived from the request. + */ + public function getAttributes(); + + /** + * Retrieve a single derived request attribute. + * + * Retrieves a single derived request attribute as described in + * getAttributes(). If the attribute has not been previously set, returns + * the default value as provided. + * + * This method obviates the need for a hasAttribute() method, as it allows + * specifying a default value to return if the attribute is not found. + * + * @see getAttributes() + * @param string $name The attribute name. + * @param mixed $default Default value to return if the attribute does not exist. + * @return mixed + */ + public function getAttribute(string $name, $default = null); + + /** + * Return an instance with the specified derived request attribute. + * + * This method allows setting a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated attribute. + * + * @see getAttributes() + * @param string $name The attribute name. + * @param mixed $value The value of the attribute. + * @return static + */ + public function withAttribute(string $name, $value); + + /** + * Return an instance that removes the specified derived request attribute. + * + * This method allows removing a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the attribute. + * + * @see getAttributes() + * @param string $name The attribute name. + * @return static + */ + public function withoutAttribute(string $name); +} diff --git a/vendor/psr/http-message/src/StreamInterface.php b/vendor/psr/http-message/src/StreamInterface.php new file mode 100644 index 0000000..5924663 --- /dev/null +++ b/vendor/psr/http-message/src/StreamInterface.php @@ -0,0 +1,160 @@ + + * [user-info@]host[:port] + * + * + * If the port component is not set or is the standard port for the current + * scheme, it SHOULD NOT be included. + * + * @see https://tools.ietf.org/html/rfc3986#section-3.2 + * @return string The URI authority, in "[user-info@]host[:port]" format. + */ + public function getAuthority(); + + /** + * Retrieve the user information component of the URI. + * + * If no user information is present, this method MUST return an empty + * string. + * + * If a user is present in the URI, this will return that value; + * additionally, if the password is also present, it will be appended to the + * user value, with a colon (":") separating the values. + * + * The trailing "@" character is not part of the user information and MUST + * NOT be added. + * + * @return string The URI user information, in "username[:password]" format. + */ + public function getUserInfo(); + + /** + * Retrieve the host component of the URI. + * + * If no host is present, this method MUST return an empty string. + * + * The value returned MUST be normalized to lowercase, per RFC 3986 + * Section 3.2.2. + * + * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 + * @return string The URI host. + */ + public function getHost(); + + /** + * Retrieve the port component of the URI. + * + * If a port is present, and it is non-standard for the current scheme, + * this method MUST return it as an integer. If the port is the standard port + * used with the current scheme, this method SHOULD return null. + * + * If no port is present, and no scheme is present, this method MUST return + * a null value. + * + * If no port is present, but a scheme is present, this method MAY return + * the standard port for that scheme, but SHOULD return null. + * + * @return null|int The URI port. + */ + public function getPort(); + + /** + * Retrieve the path component of the URI. + * + * The path can either be empty or absolute (starting with a slash) or + * rootless (not starting with a slash). Implementations MUST support all + * three syntaxes. + * + * Normally, the empty path "" and absolute path "/" are considered equal as + * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically + * do this normalization because in contexts with a trimmed base path, e.g. + * the front controller, this difference becomes significant. It's the task + * of the user to handle both "" and "/". + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.3. + * + * As an example, if the value should include a slash ("/") not intended as + * delimiter between path segments, that value MUST be passed in encoded + * form (e.g., "%2F") to the instance. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.3 + * @return string The URI path. + */ + public function getPath(); + + /** + * Retrieve the query string of the URI. + * + * If no query string is present, this method MUST return an empty string. + * + * The leading "?" character is not part of the query and MUST NOT be + * added. + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.4. + * + * As an example, if a value in a key/value pair of the query string should + * include an ampersand ("&") not intended as a delimiter between values, + * that value MUST be passed in encoded form (e.g., "%26") to the instance. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.4 + * @return string The URI query string. + */ + public function getQuery(); + + /** + * Retrieve the fragment component of the URI. + * + * If no fragment is present, this method MUST return an empty string. + * + * The leading "#" character is not part of the fragment and MUST NOT be + * added. + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.5. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.5 + * @return string The URI fragment. + */ + public function getFragment(); + + /** + * Return an instance with the specified scheme. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified scheme. + * + * Implementations MUST support the schemes "http" and "https" case + * insensitively, and MAY accommodate other schemes if required. + * + * An empty scheme is equivalent to removing the scheme. + * + * @param string $scheme The scheme to use with the new instance. + * @return static A new instance with the specified scheme. + * @throws \InvalidArgumentException for invalid or unsupported schemes. + */ + public function withScheme(string $scheme); + + /** + * Return an instance with the specified user information. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified user information. + * + * Password is optional, but the user information MUST include the + * user; an empty string for the user is equivalent to removing user + * information. + * + * @param string $user The user name to use for authority. + * @param null|string $password The password associated with $user. + * @return static A new instance with the specified user information. + */ + public function withUserInfo(string $user, ?string $password = null); + + /** + * Return an instance with the specified host. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified host. + * + * An empty host value is equivalent to removing the host. + * + * @param string $host The hostname to use with the new instance. + * @return static A new instance with the specified host. + * @throws \InvalidArgumentException for invalid hostnames. + */ + public function withHost(string $host); + + /** + * Return an instance with the specified port. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified port. + * + * Implementations MUST raise an exception for ports outside the + * established TCP and UDP port ranges. + * + * A null value provided for the port is equivalent to removing the port + * information. + * + * @param null|int $port The port to use with the new instance; a null value + * removes the port information. + * @return static A new instance with the specified port. + * @throws \InvalidArgumentException for invalid ports. + */ + public function withPort(?int $port); + + /** + * Return an instance with the specified path. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified path. + * + * The path can either be empty or absolute (starting with a slash) or + * rootless (not starting with a slash). Implementations MUST support all + * three syntaxes. + * + * If the path is intended to be domain-relative rather than path relative then + * it must begin with a slash ("/"). Paths not starting with a slash ("/") + * are assumed to be relative to some base path known to the application or + * consumer. + * + * Users can provide both encoded and decoded path characters. + * Implementations ensure the correct encoding as outlined in getPath(). + * + * @param string $path The path to use with the new instance. + * @return static A new instance with the specified path. + * @throws \InvalidArgumentException for invalid paths. + */ + public function withPath(string $path); + + /** + * Return an instance with the specified query string. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified query string. + * + * Users can provide both encoded and decoded query characters. + * Implementations ensure the correct encoding as outlined in getQuery(). + * + * An empty query string value is equivalent to removing the query string. + * + * @param string $query The query string to use with the new instance. + * @return static A new instance with the specified query string. + * @throws \InvalidArgumentException for invalid query strings. + */ + public function withQuery(string $query); + + /** + * Return an instance with the specified URI fragment. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified URI fragment. + * + * Users can provide both encoded and decoded fragment characters. + * Implementations ensure the correct encoding as outlined in getFragment(). + * + * An empty fragment value is equivalent to removing the fragment. + * + * @param string $fragment The fragment to use with the new instance. + * @return static A new instance with the specified fragment. + */ + public function withFragment(string $fragment); + + /** + * Return the string representation as a URI reference. + * + * Depending on which components of the URI are present, the resulting + * string is either a full URI or relative reference according to RFC 3986, + * Section 4.1. The method concatenates the various components of the URI, + * using the appropriate delimiters: + * + * - If a scheme is present, it MUST be suffixed by ":". + * - If an authority is present, it MUST be prefixed by "//". + * - The path can be concatenated without delimiters. But there are two + * cases where the path has to be adjusted to make the URI reference + * valid as PHP does not allow to throw an exception in __toString(): + * - If the path is rootless and an authority is present, the path MUST + * be prefixed by "/". + * - If the path is starting with more than one "/" and no authority is + * present, the starting slashes MUST be reduced to one. + * - If a query is present, it MUST be prefixed by "?". + * - If a fragment is present, it MUST be prefixed by "#". + * + * @see http://tools.ietf.org/html/rfc3986#section-4.1 + * @return string + */ + public function __toString(); +} diff --git a/vendor/psr/log/LICENSE b/vendor/psr/log/LICENSE new file mode 100644 index 0000000..474c952 --- /dev/null +++ b/vendor/psr/log/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 PHP Framework Interoperability Group + +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/vendor/psr/log/README.md b/vendor/psr/log/README.md new file mode 100644 index 0000000..a9f20c4 --- /dev/null +++ b/vendor/psr/log/README.md @@ -0,0 +1,58 @@ +PSR Log +======= + +This repository holds all interfaces/classes/traits related to +[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md). + +Note that this is not a logger of its own. It is merely an interface that +describes a logger. See the specification for more details. + +Installation +------------ + +```bash +composer require psr/log +``` + +Usage +----- + +If you need a logger, you can use the interface like this: + +```php +logger = $logger; + } + + public function doSomething() + { + if ($this->logger) { + $this->logger->info('Doing work'); + } + + try { + $this->doSomethingElse(); + } catch (Exception $exception) { + $this->logger->error('Oh no!', array('exception' => $exception)); + } + + // do something useful + } +} +``` + +You can then pick one of the implementations of the interface to get a logger. + +If you want to implement the interface, you can require this package and +implement `Psr\Log\LoggerInterface` in your code. Please read the +[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) +for details. diff --git a/vendor/psr/log/composer.json b/vendor/psr/log/composer.json new file mode 100644 index 0000000..879fc6f --- /dev/null +++ b/vendor/psr/log/composer.json @@ -0,0 +1,26 @@ +{ + "name": "psr/log", + "description": "Common interface for logging libraries", + "keywords": ["psr", "psr-3", "log"], + "homepage": "https://github.com/php-fig/log", + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "require": { + "php": ">=8.0.0" + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + } +} diff --git a/vendor/psr/log/src/AbstractLogger.php b/vendor/psr/log/src/AbstractLogger.php new file mode 100644 index 0000000..d60a091 --- /dev/null +++ b/vendor/psr/log/src/AbstractLogger.php @@ -0,0 +1,15 @@ +logger = $logger; + } +} diff --git a/vendor/psr/log/src/LoggerInterface.php b/vendor/psr/log/src/LoggerInterface.php new file mode 100644 index 0000000..cb4cf64 --- /dev/null +++ b/vendor/psr/log/src/LoggerInterface.php @@ -0,0 +1,98 @@ +log(LogLevel::EMERGENCY, $message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + */ + public function alert(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::ALERT, $message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + */ + public function critical(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::CRITICAL, $message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + */ + public function error(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::ERROR, $message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + */ + public function warning(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::WARNING, $message, $context); + } + + /** + * Normal but significant events. + */ + public function notice(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::NOTICE, $message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + */ + public function info(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::INFO, $message, $context); + } + + /** + * Detailed debug information. + */ + public function debug(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::DEBUG, $message, $context); + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * + * @throws \Psr\Log\InvalidArgumentException + */ + abstract public function log($level, string|\Stringable $message, array $context = []): void; +} diff --git a/vendor/psr/log/src/NullLogger.php b/vendor/psr/log/src/NullLogger.php new file mode 100644 index 0000000..de0561e --- /dev/null +++ b/vendor/psr/log/src/NullLogger.php @@ -0,0 +1,26 @@ +logger) { }` + * blocks. + */ +class NullLogger extends AbstractLogger +{ + /** + * Logs with an arbitrary level. + * + * @param mixed[] $context + * + * @throws \Psr\Log\InvalidArgumentException + */ + public function log($level, string|\Stringable $message, array $context = []): void + { + // noop + } +} diff --git a/vendor/psr/simple-cache/.editorconfig b/vendor/psr/simple-cache/.editorconfig new file mode 100644 index 0000000..48542cb --- /dev/null +++ b/vendor/psr/simple-cache/.editorconfig @@ -0,0 +1,12 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/vendor/psr/simple-cache/LICENSE.md b/vendor/psr/simple-cache/LICENSE.md new file mode 100644 index 0000000..e49a7c8 --- /dev/null +++ b/vendor/psr/simple-cache/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2016 PHP Framework Interoperability Group + +> 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/vendor/psr/simple-cache/README.md b/vendor/psr/simple-cache/README.md new file mode 100644 index 0000000..43641d1 --- /dev/null +++ b/vendor/psr/simple-cache/README.md @@ -0,0 +1,8 @@ +PHP FIG Simple Cache PSR +======================== + +This repository holds all interfaces related to PSR-16. + +Note that this is not a cache implementation of its own. It is merely an interface that describes a cache implementation. See [the specification](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md) for more details. + +You can find implementations of the specification by looking for packages providing the [psr/simple-cache-implementation](https://packagist.org/providers/psr/simple-cache-implementation) virtual package. diff --git a/vendor/psr/simple-cache/composer.json b/vendor/psr/simple-cache/composer.json new file mode 100644 index 0000000..f307a84 --- /dev/null +++ b/vendor/psr/simple-cache/composer.json @@ -0,0 +1,25 @@ +{ + "name": "psr/simple-cache", + "description": "Common interfaces for simple caching", + "keywords": ["psr", "psr-16", "cache", "simple-cache", "caching"], + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "require": { + "php": ">=8.0.0" + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + } +} diff --git a/vendor/psr/simple-cache/src/CacheException.php b/vendor/psr/simple-cache/src/CacheException.php new file mode 100644 index 0000000..f61b24c --- /dev/null +++ b/vendor/psr/simple-cache/src/CacheException.php @@ -0,0 +1,10 @@ + $keys A list of keys that can be obtained in a single operation. + * @param mixed $default Default value to return for keys that do not exist. + * + * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if $keys is neither an array nor a Traversable, + * or if any of the $keys are not a legal value. + */ + public function getMultiple(iterable $keys, mixed $default = null): iterable; + + /** + * Persists a set of key => value pairs in the cache, with an optional TTL. + * + * @param iterable $values A list of key => value pairs for a multiple-set operation. + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and + * the driver supports TTL then the library may set a default value + * for it or let the driver take care of that. + * + * @return bool True on success and false on failure. + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if $values is neither an array nor a Traversable, + * or if any of the $values are not a legal value. + */ + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool; + + /** + * Deletes multiple cache items in a single operation. + * + * @param iterable $keys A list of string-based keys to be deleted. + * + * @return bool True if the items were successfully removed. False if there was an error. + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if $keys is neither an array nor a Traversable, + * or if any of the $keys are not a legal value. + */ + public function deleteMultiple(iterable $keys): bool; + + /** + * Determines whether an item is present in the cache. + * + * NOTE: It is recommended that has() is only to be used for cache warming type purposes + * and not to be used within your live applications operations for get/set, as this method + * is subject to a race condition where your has() will return true and immediately after, + * another script can remove it making the state of your app out of date. + * + * @param string $key The cache item key. + * + * @return bool + * + * @throws \Psr\SimpleCache\InvalidArgumentException + * MUST be thrown if the $key string is not a legal value. + */ + public function has(string $key): bool; +} diff --git a/vendor/psr/simple-cache/src/InvalidArgumentException.php b/vendor/psr/simple-cache/src/InvalidArgumentException.php new file mode 100644 index 0000000..6a9524a --- /dev/null +++ b/vendor/psr/simple-cache/src/InvalidArgumentException.php @@ -0,0 +1,13 @@ += 5.3. + +[![Build Status](https://travis-ci.org/ralouphie/getallheaders.svg?branch=master)](https://travis-ci.org/ralouphie/getallheaders) +[![Coverage Status](https://coveralls.io/repos/ralouphie/getallheaders/badge.png?branch=master)](https://coveralls.io/r/ralouphie/getallheaders?branch=master) +[![Latest Stable Version](https://poser.pugx.org/ralouphie/getallheaders/v/stable.png)](https://packagist.org/packages/ralouphie/getallheaders) +[![Latest Unstable Version](https://poser.pugx.org/ralouphie/getallheaders/v/unstable.png)](https://packagist.org/packages/ralouphie/getallheaders) +[![License](https://poser.pugx.org/ralouphie/getallheaders/license.png)](https://packagist.org/packages/ralouphie/getallheaders) + + +This is a simple polyfill for [`getallheaders()`](http://www.php.net/manual/en/function.getallheaders.php). + +## Install + +For PHP version **`>= 5.6`**: + +``` +composer require ralouphie/getallheaders +``` + +For PHP version **`< 5.6`**: + +``` +composer require ralouphie/getallheaders "^2" +``` diff --git a/vendor/ralouphie/getallheaders/composer.json b/vendor/ralouphie/getallheaders/composer.json new file mode 100644 index 0000000..de8ce62 --- /dev/null +++ b/vendor/ralouphie/getallheaders/composer.json @@ -0,0 +1,26 @@ +{ + "name": "ralouphie/getallheaders", + "description": "A polyfill for getallheaders.", + "license": "MIT", + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^5 || ^6.5", + "php-coveralls/php-coveralls": "^2.1" + }, + "autoload": { + "files": ["src/getallheaders.php"] + }, + "autoload-dev": { + "psr-4": { + "getallheaders\\Tests\\": "tests/" + } + } +} diff --git a/vendor/ralouphie/getallheaders/src/getallheaders.php b/vendor/ralouphie/getallheaders/src/getallheaders.php new file mode 100644 index 0000000..c7285a5 --- /dev/null +++ b/vendor/ralouphie/getallheaders/src/getallheaders.php @@ -0,0 +1,46 @@ + 'Content-Type', + 'CONTENT_LENGTH' => 'Content-Length', + 'CONTENT_MD5' => 'Content-Md5', + ); + + foreach ($_SERVER as $key => $value) { + if (substr($key, 0, 5) === 'HTTP_') { + $key = substr($key, 5); + if (!isset($copy_server[$key]) || !isset($_SERVER[$key])) { + $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $key)))); + $headers[$key] = $value; + } + } elseif (isset($copy_server[$key])) { + $headers[$copy_server[$key]] = $value; + } + } + + if (!isset($headers['Authorization'])) { + if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) { + $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; + } elseif (isset($_SERVER['PHP_AUTH_USER'])) { + $basic_pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; + $headers['Authorization'] = 'Basic ' . base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $basic_pass); + } elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) { + $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST']; + } + } + + return $headers; + } + +} diff --git a/vendor/services.php b/vendor/services.php new file mode 100644 index 0000000..eaefa0f --- /dev/null +++ b/vendor/services.php @@ -0,0 +1,7 @@ + 'think\\app\\Service', + 1 => 'think\\trace\\Service', +); \ No newline at end of file diff --git a/vendor/symfony/deprecation-contracts/CHANGELOG.md b/vendor/symfony/deprecation-contracts/CHANGELOG.md new file mode 100644 index 0000000..7932e26 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/CHANGELOG.md @@ -0,0 +1,5 @@ +CHANGELOG +========= + +The changelog is maintained for all Symfony contracts at the following URL: +https://github.com/symfony/contracts/blob/main/CHANGELOG.md diff --git a/vendor/symfony/deprecation-contracts/LICENSE b/vendor/symfony/deprecation-contracts/LICENSE new file mode 100644 index 0000000..0ed3a24 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/LICENSE @@ -0,0 +1,19 @@ +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 +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/vendor/symfony/deprecation-contracts/README.md b/vendor/symfony/deprecation-contracts/README.md new file mode 100644 index 0000000..9814864 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/README.md @@ -0,0 +1,26 @@ +Symfony Deprecation Contracts +============================= + +A generic function and convention to trigger deprecation notices. + +This package provides a single global function named `trigger_deprecation()` that triggers silenced deprecation notices. + +By using a custom PHP error handler such as the one provided by the Symfony ErrorHandler component, +the triggered deprecations can be caught and logged for later discovery, both on dev and prod environments. + +The function requires at least 3 arguments: + - the name of the Composer package that is triggering the deprecation + - the version of the package that introduced the deprecation + - the message of the deprecation + - more arguments can be provided: they will be inserted in the message using `printf()` formatting + +Example: +```php +trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use "%s" instead.', 'bitcoin', 'fabcoin'); +``` + +This will generate the following message: +`Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.` + +While not recommended, the deprecation notices can be completely ignored by declaring an empty +`function trigger_deprecation() {}` in your application. diff --git a/vendor/symfony/deprecation-contracts/composer.json b/vendor/symfony/deprecation-contracts/composer.json new file mode 100644 index 0000000..5533b5c --- /dev/null +++ b/vendor/symfony/deprecation-contracts/composer.json @@ -0,0 +1,35 @@ +{ + "name": "symfony/deprecation-contracts", + "type": "library", + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=8.1" + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-main": "3.6-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + } +} diff --git a/vendor/symfony/deprecation-contracts/function.php b/vendor/symfony/deprecation-contracts/function.php new file mode 100644 index 0000000..2d56512 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/function.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (!function_exists('trigger_deprecation')) { + /** + * Triggers a silenced deprecation notice. + * + * @param string $package The name of the Composer package that is triggering the deprecation + * @param string $version The version of the package that introduced the deprecation + * @param string $message The message of the deprecation + * @param mixed ...$args Values to insert in the message using printf() formatting + * + * @author Nicolas Grekas + */ + function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void + { + @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); + } +} diff --git a/vendor/symfony/polyfill-mbstring/LICENSE b/vendor/symfony/polyfill-mbstring/LICENSE new file mode 100644 index 0000000..6e3afce --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-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/vendor/symfony/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php new file mode 100644 index 0000000..31e36a3 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/Mbstring.php @@ -0,0 +1,1045 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Polyfill\Mbstring; + +/** + * Partial mbstring implementation in PHP, iconv based, UTF-8 centric. + * + * Implemented: + * - mb_chr - Returns a specific character from its Unicode code point + * - mb_convert_encoding - Convert character encoding + * - mb_convert_variables - Convert character code in variable(s) + * - mb_decode_mimeheader - Decode string in MIME header field + * - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED + * - mb_decode_numericentity - Decode HTML numeric string reference to character + * - mb_encode_numericentity - Encode character to HTML numeric string reference + * - mb_convert_case - Perform case folding on a string + * - mb_detect_encoding - Detect character encoding + * - mb_get_info - Get internal settings of mbstring + * - mb_http_input - Detect HTTP input character encoding + * - mb_http_output - Set/Get HTTP output character encoding + * - mb_internal_encoding - Set/Get internal character encoding + * - mb_list_encodings - Returns an array of all supported encodings + * - mb_ord - Returns the Unicode code point of a character + * - mb_output_handler - Callback function converts character encoding in output buffer + * - mb_scrub - Replaces ill-formed byte sequences with substitute characters + * - mb_strlen - Get string length + * - mb_strpos - Find position of first occurrence of string in a string + * - mb_strrpos - Find position of last occurrence of a string in a string + * - mb_str_split - Convert a string to an array + * - mb_strtolower - Make a string lowercase + * - mb_strtoupper - Make a string uppercase + * - mb_substitute_character - Set/Get substitution character + * - mb_substr - Get part of string + * - mb_stripos - Finds position of first occurrence of a string within another, case insensitive + * - mb_stristr - Finds first occurrence of a string within another, case insensitive + * - mb_strrchr - Finds the last occurrence of a character in a string within another + * - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive + * - mb_strripos - Finds position of last occurrence of a string within another, case insensitive + * - mb_strstr - Finds first occurrence of a string within another + * - mb_strwidth - Return width of string + * - mb_substr_count - Count the number of substring occurrences + * - mb_ucfirst - Make a string's first character uppercase + * - mb_lcfirst - Make a string's first character lowercase + * - mb_trim - Strip whitespace (or other characters) from the beginning and end of a string + * - mb_ltrim - Strip whitespace (or other characters) from the beginning of a string + * - mb_rtrim - Strip whitespace (or other characters) from the end of a string + * + * Not implemented: + * - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more) + * - mb_ereg_* - Regular expression with multibyte support + * - mb_parse_str - Parse GET/POST/COOKIE data and set global variable + * - mb_preferred_mime_name - Get MIME charset string + * - mb_regex_encoding - Returns current encoding for multibyte regex as string + * - mb_regex_set_options - Set/Get the default options for mbregex functions + * - mb_send_mail - Send encoded mail + * - mb_split - Split multibyte string using regular expression + * - mb_strcut - Get part of string + * - mb_strimwidth - Get truncated string with specified width + * + * @author Nicolas Grekas + * + * @internal + */ +final class Mbstring +{ + public const MB_CASE_FOLD = \PHP_INT_MAX; + + private const SIMPLE_CASE_FOLD = [ + ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"], + ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'], + ]; + + private static $encodingList = ['ASCII', 'UTF-8']; + private static $language = 'neutral'; + private static $internalEncoding = 'UTF-8'; + + public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) + { + if (\is_array($s)) { + $r = []; + foreach ($s as $str) { + $r[] = self::mb_convert_encoding($str, $toEncoding, $fromEncoding); + } + + return $r; + } + + if (\is_array($fromEncoding) || (null !== $fromEncoding && false !== strpos($fromEncoding, ','))) { + $fromEncoding = self::mb_detect_encoding($s, $fromEncoding); + } else { + $fromEncoding = self::getEncoding($fromEncoding); + } + + $toEncoding = self::getEncoding($toEncoding); + + if ('BASE64' === $fromEncoding) { + $s = base64_decode($s); + $fromEncoding = $toEncoding; + } + + if ('BASE64' === $toEncoding) { + return base64_encode($s); + } + + if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) { + if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) { + $fromEncoding = 'Windows-1252'; + } + if ('UTF-8' !== $fromEncoding) { + $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s); + } + + return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s); + } + + if ('HTML-ENTITIES' === $fromEncoding) { + $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8'); + $fromEncoding = 'UTF-8'; + } + + return iconv($fromEncoding, $toEncoding.'//IGNORE', $s); + } + + public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars) + { + $ok = true; + array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) { + if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) { + $ok = false; + } + }); + + return $ok ? $fromEncoding : false; + } + + public static function mb_decode_mimeheader($s) + { + return iconv_mime_decode($s, 2, self::$internalEncoding); + } + + public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null) + { + trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING); + } + + public static function mb_decode_numericentity($s, $convmap, $encoding = null) + { + if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { + trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING); + + return null; + } + + if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) { + return false; + } + + if (null !== $encoding && !\is_scalar($encoding)) { + trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING); + + return ''; // Instead of null (cf. mb_encode_numericentity). + } + + $s = (string) $s; + if ('' === $s) { + return ''; + } + + $encoding = self::getEncoding($encoding); + + if ('UTF-8' === $encoding) { + $encoding = null; + if (!preg_match('//u', $s)) { + $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); + } + } else { + $s = iconv($encoding, 'UTF-8//IGNORE', $s); + } + + $cnt = floor(\count($convmap) / 4) * 4; + + for ($i = 0; $i < $cnt; $i += 4) { + // collector_decode_htmlnumericentity ignores $convmap[$i + 3] + $convmap[$i] += $convmap[$i + 2]; + $convmap[$i + 1] += $convmap[$i + 2]; + } + + $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) { + $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1]; + for ($i = 0; $i < $cnt; $i += 4) { + if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) { + return self::mb_chr($c - $convmap[$i + 2]); + } + } + + return $m[0]; + }, $s); + + if (null === $encoding) { + return $s; + } + + return iconv('UTF-8', $encoding.'//IGNORE', $s); + } + + public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false) + { + if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) { + trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING); + + return null; + } + + if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) { + return false; + } + + if (null !== $encoding && !\is_scalar($encoding)) { + trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING); + + return null; // Instead of '' (cf. mb_decode_numericentity). + } + + if (null !== $is_hex && !\is_scalar($is_hex)) { + trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING); + + return null; + } + + $s = (string) $s; + if ('' === $s) { + return ''; + } + + $encoding = self::getEncoding($encoding); + + if ('UTF-8' === $encoding) { + $encoding = null; + if (!preg_match('//u', $s)) { + $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); + } + } else { + $s = iconv($encoding, 'UTF-8//IGNORE', $s); + } + + static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4]; + + $cnt = floor(\count($convmap) / 4) * 4; + $i = 0; + $len = \strlen($s); + $result = ''; + + while ($i < $len) { + $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"]; + $uchr = substr($s, $i, $ulen); + $i += $ulen; + $c = self::mb_ord($uchr); + + for ($j = 0; $j < $cnt; $j += 4) { + if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) { + $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3]; + $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';'; + continue 2; + } + } + $result .= $uchr; + } + + if (null === $encoding) { + return $result; + } + + return iconv('UTF-8', $encoding.'//IGNORE', $result); + } + + public static function mb_convert_case($s, $mode, $encoding = null) + { + $s = (string) $s; + if ('' === $s) { + return ''; + } + + $encoding = self::getEncoding($encoding); + + if ('UTF-8' === $encoding) { + $encoding = null; + if (!preg_match('//u', $s)) { + $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); + } + } else { + $s = iconv($encoding, 'UTF-8//IGNORE', $s); + } + + if (\MB_CASE_TITLE == $mode) { + static $titleRegexp = null; + if (null === $titleRegexp) { + $titleRegexp = self::getData('titleCaseRegexp'); + } + $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s); + } else { + if (\MB_CASE_UPPER == $mode) { + static $upper = null; + if (null === $upper) { + $upper = self::getData('upperCase'); + } + $map = $upper; + } else { + if (self::MB_CASE_FOLD === $mode) { + static $caseFolding = null; + if (null === $caseFolding) { + $caseFolding = self::getData('caseFolding'); + } + $s = strtr($s, $caseFolding); + } + + static $lower = null; + if (null === $lower) { + $lower = self::getData('lowerCase'); + } + $map = $lower; + } + + static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4]; + + $i = 0; + $len = \strlen($s); + + while ($i < $len) { + $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"]; + $uchr = substr($s, $i, $ulen); + $i += $ulen; + + if (isset($map[$uchr])) { + $uchr = $map[$uchr]; + $nlen = \strlen($uchr); + + if ($nlen == $ulen) { + $nlen = $i; + do { + $s[--$nlen] = $uchr[--$ulen]; + } while ($ulen); + } else { + $s = substr_replace($s, $uchr, $i - $ulen, $ulen); + $len += $nlen - $ulen; + $i += $nlen - $ulen; + } + } + } + } + + if (null === $encoding) { + return $s; + } + + return iconv('UTF-8', $encoding.'//IGNORE', $s); + } + + public static function mb_internal_encoding($encoding = null) + { + if (null === $encoding) { + return self::$internalEncoding; + } + + $normalizedEncoding = self::getEncoding($encoding); + + if ('UTF-8' === $normalizedEncoding || false !== @iconv($normalizedEncoding, $normalizedEncoding, ' ')) { + self::$internalEncoding = $normalizedEncoding; + + return true; + } + + if (80000 > \PHP_VERSION_ID) { + return false; + } + + throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding)); + } + + public static function mb_language($lang = null) + { + if (null === $lang) { + return self::$language; + } + + switch ($normalizedLang = strtolower($lang)) { + case 'uni': + case 'neutral': + self::$language = $normalizedLang; + + return true; + } + + if (80000 > \PHP_VERSION_ID) { + return false; + } + + throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang)); + } + + public static function mb_list_encodings() + { + return ['UTF-8']; + } + + public static function mb_encoding_aliases($encoding) + { + switch (strtoupper($encoding)) { + case 'UTF8': + case 'UTF-8': + return ['utf8']; + } + + return false; + } + + public static function mb_check_encoding($var = null, $encoding = null) + { + if (null === $encoding) { + if (null === $var) { + return false; + } + $encoding = self::$internalEncoding; + } + + if (!\is_array($var)) { + return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var); + } + + foreach ($var as $key => $value) { + if (!self::mb_check_encoding($key, $encoding)) { + return false; + } + if (!self::mb_check_encoding($value, $encoding)) { + return false; + } + } + + return true; + } + + public static function mb_detect_encoding($str, $encodingList = null, $strict = false) + { + if (null === $encodingList) { + $encodingList = self::$encodingList; + } else { + if (!\is_array($encodingList)) { + $encodingList = array_map('trim', explode(',', $encodingList)); + } + $encodingList = array_map('strtoupper', $encodingList); + } + + foreach ($encodingList as $enc) { + switch ($enc) { + case 'ASCII': + if (!preg_match('/[\x80-\xFF]/', $str)) { + return $enc; + } + break; + + case 'UTF8': + case 'UTF-8': + if (preg_match('//u', $str)) { + return 'UTF-8'; + } + break; + + default: + if (0 === strncmp($enc, 'ISO-8859-', 9)) { + return $enc; + } + } + } + + return false; + } + + public static function mb_detect_order($encodingList = null) + { + if (null === $encodingList) { + return self::$encodingList; + } + + if (!\is_array($encodingList)) { + $encodingList = array_map('trim', explode(',', $encodingList)); + } + $encodingList = array_map('strtoupper', $encodingList); + + foreach ($encodingList as $enc) { + switch ($enc) { + default: + if (strncmp($enc, 'ISO-8859-', 9)) { + return false; + } + // no break + case 'ASCII': + case 'UTF8': + case 'UTF-8': + } + } + + self::$encodingList = $encodingList; + + return true; + } + + public static function mb_strlen($s, $encoding = null) + { + $encoding = self::getEncoding($encoding); + if ('CP850' === $encoding || 'ASCII' === $encoding) { + return \strlen($s); + } + + return @iconv_strlen($s, $encoding); + } + + public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) + { + $encoding = self::getEncoding($encoding); + if ('CP850' === $encoding || 'ASCII' === $encoding) { + return strpos($haystack, $needle, $offset); + } + + $needle = (string) $needle; + if ('' === $needle) { + if (80000 > \PHP_VERSION_ID) { + trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING); + + return false; + } + + return 0; + } + + return iconv_strpos($haystack, $needle, $offset, $encoding); + } + + public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) + { + $encoding = self::getEncoding($encoding); + if ('CP850' === $encoding || 'ASCII' === $encoding) { + return strrpos($haystack, $needle, $offset); + } + + if ($offset != (int) $offset) { + $offset = 0; + } elseif ($offset = (int) $offset) { + if ($offset < 0) { + if (0 > $offset += self::mb_strlen($needle)) { + $haystack = self::mb_substr($haystack, 0, $offset, $encoding); + } + $offset = 0; + } else { + $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding); + } + } + + $pos = '' !== $needle || 80000 > \PHP_VERSION_ID + ? iconv_strrpos($haystack, $needle, $encoding) + : self::mb_strlen($haystack, $encoding); + + return false !== $pos ? $offset + $pos : false; + } + + public static function mb_str_split($string, $split_length = 1, $encoding = null) + { + if (null !== $string && !\is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) { + trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING); + + return null; + } + + if (1 > $split_length = (int) $split_length) { + if (80000 > \PHP_VERSION_ID) { + trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING); + + return false; + } + + throw new \ValueError('Argument #2 ($length) must be greater than 0'); + } + + if (null === $encoding) { + $encoding = mb_internal_encoding(); + } + + if ('UTF-8' === $encoding = self::getEncoding($encoding)) { + $rx = '/('; + while (65535 < $split_length) { + $rx .= '.{65535}'; + $split_length -= 65535; + } + $rx .= '.{'.$split_length.'})/us'; + + return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); + } + + $result = []; + $length = mb_strlen($string, $encoding); + + for ($i = 0; $i < $length; $i += $split_length) { + $result[] = mb_substr($string, $i, $split_length, $encoding); + } + + return $result; + } + + public static function mb_strtolower($s, $encoding = null) + { + return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding); + } + + public static function mb_strtoupper($s, $encoding = null) + { + return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding); + } + + public static function mb_substitute_character($c = null) + { + if (null === $c) { + return 'none'; + } + if (0 === strcasecmp($c, 'none')) { + return true; + } + if (80000 > \PHP_VERSION_ID) { + return false; + } + if (\is_int($c) || 'long' === $c || 'entity' === $c) { + return false; + } + + throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint'); + } + + public static function mb_substr($s, $start, $length = null, $encoding = null) + { + $encoding = self::getEncoding($encoding); + if ('CP850' === $encoding || 'ASCII' === $encoding) { + return (string) substr($s, $start, null === $length ? 2147483647 : $length); + } + + if ($start < 0) { + $start = iconv_strlen($s, $encoding) + $start; + if ($start < 0) { + $start = 0; + } + } + + if (null === $length) { + $length = 2147483647; + } elseif ($length < 0) { + $length = iconv_strlen($s, $encoding) + $length - $start; + if ($length < 0) { + return ''; + } + } + + return (string) iconv_substr($s, $start, $length, $encoding); + } + + public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) + { + [$haystack, $needle] = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [ + self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding), + self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding), + ]); + + return self::mb_strpos($haystack, $needle, $offset, $encoding); + } + + public static function mb_stristr($haystack, $needle, $part = false, $encoding = null) + { + $pos = self::mb_stripos($haystack, $needle, 0, $encoding); + + return self::getSubpart($pos, $part, $haystack, $encoding); + } + + public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null) + { + $encoding = self::getEncoding($encoding); + if ('CP850' === $encoding || 'ASCII' === $encoding) { + $pos = strrpos($haystack, $needle); + } else { + $needle = self::mb_substr($needle, 0, 1, $encoding); + $pos = iconv_strrpos($haystack, $needle, $encoding); + } + + return self::getSubpart($pos, $part, $haystack, $encoding); + } + + public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null) + { + $needle = self::mb_substr($needle, 0, 1, $encoding); + $pos = self::mb_strripos($haystack, $needle, $encoding); + + return self::getSubpart($pos, $part, $haystack, $encoding); + } + + public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) + { + $haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding); + $needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding); + + $haystack = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack); + $needle = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle); + + return self::mb_strrpos($haystack, $needle, $offset, $encoding); + } + + public static function mb_strstr($haystack, $needle, $part = false, $encoding = null) + { + $pos = strpos($haystack, $needle); + if (false === $pos) { + return false; + } + if ($part) { + return substr($haystack, 0, $pos); + } + + return substr($haystack, $pos); + } + + public static function mb_get_info($type = 'all') + { + $info = [ + 'internal_encoding' => self::$internalEncoding, + 'http_output' => 'pass', + 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)', + 'func_overload' => 0, + 'func_overload_list' => 'no overload', + 'mail_charset' => 'UTF-8', + 'mail_header_encoding' => 'BASE64', + 'mail_body_encoding' => 'BASE64', + 'illegal_chars' => 0, + 'encoding_translation' => 'Off', + 'language' => self::$language, + 'detect_order' => self::$encodingList, + 'substitute_character' => 'none', + 'strict_detection' => 'Off', + ]; + + if ('all' === $type) { + return $info; + } + if (isset($info[$type])) { + return $info[$type]; + } + + return false; + } + + public static function mb_http_input($type = '') + { + return false; + } + + public static function mb_http_output($encoding = null) + { + return null !== $encoding ? 'pass' === $encoding : 'pass'; + } + + public static function mb_strwidth($s, $encoding = null) + { + $encoding = self::getEncoding($encoding); + + if ('UTF-8' !== $encoding) { + $s = iconv($encoding, 'UTF-8//IGNORE', $s); + } + + $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide); + + return ($wide << 1) + iconv_strlen($s, 'UTF-8'); + } + + public static function mb_substr_count($haystack, $needle, $encoding = null) + { + return substr_count($haystack, $needle); + } + + public static function mb_output_handler($contents, $status) + { + return $contents; + } + + public static function mb_chr($code, $encoding = null) + { + if (0x80 > $code %= 0x200000) { + $s = \chr($code); + } elseif (0x800 > $code) { + $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F); + } elseif (0x10000 > $code) { + $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F); + } else { + $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F); + } + + if ('UTF-8' !== $encoding = self::getEncoding($encoding)) { + $s = mb_convert_encoding($s, $encoding, 'UTF-8'); + } + + return $s; + } + + public static function mb_ord($s, $encoding = null) + { + if ('UTF-8' !== $encoding = self::getEncoding($encoding)) { + $s = mb_convert_encoding($s, 'UTF-8', $encoding); + } + + if (1 === \strlen($s)) { + return \ord($s); + } + + $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0; + if (0xF0 <= $code) { + return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80; + } + if (0xE0 <= $code) { + return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80; + } + if (0xC0 <= $code) { + return (($code - 0xC0) << 6) + $s[2] - 0x80; + } + + return $code; + } + + public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null): string + { + if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) { + throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH'); + } + + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given'); + } + + if (self::mb_strlen($pad_string, $encoding) <= 0) { + throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string'); + } + + $paddingRequired = $length - self::mb_strlen($string, $encoding); + + if ($paddingRequired < 1) { + return $string; + } + + switch ($pad_type) { + case \STR_PAD_LEFT: + return self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string; + case \STR_PAD_RIGHT: + return $string.self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding); + default: + $leftPaddingLength = floor($paddingRequired / 2); + $rightPaddingLength = $paddingRequired - $leftPaddingLength; + + return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding); + } + } + + public static function mb_ucfirst(string $string, ?string $encoding = null): string + { + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given'); + } + + $firstChar = mb_substr($string, 0, 1, $encoding); + $firstChar = mb_convert_case($firstChar, \MB_CASE_TITLE, $encoding); + + return $firstChar.mb_substr($string, 1, null, $encoding); + } + + public static function mb_lcfirst(string $string, ?string $encoding = null): string + { + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given'); + } + + $firstChar = mb_substr($string, 0, 1, $encoding); + $firstChar = mb_convert_case($firstChar, \MB_CASE_LOWER, $encoding); + + return $firstChar.mb_substr($string, 1, null, $encoding); + } + + private static function getSubpart($pos, $part, $haystack, $encoding) + { + if (false === $pos) { + return false; + } + if ($part) { + return self::mb_substr($haystack, 0, $pos, $encoding); + } + + return self::mb_substr($haystack, $pos, null, $encoding); + } + + private static function html_encoding_callback(array $m) + { + $i = 1; + $entities = ''; + $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8')); + + while (isset($m[$i])) { + if (0x80 > $m[$i]) { + $entities .= \chr($m[$i++]); + continue; + } + if (0xF0 <= $m[$i]) { + $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80; + } elseif (0xE0 <= $m[$i]) { + $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80; + } else { + $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80; + } + + $entities .= '&#'.$c.';'; + } + + return $entities; + } + + private static function title_case(array $s) + { + return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8'); + } + + private static function getData($file) + { + if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) { + return require $file; + } + + return false; + } + + private static function getEncoding($encoding) + { + if (null === $encoding) { + return self::$internalEncoding; + } + + if ('UTF-8' === $encoding) { + return 'UTF-8'; + } + + $encoding = strtoupper($encoding); + + if ('8BIT' === $encoding || 'BINARY' === $encoding) { + return 'CP850'; + } + + if ('UTF8' === $encoding) { + return 'UTF-8'; + } + + return $encoding; + } + + public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string + { + return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__); + } + + public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string + { + return self::mb_internal_trim('{^[%s]+}Du', $string, $characters, $encoding, __FUNCTION__); + } + + public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string + { + return self::mb_internal_trim('{[%s]+$}Du', $string, $characters, $encoding, __FUNCTION__); + } + + private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string + { + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, $function.'(): Argument #3 ($encoding) must be a valid encoding, "%s" given'); + } + + if ('' === $characters) { + return null === $encoding ? $string : self::mb_convert_encoding($string, $encoding); + } + + if ('UTF-8' === $encoding) { + $encoding = null; + if (!preg_match('//u', $string)) { + $string = @iconv('UTF-8', 'UTF-8//IGNORE', $string); + } + if (null !== $characters && !preg_match('//u', $characters)) { + $characters = @iconv('UTF-8', 'UTF-8//IGNORE', $characters); + } + } else { + $string = iconv($encoding, 'UTF-8//IGNORE', $string); + + if (null !== $characters) { + $characters = iconv($encoding, 'UTF-8//IGNORE', $characters); + } + } + + if (null === $characters) { + $characters = "\\0 \f\n\r\t\v\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}"; + } else { + $characters = preg_quote($characters); + } + + $string = preg_replace(sprintf($regex, $characters), '', $string); + + if (null === $encoding) { + return $string; + } + + return iconv('UTF-8', $encoding.'//IGNORE', $string); + } + + private static function assertEncoding(string $encoding, string $errorFormat): void + { + try { + $validEncoding = @self::mb_check_encoding('', $encoding); + } catch (\ValueError $e) { + throw new \ValueError(sprintf($errorFormat, $encoding)); + } + + // BC for PHP 7.3 and lower + if (!$validEncoding) { + throw new \ValueError(sprintf($errorFormat, $encoding)); + } + } +} diff --git a/vendor/symfony/polyfill-mbstring/README.md b/vendor/symfony/polyfill-mbstring/README.md new file mode 100644 index 0000000..478b40d --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/README.md @@ -0,0 +1,13 @@ +Symfony Polyfill / Mbstring +=========================== + +This component provides a partial, native PHP implementation for the +[Mbstring](https://php.net/mbstring) extension. + +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/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php new file mode 100644 index 0000000..512bba0 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php @@ -0,0 +1,119 @@ + 'i̇', + 'µ' => 'μ', + 'ſ' => 's', + 'ͅ' => 'ι', + 'ς' => 'σ', + 'ϐ' => 'β', + 'ϑ' => 'θ', + 'ϕ' => 'φ', + 'ϖ' => 'π', + 'ϰ' => 'κ', + 'ϱ' => 'ρ', + 'ϵ' => 'ε', + 'ẛ' => 'ṡ', + 'ι' => 'ι', + 'ß' => 'ss', + 'ʼn' => 'ʼn', + 'ǰ' => 'ǰ', + 'ΐ' => 'ΐ', + 'ΰ' => 'ΰ', + 'և' => 'եւ', + 'ẖ' => 'ẖ', + 'ẗ' => 'ẗ', + 'ẘ' => 'ẘ', + 'ẙ' => 'ẙ', + 'ẚ' => 'aʾ', + 'ẞ' => 'ss', + 'ὐ' => 'ὐ', + 'ὒ' => 'ὒ', + 'ὔ' => 'ὔ', + 'ὖ' => 'ὖ', + 'ᾀ' => 'ἀι', + 'ᾁ' => 'ἁι', + 'ᾂ' => 'ἂι', + 'ᾃ' => 'ἃι', + 'ᾄ' => 'ἄι', + 'ᾅ' => 'ἅι', + 'ᾆ' => 'ἆι', + 'ᾇ' => 'ἇι', + 'ᾈ' => 'ἀι', + 'ᾉ' => 'ἁι', + 'ᾊ' => 'ἂι', + 'ᾋ' => 'ἃι', + 'ᾌ' => 'ἄι', + 'ᾍ' => 'ἅι', + 'ᾎ' => 'ἆι', + 'ᾏ' => 'ἇι', + 'ᾐ' => 'ἠι', + 'ᾑ' => 'ἡι', + 'ᾒ' => 'ἢι', + 'ᾓ' => 'ἣι', + 'ᾔ' => 'ἤι', + 'ᾕ' => 'ἥι', + 'ᾖ' => 'ἦι', + 'ᾗ' => 'ἧι', + 'ᾘ' => 'ἠι', + 'ᾙ' => 'ἡι', + 'ᾚ' => 'ἢι', + 'ᾛ' => 'ἣι', + 'ᾜ' => 'ἤι', + 'ᾝ' => 'ἥι', + 'ᾞ' => 'ἦι', + 'ᾟ' => 'ἧι', + 'ᾠ' => 'ὠι', + 'ᾡ' => 'ὡι', + 'ᾢ' => 'ὢι', + 'ᾣ' => 'ὣι', + 'ᾤ' => 'ὤι', + 'ᾥ' => 'ὥι', + 'ᾦ' => 'ὦι', + 'ᾧ' => 'ὧι', + 'ᾨ' => 'ὠι', + 'ᾩ' => 'ὡι', + 'ᾪ' => 'ὢι', + 'ᾫ' => 'ὣι', + 'ᾬ' => 'ὤι', + 'ᾭ' => 'ὥι', + 'ᾮ' => 'ὦι', + 'ᾯ' => 'ὧι', + 'ᾲ' => 'ὰι', + 'ᾳ' => 'αι', + 'ᾴ' => 'άι', + 'ᾶ' => 'ᾶ', + 'ᾷ' => 'ᾶι', + 'ᾼ' => 'αι', + 'ῂ' => 'ὴι', + 'ῃ' => 'ηι', + 'ῄ' => 'ήι', + 'ῆ' => 'ῆ', + 'ῇ' => 'ῆι', + 'ῌ' => 'ηι', + 'ῒ' => 'ῒ', + 'ῖ' => 'ῖ', + 'ῗ' => 'ῗ', + 'ῢ' => 'ῢ', + 'ῤ' => 'ῤ', + 'ῦ' => 'ῦ', + 'ῧ' => 'ῧ', + 'ῲ' => 'ὼι', + 'ῳ' => 'ωι', + 'ῴ' => 'ώι', + 'ῶ' => 'ῶ', + 'ῷ' => 'ῶι', + 'ῼ' => 'ωι', + 'ff' => 'ff', + 'fi' => 'fi', + 'fl' => 'fl', + 'ffi' => 'ffi', + 'ffl' => 'ffl', + 'ſt' => 'st', + 'st' => 'st', + 'ﬓ' => 'մն', + 'ﬔ' => 'մե', + 'ﬕ' => 'մի', + 'ﬖ' => 'վն', + 'ﬗ' => 'մխ', +]; diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php new file mode 100644 index 0000000..fac60b0 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php @@ -0,0 +1,1397 @@ + 'a', + 'B' => 'b', + 'C' => 'c', + 'D' => 'd', + 'E' => 'e', + 'F' => 'f', + 'G' => 'g', + 'H' => 'h', + 'I' => 'i', + 'J' => 'j', + 'K' => 'k', + 'L' => 'l', + 'M' => 'm', + 'N' => 'n', + 'O' => 'o', + 'P' => 'p', + 'Q' => 'q', + 'R' => 'r', + 'S' => 's', + 'T' => 't', + 'U' => 'u', + 'V' => 'v', + 'W' => 'w', + 'X' => 'x', + 'Y' => 'y', + 'Z' => 'z', + 'À' => 'à', + 'Á' => 'á', + 'Â' => 'â', + 'Ã' => 'ã', + 'Ä' => 'ä', + 'Å' => 'å', + 'Æ' => 'æ', + 'Ç' => 'ç', + 'È' => 'è', + 'É' => 'é', + 'Ê' => 'ê', + 'Ë' => 'ë', + 'Ì' => 'ì', + 'Í' => 'í', + 'Î' => 'î', + 'Ï' => 'ï', + 'Ð' => 'ð', + 'Ñ' => 'ñ', + 'Ò' => 'ò', + 'Ó' => 'ó', + 'Ô' => 'ô', + 'Õ' => 'õ', + 'Ö' => 'ö', + 'Ø' => 'ø', + 'Ù' => 'ù', + 'Ú' => 'ú', + 'Û' => 'û', + 'Ü' => 'ü', + 'Ý' => 'ý', + 'Þ' => 'þ', + 'Ā' => 'ā', + 'Ă' => 'ă', + 'Ą' => 'ą', + 'Ć' => 'ć', + 'Ĉ' => 'ĉ', + 'Ċ' => 'ċ', + 'Č' => 'č', + 'Ď' => 'ď', + 'Đ' => 'đ', + 'Ē' => 'ē', + 'Ĕ' => 'ĕ', + 'Ė' => 'ė', + 'Ę' => 'ę', + 'Ě' => 'ě', + 'Ĝ' => 'ĝ', + 'Ğ' => 'ğ', + 'Ġ' => 'ġ', + 'Ģ' => 'ģ', + 'Ĥ' => 'ĥ', + 'Ħ' => 'ħ', + 'Ĩ' => 'ĩ', + 'Ī' => 'ī', + 'Ĭ' => 'ĭ', + 'Į' => 'į', + 'İ' => 'i̇', + 'IJ' => 'ij', + 'Ĵ' => 'ĵ', + 'Ķ' => 'ķ', + 'Ĺ' => 'ĺ', + 'Ļ' => 'ļ', + 'Ľ' => 'ľ', + 'Ŀ' => 'ŀ', + 'Ł' => 'ł', + 'Ń' => 'ń', + 'Ņ' => 'ņ', + 'Ň' => 'ň', + 'Ŋ' => 'ŋ', + 'Ō' => 'ō', + 'Ŏ' => 'ŏ', + 'Ő' => 'ő', + 'Œ' => 'œ', + 'Ŕ' => 'ŕ', + 'Ŗ' => 'ŗ', + 'Ř' => 'ř', + 'Ś' => 'ś', + 'Ŝ' => 'ŝ', + 'Ş' => 'ş', + 'Š' => 'š', + 'Ţ' => 'ţ', + 'Ť' => 'ť', + 'Ŧ' => 'ŧ', + 'Ũ' => 'ũ', + 'Ū' => 'ū', + 'Ŭ' => 'ŭ', + 'Ů' => 'ů', + 'Ű' => 'ű', + 'Ų' => 'ų', + 'Ŵ' => 'ŵ', + 'Ŷ' => 'ŷ', + 'Ÿ' => 'ÿ', + 'Ź' => 'ź', + 'Ż' => 'ż', + 'Ž' => 'ž', + 'Ɓ' => 'ɓ', + 'Ƃ' => 'ƃ', + 'Ƅ' => 'ƅ', + 'Ɔ' => 'ɔ', + 'Ƈ' => 'ƈ', + 'Ɖ' => 'ɖ', + 'Ɗ' => 'ɗ', + 'Ƌ' => 'ƌ', + 'Ǝ' => 'ǝ', + 'Ə' => 'ə', + 'Ɛ' => 'ɛ', + 'Ƒ' => 'ƒ', + 'Ɠ' => 'ɠ', + 'Ɣ' => 'ɣ', + 'Ɩ' => 'ɩ', + 'Ɨ' => 'ɨ', + 'Ƙ' => 'ƙ', + 'Ɯ' => 'ɯ', + 'Ɲ' => 'ɲ', + 'Ɵ' => 'ɵ', + 'Ơ' => 'ơ', + 'Ƣ' => 'ƣ', + 'Ƥ' => 'ƥ', + 'Ʀ' => 'ʀ', + 'Ƨ' => 'ƨ', + 'Ʃ' => 'ʃ', + 'Ƭ' => 'ƭ', + 'Ʈ' => 'ʈ', + 'Ư' => 'ư', + 'Ʊ' => 'ʊ', + 'Ʋ' => 'ʋ', + 'Ƴ' => 'ƴ', + 'Ƶ' => 'ƶ', + 'Ʒ' => 'ʒ', + 'Ƹ' => 'ƹ', + 'Ƽ' => 'ƽ', + 'DŽ' => 'dž', + 'Dž' => 'dž', + 'LJ' => 'lj', + 'Lj' => 'lj', + 'NJ' => 'nj', + 'Nj' => 'nj', + 'Ǎ' => 'ǎ', + 'Ǐ' => 'ǐ', + 'Ǒ' => 'ǒ', + 'Ǔ' => 'ǔ', + 'Ǖ' => 'ǖ', + 'Ǘ' => 'ǘ', + 'Ǚ' => 'ǚ', + 'Ǜ' => 'ǜ', + 'Ǟ' => 'ǟ', + 'Ǡ' => 'ǡ', + 'Ǣ' => 'ǣ', + 'Ǥ' => 'ǥ', + 'Ǧ' => 'ǧ', + 'Ǩ' => 'ǩ', + 'Ǫ' => 'ǫ', + 'Ǭ' => 'ǭ', + 'Ǯ' => 'ǯ', + 'DZ' => 'dz', + 'Dz' => 'dz', + 'Ǵ' => 'ǵ', + 'Ƕ' => 'ƕ', + 'Ƿ' => 'ƿ', + 'Ǹ' => 'ǹ', + 'Ǻ' => 'ǻ', + 'Ǽ' => 'ǽ', + 'Ǿ' => 'ǿ', + 'Ȁ' => 'ȁ', + 'Ȃ' => 'ȃ', + 'Ȅ' => 'ȅ', + 'Ȇ' => 'ȇ', + 'Ȉ' => 'ȉ', + 'Ȋ' => 'ȋ', + 'Ȍ' => 'ȍ', + 'Ȏ' => 'ȏ', + 'Ȑ' => 'ȑ', + 'Ȓ' => 'ȓ', + 'Ȕ' => 'ȕ', + 'Ȗ' => 'ȗ', + 'Ș' => 'ș', + 'Ț' => 'ț', + 'Ȝ' => 'ȝ', + 'Ȟ' => 'ȟ', + 'Ƞ' => 'ƞ', + 'Ȣ' => 'ȣ', + 'Ȥ' => 'ȥ', + 'Ȧ' => 'ȧ', + 'Ȩ' => 'ȩ', + 'Ȫ' => 'ȫ', + 'Ȭ' => 'ȭ', + 'Ȯ' => 'ȯ', + 'Ȱ' => 'ȱ', + 'Ȳ' => 'ȳ', + 'Ⱥ' => 'ⱥ', + 'Ȼ' => 'ȼ', + 'Ƚ' => 'ƚ', + 'Ⱦ' => 'ⱦ', + 'Ɂ' => 'ɂ', + 'Ƀ' => 'ƀ', + 'Ʉ' => 'ʉ', + 'Ʌ' => 'ʌ', + 'Ɇ' => 'ɇ', + 'Ɉ' => 'ɉ', + 'Ɋ' => 'ɋ', + 'Ɍ' => 'ɍ', + 'Ɏ' => 'ɏ', + 'Ͱ' => 'ͱ', + 'Ͳ' => 'ͳ', + 'Ͷ' => 'ͷ', + 'Ϳ' => 'ϳ', + 'Ά' => 'ά', + 'Έ' => 'έ', + 'Ή' => 'ή', + 'Ί' => 'ί', + 'Ό' => 'ό', + 'Ύ' => 'ύ', + 'Ώ' => 'ώ', + 'Α' => 'α', + 'Β' => 'β', + 'Γ' => 'γ', + 'Δ' => 'δ', + 'Ε' => 'ε', + 'Ζ' => 'ζ', + 'Η' => 'η', + 'Θ' => 'θ', + 'Ι' => 'ι', + 'Κ' => 'κ', + 'Λ' => 'λ', + 'Μ' => 'μ', + 'Ν' => 'ν', + 'Ξ' => 'ξ', + 'Ο' => 'ο', + 'Π' => 'π', + 'Ρ' => 'ρ', + 'Σ' => 'σ', + 'Τ' => 'τ', + 'Υ' => 'υ', + 'Φ' => 'φ', + 'Χ' => 'χ', + 'Ψ' => 'ψ', + 'Ω' => 'ω', + 'Ϊ' => 'ϊ', + 'Ϋ' => 'ϋ', + 'Ϗ' => 'ϗ', + 'Ϙ' => 'ϙ', + 'Ϛ' => 'ϛ', + 'Ϝ' => 'ϝ', + 'Ϟ' => 'ϟ', + 'Ϡ' => 'ϡ', + 'Ϣ' => 'ϣ', + 'Ϥ' => 'ϥ', + 'Ϧ' => 'ϧ', + 'Ϩ' => 'ϩ', + 'Ϫ' => 'ϫ', + 'Ϭ' => 'ϭ', + 'Ϯ' => 'ϯ', + 'ϴ' => 'θ', + 'Ϸ' => 'ϸ', + 'Ϲ' => 'ϲ', + 'Ϻ' => 'ϻ', + 'Ͻ' => 'ͻ', + 'Ͼ' => 'ͼ', + 'Ͽ' => 'ͽ', + 'Ѐ' => 'ѐ', + 'Ё' => 'ё', + 'Ђ' => 'ђ', + 'Ѓ' => 'ѓ', + 'Є' => 'є', + 'Ѕ' => 'ѕ', + 'І' => 'і', + 'Ї' => 'ї', + 'Ј' => 'ј', + 'Љ' => 'љ', + 'Њ' => 'њ', + 'Ћ' => 'ћ', + 'Ќ' => 'ќ', + 'Ѝ' => 'ѝ', + 'Ў' => 'ў', + 'Џ' => 'џ', + 'А' => 'а', + 'Б' => 'б', + 'В' => 'в', + 'Г' => 'г', + 'Д' => 'д', + 'Е' => 'е', + 'Ж' => 'ж', + 'З' => 'з', + 'И' => 'и', + 'Й' => 'й', + 'К' => 'к', + 'Л' => 'л', + 'М' => 'м', + 'Н' => 'н', + 'О' => 'о', + 'П' => 'п', + 'Р' => 'р', + 'С' => 'с', + 'Т' => 'т', + 'У' => 'у', + 'Ф' => 'ф', + 'Х' => 'х', + 'Ц' => 'ц', + 'Ч' => 'ч', + 'Ш' => 'ш', + 'Щ' => 'щ', + 'Ъ' => 'ъ', + 'Ы' => 'ы', + 'Ь' => 'ь', + 'Э' => 'э', + 'Ю' => 'ю', + 'Я' => 'я', + 'Ѡ' => 'ѡ', + 'Ѣ' => 'ѣ', + 'Ѥ' => 'ѥ', + 'Ѧ' => 'ѧ', + 'Ѩ' => 'ѩ', + 'Ѫ' => 'ѫ', + 'Ѭ' => 'ѭ', + 'Ѯ' => 'ѯ', + 'Ѱ' => 'ѱ', + 'Ѳ' => 'ѳ', + 'Ѵ' => 'ѵ', + 'Ѷ' => 'ѷ', + 'Ѹ' => 'ѹ', + 'Ѻ' => 'ѻ', + 'Ѽ' => 'ѽ', + 'Ѿ' => 'ѿ', + 'Ҁ' => 'ҁ', + 'Ҋ' => 'ҋ', + 'Ҍ' => 'ҍ', + 'Ҏ' => 'ҏ', + 'Ґ' => 'ґ', + 'Ғ' => 'ғ', + 'Ҕ' => 'ҕ', + 'Җ' => 'җ', + 'Ҙ' => 'ҙ', + 'Қ' => 'қ', + 'Ҝ' => 'ҝ', + 'Ҟ' => 'ҟ', + 'Ҡ' => 'ҡ', + 'Ң' => 'ң', + 'Ҥ' => 'ҥ', + 'Ҧ' => 'ҧ', + 'Ҩ' => 'ҩ', + 'Ҫ' => 'ҫ', + 'Ҭ' => 'ҭ', + 'Ү' => 'ү', + 'Ұ' => 'ұ', + 'Ҳ' => 'ҳ', + 'Ҵ' => 'ҵ', + 'Ҷ' => 'ҷ', + 'Ҹ' => 'ҹ', + 'Һ' => 'һ', + 'Ҽ' => 'ҽ', + 'Ҿ' => 'ҿ', + 'Ӏ' => 'ӏ', + 'Ӂ' => 'ӂ', + 'Ӄ' => 'ӄ', + 'Ӆ' => 'ӆ', + 'Ӈ' => 'ӈ', + 'Ӊ' => 'ӊ', + 'Ӌ' => 'ӌ', + 'Ӎ' => 'ӎ', + 'Ӑ' => 'ӑ', + 'Ӓ' => 'ӓ', + 'Ӕ' => 'ӕ', + 'Ӗ' => 'ӗ', + 'Ә' => 'ә', + 'Ӛ' => 'ӛ', + 'Ӝ' => 'ӝ', + 'Ӟ' => 'ӟ', + 'Ӡ' => 'ӡ', + 'Ӣ' => 'ӣ', + 'Ӥ' => 'ӥ', + 'Ӧ' => 'ӧ', + 'Ө' => 'ө', + 'Ӫ' => 'ӫ', + 'Ӭ' => 'ӭ', + 'Ӯ' => 'ӯ', + 'Ӱ' => 'ӱ', + 'Ӳ' => 'ӳ', + 'Ӵ' => 'ӵ', + 'Ӷ' => 'ӷ', + 'Ӹ' => 'ӹ', + 'Ӻ' => 'ӻ', + 'Ӽ' => 'ӽ', + 'Ӿ' => 'ӿ', + 'Ԁ' => 'ԁ', + 'Ԃ' => 'ԃ', + 'Ԅ' => 'ԅ', + 'Ԇ' => 'ԇ', + 'Ԉ' => 'ԉ', + 'Ԋ' => 'ԋ', + 'Ԍ' => 'ԍ', + 'Ԏ' => 'ԏ', + 'Ԑ' => 'ԑ', + 'Ԓ' => 'ԓ', + 'Ԕ' => 'ԕ', + 'Ԗ' => 'ԗ', + 'Ԙ' => 'ԙ', + 'Ԛ' => 'ԛ', + 'Ԝ' => 'ԝ', + 'Ԟ' => 'ԟ', + 'Ԡ' => 'ԡ', + 'Ԣ' => 'ԣ', + 'Ԥ' => 'ԥ', + 'Ԧ' => 'ԧ', + 'Ԩ' => 'ԩ', + 'Ԫ' => 'ԫ', + 'Ԭ' => 'ԭ', + 'Ԯ' => 'ԯ', + 'Ա' => 'ա', + 'Բ' => 'բ', + 'Գ' => 'գ', + 'Դ' => 'դ', + 'Ե' => 'ե', + 'Զ' => 'զ', + 'Է' => 'է', + 'Ը' => 'ը', + 'Թ' => 'թ', + 'Ժ' => 'ժ', + 'Ի' => 'ի', + 'Լ' => 'լ', + 'Խ' => 'խ', + 'Ծ' => 'ծ', + 'Կ' => 'կ', + 'Հ' => 'հ', + 'Ձ' => 'ձ', + 'Ղ' => 'ղ', + 'Ճ' => 'ճ', + 'Մ' => 'մ', + 'Յ' => 'յ', + 'Ն' => 'ն', + 'Շ' => 'շ', + 'Ո' => 'ո', + 'Չ' => 'չ', + 'Պ' => 'պ', + 'Ջ' => 'ջ', + 'Ռ' => 'ռ', + 'Ս' => 'ս', + 'Վ' => 'վ', + 'Տ' => 'տ', + 'Ր' => 'ր', + 'Ց' => 'ց', + 'Ւ' => 'ւ', + 'Փ' => 'փ', + 'Ք' => 'ք', + 'Օ' => 'օ', + 'Ֆ' => 'ֆ', + 'Ⴀ' => 'ⴀ', + 'Ⴁ' => 'ⴁ', + 'Ⴂ' => 'ⴂ', + 'Ⴃ' => 'ⴃ', + 'Ⴄ' => 'ⴄ', + 'Ⴅ' => 'ⴅ', + 'Ⴆ' => 'ⴆ', + 'Ⴇ' => 'ⴇ', + 'Ⴈ' => 'ⴈ', + 'Ⴉ' => 'ⴉ', + 'Ⴊ' => 'ⴊ', + 'Ⴋ' => 'ⴋ', + 'Ⴌ' => 'ⴌ', + 'Ⴍ' => 'ⴍ', + 'Ⴎ' => 'ⴎ', + 'Ⴏ' => 'ⴏ', + 'Ⴐ' => 'ⴐ', + 'Ⴑ' => 'ⴑ', + 'Ⴒ' => 'ⴒ', + 'Ⴓ' => 'ⴓ', + 'Ⴔ' => 'ⴔ', + 'Ⴕ' => 'ⴕ', + 'Ⴖ' => 'ⴖ', + 'Ⴗ' => 'ⴗ', + 'Ⴘ' => 'ⴘ', + 'Ⴙ' => 'ⴙ', + 'Ⴚ' => 'ⴚ', + 'Ⴛ' => 'ⴛ', + 'Ⴜ' => 'ⴜ', + 'Ⴝ' => 'ⴝ', + 'Ⴞ' => 'ⴞ', + 'Ⴟ' => 'ⴟ', + 'Ⴠ' => 'ⴠ', + 'Ⴡ' => 'ⴡ', + 'Ⴢ' => 'ⴢ', + 'Ⴣ' => 'ⴣ', + 'Ⴤ' => 'ⴤ', + 'Ⴥ' => 'ⴥ', + 'Ⴧ' => 'ⴧ', + 'Ⴭ' => 'ⴭ', + 'Ꭰ' => 'ꭰ', + 'Ꭱ' => 'ꭱ', + 'Ꭲ' => 'ꭲ', + 'Ꭳ' => 'ꭳ', + 'Ꭴ' => 'ꭴ', + 'Ꭵ' => 'ꭵ', + 'Ꭶ' => 'ꭶ', + 'Ꭷ' => 'ꭷ', + 'Ꭸ' => 'ꭸ', + 'Ꭹ' => 'ꭹ', + 'Ꭺ' => 'ꭺ', + 'Ꭻ' => 'ꭻ', + 'Ꭼ' => 'ꭼ', + 'Ꭽ' => 'ꭽ', + 'Ꭾ' => 'ꭾ', + 'Ꭿ' => 'ꭿ', + 'Ꮀ' => 'ꮀ', + 'Ꮁ' => 'ꮁ', + 'Ꮂ' => 'ꮂ', + 'Ꮃ' => 'ꮃ', + 'Ꮄ' => 'ꮄ', + 'Ꮅ' => 'ꮅ', + 'Ꮆ' => 'ꮆ', + 'Ꮇ' => 'ꮇ', + 'Ꮈ' => 'ꮈ', + 'Ꮉ' => 'ꮉ', + 'Ꮊ' => 'ꮊ', + 'Ꮋ' => 'ꮋ', + 'Ꮌ' => 'ꮌ', + 'Ꮍ' => 'ꮍ', + 'Ꮎ' => 'ꮎ', + 'Ꮏ' => 'ꮏ', + 'Ꮐ' => 'ꮐ', + 'Ꮑ' => 'ꮑ', + 'Ꮒ' => 'ꮒ', + 'Ꮓ' => 'ꮓ', + 'Ꮔ' => 'ꮔ', + 'Ꮕ' => 'ꮕ', + 'Ꮖ' => 'ꮖ', + 'Ꮗ' => 'ꮗ', + 'Ꮘ' => 'ꮘ', + 'Ꮙ' => 'ꮙ', + 'Ꮚ' => 'ꮚ', + 'Ꮛ' => 'ꮛ', + 'Ꮜ' => 'ꮜ', + 'Ꮝ' => 'ꮝ', + 'Ꮞ' => 'ꮞ', + 'Ꮟ' => 'ꮟ', + 'Ꮠ' => 'ꮠ', + 'Ꮡ' => 'ꮡ', + 'Ꮢ' => 'ꮢ', + 'Ꮣ' => 'ꮣ', + 'Ꮤ' => 'ꮤ', + 'Ꮥ' => 'ꮥ', + 'Ꮦ' => 'ꮦ', + 'Ꮧ' => 'ꮧ', + 'Ꮨ' => 'ꮨ', + 'Ꮩ' => 'ꮩ', + 'Ꮪ' => 'ꮪ', + 'Ꮫ' => 'ꮫ', + 'Ꮬ' => 'ꮬ', + 'Ꮭ' => 'ꮭ', + 'Ꮮ' => 'ꮮ', + 'Ꮯ' => 'ꮯ', + 'Ꮰ' => 'ꮰ', + 'Ꮱ' => 'ꮱ', + 'Ꮲ' => 'ꮲ', + 'Ꮳ' => 'ꮳ', + 'Ꮴ' => 'ꮴ', + 'Ꮵ' => 'ꮵ', + 'Ꮶ' => 'ꮶ', + 'Ꮷ' => 'ꮷ', + 'Ꮸ' => 'ꮸ', + 'Ꮹ' => 'ꮹ', + 'Ꮺ' => 'ꮺ', + 'Ꮻ' => 'ꮻ', + 'Ꮼ' => 'ꮼ', + 'Ꮽ' => 'ꮽ', + 'Ꮾ' => 'ꮾ', + 'Ꮿ' => 'ꮿ', + 'Ᏸ' => 'ᏸ', + 'Ᏹ' => 'ᏹ', + 'Ᏺ' => 'ᏺ', + 'Ᏻ' => 'ᏻ', + 'Ᏼ' => 'ᏼ', + 'Ᏽ' => 'ᏽ', + 'Ა' => 'ა', + 'Ბ' => 'ბ', + 'Გ' => 'გ', + 'Დ' => 'დ', + 'Ე' => 'ე', + 'Ვ' => 'ვ', + 'Ზ' => 'ზ', + 'Თ' => 'თ', + 'Ი' => 'ი', + 'Კ' => 'კ', + 'Ლ' => 'ლ', + 'Მ' => 'მ', + 'Ნ' => 'ნ', + 'Ო' => 'ო', + 'Პ' => 'პ', + 'Ჟ' => 'ჟ', + 'Რ' => 'რ', + 'Ს' => 'ს', + 'Ტ' => 'ტ', + 'Უ' => 'უ', + 'Ფ' => 'ფ', + 'Ქ' => 'ქ', + 'Ღ' => 'ღ', + 'Ყ' => 'ყ', + 'Შ' => 'შ', + 'Ჩ' => 'ჩ', + 'Ც' => 'ც', + 'Ძ' => 'ძ', + 'Წ' => 'წ', + 'Ჭ' => 'ჭ', + 'Ხ' => 'ხ', + 'Ჯ' => 'ჯ', + 'Ჰ' => 'ჰ', + 'Ჱ' => 'ჱ', + 'Ჲ' => 'ჲ', + 'Ჳ' => 'ჳ', + 'Ჴ' => 'ჴ', + 'Ჵ' => 'ჵ', + 'Ჶ' => 'ჶ', + 'Ჷ' => 'ჷ', + 'Ჸ' => 'ჸ', + 'Ჹ' => 'ჹ', + 'Ჺ' => 'ჺ', + 'Ჽ' => 'ჽ', + 'Ჾ' => 'ჾ', + 'Ჿ' => 'ჿ', + 'Ḁ' => 'ḁ', + 'Ḃ' => 'ḃ', + 'Ḅ' => 'ḅ', + 'Ḇ' => 'ḇ', + 'Ḉ' => 'ḉ', + 'Ḋ' => 'ḋ', + 'Ḍ' => 'ḍ', + 'Ḏ' => 'ḏ', + 'Ḑ' => 'ḑ', + 'Ḓ' => 'ḓ', + 'Ḕ' => 'ḕ', + 'Ḗ' => 'ḗ', + 'Ḙ' => 'ḙ', + 'Ḛ' => 'ḛ', + 'Ḝ' => 'ḝ', + 'Ḟ' => 'ḟ', + 'Ḡ' => 'ḡ', + 'Ḣ' => 'ḣ', + 'Ḥ' => 'ḥ', + 'Ḧ' => 'ḧ', + 'Ḩ' => 'ḩ', + 'Ḫ' => 'ḫ', + 'Ḭ' => 'ḭ', + 'Ḯ' => 'ḯ', + 'Ḱ' => 'ḱ', + 'Ḳ' => 'ḳ', + 'Ḵ' => 'ḵ', + 'Ḷ' => 'ḷ', + 'Ḹ' => 'ḹ', + 'Ḻ' => 'ḻ', + 'Ḽ' => 'ḽ', + 'Ḿ' => 'ḿ', + 'Ṁ' => 'ṁ', + 'Ṃ' => 'ṃ', + 'Ṅ' => 'ṅ', + 'Ṇ' => 'ṇ', + 'Ṉ' => 'ṉ', + 'Ṋ' => 'ṋ', + 'Ṍ' => 'ṍ', + 'Ṏ' => 'ṏ', + 'Ṑ' => 'ṑ', + 'Ṓ' => 'ṓ', + 'Ṕ' => 'ṕ', + 'Ṗ' => 'ṗ', + 'Ṙ' => 'ṙ', + 'Ṛ' => 'ṛ', + 'Ṝ' => 'ṝ', + 'Ṟ' => 'ṟ', + 'Ṡ' => 'ṡ', + 'Ṣ' => 'ṣ', + 'Ṥ' => 'ṥ', + 'Ṧ' => 'ṧ', + 'Ṩ' => 'ṩ', + 'Ṫ' => 'ṫ', + 'Ṭ' => 'ṭ', + 'Ṯ' => 'ṯ', + 'Ṱ' => 'ṱ', + 'Ṳ' => 'ṳ', + 'Ṵ' => 'ṵ', + 'Ṷ' => 'ṷ', + 'Ṹ' => 'ṹ', + 'Ṻ' => 'ṻ', + 'Ṽ' => 'ṽ', + 'Ṿ' => 'ṿ', + 'Ẁ' => 'ẁ', + 'Ẃ' => 'ẃ', + 'Ẅ' => 'ẅ', + 'Ẇ' => 'ẇ', + 'Ẉ' => 'ẉ', + 'Ẋ' => 'ẋ', + 'Ẍ' => 'ẍ', + 'Ẏ' => 'ẏ', + 'Ẑ' => 'ẑ', + 'Ẓ' => 'ẓ', + 'Ẕ' => 'ẕ', + 'ẞ' => 'ß', + 'Ạ' => 'ạ', + 'Ả' => 'ả', + 'Ấ' => 'ấ', + 'Ầ' => 'ầ', + 'Ẩ' => 'ẩ', + 'Ẫ' => 'ẫ', + 'Ậ' => 'ậ', + 'Ắ' => 'ắ', + 'Ằ' => 'ằ', + 'Ẳ' => 'ẳ', + 'Ẵ' => 'ẵ', + 'Ặ' => 'ặ', + 'Ẹ' => 'ẹ', + 'Ẻ' => 'ẻ', + 'Ẽ' => 'ẽ', + 'Ế' => 'ế', + 'Ề' => 'ề', + 'Ể' => 'ể', + 'Ễ' => 'ễ', + 'Ệ' => 'ệ', + 'Ỉ' => 'ỉ', + 'Ị' => 'ị', + 'Ọ' => 'ọ', + 'Ỏ' => 'ỏ', + 'Ố' => 'ố', + 'Ồ' => 'ồ', + 'Ổ' => 'ổ', + 'Ỗ' => 'ỗ', + 'Ộ' => 'ộ', + 'Ớ' => 'ớ', + 'Ờ' => 'ờ', + 'Ở' => 'ở', + 'Ỡ' => 'ỡ', + 'Ợ' => 'ợ', + 'Ụ' => 'ụ', + 'Ủ' => 'ủ', + 'Ứ' => 'ứ', + 'Ừ' => 'ừ', + 'Ử' => 'ử', + 'Ữ' => 'ữ', + 'Ự' => 'ự', + 'Ỳ' => 'ỳ', + 'Ỵ' => 'ỵ', + 'Ỷ' => 'ỷ', + 'Ỹ' => 'ỹ', + 'Ỻ' => 'ỻ', + 'Ỽ' => 'ỽ', + 'Ỿ' => 'ỿ', + 'Ἀ' => 'ἀ', + 'Ἁ' => 'ἁ', + 'Ἂ' => 'ἂ', + 'Ἃ' => 'ἃ', + 'Ἄ' => 'ἄ', + 'Ἅ' => 'ἅ', + 'Ἆ' => 'ἆ', + 'Ἇ' => 'ἇ', + 'Ἐ' => 'ἐ', + 'Ἑ' => 'ἑ', + 'Ἒ' => 'ἒ', + 'Ἓ' => 'ἓ', + 'Ἔ' => 'ἔ', + 'Ἕ' => 'ἕ', + 'Ἠ' => 'ἠ', + 'Ἡ' => 'ἡ', + 'Ἢ' => 'ἢ', + 'Ἣ' => 'ἣ', + 'Ἤ' => 'ἤ', + 'Ἥ' => 'ἥ', + 'Ἦ' => 'ἦ', + 'Ἧ' => 'ἧ', + 'Ἰ' => 'ἰ', + 'Ἱ' => 'ἱ', + 'Ἲ' => 'ἲ', + 'Ἳ' => 'ἳ', + 'Ἴ' => 'ἴ', + 'Ἵ' => 'ἵ', + 'Ἶ' => 'ἶ', + 'Ἷ' => 'ἷ', + 'Ὀ' => 'ὀ', + 'Ὁ' => 'ὁ', + 'Ὂ' => 'ὂ', + 'Ὃ' => 'ὃ', + 'Ὄ' => 'ὄ', + 'Ὅ' => 'ὅ', + 'Ὑ' => 'ὑ', + 'Ὓ' => 'ὓ', + 'Ὕ' => 'ὕ', + 'Ὗ' => 'ὗ', + 'Ὠ' => 'ὠ', + 'Ὡ' => 'ὡ', + 'Ὢ' => 'ὢ', + 'Ὣ' => 'ὣ', + 'Ὤ' => 'ὤ', + 'Ὥ' => 'ὥ', + 'Ὦ' => 'ὦ', + 'Ὧ' => 'ὧ', + 'ᾈ' => 'ᾀ', + 'ᾉ' => 'ᾁ', + 'ᾊ' => 'ᾂ', + 'ᾋ' => 'ᾃ', + 'ᾌ' => 'ᾄ', + 'ᾍ' => 'ᾅ', + 'ᾎ' => 'ᾆ', + 'ᾏ' => 'ᾇ', + 'ᾘ' => 'ᾐ', + 'ᾙ' => 'ᾑ', + 'ᾚ' => 'ᾒ', + 'ᾛ' => 'ᾓ', + 'ᾜ' => 'ᾔ', + 'ᾝ' => 'ᾕ', + 'ᾞ' => 'ᾖ', + 'ᾟ' => 'ᾗ', + 'ᾨ' => 'ᾠ', + 'ᾩ' => 'ᾡ', + 'ᾪ' => 'ᾢ', + 'ᾫ' => 'ᾣ', + 'ᾬ' => 'ᾤ', + 'ᾭ' => 'ᾥ', + 'ᾮ' => 'ᾦ', + 'ᾯ' => 'ᾧ', + 'Ᾰ' => 'ᾰ', + 'Ᾱ' => 'ᾱ', + 'Ὰ' => 'ὰ', + 'Ά' => 'ά', + 'ᾼ' => 'ᾳ', + 'Ὲ' => 'ὲ', + 'Έ' => 'έ', + 'Ὴ' => 'ὴ', + 'Ή' => 'ή', + 'ῌ' => 'ῃ', + 'Ῐ' => 'ῐ', + 'Ῑ' => 'ῑ', + 'Ὶ' => 'ὶ', + 'Ί' => 'ί', + 'Ῠ' => 'ῠ', + 'Ῡ' => 'ῡ', + 'Ὺ' => 'ὺ', + 'Ύ' => 'ύ', + 'Ῥ' => 'ῥ', + 'Ὸ' => 'ὸ', + 'Ό' => 'ό', + 'Ὼ' => 'ὼ', + 'Ώ' => 'ώ', + 'ῼ' => 'ῳ', + 'Ω' => 'ω', + 'K' => 'k', + 'Å' => 'å', + 'Ⅎ' => 'ⅎ', + 'Ⅰ' => 'ⅰ', + 'Ⅱ' => 'ⅱ', + 'Ⅲ' => 'ⅲ', + 'Ⅳ' => 'ⅳ', + 'Ⅴ' => 'ⅴ', + 'Ⅵ' => 'ⅵ', + 'Ⅶ' => 'ⅶ', + 'Ⅷ' => 'ⅷ', + 'Ⅸ' => 'ⅸ', + 'Ⅹ' => 'ⅹ', + 'Ⅺ' => 'ⅺ', + 'Ⅻ' => 'ⅻ', + 'Ⅼ' => 'ⅼ', + 'Ⅽ' => 'ⅽ', + 'Ⅾ' => 'ⅾ', + 'Ⅿ' => 'ⅿ', + 'Ↄ' => 'ↄ', + 'Ⓐ' => 'ⓐ', + 'Ⓑ' => 'ⓑ', + 'Ⓒ' => 'ⓒ', + 'Ⓓ' => 'ⓓ', + 'Ⓔ' => 'ⓔ', + 'Ⓕ' => 'ⓕ', + 'Ⓖ' => 'ⓖ', + 'Ⓗ' => 'ⓗ', + 'Ⓘ' => 'ⓘ', + 'Ⓙ' => 'ⓙ', + 'Ⓚ' => 'ⓚ', + 'Ⓛ' => 'ⓛ', + 'Ⓜ' => 'ⓜ', + 'Ⓝ' => 'ⓝ', + 'Ⓞ' => 'ⓞ', + 'Ⓟ' => 'ⓟ', + 'Ⓠ' => 'ⓠ', + 'Ⓡ' => 'ⓡ', + 'Ⓢ' => 'ⓢ', + 'Ⓣ' => 'ⓣ', + 'Ⓤ' => 'ⓤ', + 'Ⓥ' => 'ⓥ', + 'Ⓦ' => 'ⓦ', + 'Ⓧ' => 'ⓧ', + 'Ⓨ' => 'ⓨ', + 'Ⓩ' => 'ⓩ', + 'Ⰰ' => 'ⰰ', + 'Ⰱ' => 'ⰱ', + 'Ⰲ' => 'ⰲ', + 'Ⰳ' => 'ⰳ', + 'Ⰴ' => 'ⰴ', + 'Ⰵ' => 'ⰵ', + 'Ⰶ' => 'ⰶ', + 'Ⰷ' => 'ⰷ', + 'Ⰸ' => 'ⰸ', + 'Ⰹ' => 'ⰹ', + 'Ⰺ' => 'ⰺ', + 'Ⰻ' => 'ⰻ', + 'Ⰼ' => 'ⰼ', + 'Ⰽ' => 'ⰽ', + 'Ⰾ' => 'ⰾ', + 'Ⰿ' => 'ⰿ', + 'Ⱀ' => 'ⱀ', + 'Ⱁ' => 'ⱁ', + 'Ⱂ' => 'ⱂ', + 'Ⱃ' => 'ⱃ', + 'Ⱄ' => 'ⱄ', + 'Ⱅ' => 'ⱅ', + 'Ⱆ' => 'ⱆ', + 'Ⱇ' => 'ⱇ', + 'Ⱈ' => 'ⱈ', + 'Ⱉ' => 'ⱉ', + 'Ⱊ' => 'ⱊ', + 'Ⱋ' => 'ⱋ', + 'Ⱌ' => 'ⱌ', + 'Ⱍ' => 'ⱍ', + 'Ⱎ' => 'ⱎ', + 'Ⱏ' => 'ⱏ', + 'Ⱐ' => 'ⱐ', + 'Ⱑ' => 'ⱑ', + 'Ⱒ' => 'ⱒ', + 'Ⱓ' => 'ⱓ', + 'Ⱔ' => 'ⱔ', + 'Ⱕ' => 'ⱕ', + 'Ⱖ' => 'ⱖ', + 'Ⱗ' => 'ⱗ', + 'Ⱘ' => 'ⱘ', + 'Ⱙ' => 'ⱙ', + 'Ⱚ' => 'ⱚ', + 'Ⱛ' => 'ⱛ', + 'Ⱜ' => 'ⱜ', + 'Ⱝ' => 'ⱝ', + 'Ⱞ' => 'ⱞ', + 'Ⱡ' => 'ⱡ', + 'Ɫ' => 'ɫ', + 'Ᵽ' => 'ᵽ', + 'Ɽ' => 'ɽ', + 'Ⱨ' => 'ⱨ', + 'Ⱪ' => 'ⱪ', + 'Ⱬ' => 'ⱬ', + 'Ɑ' => 'ɑ', + 'Ɱ' => 'ɱ', + 'Ɐ' => 'ɐ', + 'Ɒ' => 'ɒ', + 'Ⱳ' => 'ⱳ', + 'Ⱶ' => 'ⱶ', + 'Ȿ' => 'ȿ', + 'Ɀ' => 'ɀ', + 'Ⲁ' => 'ⲁ', + 'Ⲃ' => 'ⲃ', + 'Ⲅ' => 'ⲅ', + 'Ⲇ' => 'ⲇ', + 'Ⲉ' => 'ⲉ', + 'Ⲋ' => 'ⲋ', + 'Ⲍ' => 'ⲍ', + 'Ⲏ' => 'ⲏ', + 'Ⲑ' => 'ⲑ', + 'Ⲓ' => 'ⲓ', + 'Ⲕ' => 'ⲕ', + 'Ⲗ' => 'ⲗ', + 'Ⲙ' => 'ⲙ', + 'Ⲛ' => 'ⲛ', + 'Ⲝ' => 'ⲝ', + 'Ⲟ' => 'ⲟ', + 'Ⲡ' => 'ⲡ', + 'Ⲣ' => 'ⲣ', + 'Ⲥ' => 'ⲥ', + 'Ⲧ' => 'ⲧ', + 'Ⲩ' => 'ⲩ', + 'Ⲫ' => 'ⲫ', + 'Ⲭ' => 'ⲭ', + 'Ⲯ' => 'ⲯ', + 'Ⲱ' => 'ⲱ', + 'Ⲳ' => 'ⲳ', + 'Ⲵ' => 'ⲵ', + 'Ⲷ' => 'ⲷ', + 'Ⲹ' => 'ⲹ', + 'Ⲻ' => 'ⲻ', + 'Ⲽ' => 'ⲽ', + 'Ⲿ' => 'ⲿ', + 'Ⳁ' => 'ⳁ', + 'Ⳃ' => 'ⳃ', + 'Ⳅ' => 'ⳅ', + 'Ⳇ' => 'ⳇ', + 'Ⳉ' => 'ⳉ', + 'Ⳋ' => 'ⳋ', + 'Ⳍ' => 'ⳍ', + 'Ⳏ' => 'ⳏ', + 'Ⳑ' => 'ⳑ', + 'Ⳓ' => 'ⳓ', + 'Ⳕ' => 'ⳕ', + 'Ⳗ' => 'ⳗ', + 'Ⳙ' => 'ⳙ', + 'Ⳛ' => 'ⳛ', + 'Ⳝ' => 'ⳝ', + 'Ⳟ' => 'ⳟ', + 'Ⳡ' => 'ⳡ', + 'Ⳣ' => 'ⳣ', + 'Ⳬ' => 'ⳬ', + 'Ⳮ' => 'ⳮ', + 'Ⳳ' => 'ⳳ', + 'Ꙁ' => 'ꙁ', + 'Ꙃ' => 'ꙃ', + 'Ꙅ' => 'ꙅ', + 'Ꙇ' => 'ꙇ', + 'Ꙉ' => 'ꙉ', + 'Ꙋ' => 'ꙋ', + 'Ꙍ' => 'ꙍ', + 'Ꙏ' => 'ꙏ', + 'Ꙑ' => 'ꙑ', + 'Ꙓ' => 'ꙓ', + 'Ꙕ' => 'ꙕ', + 'Ꙗ' => 'ꙗ', + 'Ꙙ' => 'ꙙ', + 'Ꙛ' => 'ꙛ', + 'Ꙝ' => 'ꙝ', + 'Ꙟ' => 'ꙟ', + 'Ꙡ' => 'ꙡ', + 'Ꙣ' => 'ꙣ', + 'Ꙥ' => 'ꙥ', + 'Ꙧ' => 'ꙧ', + 'Ꙩ' => 'ꙩ', + 'Ꙫ' => 'ꙫ', + 'Ꙭ' => 'ꙭ', + 'Ꚁ' => 'ꚁ', + 'Ꚃ' => 'ꚃ', + 'Ꚅ' => 'ꚅ', + 'Ꚇ' => 'ꚇ', + 'Ꚉ' => 'ꚉ', + 'Ꚋ' => 'ꚋ', + 'Ꚍ' => 'ꚍ', + 'Ꚏ' => 'ꚏ', + 'Ꚑ' => 'ꚑ', + 'Ꚓ' => 'ꚓ', + 'Ꚕ' => 'ꚕ', + 'Ꚗ' => 'ꚗ', + 'Ꚙ' => 'ꚙ', + 'Ꚛ' => 'ꚛ', + 'Ꜣ' => 'ꜣ', + 'Ꜥ' => 'ꜥ', + 'Ꜧ' => 'ꜧ', + 'Ꜩ' => 'ꜩ', + 'Ꜫ' => 'ꜫ', + 'Ꜭ' => 'ꜭ', + 'Ꜯ' => 'ꜯ', + 'Ꜳ' => 'ꜳ', + 'Ꜵ' => 'ꜵ', + 'Ꜷ' => 'ꜷ', + 'Ꜹ' => 'ꜹ', + 'Ꜻ' => 'ꜻ', + 'Ꜽ' => 'ꜽ', + 'Ꜿ' => 'ꜿ', + 'Ꝁ' => 'ꝁ', + 'Ꝃ' => 'ꝃ', + 'Ꝅ' => 'ꝅ', + 'Ꝇ' => 'ꝇ', + 'Ꝉ' => 'ꝉ', + 'Ꝋ' => 'ꝋ', + 'Ꝍ' => 'ꝍ', + 'Ꝏ' => 'ꝏ', + 'Ꝑ' => 'ꝑ', + 'Ꝓ' => 'ꝓ', + 'Ꝕ' => 'ꝕ', + 'Ꝗ' => 'ꝗ', + 'Ꝙ' => 'ꝙ', + 'Ꝛ' => 'ꝛ', + 'Ꝝ' => 'ꝝ', + 'Ꝟ' => 'ꝟ', + 'Ꝡ' => 'ꝡ', + 'Ꝣ' => 'ꝣ', + 'Ꝥ' => 'ꝥ', + 'Ꝧ' => 'ꝧ', + 'Ꝩ' => 'ꝩ', + 'Ꝫ' => 'ꝫ', + 'Ꝭ' => 'ꝭ', + 'Ꝯ' => 'ꝯ', + 'Ꝺ' => 'ꝺ', + 'Ꝼ' => 'ꝼ', + 'Ᵹ' => 'ᵹ', + 'Ꝿ' => 'ꝿ', + 'Ꞁ' => 'ꞁ', + 'Ꞃ' => 'ꞃ', + 'Ꞅ' => 'ꞅ', + 'Ꞇ' => 'ꞇ', + 'Ꞌ' => 'ꞌ', + 'Ɥ' => 'ɥ', + 'Ꞑ' => 'ꞑ', + 'Ꞓ' => 'ꞓ', + 'Ꞗ' => 'ꞗ', + 'Ꞙ' => 'ꞙ', + 'Ꞛ' => 'ꞛ', + 'Ꞝ' => 'ꞝ', + 'Ꞟ' => 'ꞟ', + 'Ꞡ' => 'ꞡ', + 'Ꞣ' => 'ꞣ', + 'Ꞥ' => 'ꞥ', + 'Ꞧ' => 'ꞧ', + 'Ꞩ' => 'ꞩ', + 'Ɦ' => 'ɦ', + 'Ɜ' => 'ɜ', + 'Ɡ' => 'ɡ', + 'Ɬ' => 'ɬ', + 'Ɪ' => 'ɪ', + 'Ʞ' => 'ʞ', + 'Ʇ' => 'ʇ', + 'Ʝ' => 'ʝ', + 'Ꭓ' => 'ꭓ', + 'Ꞵ' => 'ꞵ', + 'Ꞷ' => 'ꞷ', + 'Ꞹ' => 'ꞹ', + 'Ꞻ' => 'ꞻ', + 'Ꞽ' => 'ꞽ', + 'Ꞿ' => 'ꞿ', + 'Ꟃ' => 'ꟃ', + 'Ꞔ' => 'ꞔ', + 'Ʂ' => 'ʂ', + 'Ᶎ' => 'ᶎ', + 'Ꟈ' => 'ꟈ', + 'Ꟊ' => 'ꟊ', + 'Ꟶ' => 'ꟶ', + 'A' => 'a', + 'B' => 'b', + 'C' => 'c', + 'D' => 'd', + 'E' => 'e', + 'F' => 'f', + 'G' => 'g', + 'H' => 'h', + 'I' => 'i', + 'J' => 'j', + 'K' => 'k', + 'L' => 'l', + 'M' => 'm', + 'N' => 'n', + 'O' => 'o', + 'P' => 'p', + 'Q' => 'q', + 'R' => 'r', + 'S' => 's', + 'T' => 't', + 'U' => 'u', + 'V' => 'v', + 'W' => 'w', + 'X' => 'x', + 'Y' => 'y', + 'Z' => 'z', + '𐐀' => '𐐨', + '𐐁' => '𐐩', + '𐐂' => '𐐪', + '𐐃' => '𐐫', + '𐐄' => '𐐬', + '𐐅' => '𐐭', + '𐐆' => '𐐮', + '𐐇' => '𐐯', + '𐐈' => '𐐰', + '𐐉' => '𐐱', + '𐐊' => '𐐲', + '𐐋' => '𐐳', + '𐐌' => '𐐴', + '𐐍' => '𐐵', + '𐐎' => '𐐶', + '𐐏' => '𐐷', + '𐐐' => '𐐸', + '𐐑' => '𐐹', + '𐐒' => '𐐺', + '𐐓' => '𐐻', + '𐐔' => '𐐼', + '𐐕' => '𐐽', + '𐐖' => '𐐾', + '𐐗' => '𐐿', + '𐐘' => '𐑀', + '𐐙' => '𐑁', + '𐐚' => '𐑂', + '𐐛' => '𐑃', + '𐐜' => '𐑄', + '𐐝' => '𐑅', + '𐐞' => '𐑆', + '𐐟' => '𐑇', + '𐐠' => '𐑈', + '𐐡' => '𐑉', + '𐐢' => '𐑊', + '𐐣' => '𐑋', + '𐐤' => '𐑌', + '𐐥' => '𐑍', + '𐐦' => '𐑎', + '𐐧' => '𐑏', + '𐒰' => '𐓘', + '𐒱' => '𐓙', + '𐒲' => '𐓚', + '𐒳' => '𐓛', + '𐒴' => '𐓜', + '𐒵' => '𐓝', + '𐒶' => '𐓞', + '𐒷' => '𐓟', + '𐒸' => '𐓠', + '𐒹' => '𐓡', + '𐒺' => '𐓢', + '𐒻' => '𐓣', + '𐒼' => '𐓤', + '𐒽' => '𐓥', + '𐒾' => '𐓦', + '𐒿' => '𐓧', + '𐓀' => '𐓨', + '𐓁' => '𐓩', + '𐓂' => '𐓪', + '𐓃' => '𐓫', + '𐓄' => '𐓬', + '𐓅' => '𐓭', + '𐓆' => '𐓮', + '𐓇' => '𐓯', + '𐓈' => '𐓰', + '𐓉' => '𐓱', + '𐓊' => '𐓲', + '𐓋' => '𐓳', + '𐓌' => '𐓴', + '𐓍' => '𐓵', + '𐓎' => '𐓶', + '𐓏' => '𐓷', + '𐓐' => '𐓸', + '𐓑' => '𐓹', + '𐓒' => '𐓺', + '𐓓' => '𐓻', + '𐲀' => '𐳀', + '𐲁' => '𐳁', + '𐲂' => '𐳂', + '𐲃' => '𐳃', + '𐲄' => '𐳄', + '𐲅' => '𐳅', + '𐲆' => '𐳆', + '𐲇' => '𐳇', + '𐲈' => '𐳈', + '𐲉' => '𐳉', + '𐲊' => '𐳊', + '𐲋' => '𐳋', + '𐲌' => '𐳌', + '𐲍' => '𐳍', + '𐲎' => '𐳎', + '𐲏' => '𐳏', + '𐲐' => '𐳐', + '𐲑' => '𐳑', + '𐲒' => '𐳒', + '𐲓' => '𐳓', + '𐲔' => '𐳔', + '𐲕' => '𐳕', + '𐲖' => '𐳖', + '𐲗' => '𐳗', + '𐲘' => '𐳘', + '𐲙' => '𐳙', + '𐲚' => '𐳚', + '𐲛' => '𐳛', + '𐲜' => '𐳜', + '𐲝' => '𐳝', + '𐲞' => '𐳞', + '𐲟' => '𐳟', + '𐲠' => '𐳠', + '𐲡' => '𐳡', + '𐲢' => '𐳢', + '𐲣' => '𐳣', + '𐲤' => '𐳤', + '𐲥' => '𐳥', + '𐲦' => '𐳦', + '𐲧' => '𐳧', + '𐲨' => '𐳨', + '𐲩' => '𐳩', + '𐲪' => '𐳪', + '𐲫' => '𐳫', + '𐲬' => '𐳬', + '𐲭' => '𐳭', + '𐲮' => '𐳮', + '𐲯' => '𐳯', + '𐲰' => '𐳰', + '𐲱' => '𐳱', + '𐲲' => '𐳲', + '𑢠' => '𑣀', + '𑢡' => '𑣁', + '𑢢' => '𑣂', + '𑢣' => '𑣃', + '𑢤' => '𑣄', + '𑢥' => '𑣅', + '𑢦' => '𑣆', + '𑢧' => '𑣇', + '𑢨' => '𑣈', + '𑢩' => '𑣉', + '𑢪' => '𑣊', + '𑢫' => '𑣋', + '𑢬' => '𑣌', + '𑢭' => '𑣍', + '𑢮' => '𑣎', + '𑢯' => '𑣏', + '𑢰' => '𑣐', + '𑢱' => '𑣑', + '𑢲' => '𑣒', + '𑢳' => '𑣓', + '𑢴' => '𑣔', + '𑢵' => '𑣕', + '𑢶' => '𑣖', + '𑢷' => '𑣗', + '𑢸' => '𑣘', + '𑢹' => '𑣙', + '𑢺' => '𑣚', + '𑢻' => '𑣛', + '𑢼' => '𑣜', + '𑢽' => '𑣝', + '𑢾' => '𑣞', + '𑢿' => '𑣟', + '𖹀' => '𖹠', + '𖹁' => '𖹡', + '𖹂' => '𖹢', + '𖹃' => '𖹣', + '𖹄' => '𖹤', + '𖹅' => '𖹥', + '𖹆' => '𖹦', + '𖹇' => '𖹧', + '𖹈' => '𖹨', + '𖹉' => '𖹩', + '𖹊' => '𖹪', + '𖹋' => '𖹫', + '𖹌' => '𖹬', + '𖹍' => '𖹭', + '𖹎' => '𖹮', + '𖹏' => '𖹯', + '𖹐' => '𖹰', + '𖹑' => '𖹱', + '𖹒' => '𖹲', + '𖹓' => '𖹳', + '𖹔' => '𖹴', + '𖹕' => '𖹵', + '𖹖' => '𖹶', + '𖹗' => '𖹷', + '𖹘' => '𖹸', + '𖹙' => '𖹹', + '𖹚' => '𖹺', + '𖹛' => '𖹻', + '𖹜' => '𖹼', + '𖹝' => '𖹽', + '𖹞' => '𖹾', + '𖹟' => '𖹿', + '𞤀' => '𞤢', + '𞤁' => '𞤣', + '𞤂' => '𞤤', + '𞤃' => '𞤥', + '𞤄' => '𞤦', + '𞤅' => '𞤧', + '𞤆' => '𞤨', + '𞤇' => '𞤩', + '𞤈' => '𞤪', + '𞤉' => '𞤫', + '𞤊' => '𞤬', + '𞤋' => '𞤭', + '𞤌' => '𞤮', + '𞤍' => '𞤯', + '𞤎' => '𞤰', + '𞤏' => '𞤱', + '𞤐' => '𞤲', + '𞤑' => '𞤳', + '𞤒' => '𞤴', + '𞤓' => '𞤵', + '𞤔' => '𞤶', + '𞤕' => '𞤷', + '𞤖' => '𞤸', + '𞤗' => '𞤹', + '𞤘' => '𞤺', + '𞤙' => '𞤻', + '𞤚' => '𞤼', + '𞤛' => '𞤽', + '𞤜' => '𞤾', + '𞤝' => '𞤿', + '𞤞' => '𞥀', + '𞤟' => '𞥁', + '𞤠' => '𞥂', + '𞤡' => '𞥃', +); diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php new file mode 100644 index 0000000..2a8f6e7 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php @@ -0,0 +1,5 @@ + 'A', + 'b' => 'B', + 'c' => 'C', + 'd' => 'D', + 'e' => 'E', + 'f' => 'F', + 'g' => 'G', + 'h' => 'H', + 'i' => 'I', + 'j' => 'J', + 'k' => 'K', + 'l' => 'L', + 'm' => 'M', + 'n' => 'N', + 'o' => 'O', + 'p' => 'P', + 'q' => 'Q', + 'r' => 'R', + 's' => 'S', + 't' => 'T', + 'u' => 'U', + 'v' => 'V', + 'w' => 'W', + 'x' => 'X', + 'y' => 'Y', + 'z' => 'Z', + 'µ' => 'Μ', + 'à' => 'À', + 'á' => 'Á', + 'â' => 'Â', + 'ã' => 'Ã', + 'ä' => 'Ä', + 'å' => 'Å', + 'æ' => 'Æ', + 'ç' => 'Ç', + 'è' => 'È', + 'é' => 'É', + 'ê' => 'Ê', + 'ë' => 'Ë', + 'ì' => 'Ì', + 'í' => 'Í', + 'î' => 'Î', + 'ï' => 'Ï', + 'ð' => 'Ð', + 'ñ' => 'Ñ', + 'ò' => 'Ò', + 'ó' => 'Ó', + 'ô' => 'Ô', + 'õ' => 'Õ', + 'ö' => 'Ö', + 'ø' => 'Ø', + 'ù' => 'Ù', + 'ú' => 'Ú', + 'û' => 'Û', + 'ü' => 'Ü', + 'ý' => 'Ý', + 'þ' => 'Þ', + 'ÿ' => 'Ÿ', + 'ā' => 'Ā', + 'ă' => 'Ă', + 'ą' => 'Ą', + 'ć' => 'Ć', + 'ĉ' => 'Ĉ', + 'ċ' => 'Ċ', + 'č' => 'Č', + 'ď' => 'Ď', + 'đ' => 'Đ', + 'ē' => 'Ē', + 'ĕ' => 'Ĕ', + 'ė' => 'Ė', + 'ę' => 'Ę', + 'ě' => 'Ě', + 'ĝ' => 'Ĝ', + 'ğ' => 'Ğ', + 'ġ' => 'Ġ', + 'ģ' => 'Ģ', + 'ĥ' => 'Ĥ', + 'ħ' => 'Ħ', + 'ĩ' => 'Ĩ', + 'ī' => 'Ī', + 'ĭ' => 'Ĭ', + 'į' => 'Į', + 'ı' => 'I', + 'ij' => 'IJ', + 'ĵ' => 'Ĵ', + 'ķ' => 'Ķ', + 'ĺ' => 'Ĺ', + 'ļ' => 'Ļ', + 'ľ' => 'Ľ', + 'ŀ' => 'Ŀ', + 'ł' => 'Ł', + 'ń' => 'Ń', + 'ņ' => 'Ņ', + 'ň' => 'Ň', + 'ŋ' => 'Ŋ', + 'ō' => 'Ō', + 'ŏ' => 'Ŏ', + 'ő' => 'Ő', + 'œ' => 'Œ', + 'ŕ' => 'Ŕ', + 'ŗ' => 'Ŗ', + 'ř' => 'Ř', + 'ś' => 'Ś', + 'ŝ' => 'Ŝ', + 'ş' => 'Ş', + 'š' => 'Š', + 'ţ' => 'Ţ', + 'ť' => 'Ť', + 'ŧ' => 'Ŧ', + 'ũ' => 'Ũ', + 'ū' => 'Ū', + 'ŭ' => 'Ŭ', + 'ů' => 'Ů', + 'ű' => 'Ű', + 'ų' => 'Ų', + 'ŵ' => 'Ŵ', + 'ŷ' => 'Ŷ', + 'ź' => 'Ź', + 'ż' => 'Ż', + 'ž' => 'Ž', + 'ſ' => 'S', + 'ƀ' => 'Ƀ', + 'ƃ' => 'Ƃ', + 'ƅ' => 'Ƅ', + 'ƈ' => 'Ƈ', + 'ƌ' => 'Ƌ', + 'ƒ' => 'Ƒ', + 'ƕ' => 'Ƕ', + 'ƙ' => 'Ƙ', + 'ƚ' => 'Ƚ', + 'ƞ' => 'Ƞ', + 'ơ' => 'Ơ', + 'ƣ' => 'Ƣ', + 'ƥ' => 'Ƥ', + 'ƨ' => 'Ƨ', + 'ƭ' => 'Ƭ', + 'ư' => 'Ư', + 'ƴ' => 'Ƴ', + 'ƶ' => 'Ƶ', + 'ƹ' => 'Ƹ', + 'ƽ' => 'Ƽ', + 'ƿ' => 'Ƿ', + 'Dž' => 'DŽ', + 'dž' => 'DŽ', + 'Lj' => 'LJ', + 'lj' => 'LJ', + 'Nj' => 'NJ', + 'nj' => 'NJ', + 'ǎ' => 'Ǎ', + 'ǐ' => 'Ǐ', + 'ǒ' => 'Ǒ', + 'ǔ' => 'Ǔ', + 'ǖ' => 'Ǖ', + 'ǘ' => 'Ǘ', + 'ǚ' => 'Ǚ', + 'ǜ' => 'Ǜ', + 'ǝ' => 'Ǝ', + 'ǟ' => 'Ǟ', + 'ǡ' => 'Ǡ', + 'ǣ' => 'Ǣ', + 'ǥ' => 'Ǥ', + 'ǧ' => 'Ǧ', + 'ǩ' => 'Ǩ', + 'ǫ' => 'Ǫ', + 'ǭ' => 'Ǭ', + 'ǯ' => 'Ǯ', + 'Dz' => 'DZ', + 'dz' => 'DZ', + 'ǵ' => 'Ǵ', + 'ǹ' => 'Ǹ', + 'ǻ' => 'Ǻ', + 'ǽ' => 'Ǽ', + 'ǿ' => 'Ǿ', + 'ȁ' => 'Ȁ', + 'ȃ' => 'Ȃ', + 'ȅ' => 'Ȅ', + 'ȇ' => 'Ȇ', + 'ȉ' => 'Ȉ', + 'ȋ' => 'Ȋ', + 'ȍ' => 'Ȍ', + 'ȏ' => 'Ȏ', + 'ȑ' => 'Ȑ', + 'ȓ' => 'Ȓ', + 'ȕ' => 'Ȕ', + 'ȗ' => 'Ȗ', + 'ș' => 'Ș', + 'ț' => 'Ț', + 'ȝ' => 'Ȝ', + 'ȟ' => 'Ȟ', + 'ȣ' => 'Ȣ', + 'ȥ' => 'Ȥ', + 'ȧ' => 'Ȧ', + 'ȩ' => 'Ȩ', + 'ȫ' => 'Ȫ', + 'ȭ' => 'Ȭ', + 'ȯ' => 'Ȯ', + 'ȱ' => 'Ȱ', + 'ȳ' => 'Ȳ', + 'ȼ' => 'Ȼ', + 'ȿ' => 'Ȿ', + 'ɀ' => 'Ɀ', + 'ɂ' => 'Ɂ', + 'ɇ' => 'Ɇ', + 'ɉ' => 'Ɉ', + 'ɋ' => 'Ɋ', + 'ɍ' => 'Ɍ', + 'ɏ' => 'Ɏ', + 'ɐ' => 'Ɐ', + 'ɑ' => 'Ɑ', + 'ɒ' => 'Ɒ', + 'ɓ' => 'Ɓ', + 'ɔ' => 'Ɔ', + 'ɖ' => 'Ɖ', + 'ɗ' => 'Ɗ', + 'ə' => 'Ə', + 'ɛ' => 'Ɛ', + 'ɜ' => 'Ɜ', + 'ɠ' => 'Ɠ', + 'ɡ' => 'Ɡ', + 'ɣ' => 'Ɣ', + 'ɥ' => 'Ɥ', + 'ɦ' => 'Ɦ', + 'ɨ' => 'Ɨ', + 'ɩ' => 'Ɩ', + 'ɪ' => 'Ɪ', + 'ɫ' => 'Ɫ', + 'ɬ' => 'Ɬ', + 'ɯ' => 'Ɯ', + 'ɱ' => 'Ɱ', + 'ɲ' => 'Ɲ', + 'ɵ' => 'Ɵ', + 'ɽ' => 'Ɽ', + 'ʀ' => 'Ʀ', + 'ʂ' => 'Ʂ', + 'ʃ' => 'Ʃ', + 'ʇ' => 'Ʇ', + 'ʈ' => 'Ʈ', + 'ʉ' => 'Ʉ', + 'ʊ' => 'Ʊ', + 'ʋ' => 'Ʋ', + 'ʌ' => 'Ʌ', + 'ʒ' => 'Ʒ', + 'ʝ' => 'Ʝ', + 'ʞ' => 'Ʞ', + 'ͅ' => 'Ι', + 'ͱ' => 'Ͱ', + 'ͳ' => 'Ͳ', + 'ͷ' => 'Ͷ', + 'ͻ' => 'Ͻ', + 'ͼ' => 'Ͼ', + 'ͽ' => 'Ͽ', + 'ά' => 'Ά', + 'έ' => 'Έ', + 'ή' => 'Ή', + 'ί' => 'Ί', + 'α' => 'Α', + 'β' => 'Β', + 'γ' => 'Γ', + 'δ' => 'Δ', + 'ε' => 'Ε', + 'ζ' => 'Ζ', + 'η' => 'Η', + 'θ' => 'Θ', + 'ι' => 'Ι', + 'κ' => 'Κ', + 'λ' => 'Λ', + 'μ' => 'Μ', + 'ν' => 'Ν', + 'ξ' => 'Ξ', + 'ο' => 'Ο', + 'π' => 'Π', + 'ρ' => 'Ρ', + 'ς' => 'Σ', + 'σ' => 'Σ', + 'τ' => 'Τ', + 'υ' => 'Υ', + 'φ' => 'Φ', + 'χ' => 'Χ', + 'ψ' => 'Ψ', + 'ω' => 'Ω', + 'ϊ' => 'Ϊ', + 'ϋ' => 'Ϋ', + 'ό' => 'Ό', + 'ύ' => 'Ύ', + 'ώ' => 'Ώ', + 'ϐ' => 'Β', + 'ϑ' => 'Θ', + 'ϕ' => 'Φ', + 'ϖ' => 'Π', + 'ϗ' => 'Ϗ', + 'ϙ' => 'Ϙ', + 'ϛ' => 'Ϛ', + 'ϝ' => 'Ϝ', + 'ϟ' => 'Ϟ', + 'ϡ' => 'Ϡ', + 'ϣ' => 'Ϣ', + 'ϥ' => 'Ϥ', + 'ϧ' => 'Ϧ', + 'ϩ' => 'Ϩ', + 'ϫ' => 'Ϫ', + 'ϭ' => 'Ϭ', + 'ϯ' => 'Ϯ', + 'ϰ' => 'Κ', + 'ϱ' => 'Ρ', + 'ϲ' => 'Ϲ', + 'ϳ' => 'Ϳ', + 'ϵ' => 'Ε', + 'ϸ' => 'Ϸ', + 'ϻ' => 'Ϻ', + 'а' => 'А', + 'б' => 'Б', + 'в' => 'В', + 'г' => 'Г', + 'д' => 'Д', + 'е' => 'Е', + 'ж' => 'Ж', + 'з' => 'З', + 'и' => 'И', + 'й' => 'Й', + 'к' => 'К', + 'л' => 'Л', + 'м' => 'М', + 'н' => 'Н', + 'о' => 'О', + 'п' => 'П', + 'р' => 'Р', + 'с' => 'С', + 'т' => 'Т', + 'у' => 'У', + 'ф' => 'Ф', + 'х' => 'Х', + 'ц' => 'Ц', + 'ч' => 'Ч', + 'ш' => 'Ш', + 'щ' => 'Щ', + 'ъ' => 'Ъ', + 'ы' => 'Ы', + 'ь' => 'Ь', + 'э' => 'Э', + 'ю' => 'Ю', + 'я' => 'Я', + 'ѐ' => 'Ѐ', + 'ё' => 'Ё', + 'ђ' => 'Ђ', + 'ѓ' => 'Ѓ', + 'є' => 'Є', + 'ѕ' => 'Ѕ', + 'і' => 'І', + 'ї' => 'Ї', + 'ј' => 'Ј', + 'љ' => 'Љ', + 'њ' => 'Њ', + 'ћ' => 'Ћ', + 'ќ' => 'Ќ', + 'ѝ' => 'Ѝ', + 'ў' => 'Ў', + 'џ' => 'Џ', + 'ѡ' => 'Ѡ', + 'ѣ' => 'Ѣ', + 'ѥ' => 'Ѥ', + 'ѧ' => 'Ѧ', + 'ѩ' => 'Ѩ', + 'ѫ' => 'Ѫ', + 'ѭ' => 'Ѭ', + 'ѯ' => 'Ѯ', + 'ѱ' => 'Ѱ', + 'ѳ' => 'Ѳ', + 'ѵ' => 'Ѵ', + 'ѷ' => 'Ѷ', + 'ѹ' => 'Ѹ', + 'ѻ' => 'Ѻ', + 'ѽ' => 'Ѽ', + 'ѿ' => 'Ѿ', + 'ҁ' => 'Ҁ', + 'ҋ' => 'Ҋ', + 'ҍ' => 'Ҍ', + 'ҏ' => 'Ҏ', + 'ґ' => 'Ґ', + 'ғ' => 'Ғ', + 'ҕ' => 'Ҕ', + 'җ' => 'Җ', + 'ҙ' => 'Ҙ', + 'қ' => 'Қ', + 'ҝ' => 'Ҝ', + 'ҟ' => 'Ҟ', + 'ҡ' => 'Ҡ', + 'ң' => 'Ң', + 'ҥ' => 'Ҥ', + 'ҧ' => 'Ҧ', + 'ҩ' => 'Ҩ', + 'ҫ' => 'Ҫ', + 'ҭ' => 'Ҭ', + 'ү' => 'Ү', + 'ұ' => 'Ұ', + 'ҳ' => 'Ҳ', + 'ҵ' => 'Ҵ', + 'ҷ' => 'Ҷ', + 'ҹ' => 'Ҹ', + 'һ' => 'Һ', + 'ҽ' => 'Ҽ', + 'ҿ' => 'Ҿ', + 'ӂ' => 'Ӂ', + 'ӄ' => 'Ӄ', + 'ӆ' => 'Ӆ', + 'ӈ' => 'Ӈ', + 'ӊ' => 'Ӊ', + 'ӌ' => 'Ӌ', + 'ӎ' => 'Ӎ', + 'ӏ' => 'Ӏ', + 'ӑ' => 'Ӑ', + 'ӓ' => 'Ӓ', + 'ӕ' => 'Ӕ', + 'ӗ' => 'Ӗ', + 'ә' => 'Ә', + 'ӛ' => 'Ӛ', + 'ӝ' => 'Ӝ', + 'ӟ' => 'Ӟ', + 'ӡ' => 'Ӡ', + 'ӣ' => 'Ӣ', + 'ӥ' => 'Ӥ', + 'ӧ' => 'Ӧ', + 'ө' => 'Ө', + 'ӫ' => 'Ӫ', + 'ӭ' => 'Ӭ', + 'ӯ' => 'Ӯ', + 'ӱ' => 'Ӱ', + 'ӳ' => 'Ӳ', + 'ӵ' => 'Ӵ', + 'ӷ' => 'Ӷ', + 'ӹ' => 'Ӹ', + 'ӻ' => 'Ӻ', + 'ӽ' => 'Ӽ', + 'ӿ' => 'Ӿ', + 'ԁ' => 'Ԁ', + 'ԃ' => 'Ԃ', + 'ԅ' => 'Ԅ', + 'ԇ' => 'Ԇ', + 'ԉ' => 'Ԉ', + 'ԋ' => 'Ԋ', + 'ԍ' => 'Ԍ', + 'ԏ' => 'Ԏ', + 'ԑ' => 'Ԑ', + 'ԓ' => 'Ԓ', + 'ԕ' => 'Ԕ', + 'ԗ' => 'Ԗ', + 'ԙ' => 'Ԙ', + 'ԛ' => 'Ԛ', + 'ԝ' => 'Ԝ', + 'ԟ' => 'Ԟ', + 'ԡ' => 'Ԡ', + 'ԣ' => 'Ԣ', + 'ԥ' => 'Ԥ', + 'ԧ' => 'Ԧ', + 'ԩ' => 'Ԩ', + 'ԫ' => 'Ԫ', + 'ԭ' => 'Ԭ', + 'ԯ' => 'Ԯ', + 'ա' => 'Ա', + 'բ' => 'Բ', + 'գ' => 'Գ', + 'դ' => 'Դ', + 'ե' => 'Ե', + 'զ' => 'Զ', + 'է' => 'Է', + 'ը' => 'Ը', + 'թ' => 'Թ', + 'ժ' => 'Ժ', + 'ի' => 'Ի', + 'լ' => 'Լ', + 'խ' => 'Խ', + 'ծ' => 'Ծ', + 'կ' => 'Կ', + 'հ' => 'Հ', + 'ձ' => 'Ձ', + 'ղ' => 'Ղ', + 'ճ' => 'Ճ', + 'մ' => 'Մ', + 'յ' => 'Յ', + 'ն' => 'Ն', + 'շ' => 'Շ', + 'ո' => 'Ո', + 'չ' => 'Չ', + 'պ' => 'Պ', + 'ջ' => 'Ջ', + 'ռ' => 'Ռ', + 'ս' => 'Ս', + 'վ' => 'Վ', + 'տ' => 'Տ', + 'ր' => 'Ր', + 'ց' => 'Ց', + 'ւ' => 'Ւ', + 'փ' => 'Փ', + 'ք' => 'Ք', + 'օ' => 'Օ', + 'ֆ' => 'Ֆ', + 'ა' => 'Ა', + 'ბ' => 'Ბ', + 'გ' => 'Გ', + 'დ' => 'Დ', + 'ე' => 'Ე', + 'ვ' => 'Ვ', + 'ზ' => 'Ზ', + 'თ' => 'Თ', + 'ი' => 'Ი', + 'კ' => 'Კ', + 'ლ' => 'Ლ', + 'მ' => 'Მ', + 'ნ' => 'Ნ', + 'ო' => 'Ო', + 'პ' => 'Პ', + 'ჟ' => 'Ჟ', + 'რ' => 'Რ', + 'ს' => 'Ს', + 'ტ' => 'Ტ', + 'უ' => 'Უ', + 'ფ' => 'Ფ', + 'ქ' => 'Ქ', + 'ღ' => 'Ღ', + 'ყ' => 'Ყ', + 'შ' => 'Შ', + 'ჩ' => 'Ჩ', + 'ც' => 'Ც', + 'ძ' => 'Ძ', + 'წ' => 'Წ', + 'ჭ' => 'Ჭ', + 'ხ' => 'Ხ', + 'ჯ' => 'Ჯ', + 'ჰ' => 'Ჰ', + 'ჱ' => 'Ჱ', + 'ჲ' => 'Ჲ', + 'ჳ' => 'Ჳ', + 'ჴ' => 'Ჴ', + 'ჵ' => 'Ჵ', + 'ჶ' => 'Ჶ', + 'ჷ' => 'Ჷ', + 'ჸ' => 'Ჸ', + 'ჹ' => 'Ჹ', + 'ჺ' => 'Ჺ', + 'ჽ' => 'Ჽ', + 'ჾ' => 'Ჾ', + 'ჿ' => 'Ჿ', + 'ᏸ' => 'Ᏸ', + 'ᏹ' => 'Ᏹ', + 'ᏺ' => 'Ᏺ', + 'ᏻ' => 'Ᏻ', + 'ᏼ' => 'Ᏼ', + 'ᏽ' => 'Ᏽ', + 'ᲀ' => 'В', + 'ᲁ' => 'Д', + 'ᲂ' => 'О', + 'ᲃ' => 'С', + 'ᲄ' => 'Т', + 'ᲅ' => 'Т', + 'ᲆ' => 'Ъ', + 'ᲇ' => 'Ѣ', + 'ᲈ' => 'Ꙋ', + 'ᵹ' => 'Ᵹ', + 'ᵽ' => 'Ᵽ', + 'ᶎ' => 'Ᶎ', + 'ḁ' => 'Ḁ', + 'ḃ' => 'Ḃ', + 'ḅ' => 'Ḅ', + 'ḇ' => 'Ḇ', + 'ḉ' => 'Ḉ', + 'ḋ' => 'Ḋ', + 'ḍ' => 'Ḍ', + 'ḏ' => 'Ḏ', + 'ḑ' => 'Ḑ', + 'ḓ' => 'Ḓ', + 'ḕ' => 'Ḕ', + 'ḗ' => 'Ḗ', + 'ḙ' => 'Ḙ', + 'ḛ' => 'Ḛ', + 'ḝ' => 'Ḝ', + 'ḟ' => 'Ḟ', + 'ḡ' => 'Ḡ', + 'ḣ' => 'Ḣ', + 'ḥ' => 'Ḥ', + 'ḧ' => 'Ḧ', + 'ḩ' => 'Ḩ', + 'ḫ' => 'Ḫ', + 'ḭ' => 'Ḭ', + 'ḯ' => 'Ḯ', + 'ḱ' => 'Ḱ', + 'ḳ' => 'Ḳ', + 'ḵ' => 'Ḵ', + 'ḷ' => 'Ḷ', + 'ḹ' => 'Ḹ', + 'ḻ' => 'Ḻ', + 'ḽ' => 'Ḽ', + 'ḿ' => 'Ḿ', + 'ṁ' => 'Ṁ', + 'ṃ' => 'Ṃ', + 'ṅ' => 'Ṅ', + 'ṇ' => 'Ṇ', + 'ṉ' => 'Ṉ', + 'ṋ' => 'Ṋ', + 'ṍ' => 'Ṍ', + 'ṏ' => 'Ṏ', + 'ṑ' => 'Ṑ', + 'ṓ' => 'Ṓ', + 'ṕ' => 'Ṕ', + 'ṗ' => 'Ṗ', + 'ṙ' => 'Ṙ', + 'ṛ' => 'Ṛ', + 'ṝ' => 'Ṝ', + 'ṟ' => 'Ṟ', + 'ṡ' => 'Ṡ', + 'ṣ' => 'Ṣ', + 'ṥ' => 'Ṥ', + 'ṧ' => 'Ṧ', + 'ṩ' => 'Ṩ', + 'ṫ' => 'Ṫ', + 'ṭ' => 'Ṭ', + 'ṯ' => 'Ṯ', + 'ṱ' => 'Ṱ', + 'ṳ' => 'Ṳ', + 'ṵ' => 'Ṵ', + 'ṷ' => 'Ṷ', + 'ṹ' => 'Ṹ', + 'ṻ' => 'Ṻ', + 'ṽ' => 'Ṽ', + 'ṿ' => 'Ṿ', + 'ẁ' => 'Ẁ', + 'ẃ' => 'Ẃ', + 'ẅ' => 'Ẅ', + 'ẇ' => 'Ẇ', + 'ẉ' => 'Ẉ', + 'ẋ' => 'Ẋ', + 'ẍ' => 'Ẍ', + 'ẏ' => 'Ẏ', + 'ẑ' => 'Ẑ', + 'ẓ' => 'Ẓ', + 'ẕ' => 'Ẕ', + 'ẛ' => 'Ṡ', + 'ạ' => 'Ạ', + 'ả' => 'Ả', + 'ấ' => 'Ấ', + 'ầ' => 'Ầ', + 'ẩ' => 'Ẩ', + 'ẫ' => 'Ẫ', + 'ậ' => 'Ậ', + 'ắ' => 'Ắ', + 'ằ' => 'Ằ', + 'ẳ' => 'Ẳ', + 'ẵ' => 'Ẵ', + 'ặ' => 'Ặ', + 'ẹ' => 'Ẹ', + 'ẻ' => 'Ẻ', + 'ẽ' => 'Ẽ', + 'ế' => 'Ế', + 'ề' => 'Ề', + 'ể' => 'Ể', + 'ễ' => 'Ễ', + 'ệ' => 'Ệ', + 'ỉ' => 'Ỉ', + 'ị' => 'Ị', + 'ọ' => 'Ọ', + 'ỏ' => 'Ỏ', + 'ố' => 'Ố', + 'ồ' => 'Ồ', + 'ổ' => 'Ổ', + 'ỗ' => 'Ỗ', + 'ộ' => 'Ộ', + 'ớ' => 'Ớ', + 'ờ' => 'Ờ', + 'ở' => 'Ở', + 'ỡ' => 'Ỡ', + 'ợ' => 'Ợ', + 'ụ' => 'Ụ', + 'ủ' => 'Ủ', + 'ứ' => 'Ứ', + 'ừ' => 'Ừ', + 'ử' => 'Ử', + 'ữ' => 'Ữ', + 'ự' => 'Ự', + 'ỳ' => 'Ỳ', + 'ỵ' => 'Ỵ', + 'ỷ' => 'Ỷ', + 'ỹ' => 'Ỹ', + 'ỻ' => 'Ỻ', + 'ỽ' => 'Ỽ', + 'ỿ' => 'Ỿ', + 'ἀ' => 'Ἀ', + 'ἁ' => 'Ἁ', + 'ἂ' => 'Ἂ', + 'ἃ' => 'Ἃ', + 'ἄ' => 'Ἄ', + 'ἅ' => 'Ἅ', + 'ἆ' => 'Ἆ', + 'ἇ' => 'Ἇ', + 'ἐ' => 'Ἐ', + 'ἑ' => 'Ἑ', + 'ἒ' => 'Ἒ', + 'ἓ' => 'Ἓ', + 'ἔ' => 'Ἔ', + 'ἕ' => 'Ἕ', + 'ἠ' => 'Ἠ', + 'ἡ' => 'Ἡ', + 'ἢ' => 'Ἢ', + 'ἣ' => 'Ἣ', + 'ἤ' => 'Ἤ', + 'ἥ' => 'Ἥ', + 'ἦ' => 'Ἦ', + 'ἧ' => 'Ἧ', + 'ἰ' => 'Ἰ', + 'ἱ' => 'Ἱ', + 'ἲ' => 'Ἲ', + 'ἳ' => 'Ἳ', + 'ἴ' => 'Ἴ', + 'ἵ' => 'Ἵ', + 'ἶ' => 'Ἶ', + 'ἷ' => 'Ἷ', + 'ὀ' => 'Ὀ', + 'ὁ' => 'Ὁ', + 'ὂ' => 'Ὂ', + 'ὃ' => 'Ὃ', + 'ὄ' => 'Ὄ', + 'ὅ' => 'Ὅ', + 'ὑ' => 'Ὑ', + 'ὓ' => 'Ὓ', + 'ὕ' => 'Ὕ', + 'ὗ' => 'Ὗ', + 'ὠ' => 'Ὠ', + 'ὡ' => 'Ὡ', + 'ὢ' => 'Ὢ', + 'ὣ' => 'Ὣ', + 'ὤ' => 'Ὤ', + 'ὥ' => 'Ὥ', + 'ὦ' => 'Ὦ', + 'ὧ' => 'Ὧ', + 'ὰ' => 'Ὰ', + 'ά' => 'Ά', + 'ὲ' => 'Ὲ', + 'έ' => 'Έ', + 'ὴ' => 'Ὴ', + 'ή' => 'Ή', + 'ὶ' => 'Ὶ', + 'ί' => 'Ί', + 'ὸ' => 'Ὸ', + 'ό' => 'Ό', + 'ὺ' => 'Ὺ', + 'ύ' => 'Ύ', + 'ὼ' => 'Ὼ', + 'ώ' => 'Ώ', + 'ᾀ' => 'ἈΙ', + 'ᾁ' => 'ἉΙ', + 'ᾂ' => 'ἊΙ', + 'ᾃ' => 'ἋΙ', + 'ᾄ' => 'ἌΙ', + 'ᾅ' => 'ἍΙ', + 'ᾆ' => 'ἎΙ', + 'ᾇ' => 'ἏΙ', + 'ᾐ' => 'ἨΙ', + 'ᾑ' => 'ἩΙ', + 'ᾒ' => 'ἪΙ', + 'ᾓ' => 'ἫΙ', + 'ᾔ' => 'ἬΙ', + 'ᾕ' => 'ἭΙ', + 'ᾖ' => 'ἮΙ', + 'ᾗ' => 'ἯΙ', + 'ᾠ' => 'ὨΙ', + 'ᾡ' => 'ὩΙ', + 'ᾢ' => 'ὪΙ', + 'ᾣ' => 'ὫΙ', + 'ᾤ' => 'ὬΙ', + 'ᾥ' => 'ὭΙ', + 'ᾦ' => 'ὮΙ', + 'ᾧ' => 'ὯΙ', + 'ᾰ' => 'Ᾰ', + 'ᾱ' => 'Ᾱ', + 'ᾳ' => 'ΑΙ', + 'ι' => 'Ι', + 'ῃ' => 'ΗΙ', + 'ῐ' => 'Ῐ', + 'ῑ' => 'Ῑ', + 'ῠ' => 'Ῠ', + 'ῡ' => 'Ῡ', + 'ῥ' => 'Ῥ', + 'ῳ' => 'ΩΙ', + 'ⅎ' => 'Ⅎ', + 'ⅰ' => 'Ⅰ', + 'ⅱ' => 'Ⅱ', + 'ⅲ' => 'Ⅲ', + 'ⅳ' => 'Ⅳ', + 'ⅴ' => 'Ⅴ', + 'ⅵ' => 'Ⅵ', + 'ⅶ' => 'Ⅶ', + 'ⅷ' => 'Ⅷ', + 'ⅸ' => 'Ⅸ', + 'ⅹ' => 'Ⅹ', + 'ⅺ' => 'Ⅺ', + 'ⅻ' => 'Ⅻ', + 'ⅼ' => 'Ⅼ', + 'ⅽ' => 'Ⅽ', + 'ⅾ' => 'Ⅾ', + 'ⅿ' => 'Ⅿ', + 'ↄ' => 'Ↄ', + 'ⓐ' => 'Ⓐ', + 'ⓑ' => 'Ⓑ', + 'ⓒ' => 'Ⓒ', + 'ⓓ' => 'Ⓓ', + 'ⓔ' => 'Ⓔ', + 'ⓕ' => 'Ⓕ', + 'ⓖ' => 'Ⓖ', + 'ⓗ' => 'Ⓗ', + 'ⓘ' => 'Ⓘ', + 'ⓙ' => 'Ⓙ', + 'ⓚ' => 'Ⓚ', + 'ⓛ' => 'Ⓛ', + 'ⓜ' => 'Ⓜ', + 'ⓝ' => 'Ⓝ', + 'ⓞ' => 'Ⓞ', + 'ⓟ' => 'Ⓟ', + 'ⓠ' => 'Ⓠ', + 'ⓡ' => 'Ⓡ', + 'ⓢ' => 'Ⓢ', + 'ⓣ' => 'Ⓣ', + 'ⓤ' => 'Ⓤ', + 'ⓥ' => 'Ⓥ', + 'ⓦ' => 'Ⓦ', + 'ⓧ' => 'Ⓧ', + 'ⓨ' => 'Ⓨ', + 'ⓩ' => 'Ⓩ', + 'ⰰ' => 'Ⰰ', + 'ⰱ' => 'Ⰱ', + 'ⰲ' => 'Ⰲ', + 'ⰳ' => 'Ⰳ', + 'ⰴ' => 'Ⰴ', + 'ⰵ' => 'Ⰵ', + 'ⰶ' => 'Ⰶ', + 'ⰷ' => 'Ⰷ', + 'ⰸ' => 'Ⰸ', + 'ⰹ' => 'Ⰹ', + 'ⰺ' => 'Ⰺ', + 'ⰻ' => 'Ⰻ', + 'ⰼ' => 'Ⰼ', + 'ⰽ' => 'Ⰽ', + 'ⰾ' => 'Ⰾ', + 'ⰿ' => 'Ⰿ', + 'ⱀ' => 'Ⱀ', + 'ⱁ' => 'Ⱁ', + 'ⱂ' => 'Ⱂ', + 'ⱃ' => 'Ⱃ', + 'ⱄ' => 'Ⱄ', + 'ⱅ' => 'Ⱅ', + 'ⱆ' => 'Ⱆ', + 'ⱇ' => 'Ⱇ', + 'ⱈ' => 'Ⱈ', + 'ⱉ' => 'Ⱉ', + 'ⱊ' => 'Ⱊ', + 'ⱋ' => 'Ⱋ', + 'ⱌ' => 'Ⱌ', + 'ⱍ' => 'Ⱍ', + 'ⱎ' => 'Ⱎ', + 'ⱏ' => 'Ⱏ', + 'ⱐ' => 'Ⱐ', + 'ⱑ' => 'Ⱑ', + 'ⱒ' => 'Ⱒ', + 'ⱓ' => 'Ⱓ', + 'ⱔ' => 'Ⱔ', + 'ⱕ' => 'Ⱕ', + 'ⱖ' => 'Ⱖ', + 'ⱗ' => 'Ⱗ', + 'ⱘ' => 'Ⱘ', + 'ⱙ' => 'Ⱙ', + 'ⱚ' => 'Ⱚ', + 'ⱛ' => 'Ⱛ', + 'ⱜ' => 'Ⱜ', + 'ⱝ' => 'Ⱝ', + 'ⱞ' => 'Ⱞ', + 'ⱡ' => 'Ⱡ', + 'ⱥ' => 'Ⱥ', + 'ⱦ' => 'Ⱦ', + 'ⱨ' => 'Ⱨ', + 'ⱪ' => 'Ⱪ', + 'ⱬ' => 'Ⱬ', + 'ⱳ' => 'Ⱳ', + 'ⱶ' => 'Ⱶ', + 'ⲁ' => 'Ⲁ', + 'ⲃ' => 'Ⲃ', + 'ⲅ' => 'Ⲅ', + 'ⲇ' => 'Ⲇ', + 'ⲉ' => 'Ⲉ', + 'ⲋ' => 'Ⲋ', + 'ⲍ' => 'Ⲍ', + 'ⲏ' => 'Ⲏ', + 'ⲑ' => 'Ⲑ', + 'ⲓ' => 'Ⲓ', + 'ⲕ' => 'Ⲕ', + 'ⲗ' => 'Ⲗ', + 'ⲙ' => 'Ⲙ', + 'ⲛ' => 'Ⲛ', + 'ⲝ' => 'Ⲝ', + 'ⲟ' => 'Ⲟ', + 'ⲡ' => 'Ⲡ', + 'ⲣ' => 'Ⲣ', + 'ⲥ' => 'Ⲥ', + 'ⲧ' => 'Ⲧ', + 'ⲩ' => 'Ⲩ', + 'ⲫ' => 'Ⲫ', + 'ⲭ' => 'Ⲭ', + 'ⲯ' => 'Ⲯ', + 'ⲱ' => 'Ⲱ', + 'ⲳ' => 'Ⲳ', + 'ⲵ' => 'Ⲵ', + 'ⲷ' => 'Ⲷ', + 'ⲹ' => 'Ⲹ', + 'ⲻ' => 'Ⲻ', + 'ⲽ' => 'Ⲽ', + 'ⲿ' => 'Ⲿ', + 'ⳁ' => 'Ⳁ', + 'ⳃ' => 'Ⳃ', + 'ⳅ' => 'Ⳅ', + 'ⳇ' => 'Ⳇ', + 'ⳉ' => 'Ⳉ', + 'ⳋ' => 'Ⳋ', + 'ⳍ' => 'Ⳍ', + 'ⳏ' => 'Ⳏ', + 'ⳑ' => 'Ⳑ', + 'ⳓ' => 'Ⳓ', + 'ⳕ' => 'Ⳕ', + 'ⳗ' => 'Ⳗ', + 'ⳙ' => 'Ⳙ', + 'ⳛ' => 'Ⳛ', + 'ⳝ' => 'Ⳝ', + 'ⳟ' => 'Ⳟ', + 'ⳡ' => 'Ⳡ', + 'ⳣ' => 'Ⳣ', + 'ⳬ' => 'Ⳬ', + 'ⳮ' => 'Ⳮ', + 'ⳳ' => 'Ⳳ', + 'ⴀ' => 'Ⴀ', + 'ⴁ' => 'Ⴁ', + 'ⴂ' => 'Ⴂ', + 'ⴃ' => 'Ⴃ', + 'ⴄ' => 'Ⴄ', + 'ⴅ' => 'Ⴅ', + 'ⴆ' => 'Ⴆ', + 'ⴇ' => 'Ⴇ', + 'ⴈ' => 'Ⴈ', + 'ⴉ' => 'Ⴉ', + 'ⴊ' => 'Ⴊ', + 'ⴋ' => 'Ⴋ', + 'ⴌ' => 'Ⴌ', + 'ⴍ' => 'Ⴍ', + 'ⴎ' => 'Ⴎ', + 'ⴏ' => 'Ⴏ', + 'ⴐ' => 'Ⴐ', + 'ⴑ' => 'Ⴑ', + 'ⴒ' => 'Ⴒ', + 'ⴓ' => 'Ⴓ', + 'ⴔ' => 'Ⴔ', + 'ⴕ' => 'Ⴕ', + 'ⴖ' => 'Ⴖ', + 'ⴗ' => 'Ⴗ', + 'ⴘ' => 'Ⴘ', + 'ⴙ' => 'Ⴙ', + 'ⴚ' => 'Ⴚ', + 'ⴛ' => 'Ⴛ', + 'ⴜ' => 'Ⴜ', + 'ⴝ' => 'Ⴝ', + 'ⴞ' => 'Ⴞ', + 'ⴟ' => 'Ⴟ', + 'ⴠ' => 'Ⴠ', + 'ⴡ' => 'Ⴡ', + 'ⴢ' => 'Ⴢ', + 'ⴣ' => 'Ⴣ', + 'ⴤ' => 'Ⴤ', + 'ⴥ' => 'Ⴥ', + 'ⴧ' => 'Ⴧ', + 'ⴭ' => 'Ⴭ', + 'ꙁ' => 'Ꙁ', + 'ꙃ' => 'Ꙃ', + 'ꙅ' => 'Ꙅ', + 'ꙇ' => 'Ꙇ', + 'ꙉ' => 'Ꙉ', + 'ꙋ' => 'Ꙋ', + 'ꙍ' => 'Ꙍ', + 'ꙏ' => 'Ꙏ', + 'ꙑ' => 'Ꙑ', + 'ꙓ' => 'Ꙓ', + 'ꙕ' => 'Ꙕ', + 'ꙗ' => 'Ꙗ', + 'ꙙ' => 'Ꙙ', + 'ꙛ' => 'Ꙛ', + 'ꙝ' => 'Ꙝ', + 'ꙟ' => 'Ꙟ', + 'ꙡ' => 'Ꙡ', + 'ꙣ' => 'Ꙣ', + 'ꙥ' => 'Ꙥ', + 'ꙧ' => 'Ꙧ', + 'ꙩ' => 'Ꙩ', + 'ꙫ' => 'Ꙫ', + 'ꙭ' => 'Ꙭ', + 'ꚁ' => 'Ꚁ', + 'ꚃ' => 'Ꚃ', + 'ꚅ' => 'Ꚅ', + 'ꚇ' => 'Ꚇ', + 'ꚉ' => 'Ꚉ', + 'ꚋ' => 'Ꚋ', + 'ꚍ' => 'Ꚍ', + 'ꚏ' => 'Ꚏ', + 'ꚑ' => 'Ꚑ', + 'ꚓ' => 'Ꚓ', + 'ꚕ' => 'Ꚕ', + 'ꚗ' => 'Ꚗ', + 'ꚙ' => 'Ꚙ', + 'ꚛ' => 'Ꚛ', + 'ꜣ' => 'Ꜣ', + 'ꜥ' => 'Ꜥ', + 'ꜧ' => 'Ꜧ', + 'ꜩ' => 'Ꜩ', + 'ꜫ' => 'Ꜫ', + 'ꜭ' => 'Ꜭ', + 'ꜯ' => 'Ꜯ', + 'ꜳ' => 'Ꜳ', + 'ꜵ' => 'Ꜵ', + 'ꜷ' => 'Ꜷ', + 'ꜹ' => 'Ꜹ', + 'ꜻ' => 'Ꜻ', + 'ꜽ' => 'Ꜽ', + 'ꜿ' => 'Ꜿ', + 'ꝁ' => 'Ꝁ', + 'ꝃ' => 'Ꝃ', + 'ꝅ' => 'Ꝅ', + 'ꝇ' => 'Ꝇ', + 'ꝉ' => 'Ꝉ', + 'ꝋ' => 'Ꝋ', + 'ꝍ' => 'Ꝍ', + 'ꝏ' => 'Ꝏ', + 'ꝑ' => 'Ꝑ', + 'ꝓ' => 'Ꝓ', + 'ꝕ' => 'Ꝕ', + 'ꝗ' => 'Ꝗ', + 'ꝙ' => 'Ꝙ', + 'ꝛ' => 'Ꝛ', + 'ꝝ' => 'Ꝝ', + 'ꝟ' => 'Ꝟ', + 'ꝡ' => 'Ꝡ', + 'ꝣ' => 'Ꝣ', + 'ꝥ' => 'Ꝥ', + 'ꝧ' => 'Ꝧ', + 'ꝩ' => 'Ꝩ', + 'ꝫ' => 'Ꝫ', + 'ꝭ' => 'Ꝭ', + 'ꝯ' => 'Ꝯ', + 'ꝺ' => 'Ꝺ', + 'ꝼ' => 'Ꝼ', + 'ꝿ' => 'Ꝿ', + 'ꞁ' => 'Ꞁ', + 'ꞃ' => 'Ꞃ', + 'ꞅ' => 'Ꞅ', + 'ꞇ' => 'Ꞇ', + 'ꞌ' => 'Ꞌ', + 'ꞑ' => 'Ꞑ', + 'ꞓ' => 'Ꞓ', + 'ꞔ' => 'Ꞔ', + 'ꞗ' => 'Ꞗ', + 'ꞙ' => 'Ꞙ', + 'ꞛ' => 'Ꞛ', + 'ꞝ' => 'Ꞝ', + 'ꞟ' => 'Ꞟ', + 'ꞡ' => 'Ꞡ', + 'ꞣ' => 'Ꞣ', + 'ꞥ' => 'Ꞥ', + 'ꞧ' => 'Ꞧ', + 'ꞩ' => 'Ꞩ', + 'ꞵ' => 'Ꞵ', + 'ꞷ' => 'Ꞷ', + 'ꞹ' => 'Ꞹ', + 'ꞻ' => 'Ꞻ', + 'ꞽ' => 'Ꞽ', + 'ꞿ' => 'Ꞿ', + 'ꟃ' => 'Ꟃ', + 'ꟈ' => 'Ꟈ', + 'ꟊ' => 'Ꟊ', + 'ꟶ' => 'Ꟶ', + 'ꭓ' => 'Ꭓ', + 'ꭰ' => 'Ꭰ', + 'ꭱ' => 'Ꭱ', + 'ꭲ' => 'Ꭲ', + 'ꭳ' => 'Ꭳ', + 'ꭴ' => 'Ꭴ', + 'ꭵ' => 'Ꭵ', + 'ꭶ' => 'Ꭶ', + 'ꭷ' => 'Ꭷ', + 'ꭸ' => 'Ꭸ', + 'ꭹ' => 'Ꭹ', + 'ꭺ' => 'Ꭺ', + 'ꭻ' => 'Ꭻ', + 'ꭼ' => 'Ꭼ', + 'ꭽ' => 'Ꭽ', + 'ꭾ' => 'Ꭾ', + 'ꭿ' => 'Ꭿ', + 'ꮀ' => 'Ꮀ', + 'ꮁ' => 'Ꮁ', + 'ꮂ' => 'Ꮂ', + 'ꮃ' => 'Ꮃ', + 'ꮄ' => 'Ꮄ', + 'ꮅ' => 'Ꮅ', + 'ꮆ' => 'Ꮆ', + 'ꮇ' => 'Ꮇ', + 'ꮈ' => 'Ꮈ', + 'ꮉ' => 'Ꮉ', + 'ꮊ' => 'Ꮊ', + 'ꮋ' => 'Ꮋ', + 'ꮌ' => 'Ꮌ', + 'ꮍ' => 'Ꮍ', + 'ꮎ' => 'Ꮎ', + 'ꮏ' => 'Ꮏ', + 'ꮐ' => 'Ꮐ', + 'ꮑ' => 'Ꮑ', + 'ꮒ' => 'Ꮒ', + 'ꮓ' => 'Ꮓ', + 'ꮔ' => 'Ꮔ', + 'ꮕ' => 'Ꮕ', + 'ꮖ' => 'Ꮖ', + 'ꮗ' => 'Ꮗ', + 'ꮘ' => 'Ꮘ', + 'ꮙ' => 'Ꮙ', + 'ꮚ' => 'Ꮚ', + 'ꮛ' => 'Ꮛ', + 'ꮜ' => 'Ꮜ', + 'ꮝ' => 'Ꮝ', + 'ꮞ' => 'Ꮞ', + 'ꮟ' => 'Ꮟ', + 'ꮠ' => 'Ꮠ', + 'ꮡ' => 'Ꮡ', + 'ꮢ' => 'Ꮢ', + 'ꮣ' => 'Ꮣ', + 'ꮤ' => 'Ꮤ', + 'ꮥ' => 'Ꮥ', + 'ꮦ' => 'Ꮦ', + 'ꮧ' => 'Ꮧ', + 'ꮨ' => 'Ꮨ', + 'ꮩ' => 'Ꮩ', + 'ꮪ' => 'Ꮪ', + 'ꮫ' => 'Ꮫ', + 'ꮬ' => 'Ꮬ', + 'ꮭ' => 'Ꮭ', + 'ꮮ' => 'Ꮮ', + 'ꮯ' => 'Ꮯ', + 'ꮰ' => 'Ꮰ', + 'ꮱ' => 'Ꮱ', + 'ꮲ' => 'Ꮲ', + 'ꮳ' => 'Ꮳ', + 'ꮴ' => 'Ꮴ', + 'ꮵ' => 'Ꮵ', + 'ꮶ' => 'Ꮶ', + 'ꮷ' => 'Ꮷ', + 'ꮸ' => 'Ꮸ', + 'ꮹ' => 'Ꮹ', + 'ꮺ' => 'Ꮺ', + 'ꮻ' => 'Ꮻ', + 'ꮼ' => 'Ꮼ', + 'ꮽ' => 'Ꮽ', + 'ꮾ' => 'Ꮾ', + 'ꮿ' => 'Ꮿ', + 'a' => 'A', + 'b' => 'B', + 'c' => 'C', + 'd' => 'D', + 'e' => 'E', + 'f' => 'F', + 'g' => 'G', + 'h' => 'H', + 'i' => 'I', + 'j' => 'J', + 'k' => 'K', + 'l' => 'L', + 'm' => 'M', + 'n' => 'N', + 'o' => 'O', + 'p' => 'P', + 'q' => 'Q', + 'r' => 'R', + 's' => 'S', + 't' => 'T', + 'u' => 'U', + 'v' => 'V', + 'w' => 'W', + 'x' => 'X', + 'y' => 'Y', + 'z' => 'Z', + '𐐨' => '𐐀', + '𐐩' => '𐐁', + '𐐪' => '𐐂', + '𐐫' => '𐐃', + '𐐬' => '𐐄', + '𐐭' => '𐐅', + '𐐮' => '𐐆', + '𐐯' => '𐐇', + '𐐰' => '𐐈', + '𐐱' => '𐐉', + '𐐲' => '𐐊', + '𐐳' => '𐐋', + '𐐴' => '𐐌', + '𐐵' => '𐐍', + '𐐶' => '𐐎', + '𐐷' => '𐐏', + '𐐸' => '𐐐', + '𐐹' => '𐐑', + '𐐺' => '𐐒', + '𐐻' => '𐐓', + '𐐼' => '𐐔', + '𐐽' => '𐐕', + '𐐾' => '𐐖', + '𐐿' => '𐐗', + '𐑀' => '𐐘', + '𐑁' => '𐐙', + '𐑂' => '𐐚', + '𐑃' => '𐐛', + '𐑄' => '𐐜', + '𐑅' => '𐐝', + '𐑆' => '𐐞', + '𐑇' => '𐐟', + '𐑈' => '𐐠', + '𐑉' => '𐐡', + '𐑊' => '𐐢', + '𐑋' => '𐐣', + '𐑌' => '𐐤', + '𐑍' => '𐐥', + '𐑎' => '𐐦', + '𐑏' => '𐐧', + '𐓘' => '𐒰', + '𐓙' => '𐒱', + '𐓚' => '𐒲', + '𐓛' => '𐒳', + '𐓜' => '𐒴', + '𐓝' => '𐒵', + '𐓞' => '𐒶', + '𐓟' => '𐒷', + '𐓠' => '𐒸', + '𐓡' => '𐒹', + '𐓢' => '𐒺', + '𐓣' => '𐒻', + '𐓤' => '𐒼', + '𐓥' => '𐒽', + '𐓦' => '𐒾', + '𐓧' => '𐒿', + '𐓨' => '𐓀', + '𐓩' => '𐓁', + '𐓪' => '𐓂', + '𐓫' => '𐓃', + '𐓬' => '𐓄', + '𐓭' => '𐓅', + '𐓮' => '𐓆', + '𐓯' => '𐓇', + '𐓰' => '𐓈', + '𐓱' => '𐓉', + '𐓲' => '𐓊', + '𐓳' => '𐓋', + '𐓴' => '𐓌', + '𐓵' => '𐓍', + '𐓶' => '𐓎', + '𐓷' => '𐓏', + '𐓸' => '𐓐', + '𐓹' => '𐓑', + '𐓺' => '𐓒', + '𐓻' => '𐓓', + '𐳀' => '𐲀', + '𐳁' => '𐲁', + '𐳂' => '𐲂', + '𐳃' => '𐲃', + '𐳄' => '𐲄', + '𐳅' => '𐲅', + '𐳆' => '𐲆', + '𐳇' => '𐲇', + '𐳈' => '𐲈', + '𐳉' => '𐲉', + '𐳊' => '𐲊', + '𐳋' => '𐲋', + '𐳌' => '𐲌', + '𐳍' => '𐲍', + '𐳎' => '𐲎', + '𐳏' => '𐲏', + '𐳐' => '𐲐', + '𐳑' => '𐲑', + '𐳒' => '𐲒', + '𐳓' => '𐲓', + '𐳔' => '𐲔', + '𐳕' => '𐲕', + '𐳖' => '𐲖', + '𐳗' => '𐲗', + '𐳘' => '𐲘', + '𐳙' => '𐲙', + '𐳚' => '𐲚', + '𐳛' => '𐲛', + '𐳜' => '𐲜', + '𐳝' => '𐲝', + '𐳞' => '𐲞', + '𐳟' => '𐲟', + '𐳠' => '𐲠', + '𐳡' => '𐲡', + '𐳢' => '𐲢', + '𐳣' => '𐲣', + '𐳤' => '𐲤', + '𐳥' => '𐲥', + '𐳦' => '𐲦', + '𐳧' => '𐲧', + '𐳨' => '𐲨', + '𐳩' => '𐲩', + '𐳪' => '𐲪', + '𐳫' => '𐲫', + '𐳬' => '𐲬', + '𐳭' => '𐲭', + '𐳮' => '𐲮', + '𐳯' => '𐲯', + '𐳰' => '𐲰', + '𐳱' => '𐲱', + '𐳲' => '𐲲', + '𑣀' => '𑢠', + '𑣁' => '𑢡', + '𑣂' => '𑢢', + '𑣃' => '𑢣', + '𑣄' => '𑢤', + '𑣅' => '𑢥', + '𑣆' => '𑢦', + '𑣇' => '𑢧', + '𑣈' => '𑢨', + '𑣉' => '𑢩', + '𑣊' => '𑢪', + '𑣋' => '𑢫', + '𑣌' => '𑢬', + '𑣍' => '𑢭', + '𑣎' => '𑢮', + '𑣏' => '𑢯', + '𑣐' => '𑢰', + '𑣑' => '𑢱', + '𑣒' => '𑢲', + '𑣓' => '𑢳', + '𑣔' => '𑢴', + '𑣕' => '𑢵', + '𑣖' => '𑢶', + '𑣗' => '𑢷', + '𑣘' => '𑢸', + '𑣙' => '𑢹', + '𑣚' => '𑢺', + '𑣛' => '𑢻', + '𑣜' => '𑢼', + '𑣝' => '𑢽', + '𑣞' => '𑢾', + '𑣟' => '𑢿', + '𖹠' => '𖹀', + '𖹡' => '𖹁', + '𖹢' => '𖹂', + '𖹣' => '𖹃', + '𖹤' => '𖹄', + '𖹥' => '𖹅', + '𖹦' => '𖹆', + '𖹧' => '𖹇', + '𖹨' => '𖹈', + '𖹩' => '𖹉', + '𖹪' => '𖹊', + '𖹫' => '𖹋', + '𖹬' => '𖹌', + '𖹭' => '𖹍', + '𖹮' => '𖹎', + '𖹯' => '𖹏', + '𖹰' => '𖹐', + '𖹱' => '𖹑', + '𖹲' => '𖹒', + '𖹳' => '𖹓', + '𖹴' => '𖹔', + '𖹵' => '𖹕', + '𖹶' => '𖹖', + '𖹷' => '𖹗', + '𖹸' => '𖹘', + '𖹹' => '𖹙', + '𖹺' => '𖹚', + '𖹻' => '𖹛', + '𖹼' => '𖹜', + '𖹽' => '𖹝', + '𖹾' => '𖹞', + '𖹿' => '𖹟', + '𞤢' => '𞤀', + '𞤣' => '𞤁', + '𞤤' => '𞤂', + '𞤥' => '𞤃', + '𞤦' => '𞤄', + '𞤧' => '𞤅', + '𞤨' => '𞤆', + '𞤩' => '𞤇', + '𞤪' => '𞤈', + '𞤫' => '𞤉', + '𞤬' => '𞤊', + '𞤭' => '𞤋', + '𞤮' => '𞤌', + '𞤯' => '𞤍', + '𞤰' => '𞤎', + '𞤱' => '𞤏', + '𞤲' => '𞤐', + '𞤳' => '𞤑', + '𞤴' => '𞤒', + '𞤵' => '𞤓', + '𞤶' => '𞤔', + '𞤷' => '𞤕', + '𞤸' => '𞤖', + '𞤹' => '𞤗', + '𞤺' => '𞤘', + '𞤻' => '𞤙', + '𞤼' => '𞤚', + '𞤽' => '𞤛', + '𞤾' => '𞤜', + '𞤿' => '𞤝', + '𞥀' => '𞤞', + '𞥁' => '𞤟', + '𞥂' => '𞤠', + '𞥃' => '𞤡', + 'ß' => 'SS', + 'ff' => 'FF', + 'fi' => 'FI', + 'fl' => 'FL', + 'ffi' => 'FFI', + 'ffl' => 'FFL', + 'ſt' => 'ST', + 'st' => 'ST', + 'և' => 'ԵՒ', + 'ﬓ' => 'ՄՆ', + 'ﬔ' => 'ՄԵ', + 'ﬕ' => 'ՄԻ', + 'ﬖ' => 'ՎՆ', + 'ﬗ' => 'ՄԽ', + 'ʼn' => 'ʼN', + 'ΐ' => 'Ϊ́', + 'ΰ' => 'Ϋ́', + 'ǰ' => 'J̌', + 'ẖ' => 'H̱', + 'ẗ' => 'T̈', + 'ẘ' => 'W̊', + 'ẙ' => 'Y̊', + 'ẚ' => 'Aʾ', + 'ὐ' => 'Υ̓', + 'ὒ' => 'Υ̓̀', + 'ὔ' => 'Υ̓́', + 'ὖ' => 'Υ̓͂', + 'ᾶ' => 'Α͂', + 'ῆ' => 'Η͂', + 'ῒ' => 'Ϊ̀', + 'ΐ' => 'Ϊ́', + 'ῖ' => 'Ι͂', + 'ῗ' => 'Ϊ͂', + 'ῢ' => 'Ϋ̀', + 'ΰ' => 'Ϋ́', + 'ῤ' => 'Ρ̓', + 'ῦ' => 'Υ͂', + 'ῧ' => 'Ϋ͂', + 'ῶ' => 'Ω͂', + 'ᾈ' => 'ἈΙ', + 'ᾉ' => 'ἉΙ', + 'ᾊ' => 'ἊΙ', + 'ᾋ' => 'ἋΙ', + 'ᾌ' => 'ἌΙ', + 'ᾍ' => 'ἍΙ', + 'ᾎ' => 'ἎΙ', + 'ᾏ' => 'ἏΙ', + 'ᾘ' => 'ἨΙ', + 'ᾙ' => 'ἩΙ', + 'ᾚ' => 'ἪΙ', + 'ᾛ' => 'ἫΙ', + 'ᾜ' => 'ἬΙ', + 'ᾝ' => 'ἭΙ', + 'ᾞ' => 'ἮΙ', + 'ᾟ' => 'ἯΙ', + 'ᾨ' => 'ὨΙ', + 'ᾩ' => 'ὩΙ', + 'ᾪ' => 'ὪΙ', + 'ᾫ' => 'ὫΙ', + 'ᾬ' => 'ὬΙ', + 'ᾭ' => 'ὭΙ', + 'ᾮ' => 'ὮΙ', + 'ᾯ' => 'ὯΙ', + 'ᾼ' => 'ΑΙ', + 'ῌ' => 'ΗΙ', + 'ῼ' => 'ΩΙ', + 'ᾲ' => 'ᾺΙ', + 'ᾴ' => 'ΆΙ', + 'ῂ' => 'ῊΙ', + 'ῄ' => 'ΉΙ', + 'ῲ' => 'ῺΙ', + 'ῴ' => 'ΏΙ', + 'ᾷ' => 'Α͂Ι', + 'ῇ' => 'Η͂Ι', + 'ῷ' => 'Ω͂Ι', +); diff --git a/vendor/symfony/polyfill-mbstring/bootstrap.php b/vendor/symfony/polyfill-mbstring/bootstrap.php new file mode 100644 index 0000000..ff51ae0 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/bootstrap.php @@ -0,0 +1,172 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Polyfill\Mbstring as p; + +if (\PHP_VERSION_ID >= 80000) { + return require __DIR__.'/bootstrap80.php'; +} + +if (!function_exists('mb_convert_encoding')) { + function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); } +} +if (!function_exists('mb_decode_mimeheader')) { + function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); } +} +if (!function_exists('mb_encode_mimeheader')) { + function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); } +} +if (!function_exists('mb_decode_numericentity')) { + function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); } +} +if (!function_exists('mb_encode_numericentity')) { + function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); } +} +if (!function_exists('mb_convert_case')) { + function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); } +} +if (!function_exists('mb_internal_encoding')) { + function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); } +} +if (!function_exists('mb_language')) { + function mb_language($language = null) { return p\Mbstring::mb_language($language); } +} +if (!function_exists('mb_list_encodings')) { + function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); } +} +if (!function_exists('mb_encoding_aliases')) { + function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); } +} +if (!function_exists('mb_check_encoding')) { + function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); } +} +if (!function_exists('mb_detect_encoding')) { + function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); } +} +if (!function_exists('mb_detect_order')) { + function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); } +} +if (!function_exists('mb_parse_str')) { + function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; } +} +if (!function_exists('mb_strlen')) { + function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); } +} +if (!function_exists('mb_strpos')) { + function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); } +} +if (!function_exists('mb_strtolower')) { + function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); } +} +if (!function_exists('mb_strtoupper')) { + function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); } +} +if (!function_exists('mb_substitute_character')) { + function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); } +} +if (!function_exists('mb_substr')) { + function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); } +} +if (!function_exists('mb_stripos')) { + function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); } +} +if (!function_exists('mb_stristr')) { + function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); } +} +if (!function_exists('mb_strrchr')) { + function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); } +} +if (!function_exists('mb_strrichr')) { + function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); } +} +if (!function_exists('mb_strripos')) { + function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); } +} +if (!function_exists('mb_strrpos')) { + function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); } +} +if (!function_exists('mb_strstr')) { + function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); } +} +if (!function_exists('mb_get_info')) { + function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); } +} +if (!function_exists('mb_http_output')) { + function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); } +} +if (!function_exists('mb_strwidth')) { + function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); } +} +if (!function_exists('mb_substr_count')) { + function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); } +} +if (!function_exists('mb_output_handler')) { + function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); } +} +if (!function_exists('mb_http_input')) { + function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); } +} + +if (!function_exists('mb_convert_variables')) { + function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); } +} + +if (!function_exists('mb_ord')) { + function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); } +} +if (!function_exists('mb_chr')) { + function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); } +} +if (!function_exists('mb_scrub')) { + function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); } +} +if (!function_exists('mb_str_split')) { + function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); } +} + +if (!function_exists('mb_str_pad')) { + function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); } +} + +if (!function_exists('mb_ucfirst')) { + function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); } +} + +if (!function_exists('mb_lcfirst')) { + function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); } +} + +if (!function_exists('mb_trim')) { + function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); } +} + +if (!function_exists('mb_ltrim')) { + function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); } +} + +if (!function_exists('mb_rtrim')) { + function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); } +} + + +if (extension_loaded('mbstring')) { + return; +} + +if (!defined('MB_CASE_UPPER')) { + define('MB_CASE_UPPER', 0); +} +if (!defined('MB_CASE_LOWER')) { + define('MB_CASE_LOWER', 1); +} +if (!defined('MB_CASE_TITLE')) { + define('MB_CASE_TITLE', 2); +} diff --git a/vendor/symfony/polyfill-mbstring/bootstrap80.php b/vendor/symfony/polyfill-mbstring/bootstrap80.php new file mode 100644 index 0000000..5236e6d --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/bootstrap80.php @@ -0,0 +1,167 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Polyfill\Mbstring as p; + +if (!function_exists('mb_convert_encoding')) { + function mb_convert_encoding(array|string|null $string, ?string $to_encoding, array|string|null $from_encoding = null): array|string|false { return p\Mbstring::mb_convert_encoding($string ?? '', (string) $to_encoding, $from_encoding); } +} +if (!function_exists('mb_decode_mimeheader')) { + function mb_decode_mimeheader(?string $string): string { return p\Mbstring::mb_decode_mimeheader((string) $string); } +} +if (!function_exists('mb_encode_mimeheader')) { + function mb_encode_mimeheader(?string $string, ?string $charset = null, ?string $transfer_encoding = null, ?string $newline = "\r\n", ?int $indent = 0): string { return p\Mbstring::mb_encode_mimeheader((string) $string, $charset, $transfer_encoding, (string) $newline, (int) $indent); } +} +if (!function_exists('mb_decode_numericentity')) { + function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null): string { return p\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding); } +} +if (!function_exists('mb_encode_numericentity')) { + function mb_encode_numericentity(?string $string, array $map, ?string $encoding = null, ?bool $hex = false): string { return p\Mbstring::mb_encode_numericentity((string) $string, $map, $encoding, (bool) $hex); } +} +if (!function_exists('mb_convert_case')) { + function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null): string { return p\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding); } +} +if (!function_exists('mb_internal_encoding')) { + function mb_internal_encoding(?string $encoding = null): string|bool { return p\Mbstring::mb_internal_encoding($encoding); } +} +if (!function_exists('mb_language')) { + function mb_language(?string $language = null): string|bool { return p\Mbstring::mb_language($language); } +} +if (!function_exists('mb_list_encodings')) { + function mb_list_encodings(): array { return p\Mbstring::mb_list_encodings(); } +} +if (!function_exists('mb_encoding_aliases')) { + function mb_encoding_aliases(?string $encoding): array { return p\Mbstring::mb_encoding_aliases((string) $encoding); } +} +if (!function_exists('mb_check_encoding')) { + function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool { return p\Mbstring::mb_check_encoding($value, $encoding); } +} +if (!function_exists('mb_detect_encoding')) { + function mb_detect_encoding(?string $string, array|string|null $encodings = null, ?bool $strict = false): string|false { return p\Mbstring::mb_detect_encoding((string) $string, $encodings, (bool) $strict); } +} +if (!function_exists('mb_detect_order')) { + function mb_detect_order(array|string|null $encoding = null): array|bool { return p\Mbstring::mb_detect_order($encoding); } +} +if (!function_exists('mb_parse_str')) { + function mb_parse_str(?string $string, &$result = []): bool { parse_str((string) $string, $result); return (bool) $result; } +} +if (!function_exists('mb_strlen')) { + function mb_strlen(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strlen((string) $string, $encoding); } +} +if (!function_exists('mb_strpos')) { + function mb_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_strtolower')) { + function mb_strtolower(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtolower((string) $string, $encoding); } +} +if (!function_exists('mb_strtoupper')) { + function mb_strtoupper(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtoupper((string) $string, $encoding); } +} +if (!function_exists('mb_substitute_character')) { + function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool { return p\Mbstring::mb_substitute_character($substitute_character); } +} +if (!function_exists('mb_substr')) { + function mb_substr(?string $string, ?int $start, ?int $length = null, ?string $encoding = null): string { return p\Mbstring::mb_substr((string) $string, (int) $start, $length, $encoding); } +} +if (!function_exists('mb_stripos')) { + function mb_stripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_stripos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_stristr')) { + function mb_stristr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_stristr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_strrchr')) { + function mb_strrchr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrchr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_strrichr')) { + function mb_strrichr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrichr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_strripos')) { + function mb_strripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strripos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_strrpos')) { + function mb_strrpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strrpos((string) $haystack, (string) $needle, (int) $offset, $encoding); } +} +if (!function_exists('mb_strstr')) { + function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } +} +if (!function_exists('mb_get_info')) { + function mb_get_info(?string $type = 'all'): array|string|int|false|null { return p\Mbstring::mb_get_info((string) $type); } +} +if (!function_exists('mb_http_output')) { + function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); } +} +if (!function_exists('mb_strwidth')) { + function mb_strwidth(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strwidth((string) $string, $encoding); } +} +if (!function_exists('mb_substr_count')) { + function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null): int { return p\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding); } +} +if (!function_exists('mb_output_handler')) { + function mb_output_handler(?string $string, ?int $status): string { return p\Mbstring::mb_output_handler((string) $string, (int) $status); } +} +if (!function_exists('mb_http_input')) { + function mb_http_input(?string $type = null): array|string|false { return p\Mbstring::mb_http_input($type); } +} + +if (!function_exists('mb_convert_variables')) { + function mb_convert_variables(?string $to_encoding, array|string|null $from_encoding, mixed &$var, mixed &...$vars): string|false { return p\Mbstring::mb_convert_variables((string) $to_encoding, $from_encoding ?? '', $var, ...$vars); } +} + +if (!function_exists('mb_ord')) { + function mb_ord(?string $string, ?string $encoding = null): int|false { return p\Mbstring::mb_ord((string) $string, $encoding); } +} +if (!function_exists('mb_chr')) { + function mb_chr(?int $codepoint, ?string $encoding = null): string|false { return p\Mbstring::mb_chr((int) $codepoint, $encoding); } +} +if (!function_exists('mb_scrub')) { + function mb_scrub(?string $string, ?string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding((string) $string, $encoding, $encoding); } +} +if (!function_exists('mb_str_split')) { + function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); } +} + +if (!function_exists('mb_str_pad')) { + function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); } +} + +if (!function_exists('mb_ucfirst')) { + function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); } +} + +if (!function_exists('mb_lcfirst')) { + function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); } +} + +if (!function_exists('mb_trim')) { + function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); } +} + +if (!function_exists('mb_ltrim')) { + function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); } +} + +if (!function_exists('mb_rtrim')) { + function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); } +} + +if (extension_loaded('mbstring')) { + return; +} + +if (!defined('MB_CASE_UPPER')) { + define('MB_CASE_UPPER', 0); +} +if (!defined('MB_CASE_LOWER')) { + define('MB_CASE_LOWER', 1); +} +if (!defined('MB_CASE_TITLE')) { + define('MB_CASE_TITLE', 2); +} diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json new file mode 100644 index 0000000..daa07f8 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/composer.json @@ -0,0 +1,39 @@ +{ + "name": "symfony/polyfill-mbstring", + "type": "library", + "description": "Symfony polyfill for the Mbstring extension", + "keywords": ["polyfill", "shim", "compatibility", "portable", "mbstring"], + "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", + "ext-iconv": "*" + }, + "provide": { + "ext-mbstring": "*" + }, + "autoload": { + "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" }, + "files": [ "bootstrap.php" ] + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "minimum-stability": "dev", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + } +} diff --git a/vendor/symfony/var-dumper/CHANGELOG.md b/vendor/symfony/var-dumper/CHANGELOG.md new file mode 100644 index 0000000..bb63a98 --- /dev/null +++ b/vendor/symfony/var-dumper/CHANGELOG.md @@ -0,0 +1,116 @@ +CHANGELOG +========= + +7.3 +--- + + * Add casters for `Dba\Connection`, `SQLite3Result`, `OpenSSLAsymmetricKey` and `OpenSSLCertificateSigningRequest` + * Deprecate `ResourceCaster::castCurl()`, `ResourceCaster::castGd()` and `ResourceCaster::castOpensslX509()` + * Mark all casters as `@internal` + +7.2 +--- + + * Add support for `FORCE_COLOR` environment variable + * Add support for virtual properties + +7.1 +--- + + * Add support for new DOM extension classes in `DOMCaster` + +7.0 +--- + + * Add argument `$label` to `VarDumper::dump()` + * Require explicit argument when calling `VarDumper::setHandler()` + * Remove display of backtrace in `Twig_Template`, only `Twig\Template` is supported + +6.4 +--- + + * Dump uninitialized properties + +6.3 +--- + + * Add caster for `WeakMap` + * Add support of named arguments to `dd()` and `dump()` to display the argument name + * Add support for `Relay\Relay` + * Add display of invisible characters + +6.2 +--- + + * Add support for `FFI\CData` and `FFI\CType` + * Deprecate calling `VarDumper::setHandler()` without arguments + +5.4 +--- + + * Add ability to style integer and double values independently + * Add casters for Symfony's UUIDs and ULIDs + * Add support for `Fiber` + +5.2.0 +----- + + * added support for PHPUnit `--colors` option + * added `VAR_DUMPER_FORMAT=server` env var value support + * prevent replacing the handler when the `VAR_DUMPER_FORMAT` env var is set + +5.1.0 +----- + + * added `RdKafka` support + +4.4.0 +----- + + * added `VarDumperTestTrait::setUpVarDumper()` and `VarDumperTestTrait::tearDownVarDumper()` + to configure casters & flags to use in tests + * added `ImagineCaster` and infrastructure to dump images + * added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data + * added `UuidCaster` + * made all casters final + * added support for the `NO_COLOR` env var (https://no-color.org/) + +4.3.0 +----- + + * added `DsCaster` to support dumping the contents of data structures from the Ds extension + +4.2.0 +----- + + * support selecting the format to use by setting the environment variable `VAR_DUMPER_FORMAT` to `html` or `cli` + +4.1.0 +----- + + * added a `ServerDumper` to send serialized Data clones to a server + * added a `ServerDumpCommand` and `DumpServer` to run a server collecting + and displaying dumps on a single place with multiple formats support + * added `CliDescriptor` and `HtmlDescriptor` descriptors for `server:dump` CLI and HTML formats support + +4.0.0 +----- + + * support for passing `\ReflectionClass` instances to the `Caster::castObject()` + method has been dropped, pass class names as strings instead + * the `Data::getRawData()` method has been removed + * the `VarDumperTestTrait::assertDumpEquals()` method expects a 3rd `$filter = 0` + argument and moves `$message = ''` argument at 4th position. + * the `VarDumperTestTrait::assertDumpMatchesFormat()` method expects a 3rd `$filter = 0` + argument and moves `$message = ''` argument at 4th position. + +3.4.0 +----- + + * added `AbstractCloner::setMinDepth()` function to ensure minimum tree depth + * deprecated `MongoCaster` + +2.7.0 +----- + + * deprecated `Cloner\Data::getLimitedClone()`. Use `withMaxDepth`, `withMaxItemsPerDepth` or `withRefHandles` instead. diff --git a/vendor/symfony/var-dumper/Caster/AddressInfoCaster.php b/vendor/symfony/var-dumper/Caster/AddressInfoCaster.php new file mode 100644 index 0000000..f341c68 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/AddressInfoCaster.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * + * @internal since Symfony 7.3 + */ +final class AddressInfoCaster +{ + private const MAPS = [ + 'ai_flags' => [ + 1 => 'AI_PASSIVE', + 2 => 'AI_CANONNAME', + 4 => 'AI_NUMERICHOST', + 8 => 'AI_V4MAPPED', + 16 => 'AI_ALL', + 32 => 'AI_ADDRCONFIG', + 64 => 'AI_IDN', + 128 => 'AI_CANONIDN', + 1024 => 'AI_NUMERICSERV', + ], + 'ai_family' => [ + 1 => 'AF_UNIX', + 2 => 'AF_INET', + 10 => 'AF_INET6', + 44 => 'AF_DIVERT', + ], + 'ai_socktype' => [ + 1 => 'SOCK_STREAM', + 2 => 'SOCK_DGRAM', + 3 => 'SOCK_RAW', + 4 => 'SOCK_RDM', + 5 => 'SOCK_SEQPACKET', + ], + 'ai_protocol' => [ + 1 => 'SOL_SOCKET', + 6 => 'SOL_TCP', + 17 => 'SOL_UDP', + 136 => 'SOL_UDPLITE', + ], + ]; + + public static function castAddressInfo(\AddressInfo $h, array $a, Stub $stub, bool $isNested): array + { + static $resolvedMaps; + + if (!$resolvedMaps) { + foreach (self::MAPS as $k => $map) { + foreach ($map as $v => $name) { + if (\defined($name)) { + $resolvedMaps[$k][\constant($name)] = $name; + } elseif (!isset($resolvedMaps[$k][$v])) { + $resolvedMaps[$k][$v] = $name; + } + } + } + } + + foreach (socket_addrinfo_explain($h) as $k => $v) { + $a[Caster::PREFIX_VIRTUAL.$k] = match (true) { + 'ai_flags' === $k => ConstStub::fromBitfield($v, $resolvedMaps[$k]), + isset($resolvedMaps[$k][$v]) => new ConstStub($resolvedMaps[$k][$v], $v), + default => $v, + }; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/AmqpCaster.php b/vendor/symfony/var-dumper/Caster/AmqpCaster.php new file mode 100644 index 0000000..ff56288 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/AmqpCaster.php @@ -0,0 +1,214 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts Amqp related classes to array representation. + * + * @author Grégoire Pineau + * + * @final + * + * @internal since Symfony 7.3 + */ +class AmqpCaster +{ + private const FLAGS = [ + \AMQP_DURABLE => 'AMQP_DURABLE', + \AMQP_PASSIVE => 'AMQP_PASSIVE', + \AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE', + \AMQP_AUTODELETE => 'AMQP_AUTODELETE', + \AMQP_INTERNAL => 'AMQP_INTERNAL', + \AMQP_NOLOCAL => 'AMQP_NOLOCAL', + \AMQP_AUTOACK => 'AMQP_AUTOACK', + \AMQP_IFEMPTY => 'AMQP_IFEMPTY', + \AMQP_IFUNUSED => 'AMQP_IFUNUSED', + \AMQP_MANDATORY => 'AMQP_MANDATORY', + \AMQP_IMMEDIATE => 'AMQP_IMMEDIATE', + \AMQP_MULTIPLE => 'AMQP_MULTIPLE', + \AMQP_NOWAIT => 'AMQP_NOWAIT', + \AMQP_REQUEUE => 'AMQP_REQUEUE', + ]; + + private const EXCHANGE_TYPES = [ + \AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT', + \AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT', + \AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC', + \AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS', + ]; + + public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'is_connected' => $c->isConnected(), + ]; + + // Recent version of the extension already expose private properties + if (isset($a["\x00AMQPConnection\x00login"])) { + return $a; + } + + // BC layer in the amqp lib + if (method_exists($c, 'getReadTimeout')) { + $timeout = $c->getReadTimeout(); + } else { + $timeout = $c->getTimeout(); + } + + $a += [ + $prefix.'is_connected' => $c->isConnected(), + $prefix.'login' => $c->getLogin(), + $prefix.'password' => $c->getPassword(), + $prefix.'host' => $c->getHost(), + $prefix.'vhost' => $c->getVhost(), + $prefix.'port' => $c->getPort(), + $prefix.'read_timeout' => $timeout, + ]; + + return $a; + } + + public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'is_connected' => $c->isConnected(), + $prefix.'channel_id' => $c->getChannelId(), + ]; + + // Recent version of the extension already expose private properties + if (isset($a["\x00AMQPChannel\x00connection"])) { + return $a; + } + + $a += [ + $prefix.'connection' => $c->getConnection(), + $prefix.'prefetch_size' => $c->getPrefetchSize(), + $prefix.'prefetch_count' => $c->getPrefetchCount(), + ]; + + return $a; + } + + public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'flags' => self::extractFlags($c->getFlags()), + ]; + + // Recent version of the extension already expose private properties + if (isset($a["\x00AMQPQueue\x00name"])) { + return $a; + } + + $a += [ + $prefix.'connection' => $c->getConnection(), + $prefix.'channel' => $c->getChannel(), + $prefix.'name' => $c->getName(), + $prefix.'arguments' => $c->getArguments(), + ]; + + return $a; + } + + public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'flags' => self::extractFlags($c->getFlags()), + ]; + + $type = isset(self::EXCHANGE_TYPES[$c->getType()]) ? new ConstStub(self::EXCHANGE_TYPES[$c->getType()], $c->getType()) : $c->getType(); + + // Recent version of the extension already expose private properties + if (isset($a["\x00AMQPExchange\x00name"])) { + $a["\x00AMQPExchange\x00type"] = $type; + + return $a; + } + + $a += [ + $prefix.'connection' => $c->getConnection(), + $prefix.'channel' => $c->getChannel(), + $prefix.'name' => $c->getName(), + $prefix.'type' => $type, + $prefix.'arguments' => $c->getArguments(), + ]; + + return $a; + } + + public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode()); + + // Recent version of the extension already expose private properties + if (isset($a["\x00AMQPEnvelope\x00body"])) { + $a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode; + + return $a; + } + + if (!($filter & Caster::EXCLUDE_VERBOSE)) { + $a += [$prefix.'body' => $c->getBody()]; + } + + $a += [ + $prefix.'delivery_tag' => $c->getDeliveryTag(), + $prefix.'is_redelivery' => $c->isRedelivery(), + $prefix.'exchange_name' => $c->getExchangeName(), + $prefix.'routing_key' => $c->getRoutingKey(), + $prefix.'content_type' => $c->getContentType(), + $prefix.'content_encoding' => $c->getContentEncoding(), + $prefix.'headers' => $c->getHeaders(), + $prefix.'delivery_mode' => $deliveryMode, + $prefix.'priority' => $c->getPriority(), + $prefix.'correlation_id' => $c->getCorrelationId(), + $prefix.'reply_to' => $c->getReplyTo(), + $prefix.'expiration' => $c->getExpiration(), + $prefix.'message_id' => $c->getMessageId(), + $prefix.'timestamp' => $c->getTimeStamp(), + $prefix.'type' => $c->getType(), + $prefix.'user_id' => $c->getUserId(), + $prefix.'app_id' => $c->getAppId(), + ]; + + return $a; + } + + private static function extractFlags(int $flags): ConstStub + { + $flagsArray = []; + + foreach (self::FLAGS as $value => $name) { + if ($flags & $value) { + $flagsArray[] = $name; + } + } + + if (!$flagsArray) { + $flagsArray = ['AMQP_NOPARAM']; + } + + return new ConstStub(implode('|', $flagsArray), $flags); + } +} diff --git a/vendor/symfony/var-dumper/Caster/ArgsStub.php b/vendor/symfony/var-dumper/Caster/ArgsStub.php new file mode 100644 index 0000000..aadd033 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ArgsStub.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents a list of function arguments. + * + * @author Nicolas Grekas + */ +class ArgsStub extends EnumStub +{ + private static array $parameters = []; + + public function __construct(array $args, string $function, ?string $class) + { + [$variadic, $params] = self::getParameters($function, $class); + + $values = []; + foreach ($args as $k => $v) { + $values[$k] = !\is_scalar($v) && !$v instanceof Stub ? new CutStub($v) : $v; + } + if (null === $params) { + parent::__construct($values, false); + + return; + } + if (\count($values) < \count($params)) { + $params = \array_slice($params, 0, \count($values)); + } elseif (\count($values) > \count($params)) { + $values[] = new EnumStub(array_splice($values, \count($params)), false); + $params[] = $variadic; + } + if (['...'] === $params) { + parent::__construct($values[0]->value, false); + } else { + parent::__construct(array_combine($params, $values)); + } + } + + private static function getParameters(string $function, ?string $class): array + { + if (isset(self::$parameters[$k = $class.'::'.$function])) { + return self::$parameters[$k]; + } + + try { + $r = null !== $class ? new \ReflectionMethod($class, $function) : new \ReflectionFunction($function); + } catch (\ReflectionException) { + return [null, null]; + } + + $variadic = '...'; + $params = []; + foreach ($r->getParameters() as $v) { + $k = '$'.$v->name; + if ($v->isPassedByReference()) { + $k = '&'.$k; + } + if ($v->isVariadic()) { + $variadic .= $k; + } else { + $params[] = $k; + } + } + + return self::$parameters[$k] = [$variadic, $params]; + } +} diff --git a/vendor/symfony/var-dumper/Caster/Caster.php b/vendor/symfony/var-dumper/Caster/Caster.php new file mode 100644 index 0000000..c3bc54e --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/Caster.php @@ -0,0 +1,203 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Helper for filtering out properties in casters. + * + * @author Nicolas Grekas + * + * @final + */ +class Caster +{ + public const EXCLUDE_VERBOSE = 1; + public const EXCLUDE_VIRTUAL = 2; + public const EXCLUDE_DYNAMIC = 4; + public const EXCLUDE_PUBLIC = 8; + public const EXCLUDE_PROTECTED = 16; + public const EXCLUDE_PRIVATE = 32; + public const EXCLUDE_NULL = 64; + public const EXCLUDE_EMPTY = 128; + public const EXCLUDE_NOT_IMPORTANT = 256; + public const EXCLUDE_STRICT = 512; + public const EXCLUDE_UNINITIALIZED = 1024; + + public const PREFIX_VIRTUAL = "\0~\0"; + public const PREFIX_DYNAMIC = "\0+\0"; + public const PREFIX_PROTECTED = "\0*\0"; + // usage: sprintf(Caster::PATTERN_PRIVATE, $class, $property) + public const PATTERN_PRIVATE = "\0%s\0%s"; + + private static array $classProperties = []; + + /** + * Casts objects to arrays and adds the dynamic property prefix. + * + * @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not + * + * @internal since Symfony 7.3 + */ + public static function castObject(object $obj, string $class, bool $hasDebugInfo = false, ?string $debugClass = null): array + { + if ($hasDebugInfo) { + try { + $debugInfo = $obj->__debugInfo(); + } catch (\Throwable) { + // ignore failing __debugInfo() + $hasDebugInfo = false; + } + } + + $a = $obj instanceof \Closure ? [] : (array) $obj; + + if ($obj instanceof \__PHP_Incomplete_Class) { + return $a; + } + + $classProperties = self::$classProperties[$class] ??= self::getClassProperties(new \ReflectionClass($class)); + $a = array_replace($classProperties, $a); + + if ($a) { + $debugClass ??= get_debug_type($obj); + + $i = 0; + $prefixedKeys = []; + foreach ($a as $k => $v) { + if ("\0" !== ($k[0] ?? '')) { + if (!isset($classProperties[$k])) { + $prefixedKeys[$i] = self::PREFIX_DYNAMIC.$k; + } + } elseif ($debugClass !== $class && 1 === strpos($k, $class)) { + $prefixedKeys[$i] = "\0".$debugClass.strrchr($k, "\0"); + } + ++$i; + } + if ($prefixedKeys) { + $keys = array_keys($a); + foreach ($prefixedKeys as $i => $k) { + $keys[$i] = $k; + } + $a = array_combine($keys, $a); + } + } + + if ($hasDebugInfo && \is_array($debugInfo)) { + foreach ($debugInfo as $k => $v) { + if (!isset($k[0]) || "\0" !== $k[0]) { + if (\array_key_exists(self::PREFIX_DYNAMIC.$k, $a)) { + continue; + } + $k = self::PREFIX_VIRTUAL.$k; + } + + unset($a[$k]); + $a[$k] = $v; + } + } + + return $a; + } + + /** + * Filters out the specified properties. + * + * By default, a single match in the $filter bit field filters properties out, following an "or" logic. + * When EXCLUDE_STRICT is set, an "and" logic is applied: all bits must match for a property to be removed. + * + * @param array $a The array containing the properties to filter + * @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out + * @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set + * @param int|null &$count Set to the number of removed properties + */ + public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array + { + $count = 0; + + foreach ($a as $k => $v) { + $type = self::EXCLUDE_STRICT & $filter; + + if (null === $v) { + $type |= self::EXCLUDE_NULL & $filter; + $type |= self::EXCLUDE_EMPTY & $filter; + } elseif (false === $v || '' === $v || '0' === $v || 0 === $v || 0.0 === $v || [] === $v) { + $type |= self::EXCLUDE_EMPTY & $filter; + } elseif ($v instanceof UninitializedStub) { + $type |= self::EXCLUDE_UNINITIALIZED & $filter; + } + if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !\in_array($k, $listedProperties, true)) { + $type |= self::EXCLUDE_NOT_IMPORTANT; + } + if ((self::EXCLUDE_VERBOSE & $filter) && \in_array($k, $listedProperties, true)) { + $type |= self::EXCLUDE_VERBOSE; + } + + if (!isset($k[1]) || "\0" !== $k[0]) { + $type |= self::EXCLUDE_PUBLIC & $filter; + } elseif ('~' === $k[1]) { + $type |= self::EXCLUDE_VIRTUAL & $filter; + } elseif ('+' === $k[1]) { + $type |= self::EXCLUDE_DYNAMIC & $filter; + } elseif ('*' === $k[1]) { + $type |= self::EXCLUDE_PROTECTED & $filter; + } else { + $type |= self::EXCLUDE_PRIVATE & $filter; + } + + if ((self::EXCLUDE_STRICT & $filter) ? $type === $filter : $type) { + unset($a[$k]); + ++$count; + } + } + + return $a; + } + + /** + * @internal since Symfony 7.3 + */ + public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array + { + if (isset($a['__PHP_Incomplete_Class_Name'])) { + $stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')'; + unset($a['__PHP_Incomplete_Class_Name']); + } + + return $a; + } + + private static function getClassProperties(\ReflectionClass $class): array + { + $classProperties = []; + $className = $class->name; + + if ($parent = $class->getParentClass()) { + $classProperties += self::$classProperties[$parent->name] ??= self::getClassProperties($parent); + } + + foreach ($class->getProperties() as $p) { + if ($p->isStatic()) { + continue; + } + + $classProperties[match (true) { + $p->isPublic() => $p->name, + $p->isProtected() => self::PREFIX_PROTECTED.$p->name, + default => "\0".$className."\0".$p->name, + }] = \PHP_VERSION_ID >= 80400 && $p->isVirtual() ? new VirtualStub($p) : new UninitializedStub($p); + } + + return $classProperties; + } +} diff --git a/vendor/symfony/var-dumper/Caster/ClassStub.php b/vendor/symfony/var-dumper/Caster/ClassStub.php new file mode 100644 index 0000000..265baa5 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ClassStub.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents a PHP class identifier. + * + * @author Nicolas Grekas + */ +class ClassStub extends ConstStub +{ + /** + * @param string $identifier A PHP identifier, e.g. a class, method, interface, etc. name + * @param callable $callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier + */ + public function __construct(string $identifier, callable|array|string|null $callable = null) + { + $this->value = $identifier; + + try { + if (null !== $callable) { + if ($callable instanceof \Closure) { + $r = new \ReflectionFunction($callable); + } elseif (\is_object($callable)) { + $r = [$callable, '__invoke']; + } elseif (\is_array($callable)) { + $r = $callable; + } elseif (false !== $i = strpos($callable, '::')) { + $r = [substr($callable, 0, $i), substr($callable, 2 + $i)]; + } else { + $r = new \ReflectionFunction($callable); + } + } elseif (0 < $i = strpos($identifier, '::') ?: strpos($identifier, '->')) { + $r = [substr($identifier, 0, $i), substr($identifier, 2 + $i)]; + } else { + $r = new \ReflectionClass($identifier); + } + + if (\is_array($r)) { + try { + $r = new \ReflectionMethod($r[0], $r[1]); + } catch (\ReflectionException) { + $r = new \ReflectionClass($r[0]); + } + } + + if (str_contains($identifier, "@anonymous\0")) { + $this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $identifier); + } + + if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) { + $s = ReflectionCaster::castFunctionAbstract($r, [], new Stub(), true, Caster::EXCLUDE_VERBOSE); + $s = ReflectionCaster::getSignature($s); + + if (str_ends_with($identifier, '()')) { + $this->value = substr_replace($identifier, $s, -2); + } else { + $this->value .= $s; + } + } + } catch (\ReflectionException) { + return; + } finally { + if (0 < $i = strrpos($this->value, '\\')) { + $this->attr['ellipsis'] = \strlen($this->value) - $i; + $this->attr['ellipsis-type'] = 'class'; + $this->attr['ellipsis-tail'] = 1; + } + } + + if ($f = $r->getFileName()) { + $this->attr['file'] = $f; + $this->attr['line'] = $r->getStartLine(); + } + } + + public static function wrapCallable(mixed $callable): mixed + { + if (\is_object($callable) || !\is_callable($callable)) { + return $callable; + } + + if (!\is_array($callable)) { + $callable = new static($callable, $callable); + } elseif (\is_string($callable[0])) { + $callable[0] = new static($callable[0], $callable); + } else { + $callable[1] = new static($callable[1], $callable); + } + + return $callable; + } +} diff --git a/vendor/symfony/var-dumper/Caster/ConstStub.php b/vendor/symfony/var-dumper/Caster/ConstStub.php new file mode 100644 index 0000000..adea786 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ConstStub.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents a PHP constant and its value. + * + * @author Nicolas Grekas + */ +class ConstStub extends Stub +{ + public function __construct(string $name, string|int|float|null $value = null) + { + $this->class = $name; + $this->value = 1 < \func_num_args() ? $value : $name; + } + + public function __toString(): string + { + return (string) $this->value; + } + + /** + * @param array $values + */ + public static function fromBitfield(int $value, array $values): self + { + $names = []; + foreach ($values as $v => $name) { + if ($value & $v) { + $names[] = $name; + } + } + + if (!$names) { + $names[] = $values[0] ?? 0; + } + + return new self(implode(' | ', $names), $value); + } +} diff --git a/vendor/symfony/var-dumper/Caster/CurlCaster.php b/vendor/symfony/var-dumper/Caster/CurlCaster.php new file mode 100644 index 0000000..fe4ec52 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/CurlCaster.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * + * @internal + */ +final class CurlCaster +{ + public static function castCurl(\CurlHandle $h, array $a, Stub $stub, bool $isNested): array + { + foreach (curl_getinfo($h) as $key => $val) { + $a[Caster::PREFIX_VIRTUAL.$key] = $val; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/CutArrayStub.php b/vendor/symfony/var-dumper/Caster/CutArrayStub.php new file mode 100644 index 0000000..5912e13 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/CutArrayStub.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +/** + * Represents a cut array. + * + * @author Nicolas Grekas + */ +class CutArrayStub extends CutStub +{ + public array $preservedSubset; + + public function __construct(array $value, array $preservedKeys) + { + parent::__construct($value); + + $this->preservedSubset = array_intersect_key($value, array_flip($preservedKeys)); + $this->cut -= \count($this->preservedSubset); + } +} diff --git a/vendor/symfony/var-dumper/Caster/CutStub.php b/vendor/symfony/var-dumper/Caster/CutStub.php new file mode 100644 index 0000000..6870a9c --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/CutStub.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents the main properties of a PHP variable, pre-casted by a caster. + * + * @author Nicolas Grekas + */ +class CutStub extends Stub +{ + public function __construct(mixed $value) + { + $this->value = $value; + + switch (\gettype($value)) { + case 'object': + $this->type = self::TYPE_OBJECT; + $this->class = get_debug_type($value); + + if ($value instanceof \Closure) { + ReflectionCaster::castClosure($value, [], $this, true, Caster::EXCLUDE_VERBOSE); + } + + $this->cut = -1; + break; + + case 'array': + $this->type = self::TYPE_ARRAY; + $this->class = self::ARRAY_ASSOC; + $this->cut = $this->value = \count($value); + break; + + case 'resource': + case 'unknown type': + case 'resource (closed)': + $this->type = self::TYPE_RESOURCE; + $this->handle = (int) $value; + if ('Unknown' === $this->class = @get_resource_type($value)) { + $this->class = 'Closed'; + } + $this->cut = -1; + break; + + case 'string': + $this->type = self::TYPE_STRING; + $this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY; + $this->cut = self::STRING_BINARY === $this->class ? \strlen($value) : mb_strlen($value, 'UTF-8'); + $this->value = ''; + break; + } + } +} diff --git a/vendor/symfony/var-dumper/Caster/DOMCaster.php b/vendor/symfony/var-dumper/Caster/DOMCaster.php new file mode 100644 index 0000000..e16b33d --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/DOMCaster.php @@ -0,0 +1,318 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts DOM related classes to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class DOMCaster +{ + private const ERROR_CODES = [ + 0 => 'DOM_PHP_ERR', + \DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR', + \DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR', + \DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR', + \DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR', + \DOM_INVALID_CHARACTER_ERR => 'DOM_INVALID_CHARACTER_ERR', + \DOM_NO_DATA_ALLOWED_ERR => 'DOM_NO_DATA_ALLOWED_ERR', + \DOM_NO_MODIFICATION_ALLOWED_ERR => 'DOM_NO_MODIFICATION_ALLOWED_ERR', + \DOM_NOT_FOUND_ERR => 'DOM_NOT_FOUND_ERR', + \DOM_NOT_SUPPORTED_ERR => 'DOM_NOT_SUPPORTED_ERR', + \DOM_INUSE_ATTRIBUTE_ERR => 'DOM_INUSE_ATTRIBUTE_ERR', + \DOM_INVALID_STATE_ERR => 'DOM_INVALID_STATE_ERR', + \DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR', + \DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR', + \DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR', + \DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR', + \DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR', + ]; + + private const NODE_TYPES = [ + \XML_ELEMENT_NODE => 'XML_ELEMENT_NODE', + \XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE', + \XML_TEXT_NODE => 'XML_TEXT_NODE', + \XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE', + \XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE', + \XML_ENTITY_NODE => 'XML_ENTITY_NODE', + \XML_PI_NODE => 'XML_PI_NODE', + \XML_COMMENT_NODE => 'XML_COMMENT_NODE', + \XML_DOCUMENT_NODE => 'XML_DOCUMENT_NODE', + \XML_DOCUMENT_TYPE_NODE => 'XML_DOCUMENT_TYPE_NODE', + \XML_DOCUMENT_FRAG_NODE => 'XML_DOCUMENT_FRAG_NODE', + \XML_NOTATION_NODE => 'XML_NOTATION_NODE', + \XML_HTML_DOCUMENT_NODE => 'XML_HTML_DOCUMENT_NODE', + \XML_DTD_NODE => 'XML_DTD_NODE', + \XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE', + \XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE', + \XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE', + \XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE', + ]; + + public static function castException(\DOMException|\Dom\Exception $e, array $a, Stub $stub, bool $isNested): array + { + $k = Caster::PREFIX_PROTECTED.'code'; + if (isset($a[$k], self::ERROR_CODES[$a[$k]])) { + $a[$k] = new ConstStub(self::ERROR_CODES[$a[$k]], $a[$k]); + } + + return $a; + } + + public static function castLength($dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'length' => $dom->length, + ]; + + return $a; + } + + public static function castImplementation(\DOMImplementation|\Dom\Implementation $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'Core' => '1.0', + Caster::PREFIX_VIRTUAL.'XML' => '2.0', + ]; + + return $a; + } + + public static function castNode(\DOMNode|\Dom\Node $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'nodeName' => $dom->nodeName, + 'nodeValue' => new CutStub($dom->nodeValue), + 'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType), + 'parentNode' => new CutStub($dom->parentNode), + 'childNodes' => $dom->childNodes, + 'firstChild' => new CutStub($dom->firstChild), + 'lastChild' => new CutStub($dom->lastChild), + 'previousSibling' => new CutStub($dom->previousSibling), + 'nextSibling' => new CutStub($dom->nextSibling), + 'ownerDocument' => new CutStub($dom->ownerDocument), + 'baseURI' => $dom->baseURI ? new LinkStub($dom->baseURI) : $dom->baseURI, + 'textContent' => new CutStub($dom->textContent), + ]; + + if ($dom instanceof \DOMNode || $dom instanceof \Dom\Element) { + $a += [ + 'attributes' => $dom->attributes, + 'namespaceURI' => $dom->namespaceURI, + 'prefix' => $dom->prefix, + 'localName' => $dom->localName, + ]; + } + + return $a; + } + + public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'nodeName' => $dom->nodeName, + 'nodeValue' => new CutStub($dom->nodeValue), + 'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType), + 'prefix' => $dom->prefix, + 'localName' => $dom->localName, + 'namespaceURI' => $dom->namespaceURI, + 'ownerDocument' => new CutStub($dom->ownerDocument), + 'parentNode' => new CutStub($dom->parentNode), + ]; + + return $a; + } + + public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $a += [ + 'doctype' => $dom->doctype, + 'implementation' => $dom->implementation, + 'documentElement' => new CutStub($dom->documentElement), + 'encoding' => $dom->encoding, + 'xmlEncoding' => $dom->xmlEncoding, + 'xmlStandalone' => $dom->xmlStandalone, + 'xmlVersion' => $dom->xmlVersion, + 'strictErrorChecking' => $dom->strictErrorChecking, + 'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI, + 'formatOutput' => $dom->formatOutput, + 'validateOnParse' => $dom->validateOnParse, + 'resolveExternals' => $dom->resolveExternals, + 'preserveWhiteSpace' => $dom->preserveWhiteSpace, + 'recover' => $dom->recover, + 'substituteEntities' => $dom->substituteEntities, + ]; + + if (!($filter & Caster::EXCLUDE_VERBOSE)) { + $formatOutput = $dom->formatOutput; + $dom->formatOutput = true; + $a += [Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()]; + $dom->formatOutput = $formatOutput; + } + + return $a; + } + + public static function castXMLDocument(\Dom\XMLDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $a += [ + 'doctype' => $dom->doctype, + 'implementation' => $dom->implementation, + 'documentElement' => new CutStub($dom->documentElement), + 'inputEncoding' => $dom->inputEncoding, + 'xmlEncoding' => $dom->xmlEncoding, + 'xmlStandalone' => $dom->xmlStandalone, + 'xmlVersion' => $dom->xmlVersion, + 'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI, + 'formatOutput' => $dom->formatOutput, + ]; + + if (!($filter & Caster::EXCLUDE_VERBOSE)) { + $formatOutput = $dom->formatOutput; + $dom->formatOutput = true; + $a += [Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()]; + $dom->formatOutput = $formatOutput; + } + + return $a; + } + + public static function castHTMLDocument(\Dom\HTMLDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $a += [ + 'doctype' => $dom->doctype, + 'implementation' => $dom->implementation, + 'documentElement' => new CutStub($dom->documentElement), + 'inputEncoding' => $dom->inputEncoding, + 'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI, + ]; + + if (!($filter & Caster::EXCLUDE_VERBOSE)) { + $a += [Caster::PREFIX_VIRTUAL.'html' => $dom->saveHTML()]; + } + + return $a; + } + + public static function castCharacterData(\DOMCharacterData|\Dom\CharacterData $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'data' => $dom->data, + 'length' => $dom->length, + ]; + + return $a; + } + + public static function castAttr(\DOMAttr|\Dom\Attr $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'name' => $dom->name, + 'specified' => $dom->specified, + 'value' => $dom->value, + 'ownerElement' => $dom->ownerElement, + ]; + + if ($dom instanceof \DOMAttr) { + $a += [ + 'schemaTypeInfo' => $dom->schemaTypeInfo, + ]; + } + + return $a; + } + + public static function castElement(\DOMElement|\Dom\Element $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'tagName' => $dom->tagName, + ]; + + if ($dom instanceof \DOMElement) { + $a += [ + 'schemaTypeInfo' => $dom->schemaTypeInfo, + ]; + } + + return $a; + } + + public static function castText(\DOMText|\Dom\Text $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'wholeText' => $dom->wholeText, + ]; + + return $a; + } + + public static function castDocumentType(\DOMDocumentType|\Dom\DocumentType $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'name' => $dom->name, + 'entities' => $dom->entities, + 'notations' => $dom->notations, + 'publicId' => $dom->publicId, + 'systemId' => $dom->systemId, + 'internalSubset' => $dom->internalSubset, + ]; + + return $a; + } + + public static function castNotation(\DOMNotation|\Dom\Notation $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'publicId' => $dom->publicId, + 'systemId' => $dom->systemId, + ]; + + return $a; + } + + public static function castEntity(\DOMEntity|\Dom\Entity $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'publicId' => $dom->publicId, + 'systemId' => $dom->systemId, + 'notationName' => $dom->notationName, + ]; + + return $a; + } + + public static function castProcessingInstruction(\DOMProcessingInstruction|\Dom\ProcessingInstruction $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'target' => $dom->target, + 'data' => $dom->data, + ]; + + return $a; + } + + public static function castXPath(\DOMXPath|\Dom\XPath $dom, array $a, Stub $stub, bool $isNested): array + { + $a += [ + 'document' => $dom->document, + ]; + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/DateCaster.php b/vendor/symfony/var-dumper/Caster/DateCaster.php new file mode 100644 index 0000000..453d0cb --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/DateCaster.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts DateTimeInterface related classes to array representation. + * + * @author Dany Maillard + * + * @final + * + * @internal since Symfony 7.3 + */ +class DateCaster +{ + private const PERIOD_LIMIT = 3; + + public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter): array + { + $prefix = Caster::PREFIX_VIRTUAL; + $location = $d->getTimezone() ? $d->getTimezone()->getLocation() : null; + $fromNow = (new \DateTimeImmutable())->diff($d); + + $title = $d->format('l, F j, Y') + ."\n".self::formatInterval($fromNow).' from now' + .($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '') + ; + + unset( + $a[Caster::PREFIX_DYNAMIC.'date'], + $a[Caster::PREFIX_DYNAMIC.'timezone'], + $a[Caster::PREFIX_DYNAMIC.'timezone_type'] + ); + $a[$prefix.'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title); + + $stub->class .= $d->format(' @U'); + + return $a; + } + + public static function castInterval(\DateInterval $interval, array $a, Stub $stub, bool $isNested, int $filter): array + { + $now = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); + $numberOfSeconds = $now->add($interval)->getTimestamp() - $now->getTimestamp(); + $title = number_format($numberOfSeconds, 0, '.', ' ').'s'; + + $i = [Caster::PREFIX_VIRTUAL.'interval' => new ConstStub(self::formatInterval($interval), $title)]; + + return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a; + } + + private static function formatInterval(\DateInterval $i): string + { + $format = '%R '; + + if (0 === $i->y && 0 === $i->m && ($i->h >= 24 || $i->i >= 60 || $i->s >= 60)) { + $d = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); + $i = $d->diff($d->add($i)); // recalculate carry over points + $format .= 0 < $i->days ? '%ad ' : ''; + } else { + $format .= ($i->y ? '%yy ' : '').($i->m ? '%mm ' : '').($i->d ? '%dd ' : ''); + } + + $format .= $i->h || $i->i || $i->s || $i->f ? '%H:%I:'.self::formatSeconds($i->s, substr($i->f, 2)) : ''; + $format = '%R ' === $format ? '0s' : $format; + + return $i->format(rtrim($format)); + } + + public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, bool $isNested, int $filter): array + { + $location = $timeZone->getLocation(); + $formatted = (new \DateTimeImmutable('now', $timeZone))->format($location ? 'e (P)' : 'P'); + $title = $location && \extension_loaded('intl') ? \Locale::getDisplayRegion('-'.$location['country_code']) : ''; + + $z = [Caster::PREFIX_VIRTUAL.'timezone' => new ConstStub($formatted, $title)]; + + return $filter & Caster::EXCLUDE_VERBOSE ? $z : $z + $a; + } + + public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, bool $isNested, int $filter): array + { + $dates = []; + foreach (clone $p as $i => $d) { + if (self::PERIOD_LIMIT === $i) { + $now = new \DateTimeImmutable('now', new \DateTimeZone('UTC')); + $dates[] = \sprintf('%s more', ($end = $p->getEndDate()) + ? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u'))) + : $p->recurrences - $i + ); + break; + } + $dates[] = \sprintf('%s) %s', $i + 1, self::formatDateTime($d)); + } + + $period = \sprintf( + 'every %s, from %s%s %s', + self::formatInterval($p->getDateInterval()), + $p->include_start_date ? '[' : ']', + self::formatDateTime($p->getStartDate()), + ($end = $p->getEndDate()) ? 'to '.self::formatDateTime($end).($p->include_end_date ? ']' : '[') : 'recurring '.$p->recurrences.' time/s' + ); + + $p = [Caster::PREFIX_VIRTUAL.'period' => new ConstStub($period, implode("\n", $dates))]; + + return $filter & Caster::EXCLUDE_VERBOSE ? $p : $p + $a; + } + + private static function formatDateTime(\DateTimeInterface $d, string $extra = ''): string + { + return $d->format('Y-m-d H:i:'.self::formatSeconds($d->format('s'), $d->format('u')).$extra); + } + + private static function formatSeconds(string $s, string $us): string + { + return \sprintf('%02d.%s', $s, 0 === ($len = \strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us)); + } +} diff --git a/vendor/symfony/var-dumper/Caster/DoctrineCaster.php b/vendor/symfony/var-dumper/Caster/DoctrineCaster.php new file mode 100644 index 0000000..b963112 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/DoctrineCaster.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Doctrine\Common\Proxy\Proxy as CommonProxy; +use Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\Proxy\Proxy as OrmProxy; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts Doctrine related classes to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class DoctrineCaster +{ + public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, bool $isNested): array + { + foreach (['__cloner__', '__initializer__'] as $k) { + if (\array_key_exists($k, $a)) { + unset($a[$k]); + ++$stub->cut; + } + } + + return $a; + } + + public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, bool $isNested): array + { + foreach (['_entityPersister', '_identifier'] as $k) { + if (\array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) { + unset($a[$k]); + ++$stub->cut; + } + } + + return $a; + } + + public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, bool $isNested): array + { + foreach (['snapshot', 'association', 'typeClass'] as $k) { + if (\array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) { + $a[$k] = new CutStub($a[$k]); + } + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/DsCaster.php b/vendor/symfony/var-dumper/Caster/DsCaster.php new file mode 100644 index 0000000..b34b670 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/DsCaster.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Ds\Collection; +use Ds\Map; +use Ds\Pair; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts Ds extension classes to array representation. + * + * @author Jáchym Toušek + * + * @final + */ +class DsCaster +{ + public static function castCollection(Collection $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'count'] = $c->count(); + $a[Caster::PREFIX_VIRTUAL.'capacity'] = $c->capacity(); + + if (!$c instanceof Map) { + $a += $c->toArray(); + } + + return $a; + } + + public static function castMap(Map $c, array $a, Stub $stub, bool $isNested): array + { + foreach ($c as $k => $v) { + $a[] = new DsPairStub($k, $v); + } + + return $a; + } + + public static function castPair(Pair $c, array $a, Stub $stub, bool $isNested): array + { + foreach ($c->toArray() as $k => $v) { + $a[Caster::PREFIX_VIRTUAL.$k] = $v; + } + + return $a; + } + + public static function castPairStub(DsPairStub $c, array $a, Stub $stub, bool $isNested): array + { + if ($isNested) { + $stub->class = Pair::class; + $stub->value = null; + $stub->handle = 0; + + $a = $c->value; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/DsPairStub.php b/vendor/symfony/var-dumper/Caster/DsPairStub.php new file mode 100644 index 0000000..afa2727 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/DsPairStub.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + */ +class DsPairStub extends Stub +{ + public function __construct(mixed $key, mixed $value) + { + $this->value = [ + Caster::PREFIX_VIRTUAL.'key' => $key, + Caster::PREFIX_VIRTUAL.'value' => $value, + ]; + } +} diff --git a/vendor/symfony/var-dumper/Caster/EnumStub.php b/vendor/symfony/var-dumper/Caster/EnumStub.php new file mode 100644 index 0000000..11e0cd9 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/EnumStub.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 Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents an enumeration of values. + * + * @author Nicolas Grekas + */ +class EnumStub extends Stub +{ + public function __construct( + array $values, + public bool $dumpKeys = true, + ) { + $this->value = $values; + } +} diff --git a/vendor/symfony/var-dumper/Caster/ExceptionCaster.php b/vendor/symfony/var-dumper/Caster/ExceptionCaster.php new file mode 100644 index 0000000..4473bdc --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ExceptionCaster.php @@ -0,0 +1,397 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\ErrorHandler\Exception\FlattenException; +use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext; +use Symfony\Component\VarDumper\Cloner\Stub; +use Symfony\Component\VarDumper\Exception\ThrowingCasterException; + +/** + * Casts common Exception classes to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class ExceptionCaster +{ + public static int $srcContext = 1; + public static bool $traceArgs = true; + public static array $errorTypes = [ + \E_DEPRECATED => 'E_DEPRECATED', + \E_USER_DEPRECATED => 'E_USER_DEPRECATED', + \E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', + \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', + ]; + + private static array $framesCache = []; + + public static function castError(\Error $e, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter); + } + + public static function castException(\Exception $e, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter); + } + + public static function castErrorException(\ErrorException $e, array $a, Stub $stub, bool $isNested): array + { + if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) { + $a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]); + } + + return $a; + } + + public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, bool $isNested): array + { + $trace = Caster::PREFIX_VIRTUAL.'trace'; + $prefix = Caster::PREFIX_PROTECTED; + $xPrefix = "\0Exception\0"; + + if (isset($a[$xPrefix.'previous'], $a[$trace]) && $a[$xPrefix.'previous'] instanceof \Exception) { + $b = (array) $a[$xPrefix.'previous']; + $class = get_debug_type($a[$xPrefix.'previous']); + self::traceUnshift($b[$xPrefix.'trace'], $class, $b[$prefix.'file'], $b[$prefix.'line']); + $a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -\count($a[$trace]->value)); + } + + unset($a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']); + + return $a; + } + + public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, bool $isNested): array + { + $sPrefix = "\0".SilencedErrorContext::class."\0"; + + if (!isset($a[$s = $sPrefix.'severity'])) { + return $a; + } + + if (isset(self::$errorTypes[$a[$s]])) { + $a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]); + } + + $trace = [[ + 'file' => $a[$sPrefix.'file'], + 'line' => $a[$sPrefix.'line'], + ]]; + + if (isset($a[$sPrefix.'trace'])) { + $trace = array_merge($trace, $a[$sPrefix.'trace']); + } + + unset($a[$sPrefix.'file'], $a[$sPrefix.'line'], $a[$sPrefix.'trace']); + $a[Caster::PREFIX_VIRTUAL.'trace'] = new TraceStub($trace, self::$traceArgs); + + return $a; + } + + public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, bool $isNested): array + { + if (!$isNested) { + return $a; + } + $stub->class = ''; + $stub->handle = 0; + $frames = $trace->value; + $prefix = Caster::PREFIX_VIRTUAL; + + $a = []; + $j = \count($frames); + if (0 > $i = $trace->sliceOffset) { + $i = max(0, $j + $i); + } + if (!isset($trace->value[$i])) { + return []; + } + $lastCall = isset($frames[$i]['function']) ? (isset($frames[$i]['class']) ? $frames[0]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : ''; + $frames[] = ['function' => '']; + $collapse = false; + + for ($j += $trace->numberingOffset - $i++; isset($frames[$i]); ++$i, --$j) { + $f = $frames[$i]; + $call = isset($f['function']) ? (isset($f['class']) ? $f['class'].$f['type'] : '').$f['function'] : '???'; + + $frame = new FrameStub( + [ + 'object' => $f['object'] ?? null, + 'class' => $f['class'] ?? null, + 'type' => $f['type'] ?? null, + 'function' => $f['function'] ?? null, + ] + $frames[$i - 1], + false, + true + ); + $f = self::castFrameStub($frame, [], $frame, true); + if (isset($f[$prefix.'src'])) { + foreach ($f[$prefix.'src']->value as $label => $frame) { + if (str_starts_with($label, "\0~collapse=0")) { + if ($collapse) { + $label = substr_replace($label, '1', 11, 1); + } else { + $collapse = true; + } + } + $label = substr_replace($label, "title=Stack level $j.&", 2, 0); + } + $f = $frames[$i - 1]; + if ($trace->keepArgs && !empty($f['args']) && $frame instanceof EnumStub) { + $frame->value['arguments'] = new ArgsStub($f['args'], $f['function'] ?? null, $f['class'] ?? null); + } + } elseif ('???' !== $lastCall) { + $label = new ClassStub($lastCall); + if (isset($label->attr['ellipsis'])) { + $label->attr['ellipsis'] += 2; + $label = substr_replace($prefix, "ellipsis-type=class&ellipsis={$label->attr['ellipsis']}&ellipsis-tail=1&title=Stack level $j.", 2, 0).$label->value.'()'; + } else { + $label = substr_replace($prefix, "title=Stack level $j.", 2, 0).$label->value.'()'; + } + } else { + $label = substr_replace($prefix, "title=Stack level $j.", 2, 0).$lastCall; + } + $a[substr_replace($label, \sprintf('separator=%s&', $frame instanceof EnumStub ? ' ' : ':'), 2, 0)] = $frame; + + $lastCall = $call; + } + if (null !== $trace->sliceLength) { + $a = \array_slice($a, 0, $trace->sliceLength, true); + } + + return $a; + } + + public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, bool $isNested): array + { + if (!$isNested) { + return $a; + } + $f = $frame->value; + $prefix = Caster::PREFIX_VIRTUAL; + + if (isset($f['file'], $f['line'])) { + $cacheKey = $f; + unset($cacheKey['object'], $cacheKey['args']); + $cacheKey[] = self::$srcContext; + $cacheKey = implode('-', $cacheKey); + + if (isset(self::$framesCache[$cacheKey])) { + $a[$prefix.'src'] = self::$framesCache[$cacheKey]; + } else { + if (preg_match('/\((\d+)\)(?:\([\da-f]{32}\))? : (?:eval\(\)\'d code|runtime-created function)$/', $f['file'], $match)) { + $f['file'] = substr($f['file'], 0, -\strlen($match[0])); + $f['line'] = (int) $match[1]; + } + $src = $f['line']; + $srcKey = $f['file']; + $ellipsis = new LinkStub($srcKey, 0); + $srcAttr = 'collapse='.(int) $ellipsis->inVendor; + $ellipsisTail = $ellipsis->attr['ellipsis-tail'] ?? 0; + $ellipsis = $ellipsis->attr['ellipsis'] ?? 0; + + if (is_file($f['file']) && 0 <= self::$srcContext) { + if (!empty($f['class']) && is_subclass_of($f['class'], 'Twig\Template')) { + $template = null; + if (isset($f['object'])) { + $template = $f['object']; + } elseif ((new \ReflectionClass($f['class']))->isInstantiable()) { + $template = unserialize(\sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class'])); + } + if (null !== $template) { + $ellipsis = 0; + $templateSrc = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : ''); + $templateInfo = $template->getDebugInfo(); + if (isset($templateInfo[$f['line']])) { + if (!method_exists($template, 'getSourceContext') || !is_file($templatePath = $template->getSourceContext()->getPath())) { + $templatePath = null; + } + if ($templateSrc) { + $src = self::extractSource($templateSrc, $templateInfo[$f['line']], self::$srcContext, 'twig', $templatePath, $f); + $srcKey = ($templatePath ?: $template->getTemplateName()).':'.$templateInfo[$f['line']]; + } + } + } + } + if ($srcKey == $f['file']) { + $src = self::extractSource(file_get_contents($f['file']), $f['line'], self::$srcContext, 'php', $f['file'], $f); + $srcKey .= ':'.$f['line']; + if ($ellipsis) { + $ellipsis += 1 + \strlen($f['line']); + } + } + $srcAttr .= \sprintf('&separator= &file=%s&line=%d', rawurlencode($f['file']), $f['line']); + } else { + $srcAttr .= '&separator=:'; + } + $srcAttr .= $ellipsis ? '&ellipsis-type=path&ellipsis='.$ellipsis.'&ellipsis-tail='.$ellipsisTail : ''; + self::$framesCache[$cacheKey] = $a[$prefix.'src'] = new EnumStub(["\0~$srcAttr\0$srcKey" => $src]); + } + } + + unset($a[$prefix.'args'], $a[$prefix.'line'], $a[$prefix.'file']); + if ($frame->inTraceStub) { + unset($a[$prefix.'class'], $a[$prefix.'type'], $a[$prefix.'function']); + } + foreach ($a as $k => $v) { + if (!$v) { + unset($a[$k]); + } + } + if ($frame->keepArgs && !empty($f['args'])) { + $a[$prefix.'arguments'] = new ArgsStub($f['args'], $f['function'], $f['class']); + } + + return $a; + } + + public static function castFlattenException(FlattenException $e, array $a, Stub $stub, bool $isNested): array + { + if ($isNested) { + $k = \sprintf(Caster::PATTERN_PRIVATE, FlattenException::class, 'traceAsString'); + $a[$k] = new CutStub($a[$k]); + } + + return $a; + } + + private static function filterExceptionArray(string $xClass, array $a, string $xPrefix, int $filter): array + { + if (isset($a[$xPrefix.'trace'])) { + $trace = $a[$xPrefix.'trace']; + unset($a[$xPrefix.'trace']); // Ensures the trace is always last + } else { + $trace = []; + } + + if (!($filter & Caster::EXCLUDE_VERBOSE) && $trace) { + if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) { + self::traceUnshift($trace, $xClass, $a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']); + } + $a[Caster::PREFIX_VIRTUAL.'trace'] = new TraceStub($trace, self::$traceArgs); + } + if (empty($a[$xPrefix.'previous'])) { + unset($a[$xPrefix.'previous']); + } + unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message']); + + if (isset($a[Caster::PREFIX_PROTECTED.'message']) && str_contains($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) { + $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $a[Caster::PREFIX_PROTECTED.'message']); + } + + if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) { + $a[Caster::PREFIX_PROTECTED.'file'] = new LinkStub($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']); + } + + return $a; + } + + private static function traceUnshift(array &$trace, ?string $class, string $file, int $line): void + { + if (isset($trace[0]['file'], $trace[0]['line']) && $trace[0]['file'] === $file && $trace[0]['line'] === $line) { + return; + } + array_unshift($trace, [ + 'function' => $class ? 'new '.$class : null, + 'file' => $file, + 'line' => $line, + ]); + } + + private static function extractSource(string $srcLines, int $line, int $srcContext, string $lang, ?string $file, array $frame): EnumStub + { + $srcLines = explode("\n", $srcLines); + $src = []; + + for ($i = $line - 1 - $srcContext; $i <= $line - 1 + $srcContext; ++$i) { + $src[] = ($srcLines[$i] ?? '')."\n"; + } + + if ($frame['function'] ?? false) { + $stub = new CutStub(new \stdClass()); + $stub->class = (isset($frame['class']) ? $frame['class'].$frame['type'] : '').$frame['function']; + $stub->type = Stub::TYPE_OBJECT; + $stub->attr['cut_hash'] = true; + $stub->attr['file'] = $frame['file']; + $stub->attr['line'] = $frame['line']; + + try { + $caller = isset($frame['class']) ? new \ReflectionMethod($frame['class'], $frame['function']) : new \ReflectionFunction($frame['function']); + $stub->class .= ReflectionCaster::getSignature(ReflectionCaster::castFunctionAbstract($caller, [], $stub, true, Caster::EXCLUDE_VERBOSE)); + + if ($f = $caller->getFileName()) { + $stub->attr['file'] = $f; + $stub->attr['line'] = $caller->getStartLine(); + } + } catch (\ReflectionException) { + // ignore fake class/function + } + + $srcLines = ["\0~separator=\0" => $stub]; + } else { + $stub = null; + $srcLines = []; + } + + $ltrim = 0; + do { + $pad = null; + for ($i = $srcContext << 1; $i >= 0; --$i) { + if (isset($src[$i][$ltrim]) && "\r" !== ($c = $src[$i][$ltrim]) && "\n" !== $c) { + $pad ??= $c; + if ((' ' !== $c && "\t" !== $c) || $pad !== $c) { + break; + } + } + } + ++$ltrim; + } while (0 > $i && null !== $pad); + + --$ltrim; + + foreach ($src as $i => $c) { + if ($ltrim) { + $c = isset($c[$ltrim]) && "\r" !== $c[$ltrim] ? substr($c, $ltrim) : ltrim($c, " \t"); + } + $c = substr($c, 0, -1); + if ($i !== $srcContext) { + $c = new ConstStub('default', $c); + } else { + $c = new ConstStub($c, $stub ? 'in '.$stub->class : ''); + if (null !== $file) { + $c->attr['file'] = $file; + $c->attr['line'] = $line; + } + } + $c->attr['lang'] = $lang; + $srcLines[\sprintf("\0~separator=› &%d\0", $i + $line - $srcContext)] = $c; + } + + return new EnumStub($srcLines); + } +} diff --git a/vendor/symfony/var-dumper/Caster/FFICaster.php b/vendor/symfony/var-dumper/Caster/FFICaster.php new file mode 100644 index 0000000..973b696 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/FFICaster.php @@ -0,0 +1,171 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use FFI\CData; +use FFI\CType; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts FFI extension classes to array representation. + * + * @author Nesmeyanov Kirill + */ +final class FFICaster +{ + /** + * In case of "char*" contains a string, the length of which depends on + * some other parameter, then during the generation of the string it is + * possible to go beyond the allowable memory area. + * + * This restriction serves to ensure that processing does not take + * up the entire allowable PHP memory limit. + */ + private const MAX_STRING_LENGTH = 255; + + public static function castCTypeOrCData(CData|CType $data, array $args, Stub $stub): array + { + if ($data instanceof CType) { + $type = $data; + $data = null; + } else { + $type = \FFI::typeof($data); + } + + $stub->class = \sprintf('%s<%s> size %d align %d', ($data ?? $type)::class, $type->getName(), $type->getSize(), $type->getAlignment()); + + return match ($type->getKind()) { + CType::TYPE_FLOAT, + CType::TYPE_DOUBLE, + \defined('\FFI\CType::TYPE_LONGDOUBLE') ? CType::TYPE_LONGDOUBLE : -1, + CType::TYPE_UINT8, + CType::TYPE_SINT8, + CType::TYPE_UINT16, + CType::TYPE_SINT16, + CType::TYPE_UINT32, + CType::TYPE_SINT32, + CType::TYPE_UINT64, + CType::TYPE_SINT64, + CType::TYPE_BOOL, + CType::TYPE_CHAR, + CType::TYPE_ENUM => null !== $data ? [Caster::PREFIX_VIRTUAL.'cdata' => $data->cdata] : [], + CType::TYPE_POINTER => self::castFFIPointer($stub, $type, $data), + CType::TYPE_STRUCT => self::castFFIStructLike($type, $data), + CType::TYPE_FUNC => self::castFFIFunction($stub, $type), + default => $args, + }; + } + + private static function castFFIFunction(Stub $stub, CType $type): array + { + $arguments = []; + + for ($i = 0, $count = $type->getFuncParameterCount(); $i < $count; ++$i) { + $param = $type->getFuncParameterType($i); + + $arguments[] = $param->getName(); + } + + $abi = match ($type->getFuncABI()) { + CType::ABI_DEFAULT, + CType::ABI_CDECL => '[cdecl]', + CType::ABI_FASTCALL => '[fastcall]', + CType::ABI_THISCALL => '[thiscall]', + CType::ABI_STDCALL => '[stdcall]', + CType::ABI_PASCAL => '[pascal]', + CType::ABI_REGISTER => '[register]', + CType::ABI_MS => '[ms]', + CType::ABI_SYSV => '[sysv]', + CType::ABI_VECTORCALL => '[vectorcall]', + default => '[unknown abi]', + }; + + $returnType = $type->getFuncReturnType(); + + $stub->class = $abi.' callable('.implode(', ', $arguments).'): ' + .$returnType->getName(); + + return [Caster::PREFIX_VIRTUAL.'returnType' => $returnType]; + } + + private static function castFFIPointer(Stub $stub, CType $type, ?CData $data = null): array + { + $ptr = $type->getPointerType(); + + if (null === $data) { + return [Caster::PREFIX_VIRTUAL.'0' => $ptr]; + } + + return match ($ptr->getKind()) { + CType::TYPE_CHAR => [Caster::PREFIX_VIRTUAL.'cdata' => self::castFFIStringValue($data)], + CType::TYPE_FUNC => self::castFFIFunction($stub, $ptr), + default => [Caster::PREFIX_VIRTUAL.'cdata' => $data[0]], + }; + } + + private static function castFFIStringValue(CData $data): string|CutStub + { + $result = []; + $ffi = \FFI::cdef(<<zend_get_page_size(); + + // get cdata address + $start = $ffi->cast('uintptr_t', $ffi->cast('char*', $data))->cdata; + // accessing memory in the same page as $start is safe + $max = min(self::MAX_STRING_LENGTH, ($start | ($pageSize - 1)) - $start); + + for ($i = 0; $i < $max; ++$i) { + $result[$i] = $data[$i]; + + if ("\0" === $data[$i]) { + return implode('', $result); + } + } + + $string = implode('', $result); + $stub = new CutStub($string); + $stub->cut = -1; + $stub->value = $string; + + return $stub; + } + + private static function castFFIStructLike(CType $type, ?CData $data = null): array + { + $isUnion = ($type->getAttributes() & CType::ATTR_UNION) === CType::ATTR_UNION; + + $result = []; + + foreach ($type->getStructFieldNames() as $name) { + $field = $type->getStructFieldType($name); + + // Retrieving the value of a field from a union containing + // a pointer is not a safe operation, because may contain + // incorrect data. + $isUnsafe = $isUnion && CType::TYPE_POINTER === $field->getKind(); + + if ($isUnsafe) { + $result[Caster::PREFIX_VIRTUAL.$name.'?'] = $field; + } elseif (null === $data) { + $result[Caster::PREFIX_VIRTUAL.$name] = $field; + } else { + $fieldName = $data->{$name} instanceof CData ? '' : $field->getName().' '; + $result[Caster::PREFIX_VIRTUAL.$fieldName.$name] = $data->{$name}; + } + } + + return $result; + } +} diff --git a/vendor/symfony/var-dumper/Caster/FiberCaster.php b/vendor/symfony/var-dumper/Caster/FiberCaster.php new file mode 100644 index 0000000..c9df708 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/FiberCaster.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts Fiber related classes to array representation. + * + * @author Grégoire Pineau + */ +final class FiberCaster +{ + public static function castFiber(\Fiber $fiber, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + if ($fiber->isTerminated()) { + $status = 'terminated'; + } elseif ($fiber->isRunning()) { + $status = 'running'; + } elseif ($fiber->isSuspended()) { + $status = 'suspended'; + } elseif ($fiber->isStarted()) { + $status = 'started'; + } else { + $status = 'not started'; + } + + $a[$prefix.'status'] = $status; + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/FrameStub.php b/vendor/symfony/var-dumper/Caster/FrameStub.php new file mode 100644 index 0000000..e57aa46 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/FrameStub.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +/** + * Represents a single backtrace frame as returned by debug_backtrace() or Exception->getTrace(). + * + * @author Nicolas Grekas + */ +class FrameStub extends EnumStub +{ + public function __construct( + array $frame, + public bool $keepArgs = true, + public bool $inTraceStub = false, + ) { + parent::__construct($frame); + } +} diff --git a/vendor/symfony/var-dumper/Caster/GdCaster.php b/vendor/symfony/var-dumper/Caster/GdCaster.php new file mode 100644 index 0000000..db87653 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/GdCaster.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * + * @internal + */ +final class GdCaster +{ + public static function castGd(\GdImage $gd, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'size'] = imagesx($gd).'x'.imagesy($gd); + $a[Caster::PREFIX_VIRTUAL.'trueColor'] = imageistruecolor($gd); + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/GmpCaster.php b/vendor/symfony/var-dumper/Caster/GmpCaster.php new file mode 100644 index 0000000..325d2e9 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/GmpCaster.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts GMP objects to array representation. + * + * @author Hamza Amrouche + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class GmpCaster +{ + public static function castGmp(\GMP $gmp, array $a, Stub $stub, bool $isNested, int $filter): array + { + $a[Caster::PREFIX_VIRTUAL.'value'] = new ConstStub(gmp_strval($gmp), gmp_strval($gmp)); + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/ImagineCaster.php b/vendor/symfony/var-dumper/Caster/ImagineCaster.php new file mode 100644 index 0000000..0fb2a90 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ImagineCaster.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Imagine\Image\ImageInterface; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Grégoire Pineau + * + * @internal since Symfony 7.3 + */ +final class ImagineCaster +{ + public static function castImage(ImageInterface $c, array $a, Stub $stub, bool $isNested): array + { + $imgData = $c->get('png'); + if (\strlen($imgData) > 1 * 1000 * 1000) { + $a += [ + Caster::PREFIX_VIRTUAL.'image' => new ConstStub($c->getSize()), + ]; + } else { + $a += [ + Caster::PREFIX_VIRTUAL.'image' => new ImgStub($imgData, 'image/png', $c->getSize()), + ]; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/ImgStub.php b/vendor/symfony/var-dumper/Caster/ImgStub.php new file mode 100644 index 0000000..a16681f --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ImgStub.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +/** + * @author Grégoire Pineau + */ +class ImgStub extends ConstStub +{ + public function __construct(string $data, string $contentType, string $size = '') + { + $this->value = ''; + $this->attr['img-data'] = $data; + $this->attr['img-size'] = $size; + $this->attr['content-type'] = $contentType; + } +} diff --git a/vendor/symfony/var-dumper/Caster/IntlCaster.php b/vendor/symfony/var-dumper/Caster/IntlCaster.php new file mode 100644 index 0000000..529c8f7 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/IntlCaster.php @@ -0,0 +1,174 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * @author Jan Schädlich + * + * @final + * + * @internal since Symfony 7.3 + */ +class IntlCaster +{ + public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, bool $isNested): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), + Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), + ]; + + return self::castError($c, $a); + } + + public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), + Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), + ]; + + if ($filter & Caster::EXCLUDE_VERBOSE) { + $stub->cut += 3; + + return self::castError($c, $a); + } + + $a += [ + Caster::PREFIX_VIRTUAL.'attributes' => new EnumStub( + [ + 'PARSE_INT_ONLY' => $c->getAttribute(\NumberFormatter::PARSE_INT_ONLY), + 'GROUPING_USED' => $c->getAttribute(\NumberFormatter::GROUPING_USED), + 'DECIMAL_ALWAYS_SHOWN' => $c->getAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN), + 'MAX_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_INTEGER_DIGITS), + 'MIN_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_INTEGER_DIGITS), + 'INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::INTEGER_DIGITS), + 'MAX_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_FRACTION_DIGITS), + 'MIN_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_FRACTION_DIGITS), + 'FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::FRACTION_DIGITS), + 'MULTIPLIER' => $c->getAttribute(\NumberFormatter::MULTIPLIER), + 'GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::GROUPING_SIZE), + 'ROUNDING_MODE' => $c->getAttribute(\NumberFormatter::ROUNDING_MODE), + 'ROUNDING_INCREMENT' => $c->getAttribute(\NumberFormatter::ROUNDING_INCREMENT), + 'FORMAT_WIDTH' => $c->getAttribute(\NumberFormatter::FORMAT_WIDTH), + 'PADDING_POSITION' => $c->getAttribute(\NumberFormatter::PADDING_POSITION), + 'SECONDARY_GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::SECONDARY_GROUPING_SIZE), + 'SIGNIFICANT_DIGITS_USED' => $c->getAttribute(\NumberFormatter::SIGNIFICANT_DIGITS_USED), + 'MIN_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS), + 'MAX_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_SIGNIFICANT_DIGITS), + 'LENIENT_PARSE' => $c->getAttribute(\NumberFormatter::LENIENT_PARSE), + ] + ), + Caster::PREFIX_VIRTUAL.'text_attributes' => new EnumStub( + [ + 'POSITIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_PREFIX), + 'POSITIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_SUFFIX), + 'NEGATIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_PREFIX), + 'NEGATIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_SUFFIX), + 'PADDING_CHARACTER' => $c->getTextAttribute(\NumberFormatter::PADDING_CHARACTER), + 'CURRENCY_CODE' => $c->getTextAttribute(\NumberFormatter::CURRENCY_CODE), + 'DEFAULT_RULESET' => $c->getTextAttribute(\NumberFormatter::DEFAULT_RULESET), + 'PUBLIC_RULESETS' => $c->getTextAttribute(\NumberFormatter::PUBLIC_RULESETS), + ] + ), + Caster::PREFIX_VIRTUAL.'symbols' => new EnumStub( + [ + 'DECIMAL_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL), + 'GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL), + 'PATTERN_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::PATTERN_SEPARATOR_SYMBOL), + 'PERCENT_SYMBOL' => $c->getSymbol(\NumberFormatter::PERCENT_SYMBOL), + 'ZERO_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::ZERO_DIGIT_SYMBOL), + 'DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::DIGIT_SYMBOL), + 'MINUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::MINUS_SIGN_SYMBOL), + 'PLUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::PLUS_SIGN_SYMBOL), + 'CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::CURRENCY_SYMBOL), + 'INTL_CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL), + 'MONETARY_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL), + 'EXPONENTIAL_SYMBOL' => $c->getSymbol(\NumberFormatter::EXPONENTIAL_SYMBOL), + 'PERMILL_SYMBOL' => $c->getSymbol(\NumberFormatter::PERMILL_SYMBOL), + 'PAD_ESCAPE_SYMBOL' => $c->getSymbol(\NumberFormatter::PAD_ESCAPE_SYMBOL), + 'INFINITY_SYMBOL' => $c->getSymbol(\NumberFormatter::INFINITY_SYMBOL), + 'NAN_SYMBOL' => $c->getSymbol(\NumberFormatter::NAN_SYMBOL), + 'SIGNIFICANT_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL), + 'MONETARY_GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL), + ] + ), + ]; + + return self::castError($c, $a); + } + + public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, bool $isNested): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'display_name' => $c->getDisplayName(), + Caster::PREFIX_VIRTUAL.'id' => $c->getID(), + Caster::PREFIX_VIRTUAL.'raw_offset' => $c->getRawOffset(), + ]; + + if ($c->useDaylightTime()) { + $a += [ + Caster::PREFIX_VIRTUAL.'dst_savings' => $c->getDSTSavings(), + ]; + } + + return self::castError($c, $a); + } + + public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'type' => $c->getType(), + Caster::PREFIX_VIRTUAL.'first_day_of_week' => $c->getFirstDayOfWeek(), + Caster::PREFIX_VIRTUAL.'minimal_days_in_first_week' => $c->getMinimalDaysInFirstWeek(), + Caster::PREFIX_VIRTUAL.'repeated_wall_time_option' => $c->getRepeatedWallTimeOption(), + Caster::PREFIX_VIRTUAL.'skipped_wall_time_option' => $c->getSkippedWallTimeOption(), + Caster::PREFIX_VIRTUAL.'time' => $c->getTime(), + Caster::PREFIX_VIRTUAL.'in_daylight_time' => $c->inDaylightTime(), + Caster::PREFIX_VIRTUAL.'is_lenient' => $c->isLenient(), + Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(), + ]; + + return self::castError($c, $a); + } + + public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), + Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), + Caster::PREFIX_VIRTUAL.'calendar' => $c->getCalendar(), + Caster::PREFIX_VIRTUAL.'time_zone_id' => $c->getTimeZoneId(), + Caster::PREFIX_VIRTUAL.'time_type' => $c->getTimeType(), + Caster::PREFIX_VIRTUAL.'date_type' => $c->getDateType(), + Caster::PREFIX_VIRTUAL.'calendar_object' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getCalendarObject()) : $c->getCalendarObject(), + Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(), + ]; + + return self::castError($c, $a); + } + + private static function castError(object $c, array $a): array + { + if ($errorCode = $c->getErrorCode()) { + $a += [ + Caster::PREFIX_VIRTUAL.'error_code' => $errorCode, + Caster::PREFIX_VIRTUAL.'error_message' => $c->getErrorMessage(), + ]; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/LinkStub.php b/vendor/symfony/var-dumper/Caster/LinkStub.php new file mode 100644 index 0000000..3acd4fd --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/LinkStub.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +/** + * Represents a file or a URL. + * + * @author Nicolas Grekas + */ +class LinkStub extends ConstStub +{ + public bool $inVendor = false; + + private static array $vendorRoots; + private static array $composerRoots = []; + + public function __construct(string $label, int $line = 0, ?string $href = null) + { + $this->value = $label; + + if (!\is_string($href ??= $label)) { + return; + } + if (str_starts_with($href, 'file://')) { + if ($href === $label) { + $label = substr($label, 7); + } + $href = substr($href, 7); + } elseif (str_contains($href, '://')) { + $this->attr['href'] = $href; + + return; + } + if (!is_file($href)) { + return; + } + if ($line) { + $this->attr['line'] = $line; + } + if ($label !== $this->attr['file'] = realpath($href) ?: $href) { + return; + } + if ($composerRoot = $this->getComposerRoot($href, $this->inVendor)) { + $this->attr['ellipsis'] = \strlen($href) - \strlen($composerRoot) + 1; + $this->attr['ellipsis-type'] = 'path'; + $this->attr['ellipsis-tail'] = 1 + ($this->inVendor ? 2 + \strlen(implode('', \array_slice(explode(\DIRECTORY_SEPARATOR, substr($href, 1 - $this->attr['ellipsis'])), 0, 2))) : 0); + } elseif (3 < \count($ellipsis = explode(\DIRECTORY_SEPARATOR, $href))) { + $this->attr['ellipsis'] = 2 + \strlen(implode('', \array_slice($ellipsis, -2))); + $this->attr['ellipsis-type'] = 'path'; + $this->attr['ellipsis-tail'] = 1; + } + } + + private function getComposerRoot(string $file, bool &$inVendor): string|false + { + if (!isset(self::$vendorRoots)) { + self::$vendorRoots = []; + + foreach (get_declared_classes() as $class) { + if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) { + $r = new \ReflectionClass($class); + $v = \dirname($r->getFileName(), 2); + if (is_file($v.'/composer/installed.json')) { + self::$vendorRoots[] = $v.\DIRECTORY_SEPARATOR; + } + } + } + } + $inVendor = false; + + if (isset(self::$composerRoots[$dir = \dirname($file)])) { + return self::$composerRoots[$dir]; + } + + foreach (self::$vendorRoots as $root) { + if ($inVendor = str_starts_with($file, $root)) { + return $root; + } + } + + $parent = $dir; + while (!@is_file($parent.'/composer.json')) { + if (!@file_exists($parent)) { + // open_basedir restriction in effect + break; + } + if ($parent === \dirname($parent)) { + return self::$composerRoots[$dir] = false; + } + + $parent = \dirname($parent); + } + + return self::$composerRoots[$dir] = $parent.\DIRECTORY_SEPARATOR; + } +} diff --git a/vendor/symfony/var-dumper/Caster/MemcachedCaster.php b/vendor/symfony/var-dumper/Caster/MemcachedCaster.php new file mode 100644 index 0000000..4e4f611 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/MemcachedCaster.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Jan Schädlich + * + * @final + * + * @internal since Symfony 7.3 + */ +class MemcachedCaster +{ + private static array $optionConstants; + private static array $defaultOptions; + + public static function castMemcached(\Memcached $c, array $a, Stub $stub, bool $isNested): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'servers' => $c->getServerList(), + Caster::PREFIX_VIRTUAL.'options' => new EnumStub( + self::getNonDefaultOptions($c) + ), + ]; + + return $a; + } + + private static function getNonDefaultOptions(\Memcached $c): array + { + self::$defaultOptions ??= self::discoverDefaultOptions(); + self::$optionConstants ??= self::getOptionConstants(); + + $nonDefaultOptions = []; + foreach (self::$optionConstants as $constantKey => $value) { + if (self::$defaultOptions[$constantKey] !== $option = $c->getOption($value)) { + $nonDefaultOptions[$constantKey] = $option; + } + } + + return $nonDefaultOptions; + } + + private static function discoverDefaultOptions(): array + { + $defaultMemcached = new \Memcached(); + $defaultMemcached->addServer('127.0.0.1', 11211); + + $defaultOptions = []; + self::$optionConstants ??= self::getOptionConstants(); + + foreach (self::$optionConstants as $constantKey => $value) { + $defaultOptions[$constantKey] = $defaultMemcached->getOption($value); + } + + return $defaultOptions; + } + + private static function getOptionConstants(): array + { + $reflectedMemcached = new \ReflectionClass(\Memcached::class); + + $optionConstants = []; + foreach ($reflectedMemcached->getConstants() as $constantKey => $value) { + if (str_starts_with($constantKey, 'OPT_')) { + $optionConstants[$constantKey] = $value; + } + } + + return $optionConstants; + } +} diff --git a/vendor/symfony/var-dumper/Caster/MysqliCaster.php b/vendor/symfony/var-dumper/Caster/MysqliCaster.php new file mode 100644 index 0000000..bfe6f08 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/MysqliCaster.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * + * @internal + */ +final class MysqliCaster +{ + public static function castMysqliDriver(\mysqli_driver $c, array $a, Stub $stub, bool $isNested): array + { + foreach ($a as $k => $v) { + if (isset($c->$k)) { + $a[$k] = $c->$k; + } + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/OpenSSLCaster.php b/vendor/symfony/var-dumper/Caster/OpenSSLCaster.php new file mode 100644 index 0000000..4c311ac --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/OpenSSLCaster.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * @author Alexandre Daubois + * + * @internal + */ +final class OpenSSLCaster +{ + public static function castOpensslX509(\OpenSSLCertificate $h, array $a, Stub $stub, bool $isNested): array + { + $stub->cut = -1; + $info = openssl_x509_parse($h, false); + + $pin = openssl_pkey_get_public($h); + $pin = openssl_pkey_get_details($pin)['key']; + $pin = \array_slice(explode("\n", $pin), 1, -2); + $pin = base64_decode(implode('', $pin)); + $pin = base64_encode(hash('sha256', $pin, true)); + + $a += [ + Caster::PREFIX_VIRTUAL.'subject' => new EnumStub(array_intersect_key($info['subject'], ['organizationName' => true, 'commonName' => true])), + Caster::PREFIX_VIRTUAL.'issuer' => new EnumStub(array_intersect_key($info['issuer'], ['organizationName' => true, 'commonName' => true])), + Caster::PREFIX_VIRTUAL.'expiry' => new ConstStub(date(\DateTimeInterface::ISO8601, $info['validTo_time_t']), $info['validTo_time_t']), + Caster::PREFIX_VIRTUAL.'fingerprint' => new EnumStub([ + 'md5' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'md5')), 2, ':', true)), + 'sha1' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha1')), 2, ':', true)), + 'sha256' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha256')), 2, ':', true)), + 'pin-sha256' => new ConstStub($pin), + ]), + ]; + + return $a; + } + + public static function castOpensslAsymmetricKey(\OpenSSLAsymmetricKey $key, array $a, Stub $stub, bool $isNested): array + { + foreach (openssl_pkey_get_details($key) as $k => $v) { + $a[Caster::PREFIX_VIRTUAL.$k] = $v; + } + + unset($a[Caster::PREFIX_VIRTUAL.'rsa']); // binary data + + return $a; + } + + public static function castOpensslCsr(\OpenSSLCertificateSigningRequest $csr, array $a, Stub $stub, bool $isNested): array + { + foreach (openssl_csr_get_subject($csr, false) as $k => $v) { + $a[Caster::PREFIX_VIRTUAL.$k] = $v; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/PdoCaster.php b/vendor/symfony/var-dumper/Caster/PdoCaster.php new file mode 100644 index 0000000..697e412 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/PdoCaster.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts PDO related classes to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class PdoCaster +{ + private const PDO_ATTRIBUTES = [ + 'CASE' => [ + \PDO::CASE_LOWER => 'LOWER', + \PDO::CASE_NATURAL => 'NATURAL', + \PDO::CASE_UPPER => 'UPPER', + ], + 'ERRMODE' => [ + \PDO::ERRMODE_SILENT => 'SILENT', + \PDO::ERRMODE_WARNING => 'WARNING', + \PDO::ERRMODE_EXCEPTION => 'EXCEPTION', + ], + 'TIMEOUT', + 'PREFETCH', + 'AUTOCOMMIT', + 'PERSISTENT', + 'DRIVER_NAME', + 'SERVER_INFO', + 'ORACLE_NULLS' => [ + \PDO::NULL_NATURAL => 'NATURAL', + \PDO::NULL_EMPTY_STRING => 'EMPTY_STRING', + \PDO::NULL_TO_STRING => 'TO_STRING', + ], + 'CLIENT_VERSION', + 'SERVER_VERSION', + 'STATEMENT_CLASS', + 'EMULATE_PREPARES', + 'CONNECTION_STATUS', + 'STRINGIFY_FETCHES', + 'DEFAULT_FETCH_MODE' => [ + \PDO::FETCH_ASSOC => 'ASSOC', + \PDO::FETCH_BOTH => 'BOTH', + \PDO::FETCH_LAZY => 'LAZY', + \PDO::FETCH_NUM => 'NUM', + \PDO::FETCH_OBJ => 'OBJ', + ], + ]; + + public static function castPdo(\PDO $c, array $a, Stub $stub, bool $isNested): array + { + $attr = []; + $errmode = $c->getAttribute(\PDO::ATTR_ERRMODE); + $c->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + foreach (self::PDO_ATTRIBUTES as $k => $v) { + if (!isset($k[0])) { + $k = $v; + $v = []; + } + + try { + $attr[$k] = 'ERRMODE' === $k ? $errmode : $c->getAttribute(\constant('PDO::ATTR_'.$k)); + if ($v && isset($v[$attr[$k]])) { + $attr[$k] = new ConstStub($v[$attr[$k]], $attr[$k]); + } + } catch (\Exception) { + } + } + if (isset($attr[$k = 'STATEMENT_CLASS'][1])) { + if ($attr[$k][1]) { + $attr[$k][1] = new ArgsStub($attr[$k][1], '__construct', $attr[$k][0]); + } + $attr[$k][0] = new ClassStub($attr[$k][0]); + } + + $prefix = Caster::PREFIX_VIRTUAL; + $a += [ + $prefix.'inTransaction' => method_exists($c, 'inTransaction'), + $prefix.'errorInfo' => $c->errorInfo(), + $prefix.'attributes' => new EnumStub($attr), + ]; + + if ($a[$prefix.'inTransaction']) { + $a[$prefix.'inTransaction'] = $c->inTransaction(); + } else { + unset($a[$prefix.'inTransaction']); + } + + if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) { + unset($a[$prefix.'errorInfo']); + } + + $c->setAttribute(\PDO::ATTR_ERRMODE, $errmode); + + return $a; + } + + public static function castPdoStatement(\PDOStatement $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + $a[$prefix.'errorInfo'] = $c->errorInfo(); + + if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) { + unset($a[$prefix.'errorInfo']); + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/PgSqlCaster.php b/vendor/symfony/var-dumper/Caster/PgSqlCaster.php new file mode 100644 index 0000000..54a1906 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/PgSqlCaster.php @@ -0,0 +1,158 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts pqsql resources to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class PgSqlCaster +{ + private const PARAM_CODES = [ + 'server_encoding', + 'client_encoding', + 'is_superuser', + 'session_authorization', + 'DateStyle', + 'TimeZone', + 'IntervalStyle', + 'integer_datetimes', + 'application_name', + 'standard_conforming_strings', + ]; + + private const TRANSACTION_STATUS = [ + \PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE', + \PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE', + \PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS', + \PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR', + \PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN', + ]; + + private const RESULT_STATUS = [ + \PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY', + \PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK', + \PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK', + \PGSQL_COPY_OUT => 'PGSQL_COPY_OUT', + \PGSQL_COPY_IN => 'PGSQL_COPY_IN', + \PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE', + \PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR', + \PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR', + ]; + + private const DIAG_CODES = [ + 'severity' => \PGSQL_DIAG_SEVERITY, + 'sqlstate' => \PGSQL_DIAG_SQLSTATE, + 'message' => \PGSQL_DIAG_MESSAGE_PRIMARY, + 'detail' => \PGSQL_DIAG_MESSAGE_DETAIL, + 'hint' => \PGSQL_DIAG_MESSAGE_HINT, + 'statement position' => \PGSQL_DIAG_STATEMENT_POSITION, + 'internal position' => \PGSQL_DIAG_INTERNAL_POSITION, + 'internal query' => \PGSQL_DIAG_INTERNAL_QUERY, + 'context' => \PGSQL_DIAG_CONTEXT, + 'file' => \PGSQL_DIAG_SOURCE_FILE, + 'line' => \PGSQL_DIAG_SOURCE_LINE, + 'function' => \PGSQL_DIAG_SOURCE_FUNCTION, + ]; + + public static function castLargeObject($lo, array $a, Stub $stub, bool $isNested): array + { + $a['seek position'] = pg_lo_tell($lo); + + return $a; + } + + public static function castLink($link, array $a, Stub $stub, bool $isNested): array + { + $a['status'] = pg_connection_status($link); + $a['status'] = new ConstStub(\PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']); + $a['busy'] = pg_connection_busy($link); + + $a['transaction'] = pg_transaction_status($link); + if (isset(self::TRANSACTION_STATUS[$a['transaction']])) { + $a['transaction'] = new ConstStub(self::TRANSACTION_STATUS[$a['transaction']], $a['transaction']); + } + + $a['pid'] = pg_get_pid($link); + $a['last error'] = pg_last_error($link); + $a['last notice'] = pg_last_notice($link); + $a['host'] = pg_host($link); + $a['port'] = pg_port($link); + $a['dbname'] = pg_dbname($link); + $a['options'] = pg_options($link); + $a['version'] = pg_version($link); + + foreach (self::PARAM_CODES as $v) { + if (false !== $s = pg_parameter_status($link, $v)) { + $a['param'][$v] = $s; + } + } + + $a['param']['client_encoding'] = pg_client_encoding($link); + $a['param'] = new EnumStub($a['param']); + + return $a; + } + + public static function castResult($result, array $a, Stub $stub, bool $isNested): array + { + $a['num rows'] = pg_num_rows($result); + $a['status'] = pg_result_status($result); + if (isset(self::RESULT_STATUS[$a['status']])) { + $a['status'] = new ConstStub(self::RESULT_STATUS[$a['status']], $a['status']); + } + $a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING); + + if (-1 === $a['num rows']) { + foreach (self::DIAG_CODES as $k => $v) { + $a['error'][$k] = pg_result_error_field($result, $v); + } + } + + $a['affected rows'] = pg_affected_rows($result); + $a['last OID'] = pg_last_oid($result); + + $fields = pg_num_fields($result); + + for ($i = 0; $i < $fields; ++$i) { + $field = [ + 'name' => pg_field_name($result, $i), + 'table' => \sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), + 'type' => \sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), + 'nullable' => (bool) pg_field_is_null($result, $i), + 'storage' => pg_field_size($result, $i).' bytes', + 'display' => pg_field_prtlen($result, $i).' chars', + ]; + if (' (OID: )' === $field['table']) { + $field['table'] = null; + } + if ('-1 bytes' === $field['storage']) { + $field['storage'] = 'variable size'; + } elseif ('1 bytes' === $field['storage']) { + $field['storage'] = '1 byte'; + } + if ('1 chars' === $field['display']) { + $field['display'] = '1 char'; + } + $a['fields'][] = new EnumStub($field); + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php b/vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php new file mode 100644 index 0000000..0d954f4 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use ProxyManager\Proxy\ProxyInterface; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class ProxyManagerCaster +{ + public static function castProxy(ProxyInterface $c, array $a, Stub $stub, bool $isNested): array + { + if ($parent = get_parent_class($c)) { + $stub->class .= ' - '.$parent; + } + $stub->class .= '@proxy'; + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/RdKafkaCaster.php b/vendor/symfony/var-dumper/Caster/RdKafkaCaster.php new file mode 100644 index 0000000..bfadef2 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/RdKafkaCaster.php @@ -0,0 +1,188 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use RdKafka\Conf; +use RdKafka\Exception as RdKafkaException; +use RdKafka\KafkaConsumer; +use RdKafka\Message; +use RdKafka\Metadata\Broker as BrokerMetadata; +use RdKafka\Metadata\Collection as CollectionMetadata; +use RdKafka\Metadata\Partition as PartitionMetadata; +use RdKafka\Metadata\Topic as TopicMetadata; +use RdKafka\Topic; +use RdKafka\TopicConf; +use RdKafka\TopicPartition; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts RdKafka related classes to array representation. + * + * @author Romain Neutron + * + * @internal since Symfony 7.3 + */ +class RdKafkaCaster +{ + public static function castKafkaConsumer(KafkaConsumer $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + try { + $assignment = $c->getAssignment(); + } catch (RdKafkaException) { + $assignment = []; + } + + $a += [ + $prefix.'subscription' => $c->getSubscription(), + $prefix.'assignment' => $assignment, + ]; + + $a += self::extractMetadata($c); + + return $a; + } + + public static function castTopic(Topic $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'name' => $c->getName(), + ]; + + return $a; + } + + public static function castTopicPartition(TopicPartition $c, array $a): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'offset' => $c->getOffset(), + $prefix.'partition' => $c->getPartition(), + $prefix.'topic' => $c->getTopic(), + ]; + + return $a; + } + + public static function castMessage(Message $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'errstr' => $c->errstr(), + ]; + + return $a; + } + + public static function castConf(Conf $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + foreach ($c->dump() as $key => $value) { + $a[$prefix.$key] = $value; + } + + return $a; + } + + public static function castTopicConf(TopicConf $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + foreach ($c->dump() as $key => $value) { + $a[$prefix.$key] = $value; + } + + return $a; + } + + public static function castRdKafka(\RdKafka $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'out_q_len' => $c->getOutQLen(), + ]; + + $a += self::extractMetadata($c); + + return $a; + } + + public static function castCollectionMetadata(CollectionMetadata $c, array $a, Stub $stub, bool $isNested): array + { + $a += iterator_to_array($c); + + return $a; + } + + public static function castTopicMetadata(TopicMetadata $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'name' => $c->getTopic(), + $prefix.'partitions' => $c->getPartitions(), + ]; + + return $a; + } + + public static function castPartitionMetadata(PartitionMetadata $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'id' => $c->getId(), + $prefix.'err' => $c->getErr(), + $prefix.'leader' => $c->getLeader(), + ]; + + return $a; + } + + public static function castBrokerMetadata(BrokerMetadata $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + $a += [ + $prefix.'id' => $c->getId(), + $prefix.'host' => $c->getHost(), + $prefix.'port' => $c->getPort(), + ]; + + return $a; + } + + private static function extractMetadata(KafkaConsumer|\RdKafka $c): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + try { + $m = $c->getMetadata(true, null, 500); + } catch (RdKafkaException) { + return []; + } + + return [ + $prefix.'orig_broker_id' => $m->getOrigBrokerId(), + $prefix.'orig_broker_name' => $m->getOrigBrokerName(), + $prefix.'brokers' => $m->getBrokers(), + $prefix.'topics' => $m->getTopics(), + ]; + } +} diff --git a/vendor/symfony/var-dumper/Caster/RedisCaster.php b/vendor/symfony/var-dumper/Caster/RedisCaster.php new file mode 100644 index 0000000..a1ed95d --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/RedisCaster.php @@ -0,0 +1,152 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Relay\Relay; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts Redis class from ext-redis to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class RedisCaster +{ + private const SERIALIZERS = [ + 0 => 'NONE', // Redis::SERIALIZER_NONE + 1 => 'PHP', // Redis::SERIALIZER_PHP + 2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY + ]; + + private const MODES = [ + 0 => 'ATOMIC', // Redis::ATOMIC + 1 => 'MULTI', // Redis::MULTI + 2 => 'PIPELINE', // Redis::PIPELINE + ]; + + private const COMPRESSION_MODES = [ + 0 => 'NONE', // Redis::COMPRESSION_NONE + 1 => 'LZF', // Redis::COMPRESSION_LZF + ]; + + private const FAILOVER_OPTIONS = [ + \RedisCluster::FAILOVER_NONE => 'NONE', + \RedisCluster::FAILOVER_ERROR => 'ERROR', + \RedisCluster::FAILOVER_DISTRIBUTE => 'DISTRIBUTE', + \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES => 'DISTRIBUTE_SLAVES', + ]; + + public static function castRedis(\Redis|Relay $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + if (!$connected = $c->isConnected()) { + return $a + [ + $prefix.'isConnected' => $connected, + ]; + } + + $mode = $c->getMode(); + + return $a + [ + $prefix.'isConnected' => $connected, + $prefix.'host' => $c->getHost(), + $prefix.'port' => $c->getPort(), + $prefix.'auth' => $c->getAuth(), + $prefix.'mode' => isset(self::MODES[$mode]) ? new ConstStub(self::MODES[$mode], $mode) : $mode, + $prefix.'dbNum' => $c->getDbNum(), + $prefix.'timeout' => $c->getTimeout(), + $prefix.'lastError' => $c->getLastError(), + $prefix.'persistentId' => $c->getPersistentID(), + $prefix.'options' => self::getRedisOptions($c), + ]; + } + + public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + return $a + [ + $prefix.'hosts' => $c->_hosts(), + $prefix.'function' => ClassStub::wrapCallable($c->_function()), + $prefix.'lastError' => $c->getLastError(), + $prefix.'options' => self::getRedisOptions($c), + ]; + } + + public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + $failover = $c->getOption(\RedisCluster::OPT_SLAVE_FAILOVER); + + $a += [ + $prefix.'_masters' => $c->_masters(), + $prefix.'_redir' => $c->_redir(), + $prefix.'mode' => new ConstStub($c->getMode() ? 'MULTI' : 'ATOMIC', $c->getMode()), + $prefix.'lastError' => $c->getLastError(), + $prefix.'options' => self::getRedisOptions($c, [ + 'SLAVE_FAILOVER' => isset(self::FAILOVER_OPTIONS[$failover]) ? new ConstStub(self::FAILOVER_OPTIONS[$failover], $failover) : $failover, + ]), + ]; + + return $a; + } + + private static function getRedisOptions(\Redis|Relay|\RedisArray|\RedisCluster $redis, array $options = []): EnumStub + { + $serializer = $redis->getOption(\defined('Redis::OPT_SERIALIZER') ? \Redis::OPT_SERIALIZER : 1); + if (\is_array($serializer)) { + foreach ($serializer as &$v) { + if (isset(self::SERIALIZERS[$v])) { + $v = new ConstStub(self::SERIALIZERS[$v], $v); + } + } + } elseif (isset(self::SERIALIZERS[$serializer])) { + $serializer = new ConstStub(self::SERIALIZERS[$serializer], $serializer); + } + + $compression = \defined('Redis::OPT_COMPRESSION') ? $redis->getOption(\Redis::OPT_COMPRESSION) : 0; + if (\is_array($compression)) { + foreach ($compression as &$v) { + if (isset(self::COMPRESSION_MODES[$v])) { + $v = new ConstStub(self::COMPRESSION_MODES[$v], $v); + } + } + } elseif (isset(self::COMPRESSION_MODES[$compression])) { + $compression = new ConstStub(self::COMPRESSION_MODES[$compression], $compression); + } + + $retry = \defined('Redis::OPT_SCAN') ? $redis->getOption(\Redis::OPT_SCAN) : 0; + if (\is_array($retry)) { + foreach ($retry as &$v) { + $v = new ConstStub($v ? 'RETRY' : 'NORETRY', $v); + } + } else { + $retry = new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry); + } + + $options += [ + 'TCP_KEEPALIVE' => \defined('Redis::OPT_TCP_KEEPALIVE') ? $redis->getOption(\Redis::OPT_TCP_KEEPALIVE) : Relay::OPT_TCP_KEEPALIVE, + 'READ_TIMEOUT' => $redis->getOption(\defined('Redis::OPT_READ_TIMEOUT') ? \Redis::OPT_READ_TIMEOUT : Relay::OPT_READ_TIMEOUT), + 'COMPRESSION' => $compression, + 'SERIALIZER' => $serializer, + 'PREFIX' => $redis->getOption(\defined('Redis::OPT_PREFIX') ? \Redis::OPT_PREFIX : Relay::OPT_PREFIX), + 'SCAN' => $retry, + ]; + + return new EnumStub($options); + } +} diff --git a/vendor/symfony/var-dumper/Caster/ReflectionCaster.php b/vendor/symfony/var-dumper/Caster/ReflectionCaster.php new file mode 100644 index 0000000..e7310f4 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ReflectionCaster.php @@ -0,0 +1,448 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts Reflector related classes to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class ReflectionCaster +{ + public const UNSET_CLOSURE_FILE_INFO = ['Closure' => __CLASS__.'::unsetClosureFileInfo']; + + private const EXTRA_MAP = [ + 'docComment' => 'getDocComment', + 'extension' => 'getExtensionName', + 'isDisabled' => 'isDisabled', + 'isDeprecated' => 'isDeprecated', + 'isInternal' => 'isInternal', + 'isUserDefined' => 'isUserDefined', + 'isGenerator' => 'isGenerator', + 'isVariadic' => 'isVariadic', + ]; + + public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $prefix = Caster::PREFIX_VIRTUAL; + $c = new \ReflectionFunction($c); + + $a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter); + + if (!$c->isAnonymous()) { + $stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name; + unset($a[$prefix.'class']); + } + unset($a[$prefix.'extra']); + + $stub->class .= self::getSignature($a); + + if ($f = $c->getFileName()) { + $stub->attr['file'] = $f; + $stub->attr['line'] = $c->getStartLine(); + } + + unset($a[$prefix.'parameters']); + + if ($filter & Caster::EXCLUDE_VERBOSE) { + $stub->cut += ($c->getFileName() ? 2 : 0) + \count($a); + + return []; + } + + if ($f) { + $a[$prefix.'file'] = new LinkStub($f, $c->getStartLine()); + $a[$prefix.'line'] = $c->getStartLine().' to '.$c->getEndLine(); + } + + return $a; + } + + public static function unsetClosureFileInfo(\Closure $c, array $a): array + { + unset($a[Caster::PREFIX_VIRTUAL.'file'], $a[Caster::PREFIX_VIRTUAL.'line']); + + return $a; + } + + public static function castGenerator(\Generator $c, array $a, Stub $stub, bool $isNested): array + { + // Cannot create ReflectionGenerator based on a terminated Generator + try { + $reflectionGenerator = new \ReflectionGenerator($c); + + return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested); + } catch (\Exception) { + $a[Caster::PREFIX_VIRTUAL.'closed'] = true; + + return $a; + } + } + + public static function castType(\ReflectionType $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + if ($c instanceof \ReflectionNamedType) { + $a += [ + $prefix.'name' => $c->getName(), + $prefix.'allowsNull' => $c->allowsNull(), + $prefix.'isBuiltin' => $c->isBuiltin(), + ]; + } elseif ($c instanceof \ReflectionUnionType || $c instanceof \ReflectionIntersectionType) { + $a[$prefix.'allowsNull'] = $c->allowsNull(); + self::addMap($a, $c, [ + 'types' => 'getTypes', + ]); + } else { + $a[$prefix.'allowsNull'] = $c->allowsNull(); + } + + return $a; + } + + public static function castAttribute(\ReflectionAttribute $c, array $a, Stub $stub, bool $isNested): array + { + $map = [ + 'name' => 'getName', + 'arguments' => 'getArguments', + ]; + + if (\PHP_VERSION_ID >= 80400) { + unset($map['name']); + } + + self::addMap($a, $c, $map); + + return $a; + } + + public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + if ($c->getThis()) { + $a[$prefix.'this'] = new CutStub($c->getThis()); + } + $function = $c->getFunction(); + $frame = [ + 'class' => $function->class ?? null, + 'type' => isset($function->class) ? ($function->isStatic() ? '::' : '->') : null, + 'function' => $function->name, + 'file' => $c->getExecutingFile(), + 'line' => $c->getExecutingLine(), + ]; + if ($trace = $c->getTrace(\DEBUG_BACKTRACE_IGNORE_ARGS)) { + $function = new \ReflectionGenerator($c->getExecutingGenerator()); + array_unshift($trace, [ + 'function' => 'yield', + 'file' => $function->getExecutingFile(), + 'line' => $function->getExecutingLine(), + ]); + $trace[] = $frame; + $a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1); + } else { + $function = new FrameStub($frame, false, true); + $function = ExceptionCaster::castFrameStub($function, [], $function, true); + $a[$prefix.'executing'] = $function[$prefix.'src']; + } + + $a[Caster::PREFIX_VIRTUAL.'closed'] = false; + + return $a; + } + + public static function castClass(\ReflectionClass $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + if ($n = \Reflection::getModifierNames($c->getModifiers())) { + $a[$prefix.'modifiers'] = implode(' ', $n); + } + + self::addMap($a, $c, [ + 'extends' => 'getParentClass', + 'implements' => 'getInterfaceNames', + 'constants' => 'getReflectionConstants', + ]); + + foreach ($c->getProperties() as $n) { + $a[$prefix.'properties'][$n->name] = $n; + } + + foreach ($c->getMethods() as $n) { + $a[$prefix.'methods'][$n->name] = $n; + } + + self::addAttributes($a, $c, $prefix); + + if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) { + self::addExtra($a, $c); + } + + return $a; + } + + public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, bool $isNested, int $filter = 0): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + self::addMap($a, $c, [ + 'returnsReference' => 'returnsReference', + 'returnType' => 'getReturnType', + 'class' => 'getClosureCalledClass', + 'this' => 'getClosureThis', + ]); + + if (isset($a[$prefix.'returnType'])) { + $v = $a[$prefix.'returnType']; + $v = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v; + $a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType'] instanceof \ReflectionNamedType && $a[$prefix.'returnType']->allowsNull() && !\in_array($v, ['mixed', 'null'], true) ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']); + } + if (isset($a[$prefix.'class'])) { + $a[$prefix.'class'] = new ClassStub($a[$prefix.'class']); + } + if (isset($a[$prefix.'this'])) { + $a[$prefix.'this'] = new CutStub($a[$prefix.'this']); + } + + foreach ($c->getParameters() as $v) { + $k = '$'.$v->name; + if ($v->isVariadic()) { + $k = '...'.$k; + } + if ($v->isPassedByReference()) { + $k = '&'.$k; + } + $a[$prefix.'parameters'][$k] = $v; + } + if (isset($a[$prefix.'parameters'])) { + $a[$prefix.'parameters'] = new EnumStub($a[$prefix.'parameters']); + } + + self::addAttributes($a, $c, $prefix); + + if (!($filter & Caster::EXCLUDE_VERBOSE) && $v = $c->getStaticVariables()) { + foreach ($v as $k => &$v) { + if (\is_object($v)) { + $a[$prefix.'use']['$'.$k] = new CutStub($v); + } else { + $a[$prefix.'use']['$'.$k] = &$v; + } + } + unset($v); + $a[$prefix.'use'] = new EnumStub($a[$prefix.'use']); + } + + if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) { + self::addExtra($a, $c); + } + + return $a; + } + + public static function castClassConstant(\ReflectionClassConstant $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); + $a[Caster::PREFIX_VIRTUAL.'value'] = $c->getValue(); + + self::addAttributes($a, $c); + + return $a; + } + + public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); + + return $a; + } + + public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + + self::addMap($a, $c, [ + 'position' => 'getPosition', + 'isVariadic' => 'isVariadic', + 'byReference' => 'isPassedByReference', + 'allowsNull' => 'allowsNull', + ]); + + self::addAttributes($a, $c, $prefix); + + if ($v = $c->getType()) { + $a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v; + } + + if (isset($a[$prefix.'typeHint'])) { + $v = $a[$prefix.'typeHint']; + $a[$prefix.'typeHint'] = new ClassStub($v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']); + } else { + unset($a[$prefix.'allowsNull']); + } + + if ($c->isOptional()) { + try { + $a[$prefix.'default'] = $v = $c->getDefaultValue(); + if ($c->isDefaultValueConstant() && !\is_object($v)) { + $a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v); + } + if (null === $v) { + unset($a[$prefix.'allowsNull']); + } + } catch (\ReflectionException) { + } + } + + return $a; + } + + public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); + + self::addAttributes($a, $c); + self::addExtra($a, $c); + + return $a; + } + + public static function castReference(\ReflectionReference $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'id'] = $c->getId(); + + return $a; + } + + public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, bool $isNested): array + { + self::addMap($a, $c, [ + 'version' => 'getVersion', + 'dependencies' => 'getDependencies', + 'iniEntries' => 'getIniEntries', + 'isPersistent' => 'isPersistent', + 'isTemporary' => 'isTemporary', + 'constants' => 'getConstants', + 'functions' => 'getFunctions', + 'classes' => 'getClasses', + ]); + + return $a; + } + + public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, bool $isNested): array + { + self::addMap($a, $c, [ + 'version' => 'getVersion', + 'author' => 'getAuthor', + 'copyright' => 'getCopyright', + 'url' => 'getURL', + ]); + + return $a; + } + + public static function getSignature(array $a): string + { + $prefix = Caster::PREFIX_VIRTUAL; + $signature = ''; + + if (isset($a[$prefix.'parameters'])) { + foreach ($a[$prefix.'parameters']->value as $k => $param) { + $signature .= ', '; + if ($type = $param->getType()) { + if (!$type instanceof \ReflectionNamedType) { + $signature .= $type.' '; + } else { + if ($param->allowsNull() && !\in_array($type->getName(), ['mixed', 'null'], true)) { + $signature .= '?'; + } + $signature .= substr(strrchr('\\'.$type->getName(), '\\'), 1).' '; + } + } + $signature .= $k; + + if (!$param->isDefaultValueAvailable()) { + continue; + } + $v = $param->getDefaultValue(); + $signature .= ' = '; + + if ($param->isDefaultValueConstant()) { + $signature .= substr(strrchr('\\'.$param->getDefaultValueConstantName(), '\\'), 1); + } elseif (null === $v) { + $signature .= 'null'; + } elseif (\is_array($v)) { + $signature .= $v ? '[…'.\count($v).']' : '[]'; + } elseif (\is_string($v)) { + $signature .= 10 > \strlen($v) && !str_contains($v, '\\') ? "'{$v}'" : "'…".\strlen($v)."'"; + } elseif (\is_bool($v)) { + $signature .= $v ? 'true' : 'false'; + } elseif (\is_object($v)) { + $signature .= 'new '.substr(strrchr('\\'.get_debug_type($v), '\\'), 1); + } else { + $signature .= $v; + } + } + } + $signature = (empty($a[$prefix.'returnsReference']) ? '' : '&').'('.substr($signature, 2).')'; + + if (isset($a[$prefix.'returnType'])) { + $signature .= ': '.substr(strrchr('\\'.$a[$prefix.'returnType'], '\\'), 1); + } + + return $signature; + } + + private static function addExtra(array &$a, \Reflector $c): void + { + $x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : []; + + if (method_exists($c, 'getFileName') && $m = $c->getFileName()) { + $x['file'] = new LinkStub($m, $c->getStartLine()); + $x['line'] = $c->getStartLine().' to '.$c->getEndLine(); + } + + self::addMap($x, $c, self::EXTRA_MAP, ''); + + if ($x) { + $a[Caster::PREFIX_VIRTUAL.'extra'] = new EnumStub($x); + } + } + + private static function addMap(array &$a, object $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL): void + { + foreach ($map as $k => $m) { + if ('isDisabled' === $k) { + continue; + } + + if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) { + $a[$prefix.$k] = $m instanceof \Reflector ? $m->name : $m; + } + } + } + + private static function addAttributes(array &$a, \Reflector $c, string $prefix = Caster::PREFIX_VIRTUAL): void + { + foreach ($c->getAttributes() as $n) { + $a[$prefix.'attributes'][] = $n; + } + } +} diff --git a/vendor/symfony/var-dumper/Caster/ResourceCaster.php b/vendor/symfony/var-dumper/Caster/ResourceCaster.php new file mode 100644 index 0000000..5613c55 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ResourceCaster.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts common resource types to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class ResourceCaster +{ + /** + * @deprecated since Symfony 7.3 + */ + public static function castCurl(\CurlHandle $h, array $a, Stub $stub, bool $isNested): array + { + trigger_deprecation('symfony/var-dumper', '7.3', 'The "%s()" method is deprecated without replacement.', __METHOD__, CurlCaster::class); + + return CurlCaster::castCurl($h, $a, $stub, $isNested); + } + + /** + * @param resource|\Dba\Connection $dba + */ + public static function castDba(mixed $dba, array $a, Stub $stub, bool $isNested): array + { + if (\PHP_VERSION_ID < 80402 && !\is_resource($dba)) { + // @see https://github.com/php/php-src/issues/16990 + return $a; + } + + $list = dba_list(); + $a['file'] = $list[(int) $dba]; + + return $a; + } + + public static function castProcess($process, array $a, Stub $stub, bool $isNested): array + { + return proc_get_status($process); + } + + public static function castStream($stream, array $a, Stub $stub, bool $isNested): array + { + $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested); + if ($a['uri'] ?? false) { + $a['uri'] = new LinkStub($a['uri']); + } + + return $a; + } + + public static function castStreamContext($stream, array $a, Stub $stub, bool $isNested): array + { + return @stream_context_get_params($stream) ?: $a; + } + + /** + * @deprecated since Symfony 7.3 + */ + public static function castGd(\GdImage $gd, array $a, Stub $stub, bool $isNested): array + { + trigger_deprecation('symfony/var-dumper', '7.3', 'The "%s()" method is deprecated without replacement.', __METHOD__, GdCaster::class); + + return GdCaster::castGd($gd, $a, $stub, $isNested); + } + + /** + * @deprecated since Symfony 7.3 + */ + public static function castOpensslX509(\OpenSSLCertificate $h, array $a, Stub $stub, bool $isNested): array + { + trigger_deprecation('symfony/var-dumper', '7.3', 'The "%s()" method is deprecated without replacement.', __METHOD__, OpenSSLCaster::class); + + return OpenSSLCaster::castOpensslX509($h, $a, $stub, $isNested); + } +} diff --git a/vendor/symfony/var-dumper/Caster/ScalarStub.php b/vendor/symfony/var-dumper/Caster/ScalarStub.php new file mode 100644 index 0000000..3bb1935 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/ScalarStub.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents any arbitrary value. + * + * @author Alexandre Daubois + */ +class ScalarStub extends Stub +{ + public function __construct(mixed $value) + { + $this->value = $value; + } +} diff --git a/vendor/symfony/var-dumper/Caster/SocketCaster.php b/vendor/symfony/var-dumper/Caster/SocketCaster.php new file mode 100644 index 0000000..6b95cd1 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/SocketCaster.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Nicolas Grekas + * @author Alexandre Daubois + * + * @internal + */ +final class SocketCaster +{ + public static function castSocket(\Socket $socket, array $a, Stub $stub, bool $isNested): array + { + socket_getsockname($socket, $addr, $port); + $info = stream_get_meta_data(socket_export_stream($socket)); + + if (\PHP_VERSION_ID >= 80300) { + $uri = ($info['uri'] ?? '//'); + if (str_starts_with($uri, 'unix://')) { + $uri .= $addr; + } else { + $uri .= \sprintf(str_contains($addr, ':') ? '[%s]:%s' : '%s:%s', $addr, $port); + } + + $a[Caster::PREFIX_VIRTUAL.'uri'] = $uri; + + if (@socket_atmark($socket)) { + $a[Caster::PREFIX_VIRTUAL.'atmark'] = true; + } + } + + $a += [ + Caster::PREFIX_VIRTUAL.'timed_out' => $info['timed_out'], + Caster::PREFIX_VIRTUAL.'blocked' => $info['blocked'], + ]; + + if (!$lastError = socket_last_error($socket)) { + return $a; + } + + static $errors; + + if (!$errors) { + $errors = get_defined_constants(true)['sockets'] ?? []; + $errors = array_flip(array_filter($errors, static fn ($k) => str_starts_with($k, 'SOCKET_E'), \ARRAY_FILTER_USE_KEY)); + } + + $a[Caster::PREFIX_VIRTUAL.'last_error'] = new ConstStub($errors[$lastError], socket_strerror($lastError)); + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/SplCaster.php b/vendor/symfony/var-dumper/Caster/SplCaster.php new file mode 100644 index 0000000..31f4b11 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/SplCaster.php @@ -0,0 +1,258 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts SPL related classes to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class SplCaster +{ + private const SPL_FILE_OBJECT_FLAGS = [ + \SplFileObject::DROP_NEW_LINE => 'DROP_NEW_LINE', + \SplFileObject::READ_AHEAD => 'READ_AHEAD', + \SplFileObject::SKIP_EMPTY => 'SKIP_EMPTY', + \SplFileObject::READ_CSV => 'READ_CSV', + ]; + + public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, bool $isNested): array + { + return self::castSplArray($c, $a, $stub, $isNested); + } + + public static function castArrayIterator(\ArrayIterator $c, array $a, Stub $stub, bool $isNested): array + { + return self::castSplArray($c, $a, $stub, $isNested); + } + + public static function castHeap(\Iterator $c, array $a, Stub $stub, bool $isNested): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'heap' => iterator_to_array(clone $c), + ]; + + return $a; + } + + public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + $mode = $c->getIteratorMode(); + $c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE); + + $a += [ + $prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_DELETE) ? 'IT_MODE_DELETE' : 'IT_MODE_KEEP'), $mode), + $prefix.'dllist' => iterator_to_array($c), + ]; + $c->setIteratorMode($mode); + + return $a; + } + + public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, bool $isNested): array + { + static $map = [ + 'path' => 'getPath', + 'filename' => 'getFilename', + 'basename' => 'getBasename', + 'pathname' => 'getPathname', + 'extension' => 'getExtension', + 'realPath' => 'getRealPath', + 'aTime' => 'getATime', + 'mTime' => 'getMTime', + 'cTime' => 'getCTime', + 'inode' => 'getInode', + 'size' => 'getSize', + 'perms' => 'getPerms', + 'owner' => 'getOwner', + 'group' => 'getGroup', + 'type' => 'getType', + 'writable' => 'isWritable', + 'readable' => 'isReadable', + 'executable' => 'isExecutable', + 'file' => 'isFile', + 'dir' => 'isDir', + 'link' => 'isLink', + 'linkTarget' => 'getLinkTarget', + ]; + + $prefix = Caster::PREFIX_VIRTUAL; + unset($a["\0SplFileInfo\0fileName"]); + unset($a["\0SplFileInfo\0pathName"]); + + try { + $c->isReadable(); + } catch (\RuntimeException $e) { + if ('Object not initialized' !== $e->getMessage()) { + throw $e; + } + + $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; + + return $a; + } catch (\Error $e) { + if ('Object not initialized' !== $e->getMessage()) { + throw $e; + } + + $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; + + return $a; + } + + foreach ($map as $key => $accessor) { + try { + $a[$prefix.$key] = $c->$accessor(); + } catch (\Exception) { + } + } + + if ($a[$prefix.'realPath'] ?? false) { + $a[$prefix.'realPath'] = new LinkStub($a[$prefix.'realPath']); + } + + if (isset($a[$prefix.'perms'])) { + $a[$prefix.'perms'] = new ConstStub(\sprintf('0%o', $a[$prefix.'perms']), $a[$prefix.'perms']); + } + + static $mapDate = ['aTime', 'mTime', 'cTime']; + foreach ($mapDate as $key) { + if (isset($a[$prefix.$key])) { + $a[$prefix.$key] = new ConstStub(date('Y-m-d H:i:s', $a[$prefix.$key]), $a[$prefix.$key]); + } + } + + return $a; + } + + public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, bool $isNested): array + { + static $map = [ + 'csvControl' => 'getCsvControl', + 'flags' => 'getFlags', + 'maxLineLen' => 'getMaxLineLen', + 'fstat' => 'fstat', + 'eof' => 'eof', + 'key' => 'key', + ]; + + $prefix = Caster::PREFIX_VIRTUAL; + + foreach ($map as $key => $accessor) { + try { + $a[$prefix.$key] = $c->$accessor(); + } catch (\Exception) { + } + } + + if (isset($a[$prefix.'flags'])) { + $flagsArray = []; + foreach (self::SPL_FILE_OBJECT_FLAGS as $value => $name) { + if ($a[$prefix.'flags'] & $value) { + $flagsArray[] = $name; + } + } + $a[$prefix.'flags'] = new ConstStub(implode('|', $flagsArray), $a[$prefix.'flags']); + } + + if (isset($a[$prefix.'fstat'])) { + $a[$prefix.'fstat'] = new CutArrayStub($a[$prefix.'fstat'], ['dev', 'ino', 'nlink', 'rdev', 'blksize', 'blocks']); + } + + return $a; + } + + public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, bool $isNested): array + { + $storage = []; + unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967 + unset($a["\0SplObjectStorage\0storage"]); + + $clone = clone $c; + foreach ($clone as $obj) { + $storage[] = new EnumStub([ + 'object' => $obj, + 'info' => $clone->getInfo(), + ]); + } + + $a += [ + Caster::PREFIX_VIRTUAL.'storage' => $storage, + ]; + + return $a; + } + + public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator(); + + return $a; + } + + public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'object'] = $c->get(); + + return $a; + } + + public static function castWeakMap(\WeakMap $c, array $a, Stub $stub, bool $isNested): array + { + $map = []; + + foreach (clone $c as $obj => $data) { + $map[] = new EnumStub([ + 'object' => $obj, + 'data' => $data, + ]); + } + + $a += [ + Caster::PREFIX_VIRTUAL.'map' => $map, + ]; + + return $a; + } + + private static function castSplArray(\ArrayObject|\ArrayIterator $c, array $a, Stub $stub, bool $isNested): array + { + $prefix = Caster::PREFIX_VIRTUAL; + $flags = $c->getFlags(); + + if (!($flags & \ArrayObject::STD_PROP_LIST)) { + $c->setFlags(\ArrayObject::STD_PROP_LIST); + $a = Caster::castObject($c, $c::class, method_exists($c, '__debugInfo'), $stub->class); + $c->setFlags($flags); + } + + unset($a["\0ArrayObject\0storage"], $a["\0ArrayIterator\0storage"]); + + $a += [ + $prefix.'storage' => $c->getArrayCopy(), + $prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST), + $prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS), + ]; + if ($c instanceof \ArrayObject) { + $a[$prefix.'iteratorClass'] = new ClassStub($c->getIteratorClass()); + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/SqliteCaster.php b/vendor/symfony/var-dumper/Caster/SqliteCaster.php new file mode 100644 index 0000000..25d47ac --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/SqliteCaster.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Alexandre Daubois + * + * @internal + */ +final class SqliteCaster +{ + public static function castSqlite3Result(\SQLite3Result $result, array $a, Stub $stub, bool $isNested): array + { + $numColumns = $result->numColumns(); + for ($i = 0; $i < $numColumns; ++$i) { + $a[Caster::PREFIX_VIRTUAL.'columnNames'][$i] = $result->columnName($i); + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/StubCaster.php b/vendor/symfony/var-dumper/Caster/StubCaster.php new file mode 100644 index 0000000..85cf997 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/StubCaster.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts a caster's Stub. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class StubCaster +{ + public static function castStub(Stub $c, array $a, Stub $stub, bool $isNested): array + { + if ($isNested) { + $stub->type = $c->type; + $stub->class = $c->class; + $stub->value = $c->value; + $stub->handle = $c->handle; + $stub->cut = $c->cut; + $stub->attr = $c->attr; + + if (Stub::TYPE_REF === $c->type && !$c->class && \is_string($c->value) && !preg_match('//u', $c->value)) { + $stub->type = Stub::TYPE_STRING; + $stub->class = Stub::STRING_BINARY; + } + + $a = []; + } + + return $a; + } + + public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, bool $isNested): array + { + return $isNested ? $c->preservedSubset : $a; + } + + public static function cutInternals($obj, array $a, Stub $stub, bool $isNested): array + { + if ($isNested) { + $stub->cut += \count($a); + + return []; + } + + return $a; + } + + public static function castEnum(EnumStub $c, array $a, Stub $stub, bool $isNested): array + { + if ($isNested) { + $stub->class = $c->dumpKeys ? '' : null; + $stub->handle = 0; + $stub->value = null; + $stub->cut = $c->cut; + $stub->attr = $c->attr; + + $a = []; + + if ($c->value) { + foreach (array_keys($c->value) as $k) { + $keys[] = !isset($k[0]) || "\0" !== $k[0] ? Caster::PREFIX_VIRTUAL.$k : $k; + } + // Preserve references with array_combine() + $a = array_combine($keys, $c->value); + } + } + + return $a; + } + + public static function castScalar(ScalarStub $scalarStub, array $a, Stub $stub): array + { + $stub->type = Stub::TYPE_SCALAR; + $stub->attr['value'] = $scalarStub->value; + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/SymfonyCaster.php b/vendor/symfony/var-dumper/Caster/SymfonyCaster.php new file mode 100644 index 0000000..42dc901 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/SymfonyCaster.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Uid\Ulid; +use Symfony\Component\Uid\Uuid; +use Symfony\Component\VarDumper\Cloner\Stub; +use Symfony\Component\VarExporter\Internal\LazyObjectState; + +/** + * @final + * + * @internal since Symfony 7.3 + */ +class SymfonyCaster +{ + private const REQUEST_GETTERS = [ + 'pathInfo' => 'getPathInfo', + 'requestUri' => 'getRequestUri', + 'baseUrl' => 'getBaseUrl', + 'basePath' => 'getBasePath', + 'method' => 'getMethod', + 'format' => 'getRequestFormat', + ]; + + public static function castRequest(Request $request, array $a, Stub $stub, bool $isNested): array + { + $clone = null; + + foreach (self::REQUEST_GETTERS as $prop => $getter) { + $key = Caster::PREFIX_PROTECTED.$prop; + if (\array_key_exists($key, $a) && null === $a[$key]) { + $clone ??= clone $request; + $a[Caster::PREFIX_VIRTUAL.$prop] = $clone->{$getter}(); + } + } + + return $a; + } + + public static function castHttpClient($client, array $a, Stub $stub, bool $isNested): array + { + $multiKey = \sprintf("\0%s\0multi", $client::class); + if (isset($a[$multiKey])) { + $a[$multiKey] = new CutStub($a[$multiKey]); + } + + return $a; + } + + public static function castHttpClientResponse($response, array $a, Stub $stub, bool $isNested): array + { + $stub->cut += \count($a); + $a = []; + + foreach ($response->getInfo() as $k => $v) { + $a[Caster::PREFIX_VIRTUAL.$k] = $v; + } + + return $a; + } + + public static function castLazyObjectState($state, array $a, Stub $stub, bool $isNested): array + { + if (!$isNested) { + return $a; + } + + $stub->cut += \count($a) - 1; + + $instance = $a['realInstance'] ?? null; + + $a = ['status' => new ConstStub(match ($a['status']) { + LazyObjectState::STATUS_INITIALIZED_FULL => 'INITIALIZED_FULL', + LazyObjectState::STATUS_INITIALIZED_PARTIAL => 'INITIALIZED_PARTIAL', + LazyObjectState::STATUS_UNINITIALIZED_FULL => 'UNINITIALIZED_FULL', + LazyObjectState::STATUS_UNINITIALIZED_PARTIAL => 'UNINITIALIZED_PARTIAL', + }, $a['status'])]; + + if ($instance) { + $a['realInstance'] = $instance; + --$stub->cut; + } + + return $a; + } + + public static function castUuid(Uuid $uuid, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'toBase58'] = $uuid->toBase58(); + $a[Caster::PREFIX_VIRTUAL.'toBase32'] = $uuid->toBase32(); + + // symfony/uid >= 5.3 + if (method_exists($uuid, 'getDateTime')) { + $a[Caster::PREFIX_VIRTUAL.'time'] = $uuid->getDateTime()->format('Y-m-d H:i:s.u \U\T\C'); + } + + return $a; + } + + public static function castUlid(Ulid $ulid, array $a, Stub $stub, bool $isNested): array + { + $a[Caster::PREFIX_VIRTUAL.'toBase58'] = $ulid->toBase58(); + $a[Caster::PREFIX_VIRTUAL.'toRfc4122'] = $ulid->toRfc4122(); + + // symfony/uid >= 5.3 + if (method_exists($ulid, 'getDateTime')) { + $a[Caster::PREFIX_VIRTUAL.'time'] = $ulid->getDateTime()->format('Y-m-d H:i:s.v \U\T\C'); + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/TraceStub.php b/vendor/symfony/var-dumper/Caster/TraceStub.php new file mode 100644 index 0000000..b732eb2 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/TraceStub.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Represents a backtrace as returned by debug_backtrace() or Exception->getTrace(). + * + * @author Nicolas Grekas + */ +class TraceStub extends Stub +{ + public function __construct( + array $trace, + public bool $keepArgs = true, + public int $sliceOffset = 0, + public ?int $sliceLength = null, + public int $numberingOffset = 0, + ) { + $this->value = $trace; + } +} diff --git a/vendor/symfony/var-dumper/Caster/UninitializedStub.php b/vendor/symfony/var-dumper/Caster/UninitializedStub.php new file mode 100644 index 0000000..a9bdd9b --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/UninitializedStub.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +/** + * Represents an uninitialized property. + * + * @author Nicolas Grekas + */ +class UninitializedStub extends ConstStub +{ + public function __construct(\ReflectionProperty $property) + { + parent::__construct('?'.($property->hasType() ? ' '.$property->getType() : ''), 'Uninitialized property'); + } +} diff --git a/vendor/symfony/var-dumper/Caster/UuidCaster.php b/vendor/symfony/var-dumper/Caster/UuidCaster.php new file mode 100644 index 0000000..732ad7c --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/UuidCaster.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Ramsey\Uuid\UuidInterface; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * @author Grégoire Pineau + * + * @internal since Symfony 7.3 + */ +final class UuidCaster +{ + public static function castRamseyUuid(UuidInterface $c, array $a, Stub $stub, bool $isNested): array + { + $a += [ + Caster::PREFIX_VIRTUAL.'uuid' => (string) $c, + ]; + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Caster/VirtualStub.php b/vendor/symfony/var-dumper/Caster/VirtualStub.php new file mode 100644 index 0000000..60b58fa --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/VirtualStub.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +class VirtualStub extends ConstStub +{ + public function __construct(\ReflectionProperty $property) + { + parent::__construct('~'.($property->hasType() ? ' '.$property->getType() : ''), 'Virtual property'); + $this->attr['virtual'] = true; + } +} diff --git a/vendor/symfony/var-dumper/Caster/XmlReaderCaster.php b/vendor/symfony/var-dumper/Caster/XmlReaderCaster.php new file mode 100644 index 0000000..00420c7 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/XmlReaderCaster.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts XmlReader class to array representation. + * + * @author Baptiste Clavié + * + * @final + * + * @internal since Symfony 7.3 + */ +class XmlReaderCaster +{ + private const NODE_TYPES = [ + \XMLReader::NONE => 'NONE', + \XMLReader::ELEMENT => 'ELEMENT', + \XMLReader::ATTRIBUTE => 'ATTRIBUTE', + \XMLReader::TEXT => 'TEXT', + \XMLReader::CDATA => 'CDATA', + \XMLReader::ENTITY_REF => 'ENTITY_REF', + \XMLReader::ENTITY => 'ENTITY', + \XMLReader::PI => 'PI (Processing Instruction)', + \XMLReader::COMMENT => 'COMMENT', + \XMLReader::DOC => 'DOC', + \XMLReader::DOC_TYPE => 'DOC_TYPE', + \XMLReader::DOC_FRAGMENT => 'DOC_FRAGMENT', + \XMLReader::NOTATION => 'NOTATION', + \XMLReader::WHITESPACE => 'WHITESPACE', + \XMLReader::SIGNIFICANT_WHITESPACE => 'SIGNIFICANT_WHITESPACE', + \XMLReader::END_ELEMENT => 'END_ELEMENT', + \XMLReader::END_ENTITY => 'END_ENTITY', + \XMLReader::XML_DECLARATION => 'XML_DECLARATION', + ]; + + public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, bool $isNested): array + { + try { + $properties = [ + 'LOADDTD' => @$reader->getParserProperty(\XMLReader::LOADDTD), + 'DEFAULTATTRS' => @$reader->getParserProperty(\XMLReader::DEFAULTATTRS), + 'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE), + 'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES), + ]; + } catch (\Error) { + $properties = [ + 'LOADDTD' => false, + 'DEFAULTATTRS' => false, + 'VALIDATE' => false, + 'SUBST_ENTITIES' => false, + ]; + } + + $props = Caster::PREFIX_VIRTUAL.'parserProperties'; + $info = [ + 'localName' => $reader->localName, + 'prefix' => $reader->prefix, + 'nodeType' => new ConstStub(self::NODE_TYPES[$reader->nodeType], $reader->nodeType), + 'depth' => $reader->depth, + 'isDefault' => $reader->isDefault, + 'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement, + 'xmlLang' => $reader->xmlLang, + 'attributeCount' => $reader->attributeCount, + 'value' => $reader->value, + 'namespaceURI' => $reader->namespaceURI, + 'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI, + $props => $properties, + ]; + + if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) { + $info[$props] = new EnumStub($info[$props]); + $info[$props]->cut = $count; + } + + $a = Caster::filter($a, Caster::EXCLUDE_UNINITIALIZED, [], $count); + $info = Caster::filter($info, Caster::EXCLUDE_EMPTY, [], $count); + // +2 because hasValue and hasAttributes are always filtered + $stub->cut += $count + 2; + + return $a + $info; + } +} diff --git a/vendor/symfony/var-dumper/Caster/XmlResourceCaster.php b/vendor/symfony/var-dumper/Caster/XmlResourceCaster.php new file mode 100644 index 0000000..f6b0896 --- /dev/null +++ b/vendor/symfony/var-dumper/Caster/XmlResourceCaster.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 Symfony\Component\VarDumper\Caster; + +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * Casts XML resources to array representation. + * + * @author Nicolas Grekas + * + * @final + * + * @internal since Symfony 7.3 + */ +class XmlResourceCaster +{ + private const XML_ERRORS = [ + \XML_ERROR_NONE => 'XML_ERROR_NONE', + \XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY', + \XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX', + \XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS', + \XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN', + \XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN', + \XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR', + \XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH', + \XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE', + \XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT', + \XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF', + \XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY', + \XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF', + \XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY', + \XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF', + \XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF', + \XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF', + \XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI', + \XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING', + \XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING', + \XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION', + \XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING', + ]; + + public static function castXml($h, array $a, Stub $stub, bool $isNested): array + { + $a['current_byte_index'] = xml_get_current_byte_index($h); + $a['current_column_number'] = xml_get_current_column_number($h); + $a['current_line_number'] = xml_get_current_line_number($h); + $a['error_code'] = xml_get_error_code($h); + + if (isset(self::XML_ERRORS[$a['error_code']])) { + $a['error_code'] = new ConstStub(self::XML_ERRORS[$a['error_code']], $a['error_code']); + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Cloner/AbstractCloner.php b/vendor/symfony/var-dumper/Cloner/AbstractCloner.php new file mode 100644 index 0000000..9038d2c --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/AbstractCloner.php @@ -0,0 +1,413 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +use Symfony\Component\VarDumper\Caster\Caster; +use Symfony\Component\VarDumper\Exception\ThrowingCasterException; + +/** + * AbstractCloner implements a generic caster mechanism for objects and resources. + * + * @author Nicolas Grekas + */ +abstract class AbstractCloner implements ClonerInterface +{ + public static array $defaultCasters = [ + '__PHP_Incomplete_Class' => ['Symfony\Component\VarDumper\Caster\Caster', 'castPhpIncompleteClass'], + + 'AddressInfo' => ['Symfony\Component\VarDumper\Caster\AddressInfoCaster', 'castAddressInfo'], + 'Socket' => ['Symfony\Component\VarDumper\Caster\SocketCaster', 'castSocket'], + + 'Symfony\Component\VarDumper\Caster\CutStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'], + 'Symfony\Component\VarDumper\Caster\CutArrayStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castCutArray'], + 'Symfony\Component\VarDumper\Caster\ConstStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'], + 'Symfony\Component\VarDumper\Caster\EnumStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castEnum'], + 'Symfony\Component\VarDumper\Caster\ScalarStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castScalar'], + + 'Fiber' => ['Symfony\Component\VarDumper\Caster\FiberCaster', 'castFiber'], + + 'Closure' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClosure'], + 'Generator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castGenerator'], + 'ReflectionType' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castType'], + 'ReflectionAttribute' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castAttribute'], + 'ReflectionGenerator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReflectionGenerator'], + 'ReflectionClass' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClass'], + 'ReflectionClassConstant' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClassConstant'], + 'ReflectionFunctionAbstract' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castFunctionAbstract'], + 'ReflectionMethod' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castMethod'], + 'ReflectionParameter' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castParameter'], + 'ReflectionProperty' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castProperty'], + 'ReflectionReference' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReference'], + 'ReflectionExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castExtension'], + 'ReflectionZendExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castZendExtension'], + + 'Doctrine\Common\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Doctrine\Common\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castCommonProxy'], + 'Doctrine\ORM\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castOrmProxy'], + 'Doctrine\ORM\PersistentCollection' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castPersistentCollection'], + 'Doctrine\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + + 'DOMException' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castException'], + 'Dom\Exception' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castException'], + 'DOMStringList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'DOMNameList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'DOMImplementation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castImplementation'], + 'Dom\Implementation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castImplementation'], + 'DOMImplementationList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'DOMNode' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNode'], + 'Dom\Node' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNode'], + 'DOMNameSpaceNode' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNameSpaceNode'], + 'DOMDocument' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocument'], + 'Dom\XMLDocument' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXMLDocument'], + 'Dom\HTMLDocument' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castHTMLDocument'], + 'DOMNodeList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'Dom\NodeList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'DOMNamedNodeMap' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'Dom\DTDNamedNodeMap' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], + 'DOMCharacterData' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castCharacterData'], + 'Dom\CharacterData' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castCharacterData'], + 'DOMAttr' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castAttr'], + 'Dom\Attr' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castAttr'], + 'DOMElement' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castElement'], + 'Dom\Element' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castElement'], + 'DOMText' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castText'], + 'Dom\Text' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castText'], + 'DOMDocumentType' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocumentType'], + 'Dom\DocumentType' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocumentType'], + 'DOMNotation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNotation'], + 'Dom\Notation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNotation'], + 'DOMEntity' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castEntity'], + 'Dom\Entity' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castEntity'], + 'DOMProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'], + 'Dom\ProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'], + 'DOMXPath' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXPath'], + + 'XMLReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'], + + 'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'], + 'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'], + 'Error' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castError'], + 'Symfony\Bridge\Monolog\Logger' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Symfony\Component\DependencyInjection\ContainerInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Symfony\Component\EventDispatcher\EventDispatcherInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Symfony\Component\HttpClient\AmpHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], + 'Symfony\Component\HttpClient\CurlHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], + 'Symfony\Component\HttpClient\NativeHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], + 'Symfony\Component\HttpClient\Response\AmpResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], + 'Symfony\Component\HttpClient\Response\AmpResponseV4' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], + 'Symfony\Component\HttpClient\Response\AmpResponseV5' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], + 'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], + 'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], + 'Symfony\Component\HttpFoundation\Request' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castRequest'], + 'Symfony\Component\Uid\Ulid' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castUlid'], + 'Symfony\Component\Uid\Uuid' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castUuid'], + 'Symfony\Component\VarExporter\Internal\LazyObjectState' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castLazyObjectState'], + 'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrowingCasterException'], + 'Symfony\Component\VarDumper\Caster\TraceStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castTraceStub'], + 'Symfony\Component\VarDumper\Caster\FrameStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFrameStub'], + 'Symfony\Component\VarDumper\Cloner\AbstractCloner' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Symfony\Component\ErrorHandler\Exception\FlattenException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFlattenException'], + 'Symfony\Component\ErrorHandler\Exception\SilencedErrorContext' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castSilencedErrorContext'], + + 'Imagine\Image\ImageInterface' => ['Symfony\Component\VarDumper\Caster\ImagineCaster', 'castImage'], + + 'Ramsey\Uuid\UuidInterface' => ['Symfony\Component\VarDumper\Caster\UuidCaster', 'castRamseyUuid'], + + 'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'], + 'PHPUnit_Framework_MockObject_MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'PHPUnit\Framework\MockObject\MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'PHPUnit\Framework\MockObject\Stub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Prophecy\Prophecy\ProphecySubjectInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + 'Mockery\MockInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], + + 'PDO' => ['Symfony\Component\VarDumper\Caster\PdoCaster', 'castPdo'], + 'PDOStatement' => ['Symfony\Component\VarDumper\Caster\PdoCaster', 'castPdoStatement'], + + 'AMQPConnection' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castConnection'], + 'AMQPChannel' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castChannel'], + 'AMQPQueue' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castQueue'], + 'AMQPExchange' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castExchange'], + 'AMQPEnvelope' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castEnvelope'], + + 'ArrayObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castArrayObject'], + 'ArrayIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castArrayIterator'], + 'SplDoublyLinkedList' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castDoublyLinkedList'], + 'SplFileInfo' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileInfo'], + 'SplFileObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileObject'], + 'SplHeap' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'], + 'SplObjectStorage' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castObjectStorage'], + 'SplPriorityQueue' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'], + 'OuterIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castOuterIterator'], + 'WeakMap' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castWeakMap'], + 'WeakReference' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castWeakReference'], + + 'Redis' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'], + 'Relay\Relay' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'], + 'RedisArray' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisArray'], + 'RedisCluster' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisCluster'], + + 'DateTimeInterface' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castDateTime'], + 'DateInterval' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castInterval'], + 'DateTimeZone' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castTimeZone'], + 'DatePeriod' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castPeriod'], + + 'GMP' => ['Symfony\Component\VarDumper\Caster\GmpCaster', 'castGmp'], + + 'MessageFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castMessageFormatter'], + 'NumberFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castNumberFormatter'], + 'IntlTimeZone' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlTimeZone'], + 'IntlCalendar' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlCalendar'], + 'IntlDateFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlDateFormatter'], + + 'Memcached' => ['Symfony\Component\VarDumper\Caster\MemcachedCaster', 'castMemcached'], + + 'Ds\Collection' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castCollection'], + 'Ds\Map' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castMap'], + 'Ds\Pair' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPair'], + 'Symfony\Component\VarDumper\Caster\DsPairStub' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPairStub'], + + 'mysqli_driver' => ['Symfony\Component\VarDumper\Caster\MysqliCaster', 'castMysqliDriver'], + + 'CurlHandle' => ['Symfony\Component\VarDumper\Caster\CurlCaster', 'castCurl'], + + 'Dba\Connection' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'], + ':dba' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'], + ':dba persistent' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'], + + 'GdImage' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'], + + 'SQLite3Result' => ['Symfony\Component\VarDumper\Caster\SqliteCaster', 'castSqlite3Result'], + + 'PgSql\Lob' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLargeObject'], + 'PgSql\Connection' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'], + 'PgSql\Result' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castResult'], + + ':process' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castProcess'], + ':stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'], + + 'OpenSSLAsymmetricKey' => ['Symfony\Component\VarDumper\Caster\OpenSSLCaster', 'castOpensslAsymmetricKey'], + 'OpenSSLCertificateSigningRequest' => ['Symfony\Component\VarDumper\Caster\OpenSSLCaster', 'castOpensslCsr'], + 'OpenSSLCertificate' => ['Symfony\Component\VarDumper\Caster\OpenSSLCaster', 'castOpensslX509'], + + ':persistent stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'], + ':stream-context' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStreamContext'], + + 'XmlParser' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'], + + 'Socket' => ['Symfony\Component\VarDumper\Caster\SocketCaster', 'castSocket'], + + 'RdKafka' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castRdKafka'], + 'RdKafka\Conf' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castConf'], + 'RdKafka\KafkaConsumer' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castKafkaConsumer'], + 'RdKafka\Metadata\Broker' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castBrokerMetadata'], + 'RdKafka\Metadata\Collection' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castCollectionMetadata'], + 'RdKafka\Metadata\Partition' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castPartitionMetadata'], + 'RdKafka\Metadata\Topic' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopicMetadata'], + 'RdKafka\Message' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castMessage'], + 'RdKafka\Topic' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopic'], + 'RdKafka\TopicPartition' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopicPartition'], + 'RdKafka\TopicConf' => ['Symfony\Component\VarDumper\Caster\RdKafkaCaster', 'castTopicConf'], + + 'FFI\CData' => ['Symfony\Component\VarDumper\Caster\FFICaster', 'castCTypeOrCData'], + 'FFI\CType' => ['Symfony\Component\VarDumper\Caster\FFICaster', 'castCTypeOrCData'], + ]; + + protected int $maxItems = 2500; + protected int $maxString = -1; + protected int $minDepth = 1; + + /** + * @var array> + */ + private array $casters = []; + + /** + * @var callable|null + */ + private $prevErrorHandler; + + private array $classInfo = []; + private int $filter = 0; + + /** + * @param callable[]|null $casters A map of casters + * + * @see addCasters + */ + public function __construct(?array $casters = null) + { + $this->addCasters($casters ?? static::$defaultCasters); + } + + /** + * Adds casters for resources and objects. + * + * Maps resources or objects types to a callback. + * Types are in the key, with a callable caster for value. + * Resource types are to be prefixed with a `:`, + * see e.g. static::$defaultCasters. + * + * @param callable[] $casters A map of casters + */ + public function addCasters(array $casters): void + { + foreach ($casters as $type => $callback) { + $this->casters[$type][] = $callback; + } + } + + /** + * Sets the maximum number of items to clone past the minimum depth in nested structures. + */ + public function setMaxItems(int $maxItems): void + { + $this->maxItems = $maxItems; + } + + /** + * Sets the maximum cloned length for strings. + */ + public function setMaxString(int $maxString): void + { + $this->maxString = $maxString; + } + + /** + * Sets the minimum tree depth where we are guaranteed to clone all the items. After this + * depth is reached, only setMaxItems items will be cloned. + */ + public function setMinDepth(int $minDepth): void + { + $this->minDepth = $minDepth; + } + + /** + * Clones a PHP variable. + * + * @param int $filter A bit field of Caster::EXCLUDE_* constants + */ + public function cloneVar(mixed $var, int $filter = 0): Data + { + $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) { + if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) { + // Cloner never dies + throw new \ErrorException($msg, 0, $type, $file, $line); + } + + if ($this->prevErrorHandler) { + return ($this->prevErrorHandler)($type, $msg, $file, $line, $context); + } + + return false; + }); + $this->filter = $filter; + + if ($gc = gc_enabled()) { + gc_disable(); + } + try { + return new Data($this->doClone($var)); + } finally { + if ($gc) { + gc_enable(); + } + restore_error_handler(); + $this->prevErrorHandler = null; + } + } + + /** + * Effectively clones the PHP variable. + */ + abstract protected function doClone(mixed $var): array; + + /** + * Casts an object to an array representation. + * + * @param bool $isNested True if the object is nested in the dumped structure + */ + protected function castObject(Stub $stub, bool $isNested): array + { + $obj = $stub->value; + $class = $stub->class; + + if (str_contains($class, "@anonymous\0")) { + $stub->class = get_debug_type($obj); + } + if (isset($this->classInfo[$class])) { + [$i, $parents, $hasDebugInfo, $fileInfo] = $this->classInfo[$class]; + } else { + $i = 2; + $parents = [$class]; + $hasDebugInfo = method_exists($class, '__debugInfo'); + + foreach (class_parents($class) as $p) { + $parents[] = $p; + ++$i; + } + foreach (class_implements($class) as $p) { + $parents[] = $p; + ++$i; + } + $parents[] = '*'; + + $r = new \ReflectionClass($class); + $fileInfo = $r->isInternal() || $r->isSubclassOf(Stub::class) ? [] : [ + 'file' => $r->getFileName(), + 'line' => $r->getStartLine(), + ]; + + $this->classInfo[$class] = [$i, $parents, $hasDebugInfo, $fileInfo]; + } + + $stub->attr += $fileInfo; + $a = Caster::castObject($obj, $class, $hasDebugInfo, $stub->class); + + try { + while ($i--) { + if (!empty($this->casters[$p = $parents[$i]])) { + foreach ($this->casters[$p] as $callback) { + $a = $callback($obj, $a, $stub, $isNested, $this->filter); + } + } + } + } catch (\Exception $e) { + $a = [(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠' => new ThrowingCasterException($e)] + $a; + } + + return $a; + } + + /** + * Casts a resource to an array representation. + * + * @param bool $isNested True if the object is nested in the dumped structure + */ + protected function castResource(Stub $stub, bool $isNested): array + { + $a = []; + $res = $stub->value; + $type = $stub->class; + + try { + if (!empty($this->casters[':'.$type])) { + foreach ($this->casters[':'.$type] as $callback) { + $a = $callback($res, $a, $stub, $isNested, $this->filter); + } + } + } catch (\Exception $e) { + $a = [(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠' => new ThrowingCasterException($e)] + $a; + } + + return $a; + } +} diff --git a/vendor/symfony/var-dumper/Cloner/ClonerInterface.php b/vendor/symfony/var-dumper/Cloner/ClonerInterface.php new file mode 100644 index 0000000..5a8e2e4 --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/ClonerInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +/** + * @author Nicolas Grekas + */ +interface ClonerInterface +{ + /** + * Clones a PHP variable. + */ + public function cloneVar(mixed $var): Data; +} diff --git a/vendor/symfony/var-dumper/Cloner/Cursor.php b/vendor/symfony/var-dumper/Cloner/Cursor.php new file mode 100644 index 0000000..8923007 --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/Cursor.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +/** + * Represents the current state of a dumper while dumping. + * + * @author Nicolas Grekas + */ +class Cursor +{ + public const HASH_INDEXED = Stub::ARRAY_INDEXED; + public const HASH_ASSOC = Stub::ARRAY_ASSOC; + public const HASH_OBJECT = Stub::TYPE_OBJECT; + public const HASH_RESOURCE = Stub::TYPE_RESOURCE; + + public int $depth = 0; + public int $refIndex = 0; + public int $softRefTo = 0; + public int $softRefCount = 0; + public int $softRefHandle = 0; + public int $hardRefTo = 0; + public int $hardRefCount = 0; + public int $hardRefHandle = 0; + public int $hashType; + public string|int|null $hashKey = null; + public bool $hashKeyIsBinary; + public int $hashIndex = 0; + public int $hashLength = 0; + public int $hashCut = 0; + public bool $stop = false; + public array $attr = []; + public bool $skipChildren = false; +} diff --git a/vendor/symfony/var-dumper/Cloner/Data.php b/vendor/symfony/var-dumper/Cloner/Data.php new file mode 100644 index 0000000..21e2caa --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/Data.php @@ -0,0 +1,429 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +use Symfony\Component\VarDumper\Caster\Caster; +use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider; + +/** + * @author Nicolas Grekas + */ +class Data implements \ArrayAccess, \Countable, \IteratorAggregate, \Stringable +{ + private array $data; + private int $position = 0; + private int|string $key = 0; + private int $maxDepth = 20; + private int $maxItemsPerDepth = -1; + private int $useRefHandles = -1; + private array $context = []; + + /** + * @param array $data An array as returned by ClonerInterface::cloneVar() + */ + public function __construct(array $data) + { + $this->data = $data; + } + + public function getType(): ?string + { + $item = $this->data[$this->position][$this->key]; + + if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) { + $item = $item->value; + } + if (!$item instanceof Stub) { + return \gettype($item); + } + if (Stub::TYPE_STRING === $item->type) { + return 'string'; + } + if (Stub::TYPE_ARRAY === $item->type) { + return 'array'; + } + if (Stub::TYPE_OBJECT === $item->type) { + return $item->class; + } + if (Stub::TYPE_RESOURCE === $item->type) { + return $item->class.' resource'; + } + + return null; + } + + /** + * Returns a native representation of the original value. + * + * @param array|bool $recursive Whether values should be resolved recursively or not + * + * @return string|int|float|bool|array|Data[]|null + */ + public function getValue(array|bool $recursive = false): string|int|float|bool|array|null + { + $item = $this->data[$this->position][$this->key]; + + if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) { + $item = $item->value; + } + if (!($item = $this->getStub($item)) instanceof Stub) { + return $item; + } + if (Stub::TYPE_STRING === $item->type) { + return $item->value; + } + + $children = $item->position ? $this->data[$item->position] : []; + + foreach ($children as $k => $v) { + if ($recursive && !($v = $this->getStub($v)) instanceof Stub) { + continue; + } + $children[$k] = clone $this; + $children[$k]->key = $k; + $children[$k]->position = $item->position; + + if ($recursive) { + if (Stub::TYPE_REF === $v->type && ($v = $this->getStub($v->value)) instanceof Stub) { + $recursive = (array) $recursive; + if (isset($recursive[$v->position])) { + continue; + } + $recursive[$v->position] = true; + } + $children[$k] = $children[$k]->getValue($recursive); + } + } + + return $children; + } + + public function count(): int + { + return \count($this->getValue()); + } + + public function getIterator(): \Traversable + { + if (!\is_array($value = $this->getValue())) { + throw new \LogicException(\sprintf('"%s" object holds non-iterable type "%s".', self::class, get_debug_type($value))); + } + + yield from $value; + } + + public function __get(string $key): mixed + { + if (null !== $data = $this->seek($key)) { + $item = $this->getStub($data->data[$data->position][$data->key]); + + return $item instanceof Stub || [] === $item ? $data : $item; + } + + return null; + } + + public function __isset(string $key): bool + { + return null !== $this->seek($key); + } + + public function offsetExists(mixed $key): bool + { + return $this->__isset($key); + } + + public function offsetGet(mixed $key): mixed + { + return $this->__get($key); + } + + public function offsetSet(mixed $key, mixed $value): void + { + throw new \BadMethodCallException(self::class.' objects are immutable.'); + } + + public function offsetUnset(mixed $key): void + { + throw new \BadMethodCallException(self::class.' objects are immutable.'); + } + + public function __toString(): string + { + $value = $this->getValue(); + + if (!\is_array($value)) { + return (string) $value; + } + + return \sprintf('%s (count=%d)', $this->getType(), \count($value)); + } + + /** + * Returns a depth limited clone of $this. + */ + public function withMaxDepth(int $maxDepth): static + { + $data = clone $this; + $data->maxDepth = $maxDepth; + + return $data; + } + + /** + * Limits the number of elements per depth level. + */ + public function withMaxItemsPerDepth(int $maxItemsPerDepth): static + { + $data = clone $this; + $data->maxItemsPerDepth = $maxItemsPerDepth; + + return $data; + } + + /** + * Enables/disables objects' identifiers tracking. + * + * @param bool $useRefHandles False to hide global ref. handles + */ + public function withRefHandles(bool $useRefHandles): static + { + $data = clone $this; + $data->useRefHandles = $useRefHandles ? -1 : 0; + + return $data; + } + + public function withContext(array $context): static + { + $data = clone $this; + $data->context = $context; + + return $data; + } + + public function getContext(): array + { + return $this->context; + } + + /** + * Seeks to a specific key in nested data structures. + */ + public function seek(string|int $key): ?static + { + $item = $this->data[$this->position][$this->key]; + + if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) { + $item = $item->value; + } + if (!($item = $this->getStub($item)) instanceof Stub || !$item->position) { + return null; + } + $keys = [$key]; + + switch ($item->type) { + case Stub::TYPE_OBJECT: + $keys[] = Caster::PREFIX_DYNAMIC.$key; + $keys[] = Caster::PREFIX_PROTECTED.$key; + $keys[] = Caster::PREFIX_VIRTUAL.$key; + $keys[] = "\0$item->class\0$key"; + // no break + case Stub::TYPE_ARRAY: + case Stub::TYPE_RESOURCE: + break; + default: + return null; + } + + $data = null; + $children = $this->data[$item->position]; + + foreach ($keys as $key) { + if (isset($children[$key]) || \array_key_exists($key, $children)) { + $data = clone $this; + $data->key = $key; + $data->position = $item->position; + break; + } + } + + return $data; + } + + /** + * Dumps data with a DumperInterface dumper. + */ + public function dump(DumperInterface $dumper): void + { + $refs = [0]; + $cursor = new Cursor(); + $cursor->hashType = -1; + $cursor->attr = $this->context[SourceContextProvider::class] ?? []; + $label = $this->context['label'] ?? ''; + + if ($cursor->attr || '' !== $label) { + $dumper->dumpScalar($cursor, 'label', $label); + } + $cursor->hashType = 0; + $this->dumpItem($dumper, $cursor, $refs, $this->data[$this->position][$this->key]); + } + + /** + * Depth-first dumping of items. + * + * @param mixed $item A Stub object or the original value being dumped + */ + private function dumpItem(DumperInterface $dumper, Cursor $cursor, array &$refs, mixed $item): void + { + $cursor->refIndex = 0; + $cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0; + $cursor->hardRefTo = $cursor->hardRefHandle = $cursor->hardRefCount = 0; + $firstSeen = true; + + if (!$item instanceof Stub) { + $cursor->attr = []; + $type = \gettype($item); + if ($item && 'array' === $type) { + $item = $this->getStub($item); + } + } elseif (Stub::TYPE_REF === $item->type) { + if ($item->handle) { + if (!isset($refs[$r = $item->handle - (\PHP_INT_MAX >> 1)])) { + $cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0]; + } else { + $firstSeen = false; + } + $cursor->hardRefTo = $refs[$r]; + $cursor->hardRefHandle = $this->useRefHandles & $item->handle; + $cursor->hardRefCount = 0 < $item->handle ? $item->refCount : 0; + } + $cursor->attr = $item->attr; + $type = $item->class ?: \gettype($item->value); + $item = $this->getStub($item->value); + } + if ($item instanceof Stub) { + if ($item->refCount) { + if (!isset($refs[$r = $item->handle])) { + $cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0]; + } else { + $firstSeen = false; + } + $cursor->softRefTo = $refs[$r]; + } + $cursor->softRefHandle = $this->useRefHandles & $item->handle; + $cursor->softRefCount = $item->refCount; + $cursor->attr = $item->attr; + $cut = $item->cut; + + if ($item->position && $firstSeen) { + $children = $this->data[$item->position]; + + if ($cursor->stop) { + if ($cut >= 0) { + $cut += \count($children); + } + $children = []; + } + } else { + $children = []; + } + switch ($item->type) { + case Stub::TYPE_STRING: + $dumper->dumpString($cursor, $item->value, Stub::STRING_BINARY === $item->class, $cut); + break; + + case Stub::TYPE_ARRAY: + $item = clone $item; + $item->type = $item->class; + $item->class = $item->value; + // no break + case Stub::TYPE_OBJECT: + case Stub::TYPE_RESOURCE: + $withChildren = $children && $cursor->depth !== $this->maxDepth && $this->maxItemsPerDepth; + $dumper->enterHash($cursor, $item->type, $item->class, $withChildren); + if ($withChildren) { + if ($cursor->skipChildren) { + $withChildren = false; + $cut = -1; + } else { + $cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type, null !== $item->class); + } + } elseif ($children && 0 <= $cut) { + $cut += \count($children); + } + $cursor->skipChildren = false; + $dumper->leaveHash($cursor, $item->type, $item->class, $withChildren, $cut); + break; + + case Stub::TYPE_SCALAR: + $dumper->dumpScalar($cursor, 'default', $item->attr['value']); + break; + + default: + throw new \RuntimeException(\sprintf('Unexpected Stub type: "%s".', $item->type)); + } + } elseif ('array' === $type) { + $dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false); + $dumper->leaveHash($cursor, Cursor::HASH_INDEXED, 0, false, 0); + } elseif ('string' === $type) { + $dumper->dumpString($cursor, $item, false, 0); + } else { + $dumper->dumpScalar($cursor, $type, $item); + } + } + + /** + * Dumps children of hash structures. + * + * @return int The final number of removed items + */ + private function dumpChildren(DumperInterface $dumper, Cursor $parentCursor, array &$refs, array $children, int $hashCut, int $hashType, bool $dumpKeys): int + { + $cursor = clone $parentCursor; + ++$cursor->depth; + $cursor->hashType = $hashType; + $cursor->hashIndex = 0; + $cursor->hashLength = \count($children); + $cursor->hashCut = $hashCut; + foreach ($children as $key => $child) { + $cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key); + $cursor->hashKey = $dumpKeys ? $key : null; + $this->dumpItem($dumper, $cursor, $refs, $child); + if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) { + $parentCursor->stop = true; + + return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut; + } + } + + return $hashCut; + } + + private function getStub(mixed $item): mixed + { + if (!$item || !\is_array($item)) { + return $item; + } + + $stub = new Stub(); + $stub->type = Stub::TYPE_ARRAY; + foreach ($item as $stub->class => $stub->position) { + } + if (isset($item[0])) { + $stub->cut = $item[0]; + } + $stub->value = $stub->cut + ($stub->position ? \count($this->data[$stub->position]) : 0); + + return $stub; + } +} diff --git a/vendor/symfony/var-dumper/Cloner/DumperInterface.php b/vendor/symfony/var-dumper/Cloner/DumperInterface.php new file mode 100644 index 0000000..10f2da0 --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/DumperInterface.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +/** + * DumperInterface used by Data objects. + * + * @author Nicolas Grekas + */ +interface DumperInterface +{ + /** + * Dumps a scalar value. + */ + public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value): void; + + /** + * Dumps a string. + * + * @param string $str The string being dumped + * @param bool $bin Whether $str is UTF-8 or binary encoded + * @param int $cut The number of characters $str has been cut by + */ + public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut): void; + + /** + * Dumps while entering an hash. + * + * @param int $type A Cursor::HASH_* const for the type of hash + * @param string|int|null $class The object class, resource type or array count + * @param bool $hasChild When the dump of the hash has child item + */ + public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild): void; + + /** + * Dumps while leaving an hash. + * + * @param int $type A Cursor::HASH_* const for the type of hash + * @param string|int|null $class The object class, resource type or array count + * @param bool $hasChild When the dump of the hash has child item + * @param int $cut The number of items the hash has been cut by + */ + public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut): void; +} diff --git a/vendor/symfony/var-dumper/Cloner/Internal/NoDefault.php b/vendor/symfony/var-dumper/Cloner/Internal/NoDefault.php new file mode 100644 index 0000000..ed9db98 --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/Internal/NoDefault.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner\Internal; + +/** + * Flags a typed property that has no default value. + * + * This dummy object is used to distinguish a property with a default value of null + * from a property that is uninitialized by default. + * + * @internal + */ +enum NoDefault +{ + case NoDefault; +} diff --git a/vendor/symfony/var-dumper/Cloner/Stub.php b/vendor/symfony/var-dumper/Cloner/Stub.php new file mode 100644 index 0000000..4455a36 --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/Stub.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +use Symfony\Component\VarDumper\Cloner\Internal\NoDefault; + +/** + * Represents the main properties of a PHP variable. + * + * @author Nicolas Grekas + */ +class Stub +{ + public const TYPE_REF = 1; + public const TYPE_STRING = 2; + public const TYPE_ARRAY = 3; + public const TYPE_OBJECT = 4; + public const TYPE_RESOURCE = 5; + public const TYPE_SCALAR = 6; + + public const STRING_BINARY = 1; + public const STRING_UTF8 = 2; + + public const ARRAY_ASSOC = 1; + public const ARRAY_INDEXED = 2; + + public int $type = self::TYPE_REF; + public string|int|null $class = ''; + public mixed $value = null; + public int $cut = 0; + public int $handle = 0; + public int $refCount = 0; + public int $position = 0; + public array $attr = []; + + private static array $defaultProperties = []; + + /** + * @internal + */ + public function __sleep(): array + { + $properties = []; + + if (!isset(self::$defaultProperties[$c = static::class])) { + $reflection = new \ReflectionClass($c); + self::$defaultProperties[$c] = []; + + foreach ($reflection->getProperties() as $p) { + if ($p->isStatic()) { + continue; + } + + self::$defaultProperties[$c][$p->name] = $p->hasDefaultValue() ? $p->getDefaultValue() : ($p->hasType() ? NoDefault::NoDefault : null); + } + } + + foreach (self::$defaultProperties[$c] as $k => $v) { + if (NoDefault::NoDefault === $v || $this->$k !== $v) { + $properties[] = $k; + } + } + + return $properties; + } +} diff --git a/vendor/symfony/var-dumper/Cloner/VarCloner.php b/vendor/symfony/var-dumper/Cloner/VarCloner.php new file mode 100644 index 0000000..6a7ec28 --- /dev/null +++ b/vendor/symfony/var-dumper/Cloner/VarCloner.php @@ -0,0 +1,218 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Cloner; + +/** + * @author Nicolas Grekas + */ +class VarCloner extends AbstractCloner +{ + private static array $arrayCache = []; + + protected function doClone(mixed $var): array + { + $len = 1; // Length of $queue + $pos = 0; // Number of cloned items past the minimum depth + $refsCounter = 0; // Hard references counter + $queue = [[$var]]; // This breadth-first queue is the return value + $hardRefs = []; // Map of original zval ids to stub objects + $objRefs = []; // Map of original object handles to their stub object counterpart + $objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning + $resRefs = []; // Map of original resource handles to their stub object counterpart + $maxItems = $this->maxItems; + $maxString = $this->maxString; + $minDepth = $this->minDepth; + $currentDepth = 0; // Current tree depth + $currentDepthFinalIndex = 0; // Final $queue index for current tree depth + $minimumDepthReached = 0 === $minDepth; // Becomes true when minimum tree depth has been reached + $a = null; // Array cast for nested structures + $stub = null; // Stub capturing the main properties of an original item value + // or null if the original value is used directly + + $arrayStub = new Stub(); + $arrayStub->type = Stub::TYPE_ARRAY; + + for ($i = 0; $i < $len; ++$i) { + // Detect when we move on to the next tree depth + if ($i > $currentDepthFinalIndex) { + ++$currentDepth; + $currentDepthFinalIndex = $len - 1; + if ($currentDepth >= $minDepth) { + $minimumDepthReached = true; + } + } + + $vals = $queue[$i]; + foreach ($vals as $k => $v) { + // $v is the original value or a stub object in case of hard references + + $zvalRef = ($r = \ReflectionReference::fromArrayElement($vals, $k)) ? $r->getId() : null; + + if ($zvalRef) { + $vals[$k] = &$stub; // Break hard references to make $queue completely + unset($stub); // independent from the original structure + if (null !== $vals[$k] = $hardRefs[$zvalRef] ?? null) { + $v = $vals[$k]; + if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) { + ++$v->value->refCount; + } + ++$v->refCount; + continue; + } + $vals[$k] = new Stub(); + $vals[$k]->value = $v; + $vals[$k]->handle = ++$refsCounter; + $hardRefs[$zvalRef] = $vals[$k]; + } + // Create $stub when the original value $v cannot be used directly + // If $v is a nested structure, put that structure in array $a + switch (true) { + case null === $v: + case \is_bool($v): + case \is_int($v): + case \is_float($v): + continue 2; + case \is_string($v): + if ('' === $v) { + continue 2; + } + if (!preg_match('//u', $v)) { + $stub = new Stub(); + $stub->type = Stub::TYPE_STRING; + $stub->class = Stub::STRING_BINARY; + if (0 <= $maxString && 0 < $cut = \strlen($v) - $maxString) { + $stub->cut = $cut; + $stub->value = substr($v, 0, -$cut); + } else { + $stub->value = $v; + } + } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) { + $stub = new Stub(); + $stub->type = Stub::TYPE_STRING; + $stub->class = Stub::STRING_UTF8; + $stub->cut = $cut; + $stub->value = mb_substr($v, 0, $maxString, 'UTF-8'); + } else { + continue 2; + } + $a = null; + break; + + case \is_array($v): + if (!$v) { + continue 2; + } + $stub = $arrayStub; + + $stub->class = array_is_list($v) ? Stub::ARRAY_INDEXED : Stub::ARRAY_ASSOC; + $a = $v; + break; + + case \is_object($v): + if (empty($objRefs[$h = spl_object_id($v)])) { + $stub = new Stub(); + $stub->type = Stub::TYPE_OBJECT; + $stub->class = $v::class; + $stub->value = $v; + $stub->handle = $h; + $a = $this->castObject($stub, 0 < $i); + if ($v !== $stub->value) { + if (Stub::TYPE_OBJECT !== $stub->type || null === $stub->value) { + break; + } + $stub->handle = $h = spl_object_id($stub->value); + } + $stub->value = null; + if (0 <= $maxItems && $maxItems <= $pos && $minimumDepthReached) { + $stub->cut = \count($a); + $a = null; + } + } + if (empty($objRefs[$h])) { + $objRefs[$h] = $stub; + $objects[] = $v; + } else { + $stub = $objRefs[$h]; + ++$stub->refCount; + $a = null; + } + break; + + default: // resource + if (empty($resRefs[$h = (int) $v])) { + $stub = new Stub(); + $stub->type = Stub::TYPE_RESOURCE; + if ('Unknown' === $stub->class = @get_resource_type($v)) { + $stub->class = 'Closed'; + } + $stub->value = $v; + $stub->handle = $h; + $a = $this->castResource($stub, 0 < $i); + $stub->value = null; + if (0 <= $maxItems && $maxItems <= $pos && $minimumDepthReached) { + $stub->cut = \count($a); + $a = null; + } + } + if (empty($resRefs[$h])) { + $resRefs[$h] = $stub; + } else { + $stub = $resRefs[$h]; + ++$stub->refCount; + $a = null; + } + break; + } + + if ($a) { + if (!$minimumDepthReached || 0 > $maxItems) { + $queue[$len] = $a; + $stub->position = $len++; + } elseif ($pos < $maxItems) { + if ($maxItems < $pos += \count($a)) { + $a = \array_slice($a, 0, $maxItems - $pos, true); + if ($stub->cut >= 0) { + $stub->cut += $pos - $maxItems; + } + } + $queue[$len] = $a; + $stub->position = $len++; + } elseif ($stub->cut >= 0) { + $stub->cut += \count($a); + $stub->position = 0; + } + } + + if ($arrayStub === $stub) { + if ($arrayStub->cut) { + $stub = [$arrayStub->cut, $arrayStub->class => $arrayStub->position]; + $arrayStub->cut = 0; + } elseif (isset(self::$arrayCache[$arrayStub->class][$arrayStub->position])) { + $stub = self::$arrayCache[$arrayStub->class][$arrayStub->position]; + } else { + self::$arrayCache[$arrayStub->class][$arrayStub->position] = $stub = [$arrayStub->class => $arrayStub->position]; + } + } + + if (!$zvalRef) { + $vals[$k] = $stub; + } else { + $hardRefs[$zvalRef]->value = $stub; + } + } + + $queue[$i] = $vals; + } + + return $queue; + } +} diff --git a/vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php b/vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php new file mode 100644 index 0000000..24590fc --- /dev/null +++ b/vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Command\Descriptor; + +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\CliDumper; + +/** + * Describe collected data clones for cli output. + * + * @author Maxime Steinhausser + * + * @final + */ +class CliDescriptor implements DumpDescriptorInterface +{ + private mixed $lastIdentifier = null; + + public function __construct( + private CliDumper $dumper, + ) { + } + + public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void + { + $io = $output instanceof SymfonyStyle ? $output : new SymfonyStyle(new ArrayInput([]), $output); + $this->dumper->setColors($output->isDecorated()); + + $rows = [['date', date('r', (int) $context['timestamp'])]]; + $lastIdentifier = $this->lastIdentifier; + $this->lastIdentifier = $clientId; + + $section = "Received from client #$clientId"; + if (isset($context['request'])) { + $request = $context['request']; + $this->lastIdentifier = $request['identifier']; + $section = \sprintf('%s %s', $request['method'], $request['uri']); + if ($controller = $request['controller']) { + $rows[] = ['controller', rtrim($this->dumper->dump($controller, true), "\n")]; + } + } elseif (isset($context['cli'])) { + $this->lastIdentifier = $context['cli']['identifier']; + $section = '$ '.$context['cli']['command_line']; + } + + if ($this->lastIdentifier !== $lastIdentifier) { + $io->section($section); + } + + if (isset($context['source'])) { + $source = $context['source']; + $sourceInfo = \sprintf('%s on line %d', $source['name'], $source['line']); + if ($fileLink = $source['file_link'] ?? null) { + $sourceInfo = \sprintf('%s', $fileLink, $sourceInfo); + } + $rows[] = ['source', $sourceInfo]; + $file = $source['file_relative'] ?? $source['file']; + $rows[] = ['file', $file]; + } + + $io->table([], $rows); + + $this->dumper->dump($data); + $io->newLine(); + } +} diff --git a/vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php b/vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php new file mode 100644 index 0000000..267d27b --- /dev/null +++ b/vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Command\Descriptor; + +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\VarDumper\Cloner\Data; + +/** + * @author Maxime Steinhausser + */ +interface DumpDescriptorInterface +{ + public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void; +} diff --git a/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php b/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php new file mode 100644 index 0000000..ab9cd4d --- /dev/null +++ b/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Command\Descriptor; + +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\HtmlDumper; + +/** + * Describe collected data clones for html output. + * + * @author Maxime Steinhausser + * + * @final + */ +class HtmlDescriptor implements DumpDescriptorInterface +{ + private bool $initialized = false; + + public function __construct( + private HtmlDumper $dumper, + ) { + } + + public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void + { + if (!$this->initialized) { + $styles = file_get_contents(__DIR__.'/../../Resources/css/htmlDescriptor.css'); + $scripts = file_get_contents(__DIR__.'/../../Resources/js/htmlDescriptor.js'); + $output->writeln(""); + $this->initialized = true; + } + + $title = '-'; + if (isset($context['request'])) { + $request = $context['request']; + $controller = "{$this->dumper->dump($request['controller'], true, ['maxDepth' => 0])}"; + $title = \sprintf('%s
    %s', $request['method'], $uri = $request['uri'], $uri); + $dedupIdentifier = $request['identifier']; + } elseif (isset($context['cli'])) { + $title = '$ '.$context['cli']['command_line']; + $dedupIdentifier = $context['cli']['identifier']; + } else { + $dedupIdentifier = bin2hex(random_bytes(4)); + } + + $sourceDescription = ''; + if (isset($context['source'])) { + $source = $context['source']; + $projectDir = $source['project_dir'] ?? null; + $sourceDescription = \sprintf('%s on line %d', $source['name'], $source['line']); + if (isset($source['file_link'])) { + $sourceDescription = \sprintf('%s', $source['file_link'], $sourceDescription); + } + } + + $isoDate = $this->extractDate($context, 'c'); + $tags = array_filter([ + 'controller' => $controller ?? null, + 'project dir' => $projectDir ?? null, + ]); + + $output->writeln(<< +
    +
    +

    $title

    + +
    + {$this->renderTags($tags)} +
    +
    +

    + $sourceDescription +

    + {$this->dumper->dump($data, true)} +
    + +HTML + ); + } + + private function extractDate(array $context, string $format = 'r'): string + { + return date($format, (int) $context['timestamp']); + } + + private function renderTags(array $tags): string + { + if (!$tags) { + return ''; + } + + $renderedTags = ''; + foreach ($tags as $key => $value) { + $renderedTags .= \sprintf('
  • %s%s
  • ', $key, $value); + } + + return << +
      + $renderedTags +
    + +HTML; + } +} diff --git a/vendor/symfony/var-dumper/Command/ServerDumpCommand.php b/vendor/symfony/var-dumper/Command/ServerDumpCommand.php new file mode 100644 index 0000000..382e2b3 --- /dev/null +++ b/vendor/symfony/var-dumper/Command/ServerDumpCommand.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Command; + +use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Completion\CompletionInput; +use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor; +use Symfony\Component\VarDumper\Command\Descriptor\DumpDescriptorInterface; +use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor; +use Symfony\Component\VarDumper\Dumper\CliDumper; +use Symfony\Component\VarDumper\Dumper\HtmlDumper; +use Symfony\Component\VarDumper\Server\DumpServer; + +/** + * Starts a dump server to collect and output dumps on a single place with multiple formats support. + * + * @author Maxime Steinhausser + * + * @final + */ +#[AsCommand(name: 'server:dump', description: 'Start a dump server that collects and displays dumps in a single place')] +class ServerDumpCommand extends Command +{ + /** @var DumpDescriptorInterface[] */ + private array $descriptors; + + public function __construct( + private DumpServer $server, + array $descriptors = [], + ) { + $this->descriptors = $descriptors + [ + 'cli' => new CliDescriptor(new CliDumper()), + 'html' => new HtmlDescriptor(new HtmlDumper()), + ]; + + parent::__construct(); + } + + protected function configure(): void + { + $this + ->addOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format (%s)', implode(', ', $this->getAvailableFormats())), 'cli') + ->setHelp(<<<'EOF' +%command.name% starts a dump server that collects and displays +dumps in a single place for debugging you application: + + php %command.full_name% + +You can consult dumped data in HTML format in your browser by providing the --format=html option +and redirecting the output to a file: + + php %command.full_name% --format="html" > dump.html + +EOF + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $format = $input->getOption('format'); + + if (!$descriptor = $this->descriptors[$format] ?? null) { + throw new InvalidArgumentException(\sprintf('Unsupported format "%s".', $format)); + } + + $errorIo = $io->getErrorStyle(); + $errorIo->title('Symfony Var Dumper Server'); + + $this->server->start(); + + $errorIo->success(\sprintf('Server listening on %s', $this->server->getHost())); + $errorIo->comment('Quit the server with CONTROL-C.'); + + $this->server->listen(function (Data $data, array $context, int $clientId) use ($descriptor, $io) { + $descriptor->describe($io, $data, $context, $clientId); + }); + + return 0; + } + + public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void + { + if ($input->mustSuggestOptionValuesFor('format')) { + $suggestions->suggestValues($this->getAvailableFormats()); + } + } + + private function getAvailableFormats(): array + { + return array_keys($this->descriptors); + } +} diff --git a/vendor/symfony/var-dumper/Dumper/AbstractDumper.php b/vendor/symfony/var-dumper/Dumper/AbstractDumper.php new file mode 100644 index 0000000..c7a4c8c --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/AbstractDumper.php @@ -0,0 +1,201 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper; + +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Cloner\DumperInterface; + +/** + * Abstract mechanism for dumping a Data object. + * + * @author Nicolas Grekas + */ +abstract class AbstractDumper implements DataDumperInterface, DumperInterface +{ + public const DUMP_LIGHT_ARRAY = 1; + public const DUMP_STRING_LENGTH = 2; + public const DUMP_COMMA_SEPARATOR = 4; + public const DUMP_TRAILING_COMMA = 8; + + /** @var callable|resource|string|null */ + public static $defaultOutput = 'php://output'; + + protected string $line = ''; + /** @var callable|null */ + protected $lineDumper; + /** @var resource|null */ + protected $outputStream; + protected string $decimalPoint = '.'; + protected string $indentPad = ' '; + + private string $charset = ''; + + /** + * @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput + * @param string|null $charset The default character encoding to use for non-UTF8 strings + * @param int $flags A bit field of static::DUMP_* constants to fine tune dumps representation + */ + public function __construct( + $output = null, + ?string $charset = null, + protected int $flags = 0, + ) { + $this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8'); + $this->setOutput($output ?: static::$defaultOutput); + if (!$output && \is_string(static::$defaultOutput)) { + static::$defaultOutput = $this->outputStream; + } + } + + /** + * Sets the output destination of the dumps. + * + * @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path + * + * @return callable|resource|string|null The previous output destination + */ + public function setOutput($output) + { + $prev = $this->outputStream ?? $this->lineDumper; + + if (\is_callable($output)) { + $this->outputStream = null; + $this->lineDumper = $output; + } else { + if (\is_string($output)) { + $output = fopen($output, 'w'); + } + $this->outputStream = $output; + $this->lineDumper = $this->echoLine(...); + } + + return $prev; + } + + /** + * Sets the default character encoding to use for non-UTF8 strings. + * + * @return string The previous charset + */ + public function setCharset(string $charset): string + { + $prev = $this->charset; + + $charset = strtoupper($charset); + $charset = 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset; + + $this->charset = $charset; + + return $prev; + } + + /** + * Sets the indentation pad string. + * + * @param string $pad A string that will be prepended to dumped lines, repeated by nesting level + * + * @return string The previous indent pad + */ + public function setIndentPad(string $pad): string + { + $prev = $this->indentPad; + $this->indentPad = $pad; + + return $prev; + } + + /** + * Dumps a Data object. + * + * @param callable|resource|string|true|null $output A line dumper callable, an opened stream, an output path or true to return the dump + * + * @return string|null The dump as string when $output is true + */ + public function dump(Data $data, $output = null): ?string + { + if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(\LC_NUMERIC, 0) : null) { + setlocale(\LC_NUMERIC, 'C'); + } + + if ($returnDump = true === $output) { + $output = fopen('php://memory', 'r+'); + } + if ($output) { + $prevOutput = $this->setOutput($output); + } + try { + $data->dump($this); + $this->dumpLine(-1); + + if ($returnDump) { + $result = stream_get_contents($output, -1, 0); + fclose($output); + + return $result; + } + } finally { + if ($output) { + $this->setOutput($prevOutput); + } + if ($locale) { + setlocale(\LC_NUMERIC, $locale); + } + } + + return null; + } + + /** + * Dumps the current line. + * + * @param int $depth The recursive depth in the dumped structure for the line being dumped, + * or -1 to signal the end-of-dump to the line dumper callable + */ + protected function dumpLine(int $depth): void + { + ($this->lineDumper)($this->line, $depth, $this->indentPad); + $this->line = ''; + } + + /** + * Generic line dumper callback. + */ + protected function echoLine(string $line, int $depth, string $indentPad): void + { + if (-1 !== $depth) { + fwrite($this->outputStream, str_repeat($indentPad, $depth).$line."\n"); + } + } + + /** + * Converts a non-UTF-8 string to UTF-8. + */ + protected function utf8Encode(?string $s): ?string + { + if (null === $s || preg_match('//u', $s)) { + return $s; + } + + if (!\function_exists('iconv')) { + throw new \RuntimeException('Unable to convert a non-UTF-8 string to UTF-8: required function iconv() does not exist. You should install ext-iconv or symfony/polyfill-iconv.'); + } + + if (false !== $c = @iconv($this->charset, 'UTF-8', $s)) { + return $c; + } + if ('CP1252' !== $this->charset && false !== $c = @iconv('CP1252', 'UTF-8', $s)) { + return $c; + } + + return iconv('CP850', 'UTF-8', $s); + } +} diff --git a/vendor/symfony/var-dumper/Dumper/CliDumper.php b/vendor/symfony/var-dumper/Dumper/CliDumper.php new file mode 100644 index 0000000..c6dd88c --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/CliDumper.php @@ -0,0 +1,667 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper; + +use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; +use Symfony\Component\VarDumper\Cloner\Cursor; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * CliDumper dumps variables for command line output. + * + * @author Nicolas Grekas + */ +class CliDumper extends AbstractDumper +{ + public static bool $defaultColors; + /** @var callable|resource|string|null */ + public static $defaultOutput = 'php://stdout'; + + protected bool $colors; + protected int $maxStringWidth = 0; + protected array $styles = [ + // See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics + 'default' => '0;38;5;208', + 'num' => '1;38;5;38', + 'const' => '1;38;5;208', + 'virtual' => '3', + 'str' => '1;38;5;113', + 'note' => '38;5;38', + 'ref' => '38;5;247', + 'public' => '39', + 'protected' => '39', + 'private' => '39', + 'meta' => '38;5;170', + 'key' => '38;5;113', + 'index' => '38;5;38', + ]; + + protected static string $controlCharsRx = '/[\x00-\x1F\x7F]+/'; + protected static array $controlCharsMap = [ + "\t" => '\t', + "\n" => '\n', + "\v" => '\v', + "\f" => '\f', + "\r" => '\r', + "\033" => '\e', + ]; + protected static string $unicodeCharsRx = "/[\u{00A0}\u{00AD}\u{034F}\u{061C}\u{115F}\u{1160}\u{17B4}\u{17B5}\u{180E}\u{2000}-\u{200F}\u{202F}\u{205F}\u{2060}-\u{2064}\u{206A}-\u{206F}\u{3000}\u{2800}\u{3164}\u{FEFF}\u{FFA0}\u{1D159}\u{1D173}-\u{1D17A}]/u"; + + protected bool $collapseNextHash = false; + protected bool $expandNextHash = false; + + private array $displayOptions = [ + 'fileLinkFormat' => null, + ]; + + private bool $handlesHrefGracefully; + + public function __construct($output = null, ?string $charset = null, int $flags = 0) + { + parent::__construct($output, $charset, $flags); + + if ('\\' === \DIRECTORY_SEPARATOR && !$this->isWindowsTrueColor()) { + // Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI + $this->setStyles([ + 'default' => '31', + 'num' => '1;34', + 'const' => '1;31', + 'str' => '1;32', + 'note' => '34', + 'ref' => '1;30', + 'meta' => '35', + 'key' => '32', + 'index' => '34', + ]); + } + + $this->displayOptions['fileLinkFormat'] = class_exists(FileLinkFormatter::class) ? new FileLinkFormatter() : (\ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l'); + } + + /** + * Enables/disables colored output. + */ + public function setColors(bool $colors): void + { + $this->colors = $colors; + } + + /** + * Sets the maximum number of characters per line for dumped strings. + */ + public function setMaxStringWidth(int $maxStringWidth): void + { + $this->maxStringWidth = $maxStringWidth; + } + + /** + * Configures styles. + * + * @param array $styles A map of style names to style definitions + */ + public function setStyles(array $styles): void + { + $this->styles = $styles + $this->styles; + } + + /** + * Configures display options. + * + * @param array $displayOptions A map of display options to customize the behavior + */ + public function setDisplayOptions(array $displayOptions): void + { + $this->displayOptions = $displayOptions + $this->displayOptions; + } + + public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value): void + { + $this->dumpKey($cursor); + $this->collapseNextHash = $this->expandNextHash = false; + + $style = 'const'; + $attr = $cursor->attr; + + switch ($type) { + case 'default': + $style = 'default'; + break; + + case 'label': + $this->styles += ['label' => $this->styles['default']]; + $style = 'label'; + break; + + case 'integer': + $style = 'num'; + + if (isset($this->styles['integer'])) { + $style = 'integer'; + } + + break; + + case 'double': + $style = 'num'; + + if (isset($this->styles['float'])) { + $style = 'float'; + } + + $value = match (true) { + \INF === $value => 'INF', + -\INF === $value => '-INF', + is_nan($value) => 'NAN', + default => !str_contains($value = (string) $value, $this->decimalPoint) ? $value .= $this->decimalPoint.'0' : $value, + }; + break; + + case 'NULL': + $value = 'null'; + break; + + case 'boolean': + $value = $value ? 'true' : 'false'; + break; + + default: + $attr += ['value' => $this->utf8Encode($value)]; + $value = $this->utf8Encode($type); + break; + } + + $this->line .= $this->style($style, $value, $attr); + + $this->endValue($cursor); + } + + public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut): void + { + $this->dumpKey($cursor); + $this->collapseNextHash = $this->expandNextHash = false; + $attr = $cursor->attr; + + if ($bin) { + $str = $this->utf8Encode($str); + } + if ('' === $str) { + $this->line .= '""'; + if ($cut) { + $this->line .= '…'.$cut; + } + $this->endValue($cursor); + } else { + $attr += [ + 'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0, + 'binary' => $bin, + ]; + $str = $bin && str_contains($str, "\0") ? [$str] : explode("\n", $str); + if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) { + unset($str[1]); + $str[0] .= "\n"; + } + $m = \count($str) - 1; + $i = $lineCut = 0; + + if (self::DUMP_STRING_LENGTH & $this->flags) { + $this->line .= '('.$attr['length'].') '; + } + if ($bin) { + $this->line .= 'b'; + } + + if ($m) { + $this->line .= '"""'; + $this->dumpLine($cursor->depth); + } else { + $this->line .= '"'; + } + + foreach ($str as $str) { + if ($i < $m) { + $str .= "\n"; + } + if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) { + $str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8'); + $lineCut = $len - $this->maxStringWidth; + } + if ($m && 0 < $cursor->depth) { + $this->line .= $this->indentPad; + } + if ('' !== $str) { + $this->line .= $this->style('str', $str, $attr); + } + if ($i++ == $m) { + if ($m) { + if ('' !== $str) { + $this->dumpLine($cursor->depth); + if (0 < $cursor->depth) { + $this->line .= $this->indentPad; + } + } + $this->line .= '"""'; + } else { + $this->line .= '"'; + } + if ($cut < 0) { + $this->line .= '…'; + $lineCut = 0; + } elseif ($cut) { + $lineCut += $cut; + } + } + if ($lineCut) { + $this->line .= '…'.$lineCut; + $lineCut = 0; + } + + if ($i > $m) { + $this->endValue($cursor); + } else { + $this->dumpLine($cursor->depth); + } + } + } + } + + public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild): void + { + $this->colors ??= $this->supportsColors(); + + $this->dumpKey($cursor); + $this->expandNextHash = false; + $attr = $cursor->attr; + + if ($this->collapseNextHash) { + $cursor->skipChildren = true; + $this->collapseNextHash = $hasChild = false; + } + + $class = $this->utf8Encode($class); + if (Cursor::HASH_OBJECT === $type) { + $prefix = $class && 'stdClass' !== $class ? $this->style('note', $class, $attr).(empty($attr['cut_hash']) ? ' {' : '') : '{'; + } elseif (Cursor::HASH_RESOURCE === $type) { + $prefix = $this->style('note', $class.' resource', $attr).($hasChild ? ' {' : ' '); + } else { + $prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '['; + } + + if (($cursor->softRefCount || 0 < $cursor->softRefHandle) && empty($attr['cut_hash'])) { + $prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), ['count' => $cursor->softRefCount]); + } elseif ($cursor->hardRefTo && !$cursor->refIndex && $class) { + $prefix .= $this->style('ref', '&'.$cursor->hardRefTo, ['count' => $cursor->hardRefCount]); + } elseif (!$hasChild && Cursor::HASH_RESOURCE === $type) { + $prefix = substr($prefix, 0, -1); + } + + $this->line .= $prefix; + + if ($hasChild) { + $this->dumpLine($cursor->depth); + } + } + + public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut): void + { + if (empty($cursor->attr['cut_hash'])) { + $this->dumpEllipsis($cursor, $hasChild, $cut); + $this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : '')); + } + + $this->endValue($cursor); + } + + /** + * Dumps an ellipsis for cut children. + * + * @param bool $hasChild When the dump of the hash has child item + * @param int $cut The number of items the hash has been cut by + */ + protected function dumpEllipsis(Cursor $cursor, bool $hasChild, int $cut): void + { + if ($cut) { + $this->line .= ' …'; + if (0 < $cut) { + $this->line .= $cut; + } + if ($hasChild) { + $this->dumpLine($cursor->depth + 1); + } + } + } + + /** + * Dumps a key in a hash structure. + */ + protected function dumpKey(Cursor $cursor): void + { + if (null !== $key = $cursor->hashKey) { + if ($cursor->hashKeyIsBinary) { + $key = $this->utf8Encode($key); + } + $attr = [ + 'binary' => $cursor->hashKeyIsBinary, + 'virtual' => $cursor->attr['virtual'] ?? false, + ]; + $bin = $cursor->hashKeyIsBinary ? 'b' : ''; + $style = 'key'; + switch ($cursor->hashType) { + default: + case Cursor::HASH_INDEXED: + if (self::DUMP_LIGHT_ARRAY & $this->flags) { + break; + } + $style = 'index'; + // no break + case Cursor::HASH_ASSOC: + if (\is_int($key)) { + $this->line .= $this->style($style, $key).' => '; + } else { + $this->line .= $bin.'"'.$this->style($style, $key).'" => '; + } + break; + + case Cursor::HASH_RESOURCE: + $key = "\0~\0".$key; + // no break + case Cursor::HASH_OBJECT: + if (!isset($key[0]) || "\0" !== $key[0]) { + $this->line .= '+'.$bin.$this->style('public', $key, $attr).': '; + } elseif (0 < strpos($key, "\0", 1)) { + $key = explode("\0", substr($key, 1), 2); + + switch ($key[0][0]) { + case '+': // User inserted keys + $attr['dynamic'] = true; + $this->line .= '+'.$bin.'"'.$this->style('public', $key[1], $attr).'": '; + break 2; + case '~': + $style = 'meta'; + if (isset($key[0][1])) { + parse_str(substr($key[0], 1), $attr); + $attr += ['binary' => $cursor->hashKeyIsBinary]; + } + break; + case '*': + $style = 'protected'; + $bin = '#'.$bin; + break; + default: + $attr['class'] = $key[0]; + $style = 'private'; + $bin = '-'.$bin; + break; + } + + if (isset($attr['collapse'])) { + if ($attr['collapse']) { + $this->collapseNextHash = true; + } else { + $this->expandNextHash = true; + } + } + + $this->line .= $bin.$this->style($style, $key[1], $attr).($attr['separator'] ?? ': '); + } else { + // This case should not happen + $this->line .= '-'.$bin.'"'.$this->style('private', $key, ['class' => '']).'": '; + } + break; + } + + if ($cursor->hardRefTo) { + $this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), ['count' => $cursor->hardRefCount]).' '; + } + } + } + + /** + * Decorates a value with some style. + * + * @param string $style The type of style being applied + * @param string $value The value being styled + * @param array $attr Optional context information + */ + protected function style(string $style, string $value, array $attr = []): string + { + $this->colors ??= $this->supportsColors(); + + $this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') + && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100) + && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']); + + if (isset($attr['ellipsis'], $attr['ellipsis-type'])) { + $prefix = substr($value, 0, -$attr['ellipsis']); + if ('cli' === \PHP_SAPI && 'path' === $attr['ellipsis-type'] && isset($_SERVER[$pwd = '\\' === \DIRECTORY_SEPARATOR ? 'CD' : 'PWD']) && str_starts_with($prefix, $_SERVER[$pwd])) { + $prefix = '.'.substr($prefix, \strlen($_SERVER[$pwd])); + } + if (!empty($attr['ellipsis-tail'])) { + $prefix .= substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']); + $value = substr($value, -$attr['ellipsis'] + $attr['ellipsis-tail']); + } else { + $value = substr($value, -$attr['ellipsis']); + } + + $value = $this->style('default', $prefix).$this->style($style, $value); + + goto href; + } + + $map = static::$controlCharsMap; + $startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : ''; + $endCchr = $this->colors ? "\033[m\033[{$this->styles[$style]}m" : ''; + $value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) { + $s = $startCchr; + $c = $c[$i = 0]; + do { + $s .= $map[$c[$i]] ?? \sprintf('\x%02X', \ord($c[$i])); + } while (isset($c[++$i])); + + return $s.$endCchr; + }, $value, -1, $cchrCount); + + if (!($attr['binary'] ?? false)) { + $value = preg_replace_callback(static::$unicodeCharsRx, function ($c) use (&$cchrCount, $startCchr, $endCchr) { + ++$cchrCount; + + return $startCchr.'\u{'.strtoupper(dechex(mb_ord($c[0]))).'}'.$endCchr; + }, $value); + } + + if ($this->colors && '' !== $value) { + if ($cchrCount && "\033" === $value[0]) { + $value = substr($value, \strlen($startCchr)); + } else { + $value = "\033[{$this->styles[$style]}m".$value; + } + if ($cchrCount && str_ends_with($value, $endCchr)) { + $value = substr($value, 0, -\strlen($endCchr)); + } else { + $value .= "\033[{$this->styles['default']}m"; + } + } + + href: + if ($this->colors && $this->handlesHrefGracefully) { + if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) { + if ('note' === $style) { + $value .= "\033]8;;{$href}\033\\^\033]8;;\033\\"; + } else { + $attr['href'] = $href; + } + } + if (isset($attr['href'])) { + if ('label' === $style) { + $value .= '^'; + } + $value = "\033]8;;{$attr['href']}\033\\{$value}\033]8;;\033\\"; + } + } + + if ('label' === $style && '' !== $value) { + $value .= ' '; + } + if ($this->colors && ($attr['virtual'] ?? false)) { + $value = "\033[{$this->styles['virtual']}m".$value; + } + + return $value; + } + + protected function supportsColors(): bool + { + if ($this->outputStream !== static::$defaultOutput) { + return $this->hasColorSupport($this->outputStream); + } + if (isset(static::$defaultColors)) { + return static::$defaultColors; + } + if (isset($_SERVER['argv'][1])) { + $colors = $_SERVER['argv']; + $i = \count($colors); + while (--$i > 0) { + if (isset($colors[$i][5])) { + switch ($colors[$i]) { + case '--ansi': + case '--color': + case '--color=yes': + case '--color=force': + case '--color=always': + case '--colors=always': + return static::$defaultColors = true; + + case '--no-ansi': + case '--color=no': + case '--color=none': + case '--color=never': + case '--colors=never': + return static::$defaultColors = false; + } + } + } + } + + $h = stream_get_meta_data($this->outputStream) + ['wrapper_type' => null]; + $h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'w') : $this->outputStream; + + return static::$defaultColors = $this->hasColorSupport($h); + } + + protected function dumpLine(int $depth, bool $endOfValue = false): void + { + if ($this->colors ??= $this->supportsColors()) { + $this->line = \sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line); + } + parent::dumpLine($depth); + } + + protected function endValue(Cursor $cursor): void + { + if (-1 === $cursor->hashType) { + return; + } + + if (Stub::ARRAY_INDEXED === $cursor->hashType || Stub::ARRAY_ASSOC === $cursor->hashType) { + if (self::DUMP_TRAILING_COMMA & $this->flags && 0 < $cursor->depth) { + $this->line .= ','; + } elseif (self::DUMP_COMMA_SEPARATOR & $this->flags && 1 < $cursor->hashLength - $cursor->hashIndex) { + $this->line .= ','; + } + } + + $this->dumpLine($cursor->depth, true); + } + + /** + * Returns true if the stream supports colorization. + * + * Reference: Composer\XdebugHandler\Process::supportsColor + * https://github.com/composer/xdebug-handler + */ + private function hasColorSupport(mixed $stream): bool + { + if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) { + return false; + } + + // Follow https://no-color.org/ + if ('' !== (($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR'))[0] ?? '')) { + return false; + } + + // Follow https://force-color.org/ + if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) { + return true; + } + + // Detect msysgit/mingw and assume this is a tty because detection + // does not work correctly, see https://github.com/composer/composer/issues/9690 + if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) { + return false; + } + + if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($stream)) { + return true; + } + + if ('Hyper' === getenv('TERM_PROGRAM') + || false !== getenv('COLORTERM') + || false !== getenv('ANSICON') + || 'ON' === getenv('ConEmuANSI') + ) { + return true; + } + + if ('dumb' === $term = (string) getenv('TERM')) { + return false; + } + + // See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157 + return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term); + } + + /** + * Returns true if the Windows terminal supports true color. + * + * Note that this does not check an output stream, but relies on environment + * variables from known implementations, or a PHP and Windows version that + * supports true color. + */ + private function isWindowsTrueColor(): bool + { + $result = 183 <= getenv('ANSICON_VER') + || 'ON' === getenv('ConEmuANSI') + || 'xterm' === getenv('TERM') + || 'Hyper' === getenv('TERM_PROGRAM'); + + if (!$result) { + $version = \sprintf( + '%s.%s.%s', + PHP_WINDOWS_VERSION_MAJOR, + PHP_WINDOWS_VERSION_MINOR, + PHP_WINDOWS_VERSION_BUILD + ); + $result = $version >= '10.0.15063'; + } + + return $result; + } + + private function getSourceLink(string $file, int $line): string|false + { + if ($fmt = $this->displayOptions['fileLinkFormat']) { + return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : ($fmt->format($file, $line) ?: 'file://'.$file.'#L'.$line); + } + + return false; + } +} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php new file mode 100644 index 0000000..38f8789 --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper\ContextProvider; + +/** + * Tries to provide context on CLI. + * + * @author Maxime Steinhausser + */ +final class CliContextProvider implements ContextProviderInterface +{ + public function getContext(): ?array + { + if ('cli' !== \PHP_SAPI) { + return null; + } + + return [ + 'command_line' => $commandLine = implode(' ', $_SERVER['argv'] ?? []), + 'identifier' => hash('crc32b', $commandLine.$_SERVER['REQUEST_TIME_FLOAT']), + ]; + } +} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php new file mode 100644 index 0000000..532aa0f --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper\ContextProvider; + +/** + * Interface to provide contextual data about dump data clones sent to a server. + * + * @author Maxime Steinhausser + */ +interface ContextProviderInterface +{ + public function getContext(): ?array; +} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php new file mode 100644 index 0000000..deef252 --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper\ContextProvider; + +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\VarDumper\Caster\ReflectionCaster; +use Symfony\Component\VarDumper\Cloner\VarCloner; + +/** + * Tries to provide context from a request. + * + * @author Maxime Steinhausser + */ +final class RequestContextProvider implements ContextProviderInterface +{ + private VarCloner $cloner; + + public function __construct( + private RequestStack $requestStack, + ) { + $this->cloner = new VarCloner(); + $this->cloner->setMaxItems(0); + $this->cloner->addCasters(ReflectionCaster::UNSET_CLOSURE_FILE_INFO); + } + + public function getContext(): ?array + { + if (null === $request = $this->requestStack->getCurrentRequest()) { + return null; + } + + $controller = $request->attributes->get('_controller'); + + return [ + 'uri' => $request->getUri(), + 'method' => $request->getMethod(), + 'controller' => $controller ? $this->cloner->cloneVar($controller) : $controller, + 'identifier' => spl_object_hash($request), + ]; + } +} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php new file mode 100644 index 0000000..01e730a --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper\ContextProvider; + +use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; +use Symfony\Component\VarDumper\Cloner\VarCloner; +use Symfony\Component\VarDumper\Dumper\HtmlDumper; +use Symfony\Component\VarDumper\VarDumper; +use Twig\Template; + +/** + * Tries to provide context from sources (class name, file, line, code excerpt, ...). + * + * @author Nicolas Grekas + * @author Maxime Steinhausser + */ +final class SourceContextProvider implements ContextProviderInterface +{ + public function __construct( + private ?string $charset = null, + private ?string $projectDir = null, + private ?FileLinkFormatter $fileLinkFormatter = null, + private int $limit = 9, + ) { + } + + public function getContext(): ?array + { + $trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, $this->limit); + + $file = $trace[1]['file']; + $line = $trace[1]['line']; + $name = '-' === $file || 'Standard input code' === $file ? 'Standard input code' : false; + $fileExcerpt = false; + + for ($i = 2; $i < $this->limit; ++$i) { + if (isset($trace[$i]['class'], $trace[$i]['function']) + && 'dump' === $trace[$i]['function'] + && VarDumper::class === $trace[$i]['class'] + ) { + $file = $trace[$i]['file'] ?? $file; + $line = $trace[$i]['line'] ?? $line; + + while (++$i < $this->limit) { + if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && !str_starts_with($trace[$i]['function'], 'call_user_func')) { + $file = $trace[$i]['file']; + $line = $trace[$i]['line']; + + break; + } elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof Template) { + $template = $trace[$i]['object']; + $name = $template->getTemplateName(); + $src = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : false); + $info = $template->getDebugInfo(); + if (isset($info[$trace[$i - 1]['line']])) { + $line = $info[$trace[$i - 1]['line']]; + $file = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getPath() : null; + + if ($src) { + $src = explode("\n", $src); + $fileExcerpt = []; + + for ($i = max($line - 3, 1), $max = min($line + 3, \count($src)); $i <= $max; ++$i) { + $fileExcerpt[] = ''.$this->htmlEncode($src[$i - 1]).'

  • '; + } + + $fileExcerpt = '
      '.implode("\n", $fileExcerpt).'
    '; + } + } + break; + } + } + break; + } + } + + if (false === $name) { + $name = str_replace('\\', '/', $file); + $name = substr($name, strrpos($name, '/') + 1); + } + + $context = ['name' => $name, 'file' => $file, 'line' => $line]; + $context['file_excerpt'] = $fileExcerpt; + + if (null !== $this->projectDir) { + $context['project_dir'] = $this->projectDir; + if (str_starts_with($file, $this->projectDir)) { + $context['file_relative'] = ltrim(substr($file, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); + } + } + + if ($this->fileLinkFormatter && $fileLink = $this->fileLinkFormatter->format($context['file'], $context['line'])) { + $context['file_link'] = $fileLink; + } + + return $context; + } + + private function htmlEncode(string $s): string + { + $html = ''; + + $dumper = new HtmlDumper(function ($line) use (&$html) { $html .= $line; }, $this->charset); + $dumper->setDumpHeader(''); + $dumper->setDumpBoundaries('', ''); + + $cloner = new VarCloner(); + $dumper->dump($cloner->cloneVar($s)); + + return substr(strip_tags($html), 1, -1); + } +} diff --git a/vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php b/vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php new file mode 100644 index 0000000..6102c47 --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper; + +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface; + +/** + * @author Kévin Thérage + */ +class ContextualizedDumper implements DataDumperInterface +{ + /** + * @param ContextProviderInterface[] $contextProviders + */ + public function __construct( + private DataDumperInterface $wrappedDumper, + private array $contextProviders, + ) { + } + + public function dump(Data $data): ?string + { + $context = $data->getContext(); + foreach ($this->contextProviders as $contextProvider) { + $context[$contextProvider::class] = $contextProvider->getContext(); + } + + return $this->wrappedDumper->dump($data->withContext($context)); + } +} diff --git a/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php b/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php new file mode 100644 index 0000000..df05b6a --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper; + +use Symfony\Component\VarDumper\Cloner\Data; + +/** + * DataDumperInterface for dumping Data objects. + * + * @author Nicolas Grekas + */ +interface DataDumperInterface +{ + /** + * @return string|null + */ + public function dump(Data $data); +} diff --git a/vendor/symfony/var-dumper/Dumper/HtmlDumper.php b/vendor/symfony/var-dumper/Dumper/HtmlDumper.php new file mode 100644 index 0000000..835d6d9 --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/HtmlDumper.php @@ -0,0 +1,980 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper; + +use Symfony\Component\VarDumper\Cloner\Cursor; +use Symfony\Component\VarDumper\Cloner\Data; + +/** + * HtmlDumper dumps variables as HTML. + * + * @author Nicolas Grekas + */ +class HtmlDumper extends CliDumper +{ + /** @var callable|resource|string|null */ + public static $defaultOutput = 'php://output'; + + protected static $themes = [ + 'dark' => [ + 'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', + 'num' => 'font-weight:bold; color:#1299DA', + 'const' => 'font-weight:bold', + 'virtual' => 'font-style:italic', + 'str' => 'font-weight:bold; color:#56DB3A', + 'note' => 'color:#1299DA', + 'ref' => 'color:#A0A0A0', + 'public' => 'color:#FFFFFF', + 'protected' => 'color:#FFFFFF', + 'private' => 'color:#FFFFFF', + 'meta' => 'color:#B729D9', + 'key' => 'color:#56DB3A', + 'index' => 'color:#1299DA', + 'ellipsis' => 'color:#FF8400', + 'ns' => 'user-select:none;', + ], + 'light' => [ + 'default' => 'background:none; color:#CC7832; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', + 'num' => 'font-weight:bold; color:#1299DA', + 'const' => 'font-weight:bold', + 'virtual' => 'font-style:italic', + 'str' => 'font-weight:bold; color:#629755;', + 'note' => 'color:#6897BB', + 'ref' => 'color:#6E6E6E', + 'public' => 'color:#262626', + 'protected' => 'color:#262626', + 'private' => 'color:#262626', + 'meta' => 'color:#B729D9', + 'key' => 'color:#789339', + 'index' => 'color:#1299DA', + 'ellipsis' => 'color:#CC7832', + 'ns' => 'user-select:none;', + ], + ]; + + protected ?string $dumpHeader = null; + protected string $dumpPrefix = '
    ';
    +    protected string $dumpSuffix = '
    '; + protected string $dumpId; + protected bool $colors = true; + protected $headerIsDumped = false; + protected int $lastDepth = -1; + + private array $displayOptions = [ + 'maxDepth' => 1, + 'maxStringLength' => 160, + 'fileLinkFormat' => null, + ]; + private array $extraDisplayOptions = []; + + public function __construct($output = null, ?string $charset = null, int $flags = 0) + { + AbstractDumper::__construct($output, $charset, $flags); + $this->dumpId = 'sf-dump-'.mt_rand(); + $this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); + $this->styles = static::$themes['dark'] ?? self::$themes['dark']; + } + + public function setStyles(array $styles): void + { + $this->headerIsDumped = false; + $this->styles = $styles + $this->styles; + } + + public function setTheme(string $themeName): void + { + if (!isset(static::$themes[$themeName])) { + throw new \InvalidArgumentException(\sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class)); + } + + $this->setStyles(static::$themes[$themeName]); + } + + /** + * Configures display options. + * + * @param array $displayOptions A map of display options to customize the behavior + */ + public function setDisplayOptions(array $displayOptions): void + { + $this->headerIsDumped = false; + $this->displayOptions = $displayOptions + $this->displayOptions; + } + + /** + * Sets an HTML header that will be dumped once in the output stream. + */ + public function setDumpHeader(?string $header): void + { + $this->dumpHeader = $header; + } + + /** + * Sets an HTML prefix and suffix that will encapse every single dump. + */ + public function setDumpBoundaries(string $prefix, string $suffix): void + { + $this->dumpPrefix = $prefix; + $this->dumpSuffix = $suffix; + } + + public function dump(Data $data, $output = null, array $extraDisplayOptions = []): ?string + { + $this->extraDisplayOptions = $extraDisplayOptions; + $result = parent::dump($data, $output); + $this->dumpId = 'sf-dump-'.mt_rand(); + + return $result; + } + + /** + * Dumps the HTML header. + */ + protected function getDumpHeader(): string + { + $this->headerIsDumped = $this->outputStream ?? $this->lineDumper; + + if (null !== $this->dumpHeader) { + return $this->dumpHeader; + } + + $line = str_replace('{$options}', json_encode($this->displayOptions, \JSON_FORCE_OBJECT), <<<'EOHTML' +'.$this->dumpHeader; + } + + public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut): void + { + if ('' === $str && isset($cursor->attr['img-data'], $cursor->attr['content-type'])) { + $this->dumpKey($cursor); + $this->line .= $this->style('default', $cursor->attr['img-size'] ?? '', []); + $this->line .= $cursor->depth >= $this->displayOptions['maxDepth'] ? ' ' : ' '; + $this->endValue($cursor); + $this->line .= $this->indentPad; + $this->line .= \sprintf('', $cursor->attr['content-type'], base64_encode($cursor->attr['img-data'])); + $this->endValue($cursor); + } else { + parent::dumpString($cursor, $str, $bin, $cut); + } + } + + public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild): void + { + if (Cursor::HASH_OBJECT === $type) { + $cursor->attr['depth'] = $cursor->depth; + } + parent::enterHash($cursor, $type, $class, false); + + if ($cursor->skipChildren || $cursor->depth >= $this->displayOptions['maxDepth']) { + $cursor->skipChildren = false; + $eol = ' class=sf-dump-compact>'; + } else { + $this->expandNextHash = false; + $eol = ' class=sf-dump-expanded>'; + } + + if ($hasChild) { + $this->line .= 'dumpId, $r); + } + $this->line .= $eol; + $this->dumpLine($cursor->depth); + } + } + + public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut): void + { + $this->dumpEllipsis($cursor, $hasChild, $cut); + if ($hasChild) { + $this->line .= ''; + } + parent::leaveHash($cursor, $type, $class, $hasChild, 0); + } + + protected function style(string $style, string $value, array $attr = []): string + { + if ('' === $value && ('label' !== $style || !isset($attr['file']) && !isset($attr['href']))) { + return ''; + } + + $v = esc($value); + + if ('ref' === $style) { + if (empty($attr['count'])) { + return \sprintf('%s', $v); + } + $r = ('#' !== $v[0] ? 1 - ('@' !== $v[0]) : 2).substr($value, 1); + + return \sprintf('%s', $this->dumpId, $r, 1 + $attr['count'], $v); + } + + $dumpClasses = ['sf-dump-'.$style]; + $dumpTitle = ''; + + if ('const' === $style && isset($attr['value'])) { + $dumpTitle = esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value'])); + } elseif ('public' === $style) { + $dumpTitle = empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property'; + } elseif ('str' === $style && 1 < $attr['length']) { + $dumpTitle = \sprintf('%d%s characters', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : ''); + } elseif ('note' === $style && 0 < ($attr['depth'] ?? 0) && false !== $c = strrpos($value, '\\')) { + $attr += [ + 'ellipsis' => \strlen($value) - $c, + 'ellipsis-type' => 'note', + 'ellipsis-tail' => 1, + ]; + } elseif ('protected' === $style) { + $dumpTitle = 'Protected property'; + } elseif ('meta' === $style && isset($attr['title'])) { + $dumpTitle = esc($this->utf8Encode($attr['title'])); + } elseif ('private' === $style) { + $dumpTitle = \sprintf('Private property defined in class: `%s`', esc($this->utf8Encode($attr['class']))); + } + + if (isset($attr['ellipsis'])) { + $dumpClasses[] = 'sf-dump-ellipsization'; + $ellipsisClass = 'sf-dump-ellipsis'; + if (isset($attr['ellipsis-type'])) { + $ellipsisClass .= ' sf-dump-ellipsis-'.$attr['ellipsis-type']; + } + $label = esc(substr($value, -$attr['ellipsis'])); + $dumpTitle = $v."\n".$dumpTitle; + $v = \sprintf('%s', $ellipsisClass, substr($v, 0, -\strlen($label))); + + if (!empty($attr['ellipsis-tail'])) { + $tail = \strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']))); + $v .= \sprintf('%s%s', $ellipsisClass, substr($label, 0, $tail), substr($label, $tail)); + } else { + $v .= \sprintf('%s', $label); + } + } + + $map = static::$controlCharsMap; + $v = \sprintf( + '%s', + 1 === \count($dumpClasses) ? '' : '"', + implode(' ', $dumpClasses), + $dumpTitle ? ' title="'.$dumpTitle.'"' : '', + preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) { + $s = $b = ''; + }, $v) + ); + + if (!($attr['binary'] ?? false)) { + $v = preg_replace_callback(static::$unicodeCharsRx, function ($c) { + return '\u{'.strtoupper(dechex(mb_ord($c[0]))).'}'; + }, $v); + } + + if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) { + $attr['href'] = $href; + } + if (isset($attr['href'])) { + if ('label' === $style) { + $v .= '^'; + } + $target = isset($attr['file']) ? '' : ' target="_blank"'; + $v = \sprintf('%s', esc($this->utf8Encode($attr['href'])), $target, $v); + } + if (isset($attr['lang'])) { + $v = \sprintf('%s', esc($attr['lang']), $v); + } + if ('label' === $style) { + $v .= ' '; + } + if ($attr['virtual'] ?? false) { + $v = ''.$v.''; + } + + return $v; + } + + protected function dumpLine(int $depth, bool $endOfValue = false): void + { + if (-1 === $this->lastDepth) { + $this->line = \sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line; + } + if ($this->headerIsDumped !== ($this->outputStream ?? $this->lineDumper)) { + $this->line = $this->getDumpHeader().$this->line; + } + + if (-1 === $depth) { + $args = ['"'.$this->dumpId.'"']; + if ($this->extraDisplayOptions) { + $args[] = json_encode($this->extraDisplayOptions, \JSON_FORCE_OBJECT); + } + // Replace is for BC + $this->line .= \sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args)); + } + $this->lastDepth = $depth; + + $this->line = mb_encode_numericentity($this->line, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8'); + + if (-1 === $depth) { + AbstractDumper::dumpLine(0); + } + AbstractDumper::dumpLine($depth); + } + + private function getSourceLink(string $file, int $line): string|false + { + $options = $this->extraDisplayOptions + $this->displayOptions; + + if ($fmt = $options['fileLinkFormat']) { + return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); + } + + return false; + } +} + +function esc(string $str): string +{ + return htmlspecialchars($str, \ENT_QUOTES, 'UTF-8'); +} diff --git a/vendor/symfony/var-dumper/Dumper/ServerDumper.php b/vendor/symfony/var-dumper/Dumper/ServerDumper.php new file mode 100644 index 0000000..4602bcf --- /dev/null +++ b/vendor/symfony/var-dumper/Dumper/ServerDumper.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Dumper; + +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface; +use Symfony\Component\VarDumper\Server\Connection; + +/** + * ServerDumper forwards serialized Data clones to a server. + * + * @author Maxime Steinhausser + */ +class ServerDumper implements DataDumperInterface +{ + private Connection $connection; + + /** + * @param string $host The server host + * @param DataDumperInterface|null $wrappedDumper A wrapped instance used whenever we failed contacting the server + * @param ContextProviderInterface[] $contextProviders Context providers indexed by context name + */ + public function __construct( + string $host, + private ?DataDumperInterface $wrappedDumper = null, + array $contextProviders = [], + ) { + $this->connection = new Connection($host, $contextProviders); + } + + public function getContextProviders(): array + { + return $this->connection->getContextProviders(); + } + + public function dump(Data $data): ?string + { + if (!$this->connection->write($data) && $this->wrappedDumper) { + return $this->wrappedDumper->dump($data); + } + + return null; + } +} diff --git a/vendor/symfony/var-dumper/Exception/ThrowingCasterException.php b/vendor/symfony/var-dumper/Exception/ThrowingCasterException.php new file mode 100644 index 0000000..fd8eca9 --- /dev/null +++ b/vendor/symfony/var-dumper/Exception/ThrowingCasterException.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Exception; + +/** + * @author Nicolas Grekas + */ +class ThrowingCasterException extends \Exception +{ + /** + * @param \Throwable $prev The exception thrown from the caster + */ + public function __construct(\Throwable $prev) + { + parent::__construct('Unexpected '.$prev::class.' thrown from a caster: '.$prev->getMessage(), 0, $prev); + } +} diff --git a/vendor/symfony/var-dumper/LICENSE b/vendor/symfony/var-dumper/LICENSE new file mode 100644 index 0000000..29f72d5 --- /dev/null +++ b/vendor/symfony/var-dumper/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014-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/vendor/symfony/var-dumper/README.md b/vendor/symfony/var-dumper/README.md new file mode 100644 index 0000000..a0da8c9 --- /dev/null +++ b/vendor/symfony/var-dumper/README.md @@ -0,0 +1,15 @@ +VarDumper Component +=================== + +The VarDumper component provides mechanisms for walking through any arbitrary +PHP variable. It provides a better `dump()` function that you can use instead +of `var_dump()`. + +Resources +--------- + + * [Documentation](https://symfony.com/doc/current/components/var_dumper/introduction.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/vendor/symfony/var-dumper/Resources/bin/var-dump-server b/vendor/symfony/var-dumper/Resources/bin/var-dump-server new file mode 100644 index 0000000..f398fce --- /dev/null +++ b/vendor/symfony/var-dumper/Resources/bin/var-dump-server @@ -0,0 +1,67 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if ('cli' !== PHP_SAPI) { + throw new Exception('This script must be run from the command line.'); +} + +/** + * Starts a dump server to collect and output dumps on a single place with multiple formats support. + * + * @author Maxime Steinhausser + */ + +use Psr\Log\LoggerInterface; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Logger\ConsoleLogger; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\VarDumper\Command\ServerDumpCommand; +use Symfony\Component\VarDumper\Server\DumpServer; + +function includeIfExists(string $file): bool +{ + return file_exists($file) && include $file; +} + +if ( + !includeIfExists(__DIR__ . '/../../../../autoload.php') && + !includeIfExists(__DIR__ . '/../../vendor/autoload.php') && + !includeIfExists(__DIR__ . '/../../../../../../vendor/autoload.php') +) { + fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL); + exit(1); +} + +if (!class_exists(Application::class)) { + fwrite(STDERR, 'You need the "symfony/console" component in order to run the VarDumper server.'.PHP_EOL); + exit(1); +} + +$input = new ArgvInput(); +$output = new ConsoleOutput(); +$defaultHost = '127.0.0.1:9912'; +$host = $input->getParameterOption(['--host'], $_SERVER['VAR_DUMPER_SERVER'] ?? $defaultHost, true); +$logger = interface_exists(LoggerInterface::class) ? new ConsoleLogger($output->getErrorOutput()) : null; + +$app = new Application(); + +$app->getDefinition()->addOption( + new InputOption('--host', null, InputOption::VALUE_REQUIRED, 'The address the server should listen to', $defaultHost) +); + +$app->add($command = new ServerDumpCommand(new DumpServer($host, $logger))) + ->getApplication() + ->setDefaultCommand($command->getName(), true) + ->run($input, $output) +; diff --git a/vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css b/vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css new file mode 100644 index 0000000..8f706d6 --- /dev/null +++ b/vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css @@ -0,0 +1,130 @@ +body { + display: flex; + flex-direction: column-reverse; + justify-content: flex-end; + max-width: 1140px; + margin: auto; + padding: 15px; + word-wrap: break-word; + background-color: #F9F9F9; + color: #222; + font-family: Helvetica, Arial, sans-serif; + font-size: 14px; + line-height: 1.4; +} +p { + margin: 0; +} +a { + color: #218BC3; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +.text-small { + font-size: 12px !important; +} +article { + margin: 5px; + margin-bottom: 10px; +} +article > header > .row { + display: flex; + flex-direction: row; + align-items: baseline; + margin-bottom: 10px; +} +article > header > .row > .col { + flex: 1; + display: flex; + align-items: baseline; +} +article > header > .row > h2 { + font-size: 14px; + color: #222; + font-weight: normal; + font-family: "Lucida Console", monospace, sans-serif; + word-break: break-all; + margin: 20px 5px 0 0; + user-select: all; +} +article > header > .row > h2 > code { + white-space: nowrap; + user-select: none; + color: #cc2255; + background-color: #f7f7f9; + border: 1px solid #e1e1e8; + border-radius: 3px; + margin-right: 5px; + padding: 0 3px; +} +article > header > .row > time.col { + flex: 0; + text-align: right; + white-space: nowrap; + color: #999; + font-style: italic; +} +article > header ul.tags { + list-style: none; + padding: 0; + margin: 0; + font-size: 12px; +} +article > header ul.tags > li { + user-select: all; + margin-bottom: 2px; +} +article > header ul.tags > li > span.badge { + display: inline-block; + padding: .25em .4em; + margin-right: 5px; + border-radius: 4px; + background-color: #6c757d3b; + color: #524d4d; + font-size: 12px; + text-align: center; + font-weight: 700; + line-height: 1; + white-space: nowrap; + vertical-align: baseline; + user-select: none; +} +article > section.body { + border: 1px solid #d8d8d8; + background: #FFF; + padding: 10px; + border-radius: 3px; +} +pre.sf-dump { + border-radius: 3px; + margin-bottom: 0; +} +.hidden { + display: none !important; +} +.dumped-tag > .sf-dump { + display: inline-block; + margin: 0; + padding: 1px 5px; + line-height: 1.4; + vertical-align: top; + background-color: transparent; + user-select: auto; +} +.dumped-tag > pre.sf-dump, +.dumped-tag > .sf-dump-default { + color: #CC7832; + background: none; +} +.dumped-tag > .sf-dump .sf-dump-str { color: #629755; } +.dumped-tag > .sf-dump .sf-dump-private, +.dumped-tag > .sf-dump .sf-dump-protected, +.dumped-tag > .sf-dump .sf-dump-public { color: #262626; } +.dumped-tag > .sf-dump .sf-dump-note { color: #6897BB; } +.dumped-tag > .sf-dump .sf-dump-key { color: #789339; } +.dumped-tag > .sf-dump .sf-dump-ref { color: #6E6E6E; } +.dumped-tag > .sf-dump .sf-dump-ellipsis { color: #CC7832; max-width: 100em; } +.dumped-tag > .sf-dump .sf-dump-ellipsis-path { max-width: 5em; } +.dumped-tag > .sf-dump .sf-dump-ns { user-select: none; } diff --git a/vendor/symfony/var-dumper/Resources/functions/dump.php b/vendor/symfony/var-dumper/Resources/functions/dump.php new file mode 100644 index 0000000..c991551 --- /dev/null +++ b/vendor/symfony/var-dumper/Resources/functions/dump.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\VarDumper\Caster\ScalarStub; +use Symfony\Component\VarDumper\VarDumper; + +if (!function_exists('dump')) { + /** + * @author Nicolas Grekas + * @author Alexandre Daubois + */ + function dump(mixed ...$vars): mixed + { + if (!$vars) { + VarDumper::dump(new ScalarStub('🐛')); + + return null; + } + + if (array_key_exists(0, $vars) && 1 === count($vars)) { + VarDumper::dump($vars[0]); + $k = 0; + } else { + foreach ($vars as $k => $v) { + VarDumper::dump($v, is_int($k) ? 1 + $k : $k); + } + } + + if (1 < count($vars)) { + return $vars; + } + + return $vars[$k]; + } +} + +if (!function_exists('dd')) { + function dd(mixed ...$vars): never + { + if (!in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) && !headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + + if (!$vars) { + VarDumper::dump(new ScalarStub('🐛')); + + exit(1); + } + + if (array_key_exists(0, $vars) && 1 === count($vars)) { + VarDumper::dump($vars[0]); + } else { + foreach ($vars as $k => $v) { + VarDumper::dump($v, is_int($k) ? 1 + $k : $k); + } + } + + exit(1); + } +} diff --git a/vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js b/vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js new file mode 100644 index 0000000..63101e5 --- /dev/null +++ b/vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js @@ -0,0 +1,10 @@ +document.addEventListener('DOMContentLoaded', function() { + let prev = null; + Array.from(document.getElementsByTagName('article')).reverse().forEach(function (article) { + const dedupId = article.dataset.dedupId; + if (dedupId === prev) { + article.getElementsByTagName('header')[0].classList.add('hidden'); + } + prev = dedupId; + }); +}); diff --git a/vendor/symfony/var-dumper/Server/Connection.php b/vendor/symfony/var-dumper/Server/Connection.php new file mode 100644 index 0000000..2f1cc1b --- /dev/null +++ b/vendor/symfony/var-dumper/Server/Connection.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Server; + +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface; + +/** + * Forwards serialized Data clones to a server. + * + * @author Maxime Steinhausser + */ +class Connection +{ + private string $host; + + /** + * @var resource|null + */ + private $socket; + + /** + * @param string $host The server host + * @param ContextProviderInterface[] $contextProviders Context providers indexed by context name + */ + public function __construct( + string $host, + private array $contextProviders = [], + ) { + if (!str_contains($host, '://')) { + $host = 'tcp://'.$host; + } + + $this->host = $host; + } + + public function getContextProviders(): array + { + return $this->contextProviders; + } + + public function write(Data $data): bool + { + $socketIsFresh = !$this->socket; + if (!$this->socket = $this->socket ?: $this->createSocket()) { + return false; + } + + $context = ['timestamp' => microtime(true)]; + foreach ($this->contextProviders as $name => $provider) { + $context[$name] = $provider->getContext(); + } + $context = array_filter($context); + $encodedPayload = base64_encode(serialize([$data, $context]))."\n"; + + set_error_handler(static fn () => null); + try { + if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { + return true; + } + if (!$socketIsFresh) { + stream_socket_shutdown($this->socket, \STREAM_SHUT_RDWR); + fclose($this->socket); + $this->socket = $this->createSocket(); + } + if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { + return true; + } + } finally { + restore_error_handler(); + } + + return false; + } + + /** + * @return resource|null + */ + private function createSocket() + { + set_error_handler(static fn () => null); + try { + return stream_socket_client($this->host, $errno, $errstr, 3) ?: null; + } finally { + restore_error_handler(); + } + } +} diff --git a/vendor/symfony/var-dumper/Server/DumpServer.php b/vendor/symfony/var-dumper/Server/DumpServer.php new file mode 100644 index 0000000..149c3c4 --- /dev/null +++ b/vendor/symfony/var-dumper/Server/DumpServer.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Server; + +use Psr\Log\LoggerInterface; +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Cloner\Stub; + +/** + * A server collecting Data clones sent by a ServerDumper. + * + * @author Maxime Steinhausser + * + * @final + */ +class DumpServer +{ + private string $host; + + /** + * @var resource|null + */ + private $socket; + + public function __construct( + string $host, + private ?LoggerInterface $logger = null, + ) { + if (!str_contains($host, '://')) { + $host = 'tcp://'.$host; + } + + $this->host = $host; + } + + public function start(): void + { + if (!$this->socket = stream_socket_server($this->host, $errno, $errstr)) { + throw new \RuntimeException(\sprintf('Server start failed on "%s": ', $this->host).$errstr.' '.$errno); + } + } + + public function listen(callable $callback): void + { + if (null === $this->socket) { + $this->start(); + } + + foreach ($this->getMessages() as $clientId => $message) { + $this->logger?->info('Received a payload from client {clientId}', ['clientId' => $clientId]); + + $payload = @unserialize(base64_decode($message), ['allowed_classes' => [Data::class, Stub::class]]); + + // Impossible to decode the message, give up. + if (false === $payload) { + $this->logger?->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]); + + continue; + } + + if (!\is_array($payload) || \count($payload) < 2 || !$payload[0] instanceof Data || !\is_array($payload[1])) { + $this->logger?->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]); + + continue; + } + + [$data, $context] = $payload; + + $callback($data, $context, $clientId); + } + } + + public function getHost(): string + { + return $this->host; + } + + private function getMessages(): iterable + { + $sockets = [(int) $this->socket => $this->socket]; + $write = []; + + while (true) { + $read = $sockets; + stream_select($read, $write, $write, null); + + foreach ($read as $stream) { + if ($this->socket === $stream) { + $stream = stream_socket_accept($this->socket); + $sockets[(int) $stream] = $stream; + } elseif (feof($stream)) { + unset($sockets[(int) $stream]); + fclose($stream); + } else { + yield (int) $stream => fgets($stream); + } + } + } + } +} diff --git a/vendor/symfony/var-dumper/Test/VarDumperTestTrait.php b/vendor/symfony/var-dumper/Test/VarDumperTestTrait.php new file mode 100644 index 0000000..e29121a --- /dev/null +++ b/vendor/symfony/var-dumper/Test/VarDumperTestTrait.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Test; + +use Symfony\Component\VarDumper\Cloner\VarCloner; +use Symfony\Component\VarDumper\Dumper\CliDumper; + +/** + * @author Nicolas Grekas + */ +trait VarDumperTestTrait +{ + /** + * @internal + */ + private array $varDumperConfig = [ + 'casters' => [], + 'flags' => null, + ]; + + /** + * @param array $casters + */ + protected function setUpVarDumper(array $casters, ?int $flags = null): void + { + $this->varDumperConfig['casters'] = $casters; + $this->varDumperConfig['flags'] = $flags; + } + + /** + * @after + */ + protected function tearDownVarDumper(): void + { + $this->varDumperConfig['casters'] = []; + $this->varDumperConfig['flags'] = null; + } + + public function assertDumpEquals(mixed $expected, mixed $data, int $filter = 0, string $message = '') + { + $this->assertSame($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); + } + + public function assertDumpMatchesFormat(mixed $expected, mixed $data, int $filter = 0, string $message = '') + { + $this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); + } + + protected function getDump(mixed $data, string|int|null $key = null, int $filter = 0): ?string + { + if (null === $flags = $this->varDumperConfig['flags']) { + $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0; + $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0; + $flags |= getenv('DUMP_COMMA_SEPARATOR') ? CliDumper::DUMP_COMMA_SEPARATOR : 0; + } + + $cloner = new VarCloner(); + $cloner->addCasters($this->varDumperConfig['casters']); + $cloner->setMaxItems(-1); + $dumper = new CliDumper(null, null, $flags); + $dumper->setColors(false); + $data = $cloner->cloneVar($data, $filter)->withRefHandles(false); + if (null !== $key && null === $data = $data->seek($key)) { + return null; + } + + return rtrim($dumper->dump($data, true)); + } + + private function prepareExpectation(mixed $expected, int $filter): string + { + if (!\is_string($expected)) { + $expected = $this->getDump($expected, null, $filter); + } + + return rtrim($expected); + } +} diff --git a/vendor/symfony/var-dumper/VarDumper.php b/vendor/symfony/var-dumper/VarDumper.php new file mode 100644 index 0000000..423ffed --- /dev/null +++ b/vendor/symfony/var-dumper/VarDumper.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper; + +use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\VarDumper\Caster\ReflectionCaster; +use Symfony\Component\VarDumper\Cloner\VarCloner; +use Symfony\Component\VarDumper\Dumper\CliDumper; +use Symfony\Component\VarDumper\Dumper\ContextProvider\CliContextProvider; +use Symfony\Component\VarDumper\Dumper\ContextProvider\RequestContextProvider; +use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider; +use Symfony\Component\VarDumper\Dumper\ContextualizedDumper; +use Symfony\Component\VarDumper\Dumper\HtmlDumper; +use Symfony\Component\VarDumper\Dumper\ServerDumper; + +// Load the global dump() function +require_once __DIR__.'/Resources/functions/dump.php'; + +/** + * @author Nicolas Grekas + */ +class VarDumper +{ + /** + * @var callable|null + */ + private static $handler; + + public static function dump(mixed $var, ?string $label = null): mixed + { + if (null === self::$handler) { + self::register(); + } + + return (self::$handler)($var, $label); + } + + public static function setHandler(?callable $callable): ?callable + { + $prevHandler = self::$handler; + + // Prevent replacing the handler with expected format as soon as the env var was set: + if (isset($_SERVER['VAR_DUMPER_FORMAT'])) { + return $prevHandler; + } + + self::$handler = $callable; + + return $prevHandler; + } + + private static function register(): void + { + $cloner = new VarCloner(); + $cloner->addCasters(ReflectionCaster::UNSET_CLOSURE_FILE_INFO); + + $format = $_SERVER['VAR_DUMPER_FORMAT'] ?? null; + switch (true) { + case 'html' === $format: + $dumper = new HtmlDumper(); + break; + case 'cli' === $format: + $dumper = new CliDumper(); + break; + case 'server' === $format: + case $format && 'tcp' === parse_url($format, \PHP_URL_SCHEME): + $host = 'server' === $format ? $_SERVER['VAR_DUMPER_SERVER'] ?? '127.0.0.1:9912' : $format; + $dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? new CliDumper() : new HtmlDumper(); + $dumper = new ServerDumper($host, $dumper, self::getDefaultContextProviders()); + break; + default: + $dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? new CliDumper() : new HtmlDumper(); + } + + if (!$dumper instanceof ServerDumper) { + $dumper = new ContextualizedDumper($dumper, [new SourceContextProvider()]); + } + + self::$handler = function ($var, ?string $label = null) use ($cloner, $dumper) { + $var = $cloner->cloneVar($var); + + if (null !== $label) { + $var = $var->withContext(['label' => $label]); + } + + $dumper->dump($var); + }; + } + + private static function getDefaultContextProviders(): array + { + $contextProviders = []; + + if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) && class_exists(Request::class)) { + $requestStack = new RequestStack(); + $requestStack->push(Request::createFromGlobals()); + $contextProviders['request'] = new RequestContextProvider($requestStack); + } + + $fileLinkFormatter = class_exists(FileLinkFormatter::class) ? new FileLinkFormatter(null, $requestStack ?? null) : null; + + return $contextProviders + [ + 'cli' => new CliContextProvider(), + 'source' => new SourceContextProvider(null, null, $fileLinkFormatter), + ]; + } +} diff --git a/vendor/symfony/var-dumper/composer.json b/vendor/symfony/var-dumper/composer.json new file mode 100644 index 0000000..ed312c5 --- /dev/null +++ b/vendor/symfony/var-dumper/composer.json @@ -0,0 +1,45 @@ +{ + "name": "symfony/var-dumper", + "type": "library", + "description": "Provides mechanisms for walking through any arbitrary PHP variable", + "keywords": ["dump", "debug"], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/uid": "^6.4|^7.0", + "twig/twig": "^3.12" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "autoload": { + "files": [ "Resources/functions/dump.php" ], + "psr-4": { "Symfony\\Component\\VarDumper\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "bin": [ + "Resources/bin/var-dump-server" + ], + "minimum-stability": "dev" +} diff --git a/vendor/topthink/framework/.github/ISSUE_TEMPLATE/1-bug-report.yml b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/1-bug-report.yml new file mode 100644 index 0000000..761d348 --- /dev/null +++ b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/1-bug-report.yml @@ -0,0 +1,67 @@ +name: Bug 反馈 +description: 反馈您所遇到的问题,以帮助我们更好的改进 +labels: ["bug"] +body: + - type: dropdown + id: addon + attributes: + label: 所属功能组件 + options: + - 路由(Route) + - 控制器(Controller) + - 中间件(Middleware) + - 容器(Container) + - 服务(Service) + - 门面(Facade) + - 事件(Event) + - 请求(Request) + - 缓存(Cache) + - 响应(Response) + - 视图(View) + - 异常(Exception) + - 日志(Log) + - 验证器(Validate) + - 多语言(Lang) + - Session/Cookie + - 文件系统(Filesystem) + - 命令行(Command) + - 其它 + description: | + * 模型(Model)和数据库(Db)功能请前往 https://github.com/top-think/think-orm/issues 反馈 + * 多应用(MultiApp)功能请前往 https://github.com/top-think/think-multi-app/issues 反馈 + validations: + required: true + - type: input + id: version + attributes: + label: ThinkPHP 版本 + description: 您所使用的 ThinkPHP 版本是? + placeholder: 如:8.0.3 + validations: + required: true + - type: input + id: system + attributes: + label: 操作系统 + description: 您代码在什么系统上运行? + placeholder: 如:Windows、Centos、Ubuntu、Debian + validations: + required: true + - type: textarea + attributes: + label: 错误信息 + description: 如果有报错信息,请附上相关错误信息或截图。如:错误提示语、出错文件路径、出错行号和 Traces 等信息 + placeholder: | + 信息:控制器不存在 + 路径:vendor/topthink/framework/src/think/App.php + 行号:313 + Traces: + ...... + validations: + required: false + - type: textarea + attributes: + label: 其它说明 + description: 如您还有其它需要补充,可在此输入。 + validations: + required: false \ No newline at end of file diff --git a/vendor/topthink/framework/.github/ISSUE_TEMPLATE/2-feature_request.md b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/2-feature_request.md new file mode 100644 index 0000000..884a4cf --- /dev/null +++ b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/2-feature_request.md @@ -0,0 +1,20 @@ +--- +name: 功能请求 +about: 您对 ThinkPHP 有什么改进的想法或建议,可在此提出。 +title: '' +labels: 'enhancement' +assignees: '' + +--- + +**您的功能请求与问题相关吗?** +[是的话请在此描述] + +**描述您想要的解决方案** +[有的话请在此描述] + +**描述您考虑过的替代方案** +[有的话请在此描述] + +**其它信息** +[其它相关信息或截图] diff --git a/vendor/topthink/framework/.github/ISSUE_TEMPLATE/3-custom.md b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/3-custom.md new file mode 100644 index 0000000..7aff0b7 --- /dev/null +++ b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/3-custom.md @@ -0,0 +1,10 @@ +--- +name: 其它问题 +about: 其它问题可在此反馈 +title: '' +labels: 'question' +assignees: '' + +--- + + diff --git a/vendor/topthink/framework/.github/ISSUE_TEMPLATE/config.yml b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..a6532da --- /dev/null +++ b/vendor/topthink/framework/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: ThinkPHP 完全开发手册 + url: https://doc.thinkphp.cn/ + about: 在创建 Issue 之前,请仔细查阅开发手册,以便对其有更深入的了解,和更好地分析问题。 + - name: ThinkPHP 轻社区 + url: https://q.thinkphp.cn/ + about: 欢迎来到ThinkPHP轻社区和大家一起交流。 diff --git a/vendor/topthink/framework/.github/workflows/build.yml b/vendor/topthink/framework/.github/workflows/build.yml new file mode 100644 index 0000000..e69028e --- /dev/null +++ b/vendor/topthink/framework/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: build + +on: + push: + branches: + - "8.x" + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + tests: + runs-on: ubuntu-22.04 + + strategy: + fail-fast: true + matrix: + php: [8.0, 8.1, 8.2, 8.3, 8.4] + + name: PHP ${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 10 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: xdebug + + - name: Install dependencies + uses: nick-fields/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --prefer-dist --no-interaction --prefer-stable --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml + + - name: Upload Scrutinizer coverage + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" diff --git a/vendor/topthink/framework/.github/workflows/php-cs-fixer.yml b/vendor/topthink/framework/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..4bb205e --- /dev/null +++ b/vendor/topthink/framework/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,31 @@ +name: PHP CS Fixer + +on: + pull_request: + branches: + - "8.x" + paths: + - '**.php' + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 10 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + tools: cs2pr,php-cs-fixer + + - name: Run PHP CS Fixer + run: | + changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- '*.php') + for file in $changed_files; do + php-cs-fixer fix "$file" --dry-run --diff --rules=@PER-CS2.0 --format=checkstyle | cs2pr + done \ No newline at end of file diff --git a/vendor/topthink/framework/CONTRIBUTING.md b/vendor/topthink/framework/CONTRIBUTING.md new file mode 100644 index 0000000..03466d7 --- /dev/null +++ b/vendor/topthink/framework/CONTRIBUTING.md @@ -0,0 +1,119 @@ +如何贡献我的源代码 +=== + +此文档介绍了 ThinkPHP 团队的组成以及运转机制,您提交的代码将给 ThinkPHP 项目带来什么好处,以及如何才能加入我们的行列。 + +## 通过 Github 贡献代码 + +ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 + +参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请并。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 + +我们希望你贡献的代码符合: + +* ThinkPHP 的编码规范 +* 适当的注释,能让其他人读懂 +* 遵循 Apache2 开源协议 + +**如果想要了解更多细节或有任何疑问,请继续阅读下面的内容** + +### 注意事项 + +* 本项目代码格式化标准选用 [**PER-CS2.0**](https://cs.symfony.com/doc/ruleSets/PER-CS2.0.html); +* 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); +* 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。 +* 系统会自动在 PHP 8.0 ~ 8.3 版本上测试修改,请确保你的修改符合 PHP 版本的语法规范; +* 管理员不会合并造成 CI Failed 的修改,若出现 CI Failed 请检查自己的源代码或修改相应的[单元测试文件](tests); + +## GitHub Issue + +GitHub 提供了 Issue 功能,该功能可以用于: + +* 提出 bug +* 提出功能改进 +* 反馈使用体验 + +该功能不应该用于: + + * 提出修改意见(涉及代码署名和修订追溯问题) + * 不友善的言论 + +## 快速修改 + +**GitHub 提供了快速编辑文件的功能** + +1. 登录 GitHub 帐号; +2. 浏览项目文件,找到要进行修改的文件; +3. 点击右上角铅笔图标进行修改; +4. 填写 `Commit changes` 相关内容(Title 必填); +5. 提交修改,等待 CI 验证和管理员合并。 + +**若您需要一次提交大量修改,请继续阅读下面的内容** + +## 完整流程 + +1. `fork`本项目; +2. 克隆(`clone`)你 `fork` 的项目到本地; +3. 新建分支(`branch`)并检出(`checkout`)新分支; +4. 添加本项目到你的本地 git 仓库作为上游(`upstream`); +5. 进行修改,若你的修改包含方法或函数的增减,请记得修改[单元测试文件](tests); +6. 变基(衍合 `rebase`)你的分支到上游 master 分支; +7. `push` 你的本地仓库到 GitHub; +8. 提交 `pull request`; +9. 等待 CI 验证(若不通过则重复 5~7,GitHub 会自动更新你的 `pull request`); +10. 等待管理员处理,并及时 `rebase` 你的分支到上游 master 分支(若上游 master 分支有修改)。 + +*若有必要,可以 `git push -f` 强行推送 rebase 后的分支到自己的 `fork`* + +*绝对不可以使用 `git push -f` 强行推送修改到上游* + +### 注意事项 + +* 若对上述流程有任何不清楚的地方,请查阅 GIT 教程,如 [这个](http://backlogtool.com/git-guide/cn/); +* 对于代码**不同方面**的修改,请在自己 `fork` 的项目中**创建不同的分支**(原因参见`完整流程`第9条备注部分); +* 变基及交互式变基操作参见 [Git 交互式变基](http://pakchoi.me/2015/03/17/git-interactive-rebase/) + +## 推荐资源 + +### 开发环境 + +* [XAMPP](https://www.apachefriends.org/zh_cn/download.html) - Windows、Linux、Mac OS +* [WampServer](https://www.apachefriends.org/zh_cn/download.html) - Windows +* Docker - Windows、Linux、Mac OS + +或自行安装 + +- Apache / Nginx +- PHP 8.0 ~ 8.3 +- MySQL / MariaDB + +*Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer* + +*Linux 用户自行配置环境, Mac 用户推荐使用内置 Apache 配合 Homebrew 安装 PHP 和 MariaDB* + +### 编辑器 + +Sublime Text 3 + phpfmt 插件 + +phpfmt 插件参数 + +```json +{ + "autocomplete": true, + "enable_auto_align": true, + "format_on_save": true, + "indent_with_space": true, + "psr1_naming": false, + "psr2": true, + "version": 4 +} +``` + +或其他 编辑器 / IDE 配合自动格式化工具 + +### Git GUI + +* SourceTree +* GitHub Desktop + +或其他 Git 图形界面客户端 diff --git a/vendor/topthink/framework/LICENSE.txt b/vendor/topthink/framework/LICENSE.txt new file mode 100644 index 0000000..3dcd79f --- /dev/null +++ b/vendor/topthink/framework/LICENSE.txt @@ -0,0 +1,32 @@ + +ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 +版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) +All rights reserved。 +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +Apache Licence是著名的非盈利开源组织Apache采用的协议。 +该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, +允许代码修改,再作为开源或商业软件发布。需要满足 +的条件: +1. 需要给代码的用户一份Apache Licence ; +2. 如果你修改了代码,需要在被修改的文件中说明; +3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 +带有原来代码中的协议,商标,专利声明和其他原来作者规 +定需要包含的说明; +4. 如果再发布的产品中包含一个Notice文件,则在Notice文 +件中需要带有本协议内容。你可以在Notice中增加自己的 +许可,但不可以表现为对Apache Licence构成更改。 +具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/topthink/framework/README.md b/vendor/topthink/framework/README.md new file mode 100644 index 0000000..e0a4070 --- /dev/null +++ b/vendor/topthink/framework/README.md @@ -0,0 +1,85 @@ +![](https://www.thinkphp.cn/uploads/images/20230630/300c856765af4d8ae758c503185f8739.png) + +# ThinkPHP 8 + +[![build](https://github.com/top-think/framework/actions/workflows/build.yml/badge.svg?branch=8.0)](https://github.com/top-think/framework/actions) +[![Total Downloads](https://poser.pugx.org/topthink/framework/downloads)](https://packagist.org/packages/topthink/framework) +[![Latest Stable Version](https://poser.pugx.org/topthink/framework/v/stable)](https://packagist.org/packages/topthink/framework) +[![PHP Version](https://img.shields.io/badge/php-%3E%3D8.0-8892BF.svg)](http://www.php.net/) +[![License](https://poser.pugx.org/topthink/framework/license)](https://packagist.org/packages/topthink/framework) + +## 主要特性 + +- 基于 PHP`8.0+`重构 +- 升级`PSR`依赖 +- 依赖`think-orm`3.0+ 版本 +- 全新的`think-dumper`支持远程调试 +- `6.0`/`6.1`无缝升级 + +> ThinkPHP8 的运行环境要求 PHP8.0+ + +现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习 ThinkPHP 的旅途中享受私人 AI 助理服务! + +[![](https://www.topthink.com/uploads/assistant/20230630/4d1a3f0ad2958b49bb8189b7ef824cb0.png)](https://chat.topthink.com/) + +ThinkPHP 生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。 + +## 文档 + +[完全开发手册](https://doc.thinkphp.cn) + +基于官方手册的数据训练和提供精准解答服务 +[官方专家智能体](https://chat.topthink.com/chat/eorole) + +## 赞助商 + +全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及 GIT 仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障 ThinkPHP 的可持续发展。 + +[![](https://www.thinkphp.cn/sponsor/special.svg)](https://www.thinkphp.cn/sponsor/special) + +[![](https://www.thinkphp.cn/sponsor.svg)](https://www.thinkphp.cn/sponsor) + +## 安装 + +``` +composer create-project topthink/think tp +``` + +启动服务 + +``` +cd tp +php think run +``` + +然后就可以在浏览器中访问 + +``` +http://localhost:8000 +``` + +如果需要更新框架使用 + +``` +composer update topthink/framework +``` + +## 命名规范 + +`ThinkPHP`遵循 PSR-2 命名规范和 PSR-4 自动加载规范。 + +## 参与开发 + +直接提交 PR 或者 Issue 即可 + +## 版权信息 + +ThinkPHP 遵循 Apache2 开源协议发布,并提供免费使用。 + +本项目包含的第三方源码和二进制文件之版权信息另行标注。 + +版权所有 Copyright © 2006-2024 by ThinkPHP (http://thinkphp.cn) All rights reserved。 + +ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 + +更多细节参阅 [LICENSE.txt](LICENSE.txt) diff --git a/vendor/topthink/framework/composer.json b/vendor/topthink/framework/composer.json new file mode 100644 index 0000000..f844527 --- /dev/null +++ b/vendor/topthink/framework/composer.json @@ -0,0 +1,59 @@ +{ + "name": "topthink/framework", + "description": "The ThinkPHP Framework.", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "http://thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + }, + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "require": { + "php": ">=8.0.0", + "ext-json": "*", + "ext-mbstring": "*", + "ext-ctype": "*", + "psr/log": "^1.0|^2.0|^3.0", + "psr/simple-cache": "^1.0|^2.0|^3.0", + "psr/http-message": "^1.0", + "topthink/think-orm": "^3.0|^4.0", + "topthink/think-helper": "^3.1", + "topthink/think-container": "^3.0", + "topthink/think-validate": "^3.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^9.5", + "guzzlehttp/psr7": "^2.1.0" + }, + "autoload": { + "files": [], + "psr-4": { + "think\\": "src/think/" + } + }, + "autoload-dev": { + "psr-4": { + "think\\tests\\": "tests/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "sort-packages": true + }, + "scripts": { + "php-cs-fixer": "php-cs-fixer fix src/ --rules=@PER-CS2.0 --dry-run --diff" + } +} diff --git a/vendor/topthink/framework/logo.png b/vendor/topthink/framework/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..25fd0593688de5c9f4cd321da1a72ab9566fe331 GIT binary patch literal 6995 zcmV-Z8?5AsP)KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7} zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf zVxhe-O!X z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4 ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS= zB9o|3v?Y2H`NVi)In3rTB8+ej^> zQ=~r95NVuDChL%G$=>7$vVg20myx%S50Foi`^m%Pw-h?Xh~i8Mq9jtJloCocWk2Nv zrJpiFnV_ms&8eQ$2&#xWpIS+6pmtC%Q-`S&GF4Q#^mhymh7E(qNMa}%YZ-ePrx>>xFPTiH1=E+A$W$=bG8>s^ zm=Bn5Rah$aDtr}@$`X}2l~$F0mFKEdRdZE8)p@E5RI61Ft6o-prbbn>P~)iy)E2AN zsU20jsWz_8Qg>31P|s0cqrPALg8E|(vWA65poU1JRAaZs8I2(p#xiB`SVGovRs-uS zYnV-9TeA7=Om+qP8+I>yOjAR1s%ETak!GFdam@h^# z)@rS0t$wXH+Irf)+G6c;?H29p+V6F6oj{!|o%K3xI`?%6x;DB|x`n#ibhIR?(H}Q3Gzd138Ei2)WAMz7W9Vy`X}HnwgyEn!VS)>mv$8&{hQn>w4zwy3R}t;BYlZQm5)6pty=DfLrs+A-|>>;~;Q z_F?uV_HFjh9n2gO9o9Q^JA86v({H5aB!kjoO6 zc9$1ZZKsN-Zl8L~mE{`ly3)1N^`o1+o7}D0ZPeY&J;i;i`%NyJ8_8Y6J?}yE@b_5a zam?eLr<8@mESk|3$_SkmS{wQ>%qC18))9_|&j{ZT zes8AvOzF(F2#DZEY>2oYX&IRp`F#{ADl)1r>QS^)ba8a|EY_^#S^HO&t^Rgqwv=MZThqqEWH8 zxJo>d=ABlR_Bh=;eM9Tw|Ih34~oTE|= zX_mAr*D$vzw@+p(E0Yc6dFE}(8oqt`+R{gE3x4zjX+Sb3_cYE^= zgB=w+-tUy`ytONMS8KgRef4hA?t0j zufM;t32jm~jUGrkaOInTZ`zyfns>EuS}G30LFK_G-==(f<51|K&cocp&EJ`SxAh3? zNO>#LI=^+SEu(FqJ)ynt=!~PC9bO$rzPJB=?=j6w@a-(u02P7 zaQ)#(uUl{HW%tYNS3ItC^iAtK(eKlL`f9+{bJzISE?u8_z3;~C8@FyI-5j_jy7l;W z_U#vU3hqqYU3!mrul&B+{ptt$59)uk{;_4iZQ%G|z+lhASr6|H35TBkl>gI*;nGLU zN7W-nBaM%pA0HbH8olyl&XeJ%vZoWz%6?Y=dFykl=imL}`%BMQ{Mhgd`HRoLu6e2R za__6DuR6yg#~-}Tc|Gx_{H@O0eebyMy5GmWADJlpK>kqk(fVV@r_fLLKIeS?{4e)} z^ZO;zpECde03c&XQcVB=dL;k=fP(-4`Tqa_faw4Lbua(`>RI+y?e7jKeZ#YO-C z5P(TUK~#9!?3{UYROQ`(pS#SOWU`Z$BxDa^-w_0qRROJ_;)fy#YSH7?R(p-EbfAWiV7kMvdB&nAVk8FL`WvH-R=7$piE{anUI+fzQgaoxpU{e z?>zT?fBU_{y(@BL2)I=z*^UwhrBB4Gy1NZP^@0FsfM9?m zni!jV17^vBVHn-U3SSTeCDDXMvXbQ}q9l1ZKFxCxV26x|C7C!&G6175J~lZPfZnN>kQrBS-YxP4wF1jhNB;QPBv~1dJ^|$-!0_NXtSR(MALn;`VETA$ z^7(aXE(m~L%}u|waU@wY{ElZiiph2qqiV`UfT35Pj!ll`@?JLub*@WOMxYuO0frQh z+RW&jnPkNk1^vD_c_=2)f`M@nU~5q{FPU)#Tv2#?$aAtCB_vpTpzGR2fUOOOAc)NB z^B^(i_>kw>O%Bpx^U%)IHtv=H4Gg@Ri|HkIQkF8Z-SabJ3(?P0nyXs^^e9fo42dL=^itc4<@j~YGe*{@Hcl=KXB7)F%YR0E| zC`jth!1M`tHTVAyfIiKQMYeNu|3|s1%ujjLW)#gE8lurskdj3+!)iSOO%F;6rfMmMxJ)Pzb#T)~f@M`T}3q>QoLm63&4b&(U_o1c~4M|tX~ zh>d;d)Q)z~DNg>WTctd86lt-&sB_hH$l9Nm6=-1KQJaxPGgFK2;8&Nt6j69y%}v!0 z+d>*2-Oz})rc#ErqI!0Q+o=WM*922j;~sJcRa;sCBFyp_IbW21JH)>SV@50Q~J z(6LG}T$VRG;JcpjWu(RCanxCLPOei_0BX95Pxp`!o6m&&xs1rZs?$2Az16qt_&Usz zErfgH;?kUJ$#w+xhnhq)g-L@r+_>lb1Jn%-ujVGnmciKES&YfO9=pjARo$xUKHlE@ zESjMqVG8oSLZUT|D~lF}9HS_C2%jBV(&8wd<2LRTKm!A>>LSJz&zRin8J~YMiPo;^ zko#c&3sf|0`LWE|dS0sT;B{v;e$%hp$VwHl&%xZ&pqf0*>z$)uWf(ibo?9Wg}GHHy;Cn?X7Bsk|MQ}ml$dO48uuZKQPzPi+qIcQ zTLx1KZ)J4PnMk7CrSP^L{e+jdJ%plrgDQTH+Dwk4jQIl}#}dM@w3ZZmPjt?`o+5|4 z>U2Y8c-C~TF1?2&TSk}1&z~N6oj3RV72VK7!pnA)uyE)zI4mh)kLxfeb*js&U4UNI zg~OV{jIv)aJZpNFgLA7+R_uC;b=Au;NtU2)ky~++o6wtuL;i;(TV{vGx0@V@f*2iu zZq-R);y~u~e}wedUR@4vf5T>$?tFqnr*>kMV*(-u0|U3>q)(60%p34W9H%?CIwF!F z1&u^>Lu<24&@Mo?;$%?fB8K5GA{21uIv3k z$WSgEA2txGOp+~~I@kB@LX<=OfgxE_m^a{$m^$I5pNo83yPEg+KSxdDUMx}!<{)6a znj5QR=eoWRFeZ0ar>@tmoI+~_(W|*APaVy7$3LgueFRC6!w2ZqT$CgaV{ZRPyA)pa zsokusc!6z4KS4mmCdUO?Ejk{xnf%25%i2NS_%hPc=&j?U%9mJQy#lxD#3I{+>Lj1$Mi$LnQFI$u7T(_B z!c!=zZK?>^rUC*kAe&t502OzPI*pH>#Pc}>;^hkIfhts0z)&eV9kM7 zLasvj>`Y3EJ)28<{w(V7wjW!|2m7Dr;K}chMGH1lY|!oM)m$W5)0t2(kFmM4BA(gV zQ@@c$&j~E8Zk&MlV@y9PX9nvJufQ<$pplRK)4umok}@o+S(I9574PqRj&EyM17Ho2 z2=J;dta3{pZ&JZ6QFGkCu6Zv2ieVU-B^#NJmUg<#xI#)(MzHPZCqdPQ{1bJ^OXw4| z?fP-mt9*Rm6`a14ZR$BukQkUgo+*X5k(*E+wVS!O{%iKue;wfdXofVc2GpS$!eR_KC1jDislKb z=hV|(2|123Cgk7Du&inAb{Iq?u0Hr0d+WXqxS0km+jm&@G{56EIhL~2k*qzqqz!-u zGV7VDZ-9py*yqq9tHknB_n{lw=@RF{poO03!mHxBP51DFyB4!#r*&(BS8Zl|{+y7}O^i8# zp7CXDJN7A(6a=6wnmOFKo0`VG^mLSVc!KZm|2yyPdk$GNVUjF?EZO|xN=;YL43$fBuI1{Idx*1i{aaMNs(F{CyZ($@aR!B_87d~p z%b-zSr3<=fhim{PcaSaV`n6I`+TX+Erc5t}K_Z|nOs4>6{A zt}Va+yd+{>N+WOYd6qA#mmvxAX`^8TglwwjV|KsaQWQprm~79+Zi>UFd4F6eer~uV z$~3r-@Xe8xVNG&X#UfT$F2*MN!}F>x(qnsZ_wc`;7kE35uj8o=x3KomzcERcptYMb zs^!X}+qpF7+OWorx1?Y*IWW#je+7&zi6*{0{3fGwW(HWQvt`qfmAtd}ZZ?H0GdP#HH~}OaqM#jW=sqj)4s9uaYRA#bH06=n~b;u77lra1Z$5j1E(7r>kq%l zs)|L_xoWUV_K=AO-O%xAE+!W)U`E+5I&>XT5V4!${Ccc|rdkCAzNlUn6rg6Pys_g? zG`xTQ4ZaK#*3T{jYq`|GM+B@v7+Ym5OMe{Jd_zrU8%ew^Jk){e(R{Vo4wX4xj-@LZO ztGTh89Nf_7zZsf&MJKKt20#G;RaaPh;NN}#J!&(nD_;(%%c{CUdTcMogNsgXR-kXI2bDXH4EK zW|aN1&FvkIcr`aoz6QjzoR^RQTO8|V)>OU9ya9gzV9U|f2(7w;4Gd(_OmXs%sKGmM zayxJDd6qqO8<9m5wsy*_#_8fykJvn}DZP(DA&g;1rQY>DPHzLED7O#r%qrY+bPbc6 z=96O2;_#_G$dbABY_Z68lI@Xy0g_vF@?pgyK0WX{KHbxEi<7SoFFBtC-4 ziUTLN<5rveR(_iR1wlN$3SZ{R;)OITr~H;LfR2tuvPHa#x37K^OLzX6LyfzzO7?cs zU1z$+3X=vgt@zHUbdBve{sls-oN2qgF&4?rmZNJ(kITm_Spy!E5)koe9@GeQyr0>A zD=QYUs$vnU?!zv}wUfA2@u_Zl#O5+Fe;%W9X0%xdKUb-BRfxm4Sf`6WCq2hmvf~eIsa=Cbwg*jmp6w8OH5U#`G86LWa(S;C zi8DtpS@GGyCAgKQ05uZUtr7(Zx6*hzfEEH=9z}OkeQFo^i384gf`?A+WbxMDaHOfC zO(XGB)y~eCoa>lSFqgELyr{ZP)s4IPs^;CGJ%?eh^|tCIq9C#B#0JI%d7K~|*?w#- zuWtJ-&C01ZT@9b+Mi3+hWlUsJ!ThLI5nJolq1T z@6c~Ie*Yf-+Ws(xp@%d?ita<#Rf>`aGo|o0dZ%8}WufA`d;i9s`i-G(Y-DsV9a+V=ytZTF{SBLW?YrNf{+<66G+jl}z4T2R%QdCAJy|3W|cn}vBt^p-4q|69C(dY6^rnw&bHjBoxo$j zlGbia9T9w!ulcNG?AcF=H!G+3uwqd_Z;7g_Oe~nk%(DBteAONJVLQurKgIrr&7tCX lAFv5{16U3OylCP71_0o>R4vh7BrN~{002ovPDHLkV1liRoDKj0 literal 0 HcmV?d00001 diff --git a/vendor/topthink/framework/phpunit.xml.dist b/vendor/topthink/framework/phpunit.xml.dist new file mode 100644 index 0000000..4966885 --- /dev/null +++ b/vendor/topthink/framework/phpunit.xml.dist @@ -0,0 +1,27 @@ + + + + + ./src/think + + + + + ./tests + + + diff --git a/vendor/topthink/framework/src/helper.php b/vendor/topthink/framework/src/helper.php new file mode 100644 index 0000000..7de5839 --- /dev/null +++ b/vendor/topthink/framework/src/helper.php @@ -0,0 +1,677 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +//------------------------ +// ThinkPHP 助手函数 +//------------------------- + +use think\App; +use think\Container; +use think\exception\HttpException; +use think\exception\HttpResponseException; +use think\facade\Cache; +use think\facade\Config; +use think\facade\Cookie; +use think\facade\Env; +use think\facade\Event; +use think\facade\Lang; +use think\facade\Log; +use think\facade\Request; +use think\facade\Route; +use think\facade\Session; +use think\Response; +use think\response\File; +use think\response\Json; +use think\response\Jsonp; +use think\response\Redirect; +use think\response\View; +use think\response\Xml; +use think\route\Url as UrlBuild; +use think\Validate; +use think\validate\ValidateRuleSet; + +if (!function_exists('abort')) { + /** + * 抛出HTTP异常 + * @param integer|Response $code 状态码 或者 Response对象实例 + * @param string $message 错误信息 + * @param array $header 参数 + */ + function abort($code, string $message = '', array $header = []) + { + if ($code instanceof Response) { + throw new HttpResponseException($code); + } else { + throw new HttpException($code, $message, null, $header); + } + } +} + +if (!function_exists('app')) { + /** + * 快速获取容器中的实例 支持依赖注入 + * @template T + * @param string|class-string $name 类名或标识 默认获取当前应用实例 + * @param array $args 参数 + * @param bool $newInstance 是否每次创建新的实例 + * @return T|object|App + */ + function app(string $name = '', array $args = [], bool $newInstance = false) + { + return Container::getInstance()->make($name ?: App::class, $args, $newInstance); + } +} + +if (!function_exists('bind')) { + /** + * 绑定一个类到容器 + * @param string|array $abstract 类标识、接口(支持批量绑定) + * @param mixed $concrete 要绑定的类、闭包或者实例 + * @return Container + */ + function bind($abstract, $concrete = null) + { + return Container::getInstance()->bind($abstract, $concrete); + } +} + +if (!function_exists('cache')) { + /** + * 缓存管理 + * @param string $name 缓存名称 + * @param mixed $value 缓存值 + * @param mixed $options 缓存参数 + * @param string $tag 缓存标签 + * @return mixed + */ + function cache(?string $name = null, $value = '', $options = null, $tag = null) + { + if (is_null($name)) { + return app('cache'); + } + + if ('' === $value) { + // 获取缓存 + return str_starts_with($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name); + } elseif (is_null($value)) { + // 删除缓存 + return Cache::delete($name); + } + + // 缓存数据 + if (is_array($options)) { + $expire = $options['expire'] ?? null; //修复查询缓存无法设置过期时间 + } else { + $expire = $options; + } + + if (is_null($tag)) { + return Cache::set($name, $value, $expire); + } else { + return Cache::tag($tag)->set($name, $value, $expire); + } + } +} + +if (!function_exists('config')) { + /** + * 获取和设置配置参数 + * @param string|array $name 参数名 + * @param mixed $value 参数值 + * @return mixed + */ + function config($name = '', $value = null) + { + if (is_array($name)) { + return Config::set($name, $value); + } + + return str_starts_with($name, '?') ? Config::has(substr($name, 1)) : Config::get($name, $value); + } +} + +if (!function_exists('cookie')) { + /** + * Cookie管理 + * @param string $name cookie名称 + * @param mixed $value cookie值 + * @param mixed $option 参数 + * @return mixed + */ + function cookie(string $name, $value = '', $option = null) + { + if (is_null($value)) { + // 删除 + Cookie::delete($name, $option ?: []); + } elseif ('' === $value) { + // 获取 + return str_starts_with($name, '?') ? Cookie::has(substr($name, 1)) : Cookie::get($name); + } else { + // 设置 + return Cookie::set($name, $value, $option); + } + } +} + +if (!function_exists('download')) { + /** + * 获取\think\response\Download对象实例 + * @param string $filename 要下载的文件 + * @param string $name 显示文件名 + * @param bool $content 是否为内容 + * @param int $expire 有效期(秒) + * @return \think\response\File + */ + function download(string $filename, string $name = '', bool $content = false, int $expire = 180): File + { + return Response::create($filename, 'file')->name($name)->isContent($content)->expire($expire); + } +} + +if (!function_exists('dump')) { + /** + * 浏览器友好的变量输出 + * @param mixed $vars 要输出的变量 + * @return void + */ + function dump(...$vars) + { + ob_start(); + var_dump(...$vars); + + $output = ob_get_clean(); + $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output); + + if (PHP_SAPI == 'cli') { + $output = PHP_EOL . $output . PHP_EOL; + } else { + if (!extension_loaded('xdebug')) { + $output = htmlspecialchars($output, ENT_SUBSTITUTE); + } + $output = '
    ' . $output . '
    '; + } + + echo $output; + } +} + +if (!function_exists('env')) { + /** + * 获取环境变量值 + * @access public + * @param string $name 环境变量名(支持二级 .号分割) + * @param string $default 默认值 + * @return mixed + */ + function env(?string $name = null, $default = null) + { + return Env::get($name, $default); + } +} + +if (!function_exists('event')) { + /** + * 触发事件 + * @param mixed $event 事件名(或者类名) + * @param mixed $args 参数 + * @return mixed + */ + function event($event, $args = null) + { + return Event::trigger($event, $args); + } +} + +if (!function_exists('halt')) { + /** + * 调试变量并且中断输出 + * @param mixed $vars 调试变量或者信息 + */ + function halt(...$vars) + { + dump(...$vars); + + throw new HttpResponseException(Response::create()); + } +} + +if (!function_exists('input')) { + /** + * 获取输入数据 支持默认值和过滤 + * @param string $key 获取的变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + function input(string $key = '', $default = null, $filter = '') + { + if (str_starts_with($key, '?')) { + $key = substr($key, 1); + $has = true; + } + + if ($pos = strpos($key, '.')) { + // 指定参数来源 + $method = substr($key, 0, $pos); + if (in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'route', 'param', 'request', 'session', 'cookie', 'server', 'env', 'path', 'file'])) { + $key = substr($key, $pos + 1); + if ('server' == $method && is_null($default)) { + $default = ''; + } + } else { + $method = 'param'; + } + } else { + // 默认为自动判断 + $method = 'param'; + } + + return isset($has) ? + request()->has($key, $method) : + request()->$method($key, $default, $filter); + } +} + +if (!function_exists('invoke')) { + /** + * 调用反射实例化对象或者执行方法 支持依赖注入 + * @param mixed $call 类名或者callable + * @param array $args 参数 + * @return mixed + */ + function invoke($call, array $args = []) + { + if (is_callable($call)) { + return Container::getInstance()->invoke($call, $args); + } + + return Container::getInstance()->invokeClass($call, $args); + } +} + +if (!function_exists('json')) { + /** + * 获取\think\response\Json对象实例 + * @param mixed $data 返回的数据 + * @param int $code 状态码 + * @param array $header 头部 + * @param array $options 参数 + * @return \think\response\Json + */ + function json($data = [], $code = 200, $header = [], $options = []): Json + { + return Response::create($data, 'json', $code)->header($header)->options($options); + } +} + +if (!function_exists('jsonp')) { + /** + * 获取\think\response\Jsonp对象实例 + * @param mixed $data 返回的数据 + * @param int $code 状态码 + * @param array $header 头部 + * @param array $options 参数 + * @return \think\response\Jsonp + */ + function jsonp($data = [], $code = 200, $header = [], $options = []): Jsonp + { + return Response::create($data, 'jsonp', $code)->header($header)->options($options); + } +} + +if (!function_exists('lang')) { + /** + * 获取语言变量值 + * @param string $name 语言变量名 + * @param array $vars 动态变量值 + * @param string $lang 语言 + * @return mixed + */ + function lang(string $name, array $vars = [], string $lang = '') + { + return Lang::get($name, $vars, $lang); + } +} + +if (!function_exists('parse_name')) { + /** + * 字符串命名风格转换 + * type 0 将Java风格转换为C的风格 1 将C风格转换为Java的风格 + * @param string $name 字符串 + * @param int $type 转换类型 + * @param bool $ucfirst 首字母是否大写(驼峰规则) + * @return string + */ + function parse_name(string $name, int $type = 0, bool $ucfirst = true): string + { + if ($type) { + $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { + return strtoupper($match[1]); + }, $name); + + return $ucfirst ? ucfirst($name) : lcfirst($name); + } + + return strtolower(trim(preg_replace('/[A-Z]/', '_\\0', $name), '_')); + } +} + +if (!function_exists('redirect')) { + /** + * 获取\think\response\Redirect对象实例 + * @param string $url 重定向地址 + * @param int $code 状态码 + * @return \think\response\Redirect + */ + function redirect(string $url = '', int $code = 302): Redirect + { + return Response::create($url, 'redirect', $code); + } +} + +if (!function_exists('request')) { + /** + * 获取当前Request对象实例 + * @return Request + */ + function request(): \think\Request + { + return app('request'); + } +} + +if (!function_exists('response')) { + /** + * 创建普通 Response 对象实例 + * @param mixed $data 输出数据 + * @param int|string $code 状态码 + * @param array $header 头信息 + * @param string $type + * @return Response + */ + function response($data = '', $code = 200, $header = [], $type = 'html'): Response + { + return Response::create($data, $type, $code)->header($header); + } +} + +if (!function_exists('session')) { + /** + * Session管理 + * @param string $name session名称 + * @param mixed $value session值 + * @return mixed + */ + function session($name = '', $value = '') + { + if (is_null($name)) { + // 清除 + Session::clear(); + } elseif ('' === $name) { + return Session::all(); + } elseif (is_null($value)) { + // 删除 + Session::delete($name); + } elseif ('' === $value) { + // 判断或获取 + return str_starts_with($name, '?') ? Session::has(substr($name, 1)) : Session::get($name); + } else { + // 设置 + Session::set($name, $value); + } + } +} + +if (!function_exists('token')) { + /** + * 获取Token令牌 + * @param string $name 令牌名称 + * @param mixed $type 令牌生成方法 + * @return string + */ + function token(string $name = '__token__', string $type = 'md5'): string + { + return Request::buildToken($name, $type); + } +} + +if (!function_exists('token_field')) { + /** + * 生成令牌隐藏表单 + * @param string $name 令牌名称 + * @param mixed $type 令牌生成方法 + * @return string + */ + function token_field(string $name = '__token__', string $type = 'md5'): string + { + $token = Request::buildToken($name, $type); + + return ''; + } +} + +if (!function_exists('token_meta')) { + /** + * 生成令牌meta + * @param string $name 令牌名称 + * @param mixed $type 令牌生成方法 + * @return string + */ + function token_meta(string $name = '__token__', string $type = 'md5'): string + { + $token = Request::buildToken($name, $type); + + return ''; + } +} + +if (!function_exists('trace')) { + /** + * 记录日志信息 + * @param mixed $log log信息 支持字符串和数组 + * @param string $level 日志级别 + * @return array|void + */ + function trace($log = '[think]', string $level = 'log') + { + if ('[think]' === $log) { + return Log::getLog(); + } + + Log::record($log, $level); + } +} + +if (!function_exists('url')) { + /** + * Url生成 + * @param string $url 路由地址 + * @param array $vars 变量 + * @param bool|string $suffix 生成的URL后缀 + * @param bool|string $domain 域名 + * @return UrlBuild + */ + function url(string $url = '', array $vars = [], $suffix = true, $domain = false): UrlBuild + { + return Route::buildUrl($url, $vars)->suffix($suffix)->domain($domain); + } +} + +if (!function_exists('validate')) { + /** + * 生成验证对象 + * @param string|array $validate 验证器类名或者验证规则数组 + * @param array $message 错误提示信息 + * @param bool $batch 是否批量验证 + * @param bool $failException 是否抛出异常 + * @return Validate + */ + function validate($validate = '', array $message = [], bool $batch = false, bool $failException = true): Validate + { + if (is_array($validate) || '' === $validate) { + $v = new Validate(); + if (is_array($validate)) { + $v->rule($validate); + } + } else { + if (str_contains($validate, '.')) { + // 支持场景 + [$validate, $scene] = explode('.', $validate); + } + + $class = str_contains($validate, '\\') ? $validate : app()->parseClass('validate', $validate); + + $v = new $class(); + + if (!empty($scene)) { + $v->scene($scene); + } + } + + return $v->message($message)->batch($batch)->failException($failException); + } +} + +if (!function_exists('rules')) { + /** + * 定义ValidateRuleSet规则集合 + * @param array $rules 验证因子集 + * @return ValidateRuleSet + */ + function rules(array $rules): ValidateRuleSet + { + return ValidateRuleSet::rules($rules); + } +} + +if (!function_exists('view')) { + /** + * 渲染模板输出 + * @param string $template 模板文件 + * @param array $vars 模板变量 + * @param int $code 状态码 + * @param callable $filter 内容过滤 + * @return \think\response\View + */ + function view(string $template = '', $vars = [], $code = 200, $filter = null): View + { + return Response::create($template, 'view', $code)->assign($vars)->filter($filter); + } +} + +if (!function_exists('display')) { + /** + * 渲染模板输出 + * @param string $content 渲染内容 + * @param array $vars 模板变量 + * @param int $code 状态码 + * @param callable $filter 内容过滤 + * @return \think\response\View + */ + function display(string $content, $vars = [], $code = 200, $filter = null): View + { + return Response::create($content, 'view', $code)->isContent(true)->assign($vars)->filter($filter); + } +} + +if (!function_exists('xml')) { + /** + * 获取\think\response\Xml对象实例 + * @param mixed $data 返回的数据 + * @param int $code 状态码 + * @param array $header 头部 + * @param array $options 参数 + * @return \think\response\Xml + */ + function xml($data = [], $code = 200, $header = [], $options = []): Xml + { + return Response::create($data, 'xml', $code)->header($header)->options($options); + } +} + +if (!function_exists('app_path')) { + /** + * 获取当前应用目录 + * + * @param string $path + * @return string + */ + function app_path($path = '') + { + return app()->getAppPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); + } +} + +if (!function_exists('base_path')) { + /** + * 获取应用基础目录 + * + * @param string $path + * @return string + */ + function base_path($path = '') + { + return app()->getBasePath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); + } +} + +if (!function_exists('config_path')) { + /** + * 获取应用配置目录 + * + * @param string $path + * @return string + */ + function config_path($path = '') + { + return app()->getConfigPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); + } +} + +if (!function_exists('public_path')) { + /** + * 获取web根目录 + * + * @param string $path + * @return string + */ + function public_path($path = '') + { + return app()->getRootPath() . 'public' . DIRECTORY_SEPARATOR . ($path ? ltrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $path); + } +} + +if (!function_exists('runtime_path')) { + /** + * 获取应用运行时目录 + * + * @param string $path + * @return string + */ + function runtime_path($path = '') + { + return app()->getRuntimePath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); + } +} + +if (!function_exists('root_path')) { + /** + * 获取项目根目录 + * + * @param string $path + * @return string + */ + function root_path($path = '') + { + return app()->getRootPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); + } +} diff --git a/vendor/topthink/framework/src/lang/zh-cn.php b/vendor/topthink/framework/src/lang/zh-cn.php new file mode 100644 index 0000000..eea41d5 --- /dev/null +++ b/vendor/topthink/framework/src/lang/zh-cn.php @@ -0,0 +1,157 @@ + +// +---------------------------------------------------------------------- + +// 核心中文语言包 +return [ + // 系统错误提示 + 'Undefined variable' => '未定义变量', + 'Undefined index' => '未定义数组索引', + 'Undefined offset' => '未定义数组下标', + 'Parse error' => '语法解析错误', + 'Type error' => '类型错误', + 'Fatal error' => '致命错误', + 'syntax error' => '语法错误', + + // 框架核心错误提示 + 'dispatch type not support' => '不支持的调度类型', + 'method param miss' => '方法参数错误', + 'method not exists' => '方法不存在', + 'function not exists' => '函数不存在', + 'app not exists' => '应用不存在', + 'controller not exists' => '控制器不存在', + 'class not exists' => '类不存在', + 'property not exists' => '类的属性不存在', + 'template not exists' => '模板文件不存在', + 'illegal controller name' => '非法的控制器名称', + 'illegal action name' => '非法的操作名称', + 'url suffix deny' => '禁止的URL后缀访问', + 'Undefined cache config' => '缓存配置未定义', + 'Route Not Found' => '当前访问路由未定义或不匹配', + 'Undefined db config' => '数据库配置未定义', + 'Undefined log config' => '日志配置未定义', + 'Undefined db type' => '未定义数据库类型', + 'variable type error' => '变量类型错误', + 'PSR-4 error' => 'PSR-4 规范错误', + 'not support type' => '不支持的分页索引字段类型', + 'not support total' => '简洁模式下不能获取数据总数', + 'not support last' => '简洁模式下不能获取最后一页', + 'error session handler' => '错误的SESSION处理器类', + 'not allow php tag' => '模板不允许使用PHP语法', + 'not support' => '不支持', + 'database config error' => '数据库配置信息错误', + 'redisd master' => 'Redisd 主服务器错误', + 'redisd slave' => 'Redisd 从服务器错误', + 'must run at sae' => '必须在SAE运行', + 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', + 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', + 'fields not exists' => '数据表字段不存在', + 'where express error' => '查询表达式错误', + 'no data to update' => '没有任何数据需要更新', + 'miss data to insert' => '缺少需要写入的数据', + 'miss complex primary data' => '缺少复合主键数据', + 'miss update condition' => '缺少更新条件', + 'model data Not Found' => '模型数据不存在', + 'table data not Found' => '表数据不存在', + 'delete without condition' => '没有条件不会执行删除操作', + 'miss relation data' => '缺少关联表数据', + 'tag attr must' => '模板标签属性必须', + 'tag error' => '模板标签错误', + 'cache write error' => '缓存写入失败', + 'sae mc write error' => 'SAE mc 写入错误', + 'route name not exists' => '路由标识不存在(或参数不够)', + 'invalid request' => '非法请求', + 'bind attr has exists' => '模型的属性已经存在', + 'relation data not exists' => '关联数据不存在', + 'relation not support' => '关联不支持', + 'chunk not support order' => 'Chunk不支持调用order方法', + 'route pattern error' => '路由变量规则定义错误', + 'route behavior will not support' => '路由行为废弃(使用中间件替代)', + 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', + + // 上传错误信息 + 'unknown upload error' => '未知上传错误!', + 'file write error' => '文件写入失败!', + 'upload temp dir not found' => '找不到临时文件夹!', + 'no file to uploaded' => '没有文件被上传!', + 'only the portion of file is uploaded' => '文件只有部分被上传!', + 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', + 'upload write error' => '文件上传保存错误!', + 'has the same filename: {:filename}' => '存在同名文件:{:filename}', + 'upload illegal files' => '非法上传文件', + 'illegal image files' => '非法图片文件', + 'extensions to upload is not allowed' => '上传文件后缀不允许', + 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', + 'filesize not match' => '上传文件大小不符!', + 'directory {:path} creation failed' => '目录 {:path} 创建失败!', + + 'The middleware must return Response instance' => '中间件方法必须返回Response对象实例', + 'The queue was exhausted, with no response returned' => '中间件队列为空', + // Validate Error Message + ':attribute require' => ':attribute不能为空', + ':attribute must' => ':attribute必须', + ':attribute must be numeric' => ':attribute必须是数字', + ':attribute must be integer' => ':attribute必须是整数', + ':attribute must be float' => ':attribute必须是浮点数', + ':attribute must be string' => ':attribute必须是字符串', + ':attribute must be :rule enum' => ':attribute必须是有效的 :rule 枚举', + ':attribute must start with :rule' => ':attribute必须以 :rule 开头', + ':attribute must end with :rule' => ':attribute必须以 :rule 结尾', + ':attribute must contain :rule' => ':attribute必须包含 :rule', + ':attribute must be bool' => ':attribute必须是布尔值', + ':attribute not a valid email address' => ':attribute格式不符', + ':attribute not a valid mobile' => ':attribute格式不符', + ':attribute must be a array' => ':attribute必须是数组', + ':attribute must be yes,on,true or 1' => ':attribute必须是yes、on、true或者1', + ':attribute must be no,off,false or 0' => ':attribute必须是no、off、false或者0', + ':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式', + ':attribute not a valid file' => ':attribute不是有效的上传文件', + ':attribute not a valid image' => ':attribute不是有效的图像文件', + ':attribute must be alpha' => ':attribute只能是字母', + ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', + ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', + ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', + ':attribute must be chinese' => ':attribute只能是汉字', + ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', + ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', + ':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', + ':attribute not a valid url' => ':attribute不是有效的URL地址', + ':attribute not a valid ip' => ':attribute不是有效的IP地址', + ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', + ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', + ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', + ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', + ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', + 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', + 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', + 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', + ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', + ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', + ':attribute not within :rule' => '不在有效期内 :rule', + 'access IP is not allowed' => '不允许的IP访问', + 'access IP denied' => '禁止的IP访问', + ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', + ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', + ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', + ':attribute must greater than :rule' => ':attribute必须大于 :rule', + ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', + ':attribute must less than :rule' => ':attribute必须小于 :rule', + ':attribute must equal :rule' => ':attribute必须等于 :rule', + ':attribute must not be equal to :rule' => ':attribute不能等于 :rule', + ':attribute has exists' => ':attribute已存在', + ':attribute not conform to the rules' => ':attribute不符合指定规则', + ':attribute must multiple :rule' => ':attribute必须是 :rule 的倍数', + 'invalid Request method' => '无效的请求类型', + 'invalid token' => '令牌数据无效', + 'not conform to the rules' => '规则错误', + + 'record has update' => '记录已经被更新了', +]; diff --git a/vendor/topthink/framework/src/think/App.php b/vendor/topthink/framework/src/think/App.php new file mode 100644 index 0000000..dafb45f --- /dev/null +++ b/vendor/topthink/framework/src/think/App.php @@ -0,0 +1,651 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use Composer\InstalledVersions; +use think\event\AppInit; +use think\helper\Str; +use think\initializer\BootService; +use think\initializer\Error; +use think\initializer\RegisterService; + +/** + * App 基础类 + * @property Route $route + * @property Config $config + * @property Cache $cache + * @property Request $request + * @property Http $http + * @property Console $console + * @property Env $env + * @property Event $event + * @property Middleware $middleware + * @property Log $log + * @property Lang $lang + * @property Db $db + * @property Cookie $cookie + * @property Session $session + * @property Validate $validate + */ +class App extends Container +{ + /** + * 核心框架版本 + * @deprecated 已经废弃 请改用version()方法 + */ + const VERSION = '8.0.0'; + + /** + * 应用调试模式 + * @var bool + */ + protected $appDebug = false; + + /** + * 公共环境变量标识 + * @var string + */ + protected $baseEnvName = ''; + + /** + * 环境变量标识 + * @var string + */ + protected $envName = ''; + + /** + * 应用开始时间 + * @var float + */ + protected $beginTime; + + /** + * 应用内存初始占用 + * @var integer + */ + protected $beginMem; + + /** + * 当前应用类库命名空间 + * @var string + */ + protected $namespace = 'app'; + + /** + * 应用根目录 + * @var string + */ + protected $rootPath = ''; + + /** + * 框架目录 + * @var string + */ + protected $thinkPath = ''; + + /** + * 应用目录 + * @var string + */ + protected $appPath = ''; + + /** + * Runtime目录 + * @var string + */ + protected $runtimePath = ''; + + /** + * 路由定义目录 + * @var string + */ + protected $routePath = ''; + + /** + * 配置后缀 + * @var string + */ + protected $configExt = '.php'; + + /** + * 应用初始化器 + * @var array + */ + protected $initializers = [ + Error::class, + RegisterService::class, + BootService::class, + ]; + + /** + * 注册的系统服务 + * @var array + */ + protected $services = []; + + /** + * 初始化 + * @var bool + */ + protected $initialized = false; + + /** + * 容器绑定标识 + * @var array + */ + protected $bind = [ + 'app' => App::class, + 'cache' => Cache::class, + 'config' => Config::class, + 'console' => Console::class, + 'cookie' => Cookie::class, + 'db' => Db::class, + 'env' => Env::class, + 'event' => Event::class, + 'http' => Http::class, + 'lang' => Lang::class, + 'log' => Log::class, + 'middleware' => Middleware::class, + 'request' => Request::class, + 'response' => Response::class, + 'route' => Route::class, + 'session' => Session::class, + 'validate' => Validate::class, + 'view' => View::class, + 'think\DbManager' => Db::class, + 'think\LogManager' => Log::class, + 'think\CacheManager' => Cache::class, + + // 接口依赖注入 + 'Psr\Log\LoggerInterface' => Log::class, + ]; + + /** + * 架构方法 + * @access public + * @param string $rootPath 应用根目录 + */ + public function __construct(string $rootPath = '') + { + $this->thinkPath = realpath(dirname(__DIR__)) . DIRECTORY_SEPARATOR; + $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); + $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; + $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; + + if (is_file($this->appPath . 'provider.php')) { + $this->bind(include $this->appPath . 'provider.php'); + } + + static::setInstance($this); + + $this->instance('app', $this); + $this->instance('think\Container', $this); + } + + /** + * 注册服务 + * @access public + * @param Service|string $service 服务 + * @param bool $force 强制重新注册 + * @return Service|null + */ + public function register(Service | string $service, bool $force = false) + { + $registered = $this->getService($service); + + if ($registered && !$force) { + return $registered; + } + + if (is_string($service)) { + $service = new $service($this); + } + + if (method_exists($service, 'register')) { + $service->register(); + } + + if (property_exists($service, 'bind')) { + $this->bind($service->bind); + } + + $this->services[] = $service; + } + + /** + * 执行服务 + * @access public + * @param Service $service 服务 + * @return mixed + */ + public function bootService(Service $service) + { + if (method_exists($service, 'boot')) { + return $this->invoke([$service, 'boot']); + } + } + + /** + * 获取服务 + * @param string|Service $service + * @return Service|null + */ + public function getService(Service | string $service): ?Service + { + $name = is_string($service) ? $service : $service::class; + return array_values(array_filter($this->services, function ($value) use ($name) { + return $value instanceof $name; + }, ARRAY_FILTER_USE_BOTH))[0] ?? null; + } + + /** + * 开启应用调试模式 + * @access public + * @param bool $debug 开启应用调试模式 + * @return $this + */ + public function debug(bool $debug = true) + { + $this->appDebug = $debug; + return $this; + } + + /** + * 是否为调试模式 + * @access public + * @return bool + */ + public function isDebug(): bool + { + return $this->appDebug; + } + + /** + * 设置应用命名空间 + * @access public + * @param string $namespace 应用命名空间 + * @return $this + */ + public function setNamespace(string $namespace) + { + $this->namespace = $namespace; + return $this; + } + + /** + * 获取应用类库命名空间 + * @access public + * @return string + */ + public function getNamespace(): string + { + return $this->namespace; + } + + /** + * 设置公共环境变量标识 + * @access public + * @param string $name 环境标识 + * @return $this + */ + public function setBaseEnvName(string $name) + { + $this->baseEnvName = $name; + return $this; + } + + /** + * 设置环境变量标识 + * @access public + * @param string $name 环境标识 + * @return $this + */ + public function setEnvName(string $name) + { + $this->envName = $name; + return $this; + } + + /** + * 获取框架版本 + * @access public + * @return string + */ + public function version(): string + { + return ltrim(InstalledVersions::getPrettyVersion('topthink/framework'), 'v'); + } + + /** + * 获取应用根目录 + * @access public + * @return string + */ + public function getRootPath(): string + { + return $this->rootPath; + } + + /** + * 获取应用基础目录 + * @access public + * @return string + */ + public function getBasePath(): string + { + return $this->rootPath . 'app' . DIRECTORY_SEPARATOR; + } + + /** + * 获取当前应用目录 + * @access public + * @return string + */ + public function getAppPath(): string + { + return $this->appPath; + } + + /** + * 设置应用目录 + * @param string $path 应用目录 + */ + public function setAppPath(string $path) + { + $this->appPath = $path; + } + + /** + * 获取应用运行时目录 + * @access public + * @return string + */ + public function getRuntimePath(): string + { + return $this->runtimePath; + } + + /** + * 设置runtime目录 + * @param string $path 定义目录 + */ + public function setRuntimePath(string $path): void + { + $this->runtimePath = $path; + } + + /** + * 获取核心框架目录 + * @access public + * @return string + */ + public function getThinkPath(): string + { + return $this->thinkPath; + } + + /** + * 获取应用配置目录 + * @access public + * @return string + */ + public function getConfigPath(): string + { + return $this->rootPath . 'config' . DIRECTORY_SEPARATOR; + } + + /** + * 获取配置后缀 + * @access public + * @return string + */ + public function getConfigExt(): string + { + return $this->configExt; + } + + /** + * 获取应用开启时间 + * @access public + * @return float + */ + public function getBeginTime(): float + { + return $this->beginTime; + } + + /** + * 获取应用初始内存占用 + * @access public + * @return integer + */ + public function getBeginMem(): int + { + return $this->beginMem; + } + + /** + * 加载环境变量定义 + * @access public + * @param string $envName 环境标识 + * @return void + */ + public function loadEnv(string $envName = ''): void + { + // 加载环境变量 + $envFile = $envName ? $this->rootPath . '.env.' . $envName : $this->rootPath . '.env'; + + if (is_file($envFile)) { + $this->env->load($envFile); + } + } + + /** + * 初始化应用 + * @access public + * @return $this + */ + public function initialize() + { + $this->initialized = true; + + $this->beginTime = microtime(true); + $this->beginMem = memory_get_usage(); + + // 加载环境变量 + if ($this->baseEnvName) { + $this->loadEnv($this->baseEnvName); + } + + $this->envName = $this->envName ?: (string) $this->env->get('env_name', ''); + $this->loadEnv($this->envName); + + $this->configExt = $this->env->get('config_ext', '.php'); + + $this->debugModeInit(); + + // 加载全局初始化文件 + $this->load(); + + // 加载应用默认语言包 + $this->loadLangPack(); + + // 监听AppInit + $this->event->trigger(AppInit::class); + + date_default_timezone_set($this->config->get('app.default_timezone', 'Asia/Shanghai')); + + // 初始化 + foreach ($this->initializers as $initializer) { + $this->make($initializer)->init($this); + } + + return $this; + } + + /** + * 是否初始化过 + * @return bool + */ + public function initialized() + { + return $this->initialized; + } + + /** + * 加载语言包 + * @return void + */ + public function loadLangPack(): void + { + // 加载默认语言包 + $langSet = $this->lang->defaultLangSet(); + $this->lang->switchLangSet($langSet); + } + + /** + * 引导应用 + * @access public + * @return void + */ + public function boot(): void + { + array_walk($this->services, function ($service) { + $this->bootService($service); + }); + } + + /** + * 加载应用文件和配置 + * @access protected + * @return void + */ + protected function load(): void + { + $appPath = $this->getAppPath(); + + if (is_file($appPath . 'common.php')) { + include_once $appPath . 'common.php'; + } + + include_once $this->thinkPath . 'helper.php'; + + $configPath = $this->getConfigPath(); + + $files = []; + + if (is_dir($configPath)) { + $files = glob($configPath . '*' . $this->configExt); + } + + foreach ($files as $file) { + $this->config->load($file, pathinfo($file, PATHINFO_FILENAME)); + } + + if (is_file($appPath . 'event.php')) { + $this->loadEvent(include $appPath . 'event.php'); + } + + if (is_file($appPath . 'service.php')) { + $services = include $appPath . 'service.php'; + foreach ($services as $service) { + $this->register($service); + } + } + } + + /** + * 调试模式设置 + * @access protected + * @return void + */ + protected function debugModeInit(): void + { + // 应用调试模式 + if (!$this->appDebug) { + $this->appDebug = $this->env->get('app_debug') ? true : false; + } + + if (!$this->appDebug) { + ini_set('display_errors', 'Off'); + } + + if (!$this->runningInConsole()) { + //重新申请一块比较大的buffer + if (ob_get_level() > 0) { + $output = ob_get_clean(); + } + ob_start(); + if (!empty($output)) { + echo $output; + } + } + } + + /** + * 注册应用事件 + * @access protected + * @param array $event 事件数据 + * @return void + */ + public function loadEvent(array $event): void + { + if (isset($event['bind'])) { + $this->event->bind($event['bind']); + } + + if (isset($event['listen'])) { + $this->event->listenEvents($event['listen']); + } + + if (isset($event['subscribe'])) { + $this->event->subscribe($event['subscribe']); + } + } + + /** + * 解析应用类的类名 + * @access public + * @param string $layer 层名 controller model ... + * @param string $name 类名 + * @return string + */ + public function parseClass(string $layer, string $name): string + { + $name = str_replace(['/', '.'], '\\', $name); + $array = explode('\\', $name); + $class = Str::studly(array_pop($array)); + $path = $array ? implode('\\', $array) . '\\' : ''; + + return $this->namespace . '\\' . $layer . '\\' . $path . $class; + } + + /** + * 是否运行在命令行下 + * @return bool + */ + public function runningInConsole(): bool + { + return php_sapi_name() === 'cli' || php_sapi_name() === 'phpdbg'; + } + + /** + * 获取应用根目录 + * @access protected + * @return string + */ + protected function getDefaultRootPath(): string + { + return dirname($this->thinkPath, 4) . DIRECTORY_SEPARATOR; + } +} diff --git a/vendor/topthink/framework/src/think/Cache.php b/vendor/topthink/framework/src/think/Cache.php new file mode 100644 index 0000000..bd7ed4f --- /dev/null +++ b/vendor/topthink/framework/src/think/Cache.php @@ -0,0 +1,200 @@ + +// +---------------------------------------------------------------------- +declare(strict_types = 1); + +namespace think; + +use DateInterval; +use DateTimeInterface; +use Psr\SimpleCache\CacheInterface; +use think\cache\Driver; +use think\cache\TagSet; +use think\exception\InvalidArgumentException; +use think\helper\Arr; + +/** + * 缓存管理类 + * @mixin Driver + * @mixin \think\cache\driver\File + */ +class Cache extends Manager implements CacheInterface +{ + + protected $namespace = '\\think\\cache\\driver\\'; + + /** + * 默认驱动 + * @return string|null + */ + public function getDefaultDriver(): ?string + { + return $this->getConfig('default'); + } + + /** + * 获取缓存配置 + * @access public + * @param null|string $name 名称 + * @param mixed $default 默认值 + * @return mixed + */ + public function getConfig(?string $name = null, $default = null) + { + if (!is_null($name)) { + return $this->app->config->get('cache.' . $name, $default); + } + + return $this->app->config->get('cache'); + } + + /** + * 获取驱动配置 + * @param string $store + * @param string $name + * @param mixed $default + * @return array + */ + public function getStoreConfig(string $store, ?string $name = null, $default = null) + { + if ($config = $this->getConfig("stores.{$store}")) { + return Arr::get($config, $name, $default); + } + + throw new \InvalidArgumentException("Store [$store] not found."); + } + + protected function resolveType(string $name) + { + return $this->getStoreConfig($name, 'type', 'file'); + } + + protected function resolveConfig(string $name) + { + return $this->getStoreConfig($name); + } + + /** + * 连接或者切换缓存 + * @access public + * @param string|null $name 连接配置名 + * @return Driver + */ + public function store(?string $name = null) + { + return $this->driver($name); + } + + /** + * 清空缓冲池 + * @access public + * @return bool + */ + public function clear(): bool + { + return $this->store()->clear(); + } + + /** + * 读取缓存 + * @access public + * @param string $key 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($key, mixed $default = null): mixed + { + return $this->store()->get($key, $default); + } + + /** + * 写入缓存 + * @access public + * @param string $key 缓存变量名 + * @param mixed $value 存储数据 + * @param int|DateTimeInterface|DateInterval $ttl 有效时间 0为永久 + * @return bool + */ + public function set($key, $value, $ttl = null): bool + { + return $this->store()->set($key, $value, $ttl); + } + + /** + * 删除缓存 + * @access public + * @param string $key 缓存变量名 + * @return bool + */ + public function delete($key): bool + { + return $this->store()->delete($key); + } + + /** + * 读取缓存 + * @access public + * @param iterable $keys 缓存变量名 + * @param mixed $default 默认值 + * @return iterable + * @throws InvalidArgumentException + */ + public function getMultiple($keys, $default = null): iterable + { + return $this->store()->getMultiple($keys, $default); + } + + /** + * 写入缓存 + * @access public + * @param iterable $values 缓存数据 + * @param null|int|\DateInterval $ttl 有效时间 0为永久 + * @return bool + */ + public function setMultiple($values, $ttl = null): bool + { + return $this->store()->setMultiple($values, $ttl); + } + + /** + * 删除缓存 + * @access public + * @param iterable $keys 缓存变量名 + * @return bool + * @throws InvalidArgumentException + */ + public function deleteMultiple($keys): bool + { + return $this->store()->deleteMultiple($keys); + } + + /** + * 判断缓存是否存在 + * @access public + * @param string $key 缓存变量名 + * @return bool + */ + public function has($key): bool + { + return $this->store()->has($key); + } + + /** + * 缓存标签 + * @access public + * @param string|array $name 标签名 + * @return TagSet + */ + public function tag($name) + { + return $this->store()->tag($name); + } + +} diff --git a/vendor/topthink/framework/src/think/Config.php b/vendor/topthink/framework/src/think/Config.php new file mode 100644 index 0000000..a66a730 --- /dev/null +++ b/vendor/topthink/framework/src/think/Config.php @@ -0,0 +1,209 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use Closure; + +/** + * 配置管理类 + * @package think + */ +class Config +{ + /** + * 配置参数 + * @var array + */ + protected $config = []; + + /** + * 注册配置获取器 + * @var Closure + */ + protected $hook; + + /** + * 构造方法 + * @access public + */ + public function __construct(protected string $path = '', protected string $ext = '.php') + { + } + + public static function __make(App $app) + { + $path = $app->getConfigPath(); + $ext = $app->getConfigExt(); + + return new static($path, $ext); + } + + /** + * 加载配置文件(多种格式) + * @access public + * @param string $file 配置文件名 + * @param string $name 一级配置名 + * @return array + */ + public function load(string $file, string $name = ''): array + { + if (is_file($file)) { + $filename = $file; + } elseif (is_file($this->path . $file . $this->ext)) { + $filename = $this->path . $file . $this->ext; + } + + if (isset($filename)) { + return $this->parse($filename, $name); + } + + return $this->config; + } + + /** + * 解析配置文件 + * @access public + * @param string $file 配置文件名 + * @param string $name 一级配置名 + * @return array + */ + protected function parse(string $file, string $name): array + { + $type = pathinfo($file, PATHINFO_EXTENSION); + $config = []; + $config = match ($type) { + 'php' => include $file, + 'yml', 'yaml' => function_exists('yaml_parse_file') ? yaml_parse_file($file) : [], + 'ini' => parse_ini_file($file, true, INI_SCANNER_TYPED) ?: [], + 'json' => json_decode(file_get_contents($file), true), + default => [], + }; + + return is_array($config) ? $this->set($config, strtolower($name)) : []; + } + + /** + * 检测配置是否存在 + * @access public + * @param string $name 配置参数名(支持多级配置 .号分割) + * @return bool + */ + public function has(string $name): bool + { + if (!str_contains($name, '.') && !isset($this->config[strtolower($name)])) { + return false; + } + + return !is_null($this->get($name)); + } + + /** + * 获取一级配置 + * @access protected + * @param string $name 一级配置名 + * @return array + */ + protected function pull(string $name): array + { + return $this->config[$name] ?? []; + } + + /** + * 注册配置获取器 + * @access public + * @param Closure $callback + * @return void + */ + public function hook(Closure $callback) + { + $this->hook = $callback; + } + + /** + * 获取配置参数 为空则获取所有配置 + * @access public + * @param string $name 配置参数名(支持多级配置 .号分割) + * @param mixed $default 默认值 + * @return mixed + */ + public function get(?string $name = null, $default = null) + { + // 无参数时获取所有 + if (empty($name)) { + return $this->config; + } + + if (!str_contains($name, '.')) { + $name = strtolower($name); + $result = $this->pull($name); + return $this->hook ? $this->lazy($name, $result, []) : $result; + } + + $item = explode('.', $name); + $item[0] = strtolower($item[0]); + $config = $this->config; + + foreach ($item as $val) { + if (isset($config[$val])) { + $config = $config[$val]; + } else { + return $this->hook ? $this->lazy($name, null, $default) : $default; + } + } + + return $this->hook ? $this->lazy($name, $config, $default) : $config; + } + + /** + * 通过获取器加载配置 + * @access public + * @param string $name 配置参数 + * @param mixed $value 配置值 + * @param mixed $default 默认值 + * @return mixed + */ + protected function lazy(?string $name, $value = null, $default = null) + { + // 通过获取器返回 + $result = call_user_func_array($this->hook, [$name, $value]); + if (is_null($result)) { + return $default; + } + return $result; + } + + /** + * 设置配置参数 name为数组则为批量设置 + * @access public + * @param array $config 配置参数 + * @param string $name 配置名 + * @return array + */ + public function set(array $config, ?string $name = null): array + { + if (empty($name)) { + $this->config = array_merge($this->config, array_change_key_case($config)); + return $this->config; + } + + if (isset($this->config[$name])) { + $result = array_merge($this->config[$name], $config); + } else { + $result = $config; + } + + $this->config[$name] = $result; + + return $result; + } +} diff --git a/vendor/topthink/framework/src/think/Console.php b/vendor/topthink/framework/src/think/Console.php new file mode 100644 index 0000000..c2d51ca --- /dev/null +++ b/vendor/topthink/framework/src/think/Console.php @@ -0,0 +1,787 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use Closure; +use InvalidArgumentException; +use LogicException; +use think\console\Command; +use think\console\command\Clear; +use think\console\command\Help; +use think\console\command\Help as HelpCommand; +use think\console\command\Lists; +use think\console\command\make\Command as MakeCommand; +use think\console\command\make\Controller; +use think\console\command\make\Event; +use think\console\command\make\Listener; +use think\console\command\make\Middleware; +use think\console\command\make\Model; +use think\console\command\make\Service; +use think\console\command\make\Subscribe; +use think\console\command\make\Validate; +use think\console\command\optimize\Route; +use think\console\command\optimize\Schema; +use think\console\command\RouteList; +use think\console\command\RunServer; +use think\console\command\ServiceDiscover; +use think\console\command\VendorPublish; +use think\console\command\Version; +use think\console\Input; +use think\console\input\Argument as InputArgument; +use think\console\input\Definition as InputDefinition; +use think\console\input\Option as InputOption; +use think\console\Output; +use think\console\output\driver\Buffer; + +/** + * 控制台应用管理类 + */ +class Console +{ + /** @var Command[] */ + protected $commands = []; + + protected $wantHelps = false; + + protected $catchExceptions = true; + protected $autoExit = true; + protected $definition; + protected $defaultCommand = 'list'; + + protected $defaultCommands = [ + 'help' => Help::class, + 'list' => Lists::class, + 'clear' => Clear::class, + 'make:command' => MakeCommand::class, + 'make:controller' => Controller::class, + 'make:model' => Model::class, + 'make:middleware' => Middleware::class, + 'make:validate' => Validate::class, + 'make:event' => Event::class, + 'make:listener' => Listener::class, + 'make:service' => Service::class, + 'make:subscribe' => Subscribe::class, + 'optimize:route' => Route::class, + 'optimize:schema' => Schema::class, + 'run' => RunServer::class, + 'version' => Version::class, + 'route:list' => RouteList::class, + 'service:discover' => ServiceDiscover::class, + 'vendor:publish' => VendorPublish::class, + ]; + + /** + * 启动器 + * @var array + */ + protected static $startCallbacks = []; + + public function __construct(protected App $app) + { + $this->initialize(); + + $this->definition = $this->getDefaultInputDefinition(); + + //加载指令 + $this->loadCommands(); + + // 设置执行用户 + $user = $this->app->config->get('console.user'); + if (!empty($user)) { + $this->setUser($user); + } + + $this->start(); + } + + /** + * 初始化 + */ + protected function initialize():void + { + if (!$this->app->initialized()) { + $this->app->initialize(); + } + $this->makeRequest(); + } + + /** + * 构造request + */ + protected function makeRequest():void + { + $url = $this->app->config->get('app.url', 'http://localhost'); + + $components = parse_url($url); + + $server = $_SERVER; + + if (isset($components['path'])) { + $server = array_merge($server, [ + 'SCRIPT_FILENAME' => $components['path'], + 'SCRIPT_NAME' => $components['path'], + 'REQUEST_URI' => $components['path'], + ]); + } + + if (isset($components['host'])) { + $server['SERVER_NAME'] = $components['host']; + $server['HTTP_HOST'] = $components['host']; + } + + if (isset($components['scheme'])) { + if ('https' === $components['scheme']) { + $server['HTTPS'] = 'on'; + $server['SERVER_PORT'] = 443; + } else { + unset($server['HTTPS']); + $server['SERVER_PORT'] = 80; + } + } + + if (isset($components['port'])) { + $server['SERVER_PORT'] = $components['port']; + $server['HTTP_HOST'] .= ':' . $components['port']; + } + + /** @var Request $request */ + $request = $this->app->make('request'); + + $request->withServer($server); + } + + /** + * 添加初始化器 + * @param Closure $callback + */ + public static function starting(Closure $callback): void + { + static::$startCallbacks[] = $callback; + } + + /** + * 清空启动器 + */ + public static function flushStartCallbacks(): void + { + static::$startCallbacks = []; + } + + /** + * 设置执行用户 + * @param $user + */ + public static function setUser(string $user): void + { + if (extension_loaded('posix')) { + $user = posix_getpwnam($user); + + if (!empty($user)) { + posix_setgid($user['gid']); + posix_setuid($user['uid']); + } + } + } + + /** + * 启动 + */ + protected function start(): void + { + foreach (static::$startCallbacks as $callback) { + $callback($this); + } + } + + /** + * 加载指令 + * @access protected + */ + protected function loadCommands(): void + { + $commands = $this->app->config->get('console.commands', []); + $commands = array_merge($this->defaultCommands, $commands); + + $this->addCommands($commands); + } + + /** + * @access public + * @param string $command + * @param array $parameters + * @param string $driver + * @return Output|Buffer + */ + public function call(string $command, array $parameters = [], string $driver = 'buffer') + { + array_unshift($parameters, $command); + + $input = new Input($parameters); + $output = new Output($driver); + + $this->setCatchExceptions(false); + $this->find($command)->run($input, $output); + + return $output; + } + + /** + * 执行当前的指令 + * @access public + * @return int + * @throws \Exception + * @api + */ + public function run() + { + $input = new Input(); + $output = new Output(); + + $this->configureIO($input, $output); + + try { + $exitCode = $this->doRun($input, $output); + } catch (\Exception $e) { + if (!$this->catchExceptions) { + throw $e; + } + + $output->renderException($e); + + $exitCode = $e->getCode(); + if (is_numeric($exitCode)) { + $exitCode = (int) $exitCode; + if (0 === $exitCode) { + $exitCode = 1; + } + } else { + $exitCode = 1; + } + } + + if ($this->autoExit) { + if ($exitCode > 255) { + $exitCode = 255; + } + + exit($exitCode); + } + + return $exitCode; + } + + /** + * 执行指令 + * @access public + * @param Input $input + * @param Output $output + * @return int + */ + public function doRun(Input $input, Output $output) + { + if (true === $input->hasParameterOption(['--version', '-V'])) { + $output->writeln($this->getLongVersion()); + + return 0; + } + + $name = $this->getCommandName($input); + + if (true === $input->hasParameterOption(['--help', '-h'])) { + if (!$name) { + $name = 'help'; + $input = new Input(['help']); + } else { + $this->wantHelps = true; + } + } + + if (!$name) { + $name = $this->defaultCommand; + $input = new Input([$this->defaultCommand]); + } + + $command = $this->find($name); + + return $this->doRunCommand($command, $input, $output); + } + + /** + * 设置输入参数定义 + * @access public + * @param InputDefinition $definition + */ + public function setDefinition(InputDefinition $definition): void + { + $this->definition = $definition; + } + + /** + * 获取输入参数定义 + * @access public + * @return InputDefinition The InputDefinition instance + */ + public function getDefinition(): InputDefinition + { + return $this->definition; + } + + /** + * Gets the help message. + * @access public + * @return string A help message. + */ + public function getHelp(): string + { + return $this->getLongVersion(); + } + + /** + * 是否捕获异常 + * @access public + * @param bool $boolean + * @api + */ + public function setCatchExceptions(bool $boolean): void + { + $this->catchExceptions = $boolean; + } + + /** + * 是否自动退出 + * @access public + * @param bool $boolean + * @api + */ + public function setAutoExit(bool $boolean): void + { + $this->autoExit = $boolean; + } + + /** + * 获取完整的版本号 + * @access public + * @return string + */ + public function getLongVersion(): string + { + if ($this->app->version()) { + return sprintf('version %s', $this->app->version()); + } + + return 'Console Tool'; + } + + /** + * 添加指令集 + * @access public + * @param array $commands + */ + public function addCommands(array $commands): void + { + foreach ($commands as $key => $command) { + if (is_subclass_of($command, Command::class)) { + // 注册指令 + $this->addCommand($command, is_numeric($key) ? '' : $key); + } + } + } + + /** + * 添加一个指令 + * @access public + * @param string|Command $command 指令对象或者指令类名 + * @param string $name 指令名 留空则自动获取 + * @return Command|void + */ + public function addCommand(string|Command $command, string $name = '') + { + if ($name) { + $this->commands[$name] = $command; + return; + } + + if (is_string($command)) { + $command = $this->app->invokeClass($command); + } + + $command->setConsole($this); + + if (!$command->isEnabled()) { + $command->setConsole(null); + return; + } + + $command->setApp($this->app); + + if (null === $command->getDefinition()) { + throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', $command::class)); + } + + $this->commands[$command->getName()] = $command; + + foreach ($command->getAliases() as $alias) { + $this->commands[$alias] = $command; + } + + return $command; + } + + /** + * 获取指令 + * @access public + * @param string $name 指令名称 + * @return Command + * @throws InvalidArgumentException + */ + public function getCommand(string $name): Command + { + if (!isset($this->commands[$name])) { + throw new InvalidArgumentException(sprintf('The command "%s" does not exist.', $name)); + } + + $command = $this->commands[$name]; + + if (is_string($command)) { + $command = $this->app->invokeClass($command); + /** @var Command $command */ + $command->setConsole($this); + $command->setApp($this->app); + } + + if ($this->wantHelps) { + $this->wantHelps = false; + + /** @var HelpCommand $helpCommand */ + $helpCommand = $this->getCommand('help'); + $helpCommand->setCommand($command); + + return $helpCommand; + } + + return $command; + } + + /** + * 某个指令是否存在 + * @access public + * @param string $name 指令名称 + * @return bool + */ + public function hasCommand(string $name): bool + { + return isset($this->commands[$name]); + } + + /** + * 获取所有的命名空间 + * @access public + * @return array + */ + public function getNamespaces(): array + { + $namespaces = []; + foreach ($this->commands as $key => $command) { + if (is_string($command)) { + $namespaces = array_merge($namespaces, $this->extractAllNamespaces($key)); + } else { + $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName())); + + foreach ($command->getAliases() as $alias) { + $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias)); + } + } + } + + return array_values(array_unique(array_filter($namespaces))); + } + + /** + * 查找注册命名空间中的名称或缩写。 + * @access public + * @param string $namespace + * @return string + * @throws InvalidArgumentException + */ + public function findNamespace(string $namespace): string + { + $allNamespaces = $this->getNamespaces(); + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { + return preg_quote($matches[1]) . '[^:]*'; + }, $namespace); + $namespaces = preg_grep('{^' . $expr . '}', $allNamespaces); + + if (empty($namespaces)) { + $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); + + if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) { + if (1 == count($alternatives)) { + $message .= "\n\nDid you mean this?\n "; + } else { + $message .= "\n\nDid you mean one of these?\n "; + } + + $message .= implode("\n ", $alternatives); + } + + throw new InvalidArgumentException($message); + } + + $exact = in_array($namespace, $namespaces, true); + if (count($namespaces) > 1 && !$exact) { + throw new InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces)))); + } + + return $exact ? $namespace : reset($namespaces); + } + + /** + * 查找指令 + * @access public + * @param string $name 名称或者别名 + * @return Command + * @throws InvalidArgumentException + */ + public function find(string $name): Command + { + $allCommands = array_keys($this->commands); + + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { + return preg_quote($matches[1]) . '[^:]*'; + }, $name); + + $commands = preg_grep('{^' . $expr . '}', $allCommands); + + if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) { + if (false !== $pos = strrpos($name, ':')) { + $this->findNamespace(substr($name, 0, $pos)); + } + + $message = sprintf('Command "%s" is not defined.', $name); + + if ($alternatives = $this->findAlternatives($name, $allCommands)) { + if (1 == count($alternatives)) { + $message .= "\n\nDid you mean this?\n "; + } else { + $message .= "\n\nDid you mean one of these?\n "; + } + $message .= implode("\n ", $alternatives); + } + + throw new InvalidArgumentException($message); + } + + $exact = in_array($name, $commands, true); + if (count($commands) > 1 && !$exact) { + $suggestions = $this->getAbbreviationSuggestions(array_values($commands)); + + throw new InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions)); + } + + return $this->getCommand($exact ? $name : reset($commands)); + } + + /** + * 获取所有的指令 + * @access public + * @param string $namespace 命名空间 + * @return Command[] + * @api + */ + public function all(?string $namespace = null): array + { + if (null === $namespace) { + return $this->commands; + } + + $commands = []; + foreach ($this->commands as $name => $command) { + if ($this->extractNamespace($name, substr_count($namespace, ':') + 1) === $namespace) { + $commands[$name] = $command; + } + } + + return $commands; + } + + /** + * 配置基于用户的参数和选项的输入和输出实例。 + * @access protected + * @param Input $input 输入实例 + * @param Output $output 输出实例 + */ + protected function configureIO(Input $input, Output $output): void + { + if (true === $input->hasParameterOption(['--ansi'])) { + $output->setDecorated(true); + } elseif (true === $input->hasParameterOption(['--no-ansi'])) { + $output->setDecorated(false); + } + + if (true === $input->hasParameterOption(['--no-interaction', '-n'])) { + $input->setInteractive(false); + } + + if (true === $input->hasParameterOption(['--quiet', '-q'])) { + $output->setVerbosity(Output::VERBOSITY_QUIET); + } elseif ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { + $output->setVerbosity(Output::VERBOSITY_DEBUG); + } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) { + $output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE); + } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) { + $output->setVerbosity(Output::VERBOSITY_VERBOSE); + } + } + + /** + * 执行指令 + * @access protected + * @param Command $command 指令实例 + * @param Input $input 输入实例 + * @param Output $output 输出实例 + * @return int + * @throws \Exception + */ + protected function doRunCommand(Command $command, Input $input, Output $output) + { + return $command->run($input, $output); + } + + /** + * 获取指令的基础名称 + * @access protected + * @param Input $input + * @return string + */ + protected function getCommandName(Input $input): string + { + return $input->getFirstArgument() ?: ''; + } + + /** + * 获取默认输入定义 + * @access protected + * @return InputDefinition + */ + protected function getDefaultInputDefinition(): InputDefinition + { + return new InputDefinition([ + new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), + new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'), + new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this console version'), + new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), + new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), + new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'), + new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'), + new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'), + ]); + } + + /** + * 获取可能的建议 + * @access private + * @param array $abbrevs + * @return string + */ + private function getAbbreviationSuggestions(array $abbrevs): string + { + return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : ''); + } + + /** + * 返回命名空间部分 + * @access public + * @param string $name 指令 + * @param int $limit 部分的命名空间的最大数量 + * @return string + */ + public function extractNamespace(string $name, int $limit = 0): string + { + $parts = explode(':', $name); + array_pop($parts); + + return implode(':', 0 === $limit ? $parts : array_slice($parts, 0, $limit)); + } + + /** + * 查找可替代的建议 + * @access private + * @param string $name + * @param array|\Traversable $collection + * @return array + */ + private function findAlternatives(string $name, array|\Traversable $collection): array + { + $threshold = 1e3; + $alternatives = []; + + $collectionParts = []; + foreach ($collection as $item) { + $collectionParts[$item] = explode(':', $item); + } + + foreach (explode(':', $name) as $i => $subname) { + foreach ($collectionParts as $collectionName => $parts) { + $exists = isset($alternatives[$collectionName]); + if (!isset($parts[$i]) && $exists) { + $alternatives[$collectionName] += $threshold; + continue; + } elseif (!isset($parts[$i])) { + continue; + } + + $lev = levenshtein($subname, $parts[$i]); + if ($lev <= strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) { + $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; + } elseif ($exists) { + $alternatives[$collectionName] += $threshold; + } + } + } + + foreach ($collection as $item) { + $lev = levenshtein($name, $item); + if ($lev <= strlen($name) / 3 || str_contains($item, $name)) { + $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; + } + } + + $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { + return $lev < 2 * $threshold; + }); + asort($alternatives); + + return array_keys($alternatives); + } + + /** + * 返回所有的命名空间 + * @access private + * @param string $name + * @return array + */ + private function extractAllNamespaces(string $name): array + { + $parts = explode(':', $name, -1); + $namespaces = []; + + foreach ($parts as $part) { + if (count($namespaces)) { + $namespaces[] = end($namespaces) . ':' . $part; + } else { + $namespaces[] = $part; + } + } + + return $namespaces; + } + +} diff --git a/vendor/topthink/framework/src/think/Cookie.php b/vendor/topthink/framework/src/think/Cookie.php new file mode 100644 index 0000000..585d812 --- /dev/null +++ b/vendor/topthink/framework/src/think/Cookie.php @@ -0,0 +1,223 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace think; + +use DateTimeInterface; + +/** + * Cookie管理类 + * @package think + */ +class Cookie +{ + /** + * 配置参数 + * @var array + */ + protected $config = [ + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => false, + // samesite 设置,支持 'strict' 'lax' + 'samesite' => '', + ]; + + /** + * Cookie写入数据 + * @var array + */ + protected $cookie = []; + + /** + * 构造方法 + * @access public + */ + public function __construct(protected Request $request, array $config = []) + { + $this->config = array_merge($this->config, array_change_key_case($config)); + } + + public static function __make(Request $request, Config $config) + { + return new static($request, $config->get('cookie')); + } + + /** + * 获取cookie + * @access public + * @param mixed $name 数据名称 + * @param string $default 默认值 + * @return mixed + */ + public function get(string $name = '', $default = null) + { + return $this->request->cookie($name, $default); + } + + /** + * 是否存在Cookie参数 + * @access public + * @param string $name 变量名 + * @return bool + */ + public function has(string $name): bool + { + return $this->request->has($name, 'cookie'); + } + + /** + * Cookie 设置 + * + * @access public + * @param string $name cookie名称 + * @param string $value cookie值 + * @param mixed $option 可选参数 + * @return void + */ + public function set(string $name, string $value, $option = null): void + { + // 参数设置(会覆盖黙认设置) + if (!is_null($option)) { + if (is_numeric($option) || $option instanceof DateTimeInterface) { + $option = ['expire' => $option]; + } + + $config = array_merge($this->config, array_change_key_case($option)); + } else { + $config = $this->config; + } + + if ($config['expire'] instanceof DateTimeInterface) { + $expire = $config['expire']->getTimestamp(); + } else { + $expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0; + } + + $this->setCookie($name, $value, $expire, $config); + $this->request->setCookie($name, $value); + } + + /** + * Cookie 保存 + * + * @access public + * @param string $name cookie名称 + * @param string $value cookie值 + * @param int $expire 有效期 + * @param array $option 可选参数 + * @return void + */ + protected function setCookie(string $name, string $value, int $expire, array $option = []): void + { + $this->cookie[$name] = [$value, $expire, $option]; + } + + /** + * 永久保存Cookie数据 + * @access public + * @param string $name cookie名称 + * @param string $value cookie值 + * @param mixed $option 可选参数 可能会是 null|integer|string + * @return void + */ + public function forever(string $name, string $value = '', $option = null): void + { + if (is_null($option) || is_numeric($option)) { + $option = []; + } + + $option['expire'] = 315360000; + + $this->set($name, $value, $option); + } + + /** + * Cookie删除 + * @access public + * @param string $name cookie名称 + * @param array $options cookie参数 + * @return void + */ + public function delete(string $name, array $options = []): void + { + $config = array_merge($this->config, array_change_key_case($options)); + $this->setCookie($name, '', time() - 3600, $config); + $this->request->setCookie($name, null); + } + + /** + * 获取cookie保存数据 + * @access public + * @return array + */ + public function getCookie(): array + { + return $this->cookie; + } + + /** + * 保存Cookie + * @access public + * @return void + */ + public function save(): void + { + foreach ($this->cookie as $name => $val) { + [$value, $expire, $option] = $val; + + $this->saveCookie( + (string) $name, + $value, + $expire, + $option['path'], + $option['domain'], + (bool) $option['secure'], + (bool) $option['httponly'], + $option['samesite'], + ); + } + } + + /** + * 保存Cookie + * @access public + * @param string $name cookie名称 + * @param string $value cookie值 + * @param int $expire cookie过期时间 + * @param string $path 有效的服务器路径 + * @param string $domain 有效域名/子域名 + * @param bool $secure 是否仅仅通过HTTPS + * @param bool $httponly 仅可通过HTTP访问 + * @param string $samesite 防止CSRF攻击和用户追踪 + * @return void + */ + protected function saveCookie(string $name, string $value, int $expire, string $path, string $domain, bool $secure, bool $httponly, string $samesite): void + { + setcookie($name, $value, [ + 'expires' => $expire, + 'path' => $path, + 'domain' => $domain, + 'secure' => $secure, + 'httponly' => $httponly, + 'samesite' => $samesite, + ]); + } +} diff --git a/vendor/topthink/framework/src/think/Db.php b/vendor/topthink/framework/src/think/Db.php new file mode 100644 index 0000000..c3c04a6 --- /dev/null +++ b/vendor/topthink/framework/src/think/Db.php @@ -0,0 +1,117 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +/** + * 数据库管理类 + * @package think + * @property Config $config + */ +class Db extends DbManager +{ + /** + * @param Event $event + * @param Config $config + * @param Log $log + * @param Cache $cache + * @return Db + * @codeCoverageIgnore + */ + public static function __make(Event $event, Config $config, Log $log, Cache $cache) + { + $db = new static(); + $db->setConfig($config); + $db->setEvent($event); + $db->setLog($log); + + $store = $db->getConfig('cache_store'); + $db->setCache($cache->store($store)); + $db->triggerSql(); + + return $db; + } + + /** + * 注入模型对象 + * @access public + * @return void + */ + protected function modelMaker(): void + { + } + + /** + * 设置配置对象 + * @access public + * @param Config $config 配置对象 + * @return void + */ + public function setConfig($config): void + { + $this->config = $config; + } + + /** + * 获取配置参数 + * @access public + * @param string $name 配置参数 + * @param mixed $default 默认值 + * @return mixed + */ + public function getConfig(string $name = '', $default = null) + { + if ('' !== $name) { + return $this->config->get('database.' . $name, $default); + } + + return $this->config->get('database', []); + } + + /** + * 设置Event对象 + * @param Event $event + */ + public function setEvent(Event $event): void + { + $this->event = $event; + } + + /** + * 注册回调方法 + * @access public + * @param string $event 事件名 + * @param callable $callback 回调方法 + * @return void + */ + public function event(string $event, callable $callback): void + { + if ($this->event) { + $this->event->listen('db.' . $event, $callback); + } + } + + /** + * 触发事件 + * @access public + * @param string $event 事件名 + * @param mixed $params 传入参数 + * @param bool $once + * @return mixed + */ + public function trigger(string $event, $params = null, bool $once = false) + { + if ($this->event) { + return $this->event->trigger('db.' . $event, $params, $once); + } + } +} diff --git a/vendor/topthink/framework/src/think/Env.php b/vendor/topthink/framework/src/think/Env.php new file mode 100644 index 0000000..91e54a5 --- /dev/null +++ b/vendor/topthink/framework/src/think/Env.php @@ -0,0 +1,199 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use ArrayAccess; + +/** + * Env管理类 + * @package think + */ +class Env implements ArrayAccess +{ + /** + * 环境变量数据 + * @var array + */ + protected $data = []; + + /** + * 数据转换映射 + * @var array + */ + protected $convert = [ + 'true' => true, + 'false' => false, + 'off' => false, + 'on' => true, + ]; + + public function __construct() + { + $this->data = $_ENV; + } + + /** + * 读取环境变量定义文件 + * @access public + * @param string $file 环境变量定义文件 + * @return void + */ + public function load(string $file): void + { + $env = parse_ini_file($file, true, INI_SCANNER_RAW) ?: []; + $this->set($env); + } + + /** + * 获取环境变量值 + * @access public + * @param string $name 环境变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get(?string $name = null, $default = null) + { + if (is_null($name)) { + return $this->data; + } + + $name = strtoupper(str_replace('.', '_', $name)); + if (isset($this->data[$name])) { + $result = $this->data[$name]; + + if (is_string($result) && isset($this->convert[$result])) { + return $this->convert[$result]; + } + + return $result; + } + + return $this->getEnv($name, $default); + } + + protected function getEnv(string $name, $default = null) + { + $result = getenv('PHP_' . $name); + + if (false === $result) { + return $default; + } + + if (isset($this->convert[$result])) { + $result = $this->convert[$result]; + } + + if (!isset($this->data[$name])) { + $this->data[$name] = $result; + } + + return $result; + } + + /** + * 设置环境变量值 + * @access public + * @param string|array $env 环境变量 + * @param mixed $value 值 + * @return void + */ + public function set($env, $value = null): void + { + if (is_array($env)) { + $env = array_change_key_case($env, CASE_UPPER); + + foreach ($env as $key => $val) { + if (is_array($val)) { + foreach ($val as $k => $v) { + if (is_string($k)) { + $this->data[$key . '_' . strtoupper($k)] = $v; + } else { + $this->data[$key][$k] = $v; + } + } + } else { + $this->data[$key] = $val; + } + } + } else { + $name = strtoupper(str_replace('.', '_', $env)); + + $this->data[$name] = $value; + } + } + + /** + * 检测是否存在环境变量 + * @access public + * @param string $name 参数名 + * @return bool + */ + public function has(string $name): bool + { + return !is_null($this->get($name)); + } + + /** + * 设置环境变量 + * @access public + * @param string $name 参数名 + * @param mixed $value 值 + */ + public function __set(string $name, $value): void + { + $this->set($name, $value); + } + + /** + * 获取环境变量 + * @access public + * @param string $name 参数名 + * @return mixed + */ + public function __get(string $name) + { + return $this->get($name); + } + + /** + * 检测是否存在环境变量 + * @access public + * @param string $name 参数名 + * @return bool + */ + public function __isset(string $name): bool + { + return $this->has($name); + } + + // ArrayAccess + public function offsetSet(mixed $name, mixed $value): void + { + $this->set($name, $value); + } + + public function offsetExists(mixed $name): bool + { + return $this->__isset($name); + } + + public function offsetUnset(mixed $name): void + { + throw new Exception('not support: unset'); + } + + public function offsetGet(mixed $name): mixed + { + return $this->get($name); + } +} diff --git a/vendor/topthink/framework/src/think/Event.php b/vendor/topthink/framework/src/think/Event.php new file mode 100644 index 0000000..f653954 --- /dev/null +++ b/vendor/topthink/framework/src/think/Event.php @@ -0,0 +1,291 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use ReflectionClass; +use ReflectionMethod; +use think\helper\Str; + +/** + * 事件管理类 + * @package think + */ +class Event +{ + /** + * 监听者 + * @var array + */ + protected $listener = []; + + /** + * 观察者 + * @var array + */ + protected $observer = []; + + /** + * 事件别名 + * @var array + */ + protected $bind = [ + 'AppInit' => event\AppInit::class, + 'HttpRun' => event\HttpRun::class, + 'HttpEnd' => event\HttpEnd::class, + 'RouteLoaded' => event\RouteLoaded::class, + 'LogWrite' => event\LogWrite::class, + 'LogRecord' => event\LogRecord::class, + ]; + + /** + * 应用对象 + * @var App + */ + protected $app; + + public function __construct(App $app) + { + $this->app = $app; + } + + /** + * 批量注册事件监听 + * @access public + * @param array $events 事件定义 + * @return $this + */ + public function listenEvents(array $events) + { + foreach ($events as $event => $listeners) { + if (isset($this->bind[$event])) { + $event = $this->bind[$event]; + } + + $this->listener[$event] = array_merge($this->listener[$event] ?? [], $listeners); + } + + return $this; + } + + /** + * 注册事件监听 + * @access public + * @param string $event 事件名称 + * @param mixed $listener 监听操作(或者类名) + * @param bool $first 是否优先执行 + * @return $this + */ + public function listen(string $event, $listener, bool $first = false) + { + if (isset($this->bind[$event])) { + $event = $this->bind[$event]; + } + + if ($first && isset($this->listener[$event])) { + array_unshift($this->listener[$event], $listener); + } else { + $this->listener[$event][] = $listener; + } + + return $this; + } + + /** + * 是否存在事件监听 + * @access public + * @param string $event 事件名称 + * @return bool + */ + public function hasListener(string $event): bool + { + if (isset($this->bind[$event])) { + $event = $this->bind[$event]; + } + + return isset($this->listener[$event]); + } + + /** + * 移除事件监听 + * @access public + * @param string $event 事件名称 + * @return void + */ + public function remove(string $event): void + { + if (isset($this->bind[$event])) { + $event = $this->bind[$event]; + } + + unset($this->listener[$event]); + } + + /** + * 指定事件别名标识 便于调用 + * @access public + * @param array $events 事件别名 + * @return $this + */ + public function bind(array $events) + { + $this->bind = array_merge($this->bind, $events); + + return $this; + } + + /** + * 注册事件订阅者 + * @access public + * @param mixed $subscriber 订阅者 + * @return $this + */ + public function subscribe($subscriber) + { + $subscribers = is_object($subscriber) ? [$subscriber] : (array) $subscriber; + + foreach ($subscribers as $name => $subscriber) { + if (is_string($subscriber)) { + $subscriber = $this->app->make($subscriber); + } + + if (method_exists($subscriber, 'subscribe')) { + // 手动订阅 + $subscriber->subscribe($this); + } elseif (!is_numeric($name)) { + // 注册观察者 + $this->observer[$name] = $subscriber; + } else { + // 智能订阅 + $this->observe($subscriber); + } + } + + return $this; + } + + /** + * 自动注册事件监听 + * @access public + * @param string|object $observer 观察者 + * @param null|string $prefix 事件名前缀 + * @return $this + */ + public function observe($observer, string $prefix = '') + { + if (is_string($observer)) { + $observer = $this->app->make($observer); + } + + $reflect = new ReflectionClass($observer); + $methods = $reflect->getMethods(ReflectionMethod::IS_PUBLIC); + + if (empty($prefix) && $reflect->hasProperty('eventPrefix')) { + $reflectProperty = $reflect->getProperty('eventPrefix'); + $reflectProperty->setAccessible(true); + $prefix = $reflectProperty->getValue($observer); + } + + foreach ($methods as $method) { + $name = $method->getName(); + if (str_starts_with($name, 'on')) { + $this->listen($prefix . substr($name, 2), [$observer, $name]); + } + } + + return $this; + } + + /** + * 触发事件 + * @access public + * @param string|object $event 事件名称 + * @param mixed $params 传入参数 + * @param bool $once 只获取一个有效返回值 + * @return mixed + */ + public function trigger($event, $params = null, bool $once = false) + { + if (is_object($event)) { + $params = $event; + $event = $event::class; + } + + if (isset($this->bind[$event])) { + $event = $this->bind[$event]; + } + + $result = []; + $listeners = $this->listener[$event] ?? []; + + if (str_contains($event, '.')) { + [$prefix, $name] = explode('.', $event, 2); + if (isset($this->observer[$prefix])) { + // 检查观察者事件响应方法 + $observer = $this->observer[$prefix]; + $method = 'on' . Str::studly($name); + if (method_exists($observer, $method)) { + return $this->dispatch([$observer, $method], $params); + } + } + + $name = substr($event, 0, strrpos($event, '.')); + if (isset($this->listener[$name . '.*'])) { + $listeners = array_merge($listeners, $this->listener[$name . '.*']); + } + } + + $listeners = array_unique($listeners, SORT_REGULAR); + + foreach ($listeners as $key => $listener) { + $result[$key] = $this->dispatch($listener, $params); + + if (false === $result[$key] || (!is_null($result[$key]) && $once)) { + break; + } + } + + return $once ? end($result) : $result; + } + + /** + * 触发事件(只获取一个有效返回值) + * @param $event + * @param null $params + * @return mixed + */ + public function until($event, $params = null) + { + return $this->trigger($event, $params, true); + } + + /** + * 执行事件调度 + * @access protected + * @param mixed $event 事件方法 + * @param mixed $params 参数 + * @return mixed + */ + protected function dispatch($event, $params = null) + { + if (!is_string($event)) { + $call = $event; + } elseif (str_contains($event, '::')) { + $call = $event; + } else { + $obj = $this->app->make($event); + $call = [$obj, 'handle']; + } + + return $this->app->invoke($call, [$params]); + } +} diff --git a/vendor/topthink/framework/src/think/Exception.php b/vendor/topthink/framework/src/think/Exception.php new file mode 100644 index 0000000..048c336 --- /dev/null +++ b/vendor/topthink/framework/src/think/Exception.php @@ -0,0 +1,59 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +/** + * 异常基础类 + * @package think + */ +class Exception extends \Exception +{ + /** + * 保存异常页面显示的额外Debug数据 + * @var array + */ + protected $data = []; + + /** + * 设置异常额外的Debug数据 + * 数据将会显示为下面的格式 + * + * Exception Data + * -------------------------------------------------- + * Label 1 + * key1 value1 + * key2 value2 + * Label 2 + * key1 value1 + * key2 value2 + * + * @access protected + * @param string $label 数据分类,用于异常页面显示 + * @param array $data 需要显示的数据,必须为关联数组 + */ + final protected function setData(string $label, array $data) + { + $this->data[$label] = $data; + } + + /** + * 获取异常额外Debug数据 + * 主要用于输出到异常页面便于调试 + * @access public + * @return array 由setData设置的Debug数据 + */ + final public function getData(): array + { + return $this->data; + } +} diff --git a/vendor/topthink/framework/src/think/File.php b/vendor/topthink/framework/src/think/File.php new file mode 100644 index 0000000..9651154 --- /dev/null +++ b/vendor/topthink/framework/src/think/File.php @@ -0,0 +1,198 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use SplFileInfo; +use Closure; +use think\exception\FileException; + +/** + * 文件上传类 + * @package think + */ +class File extends SplFileInfo +{ + + /** + * 文件hash规则 + * @var array + */ + protected $hash = []; + + protected $hashName; + + /** + * 保存的文件后缀 + * @var string + */ + protected $extension; + + public function __construct(string $path, bool $checkPath = true) + { + if ($checkPath && !is_file($path)) { + throw new FileException(sprintf('The file "%s" does not exist', $path)); + } + + parent::__construct($path); + } + + /** + * 获取文件的哈希散列值 + * @access public + * @param string $type + * @return string + */ + public function hash(string $type = 'sha1'): string + { + if (!isset($this->hash[$type])) { + $this->hash[$type] = hash_file($type, $this->getPathname()); + } + + return $this->hash[$type]; + } + + /** + * 获取文件的MD5值 + * @access public + * @return string + */ + public function md5(): string + { + return $this->hash('md5'); + } + + /** + * 获取文件的SHA1值 + * @access public + * @return string + */ + public function sha1(): string + { + return $this->hash('sha1'); + } + + /** + * 获取文件类型信息 + * @access public + * @return string + */ + public function getMime(): string + { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + + return finfo_file($finfo, $this->getPathname()); + } + + /** + * 移动文件 + * @access public + * @param string $directory 保存路径 + * @param string|null $name 保存的文件名 + * @return File + */ + public function move(string $directory, ?string $name = null): File + { + $target = $this->getTargetFile($directory, $name); + + set_error_handler(function ($type, $msg) use (&$error) { + $error = $msg; + }); + $renamed = rename($this->getPathname(), (string) $target); + restore_error_handler(); + if (!$renamed) { + throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error))); + } + + @chmod((string) $target, 0666 & ~umask()); + + return $target; + } + + /** + * 实例化一个新文件 + * @param string $directory + * @param null|string $name + * @return File + */ + protected function getTargetFile(string $directory, ?string $name = null): File + { + if (!is_dir($directory)) { + if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) { + throw new FileException(sprintf('Unable to create the "%s" directory', $directory)); + } + } elseif (!is_writable($directory)) { + throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); + } + + $target = rtrim($directory, '/\\') . \DIRECTORY_SEPARATOR . (null === $name ? $this->getBasename() : $this->getName($name)); + + return new self($target, false); + } + + /** + * 获取文件名 + * @param string $name + * @return string + */ + protected function getName(string $name): string + { + $originalName = str_replace('\\', '/', $name); + $pos = strrpos($originalName, '/'); + $originalName = false === $pos ? $originalName : substr($originalName, $pos + 1); + + return $originalName; + } + + /** + * 文件扩展名 + * @return string + */ + public function extension(): string + { + return $this->getExtension(); + } + + /** + * 指定保存文件的扩展名 + * @param string $extension + * @return void + */ + public function setExtension(string $extension): void + { + $this->extension = $extension; + } + + /** + * 自动生成文件名 + * @access public + * @param string|Closure|null $rule + * @return string + */ + public function hashName(string|Closure|null $rule = null): string + { + if (!$this->hashName) { + if ($rule instanceof Closure) { + $this->hashName = call_user_func_array($rule, [$this]); + } else { + $this->hashName = match (true) { + in_array($rule, hash_algos()) && $hash = $this->hash($rule) => substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2), + is_callable($rule) => call_user_func($rule), + default => date('Ymd') . DIRECTORY_SEPARATOR . md5(microtime(true) . $this->getPathname()), + }; + } + } + + $extension = $this->extension ?? $this->extension(); + return $this->hashName . ($extension ? '.' . $extension : ''); + } +} diff --git a/vendor/topthink/framework/src/think/Http.php b/vendor/topthink/framework/src/think/Http.php new file mode 100644 index 0000000..ff0456d --- /dev/null +++ b/vendor/topthink/framework/src/think/Http.php @@ -0,0 +1,279 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use think\event\HttpEnd; +use think\event\HttpRun; +use think\event\RouteLoaded; +use think\exception\Handle; +use Throwable; + +/** + * Web应用管理类 + * @package think + */ +class Http +{ + /** + * 应用名称 + * @var string + */ + protected $name; + + /** + * 应用路径 + * @var string + */ + protected $path; + + /** + * 路由路径 + * @var string + */ + protected $routePath; + + /** + * 是否绑定应用 + * @var bool + */ + protected $isBind = false; + + public function __construct(protected App $app) + { + $this->routePath = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; + } + + /** + * 设置应用名称 + * @access public + * @param string $name 应用名称 + * @return $this + */ + public function name(string $name) + { + $this->name = $name; + return $this; + } + + /** + * 获取应用名称 + * @access public + * @return string + */ + public function getName(): string + { + return $this->name ?: ''; + } + + /** + * 设置应用目录 + * @access public + * @param string $path 应用目录 + * @return $this + */ + public function path(string $path) + { + if (str_ends_with($path, DIRECTORY_SEPARATOR)) { + $path .= DIRECTORY_SEPARATOR; + } + + $this->path = $path; + return $this; + } + + /** + * 获取应用路径 + * @access public + * @return string + */ + public function getPath(): string + { + return $this->path ?: ''; + } + + /** + * 获取路由目录 + * @access public + * @return string + */ + public function getRoutePath(): string + { + return $this->routePath; + } + + /** + * 设置路由目录 + * @access public + * @param string $path 路由定义目录 + */ + public function setRoutePath(string $path): void + { + $this->routePath = $path; + } + + /** + * 设置应用绑定 + * @access public + * @param bool $bind 是否绑定 + * @return $this + */ + public function setBind(bool $bind = true) + { + $this->isBind = $bind; + return $this; + } + + /** + * 是否绑定应用 + * @access public + * @return bool + */ + public function isBind(): bool + { + return $this->isBind; + } + + /** + * 执行应用程序 + * @access public + * @param Request|null $request + * @return Response + */ + public function run(?Request $request = null): Response + { + //初始化 + $this->initialize(); + + //自动创建request对象 + $request = $request ?? $this->app->make('request', [], true); + $this->app->instance('request', $request); + + try { + $response = $this->runWithRequest($request); + } catch (Throwable $e) { + $this->reportException($e); + + $response = $this->renderException($request, $e); + } + + return $response; + } + + /** + * 初始化 + */ + protected function initialize() + { + if (!$this->app->initialized()) { + $this->app->initialize(); + } + } + + /** + * 执行应用程序 + * @param Request $request + * @return mixed + */ + protected function runWithRequest(Request $request) + { + // 加载全局中间件 + $this->loadMiddleware(); + + // 监听HttpRun + $this->app->event->trigger(HttpRun::class); + + return $this->app->middleware->pipeline() + ->send($request) + ->then(function ($request) { + return $this->dispatchToRoute($request); + }); + } + + protected function dispatchToRoute($request) + { + $withRoute = $this->app->config->get('app.with_route', true) ? function () { + $this->loadRoutes(); + } : false; + + return $this->app->route->dispatch($request, $withRoute); + } + + /** + * 加载全局中间件 + */ + protected function loadMiddleware(): void + { + if (is_file($this->app->getBasePath() . 'middleware.php')) { + $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); + } + } + + /** + * 加载路由 + * @access protected + * @return void + */ + protected function loadRoutes(): void + { + // 加载路由定义 + $routePath = $this->getRoutePath(); + + if (is_dir($routePath)) { + $files = glob($routePath . '*.php'); + foreach ($files as $file) { + include $file; + } + } + + $this->app->event->trigger(RouteLoaded::class); + } + + /** + * Report the exception to the exception handler. + * + * @param Throwable $e + * @return void + */ + protected function reportException(Throwable $e) + { + $this->app->make(Handle::class)->report($e); + } + + /** + * Render the exception to a response. + * + * @param Request $request + * @param Throwable $e + * @return Response + */ + protected function renderException($request, Throwable $e) + { + return $this->app->make(Handle::class)->render($request, $e); + } + + /** + * HttpEnd + * @param Response $response + * @return void + */ + public function end(Response $response): void + { + $this->app->event->trigger(HttpEnd::class, $response); + + //执行中间件 + $this->app->middleware->end($response); + + // 写入日志 + $this->app->log->save(); + } +} diff --git a/vendor/topthink/framework/src/think/Lang.php b/vendor/topthink/framework/src/think/Lang.php new file mode 100644 index 0000000..a310dc9 --- /dev/null +++ b/vendor/topthink/framework/src/think/Lang.php @@ -0,0 +1,273 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +/** + * 多语言管理类 + * @package think + */ +class Lang +{ + protected $app; + + /** + * 配置参数 + * @var array + */ + protected $config = [ + // 默认语言 + 'default_lang' => 'zh-cn', + // 自动侦测浏览器语言 + 'auto_detect_browser' => true, + // 允许的语言列表 + 'allow_lang_list' => [], + // 是否使用Cookie记录 + 'use_cookie' => true, + // 扩展语言包 + 'extend_list' => [], + // 多语言cookie变量 + 'cookie_var' => 'think_lang', + // 多语言header变量 + 'header_var' => 'think-lang', + // 多语言自动侦测变量名 + 'detect_var' => 'lang', + // Accept-Language转义为对应语言包名称 + 'accept_language' => [ + 'zh-hans-cn' => 'zh-cn', + ], + // 是否支持语言分组 + 'allow_group' => false, + ]; + + /** + * 多语言信息 + * @var array + */ + private $lang = []; + + /** + * 当前语言 + * @var string + */ + private $range = 'zh-cn'; + + /** + * 构造方法 + * @access public + * @param array $config + */ + public function __construct(App $app, array $config = []) + { + $this->config = array_merge($this->config, array_change_key_case($config)); + $this->range = $this->config['default_lang']; + $this->app = $app; + } + + public static function __make(App $app, Config $config) + { + return new static($app, $config->get('lang')); + } + + /** + * 获取当前语言配置 + * @access public + * @return array + */ + public function getConfig(): array + { + return $this->config; + } + + /** + * 设置当前语言 + * @access public + * @param string $lang 语言 + * @return void + */ + public function setLangSet(string $lang): void + { + $this->range = $lang; + } + + /** + * 获取当前语言 + * @access public + * @return string + */ + public function getLangSet(): string + { + return $this->range; + } + + /** + * 获取默认语言 + * @access public + * @return string + */ + public function defaultLangSet() + { + return $this->config['default_lang']; + } + + /** + * 切换语言 + * @access public + * @param string $langset 语言 + * @return void + */ + public function switchLangSet(string $langset) + { + if (empty($langset)) { + return; + } + + $this->setLangSet($langset); + + // 加载系统语言包 + $this->load([ + $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php', + ]); + + // 加载应用语言包(支持多种类型) + $files = glob($this->app->getAppPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*'); + $this->load($files); + + // 加载扩展(自定义)语言包 + $list = $this->app->config->get('lang.extend_list', []); + + if (isset($list[$langset])) { + $this->load($list[$langset]); + } + } + + /** + * 加载语言定义(不区分大小写) + * @access public + * @param string|array $file 语言文件 + * @param string $range 语言作用域 + * @return array + */ + public function load($file, $range = ''): array + { + $range = $range ?: $this->range; + if (!isset($this->lang[$range])) { + $this->lang[$range] = []; + } + + $lang = []; + + foreach ((array) $file as $name) { + if (is_file($name)) { + $result = $this->parse($name); + $lang = array_change_key_case($result) + $lang; + } + } + + if (!empty($lang)) { + $this->lang[$range] = $lang + $this->lang[$range]; + } + + return $this->lang[$range]; + } + + /** + * 解析语言文件 + * @access protected + * @param string $file 语言文件名 + * @return array + */ + protected function parse(string $file): array + { + $type = pathinfo($file, PATHINFO_EXTENSION); + $result = match ($type) { + 'php' => include $file, + 'yml', 'yaml' => function_exists('yaml_parse_file') ? yaml_parse_file($file) : [], + 'json' => json_decode(file_get_contents($file), true), + default => [], + }; + + return is_array($result) ? $result : []; + } + + /** + * 判断是否存在语言定义(不区分大小写) + * @access public + * @param string $name 语言变量 + * @param string $range 语言作用域 + * @return bool + */ + public function has(string $name, string $range = ''): bool + { + $range = $range ?: $this->range; + + if ($this->config['allow_group'] && str_contains($name, '.')) { + [$name1, $name2] = explode('.', $name, 2); + return isset($this->lang[$range][strtolower($name1)][$name2]); + } + + return isset($this->lang[$range][strtolower($name)]); + } + + /** + * 获取语言定义(不区分大小写) + * @access public + * @param string|null $name 语言变量 + * @param array $vars 变量替换 + * @param string $range 语言作用域 + * @return mixed + */ + public function get(?string $name = null, array $vars = [], string $range = '') + { + $range = $range ?: $this->range; + + if (!isset($this->lang[$range])) { + $this->switchLangSet($range); + } + + // 空参数返回所有定义 + if (is_null($name)) { + return $this->lang[$range] ?? []; + } + + if ($this->config['allow_group'] && str_contains($name, '.')) { + [$name1, $name2] = explode('.', $name, 2); + + $value = $this->lang[$range][strtolower($name1)][$name2] ?? $name; + } else { + $value = $this->lang[$range][strtolower($name)] ?? $name; + } + + // 变量解析 + if (!empty($vars) && is_array($vars)) { + /** + * Notes: + * 为了检测的方便,数字索引的判断仅仅是参数数组的第一个元素的key为数字0 + * 数字索引采用的是系统的 sprintf 函数替换,用法请参考 sprintf 函数 + */ + if (key($vars) === 0) { + // 数字索引解析 + array_unshift($vars, $value); + $value = call_user_func_array('sprintf', $vars); + } else { + // 关联索引解析 + $replace = array_keys($vars); + foreach ($replace as &$v) { + $v = "{:{$v}}"; + } + $value = str_replace($replace, $vars, $value); + } + } + + return $value; + } +} diff --git a/vendor/topthink/framework/src/think/Log.php b/vendor/topthink/framework/src/think/Log.php new file mode 100644 index 0000000..990f4e8 --- /dev/null +++ b/vendor/topthink/framework/src/think/Log.php @@ -0,0 +1,249 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use InvalidArgumentException; +use Psr\Log\LoggerInterface; +use Psr\Log\LoggerTrait; +use Stringable; +use think\event\LogWrite; +use think\helper\Arr; +use think\log\Channel; +use think\log\ChannelSet; + +/** + * 日志管理类 + * @package think + * @mixin Channel + */ +class Log extends Manager implements LoggerInterface +{ + use LoggerTrait; + const EMERGENCY = 'emergency'; + const ALERT = 'alert'; + const CRITICAL = 'critical'; + const ERROR = 'error'; + const WARNING = 'warning'; + const NOTICE = 'notice'; + const INFO = 'info'; + const DEBUG = 'debug'; + const SQL = 'sql'; + + protected $namespace = '\\think\\log\\driver\\'; + + /** + * 默认驱动 + * @return string|null + */ + public function getDefaultDriver(): ?string + { + return $this->getConfig('default'); + } + + /** + * 获取日志配置 + * @access public + * @param null|string $name 名称 + * @param mixed $default 默认值 + * @return mixed + */ + public function getConfig(?string $name = null, $default = null) + { + if (!is_null($name)) { + return $this->app->config->get('log.' . $name, $default); + } + + return $this->app->config->get('log'); + } + + /** + * 获取渠道配置 + * @param string $channel + * @param string $name + * @param mixed $default + * @return array + */ + public function getChannelConfig(string $channel, ?string $name = null, $default = null) + { + if ($config = $this->getConfig("channels.{$channel}")) { + return Arr::get($config, $name, $default); + } + + throw new InvalidArgumentException("Channel [$channel] not found."); + } + + /** + * driver()的别名 + * @param string|array $name 渠道名 + * @return Channel|ChannelSet + */ + public function channel(string|array|null $name = null) + { + if (is_array($name)) { + return new ChannelSet($this, $name); + } + + return $this->driver($name); + } + + protected function resolveType(string $name) + { + return $this->getChannelConfig($name, 'type', 'file'); + } + + public function createDriver(string $name) + { + $driver = parent::createDriver($name); + + $lazy = !$this->getChannelConfig($name, "realtime_write", false) && !$this->app->runningInConsole(); + $allow = array_merge($this->getConfig("level", []), $this->getChannelConfig($name, "level", [])); + + return new Channel($name, $driver, $allow, $lazy, $this->app->event); + } + + protected function resolveConfig(string $name) + { + return $this->getChannelConfig($name); + } + + /** + * 清空日志信息 + * @access public + * @param string|array $channel 日志通道名 + * @return $this + */ + public function clear(string|array $channel = '*') + { + if ('*' == $channel) { + $channel = array_keys($this->drivers); + } + + $this->channel($channel)->clear(); + + return $this; + } + + /** + * 关闭本次请求日志写入 + * @access public + * @param string|array $channel 日志通道名 + * @return $this + */ + public function close(string|array $channel = '*') + { + if ('*' == $channel) { + $channel = array_keys($this->drivers); + } + + $this->channel($channel)->close(); + + return $this; + } + + /** + * 获取日志信息 + * @access public + * @param string $channel 日志通道名 + * @return array + */ + public function getLog(?string $channel = null): array + { + return $this->channel($channel)->getLog(); + } + + /** + * 保存日志信息 + * @access public + * @return bool + */ + public function save(): bool + { + /** @var Channel $channel */ + foreach ($this->drivers as $channel) { + $channel->save(); + } + + return true; + } + + /** + * 记录日志信息 + * @access public + * @param mixed $msg 日志信息 + * @param string $type 日志级别 + * @param array $context 替换内容 + * @param bool $lazy + * @return $this + */ + public function record($msg, string $type = 'info', array $context = [], bool $lazy = true) + { + $channel = $this->getConfig('type_channel.' . $type); + + $this->channel($channel)->record($msg, $type, $context, $lazy); + + return $this; + } + + /** + * 实时写入日志信息 + * @access public + * @param mixed $msg 调试信息 + * @param string $type 日志级别 + * @param array $context 替换内容 + * @return $this + */ + public function write($msg, string $type = 'info', array $context = []) + { + return $this->record($msg, $type, $context, false); + } + + /** + * 注册日志写入事件监听 + * @param $listener + * @return Event + */ + public function listen($listener) + { + return $this->app->event->listen(LogWrite::class, $listener); + } + + /** + * 记录日志信息 + * @access public + * @param mixed $level 日志级别 + * @param string|Stringable $message 日志信息 + * @param array $context 替换内容 + * @return void + */ + public function log($level, $message, array $context = []): void + { + $this->record($message, $level, $context); + } + + /** + * 记录sql信息 + * @access public + * @param string|Stringable $message 日志信息 + * @param array $context 替换内容 + * @return void + */ + public function sql($message, array $context = []): void + { + $this->log(__FUNCTION__, $message, $context); + } + + public function __call($method, $parameters) + { + $this->log($method, ...$parameters); + } +} diff --git a/vendor/topthink/framework/src/think/Manager.php b/vendor/topthink/framework/src/think/Manager.php new file mode 100644 index 0000000..d423d12 --- /dev/null +++ b/vendor/topthink/framework/src/think/Manager.php @@ -0,0 +1,173 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use InvalidArgumentException; +use think\helper\Str; + +abstract class Manager +{ + /** + * 驱动 + * @var array + */ + protected $drivers = []; + + /** + * 驱动的命名空间 + * @var string + */ + protected $namespace = null; + + public function __construct(protected App $app) + { + } + + /** + * 获取驱动实例 + * @param null|string $name + * @return mixed + */ + protected function driver(?string $name = null) + { + $name = $name ?: $this->getDefaultDriver(); + + if (is_null($name)) { + throw new InvalidArgumentException(sprintf( + 'Unable to resolve NULL driver for [%s].', + static::class + )); + } + + return $this->drivers[$name] = $this->getDriver($name); + } + + /** + * 获取驱动实例 + * @param string $name + * @return mixed + */ + protected function getDriver(string $name) + { + return $this->drivers[$name] ?? $this->createDriver($name); + } + + /** + * 获取驱动类型 + * @param string $name + * @return mixed + */ + protected function resolveType(string $name) + { + return $name; + } + + /** + * 获取驱动配置 + * @param string $name + * @return mixed + */ + protected function resolveConfig(string $name) + { + return $name; + } + + /** + * 获取驱动类 + * @param string $type + * @return string + */ + protected function resolveClass(string $type): string + { + if ($this->namespace || str_contains($type, '\\')) { + $class = str_contains($type, '\\') ? $type : $this->namespace . Str::studly($type); + + if (class_exists($class)) { + return $class; + } + } + + throw new InvalidArgumentException("Driver [$type] not supported."); + } + + /** + * 获取驱动参数 + * @param $name + * @return array + */ + protected function resolveParams($name): array + { + $config = $this->resolveConfig($name); + return [$config]; + } + + /** + * 创建驱动 + * + * @param string $name + * @return mixed + * + */ + protected function createDriver(string $name) + { + $type = $this->resolveType($name); + + $method = 'create' . Str::studly($type) . 'Driver'; + + $params = $this->resolveParams($name); + + if (method_exists($this, $method)) { + return $this->$method(...$params); + } + + $class = $this->resolveClass($type); + + return $this->app->invokeClass($class, $params); + } + + /** + * 移除一个驱动实例 + * + * @param array|string|null $name + * @return $this + */ + public function forgetDriver($name = null) + { + $name = $name ?? $this->getDefaultDriver(); + + foreach ((array) $name as $cacheName) { + if (isset($this->drivers[$cacheName])) { + unset($this->drivers[$cacheName]); + } + } + + return $this; + } + + /** + * 默认驱动 + * @return string|null + */ + abstract public function getDefaultDriver(); + + /** + * 动态调用 + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return $this->driver()->$method(...$parameters); + } +} diff --git a/vendor/topthink/framework/src/think/Middleware.php b/vendor/topthink/framework/src/think/Middleware.php new file mode 100644 index 0000000..82c8adc --- /dev/null +++ b/vendor/topthink/framework/src/think/Middleware.php @@ -0,0 +1,248 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use Closure; +use LogicException; +use think\exception\Handle; +use Throwable; + +/** + * 中间件管理类 + * @package think + */ +class Middleware +{ + /** + * 中间件执行队列 + * @var array + */ + protected $queue = []; + + public function __construct(protected App $app) + { + } + + /** + * 导入中间件 + * @access public + * @param array $middlewares + * @param string $type 中间件类型 + * @return void + */ + public function import(array $middlewares = [], string $type = 'global'): void + { + foreach ($middlewares as $middleware) { + $this->add($middleware, $type); + } + } + + /** + * 注册中间件 + * @access public + * @param mixed $middleware + * @param string $type 中间件类型 + * @return void + */ + public function add(array|string|Closure $middleware, string $type = 'global'): void + { + $middleware = $this->buildMiddleware($middleware, $type); + + if (!empty($middleware)) { + $this->queue[$type][] = $middleware; + $this->queue[$type] = array_unique($this->queue[$type], SORT_REGULAR); + } + } + + /** + * 注册路由中间件 + * @access public + * @param mixed $middleware + * @return void + */ + public function route(array|string|Closure $middleware): void + { + $this->add($middleware, 'route'); + } + + /** + * 注册控制器中间件 + * @access public + * @param mixed $middleware + * @return void + */ + public function controller(array|string|Closure $middleware): void + { + $this->add($middleware, 'controller'); + } + + /** + * 注册中间件到开始位置 + * @access public + * @param mixed $middleware + * @param string $type 中间件类型 + */ + public function unshift(array|string|Closure $middleware, string $type = 'global') + { + $middleware = $this->buildMiddleware($middleware, $type); + + if (!empty($middleware)) { + if (!isset($this->queue[$type])) { + $this->queue[$type] = []; + } + + array_unshift($this->queue[$type], $middleware); + } + } + + /** + * 获取注册的中间件 + * @access public + * @param string $type 中间件类型 + * @return array + */ + public function all(string $type = 'global'): array + { + return $this->queue[$type] ?? []; + } + + /** + * 调度管道 + * @access public + * @param string $type 中间件类型 + * @return Pipeline + */ + public function pipeline(string $type = 'global') + { + return (new Pipeline()) + ->through(array_map(function ($middleware) { + return function ($request, $next) use ($middleware) { + [$call, $params] = $middleware; + if (is_array($call) && is_string($call[0])) { + $call = [$this->app->make($call[0]), $call[1]]; + } + $response = call_user_func($call, $request, $next, ...$params); + + if (!$response instanceof Response) { + throw new LogicException('The middleware must return Response instance'); + } + return $response; + }; + }, $this->sortMiddleware($this->queue[$type] ?? []))) + ->whenException([$this, 'handleException']); + } + + /** + * 结束调度 + * @param Response $response + */ + public function end(Response $response) + { + foreach ($this->queue as $queue) { + foreach ($queue as $middleware) { + [$call] = $middleware; + if (is_array($call) && is_string($call[0])) { + $instance = $this->app->make($call[0]); + if (method_exists($instance, 'end')) { + $instance->end($response); + } + } + } + } + } + + /** + * 异常处理 + * @param Request $passable + * @param Throwable $e + * @return Response + */ + public function handleException($passable, Throwable $e) + { + /** @var Handle $handler */ + $handler = $this->app->make(Handle::class); + + $handler->report($e); + + return $handler->render($passable, $e); + } + + /** + * 解析中间件 + * @access protected + * @param array|string|Closure $middleware + * @param string $type 中间件类型 + * @return array + */ + protected function buildMiddleware(array|string|Closure $middleware, string $type): array + { + if (empty($middleware)) { + return []; + } + + if (is_array($middleware)) { + [$middleware, $params] = $middleware; + } + + if ($middleware instanceof Closure) { + return [$middleware, $params ?? []]; + } + + //中间件别名检查 + $alias = $this->app->config->get('middleware.alias', []); + + if (isset($alias[$middleware])) { + $middleware = $alias[$middleware]; + } + + if (is_array($middleware)) { + $this->import($middleware, $type); + return []; + } + + return [[$middleware, 'handle'], $params ?? []]; + } + + /** + * 中间件排序 + * @param array $middlewares + * @return array + */ + protected function sortMiddleware(array $middlewares) + { + $priority = $this->app->config->get('middleware.priority', []); + uasort($middlewares, function ($a, $b) use ($priority) { + $aPriority = $this->getMiddlewarePriority($priority, $a); + $bPriority = $this->getMiddlewarePriority($priority, $b); + return $bPriority - $aPriority; + }); + + return $middlewares; + } + + /** + * 获取中间件优先级 + * @param $priority + * @param $middleware + * @return int + */ + protected function getMiddlewarePriority($priority, $middleware) + { + [$call] = $middleware; + if (is_array($call) && is_string($call[0])) { + $index = array_search($call[0], array_reverse($priority)); + return false === $index ? -1 : $index; + } + return -1; + } +} diff --git a/vendor/topthink/framework/src/think/Pipeline.php b/vendor/topthink/framework/src/think/Pipeline.php new file mode 100644 index 0000000..9f5c3b3 --- /dev/null +++ b/vendor/topthink/framework/src/think/Pipeline.php @@ -0,0 +1,106 @@ + +// +---------------------------------------------------------------------- +namespace think; + +use Closure; +use Exception; +use Throwable; + +class Pipeline +{ + protected $passable; + + protected $pipes = []; + + protected $exceptionHandler; + + /** + * 初始数据 + * @param $passable + * @return $this + */ + public function send($passable) + { + $this->passable = $passable; + return $this; + } + + /** + * 调用栈 + * @param $pipes + * @return $this + */ + public function through($pipes) + { + $this->pipes = is_array($pipes) ? $pipes : func_get_args(); + return $this; + } + + /** + * 执行 + * @param Closure $destination + * @return mixed + */ + public function then(Closure $destination) + { + $pipeline = array_reduce( + array_reverse($this->pipes), + $this->carry(), + function ($passable) use ($destination) { + try { + return $destination($passable); + } catch (Throwable | Exception $e) { + return $this->handleException($passable, $e); + } + } + ); + + return $pipeline($this->passable); + } + + /** + * 设置异常处理器 + * @param callable $handler + * @return $this + */ + public function whenException($handler) + { + $this->exceptionHandler = $handler; + return $this; + } + + protected function carry() + { + return function ($stack, $pipe) { + return function ($passable) use ($stack, $pipe) { + try { + return $pipe($passable, $stack); + } catch (Throwable | Exception $e) { + return $this->handleException($passable, $e); + } + }; + }; + } + + /** + * 异常处理 + * @param $passable + * @param $e + * @return mixed + */ + protected function handleException($passable, Throwable $e) + { + if ($this->exceptionHandler) { + return call_user_func($this->exceptionHandler, $passable, $e); + } + throw $e; + } +} diff --git a/vendor/topthink/framework/src/think/Request.php b/vendor/topthink/framework/src/think/Request.php new file mode 100644 index 0000000..ecdb8d7 --- /dev/null +++ b/vendor/topthink/framework/src/think/Request.php @@ -0,0 +1,2218 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use ArrayAccess; +use think\facade\Lang; +use think\file\UploadedFile; +use think\route\Rule; + +/** + * 请求管理类 + * @package think + */ +class Request implements ArrayAccess +{ + /** + * 兼容PATH_INFO获取 + * @var array + */ + protected $pathinfoFetch = ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL', 'PHP_SELF']; + + /** + * PATHINFO变量名 用于兼容模式 + * @var string + */ + protected $varPathinfo = 's'; + + /** + * 请求类型 + * @var string + */ + protected $varMethod = '_method'; + + /** + * 表单ajax伪装变量 + * @var string + */ + protected $varAjax = '_ajax'; + + /** + * 表单pjax伪装变量 + * @var string + */ + protected $varPjax = '_pjax'; + + /** + * 域名根 + * @var string + */ + protected $rootDomain = ''; + + /** + * 特殊域名根标识 用于识别com.cn org.cn 这种 + * @var array + */ + protected $domainSpecialSuffix = ['com', 'net', 'org', 'edu', 'gov', 'mil', 'co', 'info']; + + /** + * HTTPS代理标识 + * @var string + */ + protected $httpsAgentName = ''; + + /** + * 前端代理服务器IP + * @var array + */ + protected $proxyServerIp = []; + + /** + * 前端代理服务器真实IP头 + * @var array + */ + protected $proxyServerIpHeader = ['HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP']; + + /** + * 请求类型 + * @var string + */ + protected $method; + + /** + * 域名(含协议及端口) + * @var string + */ + protected $domain; + + /** + * HOST(含端口) + * @var string + */ + protected $host; + + /** + * 子域名 + * @var string + */ + protected $subDomain; + + /** + * 泛域名 + * @var string + */ + protected $panDomain; + + /** + * 当前URL地址 + * @var string + */ + protected $url; + + /** + * 基础URL + * @var string + */ + protected $baseUrl; + + /** + * 当前执行的文件 + * @var string + */ + protected $baseFile; + + /** + * 访问的ROOT地址 + * @var string + */ + protected $root; + + /** + * pathinfo + * @var string + */ + protected $pathinfo; + + /** + * pathinfo(不含后缀) + * @var string + */ + protected $path; + + /** + * 当前请求的IP地址 + * @var string + */ + protected $realIP; + + /** + * 当前控制器分层名 + * @var string + */ + protected $layer; + + /** + * 当前控制器名 + * @var string + */ + protected $controller; + + /** + * 当前操作名 + * @var string + */ + protected $action; + + /** + * 当前请求参数 + * @var array + */ + protected $param = []; + + /** + * 当前GET参数 + * @var array + */ + protected $get = []; + + /** + * 当前POST参数 + * @var array + */ + protected $post = []; + + /** + * 当前REQUEST参数 + * @var array + */ + protected $request = []; + + /** + * 当前路由对象 + * @var Rule + */ + protected $rule; + + /** + * 当前ROUTE参数 + * @var array + */ + protected $route = []; + + /** + * 中间件传递的参数 + * @var array + */ + protected $middleware = []; + + /** + * 当前PUT参数 + * @var array + */ + protected $put; + + /** + * SESSION对象 + * @var Session + */ + protected $session; + + /** + * COOKIE数据 + * @var array + */ + protected $cookie = []; + + /** + * ENV对象 + * @var Env + */ + protected $env; + + /** + * 当前SERVER参数 + * @var array + */ + protected $server = []; + + /** + * 当前FILE参数 + * @var array + */ + protected $file = []; + + /** + * 当前HEADER参数 + * @var array + */ + protected $header = []; + + /** + * 资源类型定义 + * @var array + */ + protected $mimeType = [ + 'xml' => 'application/xml,text/xml,application/x-xml', + 'json' => 'application/json,text/x-json,application/jsonrequest,text/json', + 'js' => 'text/javascript,application/javascript,application/x-javascript', + 'css' => 'text/css', + 'rss' => 'application/rss+xml', + 'yaml' => 'application/x-yaml,text/yaml', + 'atom' => 'application/atom+xml', + 'pdf' => 'application/pdf', + 'text' => 'text/plain', + 'image' => 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/webp,image/*', + 'csv' => 'text/csv', + 'html' => 'text/html,application/xhtml+xml,*/*', + ]; + + /** + * 当前请求内容 + * @var string + */ + protected $content; + + /** + * 全局过滤规则 + * @var array + */ + protected $filter; + + /** + * php://input内容 + * @var string + */ + // php://input + protected $input; + + /** + * 请求安全Key + * @var string + */ + protected $secureKey; + + /** + * 是否合并Param + * @var bool + */ + protected $mergeParam = false; + + /** + * 架构函数 + * @access public + */ + public function __construct() + { + // 保存 php://input + $this->input = file_get_contents('php://input'); + } + + public static function __make(App $app) + { + $request = new static(); + + if (function_exists('apache_request_headers') && $result = apache_request_headers()) { + $header = $result; + } else { + $header = []; + $server = $_SERVER; + foreach ($server as $key => $val) { + if (str_starts_with($key, 'HTTP_')) { + $key = str_replace('_', '-', strtolower(substr($key, 5))); + $header[$key] = $val; + } + } + if (isset($server['CONTENT_TYPE'])) { + $header['content-type'] = $server['CONTENT_TYPE']; + } + if (isset($server['CONTENT_LENGTH'])) { + $header['content-length'] = $server['CONTENT_LENGTH']; + } + } + + $request->header = array_change_key_case($header); + $request->server = $_SERVER; + $request->env = $app->env; + + $inputData = $request->getInputData($request->input); + + $request->get = $_GET; + $request->post = $_POST ?: $inputData; + $request->put = $inputData; + $request->request = $_REQUEST; + $request->cookie = $_COOKIE; + $request->file = $_FILES ?? []; + + return $request; + } + + /** + * 设置当前包含协议的域名 + * @access public + * @param string $domain 域名 + * @return $this + */ + public function setDomain(string $domain) + { + $this->domain = $domain; + return $this; + } + + /** + * 获取当前包含协议的域名 + * @access public + * @param bool $port 是否需要去除端口号 + * @return string + */ + public function domain(bool $port = false): string + { + return $this->scheme() . '://' . $this->host($port); + } + + /** + * 设置根域名 + * @param string $domain + * @return $this + */ + public function setRootDomain(string $domain) + { + $this->rootDomain = $domain; + return $this; + } + + /** + * 获取当前根域名 + * @access public + * @return string + */ + public function rootDomain(): string + { + $root = $this->rootDomain; + + if (!$root) { + $item = explode('.', $this->host(true)); + $count = count($item); + if ($count > 1) { + $root = $item[$count - 2] . '.' . $item[$count - 1]; + if ($count > 2 && in_array($item[$count - 2], $this->domainSpecialSuffix)) { + $root = $item[$count - 3] . '.' . $root; + } + } else { + $root = $item[0]; + } + } + + return $root; + } + + /** + * 设置当前泛域名的值 + * @access public + * @param string $domain 域名 + * @return $this + */ + public function setSubDomain(string $domain) + { + $this->subDomain = $domain; + return $this; + } + + /** + * 获取当前子域名 + * @access public + * @return string + */ + public function subDomain(): string + { + if (is_null($this->subDomain)) { + // 获取当前主域名 + $rootDomain = $this->rootDomain(); + + if ($rootDomain) { + $sub = stristr($this->host(), $rootDomain, true); + $this->subDomain = $sub ? rtrim($sub, '.') : ''; + } else { + $this->subDomain = ''; + } + } + + return $this->subDomain; + } + + /** + * 设置当前泛域名的值 + * @access public + * @param string $domain 域名 + * @return $this + */ + public function setPanDomain(string $domain) + { + $this->panDomain = $domain; + return $this; + } + + /** + * 获取当前泛域名的值 + * @access public + * @return string + */ + public function panDomain(): string + { + return $this->panDomain ?: ''; + } + + /** + * 设置当前完整URL 包括QUERY_STRING + * @access public + * @param string $url URL地址 + * @return $this + */ + public function setUrl(string $url) + { + $this->url = $url; + return $this; + } + + /** + * 获取当前完整URL 包括QUERY_STRING + * @access public + * @param bool $complete 是否包含完整域名 + * @return string + */ + public function url(bool $complete = false): string + { + if ($this->url) { + $url = $this->url; + } elseif ($this->server('HTTP_X_REWRITE_URL')) { + $url = $this->server('HTTP_X_REWRITE_URL'); + } elseif ($this->server('REQUEST_URI')) { + $url = $this->server('REQUEST_URI'); + } elseif ($this->server('ORIG_PATH_INFO')) { + $url = $this->server('ORIG_PATH_INFO') . (!empty($this->server('QUERY_STRING')) ? '?' . $this->server('QUERY_STRING') : ''); + } elseif (isset($_SERVER['argv'][1])) { + $url = $_SERVER['argv'][1]; + } else { + $url = ''; + } + + return $complete ? $this->domain() . $url : $url; + } + + /** + * 设置当前URL 不含QUERY_STRING + * @access public + * @param string $url URL地址 + * @return $this + */ + public function setBaseUrl(string $url) + { + $this->baseUrl = $url; + return $this; + } + + /** + * 获取当前URL 不含QUERY_STRING + * @access public + * @param bool $complete 是否包含完整域名 + * @return string + */ + public function baseUrl(bool $complete = false): string + { + if (!$this->baseUrl) { + $str = $this->url(); + $this->baseUrl = str_contains($str, '?') ? strstr($str, '?', true) : $str; + } + + return $complete ? $this->domain() . $this->baseUrl : $this->baseUrl; + } + + /** + * 获取当前执行的文件 SCRIPT_NAME + * @access public + * @param bool $complete 是否包含完整域名 + * @return string + */ + public function baseFile(bool $complete = false): string + { + if (!$this->baseFile) { + $url = ''; + if (!$this->isCli()) { + $script_name = basename($this->server('SCRIPT_FILENAME')); + if (basename($this->server('SCRIPT_NAME')) === $script_name) { + $url = $this->server('SCRIPT_NAME'); + } elseif (basename($this->server('PHP_SELF')) === $script_name) { + $url = $this->server('PHP_SELF'); + } elseif (basename($this->server('ORIG_SCRIPT_NAME')) === $script_name) { + $url = $this->server('ORIG_SCRIPT_NAME'); + } elseif (($pos = strpos($this->server('PHP_SELF'), '/' . $script_name)) !== false) { + $url = substr($this->server('SCRIPT_NAME'), 0, $pos) . '/' . $script_name; + } elseif ($this->server('DOCUMENT_ROOT') && str_starts_with($this->server('SCRIPT_FILENAME'), $this->server('DOCUMENT_ROOT'))) { + $url = str_replace('\\', '/', str_replace($this->server('DOCUMENT_ROOT'), '', $this->server('SCRIPT_FILENAME'))); + } + } + $this->baseFile = $url; + } + + return $complete ? $this->domain() . $this->baseFile : $this->baseFile; + } + + /** + * 设置URL访问根地址 + * @access public + * @param string $url URL地址 + * @return $this + */ + public function setRoot(string $url) + { + $this->root = $url; + return $this; + } + + /** + * 获取URL访问根地址 + * @access public + * @param bool $complete 是否包含完整域名 + * @return string + */ + public function root(bool $complete = false): string + { + if (!$this->root) { + $file = $this->baseFile(); + if ($file && !str_starts_with($this->url(), $file)) { + $file = str_replace('\\', '/', dirname($file)); + } + $this->root = rtrim($file, '/'); + } + + return $complete ? $this->domain() . $this->root : $this->root; + } + + /** + * 获取URL访问根目录 + * @access public + * @return string + */ + public function rootUrl(): string + { + $base = $this->root(); + $root = str_contains($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base; + + if ('' != $root) { + $root = '/' . ltrim($root, '/'); + } + + return $root; + } + + /** + * 设置当前请求的pathinfo + * @access public + * @param string $pathinfo + * @return $this + */ + public function setPathinfo(string $pathinfo) + { + $this->pathinfo = $pathinfo; + return $this; + } + + /** + * 获取当前请求URL的pathinfo信息(含URL后缀) + * @access public + * @return string + */ + public function pathinfo(): string + { + if (is_null($this->pathinfo)) { + if (isset($_GET[$this->varPathinfo])) { + // 判断URL里面是否有兼容模式参数 + $pathinfo = $_GET[$this->varPathinfo]; + unset($_GET[$this->varPathinfo]); + unset($this->get[$this->varPathinfo]); + } elseif ($this->server('PATH_INFO')) { + $pathinfo = $this->server('PATH_INFO'); + } elseif (str_contains(PHP_SAPI, 'cli')) { + $pathinfo = str_contains($this->server('REQUEST_URI'), '?') ? strstr($this->server('REQUEST_URI'), '?', true) : $this->server('REQUEST_URI'); + } + + // 分析PATHINFO信息 + if (!isset($pathinfo)) { + foreach ($this->pathinfoFetch as $type) { + if ($this->server($type)) { + $pathinfo = str_starts_with($this->server($type), $this->server('SCRIPT_NAME')) ? + substr($this->server($type), strlen($this->server('SCRIPT_NAME'))) : $this->server($type); + break; + } + } + } + + if (!empty($pathinfo)) { + unset($this->get[$pathinfo], $this->request[$pathinfo]); + } + + $this->pathinfo = empty($pathinfo) || '/' == $pathinfo ? '' : ltrim($pathinfo, '/'); + } + + return $this->pathinfo; + } + + /** + * 当前URL的访问后缀 + * @access public + * @return string + */ + public function ext(): string + { + return pathinfo($this->pathinfo(), PATHINFO_EXTENSION); + } + + /** + * 获取当前请求的时间 + * @access public + * @param bool $float 是否使用浮点类型 + * @return integer|float + */ + public function time(bool $float = false) + { + return $float ? $this->server('REQUEST_TIME_FLOAT') : $this->server('REQUEST_TIME'); + } + + /** + * 当前请求的资源类型 + * @access public + * @return string + */ + public function type(): string + { + $accept = $this->server('HTTP_ACCEPT'); + + if (empty($accept)) { + return ''; + } + + foreach ($this->mimeType as $key => $val) { + $array = explode(',', $val); + foreach ($array as $k => $v) { + if (stristr($accept, $v)) { + return $key; + } + } + } + + return ''; + } + + /** + * 设置资源类型 + * @access public + * @param string|array $type 资源类型名 + * @param string $val 资源类型 + * @return void + */ + public function mimeType($type, $val = ''): void + { + if (is_array($type)) { + $this->mimeType = array_merge($this->mimeType, $type); + } else { + $this->mimeType[$type] = $val; + } + } + + /** + * 设置请求类型 + * @access public + * @param string $method 请求类型 + * @return $this + */ + public function setMethod(string $method) + { + $this->method = strtoupper($method); + return $this; + } + + /** + * 当前的请求类型 + * @access public + * @param bool $origin 是否获取原始请求类型 + * @return string + */ + public function method(bool $origin = false): string + { + if ($origin) { + // 获取原始请求类型 + return $this->server('REQUEST_METHOD') ?: 'GET'; + } + + if (!$this->method) { + if (isset($this->post[$this->varMethod])) { + $method = strtolower($this->post[$this->varMethod]); + if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) { + $this->method = strtoupper($method); + $this->{$method} = $this->post; + } else { + $this->method = 'POST'; + } + unset($this->post[$this->varMethod]); + } elseif ($this->server('HTTP_X_HTTP_METHOD_OVERRIDE')) { + $this->method = strtoupper($this->server('HTTP_X_HTTP_METHOD_OVERRIDE')); + } else { + $this->method = $this->server('REQUEST_METHOD') ?: 'GET'; + } + } + + return $this->method; + } + + /** + * 是否为GET请求 + * @access public + * @return bool + */ + public function isGet(): bool + { + return $this->method() == 'GET'; + } + + /** + * 是否为POST请求 + * @access public + * @return bool + */ + public function isPost(): bool + { + return $this->method() == 'POST'; + } + + /** + * 是否为PUT请求 + * @access public + * @return bool + */ + public function isPut(): bool + { + return $this->method() == 'PUT'; + } + + /** + * 是否为DELTE请求 + * @access public + * @return bool + */ + public function isDelete(): bool + { + return $this->method() == 'DELETE'; + } + + /** + * 是否为HEAD请求 + * @access public + * @return bool + */ + public function isHead(): bool + { + return $this->method() == 'HEAD'; + } + + /** + * 是否为PATCH请求 + * @access public + * @return bool + */ + public function isPatch(): bool + { + return $this->method() == 'PATCH'; + } + + /** + * 是否为OPTIONS请求 + * @access public + * @return bool + */ + public function isOptions(): bool + { + return $this->method() == 'OPTIONS'; + } + + /** + * 是否为cli + * @access public + * @return bool + */ + public function isCli(): bool + { + return PHP_SAPI == 'cli'; + } + + /** + * 是否为cgi + * @access public + * @return bool + */ + public function isCgi(): bool + { + return str_starts_with(PHP_SAPI, 'cgi'); + } + + /** + * 获取当前请求的参数 + * @access public + * @param string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function param($name = '', $default = null, string | array | null $filter = '') + { + if (empty($this->mergeParam)) { + $method = $this->method(true); + + // 自动获取请求变量 + $vars = match ($method) { + 'POST' => $this->post(false), + 'PUT', 'DELETE', 'PATCH' => $this->put(false), + default => [], + }; + + // 当前请求参数和URL地址中的参数合并 + $this->param = array_merge($this->param, $this->route(false), $this->get(false), $vars); + + $this->mergeParam = true; + } + + if (is_array($name)) { + return $this->only($name, $this->param, $filter); + } + + return $this->input($this->param, $name, $default, $filter); + } + + /** + * 获取包含文件在内的请求参数 + * @access public + * @param string|array $name 变量名 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function all(string | array $name = '', string | array | null $filter = '') + { + $data = array_merge($this->param(), $this->file() ?: []); + + if (is_array($name)) { + $data = $this->only($name, $data, $filter); + } elseif ($name) { + $data = $data[$name] ?? null; + } + + return $data; + } + + /** + * 设置路由变量 + * @access public + * @param Rule $rule 路由对象 + * @return $this + */ + public function setRule(Rule $rule) + { + $this->rule = $rule; + return $this; + } + + /** + * 获取当前路由对象 + * @access public + * @return Rule|null + */ + public function rule() + { + return $this->rule; + } + + /** + * 设置路由变量 + * @access public + * @param array $route 路由变量 + * @return $this + */ + public function setRoute(array $route) + { + $this->route = array_merge($this->route, $route); + $this->mergeParam = false; + return $this; + } + + /** + * 获取路由参数 + * @access public + * @param string|array|bool $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function route(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + if (is_array($name)) { + return $this->only($name, $this->route, $filter); + } + + return $this->input($this->route, $name, $default, $filter); + } + + /** + * 获取GET参数 + * @access public + * @param string|array|bool $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function get(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + if (is_array($name)) { + return $this->only($name, $this->get, $filter); + } + + return $this->input($this->get, $name, $default, $filter); + } + + /** + * 获取中间件传递的参数 + * @access public + * @param string $name 变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function middleware(?string $name = null, $default = null) + { + if (is_null($name)) { + return $this->middleware; + } + return $this->middleware[$name] ?? $default; + } + + /** + * 获取POST参数 + * @access public + * @param bool|string|array $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function post(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + if (is_array($name)) { + return $this->only($name, $this->post, $filter); + } + + return $this->input($this->post, $name, $default, $filter); + } + + /** + * 获取PUT参数 + * @access public + * @param string|array|bool $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function put(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + if (is_array($name)) { + return $this->only($name, $this->put, $filter); + } + + return $this->input($this->put, $name, $default, $filter); + } + + protected function getInputData(string $content): array + { + $contentType = $this->contentType(); + if ('application/x-www-form-urlencoded' == $contentType) { + parse_str($content, $data); + return $data; + } + + if (str_contains($contentType, 'json')) { + return (array) json_decode($content, true); + } + + return []; + } + + /** + * 设置获取DELETE参数 + * @access public + * @param mixed $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function delete(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + return $this->put($name, $default, $filter); + } + + /** + * 设置获取PATCH参数 + * @access public + * @param mixed $name 变量名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function patch(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + return $this->put($name, $default, $filter); + } + + /** + * 获取request变量 + * @access public + * @param string|array $name 数据名称 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function request(string | array | bool $name = '', $default = null, string | array | null $filter = '') + { + if (is_array($name)) { + return $this->only($name, $this->request, $filter); + } + + return $this->input($this->request, $name, $default, $filter); + } + + /** + * 获取环境变量 + * @access public + * @param string $name 数据名称 + * @param string $default 默认值 + * @return mixed + */ + public function env(string $name = '', ?string $default = null) + { + if (empty($name)) { + return $this->env->get(); + } + return $this->env->get(strtoupper($name), $default); + } + + /** + * 获取session数据 + * @access public + * @param string $name 数据名称 + * @param string $default 默认值 + * @return mixed + */ + public function session(string $name = '', $default = null) + { + if ('' === $name) { + return $this->session->all(); + } + return $this->session->get($name, $default); + } + + /** + * 获取cookie参数 + * @access public + * @param mixed $name 数据名称 + * @param string $default 默认值 + * @param string|array|null $filter 过滤方法 + * @return mixed + */ + public function cookie(string $name = '', $default = null, string | array | null $filter = '') + { + if (!empty($name)) { + $data = $this->getData($this->cookie, $name, $default); + } else { + $data = $this->cookie; + } + + // 解析过滤器 + $filter = $this->getFilter($filter, $default); + + if (is_array($data)) { + array_walk_recursive($data, [$this, 'filterValue'], $filter); + } else { + $this->filterValue($data, $name, $filter); + } + + return $data; + } + + /** + * 获取server参数 + * @access public + * @param string $name 数据名称 + * @param string $default 默认值 + * @return mixed + */ + public function server(string $name = '', string $default = '') + { + if (empty($name)) { + return $this->server; + } + return $this->server[strtoupper($name)] ?? $default; + } + + /** + * 获取上传的文件信息 + * @access public + * @param string $name 名称 + * @return null|array|UploadedFile + */ + public function file(string $name = '') + { + $files = $this->file; + if (!empty($files)) { + if (str_contains($name, '.')) { + [$name, $sub] = explode('.', $name); + } + + // 处理上传文件 + $array = $this->dealUploadFile($files, $name); + + if ('' === $name) { + // 获取全部文件 + return $array; + } elseif (isset($sub) && isset($array[$name][$sub])) { + return $array[$name][$sub]; + } elseif (isset($array[$name])) { + return $array[$name]; + } + } + } + + protected function dealUploadFile(array $files, string $name): array + { + $array = []; + foreach ($files as $key => $file) { + if (is_array($file['name'])) { + $item = []; + $keys = array_keys($file); + $count = count($file['name']); + + for ($i = 0; $i < $count; $i++) { + if ($file['error'][$i] > 0) { + if ($name == $key) { + $this->throwUploadFileError($file['error'][$i]); + } else { + continue; + } + } + + $temp['key'] = $key; + + foreach ($keys as $_key) { + $temp[$_key] = $file[$_key][$i]; + } + + $item[] = new UploadedFile($temp['tmp_name'], $temp['name'], $temp['type'], $temp['error']); + } + + $array[$key] = $item; + } else { + if ($file instanceof File) { + $array[$key] = $file; + } else { + if ($file['error'] > 0) { + if ($key == $name) { + $this->throwUploadFileError($file['error']); + } else { + continue; + } + } + + $array[$key] = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error']); + } + } + } + + return $array; + } + + protected function throwUploadFileError($error) + { + static $fileUploadErrors = [ + 1 => 'upload File size exceeds the maximum value', + 2 => 'upload File size exceeds the maximum value', + 3 => 'only the portion of file is uploaded', + 4 => 'no file to uploaded', + 6 => 'upload temp dir not found', + 7 => 'file write error', + ]; + + $msg = Lang::get($fileUploadErrors[$error]); + throw new Exception($msg, $error); + } + + /** + * 设置或者获取当前的Header + * @access public + * @param string $name header名称 + * @param string $default 默认值 + * @return string|array|null + */ + public function header(string $name = '', ?string $default = null) + { + if ('' === $name) { + return $this->header; + } + + $name = str_replace('_', '-', strtolower($name)); + return $this->header[$name] ?? $default; + } + + /** + * 获取变量 支持过滤和默认值 + * @access public + * @param array $data 数据源 + * @param string|false $name 字段名 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤函数 + * @return mixed + */ + public function input(array $data = [], string | bool $name = '', $default = null, string | array | null $filter = '') + { + if (false === $name) { + // 获取原始数据 + return $data; + } + + $name = (string) $name; + if ('' != $name) { + // 解析name + if (str_contains($name, '/')) { + [$name, $type] = explode('/', $name); + } + + $data = $this->getData($data, $name); + } + + return $this->filterData($data, $filter, $name, $default, $type ?? ''); + } + + protected function filterData($data, $filter, $name, $default, $type) + { + if (is_null($data)) { + return $default; + } + + if (is_object($data)) { + return $data; + } + + // 解析过滤器 + $filter = $this->getFilter($filter, $default); + + if (is_array($data)) { + array_walk_recursive($data, [$this, 'filterValue'], $filter); + } else { + $this->filterValue($data, $name, $filter); + } + + if ($type) { + // 强制类型转换 + $this->typeCast($data, $type); + } + + return $data; + } + + /** + * 强制类型转换 + * @access protected + * @param mixed $data + * @param string $type + * @return mixed + */ + protected function typeCast(&$data, string $type) + { + $data = match (strtolower($type)) { + 'a' => (array) $data, + 'b' => (bool) $data, + 'd' => (int) $data, + 'f' => (float) $data, + 's' => is_scalar($data) ? (string) $data : throw new \InvalidArgumentException('variable type error:' . gettype($data)), + default => $data, + }; + } + + /** + * 获取数据 + * @access protected + * @param array $data 数据源 + * @param string $name 字段名 + * @param mixed $default 默认值 + * @return mixed + */ + protected function getData(array $data, string $name, $default = null) + { + foreach (explode('.', $name) as $val) { + if (isset($data[$val])) { + $data = $data[$val]; + } else { + return $default; + } + } + + return $data; + } + + /** + * 设置或获取当前的过滤规则 + * @access public + * @param mixed $filter 过滤规则 + * @return mixed + */ + public function filter($filter = null) + { + if (is_null($filter)) { + return $this->filter; + } + + $this->filter = $filter; + + return $this; + } + + protected function getFilter($filter, $default): array + { + if (is_null($filter)) { + $filter = []; + } else { + $filter = $filter ?: $this->filter; + if (is_string($filter) && !str_contains($filter, '/')) { + $filter = explode(',', $filter); + } else { + $filter = (array) $filter; + } + } + + $filter[] = $default; + + return $filter; + } + + /** + * 递归过滤给定的值 + * @access public + * @param mixed $value 键值 + * @param mixed $key 键名 + * @param array $filters 过滤方法+默认值 + * @return mixed + */ + public function filterValue(&$value, $key, $filters) + { + $default = array_pop($filters); + + foreach ($filters as $filter) { + if (is_callable($filter)) { + // 调用函数或者方法过滤 + if (is_null($value)) { + continue; + } + + $value = call_user_func($filter, $value); + } elseif (is_scalar($value)) { + if (is_string($filter) && str_contains($filter, '/')) { + // 正则过滤 + if (!preg_match($filter, $value)) { + // 匹配不成功返回默认值 + $value = $default; + break; + } + } elseif (!empty($filter)) { + // filter函数不存在时, 则使用filter_var进行过滤 + // filter为非整形值时, 调用filter_id取得过滤id + $value = filter_var($value, is_int($filter) ? $filter : filter_id($filter)); + if (false === $value) { + $value = $default; + break; + } + } + } + } + + return $value; + } + + /** + * 是否存在某个请求参数 + * @access public + * @param string $name 变量名 + * @param string $type 变量类型 + * @param bool $checkEmpty 是否检测空值 + * @return bool + */ + public function has(string $name, string $type = 'param', bool $checkEmpty = false): bool + { + if (!in_array($type, ['param', 'get', 'post', 'put', 'patch', 'route', 'delete', 'cookie', 'session', 'env', 'request', 'server', 'header', 'file'])) { + return false; + } + + $param = empty($this->$type) ? $this->$type() : $this->$type; + + if (is_object($param)) { + return $param->has($name); + } + + // 按.拆分成多维数组进行判断 + foreach (explode('.', $name) as $val) { + if (isset($param[$val])) { + $param = $param[$val]; + } else { + return false; + } + } + + return ($checkEmpty && '' === $param) ? false : true; + } + + /** + * 获取指定的参数 + * @access public + * @param array $name 变量名 + * @param mixed $data 数据或者变量类型 + * @param string|array|null $filter 过滤方法 + * @return array + */ + public function only(array $name, $data = 'param', string | array | null $filter = ''): array + { + $data = is_array($data) ? $data : $this->$data(); + + $item = []; + foreach ($name as $key => $val) { + $type = ''; + if (is_int($key)) { + if (str_contains($val, '/')) { + [$val, $type] = explode('/', $val); + } + $default = null; + $key = $val; + if (!key_exists($key, $data)) { + continue; + } + } else { + if (str_contains($key, '/')) { + [$key, $type] = explode('/', $key); + } + $default = $val; + } + + $item[$key] = $this->filterData($data[$key] ?? $default, $filter, $key, $default, $type); + } + + return $item; + } + + /** + * 排除指定参数获取 + * @access public + * @param array $name 变量名 + * @param string $type 变量类型 + * @return mixed + */ + public function except(array $name, string $type = 'param'): array + { + $param = $this->$type(); + + foreach ($name as $key) { + if (isset($param[$key])) { + unset($param[$key]); + } + } + + return $param; + } + + /** + * 当前是否ssl + * @access public + * @return bool + */ + public function isSsl(): bool + { + if ($this->server('HTTPS') && ('1' == $this->server('HTTPS') || 'on' == strtolower($this->server('HTTPS')))) { + return true; + } elseif ('https' == $this->server('REQUEST_SCHEME')) { + return true; + } elseif ('443' == $this->server('SERVER_PORT')) { + return true; + } elseif ('https' == $this->server('HTTP_X_FORWARDED_PROTO')) { + return true; + } elseif ($this->httpsAgentName && $this->server($this->httpsAgentName)) { + return true; + } + + return false; + } + + /** + * 当前是否JSON请求 + * @access public + * @return bool + */ + public function isJson(): bool + { + $acceptType = $this->type(); + + return str_contains($acceptType, 'json'); + } + + /** + * 当前是否Ajax请求 + * @access public + * @param bool $ajax true 获取原始ajax请求 + * @return bool + */ + public function isAjax(bool $ajax = false): bool + { + $value = $this->server('HTTP_X_REQUESTED_WITH'); + $result = $value && 'xmlhttprequest' == strtolower($value) ? true : false; + + if (true === $ajax) { + return $result; + } + + return $this->param($this->varAjax) ? true : $result; + } + + /** + * 当前是否Pjax请求 + * @access public + * @param bool $pjax true 获取原始pjax请求 + * @return bool + */ + public function isPjax(bool $pjax = false): bool + { + $result = !empty($this->server('HTTP_X_PJAX')) ? true : false; + + if (true === $pjax) { + return $result; + } + + return $this->param($this->varPjax) ? true : $result; + } + + /** + * 获取客户端IP地址 + * @access public + * @return string + */ + public function ip(): string + { + if (!empty($this->realIP)) { + return $this->realIP; + } + + $this->realIP = $this->server('REMOTE_ADDR', ''); + + // 如果指定了前端代理服务器IP以及其会发送的IP头 + // 则尝试获取前端代理服务器发送过来的真实IP + $proxyIp = $this->proxyServerIp; + $proxyIpHeader = $this->proxyServerIpHeader; + + if (count($proxyIp) > 0 && count($proxyIpHeader) > 0) { + // 从指定的HTTP头中依次尝试获取IP地址 + // 直到获取到一个合法的IP地址 + foreach ($proxyIpHeader as $header) { + $tempIP = $this->server($header); + + if (empty($tempIP)) { + continue; + } + + $tempIP = trim(explode(',', $tempIP)[0]); + + if (!$this->isValidIP($tempIP)) { + $tempIP = null; + } else { + break; + } + } + + // tempIP不为空,说明获取到了一个IP地址 + // 这时我们检查 REMOTE_ADDR 是不是指定的前端代理服务器之一 + // 如果是的话说明该 IP头 是由前端代理服务器设置的 + // 否则则是伪装的 + if (!empty($tempIP)) { + $realIPBin = $this->ip2bin($this->realIP); + + foreach ($proxyIp as $ip) { + $serverIPElements = explode('/', $ip); + $serverIP = $serverIPElements[0]; + $serverIPPrefix = $serverIPElements[1] ?? 128; + $serverIPBin = $this->ip2bin($serverIP); + + // IP类型不符 + if (strlen($realIPBin) !== strlen($serverIPBin)) { + continue; + } + + if (strncmp($realIPBin, $serverIPBin, (int) $serverIPPrefix) === 0) { + $this->realIP = $tempIP; + break; + } + } + } + } + + if (!$this->isValidIP($this->realIP)) { + $this->realIP = '0.0.0.0'; + } + + return $this->realIP; + } + + /** + * 检测是否是合法的IP地址 + * + * @param string $ip IP地址 + * @param string $type IP地址类型 (ipv4, ipv6) + * + * @return boolean + */ + public function isValidIP(string $ip, string $type = ''): bool + { + $flag = match (strtolower($type)) { + 'ipv4' => FILTER_FLAG_IPV4, + 'ipv6' => FILTER_FLAG_IPV6, + default => 0, + }; + + return boolval(filter_var($ip, FILTER_VALIDATE_IP, $flag)); + } + + /** + * 将IP地址转换为二进制字符串 + * + * @param string $ip + * + * @return string + */ + public function ip2bin(string $ip): string + { + if ($this->isValidIP($ip, 'ipv6')) { + $IPHex = str_split(bin2hex(inet_pton($ip)), 4); + foreach ($IPHex as $key => $value) { + $IPHex[$key] = intval($value, 16); + } + $IPBin = vsprintf('%016b%016b%016b%016b%016b%016b%016b%016b', $IPHex); + } else { + $IPHex = str_split(bin2hex(inet_pton($ip)), 2); + foreach ($IPHex as $key => $value) { + $IPHex[$key] = intval($value, 16); + } + $IPBin = vsprintf('%08b%08b%08b%08b', $IPHex); + } + + return $IPBin; + } + + /** + * 检测是否使用手机访问 + * @access public + * @return bool + */ + public function isMobile(): bool + { + if ($this->server('HTTP_VIA') && stristr($this->server('HTTP_VIA'), "wap")) { + return true; + } elseif ($this->server('HTTP_ACCEPT') && str_contains(strtoupper($this->server('HTTP_ACCEPT')), "VND.WAP.WML")) { + return true; + } elseif ($this->server('HTTP_X_WAP_PROFILE') || $this->server('HTTP_PROFILE')) { + return true; + } elseif ($this->server('HTTP_USER_AGENT') && preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $this->server('HTTP_USER_AGENT'))) { + return true; + } + + return false; + } + + /** + * 当前URL地址中的scheme参数 + * @access public + * @return string + */ + public function scheme(): string + { + return $this->isSsl() ? 'https' : 'http'; + } + + /** + * 当前请求URL地址中的query参数 + * @access public + * @return string + */ + public function query(): string + { + return $this->server('QUERY_STRING', ''); + } + + /** + * 设置当前请求的host(包含端口) + * @access public + * @param string $host 主机名(含端口) + * @return $this + */ + public function setHost(string $host) + { + $this->host = $host; + + return $this; + } + + /** + * 当前请求的host + * @access public + * @param bool $strict true 仅仅获取HOST + * @return string + */ + public function host(bool $strict = false): string + { + if ($this->host) { + $host = $this->host; + } else { + $host = strval($this->server('HTTP_X_FORWARDED_HOST') ?: $this->server('HTTP_HOST')); + } + + return true === $strict && str_contains($host, ':') ? strstr($host, ':', true) : $host; + } + + /** + * 当前请求URL地址中的port参数 + * @access public + * @return int + */ + public function port(): int + { + return (int) ($this->server('HTTP_X_FORWARDED_PORT') ?: $this->server('SERVER_PORT', '')); + } + + /** + * 当前请求 SERVER_PROTOCOL + * @access public + * @return string + */ + public function protocol(): string + { + return $this->server('SERVER_PROTOCOL', ''); + } + + /** + * 当前请求 REMOTE_PORT + * @access public + * @return int + */ + public function remotePort(): int + { + return (int) $this->server('REMOTE_PORT', ''); + } + + /** + * 当前请求 HTTP_CONTENT_TYPE + * @access public + * @return string + */ + public function contentType(): string + { + $contentType = $this->header('Content-Type'); + + if ($contentType) { + if (str_contains($contentType, ';')) { + [$type] = explode(';', $contentType); + } else { + $type = $contentType; + } + return trim($type); + } + + return ''; + } + + /** + * 获取当前请求的安全Key + * @access public + * @return string + */ + public function secureKey(): string + { + if (is_null($this->secureKey)) { + $this->secureKey = uniqid('', true); + } + + return $this->secureKey; + } + + /** + * 设置当前的分层名 + * @access public + * @param string $layer 控制器分层名 + * @return $this + */ + public function setLayer(string $layer) + { + $this->layer = $layer; + return $this; + } + + /** + * 设置当前的控制器名 + * @access public + * @param string $controller 控制器名 + * @return $this + */ + public function setController(string $controller) + { + $this->controller = $controller; + return $this; + } + + /** + * 设置当前的操作名 + * @access public + * @param string $action 操作名 + * @return $this + */ + public function setAction(string $action) + { + $this->action = $action; + return $this; + } + + /** + * 获取当前的模块名 + * @access public + * @param bool $convert 转换为小写 + * @return string + */ + public function layer(bool $convert = false): string + { + $name = $this->layer ?: ''; + return $convert ? strtolower($name) : $name; + } + + /** + * 获取当前的控制器名 + * @access public + * @param bool $convert 转换为小写 + * @param bool $base 仅返回basename + * @return string + */ + public function controller(bool $convert = false, bool $base = false): string + { + $name = $this->controller ?: ''; + if ($base) { + $name = basename(str_replace('.', '/', $name)); + } + return $convert ? strtolower($name) : $name; + } + + /** + * 获取当前的操作名 + * @access public + * @param bool $convert 转换为小写 + * @return string + */ + public function action(bool $convert = false): string + { + $name = $this->action ?: ''; + return $convert ? strtolower($name) : $name; + } + + /** + * 设置或者获取当前请求的content + * @access public + * @return string + */ + public function getContent(): string + { + if (is_null($this->content)) { + $this->content = $this->input; + } + + return $this->content; + } + + /** + * 获取当前请求的php://input + * @access public + * @return string + */ + public function getInput(): string + { + return $this->input; + } + + /** + * 生成请求令牌 + * @access public + * @param string $name 令牌名称 + * @param mixed $type 令牌生成方法 + * @return string + */ + public function buildToken(string $name = '__token__', $type = 'md5'): string + { + $type = is_callable($type) ? $type : 'md5'; + $token = call_user_func($type, $this->server('REQUEST_TIME_FLOAT')); + + $this->session->set($name, $token); + + return $token; + } + + /** + * 检查请求令牌 + * @access public + * @param string $token 令牌名称 + * @param array $data 表单数据 + * @return bool + */ + public function checkToken(string $token = '__token__', array $data = []): bool + { + if (in_array($this->method(), ['GET', 'HEAD', 'OPTIONS'], true)) { + return true; + } + + if (!$this->session->has($token)) { + // 令牌数据无效 + return false; + } + + // Header验证 + if ($this->header('X-CSRF-TOKEN') && $this->session->get($token) === $this->header('X-CSRF-TOKEN')) { + // 防止重复提交 + $this->session->delete($token); // 验证完成销毁session + return true; + } + + if (empty($data)) { + $data = $this->post(); + } + + // 令牌验证 + if (isset($data[$token]) && $this->session->get($token) === $data[$token]) { + // 防止重复提交 + $this->session->delete($token); // 验证完成销毁session + return true; + } + + // 开启TOKEN重置 + $this->session->delete($token); + return false; + } + + /** + * 设置在中间件传递的数据 + * @access public + * @param array $middleware 数据 + * @return $this + */ + public function withMiddleware(array $middleware) + { + $this->middleware = array_merge($this->middleware, $middleware); + return $this; + } + + /** + * 设置GET数据 + * @access public + * @param array $get 数据 + * @return $this + */ + public function withGet(array $get) + { + $this->get = $get; + return $this; + } + + /** + * 设置POST数据 + * @access public + * @param array $post 数据 + * @return $this + */ + public function withPost(array $post) + { + $this->post = $post; + return $this; + } + + /** + * 设置COOKIE数据 + * @access public + * @param array $cookie 数据 + * @return $this + */ + public function withCookie(array $cookie) + { + $this->cookie = $cookie; + return $this; + } + + /** + * 更新COOKIE数据 + * @access public + * @param string $name cookie名 + * @param mixed $value 数据 + * @return void + */ + public function setCookie(string $name, mixed $value) + { + $this->cookie[$name] = $value; + } + + /** + * 设置SESSION数据 + * @access public + * @param Session $session 数据 + * @return $this + */ + public function withSession(Session $session) + { + $this->session = $session; + return $this; + } + + /** + * 设置SERVER数据 + * @access public + * @param array $server 数据 + * @return $this + */ + public function withServer(array $server) + { + $this->server = array_change_key_case($server, CASE_UPPER); + return $this; + } + + /** + * 设置HEADER数据 + * @access public + * @param array $header 数据 + * @return $this + */ + public function withHeader(array $header) + { + $this->header = array_change_key_case($header); + return $this; + } + + /** + * 设置ENV数据 + * @access public + * @param Env $env 数据 + * @return $this + */ + public function withEnv(Env $env) + { + $this->env = $env; + return $this; + } + + /** + * 设置php://input数据 + * @access public + * @param string $input RAW数据 + * @return $this + */ + public function withInput(string $input) + { + $this->input = $input; + if (!empty($input)) { + $inputData = $this->getInputData($input); + if (!empty($inputData)) { + $this->post = $inputData; + $this->put = $inputData; + } + } + return $this; + } + + /** + * 设置文件上传数据 + * @access public + * @param array $files 上传信息 + * @return $this + */ + public function withFiles(array $files) + { + $this->file = $files; + return $this; + } + + /** + * 设置ROUTE变量 + * @access public + * @param array $route 数据 + * @return $this + */ + public function withRoute(array $route) + { + $this->route = $route; + return $this; + } + + /** + * 设置中间传递数据 + * @access public + * @param string $name 参数名 + * @param mixed $value 值 + */ + public function __set(string $name, $value) + { + $this->middleware[$name] = $value; + } + + /** + * 获取中间传递数据的值 + * @access public + * @param string $name 名称 + * @return mixed + */ + public function __get(string $name) + { + return $this->middleware($name); + } + + /** + * 检测中间传递数据的值 + * @access public + * @param string $name 名称 + * @return boolean + */ + public function __isset(string $name): bool + { + return isset($this->middleware[$name]); + } + + // ArrayAccess + public function offsetExists(mixed $name): bool + { + return $this->has($name); + } + + public function offsetGet(mixed $name): mixed + { + return $this->param($name); + } + + public function offsetSet(mixed $name, mixed $value): void + { + } + + public function offsetUnset(mixed $name): void + { + } +} diff --git a/vendor/topthink/framework/src/think/Response.php b/vendor/topthink/framework/src/think/Response.php new file mode 100644 index 0000000..c0387e7 --- /dev/null +++ b/vendor/topthink/framework/src/think/Response.php @@ -0,0 +1,425 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +/** + * 响应输出基础类 + * @package think + */ +abstract class Response +{ + /** + * 原始数据 + * @var mixed + */ + protected $data; + + /** + * 当前contentType + * @var string + */ + protected $contentType = 'text/html'; + + /** + * 字符集 + * @var string + */ + protected $charset = 'utf-8'; + + /** + * 状态码 + * @var integer + */ + protected $code = 200; + + /** + * 是否允许请求缓存 + * @var bool + */ + protected $allowCache = true; + + /** + * 输出参数 + * @var array + */ + protected $options = []; + + /** + * header参数 + * @var array + */ + protected $header = []; + + /** + * 输出内容 + * @var string + */ + protected $content = null; + + /** + * Cookie对象 + * @var Cookie + */ + protected $cookie; + + /** + * Session对象 + * @var Session + */ + protected $session; + + /** + * 初始化 + * @access protected + * @param mixed $data 输出数据 + * @param int $code 状态码 + */ + protected function init($data = '', int $code = 200) + { + $this->data($data); + $this->code = $code; + + $this->contentType($this->contentType, $this->charset); + } + + /** + * 创建Response对象 + * @access public + * @param mixed $data 输出数据 + * @param string $type 输出类型 + * @param int $code 状态码 + * @return Response + */ + public static function create($data = '', string $type = 'html', int $code = 200): Response + { + $class = str_contains($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); + + return Container::getInstance()->invokeClass($class, [$data, $code]); + } + + /** + * 设置Session对象 + * @access public + * @param Session $session Session对象 + * @return $this + */ + public function setSession(Session $session) + { + $this->session = $session; + return $this; + } + + /** + * 发送数据到客户端 + * @access public + * @return void + * @throws \InvalidArgumentException + */ + public function send(): void + { + // 处理输出数据 + $data = $this->getContent(); + + if (!headers_sent()) { + if (!empty($this->header)) { + // 发送状态码 + http_response_code($this->code); + // 发送头部信息 + foreach ($this->header as $name => $val) { + header($name . (!is_null($val) ? ':' . $val : '')); + } + } + + if ($this->cookie) { + $this->cookie->save(); + } + } + + $this->sendData($data); + + if (function_exists('fastcgi_finish_request')) { + // 提高页面响应 + fastcgi_finish_request(); + } + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + */ + protected function output($data) + { + return $data; + } + + /** + * 输出数据 + * @access protected + * @param string $data 要处理的数据 + * @return void + */ + protected function sendData(string $data): void + { + echo $data; + } + + /** + * 输出的参数 + * @access public + * @param mixed $options 输出参数 + * @return $this + */ + public function options(array $options = []) + { + $this->options = array_merge($this->options, $options); + + return $this; + } + + /** + * 输出数据设置 + * @access public + * @param mixed $data 输出数据 + * @return $this + */ + public function data($data) + { + $this->data = $data; + + return $this; + } + + /** + * 是否允许请求缓存 + * @access public + * @param bool $cache 允许请求缓存 + * @return $this + */ + public function allowCache(bool $cache) + { + $this->allowCache = $cache; + + return $this; + } + + /** + * 是否允许请求缓存 + * @access public + * @return bool + */ + public function isAllowCache() + { + return $this->allowCache; + } + + /** + * 设置Cookie + * @access public + * @param string $name cookie名称 + * @param string $value cookie值 + * @param mixed $option 可选参数 + * @return $this + */ + public function cookie(string $name, string $value, $option = null) + { + $this->cookie->set($name, $value, $option); + + return $this; + } + + /** + * 设置响应头 + * @access public + * @param array $header 参数 + * @return $this + */ + public function header(array $header = []) + { + $this->header = array_merge($this->header, $header); + + return $this; + } + + /** + * 设置页面输出内容 + * @access public + * @param mixed $content + * @return $this + */ + public function content($content) + { + if ( + null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ + $content, + '__toString', + ]) + ) { + throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content))); + } + + $this->content = (string) $content; + + return $this; + } + + /** + * 发送HTTP状态 + * @access public + * @param integer $code 状态码 + * @return $this + */ + public function code(int $code) + { + $this->code = $code; + + return $this; + } + + /** + * LastModified + * @access public + * @param string $time + * @return $this + */ + public function lastModified(string $time) + { + $this->header['Last-Modified'] = $time; + + return $this; + } + + /** + * Expires + * @access public + * @param string $time + * @return $this + */ + public function expires(string $time) + { + $this->header['Expires'] = $time; + + return $this; + } + + /** + * ETag + * @access public + * @param string $eTag + * @return $this + */ + public function eTag(string $eTag) + { + $this->header['ETag'] = $eTag; + + return $this; + } + + /** + * 页面缓存控制 + * @access public + * @param string $cache 状态码 + * @return $this + */ + public function cacheControl(string $cache) + { + $this->header['Cache-control'] = $cache; + + return $this; + } + + /** + * 页面输出类型 + * @access public + * @param string $contentType 输出类型 + * @param string $charset 输出编码 + * @return $this + */ + public function contentType(string $contentType, string $charset = 'utf-8') + { + $this->header['Content-Type'] = $contentType . '; charset=' . $charset; + + return $this; + } + + /** + * 获取头部信息 + * @access public + * @param string $name 头部名称 + * @return mixed + */ + public function getHeader(string $name = '') + { + if (!empty($name)) { + return $this->header[$name] ?? null; + } + + return $this->header; + } + + /** + * 获取原始数据 + * @access public + * @return mixed + */ + public function getData() + { + return $this->data; + } + + /** + * 获取输出数据 + * @access public + * @return string + */ + public function getContent(): string + { + if (null == $this->content) { + $content = $this->output($this->data); + + if ( + null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ + $content, + '__toString', + ]) + ) { + throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content))); + } + + $this->content = (string) $content; + } + + return $this->content; + } + + /** + * 获取状态码 + * @access public + * @return integer + */ + public function getCode(): int + { + return $this->code; + } + + /** + * 获取Cookie对象 + * @access public + * @return Cookie + */ + public function getCookie() + { + return $this->cookie; + } +} diff --git a/vendor/topthink/framework/src/think/Route.php b/vendor/topthink/framework/src/think/Route.php new file mode 100644 index 0000000..0c9cc1a --- /dev/null +++ b/vendor/topthink/framework/src/think/Route.php @@ -0,0 +1,885 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use Closure; +use think\exception\RouteNotFoundException; +use think\route\Dispatch; +use think\route\dispatch\Callback; +use think\route\Domain; +use think\route\Resource; +use think\route\ResourceRegister; +use think\route\Rule; +use think\route\RuleGroup; +use think\route\RuleItem; +use think\route\RuleName; +use think\route\Url as UrlBuild; + +/** + * 路由管理类 + * @package think + */ +class Route +{ + /** + * REST定义 + * @var array + */ + protected $rest = [ + 'index' => ['get', '', 'index'], + 'create' => ['get', '/create', 'create'], + 'edit' => ['get', '//edit', 'edit'], + 'read' => ['get', '/', 'read'], + 'save' => ['post', '', 'save'], + 'update' => ['put', '/', 'update'], + 'delete' => ['delete', '/', 'delete'], + ]; + + /** + * 配置参数 + * @var array + */ + protected $config = [ + // pathinfo分隔符 + 'pathinfo_depr' => '/', + // 是否开启路由延迟解析 + 'url_lazy_route' => false, + // 是否强制使用路由 + 'url_route_must' => false, + // 是否区分大小写 + 'url_case_sensitive' => false, + // 合并路由规则 + 'route_rule_merge' => false, + // 路由是否完全匹配 + 'route_complete_match' => false, + // 去除斜杠 + 'remove_slash' => false, + // 默认的路由变量规则 + 'default_route_pattern' => '[\w\.]+', + // URL伪静态后缀 + 'url_html_suffix' => 'html', + // 访问控制器层名称 + 'controller_layer' => 'controller', + // 空控制器名 + 'empty_controller' => 'Error', + // 是否使用控制器后缀 + 'controller_suffix' => false, + // 默认模块名 + 'default_module' => 'index', + // 默认控制器名 + 'default_controller' => 'Index', + // 默认操作名 + 'default_action' => 'index', + // 操作方法后缀 + 'action_suffix' => '', + // 非路由变量是否使用普通参数方式(用于URL生成) + 'url_common_param' => true, + // 操作方法的参数绑定方式 route get param + 'action_bind_param' => 'get', + ]; + + /** + * 请求对象 + * @var Request + */ + protected $request; + + /** + * @var RuleName + */ + protected $ruleName; + + /** + * 当前HOST + * @var string + */ + protected $host; + + /** + * 当前分组对象 + * @var RuleGroup + */ + protected $group; + + /** + * 域名对象 + * @var Domain[] + */ + protected $domains = []; + + /** + * 跨域路由规则 + * @var RuleGroup + */ + protected $cross; + + /** + * 路由是否延迟解析 + * @var bool + */ + protected $lazy = false; + + /** + * (分组)路由规则是否合并解析 + * @var bool + */ + protected $mergeRuleRegex = false; + + /** + * 是否去除URL最后的斜线 + * @var bool + */ + protected $removeSlash = false; + + public function __construct(protected App $app) + { + $this->ruleName = new RuleName(); + $this->setDefaultDomain(); + + if (is_file($this->app->getRuntimePath() . 'route.php')) { + // 读取路由映射文件 + $this->import(include $this->app->getRuntimePath() . 'route.php'); + } + + $this->config = array_merge($this->config, $this->app->config->get('route')); + + $this->init(); + } + + protected function init() + { + if (!empty($this->config['middleware'])) { + $this->app->middleware->import($this->config['middleware'], 'route'); + } + + $this->lazy($this->config['url_lazy_route']); + $this->mergeRuleRegex = $this->config['route_rule_merge']; + $this->removeSlash = $this->config['remove_slash']; + + $this->group->removeSlash($this->removeSlash); + + // 注册全局MISS路由 + $this->miss(function () { + return Response::create('', 'html', 204)->header(['Allow' => 'GET, POST, PUT, DELETE']); + }, 'options'); + } + + public function config(?string $name = null) + { + if (is_null($name)) { + return $this->config; + } + + return $this->config[$name] ?? null; + } + + /** + * 设置路由域名及分组(包括资源路由)是否延迟解析 + * @access public + * @param bool $lazy 路由是否延迟解析 + * @return $this + */ + public function lazy(bool $lazy = true) + { + $this->lazy = $lazy; + return $this; + } + + /** + * 设置路由域名及分组(包括资源路由)是否合并解析 + * @access public + * @param bool $merge 路由是否合并解析 + * @return $this + */ + public function mergeRuleRegex(bool $merge = true) + { + $this->mergeRuleRegex = $merge; + $this->group->mergeRuleRegex($merge); + + return $this; + } + + /** + * 初始化默认域名 + * @access protected + * @return void + */ + protected function setDefaultDomain(): void + { + // 注册默认域名 + $domain = new Domain($this); + + $this->domains['-'] = $domain; + + // 默认分组 + $this->group = $domain; + } + + /** + * 设置当前分组 + * @access public + * @param RuleGroup $group 域名 + * @return void + */ + public function setGroup(RuleGroup $group): void + { + $this->group = $group; + } + + /** + * 获取指定标识的路由分组 不指定则获取当前分组 + * @access public + * @param string $name 分组标识 + * @return RuleGroup + */ + public function getGroup(?string $name = null) + { + return $name ? $this->ruleName->getGroup($name) : $this->group; + } + + /** + * 注册变量规则 + * @access public + * @param array $pattern 变量规则 + * @return $this + */ + public function pattern(array $pattern) + { + $this->group->pattern($pattern); + + return $this; + } + + /** + * 注册路由参数 + * @access public + * @param array $option 参数 + * @return $this + */ + public function option(array $option) + { + $this->group->option($option); + + return $this; + } + + /** + * 注册域名路由 + * @access public + * @param string|array $name 子域名 + * @param mixed $rule 路由规则 + * @return Domain + */ + public function domain(string | array $name, $rule = null): Domain + { + // 支持多个域名使用相同路由规则 + $domainName = is_array($name) ? array_shift($name) : $name; + + if (!isset($this->domains[$domainName])) { + $domain = (new Domain($this, $domainName, $rule, $this->lazy)) + ->removeSlash($this->removeSlash) + ->mergeRuleRegex($this->mergeRuleRegex); + + $this->domains[$domainName] = $domain; + } else { + $domain = $this->domains[$domainName]; + $domain->parseGroupRule($rule); + } + + if (is_array($name) && !empty($name)) { + foreach ($name as $item) { + $this->domains[$item] = $domainName; + } + } + + // 返回域名对象 + return $domain; + } + + /** + * 获取域名 + * @access public + * @return array + */ + public function getDomains(): array + { + return $this->domains; + } + + /** + * 获取域名路由的绑定信息 + * @access public + * @param string $domain 子域名 + * @return string|null + */ + public function getDomainBind(?string $domain = null) + { + if ($domain && isset($this->domains[$domain])) { + $item = $this->domains[$domain]; + if (is_string($item)) { + $item = $this->domains[$item]; + } + return $item->getBind(); + } + } + + /** + * 获取RuleName对象 + * @access public + * @return RuleName + */ + public function getRuleName(): RuleName + { + return $this->ruleName; + } + + /** + * 读取路由标识 + * @access public + * @param string $name 路由标识 + * @param string $domain 域名 + * @param string $method 请求类型 + * @return array + */ + public function getName(?string $name = null, ?string $domain = null, string $method = '*'): array + { + return $this->ruleName->getName($name, $domain, $method); + } + + /** + * 批量导入路由标识 + * @access public + * @param array $name 路由标识 + * @return void + */ + public function import(array $name): void + { + $this->ruleName->import($name); + } + + /** + * 注册路由标识 + * @access public + * @param string $name 路由标识 + * @param RuleItem $ruleItem 路由规则 + * @param bool $first 是否优先 + * @return void + */ + public function setName(string $name, RuleItem $ruleItem, bool $first = false): void + { + $this->ruleName->setName($name, $ruleItem, $first); + } + + /** + * 保存路由规则 + * @access public + * @param string $rule 路由规则 + * @param RuleItem $ruleItem RuleItem对象 + * @return void + */ + public function setRule(string $rule, ?RuleItem $ruleItem = null): void + { + $this->ruleName->setRule($rule, $ruleItem); + } + + /** + * 读取路由 + * @access public + * @param string $rule 路由规则 + * @return RuleItem[] + */ + public function getRule(string $rule): array + { + return $this->ruleName->getRule($rule); + } + + /** + * 读取路由列表 + * @access public + * @return array + */ + public function getRuleList(): array + { + return $this->ruleName->getRuleList(); + } + + /** + * 清空路由规则 + * @access public + * @return void + */ + public function clear(): void + { + $this->ruleName->clear(); + + if ($this->group) { + $this->group->clear(); + } + } + + /** + * 注册路由规则 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @param string $method 请求类型 + * @return RuleItem + */ + public function rule(string $rule, $route = null, string $method = '*'): RuleItem + { + return $this->group->addRule($rule, $route, $method); + } + + /** + * 设置路由规则全局有效 + * @access public + * @param Rule $rule 路由规则 + * @return $this + */ + public function setCrossDomainRule(Rule $rule) + { + if (!isset($this->cross)) { + $this->cross = (new RuleGroup($this))->mergeRuleRegex($this->mergeRuleRegex); + } + + $this->cross->addRuleItem($rule); + + return $this; + } + + /** + * 注册路由分组 + * @access public + * @param string|Closure $name 分组名称或者参数 + * @param mixed $route 分组路由 + * @return RuleGroup + */ + public function group(string | Closure $name, $route = null): RuleGroup + { + if ($name instanceof Closure) { + $route = $name; + $name = ''; + } + + return (new RuleGroup($this, $this->group, $name, $route, $this->lazy)) + ->removeSlash($this->removeSlash) + ->mergeRuleRegex($this->mergeRuleRegex); + } + + /** + * 注册路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function any(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, '*'); + } + + /** + * 注册GET路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function get(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'GET'); + } + + /** + * 注册POST路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function post(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'POST'); + } + + /** + * 注册PUT路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function put(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'PUT'); + } + + /** + * 注册DELETE路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function delete(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'DELETE'); + } + + /** + * 注册PATCH路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function patch(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'PATCH'); + } + + /** + * 注册HEAD路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function head(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'HEAD'); + } + + /** + * 注册OPTIONS路由 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @return RuleItem + */ + public function options(string $rule, $route): RuleItem + { + return $this->rule($rule, $route, 'OPTIONS'); + } + + /** + * 注册资源路由 + * @access public + * @param string $rule 路由规则 + * @param string $route 路由地址 + * @param Closure $extend 扩展规则 + * @return Resource|ResourceRegister + */ + public function resource(string $rule, string $route, ?Closure $extend = null) + { + $resource = (new Resource($this, $this->group, $rule, $route, $this->rest))->extend($extend); + + if (!$this->lazy) { + return new ResourceRegister($resource); + } + + return $resource; + } + + /** + * 注册视图路由 + * @access public + * @param string $rule 路由规则 + * @param string $template 路由模板地址 + * @param array $vars 模板变量 + * @return RuleItem + */ + public function view(string $rule, string $template = '', array $vars = []): RuleItem + { + return $this->rule($rule, function () use ($vars, $template) { + return Response::create($template, 'view')->assign($vars); + }, 'GET'); + } + + /** + * 注册重定向路由 + * @access public + * @param string $rule 路由规则 + * @param string $route 路由地址 + * @param int $status 状态码 + * @return RuleItem + */ + public function redirect(string $rule, string $route = '', int $status = 301): RuleItem + { + return $this->rule($rule, function (Request $request) use ($status, $route) { + $search = $replace = []; + $matches = $request->rule()->getVars(); + + foreach ($matches as $key => $value) { + $search[] = '<' . $key . '>'; + $replace[] = $value; + $search[] = '{' . $key . '}'; + $replace[] = $value; + $search[] = ':' . $key; + $replace[] = $value; + } + + $route = str_replace($search, $replace, $route); + return Response::create($route, 'redirect')->code($status); + }, '*'); + } + + /** + * rest方法定义和修改 + * @access public + * @param string|array $name 方法名称 + * @param array|bool $resource 资源 + * @return $this + */ + public function rest(string | array $name, array | bool $resource = []) + { + if (is_array($name)) { + $this->rest = $resource ? $name : array_merge($this->rest, $name); + } else { + $this->rest[$name] = $resource; + } + + return $this; + } + + /** + * 获取rest方法定义的参数 + * @access public + * @param string $name 方法名称 + * @return array|null + */ + public function getRest(?string $name = null) + { + if (is_null($name)) { + return $this->rest; + } + + return $this->rest[$name] ?? null; + } + + /** + * 注册未匹配路由规则后的处理 + * @access public + * @param string|Closure $route 路由地址 + * @param string $method 请求类型 + * @return RuleItem + */ + public function miss(string | Closure $route, string $method = '*'): RuleItem + { + return $this->group->miss($route, $method); + } + + /** + * 路由调度 + * @param Request $request + * @param Closure|bool $withRoute + * @return Response + */ + public function dispatch(Request $request, Closure | bool $withRoute = true) + { + $this->request = $request; + $this->host = $this->request->host(true); + $completeMatch = (bool) $this->config['route_complete_match']; + $url = str_replace($this->config['pathinfo_depr'], '|', $this->path()); + + if ($withRoute) { + if ($withRoute instanceof Closure) { + $withRoute(); + } + // 路由检测 + $dispatch = $this->check($url, $completeMatch); + } + + if (empty($dispatch)) { + // 默认URL调度 + $dispatch = $this->checkUrlDispatch($url); + } + + $dispatch->init($this->app); + + return $this->app->middleware->pipeline('route') + ->send($request) + ->then(function () use ($dispatch) { + return $dispatch->run(); + }); + } + + /** + * 检测URL路由 + * @access public + * @param bool $completeMatch + * @return Dispatch|false + * @throws RouteNotFoundException + */ + public function check(string $url, bool $completeMatch = false) + { + // 检测域名路由 + $result = $this->checkDomain()->check($this->request, $url, $completeMatch); + + if (false === $result && !empty($this->cross)) { + // 检测跨域路由 + $result = $this->cross->check($this->request, $url, $completeMatch); + } + + if (false === $result && $this->config['url_route_must']) { + // 开启强制路由 + throw new RouteNotFoundException(); + } + + return $result; + } + + /** + * 获取当前请求URL的pathinfo信息(不含URL后缀) + * @access protected + * @return string + */ + protected function path(): string + { + $suffix = $this->config['url_html_suffix']; + $pathinfo = $this->request->pathinfo(); + + if (false === $suffix) { + // 禁止伪静态访问 + $path = $pathinfo; + } elseif ($suffix) { + // 去除正常的URL后缀 + $path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo); + } else { + // 允许任何后缀访问 + $path = preg_replace('/\.' . $this->request->ext() . '$/i', '', $pathinfo); + } + + return $path; + } + + /** + * 自动多模块URL路由 如使用多模块在路由定义文件最后定义 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @param bool $middleware 自动注册中间件 + * @return RuleItem + */ + public function auto(string $rule = '[:__module__]/[:__controller__]/[:__action__]', $route = ':__module__/:__controller__/:__action__', bool $middleware = false): RuleItem + { + return $this->rule($rule, $route) + ->name('__think_auto_route__') + ->pattern([ + '__module__' => '[A-Za-z0-9\.\_]+', + '__controller__' => '[A-Za-z0-9\.\_]+', + '__action__' => '[A-Za-z0-9\_]+', + ])->default([ + '__module__' => $this->config['default_module'], + '__controller__' => $this->config['default_controller'], + '__action__' => $this->config['default_action'], + ])->autoMiddleware($middleware); + } + + /** + * 检测默认URL解析路由 + * @access public + * @param string $url URL + * @return Dispatch + */ + protected function checkUrlDispatch(string $url): Dispatch + { + if ($this->request->method() == 'OPTIONS') { + // 自动响应options请求 + return new Callback($this->request, $this->group, function () { + return Response::create('', 'html', 204)->header(['Allow' => 'GET, POST, PUT, DELETE']); + }); + } + + return $this->group->auto()->checkBind($this->request, $url); + } + + /** + * 检测域名的路由规则 + * @access protected + * @return Domain + */ + protected function checkDomain(): Domain + { + $item = false; + + if (count($this->domains) > 1) { + // 获取当前子域名 + $subDomain = $this->request->subDomain(); + $domain = $subDomain ? explode('.', $subDomain) : []; + $domain2 = $domain ? array_pop($domain) : ''; + + if ($domain) { + // 存在三级域名 + $domain3 = array_pop($domain); + } + + if (isset($this->domains[$this->host])) { + // 子域名配置 + $item = $this->domains[$this->host]; + } elseif (isset($this->domains[$subDomain])) { + $item = $this->domains[$subDomain]; + } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { + // 泛三级域名 + $item = $this->domains['*.' . $domain2]; + $panDomain = $domain3; + } elseif (isset($this->domains['*']) && !empty($domain2)) { + // 泛二级域名 + if ('www' != $domain2) { + $item = $this->domains['*']; + $panDomain = $domain2; + } + } + + if (isset($panDomain)) { + // 保存当前泛域名 + $this->request->setPanDomain($panDomain); + } + } + + if (false === $item) { + // 检测全局域名规则 + $item = $this->domains['-']; + } + + if (is_string($item)) { + $item = $this->domains[$item]; + } + + return $item; + } + + /** + * URL生成 支持路由反射 + * @access public + * @param string $url 路由地址 + * @param array $vars 参数 ['a'=>'val1', 'b'=>'val2'] + * @return UrlBuild + */ + public function buildUrl(string $url = '', array $vars = []): UrlBuild + { + return $this->app->make(UrlBuild::class, [$this, $this->app, $url, $vars], true); + } + + /** + * 设置全局的路由分组参数 + * @access public + * @param string $method 方法名 + * @param array $args 调用参数 + * @return RuleGroup + */ + public function __call($method, $args) + { + return call_user_func_array([$this->group, $method], $args); + } +} diff --git a/vendor/topthink/framework/src/think/Service.php b/vendor/topthink/framework/src/think/Service.php new file mode 100644 index 0000000..988f735 --- /dev/null +++ b/vendor/topthink/framework/src/think/Service.php @@ -0,0 +1,63 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use Closure; +use think\event\RouteLoaded; + +/** + * 系统服务基础类 + * @method void register() + * @method void boot() + */ +abstract class Service +{ + public function __construct(protected App $app) + { + } + + /** + * 加载路由 + * @access protected + * @param string $path 路由路径 + */ + protected function loadRoutesFrom(string $path) + { + $this->registerRoutes(function () use ($path) { + include $path; + }); + } + + /** + * 注册路由 + * @param Closure $closure + */ + protected function registerRoutes(Closure $closure) + { + $this->app->event->listen(RouteLoaded::class, $closure); + } + + /** + * 添加指令 + * @access protected + * @param array|string $commands 指令 + */ + protected function commands($commands) + { + $commands = is_array($commands) ? $commands : func_get_args(); + + Console::starting(function (Console $console) use ($commands) { + $console->addCommands($commands); + }); + } +} diff --git a/vendor/topthink/framework/src/think/Session.php b/vendor/topthink/framework/src/think/Session.php new file mode 100644 index 0000000..b3532e6 --- /dev/null +++ b/vendor/topthink/framework/src/think/Session.php @@ -0,0 +1,65 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use think\helper\Arr; +use think\session\Store; + +/** + * Session管理类 + * @package think + * @mixin Store + */ +class Session extends Manager +{ + protected $namespace = '\\think\\session\\driver\\'; + + protected function createDriver(string $name) + { + $handler = parent::createDriver($name); + + return new Store($this->getConfig('name') ?: 'PHPSESSID', $handler, $this->getConfig('serialize')); + } + + /** + * 获取Session配置 + * @access public + * @param null|string $name 名称 + * @param mixed $default 默认值 + * @return mixed + */ + public function getConfig(?string $name = null, $default = null) + { + if (!is_null($name)) { + return $this->app->config->get('session.' . $name, $default); + } + + return $this->app->config->get('session'); + } + + protected function resolveConfig(string $name) + { + $config = $this->app->config->get('session', []); + Arr::forget($config, 'type'); + return $config; + } + + /** + * 默认驱动 + * @return string|null + */ + public function getDefaultDriver() + { + return $this->app->config->get('session.type', 'file'); + } +} diff --git a/vendor/topthink/framework/src/think/View.php b/vendor/topthink/framework/src/think/View.php new file mode 100644 index 0000000..4ce4607 --- /dev/null +++ b/vendor/topthink/framework/src/think/View.php @@ -0,0 +1,187 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use think\contract\TemplateHandlerInterface; +use think\helper\Arr; + +/** + * 视图类 + * @package think + */ +class View extends Manager +{ + + protected $namespace = '\\think\\view\\driver\\'; + + /** + * 模板变量 + * @var array + */ + protected $data = []; + + /** + * 内容过滤 + * @var mixed + */ + protected $filter; + + /** + * 获取模板引擎 + * @access public + * @param string $type 模板引擎类型 + * @return TemplateHandlerInterface + */ + public function engine(?string $type = null) + { + return $this->driver($type); + } + + /** + * 模板变量赋值 + * @access public + * @param string|array $name 模板变量 + * @param mixed $value 变量值 + * @return $this + */ + public function assign(string|array $name, $value = null) + { + if (is_array($name)) { + $this->data = array_merge($this->data, $name); + } else { + $this->data[$name] = $value; + } + + return $this; + } + + /** + * 视图过滤 + * @access public + * @param Callable $filter 过滤方法或闭包 + * @return $this + */ + public function filter(?callable $filter = null) + { + $this->filter = $filter; + return $this; + } + + /** + * 解析和获取模板内容 用于输出 + * @access public + * @param string $template 模板文件名或者内容 + * @param array $vars 模板变量 + * @return string + * @throws \Exception + */ + public function fetch(string $template = '', array $vars = []): string + { + return $this->getContent(function () use ($vars, $template) { + $this->engine()->fetch($template, array_merge($this->data, $vars)); + }); + } + + /** + * 渲染内容输出 + * @access public + * @param string $content 内容 + * @param array $vars 模板变量 + * @return string + */ + public function display(string $content, array $vars = []): string + { + return $this->getContent(function () use ($vars, $content) { + $this->engine()->display($content, array_merge($this->data, $vars)); + }); + } + + /** + * 获取模板引擎渲染内容 + * @param $callback + * @return string + * @throws \Exception + */ + protected function getContent($callback): string + { + // 页面缓存 + ob_start(); + ob_implicit_flush(false); + + // 渲染输出 + try { + $callback(); + } catch (\Exception $e) { + ob_end_clean(); + throw $e; + } + + // 获取并清空缓存 + $content = ob_get_clean(); + + if ($this->filter) { + $content = call_user_func_array($this->filter, [$content]); + } + + return $content; + } + + /** + * 模板变量赋值 + * @access public + * @param string $name 变量名 + * @param mixed $value 变量值 + */ + public function __set($name, $value) + { + $this->data[$name] = $value; + } + + /** + * 取得模板显示变量的值 + * @access protected + * @param string $name 模板变量 + * @return mixed + */ + public function __get($name) + { + return $this->data[$name]; + } + + /** + * 检测模板变量是否设置 + * @access public + * @param string $name 模板变量名 + * @return bool + */ + public function __isset($name) + { + return isset($this->data[$name]); + } + + protected function resolveConfig(string $name) + { + $config = $this->app->config->get('view', []); + Arr::forget($config, 'type'); + return $config; + } + + /** + * 默认驱动 + * @return string|null + */ + public function getDefaultDriver() + { + return $this->app->config->get('view.type', 'php'); + } +} diff --git a/vendor/topthink/framework/src/think/cache/Driver.php b/vendor/topthink/framework/src/think/cache/Driver.php new file mode 100644 index 0000000..c37850e --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/Driver.php @@ -0,0 +1,385 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\cache; + +use Closure; +use DateInterval; +use DateTime; +use DateTimeInterface; +use Exception; +use think\Container; +use think\contract\CacheHandlerInterface; +use think\exception\InvalidArgumentException; +use think\exception\InvalidCacheException; +use Throwable; + +/** + * 缓存基础类 + */ +abstract class Driver implements CacheHandlerInterface +{ + /** + * 驱动句柄 + * @var object + */ + protected $handler = null; + + /** + * 缓存读取次数 + * @var integer + */ + protected $readTimes = 0; + + /** + * 缓存写入次数 + * @var integer + */ + protected $writeTimes = 0; + + /** + * 缓存参数 + * @var array + */ + protected $options = []; + + /** + * 缓存标签 + * @var array + */ + protected $tag = []; + + /** + * 获取有效期 + * @access protected + * @param integer|DateInterval|DateTimeInterface $expire 有效期 + * @return int + */ + protected function getExpireTime(int | DateInterval | DateTimeInterface $expire): int + { + if ($expire instanceof DateTimeInterface) { + $expire = $expire->getTimestamp() - time(); + } elseif ($expire instanceof DateInterval) { + $expire = DateTime::createFromFormat('U', (string) time()) + ->add($expire) + ->format('U') - time(); + } + + return $expire; + } + + /** + * 获取实际的缓存标识 + * @access public + * @param string $name 缓存名 + * @return string + */ + public function getCacheKey(string $name): string + { + return $this->options['prefix'] . $name; + } + + /** + * 读取缓存并删除 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function pull($name, $default = null) + { + if ($this->has($name)) { + $result = $this->get($name, $default); + $this->delete($name); + return $result; + } + return $this->getDefaultValue($name, $default); + } + + /** + * 追加(数组)缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @return void + */ + public function push($name, $value): void + { + $item = $this->get($name, []); + + if (!is_array($item)) { + throw new InvalidArgumentException('only array cache can be push'); + } + + $item[] = $value; + + if (count($item) > 1000) { + array_shift($item); + } + + $item = array_unique($item); + + $this->set($name, $item); + } + + /** + * 追加TagSet数据 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @return void + */ + public function append($name, $value): void + { + $this->push($name, $value); + } + + /** + * 如果不存在则写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int|DateInterval|DateTimeInterface $expire 有效时间 0为永久 + * @return mixed + */ + public function remember($name, $value, $expire = null) + { + if ($this->has($name)) { + if (($hit = $this->get($name)) !== null) { + return $hit; + } + } + + $time = time(); + + while ($time + 5 > time() && $this->has($name . '_lock')) { + // 存在锁定则等待 + usleep(200000); + } + + try { + // 锁定 + $this->set($name . '_lock', true); + + if ($value instanceof Closure) { + // 获取缓存数据 + $value = Container::getInstance()->invokeFunction($value); + } + + // 缓存数据 + $this->set($name, $value, $expire); + + // 解锁 + $this->delete($name . '_lock'); + } catch (Exception | Throwable $e) { + $this->delete($name . '_lock'); + throw $e; + } + + return $value; + } + + /** + * 缓存标签 + * @access public + * @param string|array $name 标签名 + * @return TagSet + */ + public function tag($name) + { + $name = (array) $name; + $key = implode('-', $name); + + if (!isset($this->tag[$key])) { + $this->tag[$key] = new TagSet($name, $this); + } + + return $this->tag[$key]; + } + + /** + * 获取标签包含的缓存标识 + * @access public + * @param string $tag 标签标识 + * @return array + */ + public function getTagItems(string $tag): array + { + $name = $this->getTagKey($tag); + return $this->get($name, []); + } + + /** + * 获取实际标签名 + * @access public + * @param string $tag 标签名 + * @return string + */ + public function getTagKey(string $tag): string + { + return $this->options['tag_prefix'] . md5($tag); + } + + /** + * 序列化数据 + * @access protected + * @param mixed $data 缓存数据 + * @return string + */ + protected function serialize($data) + { + if (is_numeric($data)) { + return $data; + } + + $serialize = $this->options['serialize'][0] ?? "serialize"; + + return $serialize($data); + } + + /** + * 反序列化数据 + * @access protected + * @param string $data 缓存数据 + * @return mixed + */ + protected function unserialize($data) + { + if (is_numeric($data)) { + return $data; + } + try { + $unserialize = $this->options['serialize'][1] ?? "unserialize"; + $content = $unserialize($data); + if (is_null($content)) { + throw new InvalidCacheException; + } else { + return $content; + } + } catch (Exception | Throwable $e) { + throw new InvalidCacheException; + } + } + + /** + * 获取默认值 + * @access protected + * @param string $name 缓存标识 + * @param mixed $default 默认值 + * @param bool $fail 是否有异常 + * @return mixed + */ + protected function getDefaultValue($name, $default, $fail = false) + { + if ($fail && $this->options['fail_delete']) { + $this->delete($name); + } + return $default instanceof Closure ? $default() : $default; + } + + /** + * 返回句柄对象,可执行其它高级方法 + * + * @access public + * @return object + */ + public function handler() + { + return $this->handler; + } + + /** + * 返回缓存读取次数 + * @return int + * @deprecated + * @access public + */ + public function getReadTimes(): int + { + return $this->readTimes; + } + + /** + * 返回缓存写入次数 + * @return int + * @deprecated + * @access public + */ + public function getWriteTimes(): int + { + return $this->writeTimes; + } + + /** + * 读取缓存 + * @access public + * @param iterable $keys 缓存变量名 + * @param mixed $default 默认值 + * @return iterable + * @throws InvalidArgumentException + */ + public function getMultiple($keys, $default = null): iterable + { + $result = []; + + foreach ($keys as $key) { + $result[$key] = $this->get($key, $default); + } + + return $result; + } + + /** + * 写入缓存 + * @access public + * @param iterable $values 缓存数据 + * @param null|int|\DateInterval|DateTimeInterface $ttl 有效时间 0为永久 + * @return bool + */ + public function setMultiple($values, $ttl = null): bool + { + foreach ($values as $key => $val) { + $result = $this->set($key, $val, $ttl); + + if (false === $result) { + return false; + } + } + + return true; + } + + /** + * 删除缓存 + * @access public + * @param iterable $keys 缓存变量名 + * @return bool + * @throws InvalidArgumentException + */ + public function deleteMultiple($keys): bool + { + foreach ($keys as $key) { + $result = $this->delete($key); + + if (false === $result) { + return false; + } + } + + return true; + } + + public function __call($method, $args) + { + return call_user_func_array([$this->handler, $method], $args); + } +} diff --git a/vendor/topthink/framework/src/think/cache/TagSet.php b/vendor/topthink/framework/src/think/cache/TagSet.php new file mode 100644 index 0000000..5c42c1b --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/TagSet.php @@ -0,0 +1,121 @@ + +// +---------------------------------------------------------------------- +declare(strict_types = 1); + +namespace think\cache; + +use DateInterval; +use DateTimeInterface; + +/** + * 标签集合 + */ +class TagSet +{ + /** + * 架构函数 + * @access public + * @param array $tag 缓存标签 + * @param Driver $handler 缓存对象 + */ + public function __construct(protected array $tag, protected Driver $handler) + { + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|DateInterval|DateTimeInterface $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null): bool + { + $this->handler->set($name, $value, $expire); + + $this->append($name); + + return true; + } + + /** + * 追加缓存标识到标签 + * @access public + * @param string $name 缓存变量名 + * @return void + */ + public function append(string $name): void + { + $name = $this->handler->getCacheKey($name); + + foreach ($this->tag as $tag) { + $key = $this->handler->getTagKey($tag); + $this->handler->append($key, $name); + } + } + + /** + * 写入缓存 + * @access public + * @param iterable $values 缓存数据 + * @param null|int|DateInterval|DateTimeInterface $ttl 有效时间 0为永久 + * @return bool + */ + public function setMultiple($values, $ttl = null): bool + { + foreach ($values as $key => $val) { + $result = $this->set($key, $val, $ttl); + + if (false === $result) { + return false; + } + } + + return true; + } + + /** + * 如果不存在则写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int $expire 有效时间 0为永久 + * @return mixed + */ + public function remember($name, $value, $expire = null) + { + $result = $this->handler->remember($name, $value, $expire); + + $this->append($name); + + return $result; + } + + /** + * 清除缓存 + * @access public + * @return bool + */ + public function clear(): bool + { + // 指定标签清除 + foreach ($this->tag as $tag) { + $keys = $this->handler->getTagItems($tag); + if (!empty($keys)) $this->handler->clearTag($keys); + + $key = $this->handler->getTagKey($tag); + $this->handler->delete($key); + } + + return true; + } +} diff --git a/vendor/topthink/framework/src/think/cache/driver/File.php b/vendor/topthink/framework/src/think/cache/driver/File.php new file mode 100644 index 0000000..628c699 --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/driver/File.php @@ -0,0 +1,308 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\cache\driver; + +use DateTimeInterface; +use FilesystemIterator; +use think\App; +use think\cache\Driver; +use think\exception\InvalidCacheException; + +/** + * 文件缓存类 + */ +class File extends Driver +{ + /** + * 配置参数 + * @var array + */ + protected $options = [ + 'expire' => 0, + 'cache_subdir' => true, + 'prefix' => '', + 'path' => '', + 'hash_type' => 'md5', + 'data_compress' => false, + 'tag_prefix' => 'tag:', + 'serialize' => [], + 'fail_delete' => false, + ]; + + /** + * 架构函数 + * @param App $app + * @param array $options 参数 + */ + public function __construct(App $app, array $options = []) + { + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + + if (empty($this->options['path'])) { + $this->options['path'] = $app->getRuntimePath() . 'cache'; + } + + if (!str_ends_with($this->options['path'], DIRECTORY_SEPARATOR)) { + $this->options['path'] .= DIRECTORY_SEPARATOR; + } + } + + /** + * 取得变量的存储文件名 + * @access public + * @param string $name 缓存变量名 + * @return string + */ + public function getCacheKey(string $name): string + { + $name = hash($this->options['hash_type'], $name); + + if ($this->options['cache_subdir']) { + // 使用子目录 + $name = substr($name, 0, 2) . DIRECTORY_SEPARATOR . substr($name, 2); + } + + if ($this->options['prefix']) { + $name = $this->options['prefix'] . DIRECTORY_SEPARATOR . $name; + } + + return $this->options['path'] . $name . '.php'; + } + + /** + * 获取缓存数据 + * @param string $name 缓存标识名 + * @return array|null + */ + protected function getRaw(string $name) + { + $filename = $this->getCacheKey($name); + + if (!is_file($filename)) { + return; + } + + $content = @file_get_contents($filename); + + if (false !== $content) { + $expire = (int) substr($content, 8, 12); + if (0 != $expire && time() - $expire > filemtime($filename)) { + //缓存过期删除缓存文件 + $this->unlink($filename); + return; + } + + $content = substr($content, 32); + + if ($this->options['data_compress'] && function_exists('gzcompress')) { + //启用数据压缩 + $content = gzuncompress($content); + } + + return is_string($content) ? ['content' => (string) $content, 'expire' => $expire] : null; + } + } + + /** + * 判断缓存是否存在 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name): bool + { + return $this->getRaw($name) !== null; + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = null): mixed + { + $raw = $this->getRaw($name); + + try { + return is_null($raw) ? $this->getDefaultValue($name, $default) : $this->unserialize($raw['content']); + } catch (InvalidCacheException $e) { + return $this->getDefaultValue($name, $default, true); + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int|\DateInterval|DateTimeInterface|null $expire 有效时间 0为永久 + * @return bool + */ + public function set($name, $value, $expire = null): bool + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + + $expire = $this->getExpireTime($expire); + $filename = $this->getCacheKey($name); + + $dir = dirname($filename); + + if (!is_dir($dir)) { + try { + mkdir($dir, 0755, true); + } catch (\Exception $e) { + // 创建失败 + } + } + + $data = $this->serialize($value); + + if ($this->options['data_compress'] && function_exists('gzcompress')) { + //数据压缩 + $data = gzcompress($data, 3); + } + + $data = "\n" . $data; + + if (str_contains($filename, '://') && !str_starts_with($filename, 'file://')) { + //虚拟文件不加锁 + $result = file_put_contents($filename, $data); + } else { + $result = file_put_contents($filename, $data, LOCK_EX); + } + + if ($result) { + clearstatcache(); + return true; + } + + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + if ($raw = $this->getRaw($name)) { + $value = $this->unserialize($raw['content']) + $step; + $expire = $raw['expire']; + } else { + $value = $step; + $expire = 0; + } + + return $this->set($name, $value, $expire) ? $value : false; + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + return $this->inc($name, -$step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function delete($name): bool + { + return $this->unlink($this->getCacheKey($name)); + } + + /** + * 清除缓存 + * @access public + * @return bool + */ + public function clear(): bool + { + $dirname = $this->options['path'] . $this->options['prefix']; + + $this->rmdir($dirname); + + return true; + } + + /** + * 删除缓存标签 + * @access public + * @param array $keys 缓存标识列表 + * @return void + */ + public function clearTag($keys): void + { + foreach ($keys as $key) { + $this->unlink($key); + } + } + + /** + * 判断文件是否存在后,删除 + * @access private + * @param string $path + * @return bool + */ + private function unlink(string $path): bool + { + try { + return is_file($path) && unlink($path); + } catch (\Exception $e) { + return false; + } + } + + /** + * 删除文件夹 + * @param $dirname + * @return bool + */ + private function rmdir($dirname) + { + if (!is_dir($dirname)) { + return false; + } + + $items = new FilesystemIterator($dirname); + + foreach ($items as $item) { + if ($item->isDir() && !$item->isLink()) { + $this->rmdir($item->getPathname()); + } else { + $this->unlink($item->getPathname()); + } + } + + @rmdir($dirname); + + return true; + } +} diff --git a/vendor/topthink/framework/src/think/cache/driver/Memcache.php b/vendor/topthink/framework/src/think/cache/driver/Memcache.php new file mode 100644 index 0000000..59eeccc --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/driver/Memcache.php @@ -0,0 +1,204 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\cache\driver; + +use DateInterval; +use DateTimeInterface; +use think\cache\Driver; +use think\exception\InvalidCacheException; + +/** + * Memcache缓存类 + */ +class Memcache extends Driver +{ + /** + * 配置参数 + * @var array + */ + protected $options = [ + 'host' => '127.0.0.1', + 'port' => 11211, + 'expire' => 0, + 'timeout' => 0, + 'persistent' => true, + 'prefix' => '', + 'tag_prefix' => 'tag:', + 'serialize' => [], + 'fail_delete' => false, + ]; + + /** + * 架构函数 + * @access public + * @param array $options 缓存参数 + * @throws \BadFunctionCallException + */ + public function __construct(array $options = []) + { + if (!extension_loaded('memcache')) { + throw new \BadFunctionCallException('not support: memcache'); + } + + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + + $this->handler = new \Memcache; + + // 支持集群 + $hosts = (array) $this->options['host']; + $ports = (array) $this->options['port']; + + if (empty($ports[0])) { + $ports[0] = 11211; + } + + // 建立连接 + foreach ($hosts as $i => $host) { + $port = $ports[$i] ?? $ports[0]; + $this->options['timeout'] > 0 ? + $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) : + $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name): bool + { + $key = $this->getCacheKey($name); + + return false !== $this->handler->get($key); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = null): mixed + { + $result = $this->handler->get($this->getCacheKey($name)); + + try { + return false !== $result ? $this->unserialize($result) : $this->getDefaultValue($name, $default); + } catch (InvalidCacheException $e) { + return $this->getDefaultValue($name, $default, true); + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int|DateTimeInterface|DateInterval $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null): bool + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + + $key = $this->getCacheKey($name); + $expire = $this->getExpireTime($expire); + $value = $this->serialize($value); + + if ($this->handler->set($key, $value, 0, $expire)) { + return true; + } + + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + + if ($this->handler->get($key)) { + return $this->handler->increment($key, $step); + } + + return $this->handler->set($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + $value = $this->handler->get($key) - $step; + $res = $this->handler->set($key, $value); + + return !$res ? false : $value; + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @param bool|false $ttl + * @return bool + */ + public function delete($name, $ttl = false): bool + { + $key = $this->getCacheKey($name); + + return false === $ttl ? + $this->handler->delete($key) : + $this->handler->delete($key, $ttl); + } + + /** + * 清除缓存 + * @access public + * @return bool + */ + public function clear(): bool + { + return $this->handler->flush(); + } + + /** + * 删除缓存标签 + * @access public + * @param array $keys 缓存标识列表 + * @return void + */ + public function clearTag($keys): void + { + foreach ($keys as $key) { + $this->handler->delete($key); + } + } +} diff --git a/vendor/topthink/framework/src/think/cache/driver/Memcached.php b/vendor/topthink/framework/src/think/cache/driver/Memcached.php new file mode 100644 index 0000000..5d519ae --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/driver/Memcached.php @@ -0,0 +1,215 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\cache\driver; + +use DateInterval; +use DateTimeInterface; +use think\cache\Driver; +use think\exception\InvalidCacheException; + +/** + * Memcached缓存类 + */ +class Memcached extends Driver +{ + /** + * 配置参数 + * @var array + */ + protected $options = [ + 'host' => '127.0.0.1', + 'port' => 11211, + 'expire' => 0, + 'timeout' => 0, + 'prefix' => '', + 'option' => [], + 'username' => '', + 'password' => '', + 'tag_prefix' => 'tag:', + 'serialize' => [], + 'fail_delete' => false, + ]; + + /** + * 架构函数 + * @access public + * @param array $options 缓存参数 + */ + public function __construct(array $options = []) + { + if (!extension_loaded('memcached')) { + throw new \BadFunctionCallException('not support: memcached'); + } + + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + + $this->handler = new \Memcached; + + if (!empty($this->options['option'])) { + $this->handler->setOptions($this->options['option']); + } + + // 设置连接超时时间(单位:毫秒) + if ($this->options['timeout'] > 0) { + $this->handler->setOption(\Memcached::OPT_CONNECT_TIMEOUT, $this->options['timeout']); + } + + // 支持集群 + $hosts = (array) $this->options['host']; + $ports = (array) $this->options['port']; + if (empty($ports[0])) { + $ports[0] = 11211; + } + + // 建立连接 + $servers = []; + foreach ($hosts as $i => $host) { + $servers[] = [$host, $ports[$i] ?? $ports[0], 1]; + } + + $this->handler->addServers($servers); + + if ('' != $this->options['username']) { + $this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); + $this->handler->setSaslAuthData($this->options['username'], $this->options['password']); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name): bool + { + $key = $this->getCacheKey($name); + + return $this->handler->get($key) ? true : false; + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = null): mixed + { + $result = $this->handler->get($this->getCacheKey($name)); + try { + return false !== $result ? $this->unserialize($result) : $this->getDefaultValue($name, $default); + } catch (InvalidCacheException $e) { + return $this->getDefaultValue($name, $default, true); + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|DateInterval|DateTimeInterface $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null): bool + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + + $key = $this->getCacheKey($name); + $expire = $this->getExpireTime($expire); + $value = $this->serialize($value); + + if ($this->handler->set($key, $value, $expire)) { + return true; + } + + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + + if ($this->handler->get($key)) { + return $this->handler->increment($key, $step); + } + + return $this->handler->set($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + $value = $this->handler->get($key) - $step; + $res = $this->handler->set($key, $value); + + return !$res ? false : $value; + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @param bool|false $ttl + * @return bool + */ + public function delete($name, $ttl = false): bool + { + $key = $this->getCacheKey($name); + + return false === $ttl ? + $this->handler->delete($key) : + $this->handler->delete($key, $ttl); + } + + /** + * 清除缓存 + * @access public + * @return bool + */ + public function clear(): bool + { + return $this->handler->flush(); + } + + /** + * 删除缓存标签 + * @access public + * @param array $keys 缓存标识列表 + * @return void + */ + public function clearTag($keys): void + { + $this->handler->deleteMulti($keys); + } +} diff --git a/vendor/topthink/framework/src/think/cache/driver/Redis.php b/vendor/topthink/framework/src/think/cache/driver/Redis.php new file mode 100644 index 0000000..bcac261 --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/driver/Redis.php @@ -0,0 +1,254 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\cache\driver; + +use DateInterval; +use DateTimeInterface; +use think\cache\Driver; +use think\exception\InvalidCacheException; + +class Redis extends Driver +{ + /** @var \Predis\Client|\Redis */ + protected $handler; + + /** + * 配置参数 + * @var array + */ + protected $options = [ + 'host' => '127.0.0.1', + 'port' => 6379, + 'password' => '', + 'select' => 0, + 'timeout' => 0, + 'expire' => 0, + 'persistent' => false, + 'prefix' => '', + 'tag_prefix' => 'tag:', + 'serialize' => [], + 'fail_delete' => false, + ]; + + /** + * 架构函数 + * @access public + * @param array $options 缓存参数 + */ + public function __construct(array $options = []) + { + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + } + + public function handler() + { + if (!$this->handler) { + if (extension_loaded('redis')) { + $this->handler = new \Redis; + + if ($this->options['persistent']) { + $this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_' . $this->options['select']); + } else { + $this->handler->connect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout']); + } + + if ('' != $this->options['password']) { + $this->handler->auth($this->options['password']); + } + } elseif (class_exists('\Predis\Client')) { + $params = []; + foreach ($this->options as $key => $val) { + if (in_array($key, ['aggregate', 'cluster', 'connections', 'exceptions', 'prefix', 'profile', 'replication', 'parameters'])) { + $params[$key] = $val; + unset($this->options[$key]); + } + } + + if ('' == $this->options['password']) { + unset($this->options['password']); + } + + $this->handler = new \Predis\Client($this->options, $params); + + $this->options['prefix'] = ''; + } else { + throw new \BadFunctionCallException('not support: redis'); + } + + if (0 != $this->options['select']) { + $this->handler->select((int) $this->options['select']); + } + } + + return $this->handler; + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name): bool + { + return $this->handler()->exists($this->getCacheKey($name)) ? true : false; + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = null): mixed + { + $key = $this->getCacheKey($name); + $value = $this->handler()->get($key); + + if (false === $value || is_null($value)) { + return $this->getDefaultValue($name, $default); + } + + try { + return $this->unserialize($value); + } catch (InvalidCacheException $e) { + return $this->getDefaultValue($name, $default, true); + + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|DateInterval|DateTimeInterface $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null): bool + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + + $key = $this->getCacheKey($name); + $expire = $this->getExpireTime($expire); + $value = $this->serialize($value); + + if ($expire) { + $this->handler()->setex($key, $expire, $value); + } else { + $this->handler()->set($key, $value); + } + + return true; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + + return $this->handler()->incrby($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + + return $this->handler()->decrby($key, $step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function delete($name): bool + { + $key = $this->getCacheKey($name); + $result = $this->handler()->del($key); + return $result > 0; + } + + /** + * 清除缓存 + * @access public + * @return bool + */ + public function clear(): bool + { + $this->handler()->flushDB(); + return true; + } + + /** + * 删除缓存标签 + * @access public + * @param array $keys 缓存标识列表 + * @return void + */ + public function clearTag($keys): void + { + // 指定标签清除 + $this->handler()->del($keys); + } + + /** + * 追加TagSet数据 + * @access public + * @param string $name 缓存标识 + * @param mixed $value 数据 + * @return void + */ + public function append($name, $value): void + { + $key = $this->getCacheKey($name); + $this->handler()->sAdd($key, $value); + } + + /** + * 获取标签包含的缓存标识 + * @access public + * @param string $tag 缓存标签 + * @return array + */ + public function getTagItems($tag): array + { + $name = $this->getTagKey($tag); + $key = $this->getCacheKey($name); + return $this->handler()->sMembers($key); + } + + public function __call($method, $args) + { + return call_user_func_array([$this->handler(), $method], $args); + } +} diff --git a/vendor/topthink/framework/src/think/cache/driver/Wincache.php b/vendor/topthink/framework/src/think/cache/driver/Wincache.php new file mode 100644 index 0000000..255e006 --- /dev/null +++ b/vendor/topthink/framework/src/think/cache/driver/Wincache.php @@ -0,0 +1,170 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\cache\driver; + +use DateInterval; +use DateTimeInterface; +use think\cache\Driver; +use think\exception\InvalidCacheException; + +/** + * Wincache缓存驱动 + */ +class Wincache extends Driver +{ + /** + * 配置参数 + * @var array + */ + protected $options = [ + 'prefix' => '', + 'expire' => 0, + 'tag_prefix' => 'tag:', + 'serialize' => [], + 'fail_delete' => false, + ]; + + /** + * 架构函数 + * @access public + * @param array $options 缓存参数 + * @throws \BadFunctionCallException + */ + public function __construct(array $options = []) + { + if (!function_exists('wincache_ucache_info')) { + throw new \BadFunctionCallException('not support: WinCache'); + } + + if (!empty($options)) { + $this->options = array_merge($this->options, $options); + } + } + + /** + * 判断缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function has($name): bool + { + $this->readTimes++; + + $key = $this->getCacheKey($name); + + return wincache_ucache_exists($key); + } + + /** + * 读取缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $default 默认值 + * @return mixed + */ + public function get($name, $default = null): mixed + { + $key = $this->getCacheKey($name); + try { + return wincache_ucache_exists($key) ? $this->unserialize(wincache_ucache_get($key)) : $this->getDefaultValue($name, $default); + } catch (InvalidCacheException $e) { + return $this->getDefaultValue($name, $default, true); + } + } + + /** + * 写入缓存 + * @access public + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param integer|DateInterval|DateTimeInterface $expire 有效时间(秒) + * @return bool + */ + public function set($name, $value, $expire = null): bool + { + if (is_null($expire)) { + $expire = $this->options['expire']; + } + + $key = $this->getCacheKey($name); + $expire = $this->getExpireTime($expire); + $value = $this->serialize($value); + + if (wincache_ucache_set($key, $value, $expire)) { + return true; + } + + return false; + } + + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1) + { + $key = $this->getCacheKey($name); + + return wincache_ucache_inc($key, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1) + { + $key = $this->getCacheKey($name); + + return wincache_ucache_dec($key, $step); + } + + /** + * 删除缓存 + * @access public + * @param string $name 缓存变量名 + * @return bool + */ + public function delete($name): bool + { + return wincache_ucache_delete($this->getCacheKey($name)); + } + + /** + * 清除缓存 + * @access public + * @return bool + */ + public function clear(): bool + { + return wincache_ucache_clear(); + } + + /** + * 删除缓存标签 + * @access public + * @param array $keys 缓存标识列表 + * @return void + */ + public function clearTag($keys): void + { + wincache_ucache_delete($keys); + } +} diff --git a/vendor/topthink/framework/src/think/console/Command.php b/vendor/topthink/framework/src/think/console/Command.php new file mode 100644 index 0000000..d4aa322 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/Command.php @@ -0,0 +1,504 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\console; + +use Exception; +use InvalidArgumentException; +use LogicException; +use think\App; +use think\Console; +use think\console\input\Argument; +use think\console\input\Definition; +use think\console\input\Option; + +abstract class Command +{ + + /** @var Console */ + private $console; + private $name; + private $processTitle; + private $aliases = []; + private $definition; + private $help; + private $description; + private $ignoreValidationErrors = false; + private $consoleDefinitionMerged = false; + private $consoleDefinitionMergedWithArgs = false; + private $synopsis = []; + private $usages = []; + + /** @var Input */ + protected $input; + + /** @var Output */ + protected $output; + + /** @var App */ + protected $app; + + /** + * 构造方法 + * @throws LogicException + * @api + */ + public function __construct() + { + $this->definition = new Definition(); + + $this->configure(); + + if (!$this->name) { + throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_class($this))); + } + } + + /** + * 忽略验证错误 + */ + public function ignoreValidationErrors(): void + { + $this->ignoreValidationErrors = true; + } + + /** + * 设置控制台 + * @param Console $console + */ + public function setConsole(?Console $console = null): void + { + $this->console = $console; + } + + /** + * 获取控制台 + * @return Console + * @api + */ + public function getConsole(): Console + { + return $this->console; + } + + /** + * 设置app + * @param App $app + */ + public function setApp(App $app) + { + $this->app = $app; + } + + /** + * 获取app + * @return App + */ + public function getApp() + { + return $this->app; + } + + /** + * 是否有效 + * @return bool + */ + public function isEnabled(): bool + { + return true; + } + + /** + * 配置指令 + */ + protected function configure() + { + } + + /** + * 执行指令 + * @param Input $input + * @param Output $output + * @return null|int + * @throws LogicException + * @see setCode() + */ + protected function execute(Input $input, Output $output) + { + return $this->app->invoke([$this, 'handle']); + } + + /** + * 用户验证 + * @param Input $input + * @param Output $output + */ + protected function interact(Input $input, Output $output) + { + } + + /** + * 初始化 + * @param Input $input An InputInterface instance + * @param Output $output An OutputInterface instance + */ + protected function initialize(Input $input, Output $output) + { + } + + /** + * 执行 + * @param Input $input + * @param Output $output + * @return int + * @throws Exception + * @see setCode() + * @see execute() + */ + public function run(Input $input, Output $output): int + { + $this->input = $input; + $this->output = $output; + + $this->getSynopsis(true); + $this->getSynopsis(false); + + $this->mergeConsoleDefinition(); + + try { + $input->bind($this->definition); + } catch (Exception $e) { + if (!$this->ignoreValidationErrors) { + throw $e; + } + } + + $this->initialize($input, $output); + + if (null !== $this->processTitle) { + if (function_exists('cli_set_process_title')) { + if (false === @cli_set_process_title($this->processTitle)) { + if ('Darwin' === PHP_OS) { + $output->writeln('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.'); + } else { + $error = error_get_last(); + trigger_error($error['message'], E_USER_WARNING); + } + } + } elseif (function_exists('setproctitle')) { + setproctitle($this->processTitle); + } elseif (Output::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { + $output->writeln('Install the proctitle PECL to be able to change the process title.'); + } + } + + if ($input->isInteractive()) { + $this->interact($input, $output); + } + + $input->validate(); + + $statusCode = $this->execute($input, $output); + + return is_numeric($statusCode) ? (int) $statusCode : 0; + } + + /** + * 合并参数定义 + * @param bool $mergeArgs + */ + public function mergeConsoleDefinition(bool $mergeArgs = true) + { + if (null === $this->console + || (true === $this->consoleDefinitionMerged + && ($this->consoleDefinitionMergedWithArgs || !$mergeArgs)) + ) { + return; + } + + if ($mergeArgs) { + $currentArguments = $this->definition->getArguments(); + $this->definition->setArguments($this->console->getDefinition()->getArguments()); + $this->definition->addArguments($currentArguments); + } + + $this->definition->addOptions($this->console->getDefinition()->getOptions()); + + $this->consoleDefinitionMerged = true; + if ($mergeArgs) { + $this->consoleDefinitionMergedWithArgs = true; + } + } + + /** + * 设置参数定义 + * @param array|Definition $definition + * @return Command + * @api + */ + public function setDefinition($definition) + { + if ($definition instanceof Definition) { + $this->definition = $definition; + } else { + $this->definition->setDefinition($definition); + } + + $this->consoleDefinitionMerged = false; + + return $this; + } + + /** + * 获取参数定义 + * @return Definition + * @api + */ + public function getDefinition(): Definition + { + return $this->definition; + } + + /** + * 获取当前指令的参数定义 + * @return Definition + */ + public function getNativeDefinition(): Definition + { + return $this->getDefinition(); + } + + /** + * 添加参数 + * @param string $name 名称 + * @param int $mode 类型 + * @param string $description 描述 + * @param mixed $default 默认值 + * @return Command + */ + public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null) + { + $this->definition->addArgument(new Argument($name, $mode, $description, $default)); + + return $this; + } + + /** + * 添加选项 + * @param string $name 选项名称 + * @param string $shortcut 别名 + * @param int $mode 类型 + * @param string $description 描述 + * @param mixed $default 默认值 + * @return Command + */ + public function addOption(string $name, ?string $shortcut = null, ?int $mode = null, string $description = '', $default = null) + { + $this->definition->addOption(new Option($name, $shortcut, $mode, $description, $default)); + + return $this; + } + + /** + * 设置指令名称 + * @param string $name + * @return Command + * @throws InvalidArgumentException + */ + public function setName(string $name) + { + $this->validateName($name); + + $this->name = $name; + + return $this; + } + + /** + * 设置进程名称 + * + * PHP 5.5+ or the proctitle PECL library is required + * + * @param string $title The process title + * + * @return $this + */ + public function setProcessTitle($title) + { + $this->processTitle = $title; + + return $this; + } + + /** + * 获取指令名称 + * @return string + */ + public function getName(): string + { + return $this->name ?: ''; + } + + /** + * 设置描述 + * @param string $description + * @return Command + */ + public function setDescription(string $description) + { + $this->description = $description; + + return $this; + } + + /** + * 获取描述 + * @return string + */ + public function getDescription(): string + { + return $this->description ?: ''; + } + + /** + * 设置帮助信息 + * @param string $help + * @return Command + */ + public function setHelp(string $help) + { + $this->help = $help; + + return $this; + } + + /** + * 获取帮助信息 + * @return string + */ + public function getHelp(): string + { + return $this->help ?: ''; + } + + /** + * 描述信息 + * @return string + */ + public function getProcessedHelp(): string + { + $name = $this->name; + + $placeholders = [ + '%command.name%', + '%command.full_name%', + ]; + $replacements = [ + $name, + $_SERVER['PHP_SELF'] . ' ' . $name, + ]; + + return str_replace($placeholders, $replacements, $this->getHelp()); + } + + /** + * 设置别名 + * @param string[] $aliases + * @return Command + * @throws InvalidArgumentException + */ + public function setAliases(iterable $aliases) + { + foreach ($aliases as $alias) { + $this->validateName($alias); + } + + $this->aliases = $aliases; + + return $this; + } + + /** + * 获取别名 + * @return array + */ + public function getAliases(): array + { + return $this->aliases; + } + + /** + * 获取简介 + * @param bool $short 是否简单的 + * @return string + */ + public function getSynopsis(bool $short = false): string + { + $key = $short ? 'short' : 'long'; + + if (!isset($this->synopsis[$key])) { + $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short))); + } + + return $this->synopsis[$key]; + } + + /** + * 添加用法介绍 + * @param string $usage + * @return $this + */ + public function addUsage(string $usage) + { + if (!str_starts_with($usage, $this->name)) { + $usage = sprintf('%s %s', $this->name, $usage); + } + + $this->usages[] = $usage; + + return $this; + } + + /** + * 获取用法介绍 + * @return array + */ + public function getUsages(): array + { + return $this->usages; + } + + /** + * 验证指令名称 + * @param string $name + * @throws InvalidArgumentException + */ + private function validateName(string $name) + { + if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { + throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); + } + } + + /** + * 输出表格 + * @param Table $table + * @return string + */ + protected function table(Table $table): string + { + $content = $table->render(); + $this->output->writeln($content); + return $content; + } + +} diff --git a/vendor/topthink/framework/src/think/console/Input.php b/vendor/topthink/framework/src/think/console/Input.php new file mode 100644 index 0000000..533cbf5 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/Input.php @@ -0,0 +1,465 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\console; + +use think\console\input\Argument; +use think\console\input\Definition; +use think\console\input\Option; + +class Input +{ + + /** + * @var Definition + */ + protected $definition; + + /** + * @var Option[] + */ + protected $options = []; + + /** + * @var Argument[] + */ + protected $arguments = []; + + protected $interactive = true; + + private $tokens; + private $parsed; + + public function __construct($argv = null) + { + if (null === $argv) { + $argv = $_SERVER['argv']; + // 去除命令名 + array_shift($argv); + } + + $this->tokens = $argv; + + $this->definition = new Definition(); + } + + protected function setTokens(array $tokens) + { + $this->tokens = $tokens; + } + + /** + * 绑定实例 + * @param Definition $definition A InputDefinition instance + */ + public function bind(Definition $definition): void + { + $this->arguments = []; + $this->options = []; + $this->definition = $definition; + + $this->parse(); + } + + /** + * 解析参数 + */ + protected function parse(): void + { + $parseOptions = true; + $this->parsed = $this->tokens; + while (null !== $token = array_shift($this->parsed)) { + if ($parseOptions && '' == $token) { + $this->parseArgument($token); + } elseif ($parseOptions && '--' == $token) { + $parseOptions = false; + } elseif ($parseOptions && str_starts_with($token, '--')) { + $this->parseLongOption($token); + } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { + $this->parseShortOption($token); + } else { + $this->parseArgument($token); + } + } + } + + /** + * 解析短选项 + * @param string $token 当前的指令. + */ + private function parseShortOption(string $token): void + { + $name = substr($token, 1); + + if (strlen($name) > 1) { + if ($this->definition->hasShortcut($name[0]) + && $this->definition->getOptionForShortcut($name[0])->acceptValue() + ) { + $this->addShortOption($name[0], substr($name, 1)); + } else { + $this->parseShortOptionSet($name); + } + } else { + $this->addShortOption($name, null); + } + } + + /** + * 解析短选项 + * @param string $name 当前指令 + * @throws \RuntimeException + */ + private function parseShortOptionSet(string $name): void + { + $len = strlen($name); + for ($i = 0; $i < $len; ++$i) { + if (!$this->definition->hasShortcut($name[$i])) { + throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); + } + + $option = $this->definition->getOptionForShortcut($name[$i]); + if ($option->acceptValue()) { + $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); + + break; + } else { + $this->addLongOption($option->getName(), null); + } + } + } + + /** + * 解析完整选项 + * @param string $token 当前指令 + */ + private function parseLongOption(string $token): void + { + $name = substr($token, 2); + + if (false !== $pos = strpos($name, '=')) { + $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1)); + } else { + $this->addLongOption($name, null); + } + } + + /** + * 解析参数 + * @param string $token 当前指令 + * @throws \RuntimeException + */ + private function parseArgument(string $token): void + { + $c = count($this->arguments); + + if ($this->definition->hasArgument($c)) { + $arg = $this->definition->getArgument($c); + + $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token; + + } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { + $arg = $this->definition->getArgument($c - 1); + + $this->arguments[$arg->getName()][] = $token; + } else { + throw new \RuntimeException('Too many arguments.'); + } + } + + /** + * 添加一个短选项的值 + * @param string $shortcut 短名称 + * @param mixed $value 值 + * @throws \RuntimeException + */ + private function addShortOption(string $shortcut, $value): void + { + if (!$this->definition->hasShortcut($shortcut)) { + throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); + } + + /** + * 添加一个完整选项的值 + * @param string $name 选项名 + * @param mixed $value 值 + * @throws \RuntimeException + */ + private function addLongOption(string $name, $value): void + { + if (!$this->definition->hasOption($name)) { + throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name)); + } + + $option = $this->definition->getOption($name); + + if (false === $value) { + $value = null; + } + + if (null !== $value && !$option->acceptValue()) { + throw new \RuntimeException(sprintf('The "--%s" option does not accept a value.', $name, $value)); + } + + if (null === $value && $option->acceptValue() && count($this->parsed)) { + $next = array_shift($this->parsed); + if (isset($next[0]) && '-' !== $next[0]) { + $value = $next; + } elseif (empty($next)) { + $value = ''; + } else { + array_unshift($this->parsed, $next); + } + } + + if (null === $value) { + if ($option->isValueRequired()) { + throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name)); + } + + if (!$option->isArray()) { + $value = $option->isValueOptional() ? $option->getDefault() : true; + } + } + + if ($option->isArray()) { + $this->options[$name][] = $value; + } else { + $this->options[$name] = $value; + } + } + + /** + * 获取第一个参数 + * @return string|null + */ + public function getFirstArgument() + { + foreach ($this->tokens as $token) { + if ($token && '-' === $token[0]) { + continue; + } + + return $token; + } + return; + } + + /** + * 检查原始参数是否包含某个值 + * @param string|array $values 需要检查的值 + * @return bool + */ + public function hasParameterOption($values): bool + { + $values = (array) $values; + + foreach ($this->tokens as $token) { + foreach ($values as $value) { + if ($token === $value || str_starts_with($token, $value . '=')) { + return true; + } + } + } + + return false; + } + + /** + * 获取原始选项的值 + * @param string|array $values 需要检查的值 + * @param mixed $default 默认值 + * @return mixed The option value + */ + public function getParameterOption($values, $default = false) + { + $values = (array) $values; + $tokens = $this->tokens; + + while (0 < count($tokens)) { + $token = array_shift($tokens); + + foreach ($values as $value) { + if ($token === $value || str_starts_with($token, $value . '=')) { + if (false !== $pos = strpos($token, '=')) { + return substr($token, $pos + 1); + } + + return array_shift($tokens); + } + } + } + + return $default; + } + + /** + * 验证输入 + * @throws \RuntimeException + */ + public function validate() + { + if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) { + throw new \RuntimeException('Not enough arguments.'); + } + } + + /** + * 检查输入是否是交互的 + * @return bool + */ + public function isInteractive(): bool + { + return $this->interactive; + } + + /** + * 设置输入的交互 + * @param bool + */ + public function setInteractive(bool $interactive): void + { + $this->interactive = $interactive; + } + + /** + * 获取所有的参数 + * @return Argument[] + */ + public function getArguments(): array + { + return array_merge($this->definition->getArgumentDefaults(), $this->arguments); + } + + /** + * 根据名称获取参数 + * @param string $name 参数名 + * @return mixed + * @throws \InvalidArgumentException + */ + public function getArgument(string $name) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + return $this->arguments[$name] ?? $this->definition->getArgument($name) + ->getDefault(); + } + + /** + * 设置参数的值 + * @param string $name 参数名 + * @param string $value 值 + * @throws \InvalidArgumentException + */ + public function setArgument(string $name, $value) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $this->arguments[$name] = $value; + } + + /** + * 检查是否存在某个参数 + * @param string|int $name 参数名或位置 + * @return bool + */ + public function hasArgument(string|int $name): bool + { + return $this->definition->hasArgument($name); + } + + /** + * 获取所有的选项 + * @return Option[] + */ + public function getOptions(): array + { + return array_merge($this->definition->getOptionDefaults(), $this->options); + } + + /** + * 获取选项值 + * @param string $name 选项名称 + * @return mixed + * @throws \InvalidArgumentException + */ + public function getOption(string $name) + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); + } + + return $this->options[$name] ?? $this->definition->getOption($name)->getDefault(); + } + + /** + * 设置选项值 + * @param string $name 选项名 + * @param string|bool $value 值 + * @throws \InvalidArgumentException + */ + public function setOption(string $name, $value): void + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); + } + + $this->options[$name] = $value; + } + + /** + * 是否有某个选项 + * @param string $name 选项名 + * @return bool + */ + public function hasOption(string $name): bool + { + return $this->definition->hasOption($name) && isset($this->options[$name]); + } + + /** + * 转义指令 + * @param string $token + * @return string + */ + public function escapeToken(string $token): string + { + return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token); + } + + /** + * 返回传递给命令的参数的字符串 + * @return string + */ + public function __toString() + { + $tokens = array_map(function ($token) { + if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { + return $match[1] . $this->escapeToken($match[2]); + } + + if ($token && '-' !== $token[0]) { + return $this->escapeToken($token); + } + + return $token; + }, $this->tokens); + + return implode(' ', $tokens); + } +} diff --git a/vendor/topthink/framework/src/think/console/LICENSE b/vendor/topthink/framework/src/think/console/LICENSE new file mode 100644 index 0000000..0abe056 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2016 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. \ No newline at end of file diff --git a/vendor/topthink/framework/src/think/console/Output.php b/vendor/topthink/framework/src/think/console/Output.php new file mode 100644 index 0000000..da41523 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/Output.php @@ -0,0 +1,231 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\console; + +use Exception; +use think\console\output\Ask; +use think\console\output\Descriptor; +use think\console\output\driver\Buffer; +use think\console\output\driver\Console; +use think\console\output\driver\Nothing; +use think\console\output\Question; +use think\console\output\question\Choice; +use think\console\output\question\Confirmation; +use Throwable; + +/** + * Class Output + * @package think\console + * + * @see \think\console\output\driver\Console::setDecorated + * @method void setDecorated($decorated) + * + * @see \think\console\output\driver\Buffer::fetch + * @method string fetch() + * + * @method void info($message) + * @method void error($message) + * @method void comment($message) + * @method void warning($message) + * @method void highlight($message) + * @method void question($message) + */ +class Output +{ + // 不显示信息(静默) + const VERBOSITY_QUIET = 0; + // 正常信息 + const VERBOSITY_NORMAL = 1; + // 详细信息 + const VERBOSITY_VERBOSE = 2; + // 非常详细的信息 + const VERBOSITY_VERY_VERBOSE = 3; + // 调试信息 + const VERBOSITY_DEBUG = 4; + + const OUTPUT_NORMAL = 0; + const OUTPUT_RAW = 1; + const OUTPUT_PLAIN = 2; + + // 输出信息级别 + private $verbosity = self::VERBOSITY_NORMAL; + + /** @var Buffer|Console|Nothing */ + private $handle = null; + + protected $styles = [ + 'info', + 'error', + 'comment', + 'question', + 'highlight', + 'warning', + ]; + + public function __construct($driver = 'console') + { + $class = '\\think\\console\\output\\driver\\' . ucwords($driver); + + $this->handle = new $class($this); + } + + public function ask(Input $input, $question, $default = null, $validator = null) + { + $question = new Question($question, $default); + $question->setValidator($validator); + + return $this->askQuestion($input, $question); + } + + public function askHidden(Input $input, $question, $validator = null) + { + $question = new Question($question); + + $question->setHidden(true); + $question->setValidator($validator); + + return $this->askQuestion($input, $question); + } + + public function confirm(Input $input, $question, $default = true) + { + return $this->askQuestion($input, new Confirmation($question, $default)); + } + + /** + * {@inheritdoc} + */ + public function choice(Input $input, $question, array $choices, $default = null) + { + if (null !== $default) { + $values = array_flip($choices); + $default = $values[$default]; + } + + return $this->askQuestion($input, new Choice($question, $choices, $default)); + } + + protected function askQuestion(Input $input, Question $question) + { + $ask = new Ask($input, $this, $question); + $answer = $ask->run(); + + if ($input->isInteractive()) { + $this->newLine(); + } + + return $answer; + } + + protected function block(string $style, string $message): void + { + $this->writeln("<{$style}>{$message}"); + } + + /** + * 输出空行 + * @param int $count + */ + public function newLine(int $count = 1): void + { + $this->write(str_repeat(PHP_EOL, $count)); + } + + /** + * 输出信息并换行 + * @param string $messages + * @param int $type + */ + public function writeln(string $messages, int $type = 0): void + { + $this->write($messages, true, $type); + } + + /** + * 输出信息 + * @param string $messages + * @param bool $newline + * @param int $type + */ + public function write(string $messages, bool $newline = false, int $type = 0): void + { + $this->handle->write($messages, $newline, $type); + } + + public function renderException(Throwable $e): void + { + $this->handle->renderException($e); + } + + /** + * 设置输出信息级别 + * @param int $level 输出信息级别 + */ + public function setVerbosity(int $level) + { + $this->verbosity = $level; + } + + /** + * 获取输出信息级别 + * @return int + */ + public function getVerbosity(): int + { + return $this->verbosity; + } + + public function isQuiet(): bool + { + return self::VERBOSITY_QUIET === $this->verbosity; + } + + public function isVerbose(): bool + { + return self::VERBOSITY_VERBOSE <= $this->verbosity; + } + + public function isVeryVerbose(): bool + { + return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity; + } + + public function isDebug(): bool + { + return self::VERBOSITY_DEBUG <= $this->verbosity; + } + + public function describe($object, array $options = []): void + { + $descriptor = new Descriptor(); + $options = array_merge([ + 'raw_text' => false, + ], $options); + + $descriptor->describe($this, $object, $options); + } + + public function __call($method, $args) + { + if (in_array($method, $this->styles)) { + array_unshift($args, $method); + return call_user_func_array([$this, 'block'], $args); + } + + if ($this->handle && method_exists($this->handle, $method)) { + return call_user_func_array([$this->handle, $method], $args); + } else { + throw new Exception('method not exists:' . __CLASS__ . '->' . $method); + } + } +} diff --git a/vendor/topthink/framework/src/think/console/Table.php b/vendor/topthink/framework/src/think/console/Table.php new file mode 100644 index 0000000..aa86fb4 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/Table.php @@ -0,0 +1,300 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\console; + +class Table +{ + const ALIGN_LEFT = 1; + const ALIGN_RIGHT = 0; + const ALIGN_CENTER = 2; + + /** + * 头信息数据 + * @var array + */ + protected $header = []; + + /** + * 头部对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER + * @var int + */ + protected $headerAlign = 1; + + /** + * 表格数据(二维数组) + * @var array + */ + protected $rows = []; + + /** + * 单元格对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER + * @var int + */ + protected $cellAlign = 1; + + /** + * 单元格宽度信息 + * @var array + */ + protected $colWidth = []; + + /** + * 表格输出样式 + * @var string + */ + protected $style = 'default'; + + /** + * 表格样式定义 + * @var array + */ + protected $format = [ + 'compact' => [], + 'default' => [ + 'top' => ['+', '-', '+', '+'], + 'cell' => ['|', ' ', '|', '|'], + 'middle' => ['+', '-', '+', '+'], + 'bottom' => ['+', '-', '+', '+'], + 'cross-top' => ['+', '-', '-', '+'], + 'cross-bottom' => ['+', '-', '-', '+'], + ], + 'markdown' => [ + 'top' => [' ', ' ', ' ', ' '], + 'cell' => ['|', ' ', '|', '|'], + 'middle' => ['|', '-', '|', '|'], + 'bottom' => [' ', ' ', ' ', ' '], + 'cross-top' => ['|', ' ', ' ', '|'], + 'cross-bottom' => ['|', ' ', ' ', '|'], + ], + 'borderless' => [ + 'top' => ['=', '=', ' ', '='], + 'cell' => [' ', ' ', ' ', ' '], + 'middle' => ['=', '=', ' ', '='], + 'bottom' => ['=', '=', ' ', '='], + 'cross-top' => ['=', '=', ' ', '='], + 'cross-bottom' => ['=', '=', ' ', '='], + ], + 'box' => [ + 'top' => ['┌', '─', '┬', '┐'], + 'cell' => ['│', ' ', '│', '│'], + 'middle' => ['├', '─', '┼', '┤'], + 'bottom' => ['└', '─', '┴', '┘'], + 'cross-top' => ['├', '─', '┴', '┤'], + 'cross-bottom' => ['├', '─', '┬', '┤'], + ], + 'box-double' => [ + 'top' => ['╔', '═', '╤', '╗'], + 'cell' => ['║', ' ', '│', '║'], + 'middle' => ['╠', '─', '╪', '╣'], + 'bottom' => ['╚', '═', '╧', '╝'], + 'cross-top' => ['╠', '═', '╧', '╣'], + 'cross-bottom' => ['╠', '═', '╤', '╣'], + ], + ]; + + /** + * 设置表格头信息 以及对齐方式 + * @access public + * @param array $header 要输出的Header信息 + * @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER + * @return void + */ + public function setHeader(array $header, int $align = 1): void + { + $this->header = $header; + $this->headerAlign = $align; + + $this->checkColWidth($header); + } + + /** + * 设置输出表格数据 及对齐方式 + * @access public + * @param array $rows 要输出的表格数据(二维数组) + * @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER + * @return void + */ + public function setRows(array $rows, int $align = 1): void + { + $this->rows = $rows; + $this->cellAlign = $align; + + foreach ($rows as $row) { + $this->checkColWidth($row); + } + } + + /** + * 设置全局单元格对齐方式 + * @param int $align 对齐方式 默认1 ALGIN_LEFT 0 ALIGN_RIGHT 2 ALIGN_CENTER + * @return $this + */ + public function setCellAlign(int $align = 1) + { + $this->cellAlign = $align; + return $this; + } + + /** + * 检查列数据的显示宽度 + * @access public + * @param mixed $row 行数据 + * @return void + */ + protected function checkColWidth($row): void + { + if (is_array($row)) { + foreach ($row as $key => $cell) { + $width = mb_strwidth((string) $cell); + if (!isset($this->colWidth[$key]) || $width > $this->colWidth[$key]) { + $this->colWidth[$key] = $width; + } + } + } + } + + /** + * 增加一行表格数据 + * @access public + * @param mixed $row 行数据 + * @param bool $first 是否在开头插入 + * @return void + */ + public function addRow($row, bool $first = false): void + { + if ($first) { + array_unshift($this->rows, $row); + } else { + $this->rows[] = $row; + } + + $this->checkColWidth($row); + } + + /** + * 设置输出表格的样式 + * @access public + * @param string $style 样式名 + * @return void + */ + public function setStyle(string $style): void + { + $this->style = isset($this->format[$style]) ? $style : 'default'; + } + + /** + * 输出分隔行 + * @access public + * @param string $pos 位置 + * @return string + */ + protected function renderSeparator(string $pos): string + { + $style = $this->getStyle($pos); + $array = []; + + foreach ($this->colWidth as $width) { + $array[] = str_repeat($style[1], $width + 2); + } + + return $style[0] . implode($style[2], $array) . $style[3] . PHP_EOL; + } + + /** + * 输出表格头部 + * @access public + * @return string + */ + protected function renderHeader(): string + { + $style = $this->getStyle('cell'); + $content = $this->renderSeparator('top'); + + foreach ($this->header as $key => $header) { + $array[] = ' ' . str_pad($header, $this->colWidth[$key], $style[1], $this->headerAlign); + } + + if (!empty($array)) { + $content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL; + + if (!empty($this->rows)) { + $content .= $this->renderSeparator('middle'); + } + } + + return $content; + } + + protected function getStyle(string $style): array + { + if ($this->format[$this->style]) { + $style = $this->format[$this->style][$style]; + } else { + $style = [' ', ' ', ' ', ' ']; + } + + return $style; + } + + /** + * 输出表格 + * @access public + * @param array $dataList 表格数据 + * @return string + */ + public function render(array $dataList = []): string + { + if (!empty($dataList)) { + $this->setRows($dataList); + } + + // 输出头部 + $content = $this->renderHeader(); + $style = $this->getStyle('cell'); + + if (!empty($this->rows)) { + foreach ($this->rows as $row) { + if (is_string($row) && '-' === $row) { + $content .= $this->renderSeparator('middle'); + } elseif (is_scalar($row)) { + $content .= $this->renderSeparator('cross-top'); + $width = 3 * (count($this->colWidth) - 1) + array_reduce($this->colWidth, function ($a, $b) { + return $a + $b; + }); + $array = str_pad($row, $width); + + $content .= $style[0] . ' ' . $array . ' ' . $style[3] . PHP_EOL; + $content .= $this->renderSeparator('cross-bottom'); + } else { + $array = []; + + foreach ($row as $key => $val) { + $width = $this->colWidth[$key]; + // form https://github.com/symfony/console/blob/20c9821c8d1c2189f287dcee709b2f86353ea08f/Helper/Table.php#L467 + // str_pad won't work properly with multi-byte strings, we need to fix the padding + if (false !== $encoding = mb_detect_encoding((string) $val, null, true)) { + $width += strlen((string) $val) - mb_strwidth((string) $val, $encoding); + } + $array[] = ' ' . str_pad((string) $val, $width, ' ', $this->cellAlign); + } + + $content .= $style[0] . implode(' ' . $style[2], $array) . ' ' . $style[3] . PHP_EOL; + } + } + } + + $content .= $this->renderSeparator('bottom'); + + return $content; + } +} diff --git a/vendor/topthink/framework/src/think/console/bin/README.md b/vendor/topthink/framework/src/think/console/bin/README.md new file mode 100644 index 0000000..9acc52f --- /dev/null +++ b/vendor/topthink/framework/src/think/console/bin/README.md @@ -0,0 +1 @@ +console 工具使用 hiddeninput.exe 在 windows 上隐藏密码输入,该二进制文件由第三方提供,相关源码和其他细节可以在 [Hidden Input](https://github.com/Seldaek/hidden-input) 找到。 diff --git a/vendor/topthink/framework/src/think/console/bin/hiddeninput.exe b/vendor/topthink/framework/src/think/console/bin/hiddeninput.exe new file mode 100644 index 0000000000000000000000000000000000000000..c8cf65e8d819e6e525121cf6b21f1c2429746038 GIT binary patch literal 9216 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 J0sQ~1{4brj`U(I5 literal 0 HcmV?d00001 diff --git a/vendor/topthink/framework/src/think/console/command/Clear.php b/vendor/topthink/framework/src/think/console/command/Clear.php new file mode 100644 index 0000000..a359a97 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/Clear.php @@ -0,0 +1,85 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Option; +use think\console\Output; + +class Clear extends Command +{ + protected function configure() + { + // 指令配置 + $this->setName('clear') + ->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null) + ->addOption('cache', 'c', Option::VALUE_NONE, 'clear cache file') + ->addOption('log', 'l', Option::VALUE_NONE, 'clear log file') + ->addOption('dir', 'r', Option::VALUE_NONE, 'clear empty dir') + ->addOption('expire', 'e', Option::VALUE_NONE, 'clear cache file if cache has expired') + ->setDescription('Clear runtime file'); + } + + protected function execute(Input $input, Output $output) + { + $runtimePath = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR; + + if ($input->getOption('cache')) { + $path = $runtimePath . 'cache'; + } elseif ($input->getOption('log')) { + $path = $runtimePath . 'log'; + } else { + $path = $input->getOption('path') ?: $runtimePath; + } + + $rmdir = $input->getOption('dir') ? true : false; + // --expire 仅当 --cache 时生效 + $cache_expire = $input->getOption('expire') && $input->getOption('cache') ? true : false; + $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir, $cache_expire); + + $output->writeln("Clear Successed"); + } + + protected function clear(string $path, bool $rmdir, bool $cache_expire): void + { + $files = is_dir($path) ? scandir($path) : []; + + foreach ($files as $file) { + if ('.' != $file && '..' != $file && is_dir($path . $file)) { + $this->clear($path . $file . DIRECTORY_SEPARATOR, $rmdir, $cache_expire); + if ($rmdir) { + @rmdir($path . $file); + } + } elseif ('.gitignore' != $file && is_file($path . $file)) { + if ($cache_expire) { + if ($this->cacheHasExpired($path . $file)) { + unlink($path . $file); + } + } else { + unlink($path . $file); + } + } + } + } + + /** + * 缓存文件是否已过期 + * @param $filename string 文件路径 + * @return bool + */ + protected function cacheHasExpired($filename) { + $content = file_get_contents($filename); + $expire = (int) substr($content, 8, 12); + return 0 != $expire && time() - $expire > filemtime($filename); + } + +} diff --git a/vendor/topthink/framework/src/think/console/command/Help.php b/vendor/topthink/framework/src/think/console/command/Help.php new file mode 100644 index 0000000..097a98f --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/Help.php @@ -0,0 +1,70 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument as InputArgument; +use think\console\input\Option as InputOption; +use think\console\Output; + +class Help extends Command +{ + + private $command; + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->ignoreValidationErrors(); + + $this->setName('help')->setDefinition([ + new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), + ])->setDescription('Displays help for a command')->setHelp( + <<%command.name% command displays help for a given command: + + php %command.full_name% list + +To display the list of available commands, please use the list command. +EOF + ); + } + + /** + * Sets the command. + * @param Command $command The command to set + */ + public function setCommand(Command $command): void + { + $this->command = $command; + } + + /** + * {@inheritdoc} + */ + protected function execute(Input $input, Output $output) + { + if (null === $this->command) { + $this->command = $this->getConsole()->find($input->getArgument('command_name')); + } + + $output->describe($this->command, [ + 'raw_text' => $input->getOption('raw'), + ]); + + $this->command = null; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/Lists.php b/vendor/topthink/framework/src/think/console/command/Lists.php new file mode 100644 index 0000000..b8368e9 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/Lists.php @@ -0,0 +1,74 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument as InputArgument; +use think\console\input\Definition as InputDefinition; +use think\console\input\Option as InputOption; +use think\console\Output; + +class Lists extends Command +{ + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('list')->setDefinition($this->createDefinition())->setDescription('Lists commands')->setHelp( + <<%command.name% command lists all commands: + + php %command.full_name% + +You can also display the commands for a specific namespace: + + php %command.full_name% test + +It's also possible to get raw list of commands (useful for embedding command runner): + + php %command.full_name% --raw +EOF + ); + } + + /** + * {@inheritdoc} + */ + public function getNativeDefinition(): InputDefinition + { + return $this->createDefinition(); + } + + /** + * {@inheritdoc} + */ + protected function execute(Input $input, Output $output) + { + $output->describe($this->getConsole(), [ + 'raw_text' => $input->getOption('raw'), + 'namespace' => $input->getArgument('namespace'), + ]); + } + + /** + * {@inheritdoc} + */ + private function createDefinition(): InputDefinition + { + return new InputDefinition([ + new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), + ]); + } +} diff --git a/vendor/topthink/framework/src/think/console/command/Make.php b/vendor/topthink/framework/src/think/console/command/Make.php new file mode 100644 index 0000000..ac2453d --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/Make.php @@ -0,0 +1,99 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\Output; + +abstract class Make extends Command +{ + protected $type; + + abstract protected function getStub(); + + protected function configure() + { + $this->addArgument('name', Argument::REQUIRED, "The name of the class"); + } + + protected function execute(Input $input, Output $output) + { + $name = trim($input->getArgument('name')); + + $classname = $this->getClassName($name); + + $pathname = $this->getPathName($classname); + + if (is_file($pathname)) { + $output->writeln('' . $this->type . ':' . $classname . ' already exists!'); + return false; + } + + if (!is_dir(dirname($pathname))) { + mkdir(dirname($pathname), 0755, true); + } + + file_put_contents($pathname, $this->buildClass($classname)); + + $output->writeln('' . $this->type . ':' . $classname . ' created successfully.'); + } + + protected function buildClass(string $name) + { + $stub = file_get_contents($this->getStub()); + + $namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); + + $class = str_replace($namespace . '\\', '', $name); + + return str_replace(['{%className%}', '{%actionSuffix%}', '{%namespace%}', '{%app_namespace%}'], [ + $class, + $this->app->config->get('route.action_suffix'), + $namespace, + $this->app->getNamespace(), + ], $stub); + } + + protected function getPathName(string $name): string + { + $name = substr($name, 4); + + return $this->app->getBasePath() . ltrim(str_replace('\\', '/', $name), '/') . '.php'; + } + + protected function getClassName(string $name): string + { + if (str_contains($name, '\\')) { + return $name; + } + + if (str_contains($name, '@')) { + [$app, $name] = explode('@', $name); + } else { + $app = ''; + } + + if (str_contains($name, '/')) { + $name = str_replace('/', '\\', $name); + } + + return $this->getNamespace($app) . '\\' . $name; + } + + protected function getNamespace(string $app): string + { + return 'app' . ($app ? '\\' . $app : ''); + } + +} diff --git a/vendor/topthink/framework/src/think/console/command/RouteList.php b/vendor/topthink/framework/src/think/console/command/RouteList.php new file mode 100644 index 0000000..a9a1b85 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/RouteList.php @@ -0,0 +1,128 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\input\Option; +use think\console\Output; +use think\console\Table; +use think\event\RouteLoaded; + +class RouteList extends Command +{ + protected $sortBy = [ + 'rule' => 0, + 'route' => 1, + 'method' => 2, + 'name' => 3, + 'domain' => 4, + ]; + + protected function configure() + { + $this->setName('route:list') + ->addArgument('dir', Argument::OPTIONAL, 'dir name .') + ->addArgument('style', Argument::OPTIONAL, "the style of the table.", 'default') + ->addOption('sort', 's', Option::VALUE_OPTIONAL, 'order by rule name.', 0) + ->addOption('more', 'm', Option::VALUE_NONE, 'show route options.') + ->setDescription('show route list.'); + } + + protected function execute(Input $input, Output $output) + { + $dir = $input->getArgument('dir') ?: ''; + + $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($dir ? $dir . DIRECTORY_SEPARATOR : '') . 'route_list.php'; + + if (is_file($filename)) { + unlink($filename); + } elseif (!is_dir(dirname($filename))) { + mkdir(dirname($filename), 0755); + } + + $content = $this->getRouteList($dir); + file_put_contents($filename, 'Route List' . PHP_EOL . $content); + } + + protected function getRouteList(?string $dir = null): string + { + $this->app->route->clear(); + $this->app->route->lazy(false); + + if ($dir) { + $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; + } else { + $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; + } + + $files = is_dir($path) ? scandir($path) : []; + + foreach ($files as $file) { + if (str_contains($file, '.php')) { + include $path . $file; + } + } + + //触发路由载入完成事件 + $this->app->event->trigger(RouteLoaded::class); + + $table = new Table(); + + if ($this->input->hasOption('more')) { + $header = ['Rule', 'Route', 'Method', 'Name', 'Domain', 'Option', 'Pattern']; + } else { + $header = ['Rule', 'Route', 'Method', 'Name']; + } + + $table->setHeader($header); + + $routeList = $this->app->route->getRuleList(); + $rows = []; + + foreach ($routeList as $item) { + $item['route'] = $item['route'] instanceof \Closure ? '' : $item['route']; + $row = [$item['rule'], $item['route'], $item['method'], $item['name']]; + + if ($this->input->hasOption('more')) { + array_push($row, $item['domain'], json_encode($item['option']), json_encode($item['pattern'])); + } + + $rows[] = $row; + } + + if ($this->input->getOption('sort')) { + $sort = strtolower($this->input->getOption('sort')); + + if (isset($this->sortBy[$sort])) { + $sort = $this->sortBy[$sort]; + } + + uasort($rows, function ($a, $b) use ($sort) { + $itemA = $a[$sort] ?? null; + $itemB = $b[$sort] ?? null; + + return strcasecmp($itemA, $itemB); + }); + } + + $table->setRows($rows); + + if ($this->input->getArgument('style')) { + $style = $this->input->getArgument('style'); + $table->setStyle($style); + } + + return $this->table($table); + } + +} diff --git a/vendor/topthink/framework/src/think/console/command/RunServer.php b/vendor/topthink/framework/src/think/console/command/RunServer.php new file mode 100644 index 0000000..92bdd3d --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/RunServer.php @@ -0,0 +1,72 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Option; +use think\console\Output; + +class RunServer extends Command +{ + public function configure() + { + $this->setName('run') + ->addOption( + 'host', + 'H', + Option::VALUE_OPTIONAL, + 'The host to server the application on', + '0.0.0.0' + ) + ->addOption( + 'port', + 'p', + Option::VALUE_OPTIONAL, + 'The port to server the application on', + 8000 + ) + ->addOption( + 'root', + 'r', + Option::VALUE_OPTIONAL, + 'The document root of the application', + '' + ) + ->setDescription('PHP Built-in Server for ThinkPHP'); + } + + public function execute(Input $input, Output $output) + { + $host = $input->getOption('host'); + $port = $input->getOption('port'); + $root = $input->getOption('root'); + if (empty($root)) { + $root = $this->app->getRootPath() . 'public'; + } + + $command = sprintf( + '"%s" -S %s:%d -t %s %s', + PHP_BINARY, + $host, + $port, + escapeshellarg($root), + escapeshellarg($root . DIRECTORY_SEPARATOR . 'router.php') + ); + + $output->writeln(sprintf('ThinkPHP Development server is started On ', $host, $port)); + $output->writeln(sprintf('You can exit with `CTRL-C`')); + $output->writeln(sprintf('Document root is: %s', $root)); + passthru($command); + } +} diff --git a/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php b/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php new file mode 100644 index 0000000..05cff55 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\console\command; + +use think\console\Command; +use think\console\Input; +use think\console\Output; + +class ServiceDiscover extends Command +{ + public function configure() + { + $this->setName('service:discover') + ->setDescription('Discover Services for ThinkPHP'); + } + + public function execute(Input $input, Output $output) + { + if (is_file($path = $this->app->getRootPath() . 'vendor/composer/installed.json')) { + $packages = json_decode(@file_get_contents($path), true); + // Compatibility with Composer 2.0 + if (isset($packages['packages'])) { + $packages = $packages['packages']; + } + + $services = []; + foreach ($packages as $package) { + if (!empty($package['extra']['think']['services'])) { + $services = array_merge($services, (array) $package['extra']['think']['services']); + } + } + + $header = '// This file is automatically generated at:' . date('Y-m-d H:i:s') . PHP_EOL . 'declare (strict_types = 1);' . PHP_EOL; + + $content = 'app->getRootPath() . 'vendor/services.php', $content); + + $output->writeln('Succeed!'); + } + } +} diff --git a/vendor/topthink/framework/src/think/console/command/VendorPublish.php b/vendor/topthink/framework/src/think/console/command/VendorPublish.php new file mode 100644 index 0000000..49cec9c --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/VendorPublish.php @@ -0,0 +1,69 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\console\command; + +use think\console\Command; +use think\console\input\Option; + +class VendorPublish extends Command +{ + public function configure() + { + $this->setName('vendor:publish') + ->addOption('force', 'f', Option::VALUE_NONE, 'Overwrite any existing files') + ->setDescription('Publish any publishable assets from vendor packages'); + } + + public function handle() + { + + $force = $this->input->getOption('force'); + + if (is_file($path = $this->app->getRootPath() . 'vendor/composer/installed.json')) { + $packages = json_decode(@file_get_contents($path), true); + // Compatibility with Composer 2.0 + if (isset($packages['packages'])) { + $packages = $packages['packages']; + } + foreach ($packages as $package) { + //配置 + $configDir = $this->app->getConfigPath(); + + if (!empty($package['extra']['think']['config'])) { + + $installPath = $this->app->getRootPath() . 'vendor/' . $package['name'] . DIRECTORY_SEPARATOR; + + foreach ((array) $package['extra']['think']['config'] as $name => $file) { + + $target = $configDir . $name . '.php'; + $source = $installPath . $file; + + if (is_file($target) && !$force) { + $this->output->info("File {$target} exist!"); + continue; + } + + if (!is_file($source)) { + $this->output->info("File {$source} not exist!"); + continue; + } + + copy($source, $target); + } + } + } + + $this->output->writeln('Succeed!'); + } + } +} diff --git a/vendor/topthink/framework/src/think/console/command/Version.php b/vendor/topthink/framework/src/think/console/command/Version.php new file mode 100644 index 0000000..bae3472 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/Version.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\console\command; + +use Composer\InstalledVersions; +use think\console\Command; +use think\console\Input; +use think\console\Output; + +class Version extends Command +{ + protected function configure() + { + // 指令配置 + $this->setName('version') + ->setDescription('show thinkphp framework version'); + } + + protected function execute(Input $input, Output $output) + { + $version = InstalledVersions::getPrettyVersion('topthink/framework'); + $output->writeln($version); + } + +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Command.php b/vendor/topthink/framework/src/think/console/command/make/Command.php new file mode 100644 index 0000000..c38c482 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Command.php @@ -0,0 +1,54 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; +use think\console\input\Argument; + +class Command extends Make +{ + protected $type = "Command"; + + protected function configure() + { + parent::configure(); + $this->setName('make:command') + ->addArgument('commandName', Argument::OPTIONAL, "The name of the command") + ->setDescription('Create a new command class'); + } + + protected function buildClass(string $name): string + { + $commandName = $this->input->getArgument('commandName') ?: strtolower(basename($name)); + $namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); + + $class = str_replace($namespace . '\\', '', $name); + $stub = file_get_contents($this->getStub()); + + return str_replace(['{%commandName%}', '{%className%}', '{%namespace%}', '{%app_namespace%}'], [ + $commandName, + $class, + $namespace, + $this->app->getNamespace(), + ], $stub); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'command.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\command'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Controller.php b/vendor/topthink/framework/src/think/console/command/make/Controller.php new file mode 100644 index 0000000..45157f2 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Controller.php @@ -0,0 +1,55 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; +use think\console\input\Option; + +class Controller extends Make +{ + + protected $type = "Controller"; + + protected function configure() + { + parent::configure(); + $this->setName('make:controller') + ->addOption('api', null, Option::VALUE_NONE, 'Generate an api controller class.') + ->addOption('plain', null, Option::VALUE_NONE, 'Generate an empty controller class.') + ->setDescription('Create a new resource controller class'); + } + + protected function getStub(): string + { + $stubPath = __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR; + + if ($this->input->getOption('api')) { + return $stubPath . 'controller.api.stub'; + } + + if ($this->input->getOption('plain')) { + return $stubPath . 'controller.plain.stub'; + } + + return $stubPath . 'controller.stub'; + } + + protected function getClassName(string $name): string + { + return parent::getClassName($name) . ($this->app->config->get('route.controller_suffix') ? 'Controller' : ''); + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\controller'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Event.php b/vendor/topthink/framework/src/think/console/command/make/Event.php new file mode 100644 index 0000000..efc5bb1 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Event.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\make; + +use think\console\command\Make; + +class Event extends Make +{ + protected $type = "Event"; + + protected function configure() + { + parent::configure(); + $this->setName('make:event') + ->setDescription('Create a new event class'); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'event.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\event'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Listener.php b/vendor/topthink/framework/src/think/console/command/make/Listener.php new file mode 100644 index 0000000..f5d3185 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Listener.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\make; + +use think\console\command\Make; + +class Listener extends Make +{ + protected $type = "Listener"; + + protected function configure() + { + parent::configure(); + $this->setName('make:listener') + ->setDescription('Create a new listener class'); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'listener.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\listener'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Middleware.php b/vendor/topthink/framework/src/think/console/command/make/Middleware.php new file mode 100644 index 0000000..523f186 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Middleware.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; + +class Middleware extends Make +{ + protected $type = "Middleware"; + + protected function configure() + { + parent::configure(); + $this->setName('make:middleware') + ->setDescription('Create a new middleware class'); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'middleware.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\middleware'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Model.php b/vendor/topthink/framework/src/think/console/command/make/Model.php new file mode 100644 index 0000000..00b4621 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Model.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; + +class Model extends Make +{ + protected $type = "Model"; + + protected function configure() + { + parent::configure(); + $this->setName('make:model') + ->setDescription('Create a new model class'); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'model.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\model'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Service.php b/vendor/topthink/framework/src/think/console/command/make/Service.php new file mode 100644 index 0000000..3008b0b --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Service.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; + +class Service extends Make +{ + protected $type = "Service"; + + protected function configure() + { + parent::configure(); + $this->setName('make:service') + ->setDescription('Create a new Service class'); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'service.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\service'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Subscribe.php b/vendor/topthink/framework/src/think/console/command/make/Subscribe.php new file mode 100644 index 0000000..f9211f0 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Subscribe.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\make; + +use think\console\command\Make; + +class Subscribe extends Make +{ + protected $type = "Subscribe"; + + protected function configure() + { + parent::configure(); + $this->setName('make:subscribe') + ->setDescription('Create a new subscribe class'); + } + + protected function getStub(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'subscribe.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\subscribe'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/Validate.php b/vendor/topthink/framework/src/think/console/command/make/Validate.php new file mode 100644 index 0000000..798b4cf --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/Validate.php @@ -0,0 +1,38 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\command\make; + +use think\console\command\Make; + +class Validate extends Make +{ + protected $type = "Validate"; + + protected function configure() + { + parent::configure(); + $this->setName('make:validate') + ->setDescription('Create a validate class'); + } + + protected function getStub(): string + { + $stubPath = __DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR; + + return $stubPath . 'validate.stub'; + } + + protected function getNamespace(string $app): string + { + return parent::getNamespace($app) . '\\validate'; + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/stubs/command.stub b/vendor/topthink/framework/src/think/console/command/make/stubs/command.stub new file mode 100644 index 0000000..3ee2b1c --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/stubs/command.stub @@ -0,0 +1,26 @@ +setName('{%commandName%}') + ->setDescription('the {%commandName%} command'); + } + + protected function execute(Input $input, Output $output) + { + // 指令输出 + $output->writeln('{%commandName%}'); + } +} diff --git a/vendor/topthink/framework/src/think/console/command/make/stubs/controller.api.stub b/vendor/topthink/framework/src/think/console/command/make/stubs/controller.api.stub new file mode 100644 index 0000000..5d3383d --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/make/stubs/controller.api.stub @@ -0,0 +1,64 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = []; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = []; +} diff --git a/vendor/topthink/framework/src/think/console/command/optimize/Route.php b/vendor/topthink/framework/src/think/console/command/optimize/Route.php new file mode 100644 index 0000000..ee8828f --- /dev/null +++ b/vendor/topthink/framework/src/think/console/command/optimize/Route.php @@ -0,0 +1,66 @@ + +// +---------------------------------------------------------------------- +namespace think\console\command\optimize; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\Output; +use think\event\RouteLoaded; + +class Route extends Command +{ + protected function configure() + { + $this->setName('optimize:route') + ->addArgument('dir', Argument::OPTIONAL, 'dir name .') + ->setDescription('Build app route cache.'); + } + + protected function execute(Input $input, Output $output) + { + $dir = $input->getArgument('dir') ?: ''; + + $path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); + + $filename = $path . 'route.php'; + if (is_file($filename)) { + unlink($filename); + } + + file_put_contents($filename, $this->buildRouteCache($dir)); + $output->writeln('Succeed!'); + } + + protected function buildRouteCache(?string $dir = null): string + { + $this->app->route->clear(); + $this->app->route->lazy(false); + + // 路由检测 + $path = $this->app->getRootPath() . ($dir ? 'app' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR : '') . 'route' . DIRECTORY_SEPARATOR; + + $files = is_dir($path) ? scandir($path) : []; + + foreach ($files as $file) { + if (str_contains($file, '.php')) { + include $path . $file; + } + } + + //触发路由载入完成事件 + $this->app->event->trigger(RouteLoaded::class); + $rules = $this->app->route->getName(); + + return ' +// +---------------------------------------------------------------------- +namespace think\console\command\optimize; + +use Exception; +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\input\Option; +use think\console\Output; +use think\db\PDOConnection; + +class Schema extends Command +{ + protected function configure() + { + $this->setName('optimize:schema') + ->addArgument('dir', Argument::OPTIONAL, 'dir name .') + ->addOption('connection', null, Option::VALUE_REQUIRED, 'connection name .') + ->addOption('table', null, Option::VALUE_REQUIRED, 'table name .') + ->setDescription('Build database schema cache.'); + } + + protected function execute(Input $input, Output $output) + { + $dir = $input->getArgument('dir') ?: ''; + + if ($input->hasOption('table')) { + $connection = $this->app->db->connect($input->getOption('connection')); + if (!$connection instanceof PDOConnection) { + $output->error("only PDO connection support schema cache!"); + return; + } + $table = $input->getOption('table'); + if (!str_contains($table, '.')) { + $dbName = $connection->getConfig('database'); + } else { + [$dbName, $table] = explode('.', $table); + } + + if ($table == '*') { + $table = $connection->getTables($dbName); + } + + $this->buildDataBaseSchema($connection, (array) $table, $dbName); + } else { + if ($dir) { + $appPath = $this->app->getBasePath() . $dir . DIRECTORY_SEPARATOR; + $namespace = 'app\\' . $dir; + } else { + $appPath = $this->app->getBasePath(); + $namespace = 'app'; + } + + $path = $appPath . 'model'; + $list = is_dir($path) ? scandir($path) : []; + + foreach ($list as $file) { + if (str_starts_with($file, '.')) { + continue; + } + $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); + + if (!class_exists($class)) { + continue; + } + + $this->buildModelSchema($class); + } + } + + $output->writeln('Succeed!'); + } + + protected function buildModelSchema(string $class): void + { + $reflect = new \ReflectionClass($class); + if (!$reflect->isAbstract() && $reflect->isSubclassOf('\think\Model')) { + try { + /** @var \think\Model $model */ + $model = new $class; + $connection = $model->db()->getConnection(); + if ($connection instanceof PDOConnection) { + $table = $model->getTable(); + //预读字段信息 + $connection->getSchemaInfo($table, true); + } + } catch (Exception $e) { + + } + } + } + + protected function buildDataBaseSchema(PDOConnection $connection, array $tables, string $dbName): void + { + foreach ($tables as $table) { + //预读字段信息 + $connection->getSchemaInfo("{$dbName}.{$table}", true); + } + } +} diff --git a/vendor/topthink/framework/src/think/console/input/Argument.php b/vendor/topthink/framework/src/think/console/input/Argument.php new file mode 100644 index 0000000..97262c8 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/input/Argument.php @@ -0,0 +1,138 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\input; + +class Argument +{ + // 必传参数 + const REQUIRED = 1; + + // 可选参数 + const OPTIONAL = 2; + + // 数组参数 + const IS_ARRAY = 4; + + /** + * 参数名 + * @var string + */ + private $name; + + /** + * 参数类型 + * @var int + */ + private $mode; + + /** + * 参数默认值 + * @var mixed + */ + private $default; + + /** + * 参数描述 + * @var string + */ + private $description; + + /** + * 构造方法 + * @param string $name 参数名 + * @param int $mode 参数类型: self::REQUIRED 或者 self::OPTIONAL + * @param string $description 描述 + * @param mixed $default 默认值 (仅 self::OPTIONAL 类型有效) + * @throws \InvalidArgumentException + */ + public function __construct(string $name, ?int $mode = null, string $description = '', $default = null) + { + if (null === $mode) { + $mode = self::OPTIONAL; + } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { + throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); + } + + $this->name = $name; + $this->mode = $mode; + $this->description = $description; + + $this->setDefault($default); + } + + /** + * 获取参数名 + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * 是否必须 + * @return bool + */ + public function isRequired(): bool + { + return self::REQUIRED === (self::REQUIRED & $this->mode); + } + + /** + * 该参数是否接受数组 + * @return bool + */ + public function isArray(): bool + { + return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); + } + + /** + * 设置默认值 + * @param mixed $default 默认值 + * @throws \LogicException + */ + public function setDefault($default = null): void + { + if (self::REQUIRED === $this->mode && null !== $default) { + throw new \LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); + } + + if ($this->isArray()) { + if (null === $default) { + $default = []; + } elseif (!is_array($default)) { + throw new \LogicException('A default value for an array argument must be an array.'); + } + } + + $this->default = $default; + } + + /** + * 获取默认值 + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * 获取描述 + * @return string + */ + public function getDescription(): string + { + return $this->description; + } +} diff --git a/vendor/topthink/framework/src/think/console/input/Definition.php b/vendor/topthink/framework/src/think/console/input/Definition.php new file mode 100644 index 0000000..ccf02a0 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/input/Definition.php @@ -0,0 +1,375 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\input; + +class Definition +{ + + /** + * @var Argument[] + */ + private $arguments; + + private $requiredCount; + private $hasAnArrayArgument = false; + private $hasOptional; + + /** + * @var Option[] + */ + private $options; + private $shortcuts; + + /** + * 构造方法 + * @param array $definition + * @api + */ + public function __construct(array $definition = []) + { + $this->setDefinition($definition); + } + + /** + * 设置指令的定义 + * @param array $definition 定义的数组 + */ + public function setDefinition(array $definition): void + { + $arguments = []; + $options = []; + foreach ($definition as $item) { + if ($item instanceof Option) { + $options[] = $item; + } else { + $arguments[] = $item; + } + } + + $this->setArguments($arguments); + $this->setOptions($options); + } + + /** + * 设置参数 + * @param Argument[] $arguments 参数数组 + */ + public function setArguments(array $arguments = []): void + { + $this->arguments = []; + $this->requiredCount = 0; + $this->hasOptional = false; + $this->hasAnArrayArgument = false; + $this->addArguments($arguments); + } + + /** + * 添加参数 + * @param Argument[] $arguments 参数数组 + * @api + */ + public function addArguments(array $arguments = []): void + { + if (null !== $arguments) { + foreach ($arguments as $argument) { + $this->addArgument($argument); + } + } + } + + /** + * 添加一个参数 + * @param Argument $argument 参数 + * @throws \LogicException + */ + public function addArgument(Argument $argument): void + { + if (isset($this->arguments[$argument->getName()])) { + throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName())); + } + + if ($this->hasAnArrayArgument) { + throw new \LogicException('Cannot add an argument after an array argument.'); + } + + if ($argument->isRequired() && $this->hasOptional) { + throw new \LogicException('Cannot add a required argument after an optional one.'); + } + + if ($argument->isArray()) { + $this->hasAnArrayArgument = true; + } + + if ($argument->isRequired()) { + ++$this->requiredCount; + } else { + $this->hasOptional = true; + } + + $this->arguments[$argument->getName()] = $argument; + } + + /** + * 根据名称或者位置获取参数 + * @param string|int $name 参数名或者位置 + * @return Argument 参数 + * @throws \InvalidArgumentException + */ + public function getArgument($name): Argument + { + if (!$this->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; + + return $arguments[$name]; + } + + /** + * 根据名称或位置检查是否具有某个参数 + * @param string|int $name 参数名或者位置 + * @return bool + * @api + */ + public function hasArgument($name): bool + { + $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; + + return isset($arguments[$name]); + } + + /** + * 获取所有的参数 + * @return Argument[] 参数数组 + */ + public function getArguments(): array + { + return $this->arguments; + } + + /** + * 获取参数数量 + * @return int + */ + public function getArgumentCount(): int + { + return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments); + } + + /** + * 获取必填的参数的数量 + * @return int + */ + public function getArgumentRequiredCount(): int + { + return $this->requiredCount; + } + + /** + * 获取参数默认值 + * @return array + */ + public function getArgumentDefaults(): array + { + $values = []; + foreach ($this->arguments as $argument) { + $values[$argument->getName()] = $argument->getDefault(); + } + + return $values; + } + + /** + * 设置选项 + * @param Option[] $options 选项数组 + */ + public function setOptions(array $options = []): void + { + $this->options = []; + $this->shortcuts = []; + $this->addOptions($options); + } + + /** + * 添加选项 + * @param Option[] $options 选项数组 + * @api + */ + public function addOptions(array $options = []): void + { + foreach ($options as $option) { + $this->addOption($option); + } + } + + /** + * 添加一个选项 + * @param Option $option 选项 + * @throws \LogicException + * @api + */ + public function addOption(Option $option): void + { + if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { + throw new \LogicException(sprintf('An option named "%s" already exists.', $option->getName())); + } + + if ($option->getShortcut()) { + foreach (explode('|', $option->getShortcut()) as $shortcut) { + if (isset($this->shortcuts[$shortcut]) + && !$option->equals($this->options[$this->shortcuts[$shortcut]]) + ) { + throw new \LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut)); + } + } + } + + $this->options[$option->getName()] = $option; + if ($option->getShortcut()) { + foreach (explode('|', $option->getShortcut()) as $shortcut) { + $this->shortcuts[$shortcut] = $option->getName(); + } + } + } + + /** + * 根据名称获取选项 + * @param string $name 选项名 + * @return Option + * @throws \InvalidArgumentException + * @api + */ + public function getOption(string $name): Option + { + if (!$this->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); + } + + return $this->options[$name]; + } + + /** + * 根据名称检查是否有这个选项 + * @param string $name 选项名 + * @return bool + * @api + */ + public function hasOption(string $name): bool + { + return isset($this->options[$name]); + } + + /** + * 获取所有选项 + * @return Option[] + * @api + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * 根据名称检查某个选项是否有短名称 + * @param string $name 短名称 + * @return bool + */ + public function hasShortcut(string $name): bool + { + return isset($this->shortcuts[$name]); + } + + /** + * 根据短名称获取选项 + * @param string $shortcut 短名称 + * @return Option + */ + public function getOptionForShortcut(string $shortcut): Option + { + return $this->getOption($this->shortcutToName($shortcut)); + } + + /** + * 获取所有选项的默认值 + * @return array + */ + public function getOptionDefaults(): array + { + $values = []; + foreach ($this->options as $option) { + $values[$option->getName()] = $option->getDefault(); + } + + return $values; + } + + /** + * 根据短名称获取选项名 + * @param string $shortcut 短名称 + * @return string + * @throws \InvalidArgumentException + */ + private function shortcutToName(string $shortcut): string + { + if (!isset($this->shortcuts[$shortcut])) { + throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + return $this->shortcuts[$shortcut]; + } + + /** + * 获取该指令的介绍 + * @param bool $short 是否简洁介绍 + * @return string + */ + public function getSynopsis(bool $short = false): string + { + $elements = []; + + if ($short && $this->getOptions()) { + $elements[] = '[options]'; + } elseif (!$short) { + foreach ($this->getOptions() as $option) { + $value = ''; + if ($option->acceptValue()) { + $value = sprintf(' %s%s%s', $option->isValueOptional() ? '[' : '', strtoupper($option->getName()), $option->isValueOptional() ? ']' : ''); + } + + $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; + $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value); + } + } + + if (count($elements) && $this->getArguments()) { + $elements[] = '[--]'; + } + + foreach ($this->getArguments() as $argument) { + $element = '<' . $argument->getName() . '>'; + if (!$argument->isRequired()) { + $element = '[' . $element . ']'; + } elseif ($argument->isArray()) { + $element .= ' (' . $element . ')'; + } + + if ($argument->isArray()) { + $element .= '...'; + } + + $elements[] = $element; + } + + return implode(' ', $elements); + } +} diff --git a/vendor/topthink/framework/src/think/console/input/Option.php b/vendor/topthink/framework/src/think/console/input/Option.php new file mode 100644 index 0000000..8554087 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/input/Option.php @@ -0,0 +1,221 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\input; + +/** + * 命令行选项 + * @package think\console\input + */ +class Option +{ + // 无需传值 + const VALUE_NONE = 1; + // 必须传值 + const VALUE_REQUIRED = 2; + // 可选传值 + const VALUE_OPTIONAL = 4; + // 传数组值 + const VALUE_IS_ARRAY = 8; + + /** + * 选项名 + * @var string + */ + private $name = ''; + + /** + * 选项短名称 + * @var string + */ + private $shortcut = ''; + + /** + * 选项类型 + * @var int + */ + private $mode; + + /** + * 选项默认值 + * @var mixed + */ + private $default; + + /** + * 选项描述 + * @var string + */ + private $description = ''; + + /** + * 构造方法 + * @param string $name 选项名 + * @param string|array $shortcut 短名称,多个用|隔开或者使用数组 + * @param int $mode 选项类型(可选类型为 self::VALUE_*) + * @param string $description 描述 + * @param mixed $default 默认值 (类型为 self::VALUE_REQUIRED 或者 self::VALUE_NONE 的时候必须为null) + * @throws \InvalidArgumentException + */ + public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) + { + if (str_starts_with($name, '--')) { + $name = substr($name, 2); + } + + if (empty($name)) { + throw new \InvalidArgumentException('An option name cannot be empty.'); + } + + if (empty($shortcut)) { + $shortcut = ''; + } + + if ('' !== $shortcut) { + if (is_array($shortcut)) { + $shortcut = implode('|', $shortcut); + } + $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-')); + $shortcuts = array_filter($shortcuts); + $shortcut = implode('|', $shortcuts); + + if (empty($shortcut)) { + throw new \InvalidArgumentException('An option shortcut cannot be empty.'); + } + } + + if (null === $mode) { + $mode = self::VALUE_NONE; + } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { + throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); + } + + $this->name = $name; + $this->shortcut = $shortcut; + $this->mode = $mode; + $this->description = $description; + + if ($this->isArray() && !$this->acceptValue()) { + throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); + } + + $this->setDefault($default); + } + + /** + * 获取短名称 + * @return string + */ + public function getShortcut(): string + { + return $this->shortcut; + } + + /** + * 获取选项名 + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * 是否可以设置值 + * @return bool 类型不是 self::VALUE_NONE 的时候返回true,其他均返回false + */ + public function acceptValue(): bool + { + return $this->isValueRequired() || $this->isValueOptional(); + } + + /** + * 是否必须 + * @return bool 类型是 self::VALUE_REQUIRED 的时候返回true,其他均返回false + */ + public function isValueRequired(): bool + { + return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); + } + + /** + * 是否可选 + * @return bool 类型是 self::VALUE_OPTIONAL 的时候返回true,其他均返回false + */ + public function isValueOptional(): bool + { + return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); + } + + /** + * 选项值是否接受数组 + * @return bool 类型是 self::VALUE_IS_ARRAY 的时候返回true,其他均返回false + */ + public function isArray(): bool + { + return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); + } + + /** + * 设置默认值 + * @param mixed $default 默认值 + * @throws \LogicException + */ + public function setDefault($default = null) + { + if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { + throw new \LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); + } + + if ($this->isArray()) { + if (null === $default) { + $default = []; + } elseif (!is_array($default)) { + throw new \LogicException('A default value for an array option must be an array.'); + } + } + + $this->default = $this->acceptValue() ? $default : false; + } + + /** + * 获取默认值 + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * 获取描述文字 + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * 检查所给选项是否是当前这个 + * @param Option $option + * @return bool + */ + public function equals(Option $option): bool + { + return $option->getName() === $this->getName() + && $option->getShortcut() === $this->getShortcut() + && $option->getDefault() === $this->getDefault() + && $option->isArray() === $this->isArray() + && $option->isValueRequired() === $this->isValueRequired() + && $option->isValueOptional() === $this->isValueOptional(); + } +} diff --git a/vendor/topthink/framework/src/think/console/output/Ask.php b/vendor/topthink/framework/src/think/console/output/Ask.php new file mode 100644 index 0000000..01bc219 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/Ask.php @@ -0,0 +1,336 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output; + +use think\console\Input; +use think\console\Output; +use think\console\output\question\Choice; +use think\console\output\question\Confirmation; + +class Ask +{ + private static $stty; + + private static $shell; + + /** @var Input */ + protected $input; + + /** @var Output */ + protected $output; + + /** @var Question */ + protected $question; + + public function __construct(Input $input, Output $output, Question $question) + { + $this->input = $input; + $this->output = $output; + $this->question = $question; + } + + public function run() + { + if (!$this->input->isInteractive()) { + return $this->question->getDefault(); + } + + if (!$this->question->getValidator()) { + return $this->doAsk(); + } + + $that = $this; + + $interviewer = function () use ($that) { + return $that->doAsk(); + }; + + return $this->validateAttempts($interviewer); + } + + protected function doAsk() + { + $this->writePrompt(); + + $inputStream = STDIN; + $autocomplete = $this->question->getAutocompleterValues(); + + if (null === $autocomplete || !$this->hasSttyAvailable()) { + $ret = false; + if ($this->question->isHidden()) { + try { + $ret = trim($this->getHiddenResponse($inputStream)); + } catch (\RuntimeException $e) { + if (!$this->question->isHiddenFallback()) { + throw $e; + } + } + } + + if (false === $ret) { + $ret = fgets($inputStream, 4096); + if (false === $ret) { + throw new \RuntimeException('Aborted'); + } + $ret = trim($ret); + } + } else { + $ret = trim($this->autocomplete($inputStream)); + } + + $ret = strlen($ret) > 0 ? $ret : $this->question->getDefault(); + + if ($normalizer = $this->question->getNormalizer()) { + return $normalizer($ret); + } + + return $ret; + } + + private function autocomplete($inputStream) + { + $autocomplete = $this->question->getAutocompleterValues(); + $ret = ''; + + $i = 0; + $ofs = -1; + $matches = $autocomplete; + $numMatches = count($matches); + + $sttyMode = shell_exec('stty -g'); + + shell_exec('stty -icanon -echo'); + + while (!feof($inputStream)) { + $c = fread($inputStream, 1); + + if ("\177" === $c) { + if (0 === $numMatches && 0 !== $i) { + --$i; + $this->output->write("\033[1D"); + } + + if ($i === 0) { + $ofs = -1; + $matches = $autocomplete; + $numMatches = count($matches); + } else { + $numMatches = 0; + } + + $ret = substr($ret, 0, $i); + } elseif ("\033" === $c) { + $c .= fread($inputStream, 2); + + if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) { + if ('A' === $c[2] && -1 === $ofs) { + $ofs = 0; + } + + if (0 === $numMatches) { + continue; + } + + $ofs += ('A' === $c[2]) ? -1 : 1; + $ofs = ($numMatches + $ofs) % $numMatches; + } + } elseif (ord($c) < 32) { + if ("\t" === $c || "\n" === $c) { + if ($numMatches > 0 && -1 !== $ofs) { + $ret = $matches[$ofs]; + $this->output->write(substr($ret, $i)); + $i = strlen($ret); + } + + if ("\n" === $c) { + $this->output->write($c); + break; + } + + $numMatches = 0; + } + + continue; + } else { + $this->output->write($c); + $ret .= $c; + ++$i; + + $numMatches = 0; + $ofs = 0; + + foreach ($autocomplete as $value) { + if (str_starts_with($value, $ret) && $i !== strlen($value)) { + $matches[$numMatches++] = $value; + } + } + } + + $this->output->write("\033[K"); + + if ($numMatches > 0 && -1 !== $ofs) { + $this->output->write("\0337"); + $this->output->highlight(substr($matches[$ofs], $i)); + $this->output->write("\0338"); + } + } + + shell_exec(sprintf('stty %s', $sttyMode)); + + return $ret; + } + + protected function getHiddenResponse($inputStream) + { + if ('\\' === DIRECTORY_SEPARATOR) { + $exe = __DIR__ . '/../bin/hiddeninput.exe'; + + $value = rtrim(shell_exec($exe)); + $this->output->writeln(''); + + return $value; + } + + if ($this->hasSttyAvailable()) { + $sttyMode = shell_exec('stty -g'); + + shell_exec('stty -echo'); + $value = fgets($inputStream, 4096); + shell_exec(sprintf('stty %s', $sttyMode)); + + if (false === $value) { + throw new \RuntimeException('Aborted'); + } + + $value = trim($value); + $this->output->writeln(''); + + return $value; + } + + if (false !== $shell = $this->getShell()) { + $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; + $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); + $value = rtrim(shell_exec($command)); + $this->output->writeln(''); + + return $value; + } + + throw new \RuntimeException('Unable to hide the response.'); + } + + protected function validateAttempts($interviewer) + { + /** @var \Exception $error */ + $error = null; + $attempts = $this->question->getMaxAttempts(); + while (null === $attempts || $attempts--) { + if (null !== $error) { + $this->output->error($error->getMessage()); + } + + try { + return call_user_func($this->question->getValidator(), $interviewer()); + } catch (\Exception $error) { + } + } + + throw $error; + } + + /** + * 显示问题的提示信息 + */ + protected function writePrompt() + { + $text = $this->question->getQuestion(); + $default = $this->question->getDefault(); + + switch (true) { + case null === $default: + $text = sprintf(' %s:', $text); + + break; + + case $this->question instanceof Confirmation: + $text = sprintf(' %s (yes/no) [%s]:', $text, $default ? 'yes' : 'no'); + + break; + + case $this->question instanceof Choice && $this->question->isMultiselect(): + $choices = $this->question->getChoices(); + $default = explode(',', $default); + + foreach ($default as $key => $value) { + $default[$key] = $choices[trim($value)]; + } + + $text = sprintf(' %s [%s]:', $text, implode(', ', $default)); + + break; + + case $this->question instanceof Choice: + $choices = $this->question->getChoices(); + $text = sprintf(' %s [%s]:', $text, $choices[$default]); + + break; + + default: + $text = sprintf(' %s [%s]:', $text, $default); + } + + $this->output->writeln($text); + + if ($this->question instanceof Choice) { + $width = max(array_map('strlen', array_keys($this->question->getChoices()))); + + foreach ($this->question->getChoices() as $key => $value) { + $this->output->writeln(sprintf(" [%-{$width}s] %s", $key, $value)); + } + } + + $this->output->write(' > '); + } + + private function getShell() + { + if (null !== self::$shell) { + return self::$shell; + } + + self::$shell = false; + + if (file_exists('/usr/bin/env')) { + $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; + foreach (['bash', 'zsh', 'ksh', 'csh'] as $sh) { + if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { + self::$shell = $sh; + break; + } + } + } + + return self::$shell; + } + + private function hasSttyAvailable() + { + if (null !== self::$stty) { + return self::$stty; + } + + exec('stty 2>&1', $output, $exitcode); + + return self::$stty = $exitcode === 0; + } +} diff --git a/vendor/topthink/framework/src/think/console/output/Descriptor.php b/vendor/topthink/framework/src/think/console/output/Descriptor.php new file mode 100644 index 0000000..2985ddb --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/Descriptor.php @@ -0,0 +1,323 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output; + +use think\Console; +use think\console\Command; +use think\console\input\Argument as InputArgument; +use think\console\input\Definition as InputDefinition; +use think\console\input\Option as InputOption; +use think\console\Output; +use think\console\output\descriptor\Console as ConsoleDescription; + +class Descriptor +{ + + /** + * @var Output + */ + protected $output; + + /** + * {@inheritdoc} + */ + public function describe(Output $output, $object, array $options = []) + { + $this->output = $output; + + switch (true) { + case $object instanceof InputArgument: + $this->describeInputArgument($object, $options); + break; + case $object instanceof InputOption: + $this->describeInputOption($object, $options); + break; + case $object instanceof InputDefinition: + $this->describeInputDefinition($object, $options); + break; + case $object instanceof Command: + $this->describeCommand($object, $options); + break; + case $object instanceof Console: + $this->describeConsole($object, $options); + break; + default: + throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', $object::class)); + } + } + + /** + * 输出内容 + * @param string $content + * @param bool $decorated + */ + protected function write($content, $decorated = false) + { + $this->output->write($content, false, $decorated ? Output::OUTPUT_NORMAL : Output::OUTPUT_RAW); + } + + /** + * 描述参数 + * @param InputArgument $argument + * @param array $options + * @return string|mixed + */ + protected function describeInputArgument(InputArgument $argument, array $options = []) + { + if (null !== $argument->getDefault() + && (!is_array($argument->getDefault()) + || count($argument->getDefault())) + ) { + $default = sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault())); + } else { + $default = ''; + } + + $totalWidth = $options['total_width'] ?? strlen($argument->getName()); + $spacingWidth = $totalWidth - strlen($argument->getName()) + 2; + + $this->writeText(sprintf(" %s%s%s%s", $argument->getName(), str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces + preg_replace('/\s*[\r\n]\s*/', PHP_EOL . str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default), $options); + } + + /** + * 描述选项 + * @param InputOption $option + * @param array $options + * @return string|mixed + */ + protected function describeInputOption(InputOption $option, array $options = []) + { + if ($option->acceptValue() && null !== $option->getDefault() + && (!is_array($option->getDefault()) + || count($option->getDefault())) + ) { + $default = sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault())); + } else { + $default = ''; + } + + $value = ''; + if ($option->acceptValue()) { + $value = '=' . strtoupper($option->getName()); + + if ($option->isValueOptional()) { + $value = '[' . $value . ']'; + } + } + + $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]); + $synopsis = sprintf('%s%s', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', sprintf('--%s%s', $option->getName(), $value)); + + $spacingWidth = $totalWidth - strlen($synopsis) + 2; + + $this->writeText(sprintf(" %s%s%s%s%s", $synopsis, str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces + preg_replace('/\s*[\r\n]\s*/', "\n" . str_repeat(' ', $totalWidth + 17), $option->getDescription()), $default, $option->isArray() ? ' (multiple values allowed)' : ''), $options); + } + + /** + * 描述输入 + * @param InputDefinition $definition + * @param array $options + * @return string|mixed + */ + protected function describeInputDefinition(InputDefinition $definition, array $options = []) + { + $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); + foreach ($definition->getArguments() as $argument) { + $totalWidth = max($totalWidth, strlen($argument->getName())); + } + + if ($definition->getArguments()) { + $this->writeText('Arguments:', $options); + $this->writeText("\n"); + foreach ($definition->getArguments() as $argument) { + $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth])); + $this->writeText("\n"); + } + } + + if ($definition->getArguments() && $definition->getOptions()) { + $this->writeText("\n"); + } + + if ($definition->getOptions()) { + $laterOptions = []; + + $this->writeText('Options:', $options); + foreach ($definition->getOptions() as $option) { + if (strlen($option->getShortcut()) > 1) { + $laterOptions[] = $option; + continue; + } + $this->writeText("\n"); + $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth])); + } + foreach ($laterOptions as $option) { + $this->writeText("\n"); + $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth])); + } + } + } + + /** + * 描述指令 + * @param Command $command + * @param array $options + * @return string|mixed + */ + protected function describeCommand(Command $command, array $options = []) + { + $command->getSynopsis(true); + $command->getSynopsis(false); + $command->mergeConsoleDefinition(false); + + $this->writeText('Usage:', $options); + foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) { + $this->writeText("\n"); + $this->writeText(' ' . $usage, $options); + } + $this->writeText("\n"); + + $definition = $command->getNativeDefinition(); + if ($definition->getOptions() || $definition->getArguments()) { + $this->writeText("\n"); + $this->describeInputDefinition($definition, $options); + $this->writeText("\n"); + } + + if ($help = $command->getProcessedHelp()) { + $this->writeText("\n"); + $this->writeText('Help:', $options); + $this->writeText("\n"); + $this->writeText(' ' . str_replace("\n", "\n ", $help), $options); + $this->writeText("\n"); + } + } + + /** + * 描述控制台 + * @param Console $console + * @param array $options + * @return string|mixed + */ + protected function describeConsole(Console $console, array $options = []) + { + $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; + $description = new ConsoleDescription($console, $describedNamespace); + + if (isset($options['raw_text']) && $options['raw_text']) { + $width = $this->getColumnWidth($description->getNamespaces()); + + foreach ($description->getCommands() as $command) { + $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options); + $this->writeText("\n"); + } + } else { + if ('' != $help = $console->getHelp()) { + $this->writeText("$help\n\n", $options); + } + + $this->writeText("Usage:\n", $options); + $this->writeText(" command [options] [arguments]\n\n", $options); + + $this->describeInputDefinition(new InputDefinition($console->getDefinition()->getOptions()), $options); + + $this->writeText("\n"); + $this->writeText("\n"); + + $width = $this->getColumnWidth($description->getNamespaces()); + + if ($describedNamespace) { + $this->writeText(sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options); + } else { + $this->writeText('Available commands:', $options); + } + + // add commands by namespace + foreach ($description->getNamespaces() as $namespace) { + if (!$describedNamespace && ConsoleDescription::GLOBAL_NAMESPACE !== $namespace['id']) { + $this->writeText("\n"); + $this->writeText(' ' . $namespace['id'] . '', $options); + } + + foreach ($namespace['commands'] as $name) { + $this->writeText("\n"); + $spacingWidth = $width - strlen($name); + $this->writeText(sprintf(" %s%s%s", $name, str_repeat(' ', $spacingWidth), $description->getCommand($name) + ->getDescription()), $options); + } + } + + $this->writeText("\n"); + } + } + + /** + * {@inheritdoc} + */ + private function writeText($content, array $options = []) + { + $this->write(isset($options['raw_text']) + && $options['raw_text'] ? strip_tags($content) : $content, isset($options['raw_output']) ? !$options['raw_output'] : true); + } + + /** + * 格式化 + * @param mixed $default + * @return string + */ + private function formatDefaultValue($default) + { + return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + /** + * @param Namespaces[] $namespaces + * @return int + */ + private function getColumnWidth(array $namespaces) + { + $width = 0; + foreach ($namespaces as $namespace) { + foreach ($namespace['commands'] as $name) { + if (strlen($name) > $width) { + $width = strlen($name); + } + } + } + + return $width + 2; + } + + /** + * @param InputOption[] $options + * @return int + */ + private function calculateTotalWidthForOptions($options) + { + $totalWidth = 0; + foreach ($options as $option) { + $nameLength = 4 + strlen($option->getName()) + 2; // - + shortcut + , + whitespace + name + -- + + if ($option->acceptValue()) { + $valueLength = 1 + strlen($option->getName()); // = + value + $valueLength += $option->isValueOptional() ? 2 : 0; // [ + ] + + $nameLength += $valueLength; + } + $totalWidth = max($totalWidth, $nameLength); + } + + return $totalWidth; + } +} diff --git a/vendor/topthink/framework/src/think/console/output/Formatter.php b/vendor/topthink/framework/src/think/console/output/Formatter.php new file mode 100644 index 0000000..1b97ca3 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/Formatter.php @@ -0,0 +1,198 @@ + +// +---------------------------------------------------------------------- +namespace think\console\output; + +use think\console\output\formatter\Stack as StyleStack; +use think\console\output\formatter\Style; + +class Formatter +{ + + private $decorated = false; + private $styles = []; + private $styleStack; + + /** + * 转义 + * @param string $text + * @return string + */ + public static function escape($text) + { + return preg_replace('/([^\\\\]?)setStyle('error', new Style('white', 'red')); + $this->setStyle('info', new Style('green')); + $this->setStyle('comment', new Style('yellow')); + $this->setStyle('question', new Style('black', 'cyan')); + $this->setStyle('highlight', new Style('red')); + $this->setStyle('warning', new Style('black', 'yellow')); + + $this->styleStack = new StyleStack(); + } + + /** + * 设置外观标识 + * @param bool $decorated 是否美化文字 + */ + public function setDecorated($decorated) + { + $this->decorated = (bool) $decorated; + } + + /** + * 获取外观标识 + * @return bool + */ + public function isDecorated() + { + return $this->decorated; + } + + /** + * 添加一个新样式 + * @param string $name 样式名 + * @param Style $style 样式实例 + */ + public function setStyle($name, Style $style) + { + $this->styles[strtolower($name)] = $style; + } + + /** + * 是否有这个样式 + * @param string $name + * @return bool + */ + public function hasStyle($name) + { + return isset($this->styles[strtolower($name)]); + } + + /** + * 获取样式 + * @param string $name + * @return Style + * @throws \InvalidArgumentException + */ + public function getStyle($name) + { + if (!$this->hasStyle($name)) { + throw new \InvalidArgumentException(sprintf('Undefined style: %s', $name)); + } + + return $this->styles[strtolower($name)]; + } + + /** + * 使用所给的样式格式化文字 + * @param string $message 文字 + * @return string + */ + public function format($message) + { + $offset = 0; + $output = ''; + $tagRegex = '[a-z][a-z0-9_=;-]*'; + preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#isx", $message, $matches, PREG_OFFSET_CAPTURE); + foreach ($matches[0] as $i => $match) { + $pos = $match[1]; + $text = $match[0]; + + if (0 != $pos && '\\' == $message[$pos - 1]) { + continue; + } + + $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset)); + $offset = $pos + strlen($text); + + if ($open = '/' != $text[1]) { + $tag = $matches[1][$i][0]; + } else { + $tag = $matches[3][$i][0] ?? ''; + } + + if (!$open && !$tag) { + // + $this->styleStack->pop(); + } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) { + $output .= $this->applyCurrentStyle($text); + } elseif ($open) { + $this->styleStack->push($style); + } else { + $this->styleStack->pop($style); + } + } + + $output .= $this->applyCurrentStyle(substr($message, $offset)); + + return str_replace('\\<', '<', $output); + } + + /** + * @return StyleStack + */ + public function getStyleStack() + { + return $this->styleStack; + } + + /** + * 根据字符串创建新的样式实例 + * @param string $string + * @return Style|bool + */ + private function createStyleFromString($string) + { + if (isset($this->styles[$string])) { + return $this->styles[$string]; + } + + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { + return false; + } + + $style = new Style(); + foreach ($matches as $match) { + array_shift($match); + + if ('fg' == $match[0]) { + $style->setForeground($match[1]); + } elseif ('bg' == $match[0]) { + $style->setBackground($match[1]); + } else { + try { + $style->setOption($match[1]); + } catch (\InvalidArgumentException $e) { + return false; + } + } + } + + return $style; + } + + /** + * 从堆栈应用样式到文字 + * @param string $text 文字 + * @return string + */ + private function applyCurrentStyle($text) + { + return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text; + } +} diff --git a/vendor/topthink/framework/src/think/console/output/Question.php b/vendor/topthink/framework/src/think/console/output/Question.php new file mode 100644 index 0000000..03975f2 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/Question.php @@ -0,0 +1,211 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output; + +class Question +{ + + private $question; + private $attempts; + private $hidden = false; + private $hiddenFallback = true; + private $autocompleterValues; + private $validator; + private $default; + private $normalizer; + + /** + * 构造方法 + * @param string $question 问题 + * @param mixed $default 默认答案 + */ + public function __construct($question, $default = null) + { + $this->question = $question; + $this->default = $default; + } + + /** + * 获取问题 + * @return string + */ + public function getQuestion() + { + return $this->question; + } + + /** + * 获取默认答案 + * @return mixed + */ + public function getDefault() + { + return $this->default; + } + + /** + * 是否隐藏答案 + * @return bool + */ + public function isHidden() + { + return $this->hidden; + } + + /** + * 隐藏答案 + * @param bool $hidden + * @return Question + */ + public function setHidden($hidden) + { + if ($this->autocompleterValues) { + throw new \LogicException('A hidden question cannot use the autocompleter.'); + } + + $this->hidden = (bool) $hidden; + + return $this; + } + + /** + * 不能被隐藏是否撤销 + * @return bool + */ + public function isHiddenFallback() + { + return $this->hiddenFallback; + } + + /** + * 设置不能被隐藏的时候的操作 + * @param bool $fallback + * @return Question + */ + public function setHiddenFallback($fallback) + { + $this->hiddenFallback = (bool) $fallback; + + return $this; + } + + /** + * 获取自动完成 + * @return null|array|\Traversable + */ + public function getAutocompleterValues() + { + return $this->autocompleterValues; + } + + /** + * 设置自动完成的值 + * @param null|array|\Traversable $values + * @return Question + * @throws \InvalidArgumentException + * @throws \LogicException + */ + public function setAutocompleterValues($values) + { + if (is_array($values) && $this->isAssoc($values)) { + $values = array_merge(array_keys($values), array_values($values)); + } + + if (null !== $values && !is_array($values)) { + if (!$values instanceof \Traversable || $values instanceof \Countable) { + throw new \InvalidArgumentException('Autocompleter values can be either an array, `null` or an object implementing both `Countable` and `Traversable` interfaces.'); + } + } + + if ($this->hidden) { + throw new \LogicException('A hidden question cannot use the autocompleter.'); + } + + $this->autocompleterValues = $values; + + return $this; + } + + /** + * 设置答案的验证器 + * @param null|callable $validator + * @return Question The current instance + */ + public function setValidator($validator) + { + $this->validator = $validator; + + return $this; + } + + /** + * 获取验证器 + * @return null|callable + */ + public function getValidator() + { + return $this->validator; + } + + /** + * 设置最大重试次数 + * @param null|int $attempts + * @return Question + * @throws \InvalidArgumentException + */ + public function setMaxAttempts($attempts) + { + if (null !== $attempts && $attempts < 1) { + throw new \InvalidArgumentException('Maximum number of attempts must be a positive value.'); + } + + $this->attempts = $attempts; + + return $this; + } + + /** + * 获取最大重试次数 + * @return null|int + */ + public function getMaxAttempts() + { + return $this->attempts; + } + + /** + * 设置响应的回调 + * @param string|\Closure $normalizer + * @return Question + */ + public function setNormalizer($normalizer) + { + $this->normalizer = $normalizer; + + return $this; + } + + /** + * 获取响应回调 + * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. + * @return string|\Closure + */ + public function getNormalizer() + { + return $this->normalizer; + } + + protected function isAssoc($array) + { + return (bool) count(array_filter(array_keys($array), 'is_string')); + } +} diff --git a/vendor/topthink/framework/src/think/console/output/descriptor/Console.php b/vendor/topthink/framework/src/think/console/output/descriptor/Console.php new file mode 100644 index 0000000..ff9f464 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/descriptor/Console.php @@ -0,0 +1,153 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\descriptor; + +use think\Console as ThinkConsole; +use think\console\Command; + +class Console +{ + + const GLOBAL_NAMESPACE = '_global'; + + /** + * @var ThinkConsole + */ + private $console; + + /** + * @var null|string + */ + private $namespace; + + /** + * @var array + */ + private $namespaces; + + /** + * @var Command[] + */ + private $commands; + + /** + * @var Command[] + */ + private $aliases; + + /** + * 构造方法 + * @param ThinkConsole $console + * @param string|null $namespace + */ + public function __construct(ThinkConsole $console, $namespace = null) + { + $this->console = $console; + $this->namespace = $namespace; + } + + /** + * @return array + */ + public function getNamespaces(): array + { + if (null === $this->namespaces) { + $this->inspectConsole(); + } + + return $this->namespaces; + } + + /** + * @return Command[] + */ + public function getCommands(): array + { + if (null === $this->commands) { + $this->inspectConsole(); + } + + return $this->commands; + } + + /** + * @param string $name + * @return Command + * @throws \InvalidArgumentException + */ + public function getCommand(string $name): Command + { + if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { + throw new \InvalidArgumentException(sprintf('Command %s does not exist.', $name)); + } + + return $this->commands[$name] ?? $this->aliases[$name]; + } + + private function inspectConsole(): void + { + $this->commands = []; + $this->namespaces = []; + + $all = $this->console->all($this->namespace ? $this->console->findNamespace($this->namespace) : null); + foreach ($this->sortCommands($all) as $namespace => $commands) { + $names = []; + + /** @var Command $command */ + foreach ($commands as $name => $command) { + if (is_string($command)) { + $command = new $command(); + } + + if (!$command->getName()) { + continue; + } + + if ($command->getName() === $name) { + $this->commands[$name] = $command; + } else { + $this->aliases[$name] = $command; + } + + $names[] = $name; + } + + $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names]; + } + } + + /** + * @param array $commands + * @return array + */ + private function sortCommands(array $commands): array + { + $namespacedCommands = []; + foreach ($commands as $name => $command) { + $key = $this->console->extractNamespace($name, 1); + if (!$key) { + $key = self::GLOBAL_NAMESPACE; + } + + $namespacedCommands[$key][$name] = $command; + } + ksort($namespacedCommands); + + foreach ($namespacedCommands as &$commandsSet) { + ksort($commandsSet); + } + // unset reference to keep scope clear + unset($commandsSet); + + return $namespacedCommands; + } +} diff --git a/vendor/topthink/framework/src/think/console/output/driver/Buffer.php b/vendor/topthink/framework/src/think/console/output/driver/Buffer.php new file mode 100644 index 0000000..576f31a --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/driver/Buffer.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\driver; + +use think\console\Output; + +class Buffer +{ + /** + * @var string + */ + private $buffer = ''; + + public function __construct(Output $output) + { + // do nothing + } + + public function fetch() + { + $content = $this->buffer; + $this->buffer = ''; + return $content; + } + + public function write($messages, bool $newline = false, int $options = 0) + { + $messages = (array) $messages; + + foreach ($messages as $message) { + $this->buffer .= $message; + } + if ($newline) { + $this->buffer .= "\n"; + } + } + + public function renderException(\Throwable $e) + { + // do nothing + } + +} diff --git a/vendor/topthink/framework/src/think/console/output/driver/Console.php b/vendor/topthink/framework/src/think/console/output/driver/Console.php new file mode 100644 index 0000000..5c0a9ef --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/driver/Console.php @@ -0,0 +1,369 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\driver; + +use think\console\Output; +use think\console\output\Formatter; + +class Console +{ + + /** @var Resource */ + private $stdout; + + /** @var Formatter */ + private $formatter; + + private $terminalDimensions; + + /** @var Output */ + private $output; + + public function __construct(Output $output) + { + $this->output = $output; + $this->formatter = new Formatter(); + $this->stdout = $this->openOutputStream(); + $decorated = $this->hasColorSupport($this->stdout); + $this->formatter->setDecorated($decorated); + } + + public function setDecorated($decorated) + { + $this->formatter->setDecorated($decorated); + } + + public function write($messages, bool $newline = false, int $type = 0, $stream = null) + { + if (Output::VERBOSITY_QUIET === $this->output->getVerbosity()) { + return; + } + + $messages = (array) $messages; + + foreach ($messages as $message) { + switch ($type) { + case Output::OUTPUT_NORMAL: + $message = $this->formatter->format($message); + break; + case Output::OUTPUT_RAW: + break; + case Output::OUTPUT_PLAIN: + $message = strip_tags($this->formatter->format($message)); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); + } + + $this->doWrite($message, $newline, $stream); + } + } + + public function renderException(\Throwable $e) + { + $stderr = $this->openErrorStream(); + $decorated = $this->hasColorSupport($stderr); + $this->formatter->setDecorated($decorated); + + do { + $title = sprintf(' [%s] ', $e::class); + + $len = $this->stringWidth($title); + + $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX; + + if (defined('HHVM_VERSION') && $width > 1 << 31) { + $width = 1 << 31; + } + $lines = []; + foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) { + foreach ($this->splitStringByWidth($line, $width - 4) as $line) { + + $lineLength = $this->stringWidth(preg_replace('/\[[^m]*m/', '', $line)) + 4; + $lines[] = [$line, $lineLength]; + + $len = max($lineLength, $len); + } + } + + $messages = ['', '']; + $messages[] = $emptyLine = sprintf('%s', str_repeat(' ', $len)); + $messages[] = sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title)))); + foreach ($lines as $line) { + $messages[] = sprintf(' %s %s', $line[0], str_repeat(' ', $len - $line[1])); + } + $messages[] = $emptyLine; + $messages[] = ''; + $messages[] = ''; + + $this->write($messages, true, Output::OUTPUT_NORMAL, $stderr); + + if (Output::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) { + $this->write('Exception trace:', true, Output::OUTPUT_NORMAL, $stderr); + + // exception related properties + $trace = $e->getTrace(); + array_unshift($trace, [ + 'function' => '', + 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', + 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', + 'args' => [], + ]); + + for ($i = 0, $count = count($trace); $i < $count; ++$i) { + $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; + $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; + $function = $trace[$i]['function']; + $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; + $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + + $this->write(sprintf(' %s%s%s() at %s:%s', $class, $type, $function, $file, $line), true, Output::OUTPUT_NORMAL, $stderr); + } + + $this->write('', true, Output::OUTPUT_NORMAL, $stderr); + $this->write('', true, Output::OUTPUT_NORMAL, $stderr); + } + } while ($e = $e->getPrevious()); + + } + + /** + * 获取终端宽度 + * @return int|null + */ + protected function getTerminalWidth() + { + $dimensions = $this->getTerminalDimensions(); + + return $dimensions[0]; + } + + /** + * 获取终端高度 + * @return int|null + */ + protected function getTerminalHeight() + { + $dimensions = $this->getTerminalDimensions(); + + return $dimensions[1]; + } + + /** + * 获取当前终端的尺寸 + * @return array + */ + public function getTerminalDimensions(): array + { + if ($this->terminalDimensions) { + return $this->terminalDimensions; + } + + if ('\\' === DIRECTORY_SEPARATOR) { + if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) { + return [(int) $matches[1], (int) $matches[2]]; + } + if (preg_match('/^(\d+)x(\d+)$/', $this->getMode(), $matches)) { + return [(int) $matches[1], (int) $matches[2]]; + } + } + + if ($sttyString = $this->getSttyColumns()) { + if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) { + return [(int) $matches[2], (int) $matches[1]]; + } + if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) { + return [(int) $matches[2], (int) $matches[1]]; + } + } + + return [null, null]; + } + + /** + * 获取stty列数 + * @return string + */ + private function getSttyColumns() + { + if (!function_exists('proc_open')) { + return; + } + + $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + if (is_resource($process)) { + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + return $info; + } + return; + } + + /** + * 获取终端模式 + * @return string x + */ + private function getMode() + { + if (!function_exists('proc_open')) { + return ''; + } + + $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + if (is_resource($process)) { + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { + return $matches[2] . 'x' . $matches[1]; + } + } + + return ''; + } + + private function stringWidth(string $string): int + { + if (!function_exists('mb_strwidth')) { + return strlen($string); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return strlen($string); + } + + return mb_strwidth($string, $encoding); + } + + private function splitStringByWidth(string $string, int $width): array + { + if (!function_exists('mb_strwidth')) { + return str_split($string, $width); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return str_split($string, $width); + } + + $utf8String = mb_convert_encoding($string, 'utf8', $encoding); + $lines = []; + $line = ''; + foreach (preg_split('//u', $utf8String) as $char) { + if (mb_strwidth($line . $char, 'utf8') <= $width) { + $line .= $char; + continue; + } + $lines[] = str_pad($line, $width); + $line = $char; + } + if (strlen($line)) { + $lines[] = count($lines) ? str_pad($line, $width) : $line; + } + + mb_convert_variables($encoding, 'utf8', $lines); + + return $lines; + } + + private function isRunningOS400(): bool + { + $checks = [ + function_exists('php_uname') ? php_uname('s') : '', + getenv('OSTYPE'), + PHP_OS, + ]; + return false !== stripos(implode(';', $checks), 'OS400'); + } + + /** + * 当前环境是否支持写入控制台输出到stdout. + * + * @return bool + */ + protected function hasStdoutSupport(): bool + { + return false === $this->isRunningOS400(); + } + + /** + * 当前环境是否支持写入控制台输出到stderr. + * + * @return bool + */ + protected function hasStderrSupport(): bool + { + return false === $this->isRunningOS400(); + } + + /** + * @return resource + */ + private function openOutputStream() + { + if (!$this->hasStdoutSupport()) { + return fopen('php://output', 'w'); + } + return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w'); + } + + /** + * @return resource + */ + private function openErrorStream() + { + return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w'); + } + + /** + * 将消息写入到输出。 + * @param string $message 消息 + * @param bool $newline 是否另起一行 + * @param null $stream + */ + protected function doWrite($message, $newline, $stream = null) + { + if (null === $stream) { + $stream = $this->stdout; + } + if (false === @fwrite($stream, $message . ($newline ? PHP_EOL : ''))) { + throw new \RuntimeException('Unable to write output.'); + } + + fflush($stream); + } + + /** + * 是否支持着色 + * @param $stream + * @return bool + */ + protected function hasColorSupport($stream): bool + { + if (DIRECTORY_SEPARATOR === '\\') { + return + '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD + || false !== getenv('ANSICON') + || 'ON' === getenv('ConEmuANSI') + || 'xterm' === getenv('TERM'); + } + + return function_exists('posix_isatty') && @posix_isatty($stream); + } + +} diff --git a/vendor/topthink/framework/src/think/console/output/driver/Nothing.php b/vendor/topthink/framework/src/think/console/output/driver/Nothing.php new file mode 100644 index 0000000..a7cc49e --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/driver/Nothing.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\driver; + +use think\console\Output; + +class Nothing +{ + + public function __construct(Output $output) + { + // do nothing + } + + public function write($messages, bool $newline = false, int $options = 0) + { + // do nothing + } + + public function renderException(\Throwable $e) + { + // do nothing + } +} diff --git a/vendor/topthink/framework/src/think/console/output/formatter/Stack.php b/vendor/topthink/framework/src/think/console/output/formatter/Stack.php new file mode 100644 index 0000000..8a212ba --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/formatter/Stack.php @@ -0,0 +1,116 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\formatter; + +class Stack +{ + + /** + * @var Style[] + */ + private $styles; + + /** + * @var Style + */ + private $emptyStyle; + + /** + * 构造方法 + * @param Style|null $emptyStyle + */ + public function __construct(?Style $emptyStyle = null) + { + $this->emptyStyle = $emptyStyle ?: new Style(); + $this->reset(); + } + + /** + * 重置堆栈 + */ + public function reset(): void + { + $this->styles = []; + } + + /** + * 推一个样式进入堆栈 + * @param Style $style + */ + public function push(Style $style): void + { + $this->styles[] = $style; + } + + /** + * 从堆栈中弹出一个样式 + * @param Style|null $style + * @return Style + * @throws \InvalidArgumentException + */ + public function pop(?Style $style = null): Style + { + if (empty($this->styles)) { + return $this->emptyStyle; + } + + if (null === $style) { + return array_pop($this->styles); + } + + /** + * @var int $index + * @var Style $stackedStyle + */ + foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { + if ($style->apply('') === $stackedStyle->apply('')) { + $this->styles = array_slice($this->styles, 0, $index); + + return $stackedStyle; + } + } + + throw new \InvalidArgumentException('Incorrectly nested style tag found.'); + } + + /** + * 计算堆栈的当前样式。 + * @return Style + */ + public function getCurrent(): Style + { + if (empty($this->styles)) { + return $this->emptyStyle; + } + + return $this->styles[count($this->styles) - 1]; + } + + /** + * @param Style $emptyStyle + * @return Stack + */ + public function setEmptyStyle(Style $emptyStyle) + { + $this->emptyStyle = $emptyStyle; + + return $this; + } + + /** + * @return Style + */ + public function getEmptyStyle(): Style + { + return $this->emptyStyle; + } +} diff --git a/vendor/topthink/framework/src/think/console/output/formatter/Style.php b/vendor/topthink/framework/src/think/console/output/formatter/Style.php new file mode 100644 index 0000000..2aae768 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/formatter/Style.php @@ -0,0 +1,190 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\formatter; + +class Style +{ + protected static $availableForegroundColors = [ + 'black' => ['set' => 30, 'unset' => 39], + 'red' => ['set' => 31, 'unset' => 39], + 'green' => ['set' => 32, 'unset' => 39], + 'yellow' => ['set' => 33, 'unset' => 39], + 'blue' => ['set' => 34, 'unset' => 39], + 'magenta' => ['set' => 35, 'unset' => 39], + 'cyan' => ['set' => 36, 'unset' => 39], + 'white' => ['set' => 37, 'unset' => 39], + ]; + + protected static $availableBackgroundColors = [ + 'black' => ['set' => 40, 'unset' => 49], + 'red' => ['set' => 41, 'unset' => 49], + 'green' => ['set' => 42, 'unset' => 49], + 'yellow' => ['set' => 43, 'unset' => 49], + 'blue' => ['set' => 44, 'unset' => 49], + 'magenta' => ['set' => 45, 'unset' => 49], + 'cyan' => ['set' => 46, 'unset' => 49], + 'white' => ['set' => 47, 'unset' => 49], + ]; + + protected static $availableOptions = [ + 'bold' => ['set' => 1, 'unset' => 22], + 'underscore' => ['set' => 4, 'unset' => 24], + 'blink' => ['set' => 5, 'unset' => 25], + 'reverse' => ['set' => 7, 'unset' => 27], + 'conceal' => ['set' => 8, 'unset' => 28], + ]; + + private $foreground; + private $background; + private $options = []; + + /** + * 初始化输出的样式 + * @param string|null $foreground 字体颜色 + * @param string|null $background 背景色 + * @param array $options 格式 + * @api + */ + public function __construct($foreground = null, $background = null, array $options = []) + { + if (null !== $foreground) { + $this->setForeground($foreground); + } + if (null !== $background) { + $this->setBackground($background); + } + if (count($options)) { + $this->setOptions($options); + } + } + + /** + * 设置字体颜色 + * @param string|null $color 颜色名 + * @throws \InvalidArgumentException + * @api + */ + public function setForeground($color = null) + { + if (null === $color) { + $this->foreground = null; + + return; + } + + if (!isset(static::$availableForegroundColors[$color])) { + throw new \InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors)))); + } + + $this->foreground = static::$availableForegroundColors[$color]; + } + + /** + * 设置背景色 + * @param string|null $color 颜色名 + * @throws \InvalidArgumentException + * @api + */ + public function setBackground($color = null) + { + if (null === $color) { + $this->background = null; + + return; + } + + if (!isset(static::$availableBackgroundColors[$color])) { + throw new \InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors)))); + } + + $this->background = static::$availableBackgroundColors[$color]; + } + + /** + * 设置字体格式 + * @param string $option 格式名 + * @throws \InvalidArgumentException When the option name isn't defined + * @api + */ + public function setOption(string $option): void + { + if (!isset(static::$availableOptions[$option])) { + throw new \InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)))); + } + + if (!in_array(static::$availableOptions[$option], $this->options)) { + $this->options[] = static::$availableOptions[$option]; + } + } + + /** + * 重置字体格式 + * @param string $option 格式名 + * @throws \InvalidArgumentException + */ + public function unsetOption(string $option): void + { + if (!isset(static::$availableOptions[$option])) { + throw new \InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)))); + } + + $pos = array_search(static::$availableOptions[$option], $this->options); + if (false !== $pos) { + unset($this->options[$pos]); + } + } + + /** + * 批量设置字体格式 + * @param array $options + */ + public function setOptions(array $options) + { + $this->options = []; + + foreach ($options as $option) { + $this->setOption($option); + } + } + + /** + * 应用样式到文字 + * @param string $text 文字 + * @return string + */ + public function apply(string $text): string + { + $setCodes = []; + $unsetCodes = []; + + if (null !== $this->foreground) { + $setCodes[] = $this->foreground['set']; + $unsetCodes[] = $this->foreground['unset']; + } + if (null !== $this->background) { + $setCodes[] = $this->background['set']; + $unsetCodes[] = $this->background['unset']; + } + if (count($this->options)) { + foreach ($this->options as $option) { + $setCodes[] = $option['set']; + $unsetCodes[] = $option['unset']; + } + } + + if (0 === count($setCodes)) { + return $text; + } + + return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes)); + } +} diff --git a/vendor/topthink/framework/src/think/console/output/question/Choice.php b/vendor/topthink/framework/src/think/console/output/question/Choice.php new file mode 100644 index 0000000..1da1750 --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/question/Choice.php @@ -0,0 +1,163 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\question; + +use think\console\output\Question; + +class Choice extends Question +{ + + private $choices; + private $multiselect = false; + private $prompt = ' > '; + private $errorMessage = 'Value "%s" is invalid'; + + /** + * 构造方法 + * @param string $question 问题 + * @param array $choices 选项 + * @param mixed $default 默认答案 + */ + public function __construct($question, array $choices, $default = null) + { + parent::__construct($question, $default); + + $this->choices = $choices; + $this->setValidator($this->getDefaultValidator()); + $this->setAutocompleterValues($choices); + } + + /** + * 可选项 + * @return array + */ + public function getChoices(): array + { + return $this->choices; + } + + /** + * 设置可否多选 + * @param bool $multiselect + * @return self + */ + public function setMultiselect(bool $multiselect) + { + $this->multiselect = $multiselect; + $this->setValidator($this->getDefaultValidator()); + + return $this; + } + + public function isMultiselect(): bool + { + return $this->multiselect; + } + + /** + * 获取提示 + * @return string + */ + public function getPrompt(): string + { + return $this->prompt; + } + + /** + * 设置提示 + * @param string $prompt + * @return self + */ + public function setPrompt(string $prompt) + { + $this->prompt = $prompt; + + return $this; + } + + /** + * 设置错误提示信息 + * @param string $errorMessage + * @return self + */ + public function setErrorMessage(string $errorMessage) + { + $this->errorMessage = $errorMessage; + $this->setValidator($this->getDefaultValidator()); + + return $this; + } + + /** + * 获取默认的验证方法 + * @return callable + */ + private function getDefaultValidator() + { + $choices = $this->choices; + $errorMessage = $this->errorMessage; + $multiselect = $this->multiselect; + $isAssoc = $this->isAssoc($choices); + + return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) { + // Collapse all spaces. + $selectedChoices = str_replace(' ', '', $selected); + + if ($multiselect) { + // Check for a separated comma values + if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) { + throw new \InvalidArgumentException(sprintf($errorMessage, $selected)); + } + $selectedChoices = explode(',', $selectedChoices); + } else { + $selectedChoices = [$selected]; + } + + $multiselectChoices = []; + foreach ($selectedChoices as $value) { + $results = []; + foreach ($choices as $key => $choice) { + if ($choice === $value) { + $results[] = $key; + } + } + + if (count($results) > 1) { + throw new \InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results))); + } + + $result = array_search($value, $choices); + + if (!$isAssoc) { + if (!empty($result)) { + $result = $choices[$result]; + } elseif (isset($choices[$value])) { + $result = $choices[$value]; + } + } elseif (empty($result) && array_key_exists($value, $choices)) { + $result = $value; + } + + if (false === $result) { + throw new \InvalidArgumentException(sprintf($errorMessage, $value)); + } + array_push($multiselectChoices, $result); + } + + if ($multiselect) { + return $multiselectChoices; + } + + return current($multiselectChoices); + }; + } +} diff --git a/vendor/topthink/framework/src/think/console/output/question/Confirmation.php b/vendor/topthink/framework/src/think/console/output/question/Confirmation.php new file mode 100644 index 0000000..bf71b5d --- /dev/null +++ b/vendor/topthink/framework/src/think/console/output/question/Confirmation.php @@ -0,0 +1,57 @@ + +// +---------------------------------------------------------------------- + +namespace think\console\output\question; + +use think\console\output\Question; + +class Confirmation extends Question +{ + + private $trueAnswerRegex; + + /** + * 构造方法 + * @param string $question 问题 + * @param bool $default 默认答案 + * @param string $trueAnswerRegex 验证正则 + */ + public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i') + { + parent::__construct($question, (bool) $default); + + $this->trueAnswerRegex = $trueAnswerRegex; + $this->setNormalizer($this->getDefaultNormalizer()); + } + + /** + * 获取默认的答案回调 + * @return callable + */ + private function getDefaultNormalizer() + { + $default = $this->getDefault(); + $regex = $this->trueAnswerRegex; + + return function ($answer) use ($default, $regex) { + if (is_bool($answer)) { + return $answer; + } + + $answerIsTrue = (bool) preg_match($regex, $answer); + if (false === $default) { + return $answer && $answerIsTrue; + } + + return !$answer || $answerIsTrue; + }; + } +} diff --git a/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php b/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php new file mode 100644 index 0000000..aa09d47 --- /dev/null +++ b/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php @@ -0,0 +1,71 @@ + +// +---------------------------------------------------------------------- +declare(strict_types = 1); + +namespace think\contract; + +use DateInterval; +use DateTimeInterface; +use Psr\SimpleCache\CacheInterface; +use think\cache\TagSet; + +/** + * 缓存驱动接口 + */ +interface CacheHandlerInterface extends CacheInterface +{ + + /** + * 自增缓存(针对数值缓存) + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function inc($name, $step = 1); + + /** + * 自减缓存(针对数值缓存) + * @param string $name 缓存变量名 + * @param int $step 步长 + * @return false|int + */ + public function dec($name, $step = 1); + + /** + * 读取缓存并删除 + * @param string $name 缓存变量名 + * @return mixed + */ + public function pull($name); + + /** + * 如果不存在则写入缓存 + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int|DateInterval|DateTimeInterface $expire 有效时间 0为永久 + * @return mixed + */ + public function remember($name, $value, $expire = null); + + /** + * 缓存标签 + * @param string|array $name 标签名 + * @return TagSet + */ + public function tag($name); + + /** + * 删除缓存标签 + * @param array $keys 缓存标识列表 + * @return void + */ + public function clearTag($keys); +} diff --git a/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php b/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php new file mode 100644 index 0000000..161fb93 --- /dev/null +++ b/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php @@ -0,0 +1,28 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\contract; + +/** + * 日志驱动接口 + */ +interface LogHandlerInterface +{ + /** + * 日志写入接口 + * @access public + * @param array $log 日志信息 + * @return bool + */ + public function save(array $log): bool; + +} diff --git a/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php b/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php new file mode 100644 index 0000000..66aa204 --- /dev/null +++ b/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php @@ -0,0 +1,98 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\contract; + +use Closure; +use think\db\BaseQuery as Query; +use think\Model; + +/** + * 模型关联接口 + */ +interface ModelRelationInterface +{ + /** + * 延迟获取关联数据 + * @access public + * @param array $subRelation 子关联 + * @param Closure $closure 闭包查询条件 + * @return mixed + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null); + + /** + * 预载入关联查询 + * @access public + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包条件 + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null): void; + + /** + * 预载入关联查询 + * @access public + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包条件 + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null): void; + + /** + * 关联统计 + * @access public + * @param Model $result 模型对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * @return integer + */ + public function relationCount(Model $result, Closure $closure, string $aggregate = 'count', string $field = '*', ?string &$name = null); + + /** + * 创建关联统计子查询 + * @access public + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = '*', ?string &$name = null): string; + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', ?Query $query = null): Query; + + /** + * 根据关联条件查询当前模型 + * @access public + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = ''): Query; +} diff --git a/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php b/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php new file mode 100644 index 0000000..6e5d044 --- /dev/null +++ b/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php @@ -0,0 +1,23 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\contract; + +/** + * Session驱动接口 + */ +interface SessionHandlerInterface +{ + public function read(string $sessionId): string; + public function delete(string $sessionId): bool; + public function write(string $sessionId, string $data): bool; +} diff --git a/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php b/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php new file mode 100644 index 0000000..7ab6cfa --- /dev/null +++ b/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php @@ -0,0 +1,56 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\contract; + +/** + * 视图驱动接口 + */ +interface TemplateHandlerInterface +{ + /** + * 检测是否存在模板文件 + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists(string $template): bool; + + /** + * 渲染模板文件 + * @param string $template 模板文件 + * @param array $data 模板变量 + * @return void + */ + public function fetch(string $template, array $data = []): void; + + /** + * 渲染模板内容 + * @param string $content 模板内容 + * @param array $data 模板变量 + * @return void + */ + public function display(string $content, array $data = []): void; + + /** + * 配置模板引擎 + * @param array $config 参数 + * @return void + */ + public function config(array $config): void; + + /** + * 获取模板引擎配置 + * @param string $name 参数名 + * @return mixed + */ + public function getConfig(string $name); +} diff --git a/vendor/topthink/framework/src/think/event/AppInit.php b/vendor/topthink/framework/src/think/event/AppInit.php new file mode 100644 index 0000000..3e49c42 --- /dev/null +++ b/vendor/topthink/framework/src/think/event/AppInit.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\event; + +/** + * AppInit事件类 + */ +class AppInit +{ +} diff --git a/vendor/topthink/framework/src/think/event/HttpEnd.php b/vendor/topthink/framework/src/think/event/HttpEnd.php new file mode 100644 index 0000000..935bf6b --- /dev/null +++ b/vendor/topthink/framework/src/think/event/HttpEnd.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\event; + +/** + * HttpEnd事件类 + */ +class HttpEnd +{ +} diff --git a/vendor/topthink/framework/src/think/event/HttpRun.php b/vendor/topthink/framework/src/think/event/HttpRun.php new file mode 100644 index 0000000..e9aa82a --- /dev/null +++ b/vendor/topthink/framework/src/think/event/HttpRun.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\event; + +/** + * HttpRun事件类 + */ +class HttpRun +{ +} diff --git a/vendor/topthink/framework/src/think/event/LogRecord.php b/vendor/topthink/framework/src/think/event/LogRecord.php new file mode 100644 index 0000000..a74e568 --- /dev/null +++ b/vendor/topthink/framework/src/think/event/LogRecord.php @@ -0,0 +1,29 @@ + +// +---------------------------------------------------------------------- +namespace think\event; + +/** + * LogRecord事件类 + */ +class LogRecord +{ + /** @var string */ + public $type; + + /** @var string */ + public $message; + + public function __construct($type, $message) + { + $this->type = $type; + $this->message = $message; + } +} diff --git a/vendor/topthink/framework/src/think/event/LogWrite.php b/vendor/topthink/framework/src/think/event/LogWrite.php new file mode 100644 index 0000000..a9c4fd5 --- /dev/null +++ b/vendor/topthink/framework/src/think/event/LogWrite.php @@ -0,0 +1,23 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\event; + +/** + * LogWrite事件类 + */ +class LogWrite +{ + public function __construct(public string $channel, public array $log) + { + } +} diff --git a/vendor/topthink/framework/src/think/event/RouteLoaded.php b/vendor/topthink/framework/src/think/event/RouteLoaded.php new file mode 100644 index 0000000..e40b980 --- /dev/null +++ b/vendor/topthink/framework/src/think/event/RouteLoaded.php @@ -0,0 +1,20 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\event; + +/** + * 路由加载完成事件 + */ +class RouteLoaded +{ +} diff --git a/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php b/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php new file mode 100644 index 0000000..940c3b6 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use Psr\Container\NotFoundExceptionInterface; +use RuntimeException; +use Throwable; + +class ClassNotFoundException extends RuntimeException implements NotFoundExceptionInterface +{ + public function __construct(string $message, protected string $class = '', ?Throwable $previous = null) + { + $this->message = $message; + + parent::__construct($message, 0, $previous); + } + + /** + * 获取类名 + * @access public + * @return string + */ + public function getClass() + { + return $this->class; + } +} diff --git a/vendor/topthink/framework/src/think/exception/ErrorException.php b/vendor/topthink/framework/src/think/exception/ErrorException.php new file mode 100644 index 0000000..faf1038 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/ErrorException.php @@ -0,0 +1,57 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\exception; + +use think\Exception; + +/** + * ThinkPHP错误异常 + * 主要用于封装 set_error_handler 和 register_shutdown_function 得到的错误 + * 除开从 think\Exception 继承的功能 + * 其他和PHP系统\ErrorException功能基本一样 + */ +class ErrorException extends Exception +{ + /** + * 用于保存错误级别 + * @var integer + */ + protected $severity; + + /** + * 错误异常构造函数 + * @access public + * @param integer $severity 错误级别 + * @param string $message 错误详细信息 + * @param string $file 出错文件路径 + * @param integer $line 出错行号 + */ + public function __construct(int $severity, string $message, string $file, int $line) + { + $this->severity = $severity; + $this->message = $message; + $this->file = $file; + $this->line = $line; + $this->code = 0; + } + + /** + * 获取错误级别 + * @access public + * @return integer 错误级别 + */ + final public function getSeverity() + { + return $this->severity; + } +} diff --git a/vendor/topthink/framework/src/think/exception/FileException.php b/vendor/topthink/framework/src/think/exception/FileException.php new file mode 100644 index 0000000..fdcbcd3 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/FileException.php @@ -0,0 +1,17 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\exception; + +class FileException extends \RuntimeException +{ +} diff --git a/vendor/topthink/framework/src/think/exception/Handle.php b/vendor/topthink/framework/src/think/exception/Handle.php new file mode 100644 index 0000000..470644a --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/Handle.php @@ -0,0 +1,371 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\exception; + +use Exception; +use think\App; +use think\console\Output; +use think\db\exception\DataNotFoundException; +use think\db\exception\ModelNotFoundException; +use think\Request; +use think\Response; +use Throwable; + +/** + * 系统异常处理类 + */ +class Handle +{ + protected $ignoreReport = [ + HttpException::class, + HttpResponseException::class, + ModelNotFoundException::class, + DataNotFoundException::class, + ValidateException::class, + ]; + + protected $showErrorMsg = [ + + ]; + + public function __construct(protected App $app) + { + } + + /** + * Report or log an exception. + * + * @access public + * @param Throwable $exception + * @return void + */ + public function report(Throwable $exception): void + { + if (!$this->isIgnoreReport($exception)) { + // 收集异常数据 + if ($this->app->isDebug()) { + $data = [ + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'message' => $this->getMessage($exception), + 'code' => $this->getCode($exception), + ]; + $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; + } else { + $data = [ + 'code' => $this->getCode($exception), + 'message' => $this->getMessage($exception), + ]; + $log = "[{$data['code']}]{$data['message']}"; + } + + if ($this->app->config->get('log.record_trace')) { + $log .= PHP_EOL . $exception->getTraceAsString(); + } + + try { + $this->app->log->record($log, 'error'); + } catch (Exception $e) { + } + } + } + + protected function isIgnoreReport(Throwable $exception): bool + { + foreach ($this->ignoreReport as $class) { + if ($exception instanceof $class) { + return true; + } + } + + return false; + } + + /** + * Render an exception into an HTTP response. + * + * @access public + * @param Request $request + * @param Throwable $e + * @return Response + */ + public function render(Request $request, Throwable $e): Response + { + if ($e instanceof HttpResponseException) { + return $e->getResponse(); + } elseif ($e instanceof HttpException) { + return $this->renderHttpException($request, $e); + } else { + return $this->convertExceptionToResponse($request, $e); + } + } + + /** + * @access public + * @param Output $output + * @param Throwable $e + */ + public function renderForConsole(Output $output, Throwable $e): void + { + if ($this->app->isDebug()) { + $output->setVerbosity(Output::VERBOSITY_DEBUG); + } + + $output->renderException($e); + } + + /** + * @access protected + * @param HttpException $e + * @return Response + */ + protected function renderHttpException(Request $request, HttpException $e): Response + { + $status = $e->getStatusCode(); + $template = $this->app->config->get('app.http_exception_template'); + + if (!$this->app->isDebug() && !empty($template[$status])) { + return Response::create($template[$status], 'view', $status)->assign(['e' => $e]); + } else { + return $this->convertExceptionToResponse($request, $e); + } + } + + /** + * 收集异常数据 + * @param Throwable $exception + * @return array + */ + protected function convertExceptionToArray(Throwable $exception): array + { + return $this->app->isDebug() ? $this->getDebugMsg($exception) : $this->getDeployMsg($exception); + } + + /** + * 是否显示错误信息 + * @param \Throwable $exception + * @return bool + */ + protected function isShowErrorMsg(Throwable $exception) + { + foreach ($this->showErrorMsg as $class) { + if ($exception instanceof $class) { + return true; + } + } + + return false; + } + + /** + * 获取部署模式异常数据 + * @access protected + * @param Throwable $exception + * @return array + */ + protected function getDeployMsg(Throwable $exception): array + { + $showErrorMsg = $this->isShowErrorMsg($exception); + if ($showErrorMsg || $this->app->config->get('app.show_error_msg', false)) { + $message = $this->getMessage($exception); + } else { + // 不显示详细错误信息 + $message = $this->app->config->get('app.error_message'); + } + + return [ + 'code' => $this->getCode($exception), + 'message' => $message, + ]; + } + + /** + * 收集调试模式异常数据 + * @access protected + * @param Throwable $exception + * @return array + */ + protected function getDebugMsg(Throwable $exception): array + { + // 调试模式,获取详细的错误信息 + $traces = []; + $nextException = $exception; + + do { + $traces[] = [ + 'name' => $nextException::class, + 'file' => $nextException->getFile(), + 'line' => $nextException->getLine(), + 'code' => $this->getCode($nextException), + 'message' => $this->getMessage($nextException), + 'trace' => $nextException->getTrace(), + 'source' => $this->getSourceCode($nextException), + ]; + } while ($nextException = $nextException->getPrevious()); + + return [ + 'code' => $this->getCode($exception), + 'message' => $this->getMessage($exception), + 'traces' => $traces, + 'datas' => $this->getExtendData($exception), + 'tables' => [ + 'GET Data' => $this->app->request->get(), + 'POST Data' => $this->app->request->post(), + 'Files' => $this->app->request->file(), + 'Cookies' => $this->app->request->cookie(), + 'Session' => $this->app->exists('session') ? $this->app->session->all() : [], + 'Server/Request Data' => $this->app->request->server(), + ], + ]; + } + + protected function isJson(Request $request, Throwable $exception) + { + return $request->isJson(); + } + + /** + * @access protected + * @param Throwable $exception + * @return Response + */ + protected function convertExceptionToResponse(Request $request, Throwable $exception): Response + { + if ($this->isJson($request, $exception)) { + $response = Response::create($this->convertExceptionToArray($exception), 'json'); + } else { + $response = Response::create($this->renderExceptionContent($exception)); + } + + if ($exception instanceof HttpException) { + $statusCode = $exception->getStatusCode(); + $response->header($exception->getHeaders()); + } + + return $response->code($statusCode ?? 500); + } + + protected function renderExceptionContent(Throwable $exception): string + { + ob_start(); + $data = $this->convertExceptionToArray($exception); + extract($data); + include $this->app->config->get('app.exception_tmpl') ?: __DIR__ . '/../../tpl/think_exception.tpl'; + + return ob_get_clean(); + } + + /** + * 获取错误编码 + * ErrorException则使用错误级别作为错误编码 + * @access protected + * @param Throwable $exception + * @return integer 错误编码 + */ + protected function getCode(Throwable $exception) + { + $code = $exception->getCode(); + + if (!$code && $exception instanceof ErrorException) { + $code = $exception->getSeverity(); + } + + return $code; + } + + /** + * 获取错误信息 + * ErrorException则使用错误级别作为错误编码 + * @access protected + * @param Throwable $exception + * @return string 错误信息 + */ + protected function getMessage(Throwable $exception): string + { + $message = $exception->getMessage(); + + if ($this->app->runningInConsole()) { + return $message; + } + + $lang = $this->app->lang; + + if (str_contains($message, ':')) { + $name = strstr($message, ':', true); + $message = $lang->has($name) ? $lang->get($name) . strstr($message, ':') : $message; + } elseif (str_contains($message, ',')) { + $name = strstr($message, ',', true); + $message = $lang->has($name) ? $lang->get($name) . ':' . substr(strstr($message, ','), 1) : $message; + } elseif ($lang->has($message)) { + $message = $lang->get($message); + } + + return $message; + } + + /** + * 获取出错文件内容 + * 获取错误的前9行和后9行 + * @access protected + * @param Throwable $exception + * @return array 错误文件内容 + */ + protected function getSourceCode(Throwable $exception): array + { + // 读取前9行和后9行 + $line = $exception->getLine(); + $first = ($line - 9 > 0) ? $line - 9 : 1; + + try { + $contents = file($exception->getFile()) ?: []; + $source = [ + 'first' => $first, + 'source' => array_slice($contents, $first - 1, 19), + ]; + } catch (Exception $e) { + $source = []; + } + + return $source; + } + + /** + * 获取异常扩展信息 + * 用于非调试模式html返回类型显示 + * @access protected + * @param Throwable $exception + * @return array 异常类定义的扩展数据 + */ + protected function getExtendData(Throwable $exception): array + { + $data = []; + + if ($exception instanceof \think\Exception) { + $data = $exception->getData(); + } + + return $data; + } + + /** + * 获取常量列表 + * @access protected + * @return array 常量列表 + */ + protected function getConst(): array + { + $const = get_defined_constants(true); + + return $const['user'] ?? []; + } +} diff --git a/vendor/topthink/framework/src/think/exception/HttpException.php b/vendor/topthink/framework/src/think/exception/HttpException.php new file mode 100644 index 0000000..66597e4 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/HttpException.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\exception; + +use Exception; + +/** + * HTTP异常 + */ +class HttpException extends \RuntimeException +{ + public function __construct(private int $statusCode, string $message = '', ?Exception $previous = null, private array $headers = [], $code = 0) + { + parent::__construct($message, $code, $previous); + } + + public function getStatusCode() + { + return $this->statusCode; + } + + public function getHeaders() + { + return $this->headers; + } +} diff --git a/vendor/topthink/framework/src/think/exception/HttpResponseException.php b/vendor/topthink/framework/src/think/exception/HttpResponseException.php new file mode 100644 index 0000000..2ce18e3 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/HttpResponseException.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\exception; + +use think\Response; + +/** + * HTTP响应异常 + */ +class HttpResponseException extends \RuntimeException +{ + public function __construct(protected Response $response) + { + } + + public function getResponse() + { + return $this->response; + } + +} diff --git a/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php b/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php new file mode 100644 index 0000000..8c21efb --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php @@ -0,0 +1,21 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); +namespace think\exception; + +use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInvalidArgumentInterface; + +/** + * 非法数据异常 + */ +class InvalidArgumentException extends \InvalidArgumentException implements SimpleCacheInvalidArgumentInterface +{ +} diff --git a/vendor/topthink/framework/src/think/exception/InvalidCacheException.php b/vendor/topthink/framework/src/think/exception/InvalidCacheException.php new file mode 100644 index 0000000..afe2d04 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/InvalidCacheException.php @@ -0,0 +1,19 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); +namespace think\exception; + +/** + * 非法缓存数据异常 + */ +class InvalidCacheException extends InvalidArgumentException +{ +} diff --git a/vendor/topthink/framework/src/think/exception/RouteNotFoundException.php b/vendor/topthink/framework/src/think/exception/RouteNotFoundException.php new file mode 100644 index 0000000..7cd0206 --- /dev/null +++ b/vendor/topthink/framework/src/think/exception/RouteNotFoundException.php @@ -0,0 +1,26 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\exception; + +/** + * 路由未定义异常 + */ +class RouteNotFoundException extends HttpException +{ + + public function __construct() + { + parent::__construct(404, 'Route Not Found'); + } + +} diff --git a/vendor/topthink/framework/src/think/facade/App.php b/vendor/topthink/framework/src/think/facade/App.php new file mode 100644 index 0000000..f99d1f4 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/App.php @@ -0,0 +1,59 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\App + * @package think\facade + * @mixin \think\App + * @method static \think\Service|null register(\think\Service|string $service, bool $force = false) 注册服务 + * @method static mixed bootService(\think\Service $service) 执行服务 + * @method static \think\Service|null getService(string|\think\Service $service) 获取服务 + * @method static \think\App debug(bool $debug = true) 开启应用调试模式 + * @method static bool isDebug() 是否为调试模式 + * @method static \think\App setNamespace(string $namespace) 设置应用命名空间 + * @method static string getNamespace() 获取应用类库命名空间 + * @method static string version() 获取框架版本 + * @method static string getRootPath() 获取应用根目录 + * @method static string getBasePath() 获取应用基础目录 + * @method static string getAppPath() 获取当前应用目录 + * @method static mixed setAppPath(string $path) 设置应用目录 + * @method static string getRuntimePath() 获取应用运行时目录 + * @method static void setRuntimePath(string $path) 设置runtime目录 + * @method static string getThinkPath() 获取核心框架目录 + * @method static string getConfigPath() 获取应用配置目录 + * @method static string getConfigExt() 获取配置后缀 + * @method static float getBeginTime() 获取应用开启时间 + * @method static integer getBeginMem() 获取应用初始内存占用 + * @method static \think\App initialize() 初始化应用 + * @method static bool initialized() 是否初始化过 + * @method static void loadLangPack(string $langset) 加载语言包 + * @method static void boot() 引导应用 + * @method static void loadEvent(array $event) 注册应用事件 + * @method static string parseClass(string $layer, string $name) 解析应用类的类名 + * @method static bool runningInConsole() 是否运行在命令行下 + */ +class App extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'app'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Cache.php b/vendor/topthink/framework/src/think/facade/Cache.php new file mode 100644 index 0000000..84e52a9 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Cache.php @@ -0,0 +1,48 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\cache\Driver; +use think\cache\TagSet; +use think\Facade; + +/** + * @see \think\Cache + * @package think\facade + * @mixin \think\Cache + * @method static string|null getDefaultDriver() 默认驱动 + * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置 + * @method static array getStoreConfig(string $store, string $name = null, null $default = null) 获取驱动配置 + * @method static Driver store(string $name = null) 连接或者切换缓存 + * @method static bool clear() 清空缓冲池 + * @method static mixed get(string $key, mixed $default = null) 读取缓存 + * @method static bool set(string $key, mixed $value, int|\DateInterval|\DateTimeInterface $ttl = null) 写入缓存 + * @method static bool delete(string $key) 删除缓存 + * @method static iterable getMultiple(iterable $keys, mixed $default = null) 读取缓存 + * @method static bool setMultiple(iterable $values, null|int|\DateInterval|\DateTimeInterface $ttl = null) 写入缓存 + * @method static bool deleteMultiple(iterable $keys) 删除缓存 + * @method static bool has(string $key) 判断缓存是否存在 + * @method static TagSet tag(string|array $name) 缓存标签 + */ +class Cache extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'cache'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Config.php b/vendor/topthink/framework/src/think/facade/Config.php new file mode 100644 index 0000000..d029b55 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Config.php @@ -0,0 +1,37 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Config + * @package think\facade + * @mixin \think\Config + * @method static array load(string $file, string $name = '') 加载配置文件(多种格式) + * @method static bool has(string $name) 检测配置是否存在 + * @method static mixed get(string $name = null, mixed $default = null) 获取配置参数 为空则获取所有配置 + * @method static array set(array $config, string $name = null) 设置配置参数 name为数组则为批量设置 + */ +class Config extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'config'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Console.php b/vendor/topthink/framework/src/think/facade/Console.php new file mode 100644 index 0000000..b733a6d --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Console.php @@ -0,0 +1,56 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\console\Command; +use think\console\Input; +use think\console\input\Definition as InputDefinition; +use think\console\Output; +use think\console\output\driver\Buffer; +use think\Facade; + +/** + * Class Console + * @package think\facade + * @mixin \think\Console + * @method static Output|Buffer call(string $command, array $parameters = [], string $driver = 'buffer') + * @method static int run() 执行当前的指令 + * @method static int doRun(Input $input, Output $output) 执行指令 + * @method static void setDefinition(InputDefinition $definition) 设置输入参数定义 + * @method static InputDefinition The InputDefinition instance getDefinition() 获取输入参数定义 + * @method static string A help message. getHelp() Gets the help message. + * @method static void setCatchExceptions(bool $boolean) 是否捕获异常 + * @method static void setAutoExit(bool $boolean) 是否自动退出 + * @method static string getLongVersion() 获取完整的版本号 + * @method static void addCommands(array $commands) 添加指令集 + * @method static Command|void addCommand(string|Command $command, string $name = '') 添加一个指令 + * @method static Command getCommand(string $name) 获取指令 + * @method static bool hasCommand(string $name) 某个指令是否存在 + * @method static array getNamespaces() 获取所有的命名空间 + * @method static string findNamespace(string $namespace) 查找注册命名空间中的名称或缩写。 + * @method static Command find(string $name) 查找指令 + * @method static Command[] all(string $namespace = null) 获取所有的指令 + * @method static string extractNamespace(string $name, int $limit = 0) 返回命名空间部分 + */ +class Console extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'console'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Cookie.php b/vendor/topthink/framework/src/think/facade/Cookie.php new file mode 100644 index 0000000..afbb74e --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Cookie.php @@ -0,0 +1,40 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Cookie + * @package think\facade + * @mixin \think\Cookie + * @method static mixed get(mixed $name = '', string $default = null) 获取cookie + * @method static bool has(string $name) 是否存在Cookie参数 + * @method static void set(string $name, string $value, mixed $option = null) Cookie 设置 + * @method static void forever(string $name, string $value = '', mixed $option = null) 永久保存Cookie数据 + * @method static void delete(string $name) Cookie删除 + * @method static array getCookie() 获取cookie保存数据 + * @method static void save() 保存Cookie + */ +class Cookie extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'cookie'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Env.php b/vendor/topthink/framework/src/think/facade/Env.php new file mode 100644 index 0000000..a4a506c --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Env.php @@ -0,0 +1,44 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Env + * @package think\facade + * @mixin \think\Env + * @method static void load(string $file) 读取环境变量定义文件 + * @method static mixed get(string $name = null, mixed $default = null) 获取环境变量值 + * @method static void set(string|array $env, mixed $value = null) 设置环境变量值 + * @method static bool has(string $name) 检测是否存在环境变量 + * @method static void __set(string $name, mixed $value) 设置环境变量 + * @method static mixed __get(string $name) 获取环境变量 + * @method static bool __isset(string $name) 检测是否存在环境变量 + * @method static void offsetSet($name, $value) + * @method static bool offsetExists($name) + * @method static mixed offsetUnset($name) + * @method static mixed offsetGet($name) + */ +class Env extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'env'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Event.php b/vendor/topthink/framework/src/think/facade/Event.php new file mode 100644 index 0000000..157ac9a --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Event.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Event + * @package think\facade + * @mixin \think\Event + * @method static \think\Event listenEvents(array $events) 批量注册事件监听 + * @method static \think\Event listen(string $event, mixed $listener, bool $first = false) 注册事件监听 + * @method static bool hasListener(string $event) 是否存在事件监听 + * @method static void remove(string $event) 移除事件监听 + * @method static \think\Event bind(array $events) 指定事件别名标识 便于调用 + * @method static \think\Event subscribe(mixed $subscriber) 注册事件订阅者 + * @method static \think\Event observe(string|object $observer, null|string $prefix = '') 自动注册事件观察者 + * @method static mixed trigger(string|object $event, mixed $params = null, bool $once = false) 触发事件 + * @method static mixed until($event, $params = null) 触发事件(只获取一个有效返回值) + */ +class Event extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'event'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Lang.php b/vendor/topthink/framework/src/think/facade/Lang.php new file mode 100644 index 0000000..8c7eb71 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Lang.php @@ -0,0 +1,41 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Lang + * @package think\facade + * @mixin \think\Lang + * @method static void setLangSet(string $lang) 设置当前语言 + * @method static string getLangSet() 获取当前语言 + * @method static string defaultLangSet() 获取默认语言 + * @method static array load(string|array $file, string $range = '') 加载语言定义(不区分大小写) + * @method static bool has(string|null $name, string $range = '') 判断是否存在语言定义(不区分大小写) + * @method static mixed get(string|null $name = null, array $vars = [], string $range = '') 获取语言定义(不区分大小写) + * @method static string detect(\think\Request $request) 自动侦测设置获取语言选择 + * @method static void saveToCookie(\think\Cookie $cookie) 保存当前语言到Cookie + */ +class Lang extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'lang'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Log.php b/vendor/topthink/framework/src/think/facade/Log.php new file mode 100644 index 0000000..268547c --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Log.php @@ -0,0 +1,58 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; +use think\log\Channel; +use think\log\ChannelSet; + +/** + * @see \think\Log + * @package think\facade + * @mixin \think\Log + * @method static string|null getDefaultDriver() 默认驱动 + * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取日志配置 + * @method static array getChannelConfig(string $channel, null $name = null, null $default = null) 获取渠道配置 + * @method static Channel|ChannelSet channel(string|array $name = null) driver() 的别名 + * @method static mixed createDriver(string $name) + * @method static \think\Log clear(string|array $channel = '*') 清空日志信息 + * @method static \think\Log close(string|array $channel = '*') 关闭本次请求日志写入 + * @method static array getLog(string $channel = null) 获取日志信息 + * @method static bool save() 保存日志信息 + * @method static \think\Log record(mixed $msg, string $type = 'info', array $context = [], bool $lazy = true) 记录日志信息 + * @method static \think\Log write(mixed $msg, string $type = 'info', array $context = []) 实时写入日志信息 + * @method static Event listen($listener) 注册日志写入事件监听 + * @method static void log(string $level, string|\Stringable $message, array $context = []) 记录日志信息 + * @method static void emergency(string|\Stringable $message, array $context = []) 记录emergency信息 + * @method static void alert(string|\Stringable $message, array $context = []) 记录警报信息 + * @method static void critical(string|\Stringable $message, array $context = []) 记录紧急情况 + * @method static void error(string|\Stringable $message, array $context = []) 记录错误信息 + * @method static void warning(string|\Stringable $message, array $context = []) 记录warning信息 + * @method static void notice(string|\Stringable $message, array $context = []) 记录notice信息 + * @method static void info(string|\Stringable $message, array $context = []) 记录一般信息 + * @method static void debug(string|\Stringable $message, array $context = []) 记录调试信息 + * @method static void sql(string|\Stringable $message, array $context = []) 记录sql信息 + * @method static mixed __call($method, $parameters) + */ +class Log extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'log'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Middleware.php b/vendor/topthink/framework/src/think/facade/Middleware.php new file mode 100644 index 0000000..9ad74b2 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Middleware.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Middleware + * @package think\facade + * @mixin \think\Middleware + * @method static void import(array $middlewares = [], string $type = 'global') 导入中间件 + * @method static void add(mixed $middleware, string $type = 'global') 注册中间件 + * @method static void route(mixed $middleware) 注册路由中间件 + * @method static void controller(mixed $middleware) 注册控制器中间件 + * @method static mixed unshift(mixed $middleware, string $type = 'global') 注册中间件到开始位置 + * @method static array all(string $type = 'global') 获取注册的中间件 + * @method static Pipeline pipeline(string $type = 'global') 调度管道 + * @method static mixed end(\think\Response $response) 结束调度 + * @method static \think\Response handleException(\think\Request $passable, \Throwable $e) 异常处理 + */ +class Middleware extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'middleware'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Request.php b/vendor/topthink/framework/src/think/facade/Request.php new file mode 100644 index 0000000..b4a7b0d --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Request.php @@ -0,0 +1,134 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; +use think\file\UploadedFile; +use think\route\Rule; + +/** + * @see \think\Request + * @package think\facade + * @mixin \think\Request + * @method static \think\Request setDomain(string $domain) 设置当前包含协议的域名 + * @method static string domain(bool $port = false) 获取当前包含协议的域名 + * @method static string rootDomain() 获取当前根域名 + * @method static \think\Request setSubDomain(string $domain) 设置当前泛域名的值 + * @method static string subDomain() 获取当前子域名 + * @method static \think\Request setPanDomain(string $domain) 设置当前泛域名的值 + * @method static string panDomain() 获取当前泛域名的值 + * @method static \think\Request setUrl(string $url) 设置当前完整URL 包括QUERY_STRING + * @method static string url(bool $complete = false) 获取当前完整URL 包括QUERY_STRING + * @method static \think\Request setBaseUrl(string $url) 设置当前URL 不含QUERY_STRING + * @method static string baseUrl(bool $complete = false) 获取当前URL 不含QUERY_STRING + * @method static string baseFile(bool $complete = false) 获取当前执行的文件 SCRIPT_NAME + * @method static \think\Request setRoot(string $url) 设置URL访问根地址 + * @method static string root(bool $complete = false) 获取URL访问根地址 + * @method static string rootUrl() 获取URL访问根目录 + * @method static \think\Request setPathinfo(string $pathinfo) 设置当前请求的pathinfo + * @method static string pathinfo() 获取当前请求URL的pathinfo信息(含URL后缀) + * @method static string ext() 当前URL的访问后缀 + * @method static integer|float time(bool $float = false) 获取当前请求的时间 + * @method static string type() 当前请求的资源类型 + * @method static void mimeType(string|array $type, string $val = '') 设置资源类型 + * @method static \think\Request setMethod(string $method) 设置请求类型 + * @method static string method(bool $origin = false) 当前的请求类型 + * @method static bool isGet() 是否为GET请求 + * @method static bool isPost() 是否为POST请求 + * @method static bool isPut() 是否为PUT请求 + * @method static bool isDelete() 是否为DELTE请求 + * @method static bool isHead() 是否为HEAD请求 + * @method static bool isPatch() 是否为PATCH请求 + * @method static bool isOptions() 是否为OPTIONS请求 + * @method static bool isCli() 是否为cli + * @method static bool isCgi() 是否为cgi + * @method static mixed param(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取当前请求的参数 + * @method static \think\Request setRule(Rule $rule) 设置路由变量 + * @method static Rule|null rule() 获取当前路由对象 + * @method static \think\Request setRoute(array $route) 设置路由变量 + * @method static mixed route(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取路由参数 + * @method static mixed get(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取GET参数 + * @method static mixed middleware(mixed $name, mixed $default = null) 获取中间件传递的参数 + * @method static mixed post(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取POST参数 + * @method static mixed put(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取PUT参数 + * @method static mixed delete(mixed $name = '', mixed $default = null, string|array|null $filter = '') 设置获取DELETE参数 + * @method static mixed patch(mixed $name = '', mixed $default = null, string|array|null $filter = '') 设置获取PATCH参数 + * @method static mixed request(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取request变量 + * @method static mixed env(string $name = '', string $default = null) 获取环境变量 + * @method static mixed session(string $name = '', string $default = null) 获取session数据 + * @method static mixed cookie(mixed $name = '', string $default = null, string|array|null $filter = '') 获取cookie参数 + * @method static mixed server(string $name = '', string $default = '') 获取server参数 + * @method static null|array|UploadedFile file(string $name = '') 获取上传的文件信息 + * @method static string|array header(string $name = '', string $default = null) 设置或者获取当前的Header + * @method static mixed input(array $data = [], string|false $name = '', mixed $default = null, string|array|null $filter = '') 获取变量 支持过滤和默认值 + * @method static mixed filter(mixed $filter = null) 设置或获取当前的过滤规则 + * @method static mixed filterValue(mixed &$value, mixed $key, array $filters) 递归过滤给定的值 + * @method static bool has(string $name, string $type = 'param', bool $checkEmpty = false) 是否存在某个请求参数 + * @method static array only(array $name, mixed $data = 'param', string|array|null $filter = '') 获取指定的参数 + * @method static mixed except(array $name, string $type = 'param') 排除指定参数获取 + * @method static bool isSsl() 当前是否ssl + * @method static bool isJson() 当前是否JSON请求 + * @method static bool isAjax(bool $ajax = false) 当前是否Ajax请求 + * @method static bool isPjax(bool $pjax = false) 当前是否Pjax请求 + * @method static string ip() 获取客户端IP地址 + * @method static boolean isValidIP(string $ip, string $type = '') 检测是否是合法的IP地址 + * @method static string ip2bin(string $ip) 将IP地址转换为二进制字符串 + * @method static bool isMobile() 检测是否使用手机访问 + * @method static string scheme() 当前URL地址中的scheme参数 + * @method static string query() 当前请求URL地址中的query参数 + * @method static \think\Request setHost(string $host) 设置当前请求的host(包含端口) + * @method static string host(bool $strict = false) 当前请求的host + * @method static int port() 当前请求URL地址中的port参数 + * @method static string protocol() 当前请求 SERVER_PROTOCOL + * @method static int remotePort() 当前请求 REMOTE_PORT + * @method static string contentType() 当前请求 HTTP_CONTENT_TYPE + * @method static string secureKey() 获取当前请求的安全Key + * @method static \think\Request setController(string $controller) 设置当前的控制器名 + * @method static \think\Request setAction(string $action) 设置当前的操作名 + * @method static string controller(bool $convert = false) 获取当前的控制器名 + * @method static string action(bool $convert = false) 获取当前的操作名 + * @method static string getContent() 设置或者获取当前请求的content + * @method static string getInput() 获取当前请求的php://input + * @method static string buildToken(string $name = '__token__', mixed $type = 'md5') 生成请求令牌 + * @method static bool checkToken(string $token = '__token__', array $data = []) 检查请求令牌 + * @method static \think\Request withMiddleware(array $middleware) 设置在中间件传递的数据 + * @method static \think\Request withGet(array $get) 设置GET数据 + * @method static \think\Request withPost(array $post) 设置POST数据 + * @method static \think\Request withCookie(array $cookie) 设置COOKIE数据 + * @method static \think\Request withSession(Session $session) 设置SESSION数据 + * @method static \think\Request withServer(array $server) 设置SERVER数据 + * @method static \think\Request withHeader(array $header) 设置HEADER数据 + * @method static \think\Request withEnv(Env $env) 设置ENV数据 + * @method static \think\Request withInput(string $input) 设置php://input数据 + * @method static \think\Request withFiles(array $files) 设置文件上传数据 + * @method static \think\Request withRoute(array $route) 设置ROUTE变量 + * @method static mixed __set(string $name, mixed $value) 设置中间传递数据 + * @method static mixed __get(string $name) 获取中间传递数据的值 + * @method static boolean __isset(string $name) 检测中间传递数据的值 + * @method static bool offsetExists(mixed $name) + * @method static mixed offsetGet(mixed $name) + * @method static mixed offsetSet(mixed $name, $value) + * @method static mixed offsetUnset(mixed $name) + */ +class Request extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'request'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Route.php b/vendor/topthink/framework/src/think/facade/Route.php new file mode 100644 index 0000000..b259437 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Route.php @@ -0,0 +1,82 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; +use think\route\Dispatch; +use think\route\Domain; +use think\route\Rule; +use think\route\RuleGroup; +use think\route\RuleItem; +use think\route\RuleName; +use think\route\Url as UrlBuild; + +/** + * @see \think\Route + * @package think\facade + * @mixin \think\Route + * @method static mixed config(string $name = null) + * @method static \think\Route lazy(bool $lazy = true) 设置路由域名及分组(包括资源路由)是否延迟解析 + * @method static \think\Route mergeRuleRegex(bool $merge = true) 设置路由域名及分组(包括资源路由)是否合并解析 + * @method static void setGroup(RuleGroup $group) 设置当前分组 + * @method static RuleGroup getGroup(string $name = null) 获取指定标识的路由分组 不指定则获取当前分组 + * @method static \think\Route pattern(array $pattern) 注册变量规则 + * @method static \think\Route option(array $option) 注册路由参数 + * @method static Domain domain(string|array $name, mixed $rule = null) 注册域名路由 + * @method static array getDomains() 获取域名 + * @method static RuleName getRuleName() 获取RuleName对象 + * @method static \think\Route bind(string $bind, string $domain = null) 设置路由绑定 + * @method static array getBind() 读取路由绑定信息 + * @method static string|null getDomainBind(string $domain = null) 读取路由绑定 + * @method static RuleItem[] getName(string $name = null, string $domain = null, string $method = '*') 读取路由标识 + * @method static void import(array $name) 批量导入路由标识 + * @method static void setName(string $name, RuleItem $ruleItem, bool $first = false) 注册路由标识 + * @method static void setRule(string $rule, RuleItem $ruleItem = null) 保存路由规则 + * @method static RuleItem[] getRule(string $rule) 读取路由 + * @method static array getRuleList() 读取路由列表 + * @method static void clear() 清空路由规则 + * @method static RuleItem rule(string $rule, mixed $route = null, string $method = '*') 注册路由规则 + * @method static \think\Route setCrossDomainRule(Rule $rule) 设置跨域有效路由规则 + * @method static RuleGroup group(string|\Closure $name, mixed $route = null) 注册路由分组 + * @method static RuleItem any(string $rule, mixed $route) 注册路由 + * @method static RuleItem get(string $rule, mixed $route) 注册GET路由 + * @method static RuleItem post(string $rule, mixed $route) 注册POST路由 + * @method static RuleItem put(string $rule, mixed $route) 注册PUT路由 + * @method static RuleItem delete(string $rule, mixed $route) 注册DELETE路由 + * @method static RuleItem patch(string $rule, mixed $route) 注册PATCH路由 + * @method static RuleItem head(string $rule, mixed $route) 注册HEAD路由 + * @method static RuleItem options(string $rule, mixed $route) 注册OPTIONS路由 + * @method static Resource resource(string $rule, string $route) 注册资源路由 + * @method static RuleItem view(string $rule, string $template = '', array $vars = []) 注册视图路由 + * @method static RuleItem redirect(string $rule, string $route = '', int $status = 301) 注册重定向路由 + * @method static \think\Route rest(string|array $name, array|bool $resource = []) rest方法定义和修改 + * @method static array|null getRest(string $name = null) 获取rest方法定义的参数 + * @method static RuleItem miss(string|\Closure $route, string $method = '*') 注册未匹配路由规则后的处理 + * @method static Response dispatch(\think\Request $request, Closure|bool $withRoute = true) 路由调度 + * @method static Dispatch|false check() 检测URL路由 + * @method static Dispatch url(string $url) 默认URL解析 + * @method static UrlBuild buildUrl(string $url = '', array $vars = []) URL生成 支持路由反射 + * @method static RuleGroup __call(string $method, array $args) 设置全局的路由分组参数 + */ +class Route extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'route'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/Session.php b/vendor/topthink/framework/src/think/facade/Session.php new file mode 100644 index 0000000..d7e7c14 --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/Session.php @@ -0,0 +1,45 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Session + * @package think\facade + * @mixin \think\Session + * @method static void set(string $name, mixed $value) 设置Session值 + * @method static mixed get(string $name, mixed $default = null) 获取Session值 + * @method static array all() 获取全部Session值 + * @method static void delete(string $name) 删除Session值 + * @method static mixed pull(string $name) 获取并删除Session值 + * @method static void push(string $key, mixed $value) 添加数据到一个session数组 + * @method static bool has(string $name) 判断Session值 + * @method static void clear() 清空Session数据 + * @method static void destroy() 销毁Session + * @method static void save() 写入Session数据(通常情况自动写入) + * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取Session配置 + * @method static string|null getDefaultDriver() 默认驱动 + */ +class Session extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'session'; + } +} diff --git a/vendor/topthink/framework/src/think/facade/View.php b/vendor/topthink/framework/src/think/facade/View.php new file mode 100644 index 0000000..db7dc7a --- /dev/null +++ b/vendor/topthink/framework/src/think/facade/View.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\View + * @package think\facade + * @mixin \think\View + * @method static \think\View engine(string $type = null) 获取模板引擎 + * @method static \think\View assign(string|array $name, mixed $value = null) 模板变量赋值 + * @method static \think\View filter(\think\Callable $filter = null) 视图过滤 + * @method static string fetch(string $template = '', array $vars = []) 解析和获取模板内容 用于输出 + * @method static string display(string $content, array $vars = []) 渲染内容输出 + * @method static mixed __set(string $name, mixed $value) 模板变量赋值 + * @method static mixed __get(string $name) 取得模板显示变量的值 + * @method static bool __isset(string $name) 检测模板变量是否设置 + * @method static string|null getDefaultDriver() 默认驱动 + */ +class View extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'view'; + } +} diff --git a/vendor/topthink/framework/src/think/file/UploadedFile.php b/vendor/topthink/framework/src/think/file/UploadedFile.php new file mode 100644 index 0000000..4e3c3d2 --- /dev/null +++ b/vendor/topthink/framework/src/think/file/UploadedFile.php @@ -0,0 +1,129 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\file; + +use think\exception\FileException; +use think\File; + +class UploadedFile extends File +{ + + private $test = false; + private $originalName; + private $mimeType; + private $error; + + public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $error = null, bool $test = false) + { + $this->originalName = $originalName; + $this->mimeType = $mimeType ?: 'application/octet-stream'; + $this->test = $test; + $this->error = $error ?: UPLOAD_ERR_OK; + + parent::__construct($path, UPLOAD_ERR_OK === $this->error); + } + + public function isValid(): bool + { + $isOk = UPLOAD_ERR_OK === $this->error; + + return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); + } + + /** + * 上传文件 + * @access public + * @param string $directory 保存路径 + * @param string|null $name 保存的文件名 + * @return File + */ + public function move(string $directory, ?string $name = null): File + { + if ($this->isValid()) { + if ($this->test) { + return parent::move($directory, $name); + } + + $target = $this->getTargetFile($directory, $name); + + set_error_handler(function ($type, $msg) use (&$error) { + $error = $msg; + }); + + $moved = move_uploaded_file($this->getPathname(), (string) $target); + restore_error_handler(); + if (!$moved) { + throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error))); + } + + @chmod((string) $target, 0666 & ~umask()); + + return $target; + } + + throw new FileException($this->getErrorMessage()); + } + + /** + * 获取错误信息 + * @access public + * @return string + */ + protected function getErrorMessage(): string + { + return match ($this->error) { + 1,2 => 'upload File size exceeds the maximum value', + 3 => 'only the portion of file is uploaded', + 4 => 'no file to uploaded', + 6 => 'upload temp dir not found', + 7 => 'file write error', + default => 'unknown upload error', + }; + } + + /** + * 获取上传文件类型信息 + * @return string + */ + public function getOriginalMime(): string + { + return $this->mimeType; + } + + /** + * 上传文件名 + * @return string + */ + public function getOriginalName(): string + { + return $this->originalName; + } + + /** + * 获取上传文件扩展名 + * @return string + */ + public function getOriginalExtension(): string + { + return pathinfo($this->originalName, PATHINFO_EXTENSION); + } + + /** + * 获取文件扩展名 + * @return string + */ + public function extension(): string + { + return $this->getOriginalExtension(); + } +} diff --git a/vendor/topthink/framework/src/think/initializer/BootService.php b/vendor/topthink/framework/src/think/initializer/BootService.php new file mode 100644 index 0000000..04ef6cb --- /dev/null +++ b/vendor/topthink/framework/src/think/initializer/BootService.php @@ -0,0 +1,26 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\initializer; + +use think\App; + +/** + * 启动系统服务 + */ +class BootService +{ + public function init(App $app) + { + $app->boot(); + } +} diff --git a/vendor/topthink/framework/src/think/initializer/Error.php b/vendor/topthink/framework/src/think/initializer/Error.php new file mode 100644 index 0000000..6cd0509 --- /dev/null +++ b/vendor/topthink/framework/src/think/initializer/Error.php @@ -0,0 +1,120 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\initializer; + +use think\App; +use think\console\Output as ConsoleOutput; +use think\exception\ErrorException; +use think\exception\Handle; +use Throwable; + +/** + * 错误和异常处理 + */ +class Error +{ + /** @var App */ + protected $app; + + /** + * 注册异常处理 + * @access public + * @param App $app + * @return void + */ + public function init(App $app) + { + $this->app = $app; + error_reporting(E_ALL); + ini_set('display_errors', 'Off'); + set_error_handler([$this, 'appError']); + set_exception_handler([$this, 'appException']); + register_shutdown_function([$this, 'appShutdown']); + } + + /** + * Exception Handler + * @access public + * @param \Throwable $e + */ + public function appException(Throwable $e): void + { + $handler = $this->getExceptionHandler(); + + $handler->report($e); + + if ($this->app->runningInConsole()) { + $handler->renderForConsole(new ConsoleOutput, $e); + } else { + $response = $handler->render($this->app->request, $e); + $response->send(); + $this->app->http->end($response); + } + } + + /** + * Error Handler + * @access public + * @param integer $errno 错误编号 + * @param string $errstr 详细错误信息 + * @param string $errfile 出错的文件 + * @param integer $errline 出错行号 + * @throws ErrorException + */ + public function appError(int $errno, string $errstr, string $errfile = '', int $errline = 0): void + { + $exception = new ErrorException($errno, $errstr, $errfile, $errline); + + if (error_reporting() & $errno) { + // 将错误信息托管至 think\exception\ErrorException + throw $exception; + } + } + + /** + * Shutdown Handler + * @access public + */ + public function appShutdown(): void + { + if (!is_null($error = error_get_last()) && $this->isFatal($error['type'])) { + // 将错误信息托管至think\ErrorException + $exception = new ErrorException($error['type'], $error['message'], $error['file'], $error['line']); + + $this->appException($exception); + } + } + + /** + * 确定错误类型是否致命 + * + * @access protected + * @param int $type + * @return bool + */ + protected function isFatal(int $type): bool + { + return in_array($type, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]); + } + + /** + * Get an instance of the exception handler. + * + * @access protected + * @return Handle + */ + protected function getExceptionHandler() + { + return $this->app->make(Handle::class); + } +} diff --git a/vendor/topthink/framework/src/think/initializer/RegisterService.php b/vendor/topthink/framework/src/think/initializer/RegisterService.php new file mode 100644 index 0000000..06620fe --- /dev/null +++ b/vendor/topthink/framework/src/think/initializer/RegisterService.php @@ -0,0 +1,48 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\initializer; + +use think\App; +use think\service\ModelService; +use think\service\PaginatorService; +use think\service\ValidateService; + +/** + * 注册系统服务 + */ +class RegisterService +{ + + protected $services = [ + PaginatorService::class, + ValidateService::class, + ModelService::class, + ]; + + public function init(App $app) + { + $file = $app->getRootPath() . 'vendor/services.php'; + + $services = $this->services; + + if (is_file($file)) { + $services = array_merge($services, include $file); + } + + foreach ($services as $service) { + if (class_exists($service)) { + $app->register($service); + } + } + } +} diff --git a/vendor/topthink/framework/src/think/log/Channel.php b/vendor/topthink/framework/src/think/log/Channel.php new file mode 100644 index 0000000..d86813a --- /dev/null +++ b/vendor/topthink/framework/src/think/log/Channel.php @@ -0,0 +1,163 @@ + +// +---------------------------------------------------------------------- +declare(strict_types = 1); + +namespace think\log; + +use Psr\Log\LoggerInterface; +use Psr\Log\LoggerTrait; +use Stringable; +use think\contract\LogHandlerInterface; +use think\Event; +use think\event\LogRecord; +use think\event\LogWrite; + +class Channel implements LoggerInterface +{ + use LoggerTrait; + + /** + * 日志信息 + * @var array + */ + protected $log = []; + + /** + * 关闭日志 + * @var bool + */ + protected $close = false; + + public function __construct(protected string $name, protected LogHandlerInterface $logger, protected array $allow, protected bool $lazy, protected Event $event) + { + } + + /** + * 关闭通道 + */ + public function close(): void + { + $this->clear(); + $this->close = true; + } + + /** + * 清空日志 + */ + public function clear(): void + { + $this->log = []; + } + + /** + * 记录日志信息 + * @access public + * @param mixed $msg 日志信息 + * @param string $type 日志级别 + * @param array $context 替换内容 + * @param bool $lazy + * @return $this + */ + public function record($msg, string $type = 'info', array $context = [], bool $lazy = true) + { + if ($this->close || (!empty($this->allow) && !in_array($type, $this->allow))) { + return $this; + } + + if ($msg instanceof Stringable) { + $msg = $msg->__toString(); + } + + if (is_string($msg) && !empty($context)) { + $replace = []; + foreach ($context as $key => $val) { + $replace['{' . $key . '}'] = $val; + } + + $msg = strtr($msg, $replace); + } + + if (!empty($msg) || 0 === $msg) { + $this->log[$type][] = $msg; + if ($this->event) { + $this->event->trigger(new LogRecord($type, $msg)); + } + } + + if (!$this->lazy || !$lazy) { + $this->save(); + } + + return $this; + } + + /** + * 实时写入日志信息 + * @access public + * @param mixed $msg 调试信息 + * @param string $type 日志级别 + * @param array $context 替换内容 + * @return $this + */ + public function write($msg, string $type = 'info', array $context = []) + { + return $this->record($msg, $type, $context, false); + } + + /** + * 获取日志信息 + * @return array + */ + public function getLog(): array + { + return $this->log; + } + + /** + * 保存日志 + * @return bool + */ + public function save(): bool + { + $log = $this->log; + if ($this->event) { + $event = new LogWrite($this->name, $log); + $this->event->trigger($event); + $log = $event->log; + } + + if ($this->logger->save($log)) { + $this->clear(); + return true; + } + + return false; + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string|Stringable $message + * @param array $context + * + * @return void + */ + public function log($level, $message, array $context = []): void + { + $this->record($message, $level, $context); + } + + public function __call($method, $parameters) + { + $this->log($method, ...$parameters); + } +} diff --git a/vendor/topthink/framework/src/think/log/ChannelSet.php b/vendor/topthink/framework/src/think/log/ChannelSet.php new file mode 100644 index 0000000..a3f7251 --- /dev/null +++ b/vendor/topthink/framework/src/think/log/ChannelSet.php @@ -0,0 +1,34 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\log; + +use think\Log; + +/** + * Class ChannelSet + * @package think\log + * @mixin Channel + */ +class ChannelSet +{ + public function __construct(protected Log $log, protected array $channels) + { + } + + public function __call($method, $arguments) + { + foreach ($this->channels as $channel) { + $this->log->channel($channel)->{$method}(...$arguments); + } + } +} diff --git a/vendor/topthink/framework/src/think/log/driver/File.php b/vendor/topthink/framework/src/think/log/driver/File.php new file mode 100644 index 0000000..26c0f99 --- /dev/null +++ b/vendor/topthink/framework/src/think/log/driver/File.php @@ -0,0 +1,207 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\log\driver; + +use think\App; +use think\contract\LogHandlerInterface; + +/** + * 本地化调试输出到文件 + */ +class File implements LogHandlerInterface +{ + /** + * 配置参数 + * @var array + */ + protected $config = [ + 'time_format' => 'c', + 'single' => false, + 'file_size' => 2097152, + 'path' => '', + 'apart_level' => [], + 'max_files' => 0, + 'json' => false, + 'json_options' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, + 'format' => '[%s][%s] %s', + ]; + + // 实例化并传入参数 + public function __construct(App $app, $config = []) + { + if (is_array($config)) { + $this->config = array_merge($this->config, $config); + } + + if (empty($this->config['format'])) { + $this->config['format'] = '[%s][%s] %s'; + } + + if (empty($this->config['path'])) { + $this->config['path'] = $app->getRuntimePath() . 'log'; + } + + if (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { + $this->config['path'] .= DIRECTORY_SEPARATOR; + } + } + + /** + * 日志写入接口 + * @access public + * @param array $log 日志信息 + * @return bool + */ + public function save(array $log): bool + { + $destination = $this->getMasterLogFile(); + + $path = dirname($destination); + !is_dir($path) && mkdir($path, 0755, true); + + $info = []; + + // 日志信息封装 + $time = \DateTime::createFromFormat('0.u00 U', microtime())->setTimezone(new \DateTimeZone(date_default_timezone_get()))->format($this->config['time_format']); + + foreach ($log as $type => $val) { + $message = []; + foreach ($val as $msg) { + if (!is_string($msg)) { + $msg = var_export($msg, true); + } + + $message[] = $this->config['json'] ? + json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : + sprintf($this->config['format'], $time, $type, $msg); + } + + if (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level'])) { + // 独立记录的日志级别 + $filename = $this->getApartLevelFile($path, $type); + $this->write($message, $filename); + continue; + } + + $info[$type] = $message; + } + + if ($info) { + return $this->write($info, $destination); + } + + return true; + } + + /** + * 日志写入 + * @access protected + * @param array $message 日志信息 + * @param string $destination 日志文件 + * @return bool + */ + protected function write(array $message, string $destination): bool + { + // 检测日志文件大小,超过配置大小则备份日志文件重新生成 + $this->checkLogSize($destination); + + $info = []; + + foreach ($message as $type => $msg) { + $info[$type] = is_array($msg) ? implode(PHP_EOL, $msg) : $msg; + } + + $message = implode(PHP_EOL, $info) . PHP_EOL; + + return error_log($message, 3, $destination); + } + + /** + * 获取主日志文件名 + * @access public + * @return string + */ + protected function getMasterLogFile(): string + { + + if ($this->config['max_files']) { + $files = glob($this->config['path'] . '*.log'); + + try { + if (count($files) > $this->config['max_files']) { + set_error_handler(function ($errno, $errstr, $errfile, $errline) {}); + unlink($files[0]); + restore_error_handler(); + } + } catch (\Exception $e) { + // + } + } + + if ($this->config['single']) { + $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; + $destination = $this->config['path'] . $name . '.log'; + } else { + + if ($this->config['max_files']) { + $filename = date('Ymd') . '.log'; + } else { + $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . '.log'; + } + + $destination = $this->config['path'] . $filename; + } + + return $destination; + } + + /** + * 获取独立日志文件名 + * @access public + * @param string $path 日志目录 + * @param string $type 日志类型 + * @return string + */ + protected function getApartLevelFile(string $path, string $type): string + { + + if ($this->config['single']) { + $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; + + $name .= '_' . $type; + } elseif ($this->config['max_files']) { + $name = date('Ymd') . '_' . $type; + } else { + $name = date('d') . '_' . $type; + } + + return $path . DIRECTORY_SEPARATOR . $name . '.log'; + } + + /** + * 检查日志文件大小并自动生成备份文件 + * @access protected + * @param string $destination 日志文件 + * @return void + */ + protected function checkLogSize(string $destination): void + { + if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { + try { + rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . basename($destination, '.log') . '-' . time() . '.log'); + } catch (\Exception $e) { + // + } + } + } +} diff --git a/vendor/topthink/framework/src/think/log/driver/Socket.php b/vendor/topthink/framework/src/think/log/driver/Socket.php new file mode 100644 index 0000000..427dab6 --- /dev/null +++ b/vendor/topthink/framework/src/think/log/driver/Socket.php @@ -0,0 +1,307 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\log\driver; + +use Psr\Container\NotFoundExceptionInterface; +use think\App; +use think\contract\LogHandlerInterface; + +/** + * github: https://github.com/luofei614/SocketLog + * @author luofei614 + */ +class Socket implements LogHandlerInterface +{ + protected $config = [ + // socket服务器地址 + 'host' => 'localhost', + // socket服务器端口 + 'port' => 1116, + // 是否显示加载的文件列表 + 'show_included_files' => false, + // 日志强制记录到配置的client_id + 'force_client_ids' => [], + // 限制允许读取日志的client_id + 'allow_client_ids' => [], + // 调试开关 + 'debug' => false, + // 输出到浏览器时默认展开的日志级别 + 'expand_level' => ['debug'], + // 日志头渲染回调 + 'format_head' => null, + // curl opt + 'curl_opt' => [ + CURLOPT_CONNECTTIMEOUT => 1, + CURLOPT_TIMEOUT => 10, + ], + ]; + + protected $css = [ + 'sql' => 'color:#009bb4;', + 'sql_warn' => 'color:#009bb4;font-size:14px;', + 'error' => 'color:#f4006b;font-size:14px;', + 'page' => 'color:#40e2ff;background:#171717;', + 'big' => 'font-size:20px;color:red;', + ]; + + protected $allowForceClientIds = []; //配置强制推送且被授权的client_id + + protected $clientArg = []; + + /** + * 架构函数 + * @access public + * @param App $app + * @param array $config 缓存参数 + */ + public function __construct(protected App $app, array $config = []) + { + if (!empty($config)) { + $this->config = array_merge($this->config, $config); + } + + if (!isset($config['debug'])) { + $this->config['debug'] = $app->isDebug(); + } + } + + /** + * 调试输出接口 + * @access public + * @param array $log 日志信息 + * @return bool + */ + public function save(array $log = []): bool + { + if (!$this->check()) { + return false; + } + + $trace = []; + + if ($this->config['debug']) { + if ($this->app->exists('request')) { + $currentUri = $this->app->request->url(true); + } else { + $currentUri = 'cmd:' . implode(' ', $_SERVER['argv'] ?? []); + } + + if (!empty($this->config['format_head'])) { + try { + $currentUri = $this->app->invoke($this->config['format_head'], [$currentUri]); + } catch (NotFoundExceptionInterface $notFoundException) { + // Ignore exception + } + } + + // 基本信息 + $trace[] = [ + 'type' => 'group', + 'msg' => $currentUri, + 'css' => $this->css['page'], + ]; + } + + $expandLevel = array_flip($this->config['expand_level']); + + foreach ($log as $type => $val) { + $trace[] = [ + 'type' => isset($expandLevel[$type]) ? 'group' : 'groupCollapsed', + 'msg' => '[ ' . $type . ' ]', + 'css' => $this->css[$type] ?? '', + ]; + + foreach ($val as $msg) { + if (!is_string($msg)) { + $msg = var_export($msg, true); + } + $trace[] = [ + 'type' => 'log', + 'msg' => $msg, + 'css' => '', + ]; + } + + $trace[] = [ + 'type' => 'groupEnd', + 'msg' => '', + 'css' => '', + ]; + } + + if ($this->config['show_included_files']) { + $trace[] = [ + 'type' => 'groupCollapsed', + 'msg' => '[ file ]', + 'css' => '', + ]; + + $trace[] = [ + 'type' => 'log', + 'msg' => implode("\n", get_included_files()), + 'css' => '', + ]; + + $trace[] = [ + 'type' => 'groupEnd', + 'msg' => '', + 'css' => '', + ]; + } + + $trace[] = [ + 'type' => 'groupEnd', + 'msg' => '', + 'css' => '', + ]; + + $tabid = $this->getClientArg('tabid'); + + if (!$clientId = $this->getClientArg('client_id')) { + $clientId = ''; + } + + if (!empty($this->allowForceClientIds)) { + //强制推送到多个client_id + foreach ($this->allowForceClientIds as $forceClientId) { + $clientId = $forceClientId; + $this->sendToClient($tabid, $clientId, $trace, $forceClientId); + } + } else { + $this->sendToClient($tabid, $clientId, $trace, ''); + } + + return true; + } + + /** + * 发送给指定客户端 + * @access protected + * @author Zjmainstay + * @param $tabid + * @param $clientId + * @param $logs + * @param $forceClientId + */ + protected function sendToClient($tabid, $clientId, $logs, $forceClientId) + { + $logs = [ + 'tabid' => $tabid, + 'client_id' => $clientId, + 'logs' => $logs, + 'force_client_id' => $forceClientId, + ]; + + $msg = json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR); + $address = '/' . $clientId; //将client_id作为地址, server端通过地址判断将日志发布给谁 + + $this->send($this->config['host'], $this->config['port'], $msg, $address); + } + + /** + * 检测客户授权 + * @access protected + * @return bool + */ + protected function check() + { + $tabid = $this->getClientArg('tabid'); + + //是否记录日志的检查 + if (!$tabid && !$this->config['force_client_ids']) { + return false; + } + + //用户认证 + $allowClientIds = $this->config['allow_client_ids']; + + if (!empty($allowClientIds)) { + //通过数组交集得出授权强制推送的client_id + $this->allowForceClientIds = array_intersect($allowClientIds, $this->config['force_client_ids']); + if (!$tabid && count($this->allowForceClientIds)) { + return true; + } + + $clientId = $this->getClientArg('client_id'); + if (!in_array($clientId, $allowClientIds)) { + return false; + } + } else { + $this->allowForceClientIds = $this->config['force_client_ids']; + } + + return true; + } + + /** + * 获取客户参数 + * @access protected + * @param string $name + * @return string + */ + protected function getClientArg(string $name) + { + if (!$this->app->exists('request')) { + return ''; + } + + if (empty($this->clientArg)) { + if (empty($socketLog = $this->app->request->header('socketlog'))) { + if (empty($socketLog = $this->app->request->header('User-Agent'))) { + return ''; + } + } + + if (!preg_match('/SocketLog\((.*?)\)/', $socketLog, $match)) { + $this->clientArg = ['tabid' => null, 'client_id' => null]; + return ''; + } + parse_str($match[1] ?? '', $this->clientArg); + } + + if (isset($this->clientArg[$name])) { + return $this->clientArg[$name]; + } + + return ''; + } + + /** + * @access protected + * @param string $host - $host of socket server + * @param int $port - $port of socket server + * @param string $message - 发送的消息 + * @param string $address - 地址 + * @return bool + */ + protected function send($host, $port, $message = '', $address = '/') + { + $url = 'http://' . $host . ':' . $port . $address; + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $message); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->config['curl_opt'][CURLOPT_CONNECTTIMEOUT] ?? 1); + curl_setopt($ch, CURLOPT_TIMEOUT, $this->config['curl_opt'][CURLOPT_TIMEOUT] ?? 10); + + $headers = [ + "Content-Type: application/json;charset=UTF-8", + ]; + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //设置header + + return curl_exec($ch); + } +} diff --git a/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php b/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php new file mode 100644 index 0000000..ea50f86 --- /dev/null +++ b/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php @@ -0,0 +1,63 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\middleware; + +use Closure; +use think\Config; +use think\Request; +use think\Response; + +/** + * 跨域请求支持 + */ +class AllowCrossDomain +{ + protected $cookieDomain; + + protected $header = [ + 'Access-Control-Allow-Credentials' => 'true', + 'Access-Control-Max-Age' => 1800, + 'Access-Control-Allow-Methods' => 'GET, POST, PATCH, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With', + ]; + + public function __construct(Config $config) + { + $this->cookieDomain = $config->get('cookie.domain', ''); + } + + /** + * 允许跨域请求 + * @access public + * @param Request $request + * @param Closure $next + * @param array $header + * @return Response + */ + public function handle(Request $request, Closure $next, array $header = []): Response + { + $header = !empty($header) ? array_merge($this->header, $header) : $this->header; + + if (!isset($header['Access-Control-Allow-Origin'])) { + $origin = $request->header('origin'); + + if ($origin && ('' == $this->cookieDomain || str_contains($origin, $this->cookieDomain))) { + $header['Access-Control-Allow-Origin'] = $origin; + } else { + $header['Access-Control-Allow-Origin'] = '*'; + } + } + + return $next($request)->header($header); + } +} diff --git a/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php b/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php new file mode 100644 index 0000000..b771e9d --- /dev/null +++ b/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php @@ -0,0 +1,183 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\middleware; + +use Closure; +use think\Cache; +use think\Config; +use think\Request; +use think\Response; + +/** + * 请求缓存处理 + */ +class CheckRequestCache +{ + /** + * 缓存对象 + * @var Cache + */ + protected $cache; + + /** + * 配置参数 + * @var array + */ + protected $config = [ + // 请求缓存规则 true为自动规则 + 'request_cache_key' => true, + // 请求缓存有效期 + 'request_cache_expire' => null, + // 全局请求缓存排除规则 + 'request_cache_except' => [], + // 请求缓存的Tag + 'request_cache_tag' => '', + ]; + + public function __construct(Cache $cache, Config $config) + { + $this->cache = $cache; + $this->config = array_merge($this->config, $config->get('route')); + } + + /** + * 设置当前地址的请求缓存 + * @access public + * @param Request $request + * @param Closure $next + * @param mixed $cache + * @return Response + */ + public function handle(Request $request, Closure $next, $cache = null): Response + { + if ($request->isGet() && false !== $cache) { + if (false === $this->config['request_cache_key']) { + // 关闭当前缓存 + $cache = false; + } + + $cache = $cache ?? $this->getRequestCache($request); + + if ($cache) { + if (is_array($cache)) { + [$key, $expire, $tag] = array_pad($cache, 3, ''); + } else { + $key = md5($request->url(true)); + $expire = $cache; + $tag = ''; + } + + $key = $this->parseCacheKey($request, $key); + + if (strtotime($request->server('HTTP_IF_MODIFIED_SINCE', '')) + $expire > $request->server('REQUEST_TIME')) { + // 读取缓存 + return Response::create()->code(304); + } elseif (($hit = $this->cache->get($key)) !== null) { + [$content, $header, $when] = $hit; + if (null === $expire || $when + $expire > $request->server('REQUEST_TIME')) { + return Response::create($content)->header($header); + } + } + } + } + + $response = $next($request); + + if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) { + $header = $response->getHeader(); + $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate'; + $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; + $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; + + $this->cache->tag($tag)->set($key, [$response->getContent(), $header, time()], $expire); + } + + return $response; + } + + /** + * 读取当前地址的请求缓存信息 + * @access protected + * @param Request $request + * @return mixed + */ + protected function getRequestCache($request) + { + $key = $this->config['request_cache_key']; + $expire = $this->config['request_cache_expire']; + $except = $this->config['request_cache_except']; + $tag = $this->config['request_cache_tag']; + + foreach ($except as $rule) { + if (0 === stripos($request->url(), $rule)) { + return; + } + } + + return [$key, $expire, $tag]; + } + + /** + * 读取当前地址的请求缓存信息 + * @access protected + * @param Request $request + * @param mixed $key + * @return null|string + */ + protected function parseCacheKey($request, $key) + { + if ($key instanceof Closure) { + $key = call_user_func($key, $request); + } + + if (false === $key) { + // 关闭当前缓存 + return; + } + + if (true === $key) { + // 自动缓存功能 + $key = '__URL__'; + } elseif (str_contains($key, '|')) { + [$key, $fun] = explode('|', $key); + } + + // 特殊规则替换 + if (str_contains($key, '__')) { + $key = str_replace(['__CONTROLLER__', '__ACTION__', '__URL__'], [$request->controller(), $request->action(), md5($request->url(true))], $key); + } + + if (str_contains($key, ':')) { + $param = $request->param(); + + foreach ($param as $item => $val) { + if (is_string($val) && str_contains($key, ':' . $item)) { + $key = str_replace(':' . $item, (string) $val, $key); + } + } + } elseif (str_contains($key, ']')) { + if ('[' . $request->ext() . ']' == $key) { + // 缓存某个后缀的请求 + $key = md5($request->url()); + } else { + return; + } + } + + if (isset($fun)) { + $key = $fun($key); + } + + return $key; + } +} diff --git a/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php b/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php new file mode 100644 index 0000000..c32ee41 --- /dev/null +++ b/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php @@ -0,0 +1,44 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\middleware; + +use Closure; +use think\exception\ValidateException; +use think\Request; +use think\Response; + +/** + * 表单令牌支持 + */ +class FormTokenCheck +{ + + /** + * 表单令牌检测 + * @access public + * @param Request $request + * @param Closure $next + * @param string $token 表单令牌Token名称 + * @return Response + */ + public function handle(Request $request, Closure $next, ?string $token = null): Response + { + $check = $request->checkToken($token ?: '__token__'); + + if (false === $check) { + throw new ValidateException('invalid token'); + } + + return $next($request); + } +} diff --git a/vendor/topthink/framework/src/think/middleware/LoadLangPack.php b/vendor/topthink/framework/src/think/middleware/LoadLangPack.php new file mode 100644 index 0000000..16b14dc --- /dev/null +++ b/vendor/topthink/framework/src/think/middleware/LoadLangPack.php @@ -0,0 +1,113 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\middleware; + +use Closure; +use think\App; +use think\Config; +use think\Cookie; +use think\Lang; +use think\Request; +use think\Response; + +/** + * 多语言加载 + */ +class LoadLangPack +{ + protected $config; + + public function __construct(protected App $app, protected Lang $lang, Config $config) + { + $this->config = $lang->getConfig(); + } + + /** + * 路由初始化(路由规则注册) + * @access public + * @param Request $request + * @param Closure $next + * @return Response + */ + public function handle(Request $request, Closure $next): Response + { + // 自动侦测当前语言 + $langset = $this->detect($request); + + if ($this->lang->defaultLangSet() != $langset) { + $this->lang->switchLangSet($langset); + } + + $this->saveToCookie($this->app->cookie, $langset); + + return $next($request); + } + + /** + * 自动侦测设置获取语言选择 + * @access protected + * @param Request $request + * @return string + */ + protected function detect(Request $request): string + { + // 自动侦测设置获取语言选择 + $langSet = ''; + + if ($request->get($this->config['detect_var'])) { + // url中设置了语言变量 + $langSet = $request->get($this->config['detect_var']); + } elseif ($request->header($this->config['header_var'])) { + // Header中设置了语言变量 + $langSet = $request->header($this->config['header_var']); + } elseif ($request->cookie($this->config['cookie_var'])) { + // Cookie中设置了语言变量 + $langSet = $request->cookie($this->config['cookie_var']); + } elseif ($this->config['auto_detect_browser'] && $request->server('HTTP_ACCEPT_LANGUAGE')) { + // 自动侦测浏览器语言 + $langSet = $request->server('HTTP_ACCEPT_LANGUAGE'); + } + + if (preg_match('/^([a-z\d\-]+)/i', $langSet, $matches)) { + $langSet = strtolower($matches[1]); + if (isset($this->config['accept_language'][$langSet])) { + $langSet = $this->config['accept_language'][$langSet]; + } + } else { + $langSet = $this->lang->getLangSet(); + } + + if (empty($this->config['allow_lang_list']) || in_array($langSet, $this->config['allow_lang_list'])) { + // 合法的语言 + $this->lang->setLangSet($langSet); + } else { + $langSet = $this->lang->getLangSet(); + } + + return $langSet; + } + + /** + * 保存当前语言到Cookie + * @access protected + * @param Cookie $cookie Cookie对象 + * @param string $langSet 语言 + * @return void + */ + protected function saveToCookie(Cookie $cookie, string $langSet): void + { + if ($this->config['use_cookie']) { + $cookie->set($this->config['cookie_var'], $langSet); + } + } +} diff --git a/vendor/topthink/framework/src/think/middleware/SessionInit.php b/vendor/topthink/framework/src/think/middleware/SessionInit.php new file mode 100644 index 0000000..500cc19 --- /dev/null +++ b/vendor/topthink/framework/src/think/middleware/SessionInit.php @@ -0,0 +1,71 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\middleware; + +use Closure; +use think\App; +use think\Request; +use think\Response; +use think\Session; + +/** + * Session初始化 + */ +class SessionInit +{ + public function __construct(protected App $app, protected Session $session) + { + } + + /** + * Session初始化 + * @access public + * @param Request $request + * @param Closure $next + * @return Response + */ + public function handle(Request $request, Closure $next): Response + { + // Session初始化 + $varSessionId = $this->app->config->get('session.var_session_id'); + $cookieName = $this->session->getName(); + + if ($varSessionId && $request->request($varSessionId)) { + $sessionId = $request->request($varSessionId); + } else { + $sessionId = $request->cookie($cookieName); + } + + if ($sessionId) { + $this->session->setId($sessionId); + } + + $this->session->init(); + + $request->withSession($this->session); + + /** @var Response $response */ + $response = $next($request); + + $response->setSession($this->session); + + $this->app->cookie->set($cookieName, $this->session->getId(), $this->session->getConfig('expire')); + + return $response; + } + + public function end(Response $response): void + { + $this->session->save(); + } +} diff --git a/vendor/topthink/framework/src/think/response/File.php b/vendor/topthink/framework/src/think/response/File.php new file mode 100644 index 0000000..85d5134 --- /dev/null +++ b/vendor/topthink/framework/src/think/response/File.php @@ -0,0 +1,161 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Exception; +use think\Response; + +/** + * File Response + */ +class File extends Response +{ + protected $expire = 360; + protected $name; + protected $mimeType; + protected $isContent = false; + protected $force = true; + + public function __construct($data = '', int $code = 200) + { + $this->init($data, $code); + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + * @throws \Exception + */ + protected function output($data) + { + if (!$this->isContent && !is_file($data)) { + throw new Exception('file not exists:' . $data); + } + + while (ob_get_level() > 0) { + ob_end_clean(); + } + + if (!empty($this->name)) { + $name = $this->name; + } else { + $name = !$this->isContent ? pathinfo($data, PATHINFO_BASENAME) : ''; + } + $name = urlencode($name); // 支持中文名称 + + if ($this->isContent) { + $mimeType = $this->mimeType; + $size = strlen($data); + } else { + $mimeType = $this->getMimeType($data); + $size = filesize($data); + } + + $this->header['Pragma'] = 'public'; + $this->header['Content-Type'] = $mimeType ?: 'application/octet-stream'; + $this->header['Cache-control'] = 'max-age=' . $this->expire; + $this->header['Content-Disposition'] = ($this->force ? 'attachment; ' : '') . 'filename="' . $name . '";' . "filename* = UTF-8''{$name}"; + $this->header['Content-Length'] = $size; + $this->header['Content-Transfer-Encoding'] = 'binary'; + $this->header['Expires'] = gmdate("D, d M Y H:i:s", time() + $this->expire) . ' GMT'; + + $this->lastModified(gmdate('D, d M Y H:i:s', time()) . ' GMT'); + + return $this->isContent ? $data : file_get_contents($data); + } + + /** + * 设置是否为内容 必须配合mimeType方法使用 + * @access public + * @param bool $content + * @return $this + */ + public function isContent(bool $content = true) + { + $this->isContent = $content; + return $this; + } + + /** + * 设置有效期 + * @access public + * @param integer $expire 有效期 + * @return $this + */ + public function expire(int $expire) + { + $this->expire = $expire; + return $this; + } + + /** + * 设置文件类型 + * @access public + * @param string $filename 文件名 + * @return $this + */ + public function mimeType(string $mimeType) + { + $this->mimeType = $mimeType; + return $this; + } + + /** + * 设置文件强制下载 + * @access public + * @param bool $force 强制浏览器下载 + * @return $this + */ + public function force(bool $force) + { + $this->force = $force; + return $this; + } + + /** + * 获取文件类型信息 + * @access public + * @param string $filename 文件名 + * @return string + */ + protected function getMimeType(string $filename): string + { + if (!empty($this->mimeType)) { + return $this->mimeType; + } + + $finfo = finfo_open(FILEINFO_MIME_TYPE); + + return finfo_file($finfo, $filename); + } + + /** + * 设置下载文件的显示名称 + * @access public + * @param string $filename 文件名 + * @param bool $extension 后缀自动识别 + * @return $this + */ + public function name(string $filename, bool $extension = true) + { + $this->name = $filename; + + if ($extension && !str_contains($filename, '.')) { + $this->name .= '.' . pathinfo($this->data, PATHINFO_EXTENSION); + } + + return $this; + } +} diff --git a/vendor/topthink/framework/src/think/response/Html.php b/vendor/topthink/framework/src/think/response/Html.php new file mode 100644 index 0000000..291be20 --- /dev/null +++ b/vendor/topthink/framework/src/think/response/Html.php @@ -0,0 +1,34 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Cookie; +use think\Response; + +/** + * Html Response + */ +class Html extends Response +{ + /** + * 输出type + * @var string + */ + protected $contentType = 'text/html'; + + public function __construct(Cookie $cookie, $data = '', int $code = 200) + { + $this->init($data, $code); + $this->cookie = $cookie; + } +} diff --git a/vendor/topthink/framework/src/think/response/Json.php b/vendor/topthink/framework/src/think/response/Json.php new file mode 100644 index 0000000..ed245aa --- /dev/null +++ b/vendor/topthink/framework/src/think/response/Json.php @@ -0,0 +1,61 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Cookie; +use think\Response; + +/** + * Json Response + */ +class Json extends Response +{ + // 输出参数 + protected $options = [ + 'json_encode_param' => JSON_UNESCAPED_UNICODE, + ]; + + protected $contentType = 'application/json'; + + public function __construct(Cookie $cookie, $data = '', int $code = 200) + { + $this->init($data, $code); + $this->cookie = $cookie; + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return string + * @throws \Exception + */ + protected function output($data): string + { + try { + // 返回JSON数据格式到客户端 包含状态信息 + $data = json_encode($data, $this->options['json_encode_param']); + + if (false === $data) { + throw new \InvalidArgumentException(json_last_error_msg()); + } + + return $data; + } catch (\Exception $e) { + if ($e->getPrevious()) { + throw $e->getPrevious(); + } + throw $e; + } + } +} diff --git a/vendor/topthink/framework/src/think/response/Jsonp.php b/vendor/topthink/framework/src/think/response/Jsonp.php new file mode 100644 index 0000000..9762998 --- /dev/null +++ b/vendor/topthink/framework/src/think/response/Jsonp.php @@ -0,0 +1,73 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Cookie; +use think\Request; +use think\Response; + +/** + * Jsonp Response + */ +class Jsonp extends Response +{ + // 输出参数 + protected $options = [ + 'var_jsonp_handler' => 'callback', + 'default_jsonp_handler' => 'jsonpReturn', + 'json_encode_param' => JSON_UNESCAPED_UNICODE, + ]; + + protected $contentType = 'application/javascript'; + + protected $request; + + public function __construct(Cookie $cookie, Request $request, $data = '', int $code = 200) + { + $this->init($data, $code); + + $this->cookie = $cookie; + $this->request = $request; + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return string + * @throws \Exception + */ + protected function output($data): string + { + try { + // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取] + $varJsonpHandler = $this->request->param($this->options['var_jsonp_handler'], ""); + $handler = !empty($varJsonpHandler) ? $varJsonpHandler : $this->options['default_jsonp_handler']; + + $data = json_encode($data, $this->options['json_encode_param']); + + if (false === $data) { + throw new \InvalidArgumentException(json_last_error_msg()); + } + + $data = $handler . '(' . $data . ');'; + + return $data; + } catch (\Exception $e) { + if ($e->getPrevious()) { + throw $e->getPrevious(); + } + throw $e; + } + } +} diff --git a/vendor/topthink/framework/src/think/response/Redirect.php b/vendor/topthink/framework/src/think/response/Redirect.php new file mode 100644 index 0000000..b23020a --- /dev/null +++ b/vendor/topthink/framework/src/think/response/Redirect.php @@ -0,0 +1,102 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Cookie; +use think\Request; +use think\Response; +use think\Session; + +/** + * Redirect Response + */ +class Redirect extends Response +{ + + protected $request; + + public function __construct(Cookie $cookie, Request $request, Session $session, $data = '', int $code = 302) + { + $this->init((string) $data, $code); + + $this->cookie = $cookie; + $this->request = $request; + $this->session = $session; + + $this->cacheControl('no-cache,must-revalidate'); + } + + public function data($data) + { + $this->header['Location'] = $data; + return parent::data($data); + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return string + */ + protected function output($data): string + { + return ''; + } + + /** + * 重定向传值(通过Session) + * @access protected + * @param string|array $name 变量名或者数组 + * @param mixed $value 值 + * @return $this + */ + public function with($name, $value = null) + { + if (is_array($name)) { + foreach ($name as $key => $val) { + $this->session->flash($key, $val); + } + } else { + $this->session->flash($name, $value); + } + + return $this; + } + + /** + * 记住当前url后跳转 + * @access public + * @return $this + */ + public function remember($complete = false) + { + $this->session->set('redirect_url', $this->request->url($complete)); + + return $this; + } + + /** + * 跳转到上次记住的url + * @access public + * @return $this + */ + public function restore() + { + if ($this->session->has('redirect_url')) { + $this->data($this->session->get('redirect_url')); + $this->session->delete('redirect_url'); + } + + return $this; + } +} diff --git a/vendor/topthink/framework/src/think/response/View.php b/vendor/topthink/framework/src/think/response/View.php new file mode 100644 index 0000000..8102ced --- /dev/null +++ b/vendor/topthink/framework/src/think/response/View.php @@ -0,0 +1,150 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Cookie; +use think\Response; +use think\View as BaseView; + +/** + * View Response + */ +class View extends Response +{ + /** + * 输出参数 + * @var array + */ + protected $options = []; + + /** + * 输出变量 + * @var array + */ + protected $vars = []; + + /** + * 输出过滤 + * @var mixed + */ + protected $filter; + + /** + * 输出type + * @var string + */ + protected $contentType = 'text/html'; + + /** + * View对象 + * @var BaseView + */ + protected $view; + + /** + * 是否内容渲染 + * @var bool + */ + protected $isContent = false; + + public function __construct(Cookie $cookie, BaseView $view, $data = '', int $code = 200) + { + $this->init($data, $code); + + $this->cookie = $cookie; + $this->view = $view; + } + + /** + * 设置是否为内容渲染 + * @access public + * @param bool $content + * @return $this + */ + public function isContent(bool $content = true) + { + $this->isContent = $content; + return $this; + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return string + */ + protected function output($data): string + { + // 渲染模板输出 + $this->view->filter($this->filter); + return $this->isContent ? + $this->view->display($data, $this->vars) : + $this->view->fetch($data, $this->vars); + } + + /** + * 获取视图变量 + * @access public + * @param string $name 模板变量 + * @return mixed + */ + public function getVars(?string $name = null) + { + if (is_null($name)) { + return $this->vars; + } else { + return $this->vars[$name] ?? null; + } + } + + /** + * 模板变量赋值 + * @access public + * @param string|array $name 模板变量 + * @param mixed $value 变量值 + * @return $this + */ + public function assign(string|array $name, $value = null) + { + if (is_array($name)) { + $this->vars = array_merge($this->vars, $name); + } else { + $this->vars[$name] = $value; + } + + return $this; + } + + /** + * 视图内容过滤 + * @access public + * @param callable $filter + * @return $this + */ + public function filter(?callable $filter = null) + { + $this->filter = $filter; + return $this; + } + + /** + * 检查模板是否存在 + * @access public + * @param string $name 模板名 + * @return bool + */ + public function exists(string $name): bool + { + return $this->view->exists($name); + } +} diff --git a/vendor/topthink/framework/src/think/response/Xml.php b/vendor/topthink/framework/src/think/response/Xml.php new file mode 100644 index 0000000..168fecf --- /dev/null +++ b/vendor/topthink/framework/src/think/response/Xml.php @@ -0,0 +1,127 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\response; + +use think\Collection; +use think\Cookie; +use think\Model; +use think\Response; + +/** + * XML Response + */ +class Xml extends Response +{ + // 输出参数 + protected $options = [ + // 根节点名 + 'root_node' => 'think', + // 根节点属性 + 'root_attr' => '', + //数字索引的子节点名 + 'item_node' => 'item', + // 数字索引子节点key转换的属性名 + 'item_key' => 'id', + // 数据编码 + 'encoding' => 'utf-8', + ]; + + protected $contentType = 'text/xml'; + + public function __construct(Cookie $cookie, $data = '', int $code = 200) + { + $this->init($data, $code); + $this->cookie = $cookie; + } + + /** + * 处理数据 + * @access protected + * @param mixed $data 要处理的数据 + * @return mixed + */ + protected function output($data): string + { + if (is_string($data)) { + if (!str_starts_with($data, 'options['encoding']; + $xml = ""; + $data = $xml . $data; + } + return $data; + } + + // XML数据转换 + return $this->xmlEncode($data, $this->options['root_node'], $this->options['item_node'], $this->options['root_attr'], $this->options['item_key'], $this->options['encoding']); + } + + /** + * XML编码 + * @access protected + * @param mixed $data 数据 + * @param string $root 根节点名 + * @param string $item 数字索引的子节点名 + * @param mixed $attr 根节点属性 + * @param string $id 数字索引子节点key转换的属性名 + * @param string $encoding 数据编码 + * @return string + */ + protected function xmlEncode($data, string $root, string $item, $attr, string $id, string $encoding): string + { + if (is_array($attr)) { + $array = []; + foreach ($attr as $key => $value) { + $array[] = "{$key}=\"{$value}\""; + } + $attr = implode(' ', $array); + } + + $attr = trim($attr); + $attr = empty($attr) ? '' : " {$attr}"; + $xml = ""; + $xml .= "<{$root}{$attr}>"; + $xml .= $this->dataToXml($data, $item, $id); + $xml .= ""; + + return $xml; + } + + /** + * 数据XML编码 + * @access protected + * @param mixed $data 数据 + * @param string $item 数字索引时的节点名称 + * @param string $id 数字索引key转换为的属性名 + * @return string + */ + protected function dataToXml($data, string $item, string $id): string + { + $xml = $attr = ''; + + if ($data instanceof Collection || $data instanceof Model) { + $data = $data->toArray(); + } + + foreach ($data as $key => $val) { + if (is_numeric($key)) { + $id && $attr = " {$id}=\"{$key}\""; + $key = $item; + } + $xml .= "<{$key}{$attr}>"; + $xml .= (is_array($val) || is_object($val)) ? $this->dataToXml($val, $item, $id) : $val; + $xml .= ""; + } + + return $xml; + } +} diff --git a/vendor/topthink/framework/src/think/route/Dispatch.php b/vendor/topthink/framework/src/think/route/Dispatch.php new file mode 100644 index 0000000..ab56bc9 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/Dispatch.php @@ -0,0 +1,348 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +use Psr\Http\Message\ResponseInterface; +use ReflectionClass; +use ReflectionException; +use ReflectionMethod; +use think\App; +use think\Container; +use think\exception\HttpException; +use think\Request; +use think\Response; +use think\Validate; + +/** + * 路由调度基础类 + */ +abstract class Dispatch +{ + /** + * 应用对象 + * @var App + */ + protected $app; + + public function __construct(protected Request $request, protected Rule $rule, protected $dispatch, protected array $param = [], protected array $option = []) + { + } + + public function init(App $app) + { + $this->app = $app; + + // 执行路由后置操作 + $this->doRouteAfter(); + } + + /** + * 执行路由调度 + * @access public + * @return Response + */ + public function run(): Response + { + $data = $this->exec(); + return $this->autoResponse($data); + } + + protected function autoResponse($data): Response + { + if ($data instanceof Response) { + $response = $data; + } elseif ($data instanceof ResponseInterface) { + $response = Response::create((string) $data->getBody(), 'html', $data->getStatusCode()); + + foreach ($data->getHeaders() as $header => $values) { + $response->header([$header => implode(", ", $values)]); + } + } elseif (!is_null($data)) { + // 默认自动识别响应输出类型 + $type = $this->request->isJson() ? 'json' : 'html'; + $response = Response::create($data, $type); + } else { + $data = ob_get_clean(); + + $content = false === $data ? '' : $data; + $status = '' === $content && $this->request->isJson() ? 204 : 200; + $response = Response::create($content, 'html', $status); + } + + return $response; + } + + /** + * 检查路由后置操作 + * @access protected + * @return void + */ + protected function doRouteAfter(): void + { + $option = $this->option; + + // 添加中间件 + if (!empty($option['middleware'])) { + if (isset($option['without_middleware'])) { + $middleware = !empty($option['without_middleware']) ? array_diff($option['middleware'], $option['without_middleware']) : []; + } else { + $middleware = $option['middleware']; + } + $this->app->middleware->import($middleware, 'route'); + } + + if (!empty($option['append'])) { + $this->param = array_merge($this->param, $option['append']); + } + + // 绑定模型数据 + if (!empty($option['model'])) { + $this->createBindModel($option['model'], $this->param); + } + + // 记录当前请求的路由规则 + $this->request->setRule($this->rule); + + // 记录路由变量 + $this->request->setRoute($this->param); + + // 数据自动验证 + if (isset($option['validate'])) { + $this->autoValidate($option['validate']); + } + } + + /** + * 获取操作的绑定参数 + * @access protected + * @return array + */ + protected function getActionBindVars(): array + { + $bind = $this->rule->config('action_bind_param'); + return match ($bind) { + 'route' => $this->param, + 'param' => $this->request->param(), + default => array_merge($this->request->get(), $this->param), + }; + } + + /** + * 执行中间件调度 + * @access public + * @param object $controller 控制器实例 + * @return void + */ + protected function responseWithMiddlewarePipeline($instance, $action) + { + // 注册控制器中间件 + $this->registerControllerMiddleware($instance); + return $this->app->middleware->pipeline('controller') + ->send($this->request) + ->then(function () use ($instance, $action) { + // 获取当前操作名 + $suffix = $this->rule->config('action_suffix'); + $action = $action . $suffix; + + if (is_callable([$instance, $action])) { + $vars = $this->getActionBindVars(); + try { + $reflect = new ReflectionMethod($instance, $action); + // 严格获取当前操作方法名 + $actionName = $reflect->getName(); + if ($suffix) { + $actionName = substr($actionName, 0, -strlen($suffix)); + } + + $this->request->setAction($actionName); + } catch (ReflectionException $e) { + $reflect = new ReflectionMethod($instance, '__call'); + $vars = [$action, $vars]; + $this->request->setAction($action); + } + } else { + // 操作不存在 + throw new HttpException(404, 'method not exists:' . $instance::class . '->' . $action . '()'); + } + + $data = $this->app->invokeReflectMethod($instance, $reflect, $vars); + + return $this->autoResponse($data); + }); + } + + /** + * 使用反射机制注册控制器中间件 + * @access public + * @param object $controller 控制器实例 + * @return void + */ + protected function registerControllerMiddleware($controller): void + { + $class = new ReflectionClass($controller); + + if ($class->hasProperty('middleware')) { + $reflectionProperty = $class->getProperty('middleware'); + $reflectionProperty->setAccessible(true); + + $middlewares = $reflectionProperty->getValue($controller); + $action = $this->request->action(true); + + foreach ($middlewares as $key => $val) { + if (!is_int($key)) { + $middleware = $key; + $options = $val; + } elseif (isset($val['middleware'])) { + $middleware = $val['middleware']; + $options = $val['options'] ?? []; + } else { + $middleware = $val; + $options = []; + } + + if (isset($options['only']) && !in_array($action, $this->parseActions($options['only']))) { + continue; + } elseif (isset($options['except']) && in_array($action, $this->parseActions($options['except']))) { + continue; + } + + if (is_string($middleware) && str_contains($middleware, ':')) { + $middleware = explode(':', $middleware); + if (count($middleware) > 1) { + $middleware = [$middleware[0], array_slice($middleware, 1)]; + } + } + + $this->app->middleware->controller($middleware); + } + } + } + + protected function parseActions($actions) + { + return array_map(function ($item) { + return strtolower($item); + }, is_string($actions) ? explode(',', $actions) : $actions); + } + + /** + * 路由绑定模型实例 + * @access protected + * @param array $bindModel 绑定模型 + * @param array $matches 路由变量 + * @return void + */ + protected function createBindModel(array $bindModel, array $matches): void + { + foreach ($bindModel as $key => $val) { + if ($val instanceof \Closure) { + $result = $this->app->invokeFunction($val, $matches); + } else { + $fields = explode('&', $key); + + if (is_array($val)) { + [$model, $exception] = $val; + } else { + $model = $val; + $exception = true; + } + + $where = []; + $match = true; + + foreach ($fields as $field) { + if (!isset($matches[$field])) { + $match = false; + break; + } else { + $where[] = [$field, '=', $matches[$field]]; + } + } + + if ($match) { + $result = $model::where($where)->failException($exception)->find(); + } + } + + if (!empty($result)) { + // 注入容器 + $this->app->instance($result::class, $result); + } + } + } + + /** + * 验证数据 + * @access protected + * @param array $option + * @return void + * @throws \think\exception\ValidateException + */ + protected function autoValidate(array $option): void + { + [$validate, $scene, $message, $batch] = $option; + + if (is_array($validate)) { + // 指定验证规则 + $v = new Validate(); + $v->rule($validate); + } else { + // 调用验证器 + $class = str_contains($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); + + $v = new $class(); + + if (!empty($scene)) { + $v->scene($scene); + } + } + + /** @var Validate $v */ + $v->message($message) + ->batch($batch) + ->failException(true) + ->check($this->request->param()); + } + + public function getDispatch() + { + return $this->dispatch; + } + + public function getParam(): array + { + return $this->param; + } + + abstract public function exec(); + + public function __sleep() + { + return ['rule', 'dispatch', 'param', 'controller', 'actionName']; + } + + public function __wakeup() + { + $this->app = Container::pull('app'); + $this->request = $this->app->request; + } + + public function __debugInfo() + { + return [ + 'dispatch' => $this->dispatch, + 'param' => $this->param, + 'rule' => $this->rule, + ]; + } +} diff --git a/vendor/topthink/framework/src/think/route/Domain.php b/vendor/topthink/framework/src/think/route/Domain.php new file mode 100644 index 0000000..3fb7818 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/Domain.php @@ -0,0 +1,41 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +use think\Route; + +/** + * 域名路由 + */ +class Domain extends RuleGroup +{ + /** + * 架构函数 + * @access public + * @param Route $router 路由对象 + * @param string $name 路由域名 + * @param mixed $rule 域名路由 + * @param bool $lazy 延迟解析 + */ + public function __construct(Route $router, ?string $name = null, $rule = null, bool $lazy = false) + { + $this->router = $router; + $this->domain = $name; + $this->rule = $rule; + + if (!$lazy && !is_null($rule)) { + $this->parseGroupRule($rule); + } + } + +} diff --git a/vendor/topthink/framework/src/think/route/Resource.php b/vendor/topthink/framework/src/think/route/Resource.php new file mode 100644 index 0000000..fe1a473 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/Resource.php @@ -0,0 +1,263 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +use Closure; +use think\Container; +use think\Route; + +/** + * 资源路由类 + */ +class Resource extends RuleGroup +{ + /** + * REST方法定义 + * @var array + */ + protected $rest = []; + + /** + * 模型绑定 + * @var array + */ + protected $model = []; + + /** + * 数据验证 + * @var array + */ + protected $validate = []; + + /** + * 中间件 + * @var array + */ + protected $middleware = []; + + /** + * 扩展规则 + * @var Closure + */ + protected $extend; + + /** + * 架构函数 + * @access public + * @param Route $router 路由对象 + * @param RuleGroup $parent 上级对象 + * @param string $name 资源名称 + * @param string $route 路由地址 + * @param array $rest 资源定义 + */ + public function __construct(Route $router, ?RuleGroup $parent = null, string $name = '', string $route = '', array $rest = []) + { + $name = ltrim($name, '/'); + $this->router = $router; + $this->parent = $parent; + $this->rule = $name; + $this->route = $route; + $this->name = str_contains($name, '.') ? strstr($name, '.', true) : $name; + + $this->setFullName(); + + // 资源路由默认为完整匹配 + $this->option['complete_match'] = true; + + $this->rest = $rest; + + if ($this->parent) { + $this->domain = $this->parent->getDomain(); + $this->parent->addRuleItem($this); + } + } + + /** + * 扩展额外路由规则 + * @access public + * @param Closure $extend 路由规则闭包定义 + * @return $this + */ + public function extend(?Closure $extend) + { + $this->extend = $extend; + return $this; + } + + /** + * 生成资源路由规则 + * @access public + * @param mixed $rule 路由规则 + * @return void + */ + public function parseGroupRule($rule): void + { + $option = $this->option; + $origin = $this->router->getGroup(); + $this->router->setGroup($this); + + if (str_contains($rule, '.')) { + // 注册嵌套资源路由 + $array = explode('.', $rule); + $last = array_pop($array); + $item = []; + + foreach ($array as $val) { + $item[] = $val . '/<' . ($option['var'][$val] ?? $val . '_id') . '>'; + } + + $rule = implode('/', $item) . '/' . $last; + $id = $option['var'][$last] ?? 'id'; + } else { + $id = $option['var'][$rule] ?? 'id'; + } + + $prefix = substr($rule, strlen($this->name) + 1); + + // 注册资源路由 + foreach ($this->rest as $key => $val) { + if ((isset($option['only']) && !in_array($key, $option['only'])) + || (isset($option['except']) && in_array($key, $option['except'])) + ) { + continue; + } + + if (str_contains($val[1], '') && 'id' != $id) { + $val[1] = str_replace('', '<' . $id . '>', $val[1]); + } + + $ruleItem = $this->addRule(trim($prefix . $val[1], '/'), $this->route . '/' . $val[2], $val[0]); + + foreach (['model', 'validate', 'middleware', 'pattern'] as $name) { + if (isset($this->$name[$key])) { + call_user_func_array([$ruleItem, $name], (array) $this->$name[$key]); + } + } + } + + if ($this->extend) { + // 扩展路由规则 + $group = new RuleGroup($this->router, $this, $prefix . '/<' . $id . '>'); + $this->router->setGroup($group); + Container::getInstance()->invokeFunction($this->extend); + } + + $this->router->setGroup($origin); + $this->hasParsed = true; + } + + /** + * 设置资源允许 + * @access public + * @param array $only 资源允许 + * @return $this + */ + public function only(array $only) + { + return $this->setOption('only', $only); + } + + /** + * 设置资源排除 + * @access public + * @param array $except 排除资源 + * @return $this + */ + public function except(array $except) + { + return $this->setOption('except', $except); + } + + /** + * 设置资源路由的变量 + * @access public + * @param array $vars 资源变量 + * @return $this + */ + public function vars(array $vars) + { + return $this->setOption('var', $vars); + } + + /** + * 绑定资源验证 + * @access public + * @param array|string $name 资源类型或者验证信息 + * @param array|string $validate 验证信息 + * @return $this + */ + public function withValidate(array | string $name, array | string $validate = []) + { + if (is_array($name)) { + $this->validate = array_merge($this->validate, $name); + } else { + $this->validate[$name] = $validate; + } + + return $this; + } + + /** + * 绑定资源模型 + * @access public + * @param array|string $name 资源类型或者模型绑定 + * @param array|string $model 模型绑定 + * @return $this + */ + public function withModel(array | string $name, array | string $model = []) + { + if (is_array($name)) { + $this->model = array_merge($this->model, $name); + } else { + $this->model[$name] = $model; + } + + return $this; + } + + /** + * 绑定资源中间件 + * @access public + * @param array|string $name 资源类型或者中间件定义 + * @param array|string $middleware 中间件定义 + * @return $this + */ + public function withMiddleware(array | string $name, array | string $middleware = []) + { + if (is_array($name)) { + $this->middleware = array_merge($this->middleware, $name); + } else { + $this->middleware[$name] = $middleware; + } + + return $this; + } + + /** + * rest方法定义和修改 + * @access public + * @param array|string $name 方法名称 + * @param array|bool $resource 资源 + * @return $this + */ + public function rest(array | string $name, array | bool $resource = []) + { + if (is_array($name)) { + $this->rest = $resource ? $name : array_merge($this->rest, $name); + } else { + $this->rest[$name] = $resource; + } + + return $this; + } +} diff --git a/vendor/topthink/framework/src/think/route/ResourceRegister.php b/vendor/topthink/framework/src/think/route/ResourceRegister.php new file mode 100644 index 0000000..446a84c --- /dev/null +++ b/vendor/topthink/framework/src/think/route/ResourceRegister.php @@ -0,0 +1,72 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +/** + * 资源路由注册类 + */ +class ResourceRegister +{ + /** + * 资源路由 + * @var Resource + */ + protected $resource; + + /** + * 是否注册过 + * @var bool + */ + protected $registered = false; + + /** + * 架构函数 + * @access public + * @param Resource $resource 资源路由 + */ + public function __construct(Resource $resource) + { + $this->resource = $resource; + } + + /** + * 注册资源路由 + * @access protected + * @return void + */ + protected function register() + { + $this->registered = true; + + $this->resource->parseGroupRule($this->resource->getRule()); + } + + /** + * 动态方法 + * @access public + * @param string $method 方法名 + * @param array $args 调用参数 + * @return mixed + */ + public function __call($method, $args) + { + return call_user_func_array([$this->resource, $method], $args); + } + + public function __destruct() + { + if (!$this->registered) { + $this->register(); + } + } +} diff --git a/vendor/topthink/framework/src/think/route/Rule.php b/vendor/topthink/framework/src/think/route/Rule.php new file mode 100644 index 0000000..144b2e6 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/Rule.php @@ -0,0 +1,1036 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +use Closure; +use think\Container; +use think\middleware\AllowCrossDomain; +use think\middleware\CheckRequestCache; +use think\middleware\FormTokenCheck; +use think\Request; +use think\Route; +use think\route\dispatch\Callback as CallbackDispatch; +use think\route\dispatch\Controller as ControllerDispatch; + +/** + * 路由规则基础类 + */ +abstract class Rule +{ + /** + * 路由标识 + * @var string + */ + protected $name; + + /** + * 所在域名 + * @var string + */ + protected $domain; + + /** + * 路由对象 + * @var Route + */ + protected $router; + + /** + * 路由所属分组 + * @var RuleGroup + */ + protected $parent; + + /** + * 路由规则 + * @var mixed + */ + protected $rule; + + /** + * 路由地址 + * @var string|Closure + */ + protected $route; + + /** + * 请求类型 + * @var string + */ + protected $method = '*'; + + /** + * 路由变量 + * @var array + */ + protected $vars = []; + + /** + * 路由参数 + * @var array + */ + protected $option = []; + + /** + * 路由变量规则 + * @var array + */ + protected $pattern = []; + + /** + * 预定义变量规则 + * @var array + */ + protected $regex = [ + 'int' => '\d+', + 'float' => '\d+\.\d+', + 'alpha' => '[A-Za-z]+', + 'alphaNum' => '[A-Za-z0-9]+', + 'alphaDash' => '[A-Za-z0-9\-\_]+', + ]; + + /** + * 需要和分组合并的路由参数 + * @var array + */ + protected $mergeOptions = ['model', 'append', 'middleware']; + + abstract public function check(Request $request, string $url, bool $completeMatch = false); + + /** + * 设置路由参数 + * @access public + * @param array $option 参数 + * @return $this + */ + public function option(array $option) + { + $this->option = array_merge($this->option, $option); + + return $this; + } + + /** + * 设置单个路由参数 + * @access public + * @param string $name 参数名 + * @param mixed $value 值 + * @return $this + */ + public function setOption(string $name, $value) + { + $this->option[$name] = $value; + + return $this; + } + + /** + * 注册变量规则 + * @access public + * @param array $regex 变量规则 + * @return $this + */ + public function regex(array $regex) + { + $this->regex = array_merge($this->regex, $regex); + + return $this; + } + + /** + * 注册变量(正则)规则 + * @access public + * @param array $pattern 变量规则 + * @return $this + */ + public function pattern(array $pattern) + { + $this->pattern = array_merge($this->pattern, $pattern); + + return $this; + } + + /** + * 注册路由变量和请求变量的匹配规则(支持验证类的所有内置规则) + * + * @access public + * @param string $name 变量名 + * @param mixed $rule 变量规则 + * @return $this + */ + public function when(string | array $name, $rule = null) + { + if (is_array($name)) { + $this->option['var_rule'] = $name; + } else { + $this->option['var_rule'][$name] = $rule; + } + + return $this; + } + + /** + * 设置标识 + * @access public + * @param string $name 标识名 + * @return $this + */ + public function name(string $name) + { + $this->name = $name; + + return $this; + } + + /** + * 获取路由对象 + * @access public + * @return Route + */ + public function getRouter(): Route + { + return $this->router; + } + + /** + * 获取Name + * @access public + * @return string + */ + public function getName(): string + { + return $this->name ?: ''; + } + + /** + * 获取当前路由规则 + * @access public + * @return mixed + */ + public function getRule() + { + return $this->rule; + } + + /** + * 获取当前路由地址 + * @access public + * @return mixed + */ + public function getRoute() + { + return $this->route; + } + + /** + * 获取当前路由的变量 + * @access public + * @return array + */ + public function getVars(): array + { + return $this->vars; + } + + /** + * 获取Parent对象 + * @access public + * @return $this|null + */ + public function getParent() + { + return $this->parent; + } + + /** + * 获取路由所在域名 + * @access public + * @return string + */ + public function getDomain(): string + { + return $this->domain ?: $this->parent->getDomain(); + } + + /** + * 获取路由参数 + * @access public + * @param string $name 变量名 + * @return mixed + */ + public function config(string $name = '') + { + return $this->router->config($name); + } + + /** + * 获取变量规则定义 + * @access public + * @param string $name 变量名 + * @return mixed + */ + public function getPattern(string $name = '') + { + $pattern = $this->pattern; + + if ($this->parent) { + $pattern = array_merge($this->parent->getPattern(), $pattern); + } + + if ('' === $name) { + return $pattern; + } + + return $pattern[$name] ?? null; + } + + /** + * 获取路由参数定义 + * @access public + * @param string $name 参数名 + * @param mixed $default 默认值 + * @return mixed + */ + public function getOption(string $name = '', $default = null) + { + $option = $this->option; + + if ($this->parent) { + $parentOption = $this->parent->getOption(); + + // 合并分组参数 + foreach ($this->mergeOptions as $item) { + if (isset($parentOption[$item]) && isset($option[$item])) { + $option[$item] = array_merge($parentOption[$item], $option[$item]); + } + } + + $option = array_merge($parentOption, $option); + } + + if ('' === $name) { + return $option; + } + + return $option[$name] ?? $default; + } + + /** + * 获取当前路由的请求类型 + * @access public + * @return string + */ + public function getMethod(): string + { + return strtolower($this->method); + } + + /** + * 设置路由请求类型 + * @access public + * @param string $method 请求类型 + * @return $this + */ + public function method(string $method) + { + return $this->setOption('method', strtolower($method)); + } + + /** + * 检查后缀 + * @access public + * @param string $ext URL后缀 + * @return $this + */ + public function ext(string $ext = '') + { + return $this->setOption('ext', $ext); + } + + /** + * 检查禁止后缀 + * @access public + * @param string $ext URL后缀 + * @return $this + */ + public function denyExt(string $ext = '') + { + return $this->setOption('deny_ext', $ext); + } + + /** + * 检查域名 + * @access public + * @param string $domain 域名 + * @return $this + */ + public function domain(string $domain) + { + $this->domain = $domain; + return $this->setOption('domain', $domain); + } + + /** + * 是否区分大小写 + * @access public + * @param bool $case 是否区分 + * @return $this + */ + public function caseUrl(bool $case) + { + return $this->setOption('case_sensitive', $case); + } + + /** + * 设置参数过滤检查 + * @access public + * @param array $filter 参数过滤 + * @return $this + */ + public function filter(array $filter) + { + $this->option['filter'] = $filter; + + return $this; + } + + /** + * 设置路由变量默认值 + * @access public + * @param array $default 可选路由变量默认值 + * @return $this + */ + public function default(array $default) + { + $this->option['default'] = $default; + + return $this; + } + + /** + * 设置路由自动注册中间件 + * @access public + * @param bool $auto + * @return $this + */ + public function autoMiddleware(bool $auto = true) + { + $this->option['auto_middleware'] = $auto; + + return $this; + } + + /** + * 绑定模型 + * @access public + * @param array|string|Closure $var 路由变量名 多个使用 & 分割 + * @param string|Closure|null $model 绑定模型类 + * @param bool $exception 是否抛出异常 + * @return $this + */ + public function model(array | string | Closure $var, string | Closure | null $model = null, bool $exception = true) + { + if ($var instanceof Closure) { + $this->option['model'][] = $var; + } elseif (is_array($var)) { + $this->option['model'] = $var; + } elseif (is_null($model)) { + $this->option['model']['id'] = [$var, true]; + } else { + $this->option['model'][$var] = [$model, $exception]; + } + + return $this; + } + + /** + * 附加路由隐式参数 + * @access public + * @param array $append 追加参数 + * @return $this + */ + public function append(array $append = []) + { + $this->option['append'] = array_merge($this->option['append'] ?? [], $append); + + return $this; + } + + /** + * 绑定验证 + * @access public + * @param mixed $validate 验证器类 + * @param string|array $scene 验证场景 + * @param array $message 验证提示 + * @param bool $batch 批量验证 + * @return $this + */ + public function validate($validate, string | array $scene = '', array $message = [], bool $batch = false) + { + $this->option['validate'] = [$validate, $scene, $message, $batch]; + + return $this; + } + + /** + * 指定路由中间件 + * @access public + * @param string|array|Closure $middleware 中间件 + * @param mixed $params 参数 + * @return $this + */ + public function middleware(string | array | Closure $middleware, ...$params) + { + if (empty($params) && is_array($middleware)) { + $this->option['middleware'] = array_merge($this->option['middleware'] ?? [], $middleware); + } else { + foreach ((array) $middleware as $item) { + $this->option['middleware'][] = [$item, $params]; + } + } + + return $this; + } + + /** + * 设置不使用的中间件 留空则为全部不用 + * @access public + * @param array $middleware 中间件 + * @return $this + */ + public function withoutMiddleware(array $middleware = []) + { + $this->option['without_middleware'] = $middleware; + + return $this; + } + + /** + * 允许跨域 + * @access public + * @param array $header 自定义Header + * @return $this + */ + public function allowCrossDomain(array $header = []) + { + return $this->middleware(AllowCrossDomain::class, $header); + } + + /** + * 表单令牌验证 + * @access public + * @param string $token 表单令牌token名称 + * @return $this + */ + public function token(string $token = '__token__') + { + return $this->middleware(FormTokenCheck::class, $token); + } + + /** + * 设置路由缓存 + * @access public + * @param array|string|int $cache 缓存 + * @return $this + */ + public function cache(array | string | int $cache) + { + return $this->middleware(CheckRequestCache::class, $cache); + } + + /** + * 检查URL分隔符 + * @access public + * @param string $depr URL分隔符 + * @return $this + */ + public function depr(string $depr) + { + return $this->setOption('param_depr', $depr); + } + + /** + * 设置需要合并的路由参数 + * @access public + * @param array $option 路由参数 + * @return $this + */ + public function mergeOptions(array $option = []) + { + $this->mergeOptions = array_merge($this->mergeOptions, $option); + return $this; + } + + /** + * 检查是否为HTTPS请求 + * @access public + * @param bool $https 是否为HTTPS + * @return $this + */ + public function https(bool $https = true) + { + return $this->setOption('https', $https); + } + + /** + * 检查是否为JSON请求 + * @access public + * @param bool $json 是否为JSON + * @return $this + */ + public function json(bool $json = true) + { + return $this->setOption('json', $json); + } + + /** + * 检查是否为AJAX请求 + * @access public + * @param bool $ajax 是否为AJAX + * @return $this + */ + public function ajax(bool $ajax = true) + { + return $this->setOption('ajax', $ajax); + } + + /** + * 检查是否为PJAX请求 + * @access public + * @param bool $pjax 是否为PJAX + * @return $this + */ + public function pjax(bool $pjax = true) + { + return $this->setOption('pjax', $pjax); + } + + /** + * 路由到一个模板地址 需要额外传入的模板变量 + * @access public + * @param array $view 视图 + * @return $this + */ + public function view(array $view = []) + { + return $this->setOption('view', $view); + } + + /** + * 通过闭包检查路由是否匹配 + * @access public + * @param callable $match 闭包 + * @return $this + */ + public function match(callable $match) + { + return $this->setOption('match', $match); + } + + /** + * 设置路由完整匹配 + * @access public + * @param bool $match 是否完整匹配 + * @return $this + */ + public function completeMatch(bool $match = true) + { + return $this->setOption('complete_match', $match); + } + + /** + * 是否去除URL最后的斜线 + * @access public + * @param bool $remove 是否去除最后斜线 + * @return $this + */ + public function removeSlash(bool $remove = true) + { + return $this->setOption('remove_slash', $remove); + } + + /** + * 设置路由规则全局有效 + * @access public + * @return $this + */ + public function crossDomainRule() + { + $this->router->setCrossDomainRule($this); + return $this; + } + + /** + * 解析匹配到的规则路由 + * @access public + * @param Request $request 请求对象 + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @param string $url URL地址 + * @param array $option 路由参数 + * @param array $matches 匹配的变量 + * @return Dispatch + */ + public function parseRule(Request $request, string $rule, $route, string $url, array $option = [], array $matches = []): Dispatch + { + if (is_string($route) && isset($option['prefix'])) { + // 路由地址前缀 + $route = $option['prefix'] . $route; + } + + // 替换路由地址中的变量 + $extraParams = true; + $search = $replace = []; + $depr = $this->config('pathinfo_depr'); + + foreach ($matches as $key => $value) { + $search[] = '<' . $key . '>'; + $replace[] = $value; + $search[] = '{' . $key . '}'; + $replace[] = $value; + $search[] = ':' . $key; + $replace[] = $value; + + if (str_contains($value, $depr)) { + $extraParams = false; + } + } + + if (is_string($route)) { + $route = str_replace($search, $replace, $route); + } + + // 解析额外参数 + if ($extraParams) { + $count = substr_count($rule, '/'); + $url = array_slice(explode('|', $url), $count + 1); + $this->parseUrlParams(implode('/', $url), $matches); + } + + foreach ($matches as $key => &$val) { + if (isset($this->pattern[$key]) && in_array($this->pattern[$key], ['\d+', 'int', 'float'])) { + $val = match ($this->pattern[$key]) { + 'int', '\d+' => (int) $val, + 'float' => (float) $val, + default => $val, + }; + } elseif (in_array($key, ['__module__','__controller__','__action__'])) { + unset($matches[$key]); + } + } + + $this->vars = $matches; + + // 发起路由调度 + return $this->dispatch($request, $route, $option); + } + + /** + * 发起路由调度 + * @access protected + * @param Request $request Request对象 + * @param mixed $route 路由地址 + * @param array $option 路由参数 + * @return Dispatch + */ + protected function dispatch(Request $request, $route, array $option): Dispatch + { + if (isset($option['dispatcher']) && is_subclass_of($option['dispatcher'], Dispatch::class)) { + // 指定分组的调度处理对象 + $result = new $option['dispatcher']($request, $this, $route, $this->vars, $option); + } elseif (is_subclass_of($route, Dispatch::class)) { + $result = new $route($request, $this, $route, $this->vars, $option); + } elseif ($route instanceof Closure) { + // 执行闭包 + $result = new CallbackDispatch($request, $this, $route, $this->vars, $option); + } elseif (is_array($route)) { + // 路由到类的方法 + $result = $this->dispatchMethod($request, $route, $option); + } elseif (str_contains($route, '@') || str_contains($route, '::') || str_contains($route, '\\')) { + // 路由到类的方法 + $route = str_replace('::', '@', $route); + $result = $this->dispatchMethod($request, $route, $option); + } else { + // 路由到模块/控制器/操作 + $result = $this->dispatchController($request, $route, $option); + } + + return $result; + } + + /** + * 调度到类的方法 + * @access protected + * @param Request $request Request对象 + * @param string|array $route 路由地址 + * @return CallbackDispatch + */ + protected function dispatchMethod(Request $request, string | array $route, array $option = []): CallbackDispatch + { + if (is_string($route)) { + $path = $this->parseUrlPath($route); + + $route = str_replace('/', '@', implode('/', $path)); + $method = str_contains($route, '@') ? explode('@', $route) : $route; + } else { + $method = $route; + } + + return new CallbackDispatch($request, $this, $method, $this->vars, $option); + } + + /** + * 调度到控制器方法 规则:模块/控制器/操作 + * @access protected + * @param Request $request Request对象 + * @param string $route 路由地址 + * @return ControllerDispatch + */ + protected function dispatchController(Request $request, string $route, array $option = []): ControllerDispatch + { + $path = $this->parseUrlPath($route); + + // 路由到模块/控制器/操作 + return new ControllerDispatch($request, $this, $path, $this->vars, $option); + } + + /** + * 路由检查 + * @access protected + * @param array $option 路由参数 + * @param Request $request Request对象 + * @return bool + */ + protected function checkOption(array $option, Request $request): bool + { + // 检查当前路由是否匹配 + if (isset($option['match']) && is_callable($option['match'])) { + if (false === $option['match']($this, $request)) { + return false; + } + } + + // 请求类型检测 + if (!empty($option['method'])) { + if (is_string($option['method']) && false === stripos($option['method'], $request->method())) { + return false; + } + } + + // AJAX PJAX 请求检查 + foreach (['ajax', 'pjax', 'json'] as $item) { + if (isset($option[$item])) { + $call = 'is' . $item; + if ($option[$item] && !$request->$call() || !$option[$item] && $request->$call()) { + return false; + } + } + } + + // 伪静态后缀检测 + if ($request->url() != '/' && ((isset($option['ext']) && false === stripos('|' . $option['ext'] . '|', '|' . $request->ext() . '|')) + || (isset($option['deny_ext']) && false !== stripos('|' . $option['deny_ext'] . '|', '|' . $request->ext() . '|')))) { + return false; + } + + // 域名检查 + if ((isset($option['domain']) && !in_array($option['domain'], [$request->host(true), $request->subDomain()]))) { + return false; + } + + // HTTPS检查 + if ((isset($option['https']) && $option['https'] && !$request->isSsl()) + || (isset($option['https']) && !$option['https'] && $request->isSsl()) + ) { + return false; + } + + // 请求参数过滤 + if (isset($option['filter'])) { + foreach ($option['filter'] as $name => $value) { + if ($request->param($name, '') != $value) { + return false; + } + } + } + + return true; + } + + /** + * 解析URL地址中的参数Request对象 + * @access protected + * @param string $rule 路由规则 + * @param array $var 变量 + * @return void + */ + protected function parseUrlParams(string $url, array &$var = []): void + { + if ($url) { + preg_replace_callback('/(\w+)\/([^\/]+)/', function ($match) use (&$var) { + $var[$match[1]] = strip_tags($match[2]); + }, $url); + } + } + + /** + * 解析URL的pathinfo参数 + * @access public + * @param string $url URL地址 + * @return array + */ + public function parseUrlPath(string $url): array + { + // 分隔符替换 确保路由定义使用统一的分隔符 + $url = str_replace('|', '/', $url); + $url = trim($url, '/'); + + if (str_contains($url, '/')) { + // [模块/.../控制器/操作] + $path = explode('/', $url); + } else { + $path = [$url]; + } + + return $path; + } + + /** + * 生成路由的正则规则 + * @access protected + * @param string $rule 路由规则 + * @param array $match 匹配的变量 + * @param array $pattern 路由变量规则 + * @param array $option 路由参数 + * @param bool $completeMatch 路由是否完全匹配 + * @param string $suffix 路由正则变量后缀 + * @return string + */ + protected function buildRuleRegex(string $rule, array $match, array $pattern = [], array $option = [], bool $completeMatch = false, string $suffix = ''): string + { + foreach ($match as $name) { + $value = $this->buildNameRegex($name, $pattern, $suffix); + if ($value) { + $origin[] = $name; + $replace[] = $value; + } + } + + // 是否区分 / 地址访问 + if ('/' != $rule) { + if (!empty($option['remove_slash'])) { + $rule = rtrim($rule, '/'); + } elseif (str_ends_with($rule, '/')) { + $rule = rtrim($rule, '/'); + $hasSlash = true; + } + } + + $regex = isset($replace) ? str_replace($origin, $replace, $rule) : $rule; + $regex = str_replace([')?/', ')?-'], [')/', ')-'], $regex); + + if (isset($hasSlash)) { + $regex .= '/'; + } + + return $regex . ($completeMatch ? '$' : ''); + } + + /** + * 生成路由变量的正则规则 + * @access protected + * @param string $name 路由变量 + * @param array $pattern 变量规则 + * @param string $suffix 路由正则变量后缀 + * @return string + */ + protected function buildNameRegex(string $name, array $pattern, string $suffix): string + { + $optional = ''; + $slash = substr($name, 0, 1); + + if (in_array($slash, ['/', '-'])) { + $prefix = $slash; + $name = substr($name, 1); + $slash = substr($name, 0, 1); + } else { + $prefix = ''; + } + + if ('<' != $slash) { + return ''; + } + + if (str_contains($name, '?')) { + $name = substr($name, 1, -2); + $optional = '?'; + } elseif (str_contains($name, '>')) { + $name = substr($name, 1, -1); + } + + if (isset($pattern[$name])) { + $nameRule = $pattern[$name]; + if (isset($this->regex[$nameRule])) { + $nameRule = $this->regex[$nameRule]; + } + + if (str_starts_with($nameRule, '/') && str_ends_with($nameRule, '/')) { + $nameRule = substr($nameRule, 1, -1); + } + } else { + $nameRule = $this->config('default_route_pattern'); + } + + return '(' . $prefix . '(?<' . $name . $suffix . '>' . $nameRule . '))' . $optional; + } + + /** + * 设置路由参数 + * @access public + * @param string $method 方法名 + * @param array $args 调用参数 + * @return $this + */ + public function __call($method, $args) + { + if (count($args) > 1) { + $args[0] = $args; + } + array_unshift($args, $method); + + return call_user_func_array([$this, 'setOption'], $args); + } + + public function __sleep() + { + return ['name', 'rule', 'route', 'method', 'vars', 'option', 'pattern']; + } + + public function __wakeup() + { + $this->router = Container::pull('route'); + } + + public function __debugInfo() + { + return [ + 'name' => $this->name, + 'rule' => $this->rule, + 'route' => $this->route, + 'method' => $this->method, + 'vars' => $this->vars, + 'option' => $this->option, + 'pattern' => $this->pattern, + ]; + } +} diff --git a/vendor/topthink/framework/src/think/route/RuleGroup.php b/vendor/topthink/framework/src/think/route/RuleGroup.php new file mode 100644 index 0000000..8594dd5 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/RuleGroup.php @@ -0,0 +1,732 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +use Closure; +use think\Container; +use think\Exception; +use think\helper\Str; +use think\Request; +use think\Route; +use think\route\dispatch\Callback as CallbackDispatch; +use think\route\dispatch\Controller as ControllerDispatch; + +/** + * 路由分组类 + */ +class RuleGroup extends Rule +{ + /** + * 分组路由(包括子分组) + * @var Rule[] + */ + protected $rules = []; + + /** + * MISS路由 + * @var RuleItem + */ + protected $miss; + + /** + * 完整名称 + * @var string + */ + protected $fullName; + + /** + * 分组别名 + * @var string + */ + protected $alias; + + /** + * 分组绑定 + * @var string + */ + protected $bind; + + /** + * 是否已经解析 + * @var bool + */ + protected $hasParsed; + + /** + * 架构函数 + * @access public + * @param Route $router 路由对象 + * @param RuleGroup $parent 上级对象 + * @param string $name 分组名称 + * @param mixed $rule 分组路由 + * @param bool $lazy 延迟解析 + */ + public function __construct(Route $router, ?RuleGroup $parent = null, string $name = '', $rule = null, bool $lazy = false) + { + $this->router = $router; + $this->parent = $parent; + $this->rule = $rule; + $this->name = trim($name, '/'); + + $this->setFullName(); + + if ($this->parent) { + $this->domain = $this->parent->getDomain(); + $this->parent->addRuleItem($this); + } + + if (!$lazy) { + $this->parseGroupRule($rule); + } + } + + /** + * 设置分组的路由规则 + * @access public + * @return void + */ + protected function setFullName(): void + { + if (str_contains($this->name, ':')) { + $this->name = preg_replace(['/\[\:(\w+)\]/', '/\:(\w+)/'], ['<\1?>', '<\1>'], $this->name); + } + + if ($this->parent && $this->parent->getFullName()) { + $this->fullName = $this->parent->getFullName() . ($this->name ? '/' . $this->name : ''); + } else { + $this->fullName = $this->name; + } + + if ($this->name) { + $this->router->getRuleName()->setGroup($this->name, $this); + } + } + + /** + * 获取所属域名 + * @access public + * @return string + */ + public function getDomain(): string + { + return $this->domain ?: '-'; + } + + /** + * 获取分组别名 + * @access public + * @return string + */ + public function getAlias(): string + { + return $this->alias ?: ''; + } + + /** + * 检测分组路由 + * @access public + * @param Request $request 请求对象 + * @param string $url 访问地址 + * @param bool $completeMatch 路由是否完全匹配 + * @return Dispatch|false + */ + public function check(Request $request, string $url, bool $completeMatch = false) + { + // 检查分组有效性 + if (!$this->checkOption($this->option, $request) || !$this->checkUrl($url)) { + return false; + } + + // 解析分组路由 + if (!$this->hasParsed) { + $this->parseGroupRule($this->rule); + } + + // 获取当前路由规则 + $method = strtolower($request->method()); + $rules = $this->getRules($method); + $option = $this->getOption(); + + if (isset($option['complete_match'])) { + $completeMatch = $option['complete_match']; + } + + if (!empty($option['merge_rule_regex'])) { + // 路由合并检查 + $result = $this->checkMergeRuleRegex($request, $rules, $url, $completeMatch); + + if (false !== $result) { + return $result; + } + } else { + // 检查分组路由 + foreach ($rules as $item) { + $result = $item->check($request, $url, $completeMatch); + + if (false !== $result) { + return $result; + } + } + } + + if ($this->bind) { + // 检查分组绑定 + return $this->checkBind($request, $url, $option); + } + + if ($miss = $this->getMissRule($method)) { + // MISS路由 + return $miss->parseRule($request, '', $miss->getRoute(), $url, $miss->getOption()); + } + + return false; + } + + /** + * 分组URL匹配检查 + * @access protected + * @param string $url URL + * @return bool + */ + protected function checkUrl(string $url): bool + { + if ($this->fullName) { + $pos = strpos($this->fullName, '<'); + + if (false !== $pos) { + $str = substr($this->fullName, 0, $pos); + } else { + $str = $this->fullName; + } + + if ($str && 0 !== stripos(str_replace('|', '/', $url), $str)) { + return false; + } + } + + return true; + } + + /** + * 设置路由分组别名 + * @access public + * @param string $alias 路由分组别名 + * @return $this + */ + public function alias(string $alias) + { + $this->alias = $alias; + $this->router->getRuleName()->setGroup($alias, $this); + + return $this; + } + + /** + * 解析分组和域名的路由规则及绑定 + * @access public + * @param mixed $rule 路由规则 + * @return void + */ + public function parseGroupRule($rule): void + { + if (is_string($rule) && is_subclass_of($rule, Dispatch::class)) { + $this->dispatcher($rule); + return; + } + + $origin = $this->router->getGroup(); + $this->router->setGroup($this); + + if ($rule instanceof Closure) { + Container::getInstance()->invokeFunction($rule); + } elseif (is_string($rule) && $rule) { + $this->bind($rule); + } + + $this->router->setGroup($origin); + $this->hasParsed = true; + } + + /** + * 检测分组路由 + * @access public + * @param Request $request 请求对象 + * @param array $rules 路由规则 + * @param string $url 访问地址 + * @param bool $completeMatch 路由是否完全匹配 + * @return Dispatch|false + */ + protected function checkMergeRuleRegex(Request $request, array &$rules, string $url, bool $completeMatch) + { + $depr = $this->config('pathinfo_depr'); + $url = $depr . str_replace('|', $depr, $url); + $regex = []; + $items = []; + + foreach ($rules as $key => $item) { + if ($item instanceof RuleItem) { + $rule = $depr . str_replace('/', $depr, $item->getRule()); + if ($depr == $rule && $depr != $url) { + unset($rules[$key]); + continue; + } + + $complete = $item->getOption('complete_match', $completeMatch); + + if (!str_contains($rule, '<')) { + if (0 === strcasecmp($rule, $url) || (!$complete && 0 === strncasecmp($rule, $url, strlen($rule)))) { + return $item->checkRule($request, $url, []); + } + + unset($rules[$key]); + continue; + } + + $slash = preg_quote('/-' . $depr, '/'); + + if ($matchRule = preg_split('/[' . $slash . ']<\w+\??>/', $rule, 2)) { + if ($matchRule[0] && 0 !== strncasecmp($rule, $url, strlen($matchRule[0]))) { + unset($rules[$key]); + continue; + } + } + + if (preg_match_all('/[' . $slash . ']??/', $rule, $matches)) { + unset($rules[$key]); + $pattern = array_merge($this->getPattern(), $item->getPattern()); + $option = array_merge($this->getOption(), $item->getOption()); + + $regex[$key] = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $complete, '_THINK_' . $key); + $items[$key] = $item; + } + } elseif ($item instanceof RuleGroup) { + $array = $item->getrules(); + return $this->checkMergeRuleRegex($request, $array, ltrim($url, $depr), $completeMatch); + } + } + + if (empty($regex)) { + return false; + } + + try { + $result = preg_match('~^(?:' . implode('|', $regex) . ')~u', $url, $match); + } catch (\Exception $e) { + throw new Exception('route pattern error'); + } + + if ($result) { + $var = []; + foreach ($match as $key => $val) { + if (is_string($key) && '' !== $val) { + [$name, $pos] = explode('_THINK_', $key); + + $var[$name] = $val; + } + } + + if (!isset($pos)) { + foreach ($regex as $key => $item) { + if (str_starts_with(str_replace(['\/', '\-', '\\' . $depr], ['/', '-', $depr], $item), $match[0])) { + $pos = $key; + break; + } + } + } + + $rule = $items[$pos]->getRule(); + $array = $this->router->getRule($rule); + + foreach ($array as $item) { + if (in_array($item->getMethod(), ['*', strtolower($request->method())])) { + $result = $item->checkRule($request, $url, $var); + + if (false !== $result) { + return $result; + } + } + } + } + + return false; + } + + /** + * 注册MISS路由 + * @access public + * @param string|Closure $route 路由地址 + * @param string $method 请求类型 + * @return RuleItem + */ + public function miss(string | Closure $route, string $method = '*'): RuleItem + { + // 创建路由规则实例 + $method = strtolower($method); + $ruleItem = new RuleItem($this->router, $this, null, '', $route, $method); + + $this->miss[$method] = $ruleItem->setMiss(); + + return $ruleItem; + } + + /** + * 获取分组下的MISS路由 + * @access public + * @param string $method 请求类型 + * @return RuleItem|null + */ + public function getMissRule(string $method = '*'): ?RuleItem + { + if (isset($this->miss[$method])) { + $miss = $this->miss[$method]; + } elseif (isset($this->miss['*'])) { + $miss = $this->miss['*']; + } + return $miss ?? null; + } + + /** + * 分组自动URL调度 默认绑定到当前分组名所在的控制器分级 + * @access public + * @param string $bind 绑定资源 绑定规则 class @controller :namespace /layer + * @param string|array $middleware 中间件 + * @return $this + */ + public function auto(string $bind = '', string | array $middleware = '') + { + $this->bind = $bind ?: '/' . $this->getFullName(); + if ($middleware) { + $this->middleware($middleware); + } + + return $this; + } + + /** + * 分组绑定到类 + * @access public + * @param string $class + * @param bool $prefix + * @return $this + */ + public function class(string $class, bool $prefix = true) + { + $this->bind = '\\' . $class; + if ($prefix) { + $this->prefix('\\' . $class . '@'); + } + return $this; + } + + /** + * 分组绑定到控制器 + * @access public + * @param string $controller + * @param bool $prefix + * @return $this + */ + public function controller(string $controller, bool $prefix = true) + { + $this->bind = '@' . $controller; + if ($prefix) { + $this->prefix($controller . '/'); + } + return $this; + } + + /** + * 分组绑定到命名空间 + * @access public + * @param string $namespace + * @param bool $prefix + * @return $this + */ + public function namespace(string $namespace, bool $prefix = true) + { + $this->bind = ':' . $namespace; + if ($prefix) { + $this->prefix($namespace . '\\'); + } + return $this; + } + + /** + * 分组绑定到控制器分级 + * @access public + * @param string $namespace + * @param bool $prefix + * @return $this + */ + public function layer(string $layer, bool $prefix = true) + { + $this->bind = '/' . $layer; + if ($prefix) { + $this->prefix($layer . '/'); + } + return $this; + } + + /** + * 获取分组绑定信息 + * @access public + * @return string + */ + public function getBind() + { + return $this->bind ?? ''; + } + + /** + * 检测URL绑定 + * @access private + * @param Request $request + * @param string $url URL地址 + * @param array $option 分组参数 + * @return Dispatch + */ + public function checkBind(Request $request, string $url, array $option = []): Dispatch + { + [$bind, $param] = $this->parseBindAppendParam($this->bind); + + [$call, $bind] = match (substr($bind, 0, 1)) { + '\\' => ['bindToClass', substr($bind, 1)], + '@' => ['bindToController', substr($bind, 1)], + '/' => ['bindToLayer', substr($bind, 1)], + ':' => ['bindToNamespace', substr($bind, 1)], + default => ['bindToClass', $bind], + }; + + $name = $this->getFullName(); + $url = trim(substr(str_replace('|', '/', $url), strlen($name)), '/'); + + return $this->$call($request, $url, $bind, $param, $option); + } + + protected function parseBindAppendParam(string $bind) + { + $vars = []; + if (str_contains($bind, '?')) { + [$bind, $query] = explode('?', $bind); + parse_str($query, $vars); + } + return [$bind, $vars]; + } + + /** + * 绑定到类 + * @access protected + * @param Request $request + * @param string $url URL地址 + * @param string $class 类名(带命名空间) + * @param array $param 路由变量 + * @param array $option 分组参数 + * @return CallbackDispatch + */ + protected function bindToClass(Request $request, string $url, string $class, array $param = [], array $option = []): CallbackDispatch + { + $array = explode('/', $url, 2); + $action = !empty($array[0]) ? $array[0] : $this->config('default_action'); + + if (!empty($array[1])) { + $this->parseUrlParams($array[1], $param); + } + + return new CallbackDispatch($request, $this, [$class, $action], $param, $option); + } + + /** + * 绑定到命名空间 + * @access protected + * @param Request $request + * @param string $url URL地址 + * @param string $namespace 命名空间 + * @param array $param 路由变量 + * @param array $option 分组参数 + * @return CallbackDispatch + */ + protected function bindToNamespace(Request $request, string $url, string $namespace, array $param = [], array $option = []): CallbackDispatch + { + $array = explode('/', $url, 3); + $class = !empty($array[0]) ? $array[0] : $this->config('default_controller'); + $method = !empty($array[1]) ? $array[1] : $this->config('default_action'); + + if (!empty($array[2])) { + $this->parseUrlParams($array[2], $param); + } + + return new CallbackDispatch($request, $this, [trim($namespace, '\\') . '\\' . Str::studly($class), $method], $param, $option); + } + + /** + * 绑定到控制器 + * @access protected + * @param Request $request + * @param string $url URL地址 + * @param string $controller 控制器名 + * @param array $param 路由变量 + * @param array $option 分组参数 + * @return ControllerDispatch + */ + protected function bindToController(Request $request, string $url, string $controller, array $param = [], array $option = []): ControllerDispatch + { + $array = explode('/', $url, 2); + $action = !empty($array[0]) ? $array[0] : $this->config('default_action'); + + if (!empty($array[1])) { + $this->parseUrlParams($array[1], $param); + } + + return new ControllerDispatch($request, $this, [$controller, $action], $param, $option); + } + + /** + * 绑定到控制器分级 + * @access protected + * @param Request $request + * @param string $url URL地址 + * @param string $controller 控制器名 + * @param array $param 路由变量 + * @param array $option 分组参数 + * @return ControllerDispatch + */ + protected function bindToLayer(Request $request, string $url, string $layer, array $param = [], array $option = []): ControllerDispatch + { + $array = explode('/', $url, 3); + $controller = !empty($array[0]) ? $array[0] : $this->config('default_controller'); + $action = !empty($array[1]) ? $array[1] : $this->config('default_action'); + + if (!empty($array[2])) { + $this->parseUrlParams($array[2], $param); + } + + return new ControllerDispatch($request, $this, [$layer, $controller, $action], $param, $option); + } + + /** + * 添加分组下的路由规则 + * @access public + * @param string $rule 路由规则 + * @param mixed $route 路由地址 + * @param string $method 请求类型 + * @return RuleItem + */ + public function addRule(string $rule, $route = null, string $method = '*'): RuleItem + { + // 读取路由标识 + if (is_string($route)) { + $name = $route; + } else { + $name = null; + } + + $method = strtolower($method); + + if ('' === $rule || '/' === $rule) { + $rule .= '$'; + } + + // 创建路由规则实例 + $ruleItem = new RuleItem($this->router, $this, $name, $rule, $route, $method); + + $this->addRuleItem($ruleItem); + + return $ruleItem; + } + + /** + * 注册分组下的路由规则 + * @access public + * @param Rule $rule 路由规则 + * @return $this + */ + public function addRuleItem(Rule $rule) + { + $this->rules[] = $rule; + return $this; + } + + /** + * 设置分组的路由前缀 + * @access public + * @param string $prefix 路由前缀 + * @return $this + */ + public function prefix(string $prefix) + { + if ($this->parent && $this->parent->getOption('prefix')) { + $prefix = $this->parent->getOption('prefix') . $prefix; + } + + return $this->setOption('prefix', $prefix); + } + + /** + * 合并分组的路由规则正则 + * @access public + * @param bool $merge 是否合并 + * @return $this + */ + public function mergeRuleRegex(bool $merge = true) + { + return $this->setOption('merge_rule_regex', $merge); + } + + /** + * 设置分组的Dispatch调度 + * @access public + * @param string $dispatch 调度类 + * @return $this + */ + public function dispatcher(string $dispatch) + { + return $this->setOption('dispatcher', $dispatch); + } + + /** + * 获取完整分组Name + * @access public + * @return string + */ + public function getFullName(): string + { + return $this->fullName ?: ''; + } + + /** + * 获取分组的路由规则 + * @access public + * @param string $method 请求类型 + * @return array + */ + public function getRules(string $method = ''): array + { + if ('' === $method) { + return $this->rules; + } + + return array_filter($this->rules, function ($item) use ($method) { + $ruleMethod = $item->getMethod(); + return '*' == $ruleMethod || str_contains($ruleMethod, $method); + }); + } + + /** + * 清空分组下的路由规则 + * @access public + * @return void + */ + public function clear(): void + { + $this->rules = []; + } +} diff --git a/vendor/topthink/framework/src/think/route/RuleItem.php b/vendor/topthink/framework/src/think/route/RuleItem.php new file mode 100644 index 0000000..c53c77c --- /dev/null +++ b/vendor/topthink/framework/src/think/route/RuleItem.php @@ -0,0 +1,328 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +use think\Exception; +use think\facade\Validate; +use think\Request; +use think\Route; + +/** + * 路由规则类 + */ +class RuleItem extends Rule +{ + /** + * 是否为MISS规则 + * @var bool + */ + protected $miss = false; + + /** + * 是否为额外自动注册的OPTIONS规则 + * @var bool + */ + protected $autoOption = false; + + /** + * 架构函数 + * @access public + * @param Route $router 路由实例 + * @param RuleGroup $parent 上级对象 + * @param string $name 路由标识 + * @param string $rule 路由规则 + * @param string|\Closure $route 路由地址 + * @param string $method 请求类型 + */ + public function __construct(Route $router, RuleGroup $parent, ?string $name = null, string $rule = '', $route = null, string $method = '*') + { + $this->router = $router; + $this->parent = $parent; + $this->name = $name; + $this->route = $route; + $this->method = $method; + + $this->setRule($rule); + $this->router->setRule($this->rule, $this); + } + + /** + * 设置当前路由规则为MISS路由 + * @access public + * @return $this + */ + public function setMiss() + { + $this->miss = true; + return $this; + } + + /** + * 判断当前路由规则是否为MISS路由 + * @access public + * @return bool + */ + public function isMiss(): bool + { + return $this->miss; + } + + /** + * 获取当前路由的URL后缀 + * @access public + * @return string|null + */ + public function getSuffix(): ?string + { + if (isset($this->option['ext'])) { + $suffix = $this->option['ext']; + } elseif ($this->parent->getOption('ext')) { + $suffix = $this->parent->getOption('ext'); + } + + return $suffix ?? null; + } + + /** + * 路由规则预处理 + * @access public + * @param string $rule 路由规则 + * @return void + */ + public function setRule(string $rule): void + { + if (str_ends_with($rule, '$')) { + // 是否完整匹配 + $rule = substr($rule, 0, -1); + + $this->option['complete_match'] = true; + } + + $rule = '/' != $rule ? ltrim($rule, '/') : ''; + + if ($this->parent && $prefix = $this->parent->getFullName()) { + $rule = $prefix . ($rule ? '/' . ltrim($rule, '/') : ''); + } + + if (str_contains($rule, ':') || str_contains($rule, '{')) { + $this->rule = preg_replace(['/\[\:(\w+)\]/', '/\:(\w+)/', '/\{(\w+)\}/', '/\{(\w+)\?\}/'], ['<\1?>', '<\1>', '<\1>', '<\1?>'], $rule); + } else { + $this->rule = $rule; + } + + // 生成路由标识的快捷访问 + $this->setRuleName(); + } + + /** + * 设置别名 + * @access public + * @param string $name + * @return $this + */ + public function name(string $name) + { + $this->name = $name; + $this->setRuleName(true); + + return $this; + } + + /** + * 设置路由标识 用于URL反解生成 + * @access protected + * @param bool $first 是否插入开头 + * @return void + */ + protected function setRuleName(bool $first = false): void + { + if ($this->name) { + $this->router->setName($this->name, $this, $first); + } + } + + /** + * 检测路由 + * @access public + * @param Request $request 请求对象 + * @param string $url 访问地址 + * @param array $match 匹配路由变量 + * @param bool $completeMatch 路由是否完全匹配 + * @return Dispatch|false + */ + public function checkRule(Request $request, string $url, ?array $match = null, bool $completeMatch = false) + { + // 检查参数有效性 + if (!$this->checkOption($this->option, $request)) { + return false; + } + + // 合并分组参数 + $option = $this->getOption(); + $pattern = $this->getPattern(); + $url = $this->urlSuffixCheck($request, $url, $option); + + if (is_null($match)) { + $match = $this->checkMatch($url, $option, $pattern, $completeMatch); + } + + if (false !== $match) { + return $this->parseRule($request, $this->rule, $this->route, $url, $option, $match); + } + + return false; + } + + /** + * 检测路由(含路由匹配) + * @access public + * @param Request $request 请求对象 + * @param string $url 访问地址 + * @param bool $completeMatch 路由是否完全匹配 + * @return Dispatch|false + */ + public function check(Request $request, string $url, bool $completeMatch = false) + { + return $this->checkRule($request, $url, null, $completeMatch); + } + + /** + * URL后缀及Slash检查 + * @access protected + * @param Request $request 请求对象 + * @param string $url 访问地址 + * @param array $option 路由参数 + * @return string + */ + protected function urlSuffixCheck(Request $request, string $url, array $option = []): string + { + // 是否区分 / 地址访问 + if (!empty($option['remove_slash']) && '/' != $this->rule) { + $this->rule = rtrim($this->rule, '/'); + $url = rtrim($url, '|'); + } + + if (isset($option['ext'])) { + // 路由ext参数 优先于系统配置的URL伪静态后缀参数 + $url = preg_replace('/\.(' . $request->ext() . ')$/i', '', $url); + } + + return $url; + } + + /** + * 检测URL和规则路由是否匹配 + * @access private + * @param string $url URL地址 + * @param array $option 路由参数 + * @param array $pattern 变量规则 + * @param bool $completeMatch 是否完全匹配 + * @return array|false + */ + private function checkMatch(string $url, array $option, array $pattern, bool $completeMatch) + { + if (isset($option['complete_match'])) { + $completeMatch = $option['complete_match']; + } + + $depr = $this->config('pathinfo_depr'); + if (isset($option['case_sensitive'])) { + $case = $option['case_sensitive']; + } else { + $case = $this->config('url_case_sensitive'); + } + + // 检查完整规则定义 + if (isset($pattern['__url__']) && !preg_match(str_starts_with($pattern['__url__'], '/') ? $pattern['__url__'] : '/^' . $pattern['__url__'] . ($completeMatch ? '$' : '') . '/', str_replace('|', $depr, $url))) { + return false; + } + + $var = []; + $url = $depr . str_replace('|', $depr, $url); + $rule = $depr . str_replace('/', $depr, $this->rule); + + if ($depr == $rule && $depr != $url) { + return false; + } + + if (!str_contains($rule, '<')) { + // 静态路由 + if ($case && (0 === strcmp($rule, $url) || (!$completeMatch && 0 === strncmp($rule . $depr, $url . $depr, strlen($rule . $depr))))) { + return $var; + } elseif (!$case && (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule . $depr, $url . $depr, strlen($rule . $depr))))) { + return $var; + } + return false; + } + + $slash = preg_quote('/-' . $depr, '/'); + + if ($matchRule = preg_split('/[' . $slash . ']?<\w+\??>/', $rule, 2)) { + if ($matchRule[0] && 0 !== strncasecmp($rule, $url, strlen($matchRule[0]))) { + return false; + } + } + + if (preg_match_all('/[' . $slash . ']??/', $rule, $matches)) { + $regex = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $completeMatch); + + try { + if (!preg_match('~^' . $regex . '~u' . ($case ? '' : 'i'), $url, $match)) { + return false; + } + } catch (\Exception $e) { + throw new Exception('route pattern error'); + } + + foreach ($match as $key => $val) { + if (is_string($key)) { + if (isset($option['var_rule'][$key]) && !Validate::checkRule($val, $option['var_rule'][$key])) { + // 检查变量 + return false; + } + $var[$key] = $val; + } + } + } + + if (!empty($option['default'])) { + // 可选路由变量设置默认值 + foreach ($option['default'] as $name => $default) { + if (!isset($var[$name])) { + $var[$name] = $default; + } + } + } + + // 成功匹配后返回URL中的动态变量数组 + return $var; + } + + /** + * 设置路由所属分组(用于注解路由) + * @access public + * @param string $name 分组名称或者标识 + * @return $this + */ + public function group(string $name) + { + $group = $this->router->getRuleName()->getGroup($name); + + if ($group) { + $this->parent = $group; + $this->setRule($this->rule); + } + + return $this; + } +} diff --git a/vendor/topthink/framework/src/think/route/RuleName.php b/vendor/topthink/framework/src/think/route/RuleName.php new file mode 100644 index 0000000..b5907b3 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/RuleName.php @@ -0,0 +1,212 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\route; + +/** + * 路由标识管理类 + */ +class RuleName +{ + /** + * 路由标识 + * @var array + */ + protected $item = []; + + /** + * 路由规则 + * @var array + */ + protected $rule = []; + + /** + * 路由分组 + * @var array + */ + protected $group = []; + + /** + * 注册路由标识 + * @access public + * @param string $name 路由标识 + * @param RuleItem $ruleItem 路由规则 + * @param bool $first 是否优先 + * @return void + */ + public function setName(string $name, RuleItem $ruleItem, bool $first = false): void + { + $name = strtolower($name); + $item = $this->getRuleItemInfo($ruleItem); + if ($first && isset($this->item[$name])) { + array_unshift($this->item[$name], $item); + } else { + $this->item[$name][] = $item; + } + } + + /** + * 注册路由分组标识 + * @access public + * @param string $name 路由分组标识 + * @param RuleGroup $group 路由分组 + * @return void + */ + public function setGroup(string $name, RuleGroup $group): void + { + $this->group[strtolower($name)] = $group; + } + + /** + * 注册路由规则 + * @access public + * @param string $rule 路由规则 + * @param RuleItem $ruleItem 路由 + * @return void + */ + public function setRule(string $rule, RuleItem $ruleItem): void + { + $route = $ruleItem->getRoute(); + + if (is_string($route)) { + $this->rule[$rule][$route] = $ruleItem; + } else { + $this->rule[$rule][] = $ruleItem; + } + } + + /** + * 根据路由规则获取路由对象(列表) + * @access public + * @param string $rule 路由标识 + * @return RuleItem[] + */ + public function getRule(string $rule): array + { + return $this->rule[$rule] ?? []; + } + + /** + * 根据路由分组标识获取分组 + * @access public + * @param string $name 路由分组标识 + * @return RuleGroup|null + */ + public function getGroup(string $name): ?RuleGroup + { + return $this->group[strtolower($name)] ?? null; + } + + /** + * 清空路由规则 + * @access public + * @return void + */ + public function clear(): void + { + $this->item = []; + $this->rule = []; + $this->group = []; + } + + /** + * 获取全部路由列表 + * @access public + * @return array + */ + public function getRuleList(): array + { + $list = []; + + foreach ($this->rule as $rule => $rules) { + foreach ($rules as $item) { + $val = []; + + foreach (['method', 'rule', 'name', 'route', 'domain', 'pattern', 'option'] as $param) { + $call = 'get' . $param; + $val[$param] = $item->$call(); + } + + if ($item->isMiss()) { + $val['rule'] .= ''; + } + + $list[] = $val; + } + } + + return $list; + } + + /** + * 导入路由标识 + * @access public + * @param array $item 路由标识 + * @return void + */ + public function import(array $item): void + { + $this->item = $item; + } + + /** + * 根据路由标识获取路由信息(用于URL生成) + * @access public + * @param string $name 路由标识 + * @param string $domain 域名 + * @param string $method 请求类型 + * @return array + */ + public function getName(?string $name = null, ?string $domain = null, string $method = '*'): array + { + if (is_null($name)) { + return $this->item; + } + + $name = strtolower($name); + $method = strtolower($method); + $result = []; + + if (isset($this->item[$name])) { + if (is_null($domain)) { + $result = $this->item[$name]; + } else { + foreach ($this->item[$name] as $item) { + $itemDomain = $item['domain']; + $itemMethod = $item['method']; + + if (($itemDomain == $domain || '-' == $itemDomain) && ('*' == $itemMethod || '*' == $method || $method == $itemMethod)) { + $result[] = $item; + } + } + } + } + + return $result; + } + + /** + * 获取路由信息 + * @access protected + * @param RuleItem $item 路由规则 + * @return array + */ + protected function getRuleItemInfo(RuleItem $item): array + { + return [ + 'rule' => $item->getRule(), + 'domain' => $item->getDomain(), + 'method' => $item->getMethod(), + 'suffix' => $item->getSuffix(), + ]; + } +} diff --git a/vendor/topthink/framework/src/think/route/Url.php b/vendor/topthink/framework/src/think/route/Url.php new file mode 100644 index 0000000..6090c30 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/Url.php @@ -0,0 +1,478 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\route; + +use think\App; +use think\Route; + +/** + * 路由地址生成 + */ +class Url +{ + /** + * URL 根地址 + * @var string + */ + protected $root = ''; + + /** + * HTTPS + * @var bool + */ + protected $https; + + /** + * URL后缀 + * @var string|bool + */ + protected $suffix = true; + + /** + * URL域名 + * @var string|bool + */ + protected $domain = false; + + /** + * 架构函数 + * @access public + * @param Route $route 路由对象 + * @param App $app App对象 + * @param string $url URL地址 + * @param array $vars 参数 + */ + public function __construct(protected Route $route, protected App $app, protected string $url = '', protected array $vars = []) + { + } + + /** + * 设置URL参数 + * @access public + * @param array $vars URL参数 + * @return $this + */ + public function vars(array $vars = []) + { + $this->vars = $vars; + return $this; + } + + /** + * 设置URL后缀 + * @access public + * @param string|bool $suffix URL后缀 + * @return $this + */ + public function suffix(string|bool $suffix) + { + $this->suffix = $suffix; + return $this; + } + + /** + * 设置URL域名(或者子域名) + * @access public + * @param string|bool $domain URL域名 + * @return $this + */ + public function domain(string|bool $domain) + { + $this->domain = $domain; + return $this; + } + + /** + * 设置URL 根地址 + * @access public + * @param string $root URL root + * @return $this + */ + public function root(string $root) + { + $this->root = $root; + return $this; + } + + /** + * 设置是否使用HTTPS + * @access public + * @param bool $https + * @return $this + */ + public function https(bool $https = true) + { + $this->https = $https; + return $this; + } + + /** + * 检测域名 + * @access protected + * @param string $url URL + * @param string|true $domain 域名 + * @return string + */ + protected function parseDomain(string &$url, string|bool $domain): string + { + if (!$domain) { + return ''; + } + + $request = $this->app->request; + $rootDomain = $request->rootDomain(); + + if (true === $domain) { + // 自动判断域名 + $domain = $request->host(); + $domains = $this->route->getDomains(); + + if (!empty($domains)) { + $routeDomain = array_keys($domains); + foreach ($routeDomain as $domainPrefix) { + if (str_starts_with($domainPrefix, '*.') && str_contains($domain, ltrim($domainPrefix, '*.')) !== false) { + foreach ($domains as $key => $rule) { + $rule = is_array($rule) ? $rule[0] : $rule; + if (is_string($rule) && !str_contains($key, '*') && str_starts_with($url, $rule)) { + $url = ltrim($url, $rule); + $domain = $key; + + // 生成对应子域名 + if (!empty($rootDomain)) { + $domain .= $rootDomain; + } + break; + } elseif (str_contains($key, '*')) { + if (!empty($rootDomain)) { + $domain .= $rootDomain; + } + + break; + } + } + } + } + } + } elseif (!str_contains($domain, '.') && !str_starts_with($domain, $rootDomain)) { + $domain .= '.' . $rootDomain; + } + + if (str_contains($domain, '://')) { + $scheme = ''; + } else { + $scheme = $this->https || $request->isSsl() ? 'https://' : 'http://'; + } + + return $scheme . $domain; + } + + /** + * 解析URL后缀 + * @access protected + * @param string|bool $suffix 后缀 + * @return string + */ + protected function parseSuffix(string|bool $suffix): string + { + if ($suffix) { + $suffix = true === $suffix ? $this->route->config('url_html_suffix') : $suffix; + + if (is_string($suffix) && $pos = strpos($suffix, '|')) { + $suffix = substr($suffix, 0, $pos); + } + } + + return (empty($suffix) || str_starts_with($suffix, '.')) ? (string) $suffix : '.' . $suffix; + } + + /** + * 直接解析URL地址 + * @access protected + * @param string $url URL + * @param string|bool $domain Domain + * @return string + */ + protected function parseUrl(string $url, string | bool &$domain): string + { + $request = $this->app->request; + + if (str_starts_with($url, '/')) { + // 直接作为路由地址解析 + $url = substr($url, 1); + } elseif ('' === $url) { + $url = $request->pathinfo(); + } else { + $controller = $request->controller(); + $path = explode('/', $url); + $action = array_pop($path); + $controller = empty($path) ? $controller : array_pop($path); + $url = $controller . '/' . $action; + $auto = $this->route->getName('__think_auto_route__'); + if (!empty($auto) && !strpos($controller,'.')) { + $module = empty($path) ? $request->layer() : array_pop($path); + $url = $module . '/' . $url; + } + } + + return $url; + } + + /** + * 分析路由规则中的变量 + * @access protected + * @param string $rule 路由规则 + * @return array + */ + protected function parseVar(string $rule): array + { + // 提取路由规则中的变量 + $var = []; + + if (preg_match_all('/<\w+\??>/', $rule, $matches)) { + foreach ($matches[0] as $name) { + $optional = false; + + if (str_contains($name, '?')) { + $name = substr($name, 1, -2); + $optional = true; + } else { + $name = substr($name, 1, -1); + } + + $var[$name] = $optional ? 2 : 1; + } + } + + return $var; + } + + /** + * 匹配路由地址 + * @access protected + * @param array $rule 路由规则 + * @param array $vars 路由变量 + * @param string|bool $allowDomain 允许域名 + * @return array + */ + protected function getRuleUrl(array $rule, array &$vars = [], string|bool $allowDomain = ''): array + { + $request = $this->app->request; + if (is_string($allowDomain) && !str_contains($allowDomain, '.')) { + $allowDomain .= '.' . $request->rootDomain(); + } + $port = $request->port(); + + foreach ($rule as $item) { + $url = $item['rule']; + $pattern = $this->parseVar($url); + $domain = $item['domain']; + $suffix = $item['suffix']; + + if ('-' == $domain) { + $domain = is_string($allowDomain) ? $allowDomain : $request->host(true); + } + + if (is_string($allowDomain) && $domain != $allowDomain) { + continue; + } + + if ($port && !in_array($port, [80, 443])) { + $domain .= ':' . $port; + } + + if (empty($pattern)) { + return [rtrim($url, '?-'), $domain, $suffix]; + } + + $type = $this->route->config('url_common_param'); + $keys = []; + + foreach ($pattern as $key => $val) { + if (isset($vars[$key])) { + $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? (string) $vars[$key] : urlencode((string) $vars[$key]), $url); + $keys[] = $key; + $url = str_replace(['/?', '-?'], ['/', '-'], $url); + $result = [rtrim($url, '?-'), $domain, $suffix]; + } elseif (2 == $val) { + $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); + $url = str_replace(['/?', '-?'], ['/', '-'], $url); + $result = [rtrim($url, '?-'), $domain, $suffix]; + } else { + $result = null; + $keys = []; + break; + } + } + + $vars = array_diff_key($vars, array_flip($keys)); + + if (isset($result)) { + return $result; + } + } + + return []; + } + + /** + * 生成URL地址 + * @access public + * @return string + */ + public function build(): string + { + // 解析URL + $url = $this->url; + $suffix = $this->suffix; + $domain = $this->domain; + $request = $this->app->request; + $vars = $this->vars; + + if (str_starts_with($url, '[') && $pos = strpos($url, ']')) { + // [name] 表示使用路由命名标识生成URL + $name = substr($url, 1, $pos - 1); + $url = 'name' . substr($url, $pos + 1); + } + + if (!str_contains($url, '://') && !str_starts_with($url, '/')) { + $info = parse_url($url); + $url = !empty($info['path']) ? $info['path'] : ''; + + if (isset($info['fragment'])) { + // 解析锚点 + $anchor = $info['fragment']; + + if (str_contains($anchor, '?')) { + // 解析参数 + [$anchor, $info['query']] = explode('?', $anchor, 2); + } + + if (str_contains($anchor, '@')) { + // 解析域名 + [$anchor, $domain] = explode('@', $anchor, 2); + } + } elseif (str_contains($url, '@') && !str_contains($url, '\\')) { + // 解析域名 + [$url, $domain] = explode('@', $url, 2); + } + } + + if ($url) { + $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); + $checkDomain = $domain && is_string($domain) ? $domain : null; + + $rule = $this->route->getName($checkName, $checkDomain); + + if (empty($rule) && isset($info['query'])) { + $rule = $this->route->getName($url, $checkDomain); + // 解析地址里面参数 合并到vars + parse_str($info['query'], $params); + $vars = array_merge($params, $vars); + unset($info['query']); + } + } + + if (!empty($rule) && $match = $this->getRuleUrl($rule, $vars, $domain)) { + // 匹配路由命名标识 + $url = $match[0]; + + if ($domain && !empty($match[1])) { + $domain = $match[1]; + } + + if (!is_null($match[2])) { + $suffix = $match[2]; + } + } elseif (!empty($rule) && isset($name)) { + throw new \InvalidArgumentException('route name not exists:' . $name); + } else { + // 检测URL绑定 + $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); + + if ($bind && str_starts_with($url, $bind)) { + $url = substr($url, strlen($bind) + 1); + } + + // 路由标识不存在 直接解析 + $url = $this->parseUrl($url, $domain); + + if (isset($info['query'])) { + // 解析地址里面参数 合并到vars + parse_str($info['query'], $params); + $vars = array_merge($params, $vars); + } + } + + // 还原URL分隔符 + $depr = $this->route->config('pathinfo_depr'); + $url = str_replace('/', $depr, $url); + + $file = $request->baseFile(); + if ($file && !str_starts_with($request->url(), $file)) { + $file = str_replace('\\', '/', dirname($file)); + } + + $url = rtrim($file, '/') . '/' . $url; + + // URL后缀 + if (str_ends_with($url, '/') || '' == $url) { + $suffix = ''; + } else { + $suffix = $this->parseSuffix($suffix); + } + + // 锚点 + $anchor = !empty($anchor) ? '#' . $anchor : ''; + + // 参数组装 + if (!empty($vars)) { + // 添加参数 + if ($this->route->config('url_common_param')) { + $vars = http_build_query($vars); + $url .= $suffix . ($vars ? '?' . $vars : '') . $anchor; + } else { + foreach ($vars as $var => $val) { + $val = (string) $val; + if ('' !== $val) { + $url .= $depr . $var . $depr . urlencode($val); + } + } + + $url .= $suffix . $anchor; + } + } else { + $url .= $suffix . $anchor; + } + + // 检测域名 + $domain = $this->parseDomain($url, $domain); + + // URL组装 + return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); + } + + public function __toString() + { + return $this->build(); + } + + public function __debugInfo() + { + return [ + 'url' => $this->url, + 'vars' => $this->vars, + 'suffix' => $this->suffix, + 'domain' => $this->domain, + ]; + } +} diff --git a/vendor/topthink/framework/src/think/route/dispatch/Callback.php b/vendor/topthink/framework/src/think/route/dispatch/Callback.php new file mode 100644 index 0000000..9f7175d --- /dev/null +++ b/vendor/topthink/framework/src/think/route/dispatch/Callback.php @@ -0,0 +1,65 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route\dispatch; + +use think\exception\ClassNotFoundException; +use think\route\Dispatch; + +/** + * Callback Dispatcher + */ +class Callback extends Dispatch +{ + public function exec() + { + // 执行回调方法 + if (is_array($this->dispatch)) { + [$class, $action] = $this->dispatch; + + // 设置当前请求的控制器、操作 + $controllerLayer = $this->rule->config('controller_layer') ?: 'controller'; + if (str_contains($class, '\\' . $controllerLayer . '\\')) { + [$layer, $controller] = explode('/' . $controllerLayer . '/', trim(str_replace('\\', '/', $class), '/')); + $layer = trim(str_replace('app', '', $layer), '/'); + } else { + $layer = ''; + $controller = trim(str_replace('\\', '/', $class), '/'); + } + + if ($layer && !empty($this->option['auto_middleware'])) { + // 自动为顶层layer注册中间件 + $alias = $this->app->config->get('middleware.alias', []); + + if (isset($alias[$layer])) { + $this->app->middleware->add($layer, 'route'); + } + } + + $this->request + ->setLayer($layer) + ->setController($controller) + ->setAction($action); + + if (class_exists($class)) { + $instance = $this->app->invokeClass($class); + } else { + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + + return $this->responseWithMiddlewarePipeline($instance, $action); + } + + $vars = $this->getActionBindVars(); + return $this->app->invoke($this->dispatch, $vars); + } +} diff --git a/vendor/topthink/framework/src/think/route/dispatch/Controller.php b/vendor/topthink/framework/src/think/route/dispatch/Controller.php new file mode 100644 index 0000000..c611a90 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/dispatch/Controller.php @@ -0,0 +1,115 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route\dispatch; + +use think\App; +use think\exception\ClassNotFoundException; +use think\exception\HttpException; +use think\helper\Str; +use think\route\Dispatch; + +/** + * Controller Dispatcher + */ +class Controller extends Dispatch +{ + /** + * 控制器名 + * @var string + */ + protected $controller; + + /** + * 操作名 + * @var string + */ + protected $actionName; + + public function init(App $app) + { + parent::init($app); + + $path = $this->dispatch; + if (is_string($path)) { + $path = explode('/', $path); + } + + $action = !empty($path) ? array_pop($path) : $this->rule->config('default_action'); + $controller = !empty($path) ? array_pop($path) : $this->rule->config('default_controller'); + $layer = !empty($path) ? implode('/', $path) : ''; + + if ($layer && !empty($this->option['auto_middleware'])) { + // 自动为顶层layer注册中间件 + $alias = $app->config->get('middleware.alias', []); + + if (isset($alias[$layer])) { + $this->app->middleware->add($layer, 'route'); + } + } + + // 获取控制器名和分层(目录)名 + if (str_contains($controller, '.')) { + $pos = strrpos($controller, '.'); + $layer = ($layer ? $layer . '.' : '') . substr($controller, 0, $pos); + $controller = Str::studly(substr($controller, $pos + 1)); + } else { + $controller = Str::studly($controller); + } + + $this->actionName = strip_tags($action); + $this->controller = strip_tags(($layer ? $layer . '.' : '') . $controller); + + // 设置当前请求的控制器、操作 + $this->request + ->setLayer(strip_tags($layer)) + ->setController($this->controller) + ->setAction($this->actionName); + } + + public function exec() + { + try { + // 实例化控制器 + $instance = $this->controller($this->controller); + } catch (ClassNotFoundException $e) { + throw new HttpException(404, 'controller not exists:' . $e->getClass()); + } + + return $this->responseWithMiddlewarePipeline($instance, $this->actionName); + } + + /** + * 实例化访问控制器 + * @access public + * @param string $name 资源地址 + * @return object + * @throws ClassNotFoundException + */ + public function controller(string $name) + { + $suffix = $this->rule->config('controller_suffix') ? 'Controller' : ''; + + $controllerLayer = $this->rule->config('controller_layer') ?: 'controller'; + $emptyController = $this->rule->config('empty_controller') ?: 'Error'; + + $class = $this->app->parseClass($controllerLayer, $name . $suffix); + + if (class_exists($class)) { + return $this->app->make($class, [], true); + } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController . $suffix))) { + return $this->app->make($emptyClass, [], true); + } + + throw new ClassNotFoundException('class not exists:' . $class, $class); + } +} diff --git a/vendor/topthink/framework/src/think/service/ModelService.php b/vendor/topthink/framework/src/think/service/ModelService.php new file mode 100644 index 0000000..eebb4a6 --- /dev/null +++ b/vendor/topthink/framework/src/think/service/ModelService.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\service; + +use think\Model; +use think\Service; + +/** + * 模型服务类 + */ +class ModelService extends Service +{ + public function boot() + { + Model::setDb($this->app->db); + Model::setEvent($this->app->event); + Model::setInvoker([$this->app, 'invoke']); + Model::maker(function (Model $model) { + $config = $this->app->config; + + $isAutoWriteTimestamp = $model->getAutoWriteTimestamp(); + + if (is_null($isAutoWriteTimestamp)) { + // 自动写入时间戳 + $model->isAutoWriteTimestamp($config->get('database.auto_timestamp', 'timestamp')); + } + + $dateFormat = $model->getDateFormat(); + + if (is_null($dateFormat)) { + // 设置时间戳格式 + $model->setDateFormat($config->get('database.datetime_format', 'Y-m-d H:i:s')); + } + + $timeField = $config->get('database.datetime_field'); + if (!empty($timeField)) { + [$createTime, $updateTime] = explode(',', $timeField); + $model->setTimeField($createTime, $updateTime); + } + }); + } +} diff --git a/vendor/topthink/framework/src/think/service/PaginatorService.php b/vendor/topthink/framework/src/think/service/PaginatorService.php new file mode 100644 index 0000000..ab10a0c --- /dev/null +++ b/vendor/topthink/framework/src/think/service/PaginatorService.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\service; + +use think\Paginator; +use think\paginator\driver\Bootstrap; +use think\Service; + +/** + * 分页服务类 + */ +class PaginatorService extends Service +{ + public function register() + { + if (!$this->app->bound(Paginator::class)) { + $this->app->bind(Paginator::class, Bootstrap::class); + } + } + + public function boot() + { + Paginator::maker(function (...$args) { + return $this->app->make(Paginator::class, $args, true); + }); + + Paginator::currentPathResolver(function () { + return $this->app->request->baseUrl(); + }); + + Paginator::currentPageResolver(function ($varPage = 'page') { + + $page = $this->app->request->param($varPage); + + if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { + return (int) $page; + } + + return 1; + }); + } +} diff --git a/vendor/topthink/framework/src/think/service/ValidateService.php b/vendor/topthink/framework/src/think/service/ValidateService.php new file mode 100644 index 0000000..e5c7dc7 --- /dev/null +++ b/vendor/topthink/framework/src/think/service/ValidateService.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\service; + +use think\Service; +use think\Validate; + +/** + * 验证服务类 + */ +class ValidateService extends Service +{ + public function boot() + { + Validate::maker(function (Validate $validate) { + $validate->setLang($this->app->lang); + $validate->setDb($this->app->db); + $validate->setRequest($this->app->request); + }); + } +} diff --git a/vendor/topthink/framework/src/think/session/Store.php b/vendor/topthink/framework/src/think/session/Store.php new file mode 100644 index 0000000..1e28caf --- /dev/null +++ b/vendor/topthink/framework/src/think/session/Store.php @@ -0,0 +1,325 @@ + +// +---------------------------------------------------------------------- + +namespace think\session; + +use think\contract\SessionHandlerInterface; +use think\helper\Arr; + +class Store +{ + /** + * Session数据 + * @var array + */ + protected $data = []; + + /** + * 是否初始化 + * @var bool + */ + protected $init = null; + + /** + * 记录Session Id + * @var string + */ + protected $id; + + /** @var array */ + protected $serialize = []; + + public function __construct(protected string $name, protected SessionHandlerInterface $handler, ?array $serialize = null) + { + if (!empty($serialize)) { + $this->serialize = $serialize; + } + + $this->setId(); + } + + /** + * 设置数据 + * @access public + * @param array $data + * @return void + */ + public function setData(array $data): void + { + $this->data = $data; + } + + /** + * session初始化 + * @access public + * @return void + */ + public function init(): void + { + // 读取缓存数据 + $data = $this->handler->read($this->getId()); + + if (!empty($data)) { + $this->data = array_merge($this->data, $this->unserialize($data)); + } + + $this->init = true; + } + + /** + * 设置SessionName + * @access public + * @param string $name session_name + * @return void + */ + public function setName(string $name): void + { + $this->name = $name; + } + + /** + * 获取sessionName + * @access public + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * session_id设置 + * @access public + * @param string $id session_id + * @return void + */ + public function setId(?string $id = null): void + { + $this->id = is_string($id) && strlen($id) === 32 && ctype_alnum($id) ? $id : md5(microtime(true) . session_create_id()); + } + + /** + * 获取session_id + * @access public + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * 获取所有数据 + * @return array + */ + public function all(): array + { + return $this->data; + } + + /** + * session设置 + * @access public + * @param string $name session名称 + * @param mixed $value session值 + * @return void + */ + public function set(string $name, $value): void + { + Arr::set($this->data, $name, $value); + } + + /** + * session获取 + * @access public + * @param string $name session名称 + * @param mixed $default 默认值 + * @return mixed + */ + public function get(string $name, $default = null) + { + return Arr::get($this->data, $name, $default); + } + + /** + * session获取并删除 + * @access public + * @param string $name session名称 + * @param mixed $default 默认值 + * @return mixed + */ + public function pull(string $name, $default = null) + { + return Arr::pull($this->data, $name, $default); + } + + /** + * 添加数据到一个session数组 + * @access public + * @param string $key + * @param mixed $value + * @return void + */ + public function push(string $key, $value): void + { + $array = $this->get($key, []); + + $array[] = $value; + + $this->set($key, $array); + } + + /** + * 判断session数据 + * @access public + * @param string $name session名称 + * @return bool + */ + public function has(string $name): bool + { + return Arr::has($this->data, $name); + } + + /** + * 删除session数据 + * @access public + * @param string $name session名称 + * @return void + */ + public function delete(string $name): void + { + Arr::forget($this->data, $name); + } + + /** + * 清空session数据 + * @access public + * @return void + */ + public function clear(): void + { + $this->data = []; + } + + /** + * 销毁session + */ + public function destroy(): void + { + $this->clear(); + + $this->regenerate(true); + } + + /** + * 重新生成session id + * @param bool $destroy + */ + public function regenerate(bool $destroy = false): void + { + if ($destroy) { + $this->handler->delete($this->getId()); + } + + $this->setId(); + } + + /** + * 保存session数据 + * @access public + * @return void + */ + public function save(): void + { + $this->clearFlashData(); + + $sessionId = $this->getId(); + + if (!empty($this->data)) { + $data = $this->serialize($this->data); + + $this->handler->write($sessionId, $data); + } else { + $this->handler->delete($sessionId); + } + + $this->init = false; + } + + /** + * session设置 下一次请求有效 + * @access public + * @param string $name session名称 + * @param mixed $value session值 + * @return void + */ + public function flash(string $name, $value): void + { + $this->set($name, $value); + $this->push('__flash__.__next__', $name); + $this->set('__flash__.__current__', Arr::except($this->get('__flash__.__current__', []), $name)); + } + + /** + * 将本次闪存数据推迟到下次请求 + * + * @return void + */ + public function reflash(): void + { + $keys = $this->get('__flash__.__current__', []); + $values = array_unique(array_merge($this->get('__flash__.__next__', []), $keys)); + $this->set('__flash__.__next__', $values); + $this->set('__flash__.__current__', []); + } + + /** + * 清空当前请求的session数据 + * @access public + * @return void + */ + public function clearFlashData(): void + { + Arr::forget($this->data, $this->get('__flash__.__current__', [])); + if (!empty($next = $this->get('__flash__.__next__', []))) { + $this->set('__flash__.__current__', $next); + } else { + $this->delete('__flash__.__current__'); + } + $this->delete('__flash__.__next__'); + } + + /** + * 序列化数据 + * @access protected + * @param mixed $data + * @return string + */ + protected function serialize($data): string + { + $serialize = $this->serialize[0] ?? 'serialize'; + + return $serialize($data); + } + + /** + * 反序列化数据 + * @access protected + * @param string $data + * @return array + */ + protected function unserialize(string $data): array + { + $unserialize = $this->serialize[1] ?? 'unserialize'; + + return (array) $unserialize($data); + } +} diff --git a/vendor/topthink/framework/src/think/session/driver/Cache.php b/vendor/topthink/framework/src/think/session/driver/Cache.php new file mode 100644 index 0000000..c5560f0 --- /dev/null +++ b/vendor/topthink/framework/src/think/session/driver/Cache.php @@ -0,0 +1,50 @@ + +// +---------------------------------------------------------------------- +namespace think\session\driver; + +use Psr\SimpleCache\CacheInterface; +use think\contract\SessionHandlerInterface; +use think\helper\Arr; + +class Cache implements SessionHandlerInterface +{ + + /** @var CacheInterface */ + protected $handler; + + /** @var integer */ + protected $expire; + + /** @var string */ + protected $prefix; + + public function __construct(\think\Cache $cache, array $config = []) + { + $this->handler = $cache->store(Arr::get($config, 'store')); + $this->expire = Arr::get($config, 'expire', 1440); + $this->prefix = Arr::get($config, 'prefix', ''); + } + + public function read(string $sessionId): string + { + return (string) $this->handler->get($this->prefix . $sessionId); + } + + public function delete(string $sessionId): bool + { + return $this->handler->delete($this->prefix . $sessionId); + } + + public function write(string $sessionId, string $data): bool + { + return $this->handler->set($this->prefix . $sessionId, $data, $this->expire); + } +} diff --git a/vendor/topthink/framework/src/think/session/driver/File.php b/vendor/topthink/framework/src/think/session/driver/File.php new file mode 100644 index 0000000..84bc374 --- /dev/null +++ b/vendor/topthink/framework/src/think/session/driver/File.php @@ -0,0 +1,248 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\session\driver; + +use Closure; +use Exception; +use FilesystemIterator; +use Generator; +use SplFileInfo; +use think\App; +use think\contract\SessionHandlerInterface; + +/** + * Session 文件驱动 + */ +class File implements SessionHandlerInterface +{ + protected $config = [ + 'path' => '', + 'expire' => 1440, + 'prefix' => '', + 'data_compress' => false, + 'gc_probability' => 1, + 'gc_divisor' => 100, + ]; + + public function __construct(App $app, array $config = []) + { + $this->config = array_merge($this->config, $config); + + if (empty($this->config['path'])) { + $this->config['path'] = $app->getRuntimePath() . 'session' . DIRECTORY_SEPARATOR; + } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { + $this->config['path'] .= DIRECTORY_SEPARATOR; + } + + $this->init(); + } + + /** + * 打开Session + * @access protected + * @throws Exception + */ + protected function init(): void + { + try { + !is_dir($this->config['path']) && mkdir($this->config['path'], 0755, true); + } catch (Exception $e) { + // 写入失败 + } + + // 垃圾回收 + if (random_int(1, $this->config['gc_divisor']) <= $this->config['gc_probability']) { + $this->gc(); + } + } + + /** + * Session 垃圾回收 + * @access public + * @return void + */ + public function gc(): void + { + $lifetime = $this->config['expire']; + $now = time(); + + $files = $this->findFiles($this->config['path'], function (SplFileInfo $item) use ($lifetime, $now) { + return $now - $lifetime > $item->getMTime(); + }); + + foreach ($files as $file) { + $this->unlink($file->getPathname()); + } + } + + /** + * 查找文件 + * @param string $root + * @param Closure $filter + * @return Generator + */ + protected function findFiles(string $root, Closure $filter) + { + $items = new FilesystemIterator($root); + + /** @var SplFileInfo $item */ + foreach ($items as $item) { + if ($item->isDir() && !$item->isLink()) { + yield from $this->findFiles($item->getPathname(), $filter); + } else { + if ($filter($item)) { + yield $item; + } + } + } + } + + /** + * 取得变量的存储文件名 + * @access protected + * @param string $name 缓存变量名 + * @param bool $auto 是否自动创建目录 + * @return string + */ + protected function getFileName(string $name, bool $auto = false): string + { + if ($this->config['prefix']) { + // 使用子目录 + $name = $this->config['prefix'] . DIRECTORY_SEPARATOR . 'sess_' . $name; + } else { + $name = 'sess_' . $name; + } + + $filename = $this->config['path'] . $name; + $dir = dirname($filename); + + if ($auto && !is_dir($dir)) { + try { + mkdir($dir, 0755, true); + } catch (Exception $e) { + // 创建失败 + } + } + + return $filename; + } + + /** + * 读取Session + * @access public + * @param string $sessID + * @return string + */ + public function read(string $sessID): string + { + $filename = $this->getFileName($sessID); + + if (is_file($filename) && filemtime($filename) >= time() - $this->config['expire']) { + $content = $this->readFile($filename); + + if ($this->config['data_compress'] && function_exists('gzcompress')) { + //启用数据压缩 + $content = (string) gzuncompress($content); + } + + return $content; + } + + return ''; + } + + /** + * 写文件(加锁) + * @param $path + * @param $content + * @return bool + */ + protected function writeFile($path, $content): bool + { + return (bool) file_put_contents($path, $content, LOCK_EX); + } + + /** + * 读取文件内容(加锁) + * @param $path + * @return string + */ + protected function readFile($path): string + { + $contents = ''; + + $handle = fopen($path, 'rb'); + + if ($handle) { + try { + if (flock($handle, LOCK_SH)) { + clearstatcache(true, $path); + + $contents = fread($handle, filesize($path) ?: 1); + + flock($handle, LOCK_UN); + } + } finally { + fclose($handle); + } + } + + return $contents; + } + + /** + * 写入Session + * @access public + * @param string $sessID + * @param string $sessData + * @return bool + */ + public function write(string $sessID, string $sessData): bool + { + $filename = $this->getFileName($sessID, true); + $data = $sessData; + + if ($this->config['data_compress'] && function_exists('gzcompress')) { + //数据压缩 + $data = gzcompress($data, 3); + } + + return $this->writeFile($filename, $data); + } + + /** + * 删除Session + * @access public + * @param string $sessID + * @return bool + */ + public function delete(string $sessID): bool + { + try { + return $this->unlink($this->getFileName($sessID)); + } catch (Exception $e) { + return false; + } + } + + /** + * 判断文件是否存在后,删除 + * @access private + * @param string $file + * @return bool + */ + private function unlink(string $file): bool + { + return is_file($file) && unlink($file); + } +} diff --git a/vendor/topthink/framework/src/think/view/driver/Php.php b/vendor/topthink/framework/src/think/view/driver/Php.php new file mode 100644 index 0000000..6cb00ab --- /dev/null +++ b/vendor/topthink/framework/src/think/view/driver/Php.php @@ -0,0 +1,209 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\view\driver; + +use RuntimeException; +use think\App; +use think\contract\TemplateHandlerInterface; +use think\helper\Str; + +/** + * PHP原生模板驱动 + */ +class Php implements TemplateHandlerInterface +{ + protected $template; + protected $content; + protected $app; + + // 模板引擎参数 + protected $config = [ + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 + 'auto_rule' => 1, + // 视图目录名 + 'view_dir_name' => 'view', + // 应用模板路径 + 'view_path' => '', + // 模板文件后缀 + 'view_suffix' => 'php', + // 模板文件名分隔符 + 'view_depr' => DIRECTORY_SEPARATOR, + ]; + + public function __construct(App $app, array $config = []) + { + $this->app = $app; + $this->config = array_merge($this->config, (array) $config); + } + + /** + * 检测是否存在模板文件 + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists(string $template): bool + { + $template = $this->getTemplateFile($template); + + return is_file($template); + } + + protected function getTemplateFile(string $template): string + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } elseif (!is_file($template)) { + $path = $this->config['view_path'] ?: $this->getViewPath($this->app->http->getName()); + $template = $path . $template; + } + + return $template; + } + + /** + * 渲染模板文件 + * @param string $template 模板文件 + * @param array $data 模板变量 + * @return void + */ + public function fetch(string $template, array $data = []): void + { + $template = $this->getTemplateFile($template); + + // 模板不存在 抛出异常 + if (!is_file($template)) { + throw new RuntimeException('template not exists:' . $template); + } + + $this->template = $template; + + extract($data, EXTR_OVERWRITE); + + include $this->template; + } + + /** + * 渲染模板内容 + * @param string $content 模板内容 + * @param array $data 模板变量 + * @return void + */ + public function display(string $content, array $data = []): void + { + $this->content = $content; + + extract($data, EXTR_OVERWRITE); + eval('?>' . $this->content); + } + + protected function getViewPath(string $app): string + { + $view = $this->config['view_dir_name'] . DIRECTORY_SEPARATOR; + $app = $app ? str_replace('.', DIRECTORY_SEPARATOR, $app) . DIRECTORY_SEPARATOR : ''; + $paths = [ + $this->app->getBasePath() . $app . $view, + $this->app->getBasePath() . $view . $app, + $this->app->getRootPath() . $view . $app + ]; + + foreach ($paths as $path) { + if (is_dir($path)) { + return $path; + } + } + + return ''; + } + + /** + * 自动定位模板文件 + * @param string $template 模板文件规则 + * @return string + */ + private function parseTemplate(string $template): string + { + $request = $this->app->request; + + // 获取视图根目录 + if (str_contains($template, '@')) { + // 跨应用调用 + [$app, $template] = explode('@', $template); + } elseif ($this->app->http->getName()) { + $app = $this->app->http->getName(); + } elseif ($request->layer()) { + $app = $request->layer(); + $controller = $request->controller(false, true); + } + + if ($this->config['view_path']) { + $path = $this->config['view_path']; + } else { + $path = $this->getViewPath($app ?? $this->app->http->getName()); + } + + $depr = $this->config['view_depr']; + + if (!str_starts_with($template, '/')) { + $template = str_replace(['/', ':'], $depr, $template); + $controller = $controller ?? $request->controller(); + if (str_contains($controller, '.')) { + $pos = strrpos($controller, '.'); + $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); + } else { + $controller = Str::snake($controller); + } + + if ($controller) { + if ('' == $template) { + // 如果模板文件名为空 按照默认规则定位 + if (2 == $this->config['auto_rule']) { + $template = $request->action(true); + } elseif (3 == $this->config['auto_rule']) { + $template = $request->action(); + } else { + $template = Str::snake($request->action()); + } + + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; + } elseif (!str_contains($template, $depr)) { + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; + } + } + } else { + $template = str_replace(['/', ':'], $depr, substr($template, 1)); + } + + return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); + } + + /** + * 配置模板引擎 + * @param array $config 参数 + * @return void + */ + public function config(array $config): void + { + $this->config = array_merge($this->config, $config); + } + + /** + * 获取模板引擎配置 + * @param string $name 参数名 + * @return mixed + */ + public function getConfig(string $name) + { + return $this->config[$name] ?? null; + } +} diff --git a/vendor/topthink/framework/src/tpl/think_exception.tpl b/vendor/topthink/framework/src/tpl/think_exception.tpl new file mode 100644 index 0000000..bb32aa2 --- /dev/null +++ b/vendor/topthink/framework/src/tpl/think_exception.tpl @@ -0,0 +1,502 @@ +'.end($names).''; + } +} + +if (!function_exists('parse_file')) { + function parse_file($file, $line) + { + return ''.basename($file)." line {$line}".''; + } +} + +if (!function_exists('parse_args')) { + function parse_args($args) + { + $result = []; + foreach ($args as $key => $item) { + switch (true) { + case is_object($item): + $value = sprintf('object(%s)', parse_class(get_class($item))); + break; + case is_array($item): + if (count($item) > 3) { + $value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3))); + } else { + $value = sprintf('[%s]', parse_args($item)); + } + break; + case is_string($item): + if (strlen($item) > 20) { + $value = sprintf( + '\'%s...\'', + htmlentities($item), + htmlentities(substr($item, 0, 20)) + ); + } else { + $value = sprintf("'%s'", htmlentities($item)); + } + break; + case is_int($item): + case is_float($item): + $value = $item; + break; + case is_null($item): + $value = 'null'; + break; + case is_bool($item): + $value = '' . ($item ? 'true' : 'false') . ''; + break; + case is_resource($item): + $value = 'resource'; + break; + default: + $value = htmlentities(str_replace("\n", '', var_export(strval($item), true))); + break; + } + + $result[] = is_int($key) ? $value : sprintf('\'%s\' => %s', htmlentities($key), $value); + } + + return implode(', ', $result); + } +} +if (!function_exists('echo_value')) { + function echo_value($val) + { + if (is_array($val) || is_object($val)) { + echo htmlentities(json_encode($val, JSON_PRETTY_PRINT)); + } elseif (is_bool($val)) { + echo $val ? 'true' : 'false'; + } elseif (is_scalar($val)) { + echo htmlentities($val); + } else { + echo 'Resource'; + } + } +} +?> + + + + + 系统发生错误 + + + + + + $trace) { ?> +
    +
    +
    +
    +

    +
    +

    +
    +
    + +
    +
      $value) { ?>
    1. ">
    +
    + +
    +

    Call Stack

    +
      +
    1. + +
    2. + +
    3. + +
    +
    +
    + + +
    +

    +
    + + + +
    +

    Exception Datas

    + $value) { ?> + + + + + + + $val) { ?> + + + + + + + +
    empty
    + +
    + + + +
    +

    Environment Variables

    + $value) { ?> + + + + + + + $val) { ?> + + + + + + + +
    empty
    + +
    + + + + + + + + diff --git a/vendor/topthink/framework/tests/AppTest.php b/vendor/topthink/framework/tests/AppTest.php new file mode 100644 index 0000000..2f73075 --- /dev/null +++ b/vendor/topthink/framework/tests/AppTest.php @@ -0,0 +1,207 @@ + 'class', + ]; + + public function register() + { + + } + + public function boot() + { + + } +} + +/** + * @property array initializers + */ +class AppTest extends TestCase +{ + /** @var App */ + protected $app; + + protected function setUp(): void + { + $this->app = new App(); + } + + protected function tearDown(): void + { + m::close(); + } + + public function testService() + { + $service = m::mock(SomeService::class); + + $service->shouldReceive('register')->once(); + + $this->app->register($service); + + $this->assertEquals($service, $this->app->getService(SomeService::class)); + + $service2 = m::mock(SomeService::class); + + $service2->shouldReceive('register')->once(); + + $this->app->register($service2); + + $this->assertEquals($service, $this->app->getService(SomeService::class)); + + $this->app->register($service2, true); + + $this->assertEquals($service2, $this->app->getService(SomeService::class)); + + $service->shouldReceive('boot')->once(); + $service2->shouldReceive('boot')->once(); + + $this->app->boot(); + } + + public function testDebug() + { + $this->app->debug(false); + + $this->assertFalse($this->app->isDebug()); + + $this->app->debug(true); + + $this->assertTrue($this->app->isDebug()); + } + + public function testNamespace() + { + $namespace = 'test'; + + $this->app->setNamespace($namespace); + + $this->assertEquals($namespace, $this->app->getNamespace()); + } + + public function testPath() + { + $rootPath = __DIR__ . DIRECTORY_SEPARATOR; + + $app = new App($rootPath); + + $this->assertEquals($rootPath, $app->getRootPath()); + + $this->assertEquals(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $app->getThinkPath()); + + $this->assertEquals($rootPath . 'app' . DIRECTORY_SEPARATOR, $app->getAppPath()); + + $appPath = $rootPath . 'app' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR; + $app->setAppPath($appPath); + $this->assertEquals($appPath, $app->getAppPath()); + + $this->assertEquals($rootPath . 'app' . DIRECTORY_SEPARATOR, $app->getBasePath()); + + $this->assertEquals($rootPath . 'config' . DIRECTORY_SEPARATOR, $app->getConfigPath()); + + $this->assertEquals($rootPath . 'runtime' . DIRECTORY_SEPARATOR, $app->getRuntimePath()); + + $runtimePath = $rootPath . 'runtime' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR; + $app->setRuntimePath($runtimePath); + $this->assertEquals($runtimePath, $app->getRuntimePath()); + } + + /** + * @param vfsStreamDirectory $root + * @param bool $debug + * @return App + */ + protected function prepareAppForInitialize(vfsStreamDirectory $root, $debug = true) + { + $rootPath = $root->url() . DIRECTORY_SEPARATOR; + + $app = new App($rootPath); + + $initializer = m::mock(); + $initializer->shouldReceive('init')->once()->with($app); + + $app->instance($initializer->mockery_getName(), $initializer); + + (function () use ($initializer) { + $this->initializers = [$initializer->mockery_getName()]; + })->call($app); + + $env = m::mock(Env::class); + $env->shouldReceive('load')->once()->with($rootPath . '.env'); + $env->shouldReceive('get')->once()->with('config_ext', '.php')->andReturn('.php'); + $env->shouldReceive('get')->once()->with('app_debug')->andReturn($debug); + $env->shouldReceive('get')->once()->with('env_name', '')->andReturn(''); + + $event = m::mock(Event::class); + $event->shouldReceive('trigger')->once()->with(AppInit::class); + $event->shouldReceive('bind')->once()->with([]); + $event->shouldReceive('listenEvents')->once()->with([]); + $event->shouldReceive('subscribe')->once()->with([]); + + $app->instance('env', $env); + $app->instance('event', $event); + + return $app; + } + + public function testInitialize() + { + $root = vfsStream::setup('rootDir', null, [ + '.env' => '', + 'app' => [ + 'common.php' => '', + 'event.php' => '[],"listen"=>[],"subscribe"=>[]];', + 'provider.php' => ' [ + 'app.php' => 'prepareAppForInitialize($root, true); + + $app->debug(false); + + $app->initialize(); + + $this->assertIsInt($app->getBeginMem()); + $this->assertIsFloat($app->getBeginTime()); + + $this->assertTrue($app->initialized()); + } + + public function testFactory() + { + $this->assertInstanceOf(stdClass::class, App::factory(stdClass::class)); + + $this->expectException(ClassNotFoundException::class); + + App::factory('SomeClass'); + } + + public function testParseClass() + { + $this->assertEquals('app\\controller\\SomeClass', $this->app->parseClass('controller', 'some_class')); + $this->app->setNamespace('app2'); + $this->assertEquals('app2\\controller\\SomeClass', $this->app->parseClass('controller', 'some_class')); + } + +} diff --git a/vendor/topthink/framework/tests/CacheTest.php b/vendor/topthink/framework/tests/CacheTest.php new file mode 100644 index 0000000..a469ec1 --- /dev/null +++ b/vendor/topthink/framework/tests/CacheTest.php @@ -0,0 +1,154 @@ +app = m::mock(App::class)->makePartial(); + + Container::setInstance($this->app); + $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); + $this->config = m::mock(Config::class)->makePartial(); + $this->app->shouldReceive('get')->with('config')->andReturn($this->config); + + $this->cache = new Cache($this->app); + } + + public function testGetConfig() + { + $config = [ + 'default' => 'file', + ]; + + $this->config->shouldReceive('get')->with('cache')->andReturn($config); + + $this->assertEquals($config, $this->cache->getConfig()); + + $this->expectException(InvalidArgumentException::class); + $this->cache->getStoreConfig('foo'); + } + + public function testCacheManagerInstances() + { + $this->config->shouldReceive('get')->with("cache.stores.single", null)->andReturn(['type' => 'file']); + + $channel1 = $this->cache->store('single'); + $channel2 = $this->cache->store('single'); + + $this->assertSame($channel1, $channel2); + } + + public function testFileCache() + { + $root = vfsStream::setup(); + + $this->config->shouldReceive('get')->with("cache.default", null)->andReturn('file'); + + $this->config->shouldReceive('get')->with("cache.stores.file", null) + ->andReturn(['type' => 'file', 'path' => $root->url()]); + + $this->cache->set('foo', 5); + $this->cache->inc('foo'); + $this->assertEquals(6, $this->cache->get('foo')); + $this->cache->dec('foo', 2); + $this->assertEquals(4, $this->cache->get('foo')); + + $this->cache->set('bar', true); + $this->assertTrue($this->cache->get('bar')); + + $this->cache->set('baz', null); + $this->assertTrue($this->cache->has('baz')); + $this->assertNull($this->cache->get('baz')); + + $this->cache->delete('baz'); + $this->assertFalse($this->cache->has('baz')); + $this->assertNull($this->cache->get('baz')); + $this->assertFalse($this->cache->get('baz', false)); + + $this->assertTrue($root->hasChildren()); + $this->cache->clear(); + $this->assertFalse($root->hasChildren()); + + //tags + $this->cache->tag('foo')->set('bar', 'foobar'); + $this->assertEquals('foobar', $this->cache->get('bar')); + $this->cache->tag('foo')->remember('baz', 'foobar'); + $this->assertEquals('foobar', $this->cache->get('baz')); + $this->cache->tag('foo')->clear(); + $this->assertFalse($this->cache->has('bar')); + + //multiple + $this->cache->setMultiple(['foo' => ['foobar', 'bar'], 'foobar' => ['foo', 'bar']]); + $this->cache->tag('foo')->setMultiple(['foo' => ['foobar', 'bar'], 'foobar' => ['foo', 'bar']]); + $this->assertEquals(['foo' => ['foobar', 'bar'], 'foobar' => ['foo', 'bar']], $this->cache->getMultiple(['foo', 'foobar'])); + $this->assertIsInt($this->cache->getWriteTimes()); + $this->assertTrue($this->cache->deleteMultiple(['foo', 'foobar'])); + } + + public function testRedisCache() + { + if (extension_loaded('redis')) { + return; + } + $this->config->shouldReceive('get')->with("cache.default", null)->andReturn('redis'); + $this->config->shouldReceive('get')->with("cache.stores.redis", null)->andReturn(['type' => 'redis']); + + $redis = m::mock('overload:\Predis\Client'); + + $redis->shouldReceive("set")->once()->with('foo', 5)->andReturnTrue(); + $redis->shouldReceive("incrby")->once()->with('foo', 1)->andReturnTrue(); + $redis->shouldReceive("decrby")->once()->with('foo', 2)->andReturnTrue(); + $redis->shouldReceive("get")->once()->with('foo')->andReturn('6'); + $redis->shouldReceive("get")->once()->with('foo')->andReturn('4'); + $redis->shouldReceive("set")->once()->with('bar', serialize(true))->andReturnTrue(); + $redis->shouldReceive("set")->once()->with('baz', serialize(null))->andReturnTrue(); + $redis->shouldReceive("del")->once()->with('baz')->andReturnTrue(); + $redis->shouldReceive("flushDB")->once()->andReturnTrue(); + $redis->shouldReceive("set")->once()->with('bar', serialize('foobar'))->andReturnTrue(); + $redis->shouldReceive("sAdd")->once()->with('tag:' . md5('foo'), 'bar')->andReturnTrue(); + $redis->shouldReceive("sMembers")->once()->with('tag:' . md5('foo'))->andReturn(['bar']); + $redis->shouldReceive("del")->once()->with(['bar'])->andReturnTrue(); + $redis->shouldReceive("del")->once()->with('tag:' . md5('foo'))->andReturnTrue(); + + $this->cache->set('foo', 5); + $this->cache->inc('foo'); + $this->assertEquals(6, $this->cache->get('foo')); + $this->cache->dec('foo', 2); + $this->assertEquals(4, $this->cache->get('foo')); + + $this->cache->set('bar', true); + $this->cache->set('baz', null); + $this->cache->delete('baz'); + $this->cache->clear(); + + //tags + $this->cache->tag('foo')->set('bar', 'foobar'); + $this->cache->tag('foo')->clear(); + } +} diff --git a/vendor/topthink/framework/tests/ConfigTest.php b/vendor/topthink/framework/tests/ConfigTest.php new file mode 100644 index 0000000..271a34f --- /dev/null +++ b/vendor/topthink/framework/tests/ConfigTest.php @@ -0,0 +1,46 @@ +setContent(" 'value1','key2'=>'value2'];"); + $root->addChild($file); + + $config = new Config(); + + $config->load($file->url(), 'test'); + + $this->assertEquals('value1', $config->get('test.key1')); + $this->assertEquals('value2', $config->get('test.key2')); + + $this->assertSame(['key1' => 'value1', 'key2' => 'value2'], $config->get('test')); + } + + public function testSetAndGet() + { + $config = new Config(); + + $config->set([ + 'key1' => 'value1', + 'key2' => [ + 'key3' => 'value3', + ], + ], 'test'); + + $this->assertTrue($config->has('test.key1')); + $this->assertEquals('value1', $config->get('test.key1')); + $this->assertEquals('value3', $config->get('test.key2.key3')); + + $this->assertEquals(['key3' => 'value3'], $config->get('test.key2')); + $this->assertFalse($config->has('test.key3')); + $this->assertEquals('none', $config->get('test.key3', 'none')); + } +} diff --git a/vendor/topthink/framework/tests/DbTest.php b/vendor/topthink/framework/tests/DbTest.php new file mode 100644 index 0000000..3bd0c1e --- /dev/null +++ b/vendor/topthink/framework/tests/DbTest.php @@ -0,0 +1,49 @@ +shouldReceive('get')->with('database.cache_store', null)->andReturn(null); + $cache->shouldReceive('store')->with(null)->andReturn($store); + + $db = Db::__make($event, $config, $log, $cache); + + $config->shouldReceive('get')->with('database.foo', null)->andReturn('foo'); + $this->assertEquals('foo', $db->getConfig('foo')); + + $config->shouldReceive('get')->with('database', [])->andReturn([]); + $this->assertEquals([], $db->getConfig()); + + $callback = function () { + }; + $event->shouldReceive('listen')->with('db.some', $callback); + $db->event('some', $callback); + + $event->shouldReceive('trigger')->with('db.some', null, false); + $db->trigger('some'); + } + +} diff --git a/vendor/topthink/framework/tests/DispatchTest.php b/vendor/topthink/framework/tests/DispatchTest.php new file mode 100644 index 0000000..2b9e413 --- /dev/null +++ b/vendor/topthink/framework/tests/DispatchTest.php @@ -0,0 +1,32 @@ + ['tp', 'thinkphp'], 'psr' => 'psr-7'], '123'); + } + }; + + $response = $dispatch->run(); + + $this->assertInstanceOf(\think\Response::class, $response); + $this->assertEquals('123', $response->getContent()); + $this->assertEquals('tp, thinkphp', $response->getHeader('framework')); + $this->assertEquals('psr-7', $response->getHeader('psr')); + } +} diff --git a/vendor/topthink/framework/tests/EnvTest.php b/vendor/topthink/framework/tests/EnvTest.php new file mode 100644 index 0000000..9b3b615 --- /dev/null +++ b/vendor/topthink/framework/tests/EnvTest.php @@ -0,0 +1,80 @@ +setContent("key1=value1\nkey2=value2"); + $root->addChild($envFile); + + $env = new Env(); + + $env->load($envFile->url()); + + $this->assertEquals('value1', $env->get('key1')); + $this->assertEquals('value2', $env->get('key2')); + } + + public function testServerEnv() + { + $env = new Env(); + + $this->assertEquals('value2', $env->get('key2', 'value2')); + + putenv('PHP_KEY7=value7'); + putenv('PHP_KEY8=false'); + putenv('PHP_KEY9=true'); + + $this->assertEquals('value7', $env->get('key7')); + $this->assertFalse($env->get('KEY8')); + $this->assertTrue($env->get('key9')); + } + + public function testSetEnv() + { + $env = new Env(); + + $env->set([ + 'key1' => 'value1', + 'key2' => [ + 'key1' => 'value1-2', + ], + ]); + + $env->set('key3', 'value3'); + + $env->key4 = 'value4'; + + $env['key5'] = 'value5'; + + $this->assertEquals('value1', $env->get('key1')); + $this->assertEquals('value1-2', $env->get('key2.key1')); + + $this->assertEquals('value3', $env->get('key3')); + + $this->assertEquals('value4', $env->key4); + + $this->assertEquals('value5', $env['key5']); + + $this->expectException(Exception::class); + + unset($env['key5']); + } + + public function testHasEnv() + { + $env = new Env(); + $env->set(['foo' => 'bar']); + $this->assertTrue($env->has('foo')); + $this->assertTrue(isset($env->foo)); + $this->assertTrue($env->offsetExists('foo')); + } +} diff --git a/vendor/topthink/framework/tests/EventTest.php b/vendor/topthink/framework/tests/EventTest.php new file mode 100644 index 0000000..797c4d6 --- /dev/null +++ b/vendor/topthink/framework/tests/EventTest.php @@ -0,0 +1,134 @@ +app = m::mock(App::class)->makePartial(); + + Container::setInstance($this->app); + $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); + $this->config = m::mock(Config::class)->makePartial(); + $this->app->shouldReceive('get')->with('config')->andReturn($this->config); + + $this->event = new Event($this->app); + } + + public function testBasic() + { + $this->event->bind(['foo' => 'baz']); + + $this->event->listen('foo', function ($bar) { + $this->assertEquals('bar', $bar); + }); + + $this->assertTrue($this->event->hasListener('foo')); + + $this->event->trigger('baz', 'bar'); + + $this->event->remove('foo'); + + $this->assertFalse($this->event->hasListener('foo')); + } + + public function testOnceEvent() + { + $this->event->listen('AppInit', function ($bar) { + $this->assertEquals('bar', $bar); + return 'foo'; + }); + + $this->assertEquals('foo', $this->event->trigger('AppInit', 'bar', true)); + $this->assertEquals(['foo'], $this->event->trigger('AppInit', 'bar')); + } + + public function testClassListener() + { + $listener = m::mock("overload:SomeListener", TestListener::class); + + $listener->shouldReceive('handle')->andReturnTrue(); + + $this->event->listen('some', "SomeListener"); + + $this->assertTrue($this->event->until('some')); + } + + public function testSubscribe() + { + $listener = m::mock("overload:SomeListener", TestListener::class); + + $listener->shouldReceive('subscribe')->andReturnUsing(function (Event $event) use ($listener) { + + $listener->shouldReceive('onBar')->once()->andReturnFalse(); + + $event->listenEvents(['SomeListener::onBar' => [[$listener, 'onBar']]]); + }); + + $this->event->subscribe('SomeListener'); + + $this->assertTrue($this->event->hasListener('SomeListener::onBar')); + + $this->event->trigger('SomeListener::onBar'); + } + + public function testAutoObserve() + { + $listener = m::mock("overload:SomeListener", TestListener::class); + + $listener->shouldReceive('onBar')->once(); + + $this->app->shouldReceive('make')->with('SomeListener')->andReturn($listener); + + $this->event->observe('SomeListener'); + + $this->event->trigger('bar'); + } + +} + +class TestListener +{ + public function handle() + { + + } + + public function onBar() + { + + } + + public function onFoo() + { + + } + + public function subscribe() + { + + } +} diff --git a/vendor/topthink/framework/tests/HttpTest.php b/vendor/topthink/framework/tests/HttpTest.php new file mode 100644 index 0000000..49b509d --- /dev/null +++ b/vendor/topthink/framework/tests/HttpTest.php @@ -0,0 +1,153 @@ +app = m::mock(App::class)->makePartial(); + + $this->http = m::mock(Http::class, [$this->app])->shouldAllowMockingProtectedMethods()->makePartial(); + } + + protected function prepareApp($request, $response) + { + $this->app->shouldReceive('instance')->once()->with('request', $request); + $this->app->shouldReceive('initialized')->once()->andReturnFalse(); + $this->app->shouldReceive('initialize')->once(); + $this->app->shouldReceive('get')->with('request')->andReturn($request); + + $route = m::mock(Route::class); + + $route->shouldReceive('dispatch')->withArgs(function ($req, $withRoute) use ($request) { + if ($withRoute) { + $withRoute(); + } + return $req === $request; + })->andReturn($response); + + $this->app->shouldReceive('get')->with('route')->andReturn($route); + + $console = m::mock(Console::class); + + $console->shouldReceive('call'); + + $this->app->shouldReceive('get')->with('console')->andReturn($console); + } + + public function testRun() + { + $root = vfsStream::setup('rootDir', null, [ + 'app' => [ + 'controller' => [], + 'middleware.php' => ' [ + 'route.php' => 'app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR); + $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR); + + $request = m::mock(Request::class)->makePartial(); + $response = m::mock(Response::class)->makePartial(); + + $this->prepareApp($request, $response); + + $this->assertEquals($response, $this->http->run($request)); + } + + public function multiAppRunProvider() + { + $request1 = m::mock(Request::class)->makePartial(); + $request1->shouldReceive('subDomain')->andReturn('www'); + $request1->shouldReceive('host')->andReturn('www.domain.com'); + + $request2 = m::mock(Request::class)->makePartial(); + $request2->shouldReceive('subDomain')->andReturn('app2'); + $request2->shouldReceive('host')->andReturn('app2.domain.com'); + + $request3 = m::mock(Request::class)->makePartial(); + $request3->shouldReceive('pathinfo')->andReturn('some1/a/b/c'); + + $request4 = m::mock(Request::class)->makePartial(); + $request4->shouldReceive('pathinfo')->andReturn('app3/a/b/c'); + + $request5 = m::mock(Request::class)->makePartial(); + $request5->shouldReceive('pathinfo')->andReturn('some2/a/b/c'); + + return [ + [$request1, true, 'app1'], + [$request2, true, 'app2'], + [$request3, true, 'app3'], + [$request4, true, null], + [$request5, true, 'some2', 'path'], + [$request1, false, 'some3'], + ]; + } + + public function testRunWithException() + { + $request = m::mock(Request::class); + $response = m::mock(Response::class); + + $this->app->shouldReceive('instance')->once()->with('request', $request); + $this->app->shouldReceive('initialize')->once(); + + $exception = new Exception(); + + $this->http->shouldReceive('runWithRequest')->once()->with($request)->andThrow($exception); + + $handle = m::mock(Handle::class); + + $handle->shouldReceive('report')->once()->with($exception); + $handle->shouldReceive('render')->once()->with($request, $exception)->andReturn($response); + + $this->app->shouldReceive('make')->with(Handle::class)->andReturn($handle); + + $this->assertEquals($response, $this->http->run($request)); + } + + public function testEnd() + { + $response = m::mock(Response::class); + $event = m::mock(Event::class); + $event->shouldReceive('trigger')->once()->with(HttpEnd::class, $response); + $this->app->shouldReceive('get')->once()->with('event')->andReturn($event); + $log = m::mock(Log::class); + $log->shouldReceive('save')->once(); + $this->app->shouldReceive('get')->once()->with('log')->andReturn($log); + + $this->http->end($response); + } + +} diff --git a/vendor/topthink/framework/tests/InteractsWithApp.php b/vendor/topthink/framework/tests/InteractsWithApp.php new file mode 100644 index 0000000..f4fcf73 --- /dev/null +++ b/vendor/topthink/framework/tests/InteractsWithApp.php @@ -0,0 +1,30 @@ +app = m::mock(App::class)->makePartial(); + Container::setInstance($this->app); + $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); + $this->app->shouldReceive('isDebug')->andReturnTrue(); + $this->config = m::mock(Config::class)->makePartial(); + $this->config->shouldReceive('get')->with('app.show_error_msg')->andReturnTrue(); + $this->app->shouldReceive('get')->with('config')->andReturn($this->config); + $this->app->shouldReceive('runningInConsole')->andReturn(false); + } +} diff --git a/vendor/topthink/framework/tests/LogTest.php b/vendor/topthink/framework/tests/LogTest.php new file mode 100644 index 0000000..218b815 --- /dev/null +++ b/vendor/topthink/framework/tests/LogTest.php @@ -0,0 +1,132 @@ +prepareApp(); + + $this->log = new Log($this->app); + } + + public function testGetConfig() + { + $config = [ + 'default' => 'file', + ]; + + $this->config->shouldReceive('get')->with('log')->andReturn($config); + + $this->assertEquals($config, $this->log->getConfig()); + + $this->expectException(InvalidArgumentException::class); + $this->log->getChannelConfig('foo'); + } + + public function testChannel() + { + $this->assertInstanceOf(ChannelSet::class, $this->log->channel(['file', 'mail'])); + } + + public function testLogManagerInstances() + { + $this->config->shouldReceive('get')->with("log.channels.single", null)->andReturn(['type' => 'file']); + + $channel1 = $this->log->channel('single'); + $channel2 = $this->log->channel('single'); + + $this->assertSame($channel1, $channel2); + } + + public function testFileLog() + { + $root = vfsStream::setup(); + + $this->config->shouldReceive('get')->with("log.default", null)->andReturn('file'); + + $this->config->shouldReceive('get')->with("log.channels.file", null) + ->andReturn(['type' => 'file', 'path' => $root->url()]); + + $this->log->info('foo'); + + $this->assertEquals($this->log->getLog(), ['info' => ['foo']]); + + $this->log->clear(); + + $this->assertEmpty($this->log->getLog()); + + $this->log->error('foo'); + $this->assertArrayHasKey('error', $this->log->getLog()); + + $this->log->emergency('foo'); + $this->assertArrayHasKey('emergency', $this->log->getLog()); + + $this->log->alert('foo'); + $this->assertArrayHasKey('alert', $this->log->getLog()); + + $this->log->critical('foo'); + $this->assertArrayHasKey('critical', $this->log->getLog()); + + $this->log->warning('foo'); + $this->assertArrayHasKey('warning', $this->log->getLog()); + + $this->log->notice('foo'); + $this->assertArrayHasKey('notice', $this->log->getLog()); + + $this->log->debug('foo'); + $this->assertArrayHasKey('debug', $this->log->getLog()); + + $this->log->sql('foo'); + $this->assertArrayHasKey('sql', $this->log->getLog()); + + $this->log->custom('foo'); + $this->assertArrayHasKey('custom', $this->log->getLog()); + + $this->log->write('foo'); + $this->assertTrue($root->hasChildren()); + $this->assertEmpty($this->log->getLog()); + + $this->log->close(); + + $this->log->info('foo'); + + $this->assertEmpty($this->log->getLog()); + } + + public function testSave() + { + $root = vfsStream::setup(); + + $this->config->shouldReceive('get')->with("log.default", null)->andReturn('file'); + + $this->config->shouldReceive('get')->with("log.channels.file", null) + ->andReturn(['type' => 'file', 'path' => $root->url()]); + + $this->log->info('foo'); + + $this->log->save(); + + $this->assertTrue($root->hasChildren()); + } + +} diff --git a/vendor/topthink/framework/tests/MiddlewareTest.php b/vendor/topthink/framework/tests/MiddlewareTest.php new file mode 100644 index 0000000..e57aecf --- /dev/null +++ b/vendor/topthink/framework/tests/MiddlewareTest.php @@ -0,0 +1,110 @@ +prepareApp(); + + $this->middleware = new Middleware($this->app); + } + + public function testSetMiddleware() + { + $this->middleware->add('BarMiddleware', 'bar'); + + $this->assertEquals(1, count($this->middleware->all('bar'))); + + $this->middleware->controller('BarMiddleware'); + $this->assertEquals(1, count($this->middleware->all('controller'))); + + $this->middleware->import(['FooMiddleware']); + $this->assertEquals(1, count($this->middleware->all())); + + $this->middleware->unshift(['BazMiddleware', 'baz']); + $this->assertEquals(2, count($this->middleware->all())); + $this->assertEquals([['BazMiddleware', 'handle'], 'baz'], $this->middleware->all()[0]); + + $this->config->shouldReceive('get')->with('middleware.alias', []) + ->andReturn(['foo' => ['FooMiddleware', 'FarMiddleware']]); + + $this->middleware->add('foo'); + $this->assertEquals(3, count($this->middleware->all())); + $this->middleware->add(function () { + }); + $this->middleware->add(function () { + }); + $this->assertEquals(5, count($this->middleware->all())); + } + + public function testPipelineAndEnd() + { + $bar = m::mock("overload:BarMiddleware"); + $foo = m::mock("overload:FooMiddleware", Foo::class); + + $request = m::mock(Request::class); + $response = m::mock(Response::class); + + $e = new Exception(); + + $handle = m::mock(Handle::class); + $handle->shouldReceive('report')->with($e)->andReturnNull(); + $handle->shouldReceive('render')->with($request, $e)->andReturn($response); + + $foo->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) { + return $next($request); + }); + $bar->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) use ($e) { + $next($request); + throw $e; + }); + + $foo->shouldReceive('end')->once()->with($response)->andReturnNull(); + + $this->app->shouldReceive('make')->with(Handle::class)->andReturn($handle); + + $this->config->shouldReceive('get')->once()->with('middleware.priority', []) + ->andReturn(['FooMiddleware', 'BarMiddleware']); + + $this->middleware->import([function ($request, $next) { + return $next($request); + }, 'BarMiddleware', 'FooMiddleware']); + + $this->assertInstanceOf(Pipeline::class, $pipeline = $this->middleware->pipeline()); + + $pipeline->send($request)->then(function ($request) use ($e, $response) { + throw $e; + }); + + $this->middleware->end($response); + } +} + +class Foo +{ + public function end(Response $response) + { + } +} diff --git a/vendor/topthink/framework/tests/RouteTest.php b/vendor/topthink/framework/tests/RouteTest.php new file mode 100644 index 0000000..03e9ef3 --- /dev/null +++ b/vendor/topthink/framework/tests/RouteTest.php @@ -0,0 +1,230 @@ +prepareApp(); + + $this->config->shouldReceive('get')->with('route')->andReturn(['url_route_must' => true]); + $this->route = new Route($this->app); + } + + /** + * @param $path + * @param string $method + * @param string $host + * @return m\Mock|Request + */ + protected function makeRequest($path, $method = 'GET', $host = 'localhost') + { + $request = m::mock(Request::class)->makePartial(); + $request->shouldReceive('host')->andReturn($host); + $request->shouldReceive('pathinfo')->andReturn($path); + $request->shouldReceive('url')->andReturn('/' . $path); + $request->shouldReceive('method')->andReturn(strtoupper($method)); + return $request; + } + + public function testSimpleRequest() + { + $this->route->get('foo', function () { + return 'get-foo'; + }); + + $this->route->put('foo', function () { + return 'put-foo'; + }); + + $this->route->group(function () { + $this->route->post('foo', function () { + return 'post-foo'; + }); + }); + + $request = $this->makeRequest('foo', 'post'); + $response = $this->route->dispatch($request); + $this->assertEquals(200, $response->getCode()); + $this->assertEquals('post-foo', $response->getContent()); + + $request = $this->makeRequest('foo', 'get'); + $response = $this->route->dispatch($request); + $this->assertEquals(200, $response->getCode()); + $this->assertEquals('get-foo', $response->getContent()); + } + + public function testGroup() + { + $this->route->group(function () { + $this->route->group('foo', function () { + $this->route->post('bar', function () { + return 'hello,world!'; + }); + }); + }); + + $request = $this->makeRequest('foo/bar', 'post'); + $response = $this->route->dispatch($request); + $this->assertEquals(200, $response->getCode()); + $this->assertEquals('hello,world!', $response->getContent()); + } + + public function testAllowCrossDomain() + { + $this->route->get('foo', function () { + return 'get-foo'; + })->allowCrossDomain(['some' => 'bar']); + + $request = $this->makeRequest('foo', 'get'); + $response = $this->route->dispatch($request); + + $this->assertEquals('bar', $response->getHeader('some')); + $this->assertArrayHasKey('Access-Control-Allow-Credentials', $response->getHeader()); + + //$this->expectException(RouteNotFoundException::class); + $request = $this->makeRequest('foo2', 'options'); + $this->route->dispatch($request); + } + + public function testControllerDispatch() + { + $this->route->get('foo', 'foo/bar'); + + $controller = m::Mock(\stdClass::class); + + $this->app->shouldReceive('parseClass')->with('controller', 'Foo')->andReturn($controller->mockery_getName()); + $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); + + $controller->shouldReceive('bar')->andReturn('bar'); + + $request = $this->makeRequest('foo'); + $response = $this->route->dispatch($request); + $this->assertEquals('bar', $response->getContent()); + } + + public function testEmptyControllerDispatch() + { + $this->route->get('foo', 'foo/bar'); + + $controller = m::Mock(\stdClass::class); + + $this->app->shouldReceive('parseClass')->with('controller', 'Error')->andReturn($controller->mockery_getName()); + $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); + + $controller->shouldReceive('bar')->andReturn('bar'); + + $request = $this->makeRequest('foo'); + $response = $this->route->dispatch($request); + $this->assertEquals('bar', $response->getContent()); + } + + protected function createMiddleware($times = 1) + { + $middleware = m::mock(Str::random(5)); + $middleware->shouldReceive('handle')->times($times)->andReturnUsing(function ($request, Closure $next) { + return $next($request); + }); + $this->app->shouldReceive('make')->with($middleware->mockery_getName())->andReturn($middleware); + + return $middleware; + } + + public function testControllerWithMiddleware() + { + $this->route->get('foo', 'foo/bar'); + + $controller = m::mock(FooClass::class); + + $controller->middleware = [ + $this->createMiddleware()->mockery_getName() . ":params1:params2", + $this->createMiddleware(0)->mockery_getName() => ['except' => 'bar'], + $this->createMiddleware()->mockery_getName() => ['only' => 'bar'], + [ + 'middleware' => [$this->createMiddleware()->mockery_getName(), [new \stdClass()]], + 'options' => ['only' => 'bar'], + ], + ]; + + $this->app->shouldReceive('parseClass')->with('controller', 'Foo')->andReturn($controller->mockery_getName()); + $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); + + $controller->shouldReceive('bar')->once()->andReturn('bar'); + + $request = $this->makeRequest('foo'); + $response = $this->route->dispatch($request); + $this->assertEquals('bar', $response->getContent()); + } + + public function testRedirectDispatch() + { + $this->route->redirect('foo', 'http://localhost', 302); + + $request = $this->makeRequest('foo'); + $this->app->shouldReceive('make')->with(Request::class)->andReturn($request); + $response = $this->route->dispatch($request); + + $this->assertInstanceOf(Redirect::class, $response); + $this->assertEquals(302, $response->getCode()); + $this->assertEquals('http://localhost', $response->getData()); + } + + public function testViewDispatch() + { + $this->route->view('foo', 'index/hello', ['city' => 'shanghai']); + + $request = $this->makeRequest('foo'); + $response = $this->route->dispatch($request); + + $this->assertInstanceOf(View::class, $response); + $this->assertEquals(['city' => 'shanghai'], $response->getVars()); + $this->assertEquals('index/hello', $response->getData()); + } + + public function testDomainBindResponse() + { + $this->route->domain('test', function () { + $this->route->get('/', function () { + return 'Hello,ThinkPHP'; + }); + }); + + $request = $this->makeRequest('', 'get', 'test.domain.com'); + $response = $this->route->dispatch($request); + + $this->assertEquals('Hello,ThinkPHP', $response->getContent()); + $this->assertEquals(200, $response->getCode()); + } + +} + +class FooClass +{ + public $middleware = []; + + public function bar() + { + + } +} diff --git a/vendor/topthink/framework/tests/SessionTest.php b/vendor/topthink/framework/tests/SessionTest.php new file mode 100644 index 0000000..f9b4827 --- /dev/null +++ b/vendor/topthink/framework/tests/SessionTest.php @@ -0,0 +1,225 @@ +app = m::mock(App::class)->makePartial(); + Container::setInstance($this->app); + + $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); + $this->config = m::mock(Config::class)->makePartial(); + + $this->app->shouldReceive('get')->with('config')->andReturn($this->config); + $handlerClass = "\\think\\session\\driver\\Test" . Str::random(10); + $this->config->shouldReceive("get")->with("session.type", "file")->andReturn($handlerClass); + $this->session = new Session($this->app); + + $this->handler = m::mock('overload:' . $handlerClass, SessionHandlerInterface::class); + } + + public function testLoadData() + { + $data = [ + "bar" => 'foo', + ]; + + $id = md5(uniqid()); + + $this->handler->shouldReceive("read")->once()->with($id)->andReturn(serialize($data)); + + $this->session->setId($id); + $this->session->init(); + + $this->assertEquals('foo', $this->session->get('bar')); + $this->assertTrue($this->session->has('bar')); + $this->assertFalse($this->session->has('foo')); + + $this->session->set('foo', 'bar'); + $this->assertTrue($this->session->has('foo')); + + $this->assertEquals('bar', $this->session->pull('foo')); + $this->assertFalse($this->session->has('foo')); + } + + public function testSave() + { + + $id = md5(uniqid()); + + $this->handler->shouldReceive('read')->once()->with($id)->andReturn(""); + + $this->handler->shouldReceive('write')->once()->with($id, serialize([ + "bar" => 'foo', + ]))->andReturnTrue(); + + $this->session->setId($id); + $this->session->init(); + + $this->session->set('bar', 'foo'); + + $this->session->save(); + } + + public function testFlash() + { + $this->session->flash('foo', 'bar'); + $this->session->flash('bar', 0); + $this->session->flash('baz', true); + + $this->assertTrue($this->session->has('foo')); + $this->assertEquals('bar', $this->session->get('foo')); + $this->assertEquals(0, $this->session->get('bar')); + $this->assertTrue($this->session->get('baz')); + + $this->session->clearFlashData(); + + $this->assertTrue($this->session->has('foo')); + $this->assertEquals('bar', $this->session->get('foo')); + $this->assertEquals(0, $this->session->get('bar')); + + $this->session->clearFlashData(); + + $this->assertFalse($this->session->has('foo')); + $this->assertNull($this->session->get('foo')); + + $this->session->flash('foo', 'bar'); + $this->assertTrue($this->session->has('foo')); + $this->session->clearFlashData(); + $this->session->reflash(); + $this->session->clearFlashData(); + + $this->assertTrue($this->session->has('foo')); + } + + public function testClear() + { + $this->session->set('bar', 'foo'); + $this->assertEquals('foo', $this->session->get('bar')); + $this->session->clear(); + $this->assertFalse($this->session->has('foo')); + } + + public function testSetName() + { + $this->session->setName('foo'); + $this->assertEquals('foo', $this->session->getName()); + } + + public function testDestroy() + { + $id = md5(uniqid()); + + $this->handler->shouldReceive('read')->once()->with($id)->andReturn(""); + $this->handler->shouldReceive('delete')->once()->with($id)->andReturnTrue(); + + $this->session->setId($id); + $this->session->init(); + + $this->session->set('bar', 'foo'); + + $this->session->destroy(); + + $this->assertFalse($this->session->has('bar')); + + $this->assertNotEquals($id, $this->session->getId()); + } + + public function testFileHandler() + { + $root = vfsStream::setup(); + + vfsStream::newFile('bar') + ->at($root) + ->lastModified(time()); + + vfsStream::newFile('bar') + ->at(vfsStream::newDirectory("foo")->at($root)) + ->lastModified(100); + + $this->assertTrue($root->hasChild("bar")); + $this->assertTrue($root->hasChild("foo/bar")); + + $handler = new TestFileHandle($this->app, [ + 'path' => $root->url(), + 'gc_probability' => 1, + 'gc_divisor' => 1, + ]); + + $this->assertTrue($root->hasChild("bar")); + $this->assertFalse($root->hasChild("foo/bar")); + + $id = md5(uniqid()); + $handler->write($id, "bar"); + + $this->assertTrue($root->hasChild("sess_{$id}")); + + $this->assertEquals("bar", $handler->read($id)); + + $handler->delete($id); + + $this->assertFalse($root->hasChild("sess_{$id}")); + } + + public function testCacheHandler() + { + $id = md5(uniqid()); + + $cache = m::mock(\think\Cache::class); + + $store = m::mock(Driver::class); + + $cache->shouldReceive('store')->once()->with('redis')->andReturn($store); + + $handler = new Cache($cache, ['store' => 'redis']); + + $store->shouldReceive("set")->with($id, "bar", 1440)->once()->andReturnTrue(); + $handler->write($id, "bar"); + + $store->shouldReceive("get")->with($id)->once()->andReturn("bar"); + $this->assertEquals("bar", $handler->read($id)); + + $store->shouldReceive("delete")->with($id)->once()->andReturnTrue(); + $handler->delete($id); + } +} + +class TestFileHandle extends File +{ + protected function writeFile($path, $content): bool + { + return (bool) file_put_contents($path, $content); + } +} diff --git a/vendor/topthink/framework/tests/UrlRouteTest.php b/vendor/topthink/framework/tests/UrlRouteTest.php new file mode 100644 index 0000000..28c502f --- /dev/null +++ b/vendor/topthink/framework/tests/UrlRouteTest.php @@ -0,0 +1,60 @@ +prepareApp(); + + $this->route = new Route($this->app); + } + + public function testUrlDispatch() + { + $controller = m::mock(FooClass::class); + $controller->shouldReceive('index')->andReturn('bar'); + + $this->app->shouldReceive('parseClass')->once()->with('controller', 'Foo') + ->andReturn($controller->mockery_getName()); + $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); + + $request = $this->makeRequest('foo'); + $response = $this->route->dispatch($request); + $this->assertEquals('bar', $response->getContent()); + } + + /** + * @param $path + * @param string $method + * @param string $host + * @return m\Mock|Request + */ + protected function makeRequest($path, $method = 'GET', $host = 'localhost') + { + $request = m::mock(Request::class)->makePartial(); + $request->shouldReceive('host')->andReturn($host); + $request->shouldReceive('pathinfo')->andReturn($path); + $request->shouldReceive('url')->andReturn('/' . $path); + $request->shouldReceive('method')->andReturn(strtoupper($method)); + return $request; + } + +} diff --git a/vendor/topthink/framework/tests/ViewTest.php b/vendor/topthink/framework/tests/ViewTest.php new file mode 100644 index 0000000..9bd6dc4 --- /dev/null +++ b/vendor/topthink/framework/tests/ViewTest.php @@ -0,0 +1,122 @@ +app = m::mock(App::class)->makePartial(); + Container::setInstance($this->app); + + $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); + $this->config = m::mock(Config::class)->makePartial(); + $this->app->shouldReceive('get')->with('config')->andReturn($this->config); + + $this->view = new View($this->app); + } + + public function testAssignData() + { + $this->view->assign('foo', 'bar'); + $this->view->assign(['baz' => 'boom']); + $this->view->qux = "corge"; + + $this->assertEquals('bar', $this->view->foo); + $this->assertEquals('boom', $this->view->baz); + $this->assertEquals('corge', $this->view->qux); + $this->assertTrue(isset($this->view->qux)); + } + + public function testRender() + { + $this->config->shouldReceive("get")->with("view.type", 'php')->andReturn(TestTemplate::class); + + $this->view->filter(function ($content) { + return $content; + }); + + $this->assertEquals("fetch", $this->view->fetch('foo')); + $this->assertEquals("display", $this->view->display('foo')); + } + +} + +class TestTemplate implements TemplateHandlerInterface +{ + + /** + * 检测是否存在模板文件 + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists(string $template): bool + { + return true; + } + + /** + * 渲染模板文件 + * @param string $template 模板文件 + * @param array $data 模板变量 + * @return void + */ + public function fetch(string $template, array $data = []): void + { + echo "fetch"; + } + + /** + * 渲染模板内容 + * @param string $content 模板内容 + * @param array $data 模板变量 + * @return void + */ + public function display(string $content, array $data = []): void + { + echo "display"; + } + + /** + * 配置模板引擎 + * @param array $config 参数 + * @return void + */ + public function config(array $config): void + { + // TODO: Implement config() method. + } + + /** + * 获取模板引擎配置 + * @param string $name 参数名 + * @return mixed + */ + public function getConfig(string $name) + { + // TODO: Implement getConfig() method. + } +} diff --git a/vendor/topthink/framework/tests/bootstrap.php b/vendor/topthink/framework/tests/bootstrap.php new file mode 100644 index 0000000..3459061 --- /dev/null +++ b/vendor/topthink/framework/tests/bootstrap.php @@ -0,0 +1,3 @@ +bind('cache', '\app\common\Cache'); +// 判断是否存在对象实例 +$container->has('cache'); +// 从容器中获取对象的唯一实例 +$container->get('cache'); +// 从容器中获取对象,没有则自动实例化 +$container->make('cache'); +// 删除容器中的对象实例 +$container->delete('cache'); +// 执行某个方法或者闭包 支持依赖注入 +$container->invoke($callable, $vars); +// 执行某个类的实例化 支持依赖注入 +$container->invokeClass($class, $vars); +// 静态方法获取容器对象实例 不存在则自动实例化 +\think\Container::pull('cache'); +~~~ + +对象化操作 +~~~ +// 获取容器实例 +$container = \think\Container::getInstance(); +// 绑定一个类、闭包、实例、接口实现到容器 +$container->cache = '\app\common\Cache'; +// 判断是否存在对象实例 +isset($container->cache); +// 从容器中获取对象的唯一实例 +$container->cache; +// 删除容器中的对象实例 +unset($container->cache); +~~~ + +## Facade + + +定义一个`app\facade\App`类之后,即可以静态方式调用`\think\App`类的动态方法 +~~~ +=8.0", + "psr/container": "^2.0", + "topthink/think-helper":"^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "autoload": { + "psr-4": { + "think\\": "src" + }, + "files": [ + ] + } +} diff --git a/vendor/topthink/think-container/phpunit.xml.dist b/vendor/topthink/think-container/phpunit.xml.dist new file mode 100644 index 0000000..dbccd71 --- /dev/null +++ b/vendor/topthink/think-container/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + ./tests + + + + + ./src + + + diff --git a/vendor/topthink/think-container/src/Container.php b/vendor/topthink/think-container/src/Container.php new file mode 100644 index 0000000..b9ebea1 --- /dev/null +++ b/vendor/topthink/think-container/src/Container.php @@ -0,0 +1,564 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use ArrayAccess; +use ArrayIterator; +use Closure; +use Countable; +use InvalidArgumentException; +use IteratorAggregate; +use Psr\Container\ContainerInterface; +use ReflectionClass; +use ReflectionException; +use ReflectionFunction; +use ReflectionFunctionAbstract; +use ReflectionMethod; +use ReflectionNamedType; +use ReflectionParameter; +use think\exception\ClassNotFoundException; +use think\exception\FuncNotFoundException; +use think\helper\Str; +use Throwable; +use Traversable; + +/** + * 容器管理类 支持PSR-11 + */ +class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, Countable +{ + /** + * 容器对象实例 + * @var Container|Closure + */ + protected static $instance; + + /** + * 容器中的对象实例 + * @var array + */ + protected $instances = []; + + /** + * 容器绑定标识 + * @var array + */ + protected $bind = []; + + /** + * 容器回调 + * @var array + */ + protected $invokeCallback = []; + + /** + * 获取当前容器的实例(单例) + * @access public + * @return static + */ + public static function getInstance() + { + if (is_null(static::$instance)) { + static::$instance = new static; + } + + if (static::$instance instanceof Closure) { + return (static::$instance)(); + } + + return static::$instance; + } + + /** + * 设置当前容器的实例 + * @access public + * @param object|Closure $instance + * @return void + */ + public static function setInstance($instance): void + { + static::$instance = $instance; + } + + /** + * 注册一个容器对象回调 + * + * @param string|Closure $abstract + * @param Closure|null $callback + * @return void + */ + public function resolving(string|Closure $abstract, ?Closure $callback = null): void + { + if ($abstract instanceof Closure) { + $this->invokeCallback['*'][] = $abstract; + return; + } + + $abstract = $this->getAlias($abstract); + + $this->invokeCallback[$abstract][] = $callback; + } + + /** + * 获取容器中的对象实例 不存在则创建 + * @template T + * @param string|class-string $abstract 类名或者标识 + * @param array $vars 变量 + * @param bool $newInstance 是否每次创建新的实例 + * @return T|object + */ + public static function pull(string $abstract, array $vars = [], bool $newInstance = false) + { + return static::getInstance()->make($abstract, $vars, $newInstance); + } + + /** + * 获取容器中的对象实例 + * @template T + * @param string|class-string $abstract 类名或者标识 + * @return T|object + */ + public function get(string $abstract) + { + if ($this->has($abstract)) { + return $this->make($abstract); + } + + throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract); + } + + /** + * 绑定一个类、闭包、实例、接口实现到容器 + * @access public + * @param string|array $abstract 类标识、接口 + * @param mixed $concrete 要绑定的类、闭包或者实例 + * @return $this + */ + public function bind(string|array $abstract, $concrete = null) + { + if (is_array($abstract)) { + foreach ($abstract as $key => $val) { + $this->bind($key, $val); + } + } elseif ($concrete instanceof Closure) { + $this->bind[$abstract] = $concrete; + } elseif (is_object($concrete)) { + $this->instance($abstract, $concrete); + } else { + $abstract = $this->getAlias($abstract); + if ($abstract != $concrete) { + $this->bind[$abstract] = $concrete; + } + } + + return $this; + } + + /** + * 根据别名获取真实类名 + * @param string $abstract + * @return string + */ + public function getAlias(string $abstract): string + { + if (isset($this->bind[$abstract])) { + $bind = $this->bind[$abstract]; + + if (is_string($bind)) { + return $this->getAlias($bind); + } + } + + return $abstract; + } + + /** + * 绑定一个类实例到容器 + * @access public + * @param string $abstract 类名或者标识 + * @param object $instance 类的实例 + * @return $this + */ + public function instance(string $abstract, $instance) + { + $abstract = $this->getAlias($abstract); + + $this->instances[$abstract] = $instance; + + return $this; + } + + /** + * 判断容器中是否存在类及标识 + * @access public + * @param string $abstract 类名或者标识 + * @return bool + */ + public function bound(string $abstract): bool + { + return isset($this->bind[$abstract]) || isset($this->instances[$abstract]); + } + + /** + * 判断容器中是否存在类及标识 + * @access public + * @param string $name 类名或者标识 + * @return bool + */ + public function has(string $name): bool + { + return $this->bound($name); + } + + /** + * 判断容器中是否存在对象实例 + * @access public + * @param string $abstract 类名或者标识 + * @return bool + */ + public function exists(string $abstract): bool + { + $abstract = $this->getAlias($abstract); + + return isset($this->instances[$abstract]); + } + + /** + * 创建类的实例 已经存在则直接获取 + * @template T + * @param string|class-string $abstract 类名或者标识 + * @param array $vars 变量 + * @param bool $newInstance 是否每次创建新的实例 + * @return T|object + */ + public function make(string $abstract, array $vars = [], bool $newInstance = false) + { + $abstract = $this->getAlias($abstract); + + if (isset($this->instances[$abstract]) && !$newInstance) { + return $this->instances[$abstract]; + } + + if (isset($this->bind[$abstract]) && $this->bind[$abstract] instanceof Closure) { + $object = $this->invokeFunction($this->bind[$abstract], $vars); + } else { + $object = $this->invokeClass($abstract, $vars); + } + + $this->invokeAfter($abstract, $object); + + if (!$newInstance) { + $this->instances[$abstract] = $object; + } + + return $object; + } + + /** + * 删除容器中的对象实例 + * @access public + * @param string $name 类名或者标识 + * @return void + */ + public function delete(string $name) + { + $name = $this->getAlias($name); + + if (isset($this->instances[$name])) { + unset($this->instances[$name]); + } + } + + /** + * 执行函数或者闭包方法 支持参数调用 + * @access public + * @param string|Closure $function 函数或者闭包 + * @param array $vars 参数 + * @return mixed + */ + public function invokeFunction(string|Closure $function, array $vars = []) + { + try { + $reflect = new ReflectionFunction($function); + } catch (ReflectionException $e) { + throw new FuncNotFoundException("function not exists: {$function}()", $function, $e); + } + + $args = $this->bindParams($reflect, $vars); + + return $function(...$args); + } + + /** + * 调用反射执行类的方法 支持参数绑定 + * @access public + * @param mixed $method 方法 + * @param array $vars 参数 + * @param bool $accessible 设置是否可访问 + * @return mixed + */ + public function invokeMethod($method, array $vars = [], bool $accessible = false) + { + if (is_array($method)) { + [$class, $method] = $method; + + $class = is_object($class) ? $class : $this->invokeClass($class); + } else { + // 静态方法 + [$class, $method] = explode('::', $method); + } + + try { + $reflect = new ReflectionMethod($class, $method); + } catch (ReflectionException $e) { + $class = is_object($class) ? $class::class : $class; + throw new FuncNotFoundException('method not exists: ' . $class . '::' . $method . '()', "{$class}::{$method}", $e); + } + + $args = $this->bindParams($reflect, $vars); + + if ($accessible) { + $reflect->setAccessible($accessible); + } + + return $reflect->invokeArgs(is_object($class) ? $class : null, $args); + } + + /** + * 调用反射执行类的方法 支持参数绑定 + * @access public + * @param object $instance 对象实例 + * @param mixed $reflect 反射类 + * @param array $vars 参数 + * @return mixed + */ + public function invokeReflectMethod($instance, $reflect, array $vars = []) + { + $args = $this->bindParams($reflect, $vars); + + return $reflect->invokeArgs($instance, $args); + } + + /** + * 调用反射执行callable 支持参数绑定 + * @access public + * @param mixed $callable + * @param array $vars 参数 + * @param bool $accessible 设置是否可访问 + * @return mixed + */ + public function invoke($callable, array $vars = [], bool $accessible = false) + { + if ($callable instanceof Closure) { + return $this->invokeFunction($callable, $vars); + } elseif (is_string($callable) && !str_contains($callable, '::')) { + return $this->invokeFunction($callable, $vars); + } else { + return $this->invokeMethod($callable, $vars, $accessible); + } + } + + /** + * 调用反射执行类的实例化 支持依赖注入 + * @access public + * @param string $class 类名 + * @param array $vars 参数 + * @return mixed + */ + public function invokeClass(string $class, array $vars = []) + { + try { + $reflect = new ReflectionClass($class); + } catch (ReflectionException $e) { + throw new ClassNotFoundException('class not exists: ' . $class, $class, $e); + } + + if ($reflect->hasMethod('__make')) { + $method = $reflect->getMethod('__make'); + if ($method->isPublic() && $method->isStatic()) { + $args = $this->bindParams($method, $vars); + return $method->invokeArgs(null, $args); + } + } + + $constructor = $reflect->getConstructor(); + + $args = $constructor ? $this->bindParams($constructor, $vars) : []; + + return $reflect->newInstanceArgs($args); + } + + /** + * 执行invokeClass回调 + * @access protected + * @param string $class 对象类名 + * @param object $object 容器对象实例 + * @return void + */ + protected function invokeAfter(string $class, $object): void + { + if (isset($this->invokeCallback['*'])) { + foreach ($this->invokeCallback['*'] as $callback) { + $callback($object, $this); + } + } + + if (isset($this->invokeCallback[$class])) { + foreach ($this->invokeCallback[$class] as $callback) { + $callback($object, $this); + } + } + } + + /** + * 绑定参数 + * @access protected + * @param ReflectionFunctionAbstract $reflect 反射类 + * @param array $vars 参数 + * @return array + */ + protected function bindParams(ReflectionFunctionAbstract $reflect, array $vars = []): array + { + if ($reflect->getNumberOfParameters() == 0) { + return []; + } + + // 判断数组类型 数字数组时按顺序绑定参数 + $type = array_is_list($vars) ? 1 : 0; + $params = $reflect->getParameters(); + $args = []; + + foreach ($params as $param) { + $name = $param->getName(); + $lowerName = Str::snake($name); + $reflectionType = $param->getType(); + + if ($param->isVariadic()) { + return array_merge($args, array_values($vars)); + } elseif ($reflectionType && $reflectionType instanceof ReflectionNamedType && $reflectionType->isBuiltin() === false) { + $className = $reflectionType->getName(); + if ($className == 'self') { + $className = $param->getDeclaringClass()->getName(); + } + $args[] = $this->getObjectParam($className, $vars, $param); + } elseif (1 == $type && !empty($vars)) { + $args[] = array_shift($vars); + } elseif (0 == $type && array_key_exists($name, $vars)) { + $args[] = $vars[$name]; + } elseif (0 == $type && array_key_exists($lowerName, $vars)) { + $args[] = $vars[$lowerName]; + } elseif ($param->isDefaultValueAvailable()) { + $args[] = $param->getDefaultValue(); + } else { + throw new InvalidArgumentException('method param miss:' . $name); + } + } + + return $args; + } + + /** + * 创建工厂对象实例 + * @param string $name 工厂类名 + * @param string $namespace 默认命名空间 + * @param array $args + * @return mixed + * @deprecated + * @access public + */ + public static function factory(string $name, string $namespace = '', ...$args) + { + $class = str_contains($name, '\\') ? $name : $namespace . ucwords($name); + + return Container::getInstance()->invokeClass($class, $args); + } + + /** + * 获取对象类型的参数值 + * @access protected + * @param string $className 类名 + * @param array $vars 参数 + * @param ReflectionParameter $param + * @return mixed + */ + protected function getObjectParam(string $className, array &$vars, ReflectionParameter $param) + { + $array = $vars; + $value = array_shift($array); + + if ($value instanceof $className) { + $result = $value; + array_shift($vars); + } else { + if ($param->isDefaultValueAvailable()) { + $result = $this->bound($className) ? $this->make($className) : $param->getDefaultValue(); + } else { + $result = $this->make($className); + } + } + + return $result; + } + + public function __set($name, $value) + { + $this->bind($name, $value); + } + + public function __get($name) + { + return $this->get($name); + } + + public function __isset($name): bool + { + return $this->exists($name); + } + + public function __unset($name) + { + $this->delete($name); + } + + public function offsetExists(mixed $key): bool + { + return $this->exists($key); + } + + public function offsetGet(mixed $key): mixed + { + return $this->make($key); + } + + public function offsetSet(mixed $key, mixed $value): void + { + $this->bind($key, $value); + } + + public function offsetUnset(mixed $key): void + { + $this->delete($key); + } + + //Countable + public function count(): int + { + return count($this->instances); + } + + //IteratorAggregate + public function getIterator(): Traversable + { + return new ArrayIterator($this->instances); + } +} diff --git a/vendor/topthink/think-container/src/Facade.php b/vendor/topthink/think-container/src/Facade.php new file mode 100644 index 0000000..51378da --- /dev/null +++ b/vendor/topthink/think-container/src/Facade.php @@ -0,0 +1,99 @@ + +// +---------------------------------------------------------------------- +namespace think; + +/** + * Facade管理类 + */ +class Facade +{ + /** + * 始终创建新的对象实例 + * @var bool + */ + protected static $alwaysNewInstance; + + /** + * 创建Facade实例 + * @static + * @access protected + * @param string $class 类名或标识 + * @param array $args 变量 + * @param bool $newInstance 是否每次创建新的实例 + * @return object + */ + protected static function createFacade(string $class = '', array $args = [], bool $newInstance = false) + { + $class = $class ?: static::class; + + $facadeClass = static::getFacadeClass(); + + if ($facadeClass) { + $class = $facadeClass; + } + + if (static::$alwaysNewInstance) { + $newInstance = true; + } + + return Container::getInstance()->make($class, $args, $newInstance); + } + + /** + * 获取当前Facade对应类名 + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + } + + /** + * 带参数实例化当前Facade类 + * @access public + * @return object + */ + public static function instance(...$args) + { + if (__CLASS__ != static::class) { + return self::createFacade('', $args); + } + } + + /** + * 调用类的实例 + * @access public + * @param string $class 类名或者标识 + * @param array|true $args 变量 + * @param bool $newInstance 是否每次创建新的实例 + * @return object + */ + public static function make(string $class, $args = [], $newInstance = false) + { + if (__CLASS__ != static::class) { + return self::__callStatic('make', func_get_args()); + } + + if (true === $args) { + // 总是创建新的实例化对象 + $newInstance = true; + $args = []; + } + + return self::createFacade($class, $args, $newInstance); + } + + // 调用实际类的方法 + public static function __callStatic($method, $params) + { + return call_user_func_array([static::createFacade(), $method], $params); + } +} diff --git a/vendor/topthink/think-container/src/exception/ClassNotFoundException.php b/vendor/topthink/think-container/src/exception/ClassNotFoundException.php new file mode 100644 index 0000000..940c3b6 --- /dev/null +++ b/vendor/topthink/think-container/src/exception/ClassNotFoundException.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use Psr\Container\NotFoundExceptionInterface; +use RuntimeException; +use Throwable; + +class ClassNotFoundException extends RuntimeException implements NotFoundExceptionInterface +{ + public function __construct(string $message, protected string $class = '', ?Throwable $previous = null) + { + $this->message = $message; + + parent::__construct($message, 0, $previous); + } + + /** + * 获取类名 + * @access public + * @return string + */ + public function getClass() + { + return $this->class; + } +} diff --git a/vendor/topthink/think-container/src/exception/FuncNotFoundException.php b/vendor/topthink/think-container/src/exception/FuncNotFoundException.php new file mode 100644 index 0000000..f6658cd --- /dev/null +++ b/vendor/topthink/think-container/src/exception/FuncNotFoundException.php @@ -0,0 +1,27 @@ +message = $message; + + parent::__construct($message, 0, $previous); + } + + /** + * 获取方法名 + * @access public + * @return string + */ + public function getFunc() + { + return $this->func; + } +} diff --git a/vendor/topthink/think-container/tests/ContainerTest.php b/vendor/topthink/think-container/tests/ContainerTest.php new file mode 100644 index 0000000..7614f3b --- /dev/null +++ b/vendor/topthink/think-container/tests/ContainerTest.php @@ -0,0 +1,361 @@ +name = $name; + } + + public function some(Container $container) + { + } + + protected function protectionFun() + { + return true; + } + + public static function test(Container $container) + { + return $container; + } + + public static function make(self $taylor) + { + return $taylor; + } + + public static function __make() + { + return new self('Taylor'); + } +} + +class SomeClass +{ + public $container; + + public $count = 0; + + public function __construct(Container $container) + { + $this->container = $container; + } +} + +class WithDefaultValues +{ + public $container; + + public function __construct(?Container $container = null) + { + $this->container = $container; + } + + /** + * 有默认值且类存在,但无法注入 + */ + public static function classExistsButCannotBeInjected(?Closure $closure = null) + { + return $closure; + } +} + +class ContainerTest extends TestCase +{ + protected function tearDown(): void + { + Container::setInstance(null); + } + + public function testClosureResolution() + { + $container = new Container; + + Container::setInstance($container); + + $container->bind('name', function () { + return 'Taylor'; + }); + + $this->assertEquals('Taylor', $container->make('name')); + + $this->assertEquals('Taylor', Container::pull('name')); + } + + public function testGet() + { + $container = new Container; + + $this->expectException(ClassNotFoundException::class); + $this->expectExceptionMessage('class not exists: name'); + $container->get('name'); + + $container->bind('name', function () { + return 'Taylor'; + }); + + $this->assertSame('Taylor', $container->get('name')); + } + + public function testExist() + { + $container = new Container; + + $container->bind('name', function () { + return 'Taylor'; + }); + + $this->assertFalse($container->exists("name")); + + $container->make('name'); + + $this->assertTrue($container->exists('name')); + } + + public function testInstance() + { + $container = new Container; + + $container->bind('name', function () { + return 'Taylor'; + }); + + $this->assertEquals('Taylor', $container->get('name')); + + $container->bind('name2', Taylor::class); + + $object = new stdClass(); + + $this->assertFalse($container->exists('name2')); + + $container->instance('name2', $object); + + $this->assertTrue($container->exists('name2')); + + $this->assertTrue($container->exists(Taylor::class)); + + $this->assertEquals($object, $container->make(Taylor::class)); + + unset($container->name1); + + $this->assertFalse($container->exists('name1')); + + $container->delete('name2'); + + $this->assertFalse($container->exists('name2')); + + foreach ($container as $class => $instance) { + + } + } + + public function testSelf() + { + $container = new Container; + + $taylor = new Taylor('test'); + + $container->invoke([Taylor::class, 'make'], [$taylor]); + } + + public function testBind() + { + $container = new Container; + + $object = new stdClass(); + + $container->bind(['name' => Taylor::class]); + + $container->bind('name2', $object); + + $container->bind('name3', Taylor::class); + + $container->name4 = $object; + + $container['name5'] = $object; + + $this->assertTrue(isset($container->name4)); + + $this->assertTrue(isset($container['name5'])); + + $this->assertInstanceOf(Taylor::class, $container->get('name')); + + $this->assertSame($object, $container->get('name2')); + + $this->assertSame($object, $container->name4); + + $this->assertSame($object, $container['name5']); + + $this->assertInstanceOf(Taylor::class, $container->get('name3')); + + unset($container['name']); + + $this->assertFalse(isset($container['name'])); + + unset($container->name3); + + $this->assertFalse(isset($container->name3)); + } + + public function testAutoConcreteResolution() + { + $container = new Container; + + $taylor = $container->make(Taylor::class); + + $this->assertInstanceOf(Taylor::class, $taylor); + $this->assertSame('Taylor', $taylor->name); + } + + public function testGetAndSetInstance() + { + $this->assertInstanceOf(Container::class, Container::getInstance()); + + $object = new stdClass(); + + Container::setInstance($object); + + $this->assertSame($object, Container::getInstance()); + + Container::setInstance(function () { + return $this; + }); + + $this->assertSame($this, Container::getInstance()); + } + + public function testResolving() + { + $container = new Container(); + $container->bind(Container::class, $container); + + $container->resolving(function (SomeClass $taylor, Container $container) { + $taylor->count++; + }); + $container->resolving(SomeClass::class, function (SomeClass $taylor, Container $container) { + $taylor->count++; + }); + + /** @var SomeClass $someClass */ + $someClass = $container->make(SomeClass::class); + $this->assertEquals(2, $someClass->count); + } + + public function testInvokeFunctionWithoutMethodThrowsException() + { + $this->expectException(FuncNotFoundException::class); + $this->expectExceptionMessage('function not exists: ContainerTestCallStub()'); + $container = new Container(); + $container->invokeFunction('ContainerTestCallStub', []); + } + + public function testInvokeProtectionMethod() + { + $container = new Container(); + $this->assertTrue($container->invokeMethod([Taylor::class, 'protectionFun'], [], true)); + } + + public function testInvoke() + { + $container = new Container(); + + Container::setInstance($container); + + $container->bind(Container::class, $container); + + $stub = $this->createMock(Taylor::class); + + $stub->expects($this->once())->method('some')->with($container)->will($this->returnSelf()); + + $container->invokeMethod([$stub, 'some']); + + $this->assertEquals('48', $container->invoke('ord', ['0'])); + + $this->assertSame($container, $container->invoke(Taylor::class . '::test', [])); + + $this->assertSame($container, $container->invokeMethod(Taylor::class . '::test')); + + $reflect = new ReflectionMethod($container, 'exists'); + + $this->assertTrue($container->invokeReflectMethod($container, $reflect, [Container::class])); + + $this->assertSame($container, $container->invoke(function (Container $container) { + return $container; + })); + + $this->assertSame($container, $container->invoke(Taylor::class . '::test')); + + $object = $container->invokeClass(SomeClass::class); + $this->assertInstanceOf(SomeClass::class, $object); + $this->assertSame($container, $object->container); + + $stdClass = new stdClass(); + + $container->invoke(function (Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { + $this->assertEquals('value1', $key1); + $this->assertEquals('default', $key2); + $this->assertEquals('value2', $lowKey); + $this->assertSame($stdClass, $stdObject); + return $container; + }, ['some' => $stdClass, 'key1' => 'value1', 'low_key' => 'value2']); + } + + public function testInvokeMethodNotExists() + { + $container = $this->resolveContainer(); + $this->expectException(FuncNotFoundException::class); + + $container->invokeMethod([SomeClass::class, 'any']); + } + + public function testInvokeClassNotExists() + { + $container = new Container(); + + Container::setInstance($container); + + $container->bind(Container::class, $container); + + $this->expectExceptionObject(new ClassNotFoundException('class not exists: SomeClass')); + + $container->invokeClass('SomeClass'); + } + + public function testInvokeWithDefaultValues() + { + $container = $this->resolveContainer(); + + $class = $container->invokeClass(WithDefaultValues::class); + $this->assertSame(null, $class->container); + + $container->bind(Container::class, $container); + $bound = $container->invokeClass(WithDefaultValues::class); + $this->assertSame($container, $bound->container); + + $this->assertSame(null, $container->invokeMethod(WithDefaultValues::class . '::classExistsButCannotBeInjected')); + } + + protected function resolveContainer() + { + $container = new Container(); + + Container::setInstance($container); + return $container; + } +} diff --git a/vendor/topthink/think-container/tests/bootstrap.php b/vendor/topthink/think-container/tests/bootstrap.php new file mode 100644 index 0000000..991ea43 --- /dev/null +++ b/vendor/topthink/think-container/tests/bootstrap.php @@ -0,0 +1,3 @@ + 请放心,变量内容不会经过服务器,只会保存在本地浏览器,并且可以随时清除。 diff --git a/vendor/topthink/think-dumper/composer.json b/vendor/topthink/think-dumper/composer.json new file mode 100644 index 0000000..222d24c --- /dev/null +++ b/vendor/topthink/think-dumper/composer.json @@ -0,0 +1,32 @@ +{ + "name": "topthink/think-dumper", + "description": "Dumper extend for thinkphp", + "license": "Apache-2.0", + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "autoload": { + "psr-4": { + "think\\dumper\\": "src" + }, + "files": [ + "src/helper.php" + ] + }, + "autoload-dev": { + "psr-4": { + "think\\tests\\dumper\\": "tests/" + } + }, + "require": { + "php": ">=8.0.2", + "topthink/framework": "^6.0|^8.0", + "symfony/var-dumper": ">=6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.4" + } +} diff --git a/vendor/topthink/think-dumper/phpunit.xml.dist b/vendor/topthink/think-dumper/phpunit.xml.dist new file mode 100644 index 0000000..dbccd71 --- /dev/null +++ b/vendor/topthink/think-dumper/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + ./tests + + + + + ./src + + + diff --git a/vendor/topthink/think-dumper/src/Connection.php b/vendor/topthink/think-dumper/src/Connection.php new file mode 100644 index 0000000..1dc2882 --- /dev/null +++ b/vendor/topthink/think-dumper/src/Connection.php @@ -0,0 +1,82 @@ +host = env('DUMPER_HOST', 'https://developer.topthink.com'); + $this->token = env('DUMPER_TOKEN'); + $this->contextProviders = $contextProviders; + } + + public function write(Data $data): bool + { + if (!$this->handle = $this->handle ?: $this->createHandle()) { + return false; + } + + $context = ['timestamp' => microtime(true)]; + foreach ($this->contextProviders as $name => $provider) { + $context[$name] = $provider->getContext(); + } + $context = array_filter($context); + $encodedPayload = base64_encode(serialize([$data, $context])) . "\n"; + + set_error_handler(fn() => true); + try { + return $this->sendPayload($encodedPayload); + } finally { + restore_error_handler(); + } + } + + private function sendPayload($payload) + { + curl_setopt($this->handle, CURLOPT_POSTFIELDS, $payload); + $res = curl_exec($this->handle); + if ($res === false) { + curl_close($this->handle); + $this->handle = null; + return false; + } + $code = curl_getinfo($this->handle, CURLINFO_HTTP_CODE); + return $code == 204; + } + + private function createHandle() + { + set_error_handler(fn() => true); + try { + $handle = curl_init("{$this->host}/api/thinkphp/dumper/server"); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handle, CURLOPT_POST, true); + curl_setopt($handle, CURLOPT_HTTPHEADER, [ + "Accept: application/json", + "Authorization: Bearer {$this->token}", + ]); + curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($handle, CURLOPT_TIMEOUT, 3); + curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 1); + return $handle; + } finally { + restore_error_handler(); + } + } + + public function __destruct() + { + if ($this->handle) { + curl_close($this->handle); + } + } +} diff --git a/vendor/topthink/think-dumper/src/Dumper.php b/vendor/topthink/think-dumper/src/Dumper.php new file mode 100644 index 0000000..b0cdada --- /dev/null +++ b/vendor/topthink/think-dumper/src/Dumper.php @@ -0,0 +1,103 @@ +app->runningInConsole() ? 'cli' : 'html'; + + $handler = $this->createHandler($format); + + return $handler($var, $label); + } + + private function createHandler($format) + { + $cloner = new VarCloner(); + $cloner->addCasters(ReflectionCaster::UNSET_CLOSURE_FILE_INFO); + + switch ($format) { + case 'html' : + $dumper = new HtmlDumper(); + break; + case 'cli': + $dumper = new CliDumper(); + break; + default: + throw new Exception('Invalid dump format.'); + } + + if ($this->env->has('DUMPER_TOKEN')) { + $dumper = new ServerDumper($dumper, $this->getDefaultContextProviders($format)); + } else { + $dumper = new ContextualizedDumper($dumper, [new SourceContextProvider()]); + } + + return function ($var, ?string $label = null) use ($cloner, $dumper) { + $var = $cloner->cloneVar($var); + + if (null !== $label) { + $var = $var->withContext(['label' => $label]); + } + + $dumper->dump($var); + }; + } + + private function getDefaultContextProviders($format): array + { + $contextProviders = []; + + switch ($format) { + case 'html' : + $contextProviders['request'] = new class($this->app->request) implements ContextProviderInterface { + public function __construct(protected Request $request) + { + } + + public function getContext(): ?array + { + $request = $this->request; + return [ + 'uri' => $request->url(), + 'method' => $request->method(), + 'identifier' => spl_object_hash($request), + ]; + } + }; + break; + case 'cli': + $contextProviders['cli'] = new class implements ContextProviderInterface { + public function getContext(): ?array + { + return [ + 'command_line' => $commandLine = implode(' ', $_SERVER['argv'] ?? []), + 'identifier' => hash('crc32b', $commandLine . $_SERVER['REQUEST_TIME_FLOAT']), + ]; + } + }; + break; + } + + $contextProviders['source'] = new SourceContextProvider(); + + return $contextProviders; + } +} diff --git a/vendor/topthink/think-dumper/src/ServerDumper.php b/vendor/topthink/think-dumper/src/ServerDumper.php new file mode 100644 index 0000000..e072d48 --- /dev/null +++ b/vendor/topthink/think-dumper/src/ServerDumper.php @@ -0,0 +1,31 @@ +connection = new Connection($contextProviders); + $this->wrappedDumper = $wrappedDumper; + } + + /** + * @return string|null + */ + public function dump(Data $data) + { + if (!$this->connection->write($data) && $this->wrappedDumper) { + return $this->wrappedDumper->dump($data); + } + + return null; + } +} diff --git a/vendor/topthink/think-dumper/src/SourceContextProvider.php b/vendor/topthink/think-dumper/src/SourceContextProvider.php new file mode 100644 index 0000000..d9a6ea9 --- /dev/null +++ b/vendor/topthink/think-dumper/src/SourceContextProvider.php @@ -0,0 +1,58 @@ +limit); + $trace = array_reverse($trace); + + $i = 0; + $file = '-'; + $line = 0; + + do { + $file = $trace[$i]['file'] ?? $file; + $line = $trace[$i]['line'] ?? $line; + + $function = $trace[$i]['function'] ?? null; + $class = $trace[$i]['class'] ?? null; + if ($function == 'dump' && ($class == null || $class == Dumper::class || $class == VarDumper::class)) { + break; + } + } while (++$i < $this->limit); + + $name = '-' === $file || 'Standard input code' === $file ? 'Standard input code' : false; + + if (false === $name) { + $name = str_replace('\\', '/', $file); + $name = substr($name, strrpos($name, '/') + 1); + } + + $context = ['name' => $name, 'file' => $file, 'line' => $line]; + + if (null !== $this->projectDir) { + $context['project_dir'] = $this->projectDir; + if (str_starts_with($file, $this->projectDir)) { + $context['file_relative'] = ltrim(substr($file, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); + } + } + + return $context; + } + +} diff --git a/vendor/topthink/think-dumper/src/helper.php b/vendor/topthink/think-dumper/src/helper.php new file mode 100644 index 0000000..9be8568 --- /dev/null +++ b/vendor/topthink/think-dumper/src/helper.php @@ -0,0 +1,8 @@ +dump($var, $label); +}); diff --git a/vendor/topthink/think-dumper/tests/DumperTest.php b/vendor/topthink/think-dumper/tests/DumperTest.php new file mode 100644 index 0000000..5c0c518 --- /dev/null +++ b/vendor/topthink/think-dumper/tests/DumperTest.php @@ -0,0 +1,14 @@ + 'bbb', 'cc' => 'dd']); + dump($this); + } +} diff --git a/vendor/topthink/think-dumper/tests/bootstrap.php b/vendor/topthink/think-dumper/tests/bootstrap.php new file mode 100644 index 0000000..7b24a1b --- /dev/null +++ b/vendor/topthink/think-dumper/tests/bootstrap.php @@ -0,0 +1,13 @@ +config->set([ + 'default' => 'file', + 'stores' => [ + 'file' => [ + 'type' => 'File', + ], + ], +], 'cache'); + +$app->initialize(); diff --git a/vendor/topthink/think-filesystem/README.md b/vendor/topthink/think-filesystem/README.md new file mode 100644 index 0000000..1b15dd0 --- /dev/null +++ b/vendor/topthink/think-filesystem/README.md @@ -0,0 +1,5 @@ +# think-filesystem for ThinkPHP + +## 安装 + +> composer require topthink/think-filesystem diff --git a/vendor/topthink/think-filesystem/composer.json b/vendor/topthink/think-filesystem/composer.json new file mode 100644 index 0000000..10ade00 --- /dev/null +++ b/vendor/topthink/think-filesystem/composer.json @@ -0,0 +1,34 @@ +{ + "name": "topthink/think-filesystem", + "description": "The ThinkPHP6.1 Filesystem Package", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "autoload": { + "psr-4": { + "think\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "think\\tests\\": "tests/" + } + }, + "require": { + "php": "^8.2", + "topthink/framework": "^8.0", + "league/flysystem": "^3.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^11.5" + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/vendor/topthink/think-filesystem/phpunit.xml.dist b/vendor/topthink/think-filesystem/phpunit.xml.dist new file mode 100644 index 0000000..f4d61c1 --- /dev/null +++ b/vendor/topthink/think-filesystem/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + ./tests + + + + + ./src/think + + + diff --git a/vendor/topthink/think-filesystem/src/Filesystem.php b/vendor/topthink/think-filesystem/src/Filesystem.php new file mode 100644 index 0000000..f7ee976 --- /dev/null +++ b/vendor/topthink/think-filesystem/src/Filesystem.php @@ -0,0 +1,89 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use InvalidArgumentException; +use think\filesystem\Driver; +use think\filesystem\driver\Local; +use think\helper\Arr; + +/** + * Class Filesystem + * @package think + * @mixin Driver + * @mixin Local + */ +class Filesystem extends Manager +{ + protected $namespace = '\\think\\filesystem\\driver\\'; + + /** + * @param null|string $name + * @return Driver + */ + public function disk(?string $name = null): Driver + { + return $this->driver($name); + } + + protected function resolveType(string $name) + { + return $this->getDiskConfig($name, 'type', 'local'); + } + + protected function resolveConfig(string $name) + { + return $this->getDiskConfig($name); + } + + /** + * 获取缓存配置 + * @access public + * @param null|string $name 名称 + * @param mixed $default 默认值 + * @return mixed + */ + public function getConfig(?string $name = null, $default = null) + { + if (!is_null($name)) { + return $this->app->config->get('filesystem.' . $name, $default); + } + + return $this->app->config->get('filesystem'); + } + + /** + * 获取磁盘配置 + * @param string $disk + * @param null $name + * @param null $default + * @return array + */ + public function getDiskConfig($disk, $name = null, $default = null) + { + if ($config = $this->getConfig("disks.{$disk}")) { + return Arr::get($config, $name, $default); + } + + throw new InvalidArgumentException("Disk [$disk] not found."); + } + + /** + * 默认驱动 + * @return string|null + */ + public function getDefaultDriver() + { + return $this->getConfig('default'); + } +} diff --git a/vendor/topthink/think-filesystem/src/facade/Filesystem.php b/vendor/topthink/think-filesystem/src/facade/Filesystem.php new file mode 100644 index 0000000..0e32c2c --- /dev/null +++ b/vendor/topthink/think-filesystem/src/facade/Filesystem.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\facade; + +use think\Facade; +use think\filesystem\Driver; + +/** + * Class Filesystem + * @package think\facade + * @mixin \think\Filesystem + * @method static Driver disk(string $name = null) , null|string + * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置 + * @method static array getDiskConfig(string $disk, null $name = null, null $default = null) 获取磁盘配置 + * @method static string|null getDefaultDriver() 默认驱动 + */ +class Filesystem extends Facade +{ + protected static function getFacadeClass() + { + return \think\Filesystem::class; + } +} diff --git a/vendor/topthink/think-filesystem/src/filesystem/Driver.php b/vendor/topthink/think-filesystem/src/filesystem/Driver.php new file mode 100644 index 0000000..e804141 --- /dev/null +++ b/vendor/topthink/think-filesystem/src/filesystem/Driver.php @@ -0,0 +1,130 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\filesystem; + +use League\Flysystem\Filesystem; +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\UnableToSetVisibility; +use League\Flysystem\UnableToWriteFile; +use RuntimeException; +use think\Cache; +use think\File; + +/** + * Class Driver + * @package think\filesystem + * @mixin Filesystem + */ +abstract class Driver +{ + + /** @var Cache */ + protected $cache; + + /** @var Filesystem */ + protected $filesystem; + + /** + * 配置参数 + * @var array + */ + protected $config = []; + + public function __construct(Cache $cache, array $config) + { + $this->cache = $cache; + $this->config = array_merge($this->config, $config); + + $adapter = $this->createAdapter(); + $this->filesystem = $this->createFilesystem($adapter); + } + + abstract protected function createAdapter(): FilesystemAdapter; + + protected function createFilesystem(FilesystemAdapter $adapter): Filesystem + { + $config = array_intersect_key($this->config, array_flip(['visibility', 'disable_asserts', 'url'])); + + return new Filesystem($adapter, $config); + } + + /** + * 获取文件完整路径 + * @param string $path + * @return string + */ + public function path(string $path): string + { + return $path; + } + + protected function concatPathToUrl($url, $path) + { + return rtrim($url, '/') . '/' . ltrim($path, '/'); + } + + public function url(string $path): string + { + throw new RuntimeException('This driver does not support retrieving URLs.'); + } + + /** + * 保存文件 + * @param string $path 路径 + * @param File $file 文件 + * @param null|string|\Closure $rule 文件名规则 + * @param array $options 参数 + * @return bool|string + */ + public function putFile(string $path, File $file, $rule = null, array $options = []) + { + return $this->putFileAs($path, $file, $file->hashName($rule), $options); + } + + /** + * 指定文件名保存文件 + * @param string $path 路径 + * @param File $file 文件 + * @param string $name 文件名 + * @param array $options 参数 + * @return bool|string + */ + public function putFileAs(string $path, File $file, string $name, array $options = []) + { + $stream = fopen($file->getRealPath(), 'r'); + $path = trim($path . '/' . $name, '/'); + + $result = $this->put($path, $stream, $options); + + if (is_resource($stream)) { + fclose($stream); + } + + return $result ? $path : false; + } + + protected function put(string $path, $contents, array $options = []) + { + try { + $this->writeStream($path, $contents, $options); + } catch (UnableToWriteFile|UnableToSetVisibility $e) { + return false; + } + return true; + } + + public function __call($method, $parameters) + { + return $this->filesystem->$method(...$parameters); + } +} diff --git a/vendor/topthink/think-filesystem/src/filesystem/driver/Local.php b/vendor/topthink/think-filesystem/src/filesystem/driver/Local.php new file mode 100644 index 0000000..3b1b64d --- /dev/null +++ b/vendor/topthink/think-filesystem/src/filesystem/driver/Local.php @@ -0,0 +1,98 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\filesystem\driver; + +use League\Flysystem\FilesystemAdapter; +use League\Flysystem\Local\LocalFilesystemAdapter; +use League\Flysystem\PathNormalizer; +use League\Flysystem\PathPrefixer; +use League\Flysystem\UnixVisibility\PortableVisibilityConverter; +use League\Flysystem\Visibility; +use League\Flysystem\WhitespacePathNormalizer; +use think\filesystem\Driver; + +class Local extends Driver +{ + /** + * 配置参数 + * @var array + */ + protected $config = [ + 'root' => '', + ]; + + /** + * @var PathPrefixer + */ + protected $prefixer; + + /** + * @var PathNormalizer + */ + protected $normalizer; + + protected function createAdapter(): FilesystemAdapter + { + $visibility = PortableVisibilityConverter::fromArray( + $this->config['permissions'] ?? [], + $this->config['visibility'] ?? Visibility::PRIVATE + ); + + $links = ($this->config['links'] ?? null) === 'skip' + ? LocalFilesystemAdapter::SKIP_LINKS + : LocalFilesystemAdapter::DISALLOW_LINKS; + + return new LocalFilesystemAdapter( + $this->config['root'], + $visibility, + $this->config['lock'] ?? LOCK_EX, + $links + ); + } + + protected function prefixer() + { + if (!$this->prefixer) { + $this->prefixer = new PathPrefixer($this->config['root'], DIRECTORY_SEPARATOR); + } + return $this->prefixer; + } + + protected function normalizer() + { + if (!$this->normalizer) { + $this->normalizer = new WhitespacePathNormalizer(); + } + return $this->normalizer; + } + + /** + * 获取文件访问地址 + * @param string $path 文件路径 + * @return string + */ + public function url(string $path): string + { + $path = $this->normalizer()->normalizePath($path); + + if (isset($this->config['url'])) { + return $this->concatPathToUrl($this->config['url'], $path); + } + return parent::url($path); + } + + public function path(string $path): string + { + return $this->prefixer()->prefixPath($path); + } +} diff --git a/vendor/topthink/think-filesystem/tests/FilesystemTest.php b/vendor/topthink/think-filesystem/tests/FilesystemTest.php new file mode 100644 index 0000000..e0ac69b --- /dev/null +++ b/vendor/topthink/think-filesystem/tests/FilesystemTest.php @@ -0,0 +1,80 @@ +app = m::mock(App::class)->makePartial(); + Container::setInstance($this->app); + $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); + $this->config = m::mock(Config::class); + $this->config->shouldReceive('get')->with('filesystem.default', null)->andReturn('local'); + $this->app->shouldReceive('get')->with('config')->andReturn($this->config); + $this->filesystem = new Filesystem($this->app); + + $this->root = vfsStream::setup('rootDir'); + } + + protected function tearDown(): void + { + m::close(); + } + + public function testDisk() + { + $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ + 'type' => 'local', + 'root' => $this->root->url(), + ]); + + $this->config->shouldReceive('get')->with('filesystem.disks.foo', null)->andReturn([ + 'type' => 'local', + 'root' => $this->root->url(), + ]); + + $this->assertInstanceOf(Local::class, $this->filesystem->disk()); + + $this->assertInstanceOf(Local::class, $this->filesystem->disk('foo')); + } + + public function testPutFile() + { + $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ + 'type' => 'local', + 'root' => $this->root->url(), + 'lock' => 0, + ]); + $disk = $this->filesystem->disk(); + + $path = $disk->putFile('somepath', new File(__DIR__ . '/test.txt'), 'md5'); + + $this->assertTrue($this->root->hasChild(str_replace(DIRECTORY_SEPARATOR, '/', $path))); + } + +} diff --git a/vendor/topthink/think-filesystem/tests/bootstrap.php b/vendor/topthink/think-filesystem/tests/bootstrap.php new file mode 100644 index 0000000..a4abe2d --- /dev/null +++ b/vendor/topthink/think-filesystem/tests/bootstrap.php @@ -0,0 +1,2 @@ + 以下类库都在`\\think\\helper`命名空间下 + +## Str + +> 字符串操作 + +``` +// 检查字符串中是否包含某些字符串 +Str::contains($haystack, $needles) + +// 检查字符串是否以某些字符串结尾 +Str::endsWith($haystack, $needles) + +// 获取指定长度的随机字母数字组合的字符串 +Str::random($length = 16) + +// 字符串转小写 +Str::lower($value) + +// 字符串转大写 +Str::upper($value) + +// 获取字符串的长度 +Str::length($value) + +// 截取字符串 +Str::substr($string, $start, $length = null) + +``` \ No newline at end of file diff --git a/vendor/topthink/think-helper/composer.json b/vendor/topthink/think-helper/composer.json new file mode 100644 index 0000000..0892fa6 --- /dev/null +++ b/vendor/topthink/think-helper/composer.json @@ -0,0 +1,36 @@ +{ + "name": "topthink/think-helper", + "description": "The ThinkPHP6 Helper Package", + "license": "Apache-2.0", + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "autoload": { + "psr-4": { + "think\\": "src" + }, + "files": [ + "src/helper.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests" + } + }, + "scripts": { + "test": "./vendor/bin/phpunit --colors" + }, + "scripts-descriptions": { + "test": "Run all tests." + } +} diff --git a/vendor/topthink/think-helper/phpunit.xml.dist b/vendor/topthink/think-helper/phpunit.xml.dist new file mode 100644 index 0000000..c083f14 --- /dev/null +++ b/vendor/topthink/think-helper/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + ./tests/ + + + + + ./src + + + diff --git a/vendor/topthink/think-helper/src/Collection.php b/vendor/topthink/think-helper/src/Collection.php new file mode 100644 index 0000000..9403711 --- /dev/null +++ b/vendor/topthink/think-helper/src/Collection.php @@ -0,0 +1,678 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use ArrayAccess; +use ArrayIterator; +use Countable; +use IteratorAggregate; +use JsonSerializable; +use think\contract\Arrayable; +use think\contract\Jsonable; +use think\helper\Arr; +use Traversable; + +/** + * 数据集管理类 + * + * @template TKey of array-key + * @template-covariant TValue + * + * @implements ArrayAccess + * @implements IteratorAggregate + */ +class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Arrayable, Jsonable +{ + /** + * 数据集数据 + * @var array + */ + protected $items = []; + + /** + * 构造函数 + * @param iterable|Collection $items 数据 + */ + public function __construct($items = []) + { + $this->items = $this->convertToArray($items); + } + + /** + * @param iterable|Collection $items + * @return static + */ + public static function make($items = []) + { + return new static($items); + } + + /** + * 是否为空 + * @return bool + */ + public function isEmpty(): bool + { + return empty($this->items); + } + + public function toArray(): array + { + return array_map(function ($value) { + return $value instanceof Arrayable ? $value->toArray() : $value; + }, $this->items); + } + + /** + * @return array + */ + public function all(): array + { + return $this->items; + } + + /** + * 合并数组 + * + * @param mixed $items 数据 + * @return static + */ + public function merge($items) + { + return new static(array_merge($this->items, $this->convertToArray($items))); + } + + /** + * 按指定键整理数据 + * + * @param mixed $items 数据 + * @param string|null $indexKey 键名 + * @return array + */ + public function dictionary($items = null, ?string &$indexKey = null) + { + if ($items instanceof self) { + $items = $items->all(); + } + + $items = is_null($items) ? $this->items : $items; + + if ($items && empty($indexKey)) { + $indexKey = is_array($items[0]) ? 'id' : $items[0]->getPk(); + } + + if (isset($indexKey) && is_string($indexKey)) { + return array_column($items, null, $indexKey); + } + + return $items; + } + + /** + * 比较数组,返回差集 + * + * @param mixed $items 数据 + * @param string|null $indexKey 指定比较的键名 + * @return static + */ + public function diff($items, ?string $indexKey = null) + { + if ($this->isEmpty() || is_scalar($this->items[0])) { + return new static(array_diff($this->items, $this->convertToArray($items))); + } + + $diff = []; + $dictionary = $this->dictionary($items, $indexKey); + + if (is_string($indexKey)) { + foreach ($this->items as $item) { + if (!isset($dictionary[$item[$indexKey]])) { + $diff[] = $item; + } + } + } + + return new static($diff); + } + + /** + * 比较数组,返回交集 + * + * @param mixed $items 数据 + * @param string|null $indexKey 指定比较的键名 + * @return static + */ + public function intersect($items, ?string $indexKey = null) + { + if ($this->isEmpty() || is_scalar($this->items[0])) { + return new static(array_intersect($this->items, $this->convertToArray($items))); + } + + $intersect = []; + $dictionary = $this->dictionary($items, $indexKey); + + if (is_string($indexKey)) { + foreach ($this->items as $item) { + if (isset($dictionary[$item[$indexKey]])) { + $intersect[] = $item; + } + } + } + + return new static($intersect); + } + + /** + * 交换数组中的键和值 + * + * @return static + */ + public function flip() + { + return new static(array_flip($this->items)); + } + + /** + * 返回数组中所有的键名 + * + * @return static + */ + public function keys() + { + return new static(array_keys($this->items)); + } + + /** + * 返回数组中所有的值组成的新 Collection 实例 + * @return static + */ + public function values() + { + return new static(array_values($this->items)); + } + + /** + * 删除数组的最后一个元素(出栈) + * + * @return TValue + */ + public function pop() + { + return array_pop($this->items); + } + + /** + * 通过使用用户自定义函数,以字符串返回数组 + * + * @param callable $callback 调用方法 + * @param mixed $initial + * @return mixed + */ + public function reduce(callable $callback, $initial = null) + { + return array_reduce($this->items, $callback, $initial); + } + + /** + * 以相反的顺序返回数组。 + * + * @return static + */ + public function reverse() + { + return new static(array_reverse($this->items)); + } + + /** + * 删除数组中首个元素,并返回被删除元素的值 + * + * @return TValue + */ + public function shift() + { + return array_shift($this->items); + } + + /** + * 在数组结尾插入一个元素 + * + * @param mixed $value 元素 + * @param string|null $key KEY + * @return $this + */ + public function push($value, ?string $key = null) + { + if (is_null($key)) { + $this->items[] = $value; + } else { + $this->items[$key] = $value; + } + + return $this; + } + + /** + * 把一个数组分割为新的数组块. + * + * @param int $size 块大小 + * @param bool $preserveKeys + * @return static + */ + public function chunk(int $size, bool $preserveKeys = false) + { + $chunks = []; + + foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk) { + $chunks[] = new static($chunk); + } + + return new static($chunks); + } + + /** + * 在数组开头插入一个元素 + * + * @param mixed $value 元素 + * @param string|null $key KEY + * @return $this + */ + public function unshift($value, ?string $key = null) + { + if (is_null($key)) { + array_unshift($this->items, $value); + } else { + $this->items = [$key => $value] + $this->items; + } + + return $this; + } + + /** + * 给每个元素执行个回调 + * + * + * @param callable $callback 回调 + * @return $this + */ + public function each(callable $callback) + { + foreach ($this->items as $key => $item) { + $result = $callback($item, $key); + + if (false === $result) { + break; + } elseif (!is_object($item)) { + $this->items[$key] = $result; + } + } + + return $this; + } + + /** + * 用回调函数处理数组中的元素 + * + * @param callable|null $callback 回调 + * @return static + */ + public function map(callable $callback) + { + return new static(array_map($callback, $this->items)); + } + + /** + * 用回调函数过滤数组中的元素 + * + * @param callable|null $callback 回调 + * @return static + */ + public function filter(?callable $callback = null) + { + if ($callback) { + return new static(array_filter($this->items, $callback)); + } + + return new static(array_filter($this->items)); + } + + /** + * 根据字段条件过滤数组中的元素 + * + * @param string $field 字段名 + * @param mixed $operator 操作符 + * @param mixed $value 数据 + * @return static + */ + public function where(string $field, $operator, $value = null) + { + if (is_null($value)) { + $value = $operator; + $operator = '='; + } + + return $this->filter(function ($data) use ($field, $operator, $value) { + if (strpos($field, '.')) { + [$field, $relation] = explode('.', $field); + + $result = $data[$field][$relation] ?? null; + } else { + $result = $data[$field] ?? null; + } + + switch (strtolower($operator)) { + case '===': + return $result === $value; + case '!==': + return $result !== $value; + case '!=': + case '<>': + return $result != $value; + case '>': + return $result > $value; + case '>=': + return $result >= $value; + case '<': + return $result < $value; + case '<=': + return $result <= $value; + case 'like': + return is_string($result) && false !== strpos($result, $value); + case 'not like': + return is_string($result) && false === strpos($result, $value); + case 'in': + return is_scalar($result) && in_array($result, $value, true); + case 'not in': + return is_scalar($result) && !in_array($result, $value, true); + case 'between': + [$min, $max] = is_string($value) ? explode(',', $value) : $value; + return is_scalar($result) && $result >= $min && $result <= $max; + case 'not between': + [$min, $max] = is_string($value) ? explode(',', $value) : $value; + return is_scalar($result) && $result > $max || $result < $min; + case '==': + case '=': + default: + return $result == $value; + } + }); + } + + /** + * LIKE过滤 + * + * @param string $field 字段名 + * @param string $value 数据 + * @return static + */ + public function whereLike(string $field, string $value) + { + return $this->where($field, 'like', $value); + } + + /** + * NOT LIKE过滤 + * + * @param string $field 字段名 + * @param string $value 数据 + * @return static + */ + public function whereNotLike(string $field, string $value) + { + return $this->where($field, 'not like', $value); + } + + /** + * IN过滤 + * + * @param string $field 字段名 + * @param array $value 数据 + * @return static + */ + public function whereIn(string $field, array $value) + { + return $this->where($field, 'in', $value); + } + + /** + * NOT IN过滤 + * + * @param string $field 字段名 + * @param array $value 数据 + * @return static + */ + public function whereNotIn(string $field, array $value) + { + return $this->where($field, 'not in', $value); + } + + /** + * BETWEEN 过滤 + * + * @param string $field 字段名 + * @param mixed $value 数据 + * @return static + */ + public function whereBetween(string $field, $value) + { + return $this->where($field, 'between', $value); + } + + /** + * NOT BETWEEN 过滤 + * + * @param string $field 字段名 + * @param mixed $value 数据 + * @return static + */ + public function whereNotBetween(string $field, $value) + { + return $this->where($field, 'not between', $value); + } + + /** + * 返回数据中指定的一列 + * + * @param string|null $columnKey 键名 + * @param string|null $indexKey 作为索引值的列 + * @return array + */ + public function column(?string $columnKey, ?string $indexKey = null) + { + return array_column($this->items, $columnKey, $indexKey); + } + + /** + * 对数组排序 + * + * @param callable|null $callback 回调 + * @return static + */ + public function sort(?callable $callback = null) + { + $items = $this->items; + + $callback = $callback ?: function ($a, $b) { + return $a == $b ? 0 : (($a < $b) ? -1 : 1); + }; + + uasort($items, $callback); + + return new static($items); + } + + /** + * 指定字段排序 + * + * @param string $field 排序字段 + * @param string $order 排序 + * @return $this + */ + public function order(string $field, string $order = 'asc') + { + return $this->sort(function ($a, $b) use ($field, $order) { + $fieldA = $a[$field] ?? null; + $fieldB = $b[$field] ?? null; + + return 'desc' == strtolower($order) ? ($fieldB <=> $fieldA) : ($fieldA <=> $fieldB); + }); + } + + /** + * 将数组打乱 + * + * @return static + */ + public function shuffle() + { + $items = $this->items; + + shuffle($items); + + return new static($items); + } + + /** + * 获取第一个单元数据 + * + * @param callable|null $callback + * @param null $default + * @return TValue + */ + public function first(?callable $callback = null, $default = null) + { + return Arr::first($this->items, $callback, $default); + } + + /** + * 获取最后一个单元数据 + * + * @param callable|null $callback + * @param null $default + * @return TValue + */ + public function last(?callable $callback = null, $default = null) + { + return Arr::last($this->items, $callback, $default); + } + + /** + * 截取数组 + * + * @param int $offset 起始位置 + * @param int|null $length 截取长度 + * @param bool $preserveKeys preserveKeys + * @return static + */ + public function slice(int $offset, ?int $length = null, bool $preserveKeys = false) + { + return new static(array_slice($this->items, $offset, $length, $preserveKeys)); + } + + /** + * @param TKey $key + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) : bool + { + return array_key_exists($offset, $this->items); + } + + /** + * @param TKey $offset + * @return TValue + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->items[$offset]; + } + + /** + * @param TKey|null $offset + * @param TValue $value + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->items[] = $value; + } else { + $this->items[$offset] = $value; + } + } + + /** + * @param TKey $offset + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->items[$offset]); + } + + //Countable + public function count(): int + { + return count($this->items); + } + + /** + * @return ArrayIterator + */ + #[\ReturnTypeWillChange] + public function getIterator(): Traversable + { + return new ArrayIterator($this->items); + } + + //JsonSerializable + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return $this->toArray(); + } + + /** + * 转换当前数据集为JSON字符串 + * + * @param integer $options json参数 + * @return string + */ + public function toJson(int $options = JSON_UNESCAPED_UNICODE): string + { + return json_encode($this->toArray(), $options); + } + + public function __toString() + { + return $this->toJson(); + } + + /** + * 转换成数组 + * + * @param mixed $items 数据 + * @return array + */ + protected function convertToArray($items): array + { + if ($items instanceof self) { + return $items->all(); + } + + return (array) $items; + } +} diff --git a/vendor/topthink/think-helper/src/contract/Arrayable.php b/vendor/topthink/think-helper/src/contract/Arrayable.php new file mode 100644 index 0000000..7c6b992 --- /dev/null +++ b/vendor/topthink/think-helper/src/contract/Arrayable.php @@ -0,0 +1,8 @@ + +// +---------------------------------------------------------------------- + +use think\Collection; +use think\helper\Arr; + +if (!function_exists('throw_if')) { + /** + * 按条件抛异常 + * + * @template TValue + * @template TException of \Throwable + * + * @param TValue $condition + * @param TException|class-string|string $exception + * @param mixed ...$parameters + * @return TValue + * + * @throws TException + */ + function throw_if($condition, $exception, ...$parameters) + { + if ($condition) { + throw (is_string($exception) ? new $exception(...$parameters) : $exception); + } + + return $condition; + } +} + +if (!function_exists('throw_unless')) { + /** + * 按条件抛异常 + * + * @template TValue + * @template TException of \Throwable + * + * @param TValue $condition + * @param TException|class-string|string $exception + * @param mixed ...$parameters + * @return TValue + * + * @throws TException + */ + function throw_unless($condition, $exception, ...$parameters) + { + if (!$condition) { + throw (is_string($exception) ? new $exception(...$parameters) : $exception); + } + + return $condition; + } +} + +if (!function_exists('tap')) { + /** + * 对一个值调用给定的闭包,然后返回该值 + * + * @template TValue + * + * @param TValue $value + * @param (callable(TValue): mixed)|null $callback + * @return TValue + */ + function tap($value, $callback = null) + { + if (is_null($callback)) { + return $value; + } + + $callback($value); + + return $value; + } +} + +if (!function_exists('value')) { + /** + * Return the default value of the given value. + * + * @template TValue + * + * @param TValue|\Closure(): TValue $value + * @return TValue + */ + function value($value) + { + return $value instanceof Closure ? $value() : $value; + } +} + +if (!function_exists('collect')) { + /** + * Create a collection from the given value. + * + * @param mixed $value + * @return Collection + */ + function collect($value = null) + { + return new Collection($value); + } +} + +if (!function_exists('data_fill')) { + /** + * Fill in data where it's missing. + * + * @param mixed $target + * @param string|array $key + * @param mixed $value + * @return mixed + */ + function data_fill(&$target, $key, $value) + { + return data_set($target, $key, $value, false); + } +} + +if (!function_exists('data_get')) { + /** + * Get an item from an array or object using "dot" notation. + * + * @param mixed $target + * @param string|array|int $key + * @param mixed $default + * @return mixed + */ + function data_get($target, $key, $default = null) + { + if (is_null($key)) { + return $target; + } + + $key = is_array($key) ? $key : explode('.', $key); + + while (!is_null($segment = array_shift($key))) { + if ('*' === $segment) { + if ($target instanceof Collection) { + $target = $target->all(); + } elseif (!is_array($target)) { + return value($default); + } + + $result = []; + + foreach ($target as $item) { + $result[] = data_get($item, $key); + } + + return in_array('*', $key) ? Arr::collapse($result) : $result; + } + + if (Arr::accessible($target) && Arr::exists($target, $segment)) { + $target = $target[$segment]; + } elseif (is_object($target) && isset($target->{$segment})) { + $target = $target->{$segment}; + } else { + return value($default); + } + } + + return $target; + } +} + +if (!function_exists('data_set')) { + /** + * Set an item on an array or object using dot notation. + * + * @param mixed $target + * @param string|array $key + * @param mixed $value + * @param bool $overwrite + * @return mixed + */ + function data_set(&$target, $key, $value, $overwrite = true) + { + $segments = is_array($key) ? $key : explode('.', $key); + + if (($segment = array_shift($segments)) === '*') { + if (!Arr::accessible($target)) { + $target = []; + } + + if ($segments) { + foreach ($target as &$inner) { + data_set($inner, $segments, $value, $overwrite); + } + } elseif ($overwrite) { + foreach ($target as &$inner) { + $inner = $value; + } + } + } elseif (Arr::accessible($target)) { + if ($segments) { + if (!Arr::exists($target, $segment)) { + $target[$segment] = []; + } + + data_set($target[$segment], $segments, $value, $overwrite); + } elseif ($overwrite || !Arr::exists($target, $segment)) { + $target[$segment] = $value; + } + } elseif (is_object($target)) { + if ($segments) { + if (!isset($target->{$segment})) { + $target->{$segment} = []; + } + + data_set($target->{$segment}, $segments, $value, $overwrite); + } elseif ($overwrite || !isset($target->{$segment})) { + $target->{$segment} = $value; + } + } else { + $target = []; + + if ($segments) { + data_set($target[$segment], $segments, $value, $overwrite); + } elseif ($overwrite) { + $target[$segment] = $value; + } + } + + return $target; + } +} + +if (!function_exists('trait_uses_recursive')) { + /** + * 获取一个trait里所有引用到的trait + * + * @param string $trait Trait + * @return array + */ + function trait_uses_recursive(string $trait): array + { + $traits = class_uses($trait); + foreach ($traits as $trait) { + $traits += trait_uses_recursive($trait); + } + + return $traits; + } +} + +if (!function_exists('class_basename')) { + /** + * 获取类名(不包含命名空间) + * + * @param mixed $class 类名 + * @return string + */ + function class_basename($class): string + { + $class = is_object($class) ? get_class($class) : $class; + return basename(str_replace('\\', '/', $class)); + } +} + +if (!function_exists('class_uses_recursive')) { + /** + *获取一个类里所有用到的trait,包括父类的 + * + * @param mixed $class 类名 + * @return array + */ + function class_uses_recursive($class): array + { + if (is_object($class)) { + $class = get_class($class); + } + + $results = []; + $classes = array_merge([$class => $class], class_parents($class)); + foreach ($classes as $class) { + $results += trait_uses_recursive($class); + } + + return array_unique($results); + } +} + +if (!function_exists('array_is_list')) { + /** + * 判断数组是否为list + * + * @param array $array 数据 + * @return bool + */ + function array_is_list(array $array): bool + { + return array_values($array) === $array; + } +} + +if (!function_exists('json_validate')) { + /** + * 判断是否为有效json数据 + * + * @param string $string 数据 + * @return bool + */ + function json_validate(string $string): bool + { + json_decode($string); + return json_last_error() === JSON_ERROR_NONE; + } +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/helper/Arr.php b/vendor/topthink/think-helper/src/helper/Arr.php new file mode 100644 index 0000000..b671513 --- /dev/null +++ b/vendor/topthink/think-helper/src/helper/Arr.php @@ -0,0 +1,669 @@ + +// +---------------------------------------------------------------------- + +namespace think\helper; + +use ArrayAccess; +use InvalidArgumentException; +use think\Collection; + +class Arr +{ + + /** + * Determine whether the given value is array accessible. + * + * @param mixed $value + * @return bool + */ + public static function accessible($value) + { + return is_array($value) || $value instanceof ArrayAccess; + } + + /** + * Add an element to an array using "dot" notation if it doesn't exist. + * + * @param array $array + * @param string $key + * @param mixed $value + * @return array + */ + public static function add($array, $key, $value) + { + if (is_null(static::get($array, $key))) { + static::set($array, $key, $value); + } + + return $array; + } + + /** + * Collapse an array of arrays into a single array. + * + * @param array $array + * @return array + */ + public static function collapse($array) + { + $results = []; + + foreach ($array as $values) { + if ($values instanceof Collection) { + $values = $values->all(); + } elseif (!is_array($values)) { + continue; + } + + $results = array_merge($results, $values); + } + + return $results; + } + + /** + * Cross join the given arrays, returning all possible permutations. + * + * @param array ...$arrays + * @return array + */ + public static function crossJoin(...$arrays) + { + $results = [[]]; + + foreach ($arrays as $index => $array) { + $append = []; + + foreach ($results as $product) { + foreach ($array as $item) { + $product[$index] = $item; + + $append[] = $product; + } + } + + $results = $append; + } + + return $results; + } + + /** + * Divide an array into two arrays. One with keys and the other with values. + * + * @param array $array + * @return array + */ + public static function divide($array) + { + return [array_keys($array), array_values($array)]; + } + + /** + * Flatten a multi-dimensional associative array with dots. + * + * @param array $array + * @param string $prepend + * @return array + */ + public static function dot($array, $prepend = '') + { + $results = []; + + foreach ($array as $key => $value) { + if (is_array($value) && !empty($value)) { + $results = array_merge($results, static::dot($value, $prepend . $key . '.')); + } else { + $results[$prepend . $key] = $value; + } + } + + return $results; + } + + /** + * Get all of the given array except for a specified array of keys. + * + * @param array $array + * @param array|string $keys + * @return array + */ + public static function except($array, $keys) + { + static::forget($array, $keys); + + return $array; + } + + /** + * Determine if the given key exists in the provided array. + * + * @param \ArrayAccess|array $array + * @param string|int $key + * @return bool + */ + public static function exists($array, $key) + { + if ($array instanceof ArrayAccess) { + return $array->offsetExists($key); + } + + return array_key_exists($key, $array); + } + + /** + * Return the first element in an array passing a given truth test. + * + * @param array $array + * @param callable|null $callback + * @param mixed $default + * @return mixed + */ + public static function first($array, ?callable $callback = null, $default = null) + { + if (is_null($callback)) { + if (empty($array)) { + return value($default); + } + + foreach ($array as $item) { + return $item; + } + } + + foreach ($array as $key => $value) { + if (call_user_func($callback, $value, $key)) { + return $value; + } + } + + return value($default); + } + + /** + * Return the last element in an array passing a given truth test. + * + * @param array $array + * @param callable|null $callback + * @param mixed $default + * @return mixed + */ + public static function last($array, ?callable $callback = null, $default = null) + { + if (is_null($callback)) { + return empty($array) ? value($default) : end($array); + } + + return static::first(array_reverse($array, true), $callback, $default); + } + + /** + * Flatten a multi-dimensional array into a single level. + * + * @param array $array + * @param int $depth + * @return array + */ + public static function flatten($array, $depth = INF) + { + $result = []; + + foreach ($array as $item) { + $item = $item instanceof Collection ? $item->all() : $item; + + if (!is_array($item)) { + $result[] = $item; + } elseif ($depth === 1) { + $result = array_merge($result, array_values($item)); + } else { + $result = array_merge($result, static::flatten($item, $depth - 1)); + } + } + + return $result; + } + + /** + * Remove one or many array items from a given array using "dot" notation. + * + * @param array $array + * @param array|string $keys + * @return void + */ + public static function forget(&$array, $keys) + { + $original = &$array; + + $keys = (array) $keys; + + if (count($keys) === 0) { + return; + } + + foreach ($keys as $key) { + // if the exact key exists in the top-level, remove it + if (static::exists($array, $key)) { + unset($array[$key]); + + continue; + } + + $parts = explode('.', $key); + + // clean up before each pass + $array = &$original; + + while (count($parts) > 1) { + $part = array_shift($parts); + + if (isset($array[$part]) && is_array($array[$part])) { + $array = &$array[$part]; + } else { + continue 2; + } + } + + unset($array[array_shift($parts)]); + } + } + + /** + * Get an item from an array using "dot" notation. + * + * @param \ArrayAccess|array $array + * @param string $key + * @param mixed $default + * @return mixed + */ + public static function get($array, $key, $default = null) + { + if (!static::accessible($array)) { + return value($default); + } + + if (is_null($key)) { + return $array; + } + + if (static::exists($array, $key)) { + return $array[$key]; + } + + if (strpos($key, '.') === false) { + return $array[$key] ?? value($default); + } + + foreach (explode('.', $key) as $segment) { + if (static::accessible($array) && static::exists($array, $segment)) { + $array = $array[$segment]; + } else { + return value($default); + } + } + + return $array; + } + + /** + * Check if an item or items exist in an array using "dot" notation. + * + * @param \ArrayAccess|array $array + * @param string|array $keys + * @return bool + */ + public static function has($array, $keys) + { + $keys = (array) $keys; + + if (!$array || $keys === []) { + return false; + } + + foreach ($keys as $key) { + $subKeyArray = $array; + + if (static::exists($array, $key)) { + continue; + } + + foreach (explode('.', $key) as $segment) { + if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) { + $subKeyArray = $subKeyArray[$segment]; + } else { + return false; + } + } + } + + return true; + } + + /** + * Determines if an array is associative. + * + * An array is "associative" if it doesn't have sequential numerical keys beginning with zero. + * + * @param array $array + * @return bool + */ + public static function isAssoc(array $array) + { + return !array_is_list($array); + } + + /** + * Get a subset of the items from the given array. + * + * @param array $array + * @param array|string $keys + * @return array + */ + public static function only($array, $keys) + { + return array_intersect_key($array, array_flip((array) $keys)); + } + + /** + * Pluck an array of values from an array. + * + * @param array $array + * @param string|array $value + * @param string|array|null $key + * @return array + */ + public static function pluck($array, $value, $key = null) + { + $results = []; + + [$value, $key] = static::explodePluckParameters($value, $key); + + foreach ($array as $item) { + $itemValue = data_get($item, $value); + + // If the key is "null", we will just append the value to the array and keep + // looping. Otherwise we will key the array using the value of the key we + // received from the developer. Then we'll return the final array form. + if (is_null($key)) { + $results[] = $itemValue; + } else { + $itemKey = data_get($item, $key); + + if (is_object($itemKey) && method_exists($itemKey, '__toString')) { + $itemKey = (string) $itemKey; + } + + $results[$itemKey] = $itemValue; + } + } + + return $results; + } + + /** + * Explode the "value" and "key" arguments passed to "pluck". + * + * @param string|array $value + * @param string|array|null $key + * @return array + */ + protected static function explodePluckParameters($value, $key) + { + $value = is_string($value) ? explode('.', $value) : $value; + + $key = is_null($key) || is_array($key) ? $key : explode('.', $key); + + return [$value, $key]; + } + + /** + * Push an item onto the beginning of an array. + * + * @param array $array + * @param mixed $value + * @param mixed $key + * @return array + */ + public static function prepend($array, $value, $key = null) + { + if (is_null($key)) { + array_unshift($array, $value); + } else { + $array = [$key => $value] + $array; + } + + return $array; + } + + /** + * Get a value from the array, and remove it. + * + * @param array $array + * @param string $key + * @param mixed $default + * @return mixed + */ + public static function pull(&$array, $key, $default = null) + { + $value = static::get($array, $key, $default); + + static::forget($array, $key); + + return $value; + } + + /** + * Get one or a specified number of random values from an array. + * + * @param array $array + * @param int|null $number + * @return mixed + * + * @throws \InvalidArgumentException + */ + public static function random($array, $number = null) + { + $requested = is_null($number) ? 1 : $number; + + $count = count($array); + + if ($requested > $count) { + throw new InvalidArgumentException( + "You requested {$requested} items, but there are only {$count} items available." + ); + } + + if (is_null($number)) { + return $array[array_rand($array)]; + } + + if ((int) $number === 0) { + return []; + } + + $keys = array_rand($array, $number); + + $results = []; + + foreach ((array) $keys as $key) { + $results[] = $array[$key]; + } + + return $results; + } + + /** + * Set an array item to a given value using "dot" notation. + * + * If no key is given to the method, the entire array will be replaced. + * + * @param array $array + * @param string $key + * @param mixed $value + * @return array + */ + public static function set(&$array, $key, $value) + { + if (is_null($key)) { + return $array = $value; + } + + $keys = explode('.', $key); + + while (count($keys) > 1) { + $key = array_shift($keys); + + // If the key doesn't exist at this depth, we will just create an empty array + // to hold the next value, allowing us to create the arrays to hold final + // values at the correct depth. Then we'll keep digging into the array. + if (!isset($array[$key]) || !is_array($array[$key])) { + $array[$key] = []; + } + + $array = &$array[$key]; + } + + $array[array_shift($keys)] = $value; + + return $array; + } + + /** + * Shuffle the given array and return the result. + * + * @param array $array + * @param int|null $seed + * @return array + */ + public static function shuffle($array, $seed = null) + { + if (is_null($seed)) { + shuffle($array); + } else { + srand($seed); + + usort($array, function () { + return rand(-1, 1); + }); + } + + return $array; + } + + /** + * Sort the array using the given callback or "dot" notation. + * + * @param array $array + * @param callable|string|null $callback + * @return array + */ + public static function sort($array, $callback = null) + { + return Collection::make($array)->sort($callback)->all(); + } + + /** + * Recursively sort an array by keys and values. + * + * @param array $array + * @return array + */ + public static function sortRecursive($array) + { + foreach ($array as &$value) { + if (is_array($value)) { + $value = static::sortRecursive($value); + } + } + + if (static::isAssoc($array)) { + ksort($array); + } else { + sort($array); + } + + return $array; + } + + /** + * Convert the array into a query string. + * + * @param array $array + * @return string + */ + public static function query($array) + { + return http_build_query($array, null, '&', PHP_QUERY_RFC3986); + } + + /** + * Filter the array using the given callback. + * + * @param array $array + * @param callable $callback + * @return array + */ + public static function where($array, callable $callback) + { + return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH); + } + + /** + * If the given value is not an array and not null, wrap it in one. + * + * @param mixed $value + * @return array + */ + public static function wrap($value) + { + if (is_null($value)) { + return []; + } + + return is_array($value) ? $value : [$value]; + } + + /** + * Recursively merge arrays. + * If the value is an associative array, it will be merged recursively. + * If the value is an indexed array, it will be replaced entirely. + * + * @param array ...$arrays + * @return array + */ + public static function mergeDeep(array ...$arrays): array + { + $result = []; + foreach ($arrays as $array) { + foreach ($array as $key => $value) { + if (isset($result[$key]) && is_array($result[$key]) && is_array($value)) { + // 只有当两个数组都是关联数组时才递归合并 + if (self::isAssoc($result[$key]) && self::isAssoc($value)) { + $result[$key] = self::mergeDeep( + $result[$key], + $value + ); + } else { + // 如果任一数组是索引数组,则直接覆盖 + $result[$key] = $value; + } + } else { + $result[$key] = $value; + } + } + } + return $result; + } + + public static function flatMap(callable $fn, array $array): array + { + return array_merge(...array_map($fn, $array)); + } +} diff --git a/vendor/topthink/think-helper/src/helper/Macroable.php b/vendor/topthink/think-helper/src/helper/Macroable.php new file mode 100644 index 0000000..ade5db7 --- /dev/null +++ b/vendor/topthink/think-helper/src/helper/Macroable.php @@ -0,0 +1,66 @@ + +// +---------------------------------------------------------------------- +namespace think\helper; + +use Closure; +use think\exception\FuncNotFoundException; + +trait Macroable +{ + /** + * 方法注入. + * + * @var Closure[] + */ + protected static $macro = []; + + /** + * 设置方法注入. + * + * @param string $method + * @param Closure $closure + * + * @return void + */ + public static function macro(string $method, Closure $closure) + { + static::$macro[$method] = $closure; + } + + /** + * 检查方法是否已经有注入 + * + * @param string $name + * @return bool + */ + public static function hasMacro(string $method) + { + return isset(static::$macro[$method]); + } + + public function __call($method, $args) + { + if (!isset(static::$macro[$method])) { + throw new FuncNotFoundException('method not exists: ' . static::class . '::' . $method . '()', "{static::class}::{$method}"); + } + + return call_user_func_array(static::$macro[$method]->bindTo($this, static::class), $args); + } + + public static function __callStatic($method, $args) + { + if (!isset(static::$macro[$method])) { + throw new FuncNotFoundException('method not exists: ' . static::class . '::' . $method . '()', "{static::class}::{$method}"); + } + + return call_user_func_array(static::$macro[$method]->bindTo(null, static::class), $args); + } +} diff --git a/vendor/topthink/think-helper/src/helper/Str.php b/vendor/topthink/think-helper/src/helper/Str.php new file mode 100644 index 0000000..61b34d8 --- /dev/null +++ b/vendor/topthink/think-helper/src/helper/Str.php @@ -0,0 +1,234 @@ + +// +---------------------------------------------------------------------- +namespace think\helper; + +class Str +{ + + protected static $snakeCache = []; + + protected static $camelCache = []; + + protected static $studlyCache = []; + + /** + * 检查字符串中是否包含某些字符串 + * @param string $haystack + * @param string|array $needles + * @return bool + */ + public static function contains(string $haystack, $needles): bool + { + foreach ((array) $needles as $needle) { + if ('' != $needle && mb_strpos($haystack, $needle) !== false) { + return true; + } + } + + return false; + } + + /** + * 检查字符串是否以某些字符串结尾 + * + * @param string $haystack + * @param string|array $needles + * @return bool + */ + public static function endsWith(string $haystack, $needles): bool + { + foreach ((array) $needles as $needle) { + if ((string) $needle === static::substr($haystack, -static::length($needle))) { + return true; + } + } + + return false; + } + + /** + * 检查字符串是否以某些字符串开头 + * + * @param string $haystack + * @param string|array $needles + * @return bool + */ + public static function startsWith(string $haystack, $needles): bool + { + foreach ((array) $needles as $needle) { + if ('' != $needle && mb_strpos($haystack, $needle) === 0) { + return true; + } + } + + return false; + } + + /** + * 获取指定长度的随机字母数字组合的字符串 + * + * @param int $length + * @param int $type + * @param string $addChars + * @return string + */ + public static function random(int $length = 6, ?int $type = null, string $addChars = ''): string + { + $str = ''; + switch ($type) { + case 0: + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' . $addChars; + break; + case 1: + $chars = str_repeat('0123456789', 3); + break; + case 2: + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . $addChars; + break; + case 3: + $chars = 'abcdefghijklmnopqrstuvwxyz' . $addChars; + break; + case 4: + $chars = "们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在了不和有大这主中人上为来分生对于学下级地个用同行面说种过命度革而多子后自社加小机也经力线本电高量长党得实家定深法表着水理化争现所二起政三好十战无农使性前等反体合斗路图把结第里正新开论之物从当两些还天资事队批点育重其思与间内去因件日利相由压员气业代全组数果期导平各基或月毛然如应形想制心样干都向变关问比展那它最及外没看治提五解系林者米群头意只明四道马认次文通但条较克又公孔领军流入接席位情运器并飞原油放立题质指建区验活众很教决特此常石强极土少已根共直团统式转别造切九你取西持总料连任志观调七么山程百报更见必真保热委手改管处己将修支识病象几先老光专什六型具示复安带每东增则完风回南广劳轮科北打积车计给节做务被整联步类集号列温装即毫知轴研单色坚据速防史拉世设达尔场织历花受求传口断况采精金界品判参层止边清至万确究书" . $addChars; + break; + default: + $chars = 'ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789' . $addChars; + break; + } + if ($length > 10) { + $chars = $type == 1 ? str_repeat($chars, $length) : str_repeat($chars, 5); + } + if ($type != 4) { + $chars = str_shuffle($chars); + $str = substr($chars, 0, $length); + } else { + for ($i = 0; $i < $length; $i++) { + $str .= mb_substr($chars, floor(mt_rand(0, mb_strlen($chars, 'utf-8') - 1)), 1); + } + } + return $str; + } + + /** + * 字符串转小写 + * + * @param string $value + * @return string + */ + public static function lower(string $value): string + { + return mb_strtolower($value, 'UTF-8'); + } + + /** + * 字符串转大写 + * + * @param string $value + * @return string + */ + public static function upper(string $value): string + { + return mb_strtoupper($value, 'UTF-8'); + } + + /** + * 获取字符串的长度 + * + * @param string $value + * @return int + */ + public static function length(string $value): int + { + return mb_strlen($value); + } + + /** + * 截取字符串 + * + * @param string $string + * @param int $start + * @param int|null $length + * @return string + */ + public static function substr(string $string, int $start, ?int $length = null): string + { + return mb_substr($string, $start, $length, 'UTF-8'); + } + + /** + * 驼峰转下划线 + * + * @param string $value + * @param string $delimiter + * @return string + */ + public static function snake(string $value, string $delimiter = '_'): string + { + $key = $value; + + if (isset(static::$snakeCache[$key][$delimiter])) { + return static::$snakeCache[$key][$delimiter]; + } + + if (!ctype_lower($value)) { + $value = preg_replace('/\s+/u', '', ucwords($value)); + + $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1' . $delimiter, $value)); + } + + return static::$snakeCache[$key][$delimiter] = $value; + } + + /** + * 下划线转驼峰(首字母小写) + * + * @param string $value + * @return string + */ + public static function camel(string $value): string + { + if (isset(static::$camelCache[$value])) { + return static::$camelCache[$value]; + } + + return static::$camelCache[$value] = lcfirst(static::studly($value)); + } + + /** + * 下划线转驼峰(首字母大写) + * + * @param string $value + * @return string + */ + public static function studly(string $value): string + { + $key = $value; + + if (isset(static::$studlyCache[$key])) { + return static::$studlyCache[$key]; + } + + $value = ucwords(str_replace(['-', '_'], ' ', $value)); + + return static::$studlyCache[$key] = str_replace(' ', '', $value); + } + + /** + * 转为首字母大写的标题格式 + * + * @param string $value + * @return string + */ + public static function title(string $value): string + { + return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8'); + } +} diff --git a/vendor/topthink/think-helper/tests/ArrTest.php b/vendor/topthink/think-helper/tests/ArrTest.php new file mode 100644 index 0000000..eac9d7c --- /dev/null +++ b/vendor/topthink/think-helper/tests/ArrTest.php @@ -0,0 +1,372 @@ + 'ThinkPHP'], 'price', 100); + $this->assertSame(['name' => 'ThinkPHP', 'price' => 100], $array); + } + + public function testCrossJoin() + { + // Single dimension + $this->assertSame( + [[1, 'a'], [1, 'b'], [1, 'c']], + Arr::crossJoin([1], ['a', 'b', 'c']) + ); + // Square matrix + $this->assertSame( + [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']], + Arr::crossJoin([1, 2], ['a', 'b']) + ); + // Rectangular matrix + $this->assertSame( + [[1, 'a'], [1, 'b'], [1, 'c'], [2, 'a'], [2, 'b'], [2, 'c']], + Arr::crossJoin([1, 2], ['a', 'b', 'c']) + ); + // 3D matrix + $this->assertSame( + [ + [1, 'a', 'I'], [1, 'a', 'II'], [1, 'a', 'III'], + [1, 'b', 'I'], [1, 'b', 'II'], [1, 'b', 'III'], + [2, 'a', 'I'], [2, 'a', 'II'], [2, 'a', 'III'], + [2, 'b', 'I'], [2, 'b', 'II'], [2, 'b', 'III'], + ], + Arr::crossJoin([1, 2], ['a', 'b'], ['I', 'II', 'III']) + ); + // With 1 empty dimension + $this->assertSame([], Arr::crossJoin([], ['a', 'b'], ['I', 'II', 'III'])); + $this->assertSame([], Arr::crossJoin([1, 2], [], ['I', 'II', 'III'])); + $this->assertSame([], Arr::crossJoin([1, 2], ['a', 'b'], [])); + // With empty arrays + $this->assertSame([], Arr::crossJoin([], [], [])); + $this->assertSame([], Arr::crossJoin([], [])); + $this->assertSame([], Arr::crossJoin([])); + // Not really a proper usage, still, test for preserving BC + $this->assertSame([[]], Arr::crossJoin()); + } + + public function testDivide() + { + [$keys, $values] = Arr::divide(['name' => 'ThinkPHP']); + $this->assertSame(['name'], $keys); + $this->assertSame(['ThinkPHP'], $values); + } + + public function testDot() + { + $array = Arr::dot(['foo' => ['bar' => 'baz']]); + $this->assertSame(['foo.bar' => 'baz'], $array); + $array = Arr::dot([]); + $this->assertSame([], $array); + $array = Arr::dot(['foo' => []]); + $this->assertSame(['foo' => []], $array); + $array = Arr::dot(['foo' => ['bar' => []]]); + $this->assertSame(['foo.bar' => []], $array); + } + + public function testExcept() + { + $array = ['name' => 'ThinkPHP', 'price' => 100]; + $array = Arr::except($array, ['price']); + $this->assertSame(['name' => 'ThinkPHP'], $array); + } + + public function testExists() + { + $this->assertTrue(Arr::exists([1], 0)); + $this->assertTrue(Arr::exists([null], 0)); + $this->assertTrue(Arr::exists(['a' => 1], 'a')); + $this->assertTrue(Arr::exists(['a' => null], 'a')); + $this->assertFalse(Arr::exists([1], 1)); + $this->assertFalse(Arr::exists([null], 1)); + $this->assertFalse(Arr::exists(['a' => 1], 0)); + } + + public function testFirst() + { + $array = [100, 200, 300]; + $value = Arr::first($array, function ($value) { + return $value >= 150; + }); + $this->assertSame(200, $value); + $this->assertSame(100, Arr::first($array)); + + $this->assertSame('default', Arr::first([], null, 'default')); + + $this->assertSame('default', Arr::first([], function () { + return false; + }, 'default')); + } + + public function testLast() + { + $array = [100, 200, 300]; + $last = Arr::last($array, function ($value) { + return $value < 250; + }); + $this->assertSame(200, $last); + $last = Arr::last($array, function ($value, $key) { + return $key < 2; + }); + $this->assertSame(200, $last); + $this->assertSame(300, Arr::last($array)); + } + + public function testFlatten() + { + // Flat arrays are unaffected + $array = ['#foo', '#bar', '#baz']; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten(['#foo', '#bar', '#baz'])); + // Nested arrays are flattened with existing flat items + $array = [['#foo', '#bar'], '#baz']; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten($array)); + // Flattened array includes "null" items + $array = [['#foo', null], '#baz', null]; + $this->assertSame(['#foo', null, '#baz', null], Arr::flatten($array)); + // Sets of nested arrays are flattened + $array = [['#foo', '#bar'], ['#baz']]; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten($array)); + // Deeply nested arrays are flattened + $array = [['#foo', ['#bar']], ['#baz']]; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten($array)); + // Nested arrays are flattened alongside arrays + $array = [new Collection(['#foo', '#bar']), ['#baz']]; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten($array)); + // Nested arrays containing plain arrays are flattened + $array = [new Collection(['#foo', ['#bar']]), ['#baz']]; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten($array)); + // Nested arrays containing arrays are flattened + $array = [['#foo', new Collection(['#bar'])], ['#baz']]; + $this->assertSame(['#foo', '#bar', '#baz'], Arr::flatten($array)); + // Nested arrays containing arrays containing arrays are flattened + $array = [['#foo', new Collection(['#bar', ['#zap']])], ['#baz']]; + $this->assertSame(['#foo', '#bar', '#zap', '#baz'], Arr::flatten($array)); + } + + public function testFlattenWithDepth() + { + // No depth flattens recursively + $array = [['#foo', ['#bar', ['#baz']]], '#zap']; + $this->assertSame(['#foo', '#bar', '#baz', '#zap'], Arr::flatten($array)); + // Specifying a depth only flattens to that depth + $array = [['#foo', ['#bar', ['#baz']]], '#zap']; + $this->assertSame(['#foo', ['#bar', ['#baz']], '#zap'], Arr::flatten($array, 1)); + $array = [['#foo', ['#bar', ['#baz']]], '#zap']; + $this->assertSame(['#foo', '#bar', ['#baz'], '#zap'], Arr::flatten($array, 2)); + } + + public function testGet() + { + $array = ['products.item' => ['price' => 100]]; + $this->assertSame(['price' => 100], Arr::get($array, 'products.item')); + $array = ['products' => ['item' => ['price' => 100]]]; + $value = Arr::get($array, 'products.item'); + $this->assertSame(['price' => 100], $value); + // Test null array values + $array = ['foo' => null, 'bar' => ['baz' => null]]; + $this->assertNull(Arr::get($array, 'foo', 'default')); + $this->assertNull(Arr::get($array, 'bar.baz', 'default')); + // Test null key returns the whole array + $array = ['foo', 'bar']; + $this->assertSame($array, Arr::get($array, null)); + // Test $array is empty and key is null + $this->assertSame([], Arr::get([], null)); + $this->assertSame([], Arr::get([], null, 'default')); + } + + public function testHas() + { + $array = ['products.item' => ['price' => 100]]; + $this->assertTrue(Arr::has($array, 'products.item')); + $array = ['products' => ['item' => ['price' => 100]]]; + $this->assertTrue(Arr::has($array, 'products.item')); + $this->assertTrue(Arr::has($array, 'products.item.price')); + $this->assertFalse(Arr::has($array, 'products.foo')); + $this->assertFalse(Arr::has($array, 'products.item.foo')); + $array = ['foo' => null, 'bar' => ['baz' => null]]; + $this->assertTrue(Arr::has($array, 'foo')); + $this->assertTrue(Arr::has($array, 'bar.baz')); + $array = ['foo', 'bar']; + $this->assertFalse(Arr::has($array, null)); + $this->assertFalse(Arr::has([], null)); + $array = ['products' => ['item' => ['price' => 100]]]; + $this->assertTrue(Arr::has($array, ['products.item'])); + $this->assertTrue(Arr::has($array, ['products.item', 'products.item.price'])); + $this->assertTrue(Arr::has($array, ['products', 'products'])); + $this->assertFalse(Arr::has($array, ['foo'])); + $this->assertFalse(Arr::has($array, [])); + $this->assertFalse(Arr::has($array, ['products.item', 'products.price'])); + $this->assertFalse(Arr::has([], [null])); + } + + public function testIsAssoc() + { + $this->assertTrue(Arr::isAssoc(['a' => 'a', 0 => 'b'])); + $this->assertTrue(Arr::isAssoc([1 => 'a', 0 => 'b'])); + $this->assertTrue(Arr::isAssoc([1 => 'a', 2 => 'b'])); + $this->assertFalse(Arr::isAssoc([0 => 'a', 1 => 'b'])); + $this->assertFalse(Arr::isAssoc(['a', 'b'])); + } + + public function testOnly() + { + $array = ['name' => 'ThinkPHP', 'price' => 100, 'orders' => 10]; + $array = Arr::only($array, ['name', 'price']); + $this->assertSame(['name' => 'ThinkPHP', 'price' => 100], $array); + } + + public function testPrepend() + { + $array = Arr::prepend(['one', 'two', 'three', 'four'], 'zero'); + $this->assertSame(['zero', 'one', 'two', 'three', 'four'], $array); + $array = Arr::prepend(['one' => 1, 'two' => 2], 0, 'zero'); + $this->assertSame(['zero' => 0, 'one' => 1, 'two' => 2], $array); + } + + public function testPull() + { + $array = ['name' => 'ThinkPHP', 'price' => 100]; + $name = Arr::pull($array, 'name'); + $this->assertSame('ThinkPHP', $name); + $this->assertSame(['price' => 100], $array); + // Only works on first level keys + $array = ['i@example.com' => 'Joe', 'jack@localhost' => 'Jane']; + $name = Arr::pull($array, 'i@example.com'); + $this->assertSame('Joe', $name); + $this->assertSame(['jack@localhost' => 'Jane'], $array); + // Does not work for nested keys + $array = ['emails' => ['i@example.com' => 'Joe', 'jack@localhost' => 'Jane']]; + $name = Arr::pull($array, 'emails.i@example.com'); + $this->assertNull($name); + $this->assertSame(['emails' => ['i@example.com' => 'Joe', 'jack@localhost' => 'Jane']], $array); + } + + public function testRandom() + { + $randomValue = Arr::random(['foo', 'bar', 'baz']); + $this->assertContains($randomValue, ['foo', 'bar', 'baz']); + $randomValues = Arr::random(['foo', 'bar', 'baz'], 1); + $this->assertIsArray($randomValues); + $this->assertCount(1, $randomValues); + $this->assertContains($randomValues[0], ['foo', 'bar', 'baz']); + $randomValues = Arr::random(['foo', 'bar', 'baz'], 2); + $this->assertIsArray($randomValues); + $this->assertCount(2, $randomValues); + $this->assertContains($randomValues[0], ['foo', 'bar', 'baz']); + $this->assertContains($randomValues[1], ['foo', 'bar', 'baz']); + } + + public function testSet() + { + $array = ['products' => ['item' => ['price' => 100]]]; + Arr::set($array, 'products.item.price', 200); + Arr::set($array, 'goods.item.price', 200); + $this->assertSame(['products' => ['item' => ['price' => 200]], 'goods' => ['item' => ['price' => 200]]], $array); + } + + public function testWhere() + { + $array = [100, '200', 300, '400', 500]; + $array = Arr::where($array, function ($value, $key) { + return is_string($value); + }); + $this->assertSame([1 => '200', 3 => '400'], $array); + } + + public function testWhereKey() + { + $array = ['10' => 1, 'foo' => 3, 20 => 2]; + $array = Arr::where($array, function ($value, $key) { + return is_numeric($key); + }); + $this->assertSame(['10' => 1, 20 => 2], $array); + } + + public function testForget() + { + $array = ['products' => ['item' => ['price' => 100]]]; + Arr::forget($array, null); + $this->assertSame(['products' => ['item' => ['price' => 100]]], $array); + $array = ['products' => ['item' => ['price' => 100]]]; + Arr::forget($array, []); + $this->assertSame(['products' => ['item' => ['price' => 100]]], $array); + $array = ['products' => ['item' => ['price' => 100]]]; + Arr::forget($array, 'products.item'); + $this->assertSame(['products' => []], $array); + $array = ['products' => ['item' => ['price' => 100]]]; + Arr::forget($array, 'products.item.price'); + $this->assertSame(['products' => ['item' => []]], $array); + $array = ['products' => ['item' => ['price' => 100]]]; + Arr::forget($array, 'products.final.price'); + $this->assertSame(['products' => ['item' => ['price' => 100]]], $array); + $array = ['shop' => ['cart' => [150 => 0]]]; + Arr::forget($array, 'shop.final.cart'); + $this->assertSame(['shop' => ['cart' => [150 => 0]]], $array); + $array = ['products' => ['item' => ['price' => ['original' => 50, 'taxes' => 60]]]]; + Arr::forget($array, 'products.item.price.taxes'); + $this->assertSame(['products' => ['item' => ['price' => ['original' => 50]]]], $array); + $array = ['products' => ['item' => ['price' => ['original' => 50, 'taxes' => 60]]]]; + Arr::forget($array, 'products.item.final.taxes'); + $this->assertSame(['products' => ['item' => ['price' => ['original' => 50, 'taxes' => 60]]]], $array); + $array = ['products' => ['item' => ['price' => 50], null => 'something']]; + Arr::forget($array, ['products.amount.all', 'products.item.price']); + $this->assertSame(['products' => ['item' => [], null => 'something']], $array); + // Only works on first level keys + $array = ['i@example.com' => 'Joe', 'i@thinkphp.com' => 'Jane']; + Arr::forget($array, 'i@example.com'); + $this->assertSame(['i@thinkphp.com' => 'Jane'], $array); + // Does not work for nested keys + $array = ['emails' => ['i@example.com' => ['name' => 'Joe'], 'jack@localhost' => ['name' => 'Jane']]]; + Arr::forget($array, ['emails.i@example.com', 'emails.jack@localhost']); + $this->assertSame(['emails' => ['i@example.com' => ['name' => 'Joe']]], $array); + } + + public function testWrap() + { + $string = 'a'; + $array = ['a']; + $object = new stdClass(); + $object->value = 'a'; + $this->assertSame(['a'], Arr::wrap($string)); + $this->assertSame($array, Arr::wrap($array)); + $this->assertSame([$object], Arr::wrap($object)); + } + + public function testMergeDeep() + { + $this->assertSame( + [ + 'a' => [ + 'c' => [2], + 'e' => 5, + 'f' => 4, + ], + 'x' => 3, + ], + Arr::mergeDeep( + [ + 'a' => [ + 'c' => [1], + 'e' => 5, + ], + 'x' => 4, + ], + [ + 'a' => [ + 'c' => [2], + 'f' => 4, + ], + 'x' => 3, + ] + ) + ); + } +} diff --git a/vendor/topthink/think-helper/tests/CollectionTest.php b/vendor/topthink/think-helper/tests/CollectionTest.php new file mode 100644 index 0000000..b69c175 --- /dev/null +++ b/vendor/topthink/think-helper/tests/CollectionTest.php @@ -0,0 +1,70 @@ + 'Hello']); + $this->assertSame(['name' => 'Hello', 'id' => 1], $c->merge(['id' => 1])->all()); + } + + public function testFirst() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $this->assertSame('Hello', $c->first()); + } + + public function testLast() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $this->assertSame(25, $c->last()); + } + + public function testToArray() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $this->assertSame(['name' => 'Hello', 'age' => 25], $c->toArray()); + } + + public function testToJson() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $this->assertSame(json_encode(['name' => 'Hello', 'age' => 25]), $c->toJson()); + $this->assertSame(json_encode(['name' => 'Hello', 'age' => 25]), (string) $c); + $this->assertSame(json_encode(['name' => 'Hello', 'age' => 25]), json_encode($c)); + } + + public function testSerialize() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $sc = serialize($c); + $c = unserialize($sc); + + $this->assertSame(['name' => 'Hello', 'age' => 25], $c->all()); + } + + public function testGetIterator() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $this->assertInstanceOf(\ArrayIterator::class, $c->getIterator()); + + $this->assertSame(['name' => 'Hello', 'age' => 25], $c->getIterator()->getArrayCopy()); + } + + public function testCount() + { + $c = new Collection(['name' => 'Hello', 'age' => 25]); + + $this->assertCount(2, $c); + } +} diff --git a/vendor/topthink/think-helper/tests/IsAssocTest.php b/vendor/topthink/think-helper/tests/IsAssocTest.php new file mode 100644 index 0000000..b6afffc --- /dev/null +++ b/vendor/topthink/think-helper/tests/IsAssocTest.php @@ -0,0 +1,48 @@ +assertFalse(Arr::isAssoc([])); + } + + public function testSequentialArray() + { + // 顺序索引数组不是关联数组 + $this->assertFalse(Arr::isAssoc([1, 2, 3])); + $this->assertFalse(Arr::isAssoc(['a', 'b', 'c'])); + $this->assertFalse(Arr::isAssoc([null, false, true])); + } + + public function testNonSequentialArray() + { + // 非顺序索引数组是关联数组 + $this->assertTrue(Arr::isAssoc([1 => 'a', 0 => 'b'])); // 键顺序不是0,1 + $this->assertTrue(Arr::isAssoc([1 => 'a', 2 => 'b'])); // 不是从0开始 + $this->assertTrue(Arr::isAssoc([0 => 'a', 2 => 'b'])); // 不连续 + } + + public function testStringKeys() + { + // 字符串键的数组是关联数组 + $this->assertTrue(Arr::isAssoc(['a' => 1, 'b' => 2])); + // 注意:PHP会将字符串数字键'0'、'1'自动转换为整数键0、1 + // 所以这个实际上是顺序索引数组,不是关联数组 + $this->assertFalse(Arr::isAssoc(['0' => 'a', '1' => 'b'])); + $this->assertTrue(Arr::isAssoc(['a' => 'a', 0 => 'b'])); // 混合键 + } + + public function testMixedKeys() + { + // 混合键类型的数组是关联数组 + $this->assertTrue(Arr::isAssoc([0 => 'a', 'b' => 'b'])); + $this->assertTrue(Arr::isAssoc(['a' => 1, 2 => 'b'])); + } + +} diff --git a/vendor/topthink/think-helper/tests/MergeDeepTest.php b/vendor/topthink/think-helper/tests/MergeDeepTest.php new file mode 100644 index 0000000..e455d45 --- /dev/null +++ b/vendor/topthink/think-helper/tests/MergeDeepTest.php @@ -0,0 +1,69 @@ + ['b' => 2], 'c' => 3]; + $array2 = ['a' => ['b' => 4, 'd' => 5], 'e' => 6]; + + $result = Arr::mergeDeep($array1, $array2); + + $expected = [ + 'a' => ['b' => 4, 'd' => 5], + 'c' => 3, + 'e' => 6 + ]; + + $this->assertEquals($expected, $result); + } + + public function testMergeDeepWithIndexedArrays() + { + // 测试索引数组的覆盖 + $array1 = ['a' => [1, 2, 3], 'b' => 2]; + $array2 = ['a' => [4, 5], 'c' => 3]; + + $result = Arr::mergeDeep($array1, $array2); + + $expected = [ + 'a' => [4, 5], // 索引数组应该被完全覆盖 + 'b' => 2, + 'c' => 3 + ]; + + $this->assertEquals($expected, $result); + } + + public function testMergeDeepWithMixedArrays() + { + // 测试混合数组类型 + $array1 = [ + 'a' => ['b' => 2, 'c' => 3], + 'd' => [1, 2, 3], + 'e' => 4 + ]; + + $array2 = [ + 'a' => ['b' => 5, 'f' => 6], + 'd' => [7, 8], + 'g' => 9 + ]; + + $result = Arr::mergeDeep($array1, $array2); + + $expected = [ + 'a' => ['b' => 5, 'c' => 3, 'f' => 6], // 关联数组递归合并 + 'd' => [7, 8], // 索引数组被覆盖 + 'e' => 4, + 'g' => 9 + ]; + + $this->assertEquals($expected, $result); + } +} diff --git a/vendor/topthink/think-helper/tests/StrTest.php b/vendor/topthink/think-helper/tests/StrTest.php new file mode 100644 index 0000000..813ad4c --- /dev/null +++ b/vendor/topthink/think-helper/tests/StrTest.php @@ -0,0 +1,59 @@ +assertSame('fooBar', Str::camel('FooBar')); + $this->assertSame('fooBar', Str::camel('FooBar')); + $this->assertSame('fooBar', Str::camel('foo_bar')); + $this->assertSame('fooBar', Str::camel('_foo_bar')); + $this->assertSame('fooBar', Str::camel('_foo_bar_')); + } + + public function testStudly() + { + $this->assertSame('FooBar', Str::studly('fooBar')); + $this->assertSame('FooBar', Str::studly('_foo_bar')); + $this->assertSame('FooBar', Str::studly('_foo_bar_')); + $this->assertSame('FooBar', Str::studly('_foo_bar_')); + } + + public function testSnake() + { + $this->assertSame('think_p_h_p_framework', Str::snake('ThinkPHPFramework')); + $this->assertSame('think_php_framework', Str::snake('ThinkPhpFramework')); + $this->assertSame('think php framework', Str::snake('ThinkPhpFramework', ' ')); + $this->assertSame('think_php_framework', Str::snake('Think Php Framework')); + $this->assertSame('think_php_framework', Str::snake('Think Php Framework ')); + // ensure cache keys don't overlap + $this->assertSame('think__php__framework', Str::snake('ThinkPhpFramework', '__')); + $this->assertSame('think_php_framework_', Str::snake('ThinkPhpFramework_', '_')); + $this->assertSame('think_php_framework', Str::snake('think php Framework')); + $this->assertSame('think_php_frame_work', Str::snake('think php FrameWork')); + // prevent breaking changes + $this->assertSame('foo-bar', Str::snake('foo-bar')); + $this->assertSame('foo-_bar', Str::snake('Foo-Bar')); + $this->assertSame('foo__bar', Str::snake('Foo_Bar')); + $this->assertSame('żółtałódka', Str::snake('ŻółtaŁódka')); + } + + public function testTitle() + { + $this->assertSame('Welcome Back', Str::title('welcome back')); + } + + public function testRandom() + { + $this->assertIsString(Str::random(10)); + } + + public function testUpper() + { + $this->assertSame('USERNAME', Str::upper('username')); + $this->assertSame('USERNAME', Str::upper('userNaMe')); + } +} diff --git a/vendor/topthink/think-helper/tests/TestCase.php b/vendor/topthink/think-helper/tests/TestCase.php new file mode 100644 index 0000000..87f6cb3 --- /dev/null +++ b/vendor/topthink/think-helper/tests/TestCase.php @@ -0,0 +1,13 @@ + + */ +class TestCase extends BaseTestCase +{ +} diff --git a/vendor/topthink/think-multi-app/LICENSE b/vendor/topthink/think-multi-app/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/vendor/topthink/think-multi-app/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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/vendor/topthink/think-multi-app/README.md b/vendor/topthink/think-multi-app/README.md new file mode 100644 index 0000000..a746fa7 --- /dev/null +++ b/vendor/topthink/think-multi-app/README.md @@ -0,0 +1,14 @@ +# think-multi-app + +用于ThinkPHP6+的多应用支持 + +## 安装 + +~~~ +composer require topthink/think-multi-app +~~~ + +## 使用 + +用法参考ThinkPHP6完全开发手册[多应用模式](https://www.kancloud.cn/manual/thinkphp6_0/1297876)章节。 + diff --git a/vendor/topthink/think-multi-app/composer.json b/vendor/topthink/think-multi-app/composer.json new file mode 100644 index 0000000..df25420 --- /dev/null +++ b/vendor/topthink/think-multi-app/composer.json @@ -0,0 +1,28 @@ +{ + "name": "topthink/think-multi-app", + "description": "thinkphp multi app support", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=7.1.0", + "topthink/framework": "^6.0|^8.0" + }, + "autoload": { + "psr-4": { + "think\\app\\": "src" + } + }, + "extra": { + "think":{ + "services":[ + "think\\app\\Service" + ] + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/topthink/think-multi-app/src/MultiApp.php b/vendor/topthink/think-multi-app/src/MultiApp.php new file mode 100644 index 0000000..199b331 --- /dev/null +++ b/vendor/topthink/think-multi-app/src/MultiApp.php @@ -0,0 +1,223 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\app; + +use Closure; +use think\App; +use think\exception\HttpException; +use think\Request; +use think\Response; + +/** + * 多应用模式支持 + */ +class MultiApp +{ + + /** @var App */ + protected $app; + + public function __construct(App $app) + { + $this->app = $app; + } + + /** + * 多应用解析 + * @access public + * @param Request $request + * @param Closure $next + * @return Response + */ + public function handle($request, Closure $next) + { + if (!$this->parseMultiApp()) { + return $next($request); + } + + return $this->app->middleware->pipeline('app') + ->send($request) + ->then(function ($request) use ($next) { + return $next($request); + }); + } + + /** + * 获取路由目录 + * @access protected + * @return string + */ + protected function getRoutePath(): string + { + return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR; + } + + /** + * 解析多应用 + * @return bool + */ + protected function parseMultiApp(): bool + { + $scriptName = $this->getScriptName(); + $defaultApp = $this->app->config->get('app.default_app') ?: 'index'; + $appName = $this->app->http->getName(); + + if ($appName || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) { + $appName = $appName ?: $scriptName; + $this->app->http->setBind(); + } else { + // 自动多应用识别 + $this->app->http->setBind(false); + $appName = null; + + $bind = $this->app->config->get('app.domain_bind', []); + + if (!empty($bind)) { + // 获取当前子域名 + $subDomain = $this->app->request->subDomain(); + $domain = $this->app->request->host(true); + + if (isset($bind[$domain])) { + $appName = $bind[$domain]; + $this->app->http->setBind(); + } elseif (isset($bind[$subDomain])) { + $appName = $bind[$subDomain]; + $this->app->http->setBind(); + } elseif (isset($bind['*'])) { + $appName = $bind['*']; + $this->app->http->setBind(); + } + } + + if (!$this->app->http->isBind()) { + $path = $this->app->request->pathinfo(); + $map = $this->app->config->get('app.app_map', []); + $deny = $this->app->config->get('app.deny_app_list', []); + $name = current(explode('/', $path)); + + if (strpos($name, '.')) { + $name = strstr($name, '.', true); + } + + if (isset($map[$name])) { + if ($map[$name] instanceof Closure) { + $result = call_user_func_array($map[$name], [$this->app]); + $appName = $result ?: $name; + } else { + $appName = $map[$name]; + } + } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { + throw new HttpException(404, 'app not exists:' . $name); + } elseif ($name && isset($map['*'])) { + $appName = $map['*']; + } else { + $appName = $name ?: $defaultApp; + $appPath = $this->app->http->getPath() ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR; + + if (!is_dir($appPath)) { + $express = $this->app->config->get('app.app_express', false); + if ($express) { + $this->setApp($defaultApp); + return true; + } else { + return false; + } + } + } + + if ($name) { + $this->app->request->setRoot('/' . $name); + $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); + } + } + } + + $this->setApp($appName ?: $defaultApp); + return true; + } + + /** + * 获取当前运行入口名称 + * @access protected + * @codeCoverageIgnore + * @return string + */ + protected function getScriptName(): string + { + if (isset($_SERVER['SCRIPT_FILENAME'])) { + $file = $_SERVER['SCRIPT_FILENAME']; + } elseif (isset($_SERVER['argv'][0])) { + $file = realpath($_SERVER['argv'][0]); + } + + return isset($file) ? pathinfo($file, PATHINFO_FILENAME) : ''; + } + + /** + * 设置应用 + * @param string $appName + */ + protected function setApp(string $appName): void + { + $this->app->http->name($appName); + + $appPath = $this->app->http->getPath() ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR; + + $this->app->setAppPath($appPath); + // 设置应用命名空间 + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); + + if (is_dir($appPath)) { + $this->app->setRuntimePath($this->app->getRuntimePath() . $appName . DIRECTORY_SEPARATOR); + $this->app->http->setRoutePath($this->getRoutePath()); + + //加载应用 + $this->loadApp($appName, $appPath); + } + } + + /** + * 加载应用文件 + * @param string $appName 应用名 + * @return void + */ + protected function loadApp(string $appName, string $appPath): void + { + if (is_file($appPath . 'common.php')) { + include_once $appPath . 'common.php'; + } + + $files = []; + + $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); + + foreach ($files as $file) { + $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); + } + + if (is_file($appPath . 'event.php')) { + $this->app->loadEvent(include $appPath . 'event.php'); + } + + if (is_file($appPath . 'middleware.php')) { + $this->app->middleware->import(include $appPath . 'middleware.php', 'app'); + } + + if (is_file($appPath . 'provider.php')) { + $this->app->bind(include $appPath . 'provider.php'); + } + // 加载应用语言包 + $this->app->loadLangPack($this->app->lang->defaultLangSet()); + } + +} diff --git a/vendor/topthink/think-multi-app/src/Service.php b/vendor/topthink/think-multi-app/src/Service.php new file mode 100644 index 0000000..cdc90b4 --- /dev/null +++ b/vendor/topthink/think-multi-app/src/Service.php @@ -0,0 +1,32 @@ + +// +---------------------------------------------------------------------- +namespace think\app; + +use think\Service as BaseService; + +class Service extends BaseService +{ + public function boot() + { + $this->app->event->listen('HttpRun', function () { + $this->app->middleware->add(MultiApp::class); + }); + + $this->commands([ + 'build' => command\Build::class, + 'clear' => command\Clear::class, + ]); + + $this->app->bind([ + 'think\route\Url' => Url::class, + ]); + } +} diff --git a/vendor/topthink/think-multi-app/src/Url.php b/vendor/topthink/think-multi-app/src/Url.php new file mode 100644 index 0000000..6adb0a2 --- /dev/null +++ b/vendor/topthink/think-multi-app/src/Url.php @@ -0,0 +1,229 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\app; + +use think\App; +use think\Route; +use think\route\Url as UrlBuild; + +/** + * 路由地址生成 + */ +class Url extends UrlBuild +{ + /** + * 直接解析URL地址 + * @access protected + * @param string $url URL + * @param string|bool $domain Domain + * @return string + */ + protected function parseUrl(string $url, &$domain): string + { + $request = $this->app->request; + + if (0 === strpos($url, '/')) { + // 直接作为路由地址解析 + $url = substr($url, 1); + } elseif (false !== strpos($url, '\\')) { + // 解析到类 + $url = ltrim(str_replace('\\', '/', $url), '/'); + } elseif (0 === strpos($url, '@')) { + // 解析到控制器 + $url = substr($url, 1); + } elseif ('' === $url) { + $url = $request->controller() . '/' . $request->action(); + if (!$this->app->http->isBind()) { + $url = $this->getAppName() . '/' . $url; + } + } else { + // 解析到 应用/控制器/操作 + $controller = $request->controller(); + $path = explode('/', $url); + $action = array_pop($path); + $controller = empty($path) ? $controller : array_pop($path); + $app = empty($path) ? $this->getAppName() : array_pop($path); + $url = $controller . '/' . $action; + $bind = $this->app->config->get('app.domain_bind', []); + + if ($key = array_search($this->app->http->getName(), $bind)) { + isset($bind[$_SERVER['SERVER_NAME']]) && $domain = $_SERVER['SERVER_NAME']; + + $domain = is_bool($domain) ? $key : $domain; + } elseif (!$this->app->http->isBind()) { + $map = $this->app->config->get('app.app_map', []); + if ($key = array_search($app, $map)) { + $url = $key . '/' . $url; + } else { + $url = $app . '/' . $url; + } + } + } + + return $url; + } + + public function build(): string + { + // 解析URL + $url = $this->url; + $suffix = $this->suffix; + $domain = $this->domain; + $request = $this->app->request; + $vars = $this->vars; + + if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { + // [name] 表示使用路由命名标识生成URL + $name = substr($url, 1, $pos - 1); + $url = 'name' . substr($url, $pos + 1); + } + + if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { + $info = parse_url($url); + $url = !empty($info['path']) ? $info['path'] : ''; + + if (isset($info['fragment'])) { + // 解析锚点 + $anchor = $info['fragment']; + + if (false !== strpos($anchor, '?')) { + // 解析参数 + list($anchor, $info['query']) = explode('?', $anchor, 2); + } + + if (false !== strpos($anchor, '@')) { + // 解析域名 + list($anchor, $domain) = explode('@', $anchor, 2); + } + } elseif (strpos($url, '@') && false === strpos($url, '\\')) { + // 解析域名 + list($url, $domain) = explode('@', $url, 2); + } + } + + if ($url) { + $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); + $checkDomain = $domain && is_string($domain) ? $domain : null; + + $rule = $this->route->getName($checkName, $checkDomain); + + if (empty($rule) && isset($info['query'])) { + $rule = $this->route->getName($url, $checkDomain); + // 解析地址里面参数 合并到vars + parse_str($info['query'], $params); + $vars = array_merge($params, $vars); + unset($info['query']); + } + } + + if (!empty($rule) && $match = $this->getRuleUrl($rule, $vars, $domain)) { + // 匹配路由命名标识 + $url = $match[0]; + + if ($domain && !empty($match[1])) { + $domain = $match[1]; + } + + if (!is_null($match[2])) { + $suffix = $match[2]; + } + + if (!$this->app->http->isBind()) { + $app = $this->getAppName(); + $url = $app . '/' . $url; + } + } elseif (!empty($rule) && isset($name)) { + throw new \InvalidArgumentException('route name not exists:' . $name); + } else { + // 检测URL绑定 + $bind = (string) $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); + + if ($bind && 0 === strpos($url, $bind)) { + $url = substr($url, strlen($bind) + 1); + } + + // 路由标识不存在 直接解析 + $url = $this->parseUrl($url, $domain); + + if (isset($info['query'])) { + // 解析地址里面参数 合并到vars + parse_str($info['query'], $params); + $vars = array_merge($params, $vars); + } + } + + // 还原URL分隔符 + $depr = $this->route->config('pathinfo_depr'); + $url = str_replace('/', $depr, $url); + + $file = $request->baseFile(); + if ($file && 0 !== strpos($request->url(), $file)) { + $file = str_replace('\\', '/', dirname($file)); + } + + $url = rtrim($file, '/') . '/' . ltrim($url, '/'); + + // URL后缀 + if ('/' == substr($url, -1) || '' == $url) { + $suffix = ''; + } else { + $suffix = $this->parseSuffix($suffix); + } + + // 锚点 + $anchor = !empty($anchor) ? '#' . $anchor : ''; + + // 参数组装 + if (!empty($vars)) { + // 添加参数 + if ($this->route->config('url_common_param')) { + $vars = http_build_query($vars); + $url .= $suffix . '?' . $vars . $anchor; + } else { + foreach ($vars as $var => $val) { + $val = (string) $val; + if ('' !== $val) { + $url .= $depr . $var . $depr . urlencode($val); + } + } + + $url .= $suffix . $anchor; + } + } else { + $url .= $suffix . $anchor; + } + + // 检测域名 + $domain = $this->parseDomain($url, $domain); + + // URL组装 + return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); + } + + /** + * 获取URL的应用名 + * @access protected + * @return string + */ + protected function getAppName() + { + $app = $this->app->http->getName(); + $map = $this->app->config->get('app.app_map', []); + + if ($key = array_search($app, $map)) { + $app = $key; + } + + return $app; + } +} diff --git a/vendor/topthink/think-multi-app/src/command/Build.php b/vendor/topthink/think-multi-app/src/command/Build.php new file mode 100644 index 0000000..65b2f87 --- /dev/null +++ b/vendor/topthink/think-multi-app/src/command/Build.php @@ -0,0 +1,180 @@ + +// +---------------------------------------------------------------------- + +namespace think\app\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\Output; + +class Build extends Command +{ + /** + * 应用基础目录 + * @var string + */ + protected $basePath; + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('build') + ->addArgument('app', Argument::OPTIONAL, 'app name .') + ->setDescription('Build App Dirs'); + } + + protected function execute(Input $input, Output $output) + { + $this->basePath = $this->app->getBasePath(); + $app = $input->getArgument('app') ?: ''; + + if (is_file($this->basePath . 'build.php')) { + $list = include $this->basePath . 'build.php'; + } else { + $list = [ + '__dir__' => ['controller', 'model', 'view'], + ]; + } + + $this->buildApp($app, $list); + $output->writeln("Successed"); + + } + + /** + * 创建应用 + * @access protected + * @param string $app 应用名 + * @param array $list 目录结构 + * @return void + */ + protected function buildApp(string $app, array $list = []): void + { + if (!is_dir($this->basePath . $app)) { + // 创建应用目录 + mkdir($this->basePath . $app); + } + + $appPath = $this->basePath . ($app ? $app . DIRECTORY_SEPARATOR : ''); + $namespace = 'app' . ($app ? '\\' . $app : ''); + + // 创建配置文件和公共文件 + $this->buildCommon($app); + // 创建模块的默认页面 + $this->buildHello($app, $namespace); + + foreach ($list as $path => $file) { + if ('__dir__' == $path) { + // 生成子目录 + foreach ($file as $dir) { + $this->checkDirBuild($appPath . $dir); + } + } elseif ('__file__' == $path) { + // 生成(空白)文件 + foreach ($file as $name) { + if (!is_file($appPath . $name)) { + file_put_contents($appPath . $name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? 'app->config->get('route.controller_suffix')) { + $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . 'Controller.php'; + $class = $val . 'Controller'; + } + $content = "checkDirBuild(dirname($filename)); + $content = ''; + break; + default: + // 其他文件 + $content = "app->config->get('route.controller_suffix') ? 'Controller' : ''; + $filename = $this->basePath . ($app ? $app . DIRECTORY_SEPARATOR : '') . 'controller' . DIRECTORY_SEPARATOR . 'Index' . $suffix . '.php'; + + if (!is_file($filename)) { + $content = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'controller.stub'); + $content = str_replace(['{%name%}', '{%app%}', '{%layer%}', '{%suffix%}'], [$app, $namespace, 'controller', $suffix], $content); + $this->checkDirBuild(dirname($filename)); + + file_put_contents($filename, $content); + } + } + + /** + * 创建应用的公共文件 + * @access protected + * @param string $app 目录 + * @return void + */ + protected function buildCommon(string $app): void + { + $appPath = $this->basePath . ($app ? $app . DIRECTORY_SEPARATOR : ''); + + if (!is_file($appPath . 'common.php')) { + file_put_contents($appPath . 'common.php', " +// +---------------------------------------------------------------------- +namespace think\app\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Argument; +use think\console\input\Option; +use think\console\Output; + +class Clear extends Command +{ + protected function configure() + { + // 指令配置 + $this->setName('clear') + ->addArgument('app', Argument::OPTIONAL, 'app name .') + ->addOption('cache', 'c', Option::VALUE_NONE, 'clear cache file') + ->addOption('log', 'l', Option::VALUE_NONE, 'clear log file') + ->addOption('dir', 'r', Option::VALUE_NONE, 'clear empty dir') + ->setDescription('Clear runtime file'); + } + + protected function execute(Input $input, Output $output) + { + $app = $input->getArgument('app') ?: ''; + $runtimePath = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : ''); + + if ($input->getOption('cache')) { + $path = $runtimePath . 'cache'; + } elseif ($input->getOption('log')) { + $path = $runtimePath . 'log'; + } else { + $path = $runtimePath; + } + + $rmdir = $input->getOption('dir') ? true : false; + $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir); + + $output->writeln("Clear Successed"); + } + + protected function clear(string $path, bool $rmdir): void + { + $files = is_dir($path) ? scandir($path) : []; + + foreach ($files as $file) { + if ('.' != $file && '..' != $file && is_dir($path . $file)) { + array_map('unlink', glob($path . $file . DIRECTORY_SEPARATOR . '*.*')); + if ($rmdir) { + rmdir($path . $file); + } + } elseif ('.gitignore' != $file && is_file($path . $file)) { + unlink($path . $file); + } + } + } +} diff --git a/vendor/topthink/think-multi-app/src/command/stubs/controller.stub b/vendor/topthink/think-multi-app/src/command/stubs/controller.stub new file mode 100644 index 0000000..263c4c6 --- /dev/null +++ b/vendor/topthink/think-multi-app/src/command/stubs/controller.stub @@ -0,0 +1,12 @@ +=8.0.0", + "ext-json": "*", + "ext-pdo": "*", + "psr/simple-cache": ">=1.0", + "psr/log": ">=1.0", + "topthink/think-helper":"^3.1", + "topthink/think-validate":"^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6|^10" + }, + "autoload": { + "psr-4": { + "think\\": "src" + }, + "files": [ + "src/helper.php", + "stubs/load_stubs.php" + ] + }, + "autoload-dev": { + "psr-4": { + "tests\\": "tests" + } + }, + "suggest": { + "ext-mongodb": "provide mongodb support" + }, + "config": { + "sort-packages": true + } +} diff --git a/vendor/topthink/think-orm/src/DbManager.php b/vendor/topthink/think-orm/src/DbManager.php new file mode 100644 index 0000000..60e7acb --- /dev/null +++ b/vendor/topthink/think-orm/src/DbManager.php @@ -0,0 +1,400 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use Closure; +use InvalidArgumentException; +use Psr\Log\LoggerInterface; +use Psr\SimpleCache\CacheInterface; +use think\db\BaseQuery; +use think\db\ConnectionInterface; +use think\db\Query; +use think\db\Raw; + +/** + * Class DbManager. + * + * @mixin BaseQuery + * @mixin Query + */ +class DbManager +{ + /** + * 数据库连接实例. + * + * @var array + */ + protected $instance = []; + + /** + * 数据库配置. + * + * @var array + */ + protected $config = []; + + /** + * Event对象或者数组. + * + * @var array|object + */ + protected $event; + + /** + * SQL监听. + * + * @var array + */ + protected $listen = []; + + /** + * 查询次数. + * + * @var int + */ + protected $queryTimes = 0; + + /** + * 查询缓存对象 + * + * @var CacheInterface + */ + protected $cache; + + /** + * 查询日志对象 + * + * @var LoggerInterface + */ + protected $log; + + /** + * 架构函数. + */ + public function __construct() + { + $this->modelMaker(); + } + + /** + * 注入模型对象 + * + * @return void + */ + protected function modelMaker() + { + Model::maker(function (Model $model) { + $model->setOption('db', $this); + if (is_object($this->event)) { + $model->setOption('event', $this->event); + } + $isAutoWriteTimestamp = $model->getAutoWriteTimestamp(); + + if (is_null($isAutoWriteTimestamp)) { + // 自动写入时间戳 + $model->isAutoWriteTimestamp($this->getConfig('auto_timestamp', true)); + } + + $dateFormat = $model->getDateFormat(); + + if (is_null($dateFormat)) { + // 设置时间戳格式 + $model->setDateFormat($this->getConfig('datetime_format', 'Y-m-d H:i:s')); + } + }); + } + + /** + * 监听SQL. + * + * @return void + */ + public function triggerSql(): void + { + } + + /** + * 初始化配置参数. + * + * @param array $config 连接配置 + * + * @return void + */ + public function setConfig($config): void + { + $this->config = $config; + } + + /** + * 设置缓存对象 + * + * @param CacheInterface $cache 缓存对象 + * + * @return void + */ + public function setCache(CacheInterface $cache): void + { + $this->cache = $cache; + } + + /** + * 设置日志对象 + * + * @param LoggerInterface|Closure $log 日志对象 + * + * @return void + */ + public function setLog(LoggerInterface | Closure $log): void + { + $this->log = $log; + } + + /** + * 记录SQL日志. + * + * @param string $log SQL日志信息 + * @param string $type 日志类型 + * + * @return void + */ + public function log(string $log, string $type = 'sql') + { + if ($this->log) { + if ($this->log instanceof Closure) { + call_user_func_array($this->log, [$type, $log]); + } else { + $this->log->log($type, $log); + } + } + } + + /** + * 获得查询日志(没有设置日志对象使用). + * + * @deprecated + * @param bool $clear 是否清空 + * @return array + */ + public function getDbLog(bool $clear = false): array + { + return []; + } + + /** + * 获取配置参数. + * + * @param string $name 配置参数 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function getConfig(string $name = '', $default = null) + { + if ('' === $name) { + return $this->config; + } + + return $this->config[$name] ?? $default; + } + + /** + * 创建/切换数据库连接查询. + * + * @param string|array|null $name 连接配置信息 + * @param bool $force 强制重新连接 + * + * @return ConnectionInterface + */ + public function connect(string|array|null $name = null, bool $force = false) + { + return $this->instance($name, $force); + } + + /** + * 创建数据库连接实例. + * + * @param string|array|null $name 连接标识 + * @param bool $force 强制重新连接 + * + * @return ConnectionInterface + */ + protected function instance(string|array|null $name = null, bool $force = false): ConnectionInterface + { + if (empty($name)) { + $name = $this->getConfig('default', 'mysql'); + } + + $key = is_array($name) ? md5(json_encode($name)) : $name; + if ($force || !isset($this->instance[$key])) { + $this->instance[$key] = $this->createConnection($name); + } + + return $this->instance[$key]; + } + + /** + * 获取连接配置. + * + * @param string $name + * + * @return array + */ + protected function getConnectionConfig(string $name): array + { + $connections = $this->getConfig('connections'); + if (!isset($connections[$name])) { + throw new InvalidArgumentException('Undefined db config:' . $name); + } + + return $connections[$name]; + } + + /** + * 创建连接. + * + * @param string|array $config + * + * @return ConnectionInterface + */ + protected function createConnection(string|array $config): ConnectionInterface + { + $config = is_array($config) ? $config : $this->getConnectionConfig($config); + + $type = !empty($config['type']) ? $config['type'] : 'mysql'; + + if (str_contains($type, '\\')) { + $class = $type; + } else { + $class = '\\think\\db\\connector\\' . ucfirst($type); + } + + /** @var ConnectionInterface $connection */ + $connection = new $class($config); + $connection->setDb($this); + + if ($this->cache) { + $connection->setCache($this->cache); + } + + return $connection; + } + + /** + * 使用表达式设置数据. + * + * @param string $value 表达式 + * + * @return Raw + */ + public function raw(string $value, array $bind = []): Raw + { + return new Raw($value, $bind); + } + + /** + * 更新查询次数. + * @deprecated + * @return void + */ + public function updateQueryTimes(): void + { + } + + /** + * 重置查询次数. + * @deprecated + * @return void + */ + public function clearQueryTimes(): void + { + $this->queryTimes = 0; + } + + /** + * 获得查询次数. + * @deprecated + * @return int + */ + public function getQueryTimes(): int + { + return $this->queryTimes; + } + + /** + * 监听SQL执行. + * + * @param callable $callback 回调方法 + * + * @return void + */ + public function listen(callable $callback): void + { + $this->listen[] = $callback; + } + + /** + * 获取监听SQL执行. + * + * @return array + */ + public function getListen(): array + { + return $this->listen; + } + + /** + * 获取所有连接实列. + * + * @return array + */ + public function getInstance(): array + { + return $this->instance; + } + + /** + * 注册回调方法. + * + * @param string $event 事件名 + * @param callable $callback 回调方法 + * + * @return void + */ + public function event(string $event, callable $callback): void + { + $this->event[$event][] = $callback; + } + + /** + * 触发事件. + * + * @param string $event 事件名 + * @param mixed $params 传入参数 + * + * @return mixed + */ + public function trigger(string $event, $params = null) + { + if (isset($this->event[$event])) { + foreach ($this->event[$event] as $callback) { + call_user_func_array($callback, [$params]); + } + } + } + + public function __call($method, $args) + { + return call_user_func_array([$this->connect(), $method], $args); + } +} diff --git a/vendor/topthink/think-orm/src/Entity.php b/vendor/topthink/think-orm/src/Entity.php new file mode 100644 index 0000000..1e1bbfe --- /dev/null +++ b/vendor/topthink/think-orm/src/Entity.php @@ -0,0 +1,327 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use ArrayAccess; +use InvalidArgumentException; +use JsonSerializable; +use ReflectionClass; +use think\contract\Arrayable; +use think\contract\Jsonable; +use think\model\contract\Modelable; +use WeakMap; + +/** + * Class Entity. + * @mixin Model + */ +abstract class Entity implements JsonSerializable, ArrayAccess, Arrayable, Jsonable, Modelable +{ + private static ?WeakMap $weakMap = null; + + /** + * 架构函数. + * + * @param Model $model 模型连接对象 + */ + public function __construct(?Model $model = null) + { + $this->initWeakMap(); + + // 获取实体模型参数 + $options = $this->getOptions(); + + if (is_null($model)) { + $class = !empty($options['modelClass']) ? $options['modelClass'] : str_replace('\\entity\\', '\\model\\', static::class); + $model = new $class(); + $model->entity($this); + } + + self::$weakMap[$this] = [ + 'model' => $model, + ]; + + // 初始化模型 + $this->setOptions($options); + $this->init($options); + } + + protected function initWeakMap() + { + if (!self::$weakMap) { + self::$weakMap = new WeakMap; + } + } + + /** + * 在实体模型中定义 返回相关配置参数. + * + * @return array + */ + protected function getOptions(): array + { + return []; + } + + /** + * 批量设置模型参数 + * @param array $options 值 + * @return void + */ + public function setOptions(array $options): void + { + foreach ($options as $name => $value) { + $this->setOption($name, $value); + } + } + + /** + * 设置模型参数 + * + * @param string $name 参数名 + * @param mixed $value 值 + * + * @return $this + */ + public function setOption(string $name, $value) + { + self::$weakMap[$this][$name] = $value; + return $this; + } + + /** + * 获取模型参数 + * + * @param string $name 参数名 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function getOption(string $name, $default = null) + { + return self::$weakMap[$this][$name] ?? $default; + } + + /** + * 创建新的实例. + * + * @param Model $model 模型连接对象 + */ + public function newInstance(?Model $model) + { + $entity = new static(); + return $entity->setModel($model); + } + + /** + * 初始化模型. + * + * @param array $options 模型参数 + * @return void + */ + protected function init(array $options = []): void {} + + /** + * 获取模型对象实例. + * @return Model + */ + public function model() + { + return self::$weakMap[$this]['model']; + } + + /** + * 设置模型. + * + * @param Model $model 模型对象 + * @return $this + */ + public function setModel(Model $model) + { + self::$weakMap[$this]['model'] = $model; + return $this; + } + + /** + * 获取克隆的模型实例. + * + * @return static + */ + public function clone() + { + $model = new static(); + self::$weakMap[$model] = self::$weakMap[$this]; + return $model; + } + + /** + * 克隆模型实例 + * + * @return void + */ + public function __clone() + { + throw new InvalidArgumentException('use $modelObj->clone() replace clone $modelObj'); + } + + /** + * 序列化模型对象 + * + * @return array + */ + public function __serialize(): array + { + return array_diff_key(self::$weakMap[$this]); + } + + /** + * 反序列化模型对象 + * + * @param array $data + * @return void + */ + public function __unserialize(array $data) + { + $this->initWeakMap(); + + self::$weakMap[$this] = $data; + } + + /** + * 获取属性 支持获取器 + * + * @param string $name 名称 + * + * @return mixed + */ + public function __get(string $name) + { + return $this->model()->get($name); + } + + /** + * 设置数据 支持类型自动转换 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return void + */ + public function __set(string $name, $value): void + { + $this->model()->set($name, $value); + } + + /** + * 检测数据对象的值 + * + * @param string $name 名称 + * + * @return bool + */ + public function __isset(string $name): bool + { + return $this->model()->__isset($name); + } + + /** + * 销毁数据对象的值 + * + * @param string $name 名称 + * + * @return void + */ + public function __unset(string $name): void + { + $this->model()->__unset($name); + } + + public function __toString() + { + return $this->model()->toJson(); + } + + public function __debugInfo() + { + return $this->model()->getData(); + } + + // JsonSerializable + public function jsonSerialize(): array + { + return $this->model()->toArray(); + } + + /** + * 模型数据转数组. + * + * @return array + */ + public function toArray(): array + { + return $this->model()->toArray(); + } + + /** + * 模型数据转Json. + * + * @param int $options json参数 + * @return string + */ + public function toJson(int $options = JSON_UNESCAPED_UNICODE): string + { + return $this->model()->toJson($options); + } + + // ArrayAccess + public function offsetSet(mixed $name, mixed $value): void + { + $this->__set($name, $value); + } + + public function offsetGet(mixed $name): mixed + { + return $this->__get($name); + } + + public function offsetExists(mixed $name): bool + { + return $this->__isset($name); + } + + public function offsetUnset(mixed $name): void + { + $this->__unset($name); + } + + public static function __callStatic($method, $args) + { + $entity = new static(); + if (in_array($method, ['destroy', 'create', 'update', 'saveAll'])) { + // 调用model的静态方法 + $db = $entity->model(); + } else { + // 调用Query类查询方法 + $db = $entity->model()->db(); + } + + return call_user_func_array([$db, $method], $args); + } + + public function __call($method, $args) + { + // 调用Model类方法 + return call_user_func_array([$this->model(), $method], $args); + } +} diff --git a/vendor/topthink/think-orm/src/Model.php b/vendor/topthink/think-orm/src/Model.php new file mode 100644 index 0000000..f6e07ea --- /dev/null +++ b/vendor/topthink/think-orm/src/Model.php @@ -0,0 +1,892 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use ArrayAccess; +use Closure; +use JsonSerializable; +use think\contract\Arrayable; +use think\contract\Jsonable; +use think\db\BaseQuery as Query; +use think\db\Express; +use think\exception\ValidateException; +use think\model\Collection; +use think\model\contract\Modelable; +use think\model\View; +use WeakMap; + +/** + * Class Model. + * @mixin \think\db\Query + * + * @method static void onAfterRead(Model $model) after_read事件定义 + * @method static mixed onBeforeInsert(Model $model) before_insert事件定义 + * @method static void onAfterInsert(Model $model) after_insert事件定义 + * @method static mixed onBeforeUpdate(Model $model) before_update事件定义 + * @method static void onAfterUpdate(Model $model) after_update事件定义 + * @method static mixed onBeforeWrite(Model $model) before_write事件定义 + * @method static void onAfterWrite(Model $model) after_write事件定义 + * @method static mixed onBeforeDelete(Model $model) before_write事件定义 + * @method static void onAfterDelete(Model $model) after_delete事件定义 + * @method static void onBeforeRestore(Model $model) before_restore事件定义 + * @method static void onAfterRestore(Model $model) after_restore事件定义 + */ +abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonable, Modelable +{ + use model\concern\Attribute; + use model\concern\AutoWriteData; + use model\concern\Conversion; + use model\concern\DbConnect; + use model\concern\ModelEvent; + use model\concern\RelationShip; + + private static ?WeakMap $weakMap = null; + + /** + * 服务注入. + * + * @var Closure[] + */ + protected static array $_maker = []; + + /** + * 设置服务注入. + */ + public static function maker(Closure $maker): void + { + static::$_maker[] = $maker; + } + + /** + * 设置容器对象的依赖注入方法.(用于兼容) + * + * @param callable $callable 依赖注入方法 + * + * @return void + */ + public static function setInvoker(callable $callable): void + { + } + + /** + * 调用反射执行模型方法 支持参数绑定. + * + * @param mixed $method + * @param array $vars 参数 + * + * @return mixed + */ + public function invoke($method, array $vars = []) + { + if (is_string($method)) { + $method = [$this, $method]; + } + + $invoker = $this->getOption('invoker'); + if ($invoker) { + return $invoker($method instanceof Closure ? $method : Closure::fromCallable($method), $vars); + } + + return call_user_func_array($method, $vars); + } + + /** + * 架构函数. + * + * @param array|object $data 实体模型数据 + */ + public function __construct(array | object $data = []) + { + // 获取实体模型参数 + $options = $this->getOptions(); + + if (!self::$weakMap) { + self::$weakMap = new WeakMap; + } + + self::$weakMap[$this] = [ + 'get' => [], + 'data' => [], + 'origin' => [], + 'relation' => [], + 'together' => [], + 'allow' => [], + 'withAttr' => [], + 'schema' => $options['schema'] ?? [], + 'updateTime' => $options['updateTime'] ?? 'update_time', + 'createTime' => $options['createTime'] ?? 'create_time', + 'suffix' => $options['suffix'] ?? '', + 'validate' => $options['validate'] ?? $this->parseValidate(), + 'type' => $options['type'] ?? [], + 'readonly' => $options['readonly'] ?? [], + 'disuse' => $options['disuse'] ?? [], + 'hidden' => $options['hidden'] ?? [], + 'visible' => $options['visible'] ?? [], + 'append' => $options['append'] ?? [], + 'mapping' => $options['mapping'] ?? [], + 'strict' => $options['strict'] ?? true, + 'bindAttr' => $options['bindAttr'] ?? [], + 'autoRelation' => $options['autoRelation'] ?? [], + ]; + + // 设置额外参数 + $this->setOptions(array_diff_key($options, self::$weakMap[$this])); + + // 模型初始化 + $this->initialize(); + + // 初始化数据 + $this->initializeData($data); + } + + protected function initialize() + { + if (!empty(static::$_maker)) { + foreach (static::$_maker as $maker) { + call_user_func($maker, $this); + } + } + + // 初始化模型 + $this->init(); + } + + /** + * 初始化模型. + * + * @return void + */ + protected function init() + {} + + /** + * 在实体模型中定义 返回相关配置参数. + * + * @return array + */ + protected function getOptions(): array + { + return []; + } + + /** + * 批量设置模型参数 + * @param array $options 值 + * @return void + */ + public function setOptions(array $options): void + { + foreach ($options as $name => $value) { + $this->setOption($name, $value); + } + } + + /** + * 设置模型参数 + * + * @param string $name 参数名 + * @param mixed $value 值 + * + * @return $this + */ + public function setOption(string $name, $value) + { + self::$weakMap[$this][$name] = $value; + if (property_exists($this, $name)) { + $this->$name = $value; + } + return $this; + } + + /** + * 获取模型参数 + * + * @param string $name 参数名 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function getOption(string $name, $default = null) + { + // 兼容读取3.0版本的属性参数定义 + if (property_exists($this, $name) && isset($this->$name)) { + return $this->$name; + } + return self::$weakMap[$this][$name] ?? $default; + } + + private function setWeakData(string $key, string $name, $value): void + { + self::$weakMap[$this][$key][$name] = $value; + } + + private function getWeakData(string $key, string $name, $default = null) + { + return self::$weakMap[$this][$key][$name] ?? $default; + } + + /** + * 创建新的模型实例. + * + * @param array|object $data + * + * @return Model|Entity + */ + public function newInstance(array | object $data = []) + { + $model = new static($data); + if (!empty($data)) { + $model->exists(true); + } + + if ($this->getEntity()) { + // 存在对应实体模型实例 + return $this->getEntity()->newInstance($model); + } + + return $this->fetchModel($model); + } + + /** + * 获取克隆的模型实例. + * + * @return static + */ + public function clone() + { + $model = new static(); + self::$weakMap[$model] = self::$weakMap[$this]; + return $model; + } + + /** + * 获取实际模型实例. + * + * @param Model $model + * + * @return Modelable + */ + protected function fetchModel(Model $model): Modelable + { + $class = $model->getOption('entityClass', str_replace('\\model\\', '\\entity\\', static::class)); + if (class_exists($class) && is_subclass_of($class, Entity::class)) { + $entity = new $class($model); + $model->entity($entity); + return $entity; + } + return $model; + } + + public function entity(Entity $entity): void + { + $this->setOption('entity', $entity); + } + + public function getEntity(): ?Entity + { + return $this->getOption('entity'); + } + + /** + * 解析对应验证类. + * + * @return string + */ + protected function parseValidate(): string + { + $auto = $this->getOption('autoValidate', false); + $validate = $auto && str_contains(static::class, '\\model\\') ? str_replace('\\model\\', '\\validate\\', static::class) : ''; + return $validate && class_exists($validate) ? $validate : ''; + } + + /** + * 设置验证场景. + * + * @param string|array $scene 场景名或数组 + * @return $this + */ + public function scene(string|array $scene) + { + return $this->setOption('scene', $scene); + } + + /** + * 验证模型数据. + * + * @param array $data 数据 + * @param array $allow 需要验证的字段 + * + * @throws ValidateException + * @return void + */ + protected function validate(array $data, array $allow = []): void + { + $validater = $this->getOption('validate'); + if (!empty($validater)) { + validate($validater) + ->scene($this->getOption('scene') ?: $allow) + ->check($data); + } + } + + /** + * 保存模型实例数据. + * + * @param array|object $data 数据 + * @param mixed $where 更新条件 true为强制新增 + * @param bool $refresh 是否刷新数据 + * @return bool + */ + public function save(array | object $data = [], $where = [], bool $refresh = false): bool + { + if (!empty($data)) { + // 初始化模型数据 + $this->initializeData($data, true); + } + + if (false === $this->trigger('BeforeWrite')) { + return false; + } + + if (true === $where) { + $isUpdate = false; + $where = []; + } elseif (!empty($where)) { + $isUpdate = true; + } else { + $isUpdate = $this->isExists() ? true : false; + } + + if (false === $this->trigger($isUpdate ? 'BeforeUpdate' : 'BeforeInsert')) { + return false; + } + + [$data, $relations, $allow] = $this->validateAndFilterData($isUpdate); + + if (empty($data)) { + // 保存关联数据 + if ($isUpdate && $this->getOption('together')) { + $this->relationSave($relations, $isUpdate); + } + return true; + } + + // 自动写入数据 + $this->autoWriteData($data, $isUpdate, $allow); + + $db = $this->getDbWhere($where); + $result = $db->field($allow) + ->removeOption('data') + ->save($data, !$isUpdate); + + if (!$isUpdate) { + $this->exists(true); + // 写入自增键值 + $key = $db->getAutoInc(); + $val = $db->getLastInsID(); + if ($key && $val) { + $this->setData($key, $val); + } + } elseif ($refresh) { + // 刷新数据 + $this->refresh(); + } + $this->trigger($isUpdate ? 'AfterUpdate' : 'AfterInsert'); + $this->trigger('AfterWrite'); + + // 保存关联数据 + if ($this->getOption('together')) { + $this->relationSave($relations, $isUpdate); + } + + // 重置原始数据 + $this->refreshOrigin(); + return true; + } + + /** + * 验证和过滤数据 + * @param bool $isUpdate 是否更新 + * @return array [$data, $relations, $allow] + */ + protected function validateAndFilterData(bool $isUpdate): array + { + $data = $this->getData(); + $origin = $this->getOrigin(); + $allow = $this->getOption('allow') ?: array_keys($this->getFields()); + $readonly = $this->getOption('readonly'); + $disuse = $this->getOption('disuse'); + $allow = array_diff($allow, $disuse, $isUpdate ? $readonly : []); + $together = $this->getOption('together'); + + // 验证数据 + $this->validate($data, $allow); + + $relations = []; + foreach ($data as $name => &$val) { + if ($val instanceof Modelable || in_array($name, $together)) { + $relations[$name] = $val; + unset($data[$name]); + } elseif ($val instanceof Collection || (!empty($allow) && !in_array($name, $allow))) { + unset($data[$name]); + } elseif ($isUpdate && !$this->isForce() && $this->isNotRequireUpdate($name, $val, $origin)) { + unset($data[$name]); + } else { + $val = $this->setWithAttr($name, $val); + } + } + + return [$data, $relations, $allow]; + } + + /** + * 数据检查. + * @param array $data 数据 + * @param bool $isUpdate 是否更新 + * @return void + */ + protected function checkData(array &$data, bool $isUpdate): void + { + } + + protected function getDbWhere($where = []) + { + $db = $this->db(); + // 检查条件 + if (!empty($where)) { + $db->where($where); + } elseif ($this->getKey()) { + $db->setKey($this->getKey()); + } else { + $db->where($this->getOrigin()); + } + + if ($this->isForce()) { + $db->removeOption('soft_delete'); + } + + return $db; + } + + /** + * 检查字段是否有更新(主键无需更新). + * + * @param string $name 字段 + * @param mixed $val 值 + * @param array $origin 原始数据 + * @return bool + */ + protected function isNotRequireUpdate(string $name, $val, array $origin): bool + { + return (array_key_exists($name, $origin) && $val === $origin[$name]) || $this->getPk() == $name; + } + + /** + * 获取更新数据. + * + * @return array + */ + public function getChangedData(): array + { + $data = $this->getData(); + $origin = $this->getOrigin(); + $change = []; + foreach ($data as $name => $val) { + if (!array_key_exists($name, $origin) || $val !== $origin[$name]) { + $change[$name] = $val; + } + } + return $change; + } + + /** + * 判断数据是否有更新. + * + * @param string $name 字段 + * @return bool + */ + public function isChange(string $name): bool + { + return $this->getData($name) !== $this->getOrigin($name); + } + + /** + * 刷新模型数据. + * + * @return static + */ + public function refresh() + { + if ($this->isExists() && $this->getKey()) { + $data = $this->db()->find($this->getKey())->getData(); + $this->data($data); + } + return $this; + } + + /** + * 保存多个数据到当前数据对象 + * + * @param iterable $dataSet 数据 + * @param bool $replace 是否replace + * + * @return Collection + */ + public static function saveAll(iterable $dataSet, bool $replace = true): Collection + { + $result = []; + $model = new static; + $pk = $model->getPk(); + foreach ($dataSet as $key => $data) { + $model = new static; + if ($replace) { + $exists = true; + foreach ((array) $pk as $field) { + if (is_string($field) && !isset($data[$field])) { + $exists = false; + } + } + } else { + $exists = false; + } + + $model->replace($replace)->exists($exists)->save($data); + $result[$key] = $model->fetchModel($model); + } + return $model->toCollection($result); + } + + /** + * 删除模型数据. + * + * @return bool + */ + public function delete(): bool + { + if ($this->isEmpty() || false === $this->trigger('BeforeDelete')) { + return false; + } + + foreach ($this->getData() as $name => $val) { + if ($val instanceof Model || $val instanceof Collection) { + $relations[$name] = $val; + } + } + + $result = $this->getDbWhere()->delete(); + + $this->trigger('AfterDelete'); + + if ($result && !empty($relations)) { + // 删除关联数据 + $this->relationDelete($relations); + } + + $this->exists(false); + $this->clear(); + return true; + } + + /** + * 写入数据. + * + * @param array|object $data 数据 + * @param array $allowField 允许字段 + * @param bool $replace 使用Replace + * @param string $suffix 数据表后缀 + * @return Modelable + */ + public static function create(array | object $data, array $allowField = [], bool $replace = false, string $suffix = ''): Modelable + { + $model = new static(); + if (!empty($suffix)) { + $model->setSuffix($suffix); + } + $model->allowField($allowField)->replace($replace)->save($data, true); + return $model->fetchModel($model); + } + + /** + * 更新数据. + * + * @param array|object $data 数据 + * @param mixed $where 更新条件 + * @param array $allowField 允许字段 + * @param string $suffix 数据表后缀 + * @param bool $refresh 是否刷新数据 + * @return Modelable + */ + public static function update(array | object $data, $where = [], array $allowField = [], string $suffix = '', bool $refresh = false): Modelable + { + $model = new static(); + if (!empty($suffix)) { + $model->setSuffix($suffix); + } + $model->allowField($allowField)->exists(true)->save($data, $where, $refresh); + return $model->fetchModel($model); + } + + /** + * 删除记录. + * + * @param mixed $data 主键列表 支持闭包查询条件 + * @param bool $force 是否强制删除 + * + * @return bool + */ + public static function destroy($data, bool $force = false): bool + { + $model = new static(); + $db = $model->db(); + + if (is_array($data) && key($data) !== 0) { + $db->where($data); + $data = []; + } elseif ($data instanceof Closure) { + $data($db); + $data = []; + } + + $resultSet = $db->select((array) $data); + + foreach ($resultSet as $result) { + $result->force($force)->delete(); + } + return true; + } + + /** + * 字段值增长 + * + * @param string $field 字段名 + * @param float|int $step 增长值 + * @param int $lazyTime 延迟时间(秒) + * + * @return $this + */ + public function inc(string $field, float|int $step = 1, int $lazyTime = 0) + { + return $this->set($field, new Express('+', $step, $lazyTime)); + } + + /** + * 字段值减少. + * + * @param string $field 字段名 + * @param float|int $step 增长值 + * @param int $lazyTime 延迟时间(秒) + * + * @return $this + */ + public function dec(string $field, float|int $step = 1, int $lazyTime = 0) + { + return $this->set($field, new Express('-', $step, $lazyTime)); + } + + /** + * 查询缓存 数据为空不缓存. + * + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string|array $tag 缓存标签 + * + * @return $this + */ + public function setCache($key = true, $expire = null, $tag = null) + { + return $this->setOption('cache', [$key, $expire, $tag]); + } + + /** + * 允许写入字段. + * + * @param array $allow 允许字段 + * + * @return $this + */ + public function allowField(array $allow) + { + return $this->setOption('allow', $allow); + } + + /** + * 动态设置只读字段. + * + * @param array $fields 只读字段 + * + * @return $this + */ + public function readonly(array $fields) + { + return $this->setOption('readonly', $fields); + } + + /** + * 强制写入或删除 + * + * @param bool $force 强制更新 + * + * @return $this + */ + public function force(bool $force = true) + { + return $this->setOption('force', $force); + } + + /** + * 判断数据是否强制写入或删除. + * + * @return bool + */ + public function isForce(): bool + { + return $this->getOption('force', false); + } + + /** + * 获取属性 支持获取器 + * + * @param string $name 名称 + * + * @return mixed + */ + public function __get(string $name) + { + return $this->get($name); + } + + /** + * 设置数据 支持类型自动转换 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return void + */ + public function __set(string $name, $value): void + { + if ($value instanceof Modelable && $bind = $this->getBindAttr($this->getOption('bindAttr'), $name)) { + // 关联属性绑定 + $this->bindRelationAttr($value, $bind); + } else { + $this->set($name, $value); + } + } + + /** + * 检测数据对象的值 + * + * @param string $name 名称 + * + * @return bool + */ + public function __isset(string $name): bool + { + return !is_null($this->get($name)); + } + + /** + * 销毁数据对象的值 + * + * @param string $name 名称 + * + * @return void + */ + public function __unset(string $name): void + { + $name = $this->getRealFieldName($name); + + $this->setWeakData('data', $name, null); + $this->setWeakData('get', $name, null); + } + + public function __toString() + { + return $this->toJson(); + } + + public function __debugInfo() + { + return [ + 'data' => $this->getOption('data'), + 'origin' => $this->getOption('origin'), + 'schema' => $this->getOption('schema'), + ]; + } + + // JsonSerializable + public function jsonSerialize(): array + { + return $this->toArray(); + } + + /** + * 序列化模型对象 + * + * @return array + */ + public function __serialize(): array + { + $removeKeys = ['invoker', 'db', 'event']; + return array_diff_key(self::$weakMap[$this], array_flip($removeKeys)); + } + + /** + * 反序列化模型对象 + * + * @param array $data + * @return void + */ + public function __unserialize(array $data) + { + if (!self::$weakMap) { + self::$weakMap = new WeakMap; + } + + self::$weakMap[$this] = $data; + // 重新初始化 + $this->initialize(); + } + + /** + * 克隆模型实例 + * + * @return void + */ + public function __clone() + { + throw new InvalidArgumentException('use $modelObj->clone() replace clone $modelObj'); + } + + // ArrayAccess + public function offsetSet(mixed $name, mixed $value): void + { + $this->set($name, $value); + } + + public function offsetGet(mixed $name): mixed + { + return $this->get($name); + } + + public function offsetExists(mixed $name): bool + { + return $this->__isset($name); + } + + public function offsetUnset(mixed $name): void + { + $this->__unset($name); + } +} diff --git a/vendor/topthink/think-orm/src/Paginator.php b/vendor/topthink/think-orm/src/Paginator.php new file mode 100644 index 0000000..a9f7391 --- /dev/null +++ b/vendor/topthink/think-orm/src/Paginator.php @@ -0,0 +1,568 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +use ArrayAccess; +use ArrayIterator; +use Closure; +use Countable; +use DomainException; +use IteratorAggregate; +use JsonSerializable; +use think\paginator\driver\Bootstrap; +use Traversable; + +/** + * 分页基础类. + * + * @mixin Collection + */ +abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable +{ + /** + * 是否简洁模式. + * + * @var bool + */ + protected $simple = false; + + /** + * 数据集. + * + * @var Collection + */ + protected $items; + + /** + * 当前页. + * + * @var int + */ + protected $currentPage; + + /** + * 最后一页. + * + * @var int + */ + protected $lastPage; + + /** + * 数据总数. + * + * @var int|null + */ + protected $total; + + /** + * 每页数量. + * + * @var int + */ + protected $listRows; + + /** + * 是否有下一页. + * + * @var bool + */ + protected $hasMore; + + /** + * 分页配置. + * + * @var array + */ + protected $options = [ + 'var_page' => 'page', + 'path' => '/', + 'query' => [], + 'fragment' => '', + ]; + + /** + * 获取当前页码 + * + * @var Closure + */ + protected static $currentPageResolver; + + /** + * 获取当前路径. + * + * @var Closure + */ + protected static $currentPathResolver; + + /** + * @var Closure + */ + protected static $maker; + + public function __construct($items, int $listRows, int $currentPage = 1, ?int $total = null, bool $simple = false, array $options = []) + { + $this->options = array_merge($this->options, $options); + + $this->options['path'] = '/' != $this->options['path'] ? rtrim($this->options['path'], '/') : $this->options['path']; + + $this->simple = $simple; + $this->listRows = $listRows; + + if (!$items instanceof Collection) { + $items = Collection::make($items); + } + + if ($simple) { + $this->currentPage = $this->setCurrentPage($currentPage); + $this->hasMore = count($items) > ($this->listRows); + $items = $items->slice(0, $this->listRows); + } else { + $this->total = $total; + $this->lastPage = (int) ceil($total / $listRows); + $this->currentPage = $this->setCurrentPage($currentPage); + $this->hasMore = $this->currentPage < $this->lastPage; + } + $this->items = $items; + } + + /** + * @param mixed $items + * @param int $listRows + * @param int $currentPage + * @param int $total + * @param bool $simple + * @param array $options + * + * @return Paginator + */ + public static function make($items, int $listRows, int $currentPage = 1, ?int $total = null, bool $simple = false, array $options = []) + { + if (isset(static::$maker)) { + return call_user_func(static::$maker, $items, $listRows, $currentPage, $total, $simple, $options); + } + + return new Bootstrap($items, $listRows, $currentPage, $total, $simple, $options); + } + + public static function maker(Closure $resolver) + { + static::$maker = $resolver; + } + + protected function setCurrentPage(int $currentPage): int + { + if (!$this->simple && $currentPage > $this->lastPage) { + return $this->lastPage > 0 ? $this->lastPage : 1; + } + + return $currentPage; + } + + /** + * 获取页码对应的链接. + * + * @param int $page + * + * @return string + */ + protected function url(int $page): string + { + if ($page <= 0) { + $page = 1; + } + + if (!str_contains($this->options['path'], '[PAGE]')) { + $parameters = [$this->options['var_page'] => $page]; + $path = $this->options['path']; + } else { + $parameters = []; + $path = str_replace('[PAGE]', (string) $page, $this->options['path']); + } + + if (count($this->options['query']) > 0) { + $parameters = array_merge($this->options['query'], $parameters); + } + + $url = $path; + if (!empty($parameters)) { + $url .= '?' . http_build_query($parameters, '', '&'); + } + + return $url . $this->buildFragment(); + } + + /** + * 自动获取当前页码 + * + * @param string $varPage + * @param int $default + * + * @return int + */ + public static function getCurrentPage(string $varPage = 'page', int $default = 1): int + { + if (isset(static::$currentPageResolver)) { + return call_user_func(static::$currentPageResolver, $varPage); + } + + return $default; + } + + /** + * 设置获取当前页码闭包. + * + * @param Closure $resolver + */ + public static function currentPageResolver(Closure $resolver) + { + static::$currentPageResolver = $resolver; + } + + /** + * 自动获取当前的path. + * + * @param string $default + * + * @return string + */ + public static function getCurrentPath($default = '/'): string + { + if (isset(static::$currentPathResolver)) { + return call_user_func(static::$currentPathResolver); + } + + return $default; + } + + /** + * 设置获取当前路径闭包. + * + * @param Closure $resolver + */ + public static function currentPathResolver(Closure $resolver) + { + static::$currentPathResolver = $resolver; + } + + /** + * 获取数据总条数. + * + * @return int + */ + public function total(): int + { + if ($this->simple) { + throw new DomainException('not support total'); + } + + return $this->total; + } + + /** + * 获取每页数量. + * + * @return int + */ + public function listRows(): int + { + return $this->listRows; + } + + /** + * 获取当前页页码 + * + * @return bool + */ + public function hasMore(): bool + { + return $this->hasMore; + } + + /** + * 获取当前页页码 + * + * @return int + */ + public function currentPage(): int + { + return $this->currentPage; + } + + /** + * 获取最后一页页码 + * + * @return int + */ + public function lastPage(): int + { + if ($this->simple) { + throw new DomainException('not support last'); + } + + return $this->lastPage; + } + + /** + * 数据是否足够分页. + * + * @return bool + */ + public function hasPages(): bool + { + return !(1 == $this->currentPage && !$this->hasMore); + } + + /** + * 创建一组分页链接. + * + * @param int $start + * @param int $end + * + * @return array + */ + public function getUrlRange(int $start, int $end): array + { + $urls = []; + + for ($page = $start; $page <= $end; $page++) { + $urls[$page] = $this->url($page); + } + + return $urls; + } + + /** + * 设置URL锚点. + * + * @param string|null $fragment + * + * @return $this + */ + public function fragment(?string $fragment = null) + { + $this->options['fragment'] = $fragment; + + return $this; + } + + /** + * 添加URL参数. + * + * @param array $append + * + * @return $this + */ + public function appends(array $append) + { + foreach ($append as $k => $v) { + if ($k !== $this->options['var_page']) { + $this->options['query'][$k] = $v; + } + } + + return $this; + } + + /** + * 构造锚点字符串. + * + * @return string + */ + protected function buildFragment(): string + { + return $this->options['fragment'] ? '#' . $this->options['fragment'] : ''; + } + + /** + * 渲染分页html. + * + * @return mixed + */ + abstract public function render(); + + public function items() + { + return $this->items->all(); + } + + /** + * 获取数据集. + * + * @return Collection|\think\model\Collection + */ + public function getCollection() + { + return $this->items; + } + + /** + * 设置数据集. + * + * @param Collection $items + * + * @return $this + */ + public function setCollection(Collection $items) + { + $this->items = $items; + + return $this; + } + + public function isEmpty(): bool + { + return $this->items->isEmpty(); + } + + /** + * 给每个元素执行个回调. + * + * @param callable $callback + * + * @return $this + */ + public function each(callable $callback) + { + foreach ($this->items as $key => $item) { + $result = $callback($item, $key); + + if (false === $result) { + break; + } elseif (!is_object($item)) { + $this->items[$key] = $result; + } + } + + return $this; + } + + /** + * Retrieve an external iterator. + * + * @return Traversable An instance of an object implementing Iterator or + * Traversable + */ + public function getIterator(): Traversable + { + return new ArrayIterator($this->items->all()); + } + + /** + * Whether a offset exists. + * + * @param mixed $offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return $this->items->offsetExists($offset); + } + + /** + * Offset to retrieve. + * + * @param mixed $offset + * + * @return mixed + */ + public function offsetGet(mixed $offset): mixed + { + return $this->items->offsetGet($offset); + } + + /** + * Offset to set. + * + * @param mixed $offset + * @param mixed $value + */ + public function offsetSet(mixed $offset, mixed $value): void + { + $this->items->offsetSet($offset, $value); + } + + /** + * Offset to unset. + * + * @param mixed $offset + * + * @return void + * + * @since 5.0.0 + */ + public function offsetUnset(mixed $offset): void + { + $this->items->offsetUnset($offset); + } + + /** + * 统计数据集条数. + * + * @return int + */ + public function count(): int + { + return $this->items->count(); + } + + public function __toString() + { + return (string) $this->render(); + } + + /** + * 转换为数组. + * + * @return array + */ + public function toArray(): array + { + try { + $total = $this->total(); + } catch (DomainException $e) { + $total = null; + } + + return [ + 'total' => $total, + 'per_page' => $this->listRows(), + 'current_page' => $this->currentPage(), + 'last_page' => $this->lastPage, + 'data' => $this->items->toArray(), + 'has_more' => $this->hasMore, + ]; + } + + /** + * Specify data which should be serialized to JSON. + */ + public function jsonSerialize(): array + { + return $this->toArray(); + } + + public function __call($name, $arguments) + { + $result = call_user_func_array([$this->items, $name], $arguments); + + if ($result instanceof Collection) { + $this->items = $result; + + return $this; + } + + return $result; + } +} diff --git a/vendor/topthink/think-orm/src/db/BaseBuilder.php b/vendor/topthink/think-orm/src/db/BaseBuilder.php new file mode 100644 index 0000000..2796e55 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/BaseBuilder.php @@ -0,0 +1,971 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use BackedEnum; +use Closure; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use UnitEnum; + +/** + * Db Base Builder. + */ +abstract class BaseBuilder +{ + /** + * Connection对象 + * + * @var ConnectionInterface + */ + protected $connection; + + /** + * 查询表达式映射. + * + * @var array + */ + protected $exp = ['NOTLIKE' => 'NOT LIKE', 'NOTIN' => 'NOT IN', 'NOTBETWEEN' => 'NOT BETWEEN', 'NOTEXISTS' => 'NOT EXISTS', 'NOTNULL' => 'NOT NULL', 'NOTBETWEEN TIME' => 'NOT BETWEEN TIME']; + + /** + * 查询表达式解析. + * + * @var array + */ + protected $parser = [ + 'parseCompare' => ['=', '<>', '>', '>=', '<', '<=', '&', '|', '^', '>>', '<<'], + 'parseLike' => ['LIKE', 'NOT LIKE'], + 'parseBetween' => ['NOT BETWEEN', 'BETWEEN'], + 'parseIn' => ['NOT IN', 'IN'], + 'parseExp' => ['EXP'], + 'parseNull' => ['NOT NULL', 'NULL'], + 'parseBetweenTime' => ['BETWEEN TIME', 'NOT BETWEEN TIME'], + 'parseTime' => ['< TIME', '> TIME', '<= TIME', '>= TIME'], + 'parseExists' => ['NOT EXISTS', 'EXISTS'], + 'parseColumn' => ['COLUMN'], + ]; + + /** + * SELECT SQL表达式. + * + * @var string + */ + protected $selectSql = 'SELECT%DISTINCT%%EXTRA% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * INSERT SQL表达式. + * + * @var string + */ + protected $insertSql = '%INSERT%%EXTRA% INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + + /** + * INSERT ALL SQL表达式. + * + * @var string + */ + protected $insertAllSql = '%INSERT%%EXTRA% INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + + /** + * UPDATE SQL表达式. + * + * @var string + */ + protected $updateSql = 'UPDATE%EXTRA% %TABLE% SET %SET%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * DELETE SQL表达式. + * + * @var string + */ + protected $deleteSql = 'DELETE%EXTRA% FROM %TABLE%%USING%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * 架构函数. + * + * @param ConnectionInterface $connection 数据库连接对象实例 + */ + public function __construct(?ConnectionInterface $connection) + { + $this->connection = $connection; + } + + /** + * 获取当前的连接对象实例. + * + * @return ConnectionInterface + */ + public function getConnection(): ConnectionInterface + { + return $this->connection; + } + + /** + * 注册查询表达式解析. + * + * @param string $name 解析方法 + * @param array $parser 匹配表达式数据 + * + * @return $this + */ + public function bindParser(string $name, array $parser) + { + $this->parser[$name] = $parser; + + return $this; + } + + /** + * 数据分析. + * + * @param Query $query 查询对象 + * @param array $data 数据 + * @param array $fields 字段信息 + * @param array $bind 参数绑定 + * + * @return array + */ + abstract protected function parseData(Query $query, array $data = [], array $fields = [], array $bind = []): array; + + /** + * 数据绑定处理. + * + * @param Query $query 查询对象 + * @param string $key 字段名 + * @param mixed $data 数据 + * @param array $bind 绑定数据 + * + * @return string + */ + abstract protected function parseDataBind(Query $query, string $key, $data, array $bind = []): string; + + /** + * 字段名分析. + * + * @param Query $query 查询对象 + * @param mixed $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + abstract public function parseKey(Query $query, string | int | Raw $key, bool $strict = false): string; + + /** + * 查询额外参数分析. + * + * @param Query $query 查询对象 + * @param string $extra 额外参数 + * + * @return string + */ + abstract protected function parseExtra(Query $query, string $extra): string; + + /** + * field分析. + * + * @param Query $query 查询对象 + * @param array $fields 字段名 + * + * @return string + */ + abstract protected function parseField(Query $query, array $fields): string; + + /** + * table分析. + * + * @param Query $query 查询对象 + * @param array|string $tables 表名 + * + * @return string + */ + abstract protected function parseTable(Query $query, array | string $tables): string; + + /** + * where分析. + * + * @param Query $query 查询对象 + * @param array $where 查询条件 + * + * @return string + */ + abstract protected function parseWhere(Query $query, array $where): string; + + /** + * 生成查询条件SQL. + * + * @param Query $query 查询对象 + * @param array $where 查询条件 + * + * @return string + */ + public function buildWhere(Query $query, array $where): string + { + if (empty($where)) { + $where = []; + } + + $whereStr = ''; + + $binds = $query->getFieldsBindType(); + + foreach ($where as $logic => $val) { + $str = $this->parseWhereLogic($query, $logic, $val, $binds); + + $whereStr .= empty($whereStr) ? substr(implode(' ', $str), strlen($logic) + 1) : implode(' ', $str); + } + + return $whereStr; + } + + /** + * 不同字段使用相同查询条件(AND). + * + * @param Query $query 查询对象 + * @param string $logic Logic + * @param array $val 查询条件 + * @param array $binds 参数绑定 + * + * @return array + */ + protected function parseWhereLogic(Query $query, string $logic, array $val, array $binds = []): array + { + $where = []; + foreach ($val as $value) { + if ($value instanceof Raw) { + $where[] = ' ' . $logic . ' ( ' . $this->parseRaw($query, $value) . ' )'; + continue; + } + + if (is_array($value)) { + if (key($value) !== 0) { + throw new Exception('where express error:' . var_export($value, true)); + } + $field = array_shift($value); + } elseif (true === $value) { + $where[] = ' ' . $logic . ' 1 '; + continue; + } elseif (!($value instanceof Closure)) { + throw new Exception('where express error:' . var_export($value, true)); + } + + if ($value instanceof Closure) { + // 使用闭包查询 + $whereClosureStr = $this->parseClosureWhere($query, $value, $logic); + if ($whereClosureStr) { + $where[] = $whereClosureStr; + } + } elseif (is_array($field)) { + $where[] = $this->parseMultiWhereField($query, $value, $field, $logic, $binds); + } elseif ($field instanceof Raw) { + $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); + } elseif (str_contains($field, '|')) { + $where[] = $this->parseFieldsOr($query, $value, $field, $logic, $binds); + } elseif (str_contains($field, '&')) { + $where[] = $this->parseFieldsAnd($query, $value, $field, $logic, $binds); + } else { + // 对字段使用表达式查询 + $field = is_string($field) ? $field : ''; + $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); + } + } + + return $where; + } + + /** + * 不同字段使用相同查询条件(AND). + * + * @param Query $query 查询对象 + * @param mixed $value 查询条件 + * @param string $field 查询字段 + * @param string $logic Logic + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseFieldsAnd(Query $query, $value, string $field, string $logic, array $binds): string + { + $item = []; + + foreach (explode('&', $field) as $k) { + $item[] = $this->parseWhereItem($query, $k, $value, $binds); + } + + return ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )'; + } + + /** + * 不同字段使用相同查询条件(OR). + * + * @param Query $query 查询对象 + * @param array $value 查询条件 + * @param string $field 查询字段 + * @param string $logic Logic + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseFieldsOr(Query $query, array $value, string $field, string $logic, array $binds): string + { + $item = []; + + foreach (explode('|', $field) as $k) { + $item[] = $this->parseWhereItem($query, $k, $value, $binds); + } + + return ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )'; + } + + /** + * 闭包查询. + * + * @param Query $query 查询对象 + * @param Closure $value 查询条件 + * @param string $logic Logic + * + * @return string + */ + protected function parseClosureWhere(Query $query, Closure $value, string $logic): string + { + $newQuery = $query->newQuery(); + $value($newQuery); + $whereClosure = $this->buildWhere($newQuery, $newQuery->getOption('where') ?: []); + + if (!empty($whereClosure)) { + $query->bind($newQuery->getBind(false)); + $where = ' ' . $logic . ' ( ' . $whereClosure . ' )'; + } + + return $where ?? ''; + } + + /** + * 复合条件查询. + * + * @param Query $query 查询对象 + * @param mixed $value 查询条件 + * @param mixed $field 查询字段 + * @param string $logic Logic + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseMultiWhereField(Query $query, array $value, $field, string $logic, array $binds): string + { + array_unshift($value, $field); + + $where = []; + foreach ($value as $item) { + $where[] = $this->parseWhereItem($query, array_shift($item), $item, $binds); + } + + return ' ' . $logic . ' ( ' . implode(' AND ', $where) . ' )'; + } + + /** + * where子单元分析. + * + * @param Query $query 查询对象 + * @param mixed $field 查询字段 + * @param array $val 查询条件 + * @param array $binds 参数绑定 + * + * @return string + */ + abstract protected function parseWhereItem(Query $query, $field, array $val, array $binds = []): string; + + /** + * 模糊查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param array $value + * @param string $field + * @param int $bindType + * @param string $logic + * + * @return string + */ + abstract protected function parseLike(Query $query, string $key, string $exp, $value, $field, int $bindType, string $logic): string; + + /** + * 表达式查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param Raw $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseExp(Query $query, string $key, string $exp, Raw $value, string $field, int $bindType): string + { + // 表达式查询 + return '( ' . $key . ' ' . $this->parseRaw($query, $value) . ' )'; + } + + /** + * 表达式查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param array $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseColumn(Query $query, string $key, $exp, array $value, string $field, int $bindType): string + { + // 字段比较查询 + [$op, $field] = $value; + + if (!in_array(trim($op), ['=', '<>', '>', '>=', '<', '<='])) { + throw new Exception('where express error:' . var_export($value, true)); + } + + return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field, true) . ' )'; + } + + /** + * Null查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + abstract protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string; + + /** + * 范围查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + abstract protected function parseBetween(Query $query, string $key, string $exp, array | string $value, $field, int $bindType): string; + + /** + * Exists查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param Raw|Closure $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseExists(Query $query, string $key, string $exp, Raw | Closure $value, string $field, int $bindType): string + { + // EXISTS 查询 + if ($value instanceof Closure) { + $value = $this->parseClosure($query, $value, false); + } elseif ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } + + return $exp . ' ( ' . $value . ' )'; + } + + /** + * 时间比较查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType); + } + + /** + * 大小比较查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * @param string $param + * + * @return string + */ + protected function parseCompare(Query $query, string $key, string $exp, $value, $field, int $bindType, ?string $param = null): string + { + if (is_array($value)) { + throw new Exception('where express error:' . $exp . var_export($value, true)); + } + + // 比较运算 + if ($value instanceof Closure) { + $value = $this->parseClosure($query, $value); + } elseif ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } elseif ($value instanceof BackedEnum) { + $value = $value->value; + } elseif ($value instanceof UnitEnum) { + $value = $value->name; + } + + if ('=' == $exp && is_null($value)) { + return $key . ' IS NULL'; + } + + if (is_null($param)) { + return $key . ' ' . $exp . ' ' . $value; + } else { + return '( ' . $key . ' ' . $exp . ' ' . $value . ' ) ' . $param; + } + } + + /** + * 时间范围查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseBetweenTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + if (is_string($value)) { + $value = explode(',', $value); + } + + return $key . ' ' . substr($exp, 0, -4) + . $this->parseDateTime($query, $value[0], $field, $bindType) + . ' AND ' + . $this->parseDateTime($query, $value[1], $field, $bindType); + } + + /** + * IN查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + abstract protected function parseIn(Query $query, string $key, string $exp, $value, $field, int $bindType): string; + + /** + * 闭包子查询. + * + * @param Query $query 查询对象 + * @param Closure $call + * @param bool $show + * + * @return string + */ + protected function parseClosure(Query $query, Closure $call, bool $show = true): string + { + $newQuery = $query->newQuery()->removeOption(); + $call($newQuery); + + return $newQuery->buildSql($show); + } + + /** + * 日期时间条件解析. + * + * @param Query $query 查询对象 + * @param mixed $value + * @param string $key + * @param int $bindType + * + * @return string + */ + abstract protected function parseDateTime(Query $query, $value, string $key, int $bindType): string; + + /** + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + abstract protected function parseLimit(Query $query, string $limit): string; + + /** + * join分析. + * + * @param Query $query 查询对象 + * @param array $join + * + * @return string + */ + abstract protected function parseJoin(Query $query, array $join): string; + + /** + * order分析. + * + * @param Query $query 查询对象 + * @param array $order + * + * @return string + */ + abstract protected function parseOrder(Query $query, array $order): string; + + /** + * 分析Raw对象 + * + * @param Query $query 查询对象 + * @param Raw $raw Raw对象 + * + * @return string + */ + abstract protected function parseRaw(Query $query, Raw $raw): string; + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + abstract protected function parseRand(Query $query): string; + + /** + * group分析. + * + * @param Query $query 查询对象 + * @param mixed $group + * + * @return string + */ + abstract protected function parseGroup(Query $query, string | array $group): string; + + /** + * having分析. + * + * @param Query $query 查询对象 + * @param string $having + * + * @return string + */ + abstract protected function parseHaving(Query $query, string $having): string; + + /** + * comment分析. + * + * @param Query $query 查询对象 + * @param string $comment + * + * @return string + */ + protected function parseComment(Query $query, string $comment): string + { + if (str_contains($comment, '*/')) { + $comment = strstr($comment, '*/', true); + } + + return !empty($comment) ? ' /* ' . $comment . ' */' : ''; + } + + /** + * distinct分析. + * + * @param Query $query 查询对象 + * @param mixed $distinct + * + * @return string + */ + abstract protected function parseDistinct(Query $query, bool $distinct): string; + + /** + * union分析. + * + * @param Query $query 查询对象 + * @param array $union + * + * @return string + */ + protected function parseUnion(Query $query, array $union): string + { + if (empty($union)) { + return ''; + } + + $type = $union['type']; + unset($union['type']); + + foreach ($union as $u) { + if ($u instanceof Closure) { + $sql[] = $type . ' ' . $this->parseClosure($query, $u); + } elseif (is_string($u)) { + $sql[] = $type . ' ( ' . $u . ' )'; + } + } + + return ' ' . implode(' ', $sql); + } + + /** + * index分析,可在操作链中指定需要强制使用的索引. + * + * @param Query $query 查询对象 + * @param mixed $index + * + * @return string + */ + abstract protected function parseForce(Query $query, string | array $index): string; + + /** + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * + * @return string + */ + abstract protected function parseLock(Query $query, bool | string $lock = false): string; + + /** + * 生成查询SQL. + * + * @param Query $query 查询对象 + * @param bool $one 是否仅获取一个记录 + * + * @return string + */ + public function select(Query $query, bool $one = false): string + { + $options = $query->getOptions(); + + return str_replace( + ['%TABLE%', '%DISTINCT%', '%EXTRA%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'], + [ + $this->parseTable($query, $options['table']), + $this->parseDistinct($query, $options['distinct']), + $this->parseExtra($query, $options['extra']), + $this->parseField($query, $options['field'] ?? []), + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseGroup($query, $options['group']), + $this->parseHaving($query, $options['having']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $one ? '1' : $options['limit']), + $this->parseUnion($query, $options['union']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + $this->parseForce($query, $options['force']), + ], + $this->selectSql + ); + } + + /** + * 生成Insert SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function insert(Query $query): string + { + $options = $query->getOptions(); + + // 分析并处理数据 + $data = $this->parseData($query, $options['data']); + if (empty($data)) { + return ''; + } + + $fields = array_keys($data); + $values = array_values($data); + + return str_replace( + ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $fields), + implode(' , ', $values), + $this->parseComment($query, $options['comment']), + ], + $this->insertSql + ); + } + + /** + * 生成insertall SQL. + * + * @param Query $query 查询对象 + * @param array $dataSet 数据集 + * + * @return string + */ + public function insertAll(Query $query, array $dataSet): string + { + $options = $query->getOptions(); + + // 获取绑定信息 + $bind = $query->getFieldsBindType(); + + // 获取合法的字段 + if (empty($options['field']) || '*' == $options['field']) { + $allowFields = array_keys($bind); + } else { + $allowFields = $options['field']; + } + + $fields = []; + $values = []; + + foreach ($dataSet as $k => $data) { + $data = $this->parseData($query, $data, $allowFields, $bind); + + $values[] = 'SELECT ' . implode(',', array_values($data)); + + if (!isset($insertFields)) { + $insertFields = array_keys($data); + } + } + + foreach ($insertFields as $field) { + $fields[] = $this->parseKey($query, $field); + } + + return str_replace( + ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $fields), + implode(' UNION ALL ', $values), + $this->parseComment($query, $options['comment']), + ], + $this->insertAllSql + ); + } + + /** + * 生成slect insert SQL. + * + * @param Query $query 查询对象 + * @param array $fields 数据 + * @param string $table 数据表 + * + * @return string + */ + public function selectInsert(Query $query, array $fields, string $table): string + { + foreach ($fields as &$field) { + $field = $this->parseKey($query, $field, true); + } + + return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query); + } + + /** + * 生成update SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function update(Query $query): string + { + $options = $query->getOptions(); + + $data = $this->parseData($query, $options['data']); + + if (empty($data)) { + return ''; + } + + $set = []; + foreach ($data as $key => $val) { + $set[] = $key . ' = ' . $val; + } + + return str_replace( + ['%TABLE%', '%EXTRA%', '%SET%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $set), + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $options['limit']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + ], + $this->updateSql + ); + } + + /** + * 生成delete SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function delete(Query $query): string + { + $options = $query->getOptions(); + + return str_replace( + ['%TABLE%', '%EXTRA%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $options['limit']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + ], + $this->deleteSql + ); + } +} diff --git a/vendor/topthink/think-orm/src/db/BaseQuery.php b/vendor/topthink/think-orm/src/db/BaseQuery.php new file mode 100644 index 0000000..34f65a8 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/BaseQuery.php @@ -0,0 +1,1756 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use Closure; +use Psr\SimpleCache\CacheInterface; +use ReflectionFunction; +use think\Collection; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException as Exception; +use think\db\exception\ModelNotFoundException; +use think\helper\Str; +use think\Model; +use think\Paginator; + +/** + * 数据查询基础类. + */ +abstract class BaseQuery +{ + use concern\TimeFieldQuery; + use concern\AggregateQuery; + use concern\ModelRelationQuery; + use concern\ParamsBind; + use concern\ResultOperation; + use concern\WhereQuery; + + /** + * 当前数据库连接对象 + * + * @var Connection + */ + protected $connection; + + /** + * 当前数据表名称(不含前缀). + * + * @var string + */ + protected $name = ''; + + /** + * 当前数据表主键. + * + * @var string|array + */ + protected $pk; + + /** + * 当前数据表自增主键. + * + * @var string + */ + protected $autoinc; + + /** + * 当前数据表前缀 + * + * @var string + */ + protected $prefix = ''; + + /** + * 当前数据表后缀 + * + * @var string + */ + protected $suffix = ''; + + /** + * 当前查询参数. + * + * @var array + */ + protected $options = []; + + /** + * 架构函数. + * + * @param ConnectionInterface $connection 数据库连接对象 + */ + public function __construct(ConnectionInterface $connection) + { + $this->connection = $connection; + $this->prefix = $this->getConfig('prefix'); + $timeRule = $this->getConfig('time_query_rule'); + if (!empty($timeRule)) { + $this->timeRule($timeRule); + } + } + + /** + * 利用__call方法实现一些特殊的Model方法. + * + * @param string $method 方法名称 + * @param array $args 调用参数 + * + * @throws Exception + * + * @return mixed + */ + public function __call(string $method, array $args) + { + if (strtolower(substr($method, 0, 5)) == 'getby') { + // 根据某个字段获取记录 + $field = Str::snake(substr($method, 5)); + + return $this->where($field, '=', $args[0])->find(); + } + + if (strtolower(substr($method, 0, 10)) == 'getfieldby') { + // 根据某个字段获取记录的某个值 + $name = Str::snake(substr($method, 10)); + + return $this->where($name, '=', $args[0])->value($args[1]); + } + + if (strtolower(substr($method, 0, 7)) == 'whereor') { + $name = Str::snake(substr($method, 7)); + array_unshift($args, $name); + + return call_user_func_array([$this, 'whereOr'], $args); + } + + if (strtolower(substr($method, 0, 5)) == 'where') { + $name = Str::snake(substr($method, 5)); + array_unshift($args, $name); + + return call_user_func_array([$this, 'where'], $args); + } + + if ($this->model && method_exists($this->model, 'scope' . $method)) { + // 动态调用命名范围 + array_unshift($args, $this); + $this->options['scope'][$method] = [[$this->model, 'scope' . $method], $args]; + + return $this; + } + + throw new Exception('method not exist:' . static::class . '->' . $method); + } + + /** + * 创建一个新的查询对象 + * + * @param string|null $class 查询对象类名 + * @return BaseQuery + */ + public function newQuery(?string $class = null): BaseQuery + { + if (null === $class) { + $query = new static($this->connection); + } else { + $query = new $class($this->connection); + } + + if ($this->model) { + $query->model($this->model); + } + + if (isset($this->options['table'])) { + $query->table($this->options['table']); + } else { + $query->name($this->name)->suffix($this->suffix); + } + + if (!empty($this->options['json'])) { + $query->json($this->options['json'], $this->options['json_assoc']); + } + + if (isset($this->options['field_type'])) { + $query->schema($this->options['field_type']); + } + + if (isset($this->options['lazy_fields'])) { + $query->lazyFields($this->options['lazy_fields']); + } + + return $query; + } + + /** + * 获取当前的数据库Connection对象 + * + * @return ConnectionInterface + */ + public function getConnection() + { + return $this->connection; + } + + /** + * 指定当前数据表名(不含前缀). + * + * @param string $name 不含前缀的数据表名字 + * + * @return $this + */ + public function name(string $name) + { + $this->name = $name; + + return $this; + } + + /** + * 指定当前数据表后缀. + * + * @param string $suffix 后缀 + * + * @return $this + */ + public function suffix(string $suffix) + { + $this->suffix = $suffix; + + return $this; + } + + /** + * 获取当前的数据表名称. + * + * @return string + */ + public function getName(): string + { + return $this->name ?: $this->model->getName(); + } + + /** + * 设置主键值. + * + * @param mixed $key 主键值 + * + * @return $this + */ + public function setKey($key) + { + $this->options['key'] = $key; + + return $this; + } + + /** + * 获取主键值. + * @param array $data 数据 + * + * @return mixed + */ + public function getKey(array $data = []) + { + if (!empty($data)) { + $pk = $this->getPk(); + if (is_string($pk) && isset($data[$pk])) { + $id = $data[$pk]; + } else { + $id = null; + } + return $id; + } + + return $this->getOption('key'); + } + + /** + * 获取数据库的配置参数. + * + * @param string $name 参数名称 + * + * @return mixed + */ + public function getConfig(string $name = '') + { + return $this->connection->getConfig($name); + } + + /** + * 得到当前数据表名称. + * @param bool $alias 是否返回数据表别名 + * + * @return string + */ + public function getTable(bool $alias = false) + { + if (isset($this->options['table'])) { + $table = $this->options['table']; + if ($alias && is_string($table) && !empty($this->options['alias'][$table])) { + return $this->options['alias'][$table]; + } + return $table; + } + + return $this->prefix . Str::snake($this->name) . $this->suffix; + } + + /** + * 设置字段类型信息. + * + * @param string $field 字段 + * @param string $type 字段类型 + * + * @return $this + */ + public function setFieldType(string $field, string $type) + { + $this->options['field_type'][$field] = $type; + + return $this; + } + + /** + * 设置字段类型信息. + * + * @param array $schema 字段类型信息 + * + * @return $this + */ + public function schema(array $schema) + { + $this->options['field_type'] = $schema; + + return $this; + } + + /** + * 设置只读字段. + * + * @param array $fields 只读字段 + * + * @return $this + */ + public function readonly(array $fields) + { + $this->options['readonly_fields'] = $fields; + + return $this; + } + + /** + * 获取最近一次查询的sql语句. + * + * @return string + */ + public function getLastSql(): string + { + return $this->connection->getLastSql(); + } + + /** + * 获取返回或者影响的记录数. + * + * @return int + */ + public function getNumRows(): int + { + return $this->connection->getNumRows(); + } + + /** + * 获取最近插入的ID. + * + * @param string|null $sequence 自增序列名 + * + * @return mixed + */ + public function getLastInsID(?string $sequence = null) + { + return $this->connection->getLastInsID($this, $sequence); + } + + /** + * 设置字段映射信息. + * + * @param array $map 字段映射信息 + * + * @return $this + */ + public function fieldMap(array $map) + { + $this->options['field_map'] = $map; + + return $this; + } + + /** + * 获取字段映射名 + * + * @param string $name 字段名 + * + * @return mixed + */ + public function getFieldMap(string $name) + { + $map = $this->getOption('field_map', []); + return $map[$name] ?? null; + } + + /** + * 得到某个字段的值 + * + * @param string $field 字段名 + * @param mixed $default 默认值 + * @param bool $useModelAttr 是否使用模型获取器 + * + * @return mixed + */ + public function value(string $field, $default = null, bool $useModelAttr = false) + { + $result = $this->connection->value($this, $field, $default); + + $array[$field] = $result; + if ($this->model && $useModelAttr) { + // JSON数据处理 + if (!empty($this->options['json'])) { + $this->jsonModelResult($array); + } + return $this->model->newInstance($array)->get($field); + } + + if (!empty($this->options['json'])) { + $this->jsonResult($array); + } + return $array[$field]; + } + + /** + * 得到某个字段的值 并且经过模型的获取器处理 + * + * @param string $field 字段名 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function valueWithAttr(string $field, $default = null) + { + return $this->value($field, $default, true); + } + + /** + * 得到某个列的数组. + * + * @param string|array $field 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * @param bool $useModelAttr 是否使用模型获取器 + * + * @return array + */ + public function column(string | array $field, string $key = '', bool $useModelAttr = false): array + { + $result = $this->connection->column($this, $field, $key); + return array_map(function ($item) use ($field, $useModelAttr) { + if (is_array($item)) { + if ($this->model && $useModelAttr) { + // JSON数据处理 + if (!empty($this->options['json'])) { + $this->jsonModelResult($item); + } + return $this->model->newInstance($item)->toArray(); + } + if (!empty($this->options['json'])) { + $this->jsonResult($item); + } + return $item; + } + + if (is_array($field) && 1 === count($field)) { + $field = current($field); + } + + $array[$field] = $item; + if ($this->model && $useModelAttr) { + if (!empty($this->options['json'])) { + $this->jsonModelResult($array); + } + return $this->model->newInstance($array)->get($field); + } + if (!empty($this->options['json'])) { + $this->jsonResult($array); + } + return $array[$field]; + }, $result); + } + + /** + * 得到某个列的数组 并且经过模型的获取器处理. + * + * @param string|array $field 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * + * @return array + */ + public function columnWithAttr(string | array $field, string $key = '') + { + return $this->column($field, $key, true); + } + + /** + * 查询SQL组装 union. + * + * @param string|array|Closure $union UNION + * @param bool $all 是否适用UNION ALL + * + * @return $this + */ + public function union(string | array | Closure $union, bool $all = false) + { + $this->options['union']['type'] = $all ? 'UNION ALL' : 'UNION'; + + if (is_array($union)) { + $this->options['union'] = array_merge($this->options['union'], $union); + } else { + $this->options['union'][] = $union; + } + + return $this; + } + + /** + * 查询SQL组装 union all. + * + * @param mixed $union UNION数据 + * + * @return $this + */ + public function unionAll(string | array | Closure $union) + { + return $this->union($union, true); + } + + /** + * 指定查询字段. + * + * @param string|array|Raw|true $field 字段信息 + * + * @return $this + */ + public function field(string | array | Raw | bool $field) + { + if (empty($field)) { + return $this; + } elseif ($field instanceof Raw) { + $this->options['field'][] = $field; + + return $this; + } + + if (is_string($field)) { + if (preg_match('/[\<\'\"\(]/', $field)) { + return $this->fieldRaw($field); + } + + $field = array_map('trim', explode(',', $field)); + } + + if (true === $field) { + // 获取全部字段 + $fields = $this->getTableFields(); + $field = $fields ?: ['*']; + } + + if (isset($this->options['field'])) { + $field = array_merge((array) $this->options['field'], $field); + } + + $this->options['field'] = array_unique($field, SORT_REGULAR); + + return $this; + } + + /** + * 指定要排除的查询字段. + * + * @param array|string $field 要排除的字段 + * + * @return $this + */ + public function withoutField(array | string $field) + { + if (empty($field)) { + return $this; + } + + if (is_string($field)) { + $field = array_map('trim', explode(',', $field)); + } + + // 字段排除 + $fields = $this->getTableFields(); + $field = $fields ? array_diff($fields, $field) : $field; + + if (isset($this->options['field'])) { + $field = array_merge((array) $this->options['field'], $field); + } + + $this->options['field'] = array_unique($field, SORT_REGULAR); + + return $this; + } + + /** + * 指定其它数据表的查询字段. + * + * @param string|array|true $field 字段信息 + * @param string $tableName 数据表名 + * @param string $prefix 字段前缀 + * @param string $alias 别名前缀 + * + * @return $this + */ + public function tableField(string | array | bool $field, string $tableName, string $prefix = '', string $alias = '') + { + if (empty($field)) { + return $this; + } + + if (is_string($field)) { + $field = array_map('trim', explode(',', $field)); + } + + if (true === $field) { + // 获取全部字段 + $fields = $this->getTableFields($tableName); + $field = $fields ?: ['*']; + } + + // 添加统一的前缀 + $prefix = $prefix ?: $tableName; + foreach ($field as $key => &$val) { + if (strpos($val, '.')) { + continue; + } + + if (is_numeric($key) && $alias) { + $field[$prefix . '.' . $val] = $alias . $val; + unset($field[$key]); + } elseif (is_numeric($key)) { + $val = $prefix . '.' . $val; + } + } + + if (isset($this->options['field'])) { + $field = array_merge((array) $this->options['field'], $field); + } + + $this->options['field'] = array_unique($field, SORT_REGULAR); + + return $this; + } + + /** + * 设置数据. + * + * @param array $data 数据 + * + * @return $this + */ + public function data(array $data) + { + $this->options['data'] = $data; + + return $this; + } + + /** + * 指定查询数量. + * + * @param int $offset 起始位置 + * @param int|null $length 查询数量 + * + * @return $this + */ + public function limit(int $offset, ?int $length = null) + { + $this->options['limit'] = $offset . ($length ? ',' . $length : ''); + + return $this; + } + + /** + * 指定分页. + * + * @param int $page 页数 + * @param int|null $listRows 每页数量 + * + * @return $this + */ + public function page(int $page, ?int $listRows = null) + { + $this->options['page'] = [$page, $listRows]; + + return $this; + } + + /** + * 指定当前操作的数据表. + * + * @param string|array|Raw $table 表名 + * + * @return $this + */ + public function table(string | array | Raw $table) + { + if (is_string($table) && !str_contains($table, ')')) { + $table = $this->tableStr($table); + } elseif (is_array($table)) { + $table = $this->tableArr($table); + } + + $this->options['table'] = $table; + return $this; + } + + /** + * 指定数据表(字符串). + * + * @param string $table 表名 + * + * @return array|string + */ + protected function tableStr(string $table): array | string + { + if (!str_contains($table, ',')) { + // 单表 + if (str_contains($table, ' ')) { + [$item, $alias] = explode(' ', $table); + $table = []; + $this->alias([$item => $alias]); + $table[$item] = $alias; + } + } else { + // 多表 + $tables = explode(',', $table); + $table = []; + + foreach ($tables as $item) { + $item = trim($item); + if (str_contains($item, ' ')) { + [$item, $alias] = explode(' ', $item); + $this->alias([$item => $alias]); + $table[$item] = $alias; + } else { + $table[] = $item; + } + } + } + return $table; + } + + /** + * 指定多个数据表(数组格式). + * + * @param array $tables 表名列表 + * + * @return array + */ + protected function tableArr(array $tables): array + { + $table = []; + foreach ($tables as $key => $val) { + if (is_numeric($key)) { + $table[] = $val; + } else { + $this->alias([$key => $val]); + $table[$key] = $val; + } + } + + return $table; + } + + /** + * 指定排序 order('id','desc') 或者 order(['id'=>'desc','create_time'=>'desc']). + * + * @param string|array|Raw $field 排序字段 + * @param string $order 排序 + * + * @return $this + */ + public function order(string | array | Raw $field, string $order = '') + { + if (empty($field)) { + return $this; + } elseif ($field instanceof Raw) { + $this->options['order'][] = $field; + return $this; + } + + if (is_string($field)) { + $field = $this->parseOrderField($this->getFieldMap($field) ?: $field); + if (is_string($field) && strpos($field, '->')) { + [$alias, $attr] = explode('->', $field, 2); + + $type = $this->getFieldType($alias); + if (is_null($type)) { + $this->hasWhere($alias); + $field = $alias . '.' . $attr; + } + } + + if (str_contains($field, ',')) { + $field = array_map('trim', explode(',', $field)); + } else { + $field = empty($order) ? $field : [$field => $order]; + } + } elseif (!empty($this->options['via'])) { + foreach ($field as $key => $val) { + if (is_numeric($key)) { + $field[$key] = $this->parseOrderField($val); + } else { + $key1 = $this->parseOrderField($key); + if ($key != $key1) { + $field[$key1] = $val; + unset($field[$key]); + } + } + } + } + + if (!isset($this->options['order'])) { + $this->options['order'] = []; + } + + if (is_array($field)) { + $this->options['order'] = array_merge($this->options['order'], $field); + } else { + $this->options['order'][] = $field; + } + + return $this; + } + + protected function parseOrderField(string $field): string + { + if (!empty($this->options['via']) && !str_contains($field, '.') && !str_contains($field, '->')) { + $field = $this->options['via'] . '.' . $field; + } + return $field; + } + /** + * 分页查询. + * + * @param int|array|null $listRows 每页数量 数组表示配置参数 + * @param int|bool $simple 是否简洁模式或者总记录数 + * + * @return Paginator + * + * @throws Exception + */ + public function paginate(int | array | null $listRows = null, int | bool $simple = false): Paginator + { + if (is_int($simple)) { + $total = $simple; + $simple = false; + } + + $defaultConfig = [ + 'query' => [], //url额外参数 + 'fragment' => '', //url锚点 + 'var_page' => 'page', //分页变量 + 'list_rows' => 15, //每页数量 + ]; + + if (is_array($listRows)) { + $config = array_merge($defaultConfig, $listRows); + $listRows = intval($config['list_rows']); + } else { + $config = $defaultConfig; + $listRows = intval($listRows ?: $config['list_rows']); + } + + $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); + $page = max($page, 1); + $config['path'] = $config['path'] ?? Paginator::getCurrentPath(); + + if (!isset($total) && !$simple) { + $options = $this->getOptions(); + + unset($this->options['order'], $this->options['cache'], $this->options['limit'], $this->options['page'], $this->options['field']); + + $bind = $this->bind; + $total = $this->count(); + if ($total > 0) { + $results = $this->options($options)->bind($bind)->page($page, $listRows)->select(); + } else { + if (!empty($this->model)) { + $results = new \think\model\Collection([]); + } else { + $results = new \think\Collection([]); + } + } + } elseif ($simple) { + $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); + $total = null; + } else { + $results = $this->page($page, $listRows)->select(); + } + + $this->removeOption('limit'); + $this->removeOption('page'); + + return Paginator::make($results, $listRows, $page, $total, $simple, $config); + } + + /** + * 根据数字类型字段进行分页查询(大数据). + * + * @param int|array|null $listRows 每页数量或者分页配置 + * @param string|null $key 分页索引键 + * @param string|null $sort 索引键排序 asc|desc + * + * @return Paginator + * + * @throws Exception + */ + public function paginateX(int | array | null $listRows = null, ?string $key = null, ?string $sort = null): Paginator + { + $defaultConfig = [ + 'query' => [], //url额外参数 + 'fragment' => '', //url锚点 + 'var_page' => 'page', //分页变量 + 'list_rows' => 15, //每页数量 + ]; + + $config = is_array($listRows) ? array_merge($defaultConfig, $listRows) : $defaultConfig; + $listRows = is_int($listRows) ? $listRows : (int) $config['list_rows']; + $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); + $page = max($page, 1); + + $config['path'] = $config['path'] ?? Paginator::getCurrentPath(); + + $key = $key ?: $this->getPk(); + $options = $this->getOptions(); + + if (is_null($sort)) { + $order = $options['order'] ?? ''; + if (!empty($order)) { + $sort = $order[$key] ?? 'desc'; + } else { + $this->order($key, 'desc'); + $sort = 'desc'; + } + } else { + $this->order($key, $sort); + } + + $newOption = $options; + unset($newOption['field'], $newOption['page']); + + $data = $this->newQuery() + ->options($newOption) + ->field($key) + ->where(true) + ->order($key, $sort) + ->limit(1) + ->find(); + + $result = $data[$key] ?? 0; + + if (is_numeric($result)) { + $lastId = 'asc' == $sort ? ($result - 1) + ($page - 1) * $listRows : ($result + 1) - ($page - 1) * $listRows; + } else { + throw new Exception('not support type'); + } + + $results = $this->when($lastId, function ($query) use ($key, $sort, $lastId) { + $query->where($key, 'asc' == $sort ? '>' : '<', $lastId); + }) + ->limit($listRows) + ->select(); + + $this->options($options); + + return Paginator::make($results, $listRows, $page, null, true, $config); + } + + /** + * 根据最后ID查询更多N个数据. + * + * @param int $limit 数量 + * @param int|string|null $lastId 最后ID + * @param string|null $key 分页索引键 默认为主键 + * @param string|null $sort 索引键排序 asc|desc + * + * @return array + * + * @throws Exception + */ + public function more(int $limit, int | string | null $lastId = null, ?string $key = null, ?string $sort = null): array + { + $key = $key ?: $this->getPk(); + + if (is_null($sort)) { + $order = $this->getOption('order'); + if (!empty($order)) { + $sort = $order[$key] ?? 'desc'; + } else { + $this->order($key, 'desc'); + $sort = 'desc'; + } + } else { + $this->order($key, $sort); + } + + $result = $this->when($lastId, function ($query) use ($key, $sort, $lastId) { + $query->where($key, 'asc' == $sort ? '>' : '<', $lastId); + })->limit($limit)->select(); + + $last = $result->last(); + + $result->first(); + + return [ + 'data' => $result, + 'lastId' => $last ? $last[$key] : null, + ]; + } + + /** + * 获取当前的缓存对象 + * + * @return CacheInterface|null + */ + public function getCache() + { + return $this->getConnection()->getCache(); + } + + /** + * 查询缓存 数据为空不缓存. + * + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string|array $tag 缓存标签 + * + * @return $this + */ + public function cache($key = true, $expire = null, $tag = null) + { + if (false === $key || !$this->getCache()) { + return $this; + } + + if ($key instanceof \DateTimeInterface || $key instanceof \DateInterval || (is_int($key) && is_null($expire))) { + $expire = $key; + $key = true; + } + + $this->options['cache'] = [$key, $expire, $tag ?: $this->getTable()]; + return $this; + } + + /** + * 查询缓存 允许缓存空数据. + * + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string|array $tag 缓存标签 + * + * @return $this + */ + public function cacheAlways($key = true, $expire = null, $tag = null) + { + $this->options['cache_always'] = true; + return $this->cache($key, $expire, $tag); + } + + /** + * 强制更新缓存 + * + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string|array $tag 缓存标签 + * + * @return $this + */ + public function cacheForce($key = true, $expire = null, $tag = null) + { + $this->options['force_cache'] = true; + + return $this->cache($key, $expire, $tag); + } + + /** + * 指定查询lock. + * + * @param bool|string $lock 是否lock + * + * @return $this + */ + public function lock(bool | string $lock = false) + { + $this->options['lock'] = $lock; + + if ($lock) { + $this->options['master'] = true; + } + + return $this; + } + + /** + * 指定数据表别名. + * + * @param array|string $alias 数据表别名 + * + * @return $this + */ + public function alias(array | string $alias) + { + if (is_array($alias)) { + $this->options['alias'] = $alias; + } else { + $table = $this->getTable(); + + $this->options['alias'][$table] = $alias; + } + + return $this; + } + + /** + * 获取数据表别名. + * + * @param string $table 数据表(留空取当前表) + * + * @return string + */ + public function getAlias(string $table = '') + { + if ('' === $table) { + $table = $this->getTable(); + } + + return $this->options['alias'][$table] ?? ''; + } + + /** + * 设置从主服务器读取数据. + * + * @param bool $readMaster 是否从主服务器读取 + * + * @return $this + */ + public function master(bool $readMaster = true) + { + $this->options['master'] = $readMaster; + + return $this; + } + + /** + * 设置是否严格检查字段名. + * + * @param bool $strict 是否严格检查字段 + * + * @return $this + */ + public function strict(bool $strict = true) + { + $this->options['strict'] = $strict; + + return $this; + } + + /** + * 设置自增序列名. + * + * @param string|null $sequence 自增序列名 + * + * @return $this + */ + public function sequence(?string $sequence = null) + { + $this->options['sequence'] = $sequence; + + return $this; + } + + /** + * 设置JSON字段信息. + * + * @param array $json JSON字段 + * @param bool $assoc 是否取出数组 + * + * @return $this + */ + public function json(array $json = [], bool $assoc = false) + { + $this->options['json'] = $json; + $this->options['json_assoc'] = $assoc; + + return $this; + } + + /** + * 设置延迟写入字段 用于实时获取缓存数据 + * + * @param array $fields 延迟写入字段 + * + * @return $this + */ + public function lazyFields(array $fields) + { + $this->options['lazy_fields'] = $fields; + + return $this; + } + + /** + * 指定数据表主键. + * + * @param string|array|bool|null $pk 主键 + * + * @return $this + */ + public function pk(string | array | bool | null $pk) + { + $this->pk = $pk; + + return $this; + } + + /** + * 查询参数批量赋值 + * + * @param array $options 表达式参数 + * + * @return $this + */ + protected function options(array $options) + { + $this->options = $options; + + return $this; + } + + /** + * 获取所有查询参数. + * + * @return mixed + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * 获取查询参数. + * + * @param string $name 参数名 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function getOption(string $name, $default = null) + { + return $this->options[$name] ?? $default; + } + + /** + * 设置当前的查询参数. + * + * @param string $option 参数名 + * @param mixed $value 参数值 + * + * @return $this + */ + public function setOption(string $option, $value) + { + $this->options[$option] = $value; + + return $this; + } + + /** + * 去除查询参数. + * + * @param string $option 参数名 留空去除所有参数 + * + * @return $this + */ + public function removeOption(string $option = '') + { + if ('' === $option) { + $this->options = []; + $this->bind = []; + } elseif (isset($this->options[$option])) { + unset($this->options[$option]); + } + + return $this; + } + + /** + * 设置当前字段添加的表别名. + * + * @param string $via 临时表别名 + * + * @return $this + */ + public function via(string $via = '') + { + $this->options['via'] = $via; + + return $this; + } + + /** + * 保存记录 自动判断insert或者update. + * + * @param array $data 数据 + * @param bool $forceInsert 是否强制insert + * + * @return int + */ + public function save(array $data = [], bool $forceInsert = false) + { + if ($forceInsert) { + return $this->insert($data); + } + + $this->options['data'] = array_merge($this->options['data'] ?? [], $data); + + if (!empty($this->options['where'])) { + $isUpdate = true; + } else { + $isUpdate = $this->parseUpdateData($this->options['data']); + } + + return $isUpdate ? $this->update() : $this->insert(); + } + + /** + * 插入记录. + * + * @param array $data 数据 + * @param bool $getLastInsID 返回自增主键 + * + * @return int|string + */ + public function insert(array $data = [], bool $getLastInsID = false) + { + if (!empty($data)) { + $this->options['data'] = $data; + } + + return $this->connection->insert($this, $getLastInsID); + } + + /** + * 插入记录并获取自增ID. + * + * @param array $data 数据 + * + * @return int|string + */ + public function insertGetId(array $data) + { + return $this->insert($data, true); + } + + /** + * 批量插入记录. + * + * @param array $dataSet 数据集 + * @param int $limit 每次写入数据限制 + * + * @return int + */ + public function insertAll(array $dataSet = [], int $limit = 0): int + { + if (empty($dataSet)) { + $dataSet = $this->options['data'] ?? []; + } + + if ($limit) { + $this->limit($limit); + } + + return $this->connection->insertAll($this, $dataSet); + } + + /** + * 批量插入记录 + * @access public + * @param array $keys 键值 + * @param array $values 数据 + * @param integer $limit 每次写入数据限制 + * @return integer + */ + public function insertAllByKeys(array $keys, array $values, int $limit = 0): int + { + if ($limit) { + $this->limit($limit); + } + + return $this->connection->insertAllByKeys($this, $keys, $values); + } + + /** + * 通过Select方式插入记录. + * + * @param array $fields 要插入的数据表字段名 + * @param string $table 要插入的数据表名 + * + * @return int + */ + public function selectInsert(array $fields, string $table): int + { + return $this->connection->selectInsert($this, $fields, $table); + } + + /** + * 更新记录. + * + * @param array $data 数据 + * + * @throws Exception + * + * @return int + */ + public function update(array $data = []): int + { + if (!empty($data)) { + $this->options['data'] = array_merge($this->options['data'] ?? [], $data); + } + + if (empty($this->options['where'])) { + $this->parseUpdateData($this->options['data']); + } + + if (empty($this->options['where']) && empty($this->options['scope'])) { + // 如果没有任何更新条件则不执行 + throw new Exception('miss update condition'); + } + + // 检查只读字段 + if (!empty($this->options['readonly_fields'])) { + foreach ($this->options['readonly_fields'] as $field) { + if (array_key_exists($field, $this->options['data'])) { + unset($this->options['data'][$field]); + } + } + } + + return $this->connection->update($this); + } + + /** + * 删除记录. + * + * @param mixed $data 表达式 true 表示强制删除 + * + * @throws Exception + * + * @return int + */ + public function delete($data = null): int + { + if (!is_null($data) && true !== $data) { + // AR模式分析主键条件 + $this->parsePkWhere($data); + } + + if (empty($this->options['where']) && !empty($this->options['key'])) { + if (is_array($this->pk)) { + $this->where($this->options['key']); + } else { + $this->where($this->pk, '=', $this->options['key']); + } + } + + if (true !== $data && empty($this->options['where']) && empty($this->options['scope'])) { + // 如果条件为空 不进行删除操作 除非设置 1=1 + throw new Exception('delete without condition'); + } + + if (!empty($this->options['soft_delete'])) { + // 软删除 + list($field, $condition) = $this->options['soft_delete']; + if ($condition) { + unset($this->options['soft_delete']); + $this->options['data'] = [$field => $condition]; + + return $this->connection->update($this); + } + } + + $this->options['data'] = $data; + + return $this->connection->delete($this); + } + + /** + * 查找记录. + * + * @param array $data 主键数据 + * + * @throws Exception + * @throws ModelNotFoundException + * @throws DataNotFoundException + * + * @return Collection + */ + public function select(array $data = []): Collection + { + if (!empty($data)) { + // 主键条件分析 + $this->parsePkWhere($data); + } + + $resultSet = $this->connection->select($this); + + // 返回结果处理 + if (!empty($this->options['fail']) && count($resultSet) == 0) { + $this->throwNotFound(); + } + + // 数据列表读取后的处理 + if (!empty($this->model)) { + // 生成模型对象 + $resultSet = $this->resultSetToModelCollection($resultSet); + } else { + $this->resultSet($resultSet); + } + + return $resultSet; + } + + /** + * 查找单条记录. + * + * @param mixed $data 主键数据 + * @param ?Closure $closure 闭包数据 + * + * @throws Exception + * @throws ModelNotFoundException + * @throws DataNotFoundException + * + * @return mixed|static + */ + public function find($data = null, ?Closure $closure = null) + { + if ($data instanceof Closure) { + $closure = $data; + } elseif (!is_null($data)) { + // AR模式分析主键条件 + $this->parsePkWhere($data); + } + + if (empty($this->options['where']) && empty($this->options['scope']) && empty($this->options['order']) && empty($this->options['sort'])) { + $result = []; + } else { + $result = $this->connection->find($this); + } + + // 数据处理 + if (empty($result)) { + return $this->resultToEmpty($closure); + } + + if (!empty($this->model)) { + // 返回模型对象 + $this->resultToModel($result); + } else { + $this->result($result); + } + + return $result; + } + + /** + * 分析表达式(可用于查询或者写入操作). + * + * @return array + */ + public function parseOptions(): array + { + // 执行全局查询范围 + $this->scopeQuery(); + + $options = $this->getOptions(); + + // 获取数据表 + if (empty($options['table'])) { + $options['table'] = $this->getTable(); + } + + if (!isset($options['where'])) { + $options['where'] = []; + } elseif (isset($options['view'])) { + // 视图查询条件处理 + $this->parseView($options); + } + + foreach (['data', 'order', 'join', 'union', 'filter', 'json', 'with_attr', 'with_relation_attr'] as $name) { + if (!isset($options[$name])) { + $options[$name] = []; + } + } + + if (!isset($options['strict'])) { + $options['strict'] = $this->getConfig('fields_strict'); + } + + foreach (['master', 'lock', 'fetch_sql', 'array', 'distinct', 'procedure', 'with_cache'] as $name) { + if (!isset($options[$name])) { + $options[$name] = false; + } + } + + foreach (['group', 'having', 'limit', 'force', 'comment', 'partition', 'duplicate', 'extra'] as $name) { + if (!isset($options[$name])) { + $options[$name] = ''; + } + } + + if (isset($options['page'])) { + // 根据页数计算limit + [$page, $listRows] = $options['page']; + + $page = $page > 0 ? $page : 1; + $listRows = $listRows ?: (is_numeric($options['limit']) ? $options['limit'] : 20); + $offset = $listRows * ($page - 1); + + $options['limit'] = $offset . ',' . $listRows; + } + + $this->options = $options; + + return $options; + } + + /** + * 分析数据是否存在更新条件. + * + * @param array $data 数据 + * + * @throws Exception + * + * @return bool + */ + public function parseUpdateData(array &$data): bool + { + $pk = $this->getPk(); + $isUpdate = false; + // 如果存在主键数据 则自动作为更新条件 + if (!empty($this->options['key'])) { + if (is_array($pk)) { + $this->where($this->options['key']); + } else { + $this->where($pk, '=', $this->options['key']); + } + $isUpdate = true; + } elseif (is_string($pk) && isset($data[$pk])) { + $this->where($pk, '=', $data[$pk]); + $this->options['key'] = $data[$pk]; + unset($data[$pk]); + $isUpdate = true; + } elseif (is_array($pk)) { + foreach ($pk as $field) { + if (isset($data[$field])) { + $this->where($field, '=', $data[$field]); + $isUpdate = true; + } else { + // 如果缺少复合主键数据则不执行 + throw new Exception('miss complex primary data'); + } + unset($data[$field]); + } + } + + return $isUpdate; + } + + /** + * 把主键值转换为查询条件 支持复合主键. + * + * @param mixed $data 主键数据 + * + * @throws Exception + * + * @return void + */ + public function parsePkWhere($data): void + { + $pk = $this->getPk(); + + if (!is_string($pk)) { + return; + } + + // 获取数据表 + if (empty($this->options['table'])) { + $this->options['table'] = $this->getTable(); + } + + $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table']; + + if (!empty($this->options['alias'][$table])) { + $alias = $this->options['alias'][$table]; + } + + $key = isset($alias) ? $alias . '.' . $pk : $pk; + // 根据主键查询 + if (is_array($data)) { + $this->where($key, 'in', $data); + } else { + $this->where($key, '=', $data); + $this->options['key'] = $data; + } + } + + /** + * 获取当前的查询标识. + * + * @return string + */ + public function getQueryGuid(): string + { + $data = $this->options; + unset($data['scope'], $data['default_model']); + $data['database'] = $this->getConfig('database'); + $data['table'] = $this->getTable(); + foreach (['AND', 'OR', 'XOR'] as $logic) { + if (isset($data['where'][$logic])) { + foreach ($data['where'][$logic] as $key => $val) { + if ($val instanceof Closure) { + $reflection = new ReflectionFunction($val); + $properties = $reflection->getStaticVariables(); + if (empty($properties)) { + $name = $reflection->getName() . $reflection->getStartLine() . '-' . $reflection->getEndLine(); + } else { + $name = var_export($properties, true); + } + $data['Closure'][] = $name; + unset($data['where'][$logic][$key]); + } + } + } + } + + return md5(serialize(var_export($data, true)) . serialize($this->getBind(false))); + } +} diff --git a/vendor/topthink/think-orm/src/db/Builder.php b/vendor/topthink/think-orm/src/db/Builder.php new file mode 100644 index 0000000..5d467ae --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Builder.php @@ -0,0 +1,839 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use BackedEnum; +use Closure; +use Stringable; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use UnitEnum; + +/** + * Db Builder. + */ +class Builder extends BaseBuilder +{ + + /** + * 数据分析. + * + * @param Query $query 查询对象 + * @param array $data 数据 + * @param array $fields 字段信息 + * @param array $bind 参数绑定 + * + * @return array + */ + protected function parseData(Query $query, array $data = [], array $fields = [], array $bind = []): array + { + if (empty($data)) { + return []; + } + + $options = $query->getOptions(); + + // 获取绑定信息 + if (empty($bind)) { + $bind = $query->getFieldsBindType(); + } + + if (empty($fields)) { + if (empty($options['field']) || '*' == $options['field']) { + $fields = array_keys($bind); + } else { + $fields = $options['field']; + } + } + + $result = []; + + foreach ($data as $key => $val) { + $item = $this->parseKey($query, $key, true); + if ($val instanceof UnitEnum) { + $val = $this->parseEnum($val); + } elseif ($val instanceof Raw) { + $result[$item] = $this->parseRaw($query, $val); + continue; + } elseif (is_null($val) && in_array($key, $fields, true)) { + $result[$item] = 'NULL'; + continue; + } elseif (!is_scalar($val) && (in_array($key, (array) $query->getOption('json')) || 'json' == $query->getFieldType($key))) { + $val = json_encode($val); + } + + if (str_contains($key, '->')) { + [$key, $name] = explode('->', $key, 2); + $item = $this->parseKey($query, $key); + + $result[$item . '->' . $name] = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key . '->' . $name, $val, $bind) . ')'; + } elseif (!str_contains($key, '.') && !in_array($key, $fields, true)) { + if ($options['strict']) { + throw new Exception('fields not exists:[' . $key . ']'); + } + } elseif ($val instanceof Express) { + if ($val->getLazyTime() && in_array($val->getType(), ['+', '-'])) { + $step = $query->lazyWrite($key, $val->getType() == '+' ? 'inc' : 'dec', $val->getStep(), $val->getLazyTime()); + if (false === $step) { + continue; + } + $result[$item] = $item . ' + ' . $step; + } else { + $result[$item] = $item . $this->parseExpress($query, $val); + } + } elseif (is_array($val) && !empty($val) && is_string($val[0])) { + if (in_array(strtoupper($val[0]), ['INC', 'DEC'])) { + $result[$item] = match (strtoupper($val[0])) { + 'INC' => $item . ' + ' . floatval($val[1]), + 'DEC' => $item . ' - ' . floatval($val[1]), + }; + } + } elseif (is_scalar($val)) { + // 过滤非标量数据 + if (!$query->isAutoBind() && Connection::PARAM_STR == $bind[$key]) { + $val = '\'' . $val . '\''; + } + $result[$item] = !$query->isAutoBind() ? $val : $this->parseDataBind($query, $key, $val, $bind); + } + } + + return $result; + } + + /** + * 数据绑定处理. + * + * @param Query $query 查询对象 + * @param string $key 字段名 + * @param mixed $data 数据 + * @param array $bind 绑定数据 + * + * @return string + */ + protected function parseDataBind(Query $query, string $key, $data, array $bind = []): string + { + if ($data instanceof Raw) { + return $this->parseRaw($query, $data); + } + + $name = $query->bindValue($data, $bind[$key] ?? Connection::PARAM_STR); + + return ':' . $name; + } + + /** + * 字段名分析. + * + * @param Query $query 查询对象 + * @param mixed $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + public function parseKey(Query $query, string | int | Raw $key, bool $strict = false): string + { + return $key; + } + + /** + * 查询额外参数分析. + * + * @param Query $query 查询对象 + * @param string $extra 额外参数 + * + * @return string + */ + protected function parseExtra(Query $query, string $extra): string + { + return preg_match('/^[\w]+$/i', $extra) ? ' ' . strtoupper($extra) : ''; + } + + /** + * field分析. + * + * @param Query $query 查询对象 + * @param array $fields 字段名 + * + * @return string + */ + protected function parseField(Query $query, array $fields): string + { + if (empty($fields)) { + return '*'; + } + + // 支持 'field1' => 'field2' 这样的字段别名定义 + $array = array_map(function ($field, $key) use ($query) { + if ($field instanceof Raw) { + return $this->parseRaw($query, $field); + } elseif (!is_numeric($key)) { + // 字段别名定义 + return $this->parseKey($query, $key) . ' AS ' . $this->parseKey($query, $field, true); + } else { + return $this->parseKey($query, $field); + } + }, $fields, array_keys($fields)); + + return implode(',', $array); + } + + /** + * table分析. + * + * @param Query $query 查询对象 + * @param array|string $tables 表名 + * + * @return string + */ + protected function parseTable(Query $query, array | string $tables): string + { + $item = []; + $options = $query->getOptions(); + + foreach ((array) $tables as $key => $table) { + if ($table instanceof Raw) { + $item[] = $this->parseRaw($query, $table); + } elseif (!is_numeric($key)) { + $item[] = $this->parseKey($query, $key) . ' ' . $this->parseKey($query, $table); + } elseif (isset($options['alias'][$table])) { + $item[] = $this->parseKey($query, $table) . ' ' . $this->parseKey($query, $options['alias'][$table]); + } else { + $item[] = $this->parseKey($query, $table); + } + } + + return implode(',', $item); + } + + /** + * where分析. + * + * @param Query $query 查询对象 + * @param array $where 查询条件 + * + * @return string + */ + protected function parseWhere(Query $query, array $where): string + { + $options = $query->getOptions(); + $whereStr = $this->buildWhere($query, $where); + + if (!empty($options['soft_delete'])) { + // 附加软删除条件 + [$field, $condition] = $options['soft_delete']; + + $binds = $query->getFieldsBindType(); + $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; + $whereStr = $whereStr . $this->parseWhereItem($query, $field, $condition, $binds); + } + + return empty($whereStr) ? '' : ' WHERE ' . $whereStr; + } + + /** + * where子单元分析. + * + * @param Query $query 查询对象 + * @param mixed $field 查询字段 + * @param array $val 查询条件 + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseWhereItem(Query $query, $field, array $val, array $binds = []): string + { + // 字段分析 + $key = $field ? $this->parseKey($query, $field, true) : ''; + + [$exp, $value] = $val; + + // 检测操作符 + if (!is_string($exp)) { + throw new Exception('where express error:' . var_export($exp, true)); + } + + $param = $val[2] ?? null; + $exp = strtoupper($exp); + if (isset($this->exp[$exp])) { + $exp = $this->exp[$exp]; + } + + if (is_string($field) && 'LIKE' != $exp) { + $bindType = $binds[$field] ?? Connection::PARAM_STR; + } else { + $bindType = Connection::PARAM_STR; + } + + if ($value instanceof Raw) { + } elseif ($value instanceof Stringable) { + // 对象数据写入 + $value = $value->__toString(); + } elseif ($value instanceof UnitEnum) { + $value = $this->parseEnum($value); + } + + if (is_scalar($value) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && !str_contains($exp, 'TIME')) { + if (is_string($value) && str_starts_with($value, ':') && $query->isBind(substr($value, 1))) { + } else { + $name = $query->bindValue($value, $bindType); + $value = ':' . $name; + } + } + + // 解析查询表达式 + foreach ($this->parser as $fun => $parse) { + if (in_array($exp, $parse)) { + return $this->$fun($query, $key, $exp, $value, $field, $bindType, $param); + } + } + + throw new Exception('where express error:' . $exp); + } + + /** + * 模糊查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param array $value + * @param string $field + * @param int $bindType + * @param string $logic + * + * @return string + */ + protected function parseLike(Query $query, string $key, string $exp, $value, $field, int $bindType, ?string $logic = null): string + { + // 模糊匹配 + $logic = $logic ?: 'AND'; + if (is_array($value)) { + $array = []; + foreach ($value as $item) { + $name = $query->bindValue($item, Connection::PARAM_STR); + $array[] = $key . ' ' . $exp . ' :' . $name; + } + + $whereStr = '(' . implode(' ' . strtoupper($logic) . ' ', $array) . ')'; + } else { + $whereStr = $key . ' ' . $exp . ' ' . $value; + } + + return $whereStr; + } + + /** + * 表达式查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param Raw $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseExp(Query $query, string $key, string $exp, Raw $value, string $field, int $bindType): string + { + // 表达式查询 + return '( ' . $key . ' ' . $this->parseRaw($query, $value) . ' )'; + } + + /** + * Null查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + // NULL 查询 + return $key . ' IS ' . $exp; + } + + /** + * 范围查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseBetween(Query $query, string $key, string $exp, array | string $value, $field, int $bindType): string + { + // BETWEEN 查询 + $data = is_array($value) ? $value : explode(',', $value); + + $min = $query->bindValue($data[0], $bindType); + $max = $query->bindValue($data[1], $bindType); + + return $key . ' ' . $exp . ' :' . $min . ' AND :' . $max . ' '; + } + + /** + * 解析枚举类型值 + * + * @param UnitEnum $value + * + * @return mixed + */ + protected function parseEnum(UnitEnum $value) + { + if ($value instanceof BackedEnum) { + $value = $value->value; + } else { + $value = $value->name; + } + return $value; + } + + /** + * IN查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseIn(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + // IN 查询 + if ($value instanceof Closure) { + $value = $this->parseClosure($query, $value, false); + } elseif ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } else { + // 检查枚举类型 + if (is_subclass_of($value, UnitEnum::class, false)) { + if (is_subclass_of($value, BackedEnum::class, false)) { + $value = array_column($value::cases(), 'value'); + } else { + $value = array_column($value::cases(), 'name'); + } + } else { + $value = is_array($value) ? $value : array_unique(explode(',', (string) $value)); + } + + if (count($value) === 0) { + return 'IN' == $exp ? '0 = 1' : '1 = 1'; + } + + if ($query->isAutoBind()) { + $array = []; + foreach ($value as $v) { + if ($v instanceof UnitEnum) { + $v = $this->parseEnum($v); + } + $name = $query->bindValue($v, $bindType); + $array[] = ':' . $name; + } + $value = implode(',', $array); + } else{ + foreach ($value as &$v) { + if ($v instanceof UnitEnum) { + $v = $this->parseEnum($v); + } + } + if (Connection::PARAM_STR == $bindType) { + $value = '\'' . implode('\',\'', $value) . '\''; + } else { + $value = implode(',', $value); + } + } + + if (!str_contains($value, ',')) { + return $key . ('IN' == $exp ? ' = ' : ' <> ') . $value; + } + } + + return $key . ' ' . $exp . ' (' . $value . ')'; + } + + /** + * 日期时间条件解析. + * + * @param Query $query 查询对象 + * @param mixed $value + * @param string $key + * @param int $bindType + * + * @return string + */ + protected function parseDateTime(Query $query, $value, string $key, int $bindType): string + { + $options = $query->getOptions(); + + // 获取时间字段类型 + if (str_contains($key, '.')) { + [$table, $key] = explode('.', $key); + + if (isset($options['alias']) && $pos = array_search($table, $options['alias'])) { + $table = $pos; + } + } else { + $table = $options['table']; + } + + $type = $query->getFieldType($key); + + if ($type) { + if (is_string($value)) { + $value = strtotime($value) ?: $value; + } + + if (is_int($value)) { + if (preg_match('/(datetime|timestamp)/is', $type)) { + // 日期及时间戳类型 + $value = date('Y-m-d H:i:s', $value); + } elseif (preg_match('/(date)/is', $type)) { + // 日期及时间戳类型 + $value = date('Y-m-d', $value); + } + } + } + + $name = $query->bindValue($value, $bindType); + + return ':' . $name; + } + + /** + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + protected function parseLimit(Query $query, string $limit): string + { + return (!empty($limit) && !str_contains($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; + } + + /** + * join分析. + * + * @param Query $query 查询对象 + * @param array $join + * + * @return string + */ + protected function parseJoin(Query $query, array $join): string + { + $joinStr = ''; + + foreach ($join as $item) { + [$table, $type, $on] = $item; + + if (str_contains($on, '=')) { + [$val1, $val2] = explode('=', $on, 2); + + $condition = $this->parseKey($query, $val1) . '=' . $this->parseKey($query, $val2); + } else { + $condition = $on; + } + + $table = $this->parseTable($query, $table); + + $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . $condition; + } + + return $joinStr; + } + + /** + * order分析. + * + * @param Query $query 查询对象 + * @param array $order + * + * @return string + */ + protected function parseOrder(Query $query, array $order): string + { + $array = []; + foreach ($order as $key => $val) { + if ($val instanceof Raw) { + $array[] = $this->parseRaw($query, $val); + } elseif (is_array($val) && preg_match('/^[\w\.]+$/', $key)) { + $array[] = $this->parseOrderField($query, $key, $val); + } elseif ('[rand]' == $val) { + $array[] = $this->parseRand($query); + } elseif (is_string($val)) { + if (is_numeric($key)) { + [$key, $sort] = explode(' ', str_contains($val, ' ') ? $val : $val . ' '); + } else { + $sort = $val; + } + + if (preg_match('/^[\w\-\>\.]+$/', $key)) { + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; + $array[] = $this->parseKey($query, $key, true) . $sort; + } else { + throw new Exception('order express error:' . $key); + } + } + } + + return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); + } + + /** + * 分析Raw对象 + * + * @param Query $query 查询对象 + * @param Raw $raw Raw对象 + * + * @return string + */ + protected function parseRaw(Query $query, Raw $raw): string + { + $sql = $raw->getValue(); + $bind = $raw->getBind(); + + if ($bind) { + $query->bindParams($sql, $bind); + } + + return $sql; + } + + /** + * 分析Express对象 + * + * @param Query $query 查询对象 + * @param Express $express Express对象 + * + * @return string + */ + protected function parseExpress(Query $query, Express $express): string + { + return $express->getValue(); + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + protected function parseRand(Query $query): string + { + return ''; + } + + /** + * orderField分析. + * + * @param Query $query 查询对象 + * @param string $key + * @param array $val + * + * @return string + */ + protected function parseOrderField(Query $query, string $key, array $val): string + { + if (isset($val['sort'])) { + $sort = $val['sort']; + unset($val['sort']); + } else { + $sort = ''; + } + + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; + $bind = $query->getFieldsBindType(); + + foreach ($val as $k => $item) { + $val[$k] = $this->parseDataBind($query, $key, $item, $bind); + } + + return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort; + } + + /** + * group分析. + * + * @param Query $query 查询对象 + * @param mixed $group + * + * @return string + */ + protected function parseGroup(Query $query, string | array $group): string + { + if (empty($group)) { + return ''; + } + + if (is_string($group)) { + $group = explode(',', $group); + } + + $val = []; + foreach ($group as $key) { + $val[] = $this->parseKey($query, $key); + } + + return ' GROUP BY ' . implode(',', $val); + } + + /** + * having分析. + * + * @param Query $query 查询对象 + * @param string $having + * + * @return string + */ + protected function parseHaving(Query $query, string $having): string + { + return !empty($having) ? ' HAVING ' . $having : ''; + } + + /** + * comment分析. + * + * @param Query $query 查询对象 + * @param string $comment + * + * @return string + */ + protected function parseComment(Query $query, string $comment): string + { + if (str_contains($comment, '*/')) { + $comment = strstr($comment, '*/', true); + } + + return !empty($comment) ? ' /* ' . $comment . ' */' : ''; + } + + /** + * distinct分析. + * + * @param Query $query 查询对象 + * @param mixed $distinct + * + * @return string + */ + protected function parseDistinct(Query $query, bool $distinct): string + { + return !empty($distinct) ? ' DISTINCT ' : ''; + } + + /** + * index分析,可在操作链中指定需要强制使用的索引. + * + * @param Query $query 查询对象 + * @param mixed $index + * + * @return string + */ + protected function parseForce(Query $query, string | array $index): string + { + if (empty($index)) { + return ''; + } + + if (is_array($index)) { + $index = implode(',', $index); + } + + return sprintf(' FORCE INDEX ( %s ) ', $index); + } + + /** + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * + * @return string + */ + protected function parseLock(Query $query, bool | string $lock = false): string + { + if (is_bool($lock)) { + return $lock ? ' FOR UPDATE ' : ''; + } + + if (is_string($lock) && !empty($lock)) { + return ' ' . trim($lock) . ' '; + } + return ''; + } + + /** + * 生成insertall SQL. + * + * @param Query $query 查询对象 + * @param array $keys 字段名 + * @param array $datas 数据 + * + * @return string + */ + public function insertAllByKeys(Query $query, array $keys, array $datas): string + { + $options = $query->getOptions(); + + // 获取绑定信息 + $bind = $query->getFieldsBindType(); + $fields = []; + $values = []; + + foreach ($keys as $field) { + $fields[] = $this->parseKey($query, $field); + } + + foreach ($datas as $k => $data) { + foreach ($data as $key => &$val) { + if (!$query->isAutoBind()) { + $val = Connection::PARAM_STR == $bind[$keys[$key]] ? '\'' . $val . '\'' : $val; + } else { + $val = $this->parseDataBind($query, $keys[$key], $val, $bind); + } + } + + $values[] = 'SELECT ' . implode(',', $data); + } + + return str_replace( + ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $fields), + implode(' UNION ALL ', $values), + $this->parseComment($query, $options['comment']), + ], + $this->insertAllSql + ); + } +} diff --git a/vendor/topthink/think-orm/src/db/CacheItem.php b/vendor/topthink/think-orm/src/db/CacheItem.php new file mode 100644 index 0000000..85dd4c8 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/CacheItem.php @@ -0,0 +1,220 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db; + +use DateInterval; +use DateTime; +use DateTimeInterface; +use think\db\exception\InvalidArgumentException; + +/** + * CacheItem实现类. + */ +class CacheItem +{ + /** + * 缓存Key. + * + * @var string + */ + protected $key; + + /** + * 缓存内容. + * + * @var mixed + */ + protected $value; + + /** + * 过期时间. + * + * @var int|DateTimeInterface + */ + protected $expire; + + /** + * 缓存tag. + * + * @var string + */ + protected $tag; + + /** + * 缓存是否命中. + * + * @var bool + */ + protected $isHit = false; + + public function __construct(?string $key = null) + { + $this->key = $key; + } + + /** + * 为此缓存项设置「键」. + * + * @param string $key + * + * @return $this + */ + public function setKey(string $key) + { + $this->key = $key; + + return $this; + } + + /** + * 返回当前缓存项的「键」. + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * 返回当前缓存项的有效期 + * + * @return DateTimeInterface|int|null + */ + public function getExpire() + { + if ($this->expire instanceof DateTimeInterface) { + return $this->expire; + } + + return $this->expire ? $this->expire - time() : null; + } + + /** + * 获取缓存Tag. + * + * @return string|array + */ + public function getTag() + { + return $this->tag; + } + + /** + * 凭借此缓存项的「键」从缓存系统里面取出缓存项. + * + * @return mixed + */ + public function get() + { + return $this->value; + } + + /** + * 确认缓存项的检查是否命中. + * + * @return bool + */ + public function isHit(): bool + { + return $this->isHit; + } + + /** + * 为此缓存项设置「值」. + * + * @param mixed $value + * + * @return $this + */ + public function set($value) + { + $this->value = $value; + $this->isHit = true; + + return $this; + } + + /** + * 为此缓存项设置所属标签. + * + * @param string|array $tag + * + * @return $this + */ + public function tag($tag = null) + { + $this->tag = $tag; + + return $this; + } + + /** + * 设置缓存项的有效期 + * + * @param mixed $expire + * + * @return $this + */ + public function expire($expire) + { + if (is_null($expire)) { + $this->expire = null; + } elseif (is_numeric($expire) || $expire instanceof DateInterval) { + $this->expiresAfter($expire); + } elseif ($expire instanceof DateTimeInterface) { + $this->expire = $expire; + } else { + throw new InvalidArgumentException('not support datetime'); + } + + return $this; + } + + /** + * 设置缓存项的准确过期时间点. + * + * @param DateTimeInterface $expiration + * + * @return $this + */ + public function expiresAt(DateTimeInterface $expiration) + { + $this->expire = $expiration; + + return $this; + } + + /** + * 设置缓存项的过期时间. + * + * @param int|DateInterval $timeInterval + * + * @throws InvalidArgumentException + * + * @return $this + */ + public function expiresAfter($timeInterval) + { + if ($timeInterval instanceof DateInterval) { + $this->expire = (int) DateTime::createFromFormat('U', (string) time())->add($timeInterval)->format('U'); + } elseif (is_numeric($timeInterval)) { + $this->expire = $timeInterval + time(); + } else { + throw new InvalidArgumentException('not support datetime'); + } + + return $this; + } +} diff --git a/vendor/topthink/think-orm/src/db/Connection.php b/vendor/topthink/think-orm/src/db/Connection.php new file mode 100644 index 0000000..860664d --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Connection.php @@ -0,0 +1,383 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use Psr\SimpleCache\CacheInterface; +use think\DbManager; + +/** + * 数据库连接基础类. + */ +abstract class Connection implements ConnectionInterface +{ + const PARAM_INT = 1; + const PARAM_STR = 2; + const PARAM_BOOL = 5; + const PARAM_FLOAT = 21; + + /** + * 当前SQL指令. + * + * @var string + */ + protected $queryStr = ''; + + /** + * 返回或者影响记录数. + * + * @var int + */ + protected $numRows = 0; + + /** + * 事务指令数. + * + * @var int + */ + protected $transTimes = 0; + + /** + * 错误信息. + * + * @var string + */ + protected $error = ''; + + /** + * 数据库连接ID 支持多个连接. + * + * @var array + */ + protected $links = []; + + /** + * 当前连接ID. + * + * @var object + */ + protected $linkID; + + /** + * 当前读连接ID. + * + * @var object + */ + protected $linkRead; + + /** + * 当前写连接ID. + * + * @var object + */ + protected $linkWrite; + + /** + * 数据表信息. + * + * @var array + */ + protected $info = []; + + /** + * 查询开始时间. + * + * @var float + */ + protected $queryStartTime; + + /** + * Builder对象 + * + * @var Builder + */ + protected $builder; + + /** + * Db对象 + * + * @var DbManager + */ + protected $db; + + /** + * 是否读取主库. + * + * @var bool + */ + protected $readMaster = false; + + /** + * 数据库连接参数配置. + * + * @var array + */ + protected $config = []; + + /** + * 缓存对象 + * + * @var CacheInterface + */ + protected $cache; + + /** + * 架构函数 读取数据库配置信息. + * + * @param array $config 数据库配置数组 + */ + public function __construct(array $config = []) + { + if (!empty($config)) { + $this->config = array_merge($this->config, $config); + } + + // 创建Builder对象 + $class = $this->getBuilderClass(); + + $this->builder = new $class($this); + } + + /** + * 获取当前的builder实例对象 + * + * @return Builder + */ + public function getBuilder() + { + return $this->builder; + } + + /** + * 创建查询对象 + */ + public function newQuery(): BaseQuery + { + $class = $this->getQueryClass(); + + return new $class($this); + } + + /** + * 设置当前的数据库Db对象 + * + * @param DbManager $db + * + * @return void + */ + public function setDb(DbManager $db) + { + $this->db = $db; + } + + /** + * 设置当前的缓存对象 + * + * @param CacheInterface $cache + * + * @return void + */ + public function setCache(CacheInterface $cache) + { + $this->cache = $cache; + } + + /** + * 获取当前的缓存对象 + * + * @return CacheInterface|null + */ + public function getCache() + { + return $this->cache; + } + + /** + * 获取数据库的配置参数. + * + * @param string $config 配置名称 + * + * @return mixed + */ + public function getConfig(string $config = '') + { + if ('' === $config) { + return $this->config; + } + + return $this->config[$config] ?? null; + } + + /** + * 数据库SQL监控. + * + * @param string $sql 执行的SQL语句 留空自动获取 + * @param bool $master 主从标记 + * + * @return void + */ + protected function trigger(string $sql = '', bool $master = false): void + { + $listen = $this->db->getListen(); + if (empty($listen)) { + $listen[] = function ($sql, $time, $master) { + if (str_starts_with($sql, 'CONNECT:')) { + $this->db->log($sql); + + return; + } + + // 记录SQL + if (is_bool($master)) { + // 分布式记录当前操作的主从 + $master = $master ? 'master|' : 'slave|'; + } else { + $master = ''; + } + + $this->db->log($sql . ' [ ' . $master . 'RunTime:' . $time . 's ]'); + }; + } + + $runtime = number_format((microtime(true) - $this->queryStartTime), 6); + $sql = $sql ?: $this->getLastsql(); + + if (empty($this->config['deploy'])) { + $master = null; + } + + foreach ($listen as $callback) { + if (is_callable($callback)) { + $callback($sql, $runtime, $master); + } + } + } + + /** + * 缓存数据. + * + * @param CacheItem $cacheItem 缓存Item + */ + protected function cacheData(CacheItem $cacheItem) + { + if ($cacheItem->getTag() && method_exists($this->cache, 'tag')) { + $this->cache->tag($cacheItem->getTag())->set($cacheItem->getKey(), $cacheItem->get(), $cacheItem->getExpire()); + } else { + $this->cache->set($cacheItem->getKey(), $cacheItem->get(), $cacheItem->getExpire()); + } + } + + /** + * 分析缓存Key. + * + * @param BaseQuery $query 查询对象 + * @param string $method 查询方法 + * + * @return string + */ + protected function getCacheKey(BaseQuery $query, string $method = ''): string + { + if (!empty($query->getOption('key')) && empty($method)) { + $key = 'think_' . $this->getConfig('database') . '.' . var_export($query->getTable(), true) . '|' . var_export($query->getOption('key'), true); + } else { + $key = $query->getQueryGuid(); + } + + return $key; + } + + /** + * 分析缓存. + * + * @param BaseQuery $query 查询对象 + * @param array $cache 缓存信息 + * @param string $method 查询方法 + * + * @return CacheItem + */ + protected function parseCache(BaseQuery $query, array $cache, string $method = ''): CacheItem + { + [$key, $expire, $tag] = $cache; + + if ($key instanceof CacheItem) { + $cacheItem = $key; + } else { + if (true === $key) { + $key = $this->getCacheKey($query, $method); + } + + $cacheItem = new CacheItem($key); + $cacheItem->expire($expire); + $cacheItem->tag($tag); + } + + return $cacheItem; + } + + /** + * 获取返回或者影响的记录数. + * + * @return int + */ + public function getNumRows(): int + { + return $this->numRows; + } + + /** + * 获取最终的SQL语句. + * + * @param string $sql 带参数绑定的sql语句 + * @param array $bind 参数绑定列表 + * + * @return string + */ + public function getRealSql(string $sql, array $bind = []): string + { + foreach ($bind as $key => $val) { + $value = strval(is_array($val) ? $val[0] : $val); + $type = is_array($val) ? $val[1] : self::PARAM_STR; + + if (self::PARAM_FLOAT == $type || self::PARAM_STR == $type) { + $value = '\'' . addslashes($value) . '\''; + } elseif (self::PARAM_INT == $type && '' === $value) { + $value = '0'; + } + + // 判断占位符 + $sql = is_numeric($key) ? + substr_replace($sql, $value, strpos($sql, '?'), 1) : + str_replace( + [':' . $key . ' ', ':' . $key . ',', ':' . $key . ')'], + [$value . ' ', $value . ',', $value . ')'], + $sql . ' '); + } + + return rtrim($sql); + } + + /** + * 析构方法. + */ + public function __destruct() + { + // 关闭连接 + $this->close(); + } + + public function __call($method, $args) + { + // 调用Query类方法 + return call_user_func_array([$this->newQuery(), $method], $args); + } +} diff --git a/vendor/topthink/think-orm/src/db/ConnectionInterface.php b/vendor/topthink/think-orm/src/db/ConnectionInterface.php new file mode 100644 index 0000000..0955b30 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/ConnectionInterface.php @@ -0,0 +1,208 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db; + +use Psr\SimpleCache\CacheInterface; +use think\DbManager; + +/** + * Connection interface. + */ +interface ConnectionInterface +{ + /** + * 获取当前连接器类对应的Query类. + * + * @return string + */ + public function getQueryClass(): string; + + /** + * 连接数据库方法. + * + * @param array $config 接参数 + * @param int $linkNum 连接序号 + * + * @return mixed + */ + public function connect(array $config = [], $linkNum = 0); + + /** + * 设置当前的数据库Db对象 + * + * @param DbManager $db + * + * @return void + */ + public function setDb(DbManager $db); + + /** + * 设置当前的缓存对象 + * + * @param CacheInterface $cache + * + * @return void + */ + public function setCache(CacheInterface $cache); + + /** + * 获取数据库的配置参数. + * + * @param string $config 配置名称 + * + * @return mixed + */ + public function getConfig(string $config = ''); + + /** + * 关闭数据库(或者重新连接). + * + * @return $this + */ + public function close(); + + /** + * 查找单条记录. + * + * @param BaseQuery $query 查询对象 + * + * @return array + */ + public function find(BaseQuery $query): array; + + /** + * 查找记录. + * + * @param BaseQuery $query 查询对象 + * + * @return array + */ + public function select(BaseQuery $query): array; + + /** + * 插入记录. + * + * @param BaseQuery $query 查询对象 + * @param bool $getLastInsID 返回自增主键 + * + * @return mixed + */ + public function insert(BaseQuery $query, bool $getLastInsID = false); + + /** + * 批量插入记录. + * + * @param BaseQuery $query 查询对象 + * @param mixed $dataSet 数据集 + * + * @return int + */ + public function insertAll(BaseQuery $query, array $dataSet = []): int; + + /** + * 更新记录. + * + * @param BaseQuery $query 查询对象 + * + * @return int + */ + public function update(BaseQuery $query): int; + + /** + * 删除记录. + * + * @param BaseQuery $query 查询对象 + * + * @return int + */ + public function delete(BaseQuery $query): int; + + /** + * 得到某个字段的值 + * + * @param BaseQuery $query 查询对象 + * @param string $field 字段名 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function value(BaseQuery $query, string $field, $default = null); + + /** + * 得到某个列的数组. + * + * @param BaseQuery $query 查询对象 + * @param string|array $column 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * + * @return array + */ + public function column(BaseQuery $query, string|array $column, string $key = ''): array; + + /** + * 执行数据库事务 + * + * @param callable $callback 数据操作方法回调 + * + * @return mixed + */ + public function transaction(callable $callback); + + /** + * 启动事务 + * + * @return void + */ + public function startTrans(); + + /** + * 用于非自动提交状态下面的查询提交. + * + * @return void + */ + public function commit(); + + /** + * 事务回滚. + * + * @return void + */ + public function rollback(); + + /** + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getTableFields(string $tableName): array; + + /** + * 获取最近一次查询的sql语句. + * + * @return string + */ + public function getLastSql(): string; + + /** + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 + * @param string $sequence 自增序列名 + * + * @return mixed + */ + public function getLastInsID(BaseQuery $query, ?string $sequence = null); +} diff --git a/vendor/topthink/think-orm/src/db/Express.php b/vendor/topthink/think-orm/src/db/Express.php new file mode 100644 index 0000000..82eb87d --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Express.php @@ -0,0 +1,64 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +/** + * SQL Express. + */ +class Express +{ + /** + * 创建一个SQL运算表达式. + * + * @param string $type + * @param float $value + * @param int $lazyTime + * + * @return void + */ + public function __construct(protected string $type, protected float $step = 1, protected int $lazyTime = 0) + { + } + + public function getStep() + { + return $this->step; + } + + public function getType() + { + return $this->type; + } + + public function getLazyTime() + { + return $this->lazyTime; + } + + /** + * 获取表达式. + * + * @return string + */ + public function getValue(): string + { + return match ($this->type) { + '+' => ' + ' . $this->step, + '-' => ' - ' . $this->step, + '*' => ' * ' . $this->step, + '/' => ' / ' . $this->step, + default => ' + 0', + }; + } +} diff --git a/vendor/topthink/think-orm/src/db/Fetch.php b/vendor/topthink/think-orm/src/db/Fetch.php new file mode 100644 index 0000000..450dc0d --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Fetch.php @@ -0,0 +1,544 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use think\helper\Str; + +/** + * SQL获取类. + */ +class Fetch +{ + /** + * Connection对象 + * + * @var Connection + */ + protected $connection; + + /** + * Builder对象 + * + * @var Builder + */ + protected $builder; + + /** + * 创建一个查询SQL获取对象 + * + * @param Query $query 查询对象 + */ + public function __construct(protected Query $query) + { + $this->connection = $query->getConnection(); + $this->builder = $this->connection->getBuilder(); + } + + /** + * 聚合查询. + * + * @param string $aggregate 聚合方法 + * @param string $field 字段名 + * + * @return string + */ + protected function aggregate(string $aggregate, string $field): string + { + $this->query->parseOptions(); + + $field = $aggregate . '(' . $this->builder->parseKey($this->query, $field) . ') AS think_' . strtolower($aggregate); + + return $this->value($field, 0, false); + } + + /** + * 得到某个字段的值 + * + * @param string $field 字段名 + * @param mixed $default 默认值 + * @param bool $one + * + * @return string + */ + public function value(string $field, $default = null, bool $one = true): string + { + $options = $this->query->parseOptions(); + + if (isset($options['field'])) { + $this->query->removeOption('field'); + } + + $this->query->setOption('field', (array) $field); + + // 生成查询SQL + $sql = $this->builder->select($this->query, $one); + + if (isset($options['field'])) { + $this->query->setOption('field', $options['field']); + } else { + $this->query->removeOption('field'); + } + + return $this->fetch($sql); + } + + /** + * 得到某个列的数组. + * + * @param string $field 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * + * @return string + */ + public function column(string $field, string $key = ''): string + { + $options = $this->query->parseOptions(); + + if (isset($options['field'])) { + $this->query->removeOption('field'); + } + + if ($key && '*' != $field) { + $field = $key . ',' . $field; + } + + $field = array_map('trim', explode(',', $field)); + + $this->query->setOption('field', $field); + + // 生成查询SQL + $sql = $this->builder->select($this->query); + + if (isset($options['field'])) { + $this->query->setOption('field', $options['field']); + } else { + $this->query->removeOption('field'); + } + + return $this->fetch($sql); + } + + /** + * 插入记录. + * + * @param array $data 数据 + * + * @return string + */ + public function insert(array $data = []): string + { + $options = $this->query->parseOptions(); + + if (!empty($data)) { + $this->query->setOption('data', $data); + } + + $sql = $this->builder->insert($this->query); + + return $this->fetch($sql); + } + + /** + * 插入记录并获取自增ID. + * + * @param array $data 数据 + * + * @return string + */ + public function insertGetId(array $data = []): string + { + return $this->insert($data); + } + + /** + * 保存数据 自动判断insert或者update. + * + * @param array $data 数据 + * @param bool $forceInsert 是否强制insert + * + * @return string + */ + public function save(array $data = [], bool $forceInsert = false): string + { + if ($forceInsert) { + return $this->insert($data); + } + + $data = array_merge($this->query->getOption('data', []), $data); + + $this->query->setOption('data', $data); + + if ($this->query->getOption('where')) { + $isUpdate = true; + } else { + $isUpdate = $this->query->parseUpdateData($data); + } + + return $isUpdate ? $this->update() : $this->insert(); + } + + /** + * 批量插入记录. + * + * @param array $dataSet 数据集 + * @param int $limit 每次写入数据限制 + * + * @return string + */ + public function insertAll(array $dataSet = [], ?int $limit = null): string + { + $options = $this->query->parseOptions(); + + if (empty($dataSet)) { + $dataSet = $options['data']; + } + + if (empty($limit) && !empty($options['limit'])) { + $limit = $options['limit']; + } + + if ($limit) { + $array = array_chunk($dataSet, $limit, true); + $fetchSql = []; + foreach ($array as $item) { + $sql = $this->builder->insertAll($this->query, $item); + $bind = $this->query->getBind(); + + $fetchSql[] = $this->connection->getRealSql($sql, $bind); + } + + return implode(';', $fetchSql); + } + + $sql = $this->builder->insertAll($this->query, $dataSet); + + return $this->fetch($sql); + } + + /** + * 通过Select方式插入记录. + * + * @param array $fields 要插入的数据表字段名 + * @param string $table 要插入的数据表名 + * + * @return string + */ + public function selectInsert(array $fields, string $table): string + { + $this->query->parseOptions(); + + $sql = $this->builder->selectInsert($this->query, $fields, $table); + + return $this->fetch($sql); + } + + /** + * 字段值增长 + * + * @param string $field 字段名 + * @param float|int $step 步进值 + * @param int $lazyTime 延迟时间(秒) + * + * @return string + */ + public function setInc(string $field, float|int $step = 1, int $lazyTime = 0) + { + return $this->inc($field, $step)->update(); + } + + /** + * 字段值减少 + * + * @param string $field 字段名 + * @param float|int $step 步进值 + * @param int $lazyTime 延迟时间(秒) + * + * @return string + */ + public function setDec(string $field, float|int $step = 1, int $lazyTime = 0) + { + return $this->dec($field, $step)->update(); + } + + /** + * 更新记录. + * + * @param mixed $data 数据 + * + * @return string + */ + public function update(array $data = []): string + { + $options = $this->query->parseOptions(); + + $data = !empty($data) ? $data : $options['data']; + + $pk = $this->query->getPk(); + + if (empty($options['where'])) { + // 如果存在主键数据 则自动作为更新条件 + if (is_string($pk) && isset($data[$pk])) { + $this->query->where($pk, '=', $data[$pk]); + unset($data[$pk]); + } elseif (is_array($pk)) { + // 增加复合主键支持 + foreach ($pk as $field) { + if (isset($data[$field])) { + $this->query->where($field, '=', $data[$field]); + } else { + // 如果缺少复合主键数据则不执行 + throw new Exception('miss complex primary data'); + } + unset($data[$field]); + } + } + + if (empty($this->query->getOption('where'))) { + // 如果没有任何更新条件则不执行 + throw new Exception('miss update condition'); + } + } + + // 更新数据 + $this->query->setOption('data', $data); + + // 生成UPDATE SQL语句 + $sql = $this->builder->update($this->query); + + return $this->fetch($sql); + } + + /** + * 删除记录. + * + * @param mixed $data 表达式 true 表示强制删除 + * + * @return string + */ + public function delete($data = null): string + { + $options = $this->query->parseOptions(); + + if (!is_null($data) && true !== $data) { + // AR模式分析主键条件 + $this->query->parsePkWhere($data); + } + + if (!empty($options['soft_delete'])) { + // 软删除 + [$field, $condition] = $options['soft_delete']; + if ($condition) { + $this->query->setOption('soft_delete', null); + $this->query->setOption('data', [$field => $condition]); + // 生成删除SQL语句 + $sql = $this->builder->update($this->query); + + return $this->fetch($sql); + } + } + + // 生成删除SQL语句 + $sql = $this->builder->delete($this->query); + + return $this->fetch($sql); + } + + /** + * 查找记录 返回SQL. + * + * @param array $data + * + * @return string + */ + public function select(array $data = []): string + { + $this->query->parseOptions(); + + if (!empty($data)) { + // 主键条件分析 + $this->query->parsePkWhere($data); + } + + // 生成查询SQL + $sql = $this->builder->select($this->query); + + return $this->fetch($sql); + } + + /** + * 查找单条记录 返回SQL语句. + * + * @param mixed $data + * + * @return string + */ + public function find($data = null): string + { + $this->query->parseOptions(); + + if (!is_null($data)) { + // AR模式分析主键条件 + $this->query->parsePkWhere($data); + } + + // 生成查询SQL + $sql = $this->builder->select($this->query, true); + + // 获取实际执行的SQL语句 + return $this->fetch($sql); + } + + /** + * 查找多条记录 如果不存在则抛出异常. + * + * @param mixed $data + * + * @return string + */ + public function selectOrFail($data = null): string + { + return $this->select($data); + } + + /** + * 查找单条记录 如果不存在则抛出异常. + * + * @param mixed $data + * + * @return string + */ + public function findOrFail($data = null): string + { + return $this->find($data); + } + + /** + * 查找单条记录 不存在返回空数据(或者空模型). + * + * @param mixed $data 数据 + * + * @return string + */ + public function findOrEmpty($data = null) + { + return $this->find($data); + } + + /** + * 获取实际的SQL语句. + * + * @param string $sql + * + * @return string + */ + public function fetch(string $sql): string + { + $bind = $this->query->getBind(); + + return $this->connection->getRealSql($sql, $bind); + } + + /** + * COUNT查询. + * + * @param string $field 字段名 + * + * @return string + */ + public function count(string $field = '*'): string + { + $options = $this->query->parseOptions(); + + if (!empty($options['group'])) { + // 支持GROUP + $subSql = $this->query->field('count(' . $field . ') AS think_count')->buildSql(); + $query = $this->query->newQuery()->table([$subSql => '_group_count_']); + + return $query->fetchsql()->aggregate('COUNT', '*'); + } + + return $this->aggregate('COUNT', $field); + } + + /** + * SUM查询. + * + * @param string $field 字段名 + * + * @return string + */ + public function sum(string $field): string + { + return $this->aggregate('SUM', $field); + } + + /** + * MIN查询. + * + * @param string $field 字段名 + * + * @return string + */ + public function min(string $field): string + { + return $this->aggregate('MIN', $field); + } + + /** + * MAX查询. + * + * @param string $field 字段名 + * + * @return string + */ + public function max(string $field): string + { + return $this->aggregate('MAX', $field); + } + + /** + * AVG查询. + * + * @param string $field 字段名 + * + * @return string + */ + public function avg(string $field): string + { + return $this->aggregate('AVG', $field); + } + + public function __call($method, $args) + { + if (strtolower(substr($method, 0, 5)) == 'getby') { + // 根据某个字段获取记录 + $field = Str::snake(substr($method, 5)); + + return $this->where($field, '=', $args[0])->find(); + } + + if (strtolower(substr($method, 0, 10)) == 'getfieldby') { + // 根据某个字段获取记录的某个值 + $name = Str::snake(substr($method, 10)); + + return $this->where($name, '=', $args[0])->value($args[1]); + } + + $result = call_user_func_array([$this->query, $method], $args); + + return $result === $this->query ? $this : $result; + } +} diff --git a/vendor/topthink/think-orm/src/db/Mongo.php b/vendor/topthink/think-orm/src/db/Mongo.php new file mode 100644 index 0000000..aef0a7c --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Mongo.php @@ -0,0 +1,802 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use MongoDB\Driver\Command; +use MongoDB\Driver\Cursor; +use MongoDB\Driver\Exception\AuthenticationException; +use MongoDB\Driver\Exception\ConnectionException; +use MongoDB\Driver\Exception\InvalidArgumentException; +use MongoDB\Driver\Exception\RuntimeException; +use MongoDB\Driver\ReadPreference; +use MongoDB\Driver\WriteConcern; +use think\db\exception\DbException as Exception; +use think\Paginator; + +class Mongo extends BaseQuery +{ + /** + * 当前数据库连接对象 + * + * @var \think\db\connector\Mongo + */ + protected $connection; + + /** + * 执行指令 返回数据集. + * + * @param Command $command 指令 + * @param string $dbName + * @param ReadPreference $readPreference readPreference + * @param string|array $typeMap 指定返回的typeMap + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return mixed + */ + public function command(Command $command, string $dbName = '', ?ReadPreference $readPreference = null, $typeMap = null) + { + return $this->connection->command($command, $dbName, $readPreference, $typeMap); + } + + /** + * 执行command. + * + * @param string|array|object $command 指令 + * @param mixed $extra 额外参数 + * @param string $db 数据库名 + * + * @return array + */ + public function cmd($command, $extra = null, string $db = ''): array + { + $this->parseOptions(); + + return $this->connection->cmd($this, $command, $extra, $db); + } + + /** + * 指定distinct查询. + * + * @param string $field 字段名 + * + * @return array + */ + public function getDistinct(string $field) + { + $result = $this->cmd('distinct', $field); + + return $result[0]['values']; + } + + /** + * 获取数据库的所有collection. + * + * @param string $db 数据库名称 留空为当前数据库 + * + * @throws Exception + */ + public function listCollections(string $db = '') + { + $cursor = $this->cmd('listCollections', null, $db); + $result = []; + foreach ($cursor as $collection) { + $result[] = $collection['name']; + } + + return $result; + } + + /** + * COUNT查询. + * + * @param string $field 字段名 + * + * @return int + */ + public function count(?string $field = null): int + { + $result = $this->cmd('count'); + + return $result[0]['n']; + } + + /** + * 聚合查询. + * + * @param string $aggregate 聚合指令 + * @param string $field 字段名 + * @param bool $force 强制转为数字类型 + * + * @return mixed + */ + public function aggregate(string $aggregate, $field, bool $force = false, bool $one = false) + { + $result = $this->cmd('aggregate', [strtolower($aggregate), $field]); + $value = $result[0]['aggregate'] ?? 0; + + if ($force) { + $value += 0; + } + + return $value; + } + + /** + * 多聚合操作. + * + * @param array $aggregate 聚合指令, 可以聚合多个参数, 如 ['sum' => 'field1', 'avg' => 'field2'] + * @param array $groupBy 类似mysql里面的group字段, 可以传入多个字段, 如 ['field_a', 'field_b', 'field_c'] + * + * @return array 查询结果 + */ + public function multiAggregate(array $aggregate, array $groupBy): array + { + $result = $this->cmd('multiAggregate', [$aggregate, $groupBy]); + + foreach ($result as &$row) { + if (isset($row['_id']) && !empty($row['_id'])) { + foreach ($row['_id'] as $k => $v) { + $row[$k] = $v; + } + unset($row['_id']); + } + } + + return $result; + } + + /** + * 字段值增长 + * + * @param string $field 字段名 + * @param float|int $step 增长值 + * + * @return $this + */ + public function inc(string $field, float|int $step = 1) + { + $this->options['data'][$field] = ['$inc', $step]; + + return $this; + } + + /** + * 字段值减少. + * + * @param string $field 字段名 + * @param float|int $step 减少值 + * + * @return $this + */ + public function dec(string $field, float|int $step = 1) + { + return $this->inc($field, -1 * $step); + } + + /** + * 指定当前操作的Collection. + * + * @param string $table 表名 + * + * @return $this + */ + public function table($table) + { + $this->options['table'] = $table; + + return $this; + } + + /** + * table方法的别名. + * + * @param string $collection + * + * @return $this + */ + public function collection(string $collection) + { + return $this->table($collection); + } + + /** + * 设置typeMap. + * + * @param string|array $typeMap + * + * @return $this + */ + public function typeMap($typeMap) + { + $this->options['typeMap'] = $typeMap; + + return $this; + } + + /** + * awaitData. + * + * @param bool $awaitData + * + * @return $this + */ + public function awaitData(bool $awaitData) + { + $this->options['awaitData'] = $awaitData; + + return $this; + } + + /** + * batchSize. + * + * @param int $batchSize + * + * @return $this + */ + public function batchSize(int $batchSize) + { + $this->options['batchSize'] = $batchSize; + + return $this; + } + + /** + * exhaust. + * + * @param bool $exhaust + * + * @return $this + */ + public function exhaust(bool $exhaust) + { + $this->options['exhaust'] = $exhaust; + + return $this; + } + + /** + * 设置modifiers. + * + * @param array $modifiers + * + * @return $this + */ + public function modifiers(array $modifiers) + { + $this->options['modifiers'] = $modifiers; + + return $this; + } + + /** + * 设置noCursorTimeout. + * + * @param bool $noCursorTimeout + * + * @return $this + */ + public function noCursorTimeout(bool $noCursorTimeout) + { + $this->options['noCursorTimeout'] = $noCursorTimeout; + + return $this; + } + + /** + * 设置oplogReplay. + * + * @param bool $oplogReplay + * + * @return $this + */ + public function oplogReplay(bool $oplogReplay) + { + $this->options['oplogReplay'] = $oplogReplay; + + return $this; + } + + /** + * 设置partial. + * + * @param bool $partial + * + * @return $this + */ + public function partial(bool $partial) + { + $this->options['partial'] = $partial; + + return $this; + } + + /** + * maxTimeMS. + * + * @param string $maxTimeMS + * + * @return $this + */ + public function maxTimeMS(string $maxTimeMS) + { + $this->options['maxTimeMS'] = $maxTimeMS; + + return $this; + } + + /** + * collation. + * + * @param array $collation + * + * @return $this + */ + public function collation(array $collation) + { + $this->options['collation'] = $collation; + + return $this; + } + + /** + * 设置是否REPLACE. + * + * @param bool $replace 是否使用REPLACE写入数据 + * + * @return $this + */ + public function replace(bool $replace = true) + { + return $this; + } + + /** + * 设置返回字段. + * + * @param mixed $field 字段信息 + * + * @return $this + */ + public function field($field) + { + if (empty($field) || '*' == $field) { + return $this; + } + + if (is_string($field)) { + $field = array_map('trim', explode(',', $field)); + } + + $projection = []; + foreach ($field as $key => $val) { + if (is_numeric($key)) { + $projection[$val] = 1; + } else { + $projection[$key] = $val; + } + } + + $this->options['projection'] = $projection; + + return $this; + } + + /** + * 指定要排除的查询字段. + * + * @param array|string $field 要排除的字段 + * + * @return $this + */ + public function withoutField($field) + { + if (empty($field) || '*' == $field) { + return $this; + } + + if (is_string($field)) { + $field = array_map('trim', explode(',', $field)); + } + + $projection = []; + foreach ($field as $key => $val) { + if (is_numeric($key)) { + $projection[$val] = 0; + } else { + $projection[$key] = $val; + } + } + + $this->options['projection'] = $projection; + + return $this; + } + + /** + * 设置skip. + * + * @param int $skip + * + * @return $this + */ + public function skip(int $skip) + { + $this->options['skip'] = $skip; + + return $this; + } + + /** + * 设置slaveOk. + * + * @param bool $slaveOk + * + * @return $this + */ + public function slaveOk(bool $slaveOk) + { + $this->options['slaveOk'] = $slaveOk; + + return $this; + } + + /** + * 指定查询数量. + * + * @param int $offset 起始位置 + * @param int $length 查询数量 + * + * @return $this + */ + public function limit(int $offset, ?int $length = null) + { + if (is_null($length)) { + $length = $offset; + $offset = 0; + } + + $this->options['skip'] = $offset; + $this->options['limit'] = $length; + + return $this; + } + + /** + * 设置sort. + * + * @param array|string $field + * @param string $order + * + * @return $this + */ + public function order($field, string $order = '') + { + if (is_array($field)) { + $this->options['sort'] = array_map(function ($val) { + return 'asc' == strtolower($val) ? 1 : -1; + }, $field); + } else { + $this->options['sort'][$field] = 'asc' == strtolower($order) ? 1 : -1; + } + + return $this; + } + + /** + * 设置tailable. + * + * @param bool $tailable + * + * @return $this + */ + public function tailable(bool $tailable) + { + $this->options['tailable'] = $tailable; + + return $this; + } + + /** + * 设置writeConcern对象 + * + * @param WriteConcern $writeConcern + * + * @return $this + */ + public function writeConcern(WriteConcern $writeConcern) + { + $this->options['writeConcern'] = $writeConcern; + + return $this; + } + + /** + * 获取当前数据表的主键. + * + * @return string|array + */ + public function getPk() + { + return $this->pk ?: $this->connection->getConfig('pk'); + } + + /** + * 执行查询但只返回Cursor对象 + * + * @return Cursor + */ + public function cursor(): Cursor + { + return $this->getCursor(); + } + + /** + * 执行查询但只返回Cursor对象 + * + * @return Cursor + */ + public function getCursor(): Cursor + { + $this->parseOptions(); + + return $this->connection->cursor($this); + } + + /** + * 分页查询. + * + * @param int|array $listRows 每页数量 数组表示配置参数 + * @param int|bool $simple 是否简洁模式或者总记录数 + * + * @throws Exception + * + * @return Paginator + */ + public function paginate($listRows = null, $simple = false): Paginator + { + if (is_int($simple)) { + $total = $simple; + $simple = false; + } + + $defaultConfig = [ + 'query' => [], //url额外参数 + 'fragment' => '', //url锚点 + 'var_page' => 'page', //分页变量 + 'list_rows' => 15, //每页数量 + ]; + + if (is_array($listRows)) { + $config = array_merge($defaultConfig, $listRows); + $listRows = intval($config['list_rows']); + } else { + $config = $defaultConfig; + $listRows = intval($listRows ?: $config['list_rows']); + } + + $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); + + $page = max($page, 1); + + $config['path'] = $config['path'] ?? Paginator::getCurrentPath(); + + if (!isset($total) && !$simple) { + $options = $this->getOptions(); + + unset($this->options['order'], $this->options['limit'], $this->options['page'], $this->options['field']); + + $total = $this->count(); + $results = $this->options($options)->page($page, $listRows)->select(); + } elseif ($simple) { + $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); + $total = null; + } else { + $results = $this->page($page, $listRows)->select(); + } + + $this->removeOption('limit'); + $this->removeOption('page'); + + return Paginator::make($results, $listRows, $page, $total, $simple, $config); + } + + /** + * 分批数据返回处理. + * + * @param int $count 每次处理的数据数量 + * @param callable $callback 处理回调方法 + * @param string|array $column 分批处理的字段名 + * @param string $order 字段排序 + * + * @throws Exception + * + * @return bool + */ + public function chunk(int $count, callable $callback, $column = null, string $order = 'asc'): bool + { + $options = $this->getOptions(); + $column = $column ?: $this->getPk(); + + if (isset($options['order'])) { + unset($options['order']); + } + + if (is_array($column)) { + $times = 1; + $query = $this->options($options)->page($times, $count); + } else { + $query = $this->options($options)->limit($count); + + if (str_contains($column, '.')) { + [$alias, $key] = explode('.', $column); + } else { + $key = $column; + if ($key == '_id' && $this->connection->getConfig('pk_convert_id')) { + $key = 'id'; + } + } + } + + $resultSet = $query->order($column, $order)->select(); + + while (count($resultSet) > 0) { + if (false === call_user_func($callback, $resultSet)) { + return false; + } + + if (isset($times)) { + $times++; + $query = $this->options($options)->page($times, $count); + } else { + $end = $resultSet->pop(); + $lastId = is_array($end) ? $end[$key] : $end->getData($key); + + $query = $this->options($options) + ->limit($count) + ->where($column, 'asc' == strtolower($order) ? '>' : '<', $lastId); + } + + $resultSet = $query->order($column, $order)->select(); + } + + return true; + } + + /** + * 分析表达式(可用于查询或者写入操作). + * + * @return array + */ + public function parseOptions(): array + { + $options = $this->options; + + // 获取数据表 + if (empty($options['table'])) { + $options['table'] = $this->getTable(); + } + + foreach (['where', 'data', 'projection', 'filter', 'json', 'with_attr', 'with_relation_attr'] as $name) { + if (!isset($options[$name])) { + $options[$name] = []; + } + } + + $modifiers = empty($options['modifiers']) ? [] : $options['modifiers']; + if (isset($options['comment'])) { + $modifiers['$comment'] = $options['comment']; + } + + if (isset($options['maxTimeMS'])) { + $modifiers['$maxTimeMS'] = $options['maxTimeMS']; + } + + if (!empty($modifiers)) { + $options['modifiers'] = $modifiers; + } + + if (!isset($options['typeMap'])) { + $options['typeMap'] = $this->getConfig('type_map'); + } + + if (!isset($options['limit'])) { + $options['limit'] = 0; + } + + foreach (['master', 'fetch_sql', 'fetch_cursor'] as $name) { + if (!isset($options[$name])) { + $options[$name] = false; + } + } + + if (isset($options['page'])) { + // 根据页数计算limit + [$page, $listRows] = $options['page']; + + $page = $page > 0 ? $page : 1; + $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); + $offset = $listRows * ($page - 1); + $options['skip'] = intval($offset); + $options['limit'] = intval($listRows); + } + + $this->options = $options; + + return $options; + } + + /** + * 获取字段类型信息. + * + * @return array + */ + public function getFieldsType(): array + { + if (!empty($this->options['field_type'])) { + return $this->options['field_type']; + } + + return []; + } + + /** + * 获取字段类型信息. + * + * @param string $field 字段名 + * + * @return string|null + */ + public function getFieldType(string $field) + { + $fieldType = $this->getFieldsType(); + + return $fieldType[$field] ?? null; + } + + /** + * 获取字段类型 + * + * @return array + */ + public function getType() + { + return $this->getFieldsType(); + } + + /** + * 获取自增主键 + * + * @return string + */ + public function getAutoInc() + { + return ''; + } + + /** + * 设置自增主键 + * + * @param string $autoInc + * @return static + */ + public function autoInc(?string $autoInc) + { + return $this; + } +} diff --git a/vendor/topthink/think-orm/src/db/PDOConnection.php b/vendor/topthink/think-orm/src/db/PDOConnection.php new file mode 100644 index 0000000..98d5ed6 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/PDOConnection.php @@ -0,0 +1,2003 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use Closure; +use PDO; +use PDOStatement; +use think\db\exception\BindParamException; +use think\db\exception\DbEventException; +use think\db\exception\DbException; +use think\db\exception\DuplicateException; +use think\db\exception\PDOException; +use think\model\contract\Modelable as Model; + +/** + * 数据库连接基础类. + * + * @property PDO[] $links + * @property PDO $linkID + * @property PDO $linkRead + * @property PDO $linkWrite + */ +abstract class PDOConnection extends Connection +{ + /** + * 数据库连接参数配置. + * + * @var array + */ + protected $config = [ + // 数据库类型 + 'type' => '', + // 服务器地址 + 'hostname' => '', + // 数据库名 + 'database' => '', + // 用户名 + 'username' => '', + // 密码 + 'password' => '', + // 端口 + 'hostport' => '', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => '', + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 模型写入后自动读取主服务器 + 'read_master' => false, + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 开启字段缓存 + 'fields_cache' => false, + // 监听SQL + 'trigger_sql' => true, + // Builder类 + 'builder' => '', + // Query类 + 'query' => '', + // 是否需要断线重连 + 'break_reconnect' => false, + // 断线标识字符串 + 'break_match_str' => [], + // 自动参数绑定 + 'auto_param_bind' => true, + ]; + + /** + * PDO操作实例. + * + * @var PDOStatement + */ + protected $PDOStatement; + + /** + * 当前SQL指令. + * + * @var string + */ + protected $queryStr = ''; + + /** + * 事务指令数. + * + * @var int + */ + protected $transTimes = 0; + + /** + * 重连次数. + * + * @var int + */ + protected $reConnectTimes = 0; + + /** + * 查询结果类型. + * + * @var int + */ + protected $fetchType = PDO::FETCH_ASSOC; + + /** + * 字段属性大小写. + * + * @var int + */ + protected $attrCase = PDO::CASE_LOWER; + + /** + * 数据表信息. + * + * @var array + */ + protected $info = []; + + /** + * 查询开始时间. + * + * @var float + */ + protected $queryStartTime; + + /** + * PDO连接参数. + * + * @var array + */ + protected $params = [ + PDO::ATTR_CASE => PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + + /** + * 参数绑定类型映射. + * + * @var array + */ + protected $bindType = [ + 'string' => self::PARAM_STR, + 'str' => self::PARAM_STR, + 'bigint' => self::PARAM_STR, + 'set' => self::PARAM_STR, + 'enum' => self::PARAM_STR, + 'integer' => self::PARAM_INT, + 'int' => self::PARAM_INT, + 'boolean' => self::PARAM_BOOL, + 'bool' => self::PARAM_BOOL, + 'float' => self::PARAM_FLOAT, + 'datetime' => self::PARAM_STR, + 'date' => self::PARAM_STR, + 'timestamp' => self::PARAM_STR, + ]; + + /** + * 服务器断线标识字符. + * + * @var array + */ + protected $breakMatchStr = [ + 'server has gone away', + 'no connection to the server', + 'Lost connection', + 'is dead or not enabled', + 'Error while sending', + 'decryption failed or bad record mac', + 'server closed the connection unexpectedly', + 'SSL connection has been closed unexpectedly', + 'Error writing data to the connection', + 'Resource deadlock avoided', + 'failed with errno', + 'child connection forced to terminate due to client_idle_limit', + 'query_wait_timeout', + 'reset by peer', + 'Physical connection is not usable', + 'TCP Provider: Error code 0x68', + 'ORA-03114', + 'Packets out of order. Expected', + 'Adaptive Server connection failed', + 'Communication link failure', + 'connection is no longer usable', + 'Login timeout expired', + 'SQLSTATE[HY000] [2002] Connection refused', + 'running with the --read-only option so it cannot execute this statement', + 'The connection is broken and recovery is not possible. The connection is marked by the client driver as unrecoverable. No attempt was made to restore the connection.', + 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again', + 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known', + 'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: EOF detected', + 'SQLSTATE[HY000] [2002] Connection timed out', + 'SSL: Connection timed out', + 'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.', + ]; + + /** + * 绑定参数. + * + * @var array + */ + protected $bind = []; + + /** + * 获取当前连接器类对应的Query类. + * + * @return string + */ + public function getQueryClass(): string + { + return $this->getConfig('query') ?: Query::class; + } + + /** + * 获取当前连接器类对应的Builder类. + * + * @return string + */ + public function getBuilderClass(): string + { + return $this->getConfig('builder') ?: '\\think\\db\\builder\\' . ucfirst($this->getConfig('type')); + } + + /** + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * + * @return string + */ + abstract protected function parseDsn(array $config): string; + + /** + * 取得数据表的字段信息. + * + * @param string $tableName 数据表名称 + * + * @return array + */ + abstract public function getFields(string $tableName): array; + + /** + * 取得数据库的表信息. + * + * @param string $dbName 数据库名称 + * + * @return array + */ + abstract public function getTables(string $dbName = ''): array; + + /** + * 对返数据表字段信息进行大小写转换出来. + * + * @param array $info 字段信息 + * + * @return array + */ + public function fieldCase(array $info): array + { + // 字段大小写转换 + return match ($this->attrCase) { + PDO::CASE_LOWER => array_change_key_case($info), + PDO::CASE_UPPER => array_change_key_case($info, CASE_UPPER), + PDO::CASE_NATURAL => $info, + default => $info, + }; + } + + /** + * 获取字段类型. + * + * @param string $type 字段类型 + * + * @return string + */ + protected function getFieldType(string $type): string + { + // 将字段类型转换为小写以进行比较 + $type = strtolower($type); + + return match (true) { + str_starts_with($type, 'set') => 'set', + str_starts_with($type, 'enum') => 'enum', + str_starts_with($type, 'bigint') => 'bigint', + str_contains($type, 'float') || str_contains($type, 'double') || + str_contains($type, 'real') => 'float', + str_contains($type, 'int') || str_contains($type, 'serial') || + str_contains($type, 'bit') => 'int', + str_contains($type, 'bool') => 'bool', + str_contains($type, 'json') => 'json', + str_starts_with($type, 'timestamp') => 'timestamp', + str_starts_with($type, 'datetime') => 'datetime', + str_starts_with($type, 'date') => 'date', + default => 'string', + }; + } + + /** + * 获取字段绑定类型. + * + * @param string $type 字段类型 + * + * @return int + */ + public function getFieldBindType(string $type): int + { + return $this->bindType[$type] ?? self::PARAM_STR; + } + + /** + * 获取数据表信息缓存key. + * + * @param string $schema 数据表名称 + * + * @return string + */ + protected function getSchemaCacheKey(string $schema): string + { + $hostname = $this->getConfig('hostname'); + return (is_array($hostname) ? $hostname[0] : $hostname) . '_' . $this->getConfig('hostport') . '|' . $schema; + } + + /** + * @param string $tableName 数据表名称 + * @param bool $force 强制从数据库获取 + * + * @return array + */ + public function getSchemaInfo(string $tableName, bool $force = false): array + { + $schema = str_contains($tableName, '.') ? $tableName : $this->getConfig('database') . '.' . $tableName; + + if (isset($this->info[$schema]) && !$force) { + return $this->info[$schema]; + } + + // 读取字段缓存 + $cacheKey = $this->getSchemaCacheKey($schema); + $info = $this->getCachedSchemaInfo($cacheKey, $tableName, $force); + + $pk = $info['_pk'] ?? null; + $autoinc = $info['_autoinc'] ?? null; + unset($info['_pk'], $info['_autoinc']); + + $bind = array_map(fn($val) => $this->getFieldBindType($val), $info); + + $this->info[$schema] = [ + 'fields' => array_keys($info), + 'type' => $info, + 'bind' => $bind, + 'pk' => $pk, + 'autoinc' => $autoinc, + ]; + + return $this->info[$schema]; + } + + /** + * @param string $cacheKey 缓存key + * @param string $tableName 数据表名称 + * @param bool $force 强制从数据库获取 + * + * @return array + */ + protected function getCachedSchemaInfo(string $cacheKey, string $tableName, bool $force): array + { + if ($this->config['fields_cache'] && !empty($this->cache) && !$force) { + $info = $this->cache->get($cacheKey); + if (!empty($info)) { + if (is_object($info)) { + $info = get_object_vars($info); + } + return $info; + } + } + + $info = $this->getTableFieldsInfo($tableName); + if (!empty($this->cache) && ($this->config['fields_cache'] || $force)) { + $this->cache->set($cacheKey, $info); + } + + return $info; + } + + /** + * 获取数据表信息. + * + * @param mixed $tableName 数据表名 留空自动获取 + * @param string $fetch 获取信息类型 包括 fields type bind pk + * + * @return mixed + */ + public function getTableInfo(array | string $tableName, string $fetch = '') + { + if (is_array($tableName)) { + $tableName = key($tableName) ?: current($tableName); + } + + if (str_contains($tableName, ',') || str_contains($tableName, ')')) { + // 多表不获取字段信息 + return []; + } + + [$tableName] = explode(' ', $tableName); + + $info = $this->getSchemaInfo($tableName); + + return $fetch && array_key_exists($fetch, $info) ? $info[$fetch] : $info; + } + + /** + * 获取数据表的字段信息. + * + * @param string $tableName 数据表名 + * + * @return array + */ + public function getTableFieldsInfo(string $tableName): array + { + $fields = $this->getFields($tableName); + $info = []; + + foreach ($fields as $key => $val) { + // 记录字段类型 + $info[$key] = $this->getFieldType($val['type']); + + if (!empty($val['primary'])) { + $pk[] = $key; + } + + if (!empty($val['autoinc'])) { + $autoinc = $key; + } + } + + if (isset($pk)) { + // 设置主键 + $pk = count($pk) > 1 ? $pk : $pk[0]; + $info['_pk'] = $pk; + } + + if (isset($autoinc)) { + $info['_autoinc'] = $autoinc; + } + + return $info; + } + + /** + * 获取数据表的主键. + * + * @param mixed $tableName 数据表名 + * + * @return string|array + */ + public function getPk($tableName) + { + return $this->getTableInfo($tableName, 'pk'); + } + + /** + * 获取数据表的自增主键. + * + * @param mixed $tableName 数据表名 + * + * @return string|null + */ + public function getAutoInc($tableName) + { + return $this->getTableInfo($tableName, 'autoinc'); + } + + /** + * 获取数据表字段信息. + * + * @param mixed $tableName 数据表名 + * + * @return array + */ + public function getTableFields($tableName): array + { + return $this->getTableInfo($tableName, 'fields'); + } + + /** + * 获取数据表字段类型. + * + * @param mixed $tableName 数据表名 + * @param string $field 字段名 + * + * @return array|string + */ + public function getFieldsType($tableName, ?string $field = null) + { + $result = $this->getTableInfo($tableName, 'type'); + + if ($field && isset($result[$field])) { + return $result[$field]; + } + + return $result; + } + + /** + * 获取数据表绑定信息. + * + * @param mixed $tableName 数据表名 + * + * @return array + */ + public function getFieldsBind($tableName): array + { + return $this->getTableInfo($tableName, 'bind'); + } + + /** + * 连接数据库方法. + * + * @param array $config 连接参数 + * @param int $linkNum 连接序号 + * @param array|bool $autoConnection 是否自动连接主数据库(用于分布式) + * + * @throws PDOException + * + * @return PDO + */ + public function connect(array $config = [], $linkNum = 0, $autoConnection = false): PDO + { + if (isset($this->links[$linkNum])) { + return $this->links[$linkNum]; + } + + if (empty($config)) { + $config = $this->config; + } else { + $config = array_merge($this->config, $config); + } + + // 连接参数 + if (isset($config['params']) && is_array($config['params'])) { + $params = $config['params'] + $this->params; + } else { + $params = $this->params; + } + + // 记录当前字段属性大小写设置 + $this->attrCase = $params[PDO::ATTR_CASE]; + + if (!empty($config['break_match_str'])) { + $this->breakMatchStr = array_merge($this->breakMatchStr, (array) $config['break_match_str']); + } + + try { + if (empty($config['dsn'])) { + $config['dsn'] = $this->parseDsn($config); + } + + $startTime = microtime(true); + + $this->links[$linkNum] = $this->createPdo($config['dsn'], $config['username'], $config['password'], $params); + + // SQL监控 + if (!empty($config['trigger_sql'])) { + $this->trigger('CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']); + } + + return $this->links[$linkNum]; + } catch (\PDOException $e) { + if ($autoConnection) { + $this->db->log($e->getMessage(), 'error'); + + return $this->connect($autoConnection, $linkNum); + } else { + throw $e; + } + } + } + + /** + * 视图查询. + * + * @param array $args + * + * @return BaseQuery + */ + public function view(...$args) + { + return $this->newQuery()->view(...$args); + } + + /** + * 创建PDO实例. + * + * @param $dsn + * @param $username + * @param $password + * @param $params + * + * @return PDO + */ + protected function createPdo($dsn, $username, $password, $params) + { + return new PDO($dsn, $username, $password, $params); + } + + /** + * 释放查询结果. + */ + public function free(): void + { + $this->PDOStatement = null; + } + + /** + * 获取PDO对象 + * + * @return PDO|false + */ + public function getPdo() + { + if (!$this->linkID) { + return false; + } + + return $this->linkID; + } + + /** + * 执行查询 使用生成器返回数据. + * + * @param BaseQuery $query 查询对象 + * @param string $sql sql指令 + * @param Model|null $model 模型对象实例 + * + * @throws DbException + * + * @return \Generator + */ + public function getCursor(BaseQuery $query, string $sql, $model = null) + { + $this->queryPDOStatement($query, $sql); + + // 返回结果集 + while ($result = $this->PDOStatement->fetch($this->fetchType)) { + if ($model) { + yield $model->newInstance($result); + } else { + yield $result; + } + } + } + + /** + * 执行查询 返回数据集. + * + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @param bool $master 主库读取 + * + * @throws DbException + * + * @return array + */ + public function query(string $sql, array $bind = [], bool $master = false): array + { + $this->getPDOStatement($sql, $bind, $master); + return $this->getResult(); + } + + /** + * 执行语句. + * + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * + * @throws DbException + * + * @return int + */ + public function execute(string $sql, array $bind = []): int + { + $this->getPDOStatement($sql, $bind, true); + return $this->PDOStatement->rowCount(); + } + + /** + * 获取最近插入的ID. + * @param string $sequence 自增序列名 + * + * @return mixed + */ + public function getAutoID(?string $sequence = null) + { + try { + $insertId = $this->linkID->lastInsertId($sequence); + } catch (\Exception $e) { + $insertId = ''; + } + + return $insertId; + } + + /** + * 执行查询 返回数据集. + * + * @param BaseQuery $query 查询对象 + * @param mixed $sql sql指令 + * @param bool $master 主库读取 + * + * @throws DbException + * + * @return array + */ + protected function pdoQuery(BaseQuery $query, $sql, ?bool $master = null): array + { + // 分析查询表达式 + $query->parseOptions(); + $bind = $query->getBind(); + + if ($query->getOption('cache')) { + // 检查查询缓存 + $cacheItem = $this->parseCache($query, $query->getOption('cache')); + if (!$query->getOption('force_cache')) { + $key = $cacheItem->getKey(); + + if ($this->cache->has($key)) { + $data = $this->cache->get($key); + if (null !== $data && is_array($data)) { + return $data; + } + } + } + } + + if ($sql instanceof Closure) { + $sql = $sql($query); + $bind = array_merge($bind, $query->getBind()); + } + + if (!isset($master)) { + $master = (bool) $query->getOption('master'); + } + + $procedure = $query->getOption('procedure') || in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); + + $this->getPDOStatement($sql, $bind, $master, $procedure); + + $resultSet = $this->getResult($procedure); + $requireCache = $query->getOption('cache_always') || !empty($resultSet); + + if (isset($cacheItem) && $requireCache) { + // 缓存数据集 + $cacheItem->set($resultSet); + $this->cacheData($cacheItem); + } + + return $resultSet; + } + + /** + * 执行查询但只返回PDOStatement对象 + * + * @param BaseQuery $query 查询对象 + * + * @throws DbException + * + * @return \PDOStatement + */ + public function pdo(BaseQuery $query): PDOStatement + { + // 生成查询SQL + $sql = $this->builder->select($query); + + return $this->queryPDOStatement($query, $sql); + } + + /** + * 执行查询但只返回PDOStatement对象 + * + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @param bool $master 是否在主服务器读操作 + * @param bool $procedure 是否为存储过程调用 + * + * @throws DbException + * + * @return PDOStatement + */ + public function getPDOStatement(string $sql, array $bind = [], bool $master = false, bool $procedure = false): PDOStatement + { + try { + $this->initConnect($this->readMaster ?: $master); + // 记录SQL语句 + $this->queryStr = $sql; + $this->bind = $bind; + + $this->queryStartTime = microtime(true); + + // 预处理 + $this->PDOStatement = $this->linkID->prepare($sql); + + // 参数绑定 + if ($procedure) { + $this->bindParam($bind); + } else { + $this->bindValue($bind); + } + + // 执行查询 + $this->PDOStatement->execute(); + + // SQL监控 + if (!empty($this->config['trigger_sql'])) { + $this->trigger('', $master); + } + + $this->reConnectTimes = 0; + + return $this->PDOStatement; + } catch (\Throwable | \Exception $e) { + if ($this->transTimes > 0) { + // 事务活动中时不应该进行重试,应直接中断执行,防止造成污染。 + if ($this->isBreak($e)) { + // 尝试对事务计数进行重置 + $this->transTimes = 0; + } + } else { + if ($this->reConnectTimes < 4 && $this->isBreak($e)) { + $this->reConnectTimes++; + + return $this->close()->getPDOStatement($sql, $bind, $master, $procedure); + } + } + + if ($e instanceof \PDOException) { + if (str_contains($e->getMessage(),'1062 Duplicate entry')) { + throw new DuplicateException($e, $this->config, $this->getLastsql()); + } + throw new PDOException($e, $this->config, $this->getLastsql()); + } else { + throw $e; + } + } + } + + /** + * 执行语句. + * + * @param BaseQuery $query 查询对象 + * @param string $sql sql指令 + * @param bool $origin 是否原生查询 + * + * @throws DbException + * + * @return int + */ + protected function pdoExecute(BaseQuery $query, string $sql, bool $origin = false): int + { + if ($origin) { + $query->parseOptions(); + } + + $this->queryPDOStatement($query->master(true), $sql); + + if (!$origin && !empty($this->config['deploy']) && !empty($this->config['read_master'])) { + $this->readMaster = true; + } + + $this->numRows = $this->PDOStatement->rowCount(); + + if ($query->getOption('cache')) { + // 清理缓存数据 + $cacheItem = $this->parseCache($query, $query->getOption('cache')); + $key = $cacheItem->getKey(); + $tag = $cacheItem->getTag(); + + if (isset($key) && $this->cache->has($key)) { + $this->cache->delete($key); + } elseif (!empty($tag) && method_exists($this->cache, 'tag')) { + $this->cache->tag($tag)->clear(); + } + } + + return $this->numRows; + } + + /** + * @param BaseQuery $query + * @param string $sql + * + * @throws DbException + * + * @return PDOStatement + */ + protected function queryPDOStatement(BaseQuery $query, string $sql): PDOStatement + { + $options = $query->getOptions(); + $bind = $query->getBind(); + $master = !empty($options['master']); + $procedure = !empty($options['procedure']) || in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); + + return $this->getPDOStatement($sql, $bind, $master, $procedure); + } + + /** + * 查找单条记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws DbException + * + * @return array + */ + public function find(BaseQuery $query): array + { + // 事件回调 + try { + $this->db->trigger('before_find', $query); + } catch (DbEventException $e) { + return []; + } + + // 执行查询 + $resultSet = $this->pdoQuery($query, function ($query) { + return $this->builder->select($query, true); + }); + + return $resultSet[0] ?? []; + } + + /** + * 使用游标查询记录. + * + * @param BaseQuery $query 查询对象 + * + * @return \Generator + */ + public function cursor(BaseQuery $query) + { + // 分析查询表达式 + $options = $query->parseOptions(); + + // 生成查询SQL + $sql = $this->builder->select($query); + + // 执行查询操作 + return $this->getCursor($query, $sql, $query->getModel()); + } + + /** + * 查找记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws DbException + * + * @return array + */ + public function select(BaseQuery $query): array + { + try { + $this->db->trigger('before_select', $query); + } catch (DbEventException $e) { + return []; + } + + // 执行查询操作 + return $this->pdoQuery($query, function ($query) { + return $this->builder->select($query); + }); + } + + /** + * 插入记录. + * + * @param BaseQuery $query 查询对象 + * @param bool $getLastInsID 返回自增主键 + * + * @return mixed + */ + public function insert(BaseQuery $query, bool $getLastInsID = false) + { + // 分析查询表达式 + $options = $query->parseOptions(); + + // 生成SQL语句 + $sql = $this->builder->insert($query); + + // 执行操作 + $result = '' == $sql ? 0 : $this->pdoExecute($query, $sql); + + if ($result) { + $sequence = $options['sequence'] ?? null; + $lastInsId = $this->getLastInsID($query, $sequence); + + $data = $options['data']; + + if ($lastInsId) { + $pk = $query->getAutoInc(); + if ($pk && is_string($pk)) { + $data[$pk] = $lastInsId; + } + } + + $query->setOption('data', $data); + + $this->db->trigger('after_insert', $query); + + if ($getLastInsID && $lastInsId) { + return $lastInsId; + } + } + + return $result; + } + + /** + * 批量插入记录. + * + * @param BaseQuery $query 查询对象 + * @param array $dataSet 数据集 + * + * @throws \Exception + * @throws \Throwable + * + * @return int + */ + public function insertAll(BaseQuery $query, array $dataSet = []): int + { + if (!is_array(reset($dataSet))) { + return 0; + } + + $options = $query->parseOptions(); + + if (!empty($options['limit']) && is_numeric($options['limit'])) { + $limit = (int) $options['limit']; + } else { + $limit = 0; + } + + if (0 === $limit && count($dataSet) >= 5000) { + $limit = 1000; + } + + if ($limit) { + // 分批写入 自动启动事务支持 + $this->startTrans(); + + try { + $array = array_chunk($dataSet, $limit, true); + $count = 0; + + foreach ($array as $item) { + $sql = $this->builder->insertAll($query, $item); + $count += $this->pdoExecute($query, $sql); + } + + // 提交事务 + $this->commit(); + } catch (\Exception | \Throwable $e) { + $this->rollback(); + + throw $e; + } + + return $count; + } + + $sql = $this->builder->insertAll($query, $dataSet); + + return $this->pdoExecute($query, $sql); + } + + /** + * 批量插入记录. + * + * @param BaseQuery $query 查询对象 + * @param array $keys 键值 + * @param array $values 数据 + * + * @throws \Exception + * @throws \Throwable + * + * @return int + */ + public function insertAllByKeys(BaseQuery $query, array $keys, array $values): int + { + $options = $query->parseOptions(); + + if (!empty($options['limit']) && is_numeric($options['limit'])) { + $limit = (int) $options['limit']; + } else { + $limit = 0; + } + + if (0 === $limit && count($values) >= 5000) { + $limit = 1000; + } + + if ($limit) { + // 分批写入 自动启动事务支持 + $this->startTrans(); + + try { + $array = array_chunk($values, $limit, true); + $count = 0; + + foreach ($array as $item) { + $sql = $this->builder->insertAllByKeys($query, $keys, $item); + $count += $this->pdoExecute($query, $sql); + } + + // 提交事务 + $this->commit(); + } catch (\Exception | \Throwable $e) { + $this->rollback(); + + throw $e; + } + + return $count; + } + + $sql = $this->builder->insertAllByKeys($query, $keys, $values); + + return $this->pdoExecute($query, $sql); + } + + /** + * 通过Select方式插入记录. + * + * @param BaseQuery $query 查询对象 + * @param array $fields 要插入的数据表字段名 + * @param string $table 要插入的数据表名 + * + * @throws PDOException + * + * @return int + */ + public function selectInsert(BaseQuery $query, array $fields, string $table): int + { + // 分析查询表达式 + $query->parseOptions(); + + $sql = $this->builder->selectInsert($query, $fields, $table); + + return $this->pdoExecute($query, $sql); + } + + /** + * 更新记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws PDOException + * + * @return int + */ + public function update(BaseQuery $query): int + { + $query->parseOptions(); + + // 生成UPDATE SQL语句 + $sql = $this->builder->update($query); + + // 执行操作 + $result = '' == $sql ? 0 : $this->pdoExecute($query, $sql); + + if ($result) { + $this->db->trigger('after_update', $query); + } + + return $result; + } + + /** + * 删除记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws PDOException + * + * @return int + */ + public function delete(BaseQuery $query): int + { + // 分析查询表达式 + $query->parseOptions(); + + // 生成删除SQL语句 + $sql = $this->builder->delete($query); + + // 执行操作 + $result = $this->pdoExecute($query, $sql); + + if ($result) { + $this->db->trigger('after_delete', $query); + } + + return $result; + } + + /** + * 得到某个字段的值 + * + * @param BaseQuery $query 查询对象 + * @param string $field 字段名 + * @param mixed $default 默认值 + * @param bool $one 返回一个值 + * + * @return mixed + */ + public function value(BaseQuery $query, string $field, $default = null, bool $one = true) + { + $options = $query->parseOptions(); + + if (isset($options['field'])) { + $query->removeOption('field'); + } + + if (isset($options['group'])) { + $query->group(''); + } + + $query->setOption('field', (array) $field); + + if (!empty($options['cache'])) { + $cacheItem = $this->parseCache($query, $options['cache'], 'value'); + if (empty($options['force_cache'])) { + $key = $cacheItem->getKey(); + + if ($this->cache->has($key)) { + $data = $this->cache->get($key); + if (null !== $data) { + return $data; + } + } + } + } + + // 生成查询SQL + $sql = $this->builder->select($query, $one); + + if (isset($options['field'])) { + $query->setOption('field', $options['field']); + } else { + $query->removeOption('field'); + } + + if (isset($options['group'])) { + $query->setOption('group', $options['group']); + } + + // 执行查询操作 + $pdo = $this->getPDOStatement($sql, $query->getBind(), $options['master']); + + $result = $pdo->fetchColumn(); + $result = false !== $result ? $result : $default; + $requireCache = $query->getOption('cache_always') || !empty($result); + + if (isset($cacheItem) && $requireCache) { + // 缓存数据 + $cacheItem->set($result); + $this->cacheData($cacheItem); + } + + return $result; + } + + /** + * 得到某个字段的值 + * + * @param BaseQuery $query 查询对象 + * @param string $aggregate 聚合方法 + * @param string|Raw $field 字段名 + * @param bool $force 强制转为数字类型 + * + * @return mixed + */ + public function aggregate(BaseQuery $query, string $aggregate, string | Raw $field, bool $force = false) + { + if (is_string($field) && 0 === stripos($field, 'DISTINCT ')) { + [$distinct, $field] = explode(' ', $field); + } + + $field = $aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $this->builder->parseKey($query, $field, true) . ') AS think_' . strtolower($aggregate); + + $result = $this->value($query, $field, 0, false); + + return $force ? (float) $result : $result; + } + + /** + * 得到某个列的数组. + * + * @param BaseQuery $query 查询对象 + * @param string|array $column 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * + * @return array + */ + public function column(BaseQuery $query, string | array $column, string $key = ''): array + { + $options = $query->parseOptions(); + + if (isset($options['field'])) { + $query->removeOption('field'); + } + + if (empty($key) || trim($key) === '') { + $key = null; + } + + if (is_string($column)) { + $column = trim($column); + if ('*' !== $column) { + $column = array_map('trim', explode(',', $column)); + } + } elseif (in_array('*', $column)) { + $column = '*'; + } + + $field = $column; + if ('*' !== $column && $key && !in_array($key, $column)) { + $field[] = $key; + } + + $query->setOption('field', (array) $field); + + if (!empty($options['cache'])) { + // 判断查询缓存 + $cacheItem = $this->parseCache($query, $options['cache'], 'column'); + if (empty($options['force_cache'])) { + $name = $cacheItem->getKey(); + + if ($this->cache->has($name)) { + $data = $this->cache->get($name); + if (null !== $data) { + return $data; + } + } + } + } + + // 生成查询SQL + $sql = $this->builder->select($query); + + if (isset($options['field'])) { + $query->setOption('field', $options['field']); + } else { + $query->removeOption('field'); + } + + // 执行查询操作 + $pdo = $this->getPDOStatement($sql, $query->getBind(), $options['master']); + $resultSet = $pdo->fetchAll(PDO::FETCH_ASSOC); + + if (is_string($key) && str_contains($key, '.')) { + [$alias, $key] = explode('.', $key); + } + + if (empty($resultSet)) { + $result = []; + } elseif ('*' !== $column && count($column) === 1) { + $column = array_shift($column); + if (str_contains($column, ' ')) { + $column = substr(strrchr(trim($column), ' '), 1); + } + + if (str_contains($column, '.')) { + [$alias, $column] = explode('.', $column); + } + + if (str_contains($column, '->')) { + $column = $this->builder->parseKey($query, $column); + } + + $result = array_column($resultSet, $column, $key); + } elseif ($key) { + $result = array_column($resultSet, null, $key); + } else { + $result = $resultSet; + } + + $requireCache = $query->getOption('cache_always') || !empty($result); + + if (isset($cacheItem) && $requireCache) { + // 缓存数据 + $cacheItem->set($result); + $this->cacheData($cacheItem); + } + + return $result; + } + + /** + * 参数绑定 + * 支持 ['name'=>'value','id'=>123] 对应命名占位符 + * 或者 ['value',123] 对应问号占位符. + * + * @param array $bind 要绑定的参数列表 + * + * @throws BindParamException + * + * @return void + */ + protected function bindValue(array $bind = []): void + { + foreach ($bind as $key => $val) { + // 占位符 + $param = is_numeric($key) ? $key + 1 : ':' . $key; + + if (is_array($val)) { + if (self::PARAM_INT == $val[1]) { + $val[0] = (int) $val[0]; + } elseif (self::PARAM_FLOAT == $val[1]) { + $val[0] = is_string($val[0]) ? (float) $val[0] : $val[0]; + $val[1] = self::PARAM_STR; + } + + $result = $this->PDOStatement->bindValue($param, $val[0], $val[1]); + } else { + $result = $this->PDOStatement->bindValue($param, $val); + } + + if (!$result) { + throw new BindParamException( + "Error occurred when binding parameters '{$param}'", + $this->config, + $this->getLastsql(), + $bind + ); + } + } + } + + /** + * 存储过程的输入输出参数绑定. + * + * @param array $bind 要绑定的参数列表 + * + * @throws BindParamException + * + * @return void + */ + protected function bindParam(array $bind): void + { + foreach ($bind as $key => $val) { + $param = is_numeric($key) ? $key + 1 : ':' . $key; + + if (is_array($val)) { + array_unshift($val, $param); + $result = call_user_func_array([$this->PDOStatement, 'bindParam'], $val); + } else { + $result = $this->PDOStatement->bindValue($param, $val); + } + + if (!$result) { + $param = array_shift($val); + + throw new BindParamException( + "Error occurred when binding parameters '{$param}'", + $this->config, + $this->getLastsql(), + $bind + ); + } + } + } + + /** + * 获得数据集数组. + * + * @param bool $procedure 是否存储过程 + * + * @return array + */ + protected function getResult(bool $procedure = false): array + { + if ($procedure) { + // 存储过程返回结果 + return $this->procedure(); + } + + $result = $this->PDOStatement->fetchAll($this->fetchType); + + $this->numRows = count($result); + + return $result; + } + + /** + * 获得存储过程数据集. + * + * @return array + */ + protected function procedure(): array + { + $item = []; + + do { + $result = $this->getResult(); + if (!empty($result)) { + $item[] = $result; + } + } while ($this->PDOStatement->nextRowset()); + + $this->numRows = count($item); + + return $item; + } + + /** + * 执行数据库事务 + * + * @param callable $callback 数据操作方法回调 + * + * @throws PDOException + * @throws \Exception + * @throws \Throwable + * + * @return mixed + */ + public function transaction(callable $callback) + { + $this->startTrans(); + + try { + $result = $callback($this); + + $this->commit(); + + return $result; + } catch (\Exception | \Throwable $e) { + $this->rollback(); + + throw $e; + } + } + + /** + * 启动事务 + * + * @throws \PDOException + * @throws \Exception + * + * @return void + */ + public function startTrans(): void + { + try { + $this->initConnect(true); + + if (0 == $this->transTimes) { + $this->linkID->beginTransaction(); + } elseif ($this->transTimes > 0 && $this->supportSavepoint() && $this->linkID->inTransaction()) { + $this->linkID->exec( + $this->parseSavepoint('trans' . ($this->transTimes + 1)) + ); + } + $this->transTimes++; + $this->reConnectTimes = 0; + } catch (\Throwable | \Exception $e) { + if (0 === $this->transTimes && $this->reConnectTimes < 4 && $this->isBreak($e)) { + $this->reConnectTimes++; + $this->close()->startTrans(); + } else { + if ($this->isBreak($e)) { + // 尝试对事务计数进行重置 + $this->transTimes = 0; + } + + throw $e; + } + } + } + + /** + * 用于非自动提交状态下面的查询提交. + * + * @throws \PDOException + * + * @return void + */ + public function commit(): void + { + $this->initConnect(true); + $this->transTimes = max(0, $this->transTimes - 1); + + if (0 == $this->transTimes && $this->linkID->inTransaction()) { + $this->linkID->commit(); + } + } + + /** + * 事务回滚. + * + * @throws \PDOException + * + * @return void + */ + public function rollback(): void + { + $this->initConnect(true); + $this->transTimes = max(0, $this->transTimes - 1); + + if ($this->linkID->inTransaction()) { + if (0 == $this->transTimes) { + $this->linkID->rollBack(); + } elseif ($this->transTimes > 0 && $this->supportSavepoint()) { + $this->linkID->exec( + $this->parseSavepointRollBack('trans' . ($this->transTimes + 1)) + ); + } + } + } + + /** + * 是否支持事务嵌套. + * + * @return bool + */ + protected function supportSavepoint(): bool + { + return false; + } + + /** + * 生成定义保存点的SQL. + * + * @param string $name 标识 + * + * @return string + */ + protected function parseSavepoint(string $name): string + { + return 'SAVEPOINT ' . $name; + } + + /** + * 生成回滚到保存点的SQL. + * + * @param string $name 标识 + * + * @return string + */ + protected function parseSavepointRollBack(string $name): string + { + return 'ROLLBACK TO SAVEPOINT ' . $name; + } + + /** + * 批处理执行SQL语句 + * 批处理的指令都认为是execute操作. + * + * @param array $sqlArray SQL批处理指令 + * + * @return bool + */ + public function batchQuery(array $sqlArray = []): bool + { + // 自动启动事务支持 + $this->startTrans(); + + try { + foreach ($sqlArray as $sql) { + $this->execute($sql); + } + // 提交事务 + $this->commit(); + } catch (\Exception $e) { + $this->rollback(); + + throw $e; + } + + return true; + } + + /** + * 关闭数据库(或者重新连接). + * + * @return $this + */ + public function close() + { + $this->linkID = null; + $this->linkWrite = null; + $this->linkRead = null; + $this->links = []; + $this->transTimes = 0; + + $this->free(); + + return $this; + } + + /** + * 是否断线 + * + * @param \PDOException|\Exception $e 异常对象 + * + * @return bool + */ + protected function isBreak($e): bool + { + if (!$this->config['break_reconnect']) { + return false; + } + + $error = $e->getMessage(); + + foreach ($this->breakMatchStr as $msg) { + if (false !== stripos($error, $msg)) { + return true; + } + } + + return false; + } + + /** + * 获取最近一次查询的sql语句. + * + * @return string + */ + public function getLastSql(): string + { + return $this->getRealSql($this->queryStr, $this->bind); + } + + /** + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 + * @param string $sequence 自增序列名 + * + * @return mixed + */ + public function getLastInsID(BaseQuery $query, ?string $sequence = null) + { + return $this->autoInsIDType($query, $this->getAutoID($sequence)); + } + + /** + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 + * @param string $insertId 自增ID + * + * @return mixed + */ + protected function autoInsIDType(BaseQuery $query, string $insertId) + { + $pk = $query->getAutoInc(); + + if ($pk && is_string($pk)) { + $type = $this->getFieldsBind($query->getTable())[$pk]; + + if (self::PARAM_INT == $type) { + $insertId = (int) $insertId; + } elseif (self::PARAM_FLOAT == $type) { + $insertId = (float) $insertId; + } + } + + return $insertId; + } + + /** + * 获取最近的错误信息. + * + * @return string + */ + public function getError(): string + { + if ($this->PDOStatement) { + $error = $this->PDOStatement->errorInfo(); + $error = $error[1] . ':' . $error[2]; + } else { + $error = ''; + } + + if ('' != $this->queryStr) { + $error .= "\n [ SQL语句 ] : " . $this->getLastsql(); + } + + return $error; + } + + /** + * 初始化数据库连接. + * + * @param bool $master 是否主服务器 + * + * @return void + */ + protected function initConnect(bool $master = true): void + { + if (!empty($this->config['deploy'])) { + // 采用分布式数据库 + if ($master || $this->transTimes) { + if (!$this->linkWrite) { + $this->linkWrite = $this->multiConnect(true); + } + + $this->linkID = $this->linkWrite; + } else { + if (!$this->linkRead) { + $this->linkRead = $this->multiConnect(false); + } + + $this->linkID = $this->linkRead; + } + } elseif (!$this->linkID) { + // 默认单数据库 + $this->linkID = $this->connect(); + } + } + + /** + * 连接分布式服务器. + * + * @param bool $master 主服务器 + * + * @return PDO + */ + protected function multiConnect(bool $master = false): PDO + { + $config = []; + + // 分布式数据库配置解析 + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn', 'charset'] as $name) { + $config[$name] = is_string($this->config[$name]) ? explode(',', $this->config[$name]) : $this->config[$name]; + } + + // 主服务器序号 + $m = floor(mt_rand(0, $this->config['master_num'] - 1)); + + if ($this->config['rw_separate']) { + // 主从式采用读写分离 + if ($master) { + // 主服务器写入 + $r = $m; + } elseif (is_numeric($this->config['slave_no'])) { + // 指定服务器读 + $r = $this->config['slave_no']; + } else { + // 读操作连接从服务器 每次随机连接的数据库 + $r = floor(mt_rand($this->config['master_num'], count($config['hostname']) - 1)); + } + } else { + // 读写操作不区分服务器 每次随机连接的数据库 + $r = floor(mt_rand(0, count($config['hostname']) - 1)); + } + $dbMaster = false; + + if ($m != $r) { + $dbMaster = []; + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn', 'charset'] as $name) { + $dbMaster[$name] = $config[$name][$m] ?? $config[$name][0]; + } + } + + $dbConfig = []; + + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn', 'charset'] as $name) { + $dbConfig[$name] = $config[$name][$r] ?? $config[$name][0]; + } + + return $this->connect($dbConfig, $r, $r == $m ? false : $dbMaster); + } + + /** + * 获取数据库的唯一标识. + * + * @param string $suffix 标识后缀 + * + * @return string + */ + public function getUniqueXid(string $suffix = ''): string + { + return $this->config['hostname'] . '_' . $this->config['database'] . $suffix; + } + + /** + * 执行数据库Xa事务 + * + * @param callable $callback 数据操作方法回调 + * @param array $dbs 多个查询对象或者连接对象 + * + * @throws PDOException + * @throws \Exception + * @throws \Throwable + * + * @return mixed + */ + public function transactionXa(callable $callback, array $dbs = []) + { + $xid = uniqid('xa'); + + if (empty($dbs)) { + $dbs[] = $this; + } + + foreach ($dbs as $key => $db) { + if ($db instanceof BaseQuery) { + $db = $db->getConnection(); + + $dbs[$key] = $db; + } + + $db->startTransXa($db->getUniqueXid('_' . $xid)); + } + + try { + $result = $callback($this); + + foreach ($dbs as $db) { + $db->prepareXa($db->getUniqueXid('_' . $xid)); + } + + foreach ($dbs as $db) { + $db->commitXa($db->getUniqueXid('_' . $xid)); + } + + return $result; + } catch (\Exception | \Throwable $e) { + foreach ($dbs as $db) { + $db->rollbackXa($db->getUniqueXid('_' . $xid)); + } + + throw $e; + } + } + + /** + * 启动XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function startTransXa(string $xid): void + { + } + + /** + * 预编译XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function prepareXa(string $xid): void + { + } + + /** + * 提交XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function commitXa(string $xid): void + { + } + + /** + * 回滚XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function rollbackXa(string $xid): void + { + } +} diff --git a/vendor/topthink/think-orm/src/db/Query.php b/vendor/topthink/think-orm/src/db/Query.php new file mode 100644 index 0000000..5300bf7 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Query.php @@ -0,0 +1,648 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db; + +use PDOStatement; +use think\db\exception\DbException as Exception; + +/** + * PDO数据查询类. + */ +class Query extends BaseQuery +{ + use concern\JoinAndViewQuery; + use concern\TableFieldInfo; + use concern\Transaction; + + /** + * 表达式方式指定Field排序. + * + * @param string $field 排序字段 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function orderRaw(string $field, array $bind = []) + { + $this->options['order'][] = new Raw($field, $bind); + + return $this; + } + + /** + * 表达式方式指定查询字段. + * + * @param string $field 字段名 + * + * @return $this + */ + public function fieldRaw(string $field) + { + $this->options['field'][] = new Raw($field); + + return $this; + } + + /** + * 指定Field排序 orderField('id',[1,2,3],'desc'). + * + * @param string $field 排序字段 + * @param array $values 排序值 + * @param string $order 排序 desc/asc + * + * @return $this + */ + public function orderField(string $field, array $values, string $order = '') + { + if (!empty($values)) { + $values['sort'] = $order; + + $this->options['order'][$field] = $values; + } + + return $this; + } + + /** + * 随机排序. + * + * @return $this + */ + public function orderRand() + { + $this->options['order'][] = '[rand]'; + + return $this; + } + + /** + * 使用表达式设置数据. + * + * @param string $field 字段名 + * @param string $value 字段值 + * + * @return $this + */ + public function exp(string $field, string $value) + { + $this->options['data'][$field] = new Raw($value); + + return $this; + } + + /** + * 表达式方式指定当前操作的数据表. + * + * @param mixed $table 表名 + * + * @return $this + */ + public function tableRaw(string $table) + { + $this->options['table'] = new Raw($table); + + return $this; + } + + /** + * 获取执行的SQL语句而不进行实际的查询. + * + * @param bool $fetch 是否返回sql + * + * @return $this|Fetch + */ + public function fetchSql(bool $fetch = true) + { + $this->options['fetch_sql'] = $fetch; + + if ($fetch) { + return new Fetch($this); + } + + return $this; + } + + /** + * 批处理执行SQL语句 + * 批处理的指令都认为是execute操作. + * + * @param array $sql SQL批处理指令 + * + * @return bool + */ + public function batchQuery(array $sql = []): bool + { + return $this->connection->batchQuery($sql); + } + + /** + * USING支持 用于多表删除. + * + * @param mixed $using USING + * + * @return $this + */ + public function using($using) + { + $this->options['using'] = $using; + + return $this; + } + + /** + * 存储过程调用. + * + * @param bool $procedure 是否为存储过程查询 + * + * @return $this + */ + public function procedure(bool $procedure = true) + { + $this->options['procedure'] = $procedure; + + return $this; + } + + /** + * 指定group查询. + * + * @param string|array $group GROUP + * + * @return $this + */ + public function group($group) + { + $this->options['group'] = $group; + + return $this; + } + + /** + * 指定having查询. + * + * @param string $having having + * + * @return $this + */ + public function having(string $having) + { + $this->options['having'] = $having; + + return $this; + } + + /** + * 指定distinct查询. + * + * @param bool $distinct 是否唯一 + * + * @return $this + */ + public function distinct(bool $distinct = true) + { + $this->options['distinct'] = $distinct; + + return $this; + } + + /** + * 指定强制索引. + * + * @param string $force 索引名称 + * + * @return $this + */ + public function force(string $force) + { + $this->options['force'] = $force; + + return $this; + } + + /** + * 查询注释. + * + * @param string $comment 注释 + * + * @return $this + */ + public function comment(string $comment) + { + $this->options['comment'] = $comment; + + return $this; + } + + /** + * 设置是否REPLACE. + * + * @param bool $replace 是否使用REPLACE写入数据 + * + * @return $this + */ + public function replace(bool $replace = true) + { + $this->options['replace'] = $replace; + + return $this; + } + + /** + * 设置当前查询所在的分区. + * + * @param string|array $partition 分区名称 + * + * @return $this + */ + public function partition($partition) + { + $this->options['partition'] = $partition; + + return $this; + } + + /** + * 设置DUPLICATE. + * + * @param array|string|Raw $duplicate DUPLICATE信息 + * + * @return $this + */ + public function duplicate($duplicate) + { + $this->options['duplicate'] = $duplicate; + + return $this; + } + + /** + * 设置查询的额外参数. + * + * @param string $extra 额外信息 + * + * @return $this + */ + public function extra(string $extra) + { + $this->options['extra'] = $extra; + + return $this; + } + + /** + * 创建子查询SQL. + * + * @param bool $sub 是否添加括号 + * + * @throws Exception + * + * @return string + */ + public function buildSql(bool $sub = true): string + { + return $sub ? '( ' . $this->fetchSql()->select() . ' )' : $this->fetchSql()->select(); + } + + /** + * 获取当前数据表的主键. + * + * @return string|array|null + */ + public function getPk() + { + if (empty($this->pk)) { + $this->pk = $this->connection->getPk($this->getTable()); + } + + return $this->pk; + } + + /** + * 指定数据表自增主键. + * + * @param string $autoinc 自增键 + * + * @return $this + */ + public function autoinc(?string $autoinc) + { + $this->autoinc = $autoinc; + + return $this; + } + + /** + * 获取当前数据表的自增主键. + * + * @return string|null + */ + public function getAutoInc() + { + $tableName = $this->getTable(); + + if (empty($this->autoinc) && $tableName) { + $this->autoinc = $this->connection->getAutoInc($tableName); + } + + return $this->autoinc; + } + + /** + * 字段值增长 + * + * @param string $field 字段名 + * @param float|int $step 增长值 + * @param int $lazyTime 延迟时间(秒) + * + * @return $this + */ + public function inc(string $field, float|int $step = 1, int $lazyTime = 0) + { + if ($lazyTime > 0) { + $step = $this->lazyWrite($field, 'inc', $step, $lazyTime); + if (false === $step) { + return $this; + } + } + + $this->options['data'][$field] = new Express('+', $step); + + return $this; + } + + /** + * 字段值减少. + * + * @param string $field 字段名 + * @param float|int $step 增长值 + * @param int $lazyTime 延迟时间(秒) + * + * @return $this + */ + public function dec(string $field, float|int $step = 1, int $lazyTime = 0) + { + if ($lazyTime > 0) { + $step = $this->lazyWrite($field, 'dec', $step, $lazyTime); + if (false === $step) { + return $this; + } + return $this->inc($field, $step); + } + + $this->options['data'][$field] = new Express('-', $step); + + return $this; + } + + /** + * 字段值增长(支持延迟写入) + * + * @param string $field 字段名 + * @param float|int $step 步进值 + * @param int $lazyTime 延迟时间(秒) + * + * @return int|false + */ + public function setInc(string $field, float|int $step = 1, int $lazyTime = 0) + { + return $this->inc($field, $step, $lazyTime)->update(); + } + + /** + * 字段值减少(支持延迟写入) + * + * @param string $field 字段名 + * @param float|int $step 步进值 + * @param int $lazyTime 延迟时间(秒) + * + * @return int|false + */ + public function setDec(string $field, float|int $step = 1, int $lazyTime = 0) + { + return $this->dec($field, $step, $lazyTime)->update(); + } + + /** + * 延时更新检查 返回false表示需要延时 + * 否则返回实际写入的数值 + * @access public + * @param string $field 字段名 + * @param string $type 自增或者自减 + * @param float|int $step 写入步进值 + * @param int $lazyTime 延时时间(s) + * @return false|integer + */ + public function lazyWrite(string $field, string $type, float|int $step, int $lazyTime) + { + $guid = $this->getLazyFieldCacheKey($field); + $cache = $this->getCache(); + if (!$cache->has($guid . '_time')) { + // 计时开始 + $cache->set($guid . '_time', time()); + $cache->$type($guid, $step); + } elseif (time() > $cache->get($guid . '_time') + $lazyTime) { + // 删除缓存 + $value = $cache->$type($guid, $step); + $cache->delete($guid); + $cache->delete($guid . '_time'); + return 0 === $value ? false : $value; + } else { + // 更新缓存 + $cache->$type($guid, $step); + } + + return false; + } + + /** + * 获取延迟写入字段值. + * + * @param string $field 字段名称 + * @param mixed $id 主键值 + * + * @return int + */ + protected function getLazyFieldValue(string $field, $id = null): int + { + return (int) $this->getCache()->get($this->getLazyFieldCacheKey($field, $id)); + } + + /** + * 获取延迟写入字段的缓存Key + * + * @param string $field 字段名 + * @param mixed $id 主键值 + * + * @return string + */ + protected function getLazyFieldCacheKey(string $field, $id = null): string + { + return 'lazy_' . $this->getTable() . '_' . $field . '_' . ($id ?: $this->getKey()); + } + + /** + * 执行查询但只返回PDOStatement对象 + * + * @return PDOStatement + */ + public function getPdo(): PDOStatement + { + return $this->connection->pdo($this); + } + + /** + * 使用游标查找记录. + * + * @param mixed $data 数据 + * + * @return \Generator + */ + public function cursor($data = null) + { + if (!is_null($data)) { + // 主键条件分析 + $this->parsePkWhere($data); + } + + $this->options['data'] = $data; + + $connection = clone $this->connection; + + return $connection->cursor($this); + } + + /** + * 分批数据返回处理. + * + * @param int $count 每次处理的数据数量 + * @param callable $callback 处理回调方法 + * @param string|array|null $column 分批处理的字段名 + * @param string $order 字段排序 + * + * @throws Exception + * + * @return bool + */ + public function chunk(int $count, callable $callback, string | array | null $column = null, string $order = 'asc'): bool + { + if ($count < 1) { + throw new Exception('The chunk size should be at least 1'); + } + + $options = $this->getOptions(); + $column = $column ?: $this->getPk(); + + if (isset($options['order'])) { + unset($options['order']); + } + + $bind = $this->bind; + + if (is_array($column)) { + $times = 1; + $query = $this->options($options)->page($times, $count); + } else { + $query = $this->options($options)->limit($count); + + if (str_contains($column, '.')) { + [$alias, $key] = explode('.', $column); + } else { + $key = $column; + } + } + + $resultSet = $query->order($column, $order)->select(); + + while (true) { + if (false === call_user_func($callback, $resultSet)) { + return false; + } + + if (count($resultSet) < $count) { + break; + } + + if (isset($times)) { + $times++; + $query = $this->options($options)->page($times, $count); + } else { + $end = $resultSet->pop(); + $lastId = is_array($end) ? $end[$key] : $end->getData($key); + + $query = $this->options($options) + ->limit($count) + ->where($column, 'asc' == strtolower($order) ? '>' : '<', $lastId); + } + + $resultSet = $query->bind($bind)->order($column, $order)->select(); + } + + return true; + } + + /** + * 惰性分批遍历数据 + * @param int $count 每批处理的数量 + * @param string|null $column 分批处理的字段名 + * @param string $order 字段排序 + * @return \Generator + */ + public function lazy(int $count = 1000, ?string $column = null, string $order = 'desc') + { + if ($count < 1) { + throw new Exception('The chunk size should be at least 1'); + } + + $limit = (int) $this->getOption('limit', 0); + $column = $column ?: $this->getPk(); + $length = $limit && $count >= $limit ? $limit : $count; + $options = $this->getOptions(); + $bind = $this->bind; + $times = 0; + if ($this->getOption('order') || is_array($column)) { + $page = 1; + $resultSet = $this->options($options)->page($page, $length)->select(); + } else { + $resultSet = $this->options($options)->order($column, $order)->limit($length)->select(); + } + + while (true) { + foreach ($resultSet as $item) { + yield $item; + $times++; + if ($limit > $count && $times >= $limit) { + break 2; + } + if (!isset($page)) { + $lastId = $item[$column]; + } + } + + if (count($resultSet) < $count) { + break; + } + + if (isset($page)) { + $page++; + $query = $this->options($options)->page($page, $length); + } else { + $query = $this->options($options) + ->where($column, 'asc' == strtolower($order) ? '>' : '<', $lastId) + ->order($column, $order) + ->limit($length); + } + $resultSet = $query->bind($bind)->select(); + }; + } +} diff --git a/vendor/topthink/think-orm/src/db/Raw.php b/vendor/topthink/think-orm/src/db/Raw.php new file mode 100644 index 0000000..ba28d29 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Raw.php @@ -0,0 +1,54 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db; + +use Stringable; + +/** + * SQL Raw. + */ +class Raw +{ + /** + * 创建一个查询表达式. + * + * @param string|Stringable $value + * @param array $bind + * + * @return void + */ + public function __construct(protected string|Stringable $value, protected array $bind = []) + { + } + + /** + * 获取表达式. + * + * @return string + */ + public function getValue(): string + { + return $this->value; + } + + /** + * 获取参数绑定. + * + * @return array + */ + public function getBind(): array + { + return $this->bind; + } +} diff --git a/vendor/topthink/think-orm/src/db/Where.php b/vendor/topthink/think-orm/src/db/Where.php new file mode 100644 index 0000000..aab7b6b --- /dev/null +++ b/vendor/topthink/think-orm/src/db/Where.php @@ -0,0 +1,175 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db; + +use ArrayAccess; + +/** + * 数组查询对象 + */ +class Where implements ArrayAccess +{ + /** + * 创建一个查询表达式. + * + * @param array $where 查询条件数组 + * @param bool $enclose 是否增加括号 + */ + public function __construct(protected array $where = [], protected bool $enclose = false) + { + } + + /** + * 设置是否添加括号. + * + * @param bool $enclose + * + * @return $this + */ + public function enclose(bool $enclose = true) + { + $this->enclose = $enclose; + + return $this; + } + + /** + * 解析为Query对象可识别的查询条件数组. + * + * @return array + */ + public function parse(): array + { + $where = []; + + foreach ($this->where as $key => $val) { + if ($val instanceof Raw) { + $where[] = [$key, 'exp', $val]; + } elseif (is_null($val)) { + $where[] = [$key, 'NULL', '']; + } elseif (is_array($val)) { + $where[] = $this->parseItem($key, $val); + } else { + $where[] = [$key, '=', $val]; + } + } + + return $this->enclose ? [$where] : $where; + } + + /** + * 分析查询表达式. + * + * @param string $field 查询字段 + * @param array $where 查询条件 + * + * @return array + */ + protected function parseItem(string $field, array $where = []): array + { + $op = $where[0]; + $condition = $where[1] ?? null; + + if (is_array($op)) { + // 同一字段多条件查询 + array_unshift($where, $field); + } elseif (is_null($condition)) { + if (is_string($op) && in_array(strtoupper($op), ['NULL', 'NOTNULL', 'NOT NULL'], true)) { + // null查询 + $where = [$field, $op, '']; + } elseif (is_null($op) || '=' == $op) { + $where = [$field, 'NULL', '']; + } elseif ('<>' == $op) { + $where = [$field, 'NOTNULL', '']; + } else { + // 字段相等查询 + $where = [$field, '=', $op]; + } + } else { + $where = [$field, $op, $condition]; + } + + return $where; + } + + /** + * 修改器 设置数据对象的值 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return void + */ + public function __set($name, $value) + { + $this->where[$name] = $value; + } + + /** + * 获取器 获取数据对象的值 + * + * @param string $name 名称 + * + * @return mixed + */ + public function __get($name) + { + return $this->where[$name] ?? null; + } + + /** + * 检测数据对象的值 + * + * @param string $name 名称 + * + * @return bool + */ + public function __isset($name) + { + return isset($this->where[$name]); + } + + /** + * 销毁数据对象的值 + * + * @param string $name 名称 + * + * @return void + */ + public function __unset($name) + { + unset($this->where[$name]); + } + + // ArrayAccess + public function offsetSet(mixed $name, mixed $value): void + { + $this->__set($name, $value); + } + + public function offsetExists(mixed $name): bool + { + return $this->__isset($name); + } + + public function offsetUnset(mixed $name): void + { + $this->__unset($name); + } + + public function offsetGet(mixed $name): mixed + { + return $this->__get($name); + } +} diff --git a/vendor/topthink/think-orm/src/db/builder/Mongo.php b/vendor/topthink/think-orm/src/db/builder/Mongo.php new file mode 100644 index 0000000..d2c98d8 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/builder/Mongo.php @@ -0,0 +1,692 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\builder; + +use Closure; +use MongoDB\BSON\Javascript; +use MongoDB\BSON\ObjectID; +use MongoDB\BSON\Regex; +use MongoDB\Driver\BulkWrite; +use MongoDB\Driver\Command; +use MongoDB\Driver\Exception\InvalidArgumentException; +use MongoDB\Driver\Query as MongoQuery; +use think\db\connector\Mongo as Connection; +use think\db\exception\DbException as Exception; +use think\db\Mongo as Query; + +class Mongo +{ + // connection对象实例 + protected $connection; + // 最后插入ID + protected $insertId = []; + // 查询表达式 + protected $exp = ['<>' => 'ne', '=' => 'eq', '>' => 'gt', '>=' => 'gte', '<' => 'lt', '<=' => 'lte', 'in' => 'in', 'not in' => 'nin', 'nin' => 'nin', 'mod' => 'mod', 'exists' => 'exists', 'null' => 'null', 'notnull' => 'not null', 'not null' => 'not null', 'regex' => 'regex', 'type' => 'type', 'all' => 'all', '> time' => '> time', '< time' => '< time', 'between' => 'between', 'not between' => 'not between', 'between time' => 'between time', 'not between time' => 'not between time', 'notbetween time' => 'not between time', 'like' => 'like', 'near' => 'near', 'size' => 'size']; + + /** + * 架构函数. + * + * @param Connection $connection 数据库连接对象实例 + */ + public function __construct(Connection $connection) + { + $this->connection = $connection; + } + + /** + * 获取当前的连接对象实例. + * + * @return Connection + */ + public function getConnection(): Connection + { + return $this->connection; + } + + /** + * key分析. + * + * @param string $key + * + * @return string + */ + protected function parseKey(Query $query, string $key): string + { + if (str_starts_with($key, '__TABLE__.')) { + [$collection, $key] = explode('.', $key, 2); + } + + if ('id' == $key && $this->connection->getConfig('pk_convert_id')) { + $key = '_id'; + } + + return trim($key); + } + + /** + * value分析. + * + * @param Query $query 查询对象 + * @param mixed $value + * @param string $field + * + * @return string + */ + protected function parseValue(Query $query, $value, $field = '') + { + if ('_id' == $field && 'ObjectID' == $this->connection->getConfig('pk_type') && is_string($value)) { + try { + return new ObjectID($value); + } catch (InvalidArgumentException $e) { + return new ObjectID(); + } + } + + return $value; + } + + /** + * insert数据分析. + * + * @param Query $query 查询对象 + * @param array $data 数据 + * + * @return array + */ + protected function parseData(Query $query, array $data): array + { + if (empty($data)) { + return []; + } + + $result = []; + + foreach ($data as $key => $val) { + $item = $this->parseKey($query, $key); + + if (is_object($val)) { + $result[$item] = $val; + } elseif (isset($val[0]) && 'exp' == $val[0]) { + $result[$item] = $val[1]; + } else { + $result[$item] = $this->parseValue($query, $val, $key); + } + } + + return $result; + } + + /** + * Set数据分析. + * + * @param Query $query 查询对象 + * @param array $data 数据 + * + * @return array + */ + protected function parseSet(Query $query, array $data): array + { + if (empty($data)) { + return []; + } + + $result = []; + + foreach ($data as $key => $val) { + $item = $this->parseKey($query, $key); + + if (is_array($val) && isset($val[0]) && is_string($val[0]) && str_starts_with($val[0], '$')) { + $result[$val[0]][$item] = $this->parseValue($query, $val[1], $key); + } else { + $result['$set'][$item] = $this->parseValue($query, $val, $key); + } + } + + return $result; + } + + /** + * 生成查询过滤条件. + * + * @param Query $query 查询对象 + * @param mixed $where + * + * @return array + */ + public function parseWhere(Query $query, array $where): array + { + if (empty($where)) { + $where = []; + } + + $filter = []; + foreach ($where as $logic => $val) { + $logic = '$'.strtolower($logic); + foreach ($val as $field => $value) { + if (is_array($value)) { + if (key($value) !== 0) { + throw new Exception('where express error:'.var_export($value, true)); + } + $field = array_shift($value); + } elseif (!($value instanceof Closure)) { + throw new Exception('where express error:'.var_export($value, true)); + } + + if ($value instanceof Closure) { + // 使用闭包查询 + $query = new Query($this->connection); + call_user_func_array($value, [&$query]); + $filter[$logic][] = $this->parseWhere($query, $query->getOption('where')); + } else { + if (str_contains($field, '|')) { + // 不同字段使用相同查询条件(OR) + $array = explode('|', $field); + foreach ($array as $k) { + $filter['$or'][] = $this->parseWhereItem($query, $k, $value); + } + } elseif (str_contains($field, '&')) { + // 不同字段使用相同查询条件(AND) + $array = explode('&', $field); + foreach ($array as $k) { + $filter['$and'][] = $this->parseWhereItem($query, $k, $value); + } + } else { + // 对字段使用表达式查询 + $field = is_string($field) ? $field : ''; + $filter[$logic][] = $this->parseWhereItem($query, $field, $value); + } + } + } + } + + $options = $query->getOptions(); + if (!empty($options['soft_delete'])) { + // 附加软删除条件 + [$field, $condition] = $options['soft_delete']; + $filter['$and'][] = $this->parseWhereItem($query, $field, $condition); + } + + return $filter; + } + + // where子单元分析 + protected function parseWhereItem(Query $query, $field, $val): array + { + $key = $field ? $this->parseKey($query, $field) : ''; + // 查询规则和条件 + if (!is_array($val)) { + $val = ['=', $val]; + } + [$exp, $value] = $val; + + // 对一个字段使用多个查询条件 + if (is_array($exp)) { + $data = []; + foreach ($val as $value) { + $exp = $value[0]; + $value = $value[1]; + if (!in_array($exp, $this->exp)) { + $exp = strtolower($exp); + if (isset($this->exp[$exp])) { + $exp = $this->exp[$exp]; + } + } + $k = '$'.$exp; + $data[$k] = $value; + } + $result[$key] = $data; + + return $result; + } elseif (!in_array($exp, $this->exp)) { + $exp = strtolower($exp); + if (isset($this->exp[$exp])) { + $exp = $this->exp[$exp]; + } else { + throw new Exception('where express error:'.$exp); + } + } + + $result = []; + if ('=' == $exp) { + // 普通查询 + $result[$key] = $this->parseValue($query, $value, $key); + } elseif (in_array($exp, ['neq', 'ne', 'gt', 'egt', 'gte', 'lt', 'lte', 'elt', 'mod'])) { + // 比较运算 + $k = '$'.$exp; + $result[$key] = [$k => $this->parseValue($query, $value, $key)]; + } elseif ('null' == $exp) { + // NULL 查询 + $result[$key] = null; + } elseif ('not null' == $exp) { + $result[$key] = ['$ne' => null]; + } elseif ('all' == $exp) { + // 满足所有指定条件 + $result[$key] = ['$all', $this->parseValue($query, $value, $key)]; + } elseif ('between' == $exp) { + // 区间查询 + $value = is_array($value) ? $value : explode(',', $value); + $result[$key] = ['$gte' => $this->parseValue($query, $value[0], $key), '$lte' => $this->parseValue($query, $value[1], $key)]; + } elseif ('not between' == $exp) { + // 范围查询 + $value = is_array($value) ? $value : explode(',', $value); + $result[$key] = ['$lt' => $this->parseValue($query, $value[0], $key), '$gt' => $this->parseValue($query, $value[1], $key)]; + } elseif ('exists' == $exp) { + // 字段是否存在 + $result[$key] = ['$exists' => (bool) $value]; + } elseif ('type' == $exp) { + // 类型查询 + $result[$key] = ['$type' => intval($value)]; + } elseif ('exp' == $exp) { + // 表达式查询 + $result['$where'] = $value instanceof Javascript ? $value : new Javascript($value); + } elseif ('like' == $exp) { + // 模糊查询 采用正则方式 + $result[$key] = $value instanceof Regex ? $value : new Regex($value, 'i'); + } elseif (in_array($exp, ['nin', 'in'])) { + // IN 查询 + $value = is_array($value) ? $value : explode(',', $value); + foreach ($value as $k => $val) { + $value[$k] = $this->parseValue($query, $val, $key); + } + $result[$key] = ['$'.$exp => $value]; + } elseif ('regex' == $exp) { + $result[$key] = $value instanceof Regex ? $value : new Regex($value, 'i'); + } elseif ('< time' == $exp) { + $result[$key] = ['$lt' => $this->parseDateTime($query, $value, $field)]; + } elseif ('> time' == $exp) { + $result[$key] = ['$gt' => $this->parseDateTime($query, $value, $field)]; + } elseif ('between time' == $exp) { + // 区间查询 + $value = is_array($value) ? $value : explode(',', $value); + $result[$key] = ['$gte' => $this->parseDateTime($query, $value[0], $field), '$lte' => $this->parseDateTime($query, $value[1], $field)]; + } elseif ('not between time' == $exp) { + // 范围查询 + $value = is_array($value) ? $value : explode(',', $value); + $result[$key] = ['$lt' => $this->parseDateTime($query, $value[0], $field), '$gt' => $this->parseDateTime($query, $value[1], $field)]; + } elseif ('near' == $exp) { + // 经纬度查询 + $result[$key] = ['$near' => $this->parseValue($query, $value, $key)]; + } elseif ('size' == $exp) { + // 元素长度查询 + $result[$key] = ['$size' => intval($value)]; + } else { + // 普通查询 + $result[$key] = $this->parseValue($query, $value, $key); + } + + return $result; + } + + /** + * 日期时间条件解析. + * + * @param Query $query 查询对象 + * @param string $value + * @param string $key + * + * @return string + */ + protected function parseDateTime(Query $query, $value, $key) + { + // 获取时间字段类型 + $type = $query->getFieldType($key); + + if ($type) { + if (is_string($value)) { + $value = strtotime($value) ?: $value; + } + + if (is_int($value)) { + if (preg_match('/(datetime|timestamp)/is', $type)) { + // 日期及时间戳类型 + $value = date('Y-m-d H:i:s', $value); + } elseif (preg_match('/(date)/is', $type)) { + // 日期及时间戳类型 + $value = date('Y-m-d', $value); + } + } + } + + return $value; + } + + /** + * 获取最后写入的ID 如果是insertAll方法的话 返回所有写入的ID. + * + * @return mixed + */ + public function getLastInsID() + { + return $this->insertId; + } + + /** + * 生成insert BulkWrite对象 + * + * @param Query $query 查询对象 + * + * @return BulkWrite + */ + public function insert(Query $query): BulkWrite + { + // 分析并处理数据 + $options = $query->getOptions(); + + $data = $this->parseData($query, $options['data']); + + $bulk = new BulkWrite(); + + if ($insertId = $bulk->insert($data)) { + $this->insertId = $insertId; + } + + $this->log('insert', $data, $options); + + return $bulk; + } + + /** + * 生成insertall BulkWrite对象 + * + * @param Query $query 查询对象 + * @param array $dataSet 数据集 + * + * @return BulkWrite + */ + public function insertAll(Query $query, array $dataSet): BulkWrite + { + $bulk = new BulkWrite(); + $options = $query->getOptions(); + + $this->insertId = []; + foreach ($dataSet as $data) { + // 分析并处理数据 + $data = $this->parseData($query, $data); + if ($insertId = $bulk->insert($data)) { + $this->insertId[] = $insertId; + } + } + + $this->log('insert', $dataSet, $options); + + return $bulk; + } + + /** + * 生成update BulkWrite对象 + * + * @param Query $query 查询对象 + * + * @return BulkWrite + */ + public function update(Query $query): BulkWrite + { + $options = $query->getOptions(); + + $data = $this->parseSet($query, $options['data']); + $where = $this->parseWhere($query, $options['where']); + + if (1 == $options['limit']) { + $updateOptions = ['multi' => false]; + } else { + $updateOptions = ['multi' => true]; + } + + $bulk = new BulkWrite(); + + $bulk->update($where, $data, $updateOptions); + + $this->log('update', $data, $where); + + return $bulk; + } + + /** + * 生成delete BulkWrite对象 + * + * @param Query $query 查询对象 + * + * @return BulkWrite + */ + public function delete(Query $query): BulkWrite + { + $options = $query->getOptions(); + $where = $this->parseWhere($query, $options['where']); + + $bulk = new BulkWrite(); + + if (1 == $options['limit']) { + $deleteOptions = ['limit' => 1]; + } else { + $deleteOptions = ['limit' => 0]; + } + + $bulk->delete($where, $deleteOptions); + + $this->log('remove', $where, $deleteOptions); + + return $bulk; + } + + /** + * 生成Mongo查询对象 + * + * @param Query $query 查询对象 + * @param bool $one 是否仅获取一个记录 + * + * @return MongoQuery + */ + public function select(Query $query, bool $one = false): MongoQuery + { + $options = $query->getOptions(); + + $where = $this->parseWhere($query, $options['where']); + + if ($one) { + $options['limit'] = 1; + } + + $query = new MongoQuery($where, $options); + + $this->log('find', $where, $options); + + return $query; + } + + /** + * 生成Count命令. + * + * @param Query $query 查询对象 + * + * @return Command + */ + public function count(Query $query): Command + { + $options = $query->getOptions(); + + $cmd['count'] = $options['table']; + $cmd['query'] = (object) $this->parseWhere($query, $options['where']); + + foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) { + if (isset($options[$option])) { + $cmd[$option] = $options[$option]; + } + } + + $command = new Command($cmd); + $this->log('cmd', 'count', $cmd); + + return $command; + } + + /** + * 聚合查询命令. + * + * @param Query $query 查询对象 + * @param array $extra 指令和字段 + * + * @return Command + */ + public function aggregate(Query $query, array $extra): Command + { + $options = $query->getOptions(); + [$fun, $field] = $extra; + + if ('id' == $field && $this->connection->getConfig('pk_convert_id')) { + $field = '_id'; + } + + $group = isset($options['group']) ? '$'.$options['group'] : null; + + $pipeline = [ + ['$match' => (object) $this->parseWhere($query, $options['where'])], + ['$group' => ['_id' => $group, 'aggregate' => ['$'.$fun => '$'.$field]]], + ]; + + $cmd = [ + 'aggregate' => $options['table'], + 'allowDiskUse' => true, + 'pipeline' => $pipeline, + 'cursor' => new \stdClass(), + ]; + + foreach (['explain', 'collation', 'bypassDocumentValidation', 'readConcern'] as $option) { + if (isset($options[$option])) { + $cmd[$option] = $options[$option]; + } + } + + $command = new Command($cmd); + + $this->log('aggregate', $cmd); + + return $command; + } + + /** + * 多聚合查询命令, 可以对多个字段进行 group by 操作. + * + * @param Query $query 查询对象 + * @param array $extra 指令和字段 + * + * @return Command + */ + public function multiAggregate(Query $query, $extra): Command + { + $options = $query->getOptions(); + + [$aggregate, $groupBy] = $extra; + + $groups = ['_id' => []]; + + foreach ($groupBy as $field) { + $groups['_id'][$field] = '$'.$field; + } + + foreach ($aggregate as $fun => $field) { + $groups[$field.'_'.$fun] = ['$'.$fun => '$'.$field]; + } + + $pipeline = [ + ['$match' => (object) $this->parseWhere($query, $options['where'])], + ['$group' => $groups], + ]; + + $cmd = [ + 'aggregate' => $options['table'], + 'allowDiskUse' => true, + 'pipeline' => $pipeline, + 'cursor' => new \stdClass(), + ]; + + foreach (['explain', 'collation', 'bypassDocumentValidation', 'readConcern'] as $option) { + if (isset($options[$option])) { + $cmd[$option] = $options[$option]; + } + } + + $command = new Command($cmd); + $this->log('group', $cmd); + + return $command; + } + + /** + * 生成distinct命令. + * + * @param Query $query 查询对象 + * @param string $field 字段名 + * + * @return Command + */ + public function distinct(Query $query, $field): Command + { + $options = $query->getOptions(); + + $cmd = [ + 'distinct' => $options['table'], + 'key' => $field, + ]; + + if (!empty($options['where'])) { + $cmd['query'] = (object) $this->parseWhere($query, $options['where']); + } + + if (isset($options['maxTimeMS'])) { + $cmd['maxTimeMS'] = $options['maxTimeMS']; + } + + $command = new Command($cmd); + + $this->log('cmd', 'distinct', $cmd); + + return $command; + } + + /** + * 查询所有的collection. + * + * @return Command + */ + public function listcollections(): Command + { + $cmd = ['listCollections' => 1]; + $command = new Command($cmd); + + $this->log('cmd', 'listCollections', $cmd); + + return $command; + } + + /** + * 查询数据表的状态信息. + * + * @param Query $query 查询对象 + * + * @return Command + */ + public function collStats(Query $query): Command + { + $options = $query->getOptions(); + + $cmd = ['collStats' => $options['table']]; + $command = new Command($cmd); + + $this->log('cmd', 'collStats', $cmd); + + return $command; + } + + protected function log($type, $data, $options = []) + { + $this->connection->mongoLog($type, $data, $options); + } +} diff --git a/vendor/topthink/think-orm/src/db/builder/Mysql.php b/vendor/topthink/think-orm/src/db/builder/Mysql.php new file mode 100644 index 0000000..11e4548 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/builder/Mysql.php @@ -0,0 +1,525 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\builder; + +use PDO; +use think\db\BaseQuery as Query; +use think\db\Builder; +use think\db\exception\DbException as Exception; +use think\db\Raw; + +/** + * mysql数据库驱动. + */ +class Mysql extends Builder +{ + /** + * 查询表达式解析. + * + * @var array + */ + protected $parser = [ + 'parseCompare' => ['=', '!=', '<>', '>', '>=', '<', '<=', '&', '|', '^', '>>', '<<'], + 'parseLike' => ['LIKE', 'NOT LIKE'], + 'parseBetween' => ['NOT BETWEEN', 'BETWEEN'], + 'parseIn' => ['NOT IN', 'IN'], + 'parseExp' => ['EXP'], + 'parseRegexp' => ['REGEXP', 'NOT REGEXP'], + 'parseNull' => ['NOT NULL', 'NULL'], + 'parseBetweenTime' => ['BETWEEN TIME', 'NOT BETWEEN TIME'], + 'parseTime' => ['< TIME', '> TIME', '<= TIME', '>= TIME'], + 'parseExists' => ['NOT EXISTS', 'EXISTS'], + 'parseColumn' => ['COLUMN'], + 'parseFindInSet' => ['FIND IN SET'], + ]; + + /** + * SELECT SQL表达式. + * + * @var string + */ + protected $selectSql = 'SELECT%DISTINCT%%EXTRA% %FIELD% FROM %TABLE%%PARTITION%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * INSERT SQL表达式. + * + * @var string + */ + protected $insertSql = '%INSERT%%EXTRA% INTO %TABLE%%PARTITION% SET %SET% %DUPLICATE%%COMMENT%'; + + /** + * INSERT ALL SQL表达式. + * + * @var string + */ + protected $insertAllSql = '%INSERT%%EXTRA% INTO %TABLE%%PARTITION% (%FIELD%) VALUES %DATA% %DUPLICATE%%COMMENT%'; + + /** + * UPDATE SQL表达式. + * + * @var string + */ + protected $updateSql = 'UPDATE%EXTRA% %TABLE%%PARTITION% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * DELETE SQL表达式. + * + * @var string + */ + protected $deleteSql = 'DELETE%EXTRA% FROM %TABLE%%PARTITION%%USING%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * 生成查询SQL. + * + * @param Query $query 查询对象 + * @param bool $one 是否仅获取一个记录 + * + * @return string + */ + public function select(Query $query, bool $one = false): string + { + $options = $query->getOptions(); + + return str_replace( + ['%TABLE%', '%PARTITION%', '%DISTINCT%', '%EXTRA%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'], + [ + $this->parseTable($query, $options['table']), + $this->parsePartition($query, $options['partition']), + $this->parseDistinct($query, $options['distinct']), + $this->parseExtra($query, $options['extra']), + $this->parseField($query, $options['field'] ?? []), + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseGroup($query, $options['group']), + $this->parseHaving($query, $options['having']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $one ? '1' : $options['limit']), + $this->parseUnion($query, $options['union']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + $this->parseForce($query, $options['force']), + ], + $this->selectSql + ); + } + + /** + * 生成Insert SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function insert(Query $query): string + { + $options = $query->getOptions(); + + // 分析并处理数据 + $data = $this->parseData($query, $options['data']); + if (empty($data)) { + return ''; + } + + $set = []; + foreach ($data as $key => $val) { + $set[] = $key . ' = ' . $val; + } + + return str_replace( + ['%INSERT%', '%EXTRA%', '%TABLE%', '%PARTITION%', '%SET%', '%DUPLICATE%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseExtra($query, $options['extra']), + $this->parseTable($query, $options['table']), + $this->parsePartition($query, $options['partition']), + implode(' , ', $set), + $this->parseDuplicate($query, $options['duplicate']), + $this->parseComment($query, $options['comment']), + ], + $this->insertSql + ); + } + + /** + * 生成insertall SQL. + * + * @param Query $query 查询对象 + * @param array $dataSet 数据集 + * + * @return string + */ + public function insertAll(Query $query, array $dataSet): string + { + $options = $query->getOptions(); + $bind = $query->getFieldsBindType(); + + // 获取合法的字段 + if (empty($options['field']) || '*' == $options['field']) { + $allowFields = array_keys($bind); + } else { + $allowFields = $options['field']; + } + + $fields = []; + $values = []; + + foreach ($dataSet as $data) { + $data = $this->parseData($query, $data, $allowFields, $bind); + + $values[] = '( ' . implode(',', array_values($data)) . ' )'; + + if (!isset($insertFields)) { + $insertFields = array_keys($data); + } + } + + foreach ($insertFields as $field) { + $fields[] = $this->parseKey($query, $field); + } + + return str_replace( + ['%INSERT%', '%EXTRA%', '%TABLE%', '%PARTITION%', '%FIELD%', '%DATA%', '%DUPLICATE%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseExtra($query, $options['extra']), + $this->parseTable($query, $options['table']), + $this->parsePartition($query, $options['partition']), + implode(' , ', $fields), + implode(' , ', $values), + $this->parseDuplicate($query, $options['duplicate']), + $this->parseComment($query, $options['comment']), + ], + $this->insertAllSql + ); + } + + /** + * 生成insertall SQL + * @access public + * @param Query $query 查询对象 + * @param array $keys 键值 + * @param array $values 数据 + * @return string + */ + public function insertAllByKeys(Query $query, array $keys, array $datas): string + { + $options = $query->getOptions(); + $bind = $query->getFieldsBindType(); + $fields = []; + $values = []; + + foreach ($keys as $field) { + $fields[] = $this->parseKey($query, $field); + } + + foreach ($datas as $data) { + foreach ($data as $key => &$val) { + if (!$query->isAutoBind()) { + $val = PDO::PARAM_STR == $bind[$keys[$key]] ? '\'' . $val . '\'' : $val; + } else { + $val = $this->parseDataBind($query, $keys[$key], $val, $bind); + } + } + $values[] = '( ' . implode(',', $data) . ' )'; + } + + return str_replace( + ['%INSERT%', '%EXTRA%', '%TABLE%', '%PARTITION%', '%FIELD%', '%DATA%', '%DUPLICATE%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseExtra($query, $options['extra']), + $this->parseTable($query, $options['table']), + $this->parsePartition($query, $options['partition']), + implode(' , ', $fields), + implode(' , ', $values), + $this->parseDuplicate($query, $options['duplicate']), + $this->parseComment($query, $options['comment']), + ], + $this->insertAllSql + ); + } + + /** + * 生成update SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function update(Query $query): string + { + $options = $query->getOptions(); + $data = $this->parseData($query, $options['data']); + + if (empty($data)) { + return ''; + } + + $set = []; + foreach ($data as $key => $val) { + $set[] = (str_contains($key, '->') ? strstr($key, '->', true) : $key) . ' = ' . $val; + } + + return str_replace( + ['%TABLE%', '%PARTITION%', '%EXTRA%', '%SET%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($query, $options['table']), + $this->parsePartition($query, $options['partition']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $set), + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $options['limit']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + ], + $this->updateSql + ); + } + + /** + * 生成delete SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function delete(Query $query): string + { + $options = $query->getOptions(); + + return str_replace( + ['%TABLE%', '%PARTITION%', '%EXTRA%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($query, $options['table']), + $this->parsePartition($query, $options['partition']), + $this->parseExtra($query, $options['extra']), + !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $options['limit']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + ], + $this->deleteSql + ); + } + + /** + * 正则查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * + * @return string + */ + protected function parseRegexp(Query $query, string $key, string $exp, $value, string $field): string + { + if ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } + + return $key . ' ' . $exp . ' ' . $value; + } + + /** + * FIND_IN_SET 查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * + * @return string + */ + protected function parseFindInSet(Query $query, string $key, string $exp, $value, string $field): string + { + if ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } + + return 'FIND_IN_SET(' . $value . ', ' . $key . ')'; + } + + /** + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param mixed $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + public function parseKey(Query $query, string | int | Raw $key, bool $strict = false): string + { + if (is_int($key)) { + return (string) $key; + } + + if ($key instanceof Raw) { + return $this->parseRaw($query, $key); + } + + $key = trim($key); + + if (str_contains($key, '->>') && !str_contains($key, '(')) { + // JSON字段支持 + [$field, $name] = explode('->>', $key, 2); + + return $this->parseKey($query, $field, true) . '->>\'$' . (str_starts_with($name, '[') ? '' : '.') . str_replace('->>', '.', $name) . '\''; + } + + if (str_contains($key, '->') && !str_contains($key, '(')) { + // JSON字段支持 + [$field, $name] = explode('->', $key, 2); + + return 'json_unquote(json_extract(' . $this->parseKey($query, $field, true) . ', \'$' . (str_starts_with($name, '[') ? '' : '.') . str_replace('->', '.', $name) . '\'))'; + } + + if (str_contains($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { + [$table, $key] = explode('.', $key, 2); + + $alias = $query->getOption('alias'); + + if ('__TABLE__' == $table) { + $table = $query->getOption('table'); + $table = is_array($table) ? array_shift($table) : $table; + } + + if (isset($alias[$table])) { + $table = $alias[$table]; + } + } + + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + + if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { + $key = '`' . $key . '`'; + } + + if (isset($table)) { + if (str_contains($table, '.')) { + $table = str_replace('.', '`.`', $table); + } + + $key = '`' . $table . '`.' . $key; + } + + return $key; + } + + /** + * Null查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + if (str_starts_with($key, "json_unquote(json_extract")) { + if ('NULL' === $exp) { + return '(' . $key . ' is null OR ' . $key . ' = \'null\')'; + } elseif ('NOT NULL' === $exp) { + return '(' . $key . ' is not null AND ' . $key . ' != \'null\')'; + } + } + + return parent::parseNull($query, $key, $exp, $value, $field, $bindType); + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + protected function parseRand(Query $query): string + { + return 'rand()'; + } + + /** + * Partition 分析. + * + * @param Query $query 查询对象 + * @param string|array $partition 分区 + * + * @return string + */ + protected function parsePartition(Query $query, $partition): string + { + if ('' == $partition) { + return ''; + } + + if (is_string($partition)) { + $partition = explode(',', $partition); + } + + return ' PARTITION (' . implode(' , ', $partition) . ') '; + } + + /** + * ON DUPLICATE KEY UPDATE 分析. + * + * @param Query $query 查询对象 + * @param mixed $duplicate + * + * @return string + */ + protected function parseDuplicate(Query $query, $duplicate): string + { + if ('' == $duplicate) { + return ''; + } + + if ($duplicate instanceof Raw) { + return ' ON DUPLICATE KEY UPDATE ' . $this->parseRaw($query, $duplicate) . ' '; + } + + if (is_string($duplicate)) { + $duplicate = explode(',', $duplicate); + } + + $updates = []; + foreach ($duplicate as $key => $val) { + if (is_numeric($key)) { + $val = $this->parseKey($query, $val); + $updates[] = $val . ' = VALUES(' . $val . ')'; + } elseif ($val instanceof Raw) { + $updates[] = $this->parseKey($query, $key) . ' = ' . $this->parseRaw($query, $val); + } else { + $name = $query->bindValue($val, $query->getConnection()->getFieldBindType($key)); + $updates[] = $this->parseKey($query, $key) . ' = :' . $name; + } + } + + return ' ON DUPLICATE KEY UPDATE ' . implode(' , ', $updates) . ' '; + } +} diff --git a/vendor/topthink/think-orm/src/db/builder/Oracle.php b/vendor/topthink/think-orm/src/db/builder/Oracle.php new file mode 100644 index 0000000..f31653a --- /dev/null +++ b/vendor/topthink/think-orm/src/db/builder/Oracle.php @@ -0,0 +1,134 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\builder; + +use think\db\Builder; +use think\db\exception\DbException as Exception; +use think\db\BaseQuery as Query; +use think\db\Raw; + +/** + * Oracle数据库驱动. + */ +class Oracle extends Builder +{ + protected $selectSql = 'SELECT * FROM (SELECT thinkphp.*, rownum AS numrow FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%) thinkphp ) %LIMIT%%COMMENT%'; + + /** + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + protected function parseLimit(Query $query, string $limit): string + { + $limitStr = ''; + + if (!empty($limit)) { + $limit = explode(',', $limit); + + if (count($limit) > 1) { + $limitStr = '(numrow>' . $limit[0] . ') AND (numrow<=' . ($limit[0] + $limit[1]) . ')'; + } else { + $limitStr = '(numrow>0 AND numrow<=' . $limit[0] . ')'; + } + } + + return $limitStr ? ' WHERE ' . $limitStr : ''; + } + + /** + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * + * @return string + */ + protected function parseLock(Query $query, bool|string $lock = false): string + { + if (!$lock) { + return ''; + } + + return ' FOR UPDATE NOWAIT '; + } + + /** + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key + * @param bool $strict + * + * @throws Exception + * + * @return string + */ + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string + { + if (is_int($key)) { + return (string) $key; + } elseif ($key instanceof Raw) { + return $this->parseRaw($query, $key); + } + + $key = trim($key); + + if (str_contains($key, '->') && !str_contains($key, '(')) { + // JSON字段支持 + [$field, $name] = explode($key, '->'); + $key = $field . '."' . $name . '"'; + } elseif (str_contains($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { + [$table, $key] = explode('.', $key, 2); + + $alias = $query->getOption('alias'); + + if ('__TABLE__' == $table) { + $table = $query->getOption('table'); + $table = is_array($table) ? array_shift($table) : $table; + } + + if (isset($alias[$table])) { + $table = $alias[$table]; + } + } + + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + + if ('*' != $key && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) { + $key = '"' . $key . '"'; + } + + if (isset($table)) { + $key = '"' . $table . '".' . $key; + } + + return $key; + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + protected function parseRand(Query $query): string + { + return 'DBMS_RANDOM.value'; + } +} diff --git a/vendor/topthink/think-orm/src/db/builder/Pgsql.php b/vendor/topthink/think-orm/src/db/builder/Pgsql.php new file mode 100644 index 0000000..79ca5f5 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/builder/Pgsql.php @@ -0,0 +1,123 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\builder; + +use think\db\Builder; +use think\db\BaseQuery as Query; +use think\db\Raw; + +/** + * Pgsql数据库驱动. + */ +class Pgsql extends Builder +{ + /** + * INSERT SQL表达式. + * + * @var string + */ + protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + + /** + * INSERT ALL SQL表达式. + * + * @var string + */ + protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + + /** + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + public function parseLimit(Query $query, string $limit): string + { + $limitStr = ''; + + if (!empty($limit)) { + $limit = explode(',', $limit); + if (count($limit) > 1) { + $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; + } else { + $limitStr .= ' LIMIT ' . $limit[0] . ' '; + } + } + + return $limitStr; + } + + /** + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string + { + if (is_int($key)) { + return (string) $key; + } elseif ($key instanceof Raw) { + return $this->parseRaw($query, $key); + } + + $key = trim($key); + + if (str_contains($key, '->') && !str_contains($key, '(')) { + // JSON字段支持 + [$field, $name] = explode('->', $key); + $key = '"' . $field . '"' . '->>\'' . $name . '\''; + } elseif (str_contains($key, '.')) { + [$table, $key] = explode('.', $key, 2); + + $alias = $query->getOption('alias'); + + if ('__TABLE__' == $table) { + $table = $query->getOption('table'); + $table = is_array($table) ? array_shift($table) : $table; + } + + if (isset($alias[$table])) { + $table = $alias[$table]; + } + + if ('*' != $key && !preg_match('/[,\"\*\(\).\s]/', $key)) { + $key = '"' . $key . '"'; + } + } + + if (isset($table)) { + $key = $table . '.' . $key; + } + + return $key; + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + protected function parseRand(Query $query): string + { + return 'RANDOM()'; + } +} diff --git a/vendor/topthink/think-orm/src/db/builder/Sqlite.php b/vendor/topthink/think-orm/src/db/builder/Sqlite.php new file mode 100644 index 0000000..e028a74 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/builder/Sqlite.php @@ -0,0 +1,118 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\builder; + +use think\db\Builder; +use think\db\BaseQuery as Query; +use think\db\Raw; + +/** + * Sqlite数据库驱动. + */ +class Sqlite extends Builder +{ + /** + * limit. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + public function parseLimit(Query $query, string $limit): string + { + $limitStr = ''; + + if (!empty($limit)) { + $limit = explode(',', $limit); + if (count($limit) > 1) { + $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; + } else { + $limitStr .= ' LIMIT ' . $limit[0] . ' '; + } + } + + return $limitStr; + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + protected function parseRand(Query $query): string + { + return 'RANDOM()'; + } + + /** + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string + { + if (is_int($key)) { + return (string) $key; + } elseif ($key instanceof Raw) { + return $this->parseRaw($query, $key); + } + + $key = trim($key); + + if (str_contains($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { + [$table, $key] = explode('.', $key, 2); + + $alias = $query->getOption('alias'); + + if ('__TABLE__' == $table) { + $table = $query->getOption('table'); + $table = is_array($table) ? array_shift($table) : $table; + } + + if (isset($alias[$table])) { + $table = $alias[$table]; + } + } + + if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { + $key = '`' . $key . '`'; + } + + if (isset($table)) { + $key = '`' . $table . '`.' . $key; + } + + return $key; + } + + /** + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * + * @return string + */ + protected function parseLock(Query $query, bool|string $lock = false): string + { + return ''; + } +} diff --git a/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php b/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php new file mode 100644 index 0000000..f602b00 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php @@ -0,0 +1,194 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\builder; + +use think\db\Builder; +use think\db\exception\DbException as Exception; +use think\db\BaseQuery as Query; +use think\db\Raw; + +/** + * Sqlsrv数据库驱动. + */ +class Sqlsrv extends Builder +{ + /** + * SELECT SQL表达式. + * + * @var string + */ + protected $selectSql = 'SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER (%ORDER%) AS ROW_NUMBER FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%) AS thinkphp) AS T1 %LIMIT%%COMMENT%'; + /** + * SELECT INSERT SQL表达式. + * + * @var string + */ + protected $selectInsertSql = 'SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%'; + + /** + * UPDATE SQL表达式. + * + * @var string + */ + protected $updateSql = 'UPDATE %TABLE% SET %SET% FROM %TABLE% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; + + /** + * DELETE SQL表达式. + * + * @var string + */ + protected $deleteSql = 'DELETE FROM %TABLE% %USING% FROM %TABLE% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; + + /** + * INSERT SQL表达式. + * + * @var string + */ + protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + + /** + * INSERT ALL SQL表达式. + * + * @var string + */ + protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + + /** + * order分析. + * + * @param Query $query 查询对象 + * @param mixed $order + * + * @return string + */ + protected function parseOrder(Query $query, array $order): string + { + if (empty($order)) { + return ' ORDER BY rand()'; + } + + $array = []; + + foreach ($order as $key => $val) { + if ($val instanceof Raw) { + $array[] = $this->parseRaw($query, $val); + } elseif ('[rand]' == $val) { + $array[] = $this->parseRand($query); + } else { + if (is_numeric($key)) { + [$key, $sort] = explode(' ', str_contains($val, ' ') ? $val : $val . ' '); + } else { + $sort = $val; + } + + $sort = in_array(strtolower($sort), ['asc', 'desc'], true) ? ' ' . $sort : ''; + $array[] = $this->parseKey($query, $key, true) . $sort; + } + } + + return ' ORDER BY ' . implode(',', $array); + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + protected function parseRand(Query $query): string + { + return 'rand()'; + } + + /** + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string + { + if (is_int($key)) { + return (string) $key; + } elseif ($key instanceof Raw) { + return $this->parseRaw($query, $key); + } + + $key = trim($key); + + if (str_contains($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { + [$table, $key] = explode('.', $key, 2); + + $alias = $query->getOption('alias'); + + if ('__TABLE__' == $table) { + $table = $query->getOption('table'); + $table = is_array($table) ? array_shift($table) : $table; + } + + if (isset($alias[$table])) { + $table = $alias[$table]; + } + } + + if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { + throw new Exception('not support data:' . $key); + } + + if ('*' != $key && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) { + $key = '[' . $key . ']'; + } + + if (isset($table)) { + $key = '[' . $table . '].' . $key; + } + + return $key; + } + + /** + * limit. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + protected function parseLimit(Query $query, string $limit): string + { + if (empty($limit)) { + return ''; + } + + $limit = explode(',', $limit); + + if (count($limit) > 1) { + $limitStr = '(T1.ROW_NUMBER BETWEEN ' . $limit[0] . ' + 1 AND ' . $limit[0] . ' + ' . $limit[1] . ')'; + } else { + $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND ' . $limit[0] . ')'; + } + + return 'WHERE ' . $limitStr; + } + + public function selectInsert(Query $query, array $fields, string $table): string + { + $this->selectSql = $this->selectInsertSql; + + return parent::selectInsert($query, $fields, $table); + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php b/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php new file mode 100644 index 0000000..02fdb4a --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php @@ -0,0 +1,131 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +use think\db\exception\DbException; +use think\db\Raw; + +/** + * 聚合查询. + */ +trait AggregateQuery +{ + /** + * 聚合查询. + * + * @param string $aggregate 聚合方法 + * @param string|Raw $field 字段名 + * @param bool $force 强制转为数字类型 + * + * @return mixed + */ + protected function aggregate(string $aggregate, string | Raw $field, bool $force = false) + { + return $this->connection->aggregate($this, $aggregate, $field, $force); + } + + /** + * COUNT查询. + * + * @param string $field 字段名 + * + * @return int + */ + public function count(string $field = '*'): int + { + if (!empty($this->options['group'])) { + return $this->countWithGroup($field); + } + + return (int) $this->aggregate('COUNT', $field); + } + + protected function countWithGroup(string $field): int + { + if (!preg_match('/^[\w\.\*]+$/', $field)) { + throw new DbException('Not supported data: ' . $field); + } + + $options = $this->getOptions(); + $cache = $options['cache'] ?? null; + + if (isset($options['cache'])) { + unset($options['cache']); + } + + $subSql = $this->options($options) + ->field('count(' . $field . ') AS think_count') + ->bind($this->bind) + ->buildSql(); + + $query = $this->newQuery(); + if ($cache) { + $query->setOption('cache', $cache); + } + + $query->table([$subSql => '_group_count_']); + + return (int) $query->aggregate('COUNT', '*'); + } + + /** + * SUM查询. + * + * @param string|Raw $field 字段名 + * + * @return float + */ + public function sum(string | Raw $field): float + { + return $this->aggregate('SUM', $field, true); + } + + /** + * MIN查询. + * + * @param string|Raw $field 字段名 + * @param bool $force 强制转为数字类型 + * + * @return mixed + */ + public function min(string | Raw $field, bool $force = true) + { + return $this->aggregate('MIN', $field, $force); + } + + /** + * MAX查询. + * + * @param string|Raw $field 字段名 + * @param bool $force 强制转为数字类型 + * + * @return mixed + */ + public function max(string | Raw $field, bool $force = true) + { + return $this->aggregate('MAX', $field, $force); + } + + /** + * AVG查询. + * + * @param string|Raw $field 字段名 + * + * @return float + */ + public function avg(string | Raw $field): float + { + return $this->aggregate('AVG', $field, true); + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php b/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php new file mode 100644 index 0000000..da47eb5 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php @@ -0,0 +1,241 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +use think\db\Raw; +use think\helper\Str; + +/** + * JOIN和VIEW查询. + */ +trait JoinAndViewQuery +{ + /** + * 查询SQL组装 join. + * + * @param array|string|Raw $join 关联的表名 + * @param mixed $condition 条件 + * @param string $type JOIN类型 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function join(array | string | Raw $join, ?string $condition = null, string $type = 'INNER', array $bind = []) + { + $table = $this->getJoinTable($join, $alias); + + if (!empty($bind) && $condition) { + $this->bindParams($condition, $bind); + } + + if ($alias) { + $this->options['join'][$alias] = [$table, strtoupper($type), $condition]; + } else { + $this->options['join'][] = [$table, strtoupper($type), $condition]; + } + + return $this; + } + + /** + * LEFT JOIN. + * + * @param array|string|Raw $join 关联的表名 + * @param mixed $condition 条件 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function leftJoin(array | string | Raw $join, ?string $condition = null, array $bind = []) + { + return $this->join($join, $condition, 'LEFT', $bind); + } + + /** + * RIGHT JOIN. + * + * @param array|string|Raw $join 关联的表名 + * @param mixed $condition 条件 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function rightJoin(array | string | Raw $join, ?string $condition = null, array $bind = []) + { + return $this->join($join, $condition, 'RIGHT', $bind); + } + + /** + * FULL JOIN. + * + * @param array|string|Raw $join 关联的表名 + * @param mixed $condition 条件 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function fullJoin(array | string | Raw $join, ?string $condition = null, array $bind = []) + { + return $this->join($join, $condition, 'FULL', $bind); + } + + /** + * 获取Join表名及别名 支持 + * ['prefix_table或者子查询'=>'alias'] 'table alias'. + * + * @param array|string|Raw $join JION表名 + * @param string $alias 别名 + * + * @return string|array + */ + protected function getJoinTable(array | string | Raw $join, ?string &$alias = null) + { + if (is_array($join)) { + $table = $join; + $alias = array_shift($join); + return $table; + } + + if ($join instanceof Raw || str_contains($join, '(')) { + return $join; + } + + $join = trim($join); + + // 使用别名 + if (str_contains($join, ' ')) { + // 使用别名 + [$table, $alias] = explode(' ', $join); + } else { + $table = $join; + if (!str_contains($join, '.')) { + $alias = $join; + } + } + + if ($this->prefix && !str_contains($table, '.') && !str_starts_with($table, $this->prefix)) { + $table = $this->prefix . Str::snake($table) . $this->suffix; + } + + if (!empty($alias) && $table != $alias) { + $table = [$table => $alias]; + } + + return $table; + } + + /** + * 指定JOIN查询字段. + * + * @param array|string|Raw $join 数据表 + * @param string|array|bool $field 查询字段 + * @param string $on JOIN条件 + * @param string $type JOIN类型 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function view(array | string | Raw $join, string | array | bool $field = true, ?string $on = null, string $type = 'INNER', array $bind = []): self + { + $this->options['view'] = true; + + $fields = []; + $table = $this->getJoinTable($join, $alias); + + // 处理字段 + $fields = $this->processFields($field, $alias); + + $this->field($fields); + + // 处理连接 + if ($on) { + $this->join($table, $on, $type, $bind); + } else { + $this->table($table); + } + + return $this; + } + + protected function processFields(string | array | bool $field, string $alias): array + { + $fields = []; + + if (true === $field) { + $fields[] = $alias . '.*'; // 选取所有字段 + } else { + if (is_string($field)) { + $field = explode(',', $field); + } + + foreach ($field as $key => $val) { + $name = is_numeric($key) ? $alias . '.' . $val : (preg_match('/[,=\.\'\"\(\s]/', $key) ? $key : $alias . '.' . $key); + $fields[] = $name . (is_numeric($key) ? '' : ' AS ' . $val); + + $this->options['map'][$val] = $name; + } + } + + return $fields; + } + + /** + * 视图查询处理. + * + * @param array $options 查询参数 + * + * @return void + */ + protected function parseView(array &$options): void + { + foreach (['AND', 'OR'] as $logic) { + if (!isset($options['where'][$logic])) { + continue; + } + + // 视图查询条件处理 + foreach ($options['where'][$logic] as $key => $val) { + if (array_key_exists($key, $options['map'])) { + array_shift($val); + array_unshift($val, $options['map'][$key]); + $options['where'][$logic][$options['map'][$key]] = $val; + unset($options['where'][$logic][$key]); + } + } + } + + if (empty($options['order'])) { + return; + } + + // 视图查询排序处理 + foreach ($options['order'] as $key => $val) { + if (is_numeric($key) && is_string($val)) { + if (str_contains($val, ' ')) { + [$field, $sort] = explode(' ', $val); + if (array_key_exists($field, $options['map'])) { + $options['order'][$options['map'][$field]] = $sort; + unset($options['order'][$key]); + } + } elseif (array_key_exists($val, $options['map'])) { + $options['order'][$options['map'][$val]] = 'asc'; + unset($options['order'][$key]); + } + } elseif (array_key_exists($key, $options['map'])) { + $options['order'][$options['map'][$key]] = $val; + unset($options['order'][$key]); + } + } + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php b/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php new file mode 100644 index 0000000..829134d --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php @@ -0,0 +1,729 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +use Closure; +use think\helper\Str; +use think\model\Collection as ModelCollection; +use think\model\contract\Modelable as Model; + +/** + * 模型及关联查询. + */ +trait ModelRelationQuery +{ + /** + * 当前模型对象 + * + * @var Model + */ + protected $model; + + /** + * 指定模型. + * + * @param Model $model 模型对象实例 + * + * @return $this + */ + public function model(Model $model) + { + $this->model = $model; + + return $this; + } + + /** + * 获取当前的模型对象 + * + * @return Model|null + */ + public function getModel() + { + return $this->model; + } + + /** + * 设置需要隐藏的输出属性. + * + * @param array $hidden 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function hidden(array $hidden, bool $merge = false) + { + $this->options['hidden'] = [$hidden, $merge]; + + return $this; + } + + /** + * 设置需要输出的属性. + * + * @param array $visible 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function visible(array $visible, bool $merge = false) + { + $this->options['visible'] = [$visible, $merge]; + + return $this; + } + + /** + * 设置需要附加的输出属性. + * + * @param array $append 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function append(array $append, bool $merge = false) + { + $this->options['append'] = [$append, $merge]; + + return $this; + } + + /** + * 设置模型的输出映射. + * + * @param array $mapping 映射列表 + * + * @return $this + */ + public function mapping(array $mapping) + { + $this->options['mapping'] = $mapping; + + return $this; + } + + /** + * 添加查询范围. + * + * @param array|string|Closure $scope 查询范围定义 + * @param array $args 参数 + * + * @return $this + */ + public function scope($scope, ...$args) + { + // 查询范围的第一个参数始终是当前查询对象 + array_unshift($args, $this); + + if ($scope instanceof Closure) { + $this->options['scope'][] = [$scope, $args]; + return $this; + } + + if ($this->model) { + if (is_string($scope)) { + $scope = explode(',', $scope); + } + + // 检查模型类的查询范围方法 + $entity = $this->model->getEntity(); + foreach ($scope as $name) { + $method = 'scope' . trim($name); + if ($entity && method_exists($entity, $method)) { + $this->options['scope'][$name] = [[$entity, $method], $args]; + } elseif (method_exists($this->model, $method)) { + $this->options['scope'][$name] = [[$this->model, $method], $args]; + } + } + } + + return $this; + } + + /** + * 执行查询范围查询. + * + * @return $this + */ + protected function scopeQuery() + { + if (!empty($this->options['scope'])) { + foreach ($this->options['scope'] as $val) { + [$call, $args] = $val; + call_user_func_array($call, $args); + } + } + + return $this; + } + + /** + * 指定不使用的查询范围. + * + * @param array $scope 查询范围 + * + * @return $this + */ + public function withoutScope(array $scope = []) + { + if (empty($scope)) { + $this->options['scope'] = []; + return $this; + } + + foreach ($scope as $name) { + if (isset($this->options['scope'][$name])) { + unset($this->options['scope'][$name]); + } + } + + return $this; + } + + /** + * 设置关联查询. + * + * @param array $relation 关联名称 + * + * @return $this + */ + public function relation(array $relation) + { + if (empty($this->model) || empty($relation)) { + return $this; + } + + $this->options['relation'] = $relation; + + return $this; + } + + /** + * 使用搜索器条件搜索字段. + * + * @param string|array $fields 搜索字段 + * @param mixed $data 搜索数据 + * @param bool $strict 是否严格检查数据 + * + * @return $this + */ + public function withSearch(string | array $fields, $data = [], bool $strict = false) + { + if (is_string($fields)) { + $fields = explode(',', $fields); + } + + $likeFields = $this->getConfig('match_like_fields') ?: []; + + foreach ($fields as $key => $field) { + if ($field instanceof Closure) { + $field($this, $data[$key] ?? null, $data); + } elseif ($this->model) { + // 检查字段是否有数据 + $fieldName = is_numeric($key) ? $field : $key; + if ($strict && (!isset($data[$fieldName]) || (empty($data[$fieldName]) && !in_array($data[$fieldName], ['0', 0])))) { + continue; + } + + if (is_string($key) && isset($data[$key])) { + // 默认搜索规则 + $this->where($key, $field, 'like' == $field ? '%' . $data[$key] . '%' : $data[$key]); + continue; + } + + $method = 'search' . Str::studly($fieldName) . 'Attr'; + $entity = $this->model->getEntity(); + if ($entity && method_exists($entity, $method)) { + $entity->$method($this, $data[$fieldName] ?? null, $data); + } elseif (method_exists($this->model, $method)) { + $this->model->$method($this, $data[$fieldName] ?? null, $data); + } elseif (isset($data[$field])) { + $this->where($fieldName, in_array($fieldName, $likeFields) ? 'like' : '=', in_array($fieldName, $likeFields) ? '%' . $data[$field] . '%' : $data[$field]); + } + } + } + + return $this; + } + + /** + * 限制关联数据的字段 已废弃直接使用field或withoutfield替代. + * + * @deprecated + * + * @param array|string $field 关联字段限制 + * + * @return $this + */ + public function withField($field) + { + return $this->field($field); + } + + /** + * 限制关联数据的数量 已废弃直接使用limit替代. + * + * @deprecated + * + * @param int $limit 关联数量限制 + * + * @return $this + */ + public function withLimit(int $limit) + { + return $this->limit($limit); + } + + /** + * 设置关联数据不存在的时候默认值 + * + * @param mixed $data 默认值 + * + * @return $this + */ + public function withDefault($data = null) + { + $this->options['default_model'] = $data; + + return $this; + } + + /** + * 设置关联模型的动态绑定 + * + * @param array $attr 绑定数据 + * + * @return $this + */ + public function withBind(array $attr) + { + $this->options['bind_attr'] = $attr; + return $this; + } + + /** + * 设置数据字段获取器. + * + * @param string|array $name 字段名 + * @param callable $callback 闭包获取器 + * + * @return $this + */ + public function withAttr(string | array $name, ? callable $callback = null) + { + if (is_array($name)) { + foreach ($name as $key => $val) { + $this->withAttr($key, $val); + } + + return $this; + } + + $this->options['with_attr'][$name] = $callback; + + if (str_contains($name, '.')) { + [$relation, $field] = explode('.', $name); + + if (!empty($this->options['json']) && in_array($relation, $this->options['json'])) { + } else { + $this->options['with_relation_attr'][$relation][$field] = $callback; + unset($this->options['with_attr'][$name]); + } + } + + return $this; + } + + /** + * 关联预载入 In方式. + * + * @param array|string $with 关联方法名称 + * + * @return $this + */ + public function with(array | string $with) + { + if (empty($this->model) || empty($with)) { + return $this; + } + + $this->options['with'] = array_merge($this->options['with'] ?? [], (array) $with); + + return $this; + } + + /** + * 关联预载入 JOIN方式. + * + * @param array|string $with 关联方法名 + * @param string $joinType JOIN方式 + * + * @return $this + */ + public function withJoin(array | string $with, string $joinType = '') + { + if (empty($this->model) || empty($with)) { + return $this; + } + + $with = (array) $with; + $first = true; + + foreach ($with as $key => $relation) { + $closure = null; + $field = true; + + if ($relation instanceof Closure) { + // 支持闭包查询过滤关联条件 + $closure = $relation; + $relation = $key; + } elseif (is_array($relation)) { + $field = $relation; + $relation = $key; + } elseif (is_string($relation) && str_contains($relation, '.')) { + $relation = strstr($relation, '.', true); + } + + $result = $this->model->eagerly($this, $relation, $field, $joinType, $closure, $first); + + if (!$result) { + unset($with[$key]); + } else { + $first = false; + } + } + + $this->via(); + $this->options['with_join'] = $with; + + return $this; + } + + /** + * 关联统计 + * + * @param array|string $relations 关联方法名 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param bool $subQuery 是否使用子查询 + * + * @return $this + */ + protected function withAggregate(string | array $relations, string $aggregate = 'count', $field = 'id', bool $subQuery = true) + { + if (empty($this->model)) { + return $this; + } + + if (!$subQuery) { + $this->options['with_aggregate'][] = [(array) $relations, $aggregate, $field]; + + return $this; + } + + if (!isset($this->options['field'])) { + $this->field('*'); + } + + $this->model->relationCount($this, (array) $relations, $aggregate, $field, true); + + return $this; + } + + /** + * 关联缓存. + * + * @param string|array|bool $relation 关联方法名 + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string $tag 缓存标签 + * + * @return $this + */ + public function withCache(string | array | bool $relation = true, $key = true, $expire = null, ?string $tag = null) + { + if (empty($this->model)) { + return $this; + } + + if (false === $relation || false === $key || !$this->getConnection()->getCache()) { + return $this; + } + + if ($key instanceof \DateTimeInterface || $key instanceof \DateInterval || (is_int($key) && is_null($expire))) { + $expire = $key; + $key = true; + } + + if (true === $relation || is_numeric($relation)) { + $this->options['with_cache'] = $relation; + + return $this; + } + + $relations = (array) $relation; + foreach ($relations as $name => $relation) { + if (!is_numeric($name)) { + $this->options['with_cache'][$name] = is_array($relation) ? $relation : [$key, $relation, $tag]; + } else { + $this->options['with_cache'][$relation] = [$key, $expire, $tag]; + } + } + + return $this; + } + + /** + * 关联统计 + * + * @param string|array $relation 关联方法名 + * @param string $field 字段(默认为id) + * @param bool $subQuery 是否使用子查询 + * + * @return $this + */ + public function withCount(string | array $relation, string $field = 'id', bool $subQuery = true) + { + return $this->withAggregate($relation, 'count', $field, $subQuery); + } + + /** + * 关联统计Sum. + * + * @param string|array $relation 关联方法名 + * @param string $field 字段 + * @param bool $subQuery 是否使用子查询 + * + * @return $this + */ + public function withSum(string | array $relation, string $field, bool $subQuery = true) + { + return $this->withAggregate($relation, 'sum', $field, $subQuery); + } + + /** + * 关联统计Max. + * + * @param string|array $relation 关联方法名 + * @param string $field 字段 + * @param bool $subQuery 是否使用子查询 + * + * @return $this + */ + public function withMax(string | array $relation, string $field, bool $subQuery = true) + { + return $this->withAggregate($relation, 'max', $field, $subQuery); + } + + /** + * 关联统计Min. + * + * @param string|array $relation 关联方法名 + * @param string $field 字段 + * @param bool $subQuery 是否使用子查询 + * + * @return $this + */ + public function withMin(string | array $relation, string $field, bool $subQuery = true) + { + return $this->withAggregate($relation, 'min', $field, $subQuery); + } + + /** + * 关联统计Avg. + * + * @param string|array $relation 关联方法名 + * @param string $field 字段 + * @param bool $subQuery 是否使用子查询 + * + * @return $this + */ + public function withAvg(string | array $relation, string $field, bool $subQuery = true) + { + return $this->withAggregate($relation, 'avg', $field, $subQuery); + } + + /** + * 查询关联数据存在(或超过多少条)的模型数据. + * + * @param string $relation 关联方法名 + * @param mixed $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * + * @return $this + */ + public function has(string $relation, string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '') + { + return $this->model->has($relation, $operator, $count, $id, $joinType, $this); + } + + /** + * 查询关联数据不存在的模型数据. + * + * @param string $relation 关联方法名 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * + * @return $this + */ + public function hasNot(string $relation, string $id = '*', string $joinType = '') + { + return $this->model->has($relation, '=', 0, $id, $joinType, $this); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string|array $relation 关联方法名 或 ['关联方法名', '关联表别名'] + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * + * @return $this + */ + public function hasWhere(string|array $relation, $where = [], string $fields = '*', string $joinType = '') + { + return $this->model->hasWhere($relation, $where, $fields, $joinType, $this); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string|array $relation 关联方法名 或 ['关联方法名', '关联表别名'] + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * + * @return $this + */ + public function hasWhereOr(string|array $relation, $where = [], string $fields = '*', string $joinType = '') + { + return $this->model->hasWhereOr($relation, $where, $fields, $joinType, $this); + } + + /** + * 查询数据转换为模型数据集对象 + * + * @param array $resultSet 数据集 + * + * @return ModelCollection + */ + protected function resultSetToModelCollection(array $resultSet): ModelCollection + { + if (empty($resultSet)) { + return $this->model->toCollection(); + } + + $this->options['is_resultSet'] = true; + + foreach ($resultSet as $key => &$result) { + // 数据转换为模型对象 + $this->resultToModel($result); + } + + foreach (['with', 'with_join'] as $with) { + // 关联预载入 + if (!empty($this->options[$with])) { + $result->eagerlyResultSet( + $resultSet, + $this->options[$with], + $this->options['with_relation_attr'], + 'with_join' == $with, + $this->options['with_cache'] ?? false + ); + } + } + + // 模型数据集转换 + return $this->model->toCollection($resultSet); + } + + /** + * 查询数据转换为模型对象 + * + * @param array $result 查询数据 + * + * @return void + */ + protected function resultToModel(array &$result): void + { + // 实时读取延迟数据 + if (!empty($this->options['lazy_fields'])) { + $id = $this->getKey($result); + foreach ($this->options['lazy_fields'] as $field) { + if (isset($result[$field])) { + $result[$field] += $this->getLazyFieldValue($field, $id); + } + } + } + + $result = $this->model->newInstance($result); + + if ($this->suffix) { + $result->setSuffix($this->suffix); + } + + // 模型数据处理 + foreach ($this->options['filter'] as $filter) { + call_user_func_array($filter, [$result, $this->options]); + } + + // 关联查询 + if (!empty($this->options['relation'])) { + $result->relationQuery($this->options['relation'], $this->options['with_relation_attr']); + } + + // 关联预载入查询 + if (empty($this->options['is_resultSet'])) { + foreach (['with', 'with_join'] as $with) { + if (!empty($this->options[$with])) { + $result->eagerlyResult( + $result, + $this->options[$with], + $this->options['with_relation_attr'], + 'with_join' == $with, + $this->options['with_cache'] ?? false + ); + } + } + } + + // 关联统计查询 + if (!empty($this->options['with_aggregate'])) { + foreach ($this->options['with_aggregate'] as $val) { + $result->relationCount($this, $val[0], $val[1], $val[2], false); + } + } + + // 动态获取器 + if (!empty($this->options['with_attr'])) { + $result->withFieldAttr($this->options['with_attr']); + } + + // 模型输出设置 + foreach (['hidden', 'visible', 'append'] as $name) { + if (!empty($this->options[$name])) { + [$value, $merge] = $this->options[$name]; + $result->$name($value, $merge); + } + } + + // 字段映射 + if (!empty($this->options['mapping'])) { + $result->mapping($this->options['mapping']); + } + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/ParamsBind.php b/vendor/topthink/think-orm/src/db/concern/ParamsBind.php new file mode 100644 index 0000000..536d244 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/ParamsBind.php @@ -0,0 +1,149 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +use think\db\Connection; + +/** + * 参数绑定支持 + */ +trait ParamsBind +{ + /** + * 当前参数绑定. + * + * @var array + */ + protected $bind = []; + + /** + * 批量参数绑定. + * + * @param array $value 绑定变量值 + * + * @return $this + */ + public function bind(array $value) + { + $this->bind = array_merge($this->bind, $value); + + return $this; + } + + /** + * 单个参数绑定. + * + * @param mixed $value 绑定变量值 + * @param int $type 绑定类型 + * @param string $name 绑定标识 + * + * @return string + */ + public function bindValue($value, ?int $type = null, ?string $name = null) + { + $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_' . mt_rand() . '_'; + + $this->bind[$name] = [$value, $type ?: Connection::PARAM_STR]; + + return $name; + } + + /** + * 检测参数是否已经绑定. + * + * @param string $key 参数名 + * + * @return bool + */ + public function isBind(string $key) + { + return isset($this->bind[$key]); + } + + /** + * 设置自动参数绑定. + * + * @param bool $bind 是否自动参数绑定 + * + * @return $this + */ + public function autoBind(bool $bind) + { + $this->options['auto_bind'] = $bind; + + return $this; + } + + /** + * 检测是否开启自动参数绑定. + * + * @return bool + */ + public function isAutoBind(): bool + { + $autoBind = $this->getConfig('auto_param_bind'); + if (null !== $this->getOption('auto_bind')) { + $autoBind = $this->getOption('auto_bind'); + } + + return (bool) $autoBind; + } + + /** + * 参数绑定. + * + * @param string $sql 绑定的sql表达式 + * @param array $bind 参数绑定 + * + * @return void + */ + public function bindParams(string &$sql, array $bind = []): void + { + foreach ($bind as $key => $value) { + if (is_array($value)) { + $name = $this->bindValue($value[0], $value[1], $value[2] ?? null); + } else { + $name = $this->bindValue($value); + } + + if (is_numeric($key)) { + $sql = substr_replace($sql, ':' . $name, strpos($sql, '?'), 1); + } elseif (str_ends_with($sql, ':' . $key)) { + $sql = substr_replace($sql, ':' . $name . ' ', strrpos($sql, ':' . $key), strlen(':' . $key)); + } else { + $sql = str_replace( + [':' . $key . ' ', ':' . $key . ',', ':' . $key . ')'], + [':' . $name . ' ', ':' . $name . ',', ':' . $name . ')'], + $sql); + } + } + } + + /** + * 获取绑定的参数 并清空. + * + * @param bool $clear 是否清空绑定数据 + * + * @return array + */ + public function getBind(bool $clear = true): array + { + $bind = $this->bind; + if ($clear) { + $this->bind = []; + } + + return $bind; + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/ResultOperation.php b/vendor/topthink/think-orm/src/db/concern/ResultOperation.php new file mode 100644 index 0000000..3aab788 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/ResultOperation.php @@ -0,0 +1,266 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +use Closure; +use think\Collection; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; +use think\db\Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; + +/** + * 查询数据处理. + */ +trait ResultOperation +{ + /** + * 设置数据处理(支持模型). + * + * @param callable $filter 数据处理Callable + * @param string $index 索引(唯一) + * + * @return $this + */ + public function filter(callable $filter, ?string $index = null) + { + if ($index) { + $this->options['filter'][$index] = $filter; + } else { + $this->options['filter'][] = $filter; + } + + return $this; + } + + /** + * 是否允许返回空数据(或空模型). + * + * @param bool $allowEmpty 是否允许为空 + * + * @return $this + */ + public function allowEmpty(bool $allowEmpty = true) + { + $this->options['allow_empty'] = $allowEmpty; + + return $this; + } + + /** + * 设置查询数据不存在是否抛出异常. + * + * @param bool $fail 数据不存在是否抛出异常 + * + * @return $this + */ + public function failException(bool $fail = true) + { + $this->options['fail'] = $fail; + + return $this; + } + + /** + * 处理数据. + * + * @param array $result 查询数据 + * + * @return void + */ + protected function result(array &$result): void + { + // JSON数据处理 + if (!empty($this->options['json'])) { + $this->jsonResult($result); + } + + // 实时读取延迟数据 + if (!empty($this->options['lazy_fields'])) { + $id = $this->getKey($result); + foreach ($this->options['lazy_fields'] as $field) { + $result[$field] += $this->getLazyFieldValue($field, $id); + } + } + + // 查询数据处理 + foreach ($this->options['filter'] as $filter) { + $result = call_user_func_array($filter, [$result, $this->options]); + } + + // 获取器 + if (!empty($this->options['with_attr'])) { + $this->getResultAttr($result, $this->options['with_attr']); + } + + // 检查字段映射 + if (!empty($this->options['mapping'])) { + foreach ($this->options['mapping'] as $name => $alias) { + if (isset($result[$name])) { + $result[$alias] = $result[$name]; + unset($result[$name]); + } + } + } + } + + /** + * 处理数据集. + * + * @param array $resultSet 数据集 + * @param bool $toCollection 是否转为对象 + * + * @return void + */ + protected function resultSet(array &$resultSet, bool $toCollection = true): void + { + foreach ($resultSet as &$result) { + $this->result($result); + } + + // 返回Collection对象 + if ($toCollection) { + $resultSet = new Collection($resultSet); + } + } + + /** + * 使用获取器处理数据. + * + * @param array $result 查询数据 + * @param array $withAttr 字段获取器 + * + * @return void + */ + protected function getResultAttr(array &$result, array $withAttr = []): void + { + foreach ($withAttr as $name => $closure) { + $name = Str::snake($name); + + if (str_contains($name, '.')) { + // 支持JSON字段 获取器定义 + [$key, $field] = explode('.', $name); + + if (isset($result[$key])) { + $result[$key][$field] = $closure($result[$key][$field] ?? null, $result[$key]); + } + } else { + $result[$name] = $closure($result[$name] ?? null, $result); + } + } + } + + /** + * 处理空数据. + * @param Closure $closure 闭包数据 + * @throws DbException + * @throws ModelNotFoundException + * @throws DataNotFoundException + * + * @return array|Model|null|static + */ + protected function resultToEmpty(?Closure $closure = null) + { + if (!empty($this->options['fail'])) { + $this->throwNotFound(); + } elseif ($closure instanceof Closure) { + return $closure($this); + } elseif (!empty($this->options['allow_empty'])) { + return !empty($this->model) ? $this->model->newInstance() : []; + } + } + + /** + * 查找单条记录 不存在返回空数据(或者空模型). + * + * @param mixed $data 数据 + * + * @return array|Model|static|mixed + */ + public function findOrEmpty($data = null) + { + return $this->allowEmpty(true)->find($data); + } + + /** + * JSON字段数据转换. + * + * @param array $result 查询数据 + * + * @return void + */ + protected function jsonResult(array &$result): void + { + foreach ($this->options['json'] as $name) { + if (!isset($result[$name])) { + continue; + } + + $result[$name] = json_decode($result[$name], true); + } + } + + /** + * 查询失败 抛出异常. + * + * @throws ModelNotFoundException + * @throws DataNotFoundException + * + * @return void + */ + protected function throwNotFound(): void + { + if (!empty($this->model)) { + $class = get_class($this->model); + + throw new ModelNotFoundException('model data Not Found:' . $class, $class, $this->options); + } + + $table = $this->getTable(); + + throw new DataNotFoundException('table data not Found:' . $table, $table, $this->options); + } + + /** + * 查找多条记录 如果不存在则抛出异常. + * + * @param array|string|Query|Closure $data 数据 + * + * @throws ModelNotFoundException + * @throws DataNotFoundException + * + * @return array|Collection|static[] + */ + public function selectOrFail($data = []) + { + return $this->failException(true)->select($data); + } + + /** + * 查找单条记录 如果不存在则抛出异常. + * + * @param array|string|Query|Closure $data 数据 + * + * @throws ModelNotFoundException + * @throws DataNotFoundException + * + * @return array|Model|static|mixed + */ + public function findOrFail($data = null) + { + return $this->failException(true)->find($data); + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php b/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php new file mode 100644 index 0000000..04110db --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php @@ -0,0 +1,107 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +/** + * 数据字段信息. + */ +trait TableFieldInfo +{ + /** + * 获取数据表字段信息. + * + * @param string $tableName 数据表名 + * + * @return array + */ + public function getTableFields(string $tableName = ''): array + { + if ('' == $tableName && !empty($this->options['field_type'])) { + return array_keys($this->options['field_type']); + } + + return $this->connection->getTableFields($tableName ?: $this->getTable()); + } + + /** + * 获取详细字段类型信息. + * + * @param string $tableName 数据表名称 + * + * @return array + */ + public function getFields(string $tableName = ''): array + { + return $this->connection->getFields($tableName ?: $this->getTable()); + } + + /** + * 获取字段类型信息. + * + * @return array + */ + public function getFieldsType(): array + { + if (!empty($this->options['field_type'])) { + return $this->options['field_type']; + } + + return $this->connection->getFieldsType($this->getTable()); + } + + public function getType(): array + { + return $this->getFieldsType(); + } + + /** + * 获取字段类型信息. + * + * @param string $field 字段名 + * + * @return string|null + */ + public function getFieldType(string $field) + { + $fieldType = $this->getFieldsType(); + + return $fieldType[$field] ?? null; + } + + /** + * 获取字段类型信息. + * + * @return array + */ + public function getFieldsBindType(): array + { + $fieldType = $this->getFieldsType(); + + return array_map([$this->connection, 'getFieldBindType'], $fieldType); + } + + /** + * 获取字段类型信息. + * + * @param string $field 字段名 + * + * @return int + */ + public function getFieldBindType(string $field): int + { + $fieldType = $this->getFieldType($field); + + return $this->connection->getFieldBindType($fieldType ?: ''); + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php b/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php new file mode 100644 index 0000000..cbd3d23 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php @@ -0,0 +1,227 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\concern; + +/** + * 时间查询支持 + */ +trait TimeFieldQuery +{ + /** + * 日期查询表达式. + * + * @var array + */ + protected $timeRule = [ + 'today' => ['today', 'tomorrow -1second'], + 'yesterday' => ['yesterday', 'today -1second'], + 'week' => ['this week 00:00:00', 'next week 00:00:00 -1second'], + 'last week' => ['last week 00:00:00', 'this week 00:00:00 -1second'], + 'month' => ['first Day of this month 00:00:00', 'first Day of next month 00:00:00 -1second'], + 'last month' => ['first Day of last month 00:00:00', 'first Day of this month 00:00:00 -1second'], + 'year' => ['this year 1/1', 'next year 1/1 -1second'], + 'last year' => ['last year 1/1', 'this year 1/1 -1second'], + ]; + + /** + * 添加日期或者时间查询规则. + * + * @param array $rule 时间表达式 + * + * @return $this + */ + public function timeRule(array $rule) + { + $this->timeRule = array_merge($this->timeRule, $rule); + + return $this; + } + + /** + * 查询日期或者时间. + * + * @param string $field 日期字段名 + * @param string $op 比较运算符或者表达式 + * @param mixed $range 比较范围 + * @param string $logic AND OR + * + * @return $this + */ + public function whereTime(string $field, string $op, $range = null, string $logic = 'AND') + { + if (is_null($range)) { + $range = $this->timeRule[$op] ?? $op; + $op = is_array($range) ? 'between' : '>='; + } + + return $this->parseWhereExp($logic, $field, strtolower($op) . ' time', $range, [], true); + } + + /** + * 查询某个时间间隔数据. + * + * @param string $field 日期字段名 + * @param string $start 开始时间 + * @param string $interval 时间间隔单位 day/month/year/week/hour/minute/second + * @param int $step 间隔 + * @param string $logic AND OR + * + * @return $this + */ + public function whereTimeInterval(string $field, string $start, string $interval = 'day', int $step = 1, string $logic = 'AND') + { + $startTime = strtotime($start); + $endTime = strtotime(($step > 0 ? '+' : '-') . abs($step) . ' ' . $interval . (abs($step) > 1 ? 's' : ''), $startTime); + + return $this->whereTime($field, 'between', $step > 0 ? [$startTime, $endTime - 1] : [$endTime, $startTime - 1], $logic); + } + + /** + * 查询月数据 whereMonth('time_field', '2018-1'). + * + * @param string $field 日期字段名 + * @param string $month 月份信息 + * @param int $step 间隔 + * @param string $logic AND OR + * + * @return $this + */ + public function whereMonth(string $field, string $month = 'this month', int $step = 1, string $logic = 'AND') + { + if (in_array($month, ['this month', 'last month'])) { + if($month === 'last month') { + $month = $this->timeRule['last month'][0]; + } + + $month = date('Y-m', strtotime($month)); + } + + return $this->whereTimeInterval($field, $month, 'month', $step, $logic); + } + + /** + * 查询周数据 whereWeek('time_field', '2018-1-1') 从2018-1-1开始的一周数据. + * + * @param string $field 日期字段名 + * @param string $week 周信息 + * @param int $step 间隔 + * @param string $logic AND OR + * + * @return $this + */ + public function whereWeek(string $field, string $week = 'this week', int $step = 1, string $logic = 'AND') + { + if (in_array($week, ['this week', 'last week'])) { + $week = date('Y-m-d', strtotime($week)); + } + + return $this->whereTimeInterval($field, $week, 'week', $step, $logic); + } + + /** + * 查询年数据 whereYear('time_field', '2018'). + * + * @param string $field 日期字段名 + * @param string $year 年份信息 + * @param int $step 间隔 + * @param string $logic AND OR + * + * @return $this + */ + public function whereYear(string $field, string $year = 'this year', int $step = 1, string $logic = 'AND') + { + if (in_array($year, ['this year', 'last year'])) { + $year = date('Y', strtotime($year)); + } + + return $this->whereTimeInterval($field, $year . '-1-1', 'year', $step, $logic); + } + + /** + * 查询日数据 whereDay('time_field', '2018-1-1'). + * + * @param string $field 日期字段名 + * @param string $day 日期信息 + * @param int $step 间隔 + * @param string $logic AND OR + * + * @return $this + */ + public function whereDay(string $field, string $day = 'today', int $step = 1, string $logic = 'AND') + { + if (in_array($day, ['today', 'yesterday'])) { + $day = date('Y-m-d', strtotime($day)); + } + + return $this->whereTimeInterval($field, $day, 'day', $step, $logic); + } + + /** + * 查询日期或者时间范围 whereBetweenTime('time_field', '2018-1-1','2018-1-15'). + * + * @param string $field 日期字段名 + * @param string|int $startTime 开始时间 + * @param string|int $endTime 结束时间 + * @param string $logic AND OR + * + * @return $this + */ + public function whereBetweenTime(string $field, $startTime, $endTime, string $logic = 'AND') + { + return $this->whereTime($field, 'between', [$startTime, $endTime], $logic); + } + + /** + * 查询日期或者时间范围 whereNotBetweenTime('time_field', '2018-1-1','2018-1-15'). + * + * @param string $field 日期字段名 + * @param string|int $startTime 开始时间 + * @param string|int $endTime 结束时间 + * + * @return $this + */ + public function whereNotBetweenTime(string $field, $startTime, $endTime) + { + return $this->whereTime($field, '<', $startTime) + ->whereTime($field, '>', $endTime, 'OR'); + } + + /** + * 查询当前时间在两个时间字段范围 whereBetweenTimeField('start_time', 'end_time'). + * + * @param string $startField 开始时间字段 + * @param string $endField 结束时间字段 + * + * @return $this + */ + public function whereBetweenTimeField(string $startField, string $endField) + { + return $this->whereTime($startField, '<=', time()) + ->whereTime($endField, '>=', time()); + } + + /** + * 查询当前时间不在两个时间字段范围 whereNotBetweenTimeField('start_time', 'end_time'). + * + * @param string $startField 开始时间字段 + * @param string $endField 结束时间字段 + * + * @return $this + */ + public function whereNotBetweenTimeField(string $startField, string $endField) + { + return $this->whereTime($startField, '>', time()) + ->whereTime($endField, '<', time(), 'OR'); + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/Transaction.php b/vendor/topthink/think-orm/src/db/concern/Transaction.php new file mode 100644 index 0000000..4c2c421 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/Transaction.php @@ -0,0 +1,131 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\concern; + +/** + * 事务支持 + */ +trait Transaction +{ + /** + * 执行数据库Xa事务 + * + * @param callable $callback 数据操作方法回调 + * @param array $dbs 多个查询对象或者连接对象 + * + * @throws \PDOException + * @throws \Exception + * @throws \Throwable + * + * @return mixed + */ + public function transactionXa(callable $callback, array $dbs = []) + { + return $this->connection->transactionXa($callback, $dbs); + } + + /** + * 执行数据库事务 + * + * @param callable $callback 数据操作方法回调 + * + * @return mixed + */ + public function transaction(callable $callback) + { + return $this->connection->transaction($callback); + } + + /** + * 启动事务 + * + * @return void + */ + public function startTrans(): void + { + $this->connection->startTrans(); + } + + /** + * 用于非自动提交状态下面的查询提交. + * + * @throws \PDOException + * + * @return void + */ + public function commit(): void + { + $this->connection->commit(); + } + + /** + * 事务回滚. + * + * @throws \PDOException + * + * @return void + */ + public function rollback(): void + { + $this->connection->rollback(); + } + + /** + * 启动XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function startTransXa(string $xid): void + { + $this->connection->startTransXa($xid); + } + + /** + * 预编译XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function prepareXa(string $xid): void + { + $this->connection->prepareXa($xid); + } + + /** + * 提交XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function commitXa(string $xid): void + { + $this->connection->commitXa($xid); + } + + /** + * 回滚XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function rollbackXa(string $xid): void + { + $this->connection->rollbackXa($xid); + } +} diff --git a/vendor/topthink/think-orm/src/db/concern/WhereQuery.php b/vendor/topthink/think-orm/src/db/concern/WhereQuery.php new file mode 100644 index 0000000..7f7f2d8 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/concern/WhereQuery.php @@ -0,0 +1,670 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\concern; + +use Closure; +use think\db\BaseQuery; +use think\db\Raw; + +trait WhereQuery +{ + /** + * 指定AND查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * + * @return $this + */ + public function where($field, $op = null, $condition = null) + { + if ($field instanceof self) { + $this->parseQueryWhere($field); + return $this; + } elseif (true === $field || 1 === $field) { + $this->options['where']['AND'][] = true; + return $this; + } elseif (empty($field)) { + return $this; + } + + $pk = $this->getPk(); + if ((is_null($condition) || '=' == $op) && is_string($pk) && $pk == $field) { + $this->options['key'] = is_null($condition) ? $op : $condition; + } + + $logic = 'AND'; + $param = func_get_args(); + array_shift($param); + + if (is_array($field) && !empty($field) && array_is_list($field)) { + return $this->where(function ($query) use ($param, $condition, $op, $field, $logic) { + return $query->parseWhereExp($logic, $field, $op, $condition, $param); + }); + } + + return $this->parseWhereExp($logic, $field, $op, $condition, $param); + } + + /** + * 解析Query对象查询条件. + * + * @param BaseQuery $query 查询对象 + * + * @return void + */ + protected function parseQueryWhere(BaseQuery $query): void + { + $this->options['where'] = $query->getOption('where', []); + + $via = $query->getOption('via'); + if ($via) { + foreach ($this->options['where'] as $logic => &$where) { + foreach ($where as $key => &$val) { + if (is_array($val) && !str_contains($val[0], '.')) { + $val[0] = $via . '.' . $val[0]; + } + } + } + } + + $this->bind($query->getBind(false)); + } + + /** + * 指定OR查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * + * @return $this + */ + public function whereOr($field, $op = null, $condition = null) + { + $logic = 'OR'; + $param = func_get_args(); + array_shift($param); + + if (is_array($field) && !empty($field) && array_is_list($field)) { + return $this->where(function ($query) use ($param, $condition, $op, $field, $logic) { + return $query->parseWhereExp($logic, $field, $op, $condition, $param); + }); + } + + return $this->parseWhereExp($logic, $field, $op, $condition, $param); + } + + /** + * 指定XOR查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * + * @return $this + */ + public function whereXor($field, $op = null, $condition = null) + { + $logic = 'XOR'; + $param = func_get_args(); + array_shift($param); + + if (is_array($field) && !empty($field) && array_is_list($field)) { + return $this->where(function ($query) use ($param, $condition, $op, $field, $logic) { + return $query->parseWhereExp($logic, $field, $op, $condition, $param); + }); + } + + return $this->parseWhereExp($logic, $field, $op, $condition, $param); + } + + /** + * 指定Null查询条件. + * + * @param mixed $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereNull(string $field, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'NULL', null, [], true); + } + + /** + * 指定NotNull查询条件. + * + * @param mixed $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereNotNull(string $field, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'NOTNULL', null, [], true); + } + + /** + * 指定Exists查询条件. + * + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereExists($condition, string $logic = 'AND') + { + if (is_string($condition)) { + $condition = new Raw($condition); + } + + $this->options['where'][strtoupper($logic)][] = ['', 'EXISTS', $condition]; + + return $this; + } + + /** + * 指定NotExists查询条件. + * + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereNotExists($condition, string $logic = 'AND') + { + if (is_string($condition)) { + $condition = new Raw($condition); + } + + $this->options['where'][strtoupper($logic)][] = ['', 'NOT EXISTS', $condition]; + + return $this; + } + + /** + * 指定In查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereIn(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'IN', $condition, [], true); + } + + /** + * 指定NotIn查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereNotIn(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'NOT IN', $condition, [], true); + } + + /** + * 指定Like查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereLike(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'LIKE', $condition, [], true); + } + + /** + * 指定NotLike查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereNotLike(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'NOT LIKE', $condition, [], true); + } + + /** + * 指定Between查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereBetween(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'BETWEEN', $condition, [], true); + } + + /** + * 指定NotBetween查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereNotBetween(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'NOT BETWEEN', $condition, [], true); + } + + /** + * 指定FIND_IN_SET查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereFindInSet(string $field, $condition, string $logic = 'AND') + { + return $this->parseWhereExp($logic, $field, 'FIND IN SET', $condition, [], true); + } + + /** + * 指定json_contains查询条件. + * + * @param mixed $field 查询字段 + * @param mixed $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereJsonContains(string $field, $condition, string $logic = 'AND') + { + $value = is_null($condition) ? 'NULL' : '\'' . json_encode($condition) . '\''; + + if (str_contains($field, '->')) { + [$field, $path] = explode('->', $field, 2); + return $this->whereRaw('json_contains(' . $field . ', ' . $value . ', \'$.'. str_replace('->', '.', $path) . '\')', [], $logic); + } + return $this->whereRaw('json_contains(' . $field . ', ' . $value . ')', [], $logic); + } + + public function whereOrJsonContains(string $field, $condition) + { + return $this->whereJsonContains($field, $condition, 'OR'); + } + + /** + * 比较两个字段. + * + * @param string $field1 查询字段 + * @param string $operator 比较操作符 + * @param string $field2 比较字段 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereColumn(string $field1, string $operator, ?string $field2 = null, string $logic = 'AND') + { + if (is_null($field2)) { + $field2 = $operator; + $operator = '='; + } + + return $this->parseWhereExp($logic, $field1, 'COLUMN', [$operator, $field2], [], true); + } + + /** + * 设置软删除字段及条件. + * + * @param string $field 查询字段 + * @param mixed $condition 查询条件 + * + * @return $this + */ + public function useSoftDelete(string $field, $condition = null) + { + if ($field) { + $this->options['soft_delete'] = [$field, $condition]; + } + + return $this; + } + + /** + * 包含软删除数据. + * + * @return $this + */ + public function withTrashed() + { + if ($this->model) { + $this->options['soft_delete'] = null; + } + + return $this; + } + + /** + * 指定Exp查询条件. + * + * @param mixed $field 查询字段 + * @param string $where 查询条件 + * @param array $bind 参数绑定 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereExp(string $field, string $where, array $bind = [], string $logic = 'AND') + { + $this->options['where'][$logic][] = [$field, 'EXP', new Raw($where, $bind)]; + + return $this; + } + + /** + * 指定字段Raw查询. + * + * @param string $field 查询字段表达式 + * @param mixed $op 查询表达式 + * @param string $condition 查询条件 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereFieldRaw(string $field, $op, $condition = null, string $logic = 'AND') + { + if (is_null($condition)) { + $condition = $op; + $op = '='; + } + + $this->options['where'][$logic][] = [new Raw($field), $op, $condition]; + + return $this; + } + + /** + * 指定表达式查询条件. + * + * @param string $where 查询条件 + * @param array $bind 参数绑定 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function whereRaw(string $where, array $bind = [], string $logic = 'AND') + { + $this->options['where'][$logic][] = new Raw($where, $bind); + + return $this; + } + + /** + * 指定表达式查询条件 OR. + * + * @param string $where 查询条件 + * @param array $bind 参数绑定 + * + * @return $this + */ + public function whereOrRaw(string $where, array $bind = []) + { + return $this->whereRaw($where, $bind, 'OR'); + } + + /** + * 分析查询表达式. + * + * @param string $logic 查询逻辑 and or xor + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * @param array $param 查询参数 + * @param bool $strict 严格模式 + * + * @return $this + */ + protected function parseWhereExp(string $logic, $field, $op, $condition, array $param = [], bool $strict = false): self + { + $logic = strtoupper($logic); + + // 字段映射 + $map = $this->getOption('field_map', []); + if (is_string($field) && isset($map[$field])) { + $field = $map[$field]; + } + + // 处理 via + if (is_string($field) && !empty($this->options['via']) && !str_contains($field, '.') && !str_contains($field, '->')) { + $field = $this->options['via'] . '.' . $field; + } + + // 严格模式查询 + if ($strict) { + return $this->parseStrictWhere($field, $op, $condition, $logic); + } + + // 处理批量查询 + if (is_array($field)) { + return $this->parseArrayWhereItems($field, $logic); + } + + // 处理闭包查询 + if ($field instanceof Closure) { + $where = $field; + } elseif (is_string($field)) { + if ($condition instanceof Raw) { + } elseif (preg_match('/[,=\<\'\"\(\s]/', $field)) { + return $this->whereRaw($field, is_array($op) ? $op : [], $logic); + } elseif (is_string($op) && strtolower($op) === 'exp' && !is_null($condition)) { + $bind = isset($param[2]) && is_array($param[2]) ? $param[2] : []; + return $this->whereExp($field, $condition, $bind, $logic); + } + + $where = $this->parseWhereItem($logic, $field, $op, $condition, $param); + } + + // 添加条件到查询选项 + if (!empty($where)) { + $this->options['where'][$logic][] = $where; + } + + return $this; + } + + protected function parseStrictWhere($field, $op, $condition, string $logic): self + { + if ('=' === $op) { + $where = $this->whereEq($field, $condition); + } else { + $where = [$field, $op, $condition, $logic]; + } + + $this->options['where'][$logic][] = $where; + + return $this; + } + + /** + * 分析查询表达式. + * + * @param string $logic 查询逻辑 and or xor + * @param mixed $field 查询字段 + * @param mixed $op 查询表达式 + * @param mixed $condition 查询条件 + * @param array $param 查询参数 + * + * @return array + */ + protected function parseWhereItem(string $logic, $field, $op, $condition, array $param = []): array + { + if (is_array($op)) { + // 同一字段多条件查询 + array_unshift($param, $field); + return $param; + } + + if (is_string($field) && strpos($field, '->')) { + [$relation, $attr] = explode('->', $field, 2); + + $type = $this->getFieldType($relation); + if (is_null($type)) { + // 自动关联查询 + $this->hasWhere($relation, [[$attr , is_null($condition) ? '=' : $op, $condition ?? $op]]); + return []; + } + } + + if ($field && is_null($condition)) { + if (is_string($op) && in_array(strtoupper($op), ['NULL', 'NOTNULL', 'NOT NULL'], true)) { + // null查询 + $where = [$field, $op, '']; + } elseif ('=' === $op || is_null($op)) { + $where = [$field, 'NULL', '']; + } elseif ('<>' === $op) { + $where = [$field, 'NOTNULL', '']; + } else { + // 字段相等查询 + $where = $this->whereEq($field, $op); + } + return $where; + } + + if (is_string($op) && in_array(strtoupper($op), ['EXISTS', 'NOT EXISTS', 'NOTEXISTS'], true)) { + $where = [$field, $op, is_string($condition) ? new Raw($condition) : $condition]; + } else { + $where = $field ? [$field, $op, $condition, $param[2] ?? null] : []; + } + + return $where; + } + + /** + * 相等查询的主键处理. + * + * @param string $field 字段名 + * @param mixed $value 字段值 + * + * @return array + */ + protected function whereEq(string $field, $value): array + { + if ($this->getPk() == $field) { + $this->options['key'] = $value; + } + + return [$field, '=', $value]; + } + + /** + * 数组批量查询. + * + * @param array $field 批量查询 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + protected function parseArrayWhereItems(array $field, string $logic) + { + $where = []; + foreach ($field as $key => $val) { + if (is_int($key)) { + $where[] = $val; + } elseif ($val instanceof Raw) { + $where[] = [$key, 'exp', $val]; + } else { + $where[] = is_null($val) ? [$key, 'NULL', ''] : [$key, is_array($val) ? 'IN' : '=', $val]; + } + } + + if (!empty($where)) { + $this->options['where'][$logic] = isset($this->options['where'][$logic]) ? + array_merge($this->options['where'][$logic], $where) : $where; + } + + return $this; + } + + /** + * 去除某个查询条件. + * + * @param string $field 查询字段 + * @param string $logic 查询逻辑 and or xor + * + * @return $this + */ + public function removeWhereField(string $field, string $logic = 'AND') + { + $logic = strtoupper($logic); + + if (isset($this->options['where'][$logic])) { + foreach ($this->options['where'][$logic] as $key => $val) { + if (is_array($val) && $val[0] == $field) { + unset($this->options['where'][$logic][$key]); + } + } + } + + return $this; + } + + /** + * 条件查询. + * + * @param mixed $condition 满足条件(支持闭包) + * @param Closure|array $query 满足条件后执行的查询表达式(闭包或数组) + * @param Closure|array $otherwise 不满足条件后执行 + * + * @return $this + */ + public function when($condition, Closure | array $query, Closure | array | null $otherwise = null) + { + // 处理条件为 Closure 的情况 + if ($condition instanceof Closure) { + $condition = $condition($this); + } + + // 根据条件决定执行哪个查询 + if ($condition) { + $this->executeQuery($query, $condition); + } elseif ($otherwise) { + $this->executeQuery($otherwise, $condition); + } + + return $this; + } + + protected function executeQuery(Closure | array $query, $condition): void + { + if ($query instanceof Closure) { + $query($this, $condition); + } elseif (is_array($query)) { + $this->where($query); + } + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/Mongo.php b/vendor/topthink/think-orm/src/db/connector/Mongo.php new file mode 100644 index 0000000..e40b9da --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/Mongo.php @@ -0,0 +1,1214 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\db\connector; + +use Closure; +use MongoDB\BSON\ObjectID; +use MongoDB\Driver\BulkWrite; +use MongoDB\Driver\Command; +use MongoDB\Driver\Cursor; +use MongoDB\Driver\Exception\AuthenticationException; +use MongoDB\Driver\Exception\BulkWriteException; +use MongoDB\Driver\Exception\ConnectionException; +use MongoDB\Driver\Exception\InvalidArgumentException; +use MongoDB\Driver\Exception\RuntimeException; +use MongoDB\Driver\Manager; +use MongoDB\Driver\Query as MongoQuery; +use MongoDB\Driver\ReadPreference; +use MongoDB\Driver\WriteConcern; +use think\db\BaseQuery; +use think\db\builder\Mongo as Builder; +use think\db\Connection; +use think\db\exception\DbEventException; +use think\db\exception\DbException as Exception; +use think\db\Mongo as Query; + +/** + * Mongo数据库驱动. + * + * @property Manager[] $links + * @property Manager $linkRead + * @property Manager $linkWrite + */ +class Mongo extends Connection +{ + // 查询数据类型 + protected $dbName = ''; + protected $typeMap = 'array'; + protected $mongo; // MongoDb Object + protected $cursor; // MongoCursor Object + protected $session_uuid; // sessions会话列表当前会话数组key 随机生成 + protected $sessions = []; // 会话列表 + + /** @var Builder */ + protected $builder; + + // 数据库连接参数配置 + protected $config = [ + // 数据库类型 + 'type' => '', + // 服务器地址 + 'hostname' => '', + // 数据库名 + 'database' => '', + // 是否是复制集 + 'is_replica_set' => false, + // 用户名 + 'username' => '', + // 密码 + 'password' => '', + // 端口 + 'hostport' => '', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 主键名 + 'pk' => '_id', + // 主键类型 + 'pk_type' => 'ObjectID', + // 数据库表前缀 + 'prefix' => '', + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 开启字段缓存 + 'fields_cache' => false, + // 监听SQL + 'trigger_sql' => true, + // Builder类 + 'builder' => '', + // Query类 + 'query' => '', + // 自动写入时间戳字段 + 'auto_timestamp' => false, + // 时间字段取出后的默认时间格式 + 'datetime_format' => 'Y-m-d H:i:s', + // 是否_id转换为id + 'pk_convert_id' => false, + // typeMap + 'type_map' => ['root' => 'array', 'document' => 'array'], + ]; + + /** + * 获取当前连接器类对应的Query类. + * + * @return string + */ + public function getQueryClass(): string + { + return $this->getConfig('query') ?: Query::class; + } + + /** + * 获取当前的builder实例对象 + * + * @return Builder + */ + public function getBuilder() + { + return $this->builder; + } + + /** + * 获取当前连接器类对应的Builder类. + * + * @return string + */ + public function getBuilderClass(): string + { + return $this->getConfig('builder') ?: Builder::class; + } + + /** + * 连接数据库方法. + * + * @param array $config 连接参数 + * @param int $linkNum 连接序号 + * + * @throws InvalidArgumentException + * @throws RuntimeException + * + * @return Manager + */ + public function connect(array $config = [], $linkNum = 0) + { + if (!isset($this->links[$linkNum])) { + if (empty($config)) { + $config = $this->config; + } else { + $config = array_merge($this->config, $config); + } + + $this->dbName = $config['database']; + $this->typeMap = $config['type_map']; + + if ($config['pk_convert_id'] && '_id' == $config['pk']) { + $this->config['pk'] = 'id'; + } + + if (empty($config['dsn'])) { + $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : ''); + } + + $startTime = microtime(true); + + $this->links[$linkNum] = new Manager($config['dsn'], $config['params']); + + if (!empty($config['trigger_sql'])) { + // 记录数据库连接信息 + $this->trigger('CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']); + } + } + + return $this->links[$linkNum]; + } + + /** + * 获取Mongo Manager对象 + * + * @return Manager|null + */ + public function getMongo() + { + return $this->mongo ?: null; + } + + /** + * 设置/获取当前操作的database. + * + * @param string $db db + * + * @return string + */ + public function db(?string $db = null) + { + if (is_null($db)) { + return $this->dbName; + } else { + $this->dbName = $db; + } + } + + /** + * 执行查询但只返回Cursor对象 + * + * @param Query $query 查询对象 + * + * @return Cursor + */ + public function cursor($query) + { + // 分析查询表达式 + $options = $query->parseOptions(); + + // 生成MongoQuery对象 + $mongoQuery = $this->builder->select($query); + $master = (bool) $query->getOption('master'); + + // 执行查询操作 + return $this->getCursor($query, $mongoQuery, $master); + } + + /** + * 执行查询并返回Cursor对象 + * + * @param BaseQuery $query 查询对象 + * @param MongoQuery|Closure $mongoQuery Mongo查询对象 + * @param bool $master 是否主库操作 + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return Cursor + */ + public function getCursor(BaseQuery $query, $mongoQuery, bool $master = false): Cursor + { + $this->initConnect($master); + $this->db->updateQueryTimes(); + + $options = $query->getOptions(); + $namespace = $options['table']; + + if (!str_contains($namespace, '.')) { + $namespace = $this->dbName . '.' . $namespace; + } + + if (!empty($this->queryStr)) { + // 记录执行指令 + $this->queryStr = 'db' . strstr($namespace, '.') . '.' . $this->queryStr; + } + + if ($mongoQuery instanceof Closure) { + $mongoQuery = $mongoQuery($query); + } + + $readPreference = $options['readPreference'] ?? null; + $this->queryStartTime = microtime(true); + + if ($session = $this->getSession()) { + $this->cursor = $this->mongo->executeQuery($namespace, $mongoQuery, [ + 'readPreference' => is_null($readPreference) ? new ReadPreference(ReadPreference::RP_PRIMARY) : $readPreference, + 'session' => $session, + ]); + } else { + $this->cursor = $this->mongo->executeQuery($namespace, $mongoQuery, $readPreference); + } + + // SQL监控 + if (!empty($this->config['trigger_sql'])) { + $this->trigger('', $master); + } + + return $this->cursor; + } + + /** + * 执行查询 返回数据集. + * + * @param MongoQuery $query 查询对象 + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return mixed + */ + public function query(MongoQuery $query) + { + return $this->mongoQuery($this->newQuery(), $query); + } + + /** + * 执行语句. + * + * @param BulkWrite $bulk + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * @throws BulkWriteException + * + * @return int + */ + public function execute(BulkWrite $bulk) + { + return $this->mongoExecute($this->newQuery(), $bulk); + } + + /** + * 执行查询. + * + * @param BaseQuery $query 查询对象 + * @param MongoQuery|Closure $mongoQuery Mongo查询对象 + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return array + */ + protected function mongoQuery(BaseQuery $query, $mongoQuery): array + { + $options = $query->parseOptions(); + + if ($query->getOption('cache')) { + // 检查查询缓存 + $cacheItem = $this->parseCache($query, $query->getOption('cache')); + $key = $cacheItem->getKey(); + + if ($this->cache->has($key)) { + return $this->cache->get($key); + } + } + + if ($mongoQuery instanceof Closure) { + $mongoQuery = $mongoQuery($query); + } + + $master = (bool) $query->getOption('master'); + $this->getCursor($query, $mongoQuery, $master); + + $resultSet = $this->getResult($options['typeMap']); + + if (isset($cacheItem) && $resultSet) { + // 缓存数据集 + $cacheItem->set($resultSet); + $this->cacheData($cacheItem); + } + + return $resultSet; + } + + /** + * 执行写操作. + * + * @param BaseQuery $query + * @param BulkWrite $bulk + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * @throws BulkWriteException + * + * @return WriteResult + */ + protected function mongoExecute(BaseQuery $query, BulkWrite $bulk) + { + $this->initConnect(true); + $this->db->updateQueryTimes(); + + $options = $query->getOptions(); + $namespace = $options['table']; + if (!str_contains($namespace, '.')) { + $namespace = $this->dbName . '.' . $namespace; + } + + if (!empty($this->queryStr)) { + // 记录执行指令 + $this->queryStr = 'db' . strstr($namespace, '.') . '.' . $this->queryStr; + } + + $writeConcern = $options['writeConcern'] ?? null; + $this->queryStartTime = microtime(true); + + if ($session = $this->getSession()) { + $writeResult = $this->mongo->executeBulkWrite($namespace, $bulk, [ + 'session' => $session, + 'writeConcern' => is_null($writeConcern) ? new WriteConcern(1) : $writeConcern, + ]); + } else { + $writeResult = $this->mongo->executeBulkWrite($namespace, $bulk, $writeConcern); + } + + // SQL监控 + if (!empty($this->config['trigger_sql'])) { + $this->trigger(); + } + + $this->numRows = $writeResult->getMatchedCount(); + + if ($query->getOption('cache')) { + // 清理缓存数据 + $cacheItem = $this->parseCache($query, $query->getOption('cache')); + $key = $cacheItem->getKey(); + $tag = $cacheItem->getTag(); + + if (isset($key) && $this->cache->has($key)) { + $this->cache->delete($key); + } elseif (!empty($tag) && method_exists($this->cache, 'tag')) { + $this->cache->tag($tag)->clear(); + } + } + + return $writeResult; + } + + /** + * 执行指令. + * + * @param Command $command 指令 + * @param string $dbName 当前数据库名 + * @param ReadPreference $readPreference readPreference + * @param string|array $typeMap 指定返回的typeMap + * @param bool $master 是否主库操作 + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return array + */ + public function command(Command $command, string $dbName = '', ?ReadPreference $readPreference = null, $typeMap = null, bool $master = false): array + { + $this->initConnect($master); + $this->db->updateQueryTimes(); + + $this->queryStartTime = microtime(true); + + $dbName = $dbName ?: $this->dbName; + + if (!empty($this->queryStr)) { + $this->queryStr = 'db.' . $this->queryStr; + } + + if ($session = $this->getSession()) { + $this->cursor = $this->mongo->executeCommand($dbName, $command, [ + 'readPreference' => is_null($readPreference) ? new ReadPreference(ReadPreference::RP_PRIMARY) : $readPreference, + 'session' => $session, + ]); + } else { + $this->cursor = $this->mongo->executeCommand($dbName, $command, $readPreference); + } + + // SQL监控 + if (!empty($this->config['trigger_sql'])) { + $this->trigger('', $master); + } + + return $this->getResult($typeMap); + } + + /** + * 获得数据集. + * + * @param string|array $typeMap 指定返回的typeMap + * + * @return mixed + */ + protected function getResult($typeMap = null): array + { + // 设置结果数据类型 + if (is_null($typeMap)) { + $typeMap = $this->typeMap; + } + + $typeMap = is_string($typeMap) ? ['root' => $typeMap] : $typeMap; + + $this->cursor->setTypeMap($typeMap); + + // 获取数据集 + $result = $this->cursor->toArray(); + + if ($this->getConfig('pk_convert_id')) { + // 转换ObjectID 字段 + foreach ($result as &$data) { + $this->convertObjectID($data); + } + } + + $this->numRows = count($result); + + return $result; + } + + /** + * ObjectID处理. + * + * @param array $data 数据 + * + * @return void + */ + protected function convertObjectID(array &$data): void + { + if (isset($data['_id']) && is_object($data['_id'])) { + $data['id'] = $data['_id']->__toString(); + unset($data['_id']); + } + } + + /** + * 数据库日志记录(仅供参考). + * + * @param string $type 类型 + * @param mixed $data 数据 + * @param array $options 参数 + * + * @return void + */ + public function mongoLog(string $type, $data, array $options = []) + { + if (!$this->config['trigger_sql']) { + return; + } + + if (is_array($data)) { + array_walk_recursive($data, function (&$value) { + if ($value instanceof ObjectID) { + $value = $value->__toString(); + } + }); + } + + switch (strtolower($type)) { + case 'aggregate': + $this->queryStr = 'runCommand(' . ($data ? json_encode($data) : '') . ');'; + break; + case 'find': + $this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ')'; + + if (isset($options['sort'])) { + $this->queryStr .= '.sort(' . json_encode($options['sort']) . ')'; + } + + if (isset($options['skip'])) { + $this->queryStr .= '.skip(' . $options['skip'] . ')'; + } + + if (isset($options['limit'])) { + $this->queryStr .= '.limit(' . $options['limit'] . ')'; + } + + $this->queryStr .= ';'; + break; + case 'insert': + case 'remove': + $this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ');'; + break; + case 'update': + $this->queryStr = $type . '(' . json_encode($options) . ',' . json_encode($data) . ');'; + break; + case 'cmd': + $this->queryStr = $data . '(' . json_encode($options) . ');'; + break; + } + } + + /** + * 获取最近执行的指令. + * + * @return string + */ + public function getLastSql(): string + { + return $this->queryStr; + } + + /** + * 关闭数据库. + */ + public function close() + { + $this->mongo = null; + $this->cursor = null; + $this->linkRead = null; + $this->linkWrite = null; + $this->links = []; + } + + /** + * 初始化数据库连接. + * + * @param bool $master 是否主服务器 + * + * @return void + */ + protected function initConnect(bool $master = true): void + { + if (!empty($this->config['deploy'])) { + // 采用分布式数据库 + if ($master) { + if (!$this->linkWrite) { + $this->linkWrite = $this->multiConnect(true); + } + + $this->mongo = $this->linkWrite; + } else { + if (!$this->linkRead) { + $this->linkRead = $this->multiConnect(false); + } + + $this->mongo = $this->linkRead; + } + } elseif (!$this->mongo) { + // 默认单数据库 + $this->mongo = $this->connect(); + } + } + + /** + * 连接分布式服务器. + * + * @param bool $master 主服务器 + * + * @return Manager + */ + protected function multiConnect(bool $master = false): Manager + { + $config = []; + // 分布式数据库配置解析 + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn'] as $name) { + $config[$name] = is_string($this->config[$name]) ? explode(',', $this->config[$name]) : $this->config[$name]; + } + + // 主服务器序号 + $m = floor(mt_rand(0, $this->config['master_num'] - 1)); + + if ($this->config['rw_separate']) { + // 主从式采用读写分离 + if ($master) { + // 主服务器写入 + if ($this->config['is_replica_set']) { + return $this->replicaSetConnect(); + } else { + $r = $m; + } + } elseif (is_numeric($this->config['slave_no'])) { + // 指定服务器读 + $r = $this->config['slave_no']; + } else { + // 读操作连接从服务器 每次随机连接的数据库 + $r = floor(mt_rand($this->config['master_num'], count($config['hostname']) - 1)); + } + } else { + // 读写操作不区分服务器 每次随机连接的数据库 + $r = floor(mt_rand(0, count($config['hostname']) - 1)); + } + + $dbConfig = []; + + foreach (['username', 'password', 'hostname', 'hostport', 'database', 'dsn'] as $name) { + $dbConfig[$name] = $config[$name][$r] ?? $config[$name][0]; + } + + return $this->connect($dbConfig, $r); + } + + /** + * 创建基于复制集的连接. + * + * @return Manager + */ + public function replicaSetConnect(): Manager + { + $this->dbName = $this->config['database']; + $this->typeMap = $this->config['type_map']; + $startTime = microtime(true); + + $this->config['params']['replicaSet'] = $this->config['database']; + + $manager = new Manager($this->buildUrl(), $this->config['params']); + + // 记录数据库连接信息 + if (!empty($config['trigger_sql'])) { + $this->trigger('CONNECT:ReplicaSet[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $this->config['dsn']); + } + + return $manager; + } + + /** + * 根据配置信息 生成适用于连接复制集的 URL. + * + * @return string + */ + private function buildUrl(): string + { + $url = 'mongodb://' . ($this->config['username'] ? "{$this->config['username']}" : '') . ($this->config['password'] ? ":{$this->config['password']}@" : ''); + + $hostList = is_string($this->config['hostname']) ? explode(',', $this->config['hostname']) : $this->config['hostname']; + $portList = is_string($this->config['hostport']) ? explode(',', $this->config['hostport']) : $this->config['hostport']; + + for ($i = 0; $i < count($hostList); $i++) { + $url = $url . $hostList[$i] . ':' . $portList[0] . ','; + } + + return rtrim($url, ',') . '/'; + } + + /** + * 插入记录. + * + * @param BaseQuery $query 查询对象 + * @param bool $getLastInsID 返回自增主键 + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * @throws BulkWriteException + * + * @return mixed + */ + public function insert(BaseQuery $query, bool $getLastInsID = false) + { + // 分析查询表达式 + $options = $query->parseOptions(); + + if (empty($options['data'])) { + throw new Exception('miss data to insert'); + } + + // 生成bulk对象 + $bulk = $this->builder->insert($query); + $writeResult = $this->mongoExecute($query, $bulk); + $result = $writeResult->getInsertedCount(); + + if ($result) { + $data = $options['data']; + $lastInsId = $this->getLastInsID($query); + + if ($lastInsId) { + $pk = $query->getPk(); + $data[$pk] = $lastInsId; + } + + $query->setOption('data', $data); + + $this->db->trigger('after_insert', $query); + + if ($getLastInsID) { + return $lastInsId; + } + } + + return $result; + } + + /** + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 + * @param string $sequence 自增序列名 + * + * @return mixed + */ + public function getLastInsID(BaseQuery $query, ?string $sequence = null) + { + $id = $this->builder->getLastInsID(); + + if (is_array($id)) { + array_walk($id, function (&$item, $key) { + if ($item instanceof ObjectID) { + $item = $item->__toString(); + } + }); + } elseif ($id instanceof ObjectID) { + $id = $id->__toString(); + } + + return $id; + } + + /** + * 批量插入记录. + * + * @param BaseQuery $query 查询对象 + * @param array $dataSet 数据集 + * + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * @throws BulkWriteException + * + * @return int + */ + public function insertAll(BaseQuery $query, array $dataSet = []): int + { + // 分析查询表达式 + $query->parseOptions(); + + if (!is_array(reset($dataSet))) { + return 0; + } + + // 生成bulkWrite对象 + $bulk = $this->builder->insertAll($query, $dataSet); + $writeResult = $this->mongoExecute($query, $bulk); + + return $writeResult->getInsertedCount(); + } + + /** + * 更新记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws Exception + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * @throws BulkWriteException + * + * @return int + */ + public function update(BaseQuery $query): int + { + $query->parseOptions(); + + // 生成bulkWrite对象 + $bulk = $this->builder->update($query); + $writeResult = $this->mongoExecute($query, $bulk); + $result = $writeResult->getModifiedCount(); + + if ($result) { + $this->db->trigger('after_update', $query); + } + + return $result; + } + + /** + * 删除记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws Exception + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * @throws BulkWriteException + * + * @return int + */ + public function delete(BaseQuery $query): int + { + // 分析查询表达式 + $query->parseOptions(); + + // 生成bulkWrite对象 + $bulk = $this->builder->delete($query); + // 执行操作 + $writeResult = $this->mongoExecute($query, $bulk); + $result = $writeResult->getDeletedCount(); + + if ($result) { + $this->db->trigger('after_delete', $query); + } + + return $result; + } + + /** + * 查找记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws ModelNotFoundException + * @throws DataNotFoundException + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return array + */ + public function select(BaseQuery $query): array + { + try { + $this->db->trigger('before_select', $query); + } catch (DbEventException $e) { + return []; + } + + return $this->mongoQuery($query, function ($query) { + return $this->builder->select($query); + }); + } + + /** + * 查找单条记录. + * + * @param BaseQuery $query 查询对象 + * + * @throws ModelNotFoundException + * @throws DataNotFoundException + * @throws AuthenticationException + * @throws InvalidArgumentException + * @throws ConnectionException + * @throws RuntimeException + * + * @return array + */ + public function find(BaseQuery $query): array + { + // 事件回调 + try { + $this->db->trigger('before_find', $query); + } catch (DbEventException $e) { + return []; + } + + // 执行查询 + $resultSet = $this->mongoQuery($query, function ($query) { + return $this->builder->select($query, true); + }); + + return $resultSet[0] ?? []; + } + + /** + * 得到某个字段的值 + * + * @param string $field 字段名 + * @param mixed $default 默认值 + * + * @return mixed + */ + public function value(BaseQuery $query, string $field, $default = null) + { + $options = $query->parseOptions(); + + if (isset($options['projection'])) { + $query->removeOption('projection'); + } + + $query->setOption('projection', (array) $field); + + if (!empty($options['cache'])) { + $cacheItem = $this->parseCache($query, $options['cache']); + $key = $cacheItem->getKey(); + + if ($this->cache->has($key)) { + return $this->cache->get($key); + } + } + + $mongoQuery = $this->builder->select($query, true); + + if (isset($options['projection'])) { + $query->setOption('projection', $options['projection']); + } else { + $query->removeOption('projection'); + } + + // 执行查询操作 + $resultSet = $this->mongoQuery($query, $mongoQuery); + + if (!empty($resultSet)) { + $data = array_shift($resultSet); + $result = $data[$field]; + } else { + $result = false; + } + + if (isset($cacheItem) && false !== $result) { + // 缓存数据 + $cacheItem->set($result); + $this->cacheData($cacheItem); + } + + return false !== $result ? $result : $default; + } + + /** + * 得到某个列的数组. + * + * @param BaseQuery $query + * @param string|array $field 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * + * @return array + */ + public function column(BaseQuery $query, string | array $field, string $key = ''): array + { + $options = $query->parseOptions(); + + if (isset($options['projection'])) { + $query->removeOption('projection'); + } + + if (is_array($field)) { + $field = implode(',', $field); + } + if ($key && '*' != $field) { + $projection = $key . ',' . $field; + } else { + $projection = $field; + } + + $query->field($projection); + + if (!empty($options['cache'])) { + // 判断查询缓存 + $cacheItem = $this->parseCache($query, $options['cache']); + $key = $cacheItem->getKey(); + + if ($this->cache->has($key)) { + return $this->cache->get($key); + } + } + + $mongoQuery = $this->builder->select($query); + + if (isset($options['projection'])) { + $query->setOption('projection', $options['projection']); + } else { + $query->removeOption('projection'); + } + + // 执行查询操作 + $resultSet = $this->mongoQuery($query, $mongoQuery); + + if (('*' == $field || str_contains($field, ',')) && $key) { + $result = array_column($resultSet, null, $key); + } elseif (!empty($resultSet)) { + $result = array_column($resultSet, $field, $key); + } else { + $result = []; + } + + if (isset($cacheItem)) { + // 缓存数据 + $cacheItem->set($result); + $this->cacheData($cacheItem); + } + + return $result; + } + + /** + * 执行command. + * + * @param BaseQuery $query 查询对象 + * @param string|array|object $command 指令 + * @param mixed $extra 额外参数 + * @param string $db 数据库名 + * + * @return array + */ + public function cmd(BaseQuery $query, $command, $extra = null, string $db = ''): array + { + if (is_array($command) || is_object($command)) { + $this->mongoLog('cmd', 'cmd', $command); + + // 直接创建Command对象 + $command = new Command($command); + } else { + // 调用Builder封装的Command对象 + $command = $this->builder->$command($query, $extra); + } + + return $this->command($command, $db); + } + + /** + * 获取数据库字段. + * + * @param mixed $tableName 数据表名 + * + * @return array + */ + public function getTableFields($tableName): array + { + return []; + } + + /** + * 执行数据库事务 + * + * @param callable $callback 数据操作方法回调 + * + * @throws PDOException + * @throws \Exception + * @throws \Throwable + * + * @return mixed + */ + public function transaction(callable $callback) + { + $this->startTrans(); + + try { + $result = null; + if (is_callable($callback)) { + $result = call_user_func_array($callback, [$this]); + } + $this->commit(); + + return $result; + } catch (\Throwable $e) { + $this->rollback(); + + throw $e; + } + } + + /** + * 启动事务 + * + * @throws \PDOException + * @throws \Exception + * + * @return void + */ + public function startTrans() + { + $this->initConnect(true); + $this->session_uuid = uniqid(); + $this->sessions[$this->session_uuid] = $this->getMongo()->startSession(); + + $this->sessions[$this->session_uuid]->startTransaction([]); + } + + /** + * 用于非自动提交状态下面的查询提交. + * + * @throws PDOException + * + * @return void + */ + public function commit() + { + if ($session = $this->getSession()) { + $session->commitTransaction(); + $this->setLastSession(); + } + } + + /** + * 事务回滚. + * + * @throws PDOException + * + * @return void + */ + public function rollback() + { + if ($session = $this->getSession()) { + $session->abortTransaction(); + $this->setLastSession(); + } + } + + /** + * 结束当前会话,设置上一个会话为当前会话. + * + * @author klinson + */ + protected function setLastSession() + { + if ($session = $this->getSession()) { + $session->endSession(); + unset($this->sessions[$this->session_uuid]); + if (empty($this->sessions)) { + $this->session_uuid = null; + } else { + end($this->sessions); + $this->session_uuid = key($this->sessions); + } + } + } + + /** + * 获取当前会话. + * + * @return \MongoDB\Driver\Session|null + * + * @author klinson + */ + public function getSession() + { + return ($this->session_uuid && isset($this->sessions[$this->session_uuid])) + ? $this->sessions[$this->session_uuid] + : null; + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/Mysql.php b/vendor/topthink/think-orm/src/db/connector/Mysql.php new file mode 100644 index 0000000..7cded95 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/Mysql.php @@ -0,0 +1,169 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\connector; + +use PDO; +use think\db\PDOConnection; + +/** + * mysql数据库驱动. + */ +class Mysql extends PDOConnection +{ + /** + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * + * @return string + */ + protected function parseDsn(array $config): string + { + if (!empty($config['socket'])) { + $dsn = 'mysql:unix_socket=' . $config['socket']; + } elseif (!empty($config['hostport'])) { + $dsn = 'mysql:host=' . $config['hostname'] . ';port=' . $config['hostport']; + } else { + $dsn = 'mysql:host=' . $config['hostname']; + } + $dsn .= ';dbname=' . $config['database']; + + if (!empty($config['charset'])) { + $dsn .= ';charset=' . $config['charset']; + } + + return $dsn; + } + + /** + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getFields(string $tableName): array + { + [$tableName] = explode(' ', $tableName); + + if (!str_contains($tableName, '`')) { + if (str_contains($tableName, '.')) { + $tableName = str_replace('.', '`.`', $tableName); + } + $tableName = '`' . $tableName . '`'; + } + + $sql = 'SHOW FULL COLUMNS FROM ' . $tableName; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + if (!empty($result)) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + + $info[$val['field']] = [ + 'name' => $val['field'], + 'type' => $val['type'], + 'notnull' => 'NO' == $val['null'], + 'default' => $val['default'], + 'primary' => strtolower($val['key']) == 'pri', + 'autoinc' => strtolower($val['extra']) == 'auto_increment', + 'comment' => $val['comment'], + ]; + } + } + + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息. + * + * @param string $dbName + * + * @return array + */ + public function getTables(string $dbName = ''): array + { + $sql = !empty($dbName) ? 'SHOW TABLES FROM ' . $dbName : 'SHOW TABLES '; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + + return $info; + } + + protected function supportSavepoint(): bool + { + return true; + } + + /** + * 启动XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function startTransXa(string $xid): void + { + $this->initConnect(true); + $this->linkID->exec("XA START '$xid'"); + } + + /** + * 预编译XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function prepareXa(string $xid): void + { + $this->initConnect(true); + $this->linkID->exec("XA END '$xid'"); + $this->linkID->exec("XA PREPARE '$xid'"); + } + + /** + * 提交XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function commitXa(string $xid): void + { + $this->initConnect(true); + $this->linkID->exec("XA COMMIT '$xid'"); + } + + /** + * 回滚XA事务 + * + * @param string $xid XA事务id + * + * @return void + */ + public function rollbackXa(string $xid): void + { + $this->initConnect(true); + $this->linkID->exec("XA ROLLBACK '$xid'"); + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/Oracle.php b/vendor/topthink/think-orm/src/db/connector/Oracle.php new file mode 100644 index 0000000..8349afd --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/Oracle.php @@ -0,0 +1,125 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\connector; + +use PDO; +use think\db\BaseQuery; +use think\db\PDOConnection; + +/** + * Oracle数据库驱动. + */ +class Oracle extends PDOConnection +{ + /** + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * + * @return string + */ + protected function parseDsn(array $config): string + { + $dsn = 'oci:dbname='; + + if (!empty($config['hostname'])) { + // Oracle Instant Client + $dsn .= '//' . $config['hostname'] . ($config['hostport'] ? ':' . $config['hostport'] : '') . '/'; + } + + $dsn .= $config['database']; + + if (!empty($config['charset'])) { + $dsn .= ';charset=' . $config['charset']; + } + + return $dsn; + } + + /** + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getFields(string $tableName): array + { + [$tableName] = explode(' ', $tableName); + + $sql = "select a.column_name,data_type,DECODE (nullable, 'Y', 0, 1) notnull,data_default, DECODE (A .column_name,b.column_name,1,0) pk from all_tab_columns a,(select column_name from all_constraints c, all_cons_columns col where c.constraint_name = col.constraint_name and c.constraint_type = 'P' and c.table_name = '" . $tableName . "' ) b where table_name = '" . $tableName . "' and a.column_name = b.column_name (+)"; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + if ($result) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + + $info[$val['column_name']] = [ + 'name' => $val['column_name'], + 'type' => $val['data_type'], + 'notnull' => $val['notnull'], + 'default' => $val['data_default'], + 'primary' => $val['pk'], + 'autoinc' => $val['pk'], + ]; + } + } + + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息(暂时实现取得用户表信息). + * + * @param string $dbName + * + * @return array + */ + public function getTables(string $dbName = ''): array + { + $sql = 'select table_name from all_tables'; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + + return $info; + } + + /** + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 + * @param string|null $sequence 自增序列名 + * + * @return mixed + */ + public function getLastInsID(BaseQuery $query, ?string $sequence = null) + { + if (!is_null($sequence)) { + $pdo = $this->linkID->query("select {$sequence}.currval as id from dual"); + $result = $pdo->fetchColumn(); + } + + return $result ?? null; + } + + protected function supportSavepoint(): bool + { + return true; + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/Pgsql.php b/vendor/topthink/think-orm/src/db/connector/Pgsql.php new file mode 100644 index 0000000..d21f581 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/Pgsql.php @@ -0,0 +1,113 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\connector; + +use PDO; +use think\db\PDOConnection; + +/** + * Pgsql数据库驱动. + */ +class Pgsql extends PDOConnection +{ + /** + * 默认PDO连接参数. + * + * @var array + */ + protected $params = [ + PDO::ATTR_CASE => PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + ]; + + /** + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * + * @return string + */ + protected function parseDsn(array $config): string + { + $dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname']; + + if (!empty($config['hostport'])) { + $dsn .= ';port=' . $config['hostport']; + } + + return $dsn; + } + + /** + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getFields(string $tableName): array + { + [$tableName] = explode(' ', $tableName); + + $sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra",fields_comment as "comment" from table_msg(\'' . $tableName . '\');'; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + if (!empty($result)) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + + $info[$val['field']] = [ + 'name' => $val['field'], + 'type' => $val['type'], + 'notnull' => (bool) ('' !== $val['null']), + 'default' => $val['default'], + 'primary' => !empty($val['key']), + 'autoinc' => str_starts_with((string) $val['extra'], 'nextval('), + 'comment' => $val['comment'], + ]; + } + } + + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息. + * + * @param string $dbName + * + * @return array + */ + public function getTables(string $dbName = ''): array + { + $sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'"; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + + return $info; + } + + protected function supportSavepoint(): bool + { + return true; + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/Sqlite.php b/vendor/topthink/think-orm/src/db/connector/Sqlite.php new file mode 100644 index 0000000..745bdc7 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/Sqlite.php @@ -0,0 +1,97 @@ + +// +---------------------------------------------------------------------- + +namespace think\db\connector; + +use PDO; +use think\db\PDOConnection; + +/** + * Sqlite数据库驱动. + */ +class Sqlite extends PDOConnection +{ + /** + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * + * @return string + */ + protected function parseDsn(array $config): string + { + return 'sqlite:' . $config['database']; + } + + /** + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getFields(string $tableName): array + { + [$tableName] = explode(' ', $tableName); + + $sql = 'PRAGMA table_info( \'' . $tableName . '\' )'; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + if (!empty($result)) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + + $info[$val['name']] = [ + 'name' => $val['name'], + 'type' => $val['type'], + 'notnull' => 1 === $val['notnull'], + 'default' => $val['dflt_value'], + 'primary' => '1' == $val['pk'], + 'autoinc' => '1' == $val['pk'], + ]; + } + } + + return $this->fieldCase($info); + } + + /** + * 取得数据库的表信息. + * + * @param string $dbName + * + * @return array + */ + public function getTables(string $dbName = ''): array + { + $sql = "SELECT name FROM sqlite_master WHERE type='table' " + . 'UNION ALL SELECT name FROM sqlite_temp_master ' + . "WHERE type='table' ORDER BY name"; + + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + + return $info; + } + + protected function supportSavepoint(): bool + { + return true; + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php b/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php new file mode 100644 index 0000000..3e3c987 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php @@ -0,0 +1,131 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\connector; + +use PDO; +use think\db\PDOConnection; + +/** + * Sqlsrv数据库驱动. + */ +class Sqlsrv extends PDOConnection +{ + /** + * 默认PDO连接参数. + * + * @var array + */ + protected $params = [ + PDO::ATTR_CASE => PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + ]; + + /** + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * + * @return string + */ + protected function parseDsn(array $config): string + { + $dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname']; + + if (!empty($config['hostport'])) { + $dsn .= ',' . $config['hostport']; + } + + if (!empty($config['trust_server_certificate'])) { + $dsn .= ';TrustServerCertificate=' . $config['trust_server_certificate']; + } + + return $dsn; + } + + /** + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getFields(string $tableName): array + { + [$tableName] = explode(' ', $tableName); + str_contains($tableName, '.') && $tableName = substr($tableName, strpos($tableName, '.') + 1); + + $sql = "SELECT column_name, data_type, column_default, is_nullable + FROM information_schema.tables AS t + JOIN information_schema.columns AS c + ON t.table_catalog = c.table_catalog + AND t.table_schema = c.table_schema + AND t.table_name = c.table_name + WHERE t.table_name = '$tableName'"; + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + if (!empty($result)) { + foreach ($result as $key => $val) { + $val = array_change_key_case($val); + + $info[$val['column_name']] = [ + 'name' => $val['column_name'], + 'type' => $val['data_type'], + 'notnull' => (bool) ('' === $val['is_nullable']), // not null is empty, null is yes + 'default' => $val['column_default'], + 'primary' => false, + 'autoinc' => false, + ]; + } + } + + $sql = "SELECT column_name FROM information_schema.key_column_usage WHERE table_name='$tableName'"; + $pdo = $this->linkID->query($sql); + $result = $pdo->fetch(PDO::FETCH_ASSOC); + + if ($result) { + $info[$result['column_name']]['primary'] = true; + } + + return $this->fieldCase($info); + } + + /** + * 取得数据表的字段信息. + * + * @param string $dbName + * + * @return array + */ + public function getTables(string $dbName = ''): array + { + $sql = "SELECT TABLE_NAME + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_TYPE = 'BASE TABLE' + "; + + $pdo = $this->getPDOStatement($sql); + $result = $pdo->fetchAll(PDO::FETCH_ASSOC); + $info = []; + + foreach ($result as $key => $val) { + $info[$key] = current($val); + } + + return $info; + } +} diff --git a/vendor/topthink/think-orm/src/db/connector/pgsql.sql b/vendor/topthink/think-orm/src/db/connector/pgsql.sql new file mode 100644 index 0000000..e1a09a3 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/pgsql.sql @@ -0,0 +1,117 @@ +CREATE OR REPLACE FUNCTION pgsql_type(a_type varchar) RETURNS varchar AS +$BODY$ +DECLARE + v_type varchar; +BEGIN + IF a_type='int8' THEN + v_type:='bigint'; + ELSIF a_type='int4' THEN + v_type:='integer'; + ELSIF a_type='int2' THEN + v_type:='smallint'; + ELSIF a_type='bpchar' THEN + v_type:='char'; + ELSE + v_type:=a_type; + END IF; + RETURN v_type; +END; +$BODY$ +LANGUAGE PLPGSQL; + +CREATE TYPE "public"."tablestruct" AS ( + "fields_key_name" varchar(100), + "fields_name" VARCHAR(200), + "fields_type" VARCHAR(20), + "fields_length" BIGINT, + "fields_not_null" VARCHAR(10), + "fields_default" VARCHAR(500), + "fields_comment" VARCHAR(1000) +); + +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_schema_name varchar, a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; + v_oid oid; + v_sql varchar; + v_rec RECORD; + v_key varchar; +BEGIN + SELECT + pg_class.oid INTO v_oid + FROM + pg_class + INNER JOIN pg_namespace ON (pg_class.relnamespace = pg_namespace.oid AND lower(pg_namespace.nspname) = a_schema_name) + WHERE + pg_class.relname=a_table_name; + IF NOT FOUND THEN + RETURN; + END IF; + + v_sql=' + SELECT + pg_attribute.attname AS fields_name, + pg_attribute.attnum AS fields_index, + pgsql_type(pg_type.typname::varchar) AS fields_type, + pg_attribute.atttypmod-4 as fields_length, + CASE WHEN pg_attribute.attnotnull THEN ''not null'' + ELSE '''' + END AS fields_not_null, + pg_attrdef.adsrc AS fields_default, + pg_description.description AS fields_comment + FROM + pg_attribute + INNER JOIN pg_class ON pg_attribute.attrelid = pg_class.oid + INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid + LEFT OUTER JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum + LEFT OUTER JOIN pg_description ON pg_description.objoid = pg_class.oid AND pg_description.objsubid = pg_attribute.attnum + WHERE + pg_attribute.attnum > 0 + AND attisdropped <> ''t'' + AND pg_class.oid = ' || v_oid || ' + ORDER BY pg_attribute.attnum' ; + + FOR v_rec IN EXECUTE v_sql LOOP + v_ret.fields_name=v_rec.fields_name; + v_ret.fields_type=v_rec.fields_type; + IF v_rec.fields_length > 0 THEN + v_ret.fields_length:=v_rec.fields_length; + ELSE + v_ret.fields_length:=NULL; + END IF; + v_ret.fields_not_null=v_rec.fields_not_null; + v_ret.fields_default=v_rec.fields_default; + v_ret.fields_comment=v_rec.fields_comment; + SELECT constraint_name INTO v_key FROM information_schema.key_column_usage WHERE table_schema=a_schema_name AND table_name=a_table_name AND column_name=v_rec.fields_name; + IF FOUND THEN + v_ret.fields_key_name=v_key; + ELSE + v_ret.fields_key_name=''; + END IF; + RETURN NEXT v_ret; + END LOOP; + RETURN ; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_schema_name varchar, a_table_name varchar) +IS '获得表信息'; + +---重载一个函数 +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; +BEGIN + FOR v_ret IN SELECT * FROM table_msg('public',a_table_name) LOOP + RETURN NEXT v_ret; + END LOOP; + RETURN; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_table_name varchar) +IS '获得表信息'; \ No newline at end of file diff --git a/vendor/topthink/think-orm/src/db/connector/pgsql12.sql b/vendor/topthink/think-orm/src/db/connector/pgsql12.sql new file mode 100644 index 0000000..332b4f0 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/pgsql12.sql @@ -0,0 +1,117 @@ +CREATE OR REPLACE FUNCTION pgsql_type(a_type varchar) RETURNS varchar AS +$BODY$ +DECLARE + v_type varchar; +BEGIN + IF a_type='int8' THEN + v_type:='bigint'; + ELSIF a_type='int4' THEN + v_type:='integer'; + ELSIF a_type='int2' THEN + v_type:='smallint'; + ELSIF a_type='bpchar' THEN + v_type:='char'; + ELSE + v_type:=a_type; + END IF; + RETURN v_type; +END; +$BODY$ +LANGUAGE PLPGSQL; + +CREATE TYPE "public"."tablestruct" AS ( + "fields_key_name" varchar(100), + "fields_name" VARCHAR(200), + "fields_type" VARCHAR(20), + "fields_length" BIGINT, + "fields_not_null" VARCHAR(10), + "fields_default" VARCHAR(500), + "fields_comment" VARCHAR(1000) +); + +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_schema_name varchar, a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; + v_oid oid; + v_sql varchar; + v_rec RECORD; + v_key varchar; +BEGIN + SELECT + pg_class.oid INTO v_oid + FROM + pg_class + INNER JOIN pg_namespace ON (pg_class.relnamespace = pg_namespace.oid AND lower(pg_namespace.nspname) = a_schema_name) + WHERE + pg_class.relname=a_table_name; + IF NOT FOUND THEN + RETURN; + END IF; + + v_sql=' + SELECT + pg_attribute.attname AS fields_name, + pg_attribute.attnum AS fields_index, + pgsql_type(pg_type.typname::varchar) AS fields_type, + pg_attribute.atttypmod-4 as fields_length, + CASE WHEN pg_attribute.attnotnull THEN ''not null'' + ELSE '''' + END AS fields_not_null, + pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid) AS fields_default, + pg_description.description AS fields_comment + FROM + pg_attribute + INNER JOIN pg_class ON pg_attribute.attrelid = pg_class.oid + INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid + LEFT OUTER JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum + LEFT OUTER JOIN pg_description ON pg_description.objoid = pg_class.oid AND pg_description.objsubid = pg_attribute.attnum + WHERE + pg_attribute.attnum > 0 + AND attisdropped <> ''t'' + AND pg_class.oid = ' || v_oid || ' + ORDER BY pg_attribute.attnum' ; + + FOR v_rec IN EXECUTE v_sql LOOP + v_ret.fields_name=v_rec.fields_name; + v_ret.fields_type=v_rec.fields_type; + IF v_rec.fields_length > 0 THEN + v_ret.fields_length:=v_rec.fields_length; + ELSE + v_ret.fields_length:=NULL; + END IF; + v_ret.fields_not_null=v_rec.fields_not_null; + v_ret.fields_default=v_rec.fields_default; + v_ret.fields_comment=v_rec.fields_comment; + SELECT constraint_name INTO v_key FROM information_schema.key_column_usage WHERE table_schema=a_schema_name AND table_name=a_table_name AND column_name=v_rec.fields_name; + IF FOUND THEN + v_ret.fields_key_name=v_key; + ELSE + v_ret.fields_key_name=''; + END IF; + RETURN NEXT v_ret; + END LOOP; + RETURN ; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_schema_name varchar, a_table_name varchar) +IS '获得表信息'; + +---重载一个函数 +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; +BEGIN + FOR v_ret IN SELECT * FROM table_msg('public',a_table_name) LOOP + RETURN NEXT v_ret; + END LOOP; + RETURN; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_table_name varchar) +IS '获得表信息'; \ No newline at end of file diff --git a/vendor/topthink/think-orm/src/db/exception/BindParamException.php b/vendor/topthink/think-orm/src/db/exception/BindParamException.php new file mode 100644 index 0000000..5bad9b3 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/BindParamException.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +/** + * PDO参数绑定异常. + */ +class BindParamException extends DbException +{ + /** + * BindParamException constructor. + * + * @param string $message + * @param array $config + * @param string $sql + * @param array $bind + * @param int $code + */ + public function __construct(string $message, array $config, string $sql, array $bind, int $code = 10502) + { + $this->setData('Bind Param', $bind); + parent::__construct($message, $config, $sql, $code); + } +} diff --git a/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php b/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php new file mode 100644 index 0000000..43f493e --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php @@ -0,0 +1,44 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +class DataNotFoundException extends DbException +{ + protected $table; + + /** + * DbException constructor. + * + * @param string $message + * @param string $table + * @param array $config + */ + public function __construct(string $message, string $table = '', array $config = []) + { + $this->message = $message; + $this->table = $table; + + $this->setData('Database Config', $config); + } + + /** + * 获取数据表名. + * + * @return string + */ + public function getTable() + { + return $this->table; + } +} diff --git a/vendor/topthink/think-orm/src/db/exception/DbEventException.php b/vendor/topthink/think-orm/src/db/exception/DbEventException.php new file mode 100644 index 0000000..019b422 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/DbEventException.php @@ -0,0 +1,21 @@ + +// +---------------------------------------------------------------------- +declare(strict_types = 1); + +namespace think\db\exception; + +/** + * Db事件异常. + */ +class DbEventException extends DbException +{ +} diff --git a/vendor/topthink/think-orm/src/db/exception/DbException.php b/vendor/topthink/think-orm/src/db/exception/DbException.php new file mode 100644 index 0000000..2555382 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/DbException.php @@ -0,0 +1,45 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +use think\Exception; + +/** + * Database相关异常处理类. + */ +class DbException extends Exception +{ + /** + * DbException constructor. + * + * @param string $message + * @param array $config + * @param string $sql + * @param int $code + */ + public function __construct(string $message, array $config = [], string $sql = '', int $code = 10500) + { + $this->message = $message; + $this->code = $code; + + $this->setData('Database Status', [ + 'Error Code' => $code, + 'Error Message' => $message, + 'Error SQL' => $sql, + ]); + + unset($config['username'], $config['password']); + $this->setData('Database Config', $config); + } +} diff --git a/vendor/topthink/think-orm/src/db/exception/DuplicateException.php b/vendor/topthink/think-orm/src/db/exception/DuplicateException.php new file mode 100644 index 0000000..c642f2c --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/DuplicateException.php @@ -0,0 +1,21 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +/** + * Duplicate异常处理类 + */ +class DuplicateException extends PDOException +{ +} diff --git a/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php b/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php new file mode 100644 index 0000000..226eb07 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php @@ -0,0 +1,23 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInvalidArgumentInterface; + +/** + * 非法数据异常. + */ +class InvalidArgumentException extends \InvalidArgumentException implements SimpleCacheInvalidArgumentInterface +{ +} diff --git a/vendor/topthink/think-orm/src/db/exception/ModelEventException.php b/vendor/topthink/think-orm/src/db/exception/ModelEventException.php new file mode 100644 index 0000000..c269537 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/ModelEventException.php @@ -0,0 +1,21 @@ + +// +---------------------------------------------------------------------- +declare(strict_types = 1); + +namespace think\db\exception; + +/** + * 模型事件异常. + */ +class ModelEventException extends DbException +{ +} diff --git a/vendor/topthink/think-orm/src/db/exception/ModelNotFoundException.php b/vendor/topthink/think-orm/src/db/exception/ModelNotFoundException.php new file mode 100644 index 0000000..f6c19c9 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/ModelNotFoundException.php @@ -0,0 +1,44 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +class ModelNotFoundException extends DbException +{ + protected $model; + + /** + * 构造方法. + * + * @param string $message + * @param string $model + * @param array $config + */ + public function __construct(string $message, string $model = '', array $config = []) + { + $this->message = $message; + $this->model = $model; + + $this->setData('Database Config', $config); + } + + /** + * 获取模型类名. + * + * @return string + */ + public function getModel() + { + return $this->model; + } +} diff --git a/vendor/topthink/think-orm/src/db/exception/PDOException.php b/vendor/topthink/think-orm/src/db/exception/PDOException.php new file mode 100644 index 0000000..72c0b13 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/exception/PDOException.php @@ -0,0 +1,45 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db\exception; + +/** + * PDO异常处理类 + * 重新封装了系统的\PDOException类. + */ +class PDOException extends DbException +{ + /** + * PDOException constructor. + * + * @param \PDOException $exception + * @param array $config + * @param string $sql + * @param int $code + */ + public function __construct(\PDOException $exception, array $config = [], string $sql = '', int $code = 10501) + { + $error = $exception->errorInfo; + $message = $exception->getMessage(); + + if (!empty($error)) { + $this->setData('PDO Error Info', [ + 'SQLSTATE' => $error[0], + 'Driver Error Code' => $error[1] ?? 0, + 'Driver Error Message' => $error[2] ?? '', + ]); + } + + parent::__construct($message, $config, $sql, $code); + } +} diff --git a/vendor/topthink/think-orm/src/facade/Db.php b/vendor/topthink/think-orm/src/facade/Db.php new file mode 100644 index 0000000..fd50e49 --- /dev/null +++ b/vendor/topthink/think-orm/src/facade/Db.php @@ -0,0 +1,32 @@ + +// +---------------------------------------------------------------------- + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\DbManager + * @mixin \think\DbManager + */ +class Db extends Facade +{ + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识). + * + * @return string + */ + protected static function getFacadeClass() + { + return 'think\DbManager'; + } +} diff --git a/vendor/topthink/think-orm/src/helper.php b/vendor/topthink/think-orm/src/helper.php new file mode 100644 index 0000000..ec4ad02 --- /dev/null +++ b/vendor/topthink/think-orm/src/helper.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +//------------------------ +// ThinkORM 助手函数 +//------------------------- + +use think\db\BaseQuery as Query; +use think\db\Express; +use think\db\Raw; +use think\facade\Db; + +if (!function_exists('db')) { + function db(string $name, string|array|null $connect = null): Query + { + if ($connect) { + return Db::connect($connect)->name($name); + } + return Db::name($name); + } +} + +if (!function_exists('raw')) { + function raw(string $value, array $bind = []): Raw + { + return new Raw($value, $bind); + } +} + +if (!function_exists('inc')) { + function inc(float|int $step = 1, int $lazyTime = 0): Express + { + return new Express('+', $step, $lazyTime); + } +} + +if (!function_exists('dec')) { + function dec(float|int $step = 1, int $lazyTime = 0): Express + { + return new Express('-', $step, $lazyTime); + } +} diff --git a/vendor/topthink/think-orm/src/model/Collection.php b/vendor/topthink/think-orm/src/model/Collection.php new file mode 100644 index 0000000..d911892 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/Collection.php @@ -0,0 +1,284 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\model; + +use think\Collection as BaseCollection; +use think\model\contract\Modelable as Model; +use think\Paginator; + +/** + * 模型数据集类. + * + * @template TKey of array-key + * @template TModel of \think\Model + * + * @extends BaseCollection + */ +class Collection extends BaseCollection +{ + /** + * 延迟预载入关联查询. + * + * @param array $relation 关联 + * @param mixed $cache 关联缓存 + * + * @return $this + */ + public function load(array $relation, $cache = false) + { + if (!$this->isEmpty()) { + $item = current($this->items); + $item->eagerlyResultSet($this->items, $relation, [], false, $cache); + } + + return $this; + } + + /** + * 删除数据集的数据. + * + * @return bool + */ + public function delete(): bool + { + $this->each(function (Model $model) { + $model->delete(); + }); + + return true; + } + + /** + * 更新数据. + * + * @param array $data 数据数组 + * @param array $allowField 允许字段 + * + * @return bool + */ + public function update(array $data, array $allowField = []): bool + { + $this->each(function (Model $model) use ($data, $allowField) { + if (!empty($allowField)) { + $model->allowField($allowField); + } + + $model->save($data); + }); + + return true; + } + + /** + * 设置需要隐藏的输出属性. + * + * @param array $hidden 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function hidden(array $hidden, bool $merge = false) + { + $this->each(function (Model $model) use ($hidden, $merge) { + $model->hidden($hidden, $merge); + }); + + return $this; + } + + /** + * 设置需要输出的属性. + * + * @param array $visible + * @param bool $merge 是否合并 + * + * @return $this + */ + public function visible(array $visible, bool $merge = false) + { + $this->each(function (Model $model) use ($visible, $merge) { + $model->visible($visible, $merge); + }); + + return $this; + } + + /** + * 设置需要追加的输出属性. + * + * @param array $append 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function append(array $append, bool $merge = false) + { + $this->each(function (Model $model) use ($append, $merge) { + $model->append($append, $merge); + }); + + return $this; + } + + /** + * 设置属性映射. + * + * @param array $mapping 属性映射 + * + * @return $this + */ + public function mapping(array $mapping) + { + $this->each(function (Model $model) use ($mapping) { + $model->mapping($mapping); + }); + + return $this; + } + + /** + * 设置模型输出场景. + * + * @param string $scene 场景名称 + * + * @return $this + */ + public function scene(string $scene) + { + $this->each(function (Model $model) use ($scene) { + $model->scene($scene); + }); + + return $this; + } + + /** + * 设置数据字段获取器. + * + * @param string|array $name 字段名 + * @param callable $callback 闭包获取器 + * + * @return $this + */ + public function withAttr(string|array $name, ?callable $callback = null) + { + $this->each(function (Model $model) use ($name, $callback) { + $model->withFieldAttr($name, $callback); + }); + + return $this; + } + + /** + * 绑定(一对一)关联属性到当前模型. + * + * @param string $relation 关联名称 + * @param array $attrs 绑定属性 + * + * @throws Exception + * + * @return $this + */ + public function bindAttr(string $relation, array $attrs = []) + { + $this->each(function (Model $model) use ($relation, $attrs) { + $model->bindAttr($relation, $attrs); + }); + + return $this; + } + + /** + * 按指定键整理数据. + * + * @param mixed $items 数据 + * @param string|null $indexKey 键名 + * + * @return array + */ + public function dictionary($items = null, ?string &$indexKey = null) + { + if ($items instanceof self || $items instanceof Paginator) { + $items = $items->all(); + } + + $items = is_null($items) ? $this->items : $items; + + if ($items && empty($indexKey)) { + $indexKey = $items[0]->getPk(); + } + + if (isset($indexKey) && is_string($indexKey)) { + return array_column($items, null, $indexKey); + } + + return $items; + } + + /** + * 比较数据集,返回差集. + * + * @param mixed $items 数据 + * @param string|null $indexKey 指定比较的键名 + * + * @return static + */ + public function diff($items, ?string $indexKey = null) + { + if ($this->isEmpty()) { + return new static($items); + } + + $diff = []; + $dictionary = $this->dictionary($items, $indexKey); + + if (is_string($indexKey)) { + foreach ($this->items as $item) { + if (!isset($dictionary[$item[$indexKey]])) { + $diff[] = $item; + } + } + } + + return new static($diff); + } + + /** + * 比较数据集,返回交集. + * + * @param mixed $items 数据 + * @param string|null $indexKey 指定比较的键名 + * + * @return static + */ + public function intersect($items, ?string $indexKey = null) + { + if ($this->isEmpty()) { + return new static([]); + } + + $intersect = []; + $dictionary = $this->dictionary($items, $indexKey); + + if (is_string($indexKey)) { + foreach ($this->items as $item) { + if (isset($dictionary[$item[$indexKey]])) { + $intersect[] = $item; + } + } + } + + return new static($intersect); + } +} diff --git a/vendor/topthink/think-orm/src/model/Pivot.php b/vendor/topthink/think-orm/src/model/Pivot.php new file mode 100644 index 0000000..44cf224 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/Pivot.php @@ -0,0 +1,77 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\model; + +use think\Model; + +/** + * 多对多中间表模型类. + */ +class Pivot extends Model +{ + /** + * 父模型. + * + * @var Model + */ + public $parent; + protected $pivotName; + + /** + * 是否时间自动写入. + * + * @var bool + */ + protected $autoWriteTimestamp = false; + + /** + * 架构函数. + * + * @param array $data 数据 + * @param Model|null $parent 上级模型 + * @param string $table 中间数据表名 + */ + public function __construct(array $data = [], ?Model $parent = null, string $table = '') + { + $this->pivotName = $table; + $this->parent = $parent; + parent::__construct($data); + } + + /** + * 初始化模型. + * + * @return void + */ + protected function init() + { + if (is_null($this->getOption('name'))) { + $this->setOption('name', $this->pivotName); + } + } + + /** + * 创建新的模型实例. + * + * @param array|object $data 数据 + * @param array $options + * + * @return Model + */ + public function newInstance(array | object $data = [], array $options = []) + { + $this->data($data); + return $this->clone(); + } +} diff --git a/vendor/topthink/think-orm/src/model/Relation.php b/vendor/topthink/think-orm/src/model/Relation.php new file mode 100644 index 0000000..e613bc4 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/Relation.php @@ -0,0 +1,354 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model; + +use Closure; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use think\model\Collection; +use think\model\contract\Modelable as Model; + +/** + * 模型关联基础类. + * + * @mixin Query + */ +abstract class Relation +{ + /** + * 父模型对象 + * + * @var Model + */ + protected $parent; + + /** + * 当前关联的模型类名. + * + * @var string + */ + protected $model; + + /** + * 关联模型查询对象 + * + * @var Query + */ + protected $query; + + /** + * 关联表外键. + * + * @var string + */ + protected $foreignKey; + + /** + * 关联表主键. + * + * @var string + */ + protected $localKey; + + /** + * 是否执行关联基础查询. + * + * @var bool + */ + protected $baseQuery; + + /** + * 是否为自关联. + * + * @var bool + */ + protected $selfRelation = false; + + /** + * 关联数据字段限制. + * + * @var array + */ + protected $withField; + + /** + * 排除关联数据字段. + * + * @var array + */ + protected $withoutField; + + /** + * 默认数据. + * + * @var mixed + */ + protected $default; + + /** + * 获取一条关联数据. + * + * @var bool + */ + protected $isOneofMany = false; + + /** + * 获取关联的所属模型. + * + * @return Model + */ + public function getParent(): Model + { + return $this->parent; + } + + /** + * 获取当前的关联模型类的Query实例. + * + * @return Query + */ + public function getQuery() + { + return $this->query; + } + + /** + * 获取关联表外键. + * + * @return string + */ + public function getForeignKey(): string + { + return $this->foreignKey; + } + + /** + * 获取关联表主键. + * + * @return string + */ + public function getLocalKey(): string + { + return $this->localKey; + } + + /** + * 获取当前的关联模型类的实例. + * + * @return Model + */ + public function getModel(): Model + { + return $this->query->getModel(); + } + + /** + * 当前关联是否为自关联. + * + * @return bool + */ + public function isSelfRelation(): bool + { + return $this->selfRelation; + } + + /** + * 封装关联数据集. + * + * @param array $resultSet 数据集 + * + * @param array $resultSet 关联数据结果集 + * @return Collection 返回模型集合对象 + */ + protected function resultSetBuild(array $resultSet) + { + return (new $this->model())->toCollection($resultSet); + } + + /** + * 获取关联查询的字段 + * + * 根据模型名称处理查询字段 + * + * @param string $model 模型名称 + * @return mixed 返回处理后的查询字段 + */ + protected function getQueryFields(string $model) + { + $fields = $this->query->getOption('field'); + $this->query->removeOption('field'); + + return $this->getRelationQueryFields($fields, $model); + } + + /** + * 获取关联查询的字段 + * + * 处理关联查询的字段,添加表名前缀 + * + * @param mixed $fields 字段定义 + * @param string $model 模型名称 + * @return mixed 返回处理后的查询字段 + */ + protected function getRelationQueryFields($fields, string $model) + { + if (empty($fields) || '*' == $fields) { + return $model . '.*'; + } + + if (is_string($fields)) { + $fields = explode(',', $fields); + } + + foreach ($fields as &$field) { + if (!str_contains($field, '.')) { + $field = $model . '.' . $field; + } + } + + return $fields; + } + + /** + * 处理关联查询条件 + * + * 为查询条件添加关联表前缀 + * + * @param array &$where 查询条件 + * @param string $relation 关联表名 + * @return void + */ + protected function getQueryWhere(array &$where, string $relation): void + { + if (array_is_list($where) && isset($where[0]) && is_string($where[0])) { + $where = [ $where ]; + } + foreach ($where as $key => &$val) { + if (is_string($key)) { + $where[] = [!str_contains($key, '.') ? $relation . '.' . $key : $key, '=', $val]; + unset($where[$key]); + } elseif (is_array($val) && isset($val[0]) && !str_contains($val[0], '.')) { + $val[0] = $relation . '.' . $val[0]; + } + } + } + + /** + * 获取关联数据默认值 + * + * @param mixed $data 模型数据 + * + * @return mixed + */ + protected function getDefaultModel($data) + { + if (is_array($data)) { + $model = new $this->model($data); + } elseif ($data instanceof Closure) { + $model = new $this->model(); + $data($model); + } else { + $model = $data; + } + + return $model; + } + + /** + * 处理关联查询及软删除的关联查询 + * + * @param Query $query 查询对象 + * @param string $relation 关联名 + * @param mixed $where 查询条件 + * @param string $logic 查询逻辑 + * @return Query 返回查询对象 + */ + protected function getRelationSoftDelete(Query $query, $relation, $where = null, $logic = '') + { + if ($where) { + if (is_array($where)) { + $this->getQueryWhere($where, $relation); + } elseif ($where instanceof Query) { + $where->via($relation); + } elseif ($where instanceof Closure) { + $where($this->query->via($relation)); + $where = $this->query; + } + + $whereLogic = 'OR' == $logic ? 'whereOr' : 'where'; + $query->$whereLogic(function ($query) use ($where) { + $query->where($where); + }); + } + + // 启用软删除则增加软删除条件 + $softDelete = $this->query->getOption('soft_delete'); + return $query->when($softDelete, function ($query) use ($softDelete, $relation) { + $query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null); + }); + } + + /** + * 获取关联的最新一条数据. + * + * @param string $field 排序字段 + * + * @return $this + */ + public function first(string $field = '') + { + $field = $field ?: $this->query->getPk(); + $this->query->order($field, 'desc'); + $this->isOneofMany = true; + return $this; + } + + /** + * 获取关联的最旧一条数据. + * + * @param string $field 排序字段 + * + * @return $this + */ + public function last(string $field = '') + { + $field = $field ?: $this->query->getPk(); + $this->query->order($field, 'asc'); + $this->isOneofMany = true; + return $this; + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + } + + public function __call($method, $args) + { + if ($this->query) { + // 执行基础查询 + $this->baseQuery(); + + $result = call_user_func_array([$this->query, $method], $args); + + return $result === $this->query ? $this : $result; + } + + throw new Exception('method not exists:' . __CLASS__ . '->' . $method); + } +} diff --git a/vendor/topthink/think-orm/src/model/View.php b/vendor/topthink/think-orm/src/model/View.php new file mode 100644 index 0000000..0bbe0fa --- /dev/null +++ b/vendor/topthink/think-orm/src/model/View.php @@ -0,0 +1,744 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model; + +use ReflectionClass; +use ReflectionProperty; +use think\Entity; +use think\exception\ValidateException; +use think\helper\Str; +use think\Model; +use think\model\Collection; +use think\model\contract\Modelable; + +/** + * 视图模型 + */ +abstract class View extends Entity +{ + /** + * 架构函数. + * + * @param Model $model 模型连接对象 + */ + public function __construct(?Model $model = null) + { + parent::__construct($model); + + // 初始化模型数据 + $this->initData(); + } + + /** + * 初始化实体数据属性. + * + * @return void + */ + protected function initData() + { + // 获取属性映射关系 + $properties = $this->getEntityPropertiesMap(); + $data = $this->model()->getData(); + if (empty($data)) { + return ; + } + foreach ($properties as $key => $field) { + if (is_int($key)) { + // 主模型同名属性 + $this->$field = $this->fetchViewAttr($field, $data); + } elseif (strpos($field, '->')) { + // 关联属性或JSON字段映射 + $this->$key = $this->getRelationMapAttr($field, $data); + } else { + // 主模型属性映射 + $this->$key = $this->fetchViewAttr($field, $data); + } + } + // 标记数据存在 + $this->exists(true); + } + + /** + * 获取关联或JSON字段映射的属性值. + * + * @param string $field 视图属性 + * @param array $data 模型数据 + * + * @return mixed + */ + private function getRelationMapAttr(string $field, array $data) + { + $items = explode('->', $field); + $relation = array_shift($items); + if (isset($data[$relation])) { + $value = $this->model()->$relation; + foreach ($items as $item) { + if (is_array($value)) { + $value = $value[$item] ?? null; + } elseif (is_object($value)) { + $value = $value->$item ?? null; + } + } + } + return $value ?? null; + } + + /** + * 获取视图属性值(支持视图获取器). + * + * @param string $field 视图属性 + * @param array $data 模型数据 + * + * @return mixed + */ + private function fetchViewAttr(string $field, array $data) + { + $method = 'get' . Str::camel($field) . 'Attr'; + $model = $this->model(); + if (method_exists($this, $method)) { + // 视图获取器 + $value = $this->$method($model); + } elseif ($model->hasData($field)) { + // 获取主模型数据(支持获取器) + $value = $model->$field; + } else { + // 获取自动映射的属性数据 + $value = $this->getAutoRelationValue($field, $data); + } + return $value; + } + + /** + * 获取autoMapping自动映射的视图属性值. + * + * @param string $field 视图属性 + * @param array $data 模型数据 + * + * @return mixed + */ + private function getAutoRelationValue(string $field, array $data) + { + $relations = $this->getOption('autoMapping', []); + if ($relations) { + $mapping = $this->getOption('viewMapping', []); + foreach ($relations as $relation) { + if (isset($data[$relation]) && $this->model()->$relation->hasData($field)) { + $value = $this->model()->$relation->$field; + if (!isset($mapping[$field])) { + $mapping[$field] = $relation . '->' . $field; + } + break; + } + } + $this->setOption('viewMapping', $mapping); + } + return $value ?? null; + } + + /** + * 获取实体属性列表. + * + * @return array + */ + private function getEntityProperties(): array + { + $reflection = new ReflectionClass($this); + $properties = []; + foreach ($reflection->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { + $properties[] = $property->getName(); + } + return $properties; + } + + /** + * 获取包含映射关系的实体属性列表. + * + * @return array + */ + private function getEntityPropertiesMap(): array + { + $properties = $this->getOption('viewProperties'); + if (empty($properties)) { + // 获取实体属性列表 + $fields = $this->getEntityProperties(); + // 获取属性映射列表 + $mapping = $this->getOption('viewMapping', []); + $relations = $this->getOption('autoMapping', []); + $properties = []; + foreach ($fields as $field) { + if (isset($mapping[$field])) { + // 映射属性 + $properties[$field] = $mapping[$field]; + if (strpos($mapping[$field], '->')) { + $relation = strstr($mapping[$field], '->', true); + if (!$this->model()->getFieldType($relation)) { + $relations[] = $relation; + } + } + } else { + // 主模型同名属性 + $properties[] = $field; + } + } + $this->setOption('autoRelation', array_unique($relations)); + $this->setOption('viewProperties', $properties); + } + + return $properties; + } + + /** + * 解析autoMapping的字段映射 + * + * @return array + */ + protected function parseAutoMapping(): array + { + $fields = $this->getEntityProperties(); + $mapping = $this->getOption('viewMapping', []); + $relations = $this->getOption('autoMapping', []); + if ($relations) { + array_unshift($relations, $this->model()); + foreach ($fields as $field) { + if (isset($mapping[$field])) { + continue; + } + foreach ($relations as $relation) { + if (is_object($relation) && $relation->getFieldType($field)) { + break; + } elseif (is_string($relation) && !strpos($relation, '.') && $this->model()->$relation()->getFieldType($field)) { + $mapping[$field] = $relation . '->' . $field; + break; + } + } + } + $this->setOption('viewMapping', $mapping); + } + return $mapping; + } + + /** + * 转换为数组. 视图模型不支持 hidden visible append + * + * @return array + */ + public function toArray(): array + { + $data = $this->getData(); + foreach ($data as $name => &$val) { + if ($val instanceof Modelable || $val instanceof Collection) { + $val = $val->toArray(); + } + } + return $data; + } + + /** + * 设置视图模型数据 + * + * @param array|object $data 数据 + * @param mixed $validate 是否验证数据 + * @return $this + */ + public function data(array | object $data, $validate = false) + { + // 处理对象数据 + if (is_object($data)) { + $data = get_object_vars($data); + } + + foreach ($this->getEntityProperties() as $field) { + $this->$field = $data[$field] ?? null; + } + + // 验证数据 + if ($validate) { + if (!is_bool($validate)) { + // 指定验证场景 + $this->scene($validate); + } + $this->validate(); + } + + return $this; + } + + /** + * 刷新模型数据. + * + * @return $this + */ + public function refresh() + { + $this->initData(); + return $this; + } + + /** + * 清空视图模型数据 + * + * @return $this + */ + public function clear() + { + foreach ($this->getEntityProperties() as $field) { + $this->$field = null; + } + $this->exists(false); + return $this; + } + + /** + * 获取视图模型数据 + * + * @return array + */ + protected function getData(): array + { + $data = []; + foreach ($this->getEntityProperties() as $field) { + $data[$field] = $this->$field; + } + return $data; + } + + /** + * 判断数据是否为空. + * + * @return bool + */ + public function isEmpty(): bool + { + return $this->model()->isEmpty(); + } + + /** + * 获取克隆的模型实例. + * + * @return static + */ + public function clone() + { + $model = new static(); + return $model->setModel($this->model()); + } + + /** + * 设置模型. + * + * @param Model $model 模型对象 + * @return $this + */ + public function setModel(Model $model) + { + parent::setModel($model); + $this->initData(); + return $this; + } + + /** + * 模型数据转Json. + * + * @param int $options json参数 + * @return string + */ + public function toJson(int $options = JSON_UNESCAPED_UNICODE): string + { + return json_encode($this->toArray(), $options); + } + + // JsonSerializable + public function jsonSerialize(): array + { + return $this->toArray(); + } + + public function __toString() + { + return $this->toJson(); + } + + /** + * 设置关联数据. + * + * @param string $relation 关联属性 + * @param Model $model 关联数据 + * + * @return void + */ + public function setRelation($relation, $model) + { + $this->model()->setRelation($relation, $model); + } + + /** + * 设置关联绑定数据 + * + * @param Model $model 关联对象 + * @param array $bind 绑定属性 + * @param string $relation 关联名称 + * @return void + */ + public function bindRelationAttr($model, $bind, $relation) + { + if ($relation) { + $this->setRelation($relation, $model); + } + } + + /** + * 视图模型数据转换为模型数据(用于写入 暂不支持子关联写入). + * + * @return array + */ + private function convertData(): array + { + // 获取属性映射 + $properties = $this->getEntityPropertiesMap(); + $data = $this->getData(); + $item = []; + $together = []; + $array = []; + foreach ($properties as $key => $field) { + if (strpos($field, '->')) { + if (!isset($data[$key]) || substr_count($field, '->') > 1) { + // 排除空值 以及 多级关联属性值 + continue; + } + [$relation, $field] = explode('->', $field); + if ('json' == $this->model()->getFieldType($relation)) { + // JSON数据赋值 + $array[$relation][$field] = $data[$key]; + } else { + // 关联数据赋值 + $together[] = $relation; + if ($this->model()->hasData($relation)) { + // 关联更新 + $this->model()->$relation->$field = $data[$key]; + } else { + // 新增关联 + $array[$relation][$field] = $data[$key]; + } + } + } else { + $value = $data[is_int($key) ? $field : $key]; + if (isset($value)) { + $item[$field] = $value; + } + } + } + + // 关联数据或JSON数据封装 + foreach ($array as $relation => $val) { + $this->model()->$relation = $val; + } + + if (!empty($together)) { + // 自动关联写入 + $this->model()->together(array_unique($together)); + } + return $item; + } + + /** + * 设置验证场景. + * + * @param string|array $scene 场景名或数组 + * @return $this + */ + public function scene(string|array $scene) + { + return $this->setOption('scene', $scene); + } + + /** + * 验证视图模型数据. + * + * @throws ValidateException + * @return bool + */ + private function validate(): bool + { + $validater = $this->getOption('validate'); + if (!empty($validater) && !$this->getOption('dataHasValidate', false)) { + $data = $this->getData(); + $result = validate($validater) + ->scene($this->getOption('scene') ?: array_keys($data)) + ->check($data); + if ($result) { + $this->setOption('dataHasValidate', true); + } + return $result; + } + return true; + } + + /** + * 设置数据是否存在. + * + * @param bool $exists + * + * @return $this + */ + public function exists(bool $exists = true) + { + return $this->setOption('exists', $exists); + } + + /** + * 判断数据是否存在数据库. + * + * @return bool + */ + public function isExists(): bool + { + return $this->getOption('exists', false); + } + + /** + * 保存模型实例数据. + * + * @param array|object $data 数据 + * @param mixed $where 更新条件 true为强制新增 + * @param bool $refresh 是否刷新数据 + * @return bool + */ + public function save(array | object $data = [], $where = [], bool $refresh = false): bool + { + if ($data) { + $this->data($data); + } + // 验证数据 + $this->validate(); + + // 根据映射关系转换为实际模型数据 + $data = $this->convertData(); + + // 处理自动时间字段数据 + foreach ($this->model()->getAutoTimeFields() as $field) { + unset($data[$field]); + } + + $result = $this->model() + ->exists($this->isExists()) + ->save($data, $where, $refresh); + + if ($result) { + // 刷新数据 + $this->refresh(); + } + return $result; + } + + /** + * 删除模型数据. + * + * @return bool + */ + public function delete(): bool + { + if ($this->model()->delete()) { + $this->clear(); + return true; + } + + return false; + } + + /** + * 写入数据. + * + * @param array|object $data 数据 + * @return static + */ + public static function create(array | object $data) + { + $entity = new static(); + $entity->exists(false)->save($data, true); + return $entity; + } + + /** + * 更新数据. + * + * @param array|object $data 数据 + * @param mixed $where 更新条件 + * @return static + */ + public static function update(array | object $data, $where = []) + { + $entity = new static(); + $entity->exists(true)->save($data, $where, true); + return $entity; + } + + /** + * 数据集写入 + * + * @param iterable $dataSet 数据集 + * @param bool $replace 是否replace + * + * @return Collection + */ + public static function saveAll(iterable $dataSet, bool $replace = true): Collection + { + $collection = []; + foreach ($dataSet as $data) { + $entity = new static(); + $pk = $entity->getPk(); + if ($replace) { + $exists = true; + foreach ((array) $pk as $field) { + if (is_string($field) && !isset($data[$field])) { + $exists = false; + } + } + $entity->exists($exists); + } + $entity->save($data, !$replace); + $collection[] = $entity; + } + return new Collection($collection); + } + + /** + * 获取属性 支持获取器 + * + * @param string $name 名称 + * + * @return mixed + */ + public function __get(string $name) + { + if (property_exists($this, $name)) { + return $this->$name ?? null; + } + return $this->model()->$name; + } + + /** + * 设置数据 支持类型自动转换 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return void + */ + public function __set(string $name, $value): void + { + if (property_exists($this, $name)) { + $this->$name = $value; + } + } + + /** + * 检测数据对象的值 + * + * @param string $name 名称 + * + * @return bool + */ + public function __isset(string $name): bool + { + return !is_null($this->__get($name)); + } + + /** + * 销毁数据对象的值 + * + * @param string $name 名称 + * + * @return void + */ + public function __unset(string $name): void + { + unset($this->$name); + } + + public function __debugInfo() + { + return []; + } + + /** + * 克隆模型实例 + * + * @return void + */ + public function __clone() + { + } + + /** + * 序列化模型对象 + * + * @return array + */ + public function __serialize(): array + { + return $this->getData(); + } + + /** + * 反序列化模型对象 + * + * @param array $data + * @return void + */ + public function __unserialize(array $data) + { + parent::__construct(); + if (!empty($data)){ + $this->exists(true); + } + + foreach ($data as $name => $val) { + $this->$name = $val; + } + } + + public static function __callStatic($method, $args) + { + $entity = new static(); + $model = $entity->model(); + if (in_array($method, ['destroy'])) { + $db = $model; + } else { + // 处理映射字段的查询 + $map = $entity->parseAutoMapping(); + $alias = Str::snake(class_basename($model)); + $db = $model->db()->alias($alias)->via($alias)->fieldMap($map); + } + + $auto = $entity->getOption('autoRelation'); + if (!empty($auto) && !in_array(strtolower($method), ['with','withjoin'])) { + // 自动关联查询 + $db->with($auto); + } + + return call_user_func_array([$db, $method], $args); + } + + public function __call($method, $args) + { + if (in_array($method, ['hidden', 'visible', 'append'])) { + // 不支持输出设置 + return $this; + } + + // 调用Model类方法 + $result = call_user_func_array([$this->model(), $method], $args); + return $result instanceof Model ? $this : $result; + } +} diff --git a/vendor/topthink/think-orm/src/model/Virtual.php b/vendor/topthink/think-orm/src/model/Virtual.php new file mode 100644 index 0000000..658ee67 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/Virtual.php @@ -0,0 +1,72 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model; + +use think\db\exception\DbException as Exception; +use think\Model; +use think\model\contract\Modelable; + +/** + * Class Virtual. + * 虚拟模型 + */ +abstract class Virtual extends Model +{ + /** + * 创建数据. + * + * @param array|object $data 数据 + * @param array $allowField 允许字段 + * @param bool $replace 使用Replace + * @param string $suffix 数据表后缀 + * @return Modelable + */ + public static function create(array | object $data, array $allowField = [], bool $replace = false, string $suffix = ''): Modelable + { + $model = new static(); + + if (!empty($data)) { + // 初始化模型数据 + $model->data($data); + } + return $model; + } + + /** + * 获取Db对象实例. + * @return Query + */ + public function getQuery() + { + throw new Exception('virtual model not support db query'); + } + + /** + * 获取数据表字段类型列表(或某个字段的类型). + * + * @param string|null $field 字段名 + * + * @return array|string + */ + protected function getFields(?string $field = null) + { + $schema = array_merge($this->getOption('schema', []), $this->getOption('type', [])); + + if ($field) { + return $schema[$field] ?? null; + } + + return $schema; + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/Attribute.php b/vendor/topthink/think-orm/src/model/concern/Attribute.php new file mode 100644 index 0000000..fb52836 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/Attribute.php @@ -0,0 +1,719 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use BackedEnum; +use Stringable; +use think\db\Express; +use think\db\Raw; +use think\helper\Str; +use think\model\Collection; +use think\model\contract\EnumTransform; +use think\model\contract\FieldTypeTransform; +use think\model\contract\Modelable as Model; +use think\model\contract\Typeable; +use think\model\type\Date; +use think\model\type\DateTime; +use think\model\type\Json; + +/** + * 模型数据处理. + */ +trait Attribute +{ + /** + * 初始化模型数据. + * + * @param array|object $data 实体模型数据 + * @param bool $fromSave + * + * @return void + */ + private function initializeData(array | object $data, bool $fromSave = false) + { + // 分析数据 + $data = $this->parseData($data); + $schema = $this->getFields(); + $fields = array_keys($schema); + + // 模型赋值 + foreach ($data as $name => $value) { + if (in_array($name, $this->getOption('disuse'))) { + // 废弃字段 + continue; + } + + if (str_contains($name, '__')) { + // 组装关联JOIN查询数据 + [$relation, $attr] = explode('__', $name, 2); + + $relations[$relation][$attr] = $value; + continue; + } + + $trueName = $fromSave ? $this->getMappingName($name) : $name; + if (in_array($trueName, $fields)) { + $type = $schema[$trueName] ?? 'string'; + // 读取数据后进行类型转换 + if (!$fromSave || !$this->hasSetAttr($trueName)) { + $value = $this->readTransform($value, $type); + } + // 数据赋值 + $this->setData($trueName, $value); + if ($trueName == $this->getPk()) { + $this->setKey($value); + } + // 记录原始数据 + $origin[$trueName] = $value; + } else { + // 非数据表字段或关联数据 额外赋值 + $this->setData($trueName, $value); + } + } + + if (!empty($relations)) { + // 设置关联数据 + $this->parseRelationData($relations); + } + + if (!empty($origin) && !$fromSave) { + $this->trigger('AfterRead'); + $this->setOption('origin', $origin); + $this->setOption('get', []); + } + } + + /** + * 获取主键名. + * + * @return string|array + */ + public function getPk() + { + return $this->getOption('pk', 'id'); + } + + /** + * 获取表名(不含前后缀). + * + * @return string + */ + public function getName(): string + { + return $this->getOption('name', Str::snake(class_basename(static::class))); + } + + /** + * 解析模型数据. + * + * @param array|object $data 数据 + * + * @return array + */ + private function parseData(array | object $data): array + { + if ($data instanceof self) { + $data = $data->getData(); + } elseif (is_object($data)) { + $data = get_object_vars($data); + } + + return $data; + } + + /** + * 动态设置数据字段获取器. + * + * @param array|string $attr 字段名 + * @param callable $callback 闭包获取器 + * + * @return $this + */ + public function withFieldAttr(array | string $attr, ?callable $callback = null) + { + if (is_array($attr)) { + foreach ($attr as $name => $closure) { + $this->withFieldAttr($name, $closure); + } + } else { + $name = $this->getRealFieldName($attr); + $this->setWeakData('withAttr', $name, $callback); + // 自动追加输出 + self::$weakMap[$this]['append'][] = $name; + } + + return $this; + } + + /** + * 获取实际字段名. + * 严格模式下 完全和数据表字段对应一致(默认) + * 非严格模式 统一转换为snake规范(支持驼峰规范读取) + * + * @param string $name 字段名 + * + * @return mixed + */ + protected function getRealFieldName(string $name) + { + if (false === $this->getOption('strict')) { + return Str::snake($name); + } + + return $name; + } + + /** + * 数据读取 类型转换. + * + * @param mixed $value 值 + * @param string|array|null $type 要转换的类型 + * + * @return mixed + */ + protected function readTransform($value, string | array | null $type) + { + if (is_null($type) || is_null($value) || $value instanceof Raw || $value instanceof Express) { + return $value; + } + + $param = ''; + if (is_array($type)) { + [$type, $param] = $type; + } elseif (str_contains($type, ':')) { + [$type, $param] = explode(':', $type, 2); + } + + $typeTransform = static function (string $type, $value, $model, $param) { + if (class_exists($type) && !($value instanceof $type)) { + if (is_subclass_of($type, Typeable::class)) { + $value = $type::from($value, $model); + if ($param && $value instanceof DateTime) { + // 设置时间输出格式 + $value->setFormat($param); + } + } elseif (is_subclass_of($type, FieldTypeTransform::class)) { + $value = $type::get($value, $model); + } elseif (is_subclass_of($type, BackedEnum::class)) { + $value = $type::from($value); + if (is_subclass_of($type, EnumTransform::class)) { + $value = $value->value(); + } elseif ($model->getOption('enumReadName')) { + $method = $model->getOption('enumReadName'); + $value = is_string($method) ? $value->$method() : $value->name; + } + } else { + // 对象类型 + $value = new $type($value); + } + } + return $value; + }; + + return match ($type) { + 'string','bigint'=> (string) $value, + 'int','integer' => (int) $value, + 'float' => empty($param) ? (float) $value : (float) number_format($value, (int) $param, '.', ''), + 'bool','boolean' => (bool) $value, + 'array' => empty($value) ? [] : (is_array($value) ? $value : json_decode($value, true)), + 'object' => empty($value) ? new \stdClass() : (is_string($value) ? json_decode($value) : json_decode(json_encode($value, JSON_FORCE_OBJECT))), + 'json' => $typeTransform(Json::class, $value, $this, $param), + 'date' => $typeTransform(Date::class, $value, $this, $param), + 'datetime' => $typeTransform(DateTime::class, $value, $this, $param), + 'timestamp' => $typeTransform(DateTime::class, $value, $this, $param), + default => $typeTransform($type, $value, $this, $param), + }; + } + + /** + * 数据写入 类型转换. + * + * @param mixed $value 值 + * @param string|array|null $type 要转换的类型 + * + * @return mixed + */ + protected function writeTransform($value, string | array | null $type) + { + if (is_null($type) || is_null($value) || $value instanceof Raw || $value instanceof Express) { + return $value; + } + + $param = ''; + if (is_array($type)) { + [$type, $param] = $type; + } elseif (str_contains($type, ':')) { + [$type, $param] = explode(':', $type, 2); + } + + $typeTransform = static function (string $type, $value, $model) { + if (class_exists($type)) { + if (is_subclass_of($type, Typeable::class)) { + $value = $value->value(); + } elseif (is_subclass_of($type, FieldTypeTransform::class)) { + $value = $type::set($value, $model); + } elseif ($value instanceof BackedEnum) { + $value = $value->value; + } elseif ($value instanceof Stringable) { + $value = $value->__toString(); + } + } + return $value; + }; + + return match ($type) { + 'string','bigint' => (string) $value, + 'int', 'integer' => (int) $value, + 'float' => empty($param) ? (float) $value : (float) number_format($value, (int) $param, '.', ''), + 'bool', 'boolean' => $value ? 1 : 0, + 'object' => is_object($value) ? json_encode($value, JSON_FORCE_OBJECT) : $value, + 'array' => json_encode((array) $value, JSON_UNESCAPED_UNICODE), + 'json' => $typeTransform(Json::class, $value, $this), + 'date' => $typeTransform(Date::class, $value, $this), + 'datetime' => $typeTransform(DateTime::class, $value, $this), + 'timestamp' => $typeTransform(DateTime::class, $value, $this), + default => $typeTransform($type, $value, $this), + }; + } + + /** + * 刷新对象原始数据(为当前数据). + * + * @return $this + */ + public function refreshOrigin() + { + return $this->setOption('origin', $this->getData()); + } + + /** + * 设置主键值 + * + * @param int|string $value 值 + * @return void + */ + public function setKey($value) + { + $pk = $this->getPk(); + + if (is_string($pk)) { + $this->set($pk, $value); + } + } + + /** + * 获取主键值 + * + * @return mixed + */ + public function getKey() + { + $pk = $this->getPk(); + if (is_null($pk)) { + return; + } + + if (is_string($pk)) { + return $this->get($pk); + } + + foreach ($pk as $name) { + $data[$name] = $this->get($name); + } + return $data; + } + + /** + * 重置模型数据. + * + * @param array $data + * + * @return $this + */ + public function data(array $data) + { + $this->initializeData($data); + return $this; + } + + /** + * 获取模型实际数据. + * + * @param string|null $name 字段名 + * @return mixed + */ + public function getData(?string $name = null) + { + if ($name) { + $name = $this->getRealFieldName($name); + return $this->getWeakData('data', $name); + } + return $this->getOption('data', []); + } + + /** + * 判断模型是否存在数据字段. + * + * @param string $name 字段名 + * @return bool + */ + public function hasData(string $name): bool + { + return $this->hasGetAttr($name) || array_key_exists($this->getMappingName($name), self::$weakMap[$this]['data']); + } + + /** + * 设置数据对象的实际值 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return void + */ + protected function setData(string $name, $value) + { + $this->setWeakData('data', $name, $value); + if ($this->getWeakData('get', $name)) { + $this->setWeakData('get', $name, null); + } + } + + /** + * 清空模型数据. + * + * @return $this + */ + public function clear() + { + $this->setOption('data', []); + $this->setOption('origin', []); + $this->setOption('get', []); + $this->setOption('relation', []); + return $this; + } + + /** + * 获取原始数据. + * + * @param string|null $name 字段名 + * @param bool $transform 是否自动类型转换 + * @return mixed + */ + public function getOrigin(?string $name = null, bool $transfrom = false) + { + if ($name) { + $name = $this->getRealFieldName($name); + $result = $this->getWeakData('origin', $name); + return $transfrom ? $this->writeTransform($result, $this->getFields($name)) : $result; + } + return $this->getOption('origin'); + } + + /** + * 判断数据是否为空. + * + * @return bool + */ + public function isEmpty(): bool + { + return empty($this->getData()); + } + + /** + * 判断JSON数据是否为数组格式. + * + * @return bool|null + */ + public function isJsonAssoc(): bool|null + { + return $this->getOption('jsonAssoc', true); + } + + /** + * 设置JSON数据格式. + * + * @return $this + */ + public function jsonAssoc(bool $assoc = true) + { + return $this->setOption('jsonAssoc', $assoc); + } + + /** + * 设置数据对象的值 并进行类型自动转换 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return $this + */ + public function set(string $name, $value) + { + $name = $this->getMappingName($name); + $type = $this->getFields()[$name] ?? ''; + + if ($this->isExists() && in_array($name, $this->getOption('readonly'))) { + // 只读属性不能赋值 + return $this; + } + + if (is_null($value) && is_subclass_of($type, Model::class)) { + // 关联数据为空 设置一个空模型 + $value = new $type(); + } elseif (!($value instanceof Model || $value instanceof Collection || $value instanceof FieldTypeTransform) && $type && !$this->hasSetAttr($name)) { + // 类型自动转换 + $value = $this->readTransform($value, $type); + } + + $this->setData($name, $value); + return $this; + } + + /** + * 字段是否定义修改器 + * + * @param string $name 名称 + * + * @return bool + */ + protected function hasSetAttr(string $name): bool + { + $attr = Str::studly($name); + $method = 'set' . $attr . 'Attr'; + return method_exists($this, $method); + } + + /** + * 字段是否定义获取器 + * + * @param string $name 名称 + * + * @return bool + */ + protected function hasGetAttr(string $name): bool + { + $attr = Str::studly($name); + $method = 'get' . $attr . 'Attr'; + return method_exists($this, $method); + } + + /** + * 使用修改器或类型自动转换处理数据(写入数据前自动调用) + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return mixed + */ + private function setWithAttr(string $name, $value) + { + $attr = Str::studly($name); + $method = 'set' . $attr . 'Attr'; + if (method_exists($this, $method)) { + $value = $this->$method($value, $this->getData()); + } else { + // 类型转换 + $value = $this->writeTransform($value, $this->getFields($name)); + } + + if ($value instanceof Express) { + // 处理运算表达式 + $step = $value->getStep(); + $origin = $this->getOrigin($name); + $real = match ($value->getType()) { + '+' => $origin + $step, + '-' => $origin - $step, + '*' => $origin * $step, + '/' => $origin / $step, + default => $origin, + }; + $this->set($name, $real); + } elseif (is_scalar($value)) { + // 同步写入修改器或类型自动转换结果 + $this->set($name, $value); + } + + return $value; + } + + /** + * 获取数据对象的值(支持使用获取器) + * + * @param string $name 名称 + * @param bool $attr 是否使用获取器 + * + * @return mixed + */ + public function get(string $name, bool $attr = true) + { + $name = $this->getMappingName($name); + if ($attr && $value = $this->getWeakData('get', $name)) { + // 已经输出的数据直接返回 + return $value; + } + + if (!array_key_exists($name, $this->getData()) && !array_key_exists($name, $this->getFields())) { + // 动态获取关联数据 + $value = $this->getRelationData($name) ?: null; + } else { + $value = $this->getData($name); + } + + if ($attr) { + // 通过获取器输出 + $value = $this->getWithAttr($name, $value, $this->getData()); + $this->setWeakData('get', $name, $value); + } + + return $value; + } + + /** + * 获取映射字段 + * + * @param string $name 名称 + * + * @return string + */ + protected function getMappingName(string $name): string + { + $mapping = $this->getOption('mapping'); + return array_search($name, $mapping) ?: $this->getRealFieldName($name); + } + + /** + * 处理数据对象的值(经过获取器和类型转换) + * + * @param string $name 名称 + * @param mixed $value 值 + * @param array $data 所有数据 + * + * @return mixed + */ + private function getWithAttr(string $name, $value, array $data = []) + { + $attr = Str::studly($name); + $method = 'get' . $attr . 'Attr'; + $withAttr = $this->getWeakData('withAttr', $name); + if ($withAttr) { + // 动态获取器 + $value = $withAttr($value, $data, $this); + } elseif (method_exists($this, $method)) { + // 获取器 + $value = $this->$method($value, $data); + } elseif ($value instanceof Typeable || is_subclass_of($value, EnumTransform::class, false)) { + // 类型自动转换 + if ($value instanceof Json) { + // JSON数据转换 + $value = $this->readTransformJson($name, $value); + } else { + $value = $value->value(); + } + } elseif (is_int($value) && $this->isTimeAttr($name) && false != $this->getDateFormat()) { + // 兼容数字类型时间字段的自动转换输出 + $value = (new \DateTime()) + ->setTimestamp($value) + ->format($this->getDateFormat()); + } + return $value; + } + + /** + * 处理JSON数据对象的值 + * + * @param string $name 名称 + * @param Json $value 值 + * + * @return array|object + */ + protected function readTransformJson(string $name, Json $value) + { + // JSON数据转换 + $value = $value->value(); + if ($value) { + foreach ($value as $key => &$val) { + $type = $this->getFields($name . '->' . $key); + if ($type) { + // 定义了JSON属性类型自动转换 + $val = $this->readTransform($val, $type); + } + } + } + return $value; + } + + protected function isTimeAttr(string $name): bool + { + return in_array($name, [$this->getOption('createTime'), $this->getOption('updateTime'), $this->getOption('deleteTime')]) || in_array($name, $this->getOption('timestampField', [])); + } + + /** + * 使用获取器获取数据对象的值 + * + * @param string $name 名称 + * + * @return mixed + */ + public function getAttr(string $name) + { + return $this->get($name); + } + + /** + * 设置数据对象的值 并进行类型自动转换 + * + * @param string $name 名称 + * @param mixed $value 值 + * + * @return $this + */ + public function setAttr(string $name, $value) + { + return $this->set($name, $value); + } + + /** + * 设置数据是否存在. + * + * @param bool $exists + * + * @return $this + */ + public function exists(bool $exists = true) + { + return $this->setOption('exists', $exists); + } + + /** + * 判断数据是否存在数据库. + * + * @return bool + */ + public function isExists(): bool + { + return $this->getOption('exists', false); + } + + /** + * 设置枚举类型自动读取数据方式 + * true 表示使用name值返回 + * 字符串 表示使用枚举类的方法返回 + * + * @return $this + */ + public function withEnumRead(bool | string $method = true) + { + return $this->setOption('enumReadName', $method); + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php b/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php new file mode 100644 index 0000000..afef8e9 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php @@ -0,0 +1,138 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use Closure; +use Stringable; +use think\model\contract\Typeable; +use think\model\type\DateTime; + +/** + * 自动写入数据. + */ +trait AutoWriteData +{ + /** + * 字段自动写入. + * + * @param array $data 数据 + * @param bool $update 是否更新 + * @param array $allow 允许字段 + * @return void + */ + protected function autoWriteData(array &$data, bool $update, array $allow = []) + { + // 数据写入前置检查 + $this->checkData($data, $update); + + // 自动时间戳处理 + $this->autoDateTime($data, $update, $allow); + + $auto = $this->getOption($update ? 'update' : 'insert', []); + foreach ($auto as $name => $val) { + $field = is_string($name) ? $name : $val; + if (!isset($data[$field])) { + if ($val instanceof Closure) { + $value = $val($this); + } else { + $value = is_string($name) ? $val : $this->setWithAttr($field, null, $data); + } + $data[$field] = $value; + $this->setData($field, $value); + } + } + } + + /** + * 时间字段自动写入. + * + * @param array $data 数据 + * @param bool $update 是否更新 + * @param array $allow 允许字段 + * @return void + */ + protected function autoDateTime(array &$data, bool $update, array $allow) + { + $autoDateTime = $this->getOption('autoWriteTimestamp', true); + if ($autoDateTime) { + $dateTimeFields = [$this->getOption('updateTime')]; + if (!$update) { + array_unshift($dateTimeFields, $this->getOption('createTime')); + } + + foreach ($dateTimeFields as $field) { + if (is_string($field) && (empty($allow) || in_array($field, $allow))) { + $data[$field] = $this->getDateTime($field); + $this->setData($field, $this->readTransform($data[$field], $this->getFields($field))); + } + } + } + } + + public function getAutoTimeFields(): array + { + return [$this->getOption('createTime'), $this->getOption('updateTime')]; + } + + /** + * 获取当前时间. + * + * @param string $field 字段名 + * @return mixed + */ + protected function getDateTime(string $field) + { + $type = $this->getFields($field) ?? 'string'; + if (in_array($type, ['int', 'integer'])) { + return time(); + } elseif (is_subclass_of($type, Typeable::class)) { + return $type::from('now', $this)->format('Y-m-d H:i:s.u'); + } elseif (str_contains($type, '\\')) { + $obj = new $type(); + if ($obj instanceof Stringable) { + return $obj->__toString(); + } else { + return (string) $obj; + } + } else { + return DateTime::from('now', $this)->format('Y-m-d H:i:s.u'); + } + } + + public function getAutoWriteTimestamp() + { + return $this->getOption('autoWriteTimestamp'); + } + + public function isAutoWriteTimestamp(string | bool $auto) + { + return $this->setOption('autoWriteTimestamp', $auto); + } + + public function getDateFormat() + { + return $this->getOption('dateFormat'); + } + + public function setDateFormat(string | bool $format) + { + return $this->setOption('dateFormat', $format); + } + + public function setTimeField($createTime, $updateTime) + { + $this->setOption('createTime', $createTime); + $this->setOption('updateTime', $updateTime); + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/Conversion.php b/vendor/topthink/think-orm/src/model/concern/Conversion.php new file mode 100644 index 0000000..6068b3e --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/Conversion.php @@ -0,0 +1,208 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use Closure; +use think\helper\Str; +use think\model\Collection; +use think\model\contract\Modelable; + +/** + * 模型数据转换处理. + */ +trait Conversion +{ + /** + * 设置需要附加的输出属性. + * + * @param array $append 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function append(array $append, bool $merge = false) + { + return $this->setOption('append', $merge ? array_merge($this->getOption('append'), $append) : $append); + } + + /** + * 设置需要隐藏的输出属性. + * + * @param array $hidden 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function hidden(array $hidden, bool $merge = false) + { + return $this->setOption('hidden', $merge ? array_merge($this->getOption('hidden'), $hidden) : $hidden); + } + + /** + * 设置需要输出的属性. + * + * @param array $visible + * @param bool $merge 是否合并 + * + * @return $this + */ + public function visible(array $visible, bool $merge = false) + { + return $this->setOption('visible', $merge ? array_merge($this->getOption('visible'), $visible) : $visible); + } + + /** + * 设置属性的映射输出. + * + * @param array $map + * + * @return $this + */ + public function mapping(array $map) + { + return $this->setOption('mapping', $map); + } + + /** + * 设置输出场景. + * + * @param string $scene + * + * @return $this + */ + public function scene(string $scene) + { + $method = 'scene' . Str::studly($scene); + if (method_exists($this, $method)) { + call_user_func([$this, $method]); + } + return $this; + } + + /** + * 模型数据转数组. + * + * @return array + */ + public function toArray(): array + { + $mapping = $this->getOption('mapping'); + foreach (['visible', 'hidden', 'append'] as $convert) { + ${$convert} = $this->getOption($convert); + foreach (${$convert} as $key => $val) { + if (is_string($key)) { + $relation[$key][$convert] = $val; + unset(${$convert}[$key]); + } elseif (str_contains($val, '.')) { + [$relName, $name] = explode('.', $val); + $relation[$relName][$convert][] = $name; + unset(${$convert}[$key]); + } elseif ($item = array_search($val, $mapping)) { + ${$convert}[$key] = $item; + } + } + } + $data = $this->getData(); + $allow = array_diff($visible ?: array_keys($data), $hidden); + + $item = []; + foreach ($data as $name => $val) { + if ($val instanceof Modelable || $val instanceof Collection) { + if (in_array($name, $hidden)) { + // 隐藏关联属性 + unset($item[$name]); + continue; + } + + if (!empty($relation[$name])) { + // 处理关联数据输出 + foreach ($relation[$name] as $key => $attr) { + $val->$key($attr); + } + } + $item[$name] = $val->toArray(); + } elseif (empty($allow) || in_array($name, $allow)) { + // 通过获取器输出 + $item[$name] = $this->getWithAttr($name, $val, $data); + } + + if (array_key_exists($name, $item) && isset($mapping[$name])) { + // 检查字段映射 + $item[$mapping[$name]] = $item[$name]; + unset($item[$name]); + } + } + + // 输出额外属性 必须定义获取器 + foreach ($this->getOption('append') as $key => $field) { + if (is_numeric($key)) { + $item[$field] = $this->get($field); + } else { + // 追加关联属性 + $relation = $this->getRelationData($key, false); + foreach((array) $field as $key => $name) { + if (is_numeric($key)) { + $item[$name] = $relation?->get($name); + } else { + $item[$name] = $relation?->get($key); + } + } + } + } + + if ($this->getOption('convertNameToCamel')) { + foreach ($item as $key => $val) { + $name = Str::camel($key); + if ($name !== $key) { + $item[$name] = $val; + unset($item[$key]); + } + } + } + + return $item; + } + + /** + * 模型数据转Json. + * + * @param int $options json参数 + * @return string + */ + public function toJson(int $options = JSON_UNESCAPED_UNICODE): string + { + return json_encode($this->toArray(), $options); + } + + /** + * 转换为数据集对象 + * + * @param array|Collection $collection 数据集 + * @param string|null $resultSetType 数据集类 + * + * @return Collection + */ + public function toCollection(iterable $collection = [], ?string $resultSetType = null): Collection + { + $resultSetType = $resultSetType ?: $this->getOption('resultSetType'); + + if ($resultSetType && str_contains($resultSetType, '\\')) { + $collection = new $resultSetType($collection); + } else { + $collection = new Collection($collection); + } + + return $collection; + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/DbConnect.php b/vendor/topthink/think-orm/src/model/concern/DbConnect.php new file mode 100644 index 0000000..7fd2eb7 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/DbConnect.php @@ -0,0 +1,202 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use think\db\BaseQuery as Query; +use think\facade\Db; + +/** + * 数据库连接. + */ +trait DbConnect +{ + /** + * 设置Db对象实例.(用于兼容) + */ + public static function setDb($db) + {} + + /** + * 获取Db对象实例. + * @return Query + */ + public function getQuery() + { + $db = $this->initDb()->newQuery($this->getOption('query')); + + if ($this->getOption('cache')) { + [$key, $expire, $tag] = $this->getOption('cache'); + $db->cache($key, $expire, $tag); + } + + return $db->schema($this->getOption('schema')) + ->pk($this->getPk()) + ->suffix($this->getOption('suffix')) + ->setKey($this->getKey()) + ->replace($this->getOption('replace', false)) + ->model($this); + } + + /** + * 初始化数据库连接对象. + * @return Query + */ + private function initDb() + { + $connection = $this->getOption('connection'); + if ($this->getOption('db')) { + $db = $this->getOption('db')->connect($connection); + } else { + $db = Db::connect($connection); + } + + $db = $db->name($this->getName()); + if ($this->getOption('table')) { + $db->table($this->getOption('table')); + } else { + $db->suffix($this->getOption('suffix')); + } + + return $db; + } + + /** + * 获取数据表字段类型列表(或某个字段的类型). + * + * @param string|null $field 字段名 + * + * @return array|string + */ + protected function getFields(?string $field = null) + { + $schema = $this->getOption('schema'); + if (empty($schema)) { + // 获取数据表信息 + $db = $this->initDb(); + $fields = $db->getFieldsType(); + $schema = array_merge($fields, $this->getOption('type', [])); + // 获取主键 + if (!$this->getOption('pk')) { + $this->setOption('pk', $db->getPk()); + } + + $this->setOption('schema', $schema); + } + + if ($field) { + return $schema[$field] ?? null; + } + + return $schema; + } + + /** + * 新增数据是否使用Replace. + * + * @param bool $replace + * + * @return $this + */ + public function replace(bool $replace = true) + { + return $this->setOption('replace', $replace); + } + + /** + * 获取当前模型的数据表后缀 + * + * @return string + */ + public function getSuffix(): string + { + return $this->getOption('suffix', ''); + } + + /** + * 设置当前模型数据表的后缀 + * + * @param string $suffix 数据表后缀 + * + * @return $this + */ + public function setSuffix(string $suffix) + { + $this->setOption('suffix', $suffix); + + return $this; + } + + /** + * 构建实体模型查询. + * + * @param Query $query 查询对象 + * @return void + */ + protected function query(Query $query) {} + + /** + * 获取查询对象 + * + * @param array|null $scope 设置不使用的全局查询范围 + * @return Query + */ + public function db(array | null $scope = []): Query + { + $query = $this->getQuery(); + // 全局查询范围 + if (is_array($scope)) { + $globalScope = array_diff($this->getOption('globalScope', []), $scope); + $query->scope($globalScope); + } + // 执行扩展查询 + $this->query($query); + return $query; + } + + /** + * 设置不使用的全局查询范围. + * + * @param array $scope 不启用的全局查询范围 + * + * @return Query + */ + public static function withoutGlobalScope(?array $scope = null): Query + { + $model = new static(); + + return $model->db($scope); + } + + public static function __callStatic($method, $args) + { + $model = new static(); + $db = $model->db(); + + if (!empty(self::$weakMap[$model]['autoRelation'])) { + // 自动获取关联数据 + $db->with(self::$weakMap[$model]['autoRelation']); + } + + return call_user_func_array([$db, $method], $args); + } + + public function __call($method, $args) + { + if ($this->isExists() && strtolower($method) == 'withattr') { + return call_user_func_array([$this, 'withFieldAttr'], $args); + } + + return call_user_func_array([$this->db(), $method], $args); + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/ModelEvent.php b/vendor/topthink/think-orm/src/model/concern/ModelEvent.php new file mode 100644 index 0000000..12df036 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/ModelEvent.php @@ -0,0 +1,85 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use ReflectionClass; +use think\db\exception\ModelEventException; +use think\helper\Str; + +/** + * 模型事件处理. + */ +trait ModelEvent +{ + /** + * 设置Event对象 (用于兼容) + * + * @param object $event Event对象 + * + * @return void + */ + public static function setEvent($event) + {} + + /** + * 当前操作的事件响应. + * + * @param bool $event 是否需要事件响应 + * + * @return $this + */ + public function withEvent(bool $event) + { + return $this->setOption('withEvent', $event); + } + + /** + * 触发事件. + * + * @param string $event 事件名 + * + * @return bool + */ + protected function trigger(string $event): bool + { + if (!$this->getOption('withEvent', true)) { + return true; + } + + $method = 'on' . Str::studly($event); + $obj = $this->getOption('event'); + $obser = $this->getOption('eventObserver'); + try { + if ($obser) { + $reflect = new ReflectionClass($obser); + $observer = $reflect->newinstance(); + } else { + $observer = $this; + } + + if (method_exists($observer, $method)) { + $result = $this->invoke([$observer, $method], [$this]); + } elseif (is_object($obj) && method_exists($obj, 'trigger')) { + $result = $obj->trigger(static::class . '.' . $event, $this); + $result = empty($result) ? true : end($result); + } else { + $result = true; + } + + return false !== $result; + } catch (ModelEventException $e) { + return false; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/OptimLock.php b/vendor/topthink/think-orm/src/model/concern/OptimLock.php new file mode 100644 index 0000000..ed25504 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/OptimLock.php @@ -0,0 +1,87 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\model\concern; + +use think\db\exception\DbException as Exception; + +/** + * 乐观锁 + */ +trait OptimLock +{ + protected function getOptimLockField() + { + return $this->getOption('optimLock') ?? 'lock_version'; + } + + /** + * 数据检查. + * @param array $data 数据 + * @param bool $isUpdate 是否更新 + * @return void + */ + protected function checkData(array &$data, bool $isUpdate): void + { + $isUpdate ? $this->updateLockVersion($data) : $this->recordLockVersion($data); + } + + /** + * 记录乐观锁 + * + * @param array $data 数据 + * @return void + */ + protected function recordLockVersion(array &$data): void + { + $optimLock = $this->getOptimLockField(); + + $this->setData($optimLock, 0); + $data[$optimLock] = 0; + } + + /** + * 更新乐观锁 + * + * @param array $data 数据 + * @return void + */ + protected function updateLockVersion(array &$data): void + { + $optimLock = $this->getOptimLockField(); + $lockVer = $this->getOrigin($optimLock); + + $this->setData($optimLock, $lockVer + 1); + $data[$optimLock] = $lockVer + 1; + } + + public function getDbWhere($where) + { + $db = $this->db(); + // 检查条件 + if (!empty($where)) { + $db->where($where); + } + $optimLock = $this->getOptimLockField(); + $lockVer = $this->getOrigin($optimLock); + $pk = $this->getPk(); + if (is_array($pk)) { + $db->where($this->getKey()); + } else { + $db->where($pk, '=', $this->getKey()); + } + $db->where($optimLock, '=', $lockVer); + + return $db; + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/RelationShip.php b/vendor/topthink/think-orm/src/model/concern/RelationShip.php new file mode 100644 index 0000000..7eb4a27 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/RelationShip.php @@ -0,0 +1,902 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use Closure; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use think\db\exception\InvalidArgumentException; +use think\helper\Str; +use think\model\Collection; +use think\model\contract\Modelable as Model; +use think\model\Relation; +use think\model\relation\BelongsTo; +use think\model\relation\BelongsToMany; +use think\model\relation\HasMany; +use think\model\relation\HasManyThrough; +use think\model\relation\HasOne; +use think\model\relation\HasOneThrough; +use think\model\relation\MorphMany; +use think\model\relation\MorphOne; +use think\model\relation\MorphTo; +use think\model\relation\MorphToMany; +use think\model\relation\OneToOne; +use think\model\View; + +/** + * 实体模型关联处理. + */ +trait RelationShip +{ + /** + * 关联数据写入或删除. + * + * @param array $relation 关联 + * + * @return $this + */ + public function together(array $relation) + { + return $this->setOption('together', $relation); + } + + /** + * 设置关联JOIN数据. + * + * @param array $relations 关联数据 + * + * @return void + */ + private function parseRelationData(array $relations) + { + foreach ($relations as $relation => $val) { + $relation = $this->getRealFieldName($relation); + $type = $this->getFields($relation); + $bind = $this->getBindAttr($this->getOption('bindAttr'), $relation); + if (!empty($bind)) { + // 绑定关联属性 + $this->bindRelationAttr($val, $bind, $relation); + } elseif (is_subclass_of($type, Model::class)) { + // 明确类型直接设置关联属性 + $this->setRelation($relation, new $type($val)); + } else { + // 寄存关联数据 + $this->setTempRelation($relation, $val); + } + } + } + + /** + * 寄存关联数据. + * + * @param string $relation 关联属性 + * @param array $data 关联数据 + * + * @return void + */ + private function setTempRelation(string $relation, array $data) + { + $this->setWeakData('relation', $relation, $data); + } + + /** + * 获取寄存的关联数据. + * + * @param string $relation 关联属性 + * + * @return array + */ + public function getRelation(string $relation): array + { + return $this->getWeakData('relation', $relation, []); + } + + /** + * 写入模型关联数据(一对一). + * + * @param array $relations 数据 + * @param bool $isUpdate 是否更新 + * @return void + */ + private function relationSave(array $relations = [], bool $isUpdate = true) + { + $together = $this->getOption('together'); + foreach ($together as $key => $name) { + if (is_numeric($key) && isset($relations[$name])) { + // 支持关联写入或更新 + $method = Str::camel($name); + $relation = $relations[$name]; + $data = null; + if ($relation instanceof Model) { + if ($isUpdate) { + $relation->save(); + } else { + $data = $this->$method()->save($relation); + } + } else { + // 数组或数据集 + $relationModel = $this->$method(); + if ($relationModel instanceof OneToOne) { + $data = $relationModel->save($relation); + } elseif ($relationModel instanceof HasMany || $relationModel instanceof MorphMany) { + $data = $relationModel->saveAll($relation); + if ($data) { + $data = $this->toCollection($data); + } + } + } + if ($data) { + // 重新赋值关联数据 + $this->set($name, $data); + } + } elseif (is_array($name)) { + // 关联写入 + $data = []; + if (array_is_list($name)) { + // 绑定关联属性 + foreach($name as $field) { + if ($this->getData($field)) { + $data[$field] = $this->getData($field); + } + } + } else { + $data = $name; + } + $method = Str::camel($key); + $this->$method()->save($data); + } + } + } + + /** + * 删除模型关联数据(一对一). + * + * @param array $relations 数据 + * @return void + */ + private function relationDelete(array $relations = []) + { + foreach ($relations as $name => $relation) { + if ($relation && in_array($name, $this->getOption('together'))) { + $relation->delete(); + } + } + } + + /** + * 获取关联数据 + * + * @param string $name 名称 + * @param bool $set 是否设置为当前模型属性 + * + * @return mixed + */ + protected function getRelationData(string $name, bool $set = true) + { + $method = Str::camel($name); + if (method_exists($this, $method) && !method_exists('think\Model', $method)) { + $modelRelation = $this->$method(); + if ($modelRelation instanceof Relation) { + $value = $modelRelation->getRelation(); + if ($set) { + $this->setData($name, $value); + } + return $value; + } + } + } + + /** + * 判断是否存在关联 + * + * @param string $name 名称 + * + * @return bool + */ + public function hasRelation(string $name) + { + $method = Str::camel($name); + if (method_exists($this, $method)) { + $modelRelation = $this->$method(); + if ($modelRelation instanceof Relation) { + return true; + } + } + return false; + } + + protected function getBindAttr($bind, $name) + { + return $bind[$name] ?? []; + } + + /** + * 设置关联绑定数据 + * + * @param Model|array $model 关联对象 + * @param array $bind 绑定属性 + * @return void + */ + public function bindRelationAttr(Model | array $model, array $bind = []) + { + $data = is_array($model) ? $model : $model->toArray(); + foreach ($data as $key => $val) { + if (isset($bind[$key])) { + $this->set($bind[$key], $val); + } elseif ($attr = array_search($key, $bind)) { + $this->set(is_numeric($attr) ? $key : $attr, $val); + } elseif (in_array($key, $bind)) { + $this->set($key, $val); + } + } + } + + /** + * 设置关联数据. + * + * @param string $relation 关联属性 + * @param Model|Collection $data 关联数据 + * + * @return void + */ + public function setRelation(string $relation, $data) + { + $this->__set($relation, $data); + } + + /** + * 查询存在关联数据的模型. + * + * @param string $relation 关联方法名 + * @param mixed $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public static function has(string $relation, string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null): Query + { + return (new static()) + ->$relation() + ->has($operator, $count, $id, $joinType, $query); + } + + /** + * 查询不存在关联数据的模型. + * + * @param string $relation 关联方法名 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public static function hasNot(string $relation, string $id = '*', string $joinType = '', ?Query $query = null): Query + { + return (new static()) + ->$relation() + ->has('=', 0, $id, $joinType, $query); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string|array $relation 关联方法名 或 ['关联方法名', '关联表别名'] + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public static function hasWhere(string|array $relation, $where = [], string $fields = '*', string $joinType = '', ?Query $query = null): Query + { + if (is_array($relation)) { + [$relation, $alias] = $relation; + } + + return (new static()) + ->$relation() + ->hasWhere($where, $fields, $joinType, $query, '', $alias ?? ''); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string|array $relation 关联方法名 或 ['关联方法名', '关联表别名'] + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public static function hasWhereOr(string|array $relation, $where = [], string $fields = '*', string $joinType = '', ?Query $query = null): Query + { + if (is_array($relation)) { + [$relation, $alias] = $relation; + } + + return (new static()) + ->$relation() + ->hasWhere($where, $fields, $joinType, $query, 'OR', $alias ?? ''); + } + + /** + * 查询当前模型的关联数据. + * + * @param array $relations 关联名 + * @param array $withRelationAttr 关联获取器 + * + * @return void + */ + public function relationQuery(array $relations, array $withRelationAttr = []): void + { + foreach ($relations as $key => $relation) { + $subRelation = []; + $closure = null; + + if ($relation instanceof Closure) { + // 支持闭包查询过滤关联条件 + $closure = $relation; + $relation = $key; + } + + if (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (str_contains($relation, '.')) { + [$relation, $subRelation] = explode('.', $relation, 2); + } + + $method = Str::camel($relation); + $relationName = Str::snake($relation); + $relationResult = $this->$method(); + + if (isset($withRelationAttr[$relationName])) { + $relationResult->withAttr($withRelationAttr[$relationName]); + } + + $this->setRelation($relation, $relationResult->getRelation((array) $subRelation, $closure)); + } + } + + /** + * 预载入关联查询 JOIN方式. + * + * @param Query $query Query对象 + * @param string $relation 关联方法名 + * @param mixed $field 字段 + * @param string $joinType JOIN类型 + * @param Closure $closure 闭包 + * @param bool $first + * + * @return bool + */ + public function eagerly(Query $query, string $relation, $field, string $joinType = '', ?Closure $closure = null, bool $first = false): bool + { + $relation = Str::camel($relation); + $class = $this->$relation(); + + if ($class instanceof OneToOne) { + $class->eagerly($query, $relation, $field, $joinType, $closure, $first); + + return true; + } + + return false; + } + + /** + * 预载入关联查询 返回数据集. + * + * @param array $resultSet 数据集 + * @param array $relations 关联名 + * @param array $withRelationAttr 关联获取器 + * @param bool $join 是否为JOIN方式 + * @param mixed $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array $resultSet, array $relations, array $withRelationAttr = [], bool $join = false, $cache = false): void + { + foreach ($relations as $key => $relation) { + $subRelation = []; + $closure = null; + + if ($relation instanceof Closure) { + $closure = $relation; + $relation = $key; + } + + if (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (str_contains($relation, '.')) { + [$relation, $subRelation] = explode('.', $relation, 2); + + $subRelation = [$subRelation]; + } + + $relationName = $relation; + $relation = Str::camel($relation); + $relationResult = $this->$relation(); + + if (isset($withRelationAttr[$relationName])) { + $relationResult->withAttr($withRelationAttr[$relationName]); + } + + if (is_scalar($cache)) { + $relationCache = [$cache]; + } else { + $relationCache = $cache[$relationName] ?? $cache; + } + + $relationResult->eagerlyResultSet($resultSet, $relationName, $subRelation, $closure, $relationCache, $join); + } + + // 刷新视图模型数据 + foreach ($resultSet as $result) { + if ($result instanceof View) { + $result->refresh(); + } + } + } + + /** + * 预载入关联查询 返回模型对象 + * + * @param array $relations 关联 + * @param array $withRelationAttr 关联获取器 + * @param bool $join 是否为JOIN方式 + * @param mixed $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, array $relations, array $withRelationAttr = [], bool $join = false, $cache = false): void + { + foreach ($relations as $key => $relation) { + $subRelation = []; + $closure = null; + + if ($relation instanceof Closure) { + $closure = $relation; + $relation = $key; + } + + if (is_array($relation)) { + $subRelation = $relation; + $relation = $key; + } elseif (str_contains($relation, '.')) { + [$relation, $subRelation] = explode('.', $relation, 2); + + $subRelation = [$subRelation]; + } + + $relationName = $relation; + $relation = Str::camel($relation); + $relationResult = $this->$relation(); + + if (isset($withRelationAttr[$relationName])) { + $relationResult->withAttr($withRelationAttr[$relationName]); + } + + if (is_scalar($cache)) { + $relationCache = [$cache]; + } else { + $relationCache = $cache[$relationName] ?? []; + } + + $relationResult->eagerlyResult($result, $relationName, $subRelation, $closure, $relationCache, $join); + } + + if ($result instanceof View) { + // 刷新视图模型数据 + $result->refresh(); + } + } + + /** + * 绑定(一对一)关联属性到当前模型. + * + * @param string $relation 关联名称 + * @param array $attrs 绑定属性 + * + * @throws Exception + * + * @return $this + */ + public function bindAttr(string $relation, array $attrs = []) + { + $relation = $this->__get($relation); + + foreach ($attrs as $key => $attr) { + if (is_numeric($key)) { + if (!is_string($attr)) { + throw new InvalidArgumentException('bind attr must be string:' . $key); + } + + $key = $attr; + } + + if (null !== $this->getOrigin($key)) { + throw new Exception('bind attr has exists:' . $key); + } + + if ($attr instanceof Closure) { + $value = $attr($relation, $key, $this); + } else { + $value = $relation?->get($attr); + } + + $this->set($key, $value); + } + + return $this; + } + + /** + * 关联统计 + * + * @param Query $query 查询对象 + * @param array $relations 关联名 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param bool $useSubQuery 子查询 + * + * @return void + */ + public function relationCount(Query $query, array $relations, string $aggregate = 'sum', string $field = 'id', bool $useSubQuery = true): void + { + foreach ($relations as $key => $relation) { + $closure = $name = null; + + if ($relation instanceof Closure) { + $closure = $relation; + $relation = $key; + } elseif (is_string($key)) { + $name = $relation; + $relation = $key; + } + + $relation = Str::camel($relation); + + if ($useSubQuery) { + $count = $this->$relation()->getRelationCountQuery($closure, $aggregate, $field, $name); + } else { + $count = $this->$relation()->relationCount($this, $closure, $aggregate, $field, $name); + } + + if (empty($name)) { + $name = Str::snake($relation) . '_' . $aggregate; + } + + if ($useSubQuery) { + $query->field(['(' . $count . ')' => $name]); + } else { + $this->set($name, $count); + } + } + } + + /** + * HAS ONE 关联定义. + * + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前主键 + * + * @return HasOne + */ + public function hasOne(string $model, string $foreignKey = '', string $localKey = ''): HasOne + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->getName()); + + return new HasOne($this, $model, $foreignKey, $localKey); + } + + /** + * BELONGS TO 关联定义. + * + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 关联主键 + * + * @return BelongsTo + */ + public function belongsTo(string $model, string $foreignKey = '', string $localKey = ''): BelongsTo + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + $foreignKey = $foreignKey ?: $this->getForeignKey((new $model())->getName()); + $localKey = $localKey ?: (new $model())->getPk(); + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $relation = Str::snake($trace[1]['function']); + + return new BelongsTo($this, $model, $foreignKey, $localKey, $relation); + } + + /** + * HAS MANY 关联定义. + * + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前主键 + * + * @return HasMany + */ + public function hasMany(string $model, string $foreignKey = '', string $localKey = ''): HasMany + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->getName()); + + return new HasMany($this, $model, $foreignKey, $localKey); + } + + /** + * HAS MANY 远程关联定义. + * + * @param string $model 模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 关联外键 + * @param string $localKey 当前主键 + * @param string $throughPk 中间表主键 + * + * @return HasManyThrough + */ + public function hasManyThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', string $throughPk = ''): HasManyThrough + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + $through = $this->parseRelationModel($through); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->getName()); + $throughKey = $throughKey ?: $this->getForeignKey((new $through())->getName()); + $throughPk = $throughPk ?: (new $through())->getPk(); + + return new HasManyThrough($this, $model, $through, $foreignKey, $throughKey, $localKey, $throughPk); + } + + /** + * HAS ONE 远程关联定义. + * + * @param string $model 模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 关联外键 + * @param string $localKey 当前主键 + * @param string $throughPk 中间表主键 + * + * @return HasOneThrough + */ + public function hasOneThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', string $throughPk = ''): HasOneThrough + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + $through = $this->parseRelationModel($through); + $localKey = $localKey ?: $this->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->getName()); + $throughKey = $throughKey ?: $this->getForeignKey((new $through())->getName()); + $throughPk = $throughPk ?: (new $through())->getPk(); + + return new HasOneThrough($this, $model, $through, $foreignKey, $throughKey, $localKey, $throughPk); + } + + /** + * BELONGS TO MANY 关联定义. + * + * @param string $model 模型名 + * @param string $middle 中间表/模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型关联键 + * + * @return BelongsToMany + */ + public function belongsToMany(string $model, string $middle = '', string $foreignKey = '', string $localKey = ''): BelongsToMany + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + $name = Str::snake(class_basename($model)); + $middle = $middle ?: Str::snake($this->getName()) . '_' . $name; + $foreignKey = $foreignKey ?: $name . '_id'; + $localKey = $localKey ?: $this->getForeignKey($this->getName()); + + return new BelongsToMany($this, $model, $middle, $foreignKey, $localKey); + } + + /** + * MORPH One 关联定义. + * + * @param string $model 模型名 + * @param string|array $morph 多态字段信息 + * @param string $type 多态类型 + * + * @return MorphOne + */ + public function morphOne(string $model, string | array | null $morph = null, string $type = ''): MorphOne + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + + if (is_null($morph)) { + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $morph = Str::snake($trace[1]['function']); + } + + [$morphType, $foreignKey] = $this->parseMorph($morph); + + $type = $type ?: get_class($this); + + return new MorphOne($this, $model, $foreignKey, $morphType, $type); + } + + /** + * MORPH MANY 关联定义. + * + * @param string $model 模型名 + * @param string|array $morph 多态字段信息 + * @param string $type 多态类型 + * + * @return MorphMany + */ + public function morphMany(string $model, string | array | null $morph = null, string $type = ''): MorphMany + { + // 记录当前关联信息 + $model = $this->parseRelationModel($model); + + if (is_null($morph)) { + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $morph = Str::snake($trace[1]['function']); + } + + $type = $type ?: get_class($this); + + [$morphType, $foreignKey] = $this->parseMorph($morph); + + return new MorphMany($this, $model, $foreignKey, $morphType, $type); + } + + /** + * MORPH TO 关联定义. + * + * @param string|array $morph 多态字段信息 + * @param array $alias 多态别名定义 + * + * @return MorphTo + */ + public function morphTo(string | array | null $morph = null, array $alias = []): MorphTo + { + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $relation = Str::snake($trace[1]['function']); + + if (is_null($morph)) { + $morph = $relation; + } + + [$morphType, $foreignKey] = $this->parseMorph($morph); + + return new MorphTo($this, $morphType, $foreignKey, $alias, $relation); + } + + /** + * MORPH TO MANY关联定义. + * + * @param string $model 模型名 + * @param string $middle 中间表名/模型名 + * @param string|array $morph 多态字段信息 + * @param string $localKey 当前模型关联键 + * + * @return MorphToMany + */ + public function morphToMany(string $model, string $middle, string | array | null $morph = null, ?string $localKey = null): MorphToMany + { + if (is_null($morph)) { + $morph = $middle; + } + + [$morphType, $morphKey] = $this->parseMorph($morph); + + $model = $this->parseRelationModel($model); + $name = Str::snake(class_basename($model)); + $localKey = $localKey ?: $this->getForeignKey($name); + + return new MorphToMany($this, $model, $middle, $morphType, $morphKey, $localKey); + } + + /** + * MORPH BY MANY关联定义. + * + * @param string $model 模型名 + * @param string $middle 中间表名/模型名 + * @param string|array $morph 多态字段信息 + * @param string $foreignKey 关联外键 + * + * @return MorphToMany + */ + public function morphByMany(string $model, string $middle, string | array | null $morph = null, ?string $foreignKey = null): MorphToMany + { + if (is_null($morph)) { + $morph = $middle; + } + + [$morphType, $morphKey] = $this->parseMorph($morph); + + $model = $this->parseRelationModel($model); + $foreignKey = $foreignKey ?: $this->getForeignKey($this->getName()); + + return new MorphToMany($this, $model, $middle, $morphType, $morphKey, $foreignKey, true); + } + + /** + * 解析多态 + * + * @param string|array $morph + * + * @return array + */ + protected function parseMorph(string | array $morph): array + { + if (is_array($morph)) { + [$morphType, $foreignKey] = $morph; + } else { + $morphType = $morph . '_type'; + $foreignKey = $morph . '_id'; + } + + return [$morphType, $foreignKey]; + } + + /** + * 解析模型的完整命名空间. + * + * @param string $model 模型名(或者完整类名) + * + * @return string + */ + protected function parseRelationModel(string $model): string + { + if (!str_contains($model, '\\')) { + $path = explode('\\', static::class); + array_pop($path); + array_push($path, Str::studly($model)); + $model = implode('\\', $path); + } + + return $model; + } + + /** + * 获取模型的默认外键名. + * + * @param string $name 模型名 + * + * @return string + */ + protected function getForeignKey(string $name): string + { + if (str_contains($name, '\\')) { + $name = class_basename($name); + } + + return Str::snake($name) . '_id'; + } +} diff --git a/vendor/topthink/think-orm/src/model/concern/SoftDelete.php b/vendor/topthink/think-orm/src/model/concern/SoftDelete.php new file mode 100644 index 0000000..879e5fc --- /dev/null +++ b/vendor/topthink/think-orm/src/model/concern/SoftDelete.php @@ -0,0 +1,219 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\concern; + +use Closure; +use think\db\BaseQuery as Query; +use think\Model; + +/** + * 数据软删除 + * + * @mixin Model + * + * @method $this withTrashed() + * @method $this onlyTrashed() + */ +trait SoftDelete +{ + /** + * 获取查询对象 + * + * @param array|null $scope 设置不使用的全局查询范围 + * @return Query + */ + public function db(array | null $scope = []): Query + { + $query = parent::db($scope); + $this->withNoTrashed($query); + + return $query; + } + + /** + * 判断当前实例是否被软删除. + * + * @return bool + */ + public function trashed(): bool + { + $field = $this->getDeleteTimeField(); + + if ($field && !empty($this->getOrigin($field))) { + return true; + } + + return false; + } + + public function scopeWithTrashed(Query $query): void + { + $query->removeOption('soft_delete'); + } + + public function scopeOnlyTrashed(Query $query): void + { + $field = $this->getDeleteTimeField(true); + + if ($field) { + $query->useSoftDelete($field, $this->getWithTrashedExp()); + } + } + + /** + * 获取软删除数据的查询条件. + * + * @return array + */ + protected function getWithTrashedExp(): array + { + return is_null($this->getOption('defaultSoftDelete')) ? ['notnull', ''] : ['<>', $this->getOption('defaultSoftDelete')]; + } + + /** + * 删除当前的记录. + * + * @return bool + */ + public function delete(): bool + { + if ($this->isEmpty() || false === $this->trigger('BeforeDelete')) { + return false; + } + + $name = $this->getDeleteTimeField(); + $force = $this->isForce(); + + if ($name && !$force) { + // 软删除 + $this->exists()->withEvent(false)->save([$name => $this->getDateTime($name)]); + + $this->withEvent(true); + + $this->trigger('AfterDelete'); + $this->exists(false); + $this->clear(); + return true; + } + return parent::delete(); + } + + /** + * 删除记录. + * + * @param mixed $data 主键列表 支持闭包查询条件 + * @param bool $force 是否强制删除 + * + * @return bool + */ + public static function destroy($data, bool $force = false): bool + { + // 传入空值(包括空字符串和空数组)的时候不会做任何的数据删除操作,但传入0则是有效的 + if (empty($data) && 0 !== $data) { + return false; + } + $query = (new static())->db(); + + if ($force) { + $query->removeOption('soft_delete'); + } + + if (is_array($data) && key($data) !== 0) { + $query->where($data); + $data = []; + } elseif ($data instanceof Closure) { + call_user_func_array($data, [ &$query]); + $data = []; + } + + $resultSet = $query->select((array) $data); + + foreach ($resultSet as $result) { + /** @var Model $result */ + $result->force($force)->delete(); + } + + return true; + } + + /** + * 恢复被软删除的记录. + * + * @param array $where 更新条件 + * + * @return bool + */ + public function restore(array $where = []): bool + { + $name = $this->getDeleteTimeField(); + + if (!$name || false === $this->trigger('BeforeRestore')) { + return false; + } + + $db = $this->getDbWhere($where); + + // 恢复删除 + $db->useSoftDelete($name, $this->getWithTrashedExp()) + ->update([$name => $this->getOption('defaultSoftDelete')]); + + $this->trigger('AfterRestore'); + + return true; + } + + /** + * 获取软删除字段. + * + * @param bool $read 是否查询操作 写操作的时候会自动去掉表别名 + * + * @return string|false + */ + public function getDeleteTimeField(bool $read = false): bool | string + { + $field = $this->getOption('deleteTime', 'delete_time'); + + if (false === $field) { + return false; + } + + if (!str_contains($field, '.')) { + $field = '__TABLE__.' . $field; + } + + if (!$read && str_contains($field, '.')) { + $array = explode('.', $field); + $field = array_pop($array); + } + + return $field; + } + + /** + * 查询的时候默认排除软删除数据. + * + * @param Query $query + * + * @return void + */ + protected function withNoTrashed(Query $query): void + { + $field = $this->getDeleteTimeField(true); + + if ($field) { + $condition = is_null($this->getOption('defaultSoftDelete')) ? ['null', ''] : ['=', $this->getOption('defaultSoftDelete')]; + $query->useSoftDelete($field, $condition); + } + } +} diff --git a/vendor/topthink/think-orm/src/model/contract/EnumTransform.php b/vendor/topthink/think-orm/src/model/contract/EnumTransform.php new file mode 100644 index 0000000..2922399 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/contract/EnumTransform.php @@ -0,0 +1,10 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\db\BaseQuery as Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; + +/** + * BelongsTo关联类. + */ +class BelongsTo extends OneToOne +{ + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 关联主键 + * @param string $relation 关联名 + */ + public function __construct(Model $parent, string $model, string $foreignKey, string $localKey, ?string $relation = null) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model())->db(); + $this->relation = $relation; + + if (get_class($parent) == $model) { + $this->selfRelation = true; + } + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Model + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null) + { + if ($closure) { + $closure($this->query); + } + + $foreignKey = $this->foreignKey; + $relationModel = $this->query + ->removeWhereField($this->localKey) + ->where($this->localKey, $this->parent->$foreignKey) + ->relation($subRelation) + ->find(); + + if ($relationModel) { + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->parent->bindRelationAttr($relationModel, $this->bindAttr); + } + } else { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } + + return $relationModel; + } + + /** + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 聚合字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = 'id', &$name = ''): string + { + if ($closure) { + $closure($this->query, $name); + } + + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias . '_' . $aggregate; + return $this->query + ->alias($alias) + ->whereExp($alias . '.' . $this->localKey, '=' . $this->parent->getTable(true) . '.' . $this->foreignKey) + ->fetchSql() + ->$aggregate($field); + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) + { + $foreignKey = $this->foreignKey; + + if (!isset($result->$foreignKey)) { + return 0; + } + + if ($closure) { + $closure($this->query, $name); + } + + return $this->query + ->where($this->localKey, '=', $result->$foreignKey) + ->$aggregate($field); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null) : Query + { + $table = $this->query->getTable(); + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + if ($this->isSelfRelation() && $alias == $relation) { + $relation .= '_'; + } + + return $query->alias($alias) + ->whereExists(function ($query) use ($table, $alias, $relation) { + $query->table([$table => $relation]) + ->field($relation . '.' . $this->localKey) + ->whereColumn($alias . '.' . $this->foreignKey, $relation . '.' . $this->localKey); + + $this->getRelationSoftDelete($query, $relation); + }); + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = ''): Query + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $fields = $this->getRelationQueryFields($fields, $alias); + $relAlias = $relationAlias ?: $relation; + + if ($this->isSelfRelation() && $alias == $relAlias) { + $relAlias .= '_'; + } + + $query->alias($alias) + ->via($alias) + ->field($fields) + ->join([$table => $relAlias], $alias . '.' . $this->foreignKey . '=' . $relAlias . '.' . $this->localKey, $joinType); + + return $this->getRelationSoftDelete($query, $relAlias, $where, $logic); + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + protected function eagerlySet(array &$resultSet, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$foreignKey)) { + $range[] = $result->$foreignKey; + } + } + + if (!empty($range)) { + $this->query->removeWhereField($localKey); + $default = $this->query->getOption('default_model'); + $defaultModel = $this->getDefaultModel($default); + + $range = array_unique($range); + $data = $this->eagerlyWhere([ + [$localKey, 'in', $range], + ], $localKey, $subRelation, $closure, $cache, count($range) > 1 ? true : false); + + // 动态绑定参数 + $bindAttr = $this->query->getOption('bind_attr'); + if ($bindAttr) { + $this->bind($bindAttr); + } + + // 关联数据封装 + foreach ($resultSet as $result) { + // 关联模型 + if (!isset($data[$result->$foreignKey])) { + $relationModel = $defaultModel; + } else { + $relationModel = $data[$result->$foreignKey]; + } + + // 设置关联属性 + if (!empty($this->bindAttr) && $relationModel) { + $result->bindRelationAttr($relationModel, $this->bindAttr, $relation); + } else { + $result->setRelation($relation, $relationModel); + } + } + } + } + + /** + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + protected function eagerlyOne(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $this->query->removeWhereField($localKey); + + $data = $this->eagerlyWhere([ + [$localKey, '=', $result->$foreignKey], + ], $localKey, $subRelation, $closure, $cache); + + // 关联模型 + if (!isset($data[$result->$foreignKey])) { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } else { + $relationModel = $data[$result->$foreignKey]; + } + + // 动态绑定参数 + $bindAttr = $this->query->getOption('bind_attr'); + if ($bindAttr) { + $this->bind($bindAttr); + } + + // 设置关联属性 + if (!empty($this->bindAttr) && $relationModel) { + $result->bindRelationAttr($relationModel, $this->bindAttr, $relation); + } else { + $result->setRelation($relation, $relationModel); + } + } + + /** + * 添加关联数据. + * + * @param Model $model关联模型对象 + * + * @return Model + */ + public function associate(Model $model): Model + { + $this->parent->set($this->foreignKey, $model->getKey()); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, $model); + } + + /** + * 注销关联数据. + * + * @return Model + */ + public function dissociate(): Model + { + $foreignKey = $this->foreignKey; + + $this->parent->set($foreignKey, null); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, null); + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery)) { + if (isset($this->parent->{$this->foreignKey})) { + // 关联查询带入关联条件 + $this->query->where($this->localKey, '=', $this->parent->{$this->foreignKey}); + } + + $this->baseQuery = true; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php b/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php new file mode 100644 index 0000000..e90ea69 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php @@ -0,0 +1,735 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\Collection; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use think\db\Raw; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Pivot; +use think\model\Relation; + +/** + * 多对多关联类. + */ +class BelongsToMany extends Relation +{ + /** + * 中间表表名. + * + * @var string + */ + protected $middle; + + /** + * 中间表模型名称. + * + * @var string + */ + protected $pivotName; + + /** + * 中间表模型对象 + * + * @var Pivot + */ + protected $pivot; + + /** + * 中间表数据名称. + * + * @var string + */ + protected $pivotDataName = 'pivot'; + + /** + * 绑定的关联属性. + * + * @var array + */ + protected $bindAttr = []; + + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $middle 中间表/模型名 + * @param string $foreignKey 关联模型外键 + * @param string $localKey 当前模型关联键 + */ + public function __construct(Model $parent, string $model, string $middle, string $foreignKey, string $localKey) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + + if (str_contains($middle, '\\')) { + $this->pivotName = $middle; + $this->middle = Str::snake(class_basename($middle)); + } else { + $this->middle = $middle; + } + + $this->query = (new $model())->db(); + $this->pivot = $this->newPivot(); + } + + /** + * 设置中间表模型. + * + * @param $pivot + * + * @return $this + */ + public function pivot(string $pivot) + { + $this->pivotName = $pivot; + + return $this; + } + + /** + * 设置中间表数据名称. + * + * @param string $name + * + * @return $this + */ + public function name(string $name) + { + $this->pivotDataName = $name; + + return $this; + } + + /** + * 绑定关联表的属性到父模型属性. + * + * @param array $attr 要绑定的属性列表 + * + * @return $this + */ + public function bind(array $attr) + { + $this->bindAttr = $attr; + + return $this; + } + + /** + * 实例化中间表模型. + * + * @param $data + * + * @throws Exception + * + * @return Pivot + */ + protected function newPivot(array $data = []): Pivot + { + $class = $this->pivotName ?: Pivot::class; + $pivot = new $class($data, $this->parent, $this->middle); + + if ($pivot instanceof Pivot) { + return $pivot; + } else { + throw new Exception('pivot model must extends: \think\model\Pivot'); + } + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Collection + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null): Collection + { + if ($closure) { + $closure($this->query); + } + + return $this->relation($subRelation)->select(); + } + + /** + * 组装Pivot模型. + * + * @param Model $result 模型对象 + * + * @return array + */ + protected function matchPivot(Model $result): array + { + $pivot = $result->getRelation('pivot'); + $bindAttr = $this->query->getOption('bind_attr'); + if (empty($bindAttr)) { + $bindAttr = $this->bindAttr; + } + + foreach ($pivot as $attr => $val) { + $pos = array_search($attr, $bindAttr); + if (false !== $pos) { + // 中间表属性绑定 + $key = !is_numeric($pos) ? $pos : $attr; + if (null !== $result->getOrigin($key)) { + throw new Exception('bind attr has exists:' . $attr); + } + $result->set($key, $val); + } + } + + $result->setRelation($this->pivotDataName, $this->newPivot($pivot)); + + return $pivot; + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param string $operator 比较操作符 + * @param integer $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query|null $query Query对象 + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null): Query + { + $table = $this->query->getTable(); + $pivot = $this->pivot->getTable(); + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + if ('=' === $operator && 0 === $count) { + return $query->alias($alias) + ->whereNotExists(function ($query) use ($pivot, $alias, $relation, $table) { + $query->table([$pivot => 'pivot']) + ->field('pivot.' . $this->foreignKey) + ->join($table . ' ' . $relation, $relation . '.' . $this->query->getPk() . '= pivot.' . $this->foreignKey) + ->whereColumn($alias . '.' . $this->parent->getPk(), 'pivot.' . $this->localKey); + + $this->getRelationSoftDelete($query, $relation); + }); + } + + $query->alias($alias) + ->field($model . '.*') + ->join([$pivot => 'pivot'], 'pivot.' . $this->localKey . '=' . $alias . '.' . $this->parent->getPk(), $joinType) + ->join($table . ' ' . $relation, $relation . '.' . $this->query->getPk() . '= pivot.' . $this->foreignKey, $joinType) + ->group($alias . '.' . $this->parent->getPk()) + ->having('count(' . $id . ')' . $operator . $count); + return $this->getRelationSoftDelete($query, $relation); + } + + /** + * 根据关联条件查询当前模型 + * @access public + * @param array|Closure $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query|null $query Query对象 + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = ''): Query + { + $table = $this->query->getTable(); + $pivot = $this->pivot->getTable(); + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $fields = $this->getRelationQueryFields($fields, $alias); + $relAlias = $relationAlias ?: $relation; + + $query->alias($alias) + ->join([$pivot => 'pivot'], 'pivot.' . $this->localKey . '=' . $alias . '.' . $this->parent->getPk(), $joinType) + ->join([$table => $relAlias], $relAlias . '.' . $this->query->getPk() . '= pivot.' . $this->foreignKey, $joinType) + ->group($alias . '.' . $this->parent->getPk()) + ->field($fields); + + return $this->getRelationSoftDelete($query, $relAlias, $where, $logic); + } + + /** + * 设置中间表的查询条件. + * + * @param string $field + * @param string $op + * @param mixed $condition + * + * @return $this + */ + public function wherePivot($field, $op = null, $condition = null) + { + $this->query->where('pivot.' . $field, $op, $condition); + + return $this; + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $pk = $resultSet[0]->getPk(); + $range = []; + + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + // 查询关联数据 + $range = array_unique($range); + $data = $this->eagerlyManyToMany([ + ['pivot.' . $localKey, 'in', $range], + ], $subRelation, $closure, $cache, count($range) > 1 ? true : false); + + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$result->$pk])); + } + } + } + + /** + * 预载入关联查询(单个数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $pk = $result->getPk(); + + if (is_string($pk) && isset($result->$pk)) { + $pk = $result->$pk; + // 查询管理数据 + $data = $this->eagerlyManyToMany([ + ['pivot.' . $this->localKey, '=', $pk], + ], $subRelation, $closure, $cache); + + // 关联数据封装 + if (!isset($data[$pk])) { + $data[$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$pk])); + } + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) + { + $pk = $result->getPk(); + + if (!isset($result->$pk)) { + return 0; + } + + $pk = $result->$pk; + + if ($closure) { + $closure($this->query, $name); + } + + return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ + ['pivot.' . $this->localKey, '=', $pk], + ])->$aggregate($field); + } + + /** + * 获取关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) : string + { + if ($closure) { + $closure($this->query, $name); + } + + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias . '_' . $aggregate; + if (!str_contains($field, '.')) { + $field = $alias . '.' . $field; + } + + $this->query->alias($alias); + return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ + [ + 'pivot.' . $this->localKey, 'exp', new Raw('=' . $this->parent->getTable(true) . '.' . $this->parent->getPk()), + ], + ])->fetchSql()->$aggregate($field); + } + + /** + * 多对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * + * @return array + */ + protected function eagerlyManyToMany(array $where, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false) : array + { + if ($closure) { + $closure($this->query); + } + + $withLimit = $this->query->getOption('limit'); + if ($withLimit && $collection) { + $this->query->removeOption('limit'); + } + + if ($this->isOneofMany) { + // 仅获取一条关联数据 + if (!$collection) { + $this->query->limit(1); + } else { + $withLimit = 1; + } + } + + // 预载入关联查询 支持嵌套预载入 + $list = $this->belongsToManyQuery($this->foreignKey, $this->localKey, $where) + ->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->lazy(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $pivot = $this->matchPivot($set); + $key = $pivot[$this->localKey]; + + if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) { + continue; + } + + $data[$key][] = $set; + } + + return $data; + } + + /** + * BELONGS TO MANY 关联查询. + * + * @param string $foreignKey 关联模型关联键 + * @param string $localKey 当前模型关联键 + * @param array $condition 关联查询条件 + * + * @return Query + */ + protected function belongsToManyQuery(string $foreignKey, string $localKey, array $condition = []): Query + { + // 关联查询封装 + if (empty($this->baseQuery)) { + $tableName = $this->query->getTable(true); + $table = $this->pivot->db()->getTable(); + $fields = $this->getQueryFields($tableName); + + $this->query + ->field($fields) + ->tableField(true, $table, 'pivot', 'pivot__') + ->join([$table => 'pivot'], 'pivot.' . $foreignKey . '=' . $tableName . '.' . $this->query->getPk()) + ->where($condition); + } + + return $this->query; + } + + /** + * 保存(新增)当前关联数据对象 + * + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @param array $pivot 中间表额外数据 + * + * @return array|Pivot + */ + public function save($data, array $pivot = []) + { + // 保存关联表/中间表数据 + return $this->attach($data, $pivot); + } + + /** + * 批量保存当前关联数据对象 + * + * @param iterable $dataSet 数据集 + * @param array $pivot 中间表额外数据 + * @param bool $samePivot 额外数据是否相同 + * + * @return array|false + */ + public function saveAll(iterable $dataSet, array $pivot = [], bool $samePivot = false) + { + $result = []; + + foreach ($dataSet as $key => $data) { + if (!$samePivot) { + $pivotData = $pivot[$key] ?? []; + } else { + $pivotData = $pivot; + } + + $result[] = $this->attach($data, $pivotData); + } + + return empty($result) ? false : $result; + } + + /** + * 附加关联的一个中间表数据. + * + * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 + * @param array $pivot 中间表额外数据 + * + * @throws Exception + * + * @return array|Pivot + */ + public function attach($data, array $pivot = []) + { + if (is_array($data)) { + if (key($data) === 0) { + $id = $data; + } else { + // 保存关联表数据 + $model = new $this->model(); + $id = $model->insertGetId($data); + } + } elseif (is_numeric($data) || is_string($data)) { + // 根据关联表主键直接写入中间表 + $id = $data; + } elseif ($data instanceof Model) { + // 根据关联表主键直接写入中间表 + $id = $data->getKey(); + } + + if (!empty($id)) { + // 保存中间表数据 + $pivot[$this->localKey] = $this->parent->getKey(); + + $ids = (array) $id; + foreach ($ids as $id) { + $pivot[$this->foreignKey] = $id; + + $object = $this->newPivot(); + $object->replace()->save($pivot); + $result[] = $object; + } + + if (count($result) == 1) { + // 返回中间表模型对象 + $result = $result[0]; + } + + return $result; + } else { + throw new Exception('miss relation data'); + } + } + + /** + * 判断是否存在关联数据. + * + * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * + * @return Pivot|false + */ + public function attached($data) + { + if ($data instanceof Model) { + $id = $data->getKey(); + } else { + $id = $data; + } + + $pivot = $this->pivot + ->where($this->localKey, $this->parent->getKey()) + ->where($this->foreignKey, $id) + ->find(); + + return $pivot ?: false; + } + + /** + * 解除关联的一个中间表数据. + * + * @param int|array $data 数据 可以使用关联对象的主键 + * @param bool $relationDel 是否同时删除关联表数据 + * + * @return int + */ + public function detach($data = null, bool $relationDel = false): int + { + if (is_array($data)) { + $id = $data; + } elseif (is_numeric($data) || is_string($data)) { + // 根据关联表主键直接写入中间表 + $id = $data; + } elseif ($data instanceof Model) { + // 根据关联表主键直接写入中间表 + $id = $data->getKey(); + } + + // 删除中间表数据 + $pivot = []; + $pivot[] = [$this->localKey, '=', $this->parent->getKey()]; + + if (isset($id)) { + $pivot[] = [$this->foreignKey, is_array($id) ? 'in' : '=', $id]; + } + + $result = $this->newPivot()->where($pivot)->delete(); + + // 删除关联表数据 + if (isset($id) && $relationDel) { + $model = $this->model; + $model::destroy($id); + } + + return $result; + } + + /** + * 数据同步. + * + * @param array $ids + * @param bool $detaching + * + * @return array + */ + public function sync(array $ids, bool $detaching = true): array + { + $changes = [ + 'attached' => [], + 'detached' => [], + 'updated' => [], + ]; + + $current = $this->pivot + ->where($this->localKey, $this->parent->getKey()) + ->column($this->foreignKey); + + $records = []; + + foreach ($ids as $key => $value) { + if (!is_array($value)) { + $records[$value] = []; + } else { + $records[$key] = $value; + } + } + + $detach = array_diff($current, array_keys($records)); + + if ($detaching && count($detach) > 0) { + $this->detach($detach); + $changes['detached'] = $detach; + } + + foreach ($records as $id => $attributes) { + if (!in_array($id, $current)) { + $this->attach($id, $attributes); + $changes['attached'][] = $id; + } elseif (count($attributes) > 0) { + $this->detach($id); + $this->attach($id, $attributes); + $changes['updated'][] = $id; + } + } + + return $changes; + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery)) { + $foreignKey = $this->foreignKey; + $localKey = $this->localKey; + + $this->query->filter(function ($result, $options) { + $this->matchPivot($result); + }); + + // 关联查询 + if (null === $this->parent->getKey()) { + $condition = ['pivot.' . $localKey, 'exp', new Raw('=' . $this->parent->getTable(true) . '.' . $this->parent->getPk())]; + } else { + $condition = ['pivot.' . $localKey, '=', $this->parent->getKey()]; + } + + $this->belongsToManyQuery($foreignKey, $localKey, [$condition]); + + $this->baseQuery = true; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/HasMany.php b/vendor/topthink/think-orm/src/model/relation/HasMany.php new file mode 100644 index 0000000..6ff1a34 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/HasMany.php @@ -0,0 +1,386 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\Collection; +use think\db\BaseQuery as Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Relation; + +/** + * 一对多关联类. + */ +class HasMany extends Relation +{ + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 + */ + public function __construct(Model $parent, string $model, string $foreignKey, string $localKey) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model())->db(); + + if (get_class($parent) == $model) { + $this->selfRelation = true; + } + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Collection + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null): Collection + { + if ($closure) { + $closure($this->query); + } + + return $this->query + ->where($this->foreignKey, $this->parent->{$this->localKey}) + ->relation($subRelation) + ->select(); + } + + /** + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $range = []; + + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$localKey)) { + $range[] = $result->$localKey; + } + } + + if (!empty($range)) { + $range = array_unique($range); + $data = $this->eagerlyOneToMany([ + [$this->foreignKey, 'in', $range], + ], $subRelation, $closure, $cache, count($range) > 1 ? true : false); + + // 关联数据封装 + foreach ($resultSet as $result) { + $pk = $result->$localKey; + if (!isset($data[$pk])) { + $data[$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$pk])); + } + } + } + + /** + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + + if (isset($result->$localKey)) { + $pk = $result->$localKey; + $data = $this->eagerlyOneToMany([ + [$this->foreignKey, '=', $pk], + ], $subRelation, $closure, $cache); + + // 关联数据封装 + if (!isset($data[$pk])) { + $data[$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$pk])); + } + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) + { + $localKey = $this->localKey; + + if (!isset($result->$localKey)) { + return 0; + } + + if ($closure) { + $closure($this->query, $name); + } + + return $this->query + ->where($this->foreignKey, '=', $result->$localKey) + ->$aggregate($field); + } + + /** + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) : string + { + if ($closure) { + $closure($this->query, $name); + } + + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias . '_' . $aggregate; + return $this->query->alias($alias) + ->whereExp($alias . '.' . $this->foreignKey, '=' . $this->parent->getTable(true) . '.' . $this->localKey) + ->fetchSql() + ->$aggregate($field); + } + + /** + * 一对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * + * @return array + */ + protected function eagerlyOneToMany(array $where, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false) : array + { + $foreignKey = $this->foreignKey; + + $this->query->removeWhereField($this->foreignKey); + + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + $this->baseQuery = true; + $closure($this->query); + } + + $withLimit = $this->query->getOption('limit'); + if ($withLimit && $collection) { + $this->query->removeOption('limit'); + } + + if ($this->isOneofMany) { + if (!$collection) { + $this->query->limit(1); + } else { + $withLimit = 1; + } + } + + $list = $this->query + ->where($where) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->with($subRelation) + ->lazy(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $key = $set->$foreignKey; + + if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) { + continue; + } + + $data[$key][] = $set; + } + + return $data; + } + + /** + * 保存(新增)当前关联数据对象 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * + * @return Model|false + */ + public function save(array | Model $data, bool $replace = true) + { + $model = $this->make(); + + return $model->replace($replace)->save($data) ? $model : false; + } + + /** + * 创建关联对象实例. + * + * @param array|Model $data + * + * @return Model + */ + public function make(array | Model $data = []): Model + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $data[$this->foreignKey] = $this->parent->{$this->localKey}; + + return (new $this->model($data))->setSuffix($this->getModel()->getSuffix()); + } + + /** + * 批量保存当前关联数据对象 + * + * @param iterable $dataSet 数据集 + * @param bool $replace 是否自动识别更新和写入 + * + * @return array|false + */ + public function saveAll(iterable $dataSet, bool $replace = true) + { + $result = []; + + foreach ($dataSet as $key => $data) { + $result[] = $this->save($data, $replace); + } + + return empty($result) ? false : $result; + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', ?Query $query = null): Query + { + $table = $this->query->getTable(); + $model = Str::snake(class_basename($this->parent)); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + return $query->alias($alias) + ->whereExists(function ($query) use ($alias, $id, $table, $operator, $count) { + $table = $this->query->getTable(); + $relation = Str::snake(class_basename($this->model)); + + if ($this->isSelfRelation() && $alias == $relation) { + $relation .= '_'; + } + $query->table([$table => $relation]) + ->field('count(' . $id . ') AS count') + ->whereColumn($relation . '.' . $this->foreignKey, $alias . '.' . $this->localKey) + ->having('count ' . $operator . ' ' . $count); + + $this->getRelationSoftDelete($query, $relation); + }); + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = ''): Query + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $fields = $this->getRelationQueryFields($fields, $alias); + $relAlias = $relationAlias ?: $relation; + + if ($this->isSelfRelation() && $alias == $relAlias) { + $relAlias .= '_'; + } + + $query->alias($alias) + ->via($alias) + ->group($alias . '.' . $this->localKey) + ->field($fields) + ->join([$table => $relAlias], $alias . '.' . $this->localKey . '=' . $relAlias . '.' . $this->foreignKey, $joinType); + + return $this->getRelationSoftDelete($query, $relAlias, $where, $logic); + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery)) { + if (isset($this->parent->{$this->localKey})) { + // 关联查询带入关联条件 + $this->query->where($this->foreignKey, '=', $this->parent->{$this->localKey}); + } + + $this->baseQuery = true; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php b/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php new file mode 100644 index 0000000..4c9a1e1 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php @@ -0,0 +1,391 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\Collection; +use think\db\BaseQuery as Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Relation; + +/** + * 远程一对多关联类. + */ +class HasManyThrough extends Relation +{ + /** + * 中间关联表外键. + * + * @var string + */ + protected $throughKey; + + /** + * 中间主键. + * + * @var string + */ + protected $throughPk; + + /** + * 中间表查询对象 + * + * @var Query + */ + protected $through; + + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 关联模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 中间关联外键 + * @param string $localKey 当前模型主键 + * @param string $throughPk 中间模型主键 + */ + public function __construct(Model $parent, string $model, string $through, string $foreignKey, string $throughKey, string $localKey, string $throughPk) + { + $this->parent = $parent; + $this->model = $model; + $this->through = (new $through())->db(); + $this->foreignKey = $foreignKey; + $this->throughKey = $throughKey; + $this->localKey = $localKey; + $this->throughPk = $throughPk; + $this->query = (new $model())->db(); + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Collection + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null) + { + if ($closure) { + $closure($this->query); + } + + $this->baseQuery(); + + return $this->query->relation($subRelation)->select(); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', ?Query $query = null): Query + { + // 子查询构建 + $model = Str::snake(class_basename($this->parent)); + $table = $this->through->getTable(); + $relation = Str::snake(class_basename($this->model)); + $relationTable = (new $this->model())->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + // 统计子查询 + $subQuery = $this->through + ->field('COUNT(' . $id . ')') + ->table($table) + ->join([$relationTable => $relation], $relation . '.' . $this->throughKey . '=' . $table . '.' . $this->throughPk, $joinType) + ->whereColumn($table . '.' . $this->throughPk, $model . '.' . $this->localKey); + + $this->getRelationSoftDelete($subQuery, $relation); + return $query->alias($alias)->where('(' . $subQuery->buildSql() . ') ' . $operator . ' ' . $count); + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * @return Query + */ + public function hasWhere($where = [], $fields = null, $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = ''): Query + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->through->getTable(); + $relationTable = (new $this->model())->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $relAlias = $relationAlias ?: $relation; + + // EXISTS子查询 + $subQuery = $this->through + ->table($table) + ->join([$relationTable => $relAlias], $relAlias . '.' . $this->throughKey . '=' . $table . '.' . $this->throughPk, $joinType) + ->whereColumn($table . '.' . $this->throughPk, $alias . '.' . $this->localKey); + + $this->getRelationSoftDelete($subQuery, $relAlias, $where, $logic); + return $query->alias($alias)->whereExists($subQuery->buildSql()); + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$localKey)) { + $range[] = $result->$localKey; + } + } + + if (!empty($range)) { + $this->query->removeWhereField($foreignKey); + $range = array_unique($range); + $data = $this->eagerlyWhere([ + [$this->foreignKey, 'in', $range], + ], $foreignKey, $subRelation, $closure, $cache, count($range) > 1 ? true : false); + + // 关联数据封装 + foreach ($resultSet as $result) { + $pk = $result->$localKey; + if (!isset($data[$pk])) { + $data[$pk] = []; + } + + // 设置关联属性 + $result->setRelation($relation, $this->resultSetBuild($data[$pk])); + } + } + } + + /** + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + $pk = $result->$localKey; + + $this->query->removeWhereField($foreignKey); + + $data = $this->eagerlyWhere([ + [$foreignKey, '=', $pk], + ], $foreignKey, $subRelation, $closure, $cache); + + // 关联数据封装 + if (!isset($data[$pk])) { + $data[$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$pk])); + } + + /** + * 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * + * @return array + */ + protected function eagerlyWhere(array $where, string $key, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false): array + { + // 预载入关联查询 支持嵌套预载入 + $throughList = $this->through->where($where)->select(); + $keys = $throughList->column($this->throughPk, $this->throughPk); + + if ($closure) { + $this->baseQuery = true; + $closure($this->query); + } + + $throughKey = $this->throughKey; + + if ($this->baseQuery) { + $throughKey = Str::snake(class_basename($this->model)) . '.' . $this->throughKey; + } + + $withLimit = $this->query->getOption('limit'); + if ($withLimit && $collection) { + $this->query->removeOption('limit'); + } + + if ($this->isOneofMany) { + if (!$collection) { + $this->query->limit(1); + } else { + $withLimit = 1; + } + } + + $list = $this->query + ->where($throughKey, 'in', $keys) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->lazy(); + + // 组装模型数据 + $data = []; + $keys = $throughList->column($this->foreignKey, $this->throughPk); + + foreach ($list as $set) { + $key = $keys[$set->{$this->throughKey}]; + + if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) { + continue; + } + + $data[$key][] = $set; + } + + return $data; + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return mixed + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) + { + $localKey = $this->localKey; + + if (!isset($result->$localKey)) { + return 0; + } + + if ($closure) { + $closure($this->query, $name); + } + + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias; + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); + + if (!str_contains($field, '.')) { + $field = $alias . '.' . $field; + } + + return $this->query + ->alias($alias) + ->join($throughTable, $throughTable . '.' . $pk . '=' . $alias . '.' . $throughKey) + ->join($modelTable, $modelTable . '.' . $this->localKey . '=' . $throughTable . '.' . $this->foreignKey) + ->where($throughTable . '.' . $this->foreignKey, $result->$localKey) + ->$aggregate($field); + } + + /** + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) : string + { + if ($closure) { + $closure($this->query, $name); + } + + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias . '_' . $aggregate; + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); + + if (!str_contains($field, '.')) { + $field = $alias . '.' . $field; + } + + return $this->query + ->alias($alias) + ->join($throughTable, $throughTable . '.' . $pk . '=' . $alias . '.' . $throughKey) + ->whereColumn($throughTable . '.' . $this->foreignKey, $this->parent->getTable() . '.' . $this->localKey) + ->fetchSql() + ->$aggregate($field); + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery() : void + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $alias = Str::snake(class_basename($this->model)); + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); + $fields = $this->getQueryFields($alias); + + $this->query + ->field($fields) + ->alias($alias) + ->join($throughTable, $throughTable . '.' . $pk . '=' . $alias . '.' . $throughKey) + ->where($throughTable . '.' . $this->foreignKey, $this->parent->{$this->localKey}); + + $this->baseQuery = true; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/HasOne.php b/vendor/topthink/think-orm/src/model/relation/HasOne.php new file mode 100644 index 0000000..4252ec3 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/HasOne.php @@ -0,0 +1,317 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\db\BaseQuery as Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; + +/** + * HasOne 关联类. + */ +class HasOne extends OneToOne +{ + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 + */ + public function __construct(Model $parent, string $model, string $foreignKey, string $localKey) + { + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model())->db(); + + if (get_class($parent) == $model) { + $this->selfRelation = true; + } + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Model + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null) + { + $localKey = $this->localKey; + + if ($closure) { + $closure($this->query); + } + + // 判断关联类型执行查询 + $relationModel = $this->query + ->removeWhereField($this->foreignKey) + ->where($this->foreignKey, $this->parent->$localKey) + ->relation($subRelation) + ->find(); + + if ($relationModel) { + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->parent->bindRelationAttr($relationModel, $this->bindAttr); + } + } else { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } + + return $relationModel; + } + + /** + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) : string + { + if ($closure) { + $closure($this->query, $name); + } + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias . '_' . $aggregate; + return $this->query + ->alias($alias) + ->whereExp($alias . '.' . $this->foreignKey, '=' . $this->parent->getTable(true) . '.' . $this->localKey) + ->fetchSql() + ->$aggregate($field); + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) + { + $localKey = $this->localKey; + + if (!isset($result->$localKey)) { + return 0; + } + + if ($closure) { + $closure($this->query, $name); + } + + return $this->query + ->where($this->foreignKey, '=', $result->$localKey) + ->$aggregate($field); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null) : Query + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $method = (0 == $count && '=' == $operator) ? 'whereNotExists' : 'whereExists'; + + if ($this->isSelfRelation() && $alias == $relation) { + $relation .= '_'; + } + + return $query->alias($alias)->$method(function ($query) use ($table, $alias, $relation) { + $query->table([$table => $relation]) + ->field($relation . '.' . $this->foreignKey) + ->whereColumn($alias . '.' . $this->localKey, $relation . '.' . $this->foreignKey); + $this->getRelationSoftDelete($query, $relation); + }); + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = ''): Query + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $fields = $this->getRelationQueryFields($fields, $alias); + $relAlias = $relationAlias ?: $relation; + + if ($this->isSelfRelation() && $alias == $relAlias) { + $relAlias .= '_'; + } + + $query->alias($alias) + ->via($alias) + ->field($fields) + ->join([$table => $relAlias], $alias . '.' . $this->localKey . '=' . $relAlias . '.' . $this->foreignKey, $joinType); + + + return $this->getRelationSoftDelete($query, $relAlias, $where, $logic); + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + protected function eagerlySet(array &$resultSet, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$localKey)) { + $range[] = $result->$localKey; + } + } + + if (!empty($range)) { + $this->query->removeWhereField($foreignKey); + $default = $this->query->getOption('default_model'); + $defaultModel = $this->getDefaultModel($default); + + $range = array_unique($range); + $data = $this->eagerlyWhere([ + [$foreignKey, 'in', $range], + ], $foreignKey, $subRelation, $closure, $cache, count($range) > 1 ? true : false); + + // 动态绑定参数 + $bindAttr = $this->query->getOption('bind_attr'); + if ($bindAttr) { + $this->bind($bindAttr); + } + + // 关联数据封装 + foreach ($resultSet as $result) { + // 关联模型 + if (!isset($data[$result->$localKey])) { + $relationModel = $defaultModel; + } else { + $relationModel = $data[$result->$localKey]; + } + // 设置关联属性 + if (!empty($this->bindAttr) && $relationModel) { + $result->bindRelationAttr($relationModel, $this->bindAttr, $relation); + } else { + $result->setRelation($relation, $relationModel); + } + } + } + } + + /** + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + protected function eagerlyOne(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $this->query->removeWhereField($foreignKey); + + $data = $this->eagerlyWhere([ + [$foreignKey, '=', $result->$localKey], + ], $foreignKey, $subRelation, $closure, $cache); + + // 关联模型 + if (!isset($data[$result->$localKey])) { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } else { + $relationModel = $data[$result->$localKey]; + } + + // 动态绑定参数 + $bindAttr = $this->query->getOption('bind_attr'); + if ($bindAttr) { + $this->bind($bindAttr); + } + // 设置关联属性 + if (!empty($this->bindAttr) && $relationModel) { + $result->bindRelationAttr($relationModel, $this->bindAttr, $relation); + } else { + $result->setRelation($relation, $relationModel); + } + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery)) { + if (isset($this->parent->{$this->localKey})) { + // 关联查询带入关联条件 + $this->query->where($this->foreignKey, '=', $this->parent->{$this->localKey}); + } + + $this->baseQuery = true; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php b/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php new file mode 100644 index 0000000..0db6519 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php @@ -0,0 +1,164 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\model\contract\Modelable as Model; + +/** + * 远程一对一关联类. + */ +class HasOneThrough extends HasManyThrough +{ + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Model + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null) + { + if ($closure) { + $closure($this->query); + } + + $this->baseQuery(); + + $relationModel = $this->query->relation($subRelation)->find(); + + if ($relationModel) { + } else { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } + + return $relationModel; + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $range = []; + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$localKey)) { + $range[] = $result->$localKey; + } + } + + if (!empty($range)) { + $this->query->removeWhereField($foreignKey); + $default = $this->query->getOption('default_model'); + $defaultModel = $this->getDefaultModel($default); + + $data = $this->eagerlyWhere([ + [$this->foreignKey, 'in', $range], + ], $foreignKey, $subRelation, $closure, $cache); + + // 关联数据封装 + foreach ($resultSet as $result) { + // 关联模型 + if (!isset($data[$result->$localKey])) { + $relationModel = $defaultModel; + } else { + $relationModel = $data[$result->$localKey]; + } + + // 设置关联属性 + $result->setRelation($relation, $relationModel); + } + } + } + + /** + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $localKey = $this->localKey; + $foreignKey = $this->foreignKey; + + $this->query->removeWhereField($foreignKey); + + $data = $this->eagerlyWhere([ + [$foreignKey, '=', $result->$localKey], + ], $foreignKey, $subRelation, $closure, $cache); + + // 关联模型 + if (!isset($data[$result->$localKey])) { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } else { + $relationModel = $data[$result->$localKey]; + } + + $result->setRelation($relation, $relationModel); + } + + /** + * 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * + * @return array + */ + protected function eagerlyWhere(array $where, string $key, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false): array + { + // 预载入关联查询 支持嵌套预载入 + $keys = $this->through->where($where)->column($this->throughPk, $this->foreignKey); + + if ($closure) { + $closure($this->query); + } + + $list = $this->query + ->where($this->throughKey, 'in', $keys) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->select(); + + // 组装模型数据 + return array_map(function ($key) use ($list) { + $set = $list->where($this->throughKey, '=', $key)->first(); + return $set ?: null; + }, $keys); + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/MorphMany.php b/vendor/topthink/think-orm/src/model/relation/MorphMany.php new file mode 100644 index 0000000..911cd74 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/MorphMany.php @@ -0,0 +1,436 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\Collection; +use think\db\BaseQuery as Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Relation; + +/** + * 多态一对多关联. + */ +class MorphMany extends Relation +{ + /** + * 多态关联外键. + * + * @var string + */ + protected $morphKey; + + /** + * 多态字段名. + * + * @var string + */ + protected $morphType; + + /** + * 多态类型. + * + * @var string + */ + protected $type; + + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $morphKey 关联外键 + * @param string $morphType 多态字段名 + * @param string $type 多态类型 + */ + public function __construct(Model $parent, string $model, string $morphKey, string $morphType, string $type) + { + $this->parent = $parent; + $this->model = $model; + $this->type = $type; + $this->morphKey = $morphKey; + $this->morphType = $morphType; + $this->query = (new $model())->db(); + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Collection + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null): Collection + { + if ($closure) { + $closure($this->query); + } + + $this->baseQuery(); + + return $this->query->relation($subRelation)->select(); + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null) + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + $query->alias($alias) + ->field($alias . '.*') + ->join([$table => $relation], $alias . '.' . $this->parent->getPk() . '=' . $relation . '.' . $this->morphKey) + ->where($relation . '.' . $this->morphType, '=', $this->type) + ->group($relation . '.' . $this->morphKey) + ->having('count(' . $id . ')' . $operator . $count); + + return $this->getRelationSoftDelete($query, $relation); + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = '') + { + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $alias = $query->getAlias() ?: $model; + $fields = $this->getRelationQueryFields($fields, $alias); + $relAlias = $relationAlias ?: $relation; + + $query->alias($alias) + ->join([$table => $relAlias], $alias . '.' . $this->parent->getPk() . '=' . $relAlias . '.' . $this->morphKey, $joinType) + ->where($relAlias . '.' . $this->morphType, '=', $this->type) + ->group($relAlias . '.' . $this->morphKey) + ->field($fields); + + return $this->getRelationSoftDelete($query, $relAlias, $where, $logic); + } + + /** + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $morphType = $this->morphType; + $morphKey = $this->morphKey; + $type = $this->type; + $range = []; + + foreach ($resultSet as $result) { + $pk = $result->getPk(); + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + $where = [ + [$morphKey, 'in', array_unique($range)], + [$morphType, '=', $type], + ]; + $data = $this->eagerlyMorphToMany($where, $subRelation, $closure, $cache, true); + + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$result->$pk])); + } + } + } + + /** + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $pk = $result->getPk(); + + if (isset($result->$pk)) { + $key = $result->$pk; + $data = $this->eagerlyMorphToMany([ + [$this->morphKey, '=', $key], + [$this->morphType, '=', $this->type], + ], $subRelation, $closure, $cache); + + if (!isset($data[$key])) { + $data[$key] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$key])); + } + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return mixed + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) + { + $pk = $result->getPk(); + + if (!isset($result->$pk)) { + return 0; + } + + if ($closure) { + $closure($this->query, $name); + } + + return $this->query + ->where([ + [$this->morphKey, '=', $result->$pk], + [$this->morphType, '=', $this->type], + ]) + ->$aggregate($field); + } + + /** + * 获取关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = 'id', ? string &$name = null) : string + { + if ($closure) { + $closure($this->query, $name); + } + $alias = Str::snake(class_basename($this->model)); + $alias = $this->query->getAlias() ?: $alias . '_' . $aggregate; + return $this->query + ->alias($alias) + ->whereColumn($alias . '.' . $this->morphKey, $this->parent->getTable(true) . '.' . $this->parent->getPk()) + ->where($alias . '.' . $this->morphType, '=', $this->type) + ->fetchSql() + ->$aggregate($field); + } + + /** + * 多态一对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * + * @return array + */ + protected function eagerlyMorphToMany(array $where, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false) : array + { + // 预载入关联查询 支持嵌套预载入 + $this->query->removeOption('where'); + + if ($closure) { + $this->baseQuery = true; + $closure($this->query); + } + + $withLimit = $this->query->getOption('limit'); + if ($withLimit && $collection) { + $this->query->removeOption('limit'); + } + + if ($this->isOneofMany) { + // 仅获取一条关联数据 + if (!$collection) { + $this->query->limit(1); + } else { + $withLimit = 1; + } + } + + $list = $this->query + ->where($where) + ->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->lazy(); + + // 组装模型数据 + $data = []; + $morphKey = $this->morphKey; + foreach ($list as $set) { + $key = $set->$morphKey; + + if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) { + continue; + } + + $data[$key][] = $set; + } + + return $data; + } + + /** + * 保存(新增)当前关联数据对象 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * + * @return Model|false + */ + public function save(array | Model $data, bool $replace = true) + { + $model = $this->make(); + + return $model->replace($replace)->save($data) ? $model : false; + } + + /** + * 创建关联对象实例. + * + * @param array|Model $data + * + * @return Model + */ + public function make($data = []): Model + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $pk = $this->parent->getPk(); + + $data[$this->morphKey] = $this->parent->$pk; + $data[$this->morphType] = $this->type; + + return (new $this->model($data))->setSuffix($this->getModel()->getSuffix()); + } + + /** + * 批量保存当前关联数据对象 + * + * @param iterable $dataSet 数据集 + * @param bool $replace 是否自动识别更新和写入 + * + * @return array|false + */ + public function saveAll(iterable $dataSet, bool $replace = true) + { + $result = []; + + foreach ($dataSet as $key => $data) { + $result[] = $this->save($data, $replace); + } + + return empty($result) ? false : $result; + } + + /** + * 获取多态关联外键. + * + * @return string + */ + public function getMorphKey() + { + return $this->morphKey; + } + + /** + * 获取多态字段名. + * + * @return string + */ + public function getMorphType() + { + return $this->morphType; + } + + /** + * 获取多态类型. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $pk = $this->parent->getPk(); + + $this->query->where([ + [$this->morphKey, '=', $this->parent->$pk], + [$this->morphType, '=', $this->type], + ]); + + $this->baseQuery = true; + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/MorphOne.php b/vendor/topthink/think-orm/src/model/relation/MorphOne.php new file mode 100644 index 0000000..59b9be1 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/MorphOne.php @@ -0,0 +1,393 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Relation; + +/** + * 多态一对一关联类. + */ +class MorphOne extends Relation +{ + /** + * 多态关联外键. + * + * @var string + */ + protected $morphKey; + + /** + * 多态字段. + * + * @var string + */ + protected $morphType; + + /** + * 多态类型. + * + * @var string + */ + protected $type; + + /** + * 绑定的关联属性. + * + * @var array + */ + protected $bindAttr = []; + + /** + * 构造函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $morphKey 关联外键 + * @param string $morphType 多态字段名 + * @param string $type 多态类型 + */ + public function __construct(Model $parent, string $model, string $morphKey, string $morphType, string $type) + { + $this->parent = $parent; + $this->model = $model; + $this->type = $type; + $this->morphKey = $morphKey; + $this->morphType = $morphType; + $this->query = (new $model())->db(); + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * + * @return Model + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null) + { + if ($closure) { + $closure($this->query); + } + + $this->baseQuery(); + + $relationModel = $this->query->relation($subRelation)->find(); + + if ($relationModel) { + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($this->parent, $relationModel); + } + } else { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } + + return $relationModel; + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null) + { + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $table = $this->query->getTable(); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + $query->alias($alias) + ->field($alias . '.*') + ->join([$table => $relation], $alias . '.' . $this->parent->getPk() . '=' . $relation . '.' . $this->morphKey) + ->where($relation . '.' . $this->morphType, '=', $this->type) + ->group($relation . '.' . $this->morphKey) + ->having('count(' . $id . ')' . $operator . $count); + + return $this->getRelationSoftDelete($query, $relation); + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '', string $relationAlias = '') + { + $table = $this->query->getTable(); + $model = Str::snake(class_basename($this->parent)); + $relation = Str::snake(class_basename($this->model)); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + $fields = $this->getRelationQueryFields($fields, $alias); + $relAlias = $relationAlias ?: $relation; + + $query->alias($alias) + ->join([$table => $relAlias], $alias . '.' . $this->parent->getPk() . '=' . $relAlias . '.' . $this->morphKey, $joinType) + ->where($relAlias . '.' . $this->morphType, '=', $this->type) + ->group($relAlias . '.' . $this->morphKey) + ->field($fields); + + return $this->getRelationSoftDelete($query, $relAlias, $where, $logic); + } + + /** + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $morphType = $this->morphType; + $morphKey = $this->morphKey; + $type = $this->type; + $range = []; + + foreach ($resultSet as $result) { + $pk = $result->getPk(); + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + $data = $this->eagerlyMorphToOne([ + [$morphKey, 'in', $range], + [$morphType, '=', $type], + ], $subRelation, $closure, $cache); + + $default = $this->query->getOption('default_model'); + $defaultModel = $this->getDefaultModel($default); + + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $relationModel = $defaultModel; + } else { + $relationModel = $data[$result->$pk]; + } + + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($result, $relationModel); + } else { + // 设置关联属性 + $result->setRelation($relation, $relationModel); + } + } + } + } + + /** + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + $pk = $result->getPk(); + + if (isset($result->$pk)) { + $pk = $result->$pk; + $data = $this->eagerlyMorphToOne([ + [$this->morphKey, '=', $pk], + [$this->morphType, '=', $this->type], + ], $subRelation, $closure, $cache); + + if (isset($data[$pk])) { + $relationModel = $data[$pk]; + } else { + $default = $this->query->getOption('default_model'); + $relationModel = $this->getDefaultModel($default); + } + + if (!empty($this->bindAttr)) { + // 绑定关联属性 + $this->bindAttr($result, $relationModel); + } else { + // 设置关联属性 + $result->setRelation($relation, $relationModel); + } + } + } + + /** + * 多态一对一 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return array + */ + protected function eagerlyMorphToOne(array $where, array $subRelation = [], ?Closure $closure = null, array $cache = []): array + { + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + $this->baseQuery = true; + $closure($this->query); + } + + $list = $this->query + ->where($where) + ->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->lazy(); + + // 组装模型数据 + $data = []; + $morphKey = $this->morphKey; + foreach ($list as $set) { + $data[$set->$morphKey] = $set; + } + + return $data; + } + + /** + * 保存(新增)当前关联数据对象 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * + * @return Model|false + */ + public function save(array | Model $data, bool $replace = true) + { + $model = $this->make(); + + return $model->replace($replace)->save($data) ? $model : false; + } + + /** + * 创建关联对象实例. + * + * @param array|Model $data + * + * @return Model + */ + public function make(array | Model $data = []): Model + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $pk = $this->parent->getPk(); + + $data[$this->morphKey] = $this->parent->$pk; + $data[$this->morphType] = $this->type; + + return (new $this->model($data))->setSuffix($this->getModel()->getSuffix()); + } + + /** + * 执行基础查询(进执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery) && $this->parent->getData()) { + $pk = $this->parent->getPk(); + + $this->query->where([ + [$this->morphKey, '=', $this->parent->$pk], + [$this->morphType, '=', $this->type], + ]); + $this->baseQuery = true; + } + } + + /** + * 绑定关联表的属性到父模型属性. + * + * @param array $attr 要绑定的属性列表 + * + * @return $this + */ + public function bind(array $attr) + { + $this->bindAttr = $attr; + + return $this; + } + + /** + * 获取绑定属性. + * + * @return array + */ + public function getBindAttr(): array + { + return $this->bindAttr; + } + + /** + * 绑定关联属性到父模型. + * + * @param Model $result 父模型对象 + * @param Model $model 关联模型对象 + * + * @throws Exception + * + * @return void + */ + protected function bindAttr(Model $result, ?Model $model = null): void + { + foreach ($this->bindAttr as $key => $attr) { + $key = is_numeric($key) ? $attr : $key; + $value = $result->getOrigin($key); + + if (!is_null($value)) { + throw new Exception('bind attr has exists:' . $key); + } + + $result->set($key, $model?->get($attr)); + } + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/MorphTo.php b/vendor/topthink/think-orm/src/model/relation/MorphTo.php new file mode 100644 index 0000000..2b72488 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/MorphTo.php @@ -0,0 +1,392 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use BackedEnum; +use Closure; +use think\db\exception\DbException as Exception; +use think\db\Query; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Relation; + +/** + * 多态关联类. + */ +class MorphTo extends Relation +{ + /** + * 多态关联外键. + * + * @var string + */ + protected $morphKey; + + /** + * 多态字段. + * + * @var string + */ + protected $morphType; + + /** + * 多态别名. + * + * @var array + */ + protected $alias = []; + + /** + * 关联名. + * + * @var string + */ + protected $relation; + + protected $queryCaller = []; + + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $morphType 多态字段名 + * @param string $morphKey 外键名 + * @param array $alias 多态别名定义 + * @param ?string $relation 关联名 + */ + public function __construct(Model $parent, string $morphType, string $morphKey, array $alias = [], ?string $relation = null) + { + $this->parent = $parent; + $this->morphType = $morphType; + $this->morphKey = $morphKey; + $this->alias = $alias; + $this->relation = $relation; + } + + /** + * 获取当前的关联模型类的实例. + * + * @return Model + */ + public function getModel(): Model + { + $morphType = $this->morphType; + $model = $this->parseModel($this->parent->$morphType); + + return new $model(); + } + + /** + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param ?Closure $closure 闭包查询条件 + * + * @return Model + */ + public function getRelation(array $subRelation = [], ?Closure $closure = null) + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + + // 多态模型 + $model = $this->parseModel($this->parent->$morphType); + + // 主键数据 + $pk = $this->parent->$morphKey; + + return class_exists($model) ? $this->buildQuery((new $model())->relation($subRelation))->find($pk) : null; + } + + /** + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * + * @return Query + */ + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', ?Query $query = null) + { + return $this->parent; + } + + /** + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param ?Query $query Query对象 + * + * @return Query + */ + public function hasWhere($where = [], $fields = null, string $joinType = '', ?Query $query = null, string $logic = '') + { + $model = Str::snake(class_basename($this->parent)); + $types = $this->parent->distinct()->column($this->morphType); + $query = $query ?: $this->parent->db(); + $alias = $query->getAlias() ?: $model; + + return $query->alias($alias) + ->where(function (Query $query) use ($types, $where, $alias, $logic) { + foreach ($types as $type) { + if ($type) { + $query->whereExists(function (Query $query) use ($type, $where, $alias, $logic) { + $class = $this->parseModel($type); + /** @var Model $model */ + $model = new $class(); + + $table = $model->getTable(); + $logic = 'OR' == $logic ? 'whereOr' : 'where'; + $query + ->table($table) + ->where($alias . '.' . $this->morphType, $type) + ->whereColumn($alias . '.' . $this->morphKey, $table . '.' . $model->getPk()) + ->$logic($where); + }, 'OR'); + } + } + }); + } + + /** + * 解析模型的完整命名空间. + * + * @param string $model 模型名(或者完整类名) + * + * @return Model + */ + protected function parseModel($model): string + { + if ($model instanceof BackedEnum) { + $model = $model->value; + } + + if (isset($this->alias[$model])) { + $model = $this->alias[$model]; + } + + if (!str_contains($model, '\\')) { + $path = explode('\\', get_class($this->parent)); + array_pop($path); + array_push($path, Str::studly($model)); + $model = implode('\\', $path); + } + + return $model; + } + + /** + * 设置多态别名. + * + * @param array $alias 别名定义 + * + * @return $this + */ + public function setAlias(array $alias) + { + $this->alias = $alias; + + return $this; + } + + /** + * 移除关联查询参数. + * + * @return $this + */ + public function removeOption(string $option = '') + { + return $this; + } + + /** + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param ?Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @throws Exception + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + $range = []; + + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (!empty($result->$morphKey)) { + $range[$result->$morphType][] = $result->$morphKey; + } + } + + if (!empty($range)) { + foreach ($range as $key => $val) { + // 多态类型映射 + $model = $this->parseModel($key); + $data = []; + if (class_exists($model)) { + $obj = new $model(); + if (!is_null($closure)) { + $obj = $closure($obj); + } + $pk = $obj->getPk(); + $list = $obj->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->select($val); + + foreach ($list as $k => $vo) { + $data[$vo->$pk] = $vo; + } + } + + foreach ($resultSet as $result) { + if ($key == $result->$morphType) { + // 关联模型 + if (!isset($data[$result->$morphKey])) { + $relationModel = null; + } else { + $relationModel = $data[$result->$morphKey]; + } + + $result->setRelation($relation, $relationModel); + } + } + } + } + } + + /** + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param ?Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = []): void + { + // 多态类型映射 + $model = $this->parseModel($result->{$this->morphType}); + + $this->eagerlyMorphToOne($model, $relation, $result, $subRelation, $cache); + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param ?Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * + * @return int + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = '*') + { + } + + /** + * 多态MorphTo 关联模型预查询. + * + * @param string $model 关联模型对象 + * @param string $relation 关联名 + * @param Model $result + * @param array $subRelation 子关联 + * @param array $cache 关联缓存 + * + * @return void + */ + protected function eagerlyMorphToOne(string $model, string $relation, Model $result, array $subRelation = [], array $cache = []): void + { + // 预载入关联查询 支持嵌套预载入 + $pk = $this->parent->{$this->morphKey}; + $data = null; + + if (class_exists($model)) { + $data = (new $model())->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->find($pk); + } + + $result->setRelation($relation, $data ?: null); + } + + /** + * 添加关联数据. + * + * @param Model $model 关联模型对象 + * @param string $type 多态类型 + * + * @return Model + */ + public function associate(Model $model, string $type = ''): Model + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + $pk = $model->getPk(); + + $this->parent->set($morphKey, $model->$pk); + $this->parent->set($morphType, $type ?: get_class($model)); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, $model); + } + + /** + * 注销关联数据. + * + * @return Model + */ + public function dissociate(): Model + { + $morphKey = $this->morphKey; + $morphType = $this->morphType; + + $this->parent->set($morphKey, null); + $this->parent->set($morphType, null); + $this->parent->save(); + + return $this->parent->setRelation($this->relation, null); + } + + protected function buildQuery(Query $query) + { + foreach ($this->queryCaller as $caller) { + call_user_func_array([$query, $caller[0]], $caller[1]); + } + + return $query; + } + + public function __call($method, $args) + { + $this->queryCaller[] = [$method, $args]; + + return $this; + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/MorphToMany.php b/vendor/topthink/think-orm/src/model/relation/MorphToMany.php new file mode 100644 index 0000000..8c689a8 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/MorphToMany.php @@ -0,0 +1,497 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\model\relation; + +use Closure; +use Exception; +use think\db\BaseQuery as Query; +use think\db\Raw; +use think\model\contract\Modelable as Model; +use think\model\Pivot; + +/** + * 多态多对多关联. + */ +class MorphToMany extends BelongsToMany +{ + /** + * 多态关系的模型名映射别名的数组. + * + * @var array + */ + protected static $morphMap = []; + + /** + * 多态字段名. + * + * @var string + */ + protected $morphType; + + /** + * 多态模型名. + * + * @var string + */ + protected $morphClass; + + /** + * 是否反向关联. + * + * @var bool + */ + protected $inverse; + + /** + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $middle 中间表名/模型名 + * @param string $morphKey 关联外键 + * @param string $morphType 多态字段名 + * @param string $localKey 当前模型关联键 + * @param bool $inverse 反向关联 + */ + public function __construct(Model $parent, string $model, string $middle, string $morphType, string $morphKey, string $localKey, bool $inverse = false) + { + $this->morphType = $morphType; + $this->inverse = $inverse; + $this->morphClass = $inverse ? $model : get_class($parent); + + if (isset(static::$morphMap[$this->morphClass])) { + $this->morphClass = static::$morphMap[$this->morphClass]; + } + + $foreignKey = $inverse ? $morphKey : $localKey; + $localKey = $inverse ? $localKey : $morphKey; + + parent::__construct($parent, $model, $middle, $foreignKey, $localKey); + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $pk = $resultSet[0]->getPk(); + $range = []; + + foreach ($resultSet as $result) { + // 获取关联外键列表 + if (isset($result->$pk)) { + $range[] = $result->$pk; + } + } + + if (!empty($range)) { + // 查询关联数据 + $data = $this->eagerlyManyToMany([ + ['pivot.' . $this->localKey, 'in', array_unique($range)], + ['pivot.' . $this->morphType, '=', $this->morphClass], + ], $subRelation, $closure, $cache, true); + + // 关联数据封装 + foreach ($resultSet as $result) { + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$result->$pk])); + } + } + } + + /** + * 预载入关联查询(单个数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation, ?Closure $closure = null, array $cache = []): void + { + $pk = $result->getPk(); + + if (isset($result->$pk)) { + $pk = $result->$pk; + // 查询管理数据 + $data = $this->eagerlyManyToMany([ + ['pivot.' . $this->localKey, '=', $pk], + ['pivot.' . $this->morphType, '=', $this->morphClass], + ], $subRelation, $closure, $cache); + + // 关联数据封装 + if (!isset($data[$pk])) { + $data[$pk] = []; + } + + $result->setRelation($relation, $this->resultSetBuild($data[$pk])); + } + } + + /** + * 关联统计 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int + */ + public function relationCount(Model $result, ?Closure $closure = null, string $aggregate = 'count', string $field = '*', ?string &$name = null) + { + $pk = $result->getPk(); + + if (!isset($result->$pk)) { + return 0; + } + + if ($closure) { + $closure($this->query, $name); + } + + return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ + ['pivot.' . $this->localKey, '=', $result->$pk], + ['pivot.' . $this->morphType, '=', $this->morphClass], + ])->$aggregate($field); + } + + /** + * 获取关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return string + */ + public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = '*', ?string &$name = null): string + { + if ($closure) { + $closure($this->query, $name); + } + + return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ + ['pivot.' . $this->localKey, 'exp', new Raw('=' . $this->parent->getTable(true) . '.' . $this->parent->getPk())], + ['pivot.' . $this->morphType, '=', $this->morphClass], + ])->fetchSql()->$aggregate($field); + } + + /** + * BELONGS TO MANY 关联查询. + * + * @param string $foreignKey 关联模型关联键 + * @param string $localKey 当前模型关联键 + * @param array $condition 关联查询条件 + * + * @return Query + */ + protected function belongsToManyQuery(string $foreignKey, string $localKey, array $condition = []): Query + { + // 关联查询封装 + $tableName = $this->query->getTable(); + $table = $this->pivot->db()->getTable(); + $fields = $this->getQueryFields($tableName); + + $query = $this->query + ->field($fields) + ->tableField(true, $table, 'pivot', 'pivot__'); + + if (empty($this->baseQuery)) { + $relationFk = $this->query->getPk(); + $query->join([$table => 'pivot'], 'pivot.' . $foreignKey . '=' . $tableName . '.' . $relationFk) + ->where($condition); + } + + return $query; + } + + /** + * 多对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * + * @return array + */ + protected function eagerlyManyToMany(array $where, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false): array + { + if ($closure) { + $closure($this->query); + } + + $withLimit = $this->query->getOption('limit'); + if ($withLimit && $collection) { + $this->query->removeOption('limit'); + } + + if ($this->isOneofMany) { + // 仅获取一条关联数据 + if (!$collection) { + $this->query->limit(1); + } else { + $withLimit = 1; + } + } + + // 预载入关联查询 支持嵌套预载入 + $list = $this->belongsToManyQuery($this->foreignKey, $this->localKey, $where) + ->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->lazy(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + $pivot = $set->getRelation('pivot'); + $key = $pivot[$this->localKey]; + + if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) { + continue; + } + + $set->setRelation($this->pivotDataName, $this->newPivot($pivot)); + + $data[$key][] = $set; + } + + return $data; + } + + /** + * 附加关联的一个中间表数据. + * + * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 + * @param array $pivot 中间表额外数据 + * + * @return array|Pivot + */ + public function attach($data, array $pivot = []) + { + if (is_array($data)) { + if (key($data) === 0) { + $id = $data; + } else { + // 保存关联表数据 + $model = new $this->model(); + $id = $model->insertGetId($data); + } + } elseif (is_numeric($data) || is_string($data)) { + // 根据关联表主键直接写入中间表 + $id = $data; + } elseif ($data instanceof Model) { + // 根据关联表主键直接写入中间表 + $id = $data->getKey(); + } + + if (!empty($id)) { + // 保存中间表数据 + $pivot[$this->localKey] = $this->parent->getKey(); + $pivot[$this->morphType] = $this->morphClass; + + $result = []; + foreach ((array) $ids as $id) { + $pivot[$this->foreignKey] = $id; + $object = $this->newPivot(); + $object->replace()->save($pivot); + + $result[] = $object; + } + + if (count($result) == 1) { + // 返回中间表模型对象 + $result = $result[0]; + } + + return $result; + } else { + throw new Exception('miss relation data'); + } + } + + /** + * 判断是否存在关联数据. + * + * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * + * @return Pivot|false + */ + public function attached($data) + { + if ($data instanceof Model) { + $id = $data->getKey(); + } else { + $id = $data; + } + + $pivot = $this->pivot + ->where($this->localKey, $this->parent->getKey()) + ->where($this->morphType, $this->morphClass) + ->where($this->foreignKey, $id) + ->find(); + + return $pivot ?: false; + } + + /** + * 解除关联的一个中间表数据. + * + * @param int|array $data 数据 可以使用关联对象的主键 + * @param bool $relationDel 是否同时删除关联表数据 + * + * @return int + */ + public function detach($data = null, bool $relationDel = false): int + { + if (is_array($data)) { + $id = $data; + } elseif (is_numeric($data) || is_string($data)) { + // 根据关联表主键直接写入中间表 + $id = $data; + } elseif ($data instanceof Model) { + // 根据关联表主键直接写入中间表 + $id = $data->getKey(); + } + + // 删除中间表数据 + $pivot = [ + [$this->localKey, '=', $this->parent->getKey()], + [$this->morphType, '=', $this->morphClass], + ]; + + if (isset($id)) { + $pivot[] = [$this->foreignKey, is_array($id) ? 'in' : '=', $id]; + } + + $result = $this->newPivot()->where($pivot)->delete(); + + // 删除关联表数据 + if (isset($id) && $relationDel) { + $model = $this->model; + $model::destroy($id); + } + + return $result; + } + + /** + * 数据同步. + * + * @param array $ids + * @param bool $detaching + * + * @return array + */ + public function sync(array $ids, bool $detaching = true): array + { + $changes = [ + 'attached' => [], + 'detached' => [], + 'updated' => [], + ]; + + $current = $this->pivot + ->where($this->localKey, $this->parent->getKey()) + ->where($this->morphType, $this->morphClass) + ->column($this->foreignKey); + + $records = []; + + foreach ($ids as $key => $value) { + if (!is_array($value)) { + $records[$value] = []; + } else { + $records[$key] = $value; + } + } + + $detach = array_diff($current, array_keys($records)); + + if ($detaching && count($detach) > 0) { + $this->detach($detach); + $changes['detached'] = $detach; + } + + foreach ($records as $id => $attributes) { + if (!in_array($id, $current)) { + $this->attach($id, $attributes); + $changes['attached'][] = $id; + } elseif (count($attributes) > 0) { + $this->detach($id); + $this->attach($id, $attributes); + $changes['updated'][] = $id; + } + } + + return $changes; + } + + /** + * 执行基础查询(仅执行一次). + * + * @return void + */ + protected function baseQuery(): void + { + if (empty($this->baseQuery)) { + $foreignKey = $this->foreignKey; + $localKey = $this->localKey; + + // 关联查询 + $this->belongsToManyQuery($foreignKey, $localKey, [ + ['pivot.' . $localKey, '=', $this->parent->getKey()], + ['pivot.' . $this->morphType, '=', $this->morphClass], + ]); + + $this->baseQuery = true; + } + } + + /** + * 设置或获取多态关系的模型名映射别名的数组. + * + * @param array|null $map + * @param bool $merge + * + * @return array + */ + public static function morphMap(?array $map = null, $merge = true): array + { + if (is_array($map)) { + static::$morphMap = $merge && static::$morphMap + ? $map + static::$morphMap : $map; + } + + return static::$morphMap; + } +} diff --git a/vendor/topthink/think-orm/src/model/relation/OneToOne.php b/vendor/topthink/think-orm/src/model/relation/OneToOne.php new file mode 100644 index 0000000..201d915 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/relation/OneToOne.php @@ -0,0 +1,347 @@ + +// +---------------------------------------------------------------------- + +namespace think\model\relation; + +use Closure; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; +use think\db\exception\InvalidArgumentException; +use think\helper\Str; +use think\model\contract\Modelable as Model; +use think\model\Relation; + +/** + * 一对一关联基础类. + */ +abstract class OneToOne extends Relation +{ + /** + * JOIN类型. + * + * @var string + */ + protected $joinType = 'INNER'; + + /** + * 绑定的关联属性. + * + * @var array + */ + protected $bindAttr = []; + + /** + * 关联名. + * + * @var string + */ + protected $relation; + + /** + * 获取一对多关联的最新一条数据. + * + * @param string $field 排序字段 + * + * @return $this + */ + public function firstOfMany(string $field = '') + { + return $this->first($field); + } + + /** + * 获取一对多关联的最旧一条数据. + * + * @param string $field 排序字段 + * + * @return $this + */ + public function lastOfMany(string $field = '') + { + return $this->last($field); + } + + /** + * 设置join类型. + * + * @param string $type JOIN类型 + * + * @return $this + */ + public function joinType(string $type) + { + $this->joinType = $type; + return $this; + } + + /** + * 预载入关联查询(JOIN方式). + * + * @param Query $query 查询对象 + * @param string $relation 关联名 + * @param mixed $field 关联字段 + * @param string $joinType JOIN方式 + * @param Closure $closure 闭包条件 + * @param bool $first + * + * @return void + */ + public function eagerly(Query $query, string $relation, $field = true, string $joinType = '', ?Closure $closure = null, bool $first = false): void + { + $name = Str::snake(class_basename($this->parent)); + + if ($first) { + $table = $query->getTable(); + $query->table([$table => $name]); + + if ($query->getOption('field')) { + $masterField = $query->getOption('field'); + $query->removeOption('field'); + } else { + $masterField = true; + } + + $query->tableField($masterField, $table, $name); + } + + // 预载入封装 + $joinTable = $this->query->getTable(); + $joinAlias = Str::snake($relation); + $joinType = $joinType ?: $this->joinType; + if (true !== $field) { + $joinField = $field; + } elseif ($this->query->getOption('field')) { + $joinField = $this->query->getOption('field'); + } else { + $joinField = $field; + } + + $query->via($joinAlias); + + if ($this instanceof BelongsTo) { + $foreignKeyExp = $this->foreignKey; + + if (!str_contains($foreignKeyExp, '.')) { + $foreignKeyExp = $name . '.' . $this->foreignKey; + } + + $joinOn = $foreignKeyExp . '=' . $joinAlias . '.' . $this->localKey; + } else { + $foreignKeyExp = $this->foreignKey; + + if (!str_contains($foreignKeyExp, '.')) { + $foreignKeyExp = $joinAlias . '.' . $this->foreignKey; + } + + $joinOn = $name . '.' . $this->localKey . '=' . $foreignKeyExp; + } + + if ($closure) { + // 执行闭包查询 + $closure($query); + + // 使用field指定获取关联的字段 + $withField = $query->getOption('field'); + if ($withField) { + $joinField = $withField; + } + $query->removeOption('field'); + } + + $query->join([$joinTable => $joinAlias], $joinOn, $joinType) + ->tableField($joinField, $joinTable, $joinAlias, $joinAlias . '__'); + } + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet + * @param string $relation + * @param array $subRelation + * @param Closure $closure + * + * @return mixed + */ + abstract protected function eagerlySet(array &$resultSet, string $relation, array $subRelation = [], ?Closure $closure = null); + + /** + * 预载入关联查询(数据). + * + * @param Model $result + * @param string $relation + * @param array $subRelation + * @param Closure $closure + * + * @return mixed + */ + abstract protected function eagerlyOne(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null); + + /** + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $join 是否为JOIN方式 + * + * @return void + */ + public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $join = false): void + { + if ($join) { + // 模型JOIN关联组装 + foreach ($resultSet as $result) { + $this->match($this->model, $relation, $result); + } + } else { + // IN查询 + $this->eagerlySet($resultSet, $relation, $subRelation, $closure, $cache); + } + } + + /** + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $join 是否为JOIN方式 + * + * @return void + */ + public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $join = false): void + { + if ($join) { + // 模型JOIN关联组装 + $this->match($this->model, $relation, $result); + } else { + // IN查询 + $this->eagerlyOne($result, $relation, $subRelation, $closure, $cache); + } + } + + /** + * 保存(新增)当前关联数据对象 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * + * @return Model|false + */ + public function save(array | Model $data, bool $replace = true) + { + $model = $this->make(); + + return $model->replace($replace)->save($data) ? $model : false; + } + + /** + * 创建关联对象实例. + * + * @param array|Model $data + * + * @return Model + */ + public function make(array | Model $data = []): Model + { + if ($data instanceof Model) { + $data = $data->getData(); + } + + // 保存关联表数据 + $data[$this->foreignKey] = $this->parent->{$this->localKey}; + + return (new $this->model($data))->setSuffix($this->getModel()->getSuffix()); + } + + /** + * 绑定关联表的属性到父模型属性. + * + * @param array $attr 要绑定的属性列表 + * + * @return $this + */ + public function bind(array $attr) + { + $this->bindAttr = $attr; + + return $this; + } + + /** + * 一对一 关联模型预查询拼装. + * + * @param string $model 模型名称 + * @param string $relation 关联名 + * @param Model $result 模型对象实例 + * + * @return void + */ + protected function match(string $model, string $relation, Model $result): void + { + $data = $result->getRelation($relation); + if (!empty($data)) { + if ($this->bindAttr) { + $result->bindRelationAttr($data, $this->bindAttr); + } else { + $relationModel = new $model($data); + $result->setRelation($relation, $relationModel); + } + } + } + + /** + * 一对一 关联模型预查询(IN方式). + * + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * @param bool $collection 是否数据集查询 + * @return array + */ + protected function eagerlyWhere(array $where, string $key, array $subRelation = [], ?Closure $closure = null, array $cache = [], bool $collection = false) + { + // 预载入关联查询 支持嵌套预载入 + if ($closure) { + $this->baseQuery = true; + $closure($this->query); + } + + if ($collection) { + $this->query->removeOption('limit'); + } else { + $this->query->limit(1); + } + + $list = $this->query + ->where($where) + ->with($subRelation) + ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) + ->lazy(); + + // 组装模型数据 + $data = []; + foreach ($list as $set) { + if (!isset($data[$set->$key])) { + $data[$set->$key] = $set; + } + } + + return $data; + } +} diff --git a/vendor/topthink/think-orm/src/model/type/Date.php b/vendor/topthink/think-orm/src/model/type/Date.php new file mode 100644 index 0000000..253fc77 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/type/Date.php @@ -0,0 +1,19 @@ +data($value, 'Y-m-d'); + return $static; + } +} diff --git a/vendor/topthink/think-orm/src/model/type/DateTime.php b/vendor/topthink/think-orm/src/model/type/DateTime.php new file mode 100644 index 0000000..33d6b8d --- /dev/null +++ b/vendor/topthink/think-orm/src/model/type/DateTime.php @@ -0,0 +1,74 @@ +data($value, $model->getDateFormat()); + return $static; + } + + public function data($time, $format) + { + if ($format) { + if (class_exists($format)) { + $time = $time instanceof $format ? $time : new $format($time); + $this->format = 'Y-m-d H:i:s.u'; + } else { + if (is_object($time)) { + } elseif (is_numeric($time)) { + $time = (new \DateTime())->setTimestamp((int) $time); + } elseif (strpos('.', $time)) { + $time = \DateTime::createFromFormat('Y-m-d H:i:s.u', $time); + } else { + $time = $time ? (new \DateTime($time)) : null; + } + $this->format = $format; + } + } + $this->data = $time; + } + + public function setFormat(string $format) + { + $this->format = $format; + } + + public function format(string $format = '') + { + if ($this->data instanceof Stringable) { + return $this->data->__toString(); + } + + if (is_null($this->data)) { + return null; + } + + return $this->data->format($format ?: $this->format); + } + + public function value() + { + return $this->format(); + } + + /** + * @return string + */ + public function __toString() + { + return $this->value(); + } +} diff --git a/vendor/topthink/think-orm/src/model/type/Json.php b/vendor/topthink/think-orm/src/model/type/Json.php new file mode 100644 index 0000000..723e827 --- /dev/null +++ b/vendor/topthink/think-orm/src/model/type/Json.php @@ -0,0 +1,43 @@ +data($value, $model->isJsonAssoc()); + return $static; + } + + public function data($data, ?bool $assoc) + { + if (is_string($data) && json_validate($data)) { + $data = json_decode($data, $assoc); + } elseif (empty($data)) { + $data = []; + } + $this->data = is_string($data) ? [$data] : $data; + } + + public function value() + { + return $this->data; + } + + /** + * @return string + */ + public function __toString() + { + return json_encode($this->data, JSON_UNESCAPED_UNICODE); + } +} diff --git a/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php b/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php new file mode 100644 index 0000000..a8b9541 --- /dev/null +++ b/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php @@ -0,0 +1,219 @@ + +// +---------------------------------------------------------------------- + +namespace think\paginator\driver; + +use think\Paginator; + +/** + * Bootstrap 分页驱动. + */ +class Bootstrap extends Paginator +{ + /** + * 上一页按钮. + * + * @param string $text + * + * @return string + */ + protected function getPreviousButton(string $text = '«'): string + { + if ($this->currentPage() <= 1) { + return $this->getDisabledTextWrapper($text); + } + + $url = $this->url( + $this->currentPage() - 1 + ); + + return $this->getPageLinkWrapper($url, $text); + } + + /** + * 下一页按钮. + * + * @param string $text + * + * @return string + */ + protected function getNextButton(string $text = '»'): string + { + if (!$this->hasMore) { + return $this->getDisabledTextWrapper($text); + } + + $url = $this->url($this->currentPage() + 1); + + return $this->getPageLinkWrapper($url, $text); + } + + /** + * 页码按钮. + * + * @return string + */ + protected function getLinks(): string + { + if ($this->simple) { + return ''; + } + + $block = [ + 'first' => null, + 'slider' => null, + 'last' => null, + ]; + + $side = 3; + $window = $side * 2; + + if ($this->lastPage < $window + 6) { + $block['first'] = $this->getUrlRange(1, $this->lastPage); + } elseif ($this->currentPage <= $window) { + $block['first'] = $this->getUrlRange(1, $window + 2); + $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); + } elseif ($this->currentPage > ($this->lastPage - $window)) { + $block['first'] = $this->getUrlRange(1, 2); + $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage); + } else { + $block['first'] = $this->getUrlRange(1, 2); + $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side); + $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); + } + + $html = ''; + + if (is_array($block['first'])) { + $html .= $this->getUrlLinks($block['first']); + } + + if (is_array($block['slider'])) { + $html .= $this->getDots(); + $html .= $this->getUrlLinks($block['slider']); + } + + if (is_array($block['last'])) { + $html .= $this->getDots(); + $html .= $this->getUrlLinks($block['last']); + } + + return $html; + } + + /** + * 渲染分页html. + * + * @return mixed + */ + public function render() + { + if ($this->hasPages()) { + if ($this->simple) { + return sprintf( + '
      %s %s
    ', + $this->getPreviousButton(), + $this->getNextButton() + ); + } else { + return sprintf( + '
      %s %s %s
    ', + $this->getPreviousButton(), + $this->getLinks(), + $this->getNextButton() + ); + } + } + } + + /** + * 生成一个可点击的按钮. + * + * @param string $url + * @param string $page + * + * @return string + */ + protected function getAvailablePageWrapper(string $url, string $page): string + { + return '
  • ' . $page . '
  • '; + } + + /** + * 生成一个禁用的按钮. + * + * @param string $text + * + * @return string + */ + protected function getDisabledTextWrapper(string $text): string + { + return '
  • ' . $text . '
  • '; + } + + /** + * 生成一个激活的按钮. + * + * @param string $text + * + * @return string + */ + protected function getActivePageWrapper(string $text): string + { + return '
  • ' . $text . '
  • '; + } + + /** + * 生成省略号按钮. + * + * @return string + */ + protected function getDots(): string + { + return $this->getDisabledTextWrapper('...'); + } + + /** + * 批量生成页码按钮. + * + * @param array $urls + * + * @return string + */ + protected function getUrlLinks(array $urls): string + { + $html = ''; + + foreach ($urls as $page => $url) { + $html .= $this->getPageLinkWrapper($url, $page); + } + + return $html; + } + + /** + * 生成普通页码按钮. + * + * @param string $url + * @param string $page + * + * @return string + */ + protected function getPageLinkWrapper(string $url, string $page): string + { + if ($this->currentPage() == $page) { + return $this->getActivePageWrapper($page); + } + + return $this->getAvailablePageWrapper($url, $page); + } +} diff --git a/vendor/topthink/think-orm/stubs/Exception.php b/vendor/topthink/think-orm/stubs/Exception.php new file mode 100644 index 0000000..0597f8b --- /dev/null +++ b/vendor/topthink/think-orm/stubs/Exception.php @@ -0,0 +1,59 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +/** + * 异常基础类. + */ +class Exception extends \Exception +{ + /** + * 保存异常页面显示的额外Debug数据. + * + * @var array + */ + protected $data = []; + + /** + * 设置异常额外的Debug数据 + * 数据将会显示为下面的格式. + * + * Exception Data + * -------------------------------------------------- + * Label 1 + * key1 value1 + * key2 value2 + * Label 2 + * key1 value1 + * key2 value2 + * + * @param string $label 数据分类,用于异常页面显示 + * @param array $data 需要显示的数据,必须为关联数组 + */ + final protected function setData(string $label, array $data) + { + $this->data[$label] = $data; + } + + /** + * 获取异常额外Debug数据 + * 主要用于输出到异常页面便于调试. + * + * @return array 由setData设置的Debug数据 + */ + final public function getData() + { + return $this->data; + } +} diff --git a/vendor/topthink/think-orm/stubs/Facade.php b/vendor/topthink/think-orm/stubs/Facade.php new file mode 100644 index 0000000..c87ec92 --- /dev/null +++ b/vendor/topthink/think-orm/stubs/Facade.php @@ -0,0 +1,69 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think; + +class Facade +{ + /** + * 始终创建新的对象实例. + * + * @var bool + */ + protected static $alwaysNewInstance; + + protected static $instance; + + /** + * 获取当前Facade对应类名. + * + * @return string + */ + protected static function getFacadeClass() + { + } + + /** + * 创建Facade实例. + * + * @static + * + * @param bool $newInstance 是否每次创建新的实例 + * + * @return object + */ + protected static function createFacade(bool $newInstance = false) + { + $class = static::getFacadeClass() ?: 'think\DbManager'; + + if (static::$alwaysNewInstance) { + $newInstance = true; + } + + if ($newInstance) { + return new $class(); + } + + if (!self::$instance) { + self::$instance = new $class(); + } + + return self::$instance; + } + + // 调用实际类的方法 + public static function __callStatic($method, $params) + { + return call_user_func_array([static::createFacade(), $method], $params); + } +} diff --git a/vendor/topthink/think-orm/stubs/load_stubs.php b/vendor/topthink/think-orm/stubs/load_stubs.php new file mode 100644 index 0000000..4de0b3d --- /dev/null +++ b/vendor/topthink/think-orm/stubs/load_stubs.php @@ -0,0 +1,9 @@ + './template/', + 'cache_path' => './runtime/', + 'view_suffix' => 'html', +]; + +$template = new Template($config); +// 模板变量赋值 +$template->assign(['name' => 'think']); +// 读取模板文件渲染输出 +$template->fetch('index'); +// 完整模板文件渲染 +$template->fetch('./template/test.php'); +// 渲染内容输出 +$template->display($content); +~~~ + +支持静态调用 + +~~~ +use think\facade\Template; + +Template::config([ + 'view_path' => './template/', + 'cache_path' => './runtime/', + 'view_suffix' => 'html', +]); +Template::assign(['name' => 'think']); +Template::fetch('index',['name' => 'think']); +Template::display($content,['name' => 'think']); +~~~ + +详细用法参考[开发手册](https://doc.thinkphp.cn/@think-template) \ No newline at end of file diff --git a/vendor/topthink/think-template/composer.json b/vendor/topthink/think-template/composer.json new file mode 100644 index 0000000..5857402 --- /dev/null +++ b/vendor/topthink/think-template/composer.json @@ -0,0 +1,20 @@ +{ + "name": "topthink/think-template", + "description": "the php template engine", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=8.0.0", + "psr/simple-cache": ">=1.0" + }, + "autoload": { + "psr-4": { + "think\\": "src" + } + } +} diff --git a/vendor/topthink/think-template/phpunit.xml b/vendor/topthink/think-template/phpunit.xml new file mode 100644 index 0000000..504cc73 --- /dev/null +++ b/vendor/topthink/think-template/phpunit.xml @@ -0,0 +1,12 @@ + + + + tests/think + + + \ No newline at end of file diff --git a/vendor/topthink/think-template/src/Template.php b/vendor/topthink/think-template/src/Template.php new file mode 100644 index 0000000..0370bd6 --- /dev/null +++ b/vendor/topthink/think-template/src/Template.php @@ -0,0 +1,1316 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use Exception; +use Psr\SimpleCache\CacheInterface; +use think\template\contract\DriverInterface; + +/** + * ThinkPHP分离出来的模板引擎 + * 支持XML标签和普通标签的模板解析 + * 编译型模板引擎 支持动态缓存 + */ +class Template +{ + /** + * 模板变量 + * @var array + */ + protected array $data = []; + + /** + * 模板配置参数 + * @var array + */ + protected array $config = [ + 'view_path' => '', // 模板路径 + 'view_suffix' => 'html', // 默认模板文件后缀 + 'view_depr' => DIRECTORY_SEPARATOR, + 'cache_path' => '', + 'cache_suffix' => 'php', // 默认模板缓存后缀 + 'tpl_deny_func_list' => 'echo,exit', // 模板引擎禁用函数 + 'tpl_deny_php' => false, // 默认模板引擎是否禁用PHP原生代码 + 'tpl_begin' => '{', // 模板引擎普通标签开始标记 + 'tpl_end' => '}', // 模板引擎普通标签结束标记 + 'strip_space' => false, // 是否去除模板文件里面的html空格与换行 + 'tpl_cache' => true, // 是否开启模板编译缓存,设为false则每次都会重新编译 + 'compile_type' => 'file', // 模板编译类型 + 'cache_prefix' => '', // 模板缓存前缀标识,可以动态改变 + 'cache_time' => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒) + 'layout_on' => false, // 布局模板开关 + 'layout_name' => 'layout', // 布局模板入口文件 + 'layout_item' => '{__CONTENT__}', // 布局模板的内容替换标识 + 'taglib_begin' => '{', // 标签库标签开始标记 + 'taglib_end' => '}', // 标签库标签结束标记 + 'taglib_load' => true, // 是否使用内置标签库之外的其它标签库,默认自动检测 + 'taglib_build_in' => 'cx', // 内置标签库名称(标签使用不必指定标签库名称),以逗号分隔 注意解析顺序 + 'taglib_pre_load' => '', // 需要额外加载的标签库(须指定标签库名称),多个以逗号分隔 + 'display_cache' => false, // 模板渲染缓存 + 'cache_id' => '', // 模板缓存ID + 'tpl_replace_string' => [], + 'tpl_var_identify' => 'array', // .语法变量识别,array|object|'', 为空时自动识别 + 'default_filter' => 'htmlentities', // 默认过滤方法 用于普通标签输出 + ]; + + /** + * 保留内容信息 + * @var array + */ + private array $literal = []; + + /** + * 扩展解析规则 + * @var array + */ + private array $extend = []; + + /** + * 模板包含信息 + * @var array + */ + private array $includeFile = []; + + /** + * 模板存储对象 + * @var DriverInterface + */ + protected DriverInterface $storage; + + /** + * 查询缓存对象 + * @var CacheInterface|null + */ + protected ?CacheInterface $cache; + + /** + * 架构函数 + * @access public + * @param array $config + */ + public function __construct(array $config = []) + { + $this->config = array_merge($this->config, $config); + + $this->config['taglib_begin_origin'] = $this->config['taglib_begin']; + $this->config['taglib_end_origin'] = $this->config['taglib_end']; + + $this->config['taglib_begin'] = preg_quote($this->config['taglib_begin'], '/'); + $this->config['taglib_end'] = preg_quote($this->config['taglib_end'], '/'); + $this->config['tpl_begin'] = preg_quote($this->config['tpl_begin'], '/'); + $this->config['tpl_end'] = preg_quote($this->config['tpl_end'], '/'); + + // 初始化模板编译存储器 + $type = $this->config['compile_type'] ?: 'File'; + $class = str_contains($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type); + + $this->storage = new $class(); + } + + /** + * 模板变量赋值 + * @access public + * @param array $vars 模板变量 + * @return $this + */ + public function assign(array $vars = []): static + { + $this->data = array_merge($this->data, $vars); + return $this; + } + + /** + * 模板引擎参数赋值 + * @access public + * @param string $name + * @param mixed $value + */ + public function __set(string $name, $value) + { + $this->config[$name] = $value; + } + + /** + * 设置缓存对象 + * @access public + * @param CacheInterface $cache 缓存对象 + * @return void + */ + public function setCache(CacheInterface $cache): void + { + $this->cache = $cache; + } + + /** + * 模板引擎配置 + * @access public + * @param array $config + * @return $this + */ + public function config(array $config): static + { + $this->config = array_merge($this->config, $config); + return $this; + } + + /** + * 获取模板引擎配置项 + * @access public + * @param string $name + * @return mixed + */ + public function getConfig(string $name) + { + return $this->config[$name] ?? null; + } + + /** + * 模板变量获取 + * @access public + * @param string $name 变量名 + * @return mixed + */ + public function get(string $name = '') + { + if ('' == $name) { + return $this->data; + } + + $data = $this->data; + + foreach (explode('.', $name) as $key => $val) { + if (isset($data[$val])) { + $data = $data[$val]; + } else { + $data = null; + break; + } + } + + return $data; + } + + /** + * 扩展模板解析规则 + * @access public + * @param string $rule 解析规则 + * @param callable|null $callback 解析规则回调 + * @return void + */ + public function extend(string $rule, ?callable $callback = null): void + { + $this->extend[$rule] = $callback; + } + + /** + * 渲染模板文件 + * @access public + * @param string $template 模板文件 + * @param array $vars 模板变量 + * @return void + */ + public function fetch(string $template, array $vars = []): void + { + if ($vars) { + $this->data = array_merge($this->data, $vars); + } + + if ($this->isCache($this->config['cache_id'])) { + // 读取渲染缓存 + echo $this->cache->get($this->config['cache_id']); + return; + } + + $template = $this->parseTemplateFile($template); + + if ($template) { + $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($this->config['layout_on'] . $this->config['layout_name'] . $template) . '.' . ltrim($this->config['cache_suffix'], '.'); + + if (!$this->checkCache($cacheFile)) { + // 缓存无效 重新模板编译 + $content = file_get_contents($template); + $this->compiler($content, $cacheFile); + } + + // 页面缓存 + ob_start(); + ob_implicit_flush(false); + + // 读取编译存储 + $this->storage->read($cacheFile, $this->data); + + // 获取并清空缓存 + $content = ob_get_clean(); + + if (!empty($this->config['cache_id']) && $this->config['display_cache'] && null !== $this->cache) { + // 缓存页面输出 + $this->cache->set($this->config['cache_id'], $content, $this->config['cache_time']); + } + + echo $content; + } + } + + /** + * 检查编译缓存是否存在 + * @access public + * @param string $cacheId 缓存的id + * @return boolean + */ + public function isCache(string $cacheId): bool + { + if ($cacheId && null !== $this->cache && $this->config['display_cache']) { + // 缓存页面输出 + return $this->cache->has($cacheId); + } + + return false; + } + + /** + * 渲染模板内容 + * @access public + * @param string $content 模板内容 + * @param array $vars 模板变量 + * @return void + */ + public function display(string $content, array $vars = []): void + { + if ($vars) { + $this->data = array_merge($this->data, $vars); + } + + $cacheFile = $this->config['cache_path'] . $this->config['cache_prefix'] . md5($content) . '.' . ltrim($this->config['cache_suffix'], '.'); + + if (!$this->checkCache($cacheFile)) { + // 缓存无效 模板编译 + $this->compiler($content, $cacheFile); + } + + // 读取编译存储 + $this->storage->read($cacheFile, $this->data); + } + + /** + * 设置布局 + * @access public + * @param bool|string $name 布局模板名称 false 则关闭布局 + * @param string $replace 布局模板内容替换标识 + * @return $this + */ + public function layout(bool|string $name, string $replace = ''): static + { + if (false === $name) { + // 关闭布局 + $this->config['layout_on'] = false; + } else { + // 开启布局 + $this->config['layout_on'] = true; + + // 名称必须为字符串 + if (is_string($name)) { + $this->config['layout_name'] = $name; + } + + if (!empty($replace)) { + $this->config['layout_item'] = $replace; + } + } + + return $this; + } + + /** + * 检查编译缓存是否有效,如果无效则需要重新编译 + * @access private + * @param string $cacheFile 缓存文件名 + * @return bool + */ + private function checkCache(string $cacheFile): bool + { + if (!$this->config['tpl_cache'] || !is_file($cacheFile) || !$handle = @fopen($cacheFile, "r")) { + return false; + } + + // 读取第一行 + $line = fgets($handle); + + if (false === $line) { + return false; + } + + preg_match('/\/\*(.+?)\*\//', $line, $matches); + + if (!isset($matches[1])) { + return false; + } + + $includeFile = unserialize($matches[1]); + + if (!is_array($includeFile)) { + return false; + } + + // 检查模板文件是否有更新 + foreach ($includeFile as $path => $time) { + if (is_file($path) && filemtime($path) > $time) { + // 模板文件如果有更新则缓存需要更新 + return false; + } + } + + // 检查编译存储是否有效 + return $this->storage->check($cacheFile, $this->config['cache_time']); + } + + /** + * 编译模板文件内容 + * @access private + * @param string $content 模板内容 + * @param string $cacheFile 缓存文件名 + * @return void + */ + private function compiler(string &$content, string $cacheFile): void + { + // 判断是否启用布局 + if ($this->config['layout_on']) { + if (str_contains($content, '{__NOLAYOUT__}')) { + // 可以单独定义不使用布局 + $content = str_replace('{__NOLAYOUT__}', '', $content); + } else { + // 读取布局模板 + $layoutFile = $this->parseTemplateFile($this->config['layout_name']); + + if ($layoutFile) { + // 替换布局的主体内容 + $content = str_replace($this->config['layout_item'], $content, file_get_contents($layoutFile)); + } + } + } else { + $content = str_replace('{__NOLAYOUT__}', '', $content); + } + + // 模板解析 + $this->parse($content); + + if ($this->config['strip_space']) { + /* 去除html空格与换行 */ + $find = ['~>\s+<~', '~>(\s+\n|\r)~']; + $replace = ['><', '>']; + $content = preg_replace($find, $replace, $content); + } + + // 优化生成的php代码 + $content = preg_replace('/\?>\s*<\?php\s(?!echo\b|\bend)/s', '', $content); + + // 模板过滤输出 + $replace = $this->config['tpl_replace_string']; + $content = str_replace(array_keys($replace), array_values($replace), $content); + + // 添加安全代码及模板引用记录 + $content = 'includeFile) . '*/ ?>' . "\n" . $content; + // 编译存储 + $this->storage->write($cacheFile, $content); + + $this->includeFile = []; + } + + /** + * 模板解析入口 + * 支持普通标签和TagLib解析 支持自定义标签库 + * @access public + * @param string $content 要解析的模板内容 + * @return void + */ + public function parse(string &$content): void + { + // 内容为空不解析 + if (empty($content)) { + return; + } + + // 替换literal标签内容 + $this->parseLiteral($content); + + // 解析继承 + $this->parseExtend($content); + + // 解析布局 + $this->parseLayout($content); + + // 检查include语法 + $this->parseInclude($content); + + // 替换包含文件中literal标签内容 + $this->parseLiteral($content); + + // 检查PHP语法 + $this->parsePhp($content); + + // 获取需要引入的标签库列表 + // 标签库只需要定义一次,允许引入多个一次 + // 一般放在文件的最前面 + // 格式: + // 当TAGLIB_LOAD配置为true时才会进行检测 + if ($this->config['taglib_load']) { + $tagLibs = $this->getIncludeTagLib($content); + + if (!empty($tagLibs)) { + // 对导入的TagLib进行解析 + foreach ($tagLibs as $tagLibName) { + $this->parseTagLib($tagLibName, $content); + } + } + } + + // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀 + if ($this->config['taglib_pre_load']) { + $tagLibs = explode(',', $this->config['taglib_pre_load']); + + foreach ($tagLibs as $tag) { + $this->parseTagLib($tag, $content); + } + } + + // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀 + $tagLibs = explode(',', $this->config['taglib_build_in']); + + foreach ($tagLibs as $tag) { + $this->parseTagLib($tag, $content, true); + } + + // 解析普通模板标签 {$tagName} + $this->parseTag($content); + + // 还原被替换的Literal标签 + $this->parseLiteral($content, true); + } + + /** + * 检查PHP语法 + * @access private + * @param string $content 要解析的模板内容 + * @return void + * @throws Exception + */ + private function parsePhp(string &$content): void + { + // 短标签的情况要将' . "\n", $content); + + // PHP语法检查 + if ($this->config['tpl_deny_php'] && false !== strpos($content, 'getRegex('layout'), $content, $matches)) { + // 替换Layout标签 + $content = str_replace($matches[0], '', $content); + // 解析Layout标签 + $array = $this->parseAttr($matches[0]); + + if (!$this->config['layout_on'] || $this->config['layout_name'] != $array['name']) { + // 读取布局模板 + $layoutFile = $this->parseTemplateFile($array['name']); + + if ($layoutFile) { + $replace = isset($array['replace']) ? $array['replace'] : $this->config['layout_item']; + // 替换布局的主体内容 + $content = str_replace($replace, $content, file_get_contents($layoutFile)); + } + } + } else { + $content = str_replace('{__NOLAYOUT__}', '', $content); + } + } + + /** + * 解析模板中的include标签 + * @access private + * @param string $content 要解析的模板内容 + * @return void + */ + private function parseInclude(string &$content): void + { + $regex = $this->getRegex('include'); + $func = function ($template) use (&$func, &$regex, &$content) { + if (preg_match_all($regex, $template, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $array = $this->parseAttr($match[0]); + $file = $array['file']; + unset($array['file']); + + // 分析模板文件名并读取内容 + $parseStr = $this->parseTemplateName($file); + + foreach ($array as $k => $v) { + // 以$开头字符串转换成模板变量 + if (str_starts_with($v, '$')) { + $v = $this->get(substr($v, 1)); + } + + $parseStr = str_replace('[' . $k . ']', $v, $parseStr); + } + + $content = str_replace($match[0], $parseStr, $content); + // 再次对包含文件进行模板分析 + $func($parseStr); + } + unset($matches); + } + }; + + // 替换模板中的include标签 + $func($content); + } + + /** + * 解析模板中的extend标签 + * @access private + * @param string $content 要解析的模板内容 + * @return void + */ + private function parseExtend(string &$content): void + { + $regex = $this->getRegex('extend'); + $array = $blocks = $baseBlocks = []; + $extend = ''; + + $func = function ($template) use (&$func, &$regex, &$array, &$extend, &$blocks, &$baseBlocks) { + if (preg_match($regex, $template, $matches)) { + if (!isset($array[$matches['name']])) { + $array[$matches['name']] = 1; + // 读取继承模板 + $extend = $this->parseTemplateName($matches['name']); + + // 递归检查继承 + $func($extend); + + // 取得block标签内容 + $blocks = array_merge($blocks, $this->parseBlock($template)); + + return; + } + } else { + // 取得顶层模板block标签内容 + $baseBlocks = $this->parseBlock($template, true); + + if (empty($extend)) { + // 无extend标签但有block标签的情况 + $extend = $template; + } + } + }; + + $func($content); + + if (!empty($extend)) { + if ($baseBlocks) { + $children = []; + foreach ($baseBlocks as $name => $val) { + $replace = $val['content']; + + if (!empty($children[$name])) { + // 如果包含有子block标签 + foreach ($children[$name] as $key) { + $replace = str_replace($baseBlocks[$key]['begin'] . $baseBlocks[$key]['content'] . $baseBlocks[$key]['end'], $blocks[$key]['content'], $replace); + } + } + + if (isset($blocks[$name])) { + // 带有{__block__}表示与所继承模板的相应标签合并,而不是覆盖 + $replace = str_replace(['{__BLOCK__}', '{__block__}'], $replace, $blocks[$name]['content']); + + if (!empty($val['parent'])) { + // 如果不是最顶层的block标签 + $parent = $val['parent']; + + if (isset($blocks[$parent])) { + $blocks[$parent]['content'] = str_replace($blocks[$name]['begin'] . $blocks[$name]['content'] . $blocks[$name]['end'], $replace, $blocks[$parent]['content']); + } + + $blocks[$name]['content'] = $replace; + $children[$parent][] = $name; + + continue; + } + } elseif (!empty($val['parent'])) { + // 如果子标签没有被继承则用原值 + $children[$val['parent']][] = $name; + $blocks[$name] = $val; + } + + if (!$val['parent']) { + // 替换模板中的顶级block标签 + $extend = str_replace($val['begin'] . $val['content'] . $val['end'], $replace, $extend); + } + } + } + + $content = $extend; + unset($blocks, $baseBlocks); + } + } + + /** + * 替换页面中的literal标签 + * @access private + * @param string $content 模板内容 + * @param boolean $restore 是否为还原 + * @return void + */ + private function parseLiteral(string &$content, bool $restore = false): void + { + $regex = $this->getRegex($restore ? 'restoreliteral' : 'literal'); + + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) { + if (!$restore) { + $count = count($this->literal); + + // 替换literal标签 + foreach ($matches as $match) { + $this->literal[] = substr($match[0], strlen($match[1]), -strlen($match[2])); + $content = str_replace($match[0], "", $content); + $count++; + } + } else { + // 还原literal标签 + foreach ($matches as $match) { + $content = str_replace($match[0], $this->literal[$match[1]], $content); + } + + // 清空literal记录 + $this->literal = []; + } + + unset($matches); + } + } + + /** + * 获取模板中的block标签 + * @access private + * @param string $content 模板内容 + * @param boolean $sort 是否排序 + * @return array + */ + private function parseBlock(string &$content, bool $sort = false): array + { + $regex = $this->getRegex('block'); + $result = []; + + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { + $right = $keys = []; + + foreach ($matches as $match) { + if (empty($match['name'][0])) { + if (count($right) > 0) { + $tag = array_pop($right); + $start = $tag['offset'] + strlen($tag['tag']); + $length = $match[0][1] - $start; + + $result[$tag['name']] = [ + 'begin' => $tag['tag'], + 'content' => substr($content, $start, $length), + 'end' => $match[0][0], + 'parent' => count($right) ? end($right)['name'] : '', + ]; + + $keys[$tag['name']] = $match[0][1]; + } + } else { + // 标签头压入栈 + $right[] = [ + 'name' => $match[2][0], + 'offset' => $match[0][1], + 'tag' => $match[0][0], + ]; + } + } + + unset($right, $matches); + + if ($sort) { + // 按block标签结束符在模板中的位置排序 + array_multisort($keys, $result); + } + } + + return $result; + } + + /** + * 搜索模板页面中包含的 TagLib 库,并返回列表 + * @access private + * @param string $content 模板内容 + * @return array + */ + private function getIncludeTagLib(string &$content): array + { + // 搜索是否有TagLib标签 + if (preg_match($this->getRegex('taglib'), $content, $matches)) { + // 替换TagLib标签 + $content = str_replace($matches[0], '', $content); + + return explode(',', $matches['name']); + } + + return []; + } + + /** + * TagLib库解析 + * @access public + * @param string $tagLib 要解析的标签库 + * @param string $content 要解析的模板内容 + * @param boolean $hide 是否隐藏标签库前缀 + * @return void + */ + public function parseTagLib(string $tagLib, string &$content, bool $hide = false): void + { + if (str_contains($tagLib, '\\')) { + // 支持指定标签库的命名空间 + $className = $tagLib; + $tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1); + } else { + $className = '\\think\\template\\taglib\\' . ucwords($tagLib); + } + + $tLib = new $className($this); + + $tLib->parseTag($content, $hide ? '' : $tagLib); + } + + /** + * 分析标签属性 + * @access public + * @param string $str 属性字符串 + * @param string|null $name 不为空时返回指定的属性名 + * @return array + */ + public function parseAttr(string $str, ?string $name = null): array + { + $regex = '/\s+(?>(?P[\w-]+)\s*)=(?>\s*)([\"\'])(?P(?:(?!\\2).)*)\\2/is'; + $array = []; + + if (preg_match_all($regex, $str, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $array[$match['name']] = $match['value']; + } + unset($matches); + } + + if (!empty($name) && isset($array[$name])) { + return $array[$name]; + } + + return $array; + } + + /** + * 模板标签解析 + * 格式: {TagName:args [|content] } + * @access private + * @param string $content 要解析的模板内容 + * @return void + */ + private function parseTag(string &$content): void + { + $regex = $this->getRegex('tag'); + + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + $str = stripslashes($match[1]); + $flag = substr($str, 0, 1); + + switch ($flag) { + case '$': + // 解析模板变量 格式 {$varName} + // 是否带有?号 + if (false !== $pos = strpos($str, '?')) { + $array = preg_split('/([!=]={1,2}|(?<]={0,1})/', substr($str, 0, $pos), 2, PREG_SPLIT_DELIM_CAPTURE); + $name = $array[0]; + + $this->parseVar($name); + //$this->parseVarFunction($name); + + $str = trim(substr($str, $pos + 1)); + $this->parseVar($str); + $first = substr($str, 0, 1); + + if (strpos($name, ')')) { + // $name为对象或是自动识别,或者含有函数 + if (isset($array[1])) { + $this->parseVar($array[2]); + $name .= $array[1] . $array[2]; + } + + switch ($first) { + case '?': + $this->parseVarFunction($name); + $str = ''; + break; + case '=': + $str = ''; + break; + default: + $str = ''; + } + } else { + if (isset($array[1])) { + $this->parseVar($array[2]); + $express = $name . $array[1] . $array[2]; + } else { + $express = false; + } + + if (in_array($first, ['?', '=', ':'])) { + $str = trim(substr($str, 1)); + if (str_starts_with($str, '$')) { + $str = $this->parseVarFunction($str); + } + } + + // $name为数组 + switch ($first) { + case '?': + // {$varname??'xxx'} $varname有定义则输出$varname,否则输出xxx + $str = 'parseVarFunction($name) . ' : ' . $str . '; ?>'; + break; + case '=': + // {$varname?='xxx'} $varname为真时才输出xxx + $str = ''; + break; + case ':': + // {$varname?:'xxx'} $varname为真时输出$varname,否则输出xxx + $str = 'parseVarFunction($name) . ' : ' . $str . '; ?>'; + break; + default: + if (strpos($str, ':')) { + // {$varname ? 'a' : 'b'} $varname为真时输出a,否则输出b + $array = explode(':', $str, 2); + + $array[0] = str_starts_with(trim($array[0]), '$') ? $this->parseVarFunction($array[0]) : $array[0]; + $array[1] = str_starts_with(trim($array[1]), '$') ? $this->parseVarFunction($array[1]) : $array[1]; + + $str = implode(' : ', $array); + } + $str = ''; + } + } + } else { + $this->parseVar($str); + $this->parseVarFunction($str); + $str = ''; + } + break; + case ':': + // 输出某个函数的结果 + $str = substr($str, 1); + $this->parseVar($str); + $str = ''; + break; + case '~': + // 执行某个函数 + $str = substr($str, 1); + $this->parseVar($str); + $str = ''; + break; + case '-': + case '+': + // 输出计算 + $this->parseVar($str); + $str = ''; + break; + case '/': + // 注释标签 + $flag2 = substr($str, 1, 1); + if ('/' == $flag2 || ('*' == $flag2 && str_ends_with(rtrim($str), '*/'))) { + $str = ''; + } + break; + default: + // 未识别的标签直接返回 + $str = $this->config['tpl_begin'] . $str . $this->config['tpl_end']; + break; + } + + $content = str_replace($match[0], $str, $content); + } + + unset($matches); + } + } + + /** + * 模板变量解析,支持使用函数 + * 格式: {$varname|function1|function2=arg1,arg2} + * @access public + * @param string $varStr 变量数据 + * @return void + */ + public function parseVar(string &$varStr): void + { + $varStr = trim($varStr); + + if (preg_match_all('/\$[a-zA-Z_](?>\w*)(?:[:.][0-9a-zA-Z_](?>\w*))+/', $varStr, $matches, PREG_OFFSET_CAPTURE)) { + static $_varParseList = []; + + while ($matches[0]) { + $match = array_pop($matches[0]); + + //如果已经解析过该变量字串,则直接返回变量值 + if (isset($_varParseList[$match[0]])) { + $parseStr = $_varParseList[$match[0]]; + } else { + if (strpos($match[0], '.')) { + $vars = explode('.', $match[0]); + $first = array_shift($vars); + + if (isset($this->extend[$first])) { + $callback = $this->extend[$first]; + $parseStr = $callback($vars); + } elseif ('$Request' == $first) { + // 输出请求变量 + $parseStr = $this->parseRequestVar($vars); + } elseif ('$Think' == $first) { + // 所有以Think.打头的以特殊变量对待 无需模板赋值就可以输出 + $parseStr = $this->parseThinkVar($vars); + } else { + switch ($this->config['tpl_var_identify']) { + case 'array': // 识别为数组 + $parseStr = $first . '[\'' . implode('\'][\'', $vars) . '\']'; + break; + case 'obj': // 识别为对象 + $parseStr = $first . '->' . implode('->', $vars); + break; + default: // 自动判断数组或对象 + $parseStr = '(is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars) . ')'; + } + } + } else { + $parseStr = str_replace(':', '->', $match[0]); + } + + $_varParseList[$match[0]] = $parseStr; + } + + $varStr = substr_replace($varStr, $parseStr, $match[1], strlen($match[0])); + } + unset($matches); + } + } + + /** + * 对模板中使用了函数的变量进行解析 + * 格式 {$varname|function1|function2=arg1,arg2} + * @access public + * @param string $varStr 变量字符串 + * @param bool $autoescape 自动转义 + * @return string + */ + public function parseVarFunction(string &$varStr, bool $autoescape = true): string + { + if (!$autoescape && !str_contains($varStr, '|')) { + return $varStr; + } elseif ($autoescape && !preg_match('/\|(\s)?raw(\||\s)?/i', $varStr)) { + $varStr .= '|' . $this->config['default_filter']; + } + + static $_varFunctionList = []; + + $_key = md5($varStr); + + //如果已经解析过该变量字串,则直接返回变量值 + if (isset($_varFunctionList[$_key])) { + $varStr = $_varFunctionList[$_key]; + } else { + $varArray = explode('|', $varStr); + + // 取得变量名称 + $name = trim(array_shift($varArray)); + + // 对变量使用函数 + $length = count($varArray); + + // 取得模板禁止使用函数列表 + $template_deny_funs = explode(',', $this->config['tpl_deny_func_list']); + + for ($i = 0; $i < $length; $i++) { + $args = explode('=', $varArray[$i], 2); + + // 模板函数过滤 + $fun = trim($args[0]); + if (in_array($fun, $template_deny_funs)) { + continue; + } + + switch (strtolower($fun)) { + case 'raw': + break; + case 'htmlentities': + $name = 'htmlentities((string) ' . $name . ')'; + break; + case 'date': + $name = 'date(' . $args[1] . ',!is_numeric(' . $name . ')? strtotime(' . $name . ') : ' . $name . ')'; + break; + case 'first': + $name = 'current(' . $name . ')'; + break; + case 'last': + $name = 'end(' . $name . ')'; + break; + case 'upper': + $name = 'strtoupper(' . $name . ')'; + break; + case 'lower': + $name = 'strtolower(' . $name . ')'; + break; + case 'format': + $name = 'sprintf(' . $args[1] . ',' . $name . ')'; + break; + case 'default': // 特殊模板函数 + if (!str_contains($name, '(')) { + $name = '(isset(' . $name . ') && (' . $name . ' !== \'\')?' . $name . ':' . $args[1] . ')'; + } else { + $name = '(' . $name . ' ?: ' . $args[1] . ')'; + } + break; + default: // 通用模板函数 + if (isset($args[1])) { + if (str_contains($args[1], '###')) { + $args[1] = str_replace('###', $name, $args[1]); + $name = "$fun($args[1])"; + } else { + $name = "$fun($name,$args[1])"; + } + } else { + if (!empty($args[0])) { + $name = "$fun($name)"; + } + } + } + } + + $_varFunctionList[$_key] = $name; + $varStr = $name; + } + return $varStr; + } + + /** + * 请求变量解析 + * 格式 以 $Request. 打头的变量属于请求变量 + * @access public + * @param array $vars 变量数组 + * @return string + */ + public function parseRequestVar(array $vars): string + { + $type = strtoupper(trim(array_shift($vars))); + $param = implode('.', $vars); + + switch ($type) { + case 'SERVER': + $parseStr = '$_SERVER[\'' . $param . '\']'; + break; + case 'GET': + $parseStr = '$_GET[\'' . $param . '\']'; + break; + case 'POST': + $parseStr = '$_POST[\'' . $param . '\']'; + break; + case 'COOKIE': + $parseStr = '$_COOKIE[\'' . $param . '\']'; + break; + case 'SESSION': + $parseStr = '$_SESSION[\'' . $param . '\']'; + break; + case 'ENV': + $parseStr = '$_ENV[\'' . $param . '\']'; + break; + case 'REQUEST': + $parseStr = '$_REQUEST[\'' . $param . '\']'; + break; + default: + $parseStr = '\'\''; + } + + return $parseStr; + } + + /** + * 特殊模板变量解析 + * 格式 以 $Think. 打头的变量属于特殊模板变量 + * @access public + * @param array $vars 变量数组 + * @return string + */ + public function parseThinkVar(array $vars): string + { + $type = strtoupper(trim(array_shift($vars))); + $param = implode('.', $vars); + + return match ($type) { + 'CONST' => strtoupper($param), + 'NOW' => "date('Y-m-d g:i a',time())", + 'LDELIM' => '\'' . ltrim($this->config['tpl_begin'], '\\') . '\'', + 'RDELIM' => '\'' . ltrim($this->config['tpl_end'], '\\') . '\'', + default => defined($type) ? $type : '\'\'', + }; + } + + /** + * 分析加载的模板文件并读取内容 支持多个模板文件读取 + * @access private + * @param string $templateName 模板文件名 + * @return string + */ + private function parseTemplateName(string $templateName): string + { + $array = explode(',', $templateName); + $parseStr = ''; + + foreach ($array as $templateName) { + if (str_starts_with($templateName, '$')) { + //支持加载变量文件名 + $templateName = $this->get(substr($templateName, 1)); + } + + if (empty($templateName)) { + continue; + } + + $template = $this->parseTemplateFile($templateName); + + if ($template) { + // 获取模板文件内容 + $parseStr .= file_get_contents($template); + } + } + + return $parseStr; + } + + /** + * 解析模板文件名 + * @access private + * @param string $template 文件名 + * @return string + */ + private function parseTemplateFile(string $template): string + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + + if (!str_starts_with($template, '/')) { + $template = str_replace(['/', ':'], $this->config['view_depr'], $template); + } else { + $template = str_replace(['/', ':'], $this->config['view_depr'], substr($template, 1)); + } + + $template = $this->config['view_path'] . $template . '.' . ltrim($this->config['view_suffix'], '.'); + } + + if (is_file($template)) { + // 记录模板文件的更新时间 + $this->includeFile[$template] = filemtime($template); + + return $template; + } + + throw new Exception('template not exists:' . $template); + } + + /** + * 按标签生成正则 + * @access private + * @param string $tagName 标签名 + * @return string + */ + private function getRegex(string $tagName): string + { + $regex = ''; + if ('tag' == $tagName) { + $begin = $this->config['tpl_begin']; + $end = $this->config['tpl_end']; + + if (strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1) { + $regex = $begin . '((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>[^' . $end . ']*))' . $end; + } else { + $regex = $begin . '((?:[\$]{1,2}[a-wA-w_]|[\:\~][\$a-wA-w_]|[+]{2}[\$][a-wA-w_]|[-]{2}[\$][a-wA-w_]|\/[\*\/])(?>(?:(?!' . $end . ').)*))' . $end; + } + } else { + $begin = $this->config['taglib_begin']; + $end = $this->config['taglib_end']; + $single = strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1; + + switch ($tagName) { + case 'block': + if ($single) { + $regex = $begin . '(?:' . $tagName . '\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>[^' . $end . ']*)|\/' . $tagName . ')' . $end; + } else { + $regex = $begin . '(?:' . $tagName . '\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end; + } + break; + case 'literal': + if ($single) { + $regex = '(' . $begin . $tagName . '\b(?>[^' . $end . ']*)' . $end . ')'; + $regex .= '(?:(?>[^' . $begin . ']*)(?>(?!' . $begin . '(?>' . $tagName . '\b[^' . $end . ']*|\/' . $tagName . ')' . $end . ')' . $begin . '[^' . $begin . ']*)*)'; + $regex .= '(' . $begin . '\/' . $tagName . $end . ')'; + } else { + $regex = '(' . $begin . $tagName . '\b(?>(?:(?!' . $end . ').)*)' . $end . ')'; + $regex .= '(?:(?>(?:(?!' . $begin . ').)*)(?>(?!' . $begin . '(?>' . $tagName . '\b(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end . ')' . $begin . '(?>(?:(?!' . $begin . ').)*))*)'; + $regex .= '(' . $begin . '\/' . $tagName . $end . ')'; + } + break; + case 'restoreliteral': + $regex = ''; + break; + case 'include': + $name = 'file'; + case 'taglib': + case 'layout': + case 'extend': + if (empty($name)) { + $name = 'name'; + } + if ($single) { + $regex = $begin . $tagName . '\b\s+(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>[^' . $end . ']*)' . $end; + } else { + $regex = $begin . $tagName . '\b\s+(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>(?:(?!' . $end . ').)*)' . $end; + } + break; + } + } + + return '/' . $regex . '/is'; + } + + public function __debugInfo() + { + $data = get_object_vars($this); + unset($data['storage']); + + return $data; + } +} diff --git a/vendor/topthink/think-template/src/facade/Template.php b/vendor/topthink/think-template/src/facade/Template.php new file mode 100644 index 0000000..69cf492 --- /dev/null +++ b/vendor/topthink/think-template/src/facade/Template.php @@ -0,0 +1,83 @@ + +// +---------------------------------------------------------------------- + +namespace think\facade; + +if (class_exists('think\Facade')) { + class Facade extends \think\Facade + {} +} else { + class Facade + { + /** + * 始终创建新的对象实例 + * @var bool + */ + protected static $alwaysNewInstance; + + protected static $instance; + + /** + * 获取当前Facade对应类名 + * @access protected + * @return string + */ + protected static function getFacadeClass() + {} + + /** + * 创建Facade实例 + * @static + * @access protected + * @return object + */ + protected static function createFacade() + { + $class = static::getFacadeClass() ?: 'think\Template'; + + if (static::$alwaysNewInstance) { + return new $class(); + } + + if (!self::$instance) { + self::$instance = new $class(); + } + + return self::$instance; + + } + + // 调用实际类的方法 + public static function __callStatic($method, $params) + { + return call_user_func_array([static::createFacade(), $method], $params); + } + } +} + +/** + * @see \think\Template + * @mixin \think\Template + */ +class Template extends Facade +{ + protected static $alwaysNewInstance = true; + + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'think\Template'; + } +} diff --git a/vendor/topthink/think-template/src/template/TagLib.php b/vendor/topthink/think-template/src/template/TagLib.php new file mode 100644 index 0000000..4203b77 --- /dev/null +++ b/vendor/topthink/think-template/src/template/TagLib.php @@ -0,0 +1,341 @@ + +// +---------------------------------------------------------------------- + +namespace think\template; + +use Exception; +use think\Template; + +/** + * ThinkPHP标签库TagLib解析基类 + * @category Think + * @package Think + * @subpackage Template + * @author liu21st + */ +class TagLib +{ + + /** + * 标签库定义XML文件 + * @var string + * @access protected + */ + protected $xml = ''; + protected $tags = []; // 标签定义 + /** + * 标签库名称 + * @var string + * @access protected + */ + protected $tagLib = ''; + + /** + * 标签库标签列表 + * @var array + * @access protected + */ + protected $tagList = []; + + /** + * 标签库分析数组 + * @var array + * @access protected + */ + protected $parse = []; + + /** + * 标签库是否有效 + * @var bool + * @access protected + */ + protected $valid = false; + + protected $comparison = [' nheq ' => ' !== ', ' heq ' => ' === ', ' neq ' => ' != ', ' eq ' => ' == ', ' egt ' => ' >= ', ' gt ' => ' > ', ' elt ' => ' <= ', ' lt ' => ' < ']; + + /** + * 架构函数 + * @access public + * @param Template $tpl 模板引擎对象 + */ + public function __construct(protected Template $tpl) + { + } + + /** + * 按签标库替换页面中的标签 + * @access public + * @param string $content 模板内容 + * @param string $lib 标签库名 + * @return void + */ + public function parseTag(string &$content, string $lib = ''): void + { + $tags = []; + $lib = $lib ? strtolower($lib) . ':' : ''; + + foreach ($this->tags as $name => $val) { + $close = !isset($val['close']) || $val['close'] ? 1 : 0; + $tags[$close][$lib . $name] = $name; + if (isset($val['alias'])) { + // 别名设置 + $array = (array) $val['alias']; + foreach (explode(',', $array[0]) as $v) { + $tags[$close][$lib . $v] = $name; + } + } + } + + // 闭合标签 + if (!empty($tags[1])) { + $nodes = []; + $regex = $this->getRegex(array_keys($tags[1]), 1); + if (preg_match_all($regex, $content, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { + $right = []; + foreach ($matches as $match) { + if ('' == $match[1][0]) { + $name = strtolower($match[2][0]); + // 如果有没闭合的标签头则取出最后一个 + if (!empty($right[$name])) { + // $match[0][1]为标签结束符在模板中的位置 + $nodes[$match[0][1]] = [ + 'name' => $name, + 'begin' => array_pop($right[$name]), // 标签开始符 + 'end' => $match[0], // 标签结束符 + ]; + } + } else { + // 标签头压入栈 + $right[strtolower($match[1][0])][] = $match[0]; + } + } + unset($right, $matches); + // 按标签在模板中的位置从后向前排序 + krsort($nodes); + } + + $break = ''; + if ($nodes) { + $beginArray = []; + // 标签替换 从后向前 + foreach ($nodes as $pos => $node) { + // 对应的标签名 + $name = $tags[1][$node['name']]; + $alias = $lib . $name != $node['name'] ? ($lib ? strstr($node['name'], $lib) : $node['name']) : ''; + + // 解析标签属性 + $attrs = $this->parseAttr($node['begin'][0], $name, $alias); + $method = 'tag' . $name; + + // 读取标签库中对应的标签内容 replace[0]用来替换标签头,replace[1]用来替换标签尾 + $replace = explode($break, $this->$method($attrs, $break)); + + if (count($replace) > 1) { + while ($beginArray) { + $begin = end($beginArray); + // 判断当前标签尾的位置是否在栈中最后一个标签头的后面,是则为子标签 + if ($node['end'][1] > $begin['pos']) { + break; + } else { + // 不为子标签时,取出栈中最后一个标签头 + $begin = array_pop($beginArray); + // 替换标签头部 + $content = substr_replace($content, $begin['str'], $begin['pos'], $begin['len']); + } + } + // 替换标签尾部 + $content = substr_replace($content, $replace[1], $node['end'][1], strlen($node['end'][0])); + // 把标签头压入栈 + $beginArray[] = ['pos' => $node['begin'][1], 'len' => strlen($node['begin'][0]), 'str' => $replace[0]]; + } + } + + while ($beginArray) { + $begin = array_pop($beginArray); + // 替换标签头部 + $content = substr_replace($content, $begin['str'], $begin['pos'], $begin['len']); + } + } + } + // 自闭合标签 + if (!empty($tags[0])) { + $regex = $this->getRegex(array_keys($tags[0]), 0); + $content = preg_replace_callback($regex, function ($matches) use (&$tags, &$lib) { + // 对应的标签名 + $name = $tags[0][strtolower($matches[1])]; + $alias = $lib . $name != $matches[1] ? ($lib ? strstr($matches[1], $lib) : $matches[1]) : ''; + // 解析标签属性 + $attrs = $this->parseAttr($matches[0], $name, $alias); + $method = 'tag' . $name; + return $this->$method($attrs, ''); + }, $content); + } + } + + /** + * 按标签生成正则 + * @access public + * @param array|string $tags 标签名 + * @param boolean $close 是否为闭合标签 + * @return string + */ + public function getRegex($tags, bool $close): string + { + $begin = $this->tpl->getConfig('taglib_begin'); + $end = $this->tpl->getConfig('taglib_end'); + $single = strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1 ? true : false; + $tagName = is_array($tags) ? implode('|', $tags) : $tags; + + if ($single) { + if ($close) { + // 如果是闭合标签 + $regex = $begin . '(?:(' . $tagName . ')\b(?>[^' . $end . ']*)|\/(' . $tagName . '))' . $end; + } else { + $regex = $begin . '(' . $tagName . ')\b(?>[^' . $end . ']*)' . $end; + } + } else { + if ($close) { + // 如果是闭合标签 + $regex = $begin . '(?:(' . $tagName . ')\b(?>(?:(?!' . $end . ').)*)|\/(' . $tagName . '))' . $end; + } else { + $regex = $begin . '(' . $tagName . ')\b(?>(?:(?!' . $end . ').)*)' . $end; + } + } + + return '/' . $regex . '/is'; + } + + /** + * 分析标签属性 正则方式 + * @access public + * @param string $str 标签属性字符串 + * @param string $name 标签名 + * @param string $alias 别名 + * @return array + */ + public function parseAttr(string $str, string $name, string $alias = ''): array + { + $regex = '/\s+(?>(?P[\w-]+)\s*)=(?>\s*)([\"\'])(?P(?:(?!\\2).)*)\\2/is'; + $result = []; + + if (preg_match_all($regex, $str, $matches)) { + foreach ($matches['name'] as $key => $val) { + $result[$val] = $matches['value'][$key]; + } + + if (!isset($this->tags[$name])) { + // 检测是否存在别名定义 + foreach ($this->tags as $key => $val) { + if (isset($val['alias'])) { + $array = (array) $val['alias']; + if (in_array($name, explode(',', $array[0]))) { + $tag = $val; + $type = !empty($array[1]) ? $array[1] : 'type'; + $result[$type] = $name; + break; + } + } + } + } else { + $tag = $this->tags[$name]; + // 设置了标签别名 + if (!empty($alias) && isset($tag['alias'])) { + $type = !empty($tag['alias'][1]) ? $tag['alias'][1] : 'type'; + $result[$type] = $alias; + } + } + + if (!empty($tag['must'])) { + $must = explode(',', $tag['must']); + foreach ($must as $name) { + if (!isset($result[$name])) { + throw new Exception('tag attr must:' . $name); + } + } + } + } else { + // 允许直接使用表达式的标签 + if (!empty($this->tags[$name]['expression'])) { + static $_taglibs; + if (!isset($_taglibs[$name])) { + $_taglibs[$name][0] = strlen($this->tpl->getConfig('taglib_begin_origin') . $name); + $_taglibs[$name][1] = strlen($this->tpl->getConfig('taglib_end_origin')); + } + $result['expression'] = substr($str, $_taglibs[$name][0], -$_taglibs[$name][1]); + // 清除自闭合标签尾部/ + $result['expression'] = rtrim($result['expression'], '/'); + $result['expression'] = trim($result['expression']); + } elseif (empty($this->tags[$name]) || !empty($this->tags[$name]['attr'])) { + throw new Exception('tag error:' . $name); + } + } + + return $result; + } + + /** + * 解析条件表达式 + * @access public + * @param string $condition 表达式标签内容 + * @return string + */ + public function parseCondition(string $condition): string + { + if (strpos($condition, ':')) { + $condition = ' ' . substr(strstr($condition, ':'), 1); + } + + $condition = str_ireplace(array_keys($this->comparison), array_values($this->comparison), $condition); + $this->tpl->parseVar($condition); + + return $condition; + } + + /** + * 自动识别构建变量 + * @access public + * @param string $name 变量描述 + * @return string + */ + public function autoBuildVar(string &$name): string + { + $flag = substr($name, 0, 1); + + if (':' == $flag) { + // 以:开头为函数调用,解析前去掉: + $name = substr($name, 1); + } elseif ('$' != $flag && preg_match('/[a-zA-Z_]/', $flag)) { + // XXX: 这句的写法可能还需要改进 + // 常量不需要解析 + if (defined($name)) { + return $name; + } + + // 不以$开头并且也不是常量,自动补上$前缀 + $name = '$' . $name; + } + + $this->tpl->parseVar($name); + $this->tpl->parseVarFunction($name, false); + + return $name; + } + + /** + * 获取标签列表 + * @access public + * @return array + */ + public function getTags(): array + { + return $this->tags; + } +} diff --git a/vendor/topthink/think-template/src/template/contract/DriverInterface.php b/vendor/topthink/think-template/src/template/contract/DriverInterface.php new file mode 100644 index 0000000..e1c52da --- /dev/null +++ b/vendor/topthink/think-template/src/template/contract/DriverInterface.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- + +namespace think\template\driver; + +use Exception; +use think\template\contract\DriverInterface; + +class File implements DriverInterface +{ + protected $cacheFile; + + /** + * 写入编译缓存 + * @access public + * @param string $cacheFile 缓存的文件名 + * @param string $content 缓存的内容 + * @return void + */ + public function write(string $cacheFile, string $content): void + { + // 检测模板目录 + $dir = dirname($cacheFile); + + if (!is_dir($dir)) { + mkdir($dir, 0755, true); + } + + // 生成模板缓存文件 + if (false === file_put_contents($cacheFile, $content)) { + throw new Exception('cache write error:' . $cacheFile, 11602); + } + } + + /** + * 读取编译编译 + * @access public + * @param string $cacheFile 缓存的文件名 + * @param array $vars 变量数组 + * @return void + */ + public function read(string $cacheFile, array $vars = []): void + { + $this->cacheFile = $cacheFile; + + if (!empty($vars) && is_array($vars)) { + // 模板阵列变量分解成为独立变量 + extract($vars, EXTR_OVERWRITE); + } + + //载入模版缓存文件 + include $this->cacheFile; + } + + /** + * 检查编译缓存是否有效 + * @access public + * @param string $cacheFile 缓存的文件名 + * @param int $cacheTime 缓存时间 + * @return bool + */ + public function check(string $cacheFile, int $cacheTime): bool + { + // 缓存文件不存在, 直接返回false + if (!file_exists($cacheFile)) { + return false; + } + + if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) { + // 缓存是否在有效期 + return false; + } + + return true; + } +} diff --git a/vendor/topthink/think-template/src/template/exception/TemplateNotFoundException.php b/vendor/topthink/think-template/src/template/exception/TemplateNotFoundException.php new file mode 100644 index 0000000..193e69c --- /dev/null +++ b/vendor/topthink/think-template/src/template/exception/TemplateNotFoundException.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- + +namespace think\template\exception; + +class TemplateNotFoundException extends \RuntimeException +{ + protected $template; + + public function __construct(string $message, string $template = '') + { + $this->message = $message; + $this->template = $template; + } + + /** + * 获取模板文件 + * @access public + * @return string + */ + public function getTemplate(): string + { + return $this->template; + } +} diff --git a/vendor/topthink/think-template/src/template/taglib/Cx.php b/vendor/topthink/think-template/src/template/taglib/Cx.php new file mode 100644 index 0000000..01d7ddb --- /dev/null +++ b/vendor/topthink/think-template/src/template/taglib/Cx.php @@ -0,0 +1,715 @@ + +// +---------------------------------------------------------------------- + +namespace think\template\taglib; + +use think\template\TagLib; + +/** + * CX标签库解析类 + * @category Think + * @package Think + * @subpackage Driver.Taglib + * @author liu21st + */ +class Cx extends Taglib +{ + + // 标签定义 + protected $tags = [ + // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 + 'php' => ['attr' => ''], + 'volist' => ['attr' => 'name,id,offset,length,key,mod', 'alias' => 'iterate'], + 'foreach' => ['attr' => 'name,id,item,key,offset,length,mod', 'expression' => true], + 'if' => ['attr' => 'condition', 'expression' => true], + 'elseif' => ['attr' => 'condition', 'close' => 0, 'expression' => true], + 'else' => ['attr' => '', 'close' => 0], + 'switch' => ['attr' => 'name', 'expression' => true], + 'case' => ['attr' => 'value,break', 'expression' => true], + 'default' => ['attr' => '', 'close' => 0], + 'compare' => ['attr' => 'name,value,type', 'alias' => ['eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq', 'type']], + 'range' => ['attr' => 'name,value,type', 'alias' => ['in,notin,between,notbetween', 'type']], + 'empty' => ['attr' => 'name'], + 'notempty' => ['attr' => 'name'], + 'present' => ['attr' => 'name'], + 'notpresent' => ['attr' => 'name'], + 'defined' => ['attr' => 'name'], + 'notdefined' => ['attr' => 'name'], + 'load' => ['attr' => 'file,href,type,value,basepath', 'close' => 0, 'alias' => ['import,css,js', 'type']], + 'assign' => ['attr' => 'name,value', 'close' => 0], + 'define' => ['attr' => 'name,value', 'close' => 0], + 'for' => ['attr' => 'start,end,name,comparison,step'], + 'url' => ['attr' => 'link,vars,suffix,domain', 'close' => 0, 'expression' => true], + 'function' => ['attr' => 'name,vars,use,call'], + ]; + + /** + * php标签解析 + * 格式: + * {php}echo $name{/php} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagPhp(array $tag, string $content): string + { + $parseStr = ''; + return $parseStr; + } + + /** + * volist标签解析 循环输出数据集 + * 格式: + * {volist name="userList" id="user" empty=""} + * {user.username} + * {user.email} + * {/volist} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagVolist(array $tag, string $content): string + { + $name = $tag['name']; + $id = $tag['id']; + $empty = isset($tag['empty']) ? $tag['empty'] : ''; + $key = !empty($tag['key']) ? $tag['key'] : 'i'; + $mod = isset($tag['mod']) ? $tag['mod'] : '2'; + $offset = !empty($tag['offset']) && is_numeric($tag['offset']) ? intval($tag['offset']) : 0; + $length = !empty($tag['length']) && is_numeric($tag['length']) ? intval($tag['length']) : 'null'; + // 允许使用函数设定数据集 {$vo.name} + $parseStr = 'autoBuildVar($name); + $parseStr .= '$_result=' . $name . ';'; + $name = '$_result'; + } else { + $name = $this->autoBuildVar($name); + } + + $parseStr .= 'if(is_array(' . $name . ') || ' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator): $' . $key . ' = 0;'; + + // 设置了输出数组长度 + if (0 != $offset || 'null' != $length) { + $parseStr .= '$__LIST__ = is_array(' . $name . ') ? array_slice(' . $name . ',' . $offset . ',' . $length . ', true) : ' . $name . '->slice(' . $offset . ',' . $length . ', true); '; + } else { + $parseStr .= ' $__LIST__ = ' . $name . ';'; + } + + $parseStr .= 'if( count($__LIST__)==0 ) : echo "' . $empty . '" ;'; + $parseStr .= 'else: '; + $parseStr .= 'foreach($__LIST__ as $key=>$' . $id . '): '; + $parseStr .= '$mod = ($' . $key . ' % ' . $mod . ' );'; + $parseStr .= '++$' . $key . ';?>'; + $parseStr .= $content; + $parseStr .= ''; + + return $parseStr; + } + + /** + * foreach标签解析 循环输出数据集 + * 格式: + * {foreach name="userList" id="user" key="key" index="i" mod="2" offset="3" length="5" empty=""} + * {user.username} + * {/foreach} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagForeach(array $tag, string $content): string + { + // 直接使用表达式 + if (!empty($tag['expression'])) { + $expression = ltrim(rtrim($tag['expression'], ')'), '('); + $expression = $this->autoBuildVar($expression); + $parseStr = ''; + $parseStr .= $content; + $parseStr .= ''; + return $parseStr; + } + + $name = $tag['name']; + $key = !empty($tag['key']) ? $tag['key'] : 'key'; + $item = !empty($tag['id']) ? $tag['id'] : $tag['item']; + $empty = isset($tag['empty']) ? $tag['empty'] : ''; + $offset = !empty($tag['offset']) && is_numeric($tag['offset']) ? intval($tag['offset']) : 0; + $length = !empty($tag['length']) && is_numeric($tag['length']) ? intval($tag['length']) : 'null'; + + $parseStr = 'autoBuildVar($name); + $parseStr .= $var . '=' . $name . '; '; + $name = $var; + } else { + $name = $this->autoBuildVar($name); + } + + $parseStr .= 'if(is_array(' . $name . ') || ' . $name . ' instanceof \think\Collection || ' . $name . ' instanceof \think\Paginator): '; + + // 设置了输出数组长度 + if (0 != $offset || 'null' != $length) { + if (!isset($var)) { + $var = '$_' . uniqid(); + } + $parseStr .= $var . ' = is_array(' . $name . ') ? array_slice(' . $name . ',' . $offset . ',' . $length . ', true) : ' . $name . '->slice(' . $offset . ',' . $length . ', true); '; + } else { + $var = &$name; + } + + $parseStr .= 'if( count(' . $var . ')==0 ) : echo "' . $empty . '" ;'; + $parseStr .= 'else: '; + + // 设置了索引项 + if (isset($tag['index'])) { + $index = $tag['index']; + $parseStr .= '$' . $index . '=0; '; + } + + $parseStr .= 'foreach(' . $var . ' as $' . $key . '=>$' . $item . '): '; + + // 设置了索引项 + if (isset($tag['index'])) { + $index = $tag['index']; + if (isset($tag['mod'])) { + $mod = (int) $tag['mod']; + $parseStr .= '$mod = ($' . $index . ' % ' . $mod . '); '; + } + $parseStr .= '++$' . $index . '; '; + } + + $parseStr .= '?>'; + // 循环体中的内容 + $parseStr .= $content; + $parseStr .= ''; + + return $parseStr; + } + + /** + * if标签解析 + * 格式: + * {if condition=" $a eq 1"} + * {elseif condition="$a eq 2" /} + * {else /} + * {/if} + * 表达式支持 eq neq gt egt lt elt == > >= < <= or and || && + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagIf(array $tag, string $content): string + { + $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition']; + $condition = $this->parseCondition($condition); + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * elseif标签解析 + * 格式:见if标签 + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagElseif(array $tag, string $content): string + { + $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition']; + $condition = $this->parseCondition($condition); + $parseStr = ''; + + return $parseStr; + } + + /** + * else标签解析 + * 格式:见if标签 + * @access public + * @param array $tag 标签属性 + * @return string + */ + public function tagElse(array $tag): string + { + $parseStr = ''; + + return $parseStr; + } + + /** + * switch标签解析 + * 格式: + * {switch name="a.name"} + * {case value="1" break="false"}1{/case} + * {case value="2" }2{/case} + * {default /}other + * {/switch} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagSwitch(array $tag, string $content): string + { + $name = !empty($tag['expression']) ? $tag['expression'] : $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * case标签解析 需要配合switch才有效 + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagCase(array $tag, string $content): string + { + $value = isset($tag['expression']) ? $tag['expression'] : $tag['value']; + $flag = substr($value, 0, 1); + + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + $value = 'case ' . $value . ':'; + } elseif (strpos($value, '|')) { + $values = explode('|', $value); + $value = ''; + foreach ($values as $val) { + $value .= 'case "' . addslashes($val) . '":'; + } + } else { + $value = 'case "' . $value . '":'; + } + + $parseStr = '' . $content; + $isBreak = isset($tag['break']) ? $tag['break'] : ''; + + if ('' == $isBreak || $isBreak) { + $parseStr .= ''; + } + + return $parseStr; + } + + /** + * default标签解析 需要配合switch才有效 + * 使用: {default /}ddfdf + * @access public + * @param array $tag 标签属性 + * @return string + */ + public function tagDefault(array $tag): string + { + $parseStr = ''; + + return $parseStr; + } + + /** + * compare标签解析 + * 用于值的比较 支持 eq neq gt lt egt elt heq nheq 默认是eq + * 格式: {compare name="" type="eq" value="" }content{/compare} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagCompare(array $tag, string $content): string + { + $name = $tag['name']; + $value = $tag['value']; + $type = isset($tag['type']) ? $tag['type'] : 'eq'; // 比较类型 + $name = $this->autoBuildVar($name); + $flag = substr($value, 0, 1); + + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + } else { + $value = '\'' . $value . '\''; + } + + switch ($type) { + case 'equal': + $type = 'eq'; + break; + case 'notequal': + $type = 'neq'; + break; + } + $type = $this->parseCondition(' ' . $type . ' '); + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * range标签解析 + * 如果某个变量存在于某个范围 则输出内容 type= in 表示在范围内 否则表示在范围外 + * 格式: {range name="var|function" value="val" type='in|notin' }content{/range} + * example: {range name="a" value="1,2,3" type='in' }content{/range} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagRange(array $tag, string $content): string + { + $name = $tag['name']; + $value = $tag['value']; + $type = isset($tag['type']) ? $tag['type'] : 'in'; // 比较类型 + + $name = $this->autoBuildVar($name); + $flag = substr($value, 0, 1); + + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + $str = 'is_array(' . $value . ')?' . $value . ':explode(\',\',' . $value . ')'; + } else { + $value = '"' . $value . '"'; + $str = 'explode(\',\',' . $value . ')'; + } + + if ('between' == $type) { + $parseStr = '= $_RANGE_VAR_[0] && ' . $name . '<= $_RANGE_VAR_[1]):?>' . $content . ''; + } elseif ('notbetween' == $type) { + $parseStr = '$_RANGE_VAR_[1]):?>' . $content . ''; + } else { + $fun = ('in' == $type) ? 'in_array' : '!in_array'; + $parseStr = '' . $content . ''; + } + + return $parseStr; + } + + /** + * present标签解析 + * 如果某个变量已经设置 则输出内容 + * 格式: {present name="" }content{/present} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagPresent(array $tag, string $content): string + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * notpresent标签解析 + * 如果某个变量没有设置,则输出内容 + * 格式: {notpresent name="" }content{/notpresent} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagNotpresent(array $tag, string $content): string + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * empty标签解析 + * 如果某个变量为empty 则输出内容 + * 格式: {empty name="" }content{/empty} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagEmpty(array $tag, string $content): string + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = 'isEmpty())): ?>' . $content . ''; + + return $parseStr; + } + + /** + * notempty标签解析 + * 如果某个变量不为empty 则输出内容 + * 格式: {notempty name="" }content{/notempty} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagNotempty(array $tag, string $content): string + { + $name = $tag['name']; + $name = $this->autoBuildVar($name); + $parseStr = 'isEmpty()))): ?>' . $content . ''; + + return $parseStr; + } + + /** + * 判断是否已经定义了该常量 + * {defined name='TXT'}已定义{/defined} + * @access public + * @param array $tag + * @param string $content + * @return string + */ + public function tagDefined(array $tag, string $content): string + { + $name = $tag['name']; + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * 判断是否没有定义了该常量 + * {notdefined name='TXT'}已定义{/notdefined} + * @access public + * @param array $tag + * @param string $content + * @return string + */ + public function tagNotdefined(array $tag, string $content): string + { + $name = $tag['name']; + $parseStr = '' . $content . ''; + + return $parseStr; + } + + /** + * load 标签解析 {load file="/static/js/base.js" /} + * 格式:{load file="/static/css/base.css" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagLoad(array $tag, string $content): string + { + $file = isset($tag['file']) ? $tag['file'] : $tag['href']; + $type = isset($tag['type']) ? strtolower($tag['type']) : ''; + + $parseStr = ''; + $endStr = ''; + + // 判断是否存在加载条件 允许使用函数判断(默认为isset) + if (isset($tag['value'])) { + $name = $tag['value']; + $name = $this->autoBuildVar($name); + $name = 'isset(' . $name . ')'; + $parseStr .= ''; + $endStr = ''; + } + + // 文件方式导入 + $array = explode(',', $file); + + foreach ($array as $val) { + $type = strtolower(substr(strrchr($val, '.'), 1)); + switch ($type) { + case 'js': + $parseStr .= ''; + break; + case 'css': + $parseStr .= ''; + break; + case 'php': + $parseStr .= ''; + break; + } + } + + return $parseStr . $endStr; + } + + /** + * assign标签解析 + * 在模板中给某个变量赋值 支持变量赋值 + * 格式: {assign name="" value="" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagAssign(array $tag, string $content): string + { + $name = $this->autoBuildVar($tag['name']); + $flag = substr($tag['value'], 0, 1); + + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($tag['value']); + } else { + $value = '\'' . $tag['value'] . '\''; + } + + $parseStr = ''; + + return $parseStr; + } + + /** + * define标签解析 + * 在模板中定义常量 支持变量赋值 + * 格式: {define name="" value="" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagDefine(array $tag, string $content): string + { + $name = '\'' . $tag['name'] . '\''; + $flag = substr($tag['value'], 0, 1); + + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($tag['value']); + } else { + $value = '\'' . $tag['value'] . '\''; + } + + $parseStr = ''; + + return $parseStr; + } + + /** + * for标签解析 + * 格式: + * {for start="" end="" comparison="" step="" name=""} + * content + * {/for} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagFor(array $tag, string $content): string + { + //设置默认值 + $start = 0; + $end = 0; + $step = 1; + $comparison = 'lt'; + $name = 'i'; + $rand = rand(); //添加随机数,防止嵌套变量冲突 + + //获取属性 + foreach ($tag as $key => $value) { + $value = trim($value); + $flag = substr($value, 0, 1); + if ('$' == $flag || ':' == $flag) { + $value = $this->autoBuildVar($value); + } + + switch ($key) { + case 'start': + $start = $value; + break; + case 'end': + $end = $value; + break; + case 'step': + $step = $value; + break; + case 'comparison': + $comparison = $value; + break; + case 'name': + $name = $value; + break; + } + } + + $parseStr = 'parseCondition('$' . $name . ' ' . $comparison . ' $__FOR_END_' . $rand . '__') . ';$' . $name . '+=' . $step . '){ ?>'; + $parseStr .= $content; + $parseStr .= ''; + + return $parseStr; + } + + /** + * url函数的tag标签 + * 格式:{url link="模块/控制器/方法" vars="参数" suffix="true或者false 是否带有后缀" domain="true或者false 是否携带域名" /} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagUrl(array $tag, string $content): string + { + $url = isset($tag['link']) ? $tag['link'] : ''; + $vars = isset($tag['vars']) ? $tag['vars'] : ''; + $suffix = isset($tag['suffix']) ? $tag['suffix'] : 'true'; + $domain = isset($tag['domain']) ? $tag['domain'] : 'false'; + + return ''; + } + + /** + * function标签解析 匿名函数,可实现递归 + * 使用: + * {function name="func" vars="$data" call="$list" use="&$a,&$b"} + * {if is_array($data)} + * {foreach $data as $val} + * {~func($val) /} + * {/foreach} + * {else /} + * {$data} + * {/if} + * {/function} + * @access public + * @param array $tag 标签属性 + * @param string $content 标签内容 + * @return string + */ + public function tagFunction(array $tag, string $content): string + { + $name = !empty($tag['name']) ? $tag['name'] : 'func'; + $vars = !empty($tag['vars']) ? $tag['vars'] : ''; + $call = !empty($tag['call']) ? $tag['call'] : ''; + $use = ['&$' . $name]; + + if (!empty($tag['use'])) { + foreach (explode(',', $tag['use']) as $val) { + $use[] = '&' . ltrim(trim($val), '&'); + } + } + + $parseStr = '' . $content . '' : '?>'; + + return $parseStr; + } +} diff --git a/vendor/topthink/think-template/tests/bootstrap.php b/vendor/topthink/think-template/tests/bootstrap.php new file mode 100644 index 0000000..b1e7ece --- /dev/null +++ b/vendor/topthink/think-template/tests/bootstrap.php @@ -0,0 +1,3 @@ + ['attr' => 'time,format', 'close' => 0], //闭合标签,默认为不闭合 + 'open' => ['attr' => 'name,type', 'close' => 1], + + ]; + + /** + * 这是一个闭合标签的简单演示 + */ + public function tagClose($tag) + { + $format = empty($tag['format']) ? 'Y-m-d H:i:s' : $tag['format']; + $time = empty($tag['time']) ? time() : $tag['time']; + $parse = ''; + return $parse; + } + + /** + * 这是一个非闭合标签的简单演示 + */ + public function tagOpen($tag, $content) + { + $type = empty($tag['type']) ? 0 : 1; // 这个type目的是为了区分类型,一般来源是数据库 + $name = $tag['name']; // name是必填项,这里不做判断了 + $parse = ''; + $parse .= '{volist name="__LIST__" id="' . $name . '"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + +} \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/template/extend.html b/vendor/topthink/think-template/tests/template/extend.html new file mode 100644 index 0000000..6a2578f --- /dev/null +++ b/vendor/topthink/think-template/tests/template/extend.html @@ -0,0 +1,2 @@ +{block name="title"}标题{/block} +{block name="main"}主内容{/block} diff --git a/vendor/topthink/think-template/tests/template/fetch.html b/vendor/topthink/think-template/tests/template/fetch.html new file mode 100644 index 0000000..0f0c913 --- /dev/null +++ b/vendor/topthink/think-template/tests/template/fetch.html @@ -0,0 +1 @@ +success \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/template/include.html b/vendor/topthink/think-template/tests/template/include.html new file mode 100644 index 0000000..2996fba --- /dev/null +++ b/vendor/topthink/think-template/tests/template/include.html @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/template/layout.html b/vendor/topthink/think-template/tests/template/layout.html new file mode 100644 index 0000000..fb432d7 --- /dev/null +++ b/vendor/topthink/think-template/tests/template/layout.html @@ -0,0 +1 @@ +start{__CONTENT__}end \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/think/TemplateTest.php b/vendor/topthink/think-template/tests/think/TemplateTest.php new file mode 100644 index 0000000..2f58e2a --- /dev/null +++ b/vendor/topthink/think-template/tests/think/TemplateTest.php @@ -0,0 +1,247 @@ + __DIR__ . '/../template' . DIRECTORY_SEPARATOR, + 'cache_path' => __DIR__ . '/../cache' . DIRECTORY_SEPARATOR, + 'tpl_cache' => false, + 'tpl_replace_string' => ['__STATIC__' => '/static'], + 'taglib_pre_load' => Demo::class, + ]; + return new Template($config); + } + + // 直接渲染 + public function testDisplay() + { + $this->expectOutputString('hello-thinkphp'); + + $template = $this->getTemplate(); + $content = '{$name}-{$email}'; + $template->display($content, ['name' => 'hello', 'email' => 'thinkphp']); + } + + // 渲染文件 + public function testFetch() + { + $this->expectOutputString('success'); + + $template = $this->getTemplate(); + $template->fetch('fetch'); + } + + // 布局 + public function testLayout() + { + $this->expectOutputString('startsuccessend'); + + $template = $this->getTemplate(); + $template->layout('layout'); + $template->fetch('fetch'); + $template->layout(false); + } + + // 扩展解析 + public function testExtend() + { + $this->expectOutputString('test.name'); + + $template = $this->getTemplate(); + $template->extend('$Cms', function (array $vars) { + return '\'' . implode('.', $vars) . '\''; + }); + + $content = '{$Cms.test.name}'; + $template->display($content); + } + + // 变量 + public function testParseVar() + { + $this->expectOutputString('e10adc3949ba59abbe56e057f20f883e'); + + $template = $this->getTemplate(); + $content = '{:md5("123456")}'; + $template->display($content, ['password' => '123456']); + } + + // 变量使用函数 + public function testParseVarFunction() + { + $this->expectOutputString('e10adc3949ba59abbe56e057f20f883e-123456-666456'); + + $template = $this->getTemplate(); + $content = '{$password|md5}-{$password|raw}-{$password|str_replace=123,666,###}'; + $template->display($content, ['password' => '123456']); + } + + // 默认值 + public function testParseDefaultFunction() + { + $this->expectOutputString('test'); + + $template = $this->getTemplate(); + $content = '{$default|default="test"}'; + $template->display($content); + } + + // 系统变量 + public function testParseThinkVar() + { + $this->expectOutputString($_SERVER['PHP_SELF'] . '-' . PHP_VERSION . '-' . PHP_VERSION); + + $template = $this->getTemplate(); + $content = '{$Request.server.PHP_SELF}-{$Think.const.PHP_VERSION}-{$Think.PHP_VERSION}'; + $template->display($content); + } + + // 数组 + public function testParseArrayVar() + { + $this->expectOutputString('thinkphp
    thinkphp'); + + $template = $this->getTemplate(); + $content = '{$data.name}
    {$data["name"]}'; + $template->display($content, ['data' => ['name' => 'thinkphp']]); + } + + // 对象 + public function testParseObjectVar() + { + $this->expectOutputString('a-b-c-d'); + + $object = new class { + public string $a = 'a'; + public const b = 'b'; + + public function c($str) { + return $str; + } + + static public function d($str) { + return $str; + } + }; + + $template = $this->getTemplate(); + $content = '{$data->a}-{$data::b}-{$data->c("c")}-{$data::d("d")}'; + $template->display($content, ['data' => $object]); + } + + // 运算符 + public function testParseVarOperator() + { + $this->expectOutputString('2-0-2-0.5-1-1-1-4'); + + $template = $this->getTemplate(); + $content = '{$a+1}-{$a-1}-{$a*$b}-{$a/$b}-{$a%$b}-{$a++}-{--$b}-{$a+$b+abs(-1)}'; + $template->display($content, ['a' => 1, 'b' => 2]); + } + + // 三元运算符 + public function testParseTernaryOperator() + { + $this->expectOutputString('真-默认值-有值-NO'); + + $template = $this->getTemplate(); + $content = '{$true?"真":"假"}-{$null ?? "默认值"}-{$one ?= "有值"}-{$zero ?: "NO"}'; + $template->display($content, ['null' => null, 'zero' => 0, 'true' => true, 'one' => 1]); + } + + // 单行注释 + public function testParseSimpleNote() + { + $this->expectOutputString('123'); + + $template = $this->getTemplate(); + $content = '123{// 注释内容 }'; + $template->display($content); + } + + // 多行注释 + public function testParseMoreNote() + { + $this->expectOutputString('123'); + + $template = $this->getTemplate(); + $content = "123{/* 这是模板\r\n注释内容*/ }"; + $template->display($content); + } + + // 引用标签 + public function testParseInclude() + { + $this->expectOutputString('include'); + + $template = $this->getTemplate(); + $content = '{include file="include"}'; + $template->display($content); + } + + // 继承标签 + public function testParseExtend() + { + $this->expectOutputString("title\r\n主内容main\r\n"); + + $template = $this->getTemplate(); + $content = "{extend name='extend' /}\r\n{block name='title'}title{/block}\r\n{block name='main'}{__block__}main{/block}"; + $template->display($content); + } + + // 输出替换 + public function testParseReplaceString() + { + $this->expectOutputString("start/staticend"); + + $template = $this->getTemplate(); + $content = "start__STATIC__end"; + $template->display($content); + } + + // 标签扩展 + public function testParseDemoTag() + { + $this->expectOutputString(<<<'HTML' +

    闭合标签

    +2022-12-31 16:00:00
    +

    开放标签

    + 0=>1
    + 1=>3
    + 2=>5
    + 3=>7
    + 4=>9
    +
    + 0=>2
    + 1=>4
    + 2=>6
    + 3=>8
    + 4=>10
    + +HTML); + + $template = $this->getTemplate(); + $content = <<<'HTML' +

    闭合标签

    +{demo:close time='$demo_time'/} +
    +

    开放标签

    +{demo:open name='demo_name'} + {$key}=>{$demo_name}
    +{/demo:open} +
    +{demo:open name='demo_name' type='1'} + {$key}=>{$demo_name}
    +{/demo:open} +HTML; + + $template->display($content, ['demo_time' => 1672502400]); + } +} diff --git a/vendor/topthink/think-trace/LICENSE b/vendor/topthink/think-trace/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/vendor/topthink/think-trace/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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/vendor/topthink/think-trace/README.md b/vendor/topthink/think-trace/README.md new file mode 100644 index 0000000..6ed63ec --- /dev/null +++ b/vendor/topthink/think-trace/README.md @@ -0,0 +1,15 @@ +# think-trace + +用于ThinkPHP6+的页面Trace扩展,支持Html页面和浏览器控制台两种方式输出。 + +## 安装 + +~~~ +composer require topthink/think-trace +~~~ + +## 配置 + +安装后config目录下会自带trace.php配置文件。 + +type参数用于指定trace类型,支持html和console两种方式。 \ No newline at end of file diff --git a/vendor/topthink/think-trace/composer.json b/vendor/topthink/think-trace/composer.json new file mode 100644 index 0000000..e6cd16b --- /dev/null +++ b/vendor/topthink/think-trace/composer.json @@ -0,0 +1,31 @@ +{ + "name": "topthink/think-trace", + "description": "thinkphp debug trace", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=7.1.0", + "topthink/framework": "^6.0|^8.0" + }, + "autoload": { + "psr-4": { + "think\\trace\\": "src" + } + }, + "extra": { + "think":{ + "services":[ + "think\\trace\\Service" + ], + "config":{ + "trace": "src/config.php" + } + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/topthink/think-trace/src/Console.php b/vendor/topthink/think-trace/src/Console.php new file mode 100644 index 0000000..c97d1e0 --- /dev/null +++ b/vendor/topthink/think-trace/src/Console.php @@ -0,0 +1,173 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); +namespace think\trace; + +use think\App; +use think\Response; + +/** + * 浏览器调试输出 + */ +class Console +{ + protected $config = [ + 'tabs' => ['base' => '基本', 'file' => '文件', 'info' => '流程', 'notice|error' => '错误', 'sql' => 'SQL', 'debug|log' => '调试'], + ]; + + // 实例化并传入参数 + public function __construct(array $config = []) + { + $this->config = array_merge($this->config, $config); + } + + /** + * 调试输出接口 + * @access public + * @param Response $response Response对象 + * @param array $log 日志信息 + * @return string|bool + */ + public function output(App $app, Response $response, array $log = []) + { + $request = $app->request; + $contentType = $response->getHeader('Content-Type'); + + if ($request->isJson() || $request->isAjax()) { + return false; + } elseif (!empty($contentType) && strpos($contentType, 'html') === false) { + return false; + } elseif ($response->getCode() == 204) { + return false; + } + + // 获取基本信息 + $runtime = number_format(microtime(true) - $app->getBeginTime(), 10, '.', ''); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + $mem = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2); + + if ($request->host()) { + $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); + } else { + $uri = 'cmd:' . implode(' ', $_SERVER['argv']); + } + + // 页面Trace信息 + $base = [ + '请求信息' => date('Y-m-d H:i:s', $request->time() ?: time()) . ' ' . $uri, + '运行时间' => number_format((float) $runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), + '查询信息' => $app->db->getQueryTimes() . ' queries', + '缓存信息' => $app->cache->getReadTimes() . ' reads,' . $app->cache->getWriteTimes() . ' writes', + ]; + + if (isset($app->session)) { + $base['会话信息'] = 'SESSION_ID=' . $app->session->getId(); + } + + $info = $this->getFileInfo(); + + // 页面Trace信息 + $trace = []; + foreach ($this->config['tabs'] as $name => $title) { + $name = strtolower($name); + switch ($name) { + case 'base': // 基本信息 + $trace[$title] = $base; + break; + case 'file': // 文件信息 + $trace[$title] = $info; + break; + default: // 调试信息 + if (strpos($name, '|')) { + // 多组信息 + $names = explode('|', $name); + $result = []; + foreach ($names as $item) { + $result = array_merge($result, $log[$item] ?? []); + } + $trace[$title] = $result; + } else { + $trace[$title] = $log[$name] ?? ''; + } + } + } + + //输出到控制台 + $lines = ''; + foreach ($trace as $type => $msg) { + $lines .= $this->console($type, empty($msg) ? [] : $msg); + } + $js = << +{$lines} + +JS; + return $js; + } + + protected function console(string $type, $msg) + { + $type = strtolower($type); + $trace_tabs = array_values($this->config['tabs']); + $line = []; + $line[] = ($type == $trace_tabs[0] || '调试' == $type || '错误' == $type) + ? "console.group('{$type}');" + : "console.groupCollapsed('{$type}');"; + + foreach ((array) $msg as $key => $m) { + switch ($type) { + case '调试': + $var_type = gettype($m); + if (in_array($var_type, ['array', 'string'])) { + $line[] = "console.log(" . json_encode($m) . ");"; + } else { + $line[] = "console.log(" . json_encode(var_export($m, true)) . ");"; + } + break; + case '错误': + $msg = str_replace("\n", '\n', addslashes(is_scalar($m) ? $m : json_encode($m))); + $style = 'color:#F4006B;font-size:14px;'; + $line[] = "console.error(\"%c{$msg}\", \"{$style}\");"; + break; + case 'sql': + $msg = str_replace("\n", '\n', addslashes($m)); + $style = "color:#009bb4;"; + $line[] = "console.log(\"%c{$msg}\", \"{$style}\");"; + break; + default: + $m = is_string($key) ? $key . ' ' . $m : $key + 1 . ' ' . $m; + $msg = json_encode($m); + $line[] = "console.log({$msg});"; + break; + } + } + $line[] = "console.groupEnd();"; + return implode(PHP_EOL, $line); + } + + /** + * 获取文件加载信息 + * @access protected + * @return integer|array + */ + protected function getFileInfo() + { + $files = get_included_files(); + $info = []; + + foreach ($files as $key => $file) { + $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; + } + + return $info; + } +} diff --git a/vendor/topthink/think-trace/src/Html.php b/vendor/topthink/think-trace/src/Html.php new file mode 100644 index 0000000..35b3146 --- /dev/null +++ b/vendor/topthink/think-trace/src/Html.php @@ -0,0 +1,126 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); +namespace think\trace; + +use think\App; +use think\Response; + +/** + * 页面Trace调试 + */ +class Html +{ + protected $config = [ + 'file' => '', + 'tabs' => ['base' => '基本', 'file' => '文件', 'info' => '流程', 'notice|error' => '错误', 'sql' => 'SQL', 'debug|log' => '调试'], + ]; + + // 实例化并传入参数 + public function __construct(array $config = []) + { + $this->config = array_merge($this->config, $config); + } + + /** + * 调试输出接口 + * @access public + * @param App $app 应用实例 + * @param Response $response Response对象 + * @param array $log 日志信息 + * @return bool|string + */ + public function output(App $app, Response $response, array $log = []) + { + $request = $app->request; + $contentType = $response->getHeader('Content-Type'); + + if ($request->isJson() || $request->isAjax()) { + return false; + } elseif (!empty($contentType) && strpos($contentType, 'html') === false) { + return false; + } elseif ($response->getCode() == 204) { + return false; + } + + // 获取基本信息 + $runtime = number_format(microtime(true) - $app->getBeginTime(), 10, '.', ''); + $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; + $mem = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2); + + // 页面Trace信息 + if ($request->host()) { + $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); + } else { + $uri = 'cmd:' . implode(' ', $_SERVER['argv']); + } + + $base = [ + '请求信息' => date('Y-m-d H:i:s', $request->time() ?: time()) . ' ' . $uri, + '运行时间' => number_format((float) $runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), + '查询信息' => $app->db->getQueryTimes() . ' queries', + '缓存信息' => $app->cache->getReadTimes() . ' reads,' . $app->cache->getWriteTimes() . ' writes', + ]; + + if (isset($app->session)) { + $base['会话信息'] = 'SESSION_ID=' . $app->session->getId(); + } + + $info = $this->getFileInfo(); + + // 页面Trace信息 + $trace = []; + foreach ($this->config['tabs'] as $name => $title) { + $name = strtolower($name); + switch ($name) { + case 'base': // 基本信息 + $trace[$title] = $base; + break; + case 'file': // 文件信息 + $trace[$title] = $info; + break; + default: // 调试信息 + if (strpos($name, '|')) { + // 多组信息 + $names = explode('|', $name); + $result = []; + foreach ($names as $item) { + $result = array_merge($result, $log[$item] ?? []); + } + $trace[$title] = $result; + } else { + $trace[$title] = $log[$name] ?? ''; + } + } + } + // 调用Trace页面模板 + ob_start(); + include $this->config['file'] ?: __DIR__ . '/tpl/page_trace.tpl'; + return ob_get_clean(); + } + + /** + * 获取文件加载信息 + * @access protected + * @return integer|array + */ + protected function getFileInfo() + { + $files = get_included_files(); + $info = []; + + foreach ($files as $key => $file) { + $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; + } + + return $info; + } +} diff --git a/vendor/topthink/think-trace/src/Service.php b/vendor/topthink/think-trace/src/Service.php new file mode 100644 index 0000000..3e78ecc --- /dev/null +++ b/vendor/topthink/think-trace/src/Service.php @@ -0,0 +1,21 @@ + +// +---------------------------------------------------------------------- +namespace think\trace; + +use think\Service as BaseService; + +class Service extends BaseService +{ + public function register() + { + $this->app->middleware->add(TraceDebug::class); + } +} diff --git a/vendor/topthink/think-trace/src/TraceDebug.php b/vendor/topthink/think-trace/src/TraceDebug.php new file mode 100644 index 0000000..5ed9cbf --- /dev/null +++ b/vendor/topthink/think-trace/src/TraceDebug.php @@ -0,0 +1,109 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\trace; + +use Closure; +use think\App; +use think\Config; +use think\event\LogWrite; +use think\Request; +use think\Response; +use think\response\Redirect; + +/** + * 页面Trace中间件 + */ +class TraceDebug +{ + + /** + * Trace日志 + * @var array + */ + protected $log = []; + + /** + * 配置参数 + * @var array + */ + protected $config = []; + + /** @var App */ + protected $app; + + public function __construct(App $app, Config $config) + { + $this->app = $app; + $this->config = $config->get('trace'); + } + + /** + * 页面Trace调试 + * @access public + * @param Request $request + * @param Closure $next + * @return void + */ + public function handle($request, Closure $next) + { + $debug = $this->app->isDebug(); + + // 注册日志监听 + if ($debug) { + $this->log = []; + $this->app->event->listen(LogWrite::class, function ($event) { + if (empty($this->config['channel']) || $this->config['channel'] == $event->channel) { + $this->log = array_merge_recursive($this->log, $event->log); + } + }); + } + + $response = $next($request); + + // Trace调试注入 + if ($debug) { + $data = $response->getContent(); + $this->traceDebug($response, $data); + $response->content($data); + } + + return $response; + } + + public function traceDebug(Response $response, &$content) + { + $config = $this->config; + $type = $config['type'] ?? 'Html'; + + unset($config['type']); + + $trace = App::factory($type, '\\think\\trace\\', $config); + + if ($response instanceof Redirect) { + //TODO 记录 + } else { + $log = $this->app->log->getLog($config['channel'] ?? ''); + $log = array_merge_recursive($this->log, $log); + $output = $trace->output($this->app, $response, $log); + if (is_string($output)) { + // trace调试信息注入 + $pos = strripos($content, ''); + if (false !== $pos) { + $content = substr($content, 0, $pos) . $output . substr($content, $pos); + } else { + $content = $content . $output; + } + } + } + } +} diff --git a/vendor/topthink/think-trace/src/config.php b/vendor/topthink/think-trace/src/config.php new file mode 100644 index 0000000..fad2392 --- /dev/null +++ b/vendor/topthink/think-trace/src/config.php @@ -0,0 +1,10 @@ + 'Html', + // 读取的日志通道名 + 'channel' => '', +]; diff --git a/vendor/topthink/think-trace/src/tpl/page_trace.tpl b/vendor/topthink/think-trace/src/tpl/page_trace.tpl new file mode 100644 index 0000000..6b1b9a1 --- /dev/null +++ b/vendor/topthink/think-trace/src/tpl/page_trace.tpl @@ -0,0 +1,71 @@ +
    + + +
    +
    +
    + +
    + + diff --git a/vendor/topthink/think-validate/LICENSE b/vendor/topthink/think-validate/LICENSE new file mode 100644 index 0000000..3de04cd --- /dev/null +++ b/vendor/topthink/think-validate/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 thinkphp.cn + + 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/vendor/topthink/think-validate/README.md b/vendor/topthink/think-validate/README.md new file mode 100644 index 0000000..b9c2e92 --- /dev/null +++ b/vendor/topthink/think-validate/README.md @@ -0,0 +1,82 @@ +# think-validate + +基于PHP8.0+ 的Validate实现 + +## 主要特性 +- 基于PHP8和强类型实现 +- 内置丰富的验证规则 +- 支持验证器类、数组和链式方法定义验证规则 +- 支持验证场景和验证分组 +- 支持独立数据验证 +- 支持枚举验证 +- 支持批量验证 +- 支持抛出异常 + + +## 安装 +~~~ +composer require topthink/think-validate +~~~ + +## 用法 +~~~php +use think\facade\Validate; + +$validate = Validate::rule([ + 'name' => 'require|max:25', + 'email' => 'email' +]); + +$data = [ + 'name' => 'thinkphp', + 'email' => 'thinkphp@qq.com' +]; + +if (!$validate->check($data)) { + var_dump($validate->getError()); +} +~~~ + +支持创建验证器进行数据验证 +~~~php + 'require|max:25', + 'age' => 'number|between:1,120', + 'email' => 'email', + ]; + + protected $message = [ + 'name.require' => '名称必须', + 'name.max' => '名称最多不能超过25个字符', + 'age.number' => '年龄必须是数字', + 'age.between' => '年龄只能在1-120之间', + 'email' => '邮箱格式错误', + ]; + +} +~~~ + +验证器调用代码如下: +~~~php +$data = [ + 'name' => 'thinkphp', + 'email' => 'thinkphp@qq.com', +]; + +$validate = new \app\index\validate\User; + +if (!$validate->check($data)) { + var_dump($validate->getError()); +} +~~~ + +## 文档 + +详细使用请参考 [ThinkValidate开发指南](https://doc.thinkphp.cn/@think-validate) \ No newline at end of file diff --git a/vendor/topthink/think-validate/composer.json b/vendor/topthink/think-validate/composer.json new file mode 100644 index 0000000..f30a51e --- /dev/null +++ b/vendor/topthink/think-validate/composer.json @@ -0,0 +1,23 @@ +{ + "name": "topthink/think-validate", + "description": "think validate", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=8.0", + "topthink/think-container":">=3.0" + }, + "autoload": { + "psr-4": { + "think\\": "src" + }, + "files": [ + "src/helper.php" + ] + } +} \ No newline at end of file diff --git a/vendor/topthink/think-validate/src/Validate.php b/vendor/topthink/think-validate/src/Validate.php new file mode 100644 index 0000000..e4b5069 --- /dev/null +++ b/vendor/topthink/think-validate/src/Validate.php @@ -0,0 +1,2197 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think; + +use BackedEnum; +use Closure; +use think\contract\Enumable; +use think\exception\ValidateException; +use think\helper\Arr; +use think\helper\Str; +use think\validate\ValidateRule; +use think\validate\ValidateRuleSet; +use UnitEnum; + +/** + * 数据验证类 + * @package think + */ +class Validate +{ + /** + * 自定义验证类型 + * @var array + */ + protected $type = []; + + /** + * 验证类型别名 + * @var array + */ + protected $map = [ + '>' => 'gt', '>=' => 'egt', '<' => 'lt', '<=' => 'elt', '=' => 'eq', 'same' => 'eq', '<>' => 'neq', + ]; + + /** + * 当前验证规则 + * @var array + */ + protected $rule = []; + + /** + * 当前验证规则集 + * @var array + */ + protected $ruleSet = []; + + /** + * 当前验证规则组 + * @var array + */ + protected $group = []; + + /** + * 验证规则别名 + * @var array + */ + protected $alias = []; + + /** + * 验证提示信息 + * @var array + */ + protected $message = []; + + /** + * 验证字段描述 + * @var array + */ + protected $field = []; + + /** + * 默认规则提示 + * @var array + */ + protected $typeMsg = [ + 'require' => ':attribute require', + 'must' => ':attribute must', + 'number' => ':attribute must be numeric', + 'integer' => ':attribute must be integer', + 'float' => ':attribute must be float', + 'string' => ':attribute must be string', + 'boolean' => ':attribute must be bool', + 'enum' => ':attribute must be :rule enum', + 'email' => ':attribute not a valid email address', + 'mobile' => ':attribute not a valid mobile', + 'array' => ':attribute must be a array', + 'accepted' => ':attribute must be yes,on,true or 1', + 'acceptedIf' => ':attribute must be yes,on,true or 1', + 'declined' => ':attribute must be no,off,false or 0', + 'declinedIf' => ':attribute must be no,off,false or 0', + 'date' => ':attribute not a valid datetime', + 'file' => ':attribute not a valid file', + 'image' => ':attribute not a valid image', + 'alpha' => ':attribute must be alpha', + 'alphaNum' => ':attribute must be alpha-numeric', + 'alphaDash' => ':attribute must be alpha-numeric, dash, underscore', + 'activeUrl' => ':attribute not a valid domain or ip', + 'chs' => ':attribute must be chinese', + 'chsAlpha' => ':attribute must be chinese or alpha', + 'chsAlphaNum' => ':attribute must be chinese,alpha-numeric', + 'chsDash' => ':attribute must be chinese,alpha-numeric,underscore, dash', + 'url' => ':attribute not a valid url', + 'ip' => ':attribute not a valid ip', + 'dateFormat' => ':attribute must be dateFormat of :rule', + 'in' => ':attribute must be in :rule', + 'notIn' => ':attribute be notin :rule', + 'between' => ':attribute must between :1 - :2', + 'notBetween' => ':attribute not between :1 - :2', + 'length' => 'size of :attribute must be :rule', + 'max' => 'max size of :attribute must be :rule', + 'min' => 'min size of :attribute must be :rule', + 'after' => ':attribute cannot be less than :rule', + 'before' => ':attribute cannot exceed :rule', + 'expire' => ':attribute not within :rule', + 'allowIp' => 'access IP is not allowed', + 'denyIp' => 'access IP denied', + 'confirm' => ':attribute out of accord with :2', + 'different' => ':attribute cannot be same with :2', + 'egt' => ':attribute must greater than or equal :rule', + 'gt' => ':attribute must greater than :rule', + 'elt' => ':attribute must less than or equal :rule', + 'lt' => ':attribute must less than :rule', + 'eq' => ':attribute must equal :rule', + 'neq' => ':attribute must not be equal to :rule', + 'unique' => ':attribute has exists', + 'regex' => ':attribute not conform to the rules', + 'method' => 'invalid Request method', + 'token' => 'invalid token', + 'fileSize' => 'filesize not match', + 'fileExt' => 'extensions to upload is not allowed', + 'fileMime' => 'mimetype to upload is not allowed', + 'startWith' => ':attribute must start with :rule', + 'endWith' => ':attribute must end with :rule', + 'contain' => ':attribute must contain :rule', + 'multipleOf' => ':attribute must multiple :rule', + ]; + + protected $typeMsgZh = [ + 'require' => ':attribute不能为空', + 'must' => ':attribute必须', + 'number' => ':attribute必须是数字', + 'integer' => ':attribute必须是整数', + 'float' => ':attribute必须是浮点数', + 'string' => ':attribute必须是字符串', + 'enum' => ':attribute必须是有效的 :rule 枚举', + 'startWith' => ':attribute必须以 :rule 开头', + 'endWith' => ':attribute必须以 :rule 结尾', + 'contain' => ':attribute必须包含 :rule', + 'boolean' => ':attribute必须是布尔值', + 'email' => ':attribute格式不符', + 'mobile' => ':attribute格式不符', + 'array' => ':attribute必须是数组', + 'accepted' => ':attribute必须是yes、on、true或者1', + 'acceptedIf' => ':attribute必须是yes、on、true或者1', + 'declined' => ':attribute必须是no、off、false或者0', + 'declinedIf' => ':attribute必须是no、off、false或者0', + 'date' => ':attribute不是一个有效的日期或时间格式', + 'file' => ':attribute不是有效的上传文件', + 'image' => ':attribute不是有效的图像文件', + 'alpha' => ':attribute只能是字母', + 'alphaNum' => ':attribute只能是字母和数字', + 'alphaDash' => ':attribute只能是字母、数字和下划线_及破折号-', + 'activeUrl' => ':attribute不是有效的域名或者IP', + 'chs' => ':attribute只能是汉字', + 'chsAlpha' => ':attribute只能是汉字、字母', + 'chsAlphaNum' => ':attribute只能是汉字、字母和数字', + 'chsDash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', + 'url' => ':attribute不是有效的URL地址', + 'ip' => ':attribute不是有效的IP地址', + 'dateFormat' => ':attribute必须使用日期格式 :rule', + 'in' => ':attribute必须在 :rule 范围内', + 'notIn' => ':attribute不能在 :rule 范围内', + 'between' => ':attribute只能在 :1 - :2 之间', + 'notBetween' => ':attribute不能在 :1 - :2 之间', + 'length' => ':attribute长度不符合要求 :rule', + 'max' => ':attribute长度不能超过 :rule', + 'min' => ':attribute长度不能小于 :rule', + 'after' => ':attribute日期不能小于 :rule', + 'before' => ':attribute日期不能超过 :rule', + 'expire' => '不在有效期内 :rule', + 'allowIp' => '不允许的IP访问', + 'denyIp' => '禁止的IP访问', + 'confirm' => ':attribute和确认字段:2不一致', + 'different' => ':attribute和比较字段:2不能相同', + 'egt' => ':attribute必须大于等于 :rule', + 'gt' => ':attribute必须大于 :rule', + 'elt' => ':attribute必须小于等于 :rule', + 'lt' => ':attribute必须小于 :rule', + 'eq' => ':attribute必须等于 :rule', + 'neq' => ':attribute不能等于 :rule', + 'unique' => ':attribute已存在', + 'regex' => ':attribute不符合指定规则', + 'multipleOf' => ':attribute必须是 :rule 的倍数', + 'fileSize' => '文件大小不符', + 'fileExt' => '文件后缀不允许', + 'fileMime' => '文件类型不允许', + 'method' => '无效的请求类型', + 'token' => '令牌数据无效', + ]; + + /** + * 当前验证场景 + * @var string + */ + protected $currentScene; + + /** + * 内置正则验证规则 + * @var array + */ + protected $defaultRegex = [ + 'alpha' => '/^[A-Za-z]+$/', + 'alphaNum' => '/^[A-Za-z0-9]+$/', + 'alphaDash' => '/^[A-Za-z0-9\-\_]+$/', + 'chs' => '/^[\p{Han}]+$/u', + 'chsAlpha' => '/^[\p{Han}a-zA-Z]+$/u', + 'chsAlphaNum' => '/^[\p{Han}a-zA-Z0-9]+$/u', + 'chsDash' => '/^[\p{Han}a-zA-Z0-9\_\-]+$/u', + 'mobile' => '/^1[3-9]\d{9}$/', + 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', + 'zip' => '/\d{6}/', + ]; + + /** + * Filter_var 规则 + * @var array + */ + protected $filter = [ + 'email' => FILTER_VALIDATE_EMAIL, + 'ip' => [FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6], + 'integer' => FILTER_VALIDATE_INT, + 'url' => FILTER_VALIDATE_URL, + 'macAddr' => FILTER_VALIDATE_MAC, + 'float' => FILTER_VALIDATE_FLOAT, + ]; + + /** + * 验证场景定义 + * @var array + */ + protected $scene = []; + + /** + * 验证失败错误信息 + * @var string|array + */ + protected $error = []; + + /** + * 是否批量验证 + * @var bool + */ + protected $batch = false; + + /** + * 验证失败是否抛出异常 + * @var bool + */ + protected $failException = false; + + /** + * 必须验证的规则 + * @var array + */ + protected $must = []; + + /** + * 场景需要验证的规则 + * @var array + */ + protected $only = []; + + /** + * 场景需要移除的验证规则 + * @var array + */ + protected $remove = []; + + /** + * 场景需要追加的验证规则 + * @var array + */ + protected $append = []; + + /** + * 场景需要覆盖的验证规则 + * @var array + */ + protected $replace = []; + + /** + * 验证正则定义 + * @var array + */ + protected $regex = []; + + /** + * Db对象 + * @var Db + */ + protected $db; + + /** + * 语言对象 + * @var Lang + */ + protected $lang; + + /** + * 请求对象 + * @var Request + */ + protected $request; + + /** + * @var Closure[] + */ + protected static $maker = []; + + /** + * 构造方法 + */ + public function __construct() + { + if (!empty(static::$maker)) { + foreach (static::$maker as $maker) { + call_user_func($maker, $this); + } + } + } + + /** + * 设置服务注入 + * @param Closure $maker + * @return void + */ + public static function maker(Closure $maker) + { + static::$maker[] = $maker; + } + + /** + * 设置Lang对象 + * @param Lang $lang Lang对象 + * @return void + */ + public function setLang($lang) + { + $this->lang = $lang; + } + + /** + * 使用中文提示 + * @return $this + */ + public function useZh() + { + $this->typeMsg = array_merge($this->typeMsg, $this->typeMsgZh); + return $this; + } + + /** + * 设置Db对象 + * @param Db $db Db对象 + * @return void + */ + public function setDb($db) + { + $this->db = $db; + } + + /** + * 设置Request对象 + * @param Request $request Request对象 + * @return void + */ + public function setRequest($request) + { + $this->request = $request; + } + + /** + * 添加字段验证规则 + * @param string|array $name 字段名称或者规则数组 + * @param mixed $rule 验证规则或者字段描述信息 + * @param string|array $msg 错误信息 + * @return $this + */ + public function rule(string | array $name, $rule = '', string | array $msg = []) + { + if (is_array($name)) { + $this->rule = $name + $this->rule; + if (is_array($rule)) { + $this->field = array_merge($this->field, $rule); + } + if (!empty($msg) && is_array($msg)) { + $this->message($msg); + } + } else { + $this->rule[$name] = $rule; + if (!empty($msg)) { + $this->message[$name] = $msg; + } + } + + return $this; + } + + /** + * 获取所有验证规则 + * @return array + */ + public function getRule(): array + { + return $this->rule; + } + + /** + * 添加验证规则别名 + * @param string|array $name 验证规则别名或者别名数组 + * @param mixed $rule 验证规则 + * @return $this + */ + public function alias(string | array $name, $rule = '') + { + if (is_array($name)) { + $this->alias = $name + $this->alias; + if (is_array($rule)) { + $this->field = array_merge($this->field, $rule); + } + } else { + $this->alias[$name] = $rule; + } + + return $this; + } + + /** + * 添加验证规则组 支持闭包或数组 每个分组的验证彼此独立 + * group('group',function($validate) { + * return $validate->rule('name','rule...'); + * }) + * @param string $name 分组名 + * @param array|Closure $rules 验证规则 + * @return $this + */ + public function group(string $name, array | Closure $rules) + { + $this->group[$name] = $rules; + + return $this; + } + + /** + * 添加验证规则集 支持闭包或数组 + * @param string $name 分组名 + * @param array|Closure $rules 验证规则 + * @param array $msg 错误信息 + * @return ValidateRuleSet + */ + public function ruleSet(string $name, array | Closure $rules, array $msg = []) + { + $this->rule[$name . '.*'] = ValidateRuleSet::rules($rules, $msg); + + return $this; + } + + /** + * 注册验证(类型)规则 + * @param string $type 验证规则类型 + * @param callable $callback callback方法(或闭包) + * @param string $message 验证失败提示信息 + * @return $this + */ + public function extend(string $type, callable $callback, ?string $message = null) + { + $this->type[$type] = $callback; + + if ($message) { + $this->typeMsg[$type] = $message; + } + + return $this; + } + + /** + * 设置验证规则的默认提示信息 + * @param string|array $type 验证规则类型名称或者数组 + * @param string $msg 验证提示信息 + * @return void + */ + public function setTypeMsg(string | array $type, ?string $msg = null): void + { + if (is_array($type)) { + $this->typeMsg = array_merge($this->typeMsg, $type); + } else { + $this->typeMsg[$type] = $msg; + } + } + + /** + * 设置提示信息 + * @param array $message 错误信息 + * @return $this + */ + public function message(array $message) + { + $this->message = array_merge($this->message, $message); + + return $this; + } + + /** + * 获取提示信息 + * @return array + */ + public function getMessage(): array + { + return $this->message; + } + + /** + * 设置验证场景或直接指定需要验证的字段 + * @param string|array $name 场景名 + * @return $this + */ + public function scene(string | array $name) + { + if (is_array($name)) { + $this->only = $name; + } else { + // 设置当前场景 + $this->currentScene = $name; + } + + return $this; + } + + /** + * 判断是否存在某个验证场景 + * @param string $name 场景名 + * @return bool + */ + public function hasScene(string $name): bool + { + return isset($this->scene[$name]) || method_exists($this, 'scene' . Str::studly($name)); + } + + /** + * 设置批量验证 + * @param bool $batch 是否批量验证 + * @return $this + */ + public function batch(bool $batch = true) + { + $this->batch = $batch; + + return $this; + } + + /** + * 设置验证失败后是否抛出异常 + * @param bool $fail 是否抛出异常 + * @return $this + */ + public function failException(bool $fail = true) + { + $this->failException = $fail; + + return $this; + } + + /** + * 指定需要验证的字段列表 + * @param array $fields 字段名 + * @return $this + */ + public function only(array $fields) + { + $this->only = $fields; + + return $this; + } + + /** + * 指定需要覆盖的字段验证规则 + * @param string $field 字段名 + * @param mixed $rules 验证规则 + * @return $this + */ + public function replace(string $field, $rules) + { + $this->replace[$field] = $rules; + + return $this; + } + + /** + * 移除某个字段的验证规则 + * @param string|array $field 字段名 + * @param mixed $rule 验证规则 true 移除所有规则 + * @return $this + */ + public function remove(string | array $field, $rule = null) + { + if (is_array($field)) { + foreach ($field as $key => $rule) { + if (is_int($key)) { + $this->remove($rule); + } else { + $this->remove($key, $rule); + } + } + } else { + if (is_string($rule)) { + $rule = explode('|', $rule); + } + + $this->remove[$field] = $rule; + } + + return $this; + } + + /** + * 追加某个字段的验证规则 + * @param string|array $field 字段名 + * @param mixed $rule 验证规则 + * @return $this + */ + public function append(string | array $field, $rule = null) + { + if (is_array($field)) { + foreach ($field as $key => $rule) { + $this->append($key, $rule); + } + } else { + if (is_string($rule)) { + $rule = explode('|', $rule); + } + + $this->append[$field] = $rule; + } + + return $this; + } + + /** + * 返回定义的验证规则 + * @return mixed + */ + protected function rules() + { + return $this->rule; + } + + /** + * 获取当前的验证规则 + * @return array + */ + public function getRules(): array + { + return $this->rule; + } + + /** + * 数据自动验证 + * @param array $data 数据 + * @param array|string $rules 验证规则 + * @return bool + */ + public function check(array $data, array | string $rules = []): bool + { + $this->error = []; + + if (empty($rules)) { + // 读取验证规则 + $rules = $this->rules(); + } elseif (is_string($rules)) { + $rules = $this->getGroupRules($rules); + // 分组独立检测 + if ($rules instanceof Closure) { + return $rules(new self()) + ->alias($this->alias) + ->batch($this->batch) + ->failException($this->failException) + ->check($data); + } + } + + if ($rules instanceof Validate) { + $rules = $rules->getRules(); + } + + if ($this->currentScene) { + $this->getScene($this->currentScene); + } + + foreach ($this->append as $key => $rule) { + if (!isset($rules[$key])) { + $rules[$key] = $rule; + unset($this->append[$key]); + } + } + + foreach ($rules as $key => $rule) { + if (str_contains($key, '|')) { + // 字段|描述 用于指定属性名称 + [$key, $title] = explode('|', $key); + } else { + $title = $this->field[$key] ?? $key; + } + + // 场景检测 + if (!empty($this->only) && (!in_array($key, $this->only) && !array_key_exists($key, $this->only))) { + continue; + } + + // 数据验证 + $result = $this->checkItems($key, $rule, $data, $title); + if (false === $result) { + return false; + } + } + + if (!empty($this->error)) { + if ($this->failException) { + throw new ValidateException($this->error); + } + return false; + } + + return true; + } + + /** + * 返回经过验证的数据,只包含验证规则中的数据 + * @param array $data + * @param array|string $rules + * @return array + */ + public function checked(array $data, array | string $rules = []): array + { + $checkRes = $this->check($data, $rules); + + if (!$checkRes) { + throw new ValidateException($this->error); + } + + $results = []; + $missingValue = Str::random(10); + + foreach (array_keys($this->getRules()) as $key) { + if (str_contains($key, '|')) { + [$key] = explode('|', $key); + } + $value = data_get($data, $key, $missingValue); + + if ($value !== $missingValue) { + Arr::set($results, $key, $value); + } + } + + return $results; + } + + /** + * 验证字段规则 + * @param string $key 字段名 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @param string $title 字段描述 + * @return bool + */ + protected function checkItems($key, $rule, $data, $title): bool + { + if ($rule instanceof ValidateRuleSet) { + // 验证集 + $values = $this->getDataSet($data, $key); + if (empty($values)) { + return true; + } + $items = $rule->getRules(); + if ($items instanceof Closure) { + // 获取验证集的规则 + $items = $items(new self())->getRule(); + } + // 验证集的错误信息 + foreach ($rule->getMessage() as $name => $message) { + $this->message[$key . '.' . $name] = $message; + } + } else { + $items = [$rule]; + } + + foreach ($items as $k => $item) { + $name = is_string($k) ? $key . '.' . $k : $key; + if (str_contains($name, '|')) { + // 字段|描述 用于指定属性名称 + [$name, $title] = explode('|', $name); + } + + $values = $this->getDataSet($data, $name); + if (empty($values)) { + $values[$name] = null; + } + + foreach ($values as $value) { + $result = $this->checkItem($name, $value, $item, $data, $title); + if (true !== $result) { + // 验证失败 记录错误信息 + if (false === $result) { + $result = $this->getRuleMsg($name, $title, '', $item); + } + + $this->error[$name] = $result; + if ($this->batch) { + // 批量验证 + } elseif ($this->failException) { + throw new ValidateException($result, $name); + } else { + return false; + } + } + } + } + return true; + } + + /** + * 根据验证规则验证数据 + * @param mixed $value 字段值 + * @param mixed $rules 验证规则 + * @return bool + */ + public function checkRule($value, $rules): bool + { + if ($rules instanceof Closure) { + $result = call_user_func_array($rules, [$value]); + return is_bool($result) ? $result : false; + } + + if ($rules instanceof ValidateRule) { + $rules = $rules->getRule(); + } elseif (is_string($rules)) { + $rules = explode('|', $rules); + } + + foreach ($rules as $key => $rule) { + if ($rule instanceof Closure) { + $result = call_user_func_array($rule, [$value]); + } elseif (is_subclass_of($rule, UnitEnum::class) || is_subclass_of($rule, Enumable::class)) { + $result = $this->enum($value, $rule); + } else { + // 判断验证类型 + [$type, $rule, $callback] = $this->getValidateType($key, $rule); + + $result = call_user_func_array($callback, [$value, $rule]); + } + + if (true !== $result) { + return false; + } + } + + return true; + } + + /** + * 验证单个字段规则 + * @param string $field 字段名 + * @param mixed $value 字段值 + * @param mixed $rules 验证规则 + * @param array $data 数据 + * @param string $title 字段描述 + * @param array $msg 提示信息 + * @return mixed + */ + protected function checkItem(string $field, $value, $rules, $data, string $title = '', array $msg = []): mixed + { + if ($rules instanceof ValidateRuleSet) { + return $this->checkItems($field, $rules, $data, $title); + } + + if ($rules instanceof Closure) { + return call_user_func_array($rules, [$value, $data]); + } + + if ($rules instanceof ValidateRule) { + $title = $rules->getTitle() ?: $title; + $msg = $rules->getMsg(); + $rules = $rules->getRule(); + } elseif (is_string($rules)) { + // 检查验证规则别名 + // 'alias' => require|in:a,b,c|... 或者 ['require','in'=>'a,b,c',...] + $rules = $this->alias[$rules] ?? $rules; + } + + if (isset($this->remove[$field]) && true === $this->remove[$field] && empty($this->append[$field])) { + // 字段已经移除 无需验证 + return true; + } + + if (isset($this->replace[$field])) { + $rules = $this->replace[$field]; + } elseif (isset($this->only[$field])) { + $rules = $this->only[$field]; + } + + // 统一解析为数组规则验证 require|in:a,b,c|... 或者 ['require','in'=>'a,b,c',...] + if (is_string($rules)) { + $rules = explode('|', $rules); + } + + if (isset($this->append[$field])) { + // 追加额外的验证规则 + $rules = array_unique(array_merge($rules, $this->append[$field]), SORT_REGULAR); + unset($this->append[$field]); + } + + if (empty($rules)) { + return true; + } + + $i = 0; + foreach ($rules as $key => $rule) { + if ($rule instanceof Closure) { + $result = call_user_func_array($rule, [$value, $data]); + $type = is_numeric($key) ? '' : $key; + } elseif (is_subclass_of($rule, UnitEnum::class) || is_subclass_of($rule, Enumable::class)) { + $result = $this->enum($value, $rule); + $type = is_numeric($key) ? '' : $key; + } else { + // 判断验证类型 + [$type, $rule, $callback] = $this->getValidateType($key, $rule); + + if (isset($this->append[$field]) && in_array($type, $this->append[$field])) { + } elseif (isset($this->remove[$field]) && in_array($type, $this->remove[$field])) { + // 规则已经移除 + $i++; + continue; + } + + if ('must' == $type || str_starts_with($type, 'require') || in_array($field, $this->must) || (!is_null($value) && '' !== $value)) { + $result = call_user_func_array($callback, [$value, $rule, $data, $field, $title]); + } else { + $result = true; + } + } + + if (false === $result) { + // 验证失败 返回错误信息 + if (!empty($msg[$i])) { + $message = $msg[$i]; + if (is_string($message) && str_starts_with($message, '{%')) { + $message = $this->lang->get(substr($message, 2, -1)); + } + } else { + $message = $this->getRuleMsg($field, $title, $type, $rule); + } + + return $message; + } elseif (true !== $result) { + // 返回自定义错误信息 + return $this->parseUserErrorMessage($result, $title, $rule); + } + $i++; + } + + return $result ?? true; + } + + protected function parseUserErrorMessage($message, $title, $rule) + { + if (is_string($message) && str_contains($message, ':')) { + $message = str_replace(':attribute', $title, $message); + + if (str_contains($message, ':rule') && is_scalar($rule)) { + $message = str_replace(':rule', (string) $rule, $message); + } + } + + return $message; + } + + /** + * 获取当前验证类型及规则 + * @param mixed $key + * @param mixed $rule + * @return array + */ + protected function getValidateType($key, $rule): array + { + // 判断验证类型 + $hasParam = true; + if (!is_numeric($key)) { + $type = $key; + } elseif (str_contains($rule, ':')) { + [$type, $rule] = explode(':', $rule, 2); + } else { + $type = $rule; + $hasParam = false; + } + + // 验证类型别名 + $type = $this->map[$type] ?? $type; + + if (isset($this->type[$type])) { + // 自定义验证 + $call = $this->type[$type]; + } else { + $method = Str::camel($type); + if (method_exists($this, $method)) { + $call = [$this, $method]; + $rule = $hasParam ? $rule : ''; + } else { + $call = [$this, 'is']; + } + } + + return [$type, $rule, $call]; + } + + /** + * 验证是否和某个字段的值一致 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @param string $field 字段名 + * @return bool + */ + public function confirm($value, $rule, array $data = [], string $field = ''): bool + { + if ('' == $rule) { + if (str_contains($field, '_confirm')) { + $rule = strstr($field, '_confirm', true); + } else { + $rule = $field . '_confirm'; + } + } + + return $this->getDataValue($data, $rule) === $value; + } + + /** + * 验证是否和某个字段的值是否不同 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function different($value, $rule, array $data = []): bool + { + return $this->getDataValue($data, $rule) != $value; + } + + /** + * 验证是否大于等于某个值 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function egt($value, $rule, array $data = []): bool + { + return $value >= $this->getDataValue($data, $rule); + } + + /** + * 验证是否大于某个值 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function gt($value, $rule, array $data = []): bool + { + return $value > $this->getDataValue($data, $rule); + } + + /** + * 验证是否小于等于某个值 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function elt($value, $rule, array $data = []): bool + { + return $value <= $this->getDataValue($data, $rule); + } + + /** + * 验证是否小于某个值 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function lt($value, $rule, array $data = []): bool + { + return $value < $this->getDataValue($data, $rule); + } + + /** + * 验证是否等于某个值 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function eq($value, $rule): bool + { + return $value == $rule; + } + + /** + * 验证是否不等于某个值 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function neq($value, $rule): bool + { + return $value != $rule; + } + + /** + * 必须验证 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function must($value, $rule = null): bool + { + return !empty($value) || '0' == $value; + } + + /** + * 验证字段值是否为有效格式 + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function is($value, string $rule, array $data = []): bool + { + $call = function ($value, $rule) { + if (function_exists('ctype_' . $rule)) { + // ctype验证规则 + $ctypeFun = 'ctype_' . $rule; + $result = $ctypeFun((string) $value); + } elseif (isset($this->filter[$rule])) { + // Filter_var验证规则 + $result = $this->filter($value, $this->filter[$rule]); + } else { + // 正则验证 + $result = $this->regex($value, $rule); + } + return $result; + }; + + return match (Str::camel($rule)) { + 'require' => !empty($value) || '0' == $value, + 'accepted' => in_array($value, ['1', 'on', 'yes', 'true', 1, true], true), + 'declined' => in_array($value, ['0', 'off', 'no', 'false', 0, false], true), + 'boolean', 'bool' => in_array($value, [true, false, 'true', 'false', 0, 1, '0', '1'], true), + 'date' => false !== strtotime($value), + 'activeUrl' => checkdnsrr($value), + 'number' => is_numeric($value), + 'alphaNum' => ctype_alnum((string)$value), + 'array' => is_array($value), + 'integer', 'int' => is_numeric($value) && is_int((int)$value), + 'float' => is_numeric($value) && is_float((float)$value), + 'string' => is_string($value), + 'file' => $value instanceof File, + 'image' => $value instanceof File && in_array($this->getImageType($value->getRealPath()), [1, 2, 3, 6, 9, 10, 11, 14, 15, 17, 18]), + 'token' => $this->token($value, '__token__', $data), + default => $call($value, $rule), + }; + } + + // 判断图像类型 + protected function getImageType($image) + { + if (function_exists('exif_imagetype')) { + return exif_imagetype($image); + } + + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } + } + + /** + * 验证表单令牌 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function token($value, string $rule, array $data): bool + { + if ($this->request) { + $rule = !empty($rule) ? $rule : '__token__'; + return $this->request->checkToken($rule, $data); + } + return true; + } + + /** + * 验证是否为合格的域名或者IP 支持A,MX,NS,SOA,PTR,CNAME,AAAA,A6, SRV,NAPTR,TXT 或者 ANY类型 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function activeUrl(string $value, string $rule = 'MX'): bool + { + if (!in_array($rule, ['A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY'])) { + $rule = 'MX'; + } + + return checkdnsrr($value, $rule); + } + + /** + * 验证是否有效IP + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 ipv4 ipv6 + * @return bool + */ + public function ip($value, string $rule = 'ipv4'): bool + { + if (!in_array($rule, ['ipv4', 'ipv6'])) { + $rule = 'ipv4'; + } + + return $this->filter($value, [FILTER_VALIDATE_IP, 'ipv6' == $rule ? FILTER_FLAG_IPV6 : FILTER_FLAG_IPV4]); + } + + /** + * 检测是否以某个字符串开头 + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @return bool + */ + public function startWith($value, string $rule): bool + { + return is_string($value) && str_starts_with($value, $rule); + } + + /** + * 检测是否以某个字符串结尾 + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @return bool + */ + public function endWith($value, string $rule): bool + { + return is_string($value) && str_ends_with($value, $rule); + } + + /** + * 检测是否以包含某个字符串 + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @return bool + */ + public function contain($value, string $rule): bool + { + return is_string($value) && str_contains($value, $rule); + } + + /** + * 检测上传文件后缀 + * @param File $file + * @param array|string $ext 允许后缀 + * @return bool + */ + protected function checkExt(File $file, $ext): bool + { + if (is_string($ext)) { + $ext = explode(',', $ext); + } + + return in_array(strtolower($file->extension()), $ext); + } + + /** + * 检测上传文件大小 + * @param File $file + * @param integer $size 最大大小 + * @return bool + */ + protected function checkSize(File $file, $size): bool + { + return $file->getSize() <= (int) $size; + } + + /** + * 检测上传文件类型 + * @param File $file + * @param array|string $mime 允许类型 + * @return bool + */ + protected function checkMime(File $file, $mime): bool + { + if (is_string($mime)) { + $mime = explode(',', $mime); + } + + return in_array(strtolower($file->getMime()), $mime); + } + + /** + * 验证上传文件后缀 + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + public function fileExt($file, $rule): bool + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$this->checkExt($item, $rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $this->checkExt($file, $rule); + } + + return false; + } + + /** + * 验证上传文件类型 + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + public function fileMime($file, $rule): bool + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$this->checkMime($item, $rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $this->checkMime($file, $rule); + } + + return false; + } + + /** + * 验证上传文件大小 + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + public function fileSize($file, $rule): bool + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$this->checkSize($item, $rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $this->checkSize($file, $rule); + } + + return false; + } + + /** + * 验证图片的宽高及类型 + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + public function image($file, $rule): bool + { + if (is_array($file)) { + foreach ($file as $item) { + if (!($item instanceof File) || !$this->checkImage($item, $rule)) { + return false; + } + } + return true; + } elseif ($file instanceof File) { + return $this->checkImage($file, $rule); + } + + return false; + } + + /** + * 验证图片的宽高及类型 + * @param mixed $file 上传文件 + * @param mixed $rule 验证规则 + * @return bool + */ + public function checkImage($file, $rule): bool + { + if ($rule) { + $rule = explode(',', $rule); + + if (0 === strpos($rule[0], 'type=')) { + $type = array_shift($rule); + $imageType = substr($type, 5); + } elseif (isset($rule[2])) { + $imageType = strtolower($rule[2]); + } + + [$width, $height, $type] = getimagesize($file->getRealPath()); + if (isset($imageType)) { + if ('jpg' == $imageType) { + $imageType = 'jpeg'; + } + + if (image_type_to_extension($type, false) != strtolower($imageType)) { + return false; + } + } + + if (count($rule) > 1) { + [$w, $h] = $rule; + return $w == $width && $h == $height; + } + return true; + } + + return in_array($this->getImageType($file->getRealPath()), [1, 2, 3, 6, 9, 10, 11, 14, 15, 17, 18]); + } + + /** + * 验证时间和日期是否符合指定格式 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function dateFormat($value, $rule): bool + { + $info = date_parse_from_format($rule, $value); + if (strlen((string) $info['year']) != 4 && strpos($rule, 'Y') !== false) { + return false; + } + return 0 == $info['warning_count'] && 0 == $info['error_count']; + } + + /** + * 验证是否唯一 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 格式:数据表,字段名,排除ID,主键名 + * @param array $data 数据 + * @param string $field 验证字段名 + * @return bool + */ + public function unique($value, $rule, array $data = [], string $field = ''): bool + { + if (!$this->db) { + return true; + } + + if (is_string($rule)) { + $rule = explode(',', $rule); + } + + if (str_contains($rule[0], '\\')) { + // 指定模型类 + $db = new $rule[0](); + } else { + $db = $this->db->name($rule[0]); + } + + $key = $rule[1] ?? $field; + $map = []; + + if (str_contains($key, '^')) { + // 支持多个字段验证 + $fields = explode('^', $key); + foreach ($fields as $key) { + if (isset($data[$key])) { + $map[] = [$key, '=', $data[$key]]; + } + } + } elseif (strpos($key, '=')) { + // 支持复杂验证 + parse_str($key, $array); + foreach ($array as $k => $val) { + $map[] = [$k, '=', $data[$k] ?? $val]; + } + } elseif (isset($data[$field])) { + $map[] = [$key, '=', $data[$field]]; + } + + $pk = !empty($rule[3]) ? $rule[3] : $db->getPk(); + + if (is_string($pk)) { + if (isset($rule[2])) { + $map[] = [$pk, '<>', $rule[2]]; + } elseif (isset($data[$pk])) { + $map[] = [$pk, '<>', $data[$pk]]; + } + } + + if ($db->where($map)->field($pk)->find()) { + return false; + } + + return true; + } + + /** + * 使用filter_var方式验证 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function filter($value, $rule): bool + { + if (is_string($rule) && str_contains($rule, ',')) { + [$rule, $param] = explode(',', $rule); + } elseif (is_array($rule)) { + $param = $rule[1] ?? 0; + $rule = $rule[0]; + } else { + $param = 0; + } + + return false !== filter_var($value, is_int($rule) ? $rule : filter_id($rule), $param); + } + + /** + * 验证某个字段等于某个值的时候必须 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function requireIf($value, $rule, array $data = []): bool + { + [$field, $val] = is_string($rule) ? explode(',', $rule) : $rule; + + if ($this->getDataValue($data, $field) == $val) { + return !empty($value) || '0' == $value; + } + + return true; + } + + /** + * 通过回调方法验证某个字段是否必须 + * @param mixed $value 字段值 + * @param string|array $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function requireCallback($value, string | array $rule, array $data = []): bool + { + $callback = is_array($rule) ? $rule : [$this, $rule]; + $result = call_user_func_array($callback, [$value, $data]); + + if ($result) { + return !empty($value) || '0' == $value; + } + + return true; + } + + /** + * 验证某个字段有值的情况下必须 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function requireWith($value, $rule, array $data = []): bool + { + $val = $this->getDataValue($data, $rule); + + if (!empty($val)) { + return !empty($value) || '0' == $value; + } + + return true; + } + + /** + * 验证某个字段没有值的情况下必须 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function requireWithout($value, $rule, array $data = []): bool + { + $val = $this->getDataValue($data, $rule); + + if (empty($val)) { + return !empty($value) || '0' == $value; + } + + return true; + } + + /** + * 验证是否为数组,支持检查键名 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function array($value, $rule): bool + { + if (!is_array($value)) { + return false; + } + if ($rule) { + $keys = is_string($rule) ? explode(',', $rule) : $rule; + return empty(array_diff($keys, array_keys($value))); + } else { + return true; + } + } + + /** + * 验证是否在范围内 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function in($value, $rule): bool + { + return in_array($value, is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * 验证是否为枚举 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function enum($value, $rule): bool + { + if (is_subclass_of($rule, BackedEnum::class)) { + $values = array_map(fn($case) => $case->value, $rule::cases()); + } elseif (is_subclass_of($rule, UnitEnum::class)) { + $values = array_map(fn($case) => $case->name, $rule::cases()); + } elseif (is_subclass_of($rule, Enumable::class)) { + $values = $rule::values(); + } else { + $reflect = new \ReflectionClass($rule); + $values = $reflect->getConstants(); + } + + return in_array($value, $values ?? []); + } + + /** + * 验证是否不在某个范围 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function notIn($value, $rule): bool + { + return !in_array($value, is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * between验证数据 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function between($value, $rule): bool + { + [$min, $max] = is_string($rule) ? explode(',', $rule) : $rule; + + return $value >= $min && $value <= $max; + } + + /** + * 使用notbetween验证数据 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function notBetween($value, $rule): bool + { + [$min, $max] = is_string($rule) ? explode(',', $rule) : $rule; + + return $value < $min || $value > $max; + } + + /** + * 验证数据长度 + * @param mixed $value 字段值 + * @param string|array|int|float $rule 验证规则 + * @return bool + */ + public function length($value, $rule): bool + { + if (is_array($value)) { + $length = count($value); + } elseif ($value instanceof File) { + $length = $value->getSize(); + } else { + $length = mb_strlen((string) $value); + } + + if (is_array($rule)) { + // 长度区间 + return $length >= $rule[0] && $length <= $rule[1]; + } elseif (is_string($rule) && str_contains($rule, ',')) { + // 长度区间 + [$min, $max] = explode(',', $rule); + return $length >= $min && $length <= $max; + } + + // 指定长度 + return $length == $rule; + } + + /** + * 验证数据最大长度 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function max($value, $rule): bool + { + if (is_array($value)) { + $length = count($value); + } elseif ($value instanceof File) { + $length = $value->getSize(); + } else { + $length = mb_strlen((string) $value); + } + + return $length <= $rule; + } + + /** + * 验证数据最小长度 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function min($value, $rule): bool + { + if (is_array($value)) { + $length = count($value); + } elseif ($value instanceof File) { + $length = $value->getSize(); + } else { + $length = mb_strlen((string) $value); + } + + return $length >= $rule; + } + + /** + * 验证日期 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function after($value, $rule, array $data = []): bool + { + return strtotime($value) >= strtotime($rule); + } + + /** + * 验证日期 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function before($value, $rule, array $data = []): bool + { + return strtotime($value) <= strtotime($rule); + } + + /** + * 验证日期 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function afterWith($value, $rule, array $data = []): bool + { + $rule = $this->getDataValue($data, $rule); + return !is_null($rule) && strtotime($value) >= strtotime($rule); + } + + /** + * 验证日期 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function beforeWith($value, $rule, array $data = []): bool + { + $rule = $this->getDataValue($data, $rule); + return !is_null($rule) && strtotime($value) <= strtotime($rule); + } + + /** + * 验证有效期 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function expire($value, $rule): bool + { + [$start, $end] = is_string($rule) ? explode(',', $rule) : $rule; + + if (!is_numeric($start)) { + $start = strtotime($start); + } + + if (!is_numeric($end)) { + $end = strtotime($end); + } + + return time() >= $start && time() <= $end; + } + + /** + * 验证IP许可 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function allowIp($value, $rule): bool + { + return in_array($value, is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * 验证IP禁用 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @return bool + */ + public function denyIp($value, $rule): bool + { + return !in_array($value, is_array($rule) ? $rule : explode(',', $rule)); + } + + /** + * 验证某个字段等于指定的值,则验证中的字段必须为 yes、on、1 或 true + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function acceptedIf($value, $rule, array $data = []): bool + { + [$field, $val] = is_string($rule) ? explode(',', $rule) : $rule; + + if ($this->getDataValue($data, $field) == $val) { + return in_array($value, ['1', 'on', 'yes', 'true', 1, true], true); + } + + return true; + } + + /** + * 验证某个字段等于指定的值,则验证中的字段必须为 no、off、0 或 false + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 + * @param array $data 数据 + * @return bool + */ + public function declinedIf($value, $rule, array $data = []): bool + { + [$field, $val] = is_string($rule) ? explode(',', $rule) : $rule; + + if ($this->getDataValue($data, $field) == $val) { + return in_array($value, ['0', 'off', 'no', 'false', 0, false], true); + } + + return true; + } + + /** + * 验证某个字段必须是指定值的倍数 + * @param mixed $value 字段值 + * * @param mixed $rule 验证规则 + * @return bool + */ + public function multipleOf($value, $rule): bool + { + if ('0' == $rule || $value < $rule) { + return false; + } + + return $value % $rule === 0; + } + + /** + * 使用正则验证数据 + * @param mixed $value 字段值 + * @param mixed $rule 验证规则 正则规则或者预定义正则名 + * @return bool + */ + public function regex($value, $rule): bool + { + $rule = $this->regex[$rule] ?? $this->getDefaultRegexRule($rule); + + if (is_string($rule) && !str_starts_with($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { + // 不是正则表达式则两端补上/ + $rule = '/^' . $rule . '$/'; + } + + return is_scalar($value) && 1 === preg_match($rule, (string) $value); + } + + /** + * 获取内置正则验证规则 + * @param string $rule 验证规则 正则规则或者预定义正则名 + * @return string + */ + protected function getDefaultRegexRule(string $rule): string + { + $name = Str::camel($rule); + if (isset($this->defaultRegex[$name])) { + $rule = $this->defaultRegex[$name]; + } + return $rule; + } + + /** + * 获取错误信息 + * @param bool $withKey 是否包含字段信息 + * @return array|string + */ + public function getError(bool $withKey = false) + { + if ($withKey || count($this->error) > 1) { + // 批量验证 + return $this->error; + } + return empty($this->error) ? '' : array_values($this->error)[0]; + } + + /** + * 获取数据集合 + * @param array $data 数据 + * @param string $key 数据标识 支持二维 + * @return array + */ + protected function getDataSet(array $data, $key): array + { + if (is_string($key) && str_contains($key, '*')) { + if (substr_count($key, '*') > 1) { + [$key1, $key2] = explode('.*.', $key, 2); + + $array = $this->getDataValue($data, $key1); + $data = is_array($array) ? $this->getDataSet($data, $key1 . '.*')[0] : []; + + return $this->getDataSet($data, $key2); + } + + if (str_ends_with($key, '*')) { + // user.id.* + [$key] = explode('.*', $key); + $value = $this->getRecursiveData($data, $key) ?: []; + return is_array($value) ? $value : [$value]; + } + // user.*.id + [$key, $column] = explode('.*.', $key); + + $value = $this->getRecursiveData($data, $key); + if (!is_array($value)) { + $value = []; + } + + return array_map(function ($item) use ($column) { + return $item[$column] ?? null; + }, $value); + } + + $value = $this->getDataValue($data, $key); + return is_null($value) ? [] : [$value]; + } + + /** + * 获取数据值 + * @param array $data 数据 + * @param string $key 数据标识 支持二维 + * @return mixed + */ + protected function getDataValue(array $data, $key) + { + if (is_numeric($key)) { + $value = $key; + } elseif (is_string($key) && str_contains($key, '.')) { + // 支持多维数组验证 + $value = $this->getRecursiveData($data, $key); + } else { + $value = $data[$key] ?? null; + } + + return $value; + } + + /** + * 获取数据值 + * @param array $data 数据 + * @param string $key 数据标识 支持二维 + * @return mixed + */ + protected function getRecursiveData(array $data, string $key) + { + $keys = explode('.', $key); + foreach ($keys as $key) { + if (!isset($data[$key])) { + $value = null; + break; + } + $value = $data = $data[$key]; + } + return $value; + } + + /** + * 获取验证规则的错误提示信息 + * @param string $attribute 字段英文名 + * @param string $title 字段描述名 + * @param string $type 验证规则名称 + * @param mixed $rule 验证规则数据 + * @return string|array + */ + protected function getRuleMsg(string $attribute, string $title, string $type, $rule) + { + if (isset($this->message[$attribute . '.' . $type])) { + $msg = $this->message[$attribute . '.' . $type]; + } elseif (isset($this->message[$attribute][$type])) { + $msg = $this->message[$attribute][$type]; + } elseif (isset($this->message[$attribute])) { + $msg = $this->message[$attribute]; + } elseif (isset($this->typeMsg[$type])) { + $msg = $this->typeMsg[$type]; + } elseif (str_starts_with($type, 'require')) { + $msg = $this->typeMsg['require']; + } else { + $msg = $title . ($this->lang ? $this->lang->get('not conform to the rules') : '规则不符'); + } + + if (is_array($msg)) { + return $this->errorMsgIsArray($msg, $rule, $title); + } + + return $this->parseErrorMsg($msg, $rule, $title); + } + + /** + * 获取验证规则的错误提示信息 + * @param string $msg 错误信息 + * @param mixed $rule 验证规则数据 + * @param string $title 字段描述名 + * @return string|array + */ + protected function parseErrorMsg(string $msg, $rule, string $title) + { + if ($this->lang) { + if (str_starts_with($msg, '{%')) { + $msg = $this->lang->get(substr($msg, 2, -1)); + } elseif ($this->lang->has($msg)) { + $msg = $this->lang->get($msg); + } + } + + if (is_array($msg)) { + return $this->errorMsgIsArray($msg, $rule, $title); + } + + // rule若是数组则转为字符串 + if (is_array($rule)) { + $rule = implode(',', $rule); + } + + if (is_scalar($rule) && str_contains($msg, ':')) { + // 变量替换 + if (is_string($rule) && str_contains($rule, ',')) { + $array = array_pad(explode(',', $rule), 3, ''); + } else { + $array = array_pad([], 3, ''); + } + + $msg = str_replace( + [':attribute', ':1', ':2', ':3'], + [$title, $array[0], $array[1], $array[2]], + $msg, + ); + + if (str_contains($msg, ':rule')) { + $msg = str_replace(':rule', (string) $rule, $msg); + } + } + + return $msg; + } + + /** + * 错误信息数组处理 + * @param array $msg 错误信息 + * @param mixed $rule 验证规则数据 + * @param string $title 字段描述名 + * @return array + */ + protected function errorMsgIsArray(array $msg, $rule, string $title) + { + foreach ($msg as $key => $val) { + if (is_string($val)) { + $msg[$key] = $this->parseErrorMsg($val, $rule, $title); + } + } + return $msg; + } + + /** + * 获取数据验证的场景 + * @param string $scene 验证场景 + * @return void + */ + protected function getScene(string $scene): void + { + $method = 'scene' . Str::studly($scene); + if (method_exists($this, $method)) { + call_user_func([$this, $method]); + } elseif (isset($this->scene[$scene])) { + // 如果设置了验证适用场景 + $this->only = $this->scene[$scene]; + } + } + + /** + * 获取验证分组 + * @param string $group 分组名 + * @return mixed + */ + protected function getGroupRules(string $group) + { + $method = 'rules' . Str::studly($group); + if (method_exists($this, $method)) { + $validate = call_user_func_array([$this, $method], [new self()]); + return $validate->alias($this->alias) + ->batch($this->batch) + ->failException($this->failException); + } + return $this->group[$group] ?? []; + } + + /** + * 动态方法 直接调用is方法进行验证 + * @param string $method 方法名 + * @param array $args 调用参数 + * @return bool + */ + public function __call($method, $args) + { + if ('is' == strtolower(substr($method, 0, 2))) { + $method = substr($method, 2); + } + + array_push($args, lcfirst($method)); + + return call_user_func_array([$this, 'is'], $args); + } +} diff --git a/vendor/topthink/think-validate/src/contract/Enumable.php b/vendor/topthink/think-validate/src/contract/Enumable.php new file mode 100644 index 0000000..13b4883 --- /dev/null +++ b/vendor/topthink/think-validate/src/contract/Enumable.php @@ -0,0 +1,22 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\contract; + +/** + * 枚举类接口 + */ +interface Enumable +{ + // 返回枚举类的清单 + public static function values(): array; +} diff --git a/vendor/topthink/think-validate/src/exception/ValidateException.php b/vendor/topthink/think-validate/src/exception/ValidateException.php new file mode 100644 index 0000000..b6eee02 --- /dev/null +++ b/vendor/topthink/think-validate/src/exception/ValidateException.php @@ -0,0 +1,45 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\exception; + +/** + * 数据验证异常 + */ +class ValidateException extends \RuntimeException +{ + public function __construct(protected $error, protected $key = '') + { + $this->message = is_array($error) ? json_encode($error) : $error; + } + + /** + * 获取验证错误信息 + * @access public + * @return array|string + */ + public function getError() + { + return $this->error; + } + + /** + * 获取验证错误字段 + * @access public + * @return string + */ + public function getKey() + { + return $this->key; + } + +} diff --git a/vendor/topthink/think-validate/src/facade/Validate.php b/vendor/topthink/think-validate/src/facade/Validate.php new file mode 100644 index 0000000..6444ea1 --- /dev/null +++ b/vendor/topthink/think-validate/src/facade/Validate.php @@ -0,0 +1,80 @@ + +// +---------------------------------------------------------------------- + +namespace think\facade; + +use think\Facade; + +/** + * @see \think\Validate + * @mixin \think\Validate + * @method static \think\Validate rule(mixed $name, mixed $rule = '') 添加字段验证规则 + * @method static void extend(string $type, callable $callback = null, string $message='') 注册扩展验证(类型)规则 + * @method static void setTypeMsg(mixed $type, string $msg = null) 设置验证规则的默认提示信息 + * @method static \think\Validate message(mixed $name, string $message = '') 设置提示信息 + * @method static \think\Validate scene(string $name) 设置验证场景 + * @method static bool hasScene(string $name) 判断是否存在某个验证场景 + * @method static \think\Validate batch(bool $batch = true) 设置批量验证 + * @method static \think\Validate only(array $fields) 指定需要验证的字段列表 + * @method static \think\Validate remove(mixed $field, mixed $rule = true) 移除某个字段的验证规则 + * @method static \think\Validate append(mixed $field, mixed $rule = null) 追加某个字段的验证规则 + * @method static bool confirm(mixed $value, mixed $rule, array $data = [], string $field = '') 验证是否和某个字段的值一致 + * @method static bool different(mixed $value, mixed $rule, array $data = []) 验证是否和某个字段的值是否不同 + * @method static bool egt(mixed $value, mixed $rule, array $data = []) 验证是否大于等于某个值 + * @method static bool gt(mixed $value, mixed $rule, array $data = []) 验证是否大于某个值 + * @method static bool elt(mixed $value, mixed $rule, array $data = []) 验证是否小于等于某个值 + * @method static bool lt(mixed $value, mixed $rule, array $data = []) 验证是否小于某个值 + * @method static bool eq(mixed $value, mixed $rule) 验证是否等于某个值 + * @method static bool must(mixed $value, mixed $rule) 必须验证 + * @method static bool is(mixed $value, mixed $rule, array $data = []) 验证字段值是否为有效格式 + * @method static bool ip(mixed $value, mixed $rule) 验证是否有效IP + * @method static bool requireIf(mixed $value, mixed $rule) 验证某个字段等于某个值的时候必须 + * @method static bool requireCallback(mixed $value, mixed $rule,array $data) 通过回调方法验证某个字段是否必须 + * @method static bool requireWith(mixed $value, mixed $rule, array $data) 验证某个字段有值的情况下必须 + * @method static bool filter(mixed $value, mixed $rule) 使用 filter_var 方式验证 + * @method static bool in(mixed $value, mixed $rule) 验证是否在范围内 + * @method static bool notIn(mixed $value, mixed $rule) 验证是否不在范围内 + * @method static bool between(mixed $value, mixed $rule) between 验证数据 + * @method static bool notBetween(mixed $value, mixed $rule) 使用 notbetween 验证数据 + * @method static bool length(mixed $value, mixed $rule) 验证数据长度 + * @method static bool max(mixed $value, mixed $rule) 验证数据最大长度 + * @method static bool min(mixed $value, mixed $rule) 验证数据最小长度 + * @method static bool after(mixed $value, mixed $rule) 验证日期 + * @method static bool before(mixed $value, mixed $rule) 验证日期 + * @method static bool expire(mixed $value, mixed $rule) 验证有效期 + * @method static bool allowIp(mixed $value, mixed $rule) 验证 IP 许可 + * @method static bool denyIp(mixed $value, mixed $rule) 验证 IP 禁用 + * @method static bool regex(mixed $value, mixed $rule) 使用正则验证数据 + * @method static bool token(mixed $value, mixed $rule) 验证表单令牌 + * @method static bool dateFormat(mixed $value, mixed $rule) 验证时间和日期是否符合指定格式 + * @method static bool unique(mixed $value, mixed $rule, array $data = [], string $field = '') 验证是否唯一 + * @method static bool check(array $data, mixed $rules = []) 数据自动验证 + * @method static bool checkRule(mixed $data, mixed $rules = []) 数据手动验证 + * @method static mixed getError() 获取错误信息 + */ +class Validate extends Facade +{ + /** + * 始终创建新的对象实例 + * @var bool + */ + protected static $alwaysNewInstance = true; + + /** + * 获取当前Facade对应类名(或者已经绑定的容器对象标识) + * @access protected + * @return string + */ + protected static function getFacadeClass() + { + return 'think\Validate'; + } +} diff --git a/vendor/topthink/think-validate/src/helper.php b/vendor/topthink/think-validate/src/helper.php new file mode 100644 index 0000000..c0db84d --- /dev/null +++ b/vendor/topthink/think-validate/src/helper.php @@ -0,0 +1,67 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +//------------------------ +// ThinkPHP 助手函数 +//------------------------- + +use think\Validate; +use think\validate\ValidateRuleSet; + +if (!function_exists('validate')) { + /** + * 生成验证对象 + * @param string|array $validate 验证器类名或者验证规则数组 + * @param array $message 错误提示信息 + * @param bool $batch 是否批量验证 + * @param bool $failException 是否抛出异常 + * @return Validate + */ + function validate($validate = '', array $message = [], bool $batch = false, bool $failException = true): Validate + { + if (is_array($validate) || '' === $validate) { + $v = new Validate(); + if (is_array($validate)) { + $v->rule($validate); + } + } else { + if (str_contains($validate, '.')) { + // 支持场景 + [$validate, $scene] = explode('.', $validate); + } + + if (class_exists($validate)) { + $v = new $validate(); + + if (!empty($scene)) { + $v->scene($scene); + } + } else { + $v = new Validate(); + } + } + return $v->message($message)->batch($batch)->failException($failException); + } +} + +if (!function_exists('rules')) { + /** + * 定义ValidateRuleSet规则集合 + * @param array $rules 验证因子集 + * @return ValidateRuleSet + */ + function rules(array $rules): ValidateRuleSet + { + return ValidateRuleSet::rules($rules); + } +} + diff --git a/vendor/topthink/think-validate/src/validate/ValidateRule.php b/vendor/topthink/think-validate/src/validate/ValidateRule.php new file mode 100644 index 0000000..0a22075 --- /dev/null +++ b/vendor/topthink/think-validate/src/validate/ValidateRule.php @@ -0,0 +1,187 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\validate; + +/** + * Class ValidateRule + * @package think\validate + * @method static ValidateRule confirm(mixed $rule, string $msg = '') 验证是否和某个字段的值一致 + * @method static ValidateRule different(mixed $rule, string $msg = '') 验证是否和某个字段的值是否不同 + * @method static ValidateRule egt(mixed $rule, string $msg = '') 验证是否大于等于某个值 + * @method static ValidateRule gt(mixed $rule, string $msg = '') 验证是否大于某个值 + * @method static ValidateRule elt(mixed $rule, string $msg = '') 验证是否小于等于某个值 + * @method static ValidateRule lt(mixed $rule, string $msg = '') 验证是否小于某个值 + * @method static ValidateRule eg(mixed $rule, string $msg = '') 验证是否等于某个值 + * @method static ValidateRule in(mixed $rule, string $msg = '') 验证是否在范围内 + * @method static ValidateRule notIn(mixed $rule, string $msg = '') 验证是否不在某个范围 + * @method static ValidateRule between(mixed $rule, string $msg = '') 验证是否在某个区间 + * @method static ValidateRule notBetween(mixed $rule, string $msg = '') 验证是否不在某个区间 + * @method static ValidateRule length(mixed $rule, string $msg = '') 验证数据长度 + * @method static ValidateRule max(mixed $rule, string $msg = '') 验证数据最大长度 + * @method static ValidateRule min(mixed $rule, string $msg = '') 验证数据最小长度 + * @method static ValidateRule after(mixed $rule, string $msg = '') 验证日期 + * @method static ValidateRule before(mixed $rule, string $msg = '') 验证日期 + * @method static ValidateRule expire(mixed $rule, string $msg = '') 验证有效期 + * @method static ValidateRule allowIp(mixed $rule, string $msg = '') 验证IP许可 + * @method static ValidateRule denyIp(mixed $rule, string $msg = '') 验证IP禁用 + * @method static ValidateRule regex(mixed $rule, string $msg = '') 使用正则验证数据 + * @method static ValidateRule token(mixed $rule='__token__', string $msg = '') 验证表单令牌 + * @method static ValidateRule is(mixed $rule, string $msg = '') 验证字段值是否为有效格式 + * @method static ValidateRule isRequire(mixed $rule = null, string $msg = '') 验证字段必须 + * @method static ValidateRule isNumber(mixed $rule = null, string $msg = '') 验证字段值是否为数字 + * @method static ValidateRule isArray(mixed $rule = null, string $msg = '') 验证字段值是否为数组 + * @method static ValidateRule isInteger(mixed $rule = null, string $msg = '') 验证字段值是否为整形 + * @method static ValidateRule isFloat(mixed $rule = null, string $msg = '') 验证字段值是否为浮点数 + * @method static ValidateRule isMobile(mixed $rule = null, string $msg = '') 验证字段值是否为手机 + * @method static ValidateRule isIdCard(mixed $rule = null, string $msg = '') 验证字段值是否为身份证号码 + * @method static ValidateRule isChs(mixed $rule = null, string $msg = '') 验证字段值是否为中文 + * @method static ValidateRule isChsDash(mixed $rule = null, string $msg = '') 验证字段值是否为中文字母及下划线 + * @method static ValidateRule isChsAlpha(mixed $rule = null, string $msg = '') 验证字段值是否为中文和字母 + * @method static ValidateRule isChsAlphaNum(mixed $rule = null, string $msg = '') 验证字段值是否为中文字母和数字 + * @method static ValidateRule isDate(mixed $rule = null, string $msg = '') 验证字段值是否为有效格式 + * @method static ValidateRule isBool(mixed $rule = null, string $msg = '') 验证字段值是否为布尔值 + * @method static ValidateRule isAlpha(mixed $rule = null, string $msg = '') 验证字段值是否为字母 + * @method static ValidateRule isAlphaDash(mixed $rule = null, string $msg = '') 验证字段值是否为字母和下划线 + * @method static ValidateRule isAlphaNum(mixed $rule = null, string $msg = '') 验证字段值是否为字母和数字 + * @method static ValidateRule isAccepted(mixed $rule = null, string $msg = '') 验证字段值是否为yes, on, true, 或是 1 + * @method static ValidateRule isDeclined(mixed $rule = null, string $msg = '') 验证字段值是否为no, off, false, 或是 0 + * @method static ValidateRule isEmail(mixed $rule = null, string $msg = '') 验证字段值是否为有效邮箱格式 + * @method static ValidateRule isUrl(mixed $rule = null, string $msg = '') 验证字段值是否为有效URL地址 + * @method static ValidateRule activeUrl(mixed $rule, string $msg = '') 验证是否为合格的域名或者IP + * @method static ValidateRule ip(mixed $rule, string $msg = '') 验证是否有效IP + * @method static ValidateRule fileExt(mixed $rule, string $msg = '') 验证文件后缀 + * @method static ValidateRule fileMime(mixed $rule, string $msg = '') 验证文件类型 + * @method static ValidateRule fileSize(mixed $rule, string $msg = '') 验证文件大小 + * @method static ValidateRule image(mixed $rule, string $msg = '') 验证图像文件 + * @method static ValidateRule method(mixed $rule, string $msg = '') 验证请求类型 + * @method static ValidateRule dateFormat(mixed $rule, string $msg = '') 验证时间和日期是否符合指定格式 + * @method static ValidateRule unique(mixed $rule, string $msg = '') 验证是否唯一 + * @method static ValidateRule behavior(mixed $rule, string $msg = '') 使用行为类验证 + * @method static ValidateRule filter(mixed $rule, string $msg = '') 使用filter_var方式验证 + * @method static ValidateRule acceptedIf(mixed $rule, string $msg = '') 验证某个字段等于指定的值,则验证中的字段必须为 yes、on、1 或 true + * @method static ValidateRule declinedIf(mixed $rule, string $msg = '') 验证某个字段等于指定的值,则验证中的字段必须为 no、off、0 或 false + * @method static ValidateRule requireIf(mixed $rule, string $msg = '') 验证某个字段等于某个值的时候必须 + * @method static ValidateRule requireCallback(mixed $rule, string $msg = '') 通过回调方法验证某个字段是否必须 + * @method static ValidateRule requireWith(mixed $rule, string $msg = '') 验证某个字段有值的情况下必须 + * @method static ValidateRule must(mixed $rule = null, string $msg = '') 必须验证 + */ +class ValidateRule +{ + // 验证字段的名称 + protected $title; + + // 当前验证规则 + protected $rule = []; + + // 验证提示信息 + protected $message = []; + + /** + * 添加验证因子 + * @access protected + * @param string $name 验证名称 + * @param mixed $rule 验证规则 + * @param string $msg 提示信息 + * @return $this + */ + protected function addItem(string $name, $rule = null, string $msg = '') + { + if ($rule || 0 === $rule) { + $this->rule[$name] = $rule; + } else { + $this->rule[] = $name; + } + + $this->message[] = $msg; + + return $this; + } + + /** + * 添加验证因子集 + * @access protected + * @param array $rules 验证规则 + * @param array $msg 提示信息 + * @return ValidateRuleSet + */ + public static function ruleSet(array $rules, array $msg = []) + { + return ValidateRuleSet::rules($rules, $msg); + } + + /** + * 获取验证规则 + * @access public + * @return array + */ + public function getRule(): array + { + return $this->rule; + } + + /** + * 获取验证字段名称 + * @access public + * @return string + */ + public function getTitle(): string + { + return $this->title ?: ''; + } + + /** + * 获取验证提示 + * @access public + * @return array + */ + public function getMsg(): array + { + return $this->message; + } + + /** + * 设置验证字段名称 + * @access public + * @return $this + */ + public function title(string $title) + { + $this->title = $title; + + return $this; + } + + public function __call($method, $args) + { + if ('is' == strtolower(substr($method, 0, 2))) { + $method = substr($method, 2); + } + + array_unshift($args, lcfirst($method)); + + return call_user_func_array([$this, 'addItem'], $args); + } + + public static function __callStatic($method, $args) + { + $rule = new static(); + + if ('is' == strtolower(substr($method, 0, 2))) { + $method = substr($method, 2); + } + + array_unshift($args, lcfirst($method)); + + return call_user_func_array([$rule, 'addItem'], $args); + } +} diff --git a/vendor/topthink/think-validate/src/validate/ValidateRuleSet.php b/vendor/topthink/think-validate/src/validate/ValidateRuleSet.php new file mode 100644 index 0000000..7d7cbd3 --- /dev/null +++ b/vendor/topthink/think-validate/src/validate/ValidateRuleSet.php @@ -0,0 +1,74 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\validate; + +use Closure; + +/** + * Class ValidateRuleSet + * @package think\validate + */ +class ValidateRuleSet +{ + /** + * 构造方法 + * @access public + */ + public function __construct(protected array|Closure $rules = [], protected array $message = []) + { + } + + /** + * 添加验证因子 + * @access public + * @param array $rules 验证因子 + * @param array $message 错误信息 + * @return static + */ + public static function rules(array|Closure $rules, array $message = []) + { + return new static($rules, $message); + } + + /** + * 设置错误信息 + * @access public + * @param array $message 错误信息 + * @return $this + */ + public function message(array $message) + { + $this->message = $message; + return $this; + } + + /** + * 获取验证因子 + * @access public + * @return array + */ + public function getRules() + { + return $this->rules; + } + + /** + * 获取错误信息 + * @access public + * @return array + */ + public function getMessage(): array + { + return $this->message; + } +} diff --git a/vendor/topthink/think-view/LICENSE b/vendor/topthink/think-view/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/vendor/topthink/think-view/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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/vendor/topthink/think-view/README.md b/vendor/topthink/think-view/README.md new file mode 100644 index 0000000..fcd7b0e --- /dev/null +++ b/vendor/topthink/think-view/README.md @@ -0,0 +1,36 @@ +# think-view + +ThinkPHP8.0 Think-Template模板引擎驱动 + + +## 安装 + +~~~php +composer require topthink/think-view +~~~ + +## 用法示例 + +本扩展不能单独使用,依赖ThinkPHP8.0+ + +首先配置config目录下的template.php配置文件,然后可以按照下面的用法使用。 + +~~~php + +use think\facade\View; + +// 模板变量赋值和渲染输出 +View::assign(['name' => 'think']) + // 输出过滤 + ->filter(function($content){ + return str_replace('search', 'replace', $content); + }) + // 读取模板文件渲染输出 + ->fetch('index'); + + +// 或者使用助手函数 +view('index', ['name' => 'think']); +~~~ + +具体的模板引擎配置请参考think-template库。 \ No newline at end of file diff --git a/vendor/topthink/think-view/composer.json b/vendor/topthink/think-view/composer.json new file mode 100644 index 0000000..d9bcca7 --- /dev/null +++ b/vendor/topthink/think-view/composer.json @@ -0,0 +1,20 @@ +{ + "name": "topthink/think-view", + "description": "thinkphp template driver", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "require": { + "php": ">=8.0.0", + "topthink/think-template": "^3.0" + }, + "autoload": { + "psr-4": { + "think\\view\\driver\\": "src" + } + } +} diff --git a/vendor/topthink/think-view/src/Think.php b/vendor/topthink/think-view/src/Think.php new file mode 100644 index 0000000..2cdc7fc --- /dev/null +++ b/vendor/topthink/think-view/src/Think.php @@ -0,0 +1,254 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\view\driver; + +use think\App; +use think\contract\TemplateHandlerInterface; +use think\helper\Str; +use think\Template; +use think\template\exception\TemplateNotFoundException; + +class Think implements TemplateHandlerInterface +{ + // 模板引擎实例 + private $template; + + // 模板引擎参数 + protected $config = [ + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 + 'auto_rule' => 1, + // 视图目录名 + 'view_dir_name' => 'view', + // 模板起始路径 + 'view_path' => '', + // 模板文件后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DIRECTORY_SEPARATOR, + // 是否开启模板编译缓存,设为false则每次都会重新编译 + 'tpl_cache' => true, + ]; + + public function __construct(private App $app, array $config = []) + { + $this->config = array_merge($this->config, (array) $config); + + if (empty($this->config['cache_path'])) { + $this->config['cache_path'] = $app->getRuntimePath() . 'temp' . DIRECTORY_SEPARATOR; + } + + $this->template = new Template($this->config); + $this->template->setCache($app->cache); + $this->template->extend('$Think', function (array $vars) { + $type = strtoupper(trim(array_shift($vars))); + $param = implode('.', $vars); + + return match ($type) { + 'CONST' => strtoupper($param), + 'CONFIG' => 'config(\'' . $param . '\')', + 'LANG' => 'lang(\'' . $param . '\')', + 'NOW' => "date('Y-m-d g:i a',time())", + 'LDELIM' => '\'' . ltrim($this->getConfig('tpl_begin'), '\\') . '\'', + 'RDELIM' => '\'' . ltrim($this->getConfig('tpl_end'), '\\') . '\'', + default => defined($type) ? $type : '\'\'', + }; + }); + + $this->template->extend('$Request', function (array $vars) { + // 获取Request请求对象参数 + $method = array_shift($vars); + if (!empty($vars)) { + $params = implode('.', $vars); + if ('true' != $params) { + $params = '\'' . $params . '\''; + } + } else { + $params = ''; + } + + return 'app(\'request\')->' . $method . '(' . $params . ')'; + }); + } + + /** + * 检测是否存在模板文件 + * @access public + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists(string $template): bool + { + $template = $this->getTemplateFile($template); + + return is_file($template); + } + + protected function getTemplateFile(string $template): string + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } else{ + $path = $this->config['view_path'] ?: $this->getViewPath($this->app->http->getName()); + if (!is_file($template)) { + $template = $path . $template; + } + $this->template->view_path = $path; + } + + return $template; + } + + /** + * 渲染模板文件 + * @access public + * @param string $template 模板文件 + * @param array $data 模板变量 + * @return void + */ + public function fetch(string $template, array $data = []): void + { + $template = $this->getTemplateFile($template); + + // 模板不存在 抛出异常 + if (!is_file($template)) { + throw new TemplateNotFoundException('template not exists:' . $template, $template); + } + + $this->template->fetch($template, $data); + } + + /** + * 渲染模板内容 + * @access public + * @param string $template 模板内容 + * @param array $data 模板变量 + * @return void + */ + public function display(string $template, array $data = []): void + { + $this->template->display($template, $data); + } + + protected function getViewPath(string $app): string + { + $view = $this->config['view_dir_name'] . DIRECTORY_SEPARATOR; + $app = $app ? str_replace('.', DIRECTORY_SEPARATOR, $app) . DIRECTORY_SEPARATOR : ''; + $paths = [ + $this->app->getBasePath() . $app . $view, + $this->app->getBasePath() . $view . $app, + $this->app->getRootPath() . $view . $app + ]; + + foreach ($paths as $path) { + if (is_dir($path)) { + return $path; + } + } + + return ''; + } + + /** + * 自动定位模板文件 + * @access private + * @param string $template 模板文件规则 + * @return string + */ + private function parseTemplate(string $template): string + { + // 分析模板文件规则 + $request = $this->app['request']; + + // 获取视图根目录 + if (strpos($template, '@')) { + // 跨模块调用 + list($app, $template) = explode('@', $template); + } elseif ($this->app->http->getName()) { + $app = $this->app->http->getName(); + } elseif (method_exists($request, 'layer') && $request->layer()) { + $app = $request->layer(); + $controller = $request->controller(false, true); + } + + if ($this->config['view_path']) { + $path = $this->config['view_path']; + } else { + $path = $this->getViewPath($app ?? $this->app->http->getName()); + $this->template->view_path = $path; + } + + $depr = $this->config['view_depr']; + + if (0 !== strpos($template, '/')) { + $template = str_replace(['/', ':'], $depr, $template); + $controller = $controller ?? $request->controller(); + + if (strpos($controller, '.')) { + $pos = strrpos($controller, '.'); + $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); + } else { + $controller = Str::snake($controller); + } + + if ($controller) { + if ('' == $template) { + // 如果模板文件名为空 按照默认模板渲染规则定位 + if (2 == $this->config['auto_rule']) { + $template = $request->action(true); + } elseif (3 == $this->config['auto_rule']) { + $template = $request->action(); + } else { + $template = Str::snake($request->action()); + } + + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; + } elseif (false === strpos($template, $depr)) { + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; + } + } + } else { + $template = str_replace(['/', ':'], $depr, substr($template, 1)); + } + + return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); + } + + /** + * 配置模板引擎 + * @access private + * @param array $config 参数 + * @return void + */ + public function config(array $config): void + { + $this->template->config($config); + $this->config = array_merge($this->config, $config); + } + + /** + * 获取模板引擎配置 + * @access public + * @param string $name 参数名 + * @return void + */ + public function getConfig(string $name) + { + return $this->template->getConfig($name); + } + + public function __call($method, $params) + { + return call_user_func_array([$this->template, $method], $params); + } +}