Skip to content

Commit 30f4c8a

Browse files
authored
Remove composer dependency, insights, and tests (#575)
* remove composer dependency, insights, and tests * rm more class references
1 parent c5e48e9 commit 30f4c8a

29 files changed

+2
-15785
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"ext-json": "*",
2323
"ext-mbstring": "*",
2424
"ext-tokenizer": "*",
25-
"composer/composer": "^2.0",
25+
"composer/semver": "^3.3",
2626
"friendsofphp/php-cs-fixer": "^3.0.0",
2727
"justinrainbow/json-schema": "^5.1",
2828
"league/container": "^3.2|^4.2",

docs/insights/architecture.md

-37
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
The following insights are organised in different metrics :
44

55
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Classes` <Badge text="Architecture\Classes" type="warn" vertical="middle"/>
6-
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Composer` <Badge text="Architecture\Composer" type="warn" vertical="middle"/>
76
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Constants` <Badge text="Architecture\Constants" type="warn" vertical="middle"/>
87
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Files` <Badge text="Architecture\Files" type="warn" vertical="middle"/>
98
* `NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Functions` <Badge text="Architecture\Functions" type="warn" vertical="middle"/>
@@ -95,42 +94,6 @@ This sniff reports use of superfluous prefix or suffix "Abstract" for abstract c
9594

9695
**Insight Class**: `SlevomatCodingStandard\Sniffs\Classes\SuperfluousAbstractClassNamingSniff`
9796

98-
## `composer.json` must exist <Badge text="^1.0"/> <Badge text="Architecture\Composer" type="warn"/>
99-
100-
This insight verifies there is `composer.json`.
101-
102-
**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustExist`
103-
104-
## The name property in the `composer.json` <Badge text="^1.0"/> <Badge text="Architecture\Composer" type="warn"/>
105-
106-
This insight checks if the name section in `composer.json` contains default values (e.g. `laravel/laravel` or `symfony/symfony`).
107-
108-
**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustContainName`
109-
110-
## Composer.json must be valid <Badge text="^1.7"/> <Badge text="Architecture\Composer" type="warn"/>
111-
112-
This insight checks if the `composer.json` is valid.
113-
114-
**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerMustBeValid`
115-
116-
<details>
117-
<summary>Configuration</summary>
118-
119-
```php
120-
ComposerMustBeValid::class => [
121-
//optional configuration value for composer version 2 only
122-
//you can allow 'version' in your composer.json and disable the check of it so that you don't get an error
123-
'composerVersionCheck' => 0,
124-
]
125-
```
126-
</details>
127-
128-
## Composer.lock must be fresh <Badge text="^1.7"/> <Badge text="Architecture\Composer" type="warn"/>
129-
130-
This insight verifies that the `composer.lock` is not outdated.
131-
132-
**Insight Class**: `NunoMaduro\PhpInsights\Domain\Insights\Composer\ComposerLockMustBeFresh`
133-
13497
## Define `globals` is prohibited <Badge text="^1.0"/> <Badge text="Architecture\Constants" type="warn"/>
13598

13699
This insight disallows defining `globals`.

src/Application/Composer.php

-23
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
namespace NunoMaduro\PhpInsights\Application;
66

7-
use Composer\Semver\Semver;
8-
97
/**
108
* @internal
11-
*
12-
* @see \Tests\Application\ComposerTest
139
*/
1410
final class Composer
1511
{
@@ -51,23 +47,4 @@ public function getName(): string
5147
{
5248
return $this->config['name'] ?? '';
5349
}
54-
55-
public function hasPhpVersion(): bool
56-
{
57-
return isset($this->getRequirements()['php']);
58-
}
59-
60-
public function lowestPhpVersionIsGreaterThenOrEqualTo(string $version): bool
61-
{
62-
$composerVersion = $this->getPhpVersion();
63-
preg_match("/\d+(\.\d+)/", $composerVersion, $matches);
64-
$composerVersion = $matches[0];
65-
66-
return Semver::satisfies($composerVersion, $version);
67-
}
68-
69-
private function getPhpVersion(): string
70-
{
71-
return $this->getRequirements()['php'];
72-
}
7350
}

src/Application/DefaultPreset.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public static function get(Composer $composer): array
5252
'ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach' => true,
5353
],
5454
PropertyTypeHintSniff::class => [
55-
'enableNativeTypeHint' => $composer->hasPhpVersion()
56-
? $composer->lowestPhpVersionIsGreaterThenOrEqualTo('7.4')
57-
: PHP_VERSION_ID >= 70_400,
55+
'enableNativeTypeHint' => PHP_VERSION_ID >= 70_400,
5856
],
5957
],
6058
];

src/Domain/ComposerFinder.php

-29
This file was deleted.

src/Domain/ComposerLoader.php

-53
This file was deleted.

src/Domain/Insights/Composer/ComposerLockMustBeFresh.php

-50
This file was deleted.

src/Domain/Insights/Composer/ComposerMustBeValid.php

-72
This file was deleted.

src/Domain/Insights/Composer/ComposerMustContainName.php

-48
This file was deleted.

0 commit comments

Comments
 (0)