dropbox-sign 1.0.0.pre.beta2301
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +78 -0
- data/LICENSE +21 -0
- data/README.md +333 -0
- data/Rakefile +10 -0
- data/bin/generate-examples.php +269 -0
- data/bin/php +16 -0
- data/bin/replace +11 -0
- data/bin/ruby +16 -0
- data/bin/scan_for +32 -0
- data/composer.json +10 -0
- data/composer.lock +246 -0
- data/docs/AccountApi.md +301 -0
- data/docs/AccountCreateRequest.md +13 -0
- data/docs/AccountCreateResponse.md +12 -0
- data/docs/AccountGetResponse.md +11 -0
- data/docs/AccountResponse.md +19 -0
- data/docs/AccountResponseQuotas.md +14 -0
- data/docs/AccountUpdateRequest.md +12 -0
- data/docs/AccountVerifyRequest.md +10 -0
- data/docs/AccountVerifyResponse.md +11 -0
- data/docs/AccountVerifyResponseAccount.md +10 -0
- data/docs/ApiAppApi.md +402 -0
- data/docs/ApiAppCreateRequest.md +16 -0
- data/docs/ApiAppGetResponse.md +11 -0
- data/docs/ApiAppListResponse.md +12 -0
- data/docs/ApiAppResponse.md +19 -0
- data/docs/ApiAppResponseOAuth.md +13 -0
- data/docs/ApiAppResponseOptions.md +10 -0
- data/docs/ApiAppResponseOwnerAccount.md +11 -0
- data/docs/ApiAppResponseWhiteLabelingOptions.md +23 -0
- data/docs/ApiAppUpdateRequest.md +16 -0
- data/docs/BulkSendJobApi.md +155 -0
- data/docs/BulkSendJobGetResponse.md +13 -0
- data/docs/BulkSendJobGetResponseSignatureRequests.md +33 -0
- data/docs/BulkSendJobListResponse.md +12 -0
- data/docs/BulkSendJobResponse.md +13 -0
- data/docs/BulkSendJobSendResponse.md +11 -0
- data/docs/EmbeddedApi.md +158 -0
- data/docs/EmbeddedEditUrlRequest.md +19 -0
- data/docs/EmbeddedEditUrlResponse.md +11 -0
- data/docs/EmbeddedEditUrlResponseEmbedded.md +11 -0
- data/docs/EmbeddedSignUrlResponse.md +11 -0
- data/docs/EmbeddedSignUrlResponseEmbedded.md +11 -0
- data/docs/ErrorResponse.md +10 -0
- data/docs/ErrorResponseError.md +12 -0
- data/docs/EventCallbackRequest.md +13 -0
- data/docs/EventCallbackRequestEvent.md +13 -0
- data/docs/EventCallbackRequestEventMetadata.md +13 -0
- data/docs/FileResponse.md +11 -0
- data/docs/FileResponseDataUri.md +10 -0
- data/docs/ListInfoResponse.md +13 -0
- data/docs/OAuthApi.md +158 -0
- data/docs/OAuthTokenGenerateRequest.md +14 -0
- data/docs/OAuthTokenRefreshRequest.md +11 -0
- data/docs/OAuthTokenResponse.md +14 -0
- data/docs/ReportApi.md +83 -0
- data/docs/ReportCreateRequest.md +12 -0
- data/docs/ReportCreateResponse.md +11 -0
- data/docs/ReportResponse.md +13 -0
- data/docs/SignatureRequestApi.md +1377 -0
- data/docs/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.md +22 -0
- data/docs/SignatureRequestBulkSendWithTemplateRequest.md +22 -0
- data/docs/SignatureRequestCreateEmbeddedRequest.md +33 -0
- data/docs/SignatureRequestCreateEmbeddedWithTemplateRequest.md +24 -0
- data/docs/SignatureRequestGetResponse.md +11 -0
- data/docs/SignatureRequestListResponse.md +12 -0
- data/docs/SignatureRequestRemindRequest.md +11 -0
- data/docs/SignatureRequestResponse.md +32 -0
- data/docs/SignatureRequestResponseAttachment.md +15 -0
- data/docs/SignatureRequestResponseCustomFieldBase.md +17 -0
- data/docs/SignatureRequestResponseCustomFieldCheckbox.md +11 -0
- data/docs/SignatureRequestResponseCustomFieldText.md +11 -0
- data/docs/SignatureRequestResponseCustomFieldTypeEnum.md +9 -0
- data/docs/SignatureRequestResponseDataBase.md +14 -0
- data/docs/SignatureRequestResponseDataTypeEnum.md +9 -0
- data/docs/SignatureRequestResponseDataValueCheckbox.md +11 -0
- data/docs/SignatureRequestResponseDataValueCheckboxMerge.md +11 -0
- data/docs/SignatureRequestResponseDataValueDateSigned.md +11 -0
- data/docs/SignatureRequestResponseDataValueDropdown.md +11 -0
- data/docs/SignatureRequestResponseDataValueInitials.md +11 -0
- data/docs/SignatureRequestResponseDataValueRadio.md +11 -0
- data/docs/SignatureRequestResponseDataValueSignature.md +11 -0
- data/docs/SignatureRequestResponseDataValueText.md +11 -0
- data/docs/SignatureRequestResponseDataValueTextMerge.md +11 -0
- data/docs/SignatureRequestResponseSignatures.md +28 -0
- data/docs/SignatureRequestSendRequest.md +34 -0
- data/docs/SignatureRequestSendWithTemplateRequest.md +25 -0
- data/docs/SignatureRequestUpdateRequest.md +13 -0
- data/docs/SubAttachment.md +13 -0
- data/docs/SubBulkSignerList.md +11 -0
- data/docs/SubBulkSignerListCustomField.md +11 -0
- data/docs/SubCC.md +11 -0
- data/docs/SubCustomField.md +17 -0
- data/docs/SubEditorOptions.md +11 -0
- data/docs/SubFieldOptions.md +10 -0
- data/docs/SubFormFieldGroup.md +12 -0
- data/docs/SubFormFieldRule.md +13 -0
- data/docs/SubFormFieldRuleAction.md +13 -0
- data/docs/SubFormFieldRuleTrigger.md +13 -0
- data/docs/SubFormFieldsPerDocumentBase.md +33 -0
- data/docs/SubFormFieldsPerDocumentCheckbox.md +12 -0
- data/docs/SubFormFieldsPerDocumentCheckboxMerge.md +10 -0
- data/docs/SubFormFieldsPerDocumentDateSigned.md +10 -0
- data/docs/SubFormFieldsPerDocumentDropdown.md +12 -0
- data/docs/SubFormFieldsPerDocumentHyperlink.md +12 -0
- data/docs/SubFormFieldsPerDocumentInitials.md +10 -0
- data/docs/SubFormFieldsPerDocumentRadio.md +12 -0
- data/docs/SubFormFieldsPerDocumentSignature.md +10 -0
- data/docs/SubFormFieldsPerDocumentText.md +17 -0
- data/docs/SubFormFieldsPerDocumentTextMerge.md +10 -0
- data/docs/SubFormFieldsPerDocumentTypeEnum.md +9 -0
- data/docs/SubMergeField.md +11 -0
- data/docs/SubOAuth.md +11 -0
- data/docs/SubOptions.md +10 -0
- data/docs/SubSignatureRequestGroupedSigners.md +12 -0
- data/docs/SubSignatureRequestSigner.md +15 -0
- data/docs/SubSignatureRequestTemplateSigner.md +15 -0
- data/docs/SubSigningOptions.md +16 -0
- data/docs/SubTeamResponse.md +11 -0
- data/docs/SubTemplateRole.md +11 -0
- data/docs/SubUnclaimedDraftSigner.md +12 -0
- data/docs/SubUnclaimedDraftTemplateSigner.md +12 -0
- data/docs/SubWhiteLabelingOptions.md +26 -0
- data/docs/TeamAddMemberRequest.md +12 -0
- data/docs/TeamApi.md +737 -0
- data/docs/TeamCreateRequest.md +10 -0
- data/docs/TeamGetInfoResponse.md +11 -0
- data/docs/TeamGetResponse.md +11 -0
- data/docs/TeamInfoResponse.md +14 -0
- data/docs/TeamInviteResponse.md +15 -0
- data/docs/TeamInvitesResponse.md +11 -0
- data/docs/TeamMemberResponse.md +12 -0
- data/docs/TeamMembersResponse.md +12 -0
- data/docs/TeamParentResponse.md +11 -0
- data/docs/TeamRemoveMemberRequest.md +14 -0
- data/docs/TeamResponse.md +12 -0
- data/docs/TeamSubTeamsResponse.md +12 -0
- data/docs/TeamUpdateRequest.md +10 -0
- data/docs/TemplateAddUserRequest.md +12 -0
- data/docs/TemplateApi.md +782 -0
- data/docs/TemplateCreateEmbeddedDraftRequest.md +34 -0
- data/docs/TemplateCreateEmbeddedDraftResponse.md +11 -0
- data/docs/TemplateCreateEmbeddedDraftResponseTemplate.md +13 -0
- data/docs/TemplateEditResponse.md +10 -0
- data/docs/TemplateGetResponse.md +11 -0
- data/docs/TemplateListResponse.md +12 -0
- data/docs/TemplateRemoveUserRequest.md +11 -0
- data/docs/TemplateResponse.md +24 -0
- data/docs/TemplateResponseAccount.md +15 -0
- data/docs/TemplateResponseAccountQuota.md +13 -0
- data/docs/TemplateResponseCCRole.md +10 -0
- data/docs/TemplateResponseCustomField.md +22 -0
- data/docs/TemplateResponseDocument.md +15 -0
- data/docs/TemplateResponseDocumentCustomField.md +25 -0
- data/docs/TemplateResponseDocumentFieldGroup.md +11 -0
- data/docs/TemplateResponseDocumentFormField.md +23 -0
- data/docs/TemplateResponseDocumentStaticField.md +19 -0
- data/docs/TemplateResponseFieldAvgTextLength.md +11 -0
- data/docs/TemplateResponseNamedFormField.md +23 -0
- data/docs/TemplateResponseSignerRole.md +11 -0
- data/docs/TemplateUpdateFilesRequest.md +15 -0
- data/docs/TemplateUpdateFilesResponse.md +10 -0
- data/docs/TemplateUpdateFilesResponseTemplate.md +11 -0
- data/docs/UnclaimedDraftApi.md +359 -0
- data/docs/UnclaimedDraftCreateEmbeddedRequest.md +45 -0
- data/docs/UnclaimedDraftCreateEmbeddedWithTemplateRequest.md +38 -0
- data/docs/UnclaimedDraftCreateRequest.md +33 -0
- data/docs/UnclaimedDraftCreateResponse.md +11 -0
- data/docs/UnclaimedDraftEditAndResendRequest.md +17 -0
- data/docs/UnclaimedDraftResponse.md +15 -0
- data/docs/WarningResponse.md +11 -0
- data/dropbox-sign.gemspec +38 -0
- data/examples/AccountCreate.rb +21 -0
- data/examples/AccountGet.rb +18 -0
- data/examples/AccountUpdate.rb +21 -0
- data/examples/AccountVerify.rb +21 -0
- data/examples/ApiAppCreate.rb +35 -0
- data/examples/ApiAppDelete.rb +20 -0
- data/examples/ApiAppGet.rb +20 -0
- data/examples/ApiAppList.rb +21 -0
- data/examples/ApiAppUpdate.rb +32 -0
- data/examples/BulkSendJobGet.rb +20 -0
- data/examples/BulkSendJobList.rb +21 -0
- data/examples/EmbeddedEditUrl.rb +24 -0
- data/examples/EmbeddedSignUrl.rb +20 -0
- data/examples/EventCallback.rb +32 -0
- data/examples/OauthTokenGenerate.rb +24 -0
- data/examples/OauthTokenRefresh.rb +21 -0
- data/examples/ReportCreate.rb +23 -0
- data/examples/SignatureRequestBulkCreateEmbeddedWithTemplate.rb +59 -0
- data/examples/SignatureRequestBulkSendWithTemplate.rb +58 -0
- data/examples/SignatureRequestCancel.rb +20 -0
- data/examples/SignatureRequestCreateEmbedded.rb +46 -0
- data/examples/SignatureRequestCreateEmbeddedWithTemplate.rb +39 -0
- data/examples/SignatureRequestFiles.rb +20 -0
- data/examples/SignatureRequestFilesAsDataUri.rb +20 -0
- data/examples/SignatureRequestFilesAsFileUrl.rb +20 -0
- data/examples/SignatureRequestGet.rb +20 -0
- data/examples/SignatureRequestList.rb +21 -0
- data/examples/SignatureRequestReleaseHold.rb +20 -0
- data/examples/SignatureRequestRemind.rb +23 -0
- data/examples/SignatureRequestRemove.rb +20 -0
- data/examples/SignatureRequestSend.rb +56 -0
- data/examples/SignatureRequestSendWithTemplate.rb +50 -0
- data/examples/SignatureRequestUpdate.rb +24 -0
- data/examples/TeamAddMember.rb +21 -0
- data/examples/TeamCreate.rb +21 -0
- data/examples/TeamDelete.rb +18 -0
- data/examples/TeamGet.rb +18 -0
- data/examples/TeamInfo.rb +18 -0
- data/examples/TeamInvites.rb +20 -0
- data/examples/TeamMembers.rb +20 -0
- data/examples/TeamRemoveMember.rb +22 -0
- data/examples/TeamSubTeams.rb +20 -0
- data/examples/TeamUpdate.rb +21 -0
- data/examples/TemplateAddUser.rb +23 -0
- data/examples/TemplateCreateEmbeddedDraft.rb +49 -0
- data/examples/TemplateDelete.rb +20 -0
- data/examples/TemplateFiles.rb +20 -0
- data/examples/TemplateFilesAsDataUri.rb +20 -0
- data/examples/TemplateFilesAsFileUrl.rb +20 -0
- data/examples/TemplateGet.rb +20 -0
- data/examples/TemplateList.rb +20 -0
- data/examples/TemplateRemoveUser.rb +23 -0
- data/examples/TemplateUpdateFiles.rb +23 -0
- data/examples/UnclaimedDraftCreate.rb +56 -0
- data/examples/UnclaimedDraftCreateEmbedded.rb +24 -0
- data/examples/UnclaimedDraftCreateEmbeddedWithTemplate.rb +35 -0
- data/examples/UnclaimedDraftEditAndResend.rb +24 -0
- data/lib/dropbox-sign/api/account_api.rb +446 -0
- data/lib/dropbox-sign/api/api_app_api.rb +504 -0
- data/lib/dropbox-sign/api/bulk_send_job_api.rb +213 -0
- data/lib/dropbox-sign/api/embedded_api.rb +234 -0
- data/lib/dropbox-sign/api/o_auth_api.rb +215 -0
- data/lib/dropbox-sign/api/report_api.rb +134 -0
- data/lib/dropbox-sign/api/signature_request_api.rb +1620 -0
- data/lib/dropbox-sign/api/team_api.rb +1011 -0
- data/lib/dropbox-sign/api/template_api.rb +1037 -0
- data/lib/dropbox-sign/api/unclaimed_draft_api.rb +467 -0
- data/lib/dropbox-sign/api_client.rb +417 -0
- data/lib/dropbox-sign/api_error.rb +60 -0
- data/lib/dropbox-sign/configuration.rb +303 -0
- data/lib/dropbox-sign/event_callback_helper.rb +54 -0
- data/lib/dropbox-sign/models/account_create_request.rb +285 -0
- data/lib/dropbox-sign/models/account_create_response.rb +270 -0
- data/lib/dropbox-sign/models/account_get_response.rb +261 -0
- data/lib/dropbox-sign/models/account_response.rb +343 -0
- data/lib/dropbox-sign/models/account_response_quotas.rb +296 -0
- data/lib/dropbox-sign/models/account_update_request.rb +271 -0
- data/lib/dropbox-sign/models/account_verify_request.rb +255 -0
- data/lib/dropbox-sign/models/account_verify_response.rb +261 -0
- data/lib/dropbox-sign/models/account_verify_response_account.rb +250 -0
- data/lib/dropbox-sign/models/api_app_create_request.rb +347 -0
- data/lib/dropbox-sign/models/api_app_get_response.rb +261 -0
- data/lib/dropbox-sign/models/api_app_list_response.rb +273 -0
- data/lib/dropbox-sign/models/api_app_response.rb +343 -0
- data/lib/dropbox-sign/models/api_app_response_o_auth.rb +283 -0
- data/lib/dropbox-sign/models/api_app_response_options.rb +251 -0
- data/lib/dropbox-sign/models/api_app_response_owner_account.rb +261 -0
- data/lib/dropbox-sign/models/api_app_response_white_labeling_options.rb +367 -0
- data/lib/dropbox-sign/models/api_app_update_request.rb +324 -0
- data/lib/dropbox-sign/models/bulk_send_job_get_response.rb +282 -0
- data/lib/dropbox-sign/models/bulk_send_job_get_response_signature_requests.rb +503 -0
- data/lib/dropbox-sign/models/bulk_send_job_list_response.rb +273 -0
- data/lib/dropbox-sign/models/bulk_send_job_response.rb +282 -0
- data/lib/dropbox-sign/models/bulk_send_job_send_response.rb +261 -0
- data/lib/dropbox-sign/models/embedded_edit_url_request.rb +357 -0
- data/lib/dropbox-sign/models/embedded_edit_url_response.rb +261 -0
- data/lib/dropbox-sign/models/embedded_edit_url_response_embedded.rb +261 -0
- data/lib/dropbox-sign/models/embedded_sign_url_response.rb +261 -0
- data/lib/dropbox-sign/models/embedded_sign_url_response_embedded.rb +261 -0
- data/lib/dropbox-sign/models/error_response.rb +254 -0
- data/lib/dropbox-sign/models/error_response_error.rb +281 -0
- data/lib/dropbox-sign/models/event_callback_request.rb +281 -0
- data/lib/dropbox-sign/models/event_callback_request_event.rb +334 -0
- data/lib/dropbox-sign/models/event_callback_request_event_metadata.rb +285 -0
- data/lib/dropbox-sign/models/file_response.rb +260 -0
- data/lib/dropbox-sign/models/file_response_data_uri.rb +250 -0
- data/lib/dropbox-sign/models/list_info_response.rb +282 -0
- data/lib/dropbox-sign/models/o_auth_token_generate_request.rb +317 -0
- data/lib/dropbox-sign/models/o_auth_token_refresh_request.rb +272 -0
- data/lib/dropbox-sign/models/o_auth_token_response.rb +287 -0
- data/lib/dropbox-sign/models/report_create_request.rb +319 -0
- data/lib/dropbox-sign/models/report_create_response.rb +261 -0
- data/lib/dropbox-sign/models/report_response.rb +305 -0
- data/lib/dropbox-sign/models/signature_request_bulk_create_embedded_with_template_request.rb +445 -0
- data/lib/dropbox-sign/models/signature_request_bulk_send_with_template_request.rb +440 -0
- data/lib/dropbox-sign/models/signature_request_create_embedded_request.rb +569 -0
- data/lib/dropbox-sign/models/signature_request_create_embedded_with_template_request.rb +475 -0
- data/lib/dropbox-sign/models/signature_request_get_response.rb +261 -0
- data/lib/dropbox-sign/models/signature_request_list_response.rb +273 -0
- data/lib/dropbox-sign/models/signature_request_remind_request.rb +265 -0
- data/lib/dropbox-sign/models/signature_request_response.rb +494 -0
- data/lib/dropbox-sign/models/signature_request_response_attachment.rb +323 -0
- data/lib/dropbox-sign/models/signature_request_response_custom_field_base.rb +316 -0
- data/lib/dropbox-sign/models/signature_request_response_custom_field_checkbox.rb +272 -0
- data/lib/dropbox-sign/models/signature_request_response_custom_field_text.rb +272 -0
- data/lib/dropbox-sign/models/signature_request_response_custom_field_type_enum.rb +40 -0
- data/lib/dropbox-sign/models/signature_request_response_data_base.rb +326 -0
- data/lib/dropbox-sign/models/signature_request_response_data_type_enum.rb +47 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_checkbox.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_checkbox_merge.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_date_signed.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_dropdown.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_initials.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_radio.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_signature.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_text.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_data_value_text_merge.rb +266 -0
- data/lib/dropbox-sign/models/signature_request_response_signatures.rb +446 -0
- data/lib/dropbox-sign/models/signature_request_send_request.rb +574 -0
- data/lib/dropbox-sign/models/signature_request_send_with_template_request.rb +480 -0
- data/lib/dropbox-sign/models/signature_request_update_request.rb +286 -0
- data/lib/dropbox-sign/models/sub_attachment.rb +292 -0
- data/lib/dropbox-sign/models/sub_bulk_signer_list.rb +264 -0
- data/lib/dropbox-sign/models/sub_bulk_signer_list_custom_field.rb +270 -0
- data/lib/dropbox-sign/models/sub_cc.rb +270 -0
- data/lib/dropbox-sign/models/sub_custom_field.rb +288 -0
- data/lib/dropbox-sign/models/sub_editor_options.rb +265 -0
- data/lib/dropbox-sign/models/sub_field_options.rb +290 -0
- data/lib/dropbox-sign/models/sub_form_field_group.rb +285 -0
- data/lib/dropbox-sign/models/sub_form_field_rule.rb +353 -0
- data/lib/dropbox-sign/models/sub_form_field_rule_action.rb +323 -0
- data/lib/dropbox-sign/models/sub_form_field_rule_trigger.rb +326 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_base.rb +435 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_checkbox.rb +287 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_checkbox_merge.rb +262 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_date_signed.rb +262 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_dropdown.rb +308 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_hyperlink.rb +292 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_initials.rb +262 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_radio.rb +292 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_signature.rb +262 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_text.rb +364 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_text_merge.rb +262 -0
- data/lib/dropbox-sign/models/sub_form_fields_per_document_type_enum.rb +48 -0
- data/lib/dropbox-sign/models/sub_merge_field.rb +304 -0
- data/lib/dropbox-sign/models/sub_o_auth.rb +285 -0
- data/lib/dropbox-sign/models/sub_options.rb +253 -0
- data/lib/dropbox-sign/models/sub_signature_request_grouped_signers.rb +283 -0
- data/lib/dropbox-sign/models/sub_signature_request_signer.rb +369 -0
- data/lib/dropbox-sign/models/sub_signature_request_template_signer.rb +373 -0
- data/lib/dropbox-sign/models/sub_signing_options.rb +338 -0
- data/lib/dropbox-sign/models/sub_team_response.rb +260 -0
- data/lib/dropbox-sign/models/sub_template_role.rb +261 -0
- data/lib/dropbox-sign/models/sub_unclaimed_draft_signer.rb +281 -0
- data/lib/dropbox-sign/models/sub_unclaimed_draft_template_signer.rb +285 -0
- data/lib/dropbox-sign/models/sub_white_labeling_options.rb +439 -0
- data/lib/dropbox-sign/models/team_add_member_request.rb +304 -0
- data/lib/dropbox-sign/models/team_create_request.rb +252 -0
- data/lib/dropbox-sign/models/team_get_info_response.rb +261 -0
- data/lib/dropbox-sign/models/team_get_response.rb +261 -0
- data/lib/dropbox-sign/models/team_info_response.rb +290 -0
- data/lib/dropbox-sign/models/team_invite_response.rb +300 -0
- data/lib/dropbox-sign/models/team_invites_response.rb +263 -0
- data/lib/dropbox-sign/models/team_member_response.rb +270 -0
- data/lib/dropbox-sign/models/team_members_response.rb +272 -0
- data/lib/dropbox-sign/models/team_parent_response.rb +261 -0
- data/lib/dropbox-sign/models/team_remove_member_request.rb +324 -0
- data/lib/dropbox-sign/models/team_response.rb +274 -0
- data/lib/dropbox-sign/models/team_sub_teams_response.rb +272 -0
- data/lib/dropbox-sign/models/team_update_request.rb +250 -0
- data/lib/dropbox-sign/models/template_add_user_request.rb +272 -0
- data/lib/dropbox-sign/models/template_create_embedded_draft_request.rb +567 -0
- data/lib/dropbox-sign/models/template_create_embedded_draft_response.rb +261 -0
- data/lib/dropbox-sign/models/template_create_embedded_draft_response_template.rb +283 -0
- data/lib/dropbox-sign/models/template_edit_response.rb +250 -0
- data/lib/dropbox-sign/models/template_get_response.rb +261 -0
- data/lib/dropbox-sign/models/template_list_response.rb +273 -0
- data/lib/dropbox-sign/models/template_remove_user_request.rb +260 -0
- data/lib/dropbox-sign/models/template_response.rb +410 -0
- data/lib/dropbox-sign/models/template_response_account.rb +299 -0
- data/lib/dropbox-sign/models/template_response_account_quota.rb +281 -0
- data/lib/dropbox-sign/models/template_response_cc_role.rb +250 -0
- data/lib/dropbox-sign/models/template_response_custom_field.rb +407 -0
- data/lib/dropbox-sign/models/template_response_document.rb +309 -0
- data/lib/dropbox-sign/models/template_response_document_custom_field.rb +438 -0
- data/lib/dropbox-sign/models/template_response_document_field_group.rb +260 -0
- data/lib/dropbox-sign/models/template_response_document_form_field.rb +417 -0
- data/lib/dropbox-sign/models/template_response_document_static_field.rb +341 -0
- data/lib/dropbox-sign/models/template_response_field_avg_text_length.rb +261 -0
- data/lib/dropbox-sign/models/template_response_named_form_field.rb +383 -0
- data/lib/dropbox-sign/models/template_response_signer_role.rb +260 -0
- data/lib/dropbox-sign/models/template_update_files_request.rb +336 -0
- data/lib/dropbox-sign/models/template_update_files_response.rb +249 -0
- data/lib/dropbox-sign/models/template_update_files_response_template.rb +263 -0
- data/lib/dropbox-sign/models/unclaimed_draft_create_embedded_request.rb +728 -0
- data/lib/dropbox-sign/models/unclaimed_draft_create_embedded_with_template_request.rb +631 -0
- data/lib/dropbox-sign/models/unclaimed_draft_create_request.rb +586 -0
- data/lib/dropbox-sign/models/unclaimed_draft_create_response.rb +261 -0
- data/lib/dropbox-sign/models/unclaimed_draft_edit_and_resend_request.rb +328 -0
- data/lib/dropbox-sign/models/unclaimed_draft_response.rb +305 -0
- data/lib/dropbox-sign/models/warning_response.rb +271 -0
- data/lib/dropbox-sign/version.rb +18 -0
- data/lib/dropbox-sign.rb +204 -0
- data/openapi-config.yaml +21 -0
- data/openapi-sdk.yaml +11080 -0
- data/run-build +53 -0
- data/spec/api/account_api_spec.rb +107 -0
- data/spec/api/api_app_api_spec.rb +95 -0
- data/spec/api/bulk_send_job_api_spec.rb +52 -0
- data/spec/api/embedded_api_spec.rb +55 -0
- data/spec/api/oauth_api_spec.rb +55 -0
- data/spec/api/report_api_spec.rb +38 -0
- data/spec/api/signature_request_api_spec.rb +263 -0
- data/spec/api/team_api_spec.rb +105 -0
- data/spec/api/template_api_spec.rb +147 -0
- data/spec/api/unclaimed_draft_api_spec.rb +95 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/event_callback_helper_spec.rb +22 -0
- data/spec/fixtures_spec.rb +59 -0
- data/spec/models/sub_form_fields_per_document_base_spec.rb +24 -0
- data/spec/spec_helper.rb +111 -0
- data/spec/test_utils.rb +19 -0
- data/templates/Gemfile.mustache +10 -0
- data/templates/README.mustache +133 -0
- data/templates/Rakefile.mustache +10 -0
- data/templates/api.mustache +283 -0
- data/templates/api_client.mustache +291 -0
- data/templates/api_client_faraday_partial.mustache +136 -0
- data/templates/api_client_spec.mustache +220 -0
- data/templates/api_client_typhoeus_partial.mustache +153 -0
- data/templates/api_doc.mustache +77 -0
- data/templates/api_error.mustache +52 -0
- data/templates/api_info.mustache +12 -0
- data/templates/api_test.mustache +47 -0
- data/templates/base_object.mustache +132 -0
- data/templates/configuration.mustache +372 -0
- data/templates/configuration_spec.mustache +34 -0
- data/templates/configuration_tls_faraday_partial.mustache +29 -0
- data/templates/configuration_tls_typhoeus_partial.mustache +34 -0
- data/templates/event_callback_helper.mustache +46 -0
- data/templates/gem.mustache +55 -0
- data/templates/gemspec.mustache +35 -0
- data/templates/git_push.sh.mustache +57 -0
- data/templates/gitignore.mustache +41 -0
- data/templates/model.mustache +29 -0
- data/templates/model_doc.mustache +12 -0
- data/templates/model_test.mustache +77 -0
- data/templates/partial_model_enum_class.mustache +20 -0
- data/templates/partial_model_generic.mustache +414 -0
- data/templates/partial_model_generic_doc.mustache +10 -0
- data/templates/partial_oneof_module.mustache +137 -0
- data/templates/partial_oneof_module_doc.mustache +92 -0
- data/templates/rspec.mustache +2 -0
- data/templates/rubocop.mustache +148 -0
- data/templates/spec_helper.mustache +103 -0
- data/templates/travis.mustache +14 -0
- data/templates/version.mustache +10 -0
- data/test_fixtures/AccountCreateRequest.json +7 -0
- data/test_fixtures/AccountCreateResponse.json +15 -0
- data/test_fixtures/AccountGetResponse.json +14 -0
- data/test_fixtures/AccountUpdateRequest.json +5 -0
- data/test_fixtures/AccountVerifyRequest.json +5 -0
- data/test_fixtures/AccountVerifyResponse.json +7 -0
- data/test_fixtures/ApiAppCreateRequest.json +35 -0
- data/test_fixtures/ApiAppGetResponse.json +27 -0
- data/test_fixtures/ApiAppListResponse.json +42 -0
- data/test_fixtures/ApiAppUpdateRequest.json +35 -0
- data/test_fixtures/BulkSendJobGetResponse.json +67 -0
- data/test_fixtures/BulkSendJobListResponse.json +24 -0
- data/test_fixtures/BulkSendJobSendResponse.json +10 -0
- data/test_fixtures/EmbeddedEditUrlRequest.json +28 -0
- data/test_fixtures/EmbeddedEditUrlResponse.json +8 -0
- data/test_fixtures/EmbeddedSignUrlResponse.json +8 -0
- data/test_fixtures/ErrorResponse.json +9 -0
- data/test_fixtures/EventCallbackHelper.json +50 -0
- data/test_fixtures/FileResponse.json +6 -0
- data/test_fixtures/OAuthTokenGenerateRequest.json +9 -0
- data/test_fixtures/OAuthTokenRefreshRequest.json +6 -0
- data/test_fixtures/OAuthTokenResponse.json +15 -0
- data/test_fixtures/ReportCreateRequest.json +10 -0
- data/test_fixtures/ReportCreateResponse.json +13 -0
- data/test_fixtures/SignatureRequestBulkCreateEmbeddedWithTemplateRequest.json +67 -0
- data/test_fixtures/SignatureRequestBulkSendWithTemplateRequest.json +66 -0
- data/test_fixtures/SignatureRequestCreateEmbeddedRequest.json +252 -0
- data/test_fixtures/SignatureRequestCreateEmbeddedWithTemplateRequest.json +60 -0
- data/test_fixtures/SignatureRequestGetResponse.json +146 -0
- data/test_fixtures/SignatureRequestListResponse.json +102 -0
- data/test_fixtures/SignatureRequestRemindRequest.json +5 -0
- data/test_fixtures/SignatureRequestSendRequest.json +463 -0
- data/test_fixtures/SignatureRequestSendWithTemplateRequest.json +48 -0
- data/test_fixtures/SignatureRequestUpdateRequest.json +7 -0
- data/test_fixtures/SubFormFieldsPerDocument.json +107 -0
- data/test_fixtures/TeamAddMemberRequest.json +6 -0
- data/test_fixtures/TeamCreateRequest.json +5 -0
- data/test_fixtures/TeamGetResponse.json +34 -0
- data/test_fixtures/TeamRemoveMemberRequest.json +7 -0
- data/test_fixtures/TeamUpdateRequest.json +5 -0
- data/test_fixtures/TemplateAddUserRequest.json +7 -0
- data/test_fixtures/TemplateCreateEmbeddedDraftRequest.json +118 -0
- data/test_fixtures/TemplateCreateEmbeddedDraftResponse.json +9 -0
- data/test_fixtures/TemplateGetResponse.json +102 -0
- data/test_fixtures/TemplateListResponse.json +143 -0
- data/test_fixtures/TemplateRemoveUserRequest.json +6 -0
- data/test_fixtures/TemplateUpdateFilesRequest.json +11 -0
- data/test_fixtures/TemplateUpdateFilesResponse.json +7 -0
- data/test_fixtures/UnclaimedDraftCreateEmbeddedRequest.json +134 -0
- data/test_fixtures/UnclaimedDraftCreateEmbeddedWithTemplateRequest.json +67 -0
- data/test_fixtures/UnclaimedDraftCreateRequest.json +119 -0
- data/test_fixtures/UnclaimedDraftCreateResponse.json +9 -0
- data/test_fixtures/UnclaimedDraftEditAndResendRequest.json +15 -0
- data/test_fixtures/bulk-send-sample.csv +3 -0
- data/test_fixtures/pdf-sample-2.pdf +0 -0
- data/test_fixtures/pdf-sample.pdf +0 -0
- data/vendor/autoload.php +7 -0
- data/vendor/bin/yaml-lint +117 -0
- data/vendor/composer/ClassLoader.php +572 -0
- data/vendor/composer/InstalledVersions.php +350 -0
- data/vendor/composer/LICENSE +21 -0
- data/vendor/composer/autoload_classmap.php +10 -0
- data/vendor/composer/autoload_files.php +11 -0
- data/vendor/composer/autoload_namespaces.php +9 -0
- data/vendor/composer/autoload_psr4.php +11 -0
- data/vendor/composer/autoload_real.php +80 -0
- data/vendor/composer/autoload_static.php +46 -0
- data/vendor/composer/installed.json +239 -0
- data/vendor/composer/installed.php +50 -0
- data/vendor/composer/platform_check.php +26 -0
- data/vendor/symfony/deprecation-contracts/.gitignore +3 -0
- data/vendor/symfony/deprecation-contracts/CHANGELOG.md +5 -0
- data/vendor/symfony/deprecation-contracts/LICENSE +19 -0
- data/vendor/symfony/deprecation-contracts/README.md +26 -0
- data/vendor/symfony/deprecation-contracts/composer.json +35 -0
- data/vendor/symfony/deprecation-contracts/function.php +27 -0
- data/vendor/symfony/polyfill-ctype/Ctype.php +232 -0
- data/vendor/symfony/polyfill-ctype/LICENSE +19 -0
- data/vendor/symfony/polyfill-ctype/README.md +12 -0
- data/vendor/symfony/polyfill-ctype/bootstrap.php +50 -0
- data/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -0
- data/vendor/symfony/polyfill-ctype/composer.json +41 -0
- data/vendor/symfony/yaml/CHANGELOG.md +237 -0
- data/vendor/symfony/yaml/Command/LintCommand.php +289 -0
- data/vendor/symfony/yaml/Dumper.php +140 -0
- data/vendor/symfony/yaml/Escaper.php +95 -0
- data/vendor/symfony/yaml/Exception/DumpException.php +21 -0
- data/vendor/symfony/yaml/Exception/ExceptionInterface.php +21 -0
- data/vendor/symfony/yaml/Exception/ParseException.php +132 -0
- data/vendor/symfony/yaml/Exception/RuntimeException.php +21 -0
- data/vendor/symfony/yaml/Inline.php +812 -0
- data/vendor/symfony/yaml/LICENSE +19 -0
- data/vendor/symfony/yaml/Parser.php +1305 -0
- data/vendor/symfony/yaml/README.md +13 -0
- data/vendor/symfony/yaml/Resources/bin/yaml-lint +45 -0
- data/vendor/symfony/yaml/Tag/TaggedValue.php +38 -0
- data/vendor/symfony/yaml/Unescaper.php +132 -0
- data/vendor/symfony/yaml/Yaml.php +100 -0
- data/vendor/symfony/yaml/composer.json +42 -0
- metadata +650 -0
@@ -0,0 +1,812 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
/*
|
4
|
+
* This file is part of the Symfony package.
|
5
|
+
*
|
6
|
+
* (c) Fabien Potencier <fabien@symfony.com>
|
7
|
+
*
|
8
|
+
* For the full copyright and license information, please view the LICENSE
|
9
|
+
* file that was distributed with this source code.
|
10
|
+
*/
|
11
|
+
|
12
|
+
namespace Symfony\Component\Yaml;
|
13
|
+
|
14
|
+
use Symfony\Component\Yaml\Exception\DumpException;
|
15
|
+
use Symfony\Component\Yaml\Exception\ParseException;
|
16
|
+
use Symfony\Component\Yaml\Tag\TaggedValue;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Inline implements a YAML parser/dumper for the YAML inline syntax.
|
20
|
+
*
|
21
|
+
* @author Fabien Potencier <fabien@symfony.com>
|
22
|
+
*
|
23
|
+
* @internal
|
24
|
+
*/
|
25
|
+
class Inline
|
26
|
+
{
|
27
|
+
public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
|
28
|
+
|
29
|
+
public static $parsedLineNumber = -1;
|
30
|
+
public static $parsedFilename;
|
31
|
+
|
32
|
+
private static $exceptionOnInvalidType = false;
|
33
|
+
private static $objectSupport = false;
|
34
|
+
private static $objectForMap = false;
|
35
|
+
private static $constantSupport = false;
|
36
|
+
|
37
|
+
public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null)
|
38
|
+
{
|
39
|
+
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
|
40
|
+
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
41
|
+
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
|
42
|
+
self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
|
43
|
+
self::$parsedFilename = $parsedFilename;
|
44
|
+
|
45
|
+
if (null !== $parsedLineNumber) {
|
46
|
+
self::$parsedLineNumber = $parsedLineNumber;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Converts a YAML string to a PHP value.
|
52
|
+
*
|
53
|
+
* @param string $value A YAML string
|
54
|
+
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
55
|
+
* @param array $references Mapping of variable names to values
|
56
|
+
*
|
57
|
+
* @return mixed
|
58
|
+
*
|
59
|
+
* @throws ParseException
|
60
|
+
*/
|
61
|
+
public static function parse(string $value = null, int $flags = 0, array &$references = [])
|
62
|
+
{
|
63
|
+
self::initialize($flags);
|
64
|
+
|
65
|
+
$value = trim($value);
|
66
|
+
|
67
|
+
if ('' === $value) {
|
68
|
+
return '';
|
69
|
+
}
|
70
|
+
|
71
|
+
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
|
72
|
+
$mbEncoding = mb_internal_encoding();
|
73
|
+
mb_internal_encoding('ASCII');
|
74
|
+
}
|
75
|
+
|
76
|
+
try {
|
77
|
+
$i = 0;
|
78
|
+
$tag = self::parseTag($value, $i, $flags);
|
79
|
+
switch ($value[$i]) {
|
80
|
+
case '[':
|
81
|
+
$result = self::parseSequence($value, $flags, $i, $references);
|
82
|
+
++$i;
|
83
|
+
break;
|
84
|
+
case '{':
|
85
|
+
$result = self::parseMapping($value, $flags, $i, $references);
|
86
|
+
++$i;
|
87
|
+
break;
|
88
|
+
default:
|
89
|
+
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
|
90
|
+
}
|
91
|
+
|
92
|
+
// some comments are allowed at the end
|
93
|
+
if (preg_replace('/\s*#.*$/A', '', substr($value, $i))) {
|
94
|
+
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
95
|
+
}
|
96
|
+
|
97
|
+
if (null !== $tag && '' !== $tag) {
|
98
|
+
return new TaggedValue($tag, $result);
|
99
|
+
}
|
100
|
+
|
101
|
+
return $result;
|
102
|
+
} finally {
|
103
|
+
if (isset($mbEncoding)) {
|
104
|
+
mb_internal_encoding($mbEncoding);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Dumps a given PHP variable to a YAML string.
|
111
|
+
*
|
112
|
+
* @param mixed $value The PHP variable to convert
|
113
|
+
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
|
114
|
+
*
|
115
|
+
* @throws DumpException When trying to dump PHP resource
|
116
|
+
*/
|
117
|
+
public static function dump($value, int $flags = 0): string
|
118
|
+
{
|
119
|
+
switch (true) {
|
120
|
+
case \is_resource($value):
|
121
|
+
if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
|
122
|
+
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
|
123
|
+
}
|
124
|
+
|
125
|
+
return self::dumpNull($flags);
|
126
|
+
case $value instanceof \DateTimeInterface:
|
127
|
+
return $value->format('c');
|
128
|
+
case $value instanceof \UnitEnum:
|
129
|
+
return sprintf('!php/const %s::%s', \get_class($value), $value->name);
|
130
|
+
case \is_object($value):
|
131
|
+
if ($value instanceof TaggedValue) {
|
132
|
+
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
|
133
|
+
}
|
134
|
+
|
135
|
+
if (Yaml::DUMP_OBJECT & $flags) {
|
136
|
+
return '!php/object '.self::dump(serialize($value));
|
137
|
+
}
|
138
|
+
|
139
|
+
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
|
140
|
+
$output = [];
|
141
|
+
|
142
|
+
foreach ($value as $key => $val) {
|
143
|
+
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
144
|
+
}
|
145
|
+
|
146
|
+
return sprintf('{ %s }', implode(', ', $output));
|
147
|
+
}
|
148
|
+
|
149
|
+
if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
|
150
|
+
throw new DumpException('Object support when dumping a YAML file has been disabled.');
|
151
|
+
}
|
152
|
+
|
153
|
+
return self::dumpNull($flags);
|
154
|
+
case \is_array($value):
|
155
|
+
return self::dumpArray($value, $flags);
|
156
|
+
case null === $value:
|
157
|
+
return self::dumpNull($flags);
|
158
|
+
case true === $value:
|
159
|
+
return 'true';
|
160
|
+
case false === $value:
|
161
|
+
return 'false';
|
162
|
+
case \is_int($value):
|
163
|
+
return $value;
|
164
|
+
case is_numeric($value) && false === strpbrk($value, "\f\n\r\t\v"):
|
165
|
+
$locale = setlocale(\LC_NUMERIC, 0);
|
166
|
+
if (false !== $locale) {
|
167
|
+
setlocale(\LC_NUMERIC, 'C');
|
168
|
+
}
|
169
|
+
if (\is_float($value)) {
|
170
|
+
$repr = (string) $value;
|
171
|
+
if (is_infinite($value)) {
|
172
|
+
$repr = str_ireplace('INF', '.Inf', $repr);
|
173
|
+
} elseif (floor($value) == $value && $repr == $value) {
|
174
|
+
// Preserve float data type since storing a whole number will result in integer value.
|
175
|
+
if (false === strpos($repr, 'E')) {
|
176
|
+
$repr = $repr.'.0';
|
177
|
+
}
|
178
|
+
}
|
179
|
+
} else {
|
180
|
+
$repr = \is_string($value) ? "'$value'" : (string) $value;
|
181
|
+
}
|
182
|
+
if (false !== $locale) {
|
183
|
+
setlocale(\LC_NUMERIC, $locale);
|
184
|
+
}
|
185
|
+
|
186
|
+
return $repr;
|
187
|
+
case '' == $value:
|
188
|
+
return "''";
|
189
|
+
case self::isBinaryString($value):
|
190
|
+
return '!!binary '.base64_encode($value);
|
191
|
+
case Escaper::requiresDoubleQuoting($value):
|
192
|
+
return Escaper::escapeWithDoubleQuotes($value);
|
193
|
+
case Escaper::requiresSingleQuoting($value):
|
194
|
+
case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value):
|
195
|
+
case Parser::preg_match(self::getHexRegex(), $value):
|
196
|
+
case Parser::preg_match(self::getTimestampRegex(), $value):
|
197
|
+
return Escaper::escapeWithSingleQuotes($value);
|
198
|
+
default:
|
199
|
+
return $value;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Check if given array is hash or just normal indexed array.
|
205
|
+
*
|
206
|
+
* @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check
|
207
|
+
*/
|
208
|
+
public static function isHash($value): bool
|
209
|
+
{
|
210
|
+
if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
|
211
|
+
return true;
|
212
|
+
}
|
213
|
+
|
214
|
+
$expectedKey = 0;
|
215
|
+
|
216
|
+
foreach ($value as $key => $val) {
|
217
|
+
if ($key !== $expectedKey++) {
|
218
|
+
return true;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
return false;
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Dumps a PHP array to a YAML string.
|
227
|
+
*
|
228
|
+
* @param array $value The PHP array to dump
|
229
|
+
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
|
230
|
+
*/
|
231
|
+
private static function dumpArray(array $value, int $flags): string
|
232
|
+
{
|
233
|
+
// array
|
234
|
+
if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
|
235
|
+
$output = [];
|
236
|
+
foreach ($value as $val) {
|
237
|
+
$output[] = self::dump($val, $flags);
|
238
|
+
}
|
239
|
+
|
240
|
+
return sprintf('[%s]', implode(', ', $output));
|
241
|
+
}
|
242
|
+
|
243
|
+
// hash
|
244
|
+
$output = [];
|
245
|
+
foreach ($value as $key => $val) {
|
246
|
+
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
247
|
+
}
|
248
|
+
|
249
|
+
return sprintf('{ %s }', implode(', ', $output));
|
250
|
+
}
|
251
|
+
|
252
|
+
private static function dumpNull(int $flags): string
|
253
|
+
{
|
254
|
+
if (Yaml::DUMP_NULL_AS_TILDE & $flags) {
|
255
|
+
return '~';
|
256
|
+
}
|
257
|
+
|
258
|
+
return 'null';
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Parses a YAML scalar.
|
263
|
+
*
|
264
|
+
* @return mixed
|
265
|
+
*
|
266
|
+
* @throws ParseException When malformed inline YAML string is parsed
|
267
|
+
*/
|
268
|
+
public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], bool &$isQuoted = null)
|
269
|
+
{
|
270
|
+
if (\in_array($scalar[$i], ['"', "'"], true)) {
|
271
|
+
// quoted scalar
|
272
|
+
$isQuoted = true;
|
273
|
+
$output = self::parseQuotedScalar($scalar, $i);
|
274
|
+
|
275
|
+
if (null !== $delimiters) {
|
276
|
+
$tmp = ltrim(substr($scalar, $i), " \n");
|
277
|
+
if ('' === $tmp) {
|
278
|
+
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
279
|
+
}
|
280
|
+
if (!\in_array($tmp[0], $delimiters)) {
|
281
|
+
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
282
|
+
}
|
283
|
+
}
|
284
|
+
} else {
|
285
|
+
// "normal" string
|
286
|
+
$isQuoted = false;
|
287
|
+
|
288
|
+
if (!$delimiters) {
|
289
|
+
$output = substr($scalar, $i);
|
290
|
+
$i += \strlen($output);
|
291
|
+
|
292
|
+
// remove comments
|
293
|
+
if (Parser::preg_match('/[ \t]+#/', $output, $match, \PREG_OFFSET_CAPTURE)) {
|
294
|
+
$output = substr($output, 0, $match[0][1]);
|
295
|
+
}
|
296
|
+
} elseif (Parser::preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
|
297
|
+
$output = $match[1];
|
298
|
+
$i += \strlen($output);
|
299
|
+
$output = trim($output);
|
300
|
+
} else {
|
301
|
+
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
302
|
+
}
|
303
|
+
|
304
|
+
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
|
305
|
+
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0] || '%' === $output[0])) {
|
306
|
+
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
|
307
|
+
}
|
308
|
+
|
309
|
+
if ($evaluate) {
|
310
|
+
$output = self::evaluateScalar($output, $flags, $references, $isQuoted);
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
return $output;
|
315
|
+
}
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Parses a YAML quoted scalar.
|
319
|
+
*
|
320
|
+
* @throws ParseException When malformed inline YAML string is parsed
|
321
|
+
*/
|
322
|
+
private static function parseQuotedScalar(string $scalar, int &$i = 0): string
|
323
|
+
{
|
324
|
+
if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
|
325
|
+
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
326
|
+
}
|
327
|
+
|
328
|
+
$output = substr($match[0], 1, -1);
|
329
|
+
|
330
|
+
$unescaper = new Unescaper();
|
331
|
+
if ('"' == $scalar[$i]) {
|
332
|
+
$output = $unescaper->unescapeDoubleQuotedString($output);
|
333
|
+
} else {
|
334
|
+
$output = $unescaper->unescapeSingleQuotedString($output);
|
335
|
+
}
|
336
|
+
|
337
|
+
$i += \strlen($match[0]);
|
338
|
+
|
339
|
+
return $output;
|
340
|
+
}
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Parses a YAML sequence.
|
344
|
+
*
|
345
|
+
* @throws ParseException When malformed inline YAML string is parsed
|
346
|
+
*/
|
347
|
+
private static function parseSequence(string $sequence, int $flags, int &$i = 0, array &$references = []): array
|
348
|
+
{
|
349
|
+
$output = [];
|
350
|
+
$len = \strlen($sequence);
|
351
|
+
++$i;
|
352
|
+
|
353
|
+
// [foo, bar, ...]
|
354
|
+
while ($i < $len) {
|
355
|
+
if (']' === $sequence[$i]) {
|
356
|
+
return $output;
|
357
|
+
}
|
358
|
+
if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
|
359
|
+
++$i;
|
360
|
+
|
361
|
+
continue;
|
362
|
+
}
|
363
|
+
|
364
|
+
$tag = self::parseTag($sequence, $i, $flags);
|
365
|
+
switch ($sequence[$i]) {
|
366
|
+
case '[':
|
367
|
+
// nested sequence
|
368
|
+
$value = self::parseSequence($sequence, $flags, $i, $references);
|
369
|
+
break;
|
370
|
+
case '{':
|
371
|
+
// nested mapping
|
372
|
+
$value = self::parseMapping($sequence, $flags, $i, $references);
|
373
|
+
break;
|
374
|
+
default:
|
375
|
+
$value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references, $isQuoted);
|
376
|
+
|
377
|
+
// the value can be an array if a reference has been resolved to an array var
|
378
|
+
if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
|
379
|
+
// embedded mapping?
|
380
|
+
try {
|
381
|
+
$pos = 0;
|
382
|
+
$value = self::parseMapping('{'.$value.'}', $flags, $pos, $references);
|
383
|
+
} catch (\InvalidArgumentException $e) {
|
384
|
+
// no, it's not
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
if (!$isQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
|
389
|
+
$references[$matches['ref']] = $matches['value'];
|
390
|
+
$value = $matches['value'];
|
391
|
+
}
|
392
|
+
|
393
|
+
--$i;
|
394
|
+
}
|
395
|
+
|
396
|
+
if (null !== $tag && '' !== $tag) {
|
397
|
+
$value = new TaggedValue($tag, $value);
|
398
|
+
}
|
399
|
+
|
400
|
+
$output[] = $value;
|
401
|
+
|
402
|
+
++$i;
|
403
|
+
}
|
404
|
+
|
405
|
+
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
406
|
+
}
|
407
|
+
|
408
|
+
/**
|
409
|
+
* Parses a YAML mapping.
|
410
|
+
*
|
411
|
+
* @return array|\stdClass
|
412
|
+
*
|
413
|
+
* @throws ParseException When malformed inline YAML string is parsed
|
414
|
+
*/
|
415
|
+
private static function parseMapping(string $mapping, int $flags, int &$i = 0, array &$references = [])
|
416
|
+
{
|
417
|
+
$output = [];
|
418
|
+
$len = \strlen($mapping);
|
419
|
+
++$i;
|
420
|
+
$allowOverwrite = false;
|
421
|
+
|
422
|
+
// {foo: bar, bar:foo, ...}
|
423
|
+
while ($i < $len) {
|
424
|
+
switch ($mapping[$i]) {
|
425
|
+
case ' ':
|
426
|
+
case ',':
|
427
|
+
case "\n":
|
428
|
+
++$i;
|
429
|
+
continue 2;
|
430
|
+
case '}':
|
431
|
+
if (self::$objectForMap) {
|
432
|
+
return (object) $output;
|
433
|
+
}
|
434
|
+
|
435
|
+
return $output;
|
436
|
+
}
|
437
|
+
|
438
|
+
// key
|
439
|
+
$offsetBeforeKeyParsing = $i;
|
440
|
+
$isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true);
|
441
|
+
$key = self::parseScalar($mapping, $flags, [':', ' '], $i, false);
|
442
|
+
|
443
|
+
if ($offsetBeforeKeyParsing === $i) {
|
444
|
+
throw new ParseException('Missing mapping key.', self::$parsedLineNumber + 1, $mapping);
|
445
|
+
}
|
446
|
+
|
447
|
+
if ('!php/const' === $key) {
|
448
|
+
$key .= ' '.self::parseScalar($mapping, $flags, [':'], $i, false);
|
449
|
+
$key = self::evaluateScalar($key, $flags);
|
450
|
+
}
|
451
|
+
|
452
|
+
if (false === $i = strpos($mapping, ':', $i)) {
|
453
|
+
break;
|
454
|
+
}
|
455
|
+
|
456
|
+
if (!$isKeyQuoted) {
|
457
|
+
$evaluatedKey = self::evaluateScalar($key, $flags, $references);
|
458
|
+
|
459
|
+
if ('' !== $key && $evaluatedKey !== $key && !\is_string($evaluatedKey) && !\is_int($evaluatedKey)) {
|
460
|
+
throw new ParseException('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead.', self::$parsedLineNumber + 1, $mapping);
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
464
|
+
if (!$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], [' ', ',', '[', ']', '{', '}', "\n"], true))) {
|
465
|
+
throw new ParseException('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}").', self::$parsedLineNumber + 1, $mapping);
|
466
|
+
}
|
467
|
+
|
468
|
+
if ('<<' === $key) {
|
469
|
+
$allowOverwrite = true;
|
470
|
+
}
|
471
|
+
|
472
|
+
while ($i < $len) {
|
473
|
+
if (':' === $mapping[$i] || ' ' === $mapping[$i] || "\n" === $mapping[$i]) {
|
474
|
+
++$i;
|
475
|
+
|
476
|
+
continue;
|
477
|
+
}
|
478
|
+
|
479
|
+
$tag = self::parseTag($mapping, $i, $flags);
|
480
|
+
switch ($mapping[$i]) {
|
481
|
+
case '[':
|
482
|
+
// nested sequence
|
483
|
+
$value = self::parseSequence($mapping, $flags, $i, $references);
|
484
|
+
// Spec: Keys MUST be unique; first one wins.
|
485
|
+
// Parser cannot abort this mapping earlier, since lines
|
486
|
+
// are processed sequentially.
|
487
|
+
// But overwriting is allowed when a merge node is used in current block.
|
488
|
+
if ('<<' === $key) {
|
489
|
+
foreach ($value as $parsedValue) {
|
490
|
+
$output += $parsedValue;
|
491
|
+
}
|
492
|
+
} elseif ($allowOverwrite || !isset($output[$key])) {
|
493
|
+
if (null !== $tag) {
|
494
|
+
$output[$key] = new TaggedValue($tag, $value);
|
495
|
+
} else {
|
496
|
+
$output[$key] = $value;
|
497
|
+
}
|
498
|
+
} elseif (isset($output[$key])) {
|
499
|
+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
500
|
+
}
|
501
|
+
break;
|
502
|
+
case '{':
|
503
|
+
// nested mapping
|
504
|
+
$value = self::parseMapping($mapping, $flags, $i, $references);
|
505
|
+
// Spec: Keys MUST be unique; first one wins.
|
506
|
+
// Parser cannot abort this mapping earlier, since lines
|
507
|
+
// are processed sequentially.
|
508
|
+
// But overwriting is allowed when a merge node is used in current block.
|
509
|
+
if ('<<' === $key) {
|
510
|
+
$output += $value;
|
511
|
+
} elseif ($allowOverwrite || !isset($output[$key])) {
|
512
|
+
if (null !== $tag) {
|
513
|
+
$output[$key] = new TaggedValue($tag, $value);
|
514
|
+
} else {
|
515
|
+
$output[$key] = $value;
|
516
|
+
}
|
517
|
+
} elseif (isset($output[$key])) {
|
518
|
+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
519
|
+
}
|
520
|
+
break;
|
521
|
+
default:
|
522
|
+
$value = self::parseScalar($mapping, $flags, [',', '}', "\n"], $i, null === $tag, $references, $isValueQuoted);
|
523
|
+
// Spec: Keys MUST be unique; first one wins.
|
524
|
+
// Parser cannot abort this mapping earlier, since lines
|
525
|
+
// are processed sequentially.
|
526
|
+
// But overwriting is allowed when a merge node is used in current block.
|
527
|
+
if ('<<' === $key) {
|
528
|
+
$output += $value;
|
529
|
+
} elseif ($allowOverwrite || !isset($output[$key])) {
|
530
|
+
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
|
531
|
+
$references[$matches['ref']] = $matches['value'];
|
532
|
+
$value = $matches['value'];
|
533
|
+
}
|
534
|
+
|
535
|
+
if (null !== $tag) {
|
536
|
+
$output[$key] = new TaggedValue($tag, $value);
|
537
|
+
} else {
|
538
|
+
$output[$key] = $value;
|
539
|
+
}
|
540
|
+
} elseif (isset($output[$key])) {
|
541
|
+
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
542
|
+
}
|
543
|
+
--$i;
|
544
|
+
}
|
545
|
+
++$i;
|
546
|
+
|
547
|
+
continue 2;
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
552
|
+
}
|
553
|
+
|
554
|
+
/**
|
555
|
+
* Evaluates scalars and replaces magic values.
|
556
|
+
*
|
557
|
+
* @return mixed
|
558
|
+
*
|
559
|
+
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
|
560
|
+
*/
|
561
|
+
private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null)
|
562
|
+
{
|
563
|
+
$isQuotedString = false;
|
564
|
+
$scalar = trim($scalar);
|
565
|
+
|
566
|
+
if (0 === strpos($scalar, '*')) {
|
567
|
+
if (false !== $pos = strpos($scalar, '#')) {
|
568
|
+
$value = substr($scalar, 1, $pos - 2);
|
569
|
+
} else {
|
570
|
+
$value = substr($scalar, 1);
|
571
|
+
}
|
572
|
+
|
573
|
+
// an unquoted *
|
574
|
+
if (false === $value || '' === $value) {
|
575
|
+
throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
576
|
+
}
|
577
|
+
|
578
|
+
if (!\array_key_exists($value, $references)) {
|
579
|
+
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
580
|
+
}
|
581
|
+
|
582
|
+
return $references[$value];
|
583
|
+
}
|
584
|
+
|
585
|
+
$scalarLower = strtolower($scalar);
|
586
|
+
|
587
|
+
switch (true) {
|
588
|
+
case 'null' === $scalarLower:
|
589
|
+
case '' === $scalar:
|
590
|
+
case '~' === $scalar:
|
591
|
+
return null;
|
592
|
+
case 'true' === $scalarLower:
|
593
|
+
return true;
|
594
|
+
case 'false' === $scalarLower:
|
595
|
+
return false;
|
596
|
+
case '!' === $scalar[0]:
|
597
|
+
switch (true) {
|
598
|
+
case 0 === strpos($scalar, '!!str '):
|
599
|
+
$s = (string) substr($scalar, 6);
|
600
|
+
|
601
|
+
if (\in_array($s[0] ?? '', ['"', "'"], true)) {
|
602
|
+
$isQuotedString = true;
|
603
|
+
$s = self::parseQuotedScalar($s);
|
604
|
+
}
|
605
|
+
|
606
|
+
return $s;
|
607
|
+
case 0 === strpos($scalar, '! '):
|
608
|
+
return substr($scalar, 2);
|
609
|
+
case 0 === strpos($scalar, '!php/object'):
|
610
|
+
if (self::$objectSupport) {
|
611
|
+
if (!isset($scalar[12])) {
|
612
|
+
trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/object tag without a value is deprecated.');
|
613
|
+
|
614
|
+
return false;
|
615
|
+
}
|
616
|
+
|
617
|
+
return unserialize(self::parseScalar(substr($scalar, 12)));
|
618
|
+
}
|
619
|
+
|
620
|
+
if (self::$exceptionOnInvalidType) {
|
621
|
+
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
622
|
+
}
|
623
|
+
|
624
|
+
return null;
|
625
|
+
case 0 === strpos($scalar, '!php/const'):
|
626
|
+
if (self::$constantSupport) {
|
627
|
+
if (!isset($scalar[11])) {
|
628
|
+
trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/const tag without a value is deprecated.');
|
629
|
+
|
630
|
+
return '';
|
631
|
+
}
|
632
|
+
|
633
|
+
$i = 0;
|
634
|
+
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
|
635
|
+
return \constant($const);
|
636
|
+
}
|
637
|
+
|
638
|
+
throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
639
|
+
}
|
640
|
+
if (self::$exceptionOnInvalidType) {
|
641
|
+
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
642
|
+
}
|
643
|
+
|
644
|
+
return null;
|
645
|
+
case 0 === strpos($scalar, '!!float '):
|
646
|
+
return (float) substr($scalar, 8);
|
647
|
+
case 0 === strpos($scalar, '!!binary '):
|
648
|
+
return self::evaluateBinaryScalar(substr($scalar, 9));
|
649
|
+
}
|
650
|
+
|
651
|
+
throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
|
652
|
+
case preg_match('/^(?:\+|-)?0o(?P<value>[0-7_]++)$/', $scalar, $matches):
|
653
|
+
$value = str_replace('_', '', $matches['value']);
|
654
|
+
|
655
|
+
if ('-' === $scalar[0]) {
|
656
|
+
return -octdec($value);
|
657
|
+
}
|
658
|
+
|
659
|
+
return octdec($value);
|
660
|
+
// Optimize for returning strings.
|
661
|
+
case \in_array($scalar[0], ['+', '-', '.'], true) || is_numeric($scalar[0]):
|
662
|
+
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
|
663
|
+
$scalar = str_replace('_', '', $scalar);
|
664
|
+
}
|
665
|
+
|
666
|
+
switch (true) {
|
667
|
+
case ctype_digit($scalar):
|
668
|
+
if (preg_match('/^0[0-7]+$/', $scalar)) {
|
669
|
+
trigger_deprecation('symfony/yaml', '5.1', 'Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0. Use "%s" to represent the octal number.', '0o'.substr($scalar, 1));
|
670
|
+
|
671
|
+
return octdec($scalar);
|
672
|
+
}
|
673
|
+
|
674
|
+
$cast = (int) $scalar;
|
675
|
+
|
676
|
+
return ($scalar === (string) $cast) ? $cast : $scalar;
|
677
|
+
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
|
678
|
+
if (preg_match('/^-0[0-7]+$/', $scalar)) {
|
679
|
+
trigger_deprecation('symfony/yaml', '5.1', 'Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0. Use "%s" to represent the octal number.', '-0o'.substr($scalar, 2));
|
680
|
+
|
681
|
+
return -octdec(substr($scalar, 1));
|
682
|
+
}
|
683
|
+
|
684
|
+
$cast = (int) $scalar;
|
685
|
+
|
686
|
+
return ($scalar === (string) $cast) ? $cast : $scalar;
|
687
|
+
case is_numeric($scalar):
|
688
|
+
case Parser::preg_match(self::getHexRegex(), $scalar):
|
689
|
+
$scalar = str_replace('_', '', $scalar);
|
690
|
+
|
691
|
+
return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
|
692
|
+
case '.inf' === $scalarLower:
|
693
|
+
case '.nan' === $scalarLower:
|
694
|
+
return -log(0);
|
695
|
+
case '-.inf' === $scalarLower:
|
696
|
+
return log(0);
|
697
|
+
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
|
698
|
+
return (float) str_replace('_', '', $scalar);
|
699
|
+
case Parser::preg_match(self::getTimestampRegex(), $scalar):
|
700
|
+
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
|
701
|
+
$time = new \DateTime($scalar, new \DateTimeZone('UTC'));
|
702
|
+
|
703
|
+
if (Yaml::PARSE_DATETIME & $flags) {
|
704
|
+
return $time;
|
705
|
+
}
|
706
|
+
|
707
|
+
try {
|
708
|
+
if (false !== $scalar = $time->getTimestamp()) {
|
709
|
+
return $scalar;
|
710
|
+
}
|
711
|
+
} catch (\ValueError $e) {
|
712
|
+
// no-op
|
713
|
+
}
|
714
|
+
|
715
|
+
return $time->format('U');
|
716
|
+
}
|
717
|
+
}
|
718
|
+
|
719
|
+
return (string) $scalar;
|
720
|
+
}
|
721
|
+
|
722
|
+
private static function parseTag(string $value, int &$i, int $flags): ?string
|
723
|
+
{
|
724
|
+
if ('!' !== $value[$i]) {
|
725
|
+
return null;
|
726
|
+
}
|
727
|
+
|
728
|
+
$tagLength = strcspn($value, " \t\n[]{},", $i + 1);
|
729
|
+
$tag = substr($value, $i + 1, $tagLength);
|
730
|
+
|
731
|
+
$nextOffset = $i + $tagLength + 1;
|
732
|
+
$nextOffset += strspn($value, ' ', $nextOffset);
|
733
|
+
|
734
|
+
if ('' === $tag && (!isset($value[$nextOffset]) || \in_array($value[$nextOffset], [']', '}', ','], true))) {
|
735
|
+
throw new ParseException('Using the unquoted scalar value "!" is not supported. You must quote it.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
736
|
+
}
|
737
|
+
|
738
|
+
// Is followed by a scalar and is a built-in tag
|
739
|
+
if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
|
740
|
+
// Manage in {@link self::evaluateScalar()}
|
741
|
+
return null;
|
742
|
+
}
|
743
|
+
|
744
|
+
$i = $nextOffset;
|
745
|
+
|
746
|
+
// Built-in tags
|
747
|
+
if ('' !== $tag && '!' === $tag[0]) {
|
748
|
+
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
749
|
+
}
|
750
|
+
|
751
|
+
if ('' !== $tag && !isset($value[$i])) {
|
752
|
+
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
753
|
+
}
|
754
|
+
|
755
|
+
if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
|
756
|
+
return $tag;
|
757
|
+
}
|
758
|
+
|
759
|
+
throw new ParseException(sprintf('Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
760
|
+
}
|
761
|
+
|
762
|
+
public static function evaluateBinaryScalar(string $scalar): string
|
763
|
+
{
|
764
|
+
$parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar));
|
765
|
+
|
766
|
+
if (0 !== (\strlen($parsedBinaryData) % 4)) {
|
767
|
+
throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
768
|
+
}
|
769
|
+
|
770
|
+
if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
|
771
|
+
throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
772
|
+
}
|
773
|
+
|
774
|
+
return base64_decode($parsedBinaryData, true);
|
775
|
+
}
|
776
|
+
|
777
|
+
private static function isBinaryString(string $value): bool
|
778
|
+
{
|
779
|
+
return !preg_match('//u', $value) || preg_match('/[^\x00\x07-\x0d\x1B\x20-\xff]/', $value);
|
780
|
+
}
|
781
|
+
|
782
|
+
/**
|
783
|
+
* Gets a regex that matches a YAML date.
|
784
|
+
*
|
785
|
+
* @see http://www.yaml.org/spec/1.2/spec.html#id2761573
|
786
|
+
*/
|
787
|
+
private static function getTimestampRegex(): string
|
788
|
+
{
|
789
|
+
return <<<EOF
|
790
|
+
~^
|
791
|
+
(?P<year>[0-9][0-9][0-9][0-9])
|
792
|
+
-(?P<month>[0-9][0-9]?)
|
793
|
+
-(?P<day>[0-9][0-9]?)
|
794
|
+
(?:(?:[Tt]|[ \t]+)
|
795
|
+
(?P<hour>[0-9][0-9]?)
|
796
|
+
:(?P<minute>[0-9][0-9])
|
797
|
+
:(?P<second>[0-9][0-9])
|
798
|
+
(?:\.(?P<fraction>[0-9]*))?
|
799
|
+
(?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
|
800
|
+
(?::(?P<tz_minute>[0-9][0-9]))?))?)?
|
801
|
+
$~x
|
802
|
+
EOF;
|
803
|
+
}
|
804
|
+
|
805
|
+
/**
|
806
|
+
* Gets a regex that matches a YAML number in hexadecimal notation.
|
807
|
+
*/
|
808
|
+
private static function getHexRegex(): string
|
809
|
+
{
|
810
|
+
return '~^0x[0-9a-f_]++$~i';
|
811
|
+
}
|
812
|
+
}
|