Skip to content

Commit

Permalink
Merge branch '1.x' into soothe-sa
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym authored Mar 21, 2024
2 parents 798e8d4 + 9b1da2b commit 1711173
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
11 changes: 11 additions & 0 deletions src/Exception/DirectoryNotWritableException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace BEAR\Package\Exception;

use RuntimeException;

final class DirectoryNotWritableException extends RuntimeException
{
}
1 change: 1 addition & 0 deletions src/Injector/FileUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use BEAR\AppMeta\AbstractAppMeta;
use FilesystemIterator;
use Iterator;

Check failure on line 9 in src/Injector/FileUpdate.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Type Iterator is not used in this file.

Check failure on line 9 in src/Injector/FileUpdate.php

View workflow job for this annotation

GitHub Actions / cs / Coding Standards

Type Iterator is not used in this file.
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RecursiveRegexIterator;
Expand Down
38 changes: 38 additions & 0 deletions src/Provide/Cache/CacheDirProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace BEAR\Package\Provide\Cache;

use BEAR\AppMeta\AbstractAppMeta;
use BEAR\Package\Exception\DirectoryNotWritableException;
use Ray\Di\ProviderInterface;

use function is_writable;
use function mkdir;

/**
* Provide tmp directory
*
* @implements ProviderInterface<string>
*/
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;
}
}
2 changes: 1 addition & 1 deletion src/Provide/Router/CliRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function parseServer(array $server): array
{
/** @var array{argv: array<string>} $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 !== '') {

Check failure on line 205 in src/Provide/Router/CliRouter.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

RedundantCondition: Type string for $urlQuery is always string

Check failure on line 205 in src/Provide/Router/CliRouter.php

View workflow job for this annotation

GitHub Actions / sa / Psalm

RedundantCondition: Type string for $urlQuery is always string
Expand Down

0 comments on commit 1711173

Please sign in to comment.