mirror of
https://github.com/archtechx/gloss.git
synced 2025-12-12 11:14:04 +00:00
wip
This commit is contained in:
parent
f196fd53c2
commit
be9cefd4b3
6 changed files with 75 additions and 36 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
composer.lock
|
composer.lock
|
||||||
vendor/
|
vendor/
|
||||||
.php_cs.cache
|
.php-cs-fixer.cache
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,19 @@ $rules = [
|
||||||
'operators' => [
|
'operators' => [
|
||||||
'=>' => null,
|
'=>' => null,
|
||||||
'|' => 'no_space',
|
'|' => 'no_space',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
'blank_line_after_namespace' => true,
|
'blank_line_after_namespace' => true,
|
||||||
'blank_line_after_opening_tag' => true,
|
'blank_line_after_opening_tag' => true,
|
||||||
'no_superfluous_phpdoc_tags' => true,
|
'no_superfluous_phpdoc_tags' => true,
|
||||||
'blank_line_before_statement' => [
|
'blank_line_before_statement' => [
|
||||||
'statements' => ['return']
|
'statements' => ['return'],
|
||||||
],
|
],
|
||||||
'braces' => true,
|
'braces' => true,
|
||||||
'cast_spaces' => true,
|
'cast_spaces' => true,
|
||||||
'class_attributes_separation' => [
|
|
||||||
'elements' => ['method']
|
|
||||||
],
|
|
||||||
'class_definition' => true,
|
'class_definition' => true,
|
||||||
'concat_space' => [
|
'concat_space' => [
|
||||||
'spacing' => 'one'
|
'spacing' => 'one',
|
||||||
],
|
],
|
||||||
'declare_equal_normalize' => true,
|
'declare_equal_normalize' => true,
|
||||||
'elseif' => true,
|
'elseif' => true,
|
||||||
|
|
@ -42,7 +39,7 @@ $rules = [
|
||||||
'linebreak_after_opening_tag' => true,
|
'linebreak_after_opening_tag' => true,
|
||||||
'line_ending' => true,
|
'line_ending' => true,
|
||||||
'lowercase_cast' => true,
|
'lowercase_cast' => true,
|
||||||
'lowercase_constants' => true,
|
'constant_case' => true,
|
||||||
'lowercase_keywords' => true,
|
'lowercase_keywords' => true,
|
||||||
'lowercase_static_reference' => true, // added from Symfony
|
'lowercase_static_reference' => true, // added from Symfony
|
||||||
'magic_method_casing' => true, // added from Symfony
|
'magic_method_casing' => true, // added from Symfony
|
||||||
|
|
@ -56,7 +53,7 @@ $rules = [
|
||||||
'throw',
|
'throw',
|
||||||
'use',
|
'use',
|
||||||
'use_trait',
|
'use_trait',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
'no_blank_lines_after_class_opening' => true,
|
'no_blank_lines_after_class_opening' => true,
|
||||||
'no_blank_lines_after_phpdoc' => true,
|
'no_blank_lines_after_phpdoc' => true,
|
||||||
|
|
@ -66,11 +63,11 @@ $rules = [
|
||||||
'no_leading_import_slash' => true,
|
'no_leading_import_slash' => true,
|
||||||
'no_leading_namespace_whitespace' => true,
|
'no_leading_namespace_whitespace' => true,
|
||||||
'no_mixed_echo_print' => [
|
'no_mixed_echo_print' => [
|
||||||
'use' => 'echo'
|
'use' => 'echo',
|
||||||
],
|
],
|
||||||
'no_multiline_whitespace_around_double_arrow' => true,
|
'no_multiline_whitespace_around_double_arrow' => true,
|
||||||
'multiline_whitespace_before_semicolons' => [
|
'multiline_whitespace_before_semicolons' => [
|
||||||
'strategy' => 'no_multi_line'
|
'strategy' => 'no_multi_line',
|
||||||
],
|
],
|
||||||
'no_short_bool_cast' => true,
|
'no_short_bool_cast' => true,
|
||||||
'no_singleline_whitespace_before_semicolons' => true,
|
'no_singleline_whitespace_before_semicolons' => true,
|
||||||
|
|
@ -89,9 +86,9 @@ $rules = [
|
||||||
'normalize_index_brace' => true,
|
'normalize_index_brace' => true,
|
||||||
'not_operator_with_successor_space' => true,
|
'not_operator_with_successor_space' => true,
|
||||||
'object_operator_without_whitespace' => true,
|
'object_operator_without_whitespace' => true,
|
||||||
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
|
'ordered_imports' => ['sort_algorithm' => 'alpha'],
|
||||||
'phpdoc_indent' => true,
|
'phpdoc_indent' => true,
|
||||||
'phpdoc_inline_tag' => true,
|
'general_phpdoc_tag_rename' => true,
|
||||||
'phpdoc_no_access' => true,
|
'phpdoc_no_access' => true,
|
||||||
'phpdoc_no_package' => true,
|
'phpdoc_no_package' => true,
|
||||||
'phpdoc_no_useless_inheritdoc' => true,
|
'phpdoc_no_useless_inheritdoc' => true,
|
||||||
|
|
@ -102,18 +99,18 @@ $rules = [
|
||||||
'phpdoc_trim' => true,
|
'phpdoc_trim' => true,
|
||||||
'phpdoc_types' => true,
|
'phpdoc_types' => true,
|
||||||
'phpdoc_var_without_name' => true,
|
'phpdoc_var_without_name' => true,
|
||||||
'psr4' => true,
|
'psr_autoloading' => true,
|
||||||
'self_accessor' => true,
|
'self_accessor' => true,
|
||||||
'short_scalar_cast' => true,
|
'short_scalar_cast' => true,
|
||||||
'simplified_null_return' => false, // disabled by Shift
|
'simplified_null_return' => false, // disabled by Shift
|
||||||
'single_blank_line_at_eof' => true,
|
'single_blank_line_at_eof' => true,
|
||||||
'single_blank_line_before_namespace' => true,
|
'single_blank_line_before_namespace' => true,
|
||||||
'single_class_element_per_statement' => true,
|
'single_class_element_per_statement' => true,
|
||||||
'single_import_per_statement' => true,
|
'single_import_per_statement' => false,
|
||||||
'single_line_after_imports' => true,
|
'single_line_after_imports' => true,
|
||||||
'no_unused_imports' => true,
|
'no_unused_imports' => true,
|
||||||
'single_line_comment_style' => [
|
'single_line_comment_style' => [
|
||||||
'comment_types' => ['hash']
|
'comment_types' => ['hash'],
|
||||||
],
|
],
|
||||||
'single_quote' => true,
|
'single_quote' => true,
|
||||||
'space_after_semicolon' => true,
|
'space_after_semicolon' => true,
|
||||||
|
|
@ -121,12 +118,9 @@ $rules = [
|
||||||
'switch_case_semicolon_to_colon' => true,
|
'switch_case_semicolon_to_colon' => true,
|
||||||
'switch_case_space' => true,
|
'switch_case_space' => true,
|
||||||
'ternary_operator_spaces' => true,
|
'ternary_operator_spaces' => true,
|
||||||
'trailing_comma_in_multiline_array' => true,
|
'trailing_comma_in_multiline' => true,
|
||||||
'trim_array_spaces' => true,
|
'trim_array_spaces' => true,
|
||||||
'unary_operator_spaces' => true,
|
'unary_operator_spaces' => true,
|
||||||
// 'visibility_required' => [
|
|
||||||
// 'elements' => ['method', 'property']
|
|
||||||
// ],
|
|
||||||
'whitespace_after_comma_in_array' => true,
|
'whitespace_after_comma_in_array' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -140,7 +134,7 @@ $finder = Finder::create()
|
||||||
->ignoreDotFiles(true)
|
->ignoreDotFiles(true)
|
||||||
->ignoreVCS(true);
|
->ignoreVCS(true);
|
||||||
|
|
||||||
return Config::create()
|
return (new Config())
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
->setRules($rules)
|
->setRules($rules)
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
54
check
Executable file
54
check
Executable file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
offer_run() {
|
||||||
|
read -p "For more output, run $1. Run it now (Y/n)? " run
|
||||||
|
|
||||||
|
case ${run:0:1} in
|
||||||
|
n|N )
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (php-cs-fixer fix --dry-run --config=.php-cs-fixer.php > /dev/null 2>/dev/null); then
|
||||||
|
echo '✅ php-cs-fixer OK'
|
||||||
|
else
|
||||||
|
read -p "⚠️ php-cs-fixer found issues. Fix (Y/n)? " fix
|
||||||
|
case ${fix:0:1} in
|
||||||
|
n|N )
|
||||||
|
echo '❌ php-cs-fixer FAIL'
|
||||||
|
offer_run 'php-cs-fixer fix --config=.php-cs-fixer.php'
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
if (php-cs-fixer fix --config=.php-cs-fixer.php > /dev/null 2>/dev/null); then
|
||||||
|
echo '✅ php-cs-fixer OK'
|
||||||
|
else
|
||||||
|
echo '❌ php-cs-fixer FAIL'
|
||||||
|
offer_run 'php-cs-fixer fix --config=.php-cs-fixer.php'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (./vendor/bin/phpstan analyse > /dev/null 2>/dev/null); then
|
||||||
|
echo '✅ PHPStan OK'
|
||||||
|
else
|
||||||
|
echo '❌ PHPStan FAIL'
|
||||||
|
offer_run './vendor/bin/phpstan analyse'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (./vendor/bin/phpunit > /dev/null 2>/dev/null); then
|
||||||
|
echo '✅ PHPUnit OK'
|
||||||
|
else
|
||||||
|
echo '❌ PHPUnit FAIL'
|
||||||
|
offer_run './vendor/bin/phpunit'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '=================='
|
||||||
|
echo '✅ Everything OK'
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": "^8.0",
|
||||||
"illuminate/translation": "^6.0||^8.0||^9.0"
|
"illuminate/translation": "^6.0||^8.0||^9.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ class GlossTranslator extends Translator
|
||||||
/**
|
/**
|
||||||
* Register an override that returns a different key name.
|
* Register an override that returns a different key name.
|
||||||
*
|
*
|
||||||
* @param string $shortKey
|
|
||||||
* @param string $newKey
|
|
||||||
* @param array|null|callable $condition
|
* @param array|null|callable $condition
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,8 +43,6 @@ class GlossTranslator extends Translator
|
||||||
/**
|
/**
|
||||||
* Register an override that returns a value.
|
* Register an override that returns a value.
|
||||||
*
|
*
|
||||||
* @param string $shortKey
|
|
||||||
* @param string $value
|
|
||||||
* @param array|null|callable $condition
|
* @param array|null|callable $condition
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,7 +63,6 @@ class GlossTranslator extends Translator
|
||||||
/**
|
/**
|
||||||
* Register multiple value overrides.
|
* Register multiple value overrides.
|
||||||
*
|
*
|
||||||
* @param array $values
|
|
||||||
* @param array|null|callable $condition
|
* @param array|null|callable $condition
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
@ -82,8 +77,6 @@ class GlossTranslator extends Translator
|
||||||
/**
|
/**
|
||||||
* Customize a translation string's value using a callback.
|
* Customize a translation string's value using a callback.
|
||||||
*
|
*
|
||||||
* @param string $shortKey
|
|
||||||
* @param callable $value
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function extend(string $shortKey, callable $value)
|
public function extend(string $shortKey, callable $value)
|
||||||
|
|
@ -95,7 +88,6 @@ class GlossTranslator extends Translator
|
||||||
* Get a translation string.
|
* Get a translation string.
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param array $replace
|
|
||||||
* @param string|null $locale
|
* @param string|null $locale
|
||||||
* @param bool $fallback
|
* @param bool $fallback
|
||||||
* @return string
|
* @return string
|
||||||
|
|
@ -132,7 +124,6 @@ class GlossTranslator extends Translator
|
||||||
/**
|
/**
|
||||||
* Get a translation string and skip extensions.
|
* Get a translation string and skip extensions.
|
||||||
*
|
*
|
||||||
* @param string $key
|
|
||||||
* @param array $replace
|
* @param array $replace
|
||||||
* @param string|null $locale
|
* @param string|null $locale
|
||||||
* @param bool $fallback
|
* @param bool $fallback
|
||||||
|
|
@ -203,7 +194,9 @@ class GlossTranslator extends Translator
|
||||||
protected function choiceWithoutExtensions($key, $number, array $replace = [], $locale = null)
|
protected function choiceWithoutExtensions($key, $number, array $replace = [], $locale = null)
|
||||||
{
|
{
|
||||||
$line = $this->getWithoutExtensions(
|
$line = $this->getWithoutExtensions(
|
||||||
$key, $replace, $locale = $this->localeForChoice($locale)
|
$key,
|
||||||
|
$replace,
|
||||||
|
$locale = $this->localeForChoice($locale)
|
||||||
);
|
);
|
||||||
|
|
||||||
// If the given "number" is actually an array or countable we will simply count the
|
// If the given "number" is actually an array or countable we will simply count the
|
||||||
|
|
@ -216,7 +209,8 @@ class GlossTranslator extends Translator
|
||||||
$replace['count'] = $number;
|
$replace['count'] = $number;
|
||||||
|
|
||||||
return $this->makeReplacements(
|
return $this->makeReplacements(
|
||||||
$this->getSelector()->choose($line, $number, $locale), $replace
|
$this->getSelector()->choose($line, $number, $locale),
|
||||||
|
$replace
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,7 +246,6 @@ class GlossTranslator extends Translator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|callable $line
|
* @param string|callable $line
|
||||||
* @param array $replace
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function makeReplacements($line, array $replace)
|
protected function makeReplacements($line, array $replace)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ if (! function_exists('gloss')) {
|
||||||
*
|
*
|
||||||
* @param string|array|null $key
|
* @param string|array|null $key
|
||||||
* @param array|callable|null $replace
|
* @param array|callable|null $replace
|
||||||
* @param string|null $locale
|
|
||||||
* @return void|string|null|\Lean\Gloss\GlossTranslator
|
* @return void|string|null|\Lean\Gloss\GlossTranslator
|
||||||
*/
|
*/
|
||||||
function gloss($key = null, $replace = null, string $locale = null)
|
function gloss($key = null, $replace = null, string $locale = null)
|
||||||
|
|
@ -36,8 +35,6 @@ if (! function_exists('___') && Gloss::$underscoreHelper) {
|
||||||
* Resolve a translation string or Gloss instance.
|
* Resolve a translation string or Gloss instance.
|
||||||
*
|
*
|
||||||
* @param string|array|null $key
|
* @param string|array|null $key
|
||||||
* @param array $replace
|
|
||||||
* @param string|null $locale
|
|
||||||
* @return void|string|null|\Lean\Gloss\GlossTranslator
|
* @return void|string|null|\Lean\Gloss\GlossTranslator
|
||||||
*/
|
*/
|
||||||
function ___($key = null, array $replace = [], string $locale = null)
|
function ___($key = null, array $replace = [], string $locale = null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue