From 7a8eb918420d1c009a72777f1729706ae9761636 Mon Sep 17 00:00:00 2001 From: Jacob Baker-Kretzmar Date: Tue, 25 Jun 2024 18:20:52 -0400 Subject: [PATCH 1/4] Replace PHP-CS-Fixer with Pint and format code --- .php-cs-fixer.php | 50 ------------------- composer.json | 5 +- pint.json | 9 ++++ src/Bootstrap/HandleExceptions.php | 10 ++-- src/Collection/Collection.php | 1 + src/Collection/CollectionPaginator.php | 1 + src/Collection/CollectionRemoteItem.php | 2 + .../BladeCollectionItemHandler.php | 5 +- src/Console/BuildCommand.php | 1 + src/Console/Command.php | 4 +- src/Console/ConsoleOutput.php | 1 + src/Console/ConsoleSession.php | 2 + src/Console/InitCommand.php | 3 ++ src/Console/NullProgressBar.php | 1 + src/Console/ProgressBar.php | 2 + src/Container.php | 2 +- src/Exceptions/Handler.php | 2 +- src/File/BladeDirectivesFile.php | 1 + src/File/InputFile.php | 2 + src/File/OutputFile.php | 7 +++ src/File/TemporaryFilesystem.php | 1 + src/Handlers/BladeHandler.php | 3 ++ src/Handlers/CollectionItemHandler.php | 1 + src/Handlers/MarkdownHandler.php | 2 + src/Handlers/PaginatedPageHandler.php | 3 ++ src/Jigsaw.php | 9 ++++ src/Loaders/CollectionDataLoader.php | 6 +++ src/Loaders/CollectionRemoteItemLoader.php | 2 + src/Parsers/FrontMatterParser.php | 2 + src/Parsers/MarkdownParser.php | 2 +- src/PathResolvers/CollectionPathResolver.php | 11 ++-- src/Scaffold/CustomInstaller.php | 4 ++ src/Scaffold/DefaultInstaller.php | 5 ++ src/Scaffold/PresetPackage.php | 11 ++++ src/Scaffold/PresetScaffoldBuilder.php | 4 ++ src/Scaffold/ScaffoldBuilder.php | 4 ++ src/SiteBuilder.php | 5 ++ src/Support/helpers.php | 2 +- src/View/BladeCompiler.php | 3 +- src/View/BladeMarkdownEngine.php | 1 + src/View/MarkdownEngine.php | 2 + tests/BladeComponentTest.php | 14 +++--- tests/CollectionItemTest.php | 26 +++++----- tests/CommonMarkTest.php | 7 +-- tests/EventsTest.php | 3 +- tests/FilePathTest.php | 1 - tests/FilesystemTest.php | 6 +-- tests/Haiku.php | 1 - tests/TestCase.php | 13 +++-- tests/ViewPathTest.php | 6 +-- tests/snapshots/default/config.php | 2 +- 51 files changed, 160 insertions(+), 113 deletions(-) delete mode 100644 .php-cs-fixer.php create mode 100644 pint.json diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php deleted file mode 100644 index 00a6f028..00000000 --- a/.php-cs-fixer.php +++ /dev/null @@ -1,50 +0,0 @@ -setFinder(PhpCsFixer\Finder::create()->in(__DIR__)->exclude('tests/snapshots')) - ->setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - '@Symfony' => true, - 'align_multiline_comment' => [ - 'comment_type' => 'all_multiline', - ], - 'binary_operator_spaces' => [ - 'operators' => [ - '|' => 'single_space', // Doesn't apply to union types - ], - ], - 'blank_line_after_namespace' => true, - 'blank_line_after_opening_tag' => true, - 'blank_line_before_statement' => [ - 'statements' => ['return', 'throw'], - ], - 'concat_space' => [ - 'spacing' => 'one', - ], - 'get_class_to_class_keyword' => true, - 'global_namespace_import' => [ - 'import_classes' => true, - ], - 'new_with_braces' => false, - 'no_empty_comment' => false, - 'no_useless_else' => true, - 'not_operator_with_successor_space' => true, - 'php_unit_method_casing' => false, - 'phpdoc_annotation_without_dot' => false, - 'phpdoc_to_comment' => [ - 'ignored_tags' => ['var'], - ], - 'phpdoc_separation' => [ - 'groups' => [ - ['test', 'group', 'dataProvider', 'doesNotPerformAssertions'], - ], - ], - 'phpdoc_var_annotation_correct_order' => true, - 'single_line_empty_body' => true, - 'trailing_comma_in_multiline' => [ - 'after_heredoc' => true, - 'elements' => ['arrays', 'arguments', 'parameters'], - ], - 'yoda_style' => false, - ]); diff --git a/composer.json b/composer.json index ef5cf697..ce2ff873 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "vlucas/phpdotenv": "^5.6" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.51", + "laravel/pint": "^1.16", "mockery/mockery": "^1.6", "phpunit/phpunit": "^11.0.6" }, @@ -59,9 +59,6 @@ "bin": [ "jigsaw" ], - "scripts": { - "format": "php-cs-fixer fix --verbose" - }, "config": { "sort-packages": true, "optimize-autoloader": true diff --git a/pint.json b/pint.json new file mode 100644 index 00000000..89ff207a --- /dev/null +++ b/pint.json @@ -0,0 +1,9 @@ +{ + "preset": "laravel", + "rules": { + "concat_space": { + "spacing": "one" + }, + "single_line_empty_body": true + } +} diff --git a/src/Bootstrap/HandleExceptions.php b/src/Bootstrap/HandleExceptions.php index 96285fe8..3ac0527c 100644 --- a/src/Bootstrap/HandleExceptions.php +++ b/src/Bootstrap/HandleExceptions.php @@ -84,11 +84,11 @@ public function bootstrap(Container $app): void /** * Report PHP deprecations, or convert PHP errors to ErrorException instances. * - * @param int $level - * @param string $message - * @param string $file - * @param int $line - * @param array $context + * @param int $level + * @param string $message + * @param string $file + * @param int $line + * @param array $context * * @throws ErrorException */ diff --git a/src/Collection/Collection.php b/src/Collection/Collection.php index 1668ef8a..f064242b 100644 --- a/src/Collection/Collection.php +++ b/src/Collection/Collection.php @@ -10,6 +10,7 @@ class Collection extends BaseCollection { public $settings; + public $name; public static function withSettings(IterableObject $settings, $name) diff --git a/src/Collection/CollectionPaginator.php b/src/Collection/CollectionPaginator.php index 224af277..f39759fc 100644 --- a/src/Collection/CollectionPaginator.php +++ b/src/Collection/CollectionPaginator.php @@ -7,6 +7,7 @@ class CollectionPaginator { private $outputPathResolver; + private $prefix; public function __construct($outputPathResolver) diff --git a/src/Collection/CollectionRemoteItem.php b/src/Collection/CollectionRemoteItem.php index c4eb3b6a..a7c6a075 100644 --- a/src/Collection/CollectionRemoteItem.php +++ b/src/Collection/CollectionRemoteItem.php @@ -8,7 +8,9 @@ class CollectionRemoteItem { private $item; + private $index; + private $collectionName; public function __construct($item, $index = 0, $collectionName = null) diff --git a/src/CollectionItemHandlers/BladeCollectionItemHandler.php b/src/CollectionItemHandlers/BladeCollectionItemHandler.php index 27a51604..ae2d0516 100644 --- a/src/CollectionItemHandlers/BladeCollectionItemHandler.php +++ b/src/CollectionItemHandlers/BladeCollectionItemHandler.php @@ -32,8 +32,5 @@ public function getItemVariables($file) ); } - public function getItemContent($file) - { - return; - } + public function getItemContent($file) {} } diff --git a/src/Console/BuildCommand.php b/src/Console/BuildCommand.php index b55bcd32..942e2019 100644 --- a/src/Console/BuildCommand.php +++ b/src/Console/BuildCommand.php @@ -17,6 +17,7 @@ class BuildCommand extends Command { private $app; + private $consoleOutput; public function __construct(Container $app) diff --git a/src/Console/Command.php b/src/Console/Command.php index 12236e24..7214a995 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -8,8 +8,10 @@ abstract class Command extends SymfonyCommand { - protected InputInterface $input; + protected InputInterface $input; + protected OutputInterface $output; + protected $console; public function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Console/ConsoleOutput.php b/src/Console/ConsoleOutput.php index 66053b37..8c03ebe1 100644 --- a/src/Console/ConsoleOutput.php +++ b/src/Console/ConsoleOutput.php @@ -7,6 +7,7 @@ class ConsoleOutput extends SymfonyConsoleOutput { protected $progressBars; + protected $sections; public function setup($verbosity) diff --git a/src/Console/ConsoleSession.php b/src/Console/ConsoleSession.php index 4634e3f3..62afb3b6 100644 --- a/src/Console/ConsoleSession.php +++ b/src/Console/ConsoleSession.php @@ -12,7 +12,9 @@ class ConsoleSession { protected $input; + protected $output; + protected $question; public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $question) diff --git a/src/Console/InitCommand.php b/src/Console/InitCommand.php index 4c2d07c8..45a48f64 100644 --- a/src/Console/InitCommand.php +++ b/src/Console/InitCommand.php @@ -12,8 +12,11 @@ class InitCommand extends Command { private $base; + private $basicScaffold; + private $files; + private $presetScaffold; public function __construct(Filesystem $files, BasicScaffoldBuilder $basicScaffold, PresetScaffoldBuilder $presetScaffold) diff --git a/src/Console/NullProgressBar.php b/src/Console/NullProgressBar.php index 64b77827..bd0b44e4 100644 --- a/src/Console/NullProgressBar.php +++ b/src/Console/NullProgressBar.php @@ -5,6 +5,7 @@ class NullProgressBar { protected $consoleOutput; + protected $message; public function __construct(ConsoleOutput $consoleOutput, $message = null, $section = null) diff --git a/src/Console/ProgressBar.php b/src/Console/ProgressBar.php index db2a965d..4721d678 100644 --- a/src/Console/ProgressBar.php +++ b/src/Console/ProgressBar.php @@ -7,7 +7,9 @@ class ProgressBar { protected $consoleOutput; + protected $progressBar; + protected $message; public function __construct(ConsoleOutput $consoleOutput, $message = null, $section = null) diff --git a/src/Container.php b/src/Container.php index 77b46d87..d56d9556 100644 --- a/src/Container.php +++ b/src/Container.php @@ -147,7 +147,7 @@ private function fireAppCallbacks(array &$callbacks): void while ($index < count($callbacks)) { $callbacks[$index]($this); - ++$index; + $index++; } } diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 94ebb5a0..d6008984 100644 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -40,7 +40,7 @@ public function render($request, Throwable $e): void } /** - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @param \Symfony\Component\Console\Output\OutputInterface $output */ public function renderForConsole($output, Throwable $e): void { diff --git a/src/File/BladeDirectivesFile.php b/src/File/BladeDirectivesFile.php index 3ca2d57c..80372e1b 100644 --- a/src/File/BladeDirectivesFile.php +++ b/src/File/BladeDirectivesFile.php @@ -7,6 +7,7 @@ class BladeDirectivesFile { protected $bladeCompiler; + protected $directives; public function __construct($file_path, BladeCompiler $bladeCompiler) diff --git a/src/File/InputFile.php b/src/File/InputFile.php index 2c0defb5..dfcd9d34 100644 --- a/src/File/InputFile.php +++ b/src/File/InputFile.php @@ -8,9 +8,11 @@ class InputFile { protected $file; + protected $extraBladeExtensions = [ 'js', 'json', 'xml', 'yaml', 'yml', 'rss', 'atom', 'txt', 'text', 'html', ]; + protected $pageData; public function __construct($file) diff --git a/src/File/OutputFile.php b/src/File/OutputFile.php index 60bd0687..725b2c98 100644 --- a/src/File/OutputFile.php +++ b/src/File/OutputFile.php @@ -7,12 +7,19 @@ class OutputFile { private $inputFile; + private $path; + private $name; + private $extension; + private $contents; + private $data; + private $page; + private $prefix; public function __construct(InputFile $inputFile, $path, $name, $extension, $contents, $data, $page = 1, $prefix = '') diff --git a/src/File/TemporaryFilesystem.php b/src/File/TemporaryFilesystem.php index 293129e5..0793804f 100644 --- a/src/File/TemporaryFilesystem.php +++ b/src/File/TemporaryFilesystem.php @@ -8,6 +8,7 @@ class TemporaryFilesystem { private $tempPath; + private $filesystem; public function __construct($tempPath, $filesystem = null) diff --git a/src/Handlers/BladeHandler.php b/src/Handlers/BladeHandler.php index 681f8797..2ce4fdaf 100644 --- a/src/Handlers/BladeHandler.php +++ b/src/Handlers/BladeHandler.php @@ -12,8 +12,11 @@ class BladeHandler { private $temporaryFilesystem; + private $parser; + private $view; + private $hasFrontMatter; public function __construct(TemporaryFilesystem $temporaryFilesystem, FrontMatterParser $parser, ViewRenderer $viewRenderer) diff --git a/src/Handlers/CollectionItemHandler.php b/src/Handlers/CollectionItemHandler.php index 5dc38b93..51f29dd2 100644 --- a/src/Handlers/CollectionItemHandler.php +++ b/src/Handlers/CollectionItemHandler.php @@ -10,6 +10,7 @@ class CollectionItemHandler { private $config; + private $handlers; public function __construct(Collection $config, $handlers) diff --git a/src/Handlers/MarkdownHandler.php b/src/Handlers/MarkdownHandler.php index aad18753..9b4d6226 100644 --- a/src/Handlers/MarkdownHandler.php +++ b/src/Handlers/MarkdownHandler.php @@ -11,7 +11,9 @@ class MarkdownHandler { private $temporaryFilesystem; + private $parser; + private $view; public function __construct(TemporaryFilesystem $temporaryFilesystem, FrontMatterParser $parser, ViewRenderer $viewRenderer) diff --git a/src/Handlers/PaginatedPageHandler.php b/src/Handlers/PaginatedPageHandler.php index c0d70d8b..41ba22a5 100644 --- a/src/Handlers/PaginatedPageHandler.php +++ b/src/Handlers/PaginatedPageHandler.php @@ -13,8 +13,11 @@ class PaginatedPageHandler { private $paginator; + private $parser; + private $temporaryFilesystem; + private $view; public function __construct( diff --git a/src/Jigsaw.php b/src/Jigsaw.php index 9b38c7c8..fa3553db 100644 --- a/src/Jigsaw.php +++ b/src/Jigsaw.php @@ -13,14 +13,23 @@ class Jigsaw use Macroable; public $app; + protected $env; + protected $pageInfo; + protected $outputPaths; + protected $siteData; + protected $dataLoader; + protected $remoteItemLoader; + protected $siteBuilder; + protected $verbose; + protected static $commands = []; public function __construct( diff --git a/src/Loaders/CollectionDataLoader.php b/src/Loaders/CollectionDataLoader.php index 5e5a61ff..49b49ca2 100644 --- a/src/Loaders/CollectionDataLoader.php +++ b/src/Loaders/CollectionDataLoader.php @@ -16,11 +16,17 @@ class CollectionDataLoader { private $filesystem; + private $consoleOutput; + private $pathResolver; + private $handlers; + private $source; + private $pageSettings; + private $collectionSettings; public function __construct(Filesystem $filesystem, ConsoleOutput $consoleOutput, $pathResolver, $handlers = []) diff --git a/src/Loaders/CollectionRemoteItemLoader.php b/src/Loaders/CollectionRemoteItemLoader.php index 77b8b0ce..ceb8a028 100644 --- a/src/Loaders/CollectionRemoteItemLoader.php +++ b/src/Loaders/CollectionRemoteItemLoader.php @@ -9,7 +9,9 @@ class CollectionRemoteItemLoader { private $config; + private $files; + private $tempDirectories; public function __construct(Collection $config, Filesystem $files) diff --git a/src/Parsers/FrontMatterParser.php b/src/Parsers/FrontMatterParser.php index 137cf2e2..5b564b20 100644 --- a/src/Parsers/FrontMatterParser.php +++ b/src/Parsers/FrontMatterParser.php @@ -8,7 +8,9 @@ class FrontMatterParser { private $parser; + public $frontMatter = []; + public $content; public function __construct(Parser $parser) diff --git a/src/Parsers/MarkdownParser.php b/src/Parsers/MarkdownParser.php index 1fef8fd0..54c2c3d8 100644 --- a/src/Parsers/MarkdownParser.php +++ b/src/Parsers/MarkdownParser.php @@ -8,7 +8,7 @@ class MarkdownParser implements FrontYAMLMarkdownParserInterface { public $parser; - public function __construct(MarkdownParserContract $parser = null) + public function __construct(?MarkdownParserContract $parser = null) { $this->parser = $parser ?? new JigsawMarkdownParser; } diff --git a/src/PathResolvers/CollectionPathResolver.php b/src/PathResolvers/CollectionPathResolver.php index 07874fd9..1489c940 100644 --- a/src/PathResolvers/CollectionPathResolver.php +++ b/src/PathResolvers/CollectionPathResolver.php @@ -8,6 +8,7 @@ class CollectionPathResolver { private $outputPathResolver; + private $view; public function __construct($outputPathResolver, $viewRenderer) @@ -86,7 +87,7 @@ private function parseShorthand($path, $data) private function getParameterValue($param, $data) { - list($param, $dateFormat) = explode('|', trim($param, '{}') . '|'); + [$param, $dateFormat] = explode('|', trim($param, '{}') . '|'); $slugSeparator = ctype_alpha($param[0]) ? null : $param[0]; if ($slugSeparator) { @@ -162,9 +163,8 @@ private function slug($string, $separator = '-') /** * Transliterate a UTF-8 value to ASCII. * - * @param string $value - * @param string $language - * + * @param string $value + * @param string $language * @return string */ private static function ascii($value, $language = 'en') @@ -323,8 +323,7 @@ private static function charsArray() * * @see https://github.com/danielstjules/Stringy/blob/3.1.0/LICENSE.txt * - * @param string $language - * + * @param string $language * @return array|null */ private static function languageSpecificCharsArray($language) diff --git a/src/Scaffold/CustomInstaller.php b/src/Scaffold/CustomInstaller.php index 7b5f9438..6b975f6b 100644 --- a/src/Scaffold/CustomInstaller.php +++ b/src/Scaffold/CustomInstaller.php @@ -5,9 +5,13 @@ class CustomInstaller { public $ignore = ['init.php']; + protected $from; + protected $builder; + protected $console; + protected $question; public function setConsole($console) diff --git a/src/Scaffold/DefaultInstaller.php b/src/Scaffold/DefaultInstaller.php index 82054fd5..7c52333e 100644 --- a/src/Scaffold/DefaultInstaller.php +++ b/src/Scaffold/DefaultInstaller.php @@ -12,14 +12,19 @@ class DefaultInstaller 'node_modules', 'vendor', ]; + public const DEFAULT_COMMANDS = [ 'composer install', 'npm install', 'npm run dev', ]; + protected $commands; + protected $delete; + protected $ignore; + protected $builder; public function install(ScaffoldBuilder $builder, $settings = []) diff --git a/src/Scaffold/PresetPackage.php b/src/Scaffold/PresetPackage.php index 6381df2a..5a814e87 100644 --- a/src/Scaffold/PresetPackage.php +++ b/src/Scaffold/PresetPackage.php @@ -16,16 +16,27 @@ class PresetPackage ]; public $constraint; + public $name; + public $shortName; + public $path; + public $preset; + public $suffix; + public $vendor; + protected $builder; + protected $customInstaller; + protected $defaultInstaller; + protected $files; + protected $process; public function __construct(DefaultInstaller $default, CustomInstaller $custom, ProcessRunner $process) diff --git a/src/Scaffold/PresetScaffoldBuilder.php b/src/Scaffold/PresetScaffoldBuilder.php index c4acca31..b9a7b598 100644 --- a/src/Scaffold/PresetScaffoldBuilder.php +++ b/src/Scaffold/PresetScaffoldBuilder.php @@ -8,9 +8,13 @@ class PresetScaffoldBuilder extends ScaffoldBuilder { public $package; + protected $files; + protected $process; + protected $question; + protected $composerDependencies; public function __construct(Filesystem $files, PresetPackage $package, ProcessRunner $process) diff --git a/src/Scaffold/ScaffoldBuilder.php b/src/Scaffold/ScaffoldBuilder.php index e8e8312a..d90258a3 100644 --- a/src/Scaffold/ScaffoldBuilder.php +++ b/src/Scaffold/ScaffoldBuilder.php @@ -13,9 +13,13 @@ abstract class ScaffoldBuilder ]; public $base; + protected $console; + protected $files; + protected $process; + protected $composerCache = []; public function __construct(Filesystem $files) diff --git a/src/SiteBuilder.php b/src/SiteBuilder.php index 52e414d6..11542f26 100644 --- a/src/SiteBuilder.php +++ b/src/SiteBuilder.php @@ -10,10 +10,15 @@ class SiteBuilder { private $cachePath; + private $files; + private $handlers; + private $outputPathResolver; + private $consoleOutput; + private $useCache; public function __construct( diff --git a/src/Support/helpers.php b/src/Support/helpers.php index c655bb66..6693a5c1 100644 --- a/src/Support/helpers.php +++ b/src/Support/helpers.php @@ -7,7 +7,7 @@ use Symfony\Component\VarDumper\VarDumper; if (! function_exists('app')) { - function app(string $abstract = null, array $parameters = []): mixed + function app(?string $abstract = null, array $parameters = []): mixed { if (is_null($abstract)) { return \TightenCo\Jigsaw\Container::getInstance(); diff --git a/src/View/BladeCompiler.php b/src/View/BladeCompiler.php index 54a970a1..8bc77470 100644 --- a/src/View/BladeCompiler.php +++ b/src/View/BladeCompiler.php @@ -9,8 +9,7 @@ class BladeCompiler extends BaseBladeCompiler /** * Compile the component tags. * - * @param string $value - * + * @param string $value * @return string */ protected function compileComponentTags($value) diff --git a/src/View/BladeMarkdownEngine.php b/src/View/BladeMarkdownEngine.php index fb8a7059..afe60d3b 100644 --- a/src/View/BladeMarkdownEngine.php +++ b/src/View/BladeMarkdownEngine.php @@ -10,6 +10,7 @@ class BladeMarkdownEngine implements EngineInterface { private $blade; + private $markdown; public function __construct($compilerEngine, $markdown) diff --git a/src/View/MarkdownEngine.php b/src/View/MarkdownEngine.php index 3971ad36..2f823c67 100644 --- a/src/View/MarkdownEngine.php +++ b/src/View/MarkdownEngine.php @@ -10,7 +10,9 @@ class MarkdownEngine implements EngineInterface { private $parser; + private $file; + private $sourcePath; public function __construct($parser, $filesystem, $sourcePath) diff --git a/tests/BladeComponentTest.php b/tests/BladeComponentTest.php index 925595f1..93e9549d 100644 --- a/tests/BladeComponentTest.php +++ b/tests/BladeComponentTest.php @@ -20,18 +20,18 @@ public function can_include_blade_component_with_at_syntax() ]), '_components' => [ 'alert.blade.php' => implode("\n", [ - '
', - '

This is the component

', - '

Named title slot: {{ $title }}

', - '{{ $slot }}', - '
', + '
', + '

This is the component

', + '

Named title slot: {{ $title }}

', + '{{ $slot }}', + '
', ]), ], ]); $this->buildSite($files, []); - $this->assertOutputFile('build/page.html', <<assertOutputFile('build/page.html', <<<'HTML'

This is the component

Named title slot: Title test

@@ -147,6 +147,7 @@ class_alias('Tests\\AlertComponent', 'Components\\ClassComponent'); class AlertComponent extends Component { public $type; + public $message; public function __construct($type, $message) @@ -164,6 +165,7 @@ public function render() class InlineAlertComponent extends Component { public $type; + public $message; public function __construct($type, $message) diff --git a/tests/CollectionItemTest.php b/tests/CollectionItemTest.php index 82e8495e..0b9e223d 100644 --- a/tests/CollectionItemTest.php +++ b/tests/CollectionItemTest.php @@ -36,14 +36,13 @@ public function collection_item_contents_are_returned_when_item_is_referenced_as public function collection_item_can_be_filtered() { $config = collect(['collections' => [ - 'collection' => [ - 'path' => 'collection/{filename}', - 'filter' => function ($item) { - return $item->published; - }, - ], + 'collection' => [ + 'path' => 'collection/{filename}', + 'filter' => function ($item) { + return $item->published; + }, ], - ]); + ]]); $builtHeader = implode("\n", [ '---', 'extends: _layouts.collection_item', @@ -81,14 +80,13 @@ public function collection_item_can_be_filtered() public function collection_item_can_be_mapped() { $config = collect(['collections' => [ - 'collection' => [ - 'path' => 'collection/{filename}', - 'map' => function ($item) { - return MappedItem::fromItem($item); - }, - ], + 'collection' => [ + 'path' => 'collection/{filename}', + 'map' => function ($item) { + return MappedItem::fromItem($item); + }, ], - ]); + ]]); $itemHeader = implode("\n", [ '---', 'number: 111', diff --git a/tests/CommonMarkTest.php b/tests/CommonMarkTest.php index 90e9bdfe..de4d0556 100644 --- a/tests/CommonMarkTest.php +++ b/tests/CommonMarkTest.php @@ -47,7 +47,7 @@ public function configure_commonmark_parser() #[Test] public function replace_commonmark_extensions() { - $files = $this->withContent(<<withContent(<<<'MD' # Fruits {.class} Apple @@ -75,10 +75,11 @@ public function override_parser_with_custom_class() $files = $this->withContent('### Heading {.class}'); $this->app->bind(MarkdownParserContract::class, function () { - return new class implements MarkdownParserContract { + return new class implements MarkdownParserContract + { public function parse(string $text) { - return <<app['events']->beforeBuild(new class { + $this->app['events']->beforeBuild(new class + { private $object; public function __construct() diff --git a/tests/FilePathTest.php b/tests/FilePathTest.php index db36bea3..1b867d73 100644 --- a/tests/FilePathTest.php +++ b/tests/FilePathTest.php @@ -2,7 +2,6 @@ namespace Tests; -use PHPUnit\Framework\Attributes\Test; use TightenCo\Jigsaw\IterableObject; use TightenCo\Jigsaw\PageVariable; use TightenCo\Jigsaw\PathResolvers\CollectionPathResolver; diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index 2172fdb3..2122f410 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -45,7 +45,7 @@ public function DS_Store_is_always_ignored_when_retrieving_all_files_and_directo $files = collect( $this->app->make(Filesystem::class) - ->filesAndDirectories($this->tmp), + ->filesAndDirectories($this->tmp), )->map(function ($file) { return $file->getRelativePathName(); }); @@ -228,7 +228,7 @@ protected function getFilesMatching($match) return collect( $this->app->make(Filesystem::class) - ->filesAndDirectories($this->tmp, $match), + ->filesAndDirectories($this->tmp, $match), )->map(function ($file) { return $file->getRelativePathName(); }); @@ -240,7 +240,7 @@ protected function getFilesExcept($ignore) return collect( $this->app->make(Filesystem::class) - ->filesAndDirectories($this->tmp, null, $ignore), + ->filesAndDirectories($this->tmp, null, $ignore), )->map(function ($file) { return $file->getRelativePathName(); }); diff --git a/tests/Haiku.php b/tests/Haiku.php index 50a6e778..54f97d45 100644 --- a/tests/Haiku.php +++ b/tests/Haiku.php @@ -4,7 +4,6 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; -use PHPUnit\Framework\Attributes\Test; trait Haiku { diff --git a/tests/TestCase.php b/tests/TestCase.php index 8f8258f3..1b072ac7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -20,13 +20,16 @@ class TestCase extends PHPUnit use Haiku; public $sourcePath = __DIR__ . '/snapshots/default/source'; + public $destinationPath = __DIR__ . '/snapshots/default/build_local'; protected Container $app; + protected Filesystem $filesystem; + protected string $tmp; - public function __construct($name = null, array $data = [], $dataName = '') + public function __construct($name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); @@ -110,7 +113,8 @@ protected function setupSource($source = []) { $this->createSource(['source' => $source]); - return new class($this->tmpPath('')) { + return new class($this->tmpPath('')) + { public function __construct( protected string $tmp, ) {} @@ -122,7 +126,8 @@ public function hasChild($path) public function getChild($path) { - return new class($this->tmp, $path) { + return new class($this->tmp, $path) + { public function __construct( protected string $tmp, protected string $path, @@ -209,7 +214,7 @@ protected function fixDirectorySlashes(string $path): string return str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path); } - protected function assertOutputFile(string $path, string $contents, string $message = null): void + protected function assertOutputFile(string $path, string $contents, ?string $message = null): void { static::assertStringEqualsFile( $this->tmpPath($path), diff --git a/tests/ViewPathTest.php b/tests/ViewPathTest.php index cdd0ef23..c72d9bcd 100644 --- a/tests/ViewPathTest.php +++ b/tests/ViewPathTest.php @@ -11,7 +11,7 @@ public function can_load_views_from_custom_path() { $this->createSource([ 'source' => [ - 'page.md' => << <<<'MD' --- extends: main --- @@ -19,7 +19,7 @@ public function can_load_views_from_custom_path() MD, ], 'views' => [ - 'main.blade.php' => << <<<'BLADE' @yield('content') @@ -29,7 +29,7 @@ public function can_load_views_from_custom_path() $this->buildSite(null, [], false, '/views'); - $this->assertOutputFile('build/page.html', <<assertOutputFile('build/page.html', <<<'HTML'

Hello world!

diff --git a/tests/snapshots/default/config.php b/tests/snapshots/default/config.php index 8a900955..b82d21cd 100644 --- a/tests/snapshots/default/config.php +++ b/tests/snapshots/default/config.php @@ -79,7 +79,7 @@ }, 'author' => 'Default Author', 'date_formatted' => function ($post) { - list($year, $month, $day) = parseDate($post['date']); + [$year, $month, $day] = parseDate($post['date']); return sprintf('%s/%s/%s', $month, $day, $year); }, From f6a6b27d1452c9d982990efb9e32d280001d693b Mon Sep 17 00:00:00 2001 From: Jacob Baker-Kretzmar Date: Tue, 25 Jun 2024 18:21:01 -0400 Subject: [PATCH 2/4] Update GitHub Action --- .github/workflows/format.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 44907410..11220330 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -3,33 +3,32 @@ on: pull_request: paths: ['**.php'] jobs: - php-cs-fixer: + pint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.3 - uses: ramsey/composer-install@v2 - - name: Run PHP-CS-Fixer + - name: Run Pint id: format - # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings run: | delimiter=$RANDOM echo "summary<<${delimiter}" >> $GITHUB_OUTPUT - composer format >> $GITHUB_OUTPUT + vendor/bin/pint >> $GITHUB_OUTPUT echo $delimiter >> $GITHUB_OUTPUT - - name: Check for fixed files + - name: Check for changed files run: echo "changed=$(git diff --quiet && echo false || echo true)" >> $GITHUB_ENV - name: Commit changes - if: ${{ env.changed == 'true' }} + if: env.changed == 'true' run: | git config --global user.name github-actions git config --global user.email github-actions[bot]@users.noreply.github.com - # awk trims leading and trailing whitespace from each line, sed removes the last two lines - git commit -a -m "Format" -m "$(echo '${{ steps.format.outputs.summary }})' | awk '{$1=$1};1' | sed '$d' | sed '$d')" + # Trim leading and trailing whitespace from each line + git commit -a -m "Format" -m "$(echo '${{ steps.format.outputs.summary }})' | awk '{$1=$1};1')" git push From 098c18f4e782a65fd9c22a0203fd8084da293cb8 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 25 Jun 2024 22:22:36 +0000 Subject: [PATCH 3/4] Format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ............................................................................ .......✓.............................. ──────────────────────────────────────────────────────────────────── Laravel FIXED ................................... 114 files, 1 style issue fixed ✓ tests/rebuild.php unary_operator_spaces, not_operator_with_successor_spac… ) --- tests/rebuild.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/rebuild.php b/tests/rebuild.php index 0402d374..6b977204 100644 --- a/tests/rebuild.php +++ b/tests/rebuild.php @@ -22,5 +22,4 @@ function removeDirectory($path) rmdir($path); - return; -} + } From ef267410c0819849ddce917ae1b0fb3616b6800f Mon Sep 17 00:00:00 2001 From: Jacob Baker-Kretzmar Date: Tue, 25 Jun 2024 18:24:32 -0400 Subject: [PATCH 4/4] Remove unused `rebuild.php` test file --- tests/rebuild.php | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 tests/rebuild.php diff --git a/tests/rebuild.php b/tests/rebuild.php deleted file mode 100644 index 6b977204..00000000 --- a/tests/rebuild.php +++ /dev/null @@ -1,25 +0,0 @@ -