Skip to content

Commit ff63f10

Browse files
committed
style: apply consistent code formatting across multiple files
- Adjusted indentation and spacing for better readability in `PlaceholderModifier.php`, `ProductionAttributeModifier.php`, and test files. - Standardized inline conditional structures for improved clarity. - Reorganized import statements for multiple files to maintain consistent positioning.
1 parent b6adba0 commit ff63f10

8 files changed

Lines changed: 35 additions & 40 deletions

File tree

src/Placeholder/PlaceholderModifier.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ private function processTestFile(string $filePath, array $actions, bool $dryRun)
184184
$result = $this->replacePestPlaceholder($code, $placeholderId, array_values($productionMethods));
185185
} elseif ($useSeeTag) {
186186
$result = $this->replacePhpUnitPlaceholderWithSeeTag($code, $placeholderId, array_values($productionMethods));
187-
}
188-
else {
187+
} else {
189188
$result = $this->replacePhpUnitPlaceholder($code, $placeholderId, array_values($productionMethods));
190189
}
191190

src/Placeholder/PlaceholderRegistry.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ final class PlaceholderRegistry
2222
*/
2323
private const PLACEHOLDER_PATTERN = '/^@@?[A-Za-z][A-Za-z0-9_-]*$/';
2424

25-
/**
26-
* Regex pattern for @see tag placeholders (@@prefix).
27-
*/
25+
/** Regex pattern for @see tag placeholders (@@prefix). */
2826
private const SEE_TAG_PLACEHOLDER_PATTERN = '/^@@[A-Za-z][A-Za-z0-9_-]*$/';
2927

3028
/**

src/Sync/Discovery/ProductionFileDiscovery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace TestFlowLabs\TestLink\Sync\Discovery;
66

7-
use Composer\Autoload\ClassLoader;
87
use ReflectionClass;
8+
use Composer\Autoload\ClassLoader;
99
use TestFlowLabs\TestLink\Sync\Exception\ProductionFileNotFoundException;
1010

1111
/**

src/Sync/Modifier/ProductionAttributeModifier.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function apply(array $actions): SyncResult
5555
$newCode = $this->injectTestedBy($code, $action);
5656

5757
if ($newCode !== $code) {
58-
$code = $newCode;
59-
$modified = true;
58+
$code = $newCode;
59+
$modified = true;
6060
$addedMethods[] = $action->testIdentifier;
6161
}
6262
}
@@ -184,10 +184,8 @@ private function hasTestedByAttribute(array $lines, int $methodLine, string $tes
184184
for ($i = max(0, $methodLine - 20); $i < $methodLine; $i++) {
185185
$line = $lines[$i];
186186

187-
if (preg_match('/#\[TestedBy\s*\(/', $line) && str_contains($line, "{$testClass}::class")) {
188-
if ($testMethod === null || str_contains($line, "'{$testMethod}'")) {
189-
return true;
190-
}
187+
if (preg_match('/#\[TestedBy\s*\(/', $line) && str_contains($line, "{$testClass}::class") && ($testMethod === null || str_contains($line, "'{$testMethod}'"))) {
188+
return true;
191189
}
192190
}
193191

src/Sync/SyncCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use TestFlowLabs\TestLink\Sync\Discovery\TestFileDiscovery;
1515
use TestFlowLabs\TestLink\Sync\Modifier\ProductionFileModifier;
1616
use TestFlowLabs\TestLink\Sync\Discovery\ProductionFileDiscovery;
17-
use TestFlowLabs\TestLink\Sync\Modifier\ProductionAttributeModifier;
1817
use TestFlowLabs\TestLink\Sync\Exception\TestCaseNotFoundException;
1918
use TestFlowLabs\TestLink\Sync\Exception\TestFileNotFoundException;
19+
use TestFlowLabs\TestLink\Sync\Modifier\ProductionAttributeModifier;
2020
use TestFlowLabs\TestLink\Sync\Exception\ProductionFileNotFoundException;
2121

2222
/**

tests/Unit/Placeholder/PlaceholderModifierTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,17 @@ public function create(): void {}
410410
$content = file_get_contents($prodFile);
411411

412412
return [
413-
'has_see_tag' => str_contains($content, '@see'),
414-
'has_fqcn' => str_contains($content, '\\Tests\\Unit\\SeeTagServiceTest::testCreate'),
415-
'no_testedby' => !str_contains($content, '#[TestedBy'),
416-
'no_placeholder' => !str_contains($content, '@@A'),
413+
'has_see_tag' => str_contains($content, '@see'),
414+
'has_fqcn' => str_contains($content, '\\Tests\\Unit\\SeeTagServiceTest::testCreate'),
415+
'no_testedby' => !str_contains($content, '#[TestedBy'),
416+
'no_placeholder' => !str_contains($content, '@@A'),
417417
];
418418
})
419419
->toMatchArray([
420-
'has_see_tag' => true,
421-
'has_fqcn' => true,
422-
'no_testedby' => true,
423-
'no_placeholder' => true,
420+
'has_see_tag' => true,
421+
'has_fqcn' => true,
422+
'no_testedby' => true,
423+
'no_placeholder' => true,
424424
]);
425425

426426
it('replaces @@prefix placeholder with @see tag in PHPUnit test')
@@ -452,17 +452,17 @@ public function testCreate(): void {}
452452
$content = file_get_contents($testFile);
453453

454454
return [
455-
'has_see_tag' => str_contains($content, '@see'),
456-
'has_fqcn' => str_contains($content, '\\App\\Services\\UserService::create'),
457-
'no_attribute' => !str_contains($content, '#[LinksAndCovers'),
458-
'no_placeholder' => !str_contains($content, '@@A'),
455+
'has_see_tag' => str_contains($content, '@see'),
456+
'has_fqcn' => str_contains($content, '\\App\\Services\\UserService::create'),
457+
'no_attribute' => !str_contains($content, '#[LinksAndCovers'),
458+
'no_placeholder' => !str_contains($content, '@@A'),
459459
];
460460
})
461461
->toMatchArray([
462-
'has_see_tag' => true,
463-
'has_fqcn' => true,
464-
'no_attribute' => true,
465-
'no_placeholder' => true,
462+
'has_see_tag' => true,
463+
'has_fqcn' => true,
464+
'no_attribute' => true,
465+
'no_placeholder' => true,
466466
]);
467467

468468
it('uses FQCN with leading backslash in @see tags')
@@ -546,7 +546,7 @@ public function method(): void {}
546546
it('does not modify Pest test files for @@prefix (unsupported)')
547547
->linksAndCovers(PlaceholderModifier::class.'::apply')
548548
->expect(function () {
549-
$testFile = $this->tempDir.'/PestSeeTest.php';
549+
$testFile = $this->tempDir.'/PestSeeTest.php';
550550
$originalContent = <<<'PHP'
551551
<?php
552552
test('pest test', function () {

tests/Unit/Placeholder/PlaceholderResolverTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,18 @@
159159
$result = $resolver->resolve($registry);
160160

161161
return [
162-
'has_errors' => $result->hasErrors(),
163-
'has_actions' => $result->hasActions(),
164-
'error_contains_at' => str_contains($result->errors[0], '@@A'),
165-
'error_mentions_see' => str_contains($result->errors[0], '@see'),
162+
'has_errors' => $result->hasErrors(),
163+
'has_actions' => $result->hasActions(),
164+
'error_contains_at' => str_contains($result->errors[0], '@@A'),
165+
'error_mentions_see' => str_contains($result->errors[0], '@see'),
166166
'error_mentions_pest' => str_contains($result->errors[0], 'Pest'),
167167
];
168168
})
169169
->toMatchArray([
170-
'has_errors' => true,
171-
'has_actions' => false,
172-
'error_contains_at' => true,
173-
'error_mentions_see' => true,
170+
'has_errors' => true,
171+
'has_actions' => false,
172+
'error_contains_at' => true,
173+
'error_mentions_see' => true,
174174
'error_mentions_pest' => true,
175175
]);
176176

tests/Unit/Scanner/PestLinkScannerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
describe('PestLinkScanner', function (): void {
99
beforeEach(function (): void {
10-
$this->scanner = new PestLinkScanner();
11-
$this->testDir = sys_get_temp_dir().'/testlink-pest-scanner-'.uniqid();
10+
$this->scanner = new PestLinkScanner();
11+
$this->testDir = sys_get_temp_dir().'/testlink-pest-scanner-'.uniqid();
1212

1313
@mkdir($this->testDir.'/tests/Unit', 0777, true);
1414
});

0 commit comments

Comments
 (0)