From 1a751f74307fe10329538bbf4c7d9139a5c129ac Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 28 Sep 2024 11:09:08 -0300 Subject: [PATCH 1/5] add namespace to helper functions --- composer.json | 3 +- composer.lock | 236 +++++++++++++++++++------------------- src/Support/functions.php | 105 +++++++++++++++++ src/helpers.php | 92 +-------------- 4 files changed, 227 insertions(+), 209 deletions(-) create mode 100644 src/Support/functions.php diff --git a/composer.json b/composer.json index eee951b..b22c854 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ "Xray\\AzureStoragePhpSdk\\": "src/" }, "files": [ - "src/helpers.php" + "src/helpers.php", + "src/Support/functions.php" ] }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index 644fc28..3cf6e97 100644 --- a/composer.lock +++ b/composer.lock @@ -606,16 +606,16 @@ "packages-dev": [ { "name": "brianium/paratest", - "version": "v7.5.4", + "version": "v7.5.5", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "c490591cc9c2f4830633b905547d30d5eb609c88" + "reference": "f29c7d671afc5c4e1140bd7b9f2749e827902a1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/c490591cc9c2f4830633b905547d30d5eb609c88", - "reference": "c490591cc9c2f4830633b905547d30d5eb609c88", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/f29c7d671afc5c4e1140bd7b9f2749e827902a1e", + "reference": "f29c7d671afc5c4e1140bd7b9f2749e827902a1e", "shasum": "" }, "require": { @@ -629,7 +629,7 @@ "phpunit/php-code-coverage": "^11.0.6", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-timer": "^7.0.1", - "phpunit/phpunit": "^11.3.3", + "phpunit/phpunit": "^11.3.6", "sebastian/environment": "^7.2.0", "symfony/console": "^6.4.11 || ^7.1.4", "symfony/process": "^6.4.8 || ^7.1.3" @@ -639,11 +639,11 @@ "ext-pcov": "*", "ext-posix": "*", "infection/infection": "^0.29.6", - "phpstan/phpstan": "^1.12.1", - "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan": "^1.12.4", + "phpstan/phpstan-deprecation-rules": "^1.2.1", "phpstan/phpstan-phpunit": "^1.4.0", "phpstan/phpstan-strict-rules": "^1.6.0", - "squizlabs/php_codesniffer": "^3.10.2", + "squizlabs/php_codesniffer": "^3.10.3", "symfony/filesystem": "^6.4.9 || ^7.1.2" }, "bin": [ @@ -684,7 +684,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.5.4" + "source": "https://github.com/paratestphp/paratest/tree/v7.5.5" }, "funding": [ { @@ -696,7 +696,7 @@ "type": "paypal" } ], - "time": "2024-09-04T21:15:27+00:00" + "time": "2024-09-20T12:57:46+00:00" }, { "name": "captainhook/captainhook", @@ -1140,26 +1140,26 @@ }, { "name": "filp/whoops", - "version": "2.15.4", + "version": "2.16.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" + "reference": "befcdc0e5dce67252aa6322d82424be928214fa2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", - "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", + "url": "https://api.github.com/repos/filp/whoops/zipball/befcdc0e5dce67252aa6322d82424be928214fa2", + "reference": "befcdc0e5dce67252aa6322d82424be928214fa2", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0 || ^8.0", + "php": "^7.1 || ^8.0", "psr/log": "^1.0.1 || ^2.0 || ^3.0" }, "require-dev": { - "mockery/mockery": "^0.9 || ^1.0", - "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3", - "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0" + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^4.0 || ^5.0" }, "suggest": { "symfony/var-dumper": "Pretty print complex values better with var-dumper available", @@ -1199,7 +1199,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.15.4" + "source": "https://github.com/filp/whoops/tree/2.16.0" }, "funding": [ { @@ -1207,7 +1207,7 @@ "type": "github" } ], - "time": "2023-11-03T12:00:00+00:00" + "time": "2024-09-25T12:00:00+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -1321,16 +1321,16 @@ }, { "name": "laravel/pint", - "version": "v1.17.3", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "9d77be916e145864f10788bb94531d03e1f7b482" + "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/9d77be916e145864f10788bb94531d03e1f7b482", - "reference": "9d77be916e145864f10788bb94531d03e1f7b482", + "url": "https://api.github.com/repos/laravel/pint/zipball/35c00c05ec43e6b46d295efc0f4386ceb30d50d9", + "reference": "35c00c05ec43e6b46d295efc0f4386ceb30d50d9", "shasum": "" }, "require": { @@ -1383,7 +1383,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-09-03T15:00:28+00:00" + "time": "2024-09-24T17:22:50+00:00" }, { "name": "mockery/mockery", @@ -1530,16 +1530,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.1.0", + "version": "v5.2.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" + "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", - "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb", + "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb", "shasum": "" }, "require": { @@ -1582,9 +1582,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.2.0" }, - "time": "2024-07-01T20:03:41+00:00" + "time": "2024-09-15T16:40:33+00:00" }, { "name": "nunomaduro/collision", @@ -1836,37 +1836,37 @@ }, { "name": "pestphp/pest", - "version": "v3.0.6", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "0d50d35b5eab4164b1e777e63f689be5cd8c40e5" + "reference": "5fe79d9c18a674e9cce2f36f365516c26ae87b49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/0d50d35b5eab4164b1e777e63f689be5cd8c40e5", - "reference": "0d50d35b5eab4164b1e777e63f689be5cd8c40e5", + "url": "https://api.github.com/repos/pestphp/pest/zipball/5fe79d9c18a674e9cce2f36f365516c26ae87b49", + "reference": "5fe79d9c18a674e9cce2f36f365516c26ae87b49", "shasum": "" }, "require": { - "brianium/paratest": "^7.5.4", + "brianium/paratest": "^7.5.5", "nunomaduro/collision": "^8.4.0", "nunomaduro/termwind": "^2.1.0", "pestphp/pest-plugin": "^3.0.0", "pestphp/pest-plugin-arch": "^3.0.0", - "pestphp/pest-plugin-mutate": "^3.0.3", + "pestphp/pest-plugin-mutate": "^3.0.5", "php": "^8.2.0", - "phpunit/phpunit": "^11.3.4" + "phpunit/phpunit": "^11.3.6" }, "conflict": { - "phpunit/phpunit": ">11.3.4", + "phpunit/phpunit": ">11.3.6", "sebastian/exporter": "<6.0.0", "webmozart/assert": "<1.11.0" }, "require-dev": { "pestphp/pest-dev-tools": "^3.0.0", "pestphp/pest-plugin-type-coverage": "^3.0.0", - "symfony/process": "^7.1.3" + "symfony/process": "^7.1.5" }, "bin": [ "bin/pest" @@ -1931,7 +1931,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v3.0.6" + "source": "https://github.com/pestphp/pest/tree/v3.2.4" }, "funding": [ { @@ -1943,7 +1943,7 @@ "type": "github" } ], - "time": "2024-09-11T17:59:43+00:00" + "time": "2024-09-26T22:53:39+00:00" }, { "name": "pestphp/pest-plugin", @@ -2087,26 +2087,26 @@ }, { "name": "pestphp/pest-plugin-mutate", - "version": "v3.0.3", + "version": "v3.0.5", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-mutate.git", - "reference": "d83a5e106c92ea0ebf928eefbe4a57f028adf468" + "reference": "e10dbdc98c9e2f3890095b4fe2144f63a5717e08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/d83a5e106c92ea0ebf928eefbe4a57f028adf468", - "reference": "d83a5e106c92ea0ebf928eefbe4a57f028adf468", + "url": "https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/e10dbdc98c9e2f3890095b4fe2144f63a5717e08", + "reference": "e10dbdc98c9e2f3890095b4fe2144f63a5717e08", "shasum": "" }, "require": { - "nikic/php-parser": "^5.1.0", + "nikic/php-parser": "^5.2.0", "pestphp/pest-plugin": "^3.0.0", "php": "^8.2", "psr/simple-cache": "^3.0.0" }, "require-dev": { - "pestphp/pest": "^3.0.1", + "pestphp/pest": "^3.0.8", "pestphp/pest-dev-tools": "^3.0.0", "pestphp/pest-plugin-type-coverage": "^3.0.0" }, @@ -2139,7 +2139,7 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin-mutate/tree/v3.0.3" + "source": "https://github.com/pestphp/pest-plugin-mutate/tree/v3.0.5" }, "funding": [ { @@ -2155,7 +2155,7 @@ "type": "github" } ], - "time": "2024-09-10T15:59:08+00:00" + "time": "2024-09-22T07:54:40+00:00" }, { "name": "phar-io/manifest", @@ -2535,16 +2535,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.30.1", + "version": "1.32.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "51b95ec8670af41009e2b2b56873bad96682413e" + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e", - "reference": "51b95ec8670af41009e2b2b56873bad96682413e", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", "shasum": "" }, "require": { @@ -2576,22 +2576,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" }, - "time": "2024-09-07T20:13:05+00:00" + "time": "2024-09-26T07:23:32+00:00" }, { "name": "phpstan/phpstan", - "version": "1.12.3", + "version": "1.12.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009" + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0fcbf194ab63d8159bb70d9aa3e1350051632009", - "reference": "0fcbf194ab63d8159bb70d9aa3e1350051632009", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", + "reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17", "shasum": "" }, "require": { @@ -2636,7 +2636,7 @@ "type": "github" } ], - "time": "2024-09-09T08:10:35+00:00" + "time": "2024-09-26T12:45:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2963,16 +2963,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.3.4", + "version": "11.3.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d2ef57db1410b102b250e0cdce6675a60c2a993d" + "reference": "d62c45a19c665bb872c2a47023a0baf41a98bb2b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d2ef57db1410b102b250e0cdce6675a60c2a993d", - "reference": "d2ef57db1410b102b250e0cdce6675a60c2a993d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d62c45a19c665bb872c2a47023a0baf41a98bb2b", + "reference": "d62c45a19c665bb872c2a47023a0baf41a98bb2b", "shasum": "" }, "require": { @@ -2993,13 +2993,13 @@ "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.1", - "sebastian/comparator": "^6.0.2", + "sebastian/comparator": "^6.1.0", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.0", "sebastian/exporter": "^6.1.3", "sebastian/global-state": "^7.0.2", "sebastian/object-enumerator": "^6.0.1", - "sebastian/type": "^5.0.1", + "sebastian/type": "^5.1.0", "sebastian/version": "^5.0.1" }, "suggest": { @@ -3043,7 +3043,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.4" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.6" }, "funding": [ { @@ -3059,7 +3059,7 @@ "type": "tidelift" } ], - "time": "2024-09-09T06:08:34+00:00" + "time": "2024-09-19T10:54:28+00:00" }, { "name": "psr/container", @@ -4029,28 +4029,28 @@ }, { "name": "sebastian/type", - "version": "5.0.1", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa" + "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb6a6566f9589e86661291d13eba708cce5eb4aa", - "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/461b9c5da241511a2a0e8f240814fb23ce5c0aac", + "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -4074,7 +4074,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/type/issues", "security": "https://github.com/sebastianbergmann/type/security/policy", - "source": "https://github.com/sebastianbergmann/type/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/type/tree/5.1.0" }, "funding": [ { @@ -4082,7 +4082,7 @@ "type": "github" } ], - "time": "2024-07-03T05:11:49+00:00" + "time": "2024-09-17T13:12:04+00:00" }, { "name": "sebastian/version", @@ -4316,16 +4316,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.2", + "version": "3.10.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017" + "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017", - "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", + "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", "shasum": "" }, "require": { @@ -4392,7 +4392,7 @@ "type": "open_collective" } ], - "time": "2024-07-21T23:26:44+00:00" + "time": "2024-09-18T10:38:58+00:00" }, { "name": "symfony/config", @@ -4471,16 +4471,16 @@ }, { "name": "symfony/console", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111" + "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/1eed7af6961d763e7832e874d7f9b21c3ea9c111", - "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111", + "url": "https://api.github.com/repos/symfony/console/zipball/0fa539d12b3ccf068a722bbbffa07ca7079af9ee", + "reference": "0fa539d12b3ccf068a722bbbffa07ca7079af9ee", "shasum": "" }, "require": { @@ -4544,7 +4544,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.4" + "source": "https://github.com/symfony/console/tree/v7.1.5" }, "funding": [ { @@ -4560,20 +4560,20 @@ "type": "tidelift" } ], - "time": "2024-08-15T22:48:53+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/dependency-injection", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "5320e0bc2c9e2d7450bb4091e497a305a68b28ed" + "reference": "38465f925ec4e0707b090e9147c65869837d639d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/5320e0bc2c9e2d7450bb4091e497a305a68b28ed", - "reference": "5320e0bc2c9e2d7450bb4091e497a305a68b28ed", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/38465f925ec4e0707b090e9147c65869837d639d", + "reference": "38465f925ec4e0707b090e9147c65869837d639d", "shasum": "" }, "require": { @@ -4624,7 +4624,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v7.1.4" + "source": "https://github.com/symfony/dependency-injection/tree/v7.1.5" }, "funding": [ { @@ -4640,20 +4640,20 @@ "type": "tidelift" } ], - "time": "2024-08-29T08:16:25+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/filesystem", - "version": "v7.1.2", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "92a91985250c251de9b947a14bb2c9390b1a562c" + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/92a91985250c251de9b947a14bb2c9390b1a562c", - "reference": "92a91985250c251de9b947a14bb2c9390b1a562c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/61fe0566189bf32e8cfee78335d8776f64a66f5a", + "reference": "61fe0566189bf32e8cfee78335d8776f64a66f5a", "shasum": "" }, "require": { @@ -4690,7 +4690,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.2" + "source": "https://github.com/symfony/filesystem/tree/v7.1.5" }, "funding": [ { @@ -4706,7 +4706,7 @@ "type": "tidelift" } ], - "time": "2024-06-28T10:03:55+00:00" + "time": "2024-09-17T09:16:35+00:00" }, { "name": "symfony/finder", @@ -5092,16 +5092,16 @@ }, { "name": "symfony/process", - "version": "v7.1.3", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "7f2f542c668ad6c313dc4a5e9c3321f733197eca" + "reference": "5c03ee6369281177f07f7c68252a280beccba847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/7f2f542c668ad6c313dc4a5e9c3321f733197eca", - "reference": "7f2f542c668ad6c313dc4a5e9c3321f733197eca", + "url": "https://api.github.com/repos/symfony/process/zipball/5c03ee6369281177f07f7c68252a280beccba847", + "reference": "5c03ee6369281177f07f7c68252a280beccba847", "shasum": "" }, "require": { @@ -5133,7 +5133,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.1.3" + "source": "https://github.com/symfony/process/tree/v7.1.5" }, "funding": [ { @@ -5149,7 +5149,7 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:44:47+00:00" + "time": "2024-09-19T21:48:23+00:00" }, { "name": "symfony/service-contracts", @@ -5236,16 +5236,16 @@ }, { "name": "symfony/string", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b" + "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/6cd670a6d968eaeb1c77c2e76091c45c56bc367b", - "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b", + "url": "https://api.github.com/repos/symfony/string/zipball/d66f9c343fa894ec2037cc928381df90a7ad4306", + "reference": "d66f9c343fa894ec2037cc928381df90a7ad4306", "shasum": "" }, "require": { @@ -5303,7 +5303,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.4" + "source": "https://github.com/symfony/string/tree/v7.1.5" }, "funding": [ { @@ -5319,20 +5319,20 @@ "type": "tidelift" } ], - "time": "2024-08-12T09:59:40+00:00" + "time": "2024-09-20T08:28:38+00:00" }, { "name": "symfony/var-dumper", - "version": "v7.1.4", + "version": "v7.1.5", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "a5fa7481b199090964d6fd5dab6294d5a870c7aa" + "reference": "e20e03889539fd4e4211e14d2179226c513c010d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/a5fa7481b199090964d6fd5dab6294d5a870c7aa", - "reference": "a5fa7481b199090964d6fd5dab6294d5a870c7aa", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e20e03889539fd4e4211e14d2179226c513c010d", + "reference": "e20e03889539fd4e4211e14d2179226c513c010d", "shasum": "" }, "require": { @@ -5386,7 +5386,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.1.4" + "source": "https://github.com/symfony/var-dumper/tree/v7.1.5" }, "funding": [ { @@ -5402,7 +5402,7 @@ "type": "tidelift" } ], - "time": "2024-08-30T16:12:47+00:00" + "time": "2024-09-16T10:07:02+00:00" }, { "name": "symfony/var-exporter", diff --git a/src/Support/functions.php b/src/Support/functions.php new file mode 100644 index 0000000..51b91ef --- /dev/null +++ b/src/Support/functions.php @@ -0,0 +1,105 @@ +setTimezone(new DateTimeZone('GMT'))->format('D, d M Y H:i:s') . ' GMT'; +} + +/** + * Converts a DateTime object to RFC3339 micro format. + */ +function convert_to_RFC3339_micro(DateTime $dateTime): string +{ + $utcDateTime = $dateTime->setTimezone(new DateTimeZone('UTC')); + + $microseconds = $dateTime->format('u'); + $microseconds = str_pad($microseconds, 7, '0', STR_PAD_RIGHT); + + return $utcDateTime->format('Y-m-d\TH:i:s.') . $microseconds . 'Z'; +} + +/** + * Converts a DateTime object to ISO format. + */ +function convert_to_ISO(DateTimeImmutable|string $dateTime): string +{ + if (is_string($dateTime)) { + $dateTime = new DateTimeImmutable($dateTime); + } + + $dateTime = $dateTime->setTimezone(new DateTimeZone('UTC')); + + return str_replace('+00:00', 'Z', $dateTime->format('c')); +} diff --git a/src/helpers.php b/src/helpers.php index 7ebeb08..ce29470 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -1,9 +1,8 @@ make($key, $parameters); } } - -if (!function_exists('with')) { - /** - * Applies a closure to a value and returns the value. - * - * @template T - * @param T $value The value to be passed to the closure. - * @param \Closure(T): void $callback The closure to be applied to the value. - * @return T The original value after the closure has been applied. - */ - function with(mixed $value, Closure $callback): mixed - { - $callback($value); - - return $value; - } -} - -if (!function_exists('is_running_in_console')) { - function is_running_in_console(): bool - { - return in_array(\PHP_SAPI, ['cli', 'phpdbg'], true); - } -} - -if (!function_exists('validate_protocol')) { - function validate_protocol(string $value): true - { - $validProtocols = ['http', 'https']; - - if (!in_array($value, $validProtocols, true)) { - throw InvalidArgumentException::create(sprintf( - 'Invalid protocol: %s. Valid protocols: %s', - $value, - implode(', ', $validProtocols), - )); - } - - return true; - } -} - -if (!function_exists('str_camel_to_header')) { - function str_camel_to_header(string $value): string - { - return ucwords(preg_replace('/([a-z])([A-Z])/', '$1-$2', $value) ?? '', '-'); - } -} - -if (!function_exists('to_boolean')) { - function to_boolean(mixed $value): bool - { - return filter_var($value, FILTER_VALIDATE_BOOLEAN); - } -} - -if (!function_exists('convert_to_RFC1123')) { - function convert_to_RFC1123(DateTime $dateTime): string - { - return (clone $dateTime)->setTimezone(new DateTimeZone('GMT'))->format('D, d M Y H:i:s') . ' GMT'; - } -} - -if (!function_exists('convert_to_RFC3339_micro')) { - function convert_to_RFC3339_micro(DateTime $dateTime): string - { - $utcDateTime = $dateTime->setTimezone(new DateTimeZone('UTC')); - - $microseconds = $dateTime->format('u'); - $microseconds = str_pad($microseconds, 7, '0', STR_PAD_RIGHT); - - return $utcDateTime->format('Y-m-d\TH:i:s.') . $microseconds . 'Z'; - } -} - -if (!function_exists('convert_to_ISO')) { - function convert_to_ISO(DateTimeImmutable|string $dateTime): string - { - if (is_string($dateTime)) { - $dateTime = new DateTimeImmutable($dateTime); - } - - $dateTime = $dateTime->setTimezone(new DateTimeZone('UTC')); - - return str_replace('+00:00', 'Z', $dateTime->format('c')); - } -} From 08adade0198fcb1b270292382a584023ef2c4a9f Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 28 Sep 2024 11:09:49 -0300 Subject: [PATCH 2/5] add 'use function' to all places --- src/Authentication/SharedAccessSignature/UserDelegationSas.php | 2 ++ src/BlobStorage/Entities/Account/AccountInformation.php | 2 ++ .../Account/BlobStorageProperty/DeleteRetentionPolicy.php | 2 ++ .../Entities/Account/BlobStorageProperty/HourMetrics.php | 2 ++ .../Entities/Account/BlobStorageProperty/Logging.php | 2 ++ .../Entities/Account/BlobStorageProperty/MinuteMetrics.php | 2 ++ .../Entities/Account/BlobStorageProperty/StaticWebsite.php | 2 ++ src/BlobStorage/Entities/Account/KeyInfo.php | 2 ++ src/BlobStorage/Entities/Blob/Blob.php | 3 +++ src/BlobStorage/Entities/Blob/BlobProperty.php | 2 ++ src/BlobStorage/Entities/Blob/Properties.php | 3 +++ src/BlobStorage/Entities/Container/Container.php | 2 ++ src/BlobStorage/Entities/Container/ContainerProperties.php | 2 ++ src/BlobStorage/Entities/Container/Properties.php | 2 ++ src/BlobStorage/Managers/Blob/BlobManager.php | 3 +++ src/BlobStorage/Resources/File.php | 2 ++ src/Concerns/HasStreamingResponse.php | 2 ++ src/Http/Headers.php | 2 ++ src/Http/Request.php | 2 ++ .../SharedAccessSignature/UserDelegationSasTest.php | 2 ++ 20 files changed, 43 insertions(+) diff --git a/src/Authentication/SharedAccessSignature/UserDelegationSas.php b/src/Authentication/SharedAccessSignature/UserDelegationSas.php index c010982..26b2c66 100644 --- a/src/Authentication/SharedAccessSignature/UserDelegationSas.php +++ b/src/Authentication/SharedAccessSignature/UserDelegationSas.php @@ -15,6 +15,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\Authentication\InvalidAuthenticationMethodException; use Xray\AzureStoragePhpSdk\Exceptions\InvalidResourceTypeException; +use function Xray\AzureStoragePhpSdk\Support\convert_to_ISO; + class UserDelegationSas implements SharedAccessSignature { /** @var array */ diff --git a/src/BlobStorage/Entities/Account/AccountInformation.php b/src/BlobStorage/Entities/Account/AccountInformation.php index 1431441..29c60f4 100644 --- a/src/BlobStorage/Entities/Account/AccountInformation.php +++ b/src/BlobStorage/Entities/Account/AccountInformation.php @@ -6,6 +6,8 @@ use DateTimeImmutable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + final readonly class AccountInformation { public string $server; diff --git a/src/BlobStorage/Entities/Account/BlobStorageProperty/DeleteRetentionPolicy.php b/src/BlobStorage/Entities/Account/BlobStorageProperty/DeleteRetentionPolicy.php index 245ee08..3d78e9e 100644 --- a/src/BlobStorage/Entities/Account/BlobStorageProperty/DeleteRetentionPolicy.php +++ b/src/BlobStorage/Entities/Account/BlobStorageProperty/DeleteRetentionPolicy.php @@ -6,6 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Arrayable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type DeleteRetentionPolicyType array{Enabled?: bool, AllowPermanentDelete?: bool, Days?: int} * diff --git a/src/BlobStorage/Entities/Account/BlobStorageProperty/HourMetrics.php b/src/BlobStorage/Entities/Account/BlobStorageProperty/HourMetrics.php index b4d0eea..3ed0d44 100644 --- a/src/BlobStorage/Entities/Account/BlobStorageProperty/HourMetrics.php +++ b/src/BlobStorage/Entities/Account/BlobStorageProperty/HourMetrics.php @@ -6,6 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Arrayable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type RetentionPolicyType array{Days?: int, Enabled: bool} * @phpstan-type HourMetricsType array{Version: ?string, Enabled?: bool, IncludeAPIs?: bool, RetentionPolicy?: RetentionPolicyType} diff --git a/src/BlobStorage/Entities/Account/BlobStorageProperty/Logging.php b/src/BlobStorage/Entities/Account/BlobStorageProperty/Logging.php index 69b39c0..9fbd858 100644 --- a/src/BlobStorage/Entities/Account/BlobStorageProperty/Logging.php +++ b/src/BlobStorage/Entities/Account/BlobStorageProperty/Logging.php @@ -6,6 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Arrayable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type RetentionPolicyType array{Days?: int, Enabled: bool} * @phpstan-type LoggingType array{Version: ?string, Delete?: bool, Read?: bool, Write?: bool, RetentionPolicy?: RetentionPolicyType} diff --git a/src/BlobStorage/Entities/Account/BlobStorageProperty/MinuteMetrics.php b/src/BlobStorage/Entities/Account/BlobStorageProperty/MinuteMetrics.php index 0687bd9..2c2f246 100644 --- a/src/BlobStorage/Entities/Account/BlobStorageProperty/MinuteMetrics.php +++ b/src/BlobStorage/Entities/Account/BlobStorageProperty/MinuteMetrics.php @@ -6,6 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Arrayable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type RetentionPolicyType array{Days?: int, Enabled: bool} * @phpstan-type MinuteMetricsType array{Version: ?string, Enabled?: bool, IncludeAPIs?: bool, RetentionPolicy?: RetentionPolicyType} diff --git a/src/BlobStorage/Entities/Account/BlobStorageProperty/StaticWebsite.php b/src/BlobStorage/Entities/Account/BlobStorageProperty/StaticWebsite.php index b9e699a..7b45220 100644 --- a/src/BlobStorage/Entities/Account/BlobStorageProperty/StaticWebsite.php +++ b/src/BlobStorage/Entities/Account/BlobStorageProperty/StaticWebsite.php @@ -6,6 +6,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Arrayable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type StaticWebsiteType array{Enabled?: bool, IndexDocument?: string, DefaultIndexDocumentPath?: string, ErrorDocument404Path?: string} * diff --git a/src/BlobStorage/Entities/Account/KeyInfo.php b/src/BlobStorage/Entities/Account/KeyInfo.php index 003cf09..e9a8605 100644 --- a/src/BlobStorage/Entities/Account/KeyInfo.php +++ b/src/BlobStorage/Entities/Account/KeyInfo.php @@ -10,6 +10,8 @@ use Xray\AzureStoragePhpSdk\Converter\XmlConverter; use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; +use function Xray\AzureStoragePhpSdk\Support\convert_to_ISO; + /** @implements Arrayable */ final readonly class KeyInfo implements Arrayable, Xmlable { diff --git a/src/BlobStorage/Entities/Blob/Blob.php b/src/BlobStorage/Entities/Blob/Blob.php index 6a978f3..3c5ae5d 100644 --- a/src/BlobStorage/Entities/Blob/Blob.php +++ b/src/BlobStorage/Entities/Blob/Blob.php @@ -12,6 +12,9 @@ use Xray\AzureStoragePhpSdk\Concerns\HasManager; use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + + /** * @phpstan-import-type PropertiesType from Properties * diff --git a/src/BlobStorage/Entities/Blob/BlobProperty.php b/src/BlobStorage/Entities/Blob/BlobProperty.php index 907da8a..b3f5226 100644 --- a/src/BlobStorage/Entities/Blob/BlobProperty.php +++ b/src/BlobStorage/Entities/Blob/BlobProperty.php @@ -7,6 +7,8 @@ use DateTimeImmutable; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type BlobPropertyHeaders array{Last-Modified?: string, x-ms-creation-time?: string, x-ms-tag-count?: int, x-ms-blob-type?: string, x-ms-copy-completion-time?: string|null, x-ms-copy-status-description?: string|null, x-ms-copy-id?: string|null, x-ms-copy-progress?: string|null, x-ms-copy-source?: string|null, x-ms-copy-status?: string|null, x-ms-incremental-copy?: string|null, x-ms-copy-destination-snapshot?: string|null, x-ms-lease-duration?: string|null, x-ms-lease-state?: string|null, x-ms-lease-status?: string|null, Content-Length?: int, Content-Type?: string|null, ETag?: string, Content-MD5?: string|null, Content-Encoding?: string|null, Content-Language?: string|null, Content-Disposition?: string|null, Cache-Control?: string|null, x-ms-blob-sequence-number?: int, x-ms-request-id?: string|null, x-ms-version?: string|null, Date?: string, Accept-Ranges?: string|null, x-ms-blob-committed-block-count?: string|null, x-ms-server-encrypted?: bool, x-ms-encryption-key-sha256?: string|null, x-ms-encryption-context?: string|null, x-ms-encryption-scope?: string|null, x-ms-access-tier?: string|null, x-ms-access-tier-inferred?: string|null, x-ms-archive-status?: string|null, x-ms-access-tier-change-time?: string|null, x-ms-client-request-id?: string|null, x-ms-rehydrate-priority?: string|null, x-ms-or-policy-id?: string|null, x-ms-last-access-time?: string|null, x-ms-blob-sealed?: string|null, x-ms-immutability-policy-until-date?: string|null, x-ms-immutability-policy-mode?: string|null, x-ms-legal-hold?: string|null, x-ms-owner?: string|null, x-ms-group?: string|null, x-ms-permissions?: string|null, x-ms-acl?: string|null, x-ms-resource-type?: string|null, x-ms-expiry-time?: string|null, leaseId?: string|null, sequenceNumberAction?: string|null, Origin?: string|null} * @suppressWarnings(PHPMD) diff --git a/src/BlobStorage/Entities/Blob/Properties.php b/src/BlobStorage/Entities/Blob/Properties.php index caa332a..8be3cda 100644 --- a/src/BlobStorage/Entities/Blob/Properties.php +++ b/src/BlobStorage/Entities/Blob/Properties.php @@ -6,6 +6,9 @@ use DateTimeImmutable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + + /** * @phpstan-type PropertiesType array{Creation-Time?: string, Last-Modified?: string, Etag?: string, LeaseStatus?: string, LeaseState?: string, Owner?: string, Group?: string, Permissions?: string, Acl?: string, ResourceType?: string, Placeholder?: string, Content-Length?: string, Content-Type?: string, Content-Encoding?: string, Content-Language?: string, Content-MD5?: string, Cache-Control?: string, x-ms-blob-sequence-number?: string, BlobType?: string, AccessTier?: string, LeaseDuration?: string, CopyId?: string, CopyStatus?: string, CopySource?: string, CopyProgress?: string, CopyCompletionTime?: string, CopyStatusDescription?: string, ServerEncrypted?: string, CustomerProvidedKeySha256?: string, EncryptionContext?: string, EncryptionScope?: string, IncrementalCopy?: string, AccessTierInferred?: string, AccessTierChangeTime?: string, TagCount?: string, RehydratePriority?: string, ExpiryTime?: string, DeletedTime?: string, RemainingRetentionDays?: string} * @suppressWarnings(PHPMD.TooManyFields) diff --git a/src/BlobStorage/Entities/Container/Container.php b/src/BlobStorage/Entities/Container/Container.php index f7abccc..a52c720 100644 --- a/src/BlobStorage/Entities/Container/Container.php +++ b/src/BlobStorage/Entities/Container/Container.php @@ -11,6 +11,8 @@ use Xray\AzureStoragePhpSdk\Concerns\HasManager; use Xray\AzureStoragePhpSdk\Exceptions\RequiredFieldException; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-import-type PropertiesType from Properties * diff --git a/src/BlobStorage/Entities/Container/ContainerProperties.php b/src/BlobStorage/Entities/Container/ContainerProperties.php index adce3d2..0bf092d 100644 --- a/src/BlobStorage/Entities/Container/ContainerProperties.php +++ b/src/BlobStorage/Entities/Container/ContainerProperties.php @@ -7,6 +7,8 @@ use DateTimeImmutable; use Xray\AzureStoragePhpSdk\BlobStorage\Resource; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + final readonly class ContainerProperties { public DateTimeImmutable $lastModified; diff --git a/src/BlobStorage/Entities/Container/Properties.php b/src/BlobStorage/Entities/Container/Properties.php index db71294..2093774 100644 --- a/src/BlobStorage/Entities/Container/Properties.php +++ b/src/BlobStorage/Entities/Container/Properties.php @@ -6,6 +6,8 @@ use DateTimeImmutable; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type PropertiesType array{Last-Modified?: string, Etag?: string, LeaseStatus?: string, LeaseState?: string, DefaultEncryptionScope?: string, DenyEncryptionScopeOverride?: bool, HasImmutabilityPolicy?: bool, HasLegalHold?: bool, ImmutableStorageWithVersioningEnabled?: bool, DeletedTime?: string, RemainingRetentionDays?: int} */ diff --git a/src/BlobStorage/Managers/Blob/BlobManager.php b/src/BlobStorage/Managers/Blob/BlobManager.php index 4d813ab..4040970 100644 --- a/src/BlobStorage/Managers/Blob/BlobManager.php +++ b/src/BlobStorage/Managers/Blob/BlobManager.php @@ -18,6 +18,9 @@ use Xray\AzureStoragePhpSdk\Contracts\Manager; use Xray\AzureStoragePhpSdk\Exceptions\{InvalidArgumentException, RequestException}; +use function Xray\AzureStoragePhpSdk\Support\convert_to_RFC1123; +use function Xray\AzureStoragePhpSdk\Support\convert_to_RFC3339_micro; + /** * @phpstan-import-type BlobType from Blob as BlobTypeStan * @phpstan-import-type FileType from File diff --git a/src/BlobStorage/Resources/File.php b/src/BlobStorage/Resources/File.php index 41ae24d..8f76d4c 100644 --- a/src/BlobStorage/Resources/File.php +++ b/src/BlobStorage/Resources/File.php @@ -12,6 +12,8 @@ InvalidFileMimeTypeException, }; +use function Xray\AzureStoragePhpSdk\Support\to_boolean; + /** * @phpstan-type FileType array{Content-Length?: string, Content-Type?: string, Content-MD5?: string, Last-Modified?: string, Accept-Ranges?: string, ETag?: string, Vary?: string, Server?: string, x-ms-request-id?: string, x-ms-version?: string, x-ms-creation-time?: string, x-ms-lease-status?: string, x-ms-lease-state?: string, x-ms-blob-type?: string, x-ms-server-encrypted?: bool, Date?: string} */ diff --git a/src/Concerns/HasStreamingResponse.php b/src/Concerns/HasStreamingResponse.php index c870559..66c97b2 100644 --- a/src/Concerns/HasStreamingResponse.php +++ b/src/Concerns/HasStreamingResponse.php @@ -6,6 +6,8 @@ use Xray\AzureStoragePhpSdk\BlobStorage\Resources\File; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; +use function Xray\AzureStoragePhpSdk\Support\{is_running_in_console, with}; + trait HasStreamingResponse { public static function stream(File $file, ?int $expires = null): string diff --git a/src/Http/Headers.php b/src/Http/Headers.php index 80779fd..be18c5e 100644 --- a/src/Http/Headers.php +++ b/src/Http/Headers.php @@ -8,6 +8,8 @@ use Xray\AzureStoragePhpSdk\Contracts\{Arrayable, Stringable}; use Xray\AzureStoragePhpSdk\Exceptions\InvalidArgumentException; +use function Xray\AzureStoragePhpSdk\Support\str_camel_to_header; + /** * @property-read ?string $contentEncoding * @property-read ?string $contentLanguage diff --git a/src/Http/Request.php b/src/Http/Request.php index 476214a..8131a30 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -12,6 +12,8 @@ use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth; use Xray\AzureStoragePhpSdk\Contracts\Http\{Request as RequestContract, Response as ResponseContract}; +use function Xray\AzureStoragePhpSdk\Support\{validate_protocol, with}; + /** @suppressWarnings(PHPMD.ExcessiveParameterList) */ final class Request implements RequestContract { diff --git a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php index 3a2957e..8db4fb9 100644 --- a/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php +++ b/tests/Feature/Authentication/SharedAccessSignature/UserDelegationSasTest.php @@ -11,6 +11,8 @@ use Xray\AzureStoragePhpSdk\Exceptions\InvalidResourceTypeException; use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; +use function Xray\AzureStoragePhpSdk\Support\convert_to_ISO; + pest()->group('authentications', 'shared-access-signatures'); covers(UserDelegationSas::class); From 4cb6ed2c102d26d859689bb4f4d8d8a0fd63d3de Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 28 Sep 2024 11:21:33 -0300 Subject: [PATCH 3/5] add tests --- tests/Feature/HelpersTest.php | 87 ++-------------------- tests/Feature/Support/FunctionsTest.php | 98 +++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 80 deletions(-) create mode 100644 tests/Feature/Support/FunctionsTest.php diff --git a/tests/Feature/HelpersTest.php b/tests/Feature/HelpersTest.php index be7efd8..eb4b32e 100644 --- a/tests/Feature/HelpersTest.php +++ b/tests/Feature/HelpersTest.php @@ -1,85 +1,12 @@ group('helpers'); - -it('should check with function', function () { - $called = false; - $content = 'test'; - - expect(with($content, function (string $value) use (&$called, $content) { - $called = true; - - expect($value)->toBe($content); - }))->toBe($content); - - expect($called)->toBeTrue(); -})->covers('with'); - -it('should check if it\'s running in console', function () { - expect(is_running_in_console())->toBeTrue(); -})->covers('is_running_in_console'); - -it('should fail when an invalid protocol is validated', function () { - validate_protocol('invalid'); -})->throws( - InvalidArgumentException::class, - 'Invalid protocol: invalid. Valid protocols: http, https', -)->covers('validate_protocol'); - -it('should pass when a valid protocol is validated', function (string $protocol) { - expect(validate_protocol($protocol))->toBeTrue(); -})->with([ - 'HTTP' => ['http'], - 'HTTPS' => ['https'], -])->covers('validate_protocol'); +use Xray\AzureStoragePhpSdk\Application\Application; -it('should convert camel case string to be used in the headers', function (string $value, string $expected) { - expect(str_camel_to_header($value))->toBe($expected); -})->with([ - 'Pascal Case' => ['Test', 'Test'], - 'Multi Words' => ['MultiWords', 'Multi-Words'], - 'Camel Case' => ['camelCase', 'Camel-Case'], -])->covers('str_camel_to_header'); - -it('should convert value to boolean type', function (mixed $value, bool $expected) { - expect(to_boolean($value))->toBe($expected); -})->with([ - 'Empty Array' => [[], false], - 'Empty String' => ['', false], - 'Empty Object' => [(object)[], false], - 'True' => [true, true], - 'False' => [false, false], - 'Null' => [null, false], - 'Number 1' => [1, true], - 'Number 0' => [0, false], - 'String' => ['string', false], - 'Object' => [(object)['test' => 'test'], false], - 'Array' => [[1, 2, 3], false], -])->covers('to_boolean'); - -it('should convert date time to RFC1123 format', function () { - $datetime = (new DateTime('2022-05-26 04:12:36', new DateTimeZone('Asia/Jakarta'))); - $expected = (clone $datetime)->setTimezone(new DateTimeZone('GMT')); - - expect(convert_to_RFC1123($datetime))->toBe("{$expected->format('D, d M Y H:i:s')} GMT"); -})->covers('convert_to_RFC1123'); - -it('should convert datetime to RFC3339 micro format', function () { - $datetime = (new DateTime('2024-08-10 12:04:59', new DateTimeZone('America/New_York'))); - $expected = (clone $datetime)->setTimezone(new DateTimeZone('UTC')); - - $microseconds = $datetime->format('u'); - $microseconds = str_pad($microseconds, 7, '0', STR_PAD_LEFT); - - expect(convert_to_RFC3339_micro($datetime))->toBe("{$expected->format('Y-m-d\TH:i:s')}.{$microseconds}Z"); -})->covers('convert_to_RFC3339_micro'); +pest()->group('helpers'); -it('should convert to ISO format', function (string|DateTimeImmutable $datetime, $expected) { - expect(convert_to_ISO($datetime)) - ->toBe($expected); -})->with([ - 'String' => ['2024-10-10 12:04:59', '2024-10-10T12:04:59Z'], - 'DateTimeImmutable' => [(new DateTimeImmutable('2024-10-10 12:04:59', new DateTimeZone('UTC'))), '2024-10-10T12:04:59Z'], -])->covers('convert_to_ISO'); +it('should get the azure_app instance', function () { + expect(azure_app()) + ->toBeInstanceOf(Application::class); +})->covers('azure_app'); diff --git a/tests/Feature/Support/FunctionsTest.php b/tests/Feature/Support/FunctionsTest.php new file mode 100644 index 0000000..358254d --- /dev/null +++ b/tests/Feature/Support/FunctionsTest.php @@ -0,0 +1,98 @@ +group('supports'); + +it('should check with function', function () { + $called = false; + $content = 'test'; + + expect(with($content, function (string $value) use (&$called, $content) { + $called = true; + + expect($value)->toBe($content); + }))->toBe($content); + + expect($called)->toBeTrue(); +})->covers('\\Xray\\AzureStoragePhpSdk\\Support\\with'); + +it('should check if it\'s running in console', function () { + expect(is_running_in_console())->toBeTrue(); +})->covers('\\Xray\\AzureStoragePhpSdk\\Support\\is_running_in_console'); + +it('should fail when an invalid protocol is validated', function () { + validate_protocol('invalid'); +})->throws( + InvalidArgumentException::class, + 'Invalid protocol: invalid. Valid protocols: http, https', +)->covers('\\Xray\\AzureStoragePhpSdk\\Support\\validate_protocol'); + +it('should pass when a valid protocol is validated', function (string $protocol) { + expect(validate_protocol($protocol))->toBeTrue(); +})->with([ + 'HTTP' => ['http'], + 'HTTPS' => ['https'], +])->covers('\\Xray\\AzureStoragePhpSdk\\Support\\validate_protocol'); + +it('should convert camel case string to be used in the headers', function (string $value, string $expected) { + expect(str_camel_to_header($value))->toBe($expected); +})->with([ + 'Pascal Case' => ['Test', 'Test'], + 'Multi Words' => ['MultiWords', 'Multi-Words'], + 'Camel Case' => ['camelCase', 'Camel-Case'], +])->covers('\\Xray\\AzureStoragePhpSdk\\Support\\str_camel_to_header'); + +it('should convert value to boolean type', function (mixed $value, bool $expected) { + expect(to_boolean($value))->toBe($expected); +})->with([ + 'Empty Array' => [[], false], + 'Empty String' => ['', false], + 'Empty Object' => [(object)[], false], + 'True' => [true, true], + 'False' => [false, false], + 'Null' => [null, false], + 'Number 1' => [1, true], + 'Number 0' => [0, false], + 'String' => ['string', false], + 'Object' => [(object)['test' => 'test'], false], + 'Array' => [[1, 2, 3], false], +])->covers('\\Xray\\AzureStoragePhpSdk\\Support\\to_boolean'); + +it('should convert date time to RFC1123 format', function () { + $datetime = (new DateTime('2022-05-26 04:12:36', new DateTimeZone('Asia/Jakarta'))); + $expected = (clone $datetime)->setTimezone(new DateTimeZone('GMT')); + + expect(convert_to_RFC1123($datetime))->toBe("{$expected->format('D, d M Y H:i:s')} GMT"); +})->covers('\\Xray\\AzureStoragePhpSdk\\Support\\convert_to_RFC1123'); + +it('should convert datetime to RFC3339 micro format', function () { + $datetime = (new DateTime('2024-08-10 12:04:59', new DateTimeZone('America/New_York'))); + $expected = (clone $datetime)->setTimezone(new DateTimeZone('UTC')); + + $microseconds = $datetime->format('u'); + $microseconds = str_pad($microseconds, 7, '0', STR_PAD_LEFT); + + expect(convert_to_RFC3339_micro($datetime))->toBe("{$expected->format('Y-m-d\TH:i:s')}.{$microseconds}Z"); +})->covers('\\Xray\\AzureStoragePhpSdk\\Support\\convert_to_RFC3339_micro'); + +it('should convert to ISO format', function (string|DateTimeImmutable $datetime, $expected) { + expect(convert_to_ISO($datetime)) + ->toBe($expected); +})->with([ + 'String' => ['2024-10-10 12:04:59', '2024-10-10T12:04:59Z'], + 'DateTimeImmutable' => [(new DateTimeImmutable('2024-10-10 12:04:59', new DateTimeZone('UTC'))), '2024-10-10T12:04:59Z'], +])->covers('\\Xray\\AzureStoragePhpSdk\\Support\\convert_to_ISO'); From 06b84dc1e000b14a5e980ab5efe82ac573906bf5 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 28 Sep 2024 11:22:03 -0300 Subject: [PATCH 4/5] run 'composer fix' --- src/BlobStorage/Entities/Blob/Blob.php | 1 - src/BlobStorage/Entities/Blob/Properties.php | 1 - src/BlobStorage/Managers/Blob/BlobManager.php | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/BlobStorage/Entities/Blob/Blob.php b/src/BlobStorage/Entities/Blob/Blob.php index 3c5ae5d..a7fc007 100644 --- a/src/BlobStorage/Entities/Blob/Blob.php +++ b/src/BlobStorage/Entities/Blob/Blob.php @@ -14,7 +14,6 @@ use function Xray\AzureStoragePhpSdk\Support\to_boolean; - /** * @phpstan-import-type PropertiesType from Properties * diff --git a/src/BlobStorage/Entities/Blob/Properties.php b/src/BlobStorage/Entities/Blob/Properties.php index 8be3cda..827a698 100644 --- a/src/BlobStorage/Entities/Blob/Properties.php +++ b/src/BlobStorage/Entities/Blob/Properties.php @@ -8,7 +8,6 @@ use function Xray\AzureStoragePhpSdk\Support\to_boolean; - /** * @phpstan-type PropertiesType array{Creation-Time?: string, Last-Modified?: string, Etag?: string, LeaseStatus?: string, LeaseState?: string, Owner?: string, Group?: string, Permissions?: string, Acl?: string, ResourceType?: string, Placeholder?: string, Content-Length?: string, Content-Type?: string, Content-Encoding?: string, Content-Language?: string, Content-MD5?: string, Cache-Control?: string, x-ms-blob-sequence-number?: string, BlobType?: string, AccessTier?: string, LeaseDuration?: string, CopyId?: string, CopyStatus?: string, CopySource?: string, CopyProgress?: string, CopyCompletionTime?: string, CopyStatusDescription?: string, ServerEncrypted?: string, CustomerProvidedKeySha256?: string, EncryptionContext?: string, EncryptionScope?: string, IncrementalCopy?: string, AccessTierInferred?: string, AccessTierChangeTime?: string, TagCount?: string, RehydratePriority?: string, ExpiryTime?: string, DeletedTime?: string, RemainingRetentionDays?: string} * @suppressWarnings(PHPMD.TooManyFields) diff --git a/src/BlobStorage/Managers/Blob/BlobManager.php b/src/BlobStorage/Managers/Blob/BlobManager.php index 4040970..545fe51 100644 --- a/src/BlobStorage/Managers/Blob/BlobManager.php +++ b/src/BlobStorage/Managers/Blob/BlobManager.php @@ -18,8 +18,7 @@ use Xray\AzureStoragePhpSdk\Contracts\Manager; use Xray\AzureStoragePhpSdk\Exceptions\{InvalidArgumentException, RequestException}; -use function Xray\AzureStoragePhpSdk\Support\convert_to_RFC1123; -use function Xray\AzureStoragePhpSdk\Support\convert_to_RFC3339_micro; +use function Xray\AzureStoragePhpSdk\Support\{convert_to_RFC1123, convert_to_RFC3339_micro}; /** * @phpstan-import-type BlobType from Blob as BlobTypeStan From 08070035154cb10c8a9cf9820dc1a8a595225fe8 Mon Sep 17 00:00:00 2001 From: Gabriel Ramos Date: Sat, 28 Sep 2024 11:23:16 -0300 Subject: [PATCH 5/5] fix phpstan --- .../BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php index c0a9ffc..3d62d4d 100644 --- a/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php +++ b/tests/Feature/BlobStorage/Managers/Blob/BlobStorageBlobManagerTest.php @@ -18,6 +18,7 @@ use Xray\AzureStoragePhpSdk\Fakes\Http\{RequestFake, ResponseFake}; use Xray\AzureStoragePhpSdk\Http\Response as BaseResponse; +use function Xray\AzureStoragePhpSdk\Support\convert_to_ISO; use function Xray\Tests\mock; pest()->group('blob-storage', 'managers', 'blobs');