Skip to content

Commit 0cd0c49

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [AssetMapper] Fix URL pattern when importing es-module-shims Allow psr/container 1.1 again [Notifier] Mention `postAt()` in the Slack bridge README remove unneeded @requires PHP from tests remove unneeded @requires PHP from tests
2 parents 6f1f88f + 5f98960 commit 0cd0c49

File tree

7 files changed

+46
-16
lines changed

7 files changed

+46
-16
lines changed

src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ final class JsDelivrEsmResolver implements PackageResolverInterface
3030

3131
public const IMPORT_REGEX = '#(?:import\s*(?:\w+,)?(?:(?:\{[^}]*\}|\w+|\*\s*as\s+\w+)\s*\bfrom\s*)?|export\s*(?:\{[^}]*\}|\*)\s*from\s*)("/npm/((?:@[^/]+/)?[^@]+?)(?:@([^/]+))?((?:/[^/]+)*?)/\+esm")#';
3232

33+
private const ES_MODULE_SHIMS = 'es-module-shims';
34+
3335
private HttpClientInterface $httpClient;
3436

3537
public function __construct(
@@ -78,7 +80,7 @@ public function resolvePackages(array $packagesToRequire): array
7880
throw new RuntimeException(sprintf('Unable to find the latest version for package "%s" - try specifying the version manually.', $packageName));
7981
}
8082

81-
$pattern = str_ends_with($filePath, '.css') ? self::URL_PATTERN_DIST_CSS : self::URL_PATTERN_DIST;
83+
$pattern = $this->resolveUrlPattern($packageName, $filePath);
8284
$requiredPackages[$i][1] = $this->httpClient->request('GET', sprintf($pattern, $packageName, $version, $filePath));
8385
$requiredPackages[$i][4] = $version;
8486

@@ -169,7 +171,11 @@ public function downloadPackages(array $importMapEntries, callable $progressCall
169171
throw new \InvalidArgumentException(sprintf('The entry "%s" is not a remote package.', $entry->importName));
170172
}
171173

172-
$pattern = ImportMapType::CSS === $entry->type ? self::URL_PATTERN_DIST_CSS : self::URL_PATTERN_DIST;
174+
$pattern = $this->resolveUrlPattern(
175+
$entry->getPackageName(),
176+
$entry->getPackagePathString(),
177+
$entry->type,
178+
);
173179
$url = sprintf($pattern, $entry->getPackageName(), $entry->version, $entry->getPackagePathString());
174180

175181
$responses[$package] = [$this->httpClient->request('GET', $url), $entry];
@@ -326,4 +332,19 @@ private function makeImportsBare(string $content, array &$dependencies, array &$
326332

327333
return preg_replace('{/\*# sourceMappingURL=[^ ]*+ \*/}', '', $content);
328334
}
335+
336+
/**
337+
* Determine the URL pattern to be used by the HTTP Client.
338+
*/
339+
private function resolveUrlPattern(string $packageName, string $path, ImportMapType $type = null): string
340+
{
341+
// The URL for the es-module-shims polyfill package uses the CSS pattern to
342+
// prevent a syntax error in the browser console, so check the package name
343+
// as part of the condition.
344+
if (self::ES_MODULE_SHIMS === $packageName || str_ends_with($path, '.css') || ImportMapType::CSS === $type) {
345+
return self::URL_PATTERN_DIST_CSS;
346+
}
347+
348+
return self::URL_PATTERN_DIST;
349+
}
329350
}

src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,17 @@ public static function provideDownloadPackagesTests()
439439
],
440440
[
441441
[
442-
'url' => '/es-module-shims@1.8.2/+esm',
442+
'url' => '/es-module-shims@1.8.2',
443443
'body' => <<<'EOF'
444-
const je="\n//# sourceURL=",Ue="\n//# sourceMappingURL=",Me=/^(text|application)\/(x-)?javascript(;|$)/,_e=/^(application)\/wasm(;|$)/,Ie=/^(text|application)\/json(;|$)/,Re=/^(text|application)\/css(;|$)/,Te=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;export{t as default};
444+
const je="\n//# sourceURL=",Ue="\n//# sourceMappingURL=",Me=/^(text|application)\/(x-)?javascript(;|$)/,_e=/^(application)\/wasm(;|$)/,Ie=/^(text|application)\/json(;|$)/,Re=/^(text|application)\/css(;|$)/,Te=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
445445
//# sourceMappingURL=/sm/ef3916de598f421a779ba0e69af94655b2043095cde2410cc01893452d893338.map
446446
EOF
447447
],
448448
],
449449
[
450450
'es-module-shims' => [
451451
'content' => <<<'EOF'
452-
const je="\n//# sourceURL=",Ue="\n//# sourceMappingURL=",Me=/^(text|application)\/(x-)?javascript(;|$)/,_e=/^(application)\/wasm(;|$)/,Ie=/^(text|application)\/json(;|$)/,Re=/^(text|application)\/css(;|$)/,Te=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;export{t as default};
452+
const je="\n//# sourceURL=",Ue="\n//# sourceMappingURL=",Me=/^(text|application)\/(x-)?javascript(;|$)/,_e=/^(application)\/wasm(;|$)/,Ie=/^(text|application)\/json(;|$)/,Re=/^(text|application)\/css(;|$)/,Te=/url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
453453
EOF,
454454
'dependencies' => [],
455455
'extraFiles' => [],

src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,6 @@ public function testUnionTypePassesWithFalse()
856856
$this->addToAssertionCount(1);
857857
}
858858

859-
/**
860-
* @requires PHP 8.2
861-
*/
862859
public function testUnionTypePassesWithTrue()
863860
{
864861
$container = new ContainerBuilder();

src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ public function testDumpHandlesEnumeration()
167167
}
168168

169169
/**
170-
* @requires PHP 8.1
171-
*
172170
* @dataProvider provideDefaultClasses
173171
*/
174172
public function testDumpHandlesDefaultAttribute($class, $expectedFile)

src/Symfony/Component/Notifier/Bridge/Slack/README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SLACK_DSN=slack://xoxb-......@default?channel=fabien
2929
Adding Interactions to a Message
3030
--------------------------------
3131

32-
With a Slack message, you can use the `SlackOptions` class to add some
32+
With a Slack message, you can use the `SlackOptions` class to add some
3333
interactive options called [Block elements](https://api.slack.com/reference/block-kit/block-elements).
3434

3535
```php
@@ -177,7 +177,7 @@ $chatter->send($chatMessage);
177177
Sending a Message as a Reply
178178
----------------------------
179179

180-
To send your slack message as a reply in a thread use the `threadTs()` method.
180+
To send your Slack message as a reply in a thread use the `threadTs()` method.
181181

182182
```php
183183
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
@@ -226,6 +226,23 @@ $options = new UpdateMessageSlackOptions($channelId, $messageId);
226226
$chatter->send(new ChatMessage('Updated message', $options));
227227
```
228228

229+
Scheduling a Slack Message
230+
--------------------------
231+
232+
To schedule a message to be sent at a later time, use the `postAt()` method:
233+
234+
```php
235+
use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
236+
use Symfony\Component\Notifier\Message\ChatMessage;
237+
238+
$options = (new SlackOptions())->postAt(new \DateTime('+1 day'));
239+
240+
$chatMessage = new ChatMessage('Symfony Feature');
241+
$chatMessage->options($options);
242+
243+
$chatter->send($chatMessage);
244+
```
245+
229246
Resources
230247
---------
231248

src/Symfony/Component/Serializer/Tests/SerializerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,6 @@ public function testDeserializeWrappedScalar()
754754
$this->assertSame(42, $serializer->deserialize('{"wrapper": 42}', 'int', 'json', [UnwrappingDenormalizer::UNWRAP_PATH => '[wrapper]']));
755755
}
756756

757-
/**
758-
* @requires PHP 8
759-
*/
760757
public function testDeserializeNullableIntInXml()
761758
{
762759
$extractor = new PropertyInfoExtractor([], [new ReflectionExtractor()]);

src/Symfony/Contracts/Service/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.1",
20-
"psr/container": "^2.0"
20+
"psr/container": "^1.1|^2.0"
2121
},
2222
"conflict": {
2323
"ext-psr": "<1.1|>=2"

0 commit comments

Comments
 (0)