Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tonysm/importmap-laravel
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 30906ed0c4a59b63999bb38ebee9274295078006
Choose a base ref
..
head repository: tonysm/importmap-laravel
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e9aa62bbdc686bb163ad79fe62abd6cf936e0e85
Choose a head ref
Original file line number Diff line number Diff line change
@@ -13,9 +13,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist.php --allow-risky=yes
uses: aglipanci/laravel-pint-action@2.3.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
5 changes: 3 additions & 2 deletions src/Actions/ReplaceOrAppendTags.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
class ReplaceOrAppendTags
{
public const VITE_DIRECTIVE_PATTERN = '/(\s*)\@vite\(.*\)/';

public const CLOSING_HEAD_TAG_PATTERN = '/(\s*)(<\/head>)/';

public function __invoke(string $contents)
@@ -16,14 +17,14 @@ public function __invoke(string $contents)
if (str_contains($contents, '@vite')) {
return preg_replace(
static::VITE_DIRECTIVE_PATTERN,
"\\1<x-importmap::tags />",
'\\1<x-importmap::tags />',
$contents,
);
}

return preg_replace(
static::CLOSING_HEAD_TAG_PATTERN,
PHP_EOL."\\1 <x-importmap::tags />\\1\\2",
PHP_EOL.'\\1 <x-importmap::tags />\\1\\2',
$contents,
);
}
4 changes: 2 additions & 2 deletions src/AssetResolver.php
Original file line number Diff line number Diff line change
@@ -10,13 +10,13 @@ class AssetResolver
public function __invoke(string $fileRelativePath)
{
if (str_starts_with(trim($fileRelativePath, '/'), 'vendor/') && File::exists($absolutePath = public_path($fileRelativePath))) {
return asset($fileRelativePath).'?digest='.(new FileDigest())($absolutePath);
return asset($fileRelativePath).'?digest='.(new FileDigest)($absolutePath);
}

if (! File::exists($absolutePath = Importmap::getFileAbsolutePath('/resources/'.trim($fileRelativePath, '/')))) {
return asset($fileRelativePath);
}

return asset($fileRelativePath).'?digest='.(new FileDigest())($absolutePath);
return asset($fileRelativePath).'?digest='.(new FileDigest)($absolutePath);
}
}
4 changes: 2 additions & 2 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ private function updateAppLayouts(): void
{
$this->existingLayoutFiles()->each(fn ($file) => File::put(
$file,
(new ReplaceOrAppendTags())(File::get($file)),
(new ReplaceOrAppendTags)(File::get($file)),
));
}

@@ -170,6 +170,6 @@ private function usingSail(): bool

private function phpBinary(): string
{
return (new PhpExecutableFinder())->find(false) ?: 'php';
return (new PhpExecutableFinder)->find(false) ?: 'php';
}
}
2 changes: 1 addition & 1 deletion src/Commands/JsonCommand.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ class JsonCommand extends Command

public function handle(Importmap $importmap): int
{
$imports = $importmap->asArray(new AssetResolver());
$imports = $importmap->asArray(new AssetResolver);

$this->output->writeln(json_encode($imports, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

2 changes: 1 addition & 1 deletion src/Commands/OptimizeCommand.php
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ private function digest(string $filename, string $fileSource): string
{
return preg_replace(
'#(\.jsm?)$#',
sprintf('-%s$1', (new FileDigest())($fileSource)),
sprintf('-%s$1', (new FileDigest)($fileSource)),
$filename
);
}
2 changes: 1 addition & 1 deletion src/ImportmapLaravelServiceProvider.php
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public function configurePackage(Package $package): void

public function packageRegistered(): void
{
$this->app->scoped(Importmap::class, fn (): \Tonysm\ImportmapLaravel\Importmap => new Importmap());
$this->app->scoped(Importmap::class, fn (): \Tonysm\ImportmapLaravel\Importmap => new Importmap);

$this->app->bind('importmap-laravel', Importmap::class);
}
4 changes: 1 addition & 3 deletions src/MappedDirectory.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,5 @@

class MappedDirectory
{
public function __construct(public string $dir, public ?string $under = null, public ?string $path = null, public bool $preload = false)
{
}
public function __construct(public string $dir, public ?string $under = null, public ?string $path = null, public bool $preload = false) {}
}
4 changes: 1 addition & 3 deletions src/MappedFile.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,5 @@

class MappedFile
{
public function __construct(public string $name, public string $path, public bool $preload)
{
}
public function __construct(public string $name, public string $path, public bool $preload) {}
}
3 changes: 1 addition & 2 deletions src/PackageVersion.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,5 @@ class PackageVersion
public function __construct(
public string $name,
public string $version,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions src/VulnerablePackage.php
Original file line number Diff line number Diff line change
@@ -9,6 +9,5 @@ public function __construct(
public string $severity,
public string $vulnerableVersions,
public string $vulnerability,
) {
}
) {}
}
4 changes: 2 additions & 2 deletions tests/ReplaceOrAppendTagsTest.php
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public function replace_vite_tags(): void
</html>
BLADE;

$this->assertEquals($expected, (new ReplaceOrAppendTags())($contents));
$this->assertEquals($expected, (new ReplaceOrAppendTags)($contents));
}

#[\PHPUnit\Framework\Attributes\Test]
@@ -103,6 +103,6 @@ public function appends_to_before_closing_head_tag_when_vite_directive_is_missin
</html>
BLADE;

$this->assertEquals($expected, (new ReplaceOrAppendTags())($contents));
$this->assertEquals($expected, (new ReplaceOrAppendTags)($contents));
}
}
2 changes: 1 addition & 1 deletion tests/TagsComponentTest.php
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public function uses_given_csp_nonce(): void
#[\PHPUnit\Framework\Attributes\Test]
public function uses_custom_map(): void
{
$importmap = new Importmap();
$importmap = new Importmap;
$importmap->pin('foo', preload: true);
$importmap->pin('bar', preload: true);