Skip to content

Commit

Permalink
Configure compact brace position PHPCSFixer (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank authored Nov 18, 2024
1 parent fd9edb6 commit 44157e5
Show file tree
Hide file tree
Showing 133 changed files with 632 additions and 1,262 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'phpdoc_separation' => ['groups' => [['deprecated', 'internal'], ['standard', 'source'], ['covers', 'coversDefaultClass'], ['template', 'implements', 'extends', 'param', 'throws', 'return']]],
'phpdoc_trim' => true,
'concat_space' => ['spacing' => 'one'],
'braces_position' => ['classes_opening_brace' => 'same_line', 'control_structures_opening_brace' => 'same_line', 'functions_opening_brace' => 'same_line'],
]
)->setFinder(
PhpCsFixer\Finder::create()
Expand Down
15 changes: 5 additions & 10 deletions dev/DataSource/Mapping/CountryMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
* @template TDataSet of object{name: string, name_french: string, alpha2: string, alpha3: string, numeric: string, subdivisions: array<string, object{category: string, code: string, same_as_country: ?CountryAlpha2, parent: ?string, names: non-empty-list<object{name: string, note: ?string, languages: list<CountryAlpha2>, romanization_system: ?string, local_variant: ?string}&stdClass>}&stdClass>}&stdClass
* @implements Mapping<TDataSet>
*/
class CountryMapping implements Mapping
{
public static function url(): string
{
class CountryMapping implements Mapping {
public static function url(): string {
return 'https://www.iso.org/obp/ui/#search/code/';
}

Expand All @@ -49,8 +47,7 @@ public static function url(): string
* @throws TypeError
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$client->waitFor('#onetrust-accept-btn-handler');
$cookieButton = $crawler->filterXPath(".//button[@id='onetrust-accept-btn-handler']");
$cookieButton->click();
Expand Down Expand Up @@ -162,8 +159,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @throws ShouldNotHappenException
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$countryName = new SpecFile(CountryName::class, KeySorting::class);
$countryAlpha2 = (new SpecFile(CountryAlpha2::class, KeySorting::class))
->addMethod($getSubdivisionsMethod = new EnumMappingMethod('getSubdivisions', 'array', '[]', '/** @return list<CountrySubdivision> */'));
Expand Down Expand Up @@ -205,8 +201,7 @@ public static function toEnumMapping(array $dataSet): array
}

/** @return array{0: string, 1: ?string} */
private static function getNameNote(string $text): array
{
private static function getNameNote(string $text): array {
if (($notePos = strpos($text, '(see also')) !== false) {
return [rtrim(substr($text, 0, $notePos), ' '), ltrim(rtrim(substr($text, $notePos - 1), ')'), '(')];
}
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/CurrencyMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,16 @@
* @template TDataSet of object{CtryNm: string, CcyNm: string, Ccy: string|null, CcyNbr: string|null, CcyMnrUnts: string|null}&stdClass
* @implements Mapping<TDataSet>
*/
class CurrencyMapping implements Mapping
{
public static function url(): string
{
class CurrencyMapping implements Mapping {
public static function url(): string {
return 'https://www.six-group.com/en/products-services/financial-information/data-standards.html';
}

/**
* @throws DomElementNotFoundException|RuntimeException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$listLink = $crawler->filterXPath("//a[contains(@href, 'list-one.xml')]");
$listUrl = $listLink->first()->getAttribute('href');
if ($listUrl === null || ($specContent = file_get_contents($listUrl)) === false) {
Expand Down Expand Up @@ -92,8 +89,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @throws TransliterationException
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$currencyNameEnum = new SpecFile(CurrencyName::class, KeySorting::class);
$currencyNumericEnum = new SpecFile(CurrencyNumeric::class, KeySorting::class);
$currencyAlpha3Enum = (new SpecFile(CurrencyAlpha3::class, KeySorting::class))
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/EUMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
* @template TDataSet of object{name: string}&stdClass
* @implements Mapping<TDataSet>
*/
class EUMapping implements Mapping
{
public static function url(): string
{
class EUMapping implements Mapping {
public static function url(): string {
return 'https://european-union.europa.eu/principles-countries-history/eu-countries_en';
}

/** @throws NoSuchElementException|TimeoutException */
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$client->waitFor('//a[contains(@class, "wt-ecl-button")]');
$crawler->filterXPath('//a[contains(@class, "wt-ecl-button")]')->click();

Expand Down Expand Up @@ -58,8 +55,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
}

/** @throws NameNotFoundException|InvalidArgumentException */
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$EU = (new SpecFile(EU::class, KeySorting::class))
->addMethod($allAlpha2 = new EnumListMethod('allAlpha2', 'array', '/** @return list<CountryAlpha2> */'));

Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/HttpMethodMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@
* @template TDataSet of object{alpha3: string, alpha2: string, name: string, name_french: string, name_german: string}&stdClass
* @implements Mapping<TDataSet>
*/
class HttpMethodMapping implements Mapping
{
public static function url(): string
{
class HttpMethodMapping implements Mapping {
public static function url(): string {
return 'https://www.iana.org/assignments/http-methods/http-methods.xhtml';
}

/**
* @throws RuntimeException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$items = $crawler->filterXPath('//table[@id="table-methods"]/tbody/tr')->getIterator();

$dataSet = [];
Expand Down Expand Up @@ -59,8 +56,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @param list<TDataSet> $dataSet
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$httpMethod = new SpecFile(HttpMethod::class, KeySorting::class);
foreach ($dataSet as $dataRow) {
if ($dataRow->name === '*') {
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/HttpStatusCodeMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@
* @template TDataSet of object{value: string, description: string, reference: string, note: ?string}&stdClass
* @implements Mapping<TDataSet>
*/
class HttpStatusCodeMapping implements Mapping
{
public static function url(): string
{
class HttpStatusCodeMapping implements Mapping {
public static function url(): string {
return 'https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml';
}

/**
* @throws RuntimeException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$items = $crawler->filterXPath('//table[@id="table-http-status-codes-1"]/tbody/tr')->getIterator();

$dataSet = [];
Expand Down Expand Up @@ -67,8 +64,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @throws Exception
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$httpMethod = new SpecFile(HttpStatusCode::class, ValueSorting::class);
foreach ($dataSet as $dataRow) {
if (in_array($dataRow->description, ['Unassigned', '(Unused)'], true)) {
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/LanguageExtensiveMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
* @template TDataSet of object{Id: string, Part2B: string, Part2T: string, Part1: string, Scope: string, LanguageType: string, RefName: string, Comment: string}&stdClass
* @implements Mapping<TDataSet>
*/
class LanguageExtensiveMapping implements Mapping
{
public static function url(): string
{
class LanguageExtensiveMapping implements Mapping {
public static function url(): string {
return 'https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3_Latin1.tab';
}

/** @throws DomElementNotFoundException */
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$dataSet = [];
foreach (explode("\n", $client->getPageSource()) as $lineNumber => $line) {
if ($lineNumber === 0 || $line === '</pre></body></html>') {
Expand All @@ -51,8 +48,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
return $dataSet;
}

public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$languageExtensive = new SpecFile(LanguageAlpha3Extensive::class, ValueSorting::class);
foreach ($dataSet as $dataItem) {
if (in_array($dataItem->RefName, ['Fa D\'ambu', 'C\'lela'], true)) {
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/LanguageMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,21 @@
* @template TDataSet of object{alpha3: string, alpha2: string, name: string, name_french: string, name_german: string}&stdClass
* @implements Mapping<TDataSet>
*/
class LanguageMapping implements Mapping
{
class LanguageMapping implements Mapping {
/** @var array<string, string> where key is the new name and value is the previous name */
private const RENAMES = [
'Tlicho; Dogrib' => 'Tlicho, Dogrib',
];

public static function url(): string
{
public static function url(): string {
return 'https://www.loc.gov/standards/iso639-2/php/code_list.php';
}

/**
* @throws RuntimeException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$items = $crawler->filterXPath('//table[@width="100%"]/tbody/tr')->getIterator();

$dataSet = [];
Expand Down Expand Up @@ -77,8 +74,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @param list<TDataSet> $dataSet
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$languageAlpha2 = new SpecFile(LanguageAlpha2::class, KeySorting::class);
$languageName = new SpecFile(LanguageName::class, KeySorting::class);
$languageAlpha3Bibliographic = new SpecFile(LanguageAlpha3Bibliographic::class, KeySorting::class);
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/LanguageSubTagMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
* @template TDataSet of object{Type: string, Subtag: string, Description: string, Added: string, SuppressScript: string, Scope: string, Macrolanguage: string, Comments: string, Deprecated: string, PreferredValue: string, Prefix: string, Tag: string}&stdClass
* @implements Mapping<TDataSet>
*/
class LanguageSubTagMapping implements Mapping
{
public static function url(): string
{
class LanguageSubTagMapping implements Mapping {
public static function url(): string {
return 'https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry';
}

/**
* @throws InvalidArgumentException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$dataSet = [];
foreach (explode('%%', $client->getPageSource()) as $i => $item) {
if ($i === 0) {
Expand Down Expand Up @@ -71,8 +68,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @param list<TDataSet> $dataSet
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$languageTagVariant = new SpecFile(LanguageTagVariant::class, KeySorting::class);
foreach ($dataSet as $dataRow) {
/** @var TDataSet $dataRow */
Expand Down
3 changes: 1 addition & 2 deletions dev/DataSource/Mapping/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
/**
* @template TDataSet
*/
interface Mapping
{
interface Mapping {
public static function url(): string;

/** @return list<TDataSet> */
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/PHPRegexSupportedScriptsMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
* @template TDataSet of object{name: string}&stdClass
* @implements Mapping<TDataSet>
*/
class PHPRegexSupportedScriptsMapping implements Mapping
{
public static function url(): string
{
class PHPRegexSupportedScriptsMapping implements Mapping {
public static function url(): string {
return 'https://www.php.net/manual/en/regexp.reference.unicode.php';
}

public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$items = $crawler->filterXPath('//table[@class="doctable table"]/tbody/tr/td/code')->getIterator();

$dataSet = [];
Expand All @@ -44,8 +41,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @param list<TDataSet> $dataSet
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$scriptAliasStrings = array_map(static function (object $dataSetItem) {
return $dataSetItem->name;
}, $dataSet);
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/ScriptMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@
* @template TDataSet of object{code: string, number: string, name: string, french_name: string, alias: string, age: string, date: string}&stdClass
* @implements Mapping<TDataSet>
*/
class ScriptMapping implements Mapping
{
public static function url(): string
{
class ScriptMapping implements Mapping {
public static function url(): string {
return 'https://www.unicode.org/iso15924/iso15924-codes.html';
}

/**
* @throws RuntimeException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$items = $crawler->filterXPath('//table[@class="simple"]/tbody/tr')->getIterator();

$dataSet = [];
Expand Down Expand Up @@ -79,8 +76,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
* @throws TypeError
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$scriptCode = new SpecFile(ScriptCode::class, KeySorting::class);
$scriptName = new SpecFile(ScriptName::class, KeySorting::class);
$scriptNumber = new SpecFile(ScriptNumber::class, KeySorting::class);
Expand Down
12 changes: 4 additions & 8 deletions dev/DataSource/Mapping/TopLevelDomainMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@
* @template TDataSet of object{tld: string, type: string, manager: string}&stdClass
* @implements Mapping<TDataSet>
*/
class TopLevelDomainMapping implements Mapping
{
public static function url(): string
{
class TopLevelDomainMapping implements Mapping {
public static function url(): string {
return 'https://www.iana.org/domains/root/db';
}

/**
* @throws RuntimeException
* @return list<TDataSet>
*/
public static function toDataSet(Client $client, Crawler $crawler): array
{
public static function toDataSet(Client $client, Crawler $crawler): array {
$items = $crawler->filterXPath('//table[@id="tld-table"]/tbody/tr')->getIterator();

$dataSet = [];
Expand Down Expand Up @@ -68,8 +65,7 @@ public static function toDataSet(Client $client, Crawler $crawler): array
*@throws InvalidArgumentException
* @return array<SpecFile>
*/
public static function toEnumMapping(array $dataSet): array
{
public static function toEnumMapping(array $dataSet): array {
$countryCodeTLD = (new SpecFile(CountryCodeTLD::class, KeySorting::class))
->addMethod($toCountryAlpha2 = new EnumMappingMethod('getCountryAlpha2', '?CountryAlpha2', 'null'));
$genericRestrictedTLD = new SpecFile(GenericRestrictedTLD::class, KeySorting::class);
Expand Down
Loading

0 comments on commit 44157e5

Please sign in to comment.