Fix scrutinizer tips

This commit is contained in:
Dennis Eichhorn 2017-10-27 17:24:33 +02:00
parent f652a900d0
commit 91eb1f261f
29 changed files with 52 additions and 49 deletions

View File

@ -136,7 +136,7 @@ class Account implements ArrayableInterface, \JsonSerializable
/** /**
* Account type. * Account type.
* *
* @var AccountType|int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected $type = AccountType::USER; protected $type = AccountType::USER;
@ -144,7 +144,7 @@ class Account implements ArrayableInterface, \JsonSerializable
/** /**
* Account status. * Account status.
* *
* @var AccountStatus|int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected $status = AccountStatus::INACTIVE; protected $status = AccountStatus::INACTIVE;
@ -624,8 +624,8 @@ class Account implements ArrayableInterface, \JsonSerializable
/** /**
* Json serialize. * Json serialize.
* *
* @return string * @return array
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -208,7 +208,7 @@ class Group implements ArrayableInterface, \JsonSerializable
/** /**
* Json serialize. * Json serialize.
* *
* @return string * @return array
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -340,7 +340,7 @@ class PermissionAbstract
* *
* @param int $permission Permission * @param int $permission Permission
* *
* @return void * @return bool
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class AutoloadException extends \RuntimeException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -39,7 +39,7 @@ class CachePool implements OptionsInterface
/** /**
* MemCache instance. * MemCache instance.
* *
* @var \phpOMS\DataStorage\Cache\CacheInterface * @var \phpOMS\DataStorage\Cache\CacheInterface[]
* @since 1.0.0 * @since 1.0.0
*/ */
private $pool = null; private $pool = null;

View File

@ -65,15 +65,15 @@ abstract class ConnectionAbstract implements ConnectionInterface
/** /**
* Database type. * Database type.
* *
* @var \phpOMS\DataStorage\Database\DatabaseType * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected $type = null; protected $type = 'undefined';
/** /**
* Database status. * Database status.
* *
* @var DatabaseStatus * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected $status = DatabaseStatus::CLOSED; protected $status = DatabaseStatus::CLOSED;

View File

@ -31,7 +31,7 @@ class InvalidConnectionConfigException extends \InvalidArgumentException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class InvalidMapperException extends \RuntimeException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class TableException extends \PDOException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class LockException extends \RuntimeException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class ZeroDevisionException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -250,15 +250,15 @@ class Functions
* @example The relative fiscal month (August) in a company where the fiscal year starts in July. * @example The relative fiscal month (August) in a company where the fiscal year starts in July.
* @example 2 = getRelativeDegree(8, 12, 7); * @example 2 = getRelativeDegree(8, 12, 7);
* *
* @param mixed $value Value to get degree * @param int $value Value to get degree
* @param mixed $length Circle size * @param int $length Circle size
* @param mixed $start Start value * @param int $start Start value
* *
* @return int Lowest value is 0 and highest value is length - 1 * @return int Lowest value is 0 and highest value is length - 1
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getRelativeDegree($value, $length, $start = 0) : int public static function getRelativeDegree(int $value, int $length, int $start = 0) : int
{ {
return abs(self::mod($value - $start, $length)); return abs(self::mod($value - $start, $length));
} }

View File

@ -31,7 +31,7 @@ class InvalidDimensionException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -185,12 +185,12 @@ class Average
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function mode($values) public static function mode(array $values)
{ {
$count = array_count_values($values); $count = array_count_values($values);
$best = max($count); $best = max($count);
return array_keys($count, $best); return (float) (array_keys($count, $best)[0] ?? 0.0);
} }
/** /**

View File

@ -74,7 +74,7 @@ abstract class RequestAbstract implements MessageInterface
/** /**
* Request type. * Request type.
* *
* @var \phpOMS\Message\RequestSource * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected $source = RequestSource::UNDEFINED; protected $source = RequestSource::UNDEFINED;

View File

@ -31,7 +31,7 @@ class InvalidModuleException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class InvalidThemeException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -76,7 +76,7 @@ abstract class ModuleAbstract
/** /**
* Dependencies. * Dependencies.
* *
* @var string * @var string[]
* @since 1.0.0 * @since 1.0.0
*/ */
protected static $dependencies = []; protected static $dependencies = [];

View File

@ -70,7 +70,7 @@ class PackageManager
* Constructor. * Constructor.
* *
* @param string $path Package source path e.g. path after download. * @param string $path Package source path e.g. path after download.
* @param string basePath Path of the application * @param string $basePath Path of the application
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -85,11 +85,11 @@ class PackageManager
* *
* @param string $path Temporary extract path * @param string $path Temporary extract path
* *
* @return bool * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function extract(string $path) : bool public function extract(string $path) /* : void */
{ {
$this->extractPath = $path; $this->extractPath = $path;
Zip::unpack($this->path, $this->extractPath); Zip::unpack($this->path, $this->extractPath);

View File

@ -96,7 +96,7 @@ class Router
* @param string|RequestAbstract $request Request to route * @param string|RequestAbstract $request Request to route
* @param int $verb Route verb * @param int $verb Route verb
* *
* @return string[] * @return array[]
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* *

View File

@ -34,7 +34,7 @@ class InvalidEnumName extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -34,7 +34,7 @@ class InvalidEnumValue extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -92,7 +92,7 @@ class MultiMap implements \Countable
$inserted = false; $inserted = false;
if ($this->keyType !== KeyType::SINGLE) { if ($this->keyType !== KeyType::SINGLE) {
$keys = [implode($keys, ':')]; $keys = [implode(':', $keys)];
} }
foreach ($keys as $key) { foreach ($keys as $key) {
@ -186,14 +186,14 @@ class MultiMap implements \Countable
$keys = Permutation::permut($key); $keys = Permutation::permut($key);
foreach ($keys as $key => $value) { foreach ($keys as $key => $value) {
$key = implode($value, ':'); $key = implode(':', $value);
if (isset($this->keys[$key])) { if (isset($this->keys[$key])) {
return $this->values[$this->keys[$key]]; return $this->values[$this->keys[$key]];
} }
} }
} else { } else {
$key = implode($key, ':'); $key = implode(':', $key);
} }
} }
@ -235,12 +235,12 @@ class MultiMap implements \Countable
$permutation = Permutation::permut($key); $permutation = Permutation::permut($key);
foreach ($permutation as $permut) { foreach ($permutation as $permut) {
if ($this->set(implode($permut, ':'), $value)) { if ($this->set(implode(':', $permut), $value)) {
return true; return true;
} }
} }
} else { } else {
return $this->set(implode($key, ':'), $value); return $this->set(implode(':', $key), $value);
} }
return false; return false;
@ -302,12 +302,12 @@ class MultiMap implements \Countable
$removed = false; $removed = false;
foreach ($keys as $key => $value) { foreach ($keys as $key => $value) {
$removed |= $this->remove(implode($value, ':')); $removed |= $this->remove(implode(':', $value));
} }
return $removed; return $removed;
} else { } else {
return $this->remove(implode($key, ':')); return $this->remove(implode(':', $key));
} }
} }
@ -403,12 +403,12 @@ class MultiMap implements \Countable
$removed = false; $removed = false;
foreach ($keys as $key => $value) { foreach ($keys as $key => $value) {
$removed |= $this->removeKey(implode($value, ':')); $removed |= $this->removeKey(implode(':', $value));
} }
return $removed; return $removed;
} else { } else {
return $this->removeKey(implode($key, ':')); return $this->removeKey(implode(':', $key));
} }
} }

View File

@ -31,7 +31,7 @@ class PathException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class PermissionException extends \RuntimeException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -46,10 +46,12 @@ class SystemUtils
*/ */
public static function getRAM() : int public static function getRAM() : int
{ {
$mem = null; $mem = 0;
if (stristr(PHP_OS, 'WIN')) { if (stristr(PHP_OS, 'WIN')) {
exec('wmic memorychip get capacity', $mem); exec('wmic memorychip get capacity', $mem);
/** @var array $mem */
$mem = array_sum($mem) / 1024; $mem = array_sum($mem) / 1024;
} elseif (stristr(PHP_OS, 'LINUX')) { } elseif (stristr(PHP_OS, 'LINUX')) {
$fh = fopen('/proc/meminfo', 'r'); $fh = fopen('/proc/meminfo', 'r');
@ -62,6 +64,7 @@ class SystemUtils
break; break;
} }
} }
fclose($fh); fclose($fh);
} }

View File

@ -31,7 +31,7 @@ class InvalidUriException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -31,7 +31,7 @@ class InvalidJsonException extends \UnexpectedValueException
* *
* @param string $message Exception message * @param string $message Exception message
* @param int $code Exception code * @param int $code Exception code
* @param \Exception Previous exception * @param \Exception $previous Previous exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -182,7 +182,7 @@ abstract class ViewAbstract implements \Serializable
public function serialize() public function serialize()
{ {
if (empty($this->template)) { if (empty($this->template)) {
return $this->toArray(); return json_encode($this->toArray());
} }
return $this->render(); return $this->render();