diff --git a/bin/templatemap_generator.php b/bin/templatemap_generator.php index 86d8c36e3..0346f9e7f 100755 --- a/bin/templatemap_generator.php +++ b/bin/templatemap_generator.php @@ -1,7 +1,7 @@ #!/usr/bin/env php + * @param string $templatePath + * @return list */ function findTemplateFilesInTemplatePath($templatePath): array { @@ -138,7 +139,8 @@ function findTemplateFilesInTemplatePath($templatePath): array $files = []; foreach ($rii as $file) { - if (strtolower($file->getExtension()) != 'phtml') { + assert($file instanceof SplFileInfo); + if (strtolower($file->getExtension()) !== 'phtml') { continue; } diff --git a/composer.json b/composer.json index a0c578c6c..329269f7c 100644 --- a/composer.json +++ b/composer.json @@ -37,9 +37,9 @@ "psr/container": "^1 || ^2" }, "require-dev": { - "laminas/laminas-authentication": "^2.13", + "laminas/laminas-authentication": "^2.15", "laminas/laminas-coding-standard": "~2.5.0", - "laminas/laminas-feed": "^2.20", + "laminas/laminas-feed": "^2.21", "laminas/laminas-filter": "^2.32", "laminas/laminas-http": "^2.18", "laminas/laminas-i18n": "^2.23", @@ -52,9 +52,9 @@ "laminas/laminas-permissions-acl": "^2.15", "laminas/laminas-router": "^3.11.1", "laminas/laminas-uri": "^2.10", - "phpunit/phpunit": "^10.1.3", + "phpunit/phpunit": "^10.3.2", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.12" + "vimeo/psalm": "^5.15" }, "conflict": { "container-interop/container-interop": "<1.2", diff --git a/composer.lock b/composer.lock index 85b43771e..345758a58 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d8c4880e9375fc4df0bb44fdb9436bf2", + "content-hash": "e06dd7d89c9aea20629a02cddefedab3", "packages": [ { "name": "laminas/laminas-escaper", @@ -5493,16 +5493,16 @@ }, { "name": "vimeo/psalm", - "version": "5.14.1", + "version": "5.15.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "b9d355e0829c397b9b3b47d0c0ed042a8a70284d" + "reference": "5c774aca4746caf3d239d9c8cadb9f882ca29352" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/b9d355e0829c397b9b3b47d0c0ed042a8a70284d", - "reference": "b9d355e0829c397b9b3b47d0c0ed042a8a70284d", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/5c774aca4746caf3d239d9c8cadb9f882ca29352", + "reference": "5c774aca4746caf3d239d9c8cadb9f882ca29352", "shasum": "" }, "require": { @@ -5530,6 +5530,9 @@ "symfony/console": "^4.1.6 || ^5.0 || ^6.0", "symfony/filesystem": "^5.4 || ^6.0" }, + "conflict": { + "nikic/php-parser": "4.17.0" + }, "provide": { "psalm/psalm": "self.version" }, @@ -5593,9 +5596,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/5.14.1" + "source": "https://github.com/vimeo/psalm/tree/5.15.0" }, - "time": "2023-08-01T05:16:55+00:00" + "time": "2023-08-20T23:07:30+00:00" }, { "name": "webimpress/coding-standard", diff --git a/test/bin/TemplateMapGeneratorTest.php b/test/bin/TemplateMapGeneratorTest.php new file mode 100644 index 000000000..727c6ca1b --- /dev/null +++ b/test/bin/TemplateMapGeneratorTest.php @@ -0,0 +1,60 @@ +commandOutput('templates'); + + self::assertStringStartsWith(' __DIR__ . '/templates/one.phtml',", $output); + self::assertStringContainsString("'two' => __DIR__ . '/templates/two.phtml',", $output); + + self::assertStringNotContainsString('ignored.txt', $output); + self::assertStringNotContainsString('ignored', $output); + } + + public function testThatHelpTextWillBeOutputWhenRequested(): void + { + $output = $this->commandOutput('-h'); + self::assertStringContainsString('Generate template maps.', $output); + + $output = $this->commandOutput('--help'); + self::assertStringContainsString('Generate template maps.', $output); + } + + public function testThatTheMapGeneratorAcceptsAListOfFileNames(): void + { + $output = $this->commandOutput('. some/foo.txt bar.phtml'); + self::assertStringStartsWith(' __DIR__ . '/some/foo.txt',", $output); + self::assertStringContainsString("'bar' => __DIR__ . '/bar.phtml',", $output); + } +} diff --git a/test/bin/templates/ignored.txt b/test/bin/templates/ignored.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/bin/templates/ignored/.gitkeep b/test/bin/templates/ignored/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/test/bin/templates/one.phtml b/test/bin/templates/one.phtml new file mode 100644 index 000000000..e69de29bb diff --git a/test/bin/templates/two.phtml b/test/bin/templates/two.phtml new file mode 100644 index 000000000..e69de29bb