diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php index 4742572ea..90db564fa 100644 --- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php @@ -302,6 +302,9 @@ class ArchivableFilesFinderTest extends TestCase )); } + /** + * @return string[] + */ protected function getArchivableFiles() { $files = array(); @@ -316,11 +319,17 @@ class ArchivableFilesFinderTest extends TestCase return $files; } + /** + * @param string $command + * + * @return string[] + */ protected function getArchivedFiles($command) { if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { $process = Process::fromShellCommandline($command, $this->sources); } else { + // @phpstan-ignore-next-line symfony/process 2.8 accepts a string but not 5.3 which is used only for PHPStan $process = new Process($command, $this->sources); } $process->run(); @@ -339,6 +348,11 @@ class ArchivableFilesFinderTest extends TestCase return $files; } + /** + * @param string[] $expectedFiles + * + * @return void + */ protected function assertArchivableFiles($expectedFiles) { $actualFiles = $this->getArchivableFiles(); diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index 26dfd9a75..c73091ad1 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -98,6 +98,12 @@ class ArchiveManagerTest extends ArchiverTest unlink($target); } + /** + * @param string $format + * @param string|null $fileName + * + * @return string + */ protected function getTargetName(CompletePackage $package, $format, $fileName = null) { if (null === $fileName) { @@ -111,6 +117,8 @@ class ArchiveManagerTest extends ArchiverTest /** * Create local git repository to run tests against! + * + * @return void */ protected function setupGitRepo() { diff --git a/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php b/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php index 650dac6ee..eae607a9b 100644 --- a/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php +++ b/tests/Composer/Test/Package/Archiver/GitExcludeFilterTest.php @@ -18,7 +18,10 @@ use Composer\Test\TestCase; class GitExcludeFilterTest extends TestCase { /** - * @dataProvider patterns + * @dataProvider providePatterns + * + * @param string $ignore + * @param mixed[] $expected */ public function testPatternEscape($ignore, $expected) { @@ -27,7 +30,7 @@ class GitExcludeFilterTest extends TestCase $this->assertEquals($expected, $filter->parseGitIgnoreLine($ignore)); } - public function patterns() + public function providePatterns() { return array( array('app/config/parameters.yml', array('{(?=[^\.])app/(?=[^\.])config/(?=[^\.])parameters\.yml(?=$|/)}', false, false)), diff --git a/tests/Composer/Test/Package/Archiver/HgExcludeFilterTest.php b/tests/Composer/Test/Package/Archiver/HgExcludeFilterTest.php index ffcd71b1d..21a0260da 100644 --- a/tests/Composer/Test/Package/Archiver/HgExcludeFilterTest.php +++ b/tests/Composer/Test/Package/Archiver/HgExcludeFilterTest.php @@ -18,7 +18,10 @@ use Composer\Test\TestCase; class HgExcludeFilterTest extends TestCase { /** - * @dataProvider patterns + * @dataProvider providePatterns + * + * @param string $ignore + * @param mixed[] $expected */ public function testPatternEscape($ignore, $expected) { @@ -27,7 +30,7 @@ class HgExcludeFilterTest extends TestCase $this->assertEquals($expected, $filter->patternFromRegex($ignore)); } - public function patterns() + public function providePatterns() { return array( array('.#', array('#.\\##', false, true)), diff --git a/tests/Composer/Test/Package/Archiver/PharArchiverTest.php b/tests/Composer/Test/Package/Archiver/PharArchiverTest.php index 668e101e3..82ed226f3 100644 --- a/tests/Composer/Test/Package/Archiver/PharArchiverTest.php +++ b/tests/Composer/Test/Package/Archiver/PharArchiverTest.php @@ -48,6 +48,8 @@ class PharArchiverTest extends ArchiverTest /** * Create a local dummy repository to run tests against! + * + * @return void */ protected function setupDummyRepo() { @@ -63,13 +65,20 @@ class PharArchiverTest extends ArchiverTest chdir($currentWorkDir); } + /** + * @param string $path + * @param string $content + * @param string $currentWorkDir + * + * @return void + */ protected function writeFile($path, $content, $currentWorkDir) { if (!file_exists(dirname($path))) { mkdir(dirname($path), 0777, true); } - $result = file_put_contents($path, 'a'); + $result = file_put_contents($path, $content); if (false === $result) { chdir($currentWorkDir); throw new \RuntimeException('Could not save file.'); diff --git a/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php b/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php index a51ec2a2d..616768c01 100644 --- a/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php +++ b/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php @@ -39,6 +39,9 @@ class ZipArchiverTest extends ArchiverTest ); } + /** + * @param array $files + */ public function testZipArchive(array $files = array()) { if (!class_exists('ZipArchive')) { @@ -79,7 +82,10 @@ class ZipArchiverTest extends ArchiverTest /** * Create a local dummy repository to run tests against! - * @param array $files + * + * @param array $files + * + * @return void */ protected function setupDummyRepo(array &$files) { @@ -95,6 +101,13 @@ class ZipArchiverTest extends ArchiverTest chdir($currentWorkDir); } + /** + * @param string $path + * @param string $content + * @param string $currentWorkDir + * + * @return void + */ protected function writeFile($path, $content, $currentWorkDir) { if (!file_exists(dirname($path))) { diff --git a/tests/Composer/Test/Package/BasePackageTest.php b/tests/Composer/Test/Package/BasePackageTest.php index 2bbf42593..522722a47 100644 --- a/tests/Composer/Test/Package/BasePackageTest.php +++ b/tests/Composer/Test/Package/BasePackageTest.php @@ -44,14 +44,17 @@ class BasePackageTest extends TestCase } /** - * @dataProvider formattedVersions + * @dataProvider provideFormattedVersions + * + * @param bool $truncate + * @param string $expected */ public function testFormatVersionForDevPackage(BasePackage $package, $truncate, $expected) { $this->assertSame($expected, $package->getFullPrettyVersion($truncate)); } - public function formattedVersions() + public function provideFormattedVersions() { $data = array( array( diff --git a/tests/Composer/Test/Package/CompletePackageTest.php b/tests/Composer/Test/Package/CompletePackageTest.php index fe1a783e8..848315a1d 100644 --- a/tests/Composer/Test/Package/CompletePackageTest.php +++ b/tests/Composer/Test/Package/CompletePackageTest.php @@ -35,8 +35,10 @@ class CompletePackageTest extends TestCase } /** - * Tests memory package naming semantics * @dataProvider providerVersioningSchemes + * + * @param string $name + * @param string $version */ public function testPackageHasExpectedNamingSemantics($name, $version) { @@ -47,8 +49,10 @@ class CompletePackageTest extends TestCase } /** - * Tests memory package versioning semantics * @dataProvider providerVersioningSchemes + * + * @param string $name + * @param string $version */ public function testPackageHasExpectedVersioningSemantics($name, $version) { @@ -60,8 +64,10 @@ class CompletePackageTest extends TestCase } /** - * Tests memory package marshalling/serialization semantics * @dataProvider providerVersioningSchemes + * + * @param string $name + * @param string $version */ public function testPackageHasExpectedMarshallingSemantics($name, $version) { diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php index 39f1b0a0b..c4ace9e82 100644 --- a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -88,7 +88,12 @@ class ArrayDumperTest extends TestCase } /** - * @dataProvider getKeys + * @dataProvider provideKeys + * + * @param string $key + * @param mixed $value + * @param string $method + * @param mixed $expectedValue */ public function testKeys($key, $value, $method = null, $expectedValue = null) { @@ -106,7 +111,7 @@ class ArrayDumperTest extends TestCase $this->assertSame($expectedValue ?: $value, $config[$key]); } - public function getKeys() + public function provideKeys() { return array( array( @@ -239,6 +244,12 @@ class ArrayDumperTest extends TestCase ); } + /** + * @param string $method + * @param mixed $value + * + * @return self + */ private function packageExpects($method, $value) { $this->package diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 285dd13e4..829fc633e 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -134,6 +134,11 @@ class ArrayLoaderTest extends TestCase return array(array($validConfig)); } + /** + * @param array $config + * + * @return array + */ protected function fixConfigWhenLoadConfigIsFalse($config) { $expectedConfig = $config; @@ -147,6 +152,8 @@ class ArrayLoaderTest extends TestCase * allows require-dev libraries to have transport options included. * * @dataProvider parseDumpProvider + * + * @param array $config */ public function testParseDumpDefaultLoadConfig($config) { @@ -158,6 +165,8 @@ class ArrayLoaderTest extends TestCase /** * @dataProvider parseDumpProvider + * + * @param array $config */ public function testParseDumpTrueLoadConfig($config) { @@ -170,6 +179,8 @@ class ArrayLoaderTest extends TestCase /** * @dataProvider parseDumpProvider + * + * @param array $config */ public function testParseDumpFalseLoadConfig($config) { @@ -262,7 +273,7 @@ class ArrayLoaderTest extends TestCase $this->assertFalse($package->isAbandoned()); } - public function pluginApiVersions() + public function providePluginApiVersions() { return array( array('1.0'), @@ -284,7 +295,9 @@ class ArrayLoaderTest extends TestCase } /** - * @dataProvider pluginApiVersions + * @dataProvider providePluginApiVersions + * + * @param string $apiVersion */ public function testPluginApiVersionAreKeptAsDeclared($apiVersion) { diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index 25e74145e..d523debc0 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -15,6 +15,7 @@ namespace Composer\Test\Package\Loader; use Composer\Config; use Composer\Package\Loader\RootPackageLoader; use Composer\Package\BasePackage; +use Composer\Package\RootAliasPackage; use Composer\Package\RootPackage; use Composer\Package\Version\VersionGuesser; use Composer\Semver\VersionParser; @@ -24,6 +25,11 @@ use Prophecy\Argument; class RootPackageLoaderTest extends TestCase { + /** + * @param array $data + * + * @return RootPackage|RootAliasPackage + */ protected function loadPackage($data) { $manager = $this->getMockBuilder('Composer\\Repository\\RepositoryManager') diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index 873d90376..103c34551 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -20,6 +20,8 @@ class ValidatingArrayLoaderTest extends TestCase { /** * @dataProvider successProvider + * + * @param array $config */ public function testLoadSuccess($config) { @@ -206,6 +208,9 @@ class ValidatingArrayLoaderTest extends TestCase /** * @dataProvider errorProvider + * + * @param array $config + * @param string[] $expectedErrors */ public function testLoadFailureThrowsException($config, $expectedErrors) { @@ -224,6 +229,9 @@ class ValidatingArrayLoaderTest extends TestCase /** * @dataProvider warningProvider + * + * @param array $config + * @param string[] $expectedWarnings */ public function testLoadWarnings($config, $expectedWarnings) { @@ -239,6 +247,10 @@ class ValidatingArrayLoaderTest extends TestCase /** * @dataProvider warningProvider + * + * @param array $config + * @param string[] $expectedWarnings + * @param bool $mustCheck */ public function testLoadSkipsWarningDataWhenIgnoringErrors($config, $expectedWarnings, $mustCheck = true) { diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index 29f3e7c2a..bf8957bbe 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -255,6 +255,9 @@ class LockerTest extends TestCase $this->assertFalse($locker->isFresh()); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Json\JsonFile + */ private function createJsonFileMock() { return $this->getMockBuilder('Composer\Json\JsonFile') @@ -262,6 +265,9 @@ class LockerTest extends TestCase ->getMock(); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Installer\InstallationManager + */ private function createInstallationManagerMock() { $mock = $this->getMockBuilder('Composer\Installer\InstallationManager') @@ -271,12 +277,20 @@ class LockerTest extends TestCase return $mock; } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Package\PackageInterface + */ private function createPackageMock() { return $this->getMockBuilder('Composer\Package\PackageInterface') ->getMock(); } + /** + * @param array $customData + * + * @return false|string + */ private function getJsonContent(array $customData = array()) { $data = array_merge(array( diff --git a/tests/Composer/Test/Package/RootAliasPackageTest.php b/tests/Composer/Test/Package/RootAliasPackageTest.php index 00ca7fa05..10f9a179c 100644 --- a/tests/Composer/Test/Package/RootAliasPackageTest.php +++ b/tests/Composer/Test/Package/RootAliasPackageTest.php @@ -80,6 +80,9 @@ class RootAliasPackageTest extends TestCase $this->assertNotEmpty($alias->getReplaces()); } + /** + * @return \Prophecy\Prophecy\ObjectProphecy + */ protected function getMockRootPackageInterface() { $root = $this->prophesize('Composer\\Package\\RootPackage'); diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index 824305a5e..8277a0c0e 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -18,7 +18,10 @@ use Composer\Test\TestCase; class VersionParserTest extends TestCase { /** - * @dataProvider getParseNameVersionPairsData + * @dataProvider provideParseNameVersionPairsData + * + * @param string[] $pairs + * @param array> $result */ public function testParseNameVersionPairs($pairs, $result) { @@ -27,7 +30,7 @@ class VersionParserTest extends TestCase $this->assertSame($result, $versionParser->parseNameVersionPairs($pairs)); } - public function getParseNameVersionPairsData() + public function provideParseNameVersionPairsData() { return array( array(array('php:^7.0'), array(array('name' => 'php', 'version' => '^7.0'))), @@ -39,14 +42,18 @@ class VersionParserTest extends TestCase } /** - * @dataProvider getIsUpgradeTests + * @dataProvider provideIsUpgradeTests + * + * @param string $from + * @param string $to + * @param bool $expected */ public function testIsUpgrade($from, $to, $expected) { $this->assertSame($expected, VersionParser::isUpgrade($from, $to)); } - public function getIsUpgradeTests() + public function provideIsUpgradeTests() { return array( array('0.9.0.0', '1.0.0.0', true), diff --git a/tests/Composer/Test/Package/Version/VersionSelectorTest.php b/tests/Composer/Test/Package/Version/VersionSelectorTest.php index e02470e6b..863f74243 100644 --- a/tests/Composer/Test/Package/Version/VersionSelectorTest.php +++ b/tests/Composer/Test/Package/Version/VersionSelectorTest.php @@ -293,7 +293,12 @@ class VersionSelectorTest extends TestCase } /** - * @dataProvider getRecommendedRequireVersionPackages + * @dataProvider provideRecommendedRequireVersionPackages + * + * @param string $prettyVersion + * @param string $expectedVersion + * @param string|null $branchAlias + * @param string $packageName */ public function testFindRecommendedRequireVersion($prettyVersion, $expectedVersion, $branchAlias = null, $packageName = 'foo/bar') { @@ -313,7 +318,7 @@ class VersionSelectorTest extends TestCase $this->assertSame($expectedVersion, $recommended); } - public function getRecommendedRequireVersionPackages() + public function provideRecommendedRequireVersionPackages() { return array( // real version, expected recommendation, [branch-alias], [pkg name] @@ -353,6 +358,11 @@ class VersionSelectorTest extends TestCase ); } + /** + * @param string $version + * + * @return Package + */ private function createPackage($version) { $parser = new VersionParser(); @@ -360,6 +370,9 @@ class VersionSelectorTest extends TestCase return new Package('foo', $parser->normalize($version), $version); } + /** + * @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Repository\RepositorySet + */ private function createMockRepositorySet() { return $this->getMockBuilder('Composer\Repository\RepositorySet')