diff --git a/composer.json b/composer.json index 447e0b11..e2dd1237 100644 --- a/composer.json +++ b/composer.json @@ -69,8 +69,8 @@ "scripts": { "test": ["phpunit"], "tests": ["@cs", "@sa", "@test"], - "coverage": ["php -dzend_extension=xdebug.so -dxdebug.mode=coverage phpunit --coverage-text --coverage-html=build/coverage"], - "pcov": ["php -dextension=pcov.so -d pcov.enabled=1 phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml"], + "coverage": ["php -dzend_extension=xdebug.so -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"], + "pcov": ["php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml"], "cs": ["phpcs"], "cs-fix": ["phpcbf src tests"], "clean": ["phpstan clear-result-cache", "psalm --clear-cache", "rm -rf tests/tmp/*.php"], diff --git a/src/Exception/DirectoryNotWritableException.php b/src/Exception/DirectoryNotWritableException.php new file mode 100644 index 00000000..dde8a4ce --- /dev/null +++ b/src/Exception/DirectoryNotWritableException.php @@ -0,0 +1,11 @@ + + */ +final class CacheDirProvider implements ProviderInterface +{ + private const CACHE_DIRNAME = '/cache'; + + public function __construct(private AbstractAppMeta $appMeta) + { + } + + public function get(): string + { + $cacheDir = $this->appMeta->tmpDir . self::CACHE_DIRNAME; + if (! is_writable($cacheDir) && ! @mkdir($cacheDir)) { + // @codeCoverageIgnoreStart + throw new DirectoryNotWritableException($cacheDir); + // @codeCoverageIgnoreEnd + } + + return $cacheDir; + } +} diff --git a/src/Provide/Router/CliRouter.php b/src/Provide/Router/CliRouter.php index 27ffc74b..1eccf397 100644 --- a/src/Provide/Router/CliRouter.php +++ b/src/Provide/Router/CliRouter.php @@ -199,7 +199,7 @@ private function parseServer(array $server): array { /** @var array{argv: array} $server */ [, $method, $uri] = $server['argv']; - $urlQuery = parse_url($uri, PHP_URL_QUERY); + $urlQuery = (string) parse_url($uri, PHP_URL_QUERY); $urlPath = (string) parse_url($uri, PHP_URL_PATH); $query = []; if (is_string($urlQuery) && $urlQuery !== '') {