You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 2. Find unused Behat definitions with static analysis
186
26
187
27
Behat uses `@When()`, `@Then()` and `@Given()` annotations and their PHP 8 attribute alternatives to define method to be called in `*.feature` files. Sometimes test change and lines from `*.feature` files are deleted. But what about definitions?
188
28
189
29
This command helps you to spot definitions that are no longer needed. Just provide test directory (1 or more) and let it statically compare defined and used masks:
190
30
191
31
```bash
192
-
vendor/bin/swiss-knife behastan tests
32
+
vendor/bin/behastan unused-definitions tests
193
33
```
194
34
195
35
↓
@@ -218,119 +58,6 @@ tests/Behat/OrderContext.php
218
58
219
59
You can also add this command to CI, to get instant feedback about unused definitions.
220
60
221
-
<br>
222
-
223
-
## 8. Quick search PHP files with regex
224
-
225
-
Data beats guess. Do you need a quick idea how many files contain `$this->get('...')` calls? Or another anti-pattern you want to remove?
226
-
227
-
PhpStorm helps with similar search, but stops counting at 100+. To get exact data about your codebase, use this command:
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.
255
-
256
-
But what if we have 100+ YAML files in our project?
Symfony 5.3 introduced amazing [config builders](https://symfony.com/blog/new-in-symfony-5-3-config-builder-classes), but those classes are not available for IDE until used. To make it easier, we added a command that generates all config builder classes you project can use, in `/var/cache/Symfony`.
That way IDE, PHPStan after adding those paths and Rector can understand your config files better.
275
-
276
-
<br>
277
-
278
-
## 11. Spots Fake Traits
279
-
280
-
What is trait has 5 lines and used in single service? We know it's better to e inlined, to empower IDE, Rector and PHPStan. But don't have time to worry about these details.
281
-
282
-
We made a command to automate this process and spot the traits most likely to be inlined:
283
-
284
-
```bash
285
-
vendor/bin/swiss-knife spot-lazy-traits src
286
-
```
287
-
288
-
<br>
289
-
290
-
By default, the commands look for traits used max 2-times. To change that:
That's it! Run this command once upon a time or run it in CI to eliminate traits with low value to exists. Your code will be more robuts and easier to work with.
297
-
298
-
299
-
<br>
300
-
301
-
## 12. Mutual Private Repository Dependencies
302
-
303
-
Do you have a project that uses 5 private repositories? And another one that uses different 3 private repositories? Are their open-source dependencies up to date?
304
-
305
-
In such situations, we want to get a quick idea about the weakest link. Do all those repositories use the same version of "symfony/console"? What about their min PHP versions?
306
-
307
-
<br>
308
-
309
-
That's where `multi-package-composer-stats` comes. Feed it the links to dependency repositories you want to know versions for:
Do you want to compare **the main projects** and themselves and fetch their dependencies automatically? Provide urls to the repositories and the `--is-source` option:
0 commit comments