Skip to content

Commit

Permalink
chore: satisfy static analysis (#90)
Browse files Browse the repository at this point in the history
* chore: satisfy static analysis

* bump ekino/phpstan-banned-code
  • Loading branch information
priyadi authored Aug 24, 2024
1 parent fb8f25a commit c4ead94
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* build: add rector
* build: add `Override` attributes where applicable
* chore: satisfy static analysis

## 1.5.4

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"doctrine/doctrine-bundle": "^2.10",
"doctrine/orm": "^2.14 || ^3.0",
"doctrine/persistence": "^3.1",
"ekino/phpstan-banned-code": "^1.0",
"ekino/phpstan-banned-code": "^2.1",
"phpstan/phpstan": "^1.11.6",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ parameters:
# constants: true
ignoreErrors:
- '#ContainerBuilder::registerAttributeForAutoconfiguration#'
banned_code:
non_ignorable: false
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withImportNames(importShortClasses: false)
->withPreparedSets(
deadCode: true,
codeQuality: true,
Expand Down
14 changes: 7 additions & 7 deletions src/Command/MappingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$variantTargetType = $entry->isVariantTargetType();

if ($sourceOption !== null) {
if (preg_match('/' . preg_quote($sourceOption) . '/i', $entry->getSourceTypeString()) === 0) {
if (preg_match('/' . preg_quote($sourceOption, '/') . '/i', $entry->getSourceTypeString()) === 0) {
continue;
}

$sourceType = preg_replace('/(' . preg_quote($sourceOption) . ')/i', '<bg=yellow>$1</>', $sourceType);
$sourceType = preg_replace('/(' . preg_quote($sourceOption, '/') . ')/i', '<bg=yellow>$1</>', $sourceType);
}

if ($targetOption !== null) {
if (preg_match('/' . preg_quote($targetOption) . '/i', $entry->getTargetTypeString()) === 0) {
if (preg_match('/' . preg_quote($targetOption, '/') . '/i', $entry->getTargetTypeString()) === 0) {
continue;
}

$targetType = preg_replace('/(' . preg_quote($targetOption) . ')/i', '<bg=yellow>$1</>', $targetType);
$targetType = preg_replace('/(' . preg_quote($targetOption, '/') . ')/i', '<bg=yellow>$1</>', $targetType);
}

if ($classOption !== null) {
if (
preg_match('/' . preg_quote($classOption) . '/i', $entry->getClass()) === 0
&& preg_match('/' . preg_quote($classOption) . '/i', $entry->getId()) === 0
preg_match('/' . preg_quote($classOption, '/') . '/i', $entry->getClass()) === 0
&& preg_match('/' . preg_quote($classOption, '/') . '/i', $entry->getId()) === 0
) {
continue;
}

// $class = preg_replace('/(' . preg_quote($classOption) . ')/i', '<bg=yellow>$1</>', $class);
$id = preg_replace('/(' . preg_quote($classOption) . ')/i', '<bg=yellow>$1</>', $id);
$id = preg_replace('/(' . preg_quote($classOption, '/') . ')/i', '<bg=yellow>$1</>', $id);
}

$rows[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/TraceableTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function transform(
$parentTraceData->addNestedTraceData($traceData);
$context = $context->with($traceData);
} else {
// @phpstan-ignore-next-line
// @phpstan-ignore ekinoBannedCode.function
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
$caller = $backtrace[2];
$traceData->setCaller(
Expand Down
2 changes: 1 addition & 1 deletion src/Proxy/Implementation/ProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function createProxy(
->generateProxyCode($class, $targetProxyClass);
$this->proxyRegistry->registerProxy($targetProxyClass, $sourceCode);

// @phpstan-ignore-next-line
// @phpstan-ignore ekinoBannedCode.expression
eval($sourceCode);

// @phpstan-ignore-next-line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testProxyResolving(): void
$factory = $this->get('rekalogika.mapper.object_to_object_metadata_factory');
$this->assertInstanceOf(ObjectToObjectMetadataFactoryInterface::class, $factory);

// @phpstan-ignore-next-line
// @phpstan-ignore ekinoBannedCode.expression
eval(<<<'PHP'
namespace Proxies\__CG__\Rekalogika\Mapper\Tests\Fixtures\Scalar;
Expand Down
2 changes: 1 addition & 1 deletion tests/Service/TestLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function debug(string|\Stringable $message, array $context = []): void
}

#[\Override]
public function log($level, string|\Stringable $message, array $context = []): void
public function log(mixed $level, string|\Stringable $message, array $context = []): void
{
if (!$this->isSuppressed($message)) {
$this->logger->log($level, $message, $context);
Expand Down

0 comments on commit c4ead94

Please sign in to comment.