Skip to content

Commit ec96ded

Browse files
pushpak1300Ashley Hindle
andauthored
Update Pint Config and Add Rector
* Add Pint * Add Rector * Fix Tests --------- Co-authored-by: Ashley Hindle <[email protected]>
1 parent d33a84f commit ec96ded

File tree

78 files changed

+712
-934
lines changed

Some content is hidden

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

78 files changed

+712
-934
lines changed

all.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function packages(): \Laravel\Roster\PackageCollection
3232
$packageName = basename($dir);
3333

3434
// Skip special directories handled elsewhere in GuidelineComposer
35-
if (in_array($packageName, ['boost', 'herd'])) {
35+
if (in_array($packageName, ['boost', 'herd'], true)) {
3636
continue;
3737
}
3838

@@ -88,10 +88,10 @@ public function packages(): \Laravel\Roster\PackageCollection
8888
}
8989
};
9090

91-
$herd = new Herd();
91+
$herd = new Herd;
9292

9393
// Create GuidelineComposer with all config options enabled to get ALL guidelines
94-
$config = new GuidelineConfig();
94+
$config = new GuidelineConfig;
9595
$config->laravelStyle = true;
9696
$config->hasAnApi = true;
9797
$config->caresAboutLocalization = true;

composer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"mockery/mockery": "^1.6.12",
2929
"orchestra/testbench": "^8.36.0|^9.15.0|^10.6",
3030
"pestphp/pest": "^2.36.0|^3.8.4",
31-
"phpstan/phpstan": "^2.1.27"
31+
"phpstan/phpstan": "^2.1.27",
32+
"rector/rector": "^2.1"
3233
},
3334
"autoload": {
3435
"psr-4": {
@@ -52,12 +53,16 @@
5253
},
5354
"scripts": {
5455
"lint": [
55-
"vendor/bin/pint",
56-
"vendor/bin/phpstan"
56+
"pint",
57+
"phpstan --memory-limit=-1",
58+
"rector"
5759
],
58-
"test": [
59-
"vendor/bin/pest"
60+
"test": "pest",
61+
"test:lint": [
62+
"pint --test",
63+
"rector --dry-run"
6064
],
65+
"test:types": "phpstan",
6166
"check": [
6267
"@composer lint",
6368
"@composer test"

phpunit.xml.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<phpunit colors="true">
33
<testsuites>
44
<testsuite name="Unit">
5-
<directory suffix="Test.php">./tests/Unit</directory>
5+
<directory suffix="Test.php">tests/Unit</directory>
66
</testsuite>
77
<testsuite name="Feature">
8-
<directory suffix="Test.php">./tests/Feature</directory>
8+
<directory suffix="Test.php">tests/Feature</directory>
99
</testsuite>
1010
<testsuite name="Arch">
11-
<file>./tests/ArchTest.php</file>
11+
<file>tests/ArchTest.php</file>
1212
</testsuite>
1313
</testsuites>
1414
<php>

pint.json

Lines changed: 12 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,18 @@
11
{
2-
"preset": "empty",
2+
"preset": "laravel",
33
"rules": {
4-
"align_multiline_comment": true,
5-
"array_indentation": true,
6-
"array_syntax": {
7-
"syntax": "short"
4+
"global_namespace_import": {
5+
"import_classes": true,
6+
"import_constants": true
87
},
9-
"binary_operator_spaces": {
10-
"default": "single_space"
11-
},
12-
"blank_line_after_namespace": true,
13-
"blank_line_after_opening_tag": true,
14-
"blank_line_before_statement": {
15-
"statements": [
16-
"return"
17-
]
18-
},
19-
"blank_line_between_import_groups": true,
20-
"blank_lines_before_namespace": true,
21-
"braces_position": {
22-
"control_structures_opening_brace": "same_line",
23-
"functions_opening_brace": "next_line_unless_newline_at_signature_end",
24-
"anonymous_functions_opening_brace": "same_line",
25-
"classes_opening_brace": "next_line_unless_newline_at_signature_end",
26-
"anonymous_classes_opening_brace": "next_line_unless_newline_at_signature_end",
27-
"allow_single_line_empty_anonymous_classes": false,
28-
"allow_single_line_anonymous_functions": false
29-
},
30-
"cast_spaces": true,
31-
"class_definition": true,
32-
"class_reference_name_casing": true,
33-
"clean_namespace": true,
34-
"compact_nullable_type_declaration": true,
35-
"concat_space": true,
36-
"constant_case": {
37-
"case": "lower"
38-
},
39-
"control_structure_braces": true,
40-
"declare_equal_normalize": true,
41-
"elseif": true,
42-
"encoding": true,
8+
"phpdoc_types": false,
9+
"combine_consecutive_issets": true,
10+
"combine_consecutive_unsets": true,
4311
"explicit_string_variable": true,
44-
"full_opening_tag": true,
45-
"function_declaration": true,
46-
"heredoc_to_nowdoc": true,
47-
"include": true,
48-
"increment_style": {
49-
"style": "post"
50-
},
51-
"indentation_type": true,
52-
"integer_literal_case": true,
53-
"lambda_not_used_import": true,
54-
"line_ending": true,
55-
"list_syntax": {
56-
"syntax": "short"
57-
},
58-
"lowercase_cast": true,
59-
"lowercase_keywords": true,
60-
"lowercase_static_reference": true,
61-
"magic_constant_casing": true,
62-
"magic_method_casing": true,
63-
"method_argument_space": {
64-
"on_multiline": "ignore"
65-
},
6612
"method_chaining_indentation": true,
67-
"multiline_whitespace_before_semicolons": {
68-
"strategy": "no_multi_line"
69-
},
70-
"native_function_casing": true,
71-
"native_type_declaration_casing": true,
72-
"no_alternative_syntax": true,
73-
"no_binary_string": true,
74-
"no_blank_lines_after_class_opening": true,
75-
"no_blank_lines_after_phpdoc": true,
76-
"no_closing_tag": true,
77-
"no_empty_phpdoc": true,
78-
"no_empty_statement": true,
79-
"no_extra_blank_lines": {
80-
"tokens": [
81-
"extra",
82-
"throw",
83-
"use"
84-
]
85-
},
86-
"no_leading_import_slash": true,
87-
"no_leading_namespace_whitespace": true,
88-
"no_mixed_echo_print": {
89-
"use": "echo"
90-
},
91-
"no_multiline_whitespace_around_double_arrow": true,
92-
"no_short_bool_cast": true,
93-
"no_singleline_whitespace_before_semicolons": true,
94-
"no_space_around_double_colon": true,
95-
"no_spaces_around_offset": {
96-
"positions": [
97-
"inside",
98-
"outside"
99-
]
100-
},
101-
"no_spaces_after_function_name": true,
102-
"no_trailing_comma_in_singleline": true,
103-
"no_trailing_whitespace": true,
104-
"no_trailing_whitespace_in_comment": true,
105-
"no_unneeded_braces": true,
106-
"no_unneeded_control_parentheses": true,
107-
"no_unneeded_import_alias": true,
108-
"no_unset_cast": true,
109-
"no_unused_imports": true,
110-
"no_useless_return": true,
111-
"no_whitespace_before_comma_in_array": true,
112-
"no_whitespace_in_blank_line": true,
113-
"normalize_index_brace": true,
114-
"not_operator_with_successor_space": true,
115-
"nullable_type_declaration_for_default_null_value": true,
116-
"object_operator_without_whitespace": true,
117-
"ordered_imports": {
118-
"sort_algorithm": "alpha",
119-
"imports_order": [
120-
"const",
121-
"class",
122-
"function"
123-
]
124-
},
125-
"phpdoc_align": {
126-
"align": "left",
127-
"spacing": {
128-
"param": 1
129-
}
130-
},
131-
"phpdoc_indent": true,
132-
"phpdoc_inline_tag_normalizer": true,
133-
"phpdoc_no_access": true,
134-
"phpdoc_no_package": true,
135-
"phpdoc_no_useless_inheritdoc": true,
136-
"phpdoc_order": {
137-
"order": [
138-
"param",
139-
"return",
140-
"throws"
141-
]
142-
},
143-
"phpdoc_return_self_reference": true,
144-
"phpdoc_scalar": true,
145-
"phpdoc_separation": {
146-
"groups": [
147-
[
148-
"deprecated",
149-
"link",
150-
"see",
151-
"since"
152-
],
153-
[
154-
"author",
155-
"copyright",
156-
"license"
157-
],
158-
[
159-
"category",
160-
"package",
161-
"subpackage"
162-
],
163-
[
164-
"property",
165-
"property-read",
166-
"property-write"
167-
],
168-
[
169-
"param",
170-
"return"
171-
]
172-
]
173-
},
174-
"phpdoc_single_line_var_spacing": true,
175-
"phpdoc_summary": true,
176-
"phpdoc_trim": true,
177-
"phpdoc_types": true,
178-
"phpdoc_var_without_name": true,
179-
"return_type_declaration": {
180-
"space_before": "none"
181-
},
182-
"short_scalar_cast": true,
183-
"single_blank_line_at_eof": true,
184-
"single_class_element_per_statement": true,
185-
"single_import_per_statement": true,
186-
"single_line_after_imports": true,
187-
"single_line_comment_style": true,
188-
"single_quote": true,
189-
"space_after_semicolon": true,
190-
"spaces_inside_parentheses": true,
191-
"standardize_not_equals": true,
192-
"switch_case_semicolon_to_colon": true,
193-
"switch_case_space": true,
194-
"switch_continue_to_break": true,
195-
"ternary_operator_spaces": true,
196-
"trailing_comma_in_multiline": true,
197-
"trim_array_spaces": true,
198-
"type_declaration_spaces": true,
199-
"types_spaces": true,
200-
"unary_operator_spaces": true,
201-
"visibility_required": {
202-
"elements": [
203-
"method",
204-
"property"
205-
]
206-
},
207-
"whitespace_after_comma_in_array": true
208-
},
209-
"notPath": [
210-
"stubs/tool.stub.php"
211-
]
13+
"no_binary_string": false,
14+
"strict_comparison": true,
15+
"strict_param": true,
16+
"ternary_to_null_coalescing": true
17+
}
21218
}

rector.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
8+
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
9+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
10+
11+
return RectorConfig::configure()
12+
->withPaths([
13+
__DIR__.'/src',
14+
__DIR__.'/tests',
15+
])
16+
->withSkip([
17+
ReadOnlyPropertyRector::class,
18+
EncapsedStringsToSprintfRector::class,
19+
DisallowedEmptyRuleFixerRector::class,
20+
BooleanInBooleanNotRuleFixerRector::class,
21+
])
22+
->withPreparedSets(
23+
deadCode: true,
24+
codeQuality: true,
25+
codingStyle: true,
26+
typeDeclarations: true,
27+
earlyReturn: true,
28+
strictBooleans: true,
29+
)->withPhpSets(php81: true);

src/BoostServiceProvider.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function register(): void
4040
];
4141

4242
$cacheKey = 'boost.roster.scan';
43-
$lastModified = max(array_map(fn ($path) => file_exists($path) ? filemtime($path) : 0, $lockFiles));
43+
$lastModified = max(array_map(fn (string $path): int|false => file_exists($path) ? filemtime($path) : 0, $lockFiles));
4444

4545
$cached = cache()->get($cacheKey);
4646
if ($cached && isset($cached['timestamp']) && $cached['timestamp'] >= $lastModified) {
@@ -113,7 +113,12 @@ private function registerRoutes(): void
113113
* } $log */
114114
foreach ($logs as $log) {
115115
$logger->write(
116-
level: self::mapJsTypeToPsr3Level($log['type']),
116+
level: match ($log['type']) {
117+
'warn' => 'warning',
118+
'log', 'table' => 'debug',
119+
'window_error', 'uncaught_error', 'unhandled_rejection' => 'error',
120+
default => $log['type']
121+
},
117122
message: self::buildLogMessageFromData($log['data']),
118123
context: [
119124
'url' => $log['url'],
@@ -165,22 +170,12 @@ private function registerBrowserLogger(): void
165170

166171
private function registerBladeDirectives(BladeCompiler $bladeCompiler): void
167172
{
168-
$bladeCompiler->directive('boostJs', fn () => '<?php echo \\Laravel\\Boost\\Services\\BrowserLogger::getScript(); ?>');
169-
}
170-
171-
private static function mapJsTypeToPsr3Level(string $type): string
172-
{
173-
return match ($type) {
174-
'warn' => 'warning',
175-
'log', 'table' => 'debug',
176-
'window_error', 'uncaught_error', 'unhandled_rejection' => 'error',
177-
default => $type
178-
};
173+
$bladeCompiler->directive('boostJs', fn (): string => '<?php echo '.\Laravel\Boost\Services\BrowserLogger::class.'::getScript(); ?>');
179174
}
180175

181176
private function hookIntoResponses(Router $router): void
182177
{
183-
$this->app->booted(function () use ($router) {
178+
$this->app->booted(function () use ($router): void {
184179
$router->pushMiddlewareToGroup('web', InjectBoost::class);
185180
});
186181
}

src/Concerns/MakesHttpRequests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public function client(): PendingRequest
1717
]);
1818

1919
// Disable SSL verification for local development URLs and testing
20-
if (app()->environment(['local', 'testing']) || str_contains(config('boost.hosted.api_url', ''), '.test')) {
21-
$client = $client->withoutVerifying();
20+
if (app()->environment(['local', 'testing']) || str_contains((string) config('boost.hosted.api_url', ''), '.test')) {
21+
return $client->withoutVerifying();
2222
}
2323

2424
return $client;
@@ -30,7 +30,7 @@ public function get(string $url): Response
3030
}
3131

3232
/**
33-
* @param array<string, mixed> $json
33+
* @param array<string, mixed> $json
3434
*/
3535
public function json(string $url, array $json): Response
3636
{

0 commit comments

Comments
 (0)