Skip to content

Commit

Permalink
Merge branch 'master' into mutator/mbstring
Browse files Browse the repository at this point in the history
  • Loading branch information
majkel89 committed Mar 26, 2019
2 parents 4b513a1 + 9fe8bf0 commit 1789a0b
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 31 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Expand Up @@ -63,6 +63,7 @@ return \PhpCsFixer\Config::create()
'style' => 'prefix',
'case' => 'snake',
],
'static_lambda' => true,
'strict_comparison' => true,
'yoda_style' => false,
])
Expand Down
2 changes: 1 addition & 1 deletion src/Config/InfectionConfig.php
Expand Up @@ -189,7 +189,7 @@ private function getExcludedDirsByPattern(string $originalExcludedDir)
$excludedDirs = array_merge(
$excludedDirs,
array_map(
function ($excludeDir) use ($srcDir) {
static function ($excludeDir) use ($srcDir) {
return ltrim(
substr_replace($excludeDir, '', 0, \strlen($srcDir)),
\DIRECTORY_SEPARATOR
Expand Down
4 changes: 2 additions & 2 deletions src/Config/ValueProvider/ExcludeDirsProvider.php
Expand Up @@ -103,7 +103,7 @@ public function get(InputInterface $input, OutputInterface $output, array $dirsI
$globDirs = array_filter(glob($sourceDirs[0] . '/*'), 'is_dir');

$autocompleteValues = array_map(
function (string $dir) use ($sourceDirs) {
static function (string $dir) use ($sourceDirs) {
return str_replace($sourceDirs[0] . '/', '', $dir);
},
$globDirs
Expand All @@ -125,7 +125,7 @@ function (string $dir) use ($sourceDirs) {

private function getValidator(Locator $locator)
{
return function ($answer) use ($locator) {
return static function ($answer) use ($locator) {
if (!$answer || strpos($answer, '*') !== false) {
return $answer;
}
Expand Down
Expand Up @@ -95,7 +95,7 @@ public function get(InputInterface $input, OutputInterface $output)

private function getValidator(): \Closure
{
return function ($answerPath) {
return static function ($answerPath) {
$answerPath = $answerPath ? trim($answerPath) : $answerPath;

if (!$answerPath || !file_exists($answerPath)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Config/ValueProvider/TimeoutProvider.php
Expand Up @@ -70,7 +70,7 @@ public function get(InputInterface $input, OutputInterface $output)
$questionText = $this->consoleHelper->getQuestion('Single test suite timeout in seconds', InfectionConfig::PROCESS_TIMEOUT_SECONDS);

$timeoutQuestion = new Question($questionText, InfectionConfig::PROCESS_TIMEOUT_SECONDS);
$timeoutQuestion->setValidator(function ($answer) {
$timeoutQuestion->setValidator(static function ($answer) {
if (!$answer || !is_numeric($answer) || (int) $answer <= 0) {
throw new \RuntimeException('Timeout should be an integer greater than 0');
}
Expand Down
24 changes: 12 additions & 12 deletions src/Console/InfectionContainer.php
Expand Up @@ -97,7 +97,7 @@ public function __construct(array $values = [])
return $this->getInfectionConfig()->getPhpUnitConfigDir();
};

$this['filesystem'] = function (): Filesystem {
$this['filesystem'] = static function (): Filesystem {
return new Filesystem();
};

Expand Down Expand Up @@ -153,13 +153,13 @@ public function __construct(array $values = [])
);
};

$this['differ'] = function (): Differ {
$this['differ'] = static function (): Differ {
return new Differ(
new BaseDiffer()
);
};

$this['dispatcher'] = function (): EventDispatcherInterface {
$this['dispatcher'] = static function (): EventDispatcherInterface {
return new EventDispatcher();
};

Expand All @@ -173,7 +173,7 @@ public function __construct(array $values = [])
);
};

$this['diff.colorizer'] = function (): DiffColorizer {
$this['diff.colorizer'] = static function (): DiffColorizer {
return new DiffColorizer();
};

Expand All @@ -183,11 +183,11 @@ public function __construct(array $values = [])
);
};

$this['version.parser'] = function (): VersionParser {
$this['version.parser'] = static function (): VersionParser {
return new VersionParser();
};

$this['lexer'] = function (): Lexer {
$this['lexer'] = static function (): Lexer {
return new Lexer\Emulative([
'usedAttributes' => [
'comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos', 'startFilePos', 'endFilePos',
Expand All @@ -199,7 +199,7 @@ public function __construct(array $values = [])
return (new ParserFactory())->create(ParserFactory::PREFER_PHP7, $this['lexer']);
};

$this['pretty.printer'] = function (): Standard {
$this['pretty.printer'] = static function (): Standard {
return new Standard();
};

Expand All @@ -209,19 +209,19 @@ public function __construct(array $values = [])
return (new MutatorsGenerator($mutatorConfig))->generate();
};

$this['metrics'] = function (): MetricsCalculator {
$this['metrics'] = static function (): MetricsCalculator {
return new MetricsCalculator();
};

$this['timer'] = function (): Timer {
$this['timer'] = static function (): Timer {
return new Timer();
};

$this['time.formatter'] = function (): TimeFormatter {
$this['time.formatter'] = static function (): TimeFormatter {
return new TimeFormatter();
};

$this['memory.formatter'] = function (): MemoryFormatter {
$this['memory.formatter'] = static function (): MemoryFormatter {
return new MemoryFormatter();
};

Expand Down Expand Up @@ -254,7 +254,7 @@ public function buildDynamicDependencies(InputInterface $input): void
: sprintf('%s/%s', getcwd(), $existingCoveragePath);
};

$this['coverage.checker'] = function () use ($input): CoverageRequirementChecker {
$this['coverage.checker'] = static function () use ($input): CoverageRequirementChecker {
return new CoverageRequirementChecker(
\strlen(trim($input->getOption('coverage'))) > 0,
$input->getOption('initial-tests-php-options')
Expand Down
2 changes: 1 addition & 1 deletion src/Differ/DiffColorizer.php
Expand Up @@ -42,7 +42,7 @@ class DiffColorizer
{
public function colorize(string $diff): string
{
$lines = array_map(function (string $line) {
$lines = array_map(static function (string $line) {
if (0 === strpos($line, '-')) {
return sprintf('<diff-del>%s</diff-del>', $line);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/FileLogger.php
Expand Up @@ -115,7 +115,7 @@ abstract protected function getLogLines(): array;
*/
final protected function sortProcesses(array &$processes): void
{
usort($processes, function (MutantProcessInterface $a, MutantProcessInterface $b): int {
usort($processes, static function (MutantProcessInterface $a, MutantProcessInterface $b): int {
if ($a->getOriginalFilePath() === $b->getOriginalFilePath()) {
return $a->getOriginalStartingLine() <=> $b->getOriginalStartingLine();
}
Expand Down
2 changes: 1 addition & 1 deletion src/TestFramework/Coverage/CodeCoverageData.php
Expand Up @@ -90,7 +90,7 @@ public function hasTests(string $filePath): bool

$coveredLineTestMethods = array_filter(
$coverageData[$filePath]['byLine'],
function ($testMethods) {
static function ($testMethods) {
return \count($testMethods) > 0;
}
);
Expand Down
Expand Up @@ -189,7 +189,7 @@ private function addTestSuiteWithFilteredTestFiles(array $coverageTests, \DOMDoc
// sort tests to run the fastest first
usort(
$uniqueCoverageTests,
function (array $a, array $b) {
static function (array $a, array $b) {
return $a['time'] <=> $b['time'];
}
);
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/ProjectCodeTest.php
Expand Up @@ -349,7 +349,7 @@ public function test_src_classes_do_not_expose_public_properties(string $classNa
* we're exteding from. E.g. we can't change Symfony\Component\Process\Process to not have
* a public propery it has.
*/
$properties = array_filter($properties, function (\ReflectionProperty $property) use ($className) {
$properties = array_filter($properties, static function (\ReflectionProperty $property) use ($className) {
return $property->class === $className;
});

Expand Down Expand Up @@ -489,7 +489,7 @@ static function (SplFileInfo $file) {
private function getConcreteSrcClasses(): array
{
return array_filter($this->getSrcClasses(),
function ($class) {
static function ($class) {
$rc = new \ReflectionClass($class);

return !$rc->isInterface() && !$rc->isAbstract() && !$rc->isTrait();
Expand Down
2 changes: 1 addition & 1 deletion tests/Config/ValueProvider/ExcludeDirsProviderTest.php
Expand Up @@ -134,7 +134,7 @@ public function test_passes_when_correct_dir_typed(): void
public function excludeDirsProvider()
{
return array_map(
function (string $excludedRootDir) {
static function (string $excludedRootDir) {
return [$excludedRootDir, [$excludedRootDir, 'src']];
},
ExcludeDirsProvider::EXCLUDED_ROOT_DIRS
Expand Down
8 changes: 4 additions & 4 deletions tests/Mutant/Generator/MutationsGeneratorTest.php
Expand Up @@ -229,19 +229,19 @@ private function createMutationGenerator(

$mutatorConfig = $mutatorConfig ?? new MutatorConfig([]);

$container[Plus::class] = function () use ($mutatorConfig) {
$container[Plus::class] = static function () use ($mutatorConfig) {
return new Plus($mutatorConfig);
};

$container[PublicVisibility::class] = function () use ($mutatorConfig) {
$container[PublicVisibility::class] = static function () use ($mutatorConfig) {
return new PublicVisibility($mutatorConfig);
};

$container[TrueValue::class] = function () use ($mutatorConfig) {
$container[TrueValue::class] = static function () use ($mutatorConfig) {
return new TrueValue($mutatorConfig);
};

$container[DecrementInteger::class] = function (Container $c) use ($mutatorConfig) {
$container[DecrementInteger::class] = static function (Container $c) use ($mutatorConfig) {
return new DecrementInteger($mutatorConfig);
};

Expand Down
2 changes: 1 addition & 1 deletion tests/Mutator/Util/MutatorProfileTest.php
Expand Up @@ -144,7 +144,7 @@ private function getMutatorProfileConstants(): array

return array_filter(
$reflectionClass->getConstants(),
function (string $constantName) use ($excludedConstants): bool {
static function (string $constantName) use ($excludedConstants): bool {
return !\in_array($constantName, $excludedConstants, true);
},
ARRAY_FILTER_USE_KEY
Expand Down
Expand Up @@ -65,7 +65,7 @@ public function test_it_reacts_on_application_execution_events(): void
{
$this->output->expects($this->once())
->method('writeln')
->with($this->callback(function ($parameter) {
->with($this->callback(static function ($parameter) {
return \is_array($parameter) && '' === $parameter[0] && 0 === strpos($parameter[1], 'Time:');
}));

Expand Down
2 changes: 1 addition & 1 deletion tests/Process/Runner/InitialTestsRunnerTest.php
Expand Up @@ -57,7 +57,7 @@ public function test_it_dispatches_events(): void

$process->expects($this->once())
->method('run')
->with($this->callback(function ($processCallback): bool {
->with($this->callback(static function ($processCallback): bool {
$processCallback(Process::OUT);

return true;
Expand Down

0 comments on commit 1789a0b

Please sign in to comment.