Browse Source

Update PHPUnitGoodPractices\Traits

Dariusz Ruminski 7 years ago
parent
commit
11478ab745

+ 1 - 0
.composer-require-checker.json

@@ -6,6 +6,7 @@
         "PHPUnitGoodPractices\\Traits\\ExpectOverSetExceptionTrait",
         "PHPUnitGoodPractices\\Traits\\IdentityOverEqualityTrait",
         "PHPUnitGoodPractices\\Traits\\ProphecyOverMockObjectTrait",
+        "PHPUnitGoodPractices\\Traits\\ProphesizeOnlyInterfaceTrait",
         "Prophecy\\Argument",
 
         "null", "true", "false",

+ 1 - 1
composer.json

@@ -41,7 +41,7 @@
         "php-coveralls/php-coveralls": "^2.0",
         "php-cs-fixer/accessible-object": "^1.0",
         "phpunit/phpunit": "^5.7.23 || ^6.4.3",
-        "phpunitgoodpractices/traits": "^1.0",
+        "phpunitgoodpractices/traits": "^1.3.1",
         "symfony/phpunit-bridge": "^3.2.2 || ^4.0"
     },
     "suggest": {

+ 2 - 1
src/Console/Command/FixCommand.php

@@ -30,6 +30,7 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Terminal;
 use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\Stopwatch\Stopwatch;
 
 /**
@@ -43,7 +44,7 @@ final class FixCommand extends Command
     const COMMAND_NAME = 'fix';
 
     /**
-     * @var EventDispatcher
+     * @var EventDispatcherInterface
      */
     private $eventDispatcher;
 

+ 7 - 7
src/Console/Output/ProcessOutput.php

@@ -14,7 +14,7 @@ namespace PhpCsFixer\Console\Output;
 
 use PhpCsFixer\FixerFileProcessedEvent;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 
 /**
  * Output writer to show the process of a FixCommand.
@@ -39,7 +39,7 @@ final class ProcessOutput implements ProcessOutputInterface
     ];
 
     /**
-     * @var EventDispatcher
+     * @var EventDispatcherInterface
      */
     private $eventDispatcher;
 
@@ -66,12 +66,12 @@ final class ProcessOutput implements ProcessOutputInterface
     /**
      * @TODO 3.0 make all parameters mandatory (`null` not allowed)
      *
-     * @param OutputInterface $output
-     * @param EventDispatcher $dispatcher
-     * @param null|int        $width
-     * @param null|int        $nbFiles
+     * @param OutputInterface          $output
+     * @param EventDispatcherInterface $dispatcher
+     * @param null|int                 $width
+     * @param null|int                 $nbFiles
      */
-    public function __construct(OutputInterface $output, EventDispatcher $dispatcher, $width, $nbFiles)
+    public function __construct(OutputInterface $output, EventDispatcherInterface $dispatcher, $width, $nbFiles)
     {
         $this->output = $output;
         $this->eventDispatcher = $dispatcher;

+ 3 - 3
src/Runner/FileFilterIterator.php

@@ -16,7 +16,7 @@ use PhpCsFixer\Cache\CacheManagerInterface;
 use PhpCsFixer\FileReader;
 use PhpCsFixer\FixerFileProcessedEvent;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 
 /**
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
@@ -26,7 +26,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
 final class FileFilterIterator extends \FilterIterator
 {
     /**
-     * @var null|EventDispatcher
+     * @var null|EventDispatcherInterface
      */
     private $eventDispatcher;
 
@@ -42,7 +42,7 @@ final class FileFilterIterator extends \FilterIterator
 
     public function __construct(
         \Iterator $iterator,
-        EventDispatcher $eventDispatcher = null,
+        EventDispatcherInterface $eventDispatcher = null,
         CacheManagerInterface $cacheManager
     ) {
         parent::__construct($iterator);

+ 3 - 3
src/Runner/Runner.php

@@ -27,7 +27,7 @@ use PhpCsFixer\Linter\LintingException;
 use PhpCsFixer\Linter\LintingResultInterface;
 use PhpCsFixer\Tokenizer\Tokens;
 use Symfony\Component\EventDispatcher\Event;
-use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\Filesystem\Exception\IOException;
 
 /**
@@ -46,7 +46,7 @@ final class Runner
     private $directory;
 
     /**
-     * @var null|EventDispatcher
+     * @var null|EventDispatcherInterface
      */
     private $eventDispatcher;
 
@@ -89,7 +89,7 @@ final class Runner
         $finder,
         array $fixers,
         DifferInterface $differ,
-        EventDispatcher $eventDispatcher = null,
+        EventDispatcherInterface $eventDispatcher = null,
         ErrorsManager $errorsManager,
         LinterInterface $linter,
         $isDryRun,

+ 1 - 1
tests/ConfigurationException/InvalidForEnvFixerConfigurationExceptionTest.php

@@ -35,7 +35,7 @@ final class InvalidForEnvFixerConfigurationExceptionTest extends TestCase
             $message
         );
 
-        $this->assertInstanceOf('PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException', $exception);
+        $this->assertInstanceOf(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class, $exception);
         $this->assertSame(sprintf('[%s] %s', $fixerName, $message), $exception->getMessage());
         $this->assertSame(FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_FIXER_CONFIG, $exception->getCode());
         $this->assertSame($fixerName, $exception->getFixerName());

+ 1 - 1
tests/Console/Command/FixCommandTest.php

@@ -41,7 +41,7 @@ final class FixCommandTest extends TestCase
     public function testEmptyRulesValue()
     {
         $this->expectException(
-            'PhpCsFixer\ConfigurationException\InvalidConfigurationException'
+            \PhpCsFixer\ConfigurationException\InvalidConfigurationException::class
         );
         $this->expectExceptionMessageRegExp(
             '#^Empty rules value is not allowed\.$#'

+ 2 - 2
tests/Console/Output/ProcessOutputTest.php

@@ -35,7 +35,7 @@ final class ProcessOutputTest extends TestCase
     {
         $processOutput = new ProcessOutput(
             $output = new BufferedOutput(),
-            $this->prophesize(\Symfony\Component\EventDispatcher\EventDispatcher::class)->reveal(),
+            $this->prophesize(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->reveal(),
             $width,
             null
         );
@@ -188,7 +188,7 @@ final class ProcessOutputTest extends TestCase
 
         $processOutput = new ProcessOutput(
             $output = new BufferedOutput(),
-            $this->prophesize(\Symfony\Component\EventDispatcher\EventDispatcher::class)->reveal(),
+            $this->prophesize(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->reveal(),
             $width,
             $nbFiles
         );

+ 2 - 1
tests/Fixer/Basic/Psr0FixerTest.php

@@ -26,7 +26,8 @@ final class Psr0FixerTest extends AbstractFixerTestCase
     {
         $this->fixer->configure(['dir' => __DIR__]);
 
-        $fileProphecy = $this->prophesize(\SplFileInfo::class);
+        $fileProphecy = $this->prophesize();
+        $fileProphecy->willExtend(\SplFileInfo::class);
         $fileProphecy->getBasename()->willReturn('Bar.php');
         $fileProphecy->getRealPath()->willReturn(__DIR__.'/Psr0/Foo/Bar.php');
         $file = $fileProphecy->reveal();

Some files were not shown because too many files changed in this diff