Skip to content

Commit

Permalink
apply php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
alcohol committed Sep 4, 2018
1 parent 880621d commit 7ab2986
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 102 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ return (new PhpCsFixer\Config('satis'))
// additionally
'array_syntax' => ['syntax' => 'short'],
'concat_space' => false,
'declare_strict_types' => true,
'header_comment' => ['header' => $header],
'no_unused_imports' => false,
'no_useless_else' => true,
Expand Down
7 changes: 6 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ title: Config
"type": "composer",
"url": "https://packagist.org"
}],
"repositories-dep": [],
"require": {
"company/package1": "1.2.0",
"company/package2": "1.5.2",
Expand All @@ -28,7 +29,10 @@ title: Config
"prefix-url": "https://amazing.cdn.example.org",
"whitelist": [ "company/package1" ],
"blacklist": [ "company/package2" ],
"checksum": true
"checksum": true,
"ignore-filters": false,
"override-dist-type": true,
"rearchive": true,
},
"abandoned": {
"company/package": true,
Expand All @@ -45,6 +49,7 @@ title: Config
"config": {
},
"strip-hosts": [],
"notify-batch": "https://example.com/endpoint"
}
```
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.4/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
Expand Down
13 changes: 8 additions & 5 deletions src/Builder/ArchiveBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand All @@ -12,10 +14,10 @@
namespace Composer\Satis\Builder;

use Composer\Composer;
use Composer\Factory;
use Composer\Downloader\DownloadManager;
use Composer\Package\PackageInterface;
use Composer\Factory;
use Composer\Package\Archiver\ArchiveManager;
use Composer\Package\PackageInterface;
use Composer\Util\Filesystem;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -222,7 +224,7 @@ private function archive(DownloadManager $downloadManager, ArchiveManager $archi
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($targetDir);
$targetDir = realpath($targetDir);

if ($overrideDistType) {
$originalDistType = $package->getDistType();
$package->setDistType($format);
Expand Down Expand Up @@ -263,9 +265,10 @@ private function archive(DownloadManager $downloadManager, ArchiveManager $archi
$path = $targetDir . '/' . $packageName . '.' . $format;
$downloaded = $archiveManager->archive($package, $format, $targetDir, null, $ignoreFilters);
$filesystem->rename($downloaded, $path);

return $path;
} else {
return $archiveManager->archive($package, $format, $targetDir, null, $ignoreFilters);
}

return $archiveManager->archive($package, $format, $targetDir, null, $ignoreFilters);
}
}
2 changes: 2 additions & 0 deletions src/Builder/ArchiveBuilderHelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Builder/Builder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Builder/BuilderInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Builder/PackagesBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Builder/WebBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Console/Command/AddCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Console/Command/BuildCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Console/Command/InitCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down
11 changes: 7 additions & 4 deletions src/Console/Command/PurgeCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of composer/satis.
*
Expand Down Expand Up @@ -64,7 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$outputDir = $input->getArgument('output-dir') ?? $config['output-dir'] ?? null;
if ($outputDir === null) {
if (null === $outputDir) {
throw new \InvalidArgumentException('The output dir must be specified as second argument or be configured inside ' . $input->getArgument('file'));
}

Expand Down Expand Up @@ -138,24 +140,25 @@ private function removeEmptyDirectories($output, $dir, $depth = 2)
{
$empty = true;
$children = @scandir($dir);
if ($children === false) {
if (false === $children) {
return false;
}
foreach ($children as $child) {
if ($child === '.' || $child === '..') {
if ('.' === $child || '..' === $child) {
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $child;
if (is_dir($path)
&& $depth > 0
&& $this->removeEmptyDirectories($output, $path, $depth -1)
&& $this->removeEmptyDirectories($output, $path, $depth - 1)
&& rmdir($path)
) {
$output->writeln(sprintf('<info>Removed empty directory</info>: <comment>%s</comment>', $path));
} else {
$empty = false;
}
}

return $empty;
}
}
Loading

0 comments on commit 7ab2986

Please sign in to comment.