diff --git a/src/Composer/Autoload/NamespaceAutoloader.php b/src/Composer/Autoload/NamespaceAutoloader.php index 3e66694b..955d8ab0 100644 --- a/src/Composer/Autoload/NamespaceAutoloader.php +++ b/src/Composer/Autoload/NamespaceAutoloader.php @@ -20,8 +20,6 @@ abstract class NamespaceAutoloader implements Autoloader * A package's composer.json config autoload key's value, where $key is `psr-1`|`psr-4`|`classmap`. * * @param $autoloadConfig - * - * @return void */ public function processConfig($autoloadConfig): void { diff --git a/src/Config/Classmap.php b/src/Config/Classmap.php index f6c1ab04..c53529ed 100644 --- a/src/Config/Classmap.php +++ b/src/Config/Classmap.php @@ -3,6 +3,7 @@ namespace CoenJacobs\Mozart\Config; use CoenJacobs\Mozart\Composer\Autoload\Autoloader; +use Exception; class Classmap implements Autoloader { @@ -27,10 +28,10 @@ public function processConfig($autoloadConfig): void } /** - * @throws \Exception + * @throws Exception */ public function getSearchNamespace(): string { - throw new \Exception('Classmap autoloaders do not contain a namespace and this method can not be used.'); + throw new Exception('Classmap autoloaders do not contain a namespace and this method can not be used.'); } } diff --git a/src/Config/Package.php b/src/Config/Package.php index 33fe9cb6..a34d85ce 100644 --- a/src/Config/Package.php +++ b/src/Config/Package.php @@ -4,7 +4,6 @@ use CoenJacobs\Mozart\Composer\Autoload\Autoloader; use CoenJacobs\Mozart\Config\Autoload; -use CoenJacobs\Mozart\Config\ConfigAccessor; use CoenJacobs\Mozart\Config\Extra; use CoenJacobs\Mozart\Config\ReadsConfig; use stdClass; @@ -13,9 +12,6 @@ class Package { use ReadsConfig; - /** @var string */ - public $path = ''; - /** @var Package[] */ public $requirePackages = []; @@ -27,23 +23,6 @@ class Package public ?Autoload $autoload = null; public ?Extra $extra = null; - /** - * Create a PHP object to represent a composer package. - * - * @param string $path The path to the vendor folder with the composer.json "name", i.e. the domain/package - * definition, which is the vendor subdir from where the package's composer.json should be read. - * @param stdClass $overrideAutoload Optional configuration to replace the package's own autoload definition with - * another which Mozart can use. - */ - public function __construct($path, $overrideAutoload = null) - { - $this->path = $path; - - if (isset($overrideAutoload)) { - $this->setAutoload($overrideAutoload); - } - } - public function setAutoload(stdClass $data): void { $autoload = new Autoload(); diff --git a/src/Console/Commands/Compose.php b/src/Console/Commands/Compose.php index cb1cb0cd..11ae219e 100644 --- a/src/Console/Commands/Compose.php +++ b/src/Console/Commands/Compose.php @@ -26,9 +26,6 @@ class Compose extends Command /** @var Mozart */ private $config; - /** - * @return void - */ protected function configure(): void { $this->setName('compose'); @@ -89,8 +86,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * @param Package[] $packages - * - * @return void */ protected function movePackages($packages): void { @@ -103,8 +98,6 @@ protected function movePackages($packages): void /** * @param Package[] $packages - * - * @return void */ protected function replacePackages($packages): void { @@ -115,8 +108,6 @@ protected function replacePackages($packages): void /** * Move all the packages over, one by one, starting on the deepest level of dependencies. - * - * @return void */ public function movePackage(Package $package): void { @@ -135,8 +126,6 @@ public function movePackage(Package $package): void /** * Replace contents of all the packages, one by one, starting on the deepest level of dependencies. - * - * @return void */ public function replacePackage(Package $package): void { @@ -198,13 +187,12 @@ private function findPackages(array $slugs): array * Get an array containing all the dependencies and dependencies * @param Package $package * @param Package[] $dependencies - * @return array + * @return Package[] */ private function getAllDependenciesOfPackage(Package $package, $dependencies = []): array { if ($this->config->isExcludedPackage($package)) { return $dependencies; - ; } if (empty($package->getDependencies())) { diff --git a/src/Mover.php b/src/Mover.php index 8c264276..f0d45184 100644 --- a/src/Mover.php +++ b/src/Mover.php @@ -49,8 +49,6 @@ public function __construct(string $workingDir, Mozart $config) * Create the required `dep_directory` and `classmap_directory` and delete targetDirs of packages about to be moved. * * @param Package[] $packages The packages that, in the next step, will be moved. - * - * @return void */ public function deleteTargetDirs($packages): void { @@ -103,10 +101,7 @@ public function deleteEmptyDirs(): void } } - /** - * @return void - */ - public function movePackage(Package $package) + public function movePackage(Package $package): void { if (in_array($package->getName(), $this->movedPackages)) { return; @@ -173,14 +168,7 @@ public function movePackage(Package $package) } } - /** - * @param Package $package - * @param Autoloader $autoloader - * @param SplFileInfo $file - * @param string $path - * @return string - */ - public function moveFile(Package $package, $autoloader, $file, $path = '') + public function moveFile(Package $package, Autoloader $autoloader, SplFileInfo $file, string $path = ''): string { if ($autoloader instanceof NamespaceAutoloader) { $namespacePath = $autoloader->getNamespacePath(); @@ -214,8 +202,6 @@ public function moveFile(Package $package, $autoloader, $file, $path = '') * Deletes all the packages that are moved from the /vendor/ directory to * prevent packages that are prefixed/namespaced from being used or * influencing the output of the code. They just need to be gone. - * - * @return void */ protected function deletePackageVendorDirectories(): void { diff --git a/src/Replace/BaseReplacer.php b/src/Replace/BaseReplacer.php index 442551e8..3298c5d6 100644 --- a/src/Replace/BaseReplacer.php +++ b/src/Replace/BaseReplacer.php @@ -11,9 +11,8 @@ abstract class BaseReplacer implements Replacer /** * @param Autoloader $autoloader - * @return void */ - public function setAutoloader(Autoloader $autoloader) + public function setAutoloader(Autoloader $autoloader): void { $this->autoloader = $autoloader; } diff --git a/src/Replace/ClassmapReplacer.php b/src/Replace/ClassmapReplacer.php index 2cc297ed..41323fa3 100644 --- a/src/Replace/ClassmapReplacer.php +++ b/src/Replace/ClassmapReplacer.php @@ -17,8 +17,6 @@ class ClassmapReplacer extends BaseReplacer /** * @param false|string $contents - * - * @return string */ public function replace($contents): string { @@ -29,16 +27,16 @@ public function replace($contents): string return preg_replace_callback( " / # Start the pattern - namespace\s+[a-zA-Z0-9_\x7f-\xff\\\\]+[;{\s\n]{1}.*?(?=namespace|$) - # Look for a preceeding namespace declaration, up until + namespace\s+[a-zA-Z0-9_\x7f-\xff\\\\]+[;{\s\n]{1}.*?(?=namespace|$) + # Look for a preceeding namespace declaration, up until # a potential second namespace declaration - | # if found, match that much before repeating the search + | # if found, match that much before repeating the search # on the remainder of the string (?:abstract\sclass|class|interface)\s+ # Look behind for class, abstract class, interface - ([a-zA-Z0-9_\x7f-\xff]+) # Match the word until the first + ([a-zA-Z0-9_\x7f-\xff]+) # Match the word until the first # non-classname-valid character \s? # Allow a space after - (?:{|extends|implements|\n) # Class declaration can be followed by {, extends, + (?:{|extends|implements|\n) # Class declaration can be followed by {, extends, # implements, or a new line /sx", // # dot matches newline, ignore whitespace in regex. function ($matches) use ($contents) { diff --git a/src/Replace/NamespaceReplacer.php b/src/Replace/NamespaceReplacer.php index 711ec086..680fb413 100644 --- a/src/Replace/NamespaceReplacer.php +++ b/src/Replace/NamespaceReplacer.php @@ -14,10 +14,8 @@ class NamespaceReplacer extends BaseReplacer /** * @param string $contents The text to make replacements in. * @param null $file Only used in ClassmapReplacer (for recording which files were changed). - * - * @return string The updated text. */ - public function replace($contents, $file = null) + public function replace($contents, $file = null): string { $searchNamespace = preg_quote($this->autoloader->getSearchNamespace(), '/'); $dependencyNamespace = preg_quote($this->dep_namespace, '/'); diff --git a/src/Replacer.php b/src/Replacer.php index ef19b73e..95d82590 100644 --- a/src/Replacer.php +++ b/src/Replacer.php @@ -52,12 +52,6 @@ public function replacePackage(Package $package): void } } - /** - * @param $targetFile - * @param $autoloader - * - * @return void - */ public function replaceInFile(string $targetFile, Autoloader $autoloader): void { $targetFile = str_replace($this->workingDir, '', $targetFile); @@ -89,13 +83,7 @@ public function replaceInFile(string $targetFile, Autoloader $autoloader): void $this->filesystem->write($targetFile, $contents); } - /** - * @param Package $package - * @param $autoloader - * - * @return void - */ - public function replacePackageByAutoloader(Package $package, Composer\Autoload\Autoloader $autoloader): void + public function replacePackageByAutoloader(Package $package, Autoloader $autoloader): void { if ($autoloader instanceof NamespaceAutoloader) { $source_path = $this->workingDir . $this->targetDir @@ -117,12 +105,6 @@ public function replacePackageByAutoloader(Package $package, Composer\Autoload\A } } - /** - * @param $autoloader - * @param $directory - * - * @return void - */ public function replaceParentClassesInDirectory(string $directory): void { if (count($this->replacedClasses)===0) { @@ -171,12 +153,6 @@ function ($matches) use ($replacement) { } } - /** - * @param $autoloader - * @param $directory - * - * @return void - */ public function replaceInDirectory(NamespaceAutoloader $autoloader, string $directory): void { $finder = new Finder(); @@ -195,11 +171,6 @@ public function replaceInDirectory(NamespaceAutoloader $autoloader, string $dire * Replace everything in parent package, based on the dependency package. * This is done to ensure that package A (which requires package B), is also * updated with the replacements being made in package B. - * - * @param Package $package - * @param Package $parent - * - * @return void */ public function replaceParentPackage(Package $package, Package $parent): void { diff --git a/tests/replacers/NamespaceReplacerTest.php b/tests/replacers/NamespaceReplacerTest.php index 7694c44d..b0651bc7 100644 --- a/tests/replacers/NamespaceReplacerTest.php +++ b/tests/replacers/NamespaceReplacerTest.php @@ -20,11 +20,6 @@ protected function setUp(): void /** * Creates a NamespaceReplacer, given a namespace and a prefix. - * - * @param string $namespace - * @param string $prefix - * - * @return Psr0 */ protected static function createReplacer(string $namespace, string $prefix = self::PREFIX) : NamespaceReplacer {