phpstan fixes

This commit is contained in:
Dennis Eichhorn 2018-03-13 23:35:20 +01:00
parent 3b45692ff1
commit 1cd1ee0e10
48 changed files with 232 additions and 180 deletions

View File

@ -89,7 +89,7 @@ class AssetManager implements \Countable
*
* @param string $id Asset id
*
* @return mixed Asset
* @return string|null
*
* @since 1.0.0
*/

View File

@ -167,7 +167,7 @@ class Depreciation
* Calculate the depreciation rate
*
* @param float $start Value to depreciate (reduced by residual value if required)
* @param int $residual Residual value
* @param float $residual Residual value
* @param int $duration Useful life time
*
* @return float
@ -183,7 +183,7 @@ class Depreciation
* Calculate the depreciation value in a period
*
* @param float $start Value to depreciate (reduced by residual value if required)
* @param int $residual Residual value
* @param float $residual Residual value
* @param int $duration Useful life time
* @param int $t Period
*
@ -202,7 +202,7 @@ class Depreciation
* Calculate the residual value after some periods
*
* @param float $start Value to depreciate (reduced by residual value if required)
* @param int $residual Residual value
* @param float $residual Residual value
* @param int $duration Useful life time
* @param int $t Period
*
@ -225,7 +225,7 @@ class Depreciation
* Calculate the depreciation rate
*
* @param float $start Value to depreciate (reduced by residual value if required)
* @param int $residual Residual value
* @param float $residual Residual value
* @param int $duration Useful life time
*
* @return float
@ -241,7 +241,7 @@ class Depreciation
* Calculate the depreciation value in a period
*
* @param float $start Value to depreciate (reduced by residual value if required)
* @param int $residual Residual value
* @param float $residual Residual value
* @param int $duration Useful life time
* @param int $t Period
*
@ -259,7 +259,7 @@ class Depreciation
* Calculate the residual value after some periods
*
* @param float $start Value to depreciate (reduced by residual value if required)
* @param int $residual Residual value
* @param float $residual Residual value
* @param int $duration Useful life time
* @param int $t Period
*

View File

@ -30,11 +30,11 @@ interface OptionsInterface
*
* @param mixed $key Key to check for existence
*
* @return void
* @return bool
*
* @since 1.0.0
*/
public function exists($key);
public function exists($key) : bool;
/**
* Updating or adding settings.

View File

@ -124,7 +124,7 @@ abstract class SettingsAbstract implements OptionsInterface
* @param string[] $options Column values for filtering
* @param bool $store Save this Setting immediately to database
*
* @return mixed Option value
* @return void
*
* @since 1.0.0
*/

View File

@ -58,7 +58,7 @@ class ConnectionFactory
case CacheType::REDIS:
return new RedisCache($cacheData);
case CacheType::MEMCACHED:
return new MemcachedCache($cacheData);
return new MemCached($cacheData);
case CacheType::WINCACHE:
return new WinCache($cacheData);
default:

View File

@ -39,7 +39,7 @@ interface ConnectionInterface extends DataStorageConnectionInterface
*
* @since 1.0.0
*/
public function set($key, $value, int $expire = -1); /* : void */
public function set($key, $value, int $expire = -1) : void;
/**
* Adding new data if it doesn't exist.

View File

@ -43,10 +43,12 @@ class MemCached extends ConnectionAbstract
/**
* Constructor.
*
* @param array $data Cache data
*
* @since 1.0.0
*/
public function __construct()
public function __construct(array $data)
{
$this->memc = null;
}

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Cache\Connection;
use phpOMS\DataStorage\Cache\CacheStatus;
/**
* RedisCache class.
*
@ -27,6 +29,17 @@ namespace phpOMS\DataStorage\Cache\Connection;
class RedisCache extends ConnectionAbstract
{
/**
* Constructor
*
* @param array $data Cache data
*
* @since 1.0.0
*/
public function __construct(array $data)
{
}
/**
* {@inheritdoc}
*/

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Cache\Connection;
use phpOMS\DataStorage\Cache\CacheStatus;
/**
* WinCache class.
*
@ -26,6 +28,17 @@ namespace phpOMS\DataStorage\Cache\Connection;
*/
class WinCache extends ConnectionAbstract
{
/**
* Constructor
*
* @param array $data Cache data
*
* @since 1.0.0
*/
public function __construct(array $data)
{
}
/**
* {@inheritdoc}
*/

View File

@ -38,7 +38,7 @@ interface DataStorageConnectionInterface
*
* @since 1.0.0
*/
public function connect(array $data); /* : void */
public function connect(array $data) : void;
/**
* Get the datastorage type.
@ -65,5 +65,5 @@ interface DataStorageConnectionInterface
*
* @since 1.0.0
*/
public function close(); /* : void */
public function close() : void;
}

View File

@ -30,7 +30,7 @@ interface DataStoragePoolInterface
/**
* Add connection.
*
* @param mixed $key Connection key
* @param string $key Connection key
* @param DataStorageConnectionInterface $db Connection
*
* @return bool
@ -42,7 +42,7 @@ interface DataStoragePoolInterface
/**
* Get connection.
*
* @param mixed $key Connection key
* @param string $key Connection key
*
* @return mixed
*
@ -53,7 +53,7 @@ interface DataStoragePoolInterface
/**
* Remove connection.
*
* @param mixed $key Connection key
* @param string $key Connection key
*
* @return bool
*

View File

@ -37,7 +37,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
*
* This can be used externally to define queries and execute them.
*
* @var \PDO
* @var \PDO|null
* @since 1.0.0
*/
public $con = null;

View File

@ -0,0 +1,36 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package phpOMS\DataStorage\Database\Connection
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace phpOMS\DataStorage\Database\Connection;
use phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException;
/**
* Database handler.
*
* @package phpOMS\DataStorage\Database\Connection
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class NullConnection extends ConnectionAbstract
{
/**
* {@inheritdoc}
*/
public function connect(array $dbdata = null) : void
{
}
}

View File

@ -1076,7 +1076,7 @@ class DataMapperAbstract implements DataMapperInterface
* @param mixed $objId Model id
* @param \ReflectionClass $reflectionClass Reflection class
*
* @return mixed
* @return void
*
* @since 1.0.0
*/
@ -1302,7 +1302,7 @@ class DataMapperAbstract implements DataMapperInterface
* @param int $relations Delete all relations as well
* @param \ReflectionClass $reflectionClass Reflection class
*
* @return mixed
* @return void
*
* @since 1.0.0
*/
@ -2271,7 +2271,7 @@ class DataMapperAbstract implements DataMapperInterface
public static function fillRelationsArray(array &$obj, int $relations = RelationType::ALL, int $depth = null) : void
{
if (isset($depth) && $depth < 1) {
return null;
return;
}
if ($relations !== RelationType::NONE) {
@ -2335,7 +2335,7 @@ class DataMapperAbstract implements DataMapperInterface
* @param mixed $refKey Key
* @param string $ref Ref
*
* @return mixed
* @return array
*
* @since 1.0.0
*/
@ -2361,7 +2361,7 @@ class DataMapperAbstract implements DataMapperInterface
* @param mixed $refKey Key
* @param string $ref Ref
*
* @return mixed
* @return array
*
* @since 1.0.0
*/

View File

@ -19,6 +19,7 @@ use phpOMS\DataStorage\DataStorageConnectionInterface;
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
use phpOMS\DataStorage\Database\Connection\ConnectionInterface;
use phpOMS\DataStorage\Database\Connection\NullConnection;
/**
* Database pool handler.
@ -34,7 +35,7 @@ class DatabasePool implements DataStoragePoolInterface
/**
* Databases.
*
* @var ConnectionAbstract[]
* @var DataStorageConnectionInterface[]
* @since 1.0.0
*/
private $pool = [];
@ -51,7 +52,7 @@ class DatabasePool implements DataStoragePoolInterface
/**
* Add database.
*
* @param mixed $key Database key
* @param string $key Database key
* @param DataStorageConnectionInterface $db Database
*
* @return bool
@ -72,16 +73,16 @@ class DatabasePool implements DataStoragePoolInterface
/**
* Get database.
*
* @param mixed $key Database key
* @param string $key Database key
*
* @return ConnectionInterface|null
* @return ConnectionAbstract
*
* @since 1.0.0
*/
public function get(string $key = '') /* : ?ConnectionInterface */
public function get(string $key = '') : ConnectionAbstract
{
if ((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) {
return null;
return new NullConnection();
}
if (empty($key)) {
@ -94,7 +95,7 @@ class DatabasePool implements DataStoragePoolInterface
/**
* Remove database.
*
* @param mixed $key Database key
* @param string $key Database key
*
* @return bool
*

View File

@ -490,7 +490,7 @@ class Builder extends BuilderAbstract
throw new \InvalidArgumentException('Unknown operator.');
}
if (is_string($columns)) {
if (!is_array($columns)) {
$columns = [$columns];
$operator = [$operator];
$values = [$values];
@ -703,6 +703,10 @@ class Builder extends BuilderAbstract
public function orderBy($columns, $order = 'DESC') : Builder
{
if (is_string($columns) || $columns instanceof \Closure) {
if (!is_string($order)) {
throw new \InvalidArgumentException();
}
if (!isset($this->orders[$order])) {
$this->orders[$order] = [];
}
@ -754,7 +758,7 @@ class Builder extends BuilderAbstract
/**
* Union.
*
* @param string|\phpOMS\DataStorage\Database\Query\Builder $query Query
* @param mixed $query Query
*
* @return Builder
*
@ -796,7 +800,7 @@ class Builder extends BuilderAbstract
/**
* Create query string.
*
* @return void
* @return string
*
* @since 1.0.0
*/

View File

@ -315,9 +315,9 @@ class Grammar extends GrammarAbstract
/**
* Compile value.
*
* @param Builder $query Query builder
* @param array|string|\Closure $value Value
* @param string $prefix Prefix in case value is a table
* @param Builder $query Query builder
* @param mixed $value Value
* @param string $prefix Prefix in case value is a table
*
* @return string Returns a string representation of the value.
*

View File

@ -42,7 +42,9 @@ class ConsoleSession implements SessionInterface
*/
public function __construct($sid = false)
{
$this->sid = $sid;
if ($sid !== false) {
$this->sid = $sid;
}
}
/**

View File

@ -71,7 +71,7 @@ interface SessionInterface
*
* @since 1.0.0
*/
public function save(); /* : void */
public function save() : void;
/**
* @return int|string
@ -87,7 +87,7 @@ interface SessionInterface
*
* @since 1.0.0
*/
public function setSID($sid); /* : void */
public function setSID($sid) : void;
/**
* Lock session from further adjustments.
@ -96,5 +96,5 @@ interface SessionInterface
*
* @since 1.0.0
*/
public function lock(); /* : void */
public function lock() : void;
}

View File

@ -42,7 +42,9 @@ class SocketSession implements SessionInterface
*/
public function __construct($sid = false)
{
$this->sid = $sid;
if ($sid !== false) {
$this->sid = $sid;
}
}
/**

View File

@ -63,7 +63,7 @@ class Dispatcher
* Dispatch controller.
*
* @param string|array|\Closure $controller Controller string
* @param mixed ...$data Data
* @param array|null ...$data Data
*
* @return array
*
@ -93,8 +93,8 @@ class Dispatcher
/**
* Dispatch string.
*
* @param string|array|\Closure $controller Controller string
* @param array $data Data
* @param string $controller Controller string
* @param array|null $data Data
*
* @return array
*
@ -126,8 +126,8 @@ class Dispatcher
/**
* Dispatch array.
*
* @param string|array|\Closure $controller Controller string
* @param array $data Data
* @param array $controller Controller string
* @param array|null $data Data
*
* @return array
*
@ -146,14 +146,14 @@ class Dispatcher
/**
* Dispatch closure.
*
* @param string|array|\Closure $controller Controller string
* @param array $data Data
* @param \Closure $controller Controller string
* @param array|null $data Data
*
* @return mixed
*
* @since 1.0.0
*/
private function dispatchClosure(\Closure $controller, array $data = null) : void
private function dispatchClosure(\Closure $controller, array $data = null)
{
return $controller($this->app, ...$data);
}

View File

@ -31,7 +31,7 @@ class L11nManager
/**
* Language.
*
* @var string[][]
* @var array
* @since 1.0.0
*/
private $language = [];
@ -65,9 +65,9 @@ class L11nManager
* One module can only be loaded once. Once the module got loaded it's not
* possible to load more language files later on.
*
* @param string $language Language iso code
* @param string $from Module name
* @param string[][] $translation Language files content
* @param string $language Language iso code
* @param string $from Module name
* @param array $translation Language files content
*
* @return void
*

View File

@ -99,7 +99,7 @@ class Localization
/**
* Weight.
*
* @var string
* @var array
* @since 1.0.0
*/
private $weight = [];
@ -107,7 +107,7 @@ class Localization
/**
* Speed.
*
* @var string
* @var array
* @since 1.0.0
*/
private $speed = [];
@ -115,7 +115,7 @@ class Localization
/**
* Length.
*
* @var string
* @var array
* @since 1.0.0
*/
private $length = [];
@ -123,7 +123,7 @@ class Localization
/**
* Area.
*
* @var string
* @var array
* @since 1.0.0
*/
private $area = [];
@ -131,7 +131,7 @@ class Localization
/**
* Volume.
*
* @var string
* @var array
* @since 1.0.0
*/
private $volume = [];
@ -314,7 +314,7 @@ class Localization
*
* @param string $decimal Decimal char
*
* @return string
* @return void
*
* @since 1.0.0
*/
@ -340,7 +340,7 @@ class Localization
*
* @param string $thousands Thousands char
*
* @return string
* @return void
*
* @since 1.0.0
*/
@ -366,7 +366,7 @@ class Localization
*
* @param string $angle Angle
*
* @return string
* @return void
*
* @since 1.0.0
*/
@ -392,7 +392,7 @@ class Localization
*
* @param string $temperature Temperature
*
* @return string
* @return void
*
* @since 1.0.0
*/
@ -418,7 +418,7 @@ class Localization
*
* @param array $speed Speed
*
* @return array
* @return void
*
* @since 1.0.0
*/
@ -444,7 +444,7 @@ class Localization
*
* @param array $weight Weight type
*
* @return array
* @return void
*
* @since 1.0.0
*/
@ -470,7 +470,7 @@ class Localization
*
* @param array $length Length type
*
* @return array
* @return void
*
* @since 1.0.0
*/
@ -496,7 +496,7 @@ class Localization
*
* @param array $area Area type
*
* @return array
* @return void
*
* @since 1.0.0
*/
@ -522,7 +522,7 @@ class Localization
*
* @param array $volume Volume type
*
* @return array
* @return void
*
* @since 1.0.0
*/

View File

@ -117,7 +117,7 @@ class Money implements \Serializable
$right = substr($right, 0, self::MAX_DECIMALS);
return (int) (((int) $left) * 10 ** self::MAX_DECIMALS + (int) str_pad($right, self::MAX_DECIMALS, '0'));
return ((int) $left) * 10 ** self::MAX_DECIMALS + (int) str_pad($right, self::MAX_DECIMALS, '0');
}
/**
@ -132,7 +132,7 @@ class Money implements \Serializable
*
* @since 1.0.0
*/
public function setLocalization(string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) : void
public function setLocalization(string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) : Money
{
$this->thousands = $thousands;
$this->decimal = $decimal;

View File

@ -33,7 +33,7 @@ interface LoggerInterface
*
* @return null
*/
public function emergency(string $message, array $context = []); /* : void */
public function emergency(string $message, array $context = []) : void;
/**
* Action must be taken immediately.
@ -46,7 +46,7 @@ interface LoggerInterface
*
* @return null
*/
public function alert(string $message, array $context = []); /* : void */
public function alert(string $message, array $context = []) : void;
/**
* Critical conditions.
@ -58,7 +58,7 @@ interface LoggerInterface
*
* @return null
*/
public function critical(string $message, array $context = []); /* : void */
public function critical(string $message, array $context = []) : void;
/**
* Runtime errors that do not require immediate action but should typically
@ -69,7 +69,7 @@ interface LoggerInterface
*
* @return null
*/
public function error(string $message, array $context = []); /* : void */
public function error(string $message, array $context = []) : void;
/**
* Exceptional occurrences that are not errors.
@ -82,7 +82,7 @@ interface LoggerInterface
*
* @return null
*/
public function warning(string $message, array $context = []); /* : void */
public function warning(string $message, array $context = []) : void;
/**
* Normal but significant events.
@ -92,7 +92,7 @@ interface LoggerInterface
*
* @return null
*/
public function notice(string $message, array $context = []); /* : void */
public function notice(string $message, array $context = []) : void;
/**
* Interesting events.
@ -104,7 +104,7 @@ interface LoggerInterface
*
* @return null
*/
public function info(string $message, array $context = []); /* : void */
public function info(string $message, array $context = []) : void;
/**
* Detailed debug information.
@ -114,7 +114,7 @@ interface LoggerInterface
*
* @return null
*/
public function debug(string $message, array $context = []); /* : void */
public function debug(string $message, array $context = []) : void;
/**
* Logs with an arbitrary level.
@ -125,5 +125,5 @@ interface LoggerInterface
*
* @return null
*/
public function log(string $level, string $message, array $context = []); /* : void */
public function log(string $level, string $message, array $context = []) : void;
}

View File

@ -51,7 +51,7 @@ interface EdgeInterface
*
* @since 1.0.0
*/
public function setWeight($weight); /* : void */
public function setWeight($weight) : void;
/**
* Get vertices.
@ -72,5 +72,5 @@ interface EdgeInterface
*
* @since 1.0.0
*/
public function setVertices(VerticeInterface $a, VerticeInterface $b); /* : void */
public function setVertices(VerticeInterface $a, VerticeInterface $b) : void;
}

View File

@ -169,7 +169,7 @@ abstract class HeaderAbstract
*
* @since 1.0.0
*/
abstract public function generate(int $statusCode); /* : void */
abstract public function generate(int $statusCode) : void;
/**
* Get status code
@ -203,7 +203,7 @@ abstract class HeaderAbstract
*
* @since 1.0.0
*/
abstract public function set(string $key, string $value, bool $overwrite = false); /* : void */
abstract public function set(string $key, string $value, bool $overwrite = false) : void;
/**
* Get header by key.

View File

@ -80,7 +80,10 @@ class Request extends RequestAbstract
$this->header = new Header();
$this->header->setL11n($l11n ?? new Localization());
$this->uri = $uri;
if ($uri !== null) {
$this->uri = $uri;
}
$this->source = RequestSource::WEB;
$this->init();

View File

@ -27,11 +27,11 @@ interface MessageInterface
/**
* Retrieves all message header values.
*
* @return HeaderAbstract
* @return HeaderAbstract|null
*
* @since 1.0.0
*/
public function getHeader() : HeaderAbstract;
public function getHeader() : ?HeaderAbstract;
/**
* Gets the body of the message.

View File

@ -20,8 +20,6 @@ use phpOMS\Uri\UriInterface;
/**
* Request class.
*
* @property mixed request
*
* @package phpOMS\Message
* @license OMS License 1.0
* @link http://website.orange-management.de

View File

@ -98,7 +98,7 @@ class InfoManager
public function update() : void
{
if (!file_exists($this->path)) {
throw new PathException((string) $this->path);
throw new PathException($this->path);
}
file_put_contents($this->path, json_encode($this->info, JSON_PRETTY_PRINT));

View File

@ -42,7 +42,7 @@ interface SocketInterface
*
* @since 1.0.0
*/
public function close(); /* : void */
public function close() : void;
/**
* Run socket.
@ -51,5 +51,5 @@ interface SocketInterface
*
* @since 1.0.0
*/
public function run(); /* : void */
public function run() : void;
}

View File

@ -329,5 +329,5 @@ interface ContainerInterface
*
* @since 1.0.0
*/
public function index(); /* : void */
public function index() : void;
}

View File

@ -46,11 +46,11 @@ interface DirectoryInterface extends ContainerInterface, \Iterator, \ArrayAccess
*
* @param string $name File/direcotry name
*
* @return mixed
* @return ContainerInterface|null
*
* @since 1.0.0
*/
public function getNode(string $name);
public function getNode(string $name) : ?ContainerInterface;
/**
* Add file or directory.

View File

@ -197,7 +197,7 @@ class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*/
public function getNode(string $name) : FileAbstract
public function getNode(string $name) : ?ContainerInterface
{
return $this->nodes[$name] ?? null;
}

View File

@ -88,7 +88,7 @@ class Directory extends FileAbstract implements DirectoryInterface
new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST) as $item
) {
$list[] = str_replace('\\', '/', $iterator->getSubPathName());
$list[] = str_replace('\\', '/', $iterator->getSubPathname());
}
return $list;
@ -114,7 +114,7 @@ class Directory extends FileAbstract implements DirectoryInterface
\RecursiveIteratorIterator::SELF_FIRST) as $item
) {
if ($item->getExtension() === $extension) {
$list[] = str_replace('\\', '/', $iterator->getSubPathName());
$list[] = str_replace('\\', '/', $iterator->getSubPathname());
}
}
@ -319,9 +319,9 @@ class Directory extends FileAbstract implements DirectoryInterface
\RecursiveIteratorIterator::SELF_FIRST) as $item
) {
if ($item->isDir()) {
mkdir($to . '/' . $iterator->getSubPathName());
mkdir($to . '/' . $iterator->getSubPathname());
} else {
copy($from . '/' . $iterator->getSubPathName(), $to . '/' . $iterator->getSubPathName());
copy($from . '/' . $iterator->getSubPathname(), $to . '/' . $iterator->getSubPathname());
}
}
@ -371,7 +371,7 @@ class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*/
public function getNode(string $name) : FileAbstract
public function getNode(string $name) : ?ContainerInterface
{
return $this->nodes[$name] ?? null;
}

View File

@ -37,15 +37,6 @@ class LocalStorage extends StorageAbstract
*/
private static $instance = null;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
}
/**
* Get instance.
*

View File

@ -34,27 +34,15 @@ abstract class StorageAbstract
*/
protected $type = 0;
/**
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
}
/**
* Get instance.
*
* @return mixed Storage instance.
* @return StorageAbstract Storage instance.
*
* @since 1.0.0
*/
public static function getInstance() : StorageAbstract
{
return null;
}
abstract public static function getInstance() : StorageAbstract;
/**
* Get storage type.
*

View File

@ -27,7 +27,7 @@ final class OperatingSystem
/**
* Get OS.
*
* @return int|SystemType
* @return int
*
* @since 1.0.0
*/

View File

@ -87,7 +87,6 @@ class SystemUtils
$freeArr = explode("\n", $free);
$mem = explode(" ", $freeArr[1]);
$mem = array_filter($mem);
$mem = array_merge($mem);
$memUsage = $mem[2] / $mem[1] * 100;
}

View File

@ -126,7 +126,7 @@ interface UriInterface
*
* @since 1.0.0
*/
public function setRootPath(string $root); /* : void */
public function setRootPath(string $root) : void;
/**
* Get path element.
@ -213,5 +213,5 @@ interface UriInterface
*
* @since 1.0.0
*/
public function set(string $uri); /* : void */
public function set(string $uri) : void;
}

View File

@ -48,6 +48,6 @@ namespace phpOMS\Utils\IO\Csv {
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function importCsv($path); /* : void */
public function importCsv($path) : void;
}
}

View File

@ -358,11 +358,11 @@ class Markdown
protected static function blockCode(array $lineArray, array $block = null) : ?array
{
if ($block !== null && !isset($block['type']) && !isset($block['interrupted'])) {
return;
return null;
}
if ($lineArray['indent'] < 4) {
return;
return null;
}
return [
@ -390,7 +390,7 @@ class Markdown
protected static function blockCodeContinue(array $lineArray, array $block) : ?array
{
if ($lineArray['indent'] < 4) {
return;
return null;
}
if (isset($block['interrupted'])) {
@ -431,7 +431,7 @@ class Markdown
protected static function blockFencedCode(array $lineArray) : ?array
{
if (!preg_match('/^[' . $lineArray['text'][0] . ']{3,}[ ]*([^`]+)?[ ]*$/', $lineArray['text'], $matches)) {
return;
return null;
}
$elementArray = [
@ -468,7 +468,7 @@ class Markdown
protected static function blockFencedCodeContinue(array $lineArray, array $block) : ?array
{
if (isset($block['complete'])) {
return;
return null;
}
if (isset($block['interrupted'])) {
@ -515,7 +515,7 @@ class Markdown
protected static function blockHeader(array $lineArray) : ?array
{
if (!isset($lineArray['text'][1])) {
return;
return null;
}
$level = 1;
@ -524,7 +524,7 @@ class Markdown
}
if ($level > 6) {
return;
return null;
}
return [
@ -550,7 +550,7 @@ class Markdown
list($name, $pattern) = $lineArray['text'][0] <= '-' ? ['ul', '[*+-]'] : ['ol', '[0-9]+[.]'];
if (!preg_match('/^(' . $pattern . '[ ]+)(.*)/', $lineArray['text'], $matches)) {
return;
return null;
}
$block = [
@ -649,7 +649,7 @@ class Markdown
protected static function blockQuote(array $lineArray) : ?array
{
if (!preg_match('/^>[ ]?(.*)/', $lineArray['text'], $matches)) {
return;
return null;
}
return [
@ -704,7 +704,7 @@ class Markdown
protected static function blockRule(array $lineArray) : ?array
{
if (!preg_match('/^([' . $lineArray['text'][0] . '])([ ]*\1){2,}[ ]*$/', $lineArray['text'])) {
return;
return null;
}
return [
@ -727,11 +727,11 @@ class Markdown
protected static function blockSetextHeader(array $lineArray, array $block = null) : ?array
{
if (!isset($block) || isset($block['type']) || isset($block['interrupted'])) {
return;
return null;
}
if (chop($lineArray['text'], $lineArray['text'][0]) !== '') {
return;
return null;
}
$block['element']['name'] = $lineArray['text'][0] === '=' ? 'h1' : 'h2';
@ -751,7 +751,7 @@ class Markdown
protected static function blockReference(array $lineArray) : ?array
{
if (!preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $lineArray['text'], $matches)) {
return;
return null;
}
$data = [
@ -777,7 +777,7 @@ class Markdown
protected static function blockTable($lineArray, array $block = null) : ?array
{
if (!isset($block) || isset($block['type']) || isset($block['interrupted'])) {
return;
return null;
}
if (strpos($block['element']['text'], '|') !== false && chop($lineArray['text'], ' -:|') === '') {
@ -872,7 +872,7 @@ class Markdown
protected static function blockTableContinue(array $lineArray, array $block) : ?array
{
if (isset($block['interrupted'])) {
return;
return null;
}
if ($lineArray['text'][0] === '|' || strpos($lineArray['text'], '|')) {
@ -994,7 +994,7 @@ class Markdown
$marker = $excerpt['text'][0];
if (!preg_match('/^(' . $marker . '+)[ ]*(.+?)[ ]*(?<!' . $marker . ')\1(?!' . $marker . ')/s', $excerpt['text'], $matches)) {
return;
return null;
}
return [
@ -1018,7 +1018,7 @@ class Markdown
protected static function inlineEmailTag(array $excerpt) : ?array
{
if (strpos($excerpt['text'], '>') === false || !preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $excerpt['text'], $matches)) {
return;
return null;
}
$url = $matches[1];
@ -1051,7 +1051,7 @@ class Markdown
protected static function inlineEmphasis(array $excerpt) : ?array
{
if (!isset($excerpt['text'][1])) {
return;
return null;
}
$marker = $excerpt['text'][0];
@ -1061,7 +1061,7 @@ class Markdown
} elseif (preg_match(self::$emRegex[$marker], $excerpt['text'], $matches)) {
$emphasis = 'em';
} else {
return;
return null;
}
return [
@ -1086,7 +1086,7 @@ class Markdown
protected static function inlineEscapeSequence(array $excerpt) : ?array
{
if (!isset($excerpt['text'][1]) || !in_array($excerpt['text'][1], self::$specialCharacters)) {
return;
return null;
}
return [
@ -1107,14 +1107,14 @@ class Markdown
protected static function inlineImage(array $excerpt) : ?array
{
if (!isset($excerpt['text'][1]) || $excerpt['text'][1] !== '[') {
return;
return null;
}
$excerpt['text'] = substr($excerpt['text'], 1);
$link = self::inlineLink($excerpt);
if ($link === null) {
return;
return null;
}
$inline = [
@ -1160,7 +1160,7 @@ class Markdown
$remainder = $excerpt['text'];
if (!preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches)) {
return;
return null;
}
$element['text'] = $matches[1];
@ -1186,7 +1186,7 @@ class Markdown
}
if (!isset(self::$definitionData['Reference'][$definition])) {
return;
return null;
}
$def = self::$definitionData['Reference'][$definition];
@ -1241,11 +1241,11 @@ class Markdown
protected static function inlineStrikethrough(array $excerpt) : ?array
{
if (!isset($excerpt['text'][1])) {
return;
return null;
}
if ($excerpt['text'][1] !== '~' || !preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $excerpt['text'], $matches)) {
return;
return null;
}
return [
@ -1270,11 +1270,11 @@ class Markdown
protected static function inlineUrl(array $excerpt) : ?array
{
if (!isset($excerpt['text'][2]) || $excerpt['text'][2] !== '/') {
return;
return null;
}
if (!preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) {
return;
return null;
}
return [
@ -1302,7 +1302,7 @@ class Markdown
protected static function inlineUrlTag(array $excerpt) : ?array
{
if (strpos($excerpt['text'], '>') === false || !preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $excerpt['text'], $matches)) {
return;
return null;
}
return [
@ -1322,7 +1322,7 @@ class Markdown
*
* @param string $text Normal text
*
* @return null|array
* @return string
*
* @since 1.0.0
*/
@ -1339,7 +1339,7 @@ class Markdown
*
* @param array $element Html element
*
* @return null|array
* @return string
*
* @since 1.0.0
*/
@ -1420,7 +1420,7 @@ class Markdown
*
* @param array $element Element to sanitize
*
* @return string
* @return array
*
* @since 1.0.0
*/
@ -1492,7 +1492,7 @@ class Markdown
* @param string $string Text to check against
* @param string $needle Needle to check
*
* @return bool|string
* @return bool
*
* @since 1.0.0
*/

View File

@ -280,7 +280,7 @@ class Text
*
* @since 1.0.0
*/
private function generateParagraph(int $length) : void
private function generateParagraph(int $length) : string
{
$minSentence = 3;
$maxSentence = 10;

View File

@ -620,7 +620,7 @@ class Interval implements \Serializable
*
* @since 1.0.0
*/
public function serializeTime($time, $step) : void
public function serializeTime($time, $step) : string
{
if (($count = count($time)) > 0) {
$serialize = implode(',', $time);
@ -643,7 +643,7 @@ class Interval implements \Serializable
*
* @since 1.0.0
*/
public function serializeDayOfMonth() : void
public function serializeDayOfMonth() : string
{
if (($count = count($this->dayOfMonth['dayOfMonth'])) > 0) {
$serialize = implode(',', $this->dayOfMonth['dayOfMonth']);
@ -670,7 +670,7 @@ class Interval implements \Serializable
*
* @since 1.0.0
*/
public function serializeDayOfWeek() : void
public function serializeDayOfWeek() : string
{
if (($count = count($this->dayOfWeek['dayOfWeek'])) > 0) {
$serialize = implode(',', $this->dayOfWeek['dayOfWeek']);

View File

@ -90,9 +90,9 @@ final class Validator extends ValidatorAbstract
/**
* Validate variable by length.
*
* @param string $var Variable to validate
* @param int|float $min Min. length
* @param int|float $max Max. length
* @param string $var Variable to validate
* @param int $min Min. length
* @param int $max Max. length
*
* @return bool
*

View File

@ -62,5 +62,5 @@ interface ValidatorInterface
*
* @since 1.0.0
*/
public static function resetError(); /* : void */
public static function resetError() : void;
}

View File

@ -50,7 +50,7 @@ class View extends ViewAbstract
/**
* Application.
*
* @var ApplicationAbstract
* @var ApplicationAbstract|null
* @since 1.0.0
*/
protected $app = null;
@ -58,7 +58,7 @@ class View extends ViewAbstract
/**
* Request.
*
* @var RequestAbstract
* @var RequestAbstract|null
* @since 1.0.0
*/
protected $request = null;
@ -66,7 +66,7 @@ class View extends ViewAbstract
/**
* Request.
*
* @var ResponseAbstract
* @var ResponseAbstract|null
* @since 1.0.0
*/
protected $response = null;
@ -85,7 +85,7 @@ class View extends ViewAbstract
$this->app = $app;
$this->request = $request;
$this->response = $response;
$this->l11n = $response !== null ? $response->getHeader()->getL11n() : null;
$this->l11n = $response !== null ? $response->getHeader()->getL11n() : new Localization();
}
/**
@ -178,7 +178,7 @@ class View extends ViewAbstract
$match = '/Modules/';
if (($start = strripos($this->template, $match)) === false) {
throw new InvalidModuleException($module);
throw new InvalidModuleException($module ?? '');
}
$start = $start + strlen($match);
@ -190,7 +190,7 @@ class View extends ViewAbstract
$match = '/Theme/';
if (($start = strripos($this->template, $match)) === false) {
throw new InvalidThemeException($theme);
throw new InvalidThemeException($theme ?? '');
}
$start = $start + strlen($match);
@ -220,11 +220,11 @@ class View extends ViewAbstract
/**
* Get request of view
*
* @return RequestAbstract
* @return RequestAbstract|null
*
* @since 1.0.0
*/
public function getRequest() : RequestAbstract
public function getRequest() : ?RequestAbstract
{
return $this->request;
}
@ -232,11 +232,11 @@ class View extends ViewAbstract
/**
* Get response of view
*
* @return ResponseAbstract
* @return ResponseAbstract|null
*
* @since 1.0.0
*/
public function getResponse() : ResponseAbstract
public function getResponse() : ?ResponseAbstract
{
return $this->response;
}