Skip to content

Commit 64a46d7

Browse files
authored
Merge pull request #3286 from briannesbitt/analysis-42mnON
Apply fixes from StyleCI
2 parents 8979a41 + 0d970f7 commit 64a46d7

File tree

6 files changed

+405
-405
lines changed

6 files changed

+405
-405
lines changed

tools/check.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
$documentation = implode("\n", array_map(
2020
file_get_contents(...),
2121
[
22-
...glob(__DIR__ . '/../docs/guide/**/*.md'),
23-
...glob(__DIR__ . '/../docs/parts/**/*.md'),
22+
...glob(__DIR__.'/../docs/guide/**/*.md'),
23+
...glob(__DIR__.'/../docs/parts/**/*.md'),
2424
],
2525
));
2626

tools/generate-api.php

Lines changed: 89 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414

1515
use function Carbon\Doc\Methods\methods;
1616

17-
require __DIR__ . '/../vendor/autoload.php';
18-
require __DIR__ . '/methods.php';
17+
require __DIR__.'/../vendor/autoload.php';
18+
require __DIR__.'/methods.php';
1919

20-
$destination_file = __DIR__ . '/../docs/develop/reference.md';
20+
$destination_file = __DIR__.'/../docs/develop/reference.md';
2121

2222
trait MacroExposer
2323
{
24-
public function getMacros()
25-
{
26-
$class = get_called_class();
24+
public function getMacros()
25+
{
26+
$class = get_called_class();
2727

28-
return $class::$global_macros ?? FactoryImmutable::getDefaultInstance()->getSettings()['macros'];
29-
}
28+
return $class::$global_macros ?? FactoryImmutable::getDefaultInstance()->getSettings()['macros'];
29+
}
3030
}
3131

3232
class BusinessTimeCarbon extends Carbon
3333
{
34-
use MacroExposer;
34+
use MacroExposer;
3535
}
3636

3737
function history_line($event, $version, $ref): array
@@ -57,11 +57,11 @@ function table_markdown(array $table, ?array $header = null): string
5757
);
5858

5959
return implode("\n", array_map(
60-
static fn (array $row) => '|' . (str_starts_with($row[0], '--') ? ':' : ' ') . implode(' | ', array_map(
60+
static fn (array $row) => '|'.(str_starts_with($row[0], '--') ? ':' : ' ').implode(' | ', array_map(
6161
static fn (string $cell, int $size) => str_pad($cell, $size),
6262
$row,
6363
$sizes,
64-
)) . ' |',
64+
)).' |',
6565
[
6666
$header,
6767
array_map(static fn (int $size) => str_repeat('-', $size), $sizes),
@@ -72,73 +72,72 @@ function table_markdown(array $table, ?array $header = null): string
7272

7373
function get_classes(): Generator
7474
{
75-
if (class_exists(Carbon::class)) {
76-
yield [
77-
new Carbon(),
78-
new DateTime(),
75+
if (class_exists(Carbon::class)) {
76+
yield [
77+
new Carbon(),
78+
new DateTime(),
7979
];
8080

81-
if (class_exists(BusinessTime::class)) {
82-
yield [
83-
BusinessTime::enable(BusinessTimeCarbon::class),
84-
new Carbon(),
85-
Carbon::class,
86-
'Requires <a href="https://github.com/kylekatarnls/business-time">cmixin/business-time</a>',
87-
new BusinessTimeCarbon(),
81+
if (class_exists(BusinessTime::class)) {
82+
yield [
83+
BusinessTime::enable(BusinessTimeCarbon::class),
84+
new Carbon(),
85+
Carbon::class,
86+
'Requires <a href="https://github.com/kylekatarnls/business-time">cmixin/business-time</a>',
87+
new BusinessTimeCarbon(),
8888
];
89-
}
90-
91-
if (trait_exists(SeasonMixin::class)) {
92-
BusinessTimeCarbon::mixin(SeasonMixin::class);
93-
94-
yield [
95-
new BusinessTimeCarbon(),
96-
new Carbon(),
97-
Carbon::class,
98-
'Requires <a href="https://github.com/kylekatarnls/season">cmixin/season</a>',
99-
new class() extends BusinessTimeCarbon
100-
{
101-
use SeasonMixin;
102-
},
103-
SeasonMixin::class,
89+
}
90+
91+
if (trait_exists(SeasonMixin::class)) {
92+
BusinessTimeCarbon::mixin(SeasonMixin::class);
93+
94+
yield [
95+
new BusinessTimeCarbon(),
96+
new Carbon(),
97+
Carbon::class,
98+
'Requires <a href="https://github.com/kylekatarnls/season">cmixin/season</a>',
99+
new class() extends BusinessTimeCarbon {
100+
use SeasonMixin;
101+
},
102+
SeasonMixin::class,
104103
];
105-
}
106-
}
104+
}
105+
}
107106

108-
if (class_exists(CarbonInterval::class)) {
109-
yield [
110-
new CarbonInterval(0, 0, 0, 1),
111-
new DateInterval('P1D'),
107+
if (class_exists(CarbonInterval::class)) {
108+
yield [
109+
new CarbonInterval(0, 0, 0, 1),
110+
new DateInterval('P1D'),
112111
];
113-
}
112+
}
114113

115-
if (class_exists(CarbonPeriod::class)) {
116-
yield [
117-
new CarbonPeriod(),
118-
new stdClass(),
114+
if (class_exists(CarbonPeriod::class)) {
115+
yield [
116+
new CarbonPeriod(),
117+
new stdClass(),
119118
];
120-
}
119+
}
121120

122-
if (class_exists(CarbonTimeZone::class)) {
123-
yield [
124-
new CarbonTimeZone('Europe/Paris'),
125-
new DateTimeZone('Europe/Paris'),
121+
if (class_exists(CarbonTimeZone::class)) {
122+
yield [
123+
new CarbonTimeZone('Europe/Paris'),
124+
new DateTimeZone('Europe/Paris'),
126125
];
127-
}
126+
}
128127

129-
if (class_exists(Translator::class)) {
130-
yield [
131-
new Translator('en'),
132-
new SymfonyTranslator('en'),
128+
if (class_exists(Translator::class)) {
129+
yield [
130+
new Translator('en'),
131+
new SymfonyTranslator('en'),
133132
];
134-
}
133+
}
135134

136-
if (class_exists(Language::class)) {
137-
yield [
138-
new Language('en'),
139-
new stdClass(),
135+
if (class_exists(Language::class)) {
136+
yield [
137+
new Language('en'),
138+
new stdClass(),
140139
];
141-
}
140+
}
142141
}
143142

144143
function get_doc_blocks(): array
@@ -154,7 +153,7 @@ function get_doc_blocks(): array
154153
foreach (methods(false, false) as [$carbon_object, $class_name, $method, $parameters, $return, $description, $dateTimeObject, $info]) {
155154
$classes[$class_name] ??= new ReflectionClass($class_name);
156155

157-
$name = $classes[$class_name]->getShortName() . '::' . $method;
156+
$name = $classes[$class_name]->getShortName().'::'.$method;
158157

159158
try {
160159
$doc_comment = $classes[$class_name]->getMethod($method)->getDocComment();
@@ -177,7 +176,7 @@ function get_doc_blocks(): array
177176
$global_history = @json_decode(file_get_contents('history.json'), true);
178177

179178
foreach (get_doc_blocks() as $name => $docblock) {
180-
$markdown .= "#### $name\n\n";
179+
$markdown .= "#### $name\n\n";
181180

182181
if (is_array($docblock)) {
183182
[$description, $parameters, $return, $info] = $docblock;
@@ -217,55 +216,55 @@ function get_doc_blocks(): array
217216
}
218217
}
219218

220-
$deprecated = $docblock->getTagsByName('deprecated');
219+
$deprecated = $docblock->getTagsByName('deprecated');
221220

222221
foreach ($deprecated as $tag) {
223222
$markdown .= "::: warning Deprectated \n$tag\n:::\n";
224223
}
225224

226-
$parameters = $docblock->getTagsByName('param');
225+
$parameters = $docblock->getTagsByName('param');
227226

228-
if ($parameters !== []) {
229-
$markdown .= "##### Parameters\n";
227+
if ($parameters !== []) {
228+
$markdown .= "##### Parameters\n";
230229

231-
foreach ($parameters as $tag) {
232-
$markdown .= "- \${$tag->getVariableName()} `{$tag->getType()}`";
233-
$description = trim($tag->getDescription());
230+
foreach ($parameters as $tag) {
231+
$markdown .= "- \${$tag->getVariableName()} `{$tag->getType()}`";
232+
$description = trim($tag->getDescription());
234233

235-
// if description is multiline, indent lines
234+
// if description is multiline, indent lines
236235
$description = str_contains($description, "\n")
237-
? "\n " . str_replace("\n", "\n ", $description)
236+
? "\n ".str_replace("\n", "\n ", $description)
238237
: " $description";
239-
$markdown .= "$description\n";
240-
}
238+
$markdown .= "$description\n";
239+
}
241240

242241
$markdown .= "\n";
243-
}
242+
}
244243

245-
$return = $docblock->getTagsByName('return');
244+
$return = $docblock->getTagsByName('return');
246245

247246
foreach ($return as $tag) {
248247
$markdown .= "returns `$tag`\n\n";
249248
}
250249

251-
$examples = $docblock->getTagsByName('example');
250+
$examples = $docblock->getTagsByName('example');
252251

253-
if ($examples !== []) {
254-
$markdown .= "##### Examples\n";
252+
if ($examples !== []) {
253+
$markdown .= "##### Examples\n";
255254

256-
foreach ($examples as $tag) {
257-
$value = trim($tag->__toString());
255+
foreach ($examples as $tag) {
256+
$value = trim($tag->__toString());
258257

259-
// add ```php` if not specified
260-
$markdown .= preg_replace('/^```(?!\w)/m', '```php', $value, 1) . "\n";
261-
}
258+
// add ```php` if not specified
259+
$markdown .= preg_replace('/^```(?!\w)/m', '```php', $value, 1)."\n";
260+
}
262261

263262
$markdown .= "\n";
264-
}
263+
}
265264

266265
$history = [];
267266
[$class_name, $method] = explode('::', $name);
268-
$fqcn = 'Carbon\\' . $class_name;
267+
$fqcn = 'Carbon\\'.$class_name;
269268

270269
$key = class_exists($fqcn) ? "$fqcn::$method" : $name;
271270
$parameters = implode(', ', $parameters ?: []);
@@ -290,7 +289,7 @@ function get_doc_blocks(): array
290289
}
291290

292291
if ($history !== []) {
293-
$markdown .= table_markdown($history, ['History', 'Version', 'Description']) . "\n\n";
292+
$markdown .= table_markdown($history, ['History', 'Version', 'Description'])."\n\n";
294293
}
295294

296295
$markdown .= "----------\n\n";

0 commit comments

Comments
 (0)