Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"start": "sudo service docker start",
"install": "bash scripts/cloud-grind-setup.sh"
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@
"@test:unit:phpunit",
"@test:unit:pest"
]
}
},
"version": "8.x-dev"
}
106 changes: 8 additions & 98 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ parameters:
count: 1
path: src/Adapters/Phpunit/TestResult.php

-
message: '#^Property NunoMaduro\\Collision\\Adapters\\Phpunit\\TestResult\:\:\$context type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Adapters/Phpunit/TestResult.php

-
message: '#^Method NunoMaduro\\Collision\\ArgumentFormatter\:\:format\(\) has parameter \$arguments with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down Expand Up @@ -234,6 +228,12 @@ parameters:
count: 2
path: src/ConsoleColor.php

-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(string\|null\)\: bool given\.$#'
identifier: argument.type
count: 1
path: src/ConsoleColor.php

-
message: '#^Parameter \#2 \$styles of method NunoMaduro\\Collision\\ConsoleColor\:\:addTheme\(\) expects array\|string, mixed given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -264,54 +264,6 @@ parameters:
count: 1
path: src/Coverage.php

-
message: '#^Cannot access offset ''file'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Exceptions/TestException.php

-
message: '#^Cannot access offset ''line'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Exceptions/TestException.php

-
message: '#^Cannot access offset 0 on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: src/Exceptions/TestException.php

-
message: '#^Cannot cast mixed to int\.$#'
identifier: cast.int
count: 1
path: src/Exceptions/TestException.php

-
message: '#^Method NunoMaduro\\Collision\\Exceptions\\TestException\:\:getFile\(\) should return string but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Exceptions/TestException.php

-
message: '#^Method NunoMaduro\\Collision\\Exceptions\\TestException\:\:getTrace\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Exceptions/TestException.php

-
message: '#^Method NunoMaduro\\Collision\\Exceptions\\TestException\:\:shortenMessage\(\) has parameter \$matches with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Exceptions/TestException.php

-
message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#'
identifier: argument.type
count: 2
path: src/Exceptions/TestException.php

-
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
Expand All @@ -330,18 +282,6 @@ parameters:
count: 1
path: src/Highlighter.php

-
message: '#^Cannot access offset 0 on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Highlighter.php

-
message: '#^Cannot access offset 1 on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Highlighter.php

-
message: '#^Cannot use array destructuring on mixed\.$#'
identifier: offsetAccess.nonArray
Expand Down Expand Up @@ -372,18 +312,6 @@ parameters:
count: 1
path: src/Highlighter.php

-
message: '#^Method NunoMaduro\\Collision\\Highlighter\:\:splitToLines\(\) has parameter \$tokens with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Highlighter.php

-
message: '#^Method NunoMaduro\\Collision\\Highlighter\:\:splitToLines\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Highlighter.php

-
message: '#^Method NunoMaduro\\Collision\\Highlighter\:\:tokenize\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand All @@ -403,7 +331,7 @@ parameters:
path: src/Highlighter.php

-
message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#'
message: '#^Parameter \#1 \$tokens of method NunoMaduro\\Collision\\Highlighter\:\:splitToLines\(\) expects array\<int, array\{int\|string, string\}\>, array given\.$#'
identifier: argument.type
count: 1
path: src/Highlighter.php
Expand Down Expand Up @@ -493,25 +421,7 @@ parameters:
path: src/Writer.php

-
message: '#^Parameter \#1 \$haystack of function strpos expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Writer.php

-
message: '#^Parameter \#1 \$string of function rtrim expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Writer.php

-
message: '#^Parameter \#2 \$array of function array_map expects array, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Writer.php

-
message: '#^Parameter \#3 \$subject of function preg_replace expects array\<float\|int\|string\>\|string, mixed given\.$#'
message: '#^Parameter \#1 \$haystack of function str_contains expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Writer.php
Expand Down
35 changes: 35 additions & 0 deletions scripts/cloud-grind-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Cloud grind bootstrap: MySQL + Composer dependency-on-root fix.
set -euo pipefail

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"

wait_for_mysql() {
for _ in $(seq 1 45); do
if mysqladmin ping -h127.0.0.1 -uroot --silent 2>/dev/null; then
return 0
fi
sleep 2
done
echo "MySQL did not become ready on 127.0.0.1:3306" >&2
return 1
}

if ! mysqladmin ping -h127.0.0.1 -uroot --silent 2>/dev/null; then
if command -v docker >/dev/null 2>&1; then
docker rm -f collision-mysql 2>/dev/null || true
docker run -d --name collision-mysql \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=laravel \
-p 3306:3306 \
mysql:8.4
else
sudo service mysql start 2>/dev/null || sudo service mariadb start 2>/dev/null || true
fi
wait_for_mysql
fi

# Upstream CI pattern: satisfy pestphp/pest -> nunomaduro/collision from root package.
composer config version "8.x-dev"
composer update --prefer-stable --no-interaction --prefer-dist --no-progress --ansi
6 changes: 3 additions & 3 deletions src/Adapters/Laravel/CollisionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public function boot(): void
public function register(): void
{
if ($this->app->runningInConsole() && ! $this->app->runningUnitTests()) {
$this->app->bind(Provider::class, function (): \NunoMaduro\Collision\Provider {
$this->app->bind(Provider::class, function (): Provider {
if ($this->app->has(SolutionProviderRepository::class)) { // @phpstan-ignore-line
/** @var SolutionProviderRepository $solutionProviderRepository */
$solutionProviderRepository = $this->app->get(SolutionProviderRepository::class); // @phpstan-ignore-line

$solutionsRepository = new IgnitionSolutionsRepository($solutionProviderRepository);
} else {
$solutionsRepository = new NullSolutionsRepository();
$solutionsRepository = new NullSolutionsRepository;
}

$writer = new Writer($solutionsRepository);
Expand All @@ -57,7 +57,7 @@ public function register(): void
return new Provider(null, $handler);
});

/** @var \Illuminate\Contracts\Debug\ExceptionHandler $appExceptionHandler */
/** @var ExceptionHandlerContract $appExceptionHandler */
$appExceptionHandler = $this->app->make(ExceptionHandlerContract::class);

$this->app->singleton(
Expand Down
9 changes: 5 additions & 4 deletions src/Adapters/Laravel/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use NunoMaduro\Collision\Adapters\Laravel\Exceptions\RequirementsException;
use NunoMaduro\Collision\Coverage;
use ParaTest\Options;
use ParaTest\ParaTestCommand;
use RuntimeException;
use SebastianBergmann\Environment\Console;
use Symfony\Component\Console\Input\ArgvInput;
Expand Down Expand Up @@ -184,7 +185,7 @@ protected function commonArguments()
$arguments[] = '--colors=always';
} elseif ($this->option('no-ansi')) {
$arguments[] = '--colors=never';
} elseif ((new Console())->hasColorSupport()) {
} elseif ((new Console)->hasColorSupport()) {
$arguments[] = '--colors=always';
}

Expand Down Expand Up @@ -265,7 +266,7 @@ protected function paratestArguments($options)
"--runner=\Illuminate\Testing\ParallelRunner",
], $options);

$inputDefinition = new InputDefinition();
$inputDefinition = new InputDefinition;
Options::setInputDefinition($inputDefinition);
$input = new ArgvInput($options, $inputDefinition);

Expand Down Expand Up @@ -363,7 +364,7 @@ protected static function getEnvironmentVariables($path, $file)

$vars = [];

foreach ((new Parser())->parse($content) as $entry) {
foreach ((new Parser)->parse($content) as $entry) {
$vars[] = $entry->getName();
}

Expand All @@ -377,6 +378,6 @@ protected static function getEnvironmentVariables($path, $file)
*/
protected function isParallelDependenciesInstalled()
{
return class_exists(\ParaTest\ParaTestCommand::class);
return class_exists(ParaTestCommand::class);
}
}
7 changes: 4 additions & 3 deletions src/Adapters/Laravel/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
use Illuminate\Foundation\Exceptions\ReportableHandler;
use NunoMaduro\Collision\Provider;
use Symfony\Component\Console\Exception\ExceptionInterface as SymfonyConsoleExceptionInterface;
use Throwable;
Expand All @@ -18,7 +19,7 @@ final class ExceptionHandler implements ExceptionHandlerContract
/**
* Holds an instance of the container.
*
* @var \Illuminate\Contracts\Container\Container
* @var Container
*/
protected $container;

Expand Down Expand Up @@ -52,7 +53,7 @@ public function render($request, Throwable $e)
/**
* {@inheritdoc}
*/
public function renderForConsole(\Symfony\Component\Console\Output\OutputInterface $output, Throwable $e): void
public function renderForConsole($output, Throwable $e): void
{
if ($e instanceof SymfonyConsoleExceptionInterface) {
$this->appExceptionHandler->renderForConsole($output, $e);
Expand Down Expand Up @@ -83,7 +84,7 @@ public function shouldReport(Throwable $e)
/**
* Register a reportable callback.
*
* @return \Illuminate\Foundation\Exceptions\ReportableHandler
* @return ReportableHandler
*/
public function reportable(callable $reportUsing)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Adapters/Laravel/Exceptions/NotSupportedYetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
/**
* @internal
*/
final class NotSupportedYetException extends RuntimeException implements RenderlessEditor, RenderlessTrace
{
}
final class NotSupportedYetException extends RuntimeException implements RenderlessEditor, RenderlessTrace {}
4 changes: 1 addition & 3 deletions src/Adapters/Laravel/Exceptions/RequirementsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
/**
* @internal
*/
final class RequirementsException extends RuntimeException implements RenderlessEditor, RenderlessTrace
{
}
final class RequirementsException extends RuntimeException implements RenderlessEditor, RenderlessTrace {}
7 changes: 2 additions & 5 deletions src/Adapters/Laravel/IgnitionSolutionsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@
*/
final class IgnitionSolutionsRepository implements SolutionsRepository
{
// @phpstan-ignore-line

/**
* IgnitionSolutionsRepository constructor.
*/
public function __construct(
/**
* Holds an instance of ignition solutions provider repository.
*/
protected IgnitionSolutionProviderRepository|SolutionProviderRepository $solutionProviderRepository
) {
}
protected IgnitionSolutionProviderRepository|SolutionProviderRepository $solutionProviderRepository // @phpstan-ignore-line
) {}

/**
* {@inheritdoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/Phpunit/ConfigureIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class ConfigureIO
*/
public static function of(InputInterface $input, Output $output): void
{
$application = new Application();
$application = new Application;
$reflector = new ReflectionObject($application);
$method = $reflector->getMethod('configureIO');

Expand Down
Loading