8000 feature #54125 [AssetMapper] Deprecate unused method `splitPackageNam… · symfony/symfony@31a9b35 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31a9b35

Browse files
committed
feature #54125 [AssetMapper] Deprecate unused method splitPackageNameAndFilePath (smnandre)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [AssetMapper] Deprecate unused method `splitPackageNameAndFilePath` | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | Fix #54123 | License | MIT This method is not used in the codebase, and duplicates` ImportMapEntry::splitPackageNameAndFilePath()` Commits ------- 9af1f34 [AssetMapper] Deprecate unused method `splitPackageNameAndFilePath`
2 parents 9482c97 + 9af1f34 commit 31a9b35

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

UPGRADE-7.1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
UPGRADE FROM 7.0 to 7.1
22
=======================
33

4+
AssetMapper
5+
-----------
6+
7+
* Deprecate `ImportMapConfigReader::splitPackageNameAndFilePath()`, use `ImportMapEntry::splitPackageNameAndFilePath()` instead
8+
49
Cache
510
-----
611

src/Symfony/Component/AssetMapper/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.1
5+
---
6+
7+
* Deprecate `ImportMapConfigReader::splitPackageNameAndFilePath()`, use `ImportMapEntry::splitPackageNameAndFilePath()` instead
8+
49
6.4
510
---
611

src/Symfony/Component/AssetMapper/ImportMap/ImportMapConfigReader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,13 @@ private function getRootDirectory(): string
172172
return \dirname($this->importMapConfigPath);
173173
}
174174

175+
/**
176+
* @deprecated since Symfony 7.1, use ImportMapEntry::splitPackageNameAndFilePath() instead
177+
*/
175178
public static function splitPackageNameAndFilePath(string $packageName): array
176179
{
180+
trigger_deprecation('symfony/asset-mapper', '7.1', 'The method "%s()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.', __METHOD__);
181+
177182
$filePath = '';
178183
$i = strpos($packageName, '/');
179184

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\AssetMapper\Tests\ImportMap;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader;
1617
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries;
1718
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry;
@@ -21,6 +22,8 @@
2122

2223
class ImportMapConfigReaderTest extends TestCase
2324
{
25+
use ExpectDeprecationTrait;
26+
2427
private Filesystem $filesystem;
2528

2629
protected function setUp(): void
@@ -162,4 +165,13 @@ public function testFindRootImportMapEntry()
162165
$this->assertSame('file2', $entry->importName);
163166
$this->assertSame('file2.js', $entry->path);
164167
}
168+
169+
/**
170+
* @group legacy
171+
*/
172+
public function testDeprecatedMethodTriggerDeprecation()
173+
{
174+
$this->expectDeprecation('Since symfony/asset-mapper 7.1: The method "Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader::splitPackageNameAndFilePath()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.');
175+
ImportMapConfigReader::splitPackageNameAndFilePath('foo');
176+
}
165177
}

src/Symfony/Component/AssetMapper/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"composer/semver": "^3.0",
21+
"symfony/deprecation-contracts": "^2.1|^3",
2122
"symfony/filesystem": "^6.4|^7.0",
2223
"symfony/http-client": "^6.4|^7.0"
2324
},

0 commit comments

Comments
 (0)
0