diff --git a/.make/dependencies/rmUnnecessaryFolders.php b/.make/dependencies/rmUnnecessaryFolders.php index 3d99ed9fa..0f8d48850 100644 --- a/.make/dependencies/rmUnnecessaryFolders.php +++ b/.make/dependencies/rmUnnecessaryFolders.php @@ -53,12 +53,12 @@ switch ($sDependenciesHandlerCode) { // Start handler $oDependenciesHandler = new $sDependenciesHandlerFQCN(); -$aDeniedButStillPresent = $oDependenciesHandler->ListDeniedButStillPresentFoldersAbsPaths(); +$aDeniedButStillPresent = $oDependenciesHandler->ListDeniedButStillPresentFilesAbsPaths(); echo "\n"; foreach ($aDeniedButStillPresent as $sDir) { - if (false === $oDependenciesHandler::IsQuestionnableFolder($sDir)) + if (false === $oDependenciesHandler::IsQuestionnableFile($sDir)) { echo "ERROR found INVALID denied test dir: '$sDir'\n"; throw new \RuntimeException("$sDir is in the denied list but doesn't comply with the rule (see IsQuestionnableFolder method)"); @@ -70,7 +70,12 @@ foreach ($aDeniedButStillPresent as $sDir) } try { - SetupUtils::rrmdir($sDir); + if(is_dir($sDir)){ + SetupUtils::rrmdir($sDir); + } + else{ + unlink($sDir); + } echo "✔️ Remove denied test dir: '$sDir'\n"; } catch (\Exception $e) { @@ -80,10 +85,10 @@ foreach ($aDeniedButStillPresent as $sDir) $aAllowedAndDeniedDirs = array_merge( - $oDependenciesHandler->ListAllowedFoldersAbsPaths(), - $oDependenciesHandler->ListDeniedFoldersAbsPaths() + $oDependenciesHandler->ListAllowedFilesAbsPaths(), + $oDependenciesHandler->ListDeniedFilesAbsPaths() ); -$aExistingDirs = $oDependenciesHandler->ListAllFoldersAbsPaths(); +$aExistingDirs = $oDependenciesHandler->ListAllFilesAbsPaths(); $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); if (false === empty($aMissing)) { echo "Some new tests dirs exists !\n" diff --git a/lib/.gitignore b/lib/.gitignore index aeb628c79..8b1378917 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,33 +1 @@ -# Combodo's fork of TCPDF -/combodo/tcpdf/examples -/combodo/tcpdf/tools -/combodo/tcpdf/fonts/** -!/combodo/tcpdf/fonts/courier* -!/combodo/tcpdf/fonts/dejavusans* -!/combodo/tcpdf/fonts/droidsansfallback* -!/combodo/tcpdf/fonts/helvetica* -!/combodo/tcpdf/fonts/symbol.php -!/combodo/tcpdf/fonts/times* -!/combodo/tcpdf/fonts/zapfdingbats.php -# ArchiveTar -/pear/archive_tar/docs -/pear/archive_tar/scripts -/pear/archive_tar/sync-php4 - -# Emogrifier -/pelago/emogrifier/.github -/pelago/emogrifier/tests - -# SCSSPHP -/scssphp/scssphp/example - -# SwiftMailer -/swiftmailer/swiftmailer/.github -/swiftmailer/swiftmailer/doc -/swiftmailer/swiftmailer/tests - -# TWIG -/twig/twig/doc -/twig/twig/test -/twig/twig/drupal_test.sh diff --git a/sources/Dependencies/AbstractFolderAnalyzer.php b/sources/Dependencies/AbstractFolderAnalyzer.php index 55faecaf6..371c15d93 100644 --- a/sources/Dependencies/AbstractFolderAnalyzer.php +++ b/sources/Dependencies/AbstractFolderAnalyzer.php @@ -33,18 +33,18 @@ abstract class AbstractFolderAnalyzer * @since 3.2.0 N°7175 update regexp to also remove `examples` folder * @link https://www.regular-expressions.info/alternation.html RegExp alternation reference */ - public const QUESTIONNABLE_FOLDER_REGEXP = '/^(tests?|examples?|htdocs?|demos?|.github|.idea)$/i'; + public const QUESTIONNABLE_FILES_REGEXP = '/^(tests?|examples?|htdocs?|demos?|.github|.idea)$/i'; /** - * @param string $sFolderName + * @param string $sFileName * * @return false|int as {@see \preg_match()} - * @uses static::QUESTIONNABLE_FOLDER_REGEXP + * @uses static::QUESTIONNABLE_FILES_REGEXP * @uses \preg_match() */ - public static function IsQuestionnableFolder(string $sFolderName): false|int + public static function IsQuestionnableFile(string $sFileName): false|int { - return preg_match(static::QUESTIONNABLE_FOLDER_REGEXP, $sFolderName); + return preg_match(static::QUESTIONNABLE_FILES_REGEXP, $sFileName); } /** @@ -70,12 +70,12 @@ abstract class AbstractFolderAnalyzer } /** - * @param bool $bCheckQuestionableFoldersOnly If true, only questionnable folders {@see \Combodo\iTop\Dependencies\AbstractFolderAnalyzer::IsQuestionnableFolder()} will be listed + * @param bool $bCheckQuestionableFilesOnly If true, only questionnable folders {@see \Combodo\iTop\Dependencies\AbstractFolderAnalyzer::IsQuestionnableFile()} will be listed * - * @return array List of all subdirs of the dependencies folder that are {@see IsQuestionnableFolder}. + * @return array List of all subdirs of the dependencies folder that are {@see IsQuestionnableFile}. * Warning : each path contains slashes (meaning on Windows you'll get eg `C:/Dev/wamp64/www/itop-27/lib/goaop/framework/tests`) */ - public function ListAllFoldersAbsPaths(bool $bCheckQuestionableFoldersOnly = true): array + public function ListAllFilesAbsPaths(bool $bCheckQuestionableFilesOnly = true): array { $aAllTestDirs = array(); $sPath = realpath($this->GetDependenciesRootFolderAbsPath()); @@ -87,11 +87,8 @@ abstract class AbstractFolderAnalyzer /** @var DirectoryIterator $file */ foreach($iterator as $file) { - if(!$file->isDir()) { - continue; - } $sDirName = $file->getFilename(); - if ($bCheckQuestionableFoldersOnly && !static::IsQuestionnableFolder($sDirName)) { + if ($bCheckQuestionableFilesOnly && !static::IsQuestionnableFile($sDirName)) { continue; } @@ -106,36 +103,36 @@ abstract class AbstractFolderAnalyzer /** * @return array Array of absolute paths to allowed questionnable folders */ - abstract public function ListAllowedFoldersRelPaths(): array; + abstract public function ListAllowedFilesRelPaths(): array; /** * @return array Array of absolute paths to allowed folders */ - public function ListAllowedFoldersAbsPaths(): array + public function ListAllowedFilesAbsPaths(): array { - return array_map(fn ($sRelPath): string => $this->GetDependenciesRootFolderAbsPath() . $sRelPath, $this->ListAllowedFoldersRelPaths()); + return array_map(fn ($sRelPath): string => $this->GetDependenciesRootFolderAbsPath() . $sRelPath, $this->ListAllowedFilesRelPaths()); } /** * @return array Array of relative paths (from dependencies root folder {@see static::GetDependenciesRootFolderAbsPath()}) to denied folders */ - abstract public function ListDeniedFoldersRelPaths(): array; + abstract public function ListDeniedFilesRelPaths(): array; /** * @return array Array of absolute paths to denied folders */ - public function ListDeniedFoldersAbsPaths(): array + public function ListDeniedFilesAbsPaths(): array { - return array_map(fn ($sRelPath): string => $this->GetDependenciesRootFolderAbsPath() . $sRelPath, $this->ListDeniedFoldersRelPaths()); + return array_map(fn ($sRelPath): string => $this->GetDependenciesRootFolderAbsPath() . $sRelPath, $this->ListDeniedFilesRelPaths()); } /** * @return array Array of absolute paths to questionnable denied test folders that need to be marked as allowed or denied */ - public function ListDeniedButStillPresentFoldersAbsPaths(): array + public function ListDeniedButStillPresentFilesAbsPaths(): array { - $aDeniedTestDir = $this->ListDeniedFoldersAbsPaths(); - $aAllTestDir = $this->ListAllFoldersAbsPaths(false); + $aDeniedTestDir = $this->ListDeniedFilesAbsPaths(); + $aAllTestDir = $this->ListAllFilesAbsPaths(false); return array_intersect($aDeniedTestDir, $aAllTestDir); } } \ No newline at end of file diff --git a/sources/Dependencies/Composer/iTopComposer.php b/sources/Dependencies/Composer/iTopComposer.php index 6ae6ba404..4db223284 100644 --- a/sources/Dependencies/Composer/iTopComposer.php +++ b/sources/Dependencies/Composer/iTopComposer.php @@ -36,7 +36,7 @@ class iTopComposer extends AbstractFolderAnalyzer /** * @inheritDoc */ - public function ListAllowedFoldersRelPaths(): array + public function ListAllowedFilesRelPaths(): array { return [ 'twig/twig/src/Node/Expression/Test', @@ -46,7 +46,7 @@ class iTopComposer extends AbstractFolderAnalyzer /** * @inheritDoc */ - public function ListDeniedFoldersRelPaths(): array + public function ListDeniedFilesRelPaths(): array { return [ 'doctrine/lexer/tests', @@ -61,6 +61,9 @@ class iTopComposer extends AbstractFolderAnalyzer 'pear/archive_tar/tests', 'pear/console_getopt/tests', 'pear/pear_exception/tests', + 'pear/archive_tar/docs', + 'pear/archive_tar/scripts', + 'pear/archive_tar/sync-php4', 'psr/log/Psr/Log/Test', diff --git a/sources/Dependencies/NPM/iTopNPM.php b/sources/Dependencies/NPM/iTopNPM.php index 4a94280dd..0807f106e 100644 --- a/sources/Dependencies/NPM/iTopNPM.php +++ b/sources/Dependencies/NPM/iTopNPM.php @@ -26,7 +26,7 @@ use Combodo\iTop\Dependencies\AbstractFolderAnalyzer; class iTopNPM extends AbstractFolderAnalyzer { /** @inheritDoc */ - public const QUESTIONNABLE_FOLDER_REGEXP = '/^(tests?|examples?|htdocs?|demos?|website|external|libs?|src|.github|.idea)$/i'; + public const QUESTIONNABLE_FILES_REGEXP = '/^(tests?|examples?|htdocs?|demos?|website|external|libs?|src|.github|.idea)$/i'; /** * @inheritDoc @@ -39,7 +39,7 @@ class iTopNPM extends AbstractFolderAnalyzer /** * @inheritDoc */ - public function ListAllowedFoldersRelPaths(): array + public function ListAllowedFilesRelPaths(): array { return [ 'ace-builds/textarea/src', // Unknown usage @@ -54,7 +54,7 @@ class iTopNPM extends AbstractFolderAnalyzer /** * @inheritDoc */ - public function ListDeniedFoldersRelPaths(): array + public function ListDeniedFilesRelPaths(): array { return [ '@popperjs/core/dist/cjs', diff --git a/tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php b/tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php index a31c1dd7f..dad1ec5f9 100644 --- a/tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php +++ b/tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php @@ -39,7 +39,7 @@ class iTopComposerTest extends ItopTestCase */ public function testIsQuestionnableFolder($sDirName, $bIsTest) { - $isTestDir = iTopComposer::IsQuestionnableFolder($sDirName); + $isTestDir = iTopComposer::IsQuestionnableFile($sDirName); $this->assertIsInt($isTestDir); if (true === $bIsTest) { $this->assertTrue(($isTestDir > 0)); @@ -65,13 +65,13 @@ class iTopComposerTest extends ItopTestCase public function testListAllFoldersAbsPaths() { $oiTopComposer = new iTopComposer(); - $aDirs = $oiTopComposer->ListAllFoldersAbsPaths(); + $aDirs = $oiTopComposer->ListAllFilesAbsPaths(); $this->assertTrue(is_array($aDirs)); foreach ($aDirs as $sDir) { $sDirName = basename($sDir); - $this->assertMatchesRegularExpression(iTopComposer::QUESTIONNABLE_FOLDER_REGEXP, $sDirName, "Directory not matching test dir : $sDir"); + $this->assertMatchesRegularExpression(iTopComposer::QUESTIONNABLE_FILES_REGEXP, $sDirName, "Directory not matching test dir : $sDir"); } } @@ -79,13 +79,13 @@ class iTopComposerTest extends ItopTestCase public function testListDeniedFolderAbsPaths() { $oiTopComposer = new iTopComposer(); - $aDirs = $oiTopComposer->ListDeniedFoldersAbsPaths(); + $aDirs = $oiTopComposer->ListDeniedFilesAbsPaths(); $this->assertTrue(is_array($aDirs)); $aDeniedDirWrongFormat = []; foreach ($aDirs as $sDir) { - if (false === iTopComposer::IsQuestionnableFolder($sDir)) { + if (false === iTopComposer::IsQuestionnableFile($sDir)) { $aDeniedDirWrongFormat[] = $sDir; } } @@ -97,7 +97,7 @@ class iTopComposerTest extends ItopTestCase public function testListAllowedFoldersAbsPaths() { $oiTopComposer = new iTopComposer(); - $aDirs = $oiTopComposer->ListAllowedFoldersAbsPaths(); + $aDirs = $oiTopComposer->ListAllowedFilesAbsPaths(); $this->assertTrue(is_array($aDirs)); } @@ -109,7 +109,7 @@ class iTopComposerTest extends ItopTestCase { $oiTopComposer = new iTopComposer(); - $aDeniedButStillPresent = $oiTopComposer->ListDeniedButStillPresentFoldersAbsPaths(); + $aDeniedButStillPresent = $oiTopComposer->ListDeniedButStillPresentFilesAbsPaths(); $this->assertEmpty( $aDeniedButStillPresent, @@ -125,11 +125,11 @@ class iTopComposerTest extends ItopTestCase { $oDependenciesHandler = new iTopComposer(); $aAllowedAndDeniedDirs = array_merge( - $oDependenciesHandler->ListAllowedFoldersAbsPaths(), - $oDependenciesHandler->ListDeniedFoldersAbsPaths() + $oDependenciesHandler->ListAllowedFilesAbsPaths(), + $oDependenciesHandler->ListDeniedFilesAbsPaths() ); - $aExistingDirs = $oDependenciesHandler->ListAllFoldersAbsPaths(); + $aExistingDirs = $oDependenciesHandler->ListAllFilesAbsPaths(); $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); $aExtra = array_diff($aAllowedAndDeniedDirs, $aExistingDirs); diff --git a/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php b/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php index 01525f2be..db9971bfe 100644 --- a/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php +++ b/tests/php-unit-tests/unitary-tests/sources/Dependencies/NPM/iTopNPMTest.php @@ -40,11 +40,11 @@ class iTopNPMTest extends ItopTestCase { $oDependenciesHandler = new iTopNPM(); $aAllowedAndDeniedDirs = array_merge( - $oDependenciesHandler->ListAllowedFoldersAbsPaths(), - $oDependenciesHandler->ListDeniedFoldersAbsPaths() + $oDependenciesHandler->ListAllowedFilesAbsPaths(), + $oDependenciesHandler->ListDeniedFilesAbsPaths() ); - $aExistingDirs = $oDependenciesHandler->ListAllFoldersAbsPaths(); + $aExistingDirs = $oDependenciesHandler->ListAllFilesAbsPaths(); $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); $aExtra = array_diff($aAllowedAndDeniedDirs, $aExistingDirs);