Skip to content

Commit

Permalink
style(php): apply cs fixer and phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
thislg committed May 22, 2024
1 parent 4cebf33 commit 5fdf0cd
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 27 deletions.
21 changes: 3 additions & 18 deletions Handler/RotatingFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,8 @@
namespace LePhare\Import\Handler;

use Monolog\Handler\RotatingFileHandler as BaseRotatingFileHandler;
use Monolog\Logger;

if (Logger::API === 1) {
class RotatingFileHandler extends BaseRotatingFileHandler
{
use RotatingFileHandlerTrait {
setFilenameFormat as private typedSetFilenameFormat;
}

public function setFilenameFormat($filenameFormat, $dateFormat)
{
return $this->typedSetFilenameFormat($filenameFormat, $dateFormat);
}
}
} else {
class RotatingFileHandler extends BaseRotatingFileHandler
{
use RotatingFileHandlerTrait;
}
class RotatingFileHandler extends BaseRotatingFileHandler
{
use RotatingFileHandlerTrait;
}
2 changes: 1 addition & 1 deletion Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
StrategyRepositoryInterface $strategyRepository,
LoadStrategyRepositoryInterface $loadStrategyRepository,
ConfigurationInterface $configuration,
LoggerInterface $logger = null
?LoggerInterface $logger = null
) {
$this->configuration = $configuration;
$this->connection = $connection;
Expand Down
2 changes: 1 addition & 1 deletion ImportConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('import');

/** @var ArrayNodeDefinition */
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();

$replaceParameter = function ($string) {
Expand Down
2 changes: 1 addition & 1 deletion Load/CsvLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Behat\Transliterator\Transliterator;
use Doctrine\DBAL\Connection;
use ForceUTF8\Encoding;
use LePhare\Import\Configuration\CredentialsInterface;
use LePhare\Import\Exception\ImportException;
use LePhare\Import\ImportResource;
use ForceUTF8\Encoding;

/** @api */
class CsvLoader implements LoaderInterface
Expand Down
2 changes: 1 addition & 1 deletion Load/ExcelLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function supports(ImportResource $resource, array $context): bool
return false;
}

if (!class_exists(\PhpOffice\PhpSpreadsheet\IOFactory::class)) {
if (!class_exists(IOFactory::class)) {
throw new ImportException('PhpSpreadsheet library is missing. Try "composer require phpoffice/phpspreadsheet"');
}

Expand Down
2 changes: 1 addition & 1 deletion Load/TextLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Behat\Transliterator\Transliterator;
use Doctrine\DBAL\Connection;
use ForceUTF8\Encoding;
use LePhare\Import\Configuration\CredentialsInterface;
use LePhare\Import\Exception\ImportException;
use LePhare\Import\ImportResource;
use ForceUTF8\Encoding;

/** @api */
class TextLoader implements LoaderInterface
Expand Down
2 changes: 1 addition & 1 deletion Tests/ImportConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function providerConfigurations(): iterable
];

yield '“delimiter” should be evaluated' => [
array_merge($defaults, [
array_merge($defaults, [
'name' => $config['name'],
'source_dir' => str_replace('%kernel.project_dir%', '/app', $config['source_dir']),
'resources' => [
Expand Down
5 changes: 2 additions & 3 deletions Tests/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Psr\Log\LoggerInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Yaml\Yaml;

/**
* @covers \LePhare\Import\Import
Expand Down Expand Up @@ -112,7 +111,7 @@ public function testExecuteWithException(): void
'strategy' => 'load_alphabetically',
],
],
], ]));
], ]));

$this->assertFalse($this->import->execute());
}
Expand Down Expand Up @@ -142,7 +141,7 @@ public function testExecuteWithWrongStrategyShouldFail(): void
'strategy' => 'bad_strategy_name',
],
],
], ]));
], ]));

$this->assertFalse($this->import->execute());
}
Expand Down
9 changes: 9 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ parameters:
- .
excludePaths:
- vendor
ignoreErrors:
-
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::.+\(\)#'
paths:
- ImportConfiguration.php
-
message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::.+\(\)#'
paths:
- ImportConfiguration.php
tmpDir: .phpstan.cache

0 comments on commit 5fdf0cd

Please sign in to comment.