Skip to content

Commit

Permalink
phpstan: green on level 6
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jun 10, 2020
1 parent 9720e8d commit f0b6212
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/DevTools/ConsoleScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ function preg_quote_array(array $strings, string $delim = null) : array{
* @param string $pharPath
* @param string $basePath
* @param string[] $includedPaths
* @param array $metadata
* @param mixed[] $metadata
* @param string $stub
* @param int $signatureAlgo
* @param int|null $compression
* @phpstan-param array<string, mixed> $metadata
*
* @return Generator|string[]
*/
function buildPhar(string $pharPath, string $basePath, array $includedPaths, array $metadata, string $stub, int $signatureAlgo = \Phar::SHA1, ?int $compression = null){
$basePath = rtrim(str_replace("/", DIRECTORY_SEPARATOR, $basePath), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$includedPaths = array_map(function($path){
$includedPaths = array_map(function($path) : string{
return rtrim(str_replace("/", DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}, $includedPaths);
if(file_exists($pharPath)){
Expand Down Expand Up @@ -126,6 +127,10 @@ function buildPhar(string $pharPath, string $basePath, array $includedPaths, arr
yield "Done in " . round(microtime(true) - $start, 3) . "s";
}

/**
* @return mixed[]|null
* @phpstan-return array<string, mixed>|null
*/
function generatePluginMetadataFromYml(string $pluginYmlPath) : ?array{
if(!file_exists($pluginYmlPath)){
return null;
Expand Down Expand Up @@ -161,7 +166,7 @@ function main() : void{
}

$includedPaths = explode(",", $opts["make"]);
array_walk($includedPaths, function(&$path, $key){
array_walk($includedPaths, function(&$path, $key) : void{
$realPath = realpath($path);
if($realPath === false){
echo "[ERROR] make directory `$path` does not exist or permission denied" . PHP_EOL;
Expand Down
11 changes: 11 additions & 0 deletions src/DevTools/DevTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public function onCommand(CommandSender $sender, Command $command, string $label
}
}

/**
* @param string[] $args
*/
private function permissionCheckCommand(CommandSender $sender, array $args) : bool{
$target = $sender;
if(!isset($args[0])){
Expand Down Expand Up @@ -192,6 +195,9 @@ private function makePluginLoader(CommandSender $sender) : bool{
return true;
}

/**
* @param string[] $args
*/
private function makePluginCommand(CommandSender $sender, array $args) : bool{
if(ini_get('phar.readonly') !== '0'){
$sender->sendMessage(TextFormat::RED . "This command requires \"phar.readonly\" to be set to 0. Set it in " . php_ini_loaded_file() . " and restart the server.");
Expand Down Expand Up @@ -237,6 +243,11 @@ private function makePluginCommand(CommandSender $sender, array $args) : bool{
return true;
}

/**
* @param string[] $includedPaths
* @param mixed[] $metadata
* @phpstan-param array<string, mixed> $metadata
*/
private function buildPhar(CommandSender $sender, string $pharPath, string $basePath, array $includedPaths, array $metadata, string $stub, int $signatureAlgo = \Phar::SHA1) : void{
foreach(buildPhar($pharPath, $basePath, $includedPaths, $metadata, $stub, $signatureAlgo, \Phar::GZ) as $line){
$sender->sendMessage("[DevTools] $line");
Expand Down

0 comments on commit f0b6212

Please sign in to comment.