Skip to content

Commit

Permalink
Add missing type info
Browse files Browse the repository at this point in the history
  • Loading branch information
alies-dev committed Feb 27, 2024
1 parent e05f96a commit 563c4db
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
26 changes: 22 additions & 4 deletions psalm-baseline.xml
@@ -1,9 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<file src="src/Commands/FindMissingTranslations.php">
<MissingPropertyType>
<code><![CDATA[$exitCode]]></code>
</MissingPropertyType>
<MixedArgument>
<code><![CDATA[$baseLanguageFile]]></code>
<code><![CDATA[$currentLocaleDirectoryPath]]></code>
<code><![CDATA[$secondArray[$key]]]></code>
<code><![CDATA[$secondLanguageFile]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$baseLanguageFile]]></code>
<code><![CDATA[$currentLocaleDirectoryPath]]></code>
<code><![CDATA[$secondLanguageFile]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedReturnTypeCoercion>
<code><![CDATA[$outputDiff]]></code>
<code><![CDATA[list<string>]]></code>
</MixedReturnTypeCoercion>
<NonInvariantDocblockPropertyType>
<code><![CDATA[$description]]></code>
</NonInvariantDocblockPropertyType>
Expand All @@ -14,13 +27,15 @@
<code><![CDATA[$this->option('dir')]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast>
<code><![CDATA[$baseLocale]]></code>
<code><![CDATA[$pathToLocates]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
</PossiblyInvalidCast>
<PossiblyNullOperand>
<code><![CDATA[$pathToLocates]]></code>
</PossiblyNullOperand>
<PropertyNotSetInConstructor>
<code><![CDATA[FindMissingTranslations]]></code>
<code><![CDATA[FindMissingTranslations]]></code>
Expand All @@ -31,5 +46,8 @@
<RiskyTruthyFalsyComparison>
<code><![CDATA[$this->option('base')]]></code>
</RiskyTruthyFalsyComparison>
<UnnecessaryVarAnnotation>
<code><![CDATA[\Symfony\Component\Finder\SplFileInfo[]]]></code>
</UnnecessaryVarAnnotation>
</file>
</files>
2 changes: 1 addition & 1 deletion psalm.xml
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="2"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedVariablesAndParams="true"
Expand Down
13 changes: 11 additions & 2 deletions src/Commands/FindMissingTranslations.php
Expand Up @@ -29,7 +29,7 @@ class FindMissingTranslations extends Command
*/
protected $description = 'Helps developers to finding words which are not translated, by comparing one base locale to others.';

private $exitCode = 0;
private int $exitCode = 0;

/** @inheritDoc */
public function handle(): int
Expand All @@ -45,6 +45,7 @@ public function handle(): int
}

$baseLocale = $this->option('base') ?: config('app.locale');
assert(is_string($baseLocale), 'Invalid base locale');
$baseLocaleDirectoryPath = $pathToLocates.\DIRECTORY_SEPARATOR.$baseLocale;

$localeDirectories = File::directories($pathToLocates);
Expand All @@ -70,6 +71,10 @@ public function handle(): int
return $this->exitCode;
}

/**
* @param list<string> $baseLanguageFiles
* @param list<string> $languageFiles
*/
private function compareLanguages(string $baseLanguagePath, array $baseLanguageFiles, string $languagePath, array $languageFiles, string $languageName): void
{
foreach ($baseLanguageFiles as $languageFile) {
Expand Down Expand Up @@ -100,7 +105,10 @@ private function compareLanguages(string $baseLanguagePath, array $baseLanguageF
}
}

/** Compare array keys recursively */
/**
* Compare array keys recursively
* @return list<string>
*/
private function arrayDiffRecursive(array $firstArray, array $secondArray): array
{
$outputDiff = [];
Expand All @@ -125,6 +133,7 @@ private function arrayDiffRecursive(array $firstArray, array $secondArray): arra

/**
* Get filenames of directory
* @return list<string>
*/
private function getFilenames(string $directory): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceProvider.php
Expand Up @@ -7,13 +7,13 @@
use Diglabby\FindMissingTranslations\Commands\FindMissingTranslations;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class ServiceProvider extends BaseServiceProvider
final class ServiceProvider extends BaseServiceProvider
{
/**
* Bootstrap the application services.
* @return void
*/
public function boot()
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->commands([
Expand Down

0 comments on commit 563c4db

Please sign in to comment.