diff --git a/Account/Account.php b/Account/Account.php index 0e6b88f38..08de62591 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -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()); } diff --git a/Account/Group.php b/Account/Group.php index ebd6b6a89..bb213666f 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -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()); } diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index 51f91988c..8375eaa9b 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -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; diff --git a/Business/Finance/Forecasting/ARIMA.php b/Business/Finance/Forecasting/ARIMA.php index 0c72e76ad..f0d9adf43 100644 --- a/Business/Finance/Forecasting/ARIMA.php +++ b/Business/Finance/Forecasting/ARIMA.php @@ -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) { diff --git a/Localization/Money.php b/Localization/Money.php index e8e8f86d1..28c4c5b9d 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -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); } diff --git a/Math/Geometry/Shape/D2/Polygon.php b/Math/Geometry/Shape/D2/Polygon.php index 635ee819f..e1d1dc0fa 100644 --- a/Math/Geometry/Shape/D2/Polygon.php +++ b/Math/Geometry/Shape/D2/Polygon.php @@ -171,7 +171,7 @@ class Polygon implements D2ShapeInterface * * @since 1.0.0 */ - public function getExteriorAngleSum() + public function getExteriorAngleSum() : int { return 360; } diff --git a/Math/Matrix/LUDecomposition.php b/Math/Matrix/LUDecomposition.php index fb160b347..58ae042f2 100644 --- a/Math/Matrix/LUDecomposition.php +++ b/Math/Matrix/LUDecomposition.php @@ -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; } /** diff --git a/Math/Matrix/QRDecomposition.php b/Math/Matrix/QRDecomposition.php index 9b8bb5978..83e033176 100644 --- a/Math/Matrix/QRDecomposition.php +++ b/Math/Matrix/QRDecomposition.php @@ -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 diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index f1368c06c..dfe6e0ecd 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -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); diff --git a/Message/Console/Header.php b/Message/Console/Header.php new file mode 100644 index 000000000..e69de29bb diff --git a/Message/Console/Request.php b/Message/Console/Request.php new file mode 100644 index 000000000..439b3f455 --- /dev/null +++ b/Message/Console/Request.php @@ -0,0 +1,104 @@ +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; + } +} diff --git a/Message/Console/Response.php b/Message/Console/Response.php new file mode 100644 index 000000000..e69de29bb diff --git a/Message/Http/Request.php b/Message/Http/Request.php index bcdf79138..6b6f385aa 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -84,8 +84,6 @@ class Request extends RequestAbstract $this->uri = $uri; } - $this->source = RequestSource::WEB; - $this->init(); } diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index b01b078ad..4812f8a68 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -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(); } diff --git a/Module/PackageManager.php b/Module/PackageManager.php index 729666c50..78a3e5ffb 100644 --- a/Module/PackageManager.php +++ b/Module/PackageManager.php @@ -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); diff --git a/Socket/CommandManager.php b/Socket/CommandManager.php index 6cc621979..6d1d48d96 100644 --- a/Socket/CommandManager.php +++ b/Socket/CommandManager.php @@ -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]); diff --git a/Socket/Packets/Header.php b/Socket/Packets/Header.php index 7bb582dc2..c3fe055b9 100644 --- a/Socket/Packets/Header.php +++ b/Socket/Packets/Header.php @@ -147,7 +147,7 @@ class Header implements \Serializable * * @since 1.0.0 */ - public function serialize() + public function serialize() : string { return $this->__toString(); } diff --git a/Socket/Packets/PacketManager.php b/Socket/Packets/PacketManager.php index 7f53fe266..c0cc78107 100644 --- a/Socket/Packets/PacketManager.php +++ b/Socket/Packets/PacketManager.php @@ -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; } diff --git a/Stdlib/Base/Iban.php b/Stdlib/Base/Iban.php index 4312cd026..324663470 100644 --- a/Stdlib/Base/Iban.php +++ b/Stdlib/Base/Iban.php @@ -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(); } diff --git a/Stdlib/Base/Location.php b/Stdlib/Base/Location.php index 4fed3e89c..a79c83537 100644 --- a/Stdlib/Base/Location.php +++ b/Stdlib/Base/Location.php @@ -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()); } diff --git a/Utils/JsonBuilder.php b/Utils/JsonBuilder.php index 4e80ed12e..30e1bab9f 100644 --- a/Utils/JsonBuilder.php +++ b/Utils/JsonBuilder.php @@ -87,7 +87,7 @@ class JsonBuilder implements \Serializable, \JsonSerializable /** * {@inheritdoc} */ - public function serialize() + public function serialize() : string { return json_encode($this->json); } diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index 3f6b0fb3a..8c77675b5 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -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']); diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index ef47d2e7b..f42cc06d5 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -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()); diff --git a/tests/Message/Http/RequestTest.php b/tests/Message/Http/RequestTest.php index 6f5b74f90..68732c68a 100644 --- a/tests/Message/Http/RequestTest.php +++ b/tests/Message/Http/RequestTest.php @@ -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);