Browse Source

Tweak and fix some more phpstan reports

Jordi Boggiano 6 years ago
parent
commit
799717f102

+ 4 - 2
phpstan/config.neon

@@ -29,9 +29,11 @@ parameters:
         - '~^Undefined variable: \$vendorDir$~'
         - '~^Undefined variable: \$baseDir$~'
 
+        # variable defined in eval
+        - '~^Undefined variable: \$res$~'
+
         # always checked whether the class exists
-        - '~^Instantiated class Symfony\\Component\\Console\\Terminal not found\.$~'
-        - '~^Class Symfony\\Component\\Console\\Input\\StreamableInputInterface not found\.$~'
+        - '~^Call to an undefined static method Symfony\\Component\\Process\\Process::fromShellCommandline\(\).$~'
 
         # parent call in test mocks
         - '~^Composer\\Test\\Mock\\HttpDownloaderMock::__construct\(\) does not call parent constructor from Composer\\Util\\HttpDownloader\.$~'

+ 1 - 1
tests/Composer/Test/DependencyResolver/SolverTest.php

@@ -40,7 +40,7 @@ class SolverTest extends TestCase
         $this->repo = new ArrayRepository;
         $this->repoInstalled = new InstalledArrayRepository;
 
-        $this->request = new Request($this->repoSet);
+        $this->request = new Request();
         $this->policy = new DefaultPolicy;
     }
 

+ 2 - 2
tests/Composer/Test/Downloader/PerforceDownloaderTest.php

@@ -129,7 +129,7 @@ class PerforceDownloaderTest extends TestCase
         $this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
         $this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref));
         $perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
-        $perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
+        $perforce = $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
         $perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
         $perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref));
         $perforce->expects($this->at(2))->method('p4Login');
@@ -152,7 +152,7 @@ class PerforceDownloaderTest extends TestCase
         $this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
         $this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref));
         $perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
-        $perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
+        $perforce = $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
         $perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
         $perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref));
         $perforce->expects($this->at(2))->method('p4Login');

+ 1 - 1
tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php

@@ -108,7 +108,7 @@ class PerforceDriverTest extends TestCase
     {
         $methods = array('p4login', 'checkStream', 'writeP4ClientSpec', 'connectClient', 'getComposerInformation', 'cleanupClientSpec');
 
-        return $this->getMockBuilder('Composer\Util\Perforce', $methods)->disableOriginalConstructor()->getMock();
+        return $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
     }
 
     public function testInitializeCapturesVariablesFromRepoConfig()

+ 9 - 6
tests/Composer/Test/Repository/VcsRepositoryTest.php

@@ -32,17 +32,18 @@ class VcsRepositoryTest extends TestCase
 
     protected function initialize()
     {
-        $oldCwd = getcwd();
-        self::$composerHome = $this->getUniqueTmpDirectory();
-        self::$gitRepo = $this->getUniqueTmpDirectory();
-
         $locator = new ExecutableFinder();
         if (!$locator->find('git')) {
             $this->skipped = 'This test needs a git binary in the PATH to be able to run';
 
             return;
         }
-        if (!@mkdir(self::$gitRepo) || !@chdir(self::$gitRepo)) {
+
+        $oldCwd = getcwd();
+        self::$composerHome = $this->getUniqueTmpDirectory();
+        self::$gitRepo = $this->getUniqueTmpDirectory();
+
+        if (!@chdir(self::$gitRepo)) {
             $this->skipped = 'Could not create and move into the temp git repo '.self::$gitRepo;
 
             return;
@@ -60,6 +61,7 @@ class VcsRepositoryTest extends TestCase
         $exec('git init');
         $exec('git config user.email composertest@example.org');
         $exec('git config user.name ComposerTest');
+        $exec('git config commit.gpgsign false');
         touch('foo');
         $exec('git add foo');
         $exec('git commit -m init');
@@ -150,7 +152,8 @@ class VcsRepositoryTest extends TestCase
                 'home' => self::$composerHome,
             ),
         ));
-        $repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO, $config);
+        $httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
+        $repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO, $config, $httpDownloader);
         $packages = $repo->getPackages();
         $dumper = new ArrayDumper();