1 Commits
1.0.1 ... 1.0.2

Author SHA1 Message Date
784788e035 Add psalm checks 2021-10-21 15:13:59 +09:00
2 changed files with 16 additions and 4 deletions

14
psalm.xml Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
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"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
</ignoreFiles>
</projectFiles>
</psalm>

View File

@@ -15,16 +15,13 @@
* *
* @param string $path Folder to file, default is __DIR__ * @param string $path Folder to file, default is __DIR__
* @param string $env_file What file to load, default is .env * @param string $env_file What file to load, default is .env
* @return int -1 other error * @return int 0 for success full load
* 0 for success full load
* 1 for file loadable, but no data inside * 1 for file loadable, but no data inside
* 2 for file not readable * 2 for file not readable
* 3 for file not found * 3 for file not found
*/ */
function readEnvFile(string $path = __DIR__, string $env_file = '.env'): int function readEnvFile(string $path = __DIR__, string $env_file = '.env'): int
{ {
// default -1;
$status = -1;
$env_file_target = $path . DIRECTORY_SEPARATOR . $env_file; $env_file_target = $path . DIRECTORY_SEPARATOR . $env_file;
// this is not a file -> abort // this is not a file -> abort
if (!is_file($env_file_target)) { if (!is_file($env_file_target)) {
@@ -74,6 +71,7 @@ function readEnvFile(string $path = __DIR__, string $env_file = '.env'): int
$line = $matches[1]; $line = $matches[1];
} }
// strip line of slashes // strip line of slashes
/** @psalm-suppress MixedOperand */
$_ENV[$var] .= stripslashes($line); $_ENV[$var] .= stripslashes($line);
} }
} }