Skip to content

Commit ee4b073

Browse files
committed
Fabbot patch
1 parent d5a6081 commit ee4b073

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/PackageJsonSynchronizer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private function removeObsoletePackageJsonLinks(): bool
104104

105105
foreach (['dependencies' => $jsDependencies, 'devDependencies' => $jsDevDependencies] as $key => $packages) {
106106
foreach ($packages as $name => $version) {
107-
if ('@' !== $name[0] || 0 !== strpos($version, 'file:'.$this->vendorDir.'/') || false === strpos($version, '/assets')) {
107+
if ('@' !== $name[0] || !str_starts_with($version, 'file:'.$this->vendorDir.'/') || !str_contains($version, '/assets')) {
108108
continue;
109109
}
110110
if (file_exists($this->rootDir.'/'.substr($version, 5).'/package.json')) {
@@ -161,18 +161,18 @@ private function resolveImportMapPackages($phpPackage): array
161161
$package = $constraintConfig['package'] ?? $importMapName;
162162
$entrypoint = $constraintConfig['entrypoint'] ?? false;
163163
} else {
164-
throw new \InvalidArgumentException(sprintf('Invalid constraint config for key "%s": "%s" given, array or string expected.', $importMapName, var_export($constraintConfig, true)));
164+
throw new \InvalidArgumentException(\sprintf('Invalid constraint config for key "%s": "%s" given, array or string expected.', $importMapName, var_export($constraintConfig, true)));
165165
}
166166

167167
// When "$constraintConfig" matches one of the following cases:
168168
// - "entrypoint:%PACKAGE%/script.js"
169169
// - {"version": "entrypoint:%PACKAGE%/script.js"}
170-
if (0 === strpos($constraint, 'entrypoint:')) {
170+
if (str_starts_with($constraint, 'entrypoint:')) {
171171
$entrypoint = true;
172172
$constraint = str_replace('entrypoint:', 'path:', $constraint);
173173
}
174174

175-
if (0 === strpos($constraint, 'path:')) {
175+
if (str_starts_with($constraint, 'path:')) {
176176
$path = substr($constraint, 5);
177177
$path = str_replace('%PACKAGE%', \dirname($packageJson->getPath()), $path);
178178

@@ -280,7 +280,7 @@ private function updateImportMap(array $importMapEntries): void
280280
continue;
281281
}
282282

283-
$this->io->writeError(sprintf('Updating package <comment>%s</> from <info>%s</> to <info>%s</>.', $name, $version, $versionConstraint));
283+
$this->io->writeError(\sprintf('Updating package <comment>%s</> from <info>%s</> to <info>%s</>.', $name, $version, $versionConstraint));
284284
}
285285

286286
if (isset($importMapEntry['path'])) {
@@ -313,7 +313,7 @@ private function updateImportMap(array $importMapEntries): void
313313
continue;
314314
}
315315

316-
throw new \InvalidArgumentException(sprintf('Invalid importmap entry: "%s".', var_export($importMapEntry, true)));
316+
throw new \InvalidArgumentException(\sprintf('Invalid importmap entry: "%s".', var_export($importMapEntry, true)));
317317
}
318318
}
319319

tests/PackageJsonSynchronizerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function testSynchronizeAssetMapperUpgradesPackageIfNeeded()
401401
'version' => '1.8.0',
402402
],
403403
];
404-
file_put_contents($this->tempDir.'/importmap.php', sprintf('<?php return %s;', var_export($importMap, true)));
404+
file_put_contents($this->tempDir.'/importmap.php', \sprintf('<?php return %s;', var_export($importMap, true)));
405405

406406
$fileModulePath = $this->tempDir.'/vendor/symfony/new-package/assets/dist/loader.js';
407407
$entrypointPath = $this->tempDir.'/vendor/symfony/new-package/assets/entry.js';
@@ -434,9 +434,9 @@ public function testSynchronizeAssetMapperSkipsUpgradeIfAlreadySatisfied()
434434
'@symfony/new-package/entry2.js' => [
435435
'path' => './vendor/symfony/new-package/assets/entry2.js',
436436
'entrypoint' => true,
437-
]
437+
],
438438
];
439-
file_put_contents($this->tempDir.'/importmap.php', sprintf('<?php return %s;', var_export($importMap, true)));
439+
file_put_contents($this->tempDir.'/importmap.php', \sprintf('<?php return %s;', var_export($importMap, true)));
440440

441441
$fileModulePath = $this->tempDir.'/vendor/symfony/new-package/assets/dist/loader.js';
442442
$entrypointPath = $this->tempDir.'/vendor/symfony/new-package/assets/entry.js';
@@ -470,5 +470,4 @@ public function testExceptionWhenInvalidImportMapConstraint()
470470
],
471471
]);
472472
}
473-
474473
}

0 commit comments

Comments
 (0)