/**
  * Return refactored files
  *
  * @return array
  */
 public function modulesFilesDataProvider()
 {
     $filesList = [];
     foreach ($this->getFilesData('whitelist/refactored_modules*') as $refactoredFolder) {
         $files = \Magento\Framework\App\Utility\Files::init()->getFiles([$this->appPath . $refactoredFolder], '*.php');
         $filesList = array_merge($filesList, $files);
     }
     $result = array_map('realpath', $filesList);
     $result = array_diff($result, $this->filesBlackList);
     return \Magento\Framework\App\Utility\Files::composeDataSets($result);
 }
Ejemplo n.º 2
0
 /**
  * Returns array of PHP-files, that use or declare Magento application classes and Magento libs
  *
  * @param string $changedFilesList
  * @return array
  */
 public static function getPhpFiles($changedFilesList)
 {
     $fileHelper = \Magento\Framework\App\Utility\Files::init();
     if (isset($_ENV['INCREMENTAL_BUILD'])) {
         $phpFiles = Files::readLists($changedFilesList);
         if (!empty($phpFiles)) {
             $phpFiles = \Magento\Framework\App\Utility\Files::composeDataSets($phpFiles);
             $phpFiles = array_intersect_key($phpFiles, $fileHelper->getPhpFiles());
         }
     } else {
         $phpFiles = $fileHelper->getPhpFiles();
     }
     return $phpFiles;
 }
Ejemplo n.º 3
0
 /**
  * Return refactored files
  *
  * @return array
  */
 public function modulesFilesDataProvider()
 {
     $filesList = [];
     $componentRegistrar = new ComponentRegistrar();
     foreach ($this->getFilesData('whitelist/refactored_modules*') as $refactoredModule) {
         if ($componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)) {
             $files = \Magento\Framework\App\Utility\Files::init()->getFiles([$componentRegistrar->getPath(ComponentRegistrar::MODULE, $refactoredModule)], '*.php');
             $filesList = array_merge($filesList, $files);
         }
     }
     $result = array_map('realpath', $filesList);
     $result = array_diff($result, $this->filesBlackList);
     return \Magento\Framework\App\Utility\Files::composeDataSets($result);
 }
Ejemplo n.º 4
0
 /**
  * Returns array of PHP-files, that use or declare Magento application classes and Magento libs
  *
  * @param string $changedFilesList
  * @return array
  */
 public static function getPhpFiles($changedFilesList)
 {
     $fileHelper = \Magento\Framework\App\Utility\Files::init();
     if (isset($_ENV['INCREMENTAL_BUILD'])) {
         $phpFiles = [];
         foreach (glob($changedFilesList) as $listFile) {
             $phpFiles = array_merge($phpFiles, file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
         }
         array_walk($phpFiles, function (&$file) {
             $file = BP . '/' . $file;
         });
         if (!empty($phpFiles)) {
             $phpFiles = \Magento\Framework\App\Utility\Files::composeDataSets($phpFiles);
             $phpFiles = array_intersect_key($phpFiles, $fileHelper->getPhpFiles(Files::INCLUDE_APP_CODE | Files::INCLUDE_PUB_CODE | Files::INCLUDE_LIBS | Files::INCLUDE_TEMPLATES | Files::INCLUDE_TESTS | Files::AS_DATA_SET | Files::INCLUDE_NON_CLASSES));
         }
     } else {
         $phpFiles = $fileHelper->getPhpFiles(Files::INCLUDE_APP_CODE | Files::INCLUDE_PUB_CODE | Files::INCLUDE_LIBS | Files::INCLUDE_TEMPLATES | Files::INCLUDE_TESTS | Files::AS_DATA_SET | Files::INCLUDE_NON_CLASSES);
     }
     return $phpFiles;
 }
Ejemplo n.º 5
0
 public function testMageMethodsObsolete()
 {
     $ignored = $this->getBlacklistFiles();
     $files = Files::init()->getPhpFiles(Files::INCLUDE_APP_CODE | Files::INCLUDE_TESTS | Files::INCLUDE_DEV_TOOLS | Files::INCLUDE_LIBS);
     $files = array_map('realpath', $files);
     $files = array_diff($files, $ignored);
     $files = Files::composeDataSets($files);
     $invoker = new AggregateInvoker($this);
     $invoker(function ($file) {
         $this->_assertNotRegExp('/[^a-z\\d_]Mage\\s*::/i', file_get_contents($file), '"Mage" class methods are obsolete');
     }, $files);
 }
Ejemplo n.º 6
0
 /**
  * @return array
  */
 public function mageObsoleteDataProvider()
 {
     $blackList = (include __DIR__ . '/_files/blacklist/obsolete_mage.php');
     $ignored = [];
     $appPath = \Magento\Framework\App\Utility\Files::init()->getPathToSource();
     foreach ($blackList as $file) {
         $ignored[] = realpath($appPath . '/' . $file);
     }
     $files = \Magento\Framework\App\Utility\Files::init()->getClassFiles(true, true, true, true, false);
     $files = array_map('realpath', $files);
     $files = array_diff($files, $ignored);
     return \Magento\Framework\App\Utility\Files::composeDataSets($files);
 }