Skip to content

Commit

Permalink
[AssetMapper] Deprecate unused method splitPackageNameAndFilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre authored and fabpot committed Mar 2, 2024
1 parent 3a02e21 commit 9af1f34
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions UPGRADE-7.1.md
@@ -1,6 +1,11 @@
UPGRADE FROM 7.0 to 7.1
=======================

AssetMapper
-----------

* Deprecate `ImportMapConfigReader::splitPackageNameAndFilePath()`, use `ImportMapEntry::splitPackageNameAndFilePath()` instead

Cache
-----

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/AssetMapper/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.1
---

* Deprecate `ImportMapConfigReader::splitPackageNameAndFilePath()`, use `ImportMapEntry::splitPackageNameAndFilePath()` instead

6.4
---

Expand Down
Expand Up @@ -172,8 +172,13 @@ private function getRootDirectory(): string
return \dirname($this->importMapConfigPath);
}

/**
* @deprecated since Symfony 7.1, use ImportMapEntry::splitPackageNameAndFilePath() instead
*/
public static function splitPackageNameAndFilePath(string $packageName): array
{
trigger_deprecation('symfony/asset-mapper', '7.1', 'The method "%s()" is deprecated and will be removed in 8.0. Use ImportMapEntry::splitPackageNameAndFilePath() instead.', __METHOD__);

$filePath = '';
$i = strpos($packageName, '/');

Expand Down
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\AssetMapper\Tests\ImportMap;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\AssetMapper\ImportMap\ImportMapConfigReader;
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntries;
use Symfony\Component\AssetMapper\ImportMap\ImportMapEntry;
Expand All @@ -21,6 +22,8 @@

class ImportMapConfigReaderTest extends TestCase
{
use ExpectDeprecationTrait;

private Filesystem $filesystem;

protected function setUp(): void
Expand Down Expand Up @@ -162,4 +165,13 @@ public function testFindRootImportMapEntry()
$this->assertSame('file2', $entry->importName);
$this->assertSame('file2.js', $entry->path);
}

/**
* @group legacy
*/
public function testDeprecatedMethodTriggerDeprecation()
{
$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.');
ImportMapConfigReader::splitPackageNameAndFilePath('foo');
}
}
1 change: 1 addition & 0 deletions src/Symfony/Component/AssetMapper/composer.json
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": ">=8.2",
"composer/semver": "^3.0",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/filesystem": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0"
},
Expand Down

0 comments on commit 9af1f34

Please sign in to comment.