Skip to content

Commit

Permalink
Code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
richardDobron committed Jan 25, 2023
1 parent 301b9e8 commit d01b837
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/fbt/Transform/FbtTransform/FbtUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ public static function filterEmptyNodes(array $nodes): array
* Does the token substitution fbt() but without the string lookup.
* Used for in-place substitutions in translation mode.
*
* @return string|array
* @throws \fbt\Exceptions\FbtException
*/
public static function substituteTokens($template, $_args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FBLocaleToLang
"qt_US" => "tli",
];

public static function get($locale): string
public static function get(string $locale): string
{
// If given an fb-locale ("xx_XX"), try to map it to a language. Otherwise
// return "xx". If no '_' is found, return locale as-is.
Expand Down
4 changes: 1 addition & 3 deletions src/fbt/Transform/FbtTransform/Translate/FbtSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@ public static function fromScan($json): FbtSite
];
}

$fbtSite = new FbtSite(
return new FbtSite(
$json['type'],
$json['hashToText'],
$tableData,
$json['project']
);

return $fbtSite;
}

public function serialize(): array
Expand Down
4 changes: 2 additions & 2 deletions src/fbt/Transform/FbtTransform/Translate/FbtSiteMetaEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function getVariationMask()

if ($this->_type === null) {
return $this->_mask;
} else {
return self::getVariationMaskFromType($this->_type);
}

return self::getVariationMaskFromType($this->_type);
}

public function unwrap(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class IntlGenderType
];

/**
* @param $lang
* @param string $lang
* @return IntlDefaultGenderType|IntlMergedUnknownGenderType
*/
public static function forLanguage($lang)
public static function forLanguage(string $lang)
{
if (array_key_exists($lang, self::MERGED_LANGS)) {
return new IntlMergedUnknownGenderType();
Expand All @@ -34,10 +34,10 @@ public static function forLanguage($lang)
}

/**
* @param $locale
* @param string $locale
* @return IntlDefaultGenderType|IntlMergedUnknownGenderType
*/
public static function forLocale($locale)
public static function forLocale(string $locale)
{
if (array_key_exists($locale, self::MERGED_LOCALES)) {
return new IntlMergedUnknownGenderType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct($numberType, $genderType)
}

public function getTypesFromMask(
$mask // IntlVariationType
int $mask // IntlVariationType
): array {
if ($mask === IntlVariations::INTL_FBT_VARIATION_TYPE['NUMBER']) {
$types = $this->numberType->getNumberVariations();
Expand Down
1 change: 1 addition & 0 deletions src/fbt/fbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __toString(): string
$attributes['desc'] = $this->description;
}
$attributes += $this->options;

foreach ($attributes as $attribute => $value) {
if (array_key_exists($attribute, FbtUtils::SHORT_BOOL_CANDIDATES)) {
$attributes[$attribute] = $value === true ? 'true' : 'false';
Expand Down
5 changes: 3 additions & 2 deletions src/fbt/fbt.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ public static function sameParam(string $name): string
]);
}

public static function c(string $name, array $options = [])
public static function c(string $name, array $options = []): fbs
{
return new fbs($name, $options + [
'common' => true,
]);
}

public function _trace(array $trace): void
public function _trace(array $trace)
{
$this->trace = $trace;
}
Expand All @@ -118,6 +118,7 @@ public function __toString(): string
$attributes = [
'desc' => $this->description,
] + $this->options;

foreach ($attributes as $attribute => $value) {
if (array_key_exists($attribute, FbtUtils::SHORT_BOOL_CANDIDATES)) {
$attributes[$attribute] = $value === true ? 'true' : 'false';
Expand Down
1 change: 0 additions & 1 deletion src/fbt/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ function rsearch($folder, $pattern): \Generator
$ite = new \RecursiveIteratorIterator($dir);
$files = new \RegexIterator($ite, $pattern, \RegexIterator::MATCH);


foreach ($files as $file) {
yield $file->getPathName();
}
Expand Down

0 comments on commit d01b837

Please sign in to comment.