1313use  Magento \SemanticVersionChecker \Node \VirtualType ;
1414use  Magento \SemanticVersionChecker \Operation \DiXml \VirtualTypeChanged ;
1515use  Magento \SemanticVersionChecker \Operation \DiXml \VirtualTypeRemoved ;
16+ use  Magento \SemanticVersionChecker \Operation \DiXml \VirtualTypeToTypeChanged ;
1617use  Magento \SemanticVersionChecker \Registry \XmlRegistry ;
1718use  PHPSemVerChecker \Registry \Registry ;
1819use  PHPSemVerChecker \Report \Report ;
@@ -60,7 +61,7 @@ public function analyze($registryBefore, $registryAfter)
6061 foreach  ($ moduleNodes  as  $ name  => $ nodeBefore ) {
6162 // search nodesAfter the by name 
6263 $ nodeAfter  = $ nodesAfter [$ moduleName ][$ name ] ?? false ;
63- 
64+   $ fileAfter  =  $ registryAfter -> mapping [XmlRegistry:: NODES_KEY ][ $ moduleName ]; 
6465 if  ($ nodeAfter  !== false  && $ nodeBefore  !== $ nodeAfter ) {
6566 /* @var VirtualType $nodeAfter */ 
6667 $ this  ->triggerNodeChange ($ nodeBefore , $ nodeAfter , $ fileBefore );
@@ -78,14 +79,68 @@ public function analyze($registryBefore, $registryAfter)
7879 }
7980 }
8081
81-  $ operation  = new  VirtualTypeRemoved ($ fileBefore , $ name );
82+  $ finalPath  = $ this  ->convertClassNameToFilePath ($ fileAfter , $ name , '.php ' );
83+ 
84+  if  (file_exists ($ finalPath )) {
85+  $ operation  = new  VirtualTypeToTypeChanged ($ fileBefore , $ name );
86+  } else  {
87+  $ operation  = new  VirtualTypeRemoved ($ fileBefore , $ name );
88+  }
8289 $ this  ->report ->add ('di ' , $ operation );
8390 }
8491 }
8592
8693 return  $ this  ->report ;
8794 }
8895
96+  /** 
97+  * Method to convert class name to file path 
98+  * 
99+  * @param string $filePath 
100+  * @param string $className 
101+  * @param string $extraString 
102+  * @return string 
103+  */ 
104+  private  function  convertClassNameToFilePath ($ filePath , $ className , $ extraString  = '' ): string 
105+  {
106+  // Split the initial file path to get the base directory. 
107+  $ parts  = explode ('/ ' , $ filePath );
108+  $ classParts  = explode ('\\' , $ className );
109+ 
110+  // Find the common part between the file path and class name. 
111+  $ baseDirParts  = [];
112+  foreach  ($ parts  as  $ part ) {
113+  $ baseDirParts [] = $ part ;
114+ 
115+  if  (in_array ($ part , $ classParts )) {
116+  break ;
117+  }
118+  }
119+ 
120+  // Reconstruct the base directory path. 
121+  $ baseDir  = implode ('/ ' , $ baseDirParts );
122+ 
123+  // Replace namespace separators with directory separators in the class name. 
124+  $ classFilePath  = str_replace ('\\' , '/ ' , $ className );
125+ 
126+  $ position  = strpos ($ classFilePath , "/ " );
127+ 
128+  if  ($ position  !== false ) {
129+  $ classFilePath  = substr ($ classFilePath , $ position );
130+  }
131+ 
132+  // Combine the base directory and class file path. 
133+  $ fullPath  = rtrim ($ baseDir , '/ ' ) . $ classFilePath ;
134+ 
135+ 
136+  // Append the extra string if provided. 
137+  if  ($ extraString ) {
138+  $ fullPath  .= $ extraString ;
139+  }
140+  return  $ fullPath ;
141+  }
142+ 
143+ 
89144 /** 
90145 * Return a filtered node list from type {@link VirtualType} 
91146 * 
0 commit comments