Skip to content

Commit 23d0a99

Browse files
authored
Merge pull request #55 from boesing/qa/remove-deprecations
Remove deprecated `component-whitelist`
2 parents 9d70b71 + cb4df0f commit 23d0a99

File tree

3 files changed

+16
-193
lines changed

3 files changed

+16
-193
lines changed

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,24 @@ one or more of the following keys under the `extra.laminas` configuration in the
8282
top of:
8383
- `config/config.php`
8484

85-
## Whitelisting packages to install automatically
85+
## Marking Packages to Auto-Install or to Be Ignored
8686

8787
At the project level, you can mark packages that expose configuration providers
88-
and modules that you want to automatically inject via the `component-whitelist`
89-
key:
88+
and modules that you want to automatically inject via the `component-auto-installs`
89+
key or in case you might want to permanently ignore a component, ignore components via `component-ignore-list`:
9090

9191
```json
92-
"extra": {
93-
"laminas": {
94-
"component-whitelist": [
95-
"mezzio/mezzio",
96-
"mezzio/mezzio-helpers"
97-
]
92+
{
93+
"extra": {
94+
"laminas": {
95+
"component-auto-installs": [
96+
"mezzio/mezzio",
97+
"mezzio/mezzio-helpers"
98+
],
99+
"component-ignore-list": [
100+
"laminas/laminas-db"
101+
]
102+
}
98103
}
99104
}
100105
```

src/ComponentInstaller.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
* @internal
9393
*
9494
* @psalm-type ComposerExtraComponentInstallerProjectArrayType = array{
95-
* component-whitelist?: non-empty-list<non-empty-string>,
9695
* component-auto-installs?: non-empty-list<non-empty-string>
9796
* }
9897
* @psalm-type ComposerExtraComponentInstallerArrayType = array{
@@ -951,9 +950,7 @@ private function addPackageToConfig(
951950
/** @var array<string,mixed> $rootPackageExtra */
952951
$rootPackageExtra = $this->composer->getPackage()->getExtra();
953952
$rootExtra = $this->getExtraMetadata($rootPackageExtra, true);
954-
$autoInstallations = $rootExtra['component-auto-installs']
955-
?? $rootExtra['component-whitelist']
956-
?? [];
953+
$autoInstallations = $rootExtra['component-auto-installs'] ?? [];
957954

958955
$this->marshalInstallableComponents($extra, $options)
959956
// Create injectors
@@ -1051,14 +1048,6 @@ private function filterComponentInstallerSpecificValuesFromComposerExtra(
10511048

10521049
// We do not return component/module/config-provider for components project
10531050

1054-
if (
1055-
isset($maybeLaminasSpecificConfiguration['component-whitelist'])
1056-
&& $this->isNonEmptyListContainingNonEmptyStrings($maybeLaminasSpecificConfiguration['component-whitelist'])
1057-
) {
1058-
$laminasSpecificConfiguration['component-whitelist']
1059-
= $maybeLaminasSpecificConfiguration['component-whitelist'];
1060-
}
1061-
10621051
if (
10631052
isset($maybeLaminasSpecificConfiguration['component-auto-installs'])
10641053
&& $this->isNonEmptyListContainingNonEmptyStrings(

test/ComponentInstallerTest.php

Lines changed: 1 addition & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ final class ComponentInstallerTest extends TestCase
6262
/** @var InstallationManager&MockObject */
6363
private $installationManager;
6464

65-
/** @var array{laminas?:array{component-auto-installs?:list<non-empty-string>,component-whitelist?:list<non-empty-string>}} */
65+
/** @var array{laminas?:array{component-auto-installs?:list<non-empty-string>}} */
6666
private $rootPackageExtra = [];
6767

6868
protected function setUp(): void
@@ -1735,177 +1735,6 @@ public function testInstallAutoInstallableDevModuleWithUniqueInjector(): void
17351735
], $modules);
17361736
}
17371737

1738-
public function testInstallDeprecatedWhitelistedDevModuleWithDifferentInjectors(): void
1739-
{
1740-
$moduleConfigContent = <<<'CONFIG'
1741-
<?php
1742-
return [
1743-
'modules' => [
1744-
'Laminas\Router',
1745-
'Laminas\Validator',
1746-
'Application'
1747-
]
1748-
];
1749-
CONFIG;
1750-
1751-
$this->createConfigFile('modules.config.php', $moduleConfigContent);
1752-
1753-
$configContents = <<<'CONFIG'
1754-
<?php
1755-
return [
1756-
'modules' => [
1757-
]
1758-
];
1759-
CONFIG;
1760-
foreach (['development.config.php.dist', 'development.config.php'] as $configName) {
1761-
$this->createConfigFile($configName, $configContents);
1762-
}
1763-
1764-
$this->rootPackage->method('getDevRequires')->willReturn(['some/component' => '*']);
1765-
$this->rootPackageExtra = [
1766-
'laminas' => [
1767-
"component-whitelist" => [
1768-
"some/component",
1769-
],
1770-
],
1771-
];
1772-
1773-
$package = $this->createMock(PackageInterface::class);
1774-
$package->method('getName')->willReturn('some/component');
1775-
$package->method('getExtra')->willReturn([
1776-
'laminas' => [
1777-
'component' => [
1778-
'Some\\Component',
1779-
],
1780-
],
1781-
]);
1782-
1783-
$operation = $this->createMock(InstallOperation::class);
1784-
$operation->method('getPackage')->willReturn($package);
1785-
1786-
$event = $this->createMock(PackageEvent::class);
1787-
$event->method('isDevMode')->willReturn(true);
1788-
$event->method('getOperation')->willReturn($operation);
1789-
$this->prepareEventForPackageProviderDetection($event, 'some/component');
1790-
1791-
$this->installer->onPostPackageInstall($event);
1792-
/**
1793-
* @psalm-suppress UnresolvableInclude
1794-
* @psalm-var array{modules:list<non-empty-string>} $config
1795-
*/
1796-
$config = require vfsStream::url('project/config/modules.config.php');
1797-
$modules = $config['modules'];
1798-
self::assertEquals([
1799-
'Laminas\Router',
1800-
'Laminas\Validator',
1801-
'Application',
1802-
], $modules);
1803-
/**
1804-
* @psalm-suppress UnresolvableInclude
1805-
* @psalm-var array{modules:list<non-empty-string>} $config
1806-
*/
1807-
$config = require vfsStream::url('project/config/development.config.php');
1808-
$modules = $config['modules'];
1809-
self::assertEquals(['Some\Component'], $modules);
1810-
}
1811-
1812-
public function testOnPostPackageInstallDoesNotPromptForDeprecatedWhitelistedPackages(): void
1813-
{
1814-
$this->createApplicationConfig();
1815-
1816-
$package = $this->createMock(PackageInterface::class);
1817-
$package->method('getName')->willReturn('some/component');
1818-
$package->method('getExtra')->willReturn([
1819-
'laminas' => [
1820-
'component' => 'Some\\Component',
1821-
],
1822-
]);
1823-
1824-
$operation = $this->createMock(InstallOperation::class);
1825-
$operation->method('getPackage')->willReturn($package);
1826-
1827-
$event = $this->createMock(PackageEvent::class);
1828-
$event->method('isDevMode')->willReturn(true);
1829-
$event->method('getOperation')->willReturn($operation);
1830-
$this->prepareEventForPackageProviderDetection($event, 'some/component');
1831-
1832-
$this->rootPackage->method('getName')->willReturn('some/component');
1833-
$this->rootPackageExtra = [
1834-
'laminas' => [
1835-
'component-whitelist' => ['some/component'],
1836-
],
1837-
];
1838-
1839-
$this->createOutputAssertions([
1840-
'Installing Some\Component from package some/component',
1841-
]);
1842-
$this->io
1843-
->expects(self::never())
1844-
->method('ask');
1845-
1846-
$this->installer->onPostPackageInstall($event);
1847-
$config = file_get_contents(vfsStream::url('project/config/application.config.php'));
1848-
self::assertStringContainsString("'Some\Component'", $config);
1849-
}
1850-
1851-
public function testInstallDeprecatedWhitelistedDevModuleWithUniqueInjector(): void
1852-
{
1853-
$moduleConfigContent = <<<'CONFIG'
1854-
<?php
1855-
return [
1856-
'modules' => [
1857-
'Laminas\Router',
1858-
'Laminas\Validator',
1859-
'Application',
1860-
]
1861-
];
1862-
CONFIG;
1863-
1864-
$this->createConfigFile('modules.config.php', $moduleConfigContent);
1865-
1866-
$this->rootPackageExtra = [
1867-
'laminas' => [
1868-
"component-whitelist" => [
1869-
"some/module",
1870-
],
1871-
],
1872-
];
1873-
1874-
$package = $this->createMock(PackageInterface::class);
1875-
$package->method('getName')->willReturn('some/module');
1876-
$package->method('getExtra')->willReturn([
1877-
'laminas' => [
1878-
'module' => 'Some\\Module',
1879-
],
1880-
]);
1881-
1882-
$operation = $this->createMock(InstallOperation::class);
1883-
$operation->method('getPackage')->willReturn($package);
1884-
1885-
$event = $this->createMock(PackageEvent::class);
1886-
$event->method('isDevMode')->willReturn(true);
1887-
$event->method('getOperation')->willReturn($operation);
1888-
$this->prepareEventForPackageProviderDetection($event, 'some/module');
1889-
1890-
$this->rootPackage
1891-
->method('getName')
1892-
->willReturn('some/module');
1893-
1894-
$this->installer->onPostPackageInstall($event);
1895-
/**
1896-
* @psalm-suppress UnresolvableInclude
1897-
* @psalm-var array{modules:list<non-empty-string>} $config
1898-
*/
1899-
$config = require vfsStream::url('project/config/modules.config.php');
1900-
$modules = $config['modules'];
1901-
self::assertEquals([
1902-
'Laminas\Router',
1903-
'Laminas\Validator',
1904-
'Application',
1905-
'Some\Module',
1906-
], $modules);
1907-
}
1908-
19091738
/**
19101739
* @return array<non-empty-string,array{
19111740
* non-empty-string,

0 commit comments

Comments
 (0)