Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,7 @@ Searching for regex: #this->get\((.*)\)#

<br>

## 8. Convert Alice fixtures from YAML to PHP

The `nelmio/alice` package [allows to use PHP](https://github.com/nelmio/alice/blob/v2.3.0/doc/complete-reference.md#php) for test fixture definitions. It's much better format, because Rector and PHPStan can understand it.

But what if we have 100+ YAML files in our project?

```bash
vendor/bin/swiss-knife convert-alice-yaml-to-php fixtures
```

That's it!

<br>

## 9. Spots Fake Traits
## 8. Spots Fake Traits

What is trait has 5 lines and used in single service? We know it's better to be inlined, to empower IDE, Rector and PHPStan. But don't have time to worry about these details.

Expand All @@ -269,7 +255,7 @@ That's it! Run this command once upon a time or run it in CI to eliminate traits

<br>

## 10. Split huge Symfony config to per-package in directory
## 9. Split huge Symfony config to per-package in directory

Do you have a huge Symfony config file that is hard to navigate? Do you want to split it to per-package files?

Expand Down Expand Up @@ -345,7 +331,7 @@ All the extensions will be extracted to separate files in `config/packages/dev`

<br>

## 11. Generate Symfony Smoke Tests
## 10. Generate Symfony Smoke Tests

Cover your Symfony app with smoke tests in seconds. This command scans your `composer.json`, picks the matching test templates, and drops them under `tests/Unit/Smoke` (or your project's equivalent unit-tests directory).

Expand Down Expand Up @@ -420,7 +406,7 @@ final class ServiceContainerTest extends AbstractContainerTestCase

<br>

## 12. Detect Duplicated Code
## 11. Detect Duplicated Code

Spot copy-pasted code blocks with a token-based detector, a small clone of phpcpd.
Add it to CI to fail when a large copy-pasted block is added:
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"nette/utils": "^4.1",
"nikic/php-parser": "^5.7",
"symfony/finder": "^8.1",
"symfony/yaml": "^8.1",
"webmozart/assert": "^2.4"
},
"require-dev": {
Expand Down
87 changes: 0 additions & 87 deletions src/Command/AliceYamlFixturesToPhpCommand.php

This file was deleted.

3 changes: 3 additions & 0 deletions src/Command/NamespaceToPSR4Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

/**
* @see \Rector\SwissKnife\Tests\Command\NamespaceToPSR4CommandTest
*/
final readonly class NamespaceToPSR4Command implements CommandInterface
{
public function __construct(
Expand Down
3 changes: 3 additions & 0 deletions src/Finder/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\Finder\SplFileInfo;
use Webmozart\Assert\Assert;

/**
* @see \Rector\SwissKnife\Tests\Finder\FilesFinderTest
*/
final class FilesFinder
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Finder/PhpFilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\Finder\SplFileInfo;
use Webmozart\Assert\Assert;

/**
* @see \Rector\SwissKnife\Tests\Finder\PhpFilesFinderTest
*/
final class PhpFilesFinder
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function isConstantDefinedInParentClassAlso(Class_ $class, string $const

return array_any(
$class->implements,
fn ($implement): bool => in_array($constantName, $this->getClassConstantNames($implement->toString()), true)
fn (Name $name): bool => in_array($constantName, $this->getClassConstantNames($name->toString()), true)
);
}

Expand Down
6 changes: 2 additions & 4 deletions src/SmokeTestgen/FileSystem/TestsDirectoryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ public function resolveSmokeUnitTestDirectory(string $projectDirectory): string
{
$testDirectory = $this->resolveTestDirectory($projectDirectory);

if ($testDirectory === null) {
// fallback to default
$testDirectory = 'tests';
}
// fallback to default
$testDirectory ??= 'tests';

$unitTestDirectory = $this->resolveUnitTestsDirectory($testDirectory);
if ($unitTestDirectory === null) {
Expand Down
3 changes: 1 addition & 2 deletions src/SmokeTestgen/TestTemplateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function matchProjectPackages(array $requiredPackages): array
// find all subscribers, that match any of the required packages
return array_filter(
$this->testByPackageSubscribers,
fn (TestByPackageSubscriberInterface $testByPackageSubscriber): bool =>
array_intersect($testByPackageSubscriber->getPackageNames(), $requiredPackages) !== []
fn (TestByPackageSubscriberInterface $testByPackageSubscriber): bool => array_intersect($testByPackageSubscriber->getPackageNames(), $requiredPackages) !== []
);
}
}
3 changes: 3 additions & 0 deletions src/SmokeTestgen/Utils/TestPathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Rector\SwissKnife\SmokeTestgen\Contract\TestByPackageSubscriberInterface;

/**
* @see \Rector\SwissKnife\Tests\SmokeTestgen\Utils\TestPathResolverTest
*/
final class TestPathResolver
{
public static function resolve(
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/UnitTestFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private function isUnitTest(string $class): bool

return array_all(
self::NON_UNIT_TEST_CASE_CLASSES,
fn ($nonUnitTestCaseClass): bool => ! is_a($class, $nonUnitTestCaseClass, true)
fn (string $nonUnitTestCaseClass): bool => ! is_a($class, $nonUnitTestCaseClass, true)
);
}
}
Loading