static analysis

This commit is contained in:
Dylan K. Taylor 2017-07-13 16:45:24 +01:00
parent 23866359c9
commit 4d874e7e78
6 changed files with 7 additions and 6 deletions

View File

@ -125,7 +125,7 @@ class FormattedCommandAlias extends Command{
$replacement = ""; $replacement = "";
if($rest and $position < count($args)){ if($rest and $position < count($args)){
for($i = $position; $i < count($args); ++$i){ for($i = $position, $c = count($args); $i < $c; ++$i){
if($i !== $position){ if($i !== $position){
$replacement .= " "; $replacement .= " ";
} }

View File

@ -76,6 +76,8 @@ class Attribute{
* @param bool $shouldSend * @param bool $shouldSend
* *
* @return Attribute * @return Attribute
*
* @throws \InvalidArgumentException
*/ */
public static function addAttribute($id, $name, $minValue, $maxValue, $defaultValue, $shouldSend = true){ public static function addAttribute($id, $name, $minValue, $maxValue, $defaultValue, $shouldSend = true){
if($minValue > $maxValue or $defaultValue > $maxValue or $defaultValue < $minValue){ if($minValue > $maxValue or $defaultValue > $maxValue or $defaultValue < $minValue){

View File

@ -37,7 +37,7 @@ class BaseLang{
} }
if(is_dir($path)){ if(is_dir($path)){
$allFiles = scandir($path); $allFiles = scandir($path, SCANDIR_SORT_NONE);
if($allFiles !== false){ if($allFiles !== false){
$files = array_filter($allFiles, function($filename){ $files = array_filter($allFiles, function($filename){

View File

@ -223,7 +223,7 @@ class McRegion extends BaseLevelProvider{
$isValid = (file_exists($path . "/level.dat") and is_dir($path . "/region/")); $isValid = (file_exists($path . "/level.dat") and is_dir($path . "/region/"));
if($isValid){ if($isValid){
$files = array_filter(scandir($path . "/region/"), function($file){ $files = array_filter(scandir($path . "/region/", SCANDIR_SORT_NONE), function($file){
return substr($file, strrpos($file, ".") + 1, 2) === "mc"; //region file return substr($file, strrpos($file, ".") + 1, 2) === "mc"; //region file
}); });

View File

@ -64,7 +64,7 @@ class ResourcePackManager{
} }
if(!file_exists($this->path . "resource_packs.yml")){ if(!file_exists($this->path . "resource_packs.yml")){
file_put_contents($this->path . "resource_packs.yml", file_get_contents($this->server->getFilePath() . "src/pocketmine/resources/resource_packs.yml")); copy($this->server->getFilePath() . "src/pocketmine/resources/resource_packs.yml", $this->path . "resource_packs.yml");
} }
$this->resourcePacksConfig = new Config($this->path . "resource_packs.yml", Config::YAML, []); $this->resourcePacksConfig = new Config($this->path . "resource_packs.yml", Config::YAML, []);

View File

@ -305,7 +305,6 @@ class Utils{
break; break;
case "bsd": case "bsd":
case "mac": case "mac":
$processors = (int) `sysctl -n hw.ncpu`;
$processors = (int) `sysctl -n hw.ncpu`; $processors = (int) `sysctl -n hw.ncpu`;
break; break;
case "win": case "win":
@ -477,7 +476,7 @@ class Utils{
public static function javaStringHash($string){ public static function javaStringHash($string){
$hash = 0; $hash = 0;
for($i = 0; $i < strlen($string); $i++){ for($i = 0, $len = strlen($string); $i < $len; $i++){
$ord = ord($string{$i}); $ord = ord($string{$i});
if($ord & 0x80){ if($ord & 0x80){
$ord -= 0x100; $ord -= 0x100;