Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Jan 15, 2022
1 parent 352ced7 commit 912ba3e
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 37 deletions.
7 changes: 3 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/src'])
;
->in([__DIR__ . '/'])
->exclude(__DIR__ . '/vendor');

return (new PhpCsFixer\Config())
->setRules([
Expand Down Expand Up @@ -35,5 +35,4 @@
'no_extra_blank_lines' => true,
'no_whitespace_in_blank_line' => true,
])
->setFinder($finder)
;
->setFinder($finder);
17 changes: 10 additions & 7 deletions bin/check-versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* This script check for composer dependency incompatibilities:
* This script check for composer dependency incompatibilities:.
*
* - All required dependencies of the extracted packages MUST be
* present in the main composer.json's require(-dev) section.
Expand All @@ -23,7 +23,6 @@

include_once __DIR__ . '/tools.php';


function constraint_has_conflict(string $mainConstraint, string $packageConstraint): bool
{
$parser = new VersionParser();
Expand All @@ -34,7 +33,6 @@ function constraint_has_conflict(string $mainConstraint, string $packageConstrai
$packageLowerBound = $packageConstraint->getLowerBound()->getVersion();
$packageUpperBound = $packageConstraint->getUpperBound()->getVersion();


if (Comparator::compare($mainUpperBound, '<=', $packageLowerBound)) {
return true;
}
Expand All @@ -58,9 +56,15 @@ function constraint_has_conflict(string $mainConstraint, string $packageConstrai
$mainComposer = $filesystem->read('composer.json');
/** @var string[] $otherComposers */
$otherComposers = $filesystem->listContents('src', true)
->filter(function(StorageAttributes $item) { return $item->isFile(); })
->filter(function(FileAttributes $item) { return substr($item->path(), -5) === '.json'; })
->map(function(FileAttributes $item) { return $item->path(); })
->filter(function (StorageAttributes $item) {
return $item->isFile();
})
->filter(function (FileAttributes $item) {
return substr($item->path(), -5) === '.json';
})
->map(function (FileAttributes $item) {
return $item->path();
})
->toArray();

$mainInformation = json_decode($mainComposer, true);
Expand Down Expand Up @@ -107,4 +111,3 @@ function constraint_has_conflict(string $mainConstraint, string $packageConstrai
}

write_line("✅ Composer dependencies are looking fine.");

14 changes: 10 additions & 4 deletions bin/set-flysystem-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@

/** @var string[] $otherComposers */
$composerFiles = $filesystem->listContents('src', true)
->filter(function(StorageAttributes $item) { return $item->isFile(); })
->filter(function(FileAttributes $item) { return substr($item->path(), -5) === '.json'; })
->map(function(FileAttributes $item) { return $item->path(); })
->filter(function (StorageAttributes $item) {
return $item->isFile();
})
->filter(function (FileAttributes $item) {
return substr($item->path(), -5) === '.json';
})
->map(function (FileAttributes $item) {
return $item->path();
})
->toArray();

foreach ($composerFiles as $composerFile) {
$contents = $filesystem->read($composerFile);
$mainVersionRegex = preg_quote($mainVersion, '~');
$updated = preg_replace('~("league/flysystem": "\\^[a-zA-Z0-9\\.-]+")~ms', '"league/flysystem": "^'.$mainVersion.'"', $contents);
$updated = preg_replace('~("league/flysystem": "\\^[a-zA-Z0-9\\.-]+")~ms', '"league/flysystem": "^' . $mainVersion . '"', $contents);
$filesystem->write($composerFile, $updated);
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"phpseclib/phpseclib": "^2.0",
"aws/aws-sdk-php": "^3.198.1",
"composer/semver": "^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"friendsofphp/php-cs-fixer": "^3.5",
"google/cloud-storage": "^1.23",
"async-aws/s3": "^1.5",
"async-aws/simple-s3": "^1.0",
Expand Down
6 changes: 4 additions & 2 deletions mocked-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function filesize(...$arguments)
}

namespace League\Flysystem\InMemory {
function time() {
function time()
{
if ( ! is_mocked('time')) {
return \time();
}
Expand Down Expand Up @@ -141,7 +142,8 @@ function ftp_rawlist(...$arguments)
}

namespace League\Flysystem\ZipArchive {
function stream_get_contents(...$arguments) {
function stream_get_contents(...$arguments)
{
if ( ! is_mocked('stream_get_contents')) {
return \stream_get_contents(...$arguments);
}
Expand Down
6 changes: 3 additions & 3 deletions phpunit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

include __DIR__.'/vendor/autoload.php';
include __DIR__.'/src/AdapterTestUtilities/test-functions.php';
include __DIR__.'/mocked-functions.php';
include __DIR__ . '/vendor/autoload.php';
include __DIR__ . '/src/AdapterTestUtilities/test-functions.php';
include __DIR__ . '/mocked-functions.php';
6 changes: 3 additions & 3 deletions src/AdapterTestUtilities/FilesystemAdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace League\Flysystem\AdapterTestUtilities;

use function is_resource;
use function iterator_to_array;
use const PHP_EOL;
use Generator;
use League\Flysystem\Config;
Expand All @@ -21,6 +19,8 @@
use PHPUnit\Framework\TestCase;
use Throwable;
use function file_get_contents;
use function is_resource;
use function iterator_to_array;

/**
* @codeCoverageIgnore
Expand Down Expand Up @@ -674,7 +674,7 @@ public function trying_to_delete_a_non_existing_file(): void
*/
public function checking_if_files_exist(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$fileExistsBefore = $adapter->fileExists('some/path.txt');
$adapter->write('some/path.txt', 'contents', new Config());
Expand Down
3 changes: 2 additions & 1 deletion src/AdapterTestUtilities/RetryOnTestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace League\Flysystem\AdapterTestUtilities;

use League\Flysystem\FilesystemException;
use const PHP_EOL;
use const STDOUT;
use League\Flysystem\FilesystemException;
use Throwable;

/**
Expand Down Expand Up @@ -43,6 +43,7 @@ protected function dontRetryOnException(): void

/**
* @internal
*
* @throws Throwable
*/
protected function runSetup(callable $scenario): void
Expand Down
1 change: 0 additions & 1 deletion src/AsyncAwsS3/AsyncAwsS3AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use League\Flysystem\Config;
use League\Flysystem\FileAttributes;
use League\Flysystem\FilesystemAdapter;
use League\Flysystem\Ftp\UnableToConnectToFtpHost;
use League\Flysystem\StorageAttributes;
use League\Flysystem\UnableToCheckFileExistence;
use League\Flysystem\UnableToDeleteFile;
Expand Down
7 changes: 6 additions & 1 deletion src/AwsS3V3/AwsS3V3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,12 @@ private function mapS3ObjectMetadata(array $metadata, string $path = null): Stor
$lastModified = $dateTime instanceof DateTimeResult ? $dateTime->getTimeStamp() : null;

return new FileAttributes(
$path, $fileSize, null, $lastModified, $mimetype, $this->extractExtraMetadata($metadata)
$path,
$fileSize,
null,
$lastModified,
$mimetype,
$this->extractExtraMetadata($metadata)
);
}

Expand Down
1 change: 0 additions & 1 deletion src/Ftp/FtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use League\Flysystem\DirectoryAttributes;
use League\Flysystem\FileAttributes;
use League\Flysystem\FilesystemAdapter;
use League\Flysystem\FilesystemException;
use League\Flysystem\PathPrefixer;
use League\Flysystem\StorageAttributes;
use League\Flysystem\UnableToCopyFile;
Expand Down
2 changes: 0 additions & 2 deletions src/GoogleCloudStorage/StubRiggedBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use LogicException;
use Throwable;

use function array_key_exists;

class StubRiggedBucket extends Bucket
{
private array $triggers = [];
Expand Down
1 change: 1 addition & 0 deletions src/GoogleCloudStorage/StubStorageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function bucket($name, $userProject = false)
'requesterProjectId' => $this->projectId,
]);
}

return $name === 'flysystem' ? $this->riggedBucket : parent::bucket($name, $userProject);
}
}
1 change: 0 additions & 1 deletion src/InMemory/InMemoryFilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use League\Flysystem\DirectoryAttributes;
use League\Flysystem\FileAttributes;
use League\Flysystem\FilesystemAdapter;
use League\Flysystem\FilesystemException;
use League\Flysystem\UnableToCopyFile;
use League\Flysystem\UnableToMoveFile;
use League\Flysystem\UnableToReadFile;
Expand Down
3 changes: 1 addition & 2 deletions src/Local/LocalFilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace League\Flysystem\Local;

use function file_put_contents;
use const DIRECTORY_SEPARATOR;
use const LOCK_EX;
use DirectoryIterator;
Expand Down Expand Up @@ -38,11 +37,11 @@
use function error_clear_last;
use function error_get_last;
use function file_exists;
use function file_put_contents;
use function is_dir;
use function is_file;
use function mkdir;
use function rename;
use function stream_copy_to_stream;

class LocalFilesystemAdapter implements FilesystemAdapter
{
Expand Down
6 changes: 3 additions & 3 deletions src/Local/LocalFilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace League\Flysystem\Local;

use function strnatcasecmp;
use function usort;
use const LOCK_EX;
use League\Flysystem\AdapterTestUtilities\FilesystemAdapterTestCase;
use League\Flysystem\Config;
Expand All @@ -32,7 +30,9 @@
use function is_resource;
use function iterator_to_array;
use function mkdir;
use function strnatcasecmp;
use function symlink;
use function usort;

/**
* @group local
Expand Down Expand Up @@ -305,7 +305,7 @@ public function retrieving_visibility_while_listing_directory_contents(): void
/** @var Traversable<StorageAttributes> $contentListing */
$contentListing = $adapter->listContents('/', true);
$listing = iterator_to_array($contentListing);
usort($listing, function(StorageAttributes $a, StorageAttributes $b) {
usort($listing, function (StorageAttributes $a, StorageAttributes $b) {
return strnatcasecmp($a->path(), $b->path());
});
/**
Expand Down
2 changes: 1 addition & 1 deletion test_files/wait_for_ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$start = time();
$connected = false;

while(time() - $start < 60) {
while (time() - $start < 60) {
try {
$provider->createConnection($options);
$connected = true;
Expand Down

0 comments on commit 912ba3e

Please sign in to comment.