Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/vendor
composer.lock
.idea

# phpunit 10+
/.phpunit.cache
2 changes: 1 addition & 1 deletion src/Console/Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static function readFromProcess(string $command): ?string

private static function getAnsiconWidth(): ?int
{
if (!is_string(\getenv('ANSICON'))) {
if (! is_string(\getenv('ANSICON'))) {
return null;
}

Expand Down
4 changes: 4 additions & 0 deletions src/ErrorFormatter/SymplifyErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ private function printSingleError(Error $error, OutputStyle $outputStyle): void
$itemMessage = sprintf(" - '%s'", $regexMessage);
$this->writeln($itemMessage);

if ($this->output?->isVerbose() && $error->getIdentifier() !== null && $error->canBeIgnored()) {
$this->writeln(' 🪪 ' . $error->getIdentifier());
}

$this->separator();
$outputStyle->newLine();
}
Expand Down
1 change: 0 additions & 1 deletion src/TypeResolver/ClassConstFetchReturnTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
----------------------------------------------------------------------------------------------------------------
/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2
----------------------------------------------------------------------------------------------------------------
- '#Bar
Bar2#'
----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------
/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4
----------------------------------------------------------------------------------------------------------------
- '#Foo#'
----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------
/data/folder/with space/and unicode 😃/project/foo.php:
----------------------------------------------------------------------------------------------------------------
- '#Bar
Bar2#'
----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------
/data/folder/with space/and unicode 😃/project/foo.php:1
----------------------------------------------------------------------------------------------------------------
- '#Foo<Bar>#'
----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------
/data/folder/with space/and unicode 😃/project/foo.php:5
----------------------------------------------------------------------------------------------------------------
- '#Bar
Bar2#'
----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------
/data/folder/with space/and unicode 😃/project/foo.php:5
----------------------------------------------------------------------------------------------------------------
- '#Foobar\\Buz#'
🪪 foobar.buz
----------------------------------------------------------------------------------------------------------------


[ERROR] Found 6 errors

51 changes: 51 additions & 0 deletions tests/ErrorFormatter/SymplifyErrorFormatterVerboseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace Symplify\PHPStanExtensions\Tests\ErrorFormatter;

use Iterator;
use PHPStan\Testing\ErrorFormatterTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Symplify\PHPStanExtensions\ErrorFormatter\SymplifyErrorFormatter;

/**
* @see https://github.com/phpstan/phpstan-src/blob/1.8.x/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php
*/
final class SymplifyErrorFormatterVerboseTest extends ErrorFormatterTestCase
{
#[DataProvider('provideData')]
public function testFormatErrors(
string $message,
int $expectedExitCode,
int $numFileErrors,
int $numGenericErrors,
string $expectedOutputFile,
): void {
$symplifyErrorFormatter = self::getContainer()->getByType(SymplifyErrorFormatter::class);

$analysisResult = $this->getAnalysisResult($numFileErrors, $numGenericErrors);
$output = $this->getOutput(verbose: true);
$resultCode = $symplifyErrorFormatter->formatErrors($analysisResult, $output);

$this->assertSame($expectedExitCode, $resultCode);

$this->assertStringMatchesFormatFile($expectedOutputFile, str_replace("\r", "\r\n",$this->getOutputContent(verbose: true)));
}

/**
* @return Iterator<mixed>
*/
public static function provideData(): Iterator
{
yield ['Some message', 1, 6, 0, __DIR__ . '/Fixture/expected_single_message_many_files_report_verbose.txt'];
}

/**
* @return string[]
*/
public static function getAdditionalConfigFiles(): array
{
return [__DIR__ . '/../../config/config.neon'];
}
}
Loading