Skip to content

Commit

Permalink
Fixing build (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 12, 2021
1 parent 71a8fae commit ac302b5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_scoped_rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
tags:
- '*'

# to debug
pull_request: null

env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: "dev-main"
Expand Down
16 changes: 3 additions & 13 deletions build/config/config-downgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@
$phpStanStubLoader = new PHPStanStubLoader();
$phpStanStubLoader->loadStubs();

require_once __DIR__ . '/../../stubs-rector/PHPUnit/Framework/TestCase.php';

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();

$skip = array_merge(
DowngradeRectorConfig::DEPENDENCY_EXCLUDE_PATHS,
[
// should be skipped until phpstan is downgraded to avoid conflict like this https://github.com/rectorphp/rector-prefixed/runs/2422176105#step:4:4
DowngradeNullableTypeDeclarationRector::class
]
);
$parameters->set(Option::SKIP, $skip);

$parameters->set(Option::SKIP, DowngradeRectorConfig::DEPENDENCY_EXCLUDE_PATHS);
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . '/phpstan-for-downgrade.neon');

$containerConfigurator->import(DowngradeSetList::PHP_80);
Expand All @@ -44,10 +38,6 @@ final class DowngradeRectorConfig
// symfony test are parts of package
'*/Test/*',

// missing phpunit test case
'packages/Testing/PHPUnit/AbstractRectorTestCase.php',
'packages/Testing/PHPUnit/AbstractComposerRectorTestCase.php',

// only for dev
'packages/Testing/PhpConfigPrinter/*',

Expand Down
5 changes: 5 additions & 0 deletions build/downgrade-rector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ for directory in $directories; do
# --working-dir is needed, so "SKIP" parameter is applied in absolute path of nested directory
php -d memory_limit=-1 bin/rector process $directory --config build/config/config-downgrade.php --working-dir $BUILD_DIRECTORY --ansi
done


# CONFIRMED: give time to print all the files, before the next process takes over newly printed content
# avoids bugs like these half of files done, next half waiting https://github.com/rectorphp/rector-src/runs/2565478682
sleep 20
1 change: 0 additions & 1 deletion src/FileSystem/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Symfony\Component\Finder\SplFileInfo;
use Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver;
use Symplify\SmartFileSystem\FileSystemFilter;
use Symplify\SmartFileSystem\FileSystemGuard;
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
use Symplify\SmartFileSystem\SmartFileInfo;

Expand Down
38 changes: 19 additions & 19 deletions src/FileSystem/FilesystemTweaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function resolveDirectoriesWithFnmatch(array $directories): array
foreach ($directories as $directory) {
// is fnmatch for directories
if (Strings::contains($directory, '*')) {
$foundDirectories = $this->foundDirectoriesInGlob($directory);
$foundDirectories = $this->findDirectoriesInGlob($directory);
$absoluteDirectories = array_merge($absoluteDirectories, $foundDirectories);
} else {
// is classic directory
Expand All @@ -38,24 +38,6 @@ public function resolveDirectoriesWithFnmatch(array $directories): array
return $absoluteDirectories;
}

/**
* @return string[]
*/
private function foundDirectoriesInGlob(string $directory): array
{
$foundDirectories = [];

foreach ((array) glob($directory, GLOB_ONLYDIR) as $foundDirectory) {
if (! is_string($foundDirectory)) {
continue;
}

$foundDirectories[] = $foundDirectory;
}

return $foundDirectories;
}

/**
* This will turn paths like "src/Symfony/Component/*\/Tests" to existing directory paths
*
Expand All @@ -78,6 +60,24 @@ public function resolveWithFnmatch(array $paths): array
return $absolutePathsFound;
}

/**
* @return string[]
*/
private function findDirectoriesInGlob(string $directory): array
{
$foundDirectories = [];

foreach ((array) glob($directory, GLOB_ONLYDIR) as $foundDirectory) {
if (! is_string($foundDirectory)) {
continue;
}

$foundDirectories[] = $foundDirectory;
}

return $foundDirectories;
}

/**
* @return string[]
*/
Expand Down
13 changes: 13 additions & 0 deletions stubs-rector/PHPUnit/Framework/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace PHPUnit\Framework;

if (class_exists('PHPUnit\Framework\TestCase')) {
return;
}

abstract class TestCase
{
}

0 comments on commit ac302b5

Please sign in to comment.