Browse Source

Code grooming

Dariusz Ruminski 8 years ago
parent
commit
69f491767a

+ 6 - 0
src/Cache/FileHandler.php

@@ -63,6 +63,12 @@ final class FileHandler implements FileHandlerInterface
         $bytesWritten = @file_put_contents($this->file, $content, LOCK_EX);
 
         if (false === $bytesWritten) {
+            $error = error_get_last();
+
+            if (null !== $error) {
+                throw new IOException(sprintf('Failed to write file "%s", "%s".', $this->file, $error['message']), 0, null, $this->file);
+            }
+
             throw new IOException(sprintf('Failed to write file "%s".', $this->file), 0, null, $this->file);
         }
     }

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

@@ -377,8 +377,8 @@ EOF
         $reportSummary = ReportSummary::create()
             ->setChanged($changed)
             ->setAddAppliedFixers(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity())
-            ->setIsDecoratedOutput($output->isDecorated())
-            ->setIsDryRun($resolver->isDryRun())
+            ->setDecoratedOutput($output->isDecorated())
+            ->setDryRun($resolver->isDryRun())
             ->setMemory($fixEvent->getMemory())
             ->setTime($fixEvent->getDuration())
         ;

+ 0 - 2
src/Linter/Linter.php

@@ -12,8 +12,6 @@
 
 namespace PhpCsFixer\Linter;
 
-use Symfony\Component\Process\Process;
-
 /**
  * Handle PHP code linting process.
  *

+ 1 - 1
src/Linter/TokenizerLinter.php

@@ -23,7 +23,7 @@ use PhpCsFixer\Tokenizer\Tokens;
  */
 final class TokenizerLinter implements LinterInterface
 {
-    public function __construct($executable = null)
+    public function __construct()
     {
         if (false === defined('TOKEN_PARSE')) {
             throw new UnavailableLinterException('Cannot use tokenizer as linter.');

+ 2 - 2
src/Report/ReportSummary.php

@@ -150,7 +150,7 @@ final class ReportSummary
      *
      * @return ReportSummary
      */
-    public function setIsDecoratedOutput($isDecoratedOutput)
+    public function setDecoratedOutput($isDecoratedOutput)
     {
         $this->isDecoratedOutput = $isDecoratedOutput;
 
@@ -162,7 +162,7 @@ final class ReportSummary
      *
      * @return ReportSummary
      */
-    public function setIsDryRun($isDryRun)
+    public function setDryRun($isDryRun)
     {
         $this->isDryRun = $isDryRun;
 

+ 1 - 1
src/Runner/Runner.php

@@ -232,7 +232,7 @@ final class Runner
             if (!$this->isDryRun) {
                 if (false === @file_put_contents($file->getRealPath(), $new)) {
                     $error = error_get_last();
-                    if ($error) {
+                    if (null !== $error) {
                         throw new IOException(sprintf('Failed to write file "%s", "%s".', $file->getRealPath(), $error['message']), 0, null, $file->getRealPath());
                     }
 

+ 1 - 1
src/Tokenizer/Token.php

@@ -187,7 +187,7 @@ class Token
      */
     public function equalsAny(array $others, $caseSensitive = true)
     {
-        foreach ($others as $key => $other) {
+        foreach ($others as $other) {
             if ($this->equals($other, $caseSensitive)) {
                 return true;
             }

+ 3 - 3
tests/Cache/FileHandlerTest.php

@@ -100,9 +100,9 @@ final class FileHandlerTest extends \PHPUnit_Framework_TestCase
     {
         $file = __DIR__.'/non-existent-directory/.php_cs.cache';
 
-        $this->setExpectedException('Symfony\Component\Filesystem\Exception\IOException', sprintf(
-            'Failed to write file "%s".',
-            $file
+        $this->setExpectedExceptionRegExp('Symfony\Component\Filesystem\Exception\IOException', sprintf(
+            '#^Failed to write file "%s"(, ".*")?.#',
+            preg_quote($file)
         ));
 
         $cache = new Cache(new Signature(

+ 1 - 1
tests/Fixer/Basic/BracesFixerTest.php

@@ -1573,7 +1573,7 @@ if (1) {
     }',
             ),
             array(
-'<?php
+                '<?php
 use function some\a\{
      test1,
     test2

+ 4 - 4
tests/Fixer/ClassNotation/MethodSeparationFixerTest.php

@@ -272,7 +272,7 @@ class SomeClass
 }
 ');
         $cases[] = array(
-        '<?php
+            '<?php
 class SomeClass
 {
     // comment
@@ -675,7 +675,7 @@ function test2() {
 
         // do not touch well formatted traits
         $cases[] = array(
-    '<?php
+            '<?php
 trait OkTrait
 {
     function getReturnTypeOk()
@@ -692,7 +692,7 @@ trait OkTrait
         );
 
         $cases[] = array(
-    '<?php
+            '<?php
 trait ezcReflectionReturnInfo {
     public $x = 1;
 
@@ -721,7 +721,7 @@ trait ezcReflectionReturnInfo {
         );
 
         $cases[] = array(
-    '<?php
+            '<?php
 trait SomeReturnInfo {
     function getReturnType()
     {

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