Skip to content

Commit c9bc1c4

Browse files
#3 Apply phpstan, php-cs-fixer & rector rules
1 parent 8da051f commit c9bc1c4

File tree

6 files changed

+46
-35
lines changed

6 files changed

+46
-35
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
* This file is part of the CleverAge/ProcessBundle package.
4+
* This file is part of the CleverAge/FlysystemProcessBundle package.
55
*
66
* Copyright (c) Clever-Age
77
*

src/DependencyInjection/CleverAgeFlysystemProcessExtension.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?php declare(strict_types=1);
2-
/**
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
36
* This file is part of the CleverAge/FlysystemProcessBundle package.
47
*
5-
* Copyright (C) 2017-2019 Clever-Age
8+
* Copyright (c) Clever-Age
69
*
710
* For the full copyright and license information, please view the LICENSE
811
* file that was distributed with this source code.

src/Task/FileFetchTask.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?php declare(strict_types=1);
2-
/**
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
36
* This file is part of the CleverAge/FlysystemProcessBundle package.
47
*
5-
* Copyright (C) 2017-2019 Clever-Age
8+
* Copyright (c) Clever-Age
69
*
710
* For the full copyright and license information, please view the LICENSE
811
* file that was distributed with this source code.
@@ -20,7 +23,7 @@
2023

2124
/**
2225
* Copy (or move) file from one filesystem to another, using Flysystem
23-
* Either get files using a file regexp, or take files from input
26+
* Either get files using a file regexp, or take files from input.
2427
*/
2528
class FileFetchTask extends AbstractConfigurableTask implements IterableTaskInterface
2629
{
@@ -75,8 +78,6 @@ public function next(ProcessState $state): bool
7578
}
7679

7780
/**
78-
* @param ProcessState $state
79-
*
8081
* @throws \UnexpectedValueException
8182
* @throws \InvalidArgumentException
8283
* @throws FilesystemException
@@ -87,7 +88,7 @@ protected function findMatchingFiles(ProcessState $state): void
8788
if ($filePattern) {
8889
foreach ($this->sourceFS->listContents('/') as $file) {
8990
if ('file' === $file['type']
90-
&& preg_match($filePattern, $file['path'])
91+
&& preg_match($filePattern, (string) $file['path'])
9192
&& !\in_array($file['path'], $this->matchingFiles, true)) {
9293
$this->matchingFiles[] = $file['path'];
9394
}
@@ -131,7 +132,7 @@ protected function doFileCopy(ProcessState $state, string $filename, bool $remov
131132
}
132133

133134
if ($removeSource) {
134-
$this->sourceFS->delete(sprintf('%s://%s', $prefixFrom, $filename));
135+
$this->sourceFS->delete(\sprintf('%s://%s', $prefixFrom, $filename));
135136
}
136137

137138
return $result ? $filename : null;

src/Task/FilesystemOptionTrait.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?php declare(strict_types=1);
2-
/**
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
36
* This file is part of the CleverAge/FlysystemProcessBundle package.
47
*
5-
* Copyright (C) 2017-2019 Clever-Age
8+
* Copyright (c) Clever-Age
69
*
710
* For the full copyright and license information, please view the LICENSE
811
* file that was distributed with this source code.
@@ -17,20 +20,18 @@
1720
use Symfony\Component\OptionsResolver\OptionsResolver;
1821

1922
/**
20-
* Tools to use filesystem inside task configurations
23+
* Tools to use filesystem inside task configurations.
2124
*/
2225
trait FilesystemOptionTrait
2326
{
24-
protected function configureFilesystemOption(OptionsResolver $resolver, $optionName): void
27+
protected function configureFilesystemOption(OptionsResolver $resolver, string|array $optionName): void
2528
{
2629
$resolver->setRequired($optionName);
2730
$resolver->setAllowedTypes($optionName, 'string');
28-
$resolver->setNormalizer($optionName, function (Options $options, $value) {
29-
return new Filesystem($value);
30-
});
31+
$resolver->setNormalizer($optionName, fn (Options $options, $value) => new Filesystem($value));
3132
}
3233

33-
protected function getFilesystem(ProcessState $state, $optionName): FilesystemOperator
34+
protected function getFilesystem(ProcessState $state, string $optionName): FilesystemOperator
3435
{
3536
return $this->getOption($state, $optionName);
3637
}

src/Task/ListContentTask.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?php declare(strict_types=1);
2-
/**
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
36
* This file is part of the CleverAge/FlysystemProcessBundle package.
47
*
5-
* Copyright (C) 2017-2019 Clever-Age
8+
* Copyright (c) Clever-Age
69
*
710
* For the full copyright and license information, please view the LICENSE
811
* file that was distributed with this source code.
@@ -18,7 +21,7 @@
1821
use Symfony\Component\OptionsResolver\OptionsResolver;
1922

2023
/**
21-
* Iterate over the content of a filesystem
24+
* Iterate over the content of a filesystem.
2225
*/
2326
class ListContentTask extends AbstractConfigurableTask implements IterableTaskInterface
2427
{
@@ -40,14 +43,14 @@ protected function configureOptions(OptionsResolver $resolver): void
4043
*/
4144
public function execute(ProcessState $state): void
4245
{
43-
if ($this->fsContent === null || key($this->fsContent) === null) {
46+
if (null === $this->fsContent || null === key($this->fsContent)) {
4447
$filesystem = $this->getFilesystem($state, 'filesystem');
4548
$pattern = $this->getOption($state, 'file_pattern');
4649

4750
$this->fsContent = $this->getFilteredFilesystemContents($filesystem, $pattern);
4851
}
4952

50-
if (key($this->fsContent) === null) {
53+
if (null === key($this->fsContent)) {
5154
$state->setSkipped(true);
5255
$this->fsContent = null;
5356
} else {
@@ -57,23 +60,23 @@ public function execute(ProcessState $state): void
5760

5861
public function next(ProcessState $state): bool
5962
{
60-
if (!is_array($this->fsContent)) {
63+
if (!\is_array($this->fsContent)) {
6164
return false;
6265
}
6366

6467
next($this->fsContent);
6568

66-
return key($this->fsContent) !== null;
69+
return null !== key($this->fsContent);
6770
}
6871

6972
/**
7073
* @throws FilesystemException
7174
*/
72-
protected function getFilteredFilesystemContents(FilesystemOperator $filesystem, string $pattern = null): array
75+
protected function getFilteredFilesystemContents(FilesystemOperator $filesystem, ?string $pattern = null): array
7376
{
7477
$results = [];
7578
foreach ($filesystem->listContents('') as $item) {
76-
if ($pattern === null || \preg_match($pattern, $item['path'])) {
79+
if (null === $pattern || preg_match($pattern, (string) $item['path'])) {
7780
$results[] = $item;
7881
}
7982
}

src/Task/RemoveFileTask.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?php declare(strict_types=1);
2-
/**
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
36
* This file is part of the CleverAge/FlysystemProcessBundle package.
47
*
5-
* Copyright (C) 2017-2019 Clever-Age
8+
* Copyright (c) Clever-Age
69
*
710
* For the full copyright and license information, please view the LICENSE
811
* file that was distributed with this source code.
@@ -17,7 +20,7 @@
1720
use Symfony\Component\OptionsResolver\OptionsResolver;
1821

1922
/**
20-
* Remove a file from a filesystem
23+
* Remove a file from a filesystem.
2124
*/
2225
class RemoveFileTask extends AbstractConfigurableTask
2326
{

0 commit comments

Comments
 (0)