Skip to content

Commit

Permalink
style: fix code styling and formatting issues (#338)
Browse files Browse the repository at this point in the history
Using the latest version of the PHP CS configuration, update all source code to use the most recent code style and formatting rules. For the most part this updates the header comment and the strict type declaration. It should not have any affect on the working of the tests nor the main code.

Signed-off-by: Sacha Telgenhof <[email protected]>
  • Loading branch information
stelgenhof committed Oct 24, 2024
1 parent d10ffc0 commit d06ce02
Show file tree
Hide file tree
Showing 1,692 changed files with 10,157 additions and 5,281 deletions.
14 changes: 11 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the Yasumi package.
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand All @@ -13,7 +15,13 @@
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

$config = new AzuyaLabs\PhpCsFixerConfig\Config();
$config = new AzuyaLabs\PhpCsFixerConfig\Config('2015', null, 'Yasumi');
$config->getFinder()->in(__DIR__)->notPath('var');

$defaults = $config->getRules();

$config->setRules(array_merge($defaults, [
'php_unit_method_casing' => ['case' => 'camel_case'],
]));

return $config;
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
},
"require-dev": {
"ext-intl": "*",
"azuyalabs/php-cs-fixer-config": "^0.1",
"friendsofphp/php-cs-fixer": "^2.19 || 3.48",
"azuyalabs/php-cs-fixer-config": "^0.3",
"mikey179/vfsstream": "^1.6",
"phan/phan": "^5.4",
"phpstan/phpstan": "^1.10",
Expand Down
33 changes: 23 additions & 10 deletions examples/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,59 @@

// This file demonstrates the general use of Yasumi and its basic methods.

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

require 'vendor/autoload.php';

// Use the factory to create a new holiday provider instance
$holidays = Yasumi\Yasumi::create('USA', (int) date('Y'));

// Show the number of defined holidays
echo 'Number of defined holidays: '.$holidays->count().PHP_EOL;
echo 'Number of defined holidays: ' . $holidays->count() . PHP_EOL;
echo PHP_EOL;

// Display a list all of the holiday names (short names)
echo 'List of all the holiday names: '.PHP_EOL;
echo 'List of all the holiday names: ' . PHP_EOL;
foreach ($holidays->getHolidayNames() as $name) {
echo $name.PHP_EOL;
echo $name . PHP_EOL;
}
echo PHP_EOL;

// Display a list all of the holiday dates
echo 'List of all the holiday dates:'.PHP_EOL;
echo 'List of all the holiday dates:' . PHP_EOL;
foreach ($holidays->getHolidayDates() as $date) {
echo $date.PHP_EOL;
echo $date . PHP_EOL;
}
echo PHP_EOL;

// Get a holiday instance for Independence Day
$independenceDay = $holidays->getHoliday('independenceDay');

// Show the localized name
echo 'Name of the holiday : '.$independenceDay->getName().PHP_EOL;
echo 'Name of the holiday : ' . $independenceDay->getName() . PHP_EOL;

// Show the date
echo 'Date of the holiday : '.$independenceDay.PHP_EOL;
echo 'Date of the holiday : ' . $independenceDay . PHP_EOL;

// Show the type of holiday
echo 'Type of holiday : '.$independenceDay->getType().PHP_EOL;
echo 'Type of holiday : ' . $independenceDay->getType() . PHP_EOL;
echo PHP_EOL;

// Dump the holiday as a JSON object
echo 'Holiday as a JSON object:'.PHP_EOL;
echo 'Holiday as a JSON object:' . PHP_EOL;
echo json_encode($independenceDay, JSON_PRETTY_PRINT);

echo PHP_EOL;
25 changes: 19 additions & 6 deletions examples/between_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
// This file demonstrates the use of the `between` filter, selecting only a number of holidays
// that fall in the given date range.

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

require 'vendor/autoload.php';

Expand All @@ -12,16 +25,16 @@
// Use the factory to create a new holiday provider instance
$holidays = Yasumi\Yasumi::create('Italy', $year);
$holidaysInDecember = $holidays->between(
new DateTime('12/01/'.$year),
new DateTime('12/31/'.$year)
new DateTime('12/01/' . $year),
new DateTime('12/31/' . $year)
);

// Show all holidays in Italy for December
echo 'List of all the holidays in December: '.PHP_EOL;
echo 'List of all the holidays in December: ' . PHP_EOL;
foreach ($holidaysInDecember as $holiday) {
echo $holiday.' - '.$holiday->getName().PHP_EOL;
echo $holiday . ' - ' . $holiday->getName() . PHP_EOL;
}
echo PHP_EOL;

// Show the number of filtered holidays
echo 'Number of filtered holidays: '.$holidaysInDecember->count().PHP_EOL;
echo 'Number of filtered holidays: ' . $holidaysInDecember->count() . PHP_EOL;
21 changes: 17 additions & 4 deletions examples/custom_provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
// those scenarios where you would need only a subset of holidays of an existing provider. Or, if you you like to
// extend an existing provider with additional, non-standard holidays.

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

require 'vendor/autoload.php';

Expand Down Expand Up @@ -33,11 +46,11 @@ public function initialize(): void
$NYSEHolidays = Yasumi\Yasumi::create(NYSE::class, (int) date('Y'));

// We then can retrieve the NYSE observed holidays in the usual manner:
echo 'List of all the holiday names: '.PHP_EOL;
echo 'List of all the holiday names: ' . PHP_EOL;
foreach ($NYSEHolidays->getHolidayNames() as $day) {
echo $day.PHP_EOL;
echo $day . PHP_EOL;
}
echo PHP_EOL;

// Use the count() method to show how many holidays are returned
echo 'Number of defined holidays: '.$NYSEHolidays->count().PHP_EOL;
echo 'Number of defined holidays: ' . $NYSEHolidays->count() . PHP_EOL;
19 changes: 16 additions & 3 deletions examples/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
// based on certain conditions. In this examples we show only the holidays that are
// marked as 'official'.

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

require 'vendor/autoload.php';

Expand All @@ -14,7 +27,7 @@
// Create a filter instance for the official holidays
$official = new Yasumi\Filters\OfficialHolidaysFilter($holidays->getIterator());

echo 'List of all official holidays: '.PHP_EOL;
echo 'List of all official holidays: ' . PHP_EOL;
foreach ($official as $day) {
echo $day->getName().PHP_EOL;
echo $day->getName() . PHP_EOL;
}
15 changes: 14 additions & 1 deletion phpinsights.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

return [
/*
Expand Down
19 changes: 16 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// single rules
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Exception/Exception.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Exception/InvalidYearException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Exception/MissingTranslationException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Exception/ProviderNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Exception/UnknownLocaleException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Filters/AbstractFilter.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Filters/BankHolidaysFilter.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
8 changes: 5 additions & 3 deletions src/Yasumi/Filters/BetweenFilter.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

declare(strict_types=1);
declare(strict_types = 1);

/*
* This file is part of the Yasumi package.
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2024 AzuyaLabs
*
Expand Down
Loading

0 comments on commit d06ce02

Please sign in to comment.