Skip to content

Commit afa1ca1

Browse files
committed
Pint fixes
1 parent de2e538 commit afa1ca1

82 files changed

Lines changed: 453 additions & 431 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ jobs:
5656

5757
- name: Run PHPStan
5858
run: phpstan analyse src/ --level=8
59+
60+
# Run Pint
61+
- name: Run Pint
62+
run: vendor/bin/pint

qodana.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#-------------------------------------------------------------------------------#
2+
# Qodana analysis is configured by qodana.yaml file #
3+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4+
#-------------------------------------------------------------------------------#
5+
6+
#################################################################################
7+
# WARNING: Do not store sensitive information in this file, #
8+
# as its contents will be included in the Qodana report. #
9+
#################################################################################
10+
version: "1.0"
11+
12+
#Specify inspection profile for code analysis
13+
profile:
14+
name: qodana.starter
15+
16+
#Enable inspections
17+
#include:
18+
# - name: <SomeEnabledInspectionId>
19+
20+
#Disable inspections
21+
#exclude:
22+
# - name: <SomeDisabledInspectionId>
23+
# paths:
24+
# - <path/where/not/run/inspection>
25+
26+
php:
27+
version: 8.5 #(Applied in CI/CD pipeline)
28+
29+
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
30+
#bootstrap: sh ./prepare-qodana.sh
31+
32+
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
33+
#plugins:
34+
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
35+
36+
# Quality gate. Will fail the CI/CD pipeline if any condition is not met
37+
# severityThresholds - configures maximum thresholds for different problem severities
38+
# testCoverageThresholds - configures minimum code coverage on a whole project and newly added code
39+
# Code Coverage is available in Ultimate and Ultimate Plus plans
40+
#failureConditions:
41+
# severityThresholds:
42+
# any: 15
43+
# critical: 5
44+
# testCoverageThresholds:
45+
# fresh: 70
46+
# total: 50
47+
48+
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
49+
linter: jetbrains/qodana-php:2026.1

src/Plugin/Application/Contracts/PluginInterface.php

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

55
use Ivy\User\Application\Service\AuthService;
66

7-
interface PluginInterface {
7+
interface PluginInterface
8+
{
89
public function register(AuthService $auth): void;
10+
911
public function install(): void;
12+
1013
public function uninstall(): void;
1114
}

src/Plugin/Domain/Entity/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class Plugin extends Entity
2121
{
2222
use HasPolicies;
23-
23+
2424
protected $fillable = [
2525
'parent_id',
2626
'name',

src/Plugin/Domain/Exception/PluginException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public function __construct(
1818

1919
parent::__construct($message, 0, $previous);
2020
}
21-
}
21+
}

src/Plugin/Infrastructure/Manager/PluginManager.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
use Exception;
66
use Illuminate\Database\Capsule\Manager as Capsule;
7+
use Ivy\Plugin\Application\Contracts\PluginInterface;
8+
use Ivy\Plugin\Domain\Entity\Plugin;
79
use Ivy\Plugin\Domain\Exception\PluginException;
10+
use Ivy\Plugin\Infrastructure\Metadata\PluginInfoLoader;
811
use Ivy\Plugin\Infrastructure\Service\PluginService;
12+
use Ivy\Plugin\Presentation\Form\PluginInfoForm;
913
use Ivy\Setting\Domain\Entity\Setting;
1014
use Ivy\Template\Application\Asset\AssetPublisher;
11-
use Ivy\Plugin\Domain\Entity\Plugin;
12-
use Ivy\Plugin\Application\Contracts\PluginInterface;
13-
use Ivy\Shared\Core\Language;
14-
use Ivy\Plugin\Presentation\Form\PluginInfoForm;
15-
use Ivy\Plugin\Infrastructure\Metadata\PluginInfoLoader;
1615

1716
class PluginManager
1817
{
@@ -27,32 +26,32 @@ private function resolvePluginInterface(): PluginInterface
2726
{
2827
$class = $this->plugin->interface;
2928

30-
if (!class_exists($class)) {
29+
if (! class_exists($class)) {
3130
throw new PluginException("class {$class} not found", $this->plugin->name);
3231
}
3332

34-
$instance = new $class();
33+
$instance = new $class;
3534

36-
if (!$instance instanceof PluginInterface) {
35+
if (! $instance instanceof PluginInterface) {
3736
throw new PluginException("must implement {$class}", $this->plugin->name);
3837
}
3938

4039
return $instance;
4140
}
4241

43-
public function install():void
42+
public function install(): void
4443
{
4544
$this->plugin->authorize('install');
4645

4746
$info = (new PluginInfoLoader)->load($this->plugin->url);
4847

49-
if (!$info) {
48+
if (! $info) {
5049
throw new PluginException(message: 'contains no info.json', plugin: $this->plugin->url);
5150
}
5251

5352
$result = (new PluginInfoForm)->validate($info);
5453

55-
if (!$result->valid) {
54+
if (! $result->valid) {
5655
$errors = [];
5756

5857
foreach ($result->errors as $error) {
@@ -61,15 +60,15 @@ public function install():void
6160
}
6261
}
6362

64-
throw new PluginException(message: 'contains an invalid info.json file: ' . implode(' ', $errors), plugin: $this->plugin->url);
63+
throw new PluginException(message: 'contains an invalid info.json file: '.implode(' ', $errors), plugin: $this->plugin->url);
6564
}
6665

6766
$this->plugin->fill($result->data);
6867

6968
if (isset($info['dependencies'])) {
7069
$missing = PluginService::getMissingDependencies($info['dependencies']);
71-
if (!empty($missing)) {
72-
throw new PluginException(message: 'is missing dependencies ' . implode(', ', $missing), plugin: $this->plugin->name);
70+
if (! empty($missing)) {
71+
throw new PluginException(message: 'is missing dependencies '.implode(', ', $missing), plugin: $this->plugin->name);
7372
}
7473
}
7574

@@ -91,9 +90,9 @@ public function install():void
9190

9291
new AssetPublisher()->publishPlugin($this->plugin->url);
9392

94-
if (!empty($info['collection'])) {
93+
if (! empty($info['collection'])) {
9594

96-
$paths = glob(PluginService::getCollectionDirectory($this->plugin->url) . '[a-zA-Z0-9_-]*');
95+
$paths = glob(PluginService::getCollectionDirectory($this->plugin->url).'[a-zA-Z0-9_-]*');
9796

9897
if ($paths === false) {
9998
throw new PluginException(message: 'cannot read plugin collection directory', plugin: $this->plugin->name);
@@ -103,20 +102,20 @@ public function install():void
103102

104103
foreach ($subfolders as $subfolder) {
105104
try {
106-
$plugin = new Plugin();
105+
$plugin = new Plugin;
107106
$pluginManager = new PluginManager($plugin->fill([
108-
'url' => PluginService::getRelativePath($subfolder)
107+
'url' => PluginService::getRelativePath($subfolder),
109108
]));
110109
$pluginManager->install();
111110
} catch (PluginException $e) {
112-
throw new PluginException(message: 'cannot install plugin from its collection because ' . $e->getMessage(), plugin: $this->plugin->name, previous: $e);
111+
throw new PluginException(message: 'cannot install plugin from its collection because '.$e->getMessage(), plugin: $this->plugin->name, previous: $e);
113112
}
114113
}
115114
}
116115
});
117116
} catch (PluginException $e) {
118117
$this->resolvePluginInterface()->uninstall();
119-
throw new PluginException(message: 'installation failed. ' . $e->getMessage(), plugin: $this->plugin->name, previous: $e);
118+
throw new PluginException(message: 'installation failed. '.$e->getMessage(), plugin: $this->plugin->name, previous: $e);
120119
}
121120
}
122121

@@ -126,15 +125,15 @@ public function uninstall(): void
126125

127126
$info = (new PluginInfoLoader)->load($this->plugin->url);
128127

129-
if (!$info) {
128+
if (! $info) {
130129
throw new PluginException(message: 'has no info.json', plugin: $this->plugin->url);
131130
}
132131

133132
try {
134133
Capsule::connection()->transaction(function () use ($info) {
135-
if (!empty($info['collection'])) {
134+
if (! empty($info['collection'])) {
136135

137-
$paths = glob(PluginService::getCollectionDirectory($this->plugin->url) . '[a-zA-Z0-9_-]*');
136+
$paths = glob(PluginService::getCollectionDirectory($this->plugin->url).'[a-zA-Z0-9_-]*');
138137

139138
if ($paths === false) {
140139
throw new PluginException(message: 'cannot read plugin collection directory', plugin: $this->plugin->name);
@@ -150,7 +149,7 @@ public function uninstall(): void
150149
$pluginManager = new PluginManager($plugin);
151150
$pluginManager->uninstall();
152151
} catch (PluginException $e) {
153-
throw new PluginException(message: 'cannot uninstall plugin from its collection because ' . $e->getMessage(), plugin: $this->plugin->name, previous: $e);
152+
throw new PluginException(message: 'cannot uninstall plugin from its collection because '.$e->getMessage(), plugin: $this->plugin->name, previous: $e);
154153
}
155154
}
156155
}
@@ -159,7 +158,7 @@ public function uninstall(): void
159158
$this->plugin->delete();
160159
});
161160
} catch (PluginException $e) {
162-
throw new PluginException(message: 'cannot uninstall plugin because ' . $e->getMessage(), plugin: $this->plugin->name, previous: $e);
161+
throw new PluginException(message: 'cannot uninstall plugin because '.$e->getMessage(), plugin: $this->plugin->name, previous: $e);
163162
}
164163

165164
$this->resolvePluginInterface()->uninstall();

src/Plugin/Infrastructure/Metadata/PluginInfo.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
final readonly class PluginInfo
66
{
77
/**
8-
* @param array<string> $collection
9-
* @param array<string, mixed> $settings
10-
* @param array<string, mixed> $actions
11-
* @param array<string> $dependencies
8+
* @param array<string> $collection
9+
* @param array<string, mixed> $settings
10+
* @param array<string, mixed> $actions
11+
* @param array<string> $dependencies
1212
*/
1313
public function __construct(
14-
public string $name,
15-
public string $interface,
14+
public string $name,
15+
public string $interface,
1616
public ?string $version,
1717
public ?string $description,
18-
public string $url,
18+
public string $url,
1919
public ?string $type,
20-
public array $collection = [],
21-
public array $settings = [],
22-
public array $actions = [],
23-
public array $dependencies = [],
20+
public array $collection = [],
21+
public array $settings = [],
22+
public array $actions = [],
23+
public array $dependencies = [],
2424
) {}
2525

2626
public function hasCollection(): bool

src/Plugin/Infrastructure/Metadata/PluginInfoFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
class PluginInfoFactory
66
{
77
/**
8-
* @param mixed[] $data
9-
* @return PluginInfo
8+
* @param mixed[] $data
109
*/
1110
public function make(array $data): PluginInfo
1211
{

src/Plugin/Infrastructure/Metadata/PluginInfoLoader.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
class PluginInfoLoader
99
{
1010
/**
11-
* @param string $url
1211
* @return array<string, mixed>|null
1312
*
1413
* @throws Exception
1514
*/
16-
public function load(string $url): array|null
15+
public function load(string $url): ?array
1716
{
18-
return PluginService::parseJson($url . DIRECTORY_SEPARATOR . 'info.json');
17+
return PluginService::parseJson($url.DIRECTORY_SEPARATOR.'info.json');
1918
}
2019
}

src/Plugin/Infrastructure/Registry/PluginRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class PluginRegistry
1010
private static array $active = [];
1111

1212
/**
13-
* @param array<string, mixed> $active
13+
* @param array<string, mixed> $active
1414
*/
1515
public static function setActive(array $active): void
1616
{

0 commit comments

Comments
 (0)