Skip to content

Commit b59fdd6

Browse files
committed
Modernize
1 parent 0793740 commit b59fdd6

15 files changed

Lines changed: 817 additions & 799 deletions

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
"maslosoft/miniview": "*",
1515
"maslosoft/addendum": "*",
1616
"maslosoft/sitcom": "*",
17-
"symfony/console": ">=2.7 <7.0",
17+
"symfony/console": ">=7",
1818
"maslosoft/whitelist": "*"
1919
},
2020
"bin": [
2121
"i18n-extractor"
2222
],
2323
"require-dev": {
24-
"maslosoft/hedron": "*",
2524
"codeception/module-asserts": "^3",
2625
"codeception/codeception": "^5"
2726
},

composer.lock

Lines changed: 785 additions & 774 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

msft

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
i18n-extractor

src/ContextFiller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
class ContextFiller implements FillerInterface
3434
{
3535

36-
private $searchPaths = [];
36+
private array $searchPaths = [];
3737

38-
public function fill($searchPaths = [])
38+
public function fill($searchPaths = []): void
3939
{
4040
$this->searchPaths = $searchPaths;
4141

4242
FileWalker::scan([$this, 'walk'], $this->searchPaths);
4343
}
4444

45-
public function walk($file, $content)
45+
public function walk($file, $content): void
4646
{
4747
$context = Context::create($file, $this->searchPaths);
4848
$tokenizer = new Tokenizer($content);
@@ -64,7 +64,7 @@ public function walk($file, $content)
6464
/* @var $txCalls[] TokenInterface */
6565
foreach ($functions as $function)
6666
{
67-
if (in_array($function->value, array_keys($txFunctions)))
67+
if (array_key_exists($function->value, $txFunctions))
6868
{
6969
$txCalls[] = $function;
7070
}

src/DirectoryContextFiller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class DirectoryContextFiller implements FillerInterface
2323
{
2424

25-
public function fill($src = 'src')
25+
public function fill($src = 'src'): void
2626
{
2727
$extractor = new ContextFiller();
2828
$extractor->fill([$src]);

src/DirectoryExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class DirectoryExtractor implements ExtractorInterface
2323
{
2424

25-
public function extract($src = 'src', $dest = 'generated')
25+
public function extract($src = 'src', $dest = 'generated'): void
2626
{
2727
$extractor = new I18NExtractor();
2828
$extractor->generate([$src], $dest);

src/Helpers/AnnotationsExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
class AnnotationsExtractor
3333
{
34-
const Method = 'method';
35-
const Field = 'field';
34+
public const Method = 'method';
35+
public const Field = 'field';
3636

3737
/**
3838
* Extractor instance
@@ -45,7 +45,7 @@ public function __construct(I18NExtractor $extractor)
4545
$this->extractor = $extractor;
4646
}
4747

48-
public function getMessages($file)
48+
public function getMessages($file): array
4949
{
5050
$annotations = AnnotationUtility::rawAnnotate($file);
5151

src/Helpers/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class Context
2525

2626
/**
2727
* Create context based on file name
28-
* @param string $file
28+
* @param string $file
2929
* @param string[] $trimPaths
3030
* @return string
3131
*/
32-
public static function create($file, $trimPaths = [])
32+
public static function create(string $file, array $trimPaths = []): string
3333
{
3434
// Replace windows slashes
3535
$file = str_replace('\\', '/', $file);
@@ -40,7 +40,7 @@ public static function create($file, $trimPaths = [])
4040
// Remove search paths in from of file path
4141
foreach ($trimPaths as $path)
4242
{
43-
$pathQuoted = preg_quote($path);
43+
$pathQuoted = preg_quote($path, '~');
4444
$pattern = "~^$pathQuoted/~";
4545
if (preg_match($pattern, $name))
4646
{

src/Helpers/FileWalker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FileWalker
3939
*
4040
* @param callback $callback
4141
*/
42-
public static function scan($callback, $searchPaths = [])
42+
public static function scan(callable $callback, $searchPaths = []): void
4343
{
4444
foreach ($searchPaths as $path)
4545
{
@@ -59,7 +59,7 @@ public static function scan($callback, $searchPaths = [])
5959
// TODO Log this
6060
continue;
6161
}
62-
call_user_func($callback, $file, $contents);
62+
$callback($file, $contents);
6363
}
6464
}
6565
}

src/I18NExtractor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ class I18NExtractor
4242
*/
4343
const ConfigName = "i18n-extractor";
4444

45+
protected EmbeDi $di;
46+
4547
/**
4648
* View Renderer
4749
* @var MiniView
4850
*/
49-
public $view = null;
51+
public MiniView $view;
5052

5153
public $i18nAnnotations = [
5254
'Label',

0 commit comments

Comments
 (0)