@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | use JsonMapper\JsonMapperFactory; |
| 11 | 11 | use JsonMapper\Middleware\Rename\Rename; |
| 12 | 12 | |
| 13 | -class StraussConfig |
|
| 14 | -{ |
|
| 13 | +class StraussConfig { |
|
| 15 | 14 | /** |
| 16 | 15 | * The output directory. |
| 17 | 16 | * |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | * |
| 92 | 91 | * @throws Exception |
| 93 | 92 | */ |
| 94 | - public function __construct(Composer $composer) |
|
| 95 | - { |
|
| 93 | + public function __construct(Composer $composer) { |
|
| 96 | 94 | |
| 97 | 95 | $configExtraSettings = null; |
| 98 | 96 | |
@@ -378,8 +376,7 @@ discard block |
||
| 378 | 376 | /** |
| 379 | 377 | * Backwards compatability with Mozart. |
| 380 | 378 | */ |
| 381 | - public function setExcludePackages(array $excludePackages) |
|
| 382 | - { |
|
| 379 | + public function setExcludePackages(array $excludePackages) { |
|
| 383 | 380 | |
| 384 | 381 | if (! isset($this->excludeFromPrefix)) { |
| 385 | 382 | $this->excludeFromPrefix = array(); |
@@ -11,8 +11,7 @@ discard block |
||
| 11 | 11 | use Composer\IO\NullIO; |
| 12 | 12 | use stdClass; |
| 13 | 13 | |
| 14 | -class ComposerPackage |
|
| 15 | -{ |
|
| 14 | +class ComposerPackage { |
|
| 16 | 15 | /** |
| 17 | 16 | * The composer.json file as parsed by Composer. |
| 18 | 17 | * |
@@ -58,8 +57,7 @@ discard block |
||
| 58 | 57 | * @param array $overrideAutoload Optional configuration to replace the package's own autoload definition with |
| 59 | 58 | * another which Strauss can use. |
| 60 | 59 | */ |
| 61 | - public function __construct(string $absolutePath, array $overrideAutoload = null) |
|
| 62 | - { |
|
| 60 | + public function __construct(string $absolutePath, array $overrideAutoload = null) { |
|
| 63 | 61 | |
| 64 | 62 | if (is_dir($absolutePath)) { |
| 65 | 63 | $absolutePath = rtrim($absolutePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'composer.json'; |
@@ -7,14 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | use BrianHenryIE\Strauss\Composer\Extra\StraussConfig; |
| 9 | 9 | |
| 10 | -class ProjectComposerPackage extends ComposerPackage |
|
| 11 | -{ |
|
| 10 | +class ProjectComposerPackage extends ComposerPackage { |
|
| 12 | 11 | protected string $author; |
| 13 | 12 | |
| 14 | 13 | protected string $vendorDirectory; |
| 15 | 14 | |
| 16 | - public function __construct(string $absolutePath, array $overrideAutoload = null) |
|
| 17 | - { |
|
| 15 | + public function __construct(string $absolutePath, array $overrideAutoload = null) { |
|
| 18 | 16 | parent::__construct($absolutePath, $overrideAutoload); |
| 19 | 17 | |
| 20 | 18 | $authors = $this->composer->getPackage()->getAuthors(); |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | use League\Flysystem\Adapter\Local; |
| 13 | 13 | use League\Flysystem\Filesystem; |
| 14 | 14 | |
| 15 | -class Autoload |
|
| 16 | -{ |
|
| 15 | +class Autoload { |
|
| 17 | 16 | |
| 18 | 17 | /** @var Filesystem */ |
| 19 | 18 | protected $filesystem; |
@@ -36,16 +35,14 @@ discard block |
||
| 36 | 35 | * @param string $workingDir |
| 37 | 36 | * @param array<string, array<string>> $files |
| 38 | 37 | */ |
| 39 | - public function __construct(StraussConfig $config, string $workingDir, array $discoveredFilesAutoloaders) |
|
| 40 | - { |
|
| 38 | + public function __construct(StraussConfig $config, string $workingDir, array $discoveredFilesAutoloaders) { |
|
| 41 | 39 | $this->config = $config; |
| 42 | 40 | $this->workingDir = $workingDir; |
| 43 | 41 | $this->discoveredFilesAutoloaders = $discoveredFilesAutoloaders; |
| 44 | 42 | $this->filesystem = new Filesystem(new Local($workingDir)); |
| 45 | 43 | } |
| 46 | 44 | |
| 47 | - public function generate() |
|
| 48 | - { |
|
| 45 | + public function generate() { |
|
| 49 | 46 | |
| 50 | 47 | if (! $this->config->isClassmapOutput()) { |
| 51 | 48 | return; |
@@ -119,8 +116,7 @@ discard block |
||
| 119 | 116 | return $dirname; |
| 120 | 117 | } |
| 121 | 118 | |
| 122 | - protected function generateFilesAutoloader() |
|
| 123 | - { |
|
| 119 | + protected function generateFilesAutoloader() { |
|
| 124 | 120 | |
| 125 | 121 | // Hyphen used to match WordPress Coding Standards. |
| 126 | 122 | $outputFilename = "autoload-files.php"; |
@@ -157,8 +153,7 @@ discard block |
||
| 157 | 153 | file_put_contents($targetDirectory . $outputFilename, ob_get_clean()); |
| 158 | 154 | } |
| 159 | 155 | |
| 160 | - protected function generateAutoloadPhp() |
|
| 161 | - { |
|
| 156 | + protected function generateAutoloadPhp() { |
|
| 162 | 157 | |
| 163 | 158 | $autoloadPhp = <<<'EOD' |
| 164 | 159 | <?php |
@@ -11,8 +11,7 @@ discard block |
||
| 11 | 11 | use RecursiveDirectoryIterator; |
| 12 | 12 | use Symfony\Component\Finder\Finder; |
| 13 | 13 | |
| 14 | -class Cleanup |
|
| 15 | -{ |
|
| 14 | +class Cleanup { |
|
| 16 | 15 | |
| 17 | 16 | /** @var Filesystem */ |
| 18 | 17 | protected Filesystem $filesystem; |
@@ -21,8 +20,7 @@ discard block |
||
| 21 | 20 | |
| 22 | 21 | protected string $vendorDirectory = 'vendor'. DIRECTORY_SEPARATOR; |
| 23 | 22 | |
| 24 | - public function __construct(StraussConfig $config, string $workingDir) |
|
| 25 | - { |
|
| 23 | + public function __construct(StraussConfig $config, string $workingDir) { |
|
| 26 | 24 | |
| 27 | 25 | $this->isDeleteVendorFiles = $config->isDeleteVendorFiles(); |
| 28 | 26 | |
@@ -35,8 +33,7 @@ discard block |
||
| 35 | 33 | * |
| 36 | 34 | * @param array $sourceFiles |
| 37 | 35 | */ |
| 38 | - public function cleanup(array $sourceFiles) |
|
| 39 | - { |
|
| 36 | + public function cleanup(array $sourceFiles) { |
|
| 40 | 37 | |
| 41 | 38 | // TODO Don't do this if vendor is the target dir (i.e. in-situ updating). |
| 42 | 39 | |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | use League\Flysystem\Filesystem; |
| 14 | 14 | use Symfony\Component\Finder\Finder; |
| 15 | 15 | |
| 16 | -class FileEnumerator |
|
| 17 | -{ |
|
| 16 | +class FileEnumerator { |
|
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | 19 | * The only path variable with a leading slash. |
@@ -76,8 +75,7 @@ discard block |
||
| 76 | 75 | /** |
| 77 | 76 | * Read the autoload keys of the dependencies and generate a list of the files referenced. |
| 78 | 77 | */ |
| 79 | - public function compileFileList() |
|
| 80 | - { |
|
| 78 | + public function compileFileList() { |
|
| 81 | 79 | |
| 82 | 80 | // TODO: read 'vendor' from composer.json. |
| 83 | 81 | $prefixToRemove = $this->workingDir .'vendor'. DIRECTORY_SEPARATOR; |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | use League\Flysystem\Filesystem; |
| 23 | 23 | use Symfony\Component\Finder\Finder; |
| 24 | 24 | |
| 25 | -class Licenser |
|
| 26 | -{ |
|
| 25 | +class Licenser { |
|
| 27 | 26 | |
| 28 | 27 | protected string $workingDir; |
| 29 | 28 | |
@@ -51,8 +50,7 @@ discard block |
||
| 51 | 50 | * @param array $dependencies Whose folders are searched for existing license.txt files. |
| 52 | 51 | * @param string $author To add to each modified file's header |
| 53 | 52 | */ |
| 54 | - public function __construct(StraussConfig $config, string $workingDir, array $dependencies, string $author) |
|
| 55 | - { |
|
| 53 | + public function __construct(StraussConfig $config, string $workingDir, array $dependencies, string $author) { |
|
| 56 | 54 | $this->workingDir = $workingDir; |
| 57 | 55 | $this->dependencies = $dependencies; |
| 58 | 56 | $this->author = $author; |
@@ -92,8 +90,7 @@ discard block |
||
| 92 | 90 | /** |
| 93 | 91 | * @see https://www.phpliveregex.com/p/A5y |
| 94 | 92 | */ |
| 95 | - public function findLicenseFiles(?Finder $finder = null) |
|
| 96 | - { |
|
| 93 | + public function findLicenseFiles(?Finder $finder = null) { |
|
| 97 | 94 | |
| 98 | 95 | // Include all license files in the dependency path. |
| 99 | 96 | $finder = $finder ?? new Finder(); |
@@ -132,8 +129,7 @@ discard block |
||
| 132 | 129 | /** |
| 133 | 130 | * @param array<string, ComposerPackage> $modifiedFiles |
| 134 | 131 | */ |
| 135 | - public function addInformationToUpdatedFiles(array $modifiedFiles) |
|
| 136 | - { |
|
| 132 | + public function addInformationToUpdatedFiles(array $modifiedFiles) { |
|
| 137 | 133 | |
| 138 | 134 | // e.g. "25-April-2021". |
| 139 | 135 | $date = gmdate("d-F-Y", time()); |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | use League\Flysystem\FileNotFoundException; |
| 10 | 10 | use League\Flysystem\Filesystem; |
| 11 | 11 | |
| 12 | -class Prefixer |
|
| 13 | -{ |
|
| 12 | +class Prefixer { |
|
| 14 | 13 | /** @var StraussConfig */ |
| 15 | 14 | protected $config; |
| 16 | 15 | |
@@ -28,8 +27,7 @@ discard block |
||
| 28 | 27 | /** @var array<string, ComposerPackage> */ |
| 29 | 28 | protected array $changedFiles = array(); |
| 30 | 29 | |
| 31 | - public function __construct(StraussConfig $config, string $workingDir) |
|
| 32 | - { |
|
| 30 | + public function __construct(StraussConfig $config, string $workingDir) { |
|
| 33 | 31 | $this->filesystem = new Filesystem(new Local($workingDir)); |
| 34 | 32 | |
| 35 | 33 | $this->targetDirectory = $config->getTargetDirectory(); |
@@ -51,8 +49,7 @@ discard block |
||
| 51 | 49 | * @param array<string, ComposerPackage> $phpFileList |
| 52 | 50 | * @throws FileNotFoundException |
| 53 | 51 | */ |
| 54 | - public function replaceInFiles(array $namespaceChanges, array $classChanges, array $phpFileList) |
|
| 55 | - { |
|
| 52 | + public function replaceInFiles(array $namespaceChanges, array $classChanges, array $phpFileList) { |
|
| 56 | 53 | |
| 57 | 54 | foreach ($phpFileList as $sourceRelativeFilePathFromVendor => $package) { |
| 58 | 55 | // Skip excluded namespaces. |
@@ -109,8 +106,7 @@ discard block |
||
| 109 | 106 | * |
| 110 | 107 | * @return string The updated text. |
| 111 | 108 | */ |
| 112 | - public function replaceNamespace($contents, $originalNamespace, $replacement) |
|
| 113 | - { |
|
| 109 | + public function replaceNamespace($contents, $originalNamespace, $replacement) { |
|
| 114 | 110 | |
| 115 | 111 | // When namespaces exist inside strings... |
| 116 | 112 | $searchNamespace = |
@@ -206,8 +202,7 @@ discard block |
||
| 206 | 202 | * @return array|string|string[]|null |
| 207 | 203 | * @throws \Exception |
| 208 | 204 | */ |
| 209 | - public function replaceClassname($contents, $originalClassname, $classnamePrefix) |
|
| 210 | - { |
|
| 205 | + public function replaceClassname($contents, $originalClassname, $classnamePrefix) { |
|
| 211 | 206 | $searchClassname = preg_quote($originalClassname, '/'); |
| 212 | 207 | |
| 213 | 208 | // This could be more specific if we could enumerate all preceeding and proceeding words ("new", "("...). |
@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | use BrianHenryIE\Strauss\Composer\ComposerPackage; |
| 11 | 11 | use BrianHenryIE\Strauss\Composer\Extra\StraussConfig; |
| 12 | 12 | |
| 13 | -class ChangeEnumerator |
|
| 14 | -{ |
|
| 13 | +class ChangeEnumerator { |
|
| 15 | 14 | |
| 16 | 15 | protected string $namespacePrefix; |
| 17 | 16 | protected string $classmapPrefix; |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | * ChangeEnumerator constructor. |
| 38 | 37 | * @param \BrianHenryIE\Strauss\Composer\Extra\StraussConfig $config |
| 39 | 38 | */ |
| 40 | - public function __construct(StraussConfig $config) |
|
| 41 | - { |
|
| 39 | + public function __construct(StraussConfig $config) { |
|
| 42 | 40 | $this->namespacePrefix = $config->getNamespacePrefix(); |
| 43 | 41 | $this->classmapPrefix = $config->getClassmapPrefix(); |
| 44 | 42 | |
@@ -78,8 +76,7 @@ discard block |
||
| 78 | 76 | * @param string $dir |
| 79 | 77 | * @param array<string, ComposerPackage> $relativeFilepaths |
| 80 | 78 | */ |
| 81 | - public function findInFiles($dir, $relativeFilepaths) |
|
| 82 | - { |
|
| 79 | + public function findInFiles($dir, $relativeFilepaths) { |
|
| 83 | 80 | |
| 84 | 81 | foreach ($relativeFilepaths as $relativeFilepath => $package) { |
| 85 | 82 | foreach ($this->excludePackagesFromPrefixing as $excludePackagesName) { |
@@ -172,8 +169,7 @@ discard block |
||
| 172 | 169 | ); |
| 173 | 170 | } |
| 174 | 171 | |
| 175 | - protected function addDiscoveredNamespaceChange(string $namespace) |
|
| 176 | - { |
|
| 172 | + protected function addDiscoveredNamespaceChange(string $namespace) { |
|
| 177 | 173 | |
| 178 | 174 | foreach ($this->excludeNamespacesFromPrefixing as $excludeNamespace) { |
| 179 | 175 | if (0 === strpos($namespace, $excludeNamespace)) { |