mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Type hint fixes
This commit is contained in:
parent
af0a980d1b
commit
8067e42f78
|
|
@ -601,7 +601,7 @@ class Account implements ArrayableInterface, \JsonSerializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString() : string
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ class Group implements ArrayableInterface, \JsonSerializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString() : string
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,19 +21,18 @@ namespace phpOMS;
|
|||
* is restricted to write once in order to prevent manipulation
|
||||
* and afterwards read only.
|
||||
*
|
||||
* @property mixed orgId
|
||||
* @property string appName
|
||||
* @property \phpOMS\DataStorage\Database\DatabasePool dbPool
|
||||
* @property \phpOMS\Localization\L11nManager l11nManager
|
||||
* @property \phpOMS\Router\Router router
|
||||
* @property \phpOMS\DataStorage\Session\SessionInterface sessionManager
|
||||
* @property \phpOMS\Module\ModuleManager moduleManager
|
||||
* @property \phpOMS\Dispatcher\Dispatcher dispatcher
|
||||
* @property \phpOMS\DataStorage\Cache\CachePool cachePool
|
||||
* @property \Model\CoreSettings appSettings
|
||||
* @property \phpOMS\Event\EventManager eventManager
|
||||
* @property \phpOMS\Account\AccountManager accountManager
|
||||
* @property \phpOMS\Log\FileLogger logger
|
||||
* @property string $appName
|
||||
* @property \phpOMS\DataStorage\Database\DatabasePool $dbPool
|
||||
* @property \phpOMS\Localization\L11nManager 4l11nManager
|
||||
* @property \phpOMS\Router\Router $router
|
||||
* @property \phpOMS\DataStorage\Session\SessionInterface $sessionManager
|
||||
* @property \phpOMS\Module\ModuleManager $moduleManager
|
||||
* @property \phpOMS\Dispatcher\Dispatcher $dispatcher
|
||||
* @property \phpOMS\DataStorage\Cache\CachePool $cachePool
|
||||
* @property \Model\CoreSettings $appSettings
|
||||
* @property \phpOMS\Event\EventManager $eventManager
|
||||
* @property \phpOMS\Account\AccountManager $accountManager
|
||||
* @property \phpOMS\Log\FileLogger $logger
|
||||
*
|
||||
* @package phpOMS
|
||||
* @license OMS License 1.0
|
||||
|
|
@ -159,7 +158,7 @@ class ApplicationAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
public function __set($name, $value) : void
|
||||
{
|
||||
if (!empty($this->$name)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class ARIMA
|
|||
return $adjusted;
|
||||
}
|
||||
|
||||
private function getRemainder(array $seasonal, array $trendCycle)
|
||||
private function getRemainder(array $seasonal, array $trendCycle) : array
|
||||
{
|
||||
$remainder = [];
|
||||
foreach ($seasonal as $key => $e) {
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ class Money implements \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
return $this->getInt();
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ class Money implements \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function unserialize($value)
|
||||
public function unserialize($value) : void
|
||||
{
|
||||
$this->setInt($value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ class Polygon implements D2ShapeInterface
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getExteriorAngleSum()
|
||||
public function getExteriorAngleSum() : int
|
||||
{
|
||||
return 360;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,18 +219,18 @@ class LUDecomposition
|
|||
/**
|
||||
* Get determinant
|
||||
*
|
||||
* @return mixed
|
||||
* @return float
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function det()
|
||||
public function det() : float
|
||||
{
|
||||
$d = $this->pivSign;
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
$d *= $this->LU[$j][$j];
|
||||
}
|
||||
|
||||
return $d;
|
||||
return (float) $d;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class QRDecomposition
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getH()
|
||||
public function getH() : Matrix
|
||||
{
|
||||
$H = [[]];
|
||||
|
||||
|
|
@ -103,10 +103,10 @@ class QRDecomposition
|
|||
$matrix = new Matrix();
|
||||
$matrix->setArray($H);
|
||||
|
||||
return $this->matrix;
|
||||
return $matrix;
|
||||
}
|
||||
|
||||
public function getR()
|
||||
public function getR() : Matrix
|
||||
{
|
||||
$R = [[]];
|
||||
|
||||
|
|
@ -125,10 +125,10 @@ class QRDecomposition
|
|||
$matrix = new Matrix();
|
||||
$matrix->setArray($R);
|
||||
|
||||
return $this->matrix;
|
||||
return $matrix;
|
||||
}
|
||||
|
||||
public function getQ()
|
||||
public function getQ() : Matrix
|
||||
{
|
||||
$Q = [[]];
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ class QRDecomposition
|
|||
$matrix = new Matrix();
|
||||
$matrix->setArray($Q);
|
||||
|
||||
return $this->matrix;
|
||||
return $matrix;
|
||||
}
|
||||
|
||||
public function solve(Matrix $B) : Matrix
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class Average
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function mode(array $values)
|
||||
public static function mode(array $values) : float
|
||||
{
|
||||
$count = array_count_values($values);
|
||||
$best = max($count);
|
||||
|
|
|
|||
0
Message/Console/Header.php
Normal file
0
Message/Console/Header.php
Normal file
104
Message/Console/Request.php
Normal file
104
Message/Console/Request.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @package phpOMS\Message\Console
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Message\Http;
|
||||
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\RequestSource;
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
/**
|
||||
* Request class.
|
||||
*
|
||||
* @package phpOMS\Message\Console
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
class Request extends RequestAbstract
|
||||
{
|
||||
/**
|
||||
* OS type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $os = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param UriInterface $uri Uri
|
||||
* @param Localization $l11n Localization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(UriInterface $uri, Localization $l11n = null)
|
||||
{
|
||||
$this->header = new Header();
|
||||
|
||||
if ($l11n === null) {
|
||||
$l11n = $l11n ?? new Localization();
|
||||
}
|
||||
|
||||
$this->header->setL11n($l11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create request hashs of current request
|
||||
*
|
||||
* The hashes are based on the request path and can be used as unique id.
|
||||
*
|
||||
* @param int $start Start hash from n-th path element
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo: maybe change to normal path string e.g. /some/path/here instead of hash! Remember to adjust navigation elements
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createRequestHashs(int $start = 0) : void
|
||||
{
|
||||
$this->hash = [];
|
||||
$pathArray = $this->uri->getPathElements();
|
||||
|
||||
foreach ($pathArray as $key => $path) {
|
||||
$paths = [];
|
||||
for ($i = $start; $i < $key + 1; ++$i) {
|
||||
$paths[] = $pathArray[$i];
|
||||
}
|
||||
|
||||
$this->hash[] = sha1(implode('', $paths));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine request OS.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getOS() : string
|
||||
{
|
||||
if ($this->os === null) {
|
||||
$this->os = PHP_OS;
|
||||
}
|
||||
|
||||
return $this->os;
|
||||
}
|
||||
}
|
||||
0
Message/Console/Response.php
Normal file
0
Message/Console/Response.php
Normal file
|
|
@ -84,8 +84,6 @@ class Request extends RequestAbstract
|
|||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
$this->source = RequestSource::WEB;
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,14 +67,6 @@ abstract class RequestAbstract implements MessageInterface
|
|||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Request type.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $source = RequestSource::UNDEFINED;
|
||||
|
||||
/**
|
||||
* Request hash.
|
||||
*
|
||||
|
|
@ -137,36 +129,6 @@ abstract class RequestAbstract implements MessageInterface
|
|||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request source.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getRequestSource() : int
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set request source.
|
||||
*
|
||||
* @param int $source Request source
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setRequestSource(int $source) : void
|
||||
{
|
||||
if (!RequestSource::isValidValue($source)) {
|
||||
throw new InvalidEnumValue((string) $source);
|
||||
}
|
||||
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request method.
|
||||
*
|
||||
|
|
@ -281,7 +243,7 @@ abstract class RequestAbstract implements MessageInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->uri->__toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ class PackageManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function move($components)
|
||||
private function move($components) : void
|
||||
{
|
||||
foreach ($components as $component) {
|
||||
LocalStorage::move($this->basePath . '/' . $component['from'], $this->basePath . '/' . $component['to'], true);
|
||||
|
|
@ -194,7 +194,7 @@ class PackageManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function copy($components)
|
||||
private function copy($components) : void
|
||||
{
|
||||
foreach ($components as $component) {
|
||||
if (StringUtils::startsWith($component['from'], 'Package/')) {
|
||||
|
|
@ -214,7 +214,7 @@ class PackageManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function delete($components)
|
||||
private function delete($components) : void
|
||||
{
|
||||
foreach ($components as $component) {
|
||||
LocalStorage::delete($this->basePath . '/' . $component);
|
||||
|
|
@ -230,7 +230,7 @@ class PackageManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function execute($components)
|
||||
private function execute($components) : void
|
||||
{
|
||||
foreach ($components as $component) {
|
||||
include $this->basePath . '/' . $component;
|
||||
|
|
@ -244,7 +244,7 @@ class PackageManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function cleanup()
|
||||
public function cleanup() : void
|
||||
{
|
||||
File::delete($this->path);
|
||||
Directory::delete($this->extractPath);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class CommandManager implements \Countable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function attach(string $cmd, $callback, $source)
|
||||
public function attach(string $cmd, $callback, $source) : void
|
||||
{
|
||||
$this->commands[$cmd] = [$callback, $source];
|
||||
$this->count++;
|
||||
|
|
@ -77,7 +77,7 @@ class CommandManager implements \Countable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function detach(string $cmd, $source)
|
||||
public function detach(string $cmd, $source) : void
|
||||
{
|
||||
if (array_key_exists($cmd, $this->commands)) {
|
||||
unset($this->commands[$cmd]);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class Header implements \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
return $this->__toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class PacketManager
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function handle(string $data, $client)
|
||||
public function handle(string $data, $client) : void
|
||||
{
|
||||
echo $data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,12 +249,9 @@ class Iban implements \Serializable
|
|||
}
|
||||
|
||||
/**
|
||||
* String representation of object
|
||||
* @link http://php.net/manual/en/serializable.serialize.php
|
||||
* @return string the string representation of the object or null
|
||||
* @since 5.1.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
return $this->prettyPrint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,12 +293,9 @@ class Location implements \JsonSerializable, \Serializable
|
|||
}
|
||||
|
||||
/**
|
||||
* String representation of object
|
||||
* @link http://php.net/manual/en/serializable.serialize.php
|
||||
* @return string the string representation of the object or null
|
||||
* @since 5.1.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
return json_encode($this->jsonSerialize());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class JsonBuilder implements \Serializable, \JsonSerializable
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
return json_encode($this->json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,7 +598,7 @@ class Interval implements \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
$minute = $this->serializeTime($this->minute['minutes'], $this->minute['step']);
|
||||
$hour = $this->serializeTime($this->hour['hours'], $this->hour['step']);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ abstract class ViewAbstract implements \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function serialize()
|
||||
public function serialize() : string
|
||||
{
|
||||
if (empty($this->template)) {
|
||||
return json_encode($this->toArray());
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class RequestTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEmpty([], $request->getFiles());
|
||||
self::assertEquals(RouteVerb::GET, $request->getRouteVerb());
|
||||
self::assertEquals(RequestMethod::GET, $request->getMethod());
|
||||
self::assertEquals(RequestSource::WEB, $request->getRequestSource());
|
||||
self::assertInstanceOf('\phpOMS\Message\Http\Header', $request->getHeader());
|
||||
self::assertInstanceOf('\phpOMS\Message\Http\Request', Request::createFromSuperglobals());
|
||||
self::assertEquals('http://', $request->__toString());
|
||||
|
|
@ -89,9 +88,6 @@ class RequestTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertTrue($request->hasData('key'));
|
||||
self::assertEquals(['key' => 'value'], $request->getData());
|
||||
|
||||
$request->setRequestSource(RequestSource::SOCKET);
|
||||
self::assertEquals(RequestSource::SOCKET, $request->getRequestSource());
|
||||
|
||||
$request->setUri(new Http('http://www.google.com/test/path2'));
|
||||
$request->createRequestHashs(0);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user