Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions docs/develop/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[Complete commits list](https://github.com/CarbonPHP/carbon/compare/3.10.2...3.10.3)

New contributors:
* @sammyaxe made their first contribution in https://github.com/briannesbitt/Carbon/pull/3215
* @sammyaxe made their first contribution in [briannesbitt/Carbon#3215](https://github.com/briannesbitt/Carbon/pull/3215)


#### 3.10.3 (2 August 2025)
Expand All @@ -22,8 +22,8 @@ New contributors:
[Complete commits list](https://github.com/CarbonPHP/carbon/compare/3.10.1...3.10.2)

New contributors:
* @Disservin made their first contribution in https://github.com/briannesbitt/Carbon/pull/3213
* @Joeb454 made their first contribution in https://github.com/briannesbitt/Carbon/pull/3218
* @Disservin made their first contribution in [briannesbitt/Carbon#3213](https://github.com/briannesbitt/Carbon/pull/3213)
* @Joeb454 made their first contribution in [briannesbitt/Carbon#3218](https://github.com/briannesbitt/Carbon/pull/3218)


#### 3.10.2 (21 June 2025)
Expand All @@ -48,8 +48,8 @@ New contributors:
[Complete commits list](https://github.com/CarbonPHP/carbon/compare/3.9.1...3.10.0)

New contributors:
* @nesl247 made their first contribution in https://github.com/CarbonPHP/carbon/pull/42
* @aavtukhovich made their first contribution in https://github.com/CarbonPHP/carbon/pull/45
* @nesl247 made their first contribution in [CarbonPHP/carbon#42](https://github.com/CarbonPHP/carbon/pull/42)
* @aavtukhovich made their first contribution in [CarbonPHP/carbon#45](https://github.com/CarbonPHP/carbon/pull/45)


#### 3.10.0 (1 May 2025)
Expand All @@ -68,9 +68,9 @@ New contributors:
[Complete commits list](https://github.com/CarbonPHP/carbon/compare/3.9.0...3.9.1)

New contributors:
* @daniser made their first contribution in https://github.com/briannesbitt/Carbon/pull/3169
* @liamduckett made their first contribution in https://github.com/briannesbitt/Carbon/pull/3174
* @riesjart made their first contribution in https://github.com/briannesbitt/Carbon/pull/3176
* @daniser made their first contribution in [briannesbitt/Carbon#3169](https://github.com/briannesbitt/Carbon/pull/3169)
* @liamduckett made their first contribution in [briannesbitt/Carbon#3174](https://github.com/briannesbitt/Carbon/pull/3174)
* @riesjart made their first contribution in [briannesbitt/Carbon#3176](https://github.com/briannesbitt/Carbon/pull/3176)


#### 3.9.1 (27 March 2025)
Expand All @@ -80,8 +80,8 @@ New contributors:
[Complete commits list](https://github.com/CarbonPHP/carbon/compare/3.8.6...3.9.0)

New contributors:
* @cdburgess made their first contribution in https://github.com/CarbonPHP/carbon/pull/22
* @AndrewMast made their first contribution in https://github.com/CarbonPHP/carbon/pull/27
* @cdburgess made their first contribution in [CarbonPHP/carbon#22](https://github.com/CarbonPHP/carbon/pull/22)
* @AndrewMast made their first contribution in [CarbonPHP/carbon#27](https://github.com/CarbonPHP/carbon/pull/27)


#### 3.9.0 (20 February 2025)
Expand All @@ -98,7 +98,7 @@ New contributors:
[Complete commits list](https://github.com/briannesbitt/Carbon/compare/3.8.4...3.8.5)

New contributors:
* @novruzrhmv made their first contribution in https://github.com/briannesbitt/Carbon/pull/3144
* @novruzrhmv made their first contribution in [briannesbitt/Carbon#3144](https://github.com/briannesbitt/Carbon/pull/3144)


#### 3.8.5 (27 December 2024)
Expand All @@ -116,9 +116,9 @@ New contributors:
[Complete commits list](https://github.com/briannesbitt/Carbon/compare/3.8.2...3.8.3)

New contributors:
* @c-Rolland made their first contribution in https://github.com/briannesbitt/Carbon/pull/3110
* @Mejans made their first contribution in https://github.com/briannesbitt/Carbon/pull/3115
* @koprivan made their first contribution in https://github.com/briannesbitt/Carbon/pull/3122
* @c-Rolland made their first contribution in [briannesbitt/Carbon#3110](https://github.com/briannesbitt/Carbon/pull/3110)
* @Mejans made their first contribution in [briannesbitt/Carbon#3115](https://github.com/briannesbitt/Carbon/pull/3115)
* @koprivan made their first contribution in [briannesbitt/Carbon#3122](https://github.com/briannesbitt/Carbon/pull/3122)


#### 3.8.3 (7 November 2024)
Expand Down Expand Up @@ -152,7 +152,7 @@ New contributors:
[Complete commits list](https://github.com/briannesbitt/Carbon/compare/3.7.0...3.8.0)

New contributors:
* @DannyJJK made their first contribution in https://github.com/briannesbitt/Carbon/pull/3060
* @DannyJJK made their first contribution in [briannesbitt/Carbon#3060](https://github.com/briannesbitt/Carbon/pull/3060)


#### 3.8.0 (16 July 2024)
Expand All @@ -164,9 +164,9 @@ New contributors:
[Complete commits list](https://github.com/briannesbitt/Carbon/compare/3.6.0...3.7.0)

New contributors:
* @faissaloux made their first contribution in https://github.com/briannesbitt/Carbon/pull/3043
* @philbates35 made their first contribution in https://github.com/briannesbitt/Carbon/pull/3047
* @marcheffels made their first contribution in https://github.com/briannesbitt/Carbon/pull/3045
* @faissaloux made their first contribution in [briannesbitt/Carbon#3043](https://github.com/briannesbitt/Carbon/pull/3043)
* @philbates35 made their first contribution in [briannesbitt/Carbon#3047](https://github.com/briannesbitt/Carbon/pull/3047)
* @marcheffels made their first contribution in [briannesbitt/Carbon#3045](https://github.com/briannesbitt/Carbon/pull/3045)


#### 3.7.0 (20 June 2024)
Expand Down
510 changes: 255 additions & 255 deletions releases.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tools/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
$documentation = implode("\n", array_map(
file_get_contents(...),
[
...glob(__DIR__ . '/../docs/guide/**/*.md'),
...glob(__DIR__ . '/../docs/parts/**/*.md'),
...glob(__DIR__.'/../docs/guide/**/*.md'),
...glob(__DIR__.'/../docs/parts/**/*.md'),
],
));

Expand Down
179 changes: 89 additions & 90 deletions tools/generate-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@

use function Carbon\Doc\Methods\methods;

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/methods.php';
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/methods.php';

$destination_file = __DIR__ . '/../docs/develop/reference.md';
$destination_file = __DIR__.'/../docs/develop/reference.md';

trait MacroExposer
{
public function getMacros()
{
$class = get_called_class();
public function getMacros()
{
$class = get_called_class();

return $class::$global_macros ?? FactoryImmutable::getDefaultInstance()->getSettings()['macros'];
}
return $class::$global_macros ?? FactoryImmutable::getDefaultInstance()->getSettings()['macros'];
}
}

class BusinessTimeCarbon extends Carbon
{
use MacroExposer;
use MacroExposer;
}

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

return implode("\n", array_map(
static fn (array $row) => '|' . (str_starts_with($row[0], '--') ? ':' : ' ') . implode(' | ', array_map(
static fn (array $row) => '|'.(str_starts_with($row[0], '--') ? ':' : ' ').implode(' | ', array_map(
static fn (string $cell, int $size) => str_pad($cell, $size),
$row,
$sizes,
)) . ' |',
)).' |',
[
$header,
array_map(static fn (int $size) => str_repeat('-', $size), $sizes),
Expand All @@ -72,73 +72,72 @@ function table_markdown(array $table, ?array $header = null): string

function get_classes(): Generator
{
if (class_exists(Carbon::class)) {
yield [
new Carbon(),
new DateTime(),
if (class_exists(Carbon::class)) {
yield [
new Carbon(),
new DateTime(),
];

if (class_exists(BusinessTime::class)) {
yield [
BusinessTime::enable(BusinessTimeCarbon::class),
new Carbon(),
Carbon::class,
'Requires <a href="https://github.com/kylekatarnls/business-time">cmixin/business-time</a>',
new BusinessTimeCarbon(),
if (class_exists(BusinessTime::class)) {
yield [
BusinessTime::enable(BusinessTimeCarbon::class),
new Carbon(),
Carbon::class,
'Requires <a href="https://github.com/kylekatarnls/business-time">cmixin/business-time</a>',
new BusinessTimeCarbon(),
];
}

if (trait_exists(SeasonMixin::class)) {
BusinessTimeCarbon::mixin(SeasonMixin::class);

yield [
new BusinessTimeCarbon(),
new Carbon(),
Carbon::class,
'Requires <a href="https://github.com/kylekatarnls/season">cmixin/season</a>',
new class() extends BusinessTimeCarbon
{
use SeasonMixin;
},
SeasonMixin::class,
}

if (trait_exists(SeasonMixin::class)) {
BusinessTimeCarbon::mixin(SeasonMixin::class);

yield [
new BusinessTimeCarbon(),
new Carbon(),
Carbon::class,
'Requires <a href="https://github.com/kylekatarnls/season">cmixin/season</a>',
new class() extends BusinessTimeCarbon {
use SeasonMixin;
},
SeasonMixin::class,
];
}
}
}
}

if (class_exists(CarbonInterval::class)) {
yield [
new CarbonInterval(0, 0, 0, 1),
new DateInterval('P1D'),
if (class_exists(CarbonInterval::class)) {
yield [
new CarbonInterval(0, 0, 0, 1),
new DateInterval('P1D'),
];
}
}

if (class_exists(CarbonPeriod::class)) {
yield [
new CarbonPeriod(),
new stdClass(),
if (class_exists(CarbonPeriod::class)) {
yield [
new CarbonPeriod(),
new stdClass(),
];
}
}

if (class_exists(CarbonTimeZone::class)) {
yield [
new CarbonTimeZone('Europe/Paris'),
new DateTimeZone('Europe/Paris'),
if (class_exists(CarbonTimeZone::class)) {
yield [
new CarbonTimeZone('Europe/Paris'),
new DateTimeZone('Europe/Paris'),
];
}
}

if (class_exists(Translator::class)) {
yield [
new Translator('en'),
new SymfonyTranslator('en'),
if (class_exists(Translator::class)) {
yield [
new Translator('en'),
new SymfonyTranslator('en'),
];
}
}

if (class_exists(Language::class)) {
yield [
new Language('en'),
new stdClass(),
if (class_exists(Language::class)) {
yield [
new Language('en'),
new stdClass(),
];
}
}
}

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

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

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

foreach (get_doc_blocks() as $name => $docblock) {
$markdown .= "#### $name\n\n";
$markdown .= "#### $name\n\n";

if (is_array($docblock)) {
[$description, $parameters, $return, $info] = $docblock;
Expand Down Expand Up @@ -217,55 +216,55 @@ function get_doc_blocks(): array
}
}

$deprecated = $docblock->getTagsByName('deprecated');
$deprecated = $docblock->getTagsByName('deprecated');

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

$parameters = $docblock->getTagsByName('param');
$parameters = $docblock->getTagsByName('param');

if ($parameters !== []) {
$markdown .= "##### Parameters\n";
if ($parameters !== []) {
$markdown .= "##### Parameters\n";

foreach ($parameters as $tag) {
$markdown .= "- \${$tag->getVariableName()} `{$tag->getType()}`";
$description = trim($tag->getDescription());
foreach ($parameters as $tag) {
$markdown .= "- \${$tag->getVariableName()} `{$tag->getType()}`";
$description = trim($tag->getDescription());

// if description is multiline, indent lines
// if description is multiline, indent lines
$description = str_contains($description, "\n")
? "\n " . str_replace("\n", "\n ", $description)
? "\n ".str_replace("\n", "\n ", $description)
: " $description";
$markdown .= "$description\n";
}
$markdown .= "$description\n";
}

$markdown .= "\n";
}
}

$return = $docblock->getTagsByName('return');
$return = $docblock->getTagsByName('return');

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

$examples = $docblock->getTagsByName('example');
$examples = $docblock->getTagsByName('example');

if ($examples !== []) {
$markdown .= "##### Examples\n";
if ($examples !== []) {
$markdown .= "##### Examples\n";

foreach ($examples as $tag) {
$value = trim($tag->__toString());
foreach ($examples as $tag) {
$value = trim($tag->__toString());

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

$markdown .= "\n";
}
}

$history = [];
[$class_name, $method] = explode('::', $name);
$fqcn = 'Carbon\\' . $class_name;
$fqcn = 'Carbon\\'.$class_name;

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

if ($history !== []) {
$markdown .= table_markdown($history, ['History', 'Version', 'Description']) . "\n\n";
$markdown .= table_markdown($history, ['History', 'Version', 'Description'])."\n\n";
}

$markdown .= "----------\n\n";
Expand Down
Loading