diff --git a/.github/workflows/codesniffer.yml b/.github/workflows/codesniffer.yml index a58ac4f..d5ff803 100644 --- a/.github/workflows/codesniffer.yml +++ b/.github/workflows/codesniffer.yml @@ -15,4 +15,4 @@ jobs: name: "Codesniffer" uses: contributte/.github/.github/workflows/codesniffer.yml@master with: - php: "8.2" + php: "8.3" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 860c47e..9b105e9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,11 +8,11 @@ on: branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 9 * * 1" jobs: coverage: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master with: - php: "8.2" + php: "8.3" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index eb916bf..c0dccb4 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -8,11 +8,11 @@ on: branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 10 * * 1" jobs: phpstan: name: "Phpstan" uses: contributte/.github/.github/workflows/phpstan.yml@master with: - php: "8.2" + php: "8.3" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a574bd1..693509b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,33 +5,33 @@ on: workflow_dispatch: push: - branches: [ "*" ] + branches: ["*"] schedule: - - cron: "0 8 * * 1" + - cron: "0 10 * * 1" jobs: - test83: + test84: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.3" + php: "8.4" - test82: + test83: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.2" + php: "8.3" - test81: + test82: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.1" + php: "8.2" testlower: name: "Nette Tester" uses: contributte/.github/.github/workflows/nette-tester.yml@master with: - php: "8.1" + php: "8.2" composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/composer.json b/composer.json index 863abad..b715c6e 100644 --- a/composer.json +++ b/composer.json @@ -24,17 +24,16 @@ "issues": "https://github.com/contributte/vite/issues" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "nette/application": "^3.0.8", "nette/di": "^3.1.8", - "nette/safe": "^0.9", "tracy/tracy": "^2.10.5" }, "require-dev": { - "latte/latte": "^3.0.12", - "contributte/qa": "^0.4", - "contributte/tester": "^0.3", - "contributte/phpstan": "^0.1" + "contributte/phpstan": "^0.2.0", + "contributte/qa": "^0.4.0", + "contributte/tester": "^0.3.0", + "latte/latte": "^3.0.12" }, "suggest": { "tracy/tracy": "to enable asset debugging in the debug bar panel", @@ -45,6 +44,11 @@ "Contributte\\Vite\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests" + } + }, "minimum-stability": "dev", "prefer-stable": true, "config": { diff --git a/phpstan.neon b/phpstan.neon index 562ab05..cd64186 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,7 @@ includes: parameters: level: 9 - phpVersion: 80100 + phpVersion: 80200 scanDirectories: - src @@ -14,5 +14,3 @@ parameters: paths: - src - .docs - - ignoreErrors: diff --git a/ruleset.xml b/ruleset.xml index 2e9e01b..ba6f4a3 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,7 +1,7 @@ - + @@ -10,10 +10,6 @@ - - - - diff --git a/src/Nette/Extension.php b/src/Nette/Extension.php index 1a4107b..d99497a 100644 --- a/src/Nette/Extension.php +++ b/src/Nette/Extension.php @@ -10,7 +10,6 @@ use Nette\DI\Definitions\FactoryDefinition; use Nette\DI\Definitions\ServiceDefinition; use Nette\DI\Definitions\Statement; -use Nette\Safe; use Nette\Schema\Expect; use Nette\Schema\Schema; use Nette\Utils\Finder; @@ -120,13 +119,13 @@ private function prepareManifestPath(): string $manifestFile = $newPath; } - return Safe::realpath($manifestFile); + return (string) realpath($manifestFile); } private function prepareBasePath(string $manifestFile): string { if ($this->config->basePath === null) { - return str_replace(Safe::realpath($this->config->wwwDir), '', dirname($manifestFile)) . '/'; + return str_replace((string) realpath($this->config->wwwDir), '', dirname($manifestFile)) . '/'; } return $this->config->basePath; diff --git a/src/Service.php b/src/Service.php index 8f44a69..f33b078 100644 --- a/src/Service.php +++ b/src/Service.php @@ -23,7 +23,7 @@ final class Service private IRequest $httpRequest; - /** @var array> $manifest */ + /** @var array, imports?: list, dynamicImports?: list}> */ private array $manifest; public function __construct( @@ -46,26 +46,11 @@ public function __construct( trigger_error('Missing manifest file: ' . $this->manifestFile, E_USER_WARNING); } - /** @var array> $manifest */ + /** @var array, imports?: list, dynamicImports?: list}> $manifest */ $manifest = json_decode(FileSystem::read($this->manifestFile), true); $this->manifest = $manifest; } - /** - * @return array>> - */ - private function getEndpointManifest(string $entrypoint): array { - $entrypoint = ltrim($entrypoint, '/'); - /** @var array>> $manifest */ - $manifest = $this->manifest[$entrypoint]; - - if ($manifest === null) { - throw new LogicalException('Invalid manifest'); - } - - return $manifest; - } - public function getAsset(string $entrypoint): string { if (str_starts_with($entrypoint, 'http')) { @@ -105,7 +90,7 @@ public function getCssAssets(string $entrypoint, bool $withNestedCss = false): G } /** - * @return array + * @return list */ public function getImports(string $entrypoint): array { @@ -119,7 +104,7 @@ public function getImports(string $entrypoint): array } /** - * @return array + * @return list */ public function getDynamicImports(string $entrypoint): array { @@ -170,4 +155,18 @@ public function getViteCookie(): string return $this->viteCookie; } + /** + * @return array{file?: string, css?: list, imports?: list, dynamicImports?: list} + */ + private function getEndpointManifest(string $entrypoint): array + { + $entrypoint = ltrim($entrypoint, '/'); + + if (!isset($this->manifest[$entrypoint])) { + throw new LogicalException('Invalid manifest'); + } + + return $this->manifest[$entrypoint]; + } + } diff --git a/src/Tracy/VitePanel.php b/src/Tracy/VitePanel.php index 0e9d01b..4a41561 100644 --- a/src/Tracy/VitePanel.php +++ b/src/Tracy/VitePanel.php @@ -3,7 +3,6 @@ namespace Contributte\Vite\Tracy; use Contributte\Vite\Service; -use Nette\Safe; use Tracy\IBarPanel; final class VitePanel implements IBarPanel @@ -18,7 +17,7 @@ public function __construct(Service $vite) public function getTab(): string { - $html = Safe::file_get_contents(__DIR__ . '/Vite.html'); + $html = (string) file_get_contents(__DIR__ . '/Vite.html'); return str_replace('%viteCookie%', $this->vite->getViteCookie(), $html); } diff --git a/tests/Cases/DI/Extension.phpt b/tests/Cases/DI/Extension.phpt index 5a3c437..a119249 100644 --- a/tests/Cases/DI/Extension.phpt +++ b/tests/Cases/DI/Extension.phpt @@ -13,13 +13,12 @@ use Nette\Bridges\ApplicationDI\LatteExtension; use Nette\Bridges\ApplicationDI\RoutingExtension; use Nette\Bridges\HttpDI\HttpExtension; use Nette\DI\Compiler; -use Nette\Safe; use Tester\Assert; require_once __DIR__ . '/../../bootstrap.php'; Toolkit::test(static function (): void { - Safe::touch(Environment::getTestDir() . '/manifest.json'); + file_put_contents(Environment::getTestDir() . '/manifest.json', '{}'); $container = ContainerBuilder::of() ->withCompiler(function (Compiler $compiler): void {