diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index 6a4914a7e..616976feb 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -40,9 +40,9 @@ class ArchiveCommand extends Command ->setDefinition(array( new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'), new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'), - new InputOption('format', 'f', InputOption::VALUE_OPTIONAL, 'Format of the resulting archive: tar or zip'), - new InputOption('dir', false, InputOption::VALUE_OPTIONAL, 'Write the archive to this directory'), - new InputOption('file', false, InputOption::VALUE_OPTIONAL, 'Write the archive with the given file name.' + new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'), + new InputOption('dir', false, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'), + new InputOption('file', false, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.' .' Note that the format will be appended.'), )) ->setHelp(<<getArgument('version'), $input->getOption('format'), $input->getOption('dir'), - $input->getOption("file") + $input->getOption('file') ); if (0 === $returnCode && $composer) { diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 4a9ce4a94..51669e278 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -108,7 +108,7 @@ class ArchiveManager if (empty($format)) { throw new \InvalidArgumentException('Format must be specified'); } - if(!is_null($fileName) && !is_string($fileName)) { + if (null !== $fileName && !is_string($fileName)) { throw new \InvalidArgumentException('fileName must be a string'); } @@ -127,7 +127,7 @@ class ArchiveManager } $filesystem = new Filesystem(); - if(null === $fileName) { + if (null !== $fileName) { $packageName = $this->getPackageFilename($package); } else { $packageName = $fileName; diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index 082d6e0ca..cc0490293 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -66,11 +66,11 @@ class ArchiveManagerTest extends ArchiverTest $package = $this->setupPackage(); - $fileName = "testArchiveName"; + $fileName = 'testArchiveName'; $this->manager->archive($package, 'tar', $this->targetDir, $fileName); - $target = $this->targetDir . "/" . $fileName . ".tar"; + $target = $this->targetDir . '/' . $fileName . '.tar'; $this->assertFileExists($target); @@ -80,8 +80,9 @@ class ArchiveManagerTest extends ArchiverTest unlink($target); } - public function testNonStringFileName() { - $this->setExpectedException("InvalidArgumentException"); + public function testNonStringFileName() + { + $this->setExpectedException('InvalidArgumentException'); $package = $this->setupPackage();