瀏覽代碼

PHPStan fixes

Jordi Boggiano 5 年之前
父節點
當前提交
589abb06a3

+ 6 - 0
phpstan/config.neon

@@ -17,9 +17,15 @@ parameters:
         # variable defined in eval
         - '~^Undefined variable: \$res$~'
 
+        # erroneous detection of missing const, see https://github.com/phpstan/phpstan/issues/2960
+        - '~^Access to undefined constant ZipArchive::OPSYS_UNIX.$~'
+
         # we don't have different constructors for parent/child
         - '~^Unsafe usage of new static\(\)\.$~'
 
+        # BC with older PHPUnit
+        - '~^Call to an undefined static method PHPUnit\\Framework\\TestCase::setExpectedException\(\)\.$~'
+
         # hhvm should have support for $this in closures
         -
             count: 1

+ 3 - 3
src/Composer/Downloader/VcsDownloader.php

@@ -68,7 +68,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
                 return $this->doDownload($package, $path, $url, $prevPackage);
             } catch (\Exception $e) {
                 // rethrow phpunit exceptions to avoid hard to debug bug failures
-                if ($e instanceof \PHPUnit_Framework_Exception) {
+                if ($e instanceof \PHPUnit\Framework\Exception) {
                     throw $e;
                 }
                 if ($this->io->isDebug()) {
@@ -126,7 +126,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
                 break;
             } catch (\Exception $e) {
                 // rethrow phpunit exceptions to avoid hard to debug bug failures
-                if ($e instanceof \PHPUnit_Framework_Exception) {
+                if ($e instanceof \PHPUnit\Framework\Exception) {
                     throw $e;
                 }
                 if ($this->io->isDebug()) {
@@ -179,7 +179,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
                 break;
             } catch (\Exception $exception) {
                 // rethrow phpunit exceptions to avoid hard to debug bug failures
-                if ($exception instanceof \PHPUnit_Framework_Exception) {
+                if ($exception instanceof \PHPUnit\Framework\Exception) {
                     throw $exception;
                 }
                 if ($this->io->isDebug()) {

+ 1 - 1
tests/Composer/Test/Console/HtmlOutputFormatterTest.php

@@ -24,7 +24,7 @@ class HtmlOutputFormatterTest extends TestCase
             'warning' => new OutputFormatterStyle('black', 'yellow'),
         ));
 
-        return $this->assertEquals(
+        $this->assertEquals(
             'text <span style="color:green;">green</span> <span style="color:yellow;">yellow</span> <span style="color:black;background-color:yellow;">black w/ yello bg</span>',
             $formatter->format('text <info>green</info> <comment>yellow</comment> <warning>black w/ yello bg</warning>')
         );

+ 1 - 1
tests/Composer/Test/Repository/Pear/PackageDependencyParserTest.php

@@ -53,7 +53,7 @@ class PackageDependencyParserTest extends TestCase
     {
         $data = json_decode(file_get_contents(__DIR__.'/Fixtures/DependencyParserTestData.json'), true);
         if (0 !== json_last_error()) {
-            throw new \PHPUnit_Framework_Exception('Invalid json file.');
+            throw new \PHPUnit\Framework\Exception('Invalid json file.');
         }
 
         return $data;