diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01b8818..cc88db8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.3','8.x'] + php-versions: ['8.3','8.4','8.x'] name: Testing PHP ${{ matrix.php-versions }} steps: - name: Checkout diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index 79fab03..5921776 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.3.21","version":"3.75.0:v3.75.0#399a128ff2fdaf4281e4e79b755693286cdf325c","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\/VaultPHP\/Response\/MetaData.php":"a0563f1a67afe1f87be6f2198fe3a2c2","src\/VaultPHP\/Response\/EndpointResponse.php":"08915a35e3d329cf4f40ce153bcef6dd","src\/VaultPHP\/Response\/ApiErrors.php":"1aa4fd9b63eac400a0e40f6532870699","src\/VaultPHP\/Response\/BulkEndpointResponse.php":"14e94c100ab5bdcb7488095cb4fed55c","src\/VaultPHP\/Response\/EndpointResponseInterface.php":"3bd4424c5f7bab6cb563cb135fbd66a5","src\/VaultPHP\/Response\/MetaDataInterface.php":"3f99d08187c97f91bcc70392f4850a9c","src\/VaultPHP\/SecretEngines\/AbstractSecretEngine.php":"440cb4ea3c38808429b390401c71cbb2","src\/VaultPHP\/SecretEngines\/Traits\/PopulateDataTrait.php":"fe2e2e3051d8da28c87afcf776fe3d33","src\/VaultPHP\/SecretEngines\/Traits\/NamedRequestTrait.php":"d2897c8575f1663544d97e562e45079c","src\/VaultPHP\/SecretEngines\/Traits\/EncryptionTypeTrait.php":"32b1b5d32afccf1fe4a88cc5c010e6c4","src\/VaultPHP\/SecretEngines\/Traits\/ArrayExportTrait.php":"d5ce6245bd3b39509a0a6c54e94ca177","src\/VaultPHP\/SecretEngines\/Traits\/BulkRequestTrait.php":"5356b922ca2caed2e52bf29ee34fbccd","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Transit.php":"43facc1aef6c98182e82b512e9ce653d","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/EncryptDataResponse.php":"055a20045c7c59e06047f088e0f60172","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/DeleteKeyResponse.php":"20fc08bdf7927e17c2789f4b1c20cf0a","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/ListKeysResponse.php":"af43b2b6f6c18d5f2ba081c2329a4798","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/UpdateKeyConfigResponse.php":"d4775e5eb9c18162d6c6ad5ccc8e80dd","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/CreateKeyResponse.php":"2f26ba4e51369d6d12166592d04032c8","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/SignDataResponse.php":"6c7a9c121a7d08c4b25c98188e3c2055","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/DecryptDataResponse.php":"c63436da34fa133594943c2edaf9c4ae","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/UpdateKeyConfigRequest.php":"22473f9ca142fc53b93c33f4d05ca408","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/DecryptData\/DecryptData.php":"5d10f013084d329f896bfcad1987720c","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/DecryptData\/DecryptDataRequest.php":"eee29fd86e0ac201cd539187858e74d6","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/DecryptData\/DecryptDataBulkRequest.php":"db2a5f00ee3367e743fc202348b3a536","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/EncryptData\/EncryptData.php":"21063bf20f586d5021292df1e978e76e","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/EncryptData\/EncryptDataBulkRequest.php":"e327cefe72afc768d55de390fb831213","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/EncryptData\/EncryptDataRequest.php":"76ff2910c893fe76e0e93d8f9ea3ee9f","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/CreateKeyRequest.php":"148403f3c4d52dc516137e4bee736530","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/SignDataRequest.php":"8d36b7e821d837222389db2b0f67d3a7","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/EncryptionType.php":"53c11cc8eac506ea1ff8b2087385df16","src\/VaultPHP\/SecretEngines\/Interfaces\/ArrayExportInterface.php":"47261a03bcf0688bf4392c636f63ff06","src\/VaultPHP\/SecretEngines\/Interfaces\/BulkResourceRequestInterface.php":"a8bf6ca9d9d7fa1a55c3683a091fefaf","src\/VaultPHP\/SecretEngines\/Interfaces\/ResourceRequestInterface.php":"cd3c8e5745b947f530eedb0e94d8fcc1","src\/VaultPHP\/SecretEngines\/Interfaces\/EncryptionTypeRequestInterface.php":"9047dbed7d855f32d09542df3bf5274a","src\/VaultPHP\/SecretEngines\/Interfaces\/NamedRequestInterface.php":"9d8a2fccc731857b4d1f9f99eed090d3","src\/VaultPHP\/Exceptions\/VaultResponseException.php":"d4773dcce61689560f120b6ded52503e","src\/VaultPHP\/Exceptions\/InvalidRouteException.php":"f0476883e81bbf0a818b66c13d563114","src\/VaultPHP\/Exceptions\/KeyNameNotFoundException.php":"2088f013b61e550f8afa3dd576374ab2","src\/VaultPHP\/Exceptions\/VaultAuthenticationException.php":"812e9a4c148198cc1121ac4513633281","src\/VaultPHP\/Exceptions\/VaultHttpException.php":"2e95aec0fe1431bf9f011c8011c29f5e","src\/VaultPHP\/Exceptions\/VaultException.php":"9984162ec05bb3ab558a512bb60e219e","src\/VaultPHP\/Exceptions\/InvalidDataException.php":"e35e853b8605d8e3fa692bf0a40a1463","src\/VaultPHP\/VaultClient.php":"d1a4fa5f2f925cc7ff7789add35316db","src\/VaultPHP\/Authentication\/AuthenticationMetaData.php":"8f5005d465b1d83b717e639c0e7dce80","src\/VaultPHP\/Authentication\/AbstractAuthenticationProvider.php":"a2ae6f945f2f318ef14c031538722ce6","src\/VaultPHP\/Authentication\/Provider\/UserPassword.php":"15bbfd09e5c1de335f09d650bfa6aa6b","src\/VaultPHP\/Authentication\/Provider\/Kubernetes.php":"652baf38323a5c86089f1dfca97b6e5b","src\/VaultPHP\/Authentication\/Provider\/Token.php":"eaee4d80c935c645cb78b272a51ffad1","src\/VaultPHP\/Authentication\/Provider\/AppRole.php":"af620b2bf4fd48033bf780e99d901770","src\/VaultPHP\/Authentication\/AuthenticationProviderInterface.php":"6760e8631da9a219a2771378b83abf39"}} \ No newline at end of file +{"php":"8.5.0","version":"3.91.2:v3.91.2#f171dc216bc8a4192d5a0876a899cce6f9e379d6","indent":" ","lineEnding":"\n","rules":{"nullable_type_declaration":true,"operator_linebreak":true,"ordered_types":{"null_adjustment":"always_last"},"single_class_element_per_statement":true,"types_spaces":true,"array_indentation":true,"array_syntax":true,"cast_spaces":true,"concat_space":true,"function_declaration":{"closure_fn_spacing":"one"},"method_argument_space":{"after_heredoc":true,"on_multiline":"ensure_fully_multiline"},"new_with_parentheses":{"anonymous_class":false},"single_line_empty_body":true,"single_space_around_construct":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["array_destructuring","arrays"]},"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_definition":{"single_line":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"modifier_keywords":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["attribute","break","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","return","square_brace_block","switch","throw","use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":true,"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"simple_to_complex_string_variable":true,"octal_notation":true,"clean_namespace":true,"no_unset_cast":true,"assign_null_coalescing_to_coalesce_equal":true,"normalize_index_brace":true,"heredoc_indentation":true,"no_whitespace_before_comma_in_array":{"after_heredoc":true},"list_syntax":true,"ternary_to_null_coalescing":true,"blank_line_before_statement":{"statements":["break","case","continue","declare","default","exit","goto","include","include_once","phpdoc","require","require_once","return","switch","throw","try","yield","yield_from"]},"combine_consecutive_issets":true,"combine_consecutive_unsets":true,"empty_loop_body":true,"explicit_indirect_variable":true,"explicit_string_variable":true,"fully_qualified_strict_types":{"import_symbols":true},"heredoc_to_nowdoc":true,"method_chaining_indentation":true,"multiline_comment_opening_closing":true,"multiline_whitespace_before_semicolons":{"strategy":"new_line_for_chained_calls"},"no_superfluous_elseif":true,"no_superfluous_phpdoc_tags":{"allow_hidden_params":true,"allow_mixed":true,"remove_inheritdoc":true},"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","negative_instanceof","others","return","switch_case","yield","yield_from"]},"no_useless_else":true,"no_useless_return":true,"php_unit_data_provider_method_order":true,"php_unit_internal_class":true,"php_unit_test_class_requires_covers":true,"phpdoc_add_missing_param_annotation":true,"phpdoc_no_empty_return":true,"phpdoc_order_by_value":true,"phpdoc_types_order":true,"protected_to_private":true,"return_assignment":true,"self_static_accessor":true,"single_line_comment_style":true,"string_implicit_backslashes":true,"whitespace_after_comma_in_array":{"ensure_single_space":true},"align_multiline_comment":true,"backtick_to_shell_exec":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_reference_name_casing":true,"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_condition":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"native_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_singleline":true,"no_unneeded_braces":{"namespaces":true},"no_unneeded_import_alias":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"nullable_type_declaration_for_default_null_value":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":{"replacements":{"const":"var","link":"see","property-read":"property","property-write":"property","type":"var"}},"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":{"order":["param","return","throws"]},"phpdoc_return_self_reference":true,"phpdoc_scalar":{"types":["boolean","callback","double","integer","never-return","never-returns","no-return","real","str"]},"phpdoc_separation":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]],"skip_unlisted_annotations":false},"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":{"allow_before_return_statement":false},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_var_annotation_correct_order":true,"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"single_line_comment_spacing":true,"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"stringable_for_to_string":true,"switch_continue_to_break":true,"trim_array_spaces":true,"type_declaration_spaces":{"elements":["function","property"]},"yoda_style":true},"hashes":{"src\/VaultPHP\/SecretEngines\/Interfaces\/ArrayExportInterface.php":"9e89db6b670cec9980cd9202133e3416","src\/VaultPHP\/SecretEngines\/Interfaces\/BulkResourceRequestInterface.php":"38a1cfaa409fa5912498cbf43c2e55d7","src\/VaultPHP\/SecretEngines\/Interfaces\/ResourceRequestInterface.php":"48cde88ef852ff1fc861bb8860e711b2","src\/VaultPHP\/SecretEngines\/Interfaces\/EncryptionTypeRequestInterface.php":"3cf57d71b869baac6515eccf678e45ad","src\/VaultPHP\/SecretEngines\/Interfaces\/NamedRequestInterface.php":"a7d13581fcc213fd3cfa8426e79f4dab","src\/VaultPHP\/Exceptions\/VaultResponseException.php":"53657227126531040ff478e2dd9e1f61","src\/VaultPHP\/Exceptions\/InvalidRouteException.php":"ca4f4ef7ed00be46a09d1d96a3d8d921","src\/VaultPHP\/Exceptions\/KeyNameNotFoundException.php":"88a76c501832ebc1c40aafabd8c2f4eb","src\/VaultPHP\/Exceptions\/VaultAuthenticationException.php":"e076e6c363ad3819a8a6a44a72ee4c34","src\/VaultPHP\/Exceptions\/VaultHttpException.php":"3952b5cced0e1b8736208c44cf89874d","src\/VaultPHP\/SecretEngines\/Traits\/ArrayExportTrait.php":"82bb22771c0ec19b67b353a3e776ffc2","src\/VaultPHP\/SecretEngines\/Traits\/BulkRequestTrait.php":"d258ba53b3bcd16ebd7b716ece0063fc","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Transit.php":"a8c298db5e9125c4ebe98992af076c84","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/EncryptDataResponse.php":"11169fe166c797225ceda11a6071e239","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/DeleteKeyResponse.php":"b78ab71331d80df26205c31f0a406cb8","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/ListKeysResponse.php":"0f386293dadd3cac21320d18ea45cfe5","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/UpdateKeyConfigResponse.php":"0e316fc7b72a0e8f0c07e723541d251e","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/CreateKeyResponse.php":"6dbca6fc43227777b51a614360a6168a","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/SignDataResponse.php":"bb63d45df7f506c9089cfd179951ac3a","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Response\/DecryptDataResponse.php":"299a99c3962f8435f8720eaf419f3495","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/UpdateKeyConfigRequest.php":"afb12601aee44052a356685364e6478d","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/DecryptData\/DecryptData.php":"27a081d15e8956d2fae01c093ceeb6e4","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/DecryptData\/DecryptDataRequest.php":"cb12aaf7f9f6b6a368151548c82489a6","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/DecryptData\/DecryptDataBulkRequest.php":"a227a09991d62ea23adfc8d06c82d165","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/EncryptData\/EncryptData.php":"aa927066a686adac33749d955920e0c7","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/EncryptData\/EncryptDataBulkRequest.php":"0527b5756eba3f233cd4b293d6dda31c","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/EncryptData\/EncryptDataRequest.php":"01cd5942dee13915c01b30c8686550c1","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/CreateKeyRequest.php":"3d4c402e29170922a072ced701c02418","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/Request\/SignDataRequest.php":"56fbe709c5d3561dbe1ca0c4221e5ab2","src\/VaultPHP\/SecretEngines\/Engines\/Transit\/EncryptionType.php":"b13a9ee27efac0c5daa18f1712d3f43a","src\/VaultPHP\/Response\/MetaData.php":"a2d192fb8d999e71dca0799b4ca6cbd9","src\/VaultPHP\/Response\/EndpointResponse.php":"f9de1c57c22fe29ab9775d710c3cb933","src\/VaultPHP\/Response\/ApiErrors.php":"ed9efdf258cabc9f57f3a3d7f668f1ee","src\/VaultPHP\/Response\/BulkEndpointResponse.php":"b4a1e8183617bd36cab7e43f7e41bf07","src\/VaultPHP\/Response\/EndpointResponseInterface.php":"2d19eacc1f7ede37fa73796e6c089ebc","src\/VaultPHP\/Response\/MetaDataInterface.php":"8360e1af6d026f5ec41a4f9a904a92eb","src\/VaultPHP\/SecretEngines\/AbstractSecretEngine.php":"e4e5dc50414f8bf26d555d8f6ab51ff0","src\/VaultPHP\/SecretEngines\/Traits\/PopulateDataTrait.php":"11ea3c79ec7cccc52fc44570bb3be4f6","src\/VaultPHP\/SecretEngines\/Traits\/NamedRequestTrait.php":"6d1578b2046797e983d0a28127968153","src\/VaultPHP\/SecretEngines\/Traits\/EncryptionTypeTrait.php":"d7f03caec9790fa6a186f191b0e1d8b8","src\/VaultPHP\/Exceptions\/VaultException.php":"1fe37d29191f17116b9b23238c57f510","src\/VaultPHP\/Exceptions\/InvalidDataException.php":"d02212d33f1d1c6f4391866d51cd52b4","src\/VaultPHP\/VaultClient.php":"e699f9554512ec542fb111aa2cfb03e8","src\/VaultPHP\/Authentication\/AuthenticationMetaData.php":"29ab462428e6b0c404202af612809024","src\/VaultPHP\/Authentication\/AbstractAuthenticationProvider.php":"29d225c0889e2a76fd07d25152ef1a02","src\/VaultPHP\/Authentication\/Provider\/UserPassword.php":"198cf0ddcf5bf87a2e4a3bc912aad567","src\/VaultPHP\/Authentication\/Provider\/Kubernetes.php":"9ba984ec2dad5a20bd1ce5f3df8df4bd","src\/VaultPHP\/Authentication\/Provider\/Token.php":"23203dc303f06f2134eea4deceee9b61","src\/VaultPHP\/Authentication\/Provider\/AppRole.php":"cffd9561db66c8768add5d7318f097a6","src\/VaultPHP\/Authentication\/AuthenticationProviderInterface.php":"2817e948b2e7a21f5ade02bf99974946"}} \ No newline at end of file diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..cdc8d47 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,31 @@ +setParallelConfig(ParallelConfigFactory::detect()) // @TODO 4.0 no need to call this manually + ->setRiskyAllowed(false) + ->setRules([ + '@auto' => true, + '@PhpCsFixer' => true + ]) + // 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config + ->setFinder( + (new Finder()) + // 💡 root folder to check + ->in(__DIR__) + // 💡 additional files, eg bin entry file + // ->append([__DIR__.'/bin-entry-file']) + // 💡 folders to exclude, if any + // ->exclude([/* ... */]) + // 💡 path patterns to exclude, if any + // ->notPath([/* ... */]) + // 💡 extra configs + // ->ignoreDotFiles(false) // true by default in v3, false in v4 or future mode + // ->ignoreVCSIgnored(true) // true by default + ) +; diff --git a/composer.json b/composer.json index d0a99bb..5e8cc78 100644 --- a/composer.json +++ b/composer.json @@ -1,46 +1,46 @@ { - "name": "mittwald/vault-php", - "type": "library", - "license": "MIT", - "homepage": "https://www.mittwald.de/", - "description": "A PHP client library for 'Vault by HashiCorp'", - "require": { - "ext-json": "*", - "guzzlehttp/psr7": "^2.7.1", - "php": ">=8.3" - }, - "suggest": { - "guzzlehttp/guzzle": "HTTP Client Adapter" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^v3.75.0", - "php-http/mock-client": "^1.6.1", - "phpunit/phpunit": "^12.1.5", - "vimeo/psalm": "^6.10.3" - }, - "authors": [ - { - "name": "Marco Rieger", - "email": "m.rieger@mittwald.de" - } - ], - "autoload": { - "psr-4": { - "VaultPHP\\": "src\\VaultPHP\\" - } - }, - "autoload-dev": { - "psr-4": { - "Test\\VaultPHP\\": "tests\\VaultPHP\\" - } - }, - "scripts": { - "test": "php ./vendor/bin/phpunit --configuration ./phpunit.xml.dist", - "pretty": "php ./vendor/bin/php-cs-fixer fix ./src" - }, - "config": { - "allow-plugins": { - "php-http/discovery": false - } + "name": "mittwald/vault-php", + "type": "library", + "license": "MIT", + "homepage": "https://www.mittwald.de/", + "description": "A PHP client library for 'Vault by HashiCorp'", + "require": { + "ext-json": "*", + "guzzlehttp/psr7": "^2.7.1", + "php": ">=8.3" + }, + "suggest": { + "guzzlehttp/guzzle": "HTTP Client Adapter" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v3.91.2", + "php-http/mock-client": "^1.6.1", + "phpunit/phpunit": "^12.5.0", + "vimeo/psalm": "6.x-dev" + }, + "authors": [ + { + "name": "Marco Rieger", + "email": "m.rieger@mittwald.de" } + ], + "autoload": { + "psr-4": { + "VaultPHP\\": "src\\VaultPHP\\" + } + }, + "autoload-dev": { + "psr-4": { + "Test\\VaultPHP\\": "tests\\VaultPHP\\" + } + }, + "scripts": { + "test": "./vendor/bin/psalm --no-cache && php ./vendor/bin/phpunit --configuration ./phpunit.xml.dist", + "pretty": "php ./vendor/bin/php-cs-fixer fix ./src" + }, + "config": { + "allow-plugins": { + "php-http/discovery": false + } + } } diff --git a/src/VaultPHP/Authentication/AbstractAuthenticationProvider.php b/src/VaultPHP/Authentication/AbstractAuthenticationProvider.php index d3b6600..5d16792 100644 --- a/src/VaultPHP/Authentication/AbstractAuthenticationProvider.php +++ b/src/VaultPHP/Authentication/AbstractAuthenticationProvider.php @@ -1,4 +1,5 @@ vaultClient = $VaultClient; } - /** - * @throws VaultException - * @return VaultClient - */ - private function getVaultClient(): VaultClient - { - if (!$this->vaultClient) { - throw new VaultException('Trying to request the VaultClient before initialization'); - } - - return $this->vaultClient; - } - /** * @throws InvalidRouteException * @throws VaultHttpException @@ -50,7 +32,7 @@ private function getVaultClient(): VaultClient * @throws InvalidDataException * @throws VaultAuthenticationException */ - protected function sendApiRequest(string $method, string $endpoint, string $returnClass, ResourceRequestInterface|array $data = []): mixed + protected function sendApiRequest(string $method, string $endpoint, string $returnClass, array|ResourceRequestInterface $data = []): mixed { return $this->getVaultClient()->sendApiRequest( $method, @@ -60,4 +42,16 @@ protected function sendApiRequest(string $method, string $endpoint, string $retu false, ); } + + /** + * @throws VaultException + */ + private function getVaultClient(): VaultClient + { + if (!$this->vaultClient) { + throw new VaultException('Trying to request the VaultClient before initialization'); + } + + return $this->vaultClient; + } } diff --git a/src/VaultPHP/Authentication/AuthenticationMetaData.php b/src/VaultPHP/Authentication/AuthenticationMetaData.php index 1af1751..b850045 100644 --- a/src/VaultPHP/Authentication/AuthenticationMetaData.php +++ b/src/VaultPHP/Authentication/AuthenticationMetaData.php @@ -1,20 +1,18 @@ token; } - /** - * @return bool - */ public function isClientTokenPresent(): bool { - return !!$this->token; + return (bool) $this->token; } } diff --git a/src/VaultPHP/Authentication/AuthenticationProviderInterface.php b/src/VaultPHP/Authentication/AuthenticationProviderInterface.php index 0e6b039..1f3bc3c 100644 --- a/src/VaultPHP/Authentication/AuthenticationProviderInterface.php +++ b/src/VaultPHP/Authentication/AuthenticationProviderInterface.php @@ -1,4 +1,5 @@ sendApiRequest( diff --git a/src/VaultPHP/Authentication/Provider/Kubernetes.php b/src/VaultPHP/Authentication/Provider/Kubernetes.php index 71a0fd1..687c429 100644 --- a/src/VaultPHP/Authentication/Provider/Kubernetes.php +++ b/src/VaultPHP/Authentication/Provider/Kubernetes.php @@ -1,4 +1,5 @@ role = $role; $this->jwt = $jwt; - $this->endpoint = '/v1/' . $authPath . '/login'; + $this->endpoint = '/v1/'.$authPath.'/login'; } /** - * @return AuthenticationMetaData|false - * * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultAuthenticationException @@ -48,7 +42,7 @@ public function __construct(string $role, string $jwt, string $authPath = 'auth/ * @throws VaultHttpException */ #[\Override] - public function authenticate(): false|AuthenticationMetaData + public function authenticate(): AuthenticationMetaData|false { /** @var EndpointResponse $response */ $response = $this->sendApiRequest( diff --git a/src/VaultPHP/Authentication/Provider/Token.php b/src/VaultPHP/Authentication/Provider/Token.php index 462318d..a8a075d 100644 --- a/src/VaultPHP/Authentication/Provider/Token.php +++ b/src/VaultPHP/Authentication/Provider/Token.php @@ -1,4 +1,5 @@ token = $token; } - /** - * @return AuthenticationMetaData - */ #[\Override] public function authenticate(): AuthenticationMetaData { diff --git a/src/VaultPHP/Authentication/Provider/UserPassword.php b/src/VaultPHP/Authentication/Provider/UserPassword.php index 287792e..78a62c0 100644 --- a/src/VaultPHP/Authentication/Provider/UserPassword.php +++ b/src/VaultPHP/Authentication/Provider/UserPassword.php @@ -1,4 +1,5 @@ getAuthUrl(), EndpointResponse::class, [ - 'password' => $this->password + 'password' => $this->password, ] ); @@ -65,9 +61,6 @@ public function authenticate(): AuthenticationMetaData|bool return false; } - /** - * @return string - */ private function getAuthUrl(): string { return sprintf($this::endpoint, urlencode($this->username)); diff --git a/src/VaultPHP/Exceptions/InvalidDataException.php b/src/VaultPHP/Exceptions/InvalidDataException.php index a23a819..fd0554b 100644 --- a/src/VaultPHP/Exceptions/InvalidDataException.php +++ b/src/VaultPHP/Exceptions/InvalidDataException.php @@ -1,12 +1,10 @@ * @template-implements ArrayAccess */ -final class BulkEndpointResponse extends EndpointResponse implements Iterator, ArrayAccess, Countable +final class BulkEndpointResponse extends EndpointResponse implements \Iterator, \ArrayAccess, \Countable { - /** @var integer */ - private int $iteratorPosition = 0; - protected array $batch_results = []; + private int $iteratorPosition = 0; #[\Override] public function hasErrors(): bool diff --git a/src/VaultPHP/Response/EndpointResponse.php b/src/VaultPHP/Response/EndpointResponse.php index 38c07ae..4065978 100644 --- a/src/VaultPHP/Response/EndpointResponse.php +++ b/src/VaultPHP/Response/EndpointResponse.php @@ -1,4 +1,5 @@ metaData = new MetaData($meta); $this->populateData($data); } - /** - * @param ResponseInterface $response - * @return array - */ - protected static function getResponseContent(ResponseInterface $response): array - { - $responseBody = $response->getBody(); - $responseBody->rewind(); - $responseBodyContents = $responseBody->getContents(); - - // cast to array because we only want the first root - // as array and not the complete response - return (array) json_decode($responseBodyContents); - } - - /** - * @param ResponseInterface $response - * @return static - */ #[\Override] public static function fromResponse(ResponseInterface $response): static { $metaData = static::getResponseContent($response); - /** @var object|array $domainData */ + /** @var array|object $domainData */ $domainData = $metaData['data'] ?? []; unset($metaData['data']); return new static($domainData, $metaData); } - /** - * @param ResponseInterface $response - * @return BulkEndpointResponse - */ public static function fromBulkResponse(ResponseInterface $response): BulkEndpointResponse { $metaData = static::getResponseContent($response); - /** @var object|array $domainData */ + /** @var array|object $domainData */ $domainData = $metaData['data'] ?? []; unset($metaData['data']); $responseDTO = new BulkEndpointResponse($domainData, $metaData); $responseDTO->batch_results = array_map(function ($batchResult) { /** @var object $batchResult */ - $errors = isset($batchResult->error) && $batchResult->error ? explode(', ', (string) $batchResult->error) : []; + return new static($batchResult, [ 'errors' => $errors, ]); @@ -84,20 +58,25 @@ public static function fromBulkResponse(ResponseInterface $response): BulkEndpoi return $responseDTO; } - /** - * @return MetaData - */ #[\Override] public function getMetaData(): MetaData { return $this->metaData; } - /** - * @return bool - */ public function hasErrors(): bool { return $this->getMetaData()->hasErrors(); } + + protected static function getResponseContent(ResponseInterface $response): array + { + $responseBody = $response->getBody(); + $responseBody->rewind(); + $responseBodyContents = $responseBody->getContents(); + + // cast to array because we only want the first root + // as array and not the complete response + return (array) json_decode($responseBodyContents); + } } diff --git a/src/VaultPHP/Response/EndpointResponseInterface.php b/src/VaultPHP/Response/EndpointResponseInterface.php index 702a17f..9588d23 100644 --- a/src/VaultPHP/Response/EndpointResponseInterface.php +++ b/src/VaultPHP/Response/EndpointResponseInterface.php @@ -1,4 +1,5 @@ populateData($data); } - /** - * @return string|null - */ public function getRequestId(): ?string { return $this->request_id; } - /** - * @return string|null - */ public function getLeaseId(): ?string { return $this->lease_id; } - /** - * @return bool|null - */ public function getRenewable(): ?bool { return $this->renewable; } - /** - * @return int|null - */ public function getLeaseDuration(): ?int { return $this->lease_duration; } - /** - * @param mixed $lease_duration - * @return void - */ public function setLeaseDuration(mixed $lease_duration): void { $this->lease_duration = (int) $lease_duration; } - /** - * @param array|null $warnings - * @return void - */ - public function setWarnings(array|null $warnings): void + public function setWarnings(?array $warnings): void { $this->warnings = $warnings ?? []; } - - /** - * @return string|null - */ public function getWrapInfo(): ?string { return $this->wrap_info; @@ -113,16 +82,12 @@ public function getWarnings(): array return $this->warnings; } - /** - * @return object|null - */ #[\Override] public function getAuth(): ?object { return $this->auth; } - /** * @return string[] */ @@ -132,10 +97,6 @@ public function getErrors(): array return $this->errors; } - /** - * @param array $error - * @return boolean - */ #[\Override] public function containsError(array $error): bool { @@ -147,16 +108,15 @@ public function containsError(array $error): bool } } } + return false; } - /** - * @return boolean - */ #[\Override] public function hasErrors(): bool { $errors = $this->getErrors(); + return count($errors) >= 1; } } diff --git a/src/VaultPHP/Response/MetaDataInterface.php b/src/VaultPHP/Response/MetaDataInterface.php index be6349b..e88d617 100644 --- a/src/VaultPHP/Response/MetaDataInterface.php +++ b/src/VaultPHP/Response/MetaDataInterface.php @@ -1,38 +1,24 @@ vaultClient = $VaultClient; diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/EncryptionType.php b/src/VaultPHP/SecretEngines/Engines/Transit/EncryptionType.php index f2e446c..948600d 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/EncryptionType.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/EncryptionType.php @@ -1,22 +1,22 @@ setNonce($nonce); } - /** - * @param string $ciphertext - * @return static - */ public function setCiphertext(string $ciphertext): static { $this->ciphertext = $ciphertext; + return $this; } - /** - * @param string|null $nonce - * @return static - */ public function setNonce(?string $nonce): static { $this->nonce = $nonce; + return $this; } - /** - * @param string|null $context - * @return static - */ public function setContext(?string $context): static { $this->context = $context; + return $this; } - /** - * @return string - */ public function getCiphertext(): string { return $this->ciphertext; } - /** - * @return string|null - */ public function getContext(): ?string { return $this->context; } - /** - * @return string|null - */ public function getNonce(): ?string { return $this->nonce; diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataBulkRequest.php b/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataBulkRequest.php index 3b1349a..74ee9ed 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataBulkRequest.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataBulkRequest.php @@ -1,4 +1,5 @@ setName($name); $this->addBulkRequests($batchRequests); } - } diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataRequest.php b/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataRequest.php index 2d050bf..d1e0820 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataRequest.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Request/DecryptData/DecryptDataRequest.php @@ -1,4 +1,5 @@ setNonce($nonce); } - /** - * @param string $plaintext - * @return static - */ public function setPlaintext(string $plaintext): static { $this->plaintext = base64_encode($plaintext); + return $this; } - /** - * @param string|null $nonce - * @return static - */ public function setNonce(?string $nonce): static { $this->nonce = $nonce; + return $this; } - /** - * @param string|null $context - * @return static - */ public function setContext(?string $context): static { $this->context = $context; + return $this; } - /** - * @return string|null - */ public function getNonce(): ?string { return $this->nonce; } - /** - * @return string|null - */ public function getContext(): ?string { return $this->context; } - /** - * @return string - */ public function getPlaintext(): string { return $this->plaintext; diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Request/EncryptData/EncryptDataBulkRequest.php b/src/VaultPHP/SecretEngines/Engines/Transit/Request/EncryptData/EncryptDataBulkRequest.php index fe74550..613ca3a 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Request/EncryptData/EncryptDataBulkRequest.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Request/EncryptData/EncryptDataBulkRequest.php @@ -1,4 +1,5 @@ signature_algorithm = $signature_algorithm; } - /** - * @return string - */ public function getKey(): string { return $this->key; } - /** - * @return string - */ public function getHashAlgorithm(): string { return $this->hashAlgorithm; } - /** - * @return array - */ #[\Override] public function toArray(): array { return [ 'input' => $this->input, - 'signature_algorithm' => $this->signature_algorithm + 'signature_algorithm' => $this->signature_algorithm, ]; } } diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Request/UpdateKeyConfigRequest.php b/src/VaultPHP/SecretEngines/Engines/Transit/Request/UpdateKeyConfigRequest.php index f2ef660..2519176 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Request/UpdateKeyConfigRequest.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Request/UpdateKeyConfigRequest.php @@ -1,4 +1,5 @@ min_decryption_version; } - /** - * @param int|null $min_decryption_version - * @return void - */ public function setMinDecryptionVersion(?int $min_decryption_version): void { $this->min_decryption_version = $min_decryption_version; } - /** - * @return int|null - */ public function getMinEncryptionVersion(): ?int { return $this->min_encryption_version; } - /** - * @param int|null $min_encryption_version - * @return void - */ public function setMinEncryptionVersion(?int $min_encryption_version): void { $this->min_encryption_version = $min_encryption_version; } - /** - * @return bool|null - */ public function getExportable(): ?bool { return $this->exportable; } - /** - * @param bool|null $exportable - * @return void - */ public function setExportable(?bool $exportable): void { $this->exportable = $exportable; } - /** - * @return bool|null - */ public function getAllowPlaintextBackup(): ?bool { return $this->allow_plaintext_backup; } - /** - * @param bool|null $allow_plaintext_backup - * @return void - */ public function setAllowPlaintextBackup(?bool $allow_plaintext_backup): void { $this->allow_plaintext_backup = $allow_plaintext_backup; } - /** - * @return bool|null - */ public function getDeletionAllowed(): ?bool { return $this->deletion_allowed; } - /** - * @param bool|null $deletion_allowed - * @return void - */ public function setDeletionAllowed(?bool $deletion_allowed): void { $this->deletion_allowed = $deletion_allowed; diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Response/CreateKeyResponse.php b/src/VaultPHP/SecretEngines/Engines/Transit/Response/CreateKeyResponse.php index 7d86a2a..e43b129 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Response/CreateKeyResponse.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Response/CreateKeyResponse.php @@ -1,4 +1,5 @@ plaintext); diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Response/DeleteKeyResponse.php b/src/VaultPHP/SecretEngines/Engines/Transit/Response/DeleteKeyResponse.php index da57e11..0b9b68b 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Response/DeleteKeyResponse.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Response/DeleteKeyResponse.php @@ -1,4 +1,5 @@ ciphertext; diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Response/ListKeysResponse.php b/src/VaultPHP/SecretEngines/Engines/Transit/Response/ListKeysResponse.php index 1dc57bc..0c1320e 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Response/ListKeysResponse.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Response/ListKeysResponse.php @@ -1,4 +1,5 @@ signature; diff --git a/src/VaultPHP/SecretEngines/Engines/Transit/Response/UpdateKeyConfigResponse.php b/src/VaultPHP/SecretEngines/Engines/Transit/Response/UpdateKeyConfigResponse.php index 308518b..536ae5a 100644 --- a/src/VaultPHP/SecretEngines/Engines/Transit/Response/UpdateKeyConfigResponse.php +++ b/src/VaultPHP/SecretEngines/Engines/Transit/Response/UpdateKeyConfigResponse.php @@ -1,4 +1,5 @@ APIPath = $path; } /** - * @param CreateKeyRequest $createKeyRequest - * @return CreateKeyResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function createKey(CreateKeyRequest $createKeyRequest): CreateKeyResponse { - /** @var CreateKeyResponse */ + // @var CreateKeyResponse return $this->vaultClient->sendApiRequest( 'POST', sprintf('/v1/%s/keys/%s', $this->APIPath, urlencode($createKeyRequest->getName())), @@ -65,15 +56,13 @@ public function createKey(CreateKeyRequest $createKeyRequest): CreateKeyResponse } /** - * @param EncryptDataRequest $encryptDataRequest - * @return EncryptDataResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function encryptData(EncryptDataRequest $encryptDataRequest): EncryptDataResponse { - /** @var EncryptDataResponse */ + // @var EncryptDataResponse return $this->vaultClient->sendApiRequest( 'POST', sprintf('/v1/%s/encrypt/%s', $this->APIPath, urlencode($encryptDataRequest->getName())), @@ -83,15 +72,13 @@ public function encryptData(EncryptDataRequest $encryptDataRequest): EncryptData } /** - * @param EncryptDataBulkRequest $encryptDataBulkRequest - * @return BulkEndpointResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function encryptDataBulk(EncryptDataBulkRequest $encryptDataBulkRequest): BulkEndpointResponse { - /** @var BulkEndpointResponse */ + // @var BulkEndpointResponse return $this->vaultClient->sendApiRequest( 'POST', sprintf('/v1/%s/encrypt/%s', $this->APIPath, urlencode($encryptDataBulkRequest->getName())), @@ -101,15 +88,13 @@ public function encryptDataBulk(EncryptDataBulkRequest $encryptDataBulkRequest): } /** - * @param DecryptDataRequest $decryptDataRequest - * @return DecryptDataResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function decryptData(DecryptDataRequest $decryptDataRequest): DecryptDataResponse { - /** @var DecryptDataResponse */ + // @var DecryptDataResponse return $this->vaultClient->sendApiRequest( 'POST', sprintf('/v1/%s/decrypt/%s', $this->APIPath, urlencode($decryptDataRequest->getName())), @@ -119,8 +104,6 @@ public function decryptData(DecryptDataRequest $decryptDataRequest): DecryptData } /** - * @param DecryptDataBulkRequest $decryptDataBulkRequest - * @return BulkEndpointResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException @@ -129,7 +112,7 @@ public function decryptData(DecryptDataRequest $decryptDataRequest): DecryptData */ public function decryptDataBulk(DecryptDataBulkRequest $decryptDataBulkRequest): BulkEndpointResponse { - /** @var BulkEndpointResponse */ + // @var BulkEndpointResponse return $this->vaultClient->sendApiRequest( 'POST', sprintf('/v1/%s/decrypt/%s', $this->APIPath, urlencode($decryptDataBulkRequest->getName())), @@ -139,32 +122,29 @@ public function decryptDataBulk(DecryptDataBulkRequest $decryptDataBulkRequest): } /** - * @return ListKeysResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function listKeys(): ListKeysResponse { - /** @var ListKeysResponse */ + // @var ListKeysResponse return $this->vaultClient->sendApiRequest( 'LIST', - sprintf('/v1/%s/keys', $this->APIPath, ), + sprintf('/v1/%s/keys', $this->APIPath), ListKeysResponse::class, [] ); } /** - * @param string $name - * @return EndpointResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function deleteKey(string $name): EndpointResponse { - /** @var EndpointResponse */ + // @var EndpointResponse return $this->vaultClient->sendApiRequest( 'DELETE', sprintf('/v1/%s/keys/%s', $this->APIPath, urlencode($name)), @@ -174,15 +154,13 @@ public function deleteKey(string $name): EndpointResponse } /** - * @param UpdateKeyConfigRequest $updateKeyConfigRequest - * @return UpdateKeyConfigResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException */ public function updateKeyConfig(UpdateKeyConfigRequest $updateKeyConfigRequest): UpdateKeyConfigResponse { - /** @var UpdateKeyConfigResponse */ + // @var UpdateKeyConfigResponse return $this->vaultClient->sendApiRequest( 'POST', sprintf('/v1/%s/keys/%s/config', $this->APIPath, urlencode($updateKeyConfigRequest->getName())), @@ -192,8 +170,6 @@ public function updateKeyConfig(UpdateKeyConfigRequest $updateKeyConfigRequest): } /** - * @param SignDataRequest $signDataRequest - * @return SignDataResponse * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultException diff --git a/src/VaultPHP/SecretEngines/Interfaces/ArrayExportInterface.php b/src/VaultPHP/SecretEngines/Interfaces/ArrayExportInterface.php index d6f4160..e947e17 100644 --- a/src/VaultPHP/SecretEngines/Interfaces/ArrayExportInterface.php +++ b/src/VaultPHP/SecretEngines/Interfaces/ArrayExportInterface.php @@ -1,16 +1,13 @@ array_map_r( + /** @psalm-suppress MissingClosureParamType */ + function ($v) { + if ($v instanceof ArrayExportInterface) { + return $v->toArray(); + } + + return $v; + }, + $data + ); + + return array_filter($result); + } + private function array_map_r(callable $callback, array $input): array { $output = []; /** * @var string $key - * @var mixed $data + * @var mixed $data */ foreach ($input as $key => $data) { if (is_array($data)) { $output[$key] = $this->array_map_r($callback, $data); } else { - /** @psalm-suppress MixedAssignment */ + // @psalm-suppress MixedAssignment $output[$key] = $callback($data); } } return $output; } - - /** - * @return array - */ - public function toArray(): array - { - $data = get_object_vars($this); - $result = $this->array_map_r( - /** @psalm-suppress MissingClosureParamType */ - function ($v) { - if ($v instanceof ArrayExportInterface) { - return $v->toArray(); - } - return $v; - }, - $data - ); - - return array_filter($result); - } } diff --git a/src/VaultPHP/SecretEngines/Traits/BulkRequestTrait.php b/src/VaultPHP/SecretEngines/Traits/BulkRequestTrait.php index c1e52d7..52d9fa9 100644 --- a/src/VaultPHP/SecretEngines/Traits/BulkRequestTrait.php +++ b/src/VaultPHP/SecretEngines/Traits/BulkRequestTrait.php @@ -1,31 +1,23 @@ batch_input[] = $request; + return $this; } - /** - * @param array $requests - * @return void - */ public function addBulkRequests(array $requests): void { foreach ($requests as $request) { diff --git a/src/VaultPHP/SecretEngines/Traits/EncryptionTypeTrait.php b/src/VaultPHP/SecretEngines/Traits/EncryptionTypeTrait.php index 8cb9bcd..da7eac0 100644 --- a/src/VaultPHP/SecretEngines/Traits/EncryptionTypeTrait.php +++ b/src/VaultPHP/SecretEngines/Traits/EncryptionTypeTrait.php @@ -1,4 +1,5 @@ type = $type->value; + return $this; } } diff --git a/src/VaultPHP/SecretEngines/Traits/NamedRequestTrait.php b/src/VaultPHP/SecretEngines/Traits/NamedRequestTrait.php index f735676..01c72d3 100644 --- a/src/VaultPHP/SecretEngines/Traits/NamedRequestTrait.php +++ b/src/VaultPHP/SecretEngines/Traits/NamedRequestTrait.php @@ -1,40 +1,30 @@ name = $name; } - /** - * @return string - */ public function getName(): string { return $this->name; } - /** - * @param string $name - * @return static - */ public function setName(string $name): static { $this->name = $name; + return $this; } } diff --git a/src/VaultPHP/SecretEngines/Traits/PopulateDataTrait.php b/src/VaultPHP/SecretEngines/Traits/PopulateDataTrait.php index edb81a8..61d7ffb 100644 --- a/src/VaultPHP/SecretEngines/Traits/PopulateDataTrait.php +++ b/src/VaultPHP/SecretEngines/Traits/PopulateDataTrait.php @@ -1,30 +1,23 @@ $value) { if (method_exists(static::class, "set{$this->toCamelCase($key)}")) { call_user_func([static::class, "set{$this->toCamelCase($key)}"], $value); } elseif (property_exists(static::class, $key)) { - $this->$key = $value; + $this->{$key} = $value; } } } - /** - * @param string $str - * @return string - */ private function toCamelCase(string $str): string { return lcfirst( diff --git a/src/VaultPHP/VaultClient.php b/src/VaultPHP/VaultClient.php index a6f8045..4320bcb 100644 --- a/src/VaultPHP/VaultClient.php +++ b/src/VaultPHP/VaultClient.php @@ -1,4 +1,5 @@ httpClient = $httpClient; @@ -52,7 +44,42 @@ public function __construct(ClientInterface $httpClient, AuthenticationProviderI } /** - * @return void + * @throws InvalidDataException + * @throws InvalidRouteException + * @throws VaultAuthenticationException + * @throws VaultException + * @throws VaultHttpException + */ + public function sendApiRequest( + string $method, + string $endpoint, + string $returnClass, + array|ResourceRequestInterface $data = [], + bool $authRequired = true + ): mixed { + if ($authRequired) { + $this->authenticate(); + } + + $extractedPayload = $this->extractPayload($data); + $request = new Request( + $method, + $endpoint, + [], + $extractedPayload + ); + + $response = $this->sendRequest($request); + + return $this->parseResponse( + $request, + $response, + $returnClass, + $data instanceof BulkResourceRequestInterface + ); + } + + /** * @throws VaultAuthenticationException */ private function authenticate(): void @@ -76,71 +103,21 @@ private function authenticate(): void } } - /** - * @param ArrayExportInterface|array $data - * @return string - */ - private function extractPayload(ArrayExportInterface|array $data): string + private function extractPayload(array|ArrayExportInterface $data): string { if ($data instanceof ArrayExportInterface) { $data = $data->toArray(); } $encodedData = json_encode($data); - if ($encodedData === false) { - return ""; + if (false === $encodedData) { + return ''; } return $encodedData; } /** - * @param string $method - * @param string $endpoint - * @param string $returnClass - * @param array|ResourceRequestInterface $data - * @param bool $authRequired - * @return mixed - * @throws InvalidDataException - * @throws InvalidRouteException - * @throws VaultAuthenticationException - * @throws VaultException - * @throws VaultHttpException - */ - public function sendApiRequest( - string $method, - string $endpoint, - string $returnClass, - ResourceRequestInterface|array $data = [], - bool $authRequired = true - ): mixed { - if ($authRequired) { - $this->authenticate(); - } - - $extractedPayload = $this->extractPayload($data); - $request = new Request( - $method, - $endpoint, - [], - $extractedPayload - ); - - $response = $this->sendRequest($request); - return $this->parseResponse( - $request, - $response, - $returnClass, - $data instanceof BulkResourceRequestInterface - ); - } - - /** - * @param RequestInterface $request - * @param ResponseInterface $response - * @param string $returnClass - * @param boolean $isBulkRequest - * @return mixed * @throws InvalidDataException * @throws InvalidRouteException * @throws VaultAuthenticationException @@ -148,18 +125,18 @@ public function sendApiRequest( * @throws VaultResponseException */ private function parseResponse( - RequestInterface $request, + RequestInterface $request, ResponseInterface $response, - string $returnClass, + string $returnClass, bool $isBulkRequest ): mixed { $status = $response->getStatusCode(); - /** - * Looks like psalm can't handle the method exists with static functions - */ + // Looks like psalm can't handle the method exists with static functions if (!$isBulkRequest) { - /** @psalm-suppress ArgumentTypeCoercion */ + /** + * @psalm-suppress ArgumentTypeCoercion + */ if (!method_exists($returnClass, 'fromResponse')) { throw new VaultException('Return Class declaration lacks static::fromResponse'); } @@ -167,7 +144,9 @@ private function parseResponse( /** @var EndpointResponse $responseDataDTO */ $responseDataDTO = $returnClass::fromResponse($response); } else { - /** @psalm-suppress ArgumentTypeCoercion */ + /** + * @psalm-suppress ArgumentTypeCoercion + */ if (!method_exists($returnClass, 'fromBulkResponse')) { throw new VaultException('Return Class declaration lacks static::fromBulkResponse'); } @@ -185,16 +164,17 @@ private function parseResponse( if ($status >= 200 && $status < 300) { return $responseDataDTO; - - } elseif ($status >= 400 && $status < 500) { - if ($status === 400) { + } + if ($status >= 400 && $status < 500) { + if (400 === $status) { if ($responseMetaData->containsError(ApiErrors::ENCRYPTION_KEY_NOT_FOUND)) { throw new KeyNameNotFoundException($response, $request); } + throw new InvalidDataException($response, $request); - } elseif ($status === 403) { + } elseif (403 === $status) { throw new VaultAuthenticationException('Authentication with provided Token failed'); - } elseif ($status === 404) { + } elseif (404 === $status) { // if 404 and no error this indicates no data for e.g. List // makes no sense but hey - the vault rest is a magical unicorn if (!$isBulkRequest && !$responseHasErrors) { @@ -209,18 +189,17 @@ private function parseResponse( throw new VaultResponseException($response, $request); } - throw new VaultException(sprintf("server responded with unhandled status code %s", $response->getStatusCode())); + throw new VaultException(sprintf('server responded with unhandled status code %s', $response->getStatusCode())); } /** - * @param RequestInterface $request - * @return ResponseInterface * @throws VaultException * @throws VaultHttpException */ private function sendRequest(RequestInterface $request): ResponseInterface { $requestWithDefaults = $this->getDefaultRequest($request); + try { return $this->httpClient->sendRequest($requestWithDefaults); } catch (\Throwable $exception) { @@ -230,7 +209,7 @@ private function sendRequest(RequestInterface $request): ResponseInterface /** * @param $request RequestInterface - * @return RequestInterface + * * @throws VaultException */ private function getDefaultRequest(RequestInterface $request): RequestInterface @@ -245,7 +224,8 @@ private function getDefaultRequest(RequestInterface $request): RequestInterface $uriWithHost = $request ->getUri() ->withScheme($hostEndpoint['scheme']) - ->withHost($hostEndpoint['host']); + ->withHost($hostEndpoint['host']) + ; if (isset($hostEndpoint['port'])) { $uriWithHost = $uriWithHost->withPort($hostEndpoint['port']); @@ -255,6 +235,7 @@ private function getDefaultRequest(RequestInterface $request): RequestInterface ->withUri($uriWithHost) ->withAddedHeader('X-Vault-Request', '1') ->withAddedHeader('X-Vault-Token', $token) - ->withAddedHeader('Content-Type', 'application/json'); + ->withAddedHeader('Content-Type', 'application/json') + ; } } diff --git a/tests/VaultPHP/Exceptions/ExceptionsTest.php b/tests/VaultPHP/Exceptions/ExceptionsTest.php index 7f37498..971928c 100644 --- a/tests/VaultPHP/Exceptions/ExceptionsTest.php +++ b/tests/VaultPHP/Exceptions/ExceptionsTest.php @@ -39,6 +39,7 @@ public function testWillThrowWhenApiHostMalformed(): void { $auth = new Token('fooToken'); $httpClient = $this->createMock(ClientInterface::class); + $httpClient->expects($this->never())->method('sendRequest'); $client = new VaultClient($httpClient, $auth, "imInvalidHost"); $client->sendApiRequest('LOL', '/i/should/be/preserved', EndpointResponse::class, ['dontReplaceMe']); @@ -63,6 +64,8 @@ public function testWillThrowWhenAPIReturns403(): void { $this->expectException(VaultAuthenticationException::class); $httpClient = $this->createMock(ClientInterface::class); + $httpClient->expects($this->never())->method('sendRequest'); + $auth = $this->createMock(AuthenticationProviderInterface::class); $auth ->expects($this->once()) diff --git a/tests/VaultPHP/VaultClientTest.php b/tests/VaultPHP/VaultClientTest.php index b21df86..fe74cf9 100644 --- a/tests/VaultPHP/VaultClientTest.php +++ b/tests/VaultPHP/VaultClientTest.php @@ -37,8 +37,9 @@ public function testAuthProviderGetsClientInjected(): void $auth->expects($this->once()) ->method('setVaultClient') ->with($this->isInstanceOf(VaultClient::class)); - ; + $httpClient = $this->createMock(ClientInterface::class); + $httpClient->expects($this->never())->method('sendRequest'); new VaultClient($httpClient, $auth, TEST_VAULT_ENDPOINT); }