Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect when virtualTypes move elsewhere #72

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dev/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ public function changesDataProvider()
],
''
],
'moved-to-app-etc' => [
$pathToFixtures . '/moved-to-app-etc/source-code-before',
$pathToFixtures . '/moved-to-app-etc/source-code-after',
[
'#Suggested semantic versioning change: NONE#',
],
'Patch change is detected.',
],
'moved-to-another-module' => [
$pathToFixtures . '/moved-to-another-module/source-code-before',
$pathToFixtures . '/moved-to-another-module/source-code-after',
[
'#Suggested semantic versioning change: NONE#',
],
'Patch change is detected.',
],
'moved-to-global' => [
$pathToFixtures . '/moved-to-global/source-code-before',
$pathToFixtures . '/moved-to-global/source-code-after',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in Magento_AnotherTestModule's etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in Magento_TestModule's etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in a the global app/etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in a module's etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
11 changes: 11 additions & 0 deletions src/Analyzer/DiXml/VirtualTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ public function analyze($registryBefore, $registryAfter)
continue;
}

foreach ($nodesAfter as $newModuleNodes) {
foreach ($newModuleNodes as $nodeAfter) {
if ($nodeBefore->getName() !== $nodeAfter->getName()) {
continue;
}

$this->triggerNodeChange($nodeBefore, $nodeAfter, $fileBefore);
continue 3;
}
}

$operation = new VirtualTypeRemoved($fileBefore, $name);
$this->report->add('di', $operation);
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/application_includes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
app/code
app/etc
lib/internal/Magento
Inventory*
Adobe*
Loading