Improve codestyle

This commit is contained in:
Dennis Eichhorn 2018-02-03 10:30:13 +01:00
parent f1288ebc03
commit e4dadf447d
60 changed files with 274 additions and 309 deletions

View File

@ -112,7 +112,7 @@ abstract class SettingsAbstract implements OptionsInterface
return count($options) > 1 ? $options : reset($options);
} catch (\PDOException $e) {
$exception = DatabaseExceptionFactory::createException($e);
$message = DatabaseExceptionFactory::createExceptionMessage($e);
$message = DatabaseExceptionFactory::createExceptionMessage($e);
throw new $exception($message);
}
@ -133,7 +133,7 @@ abstract class SettingsAbstract implements OptionsInterface
$this->setOptions($options);
if ($store) {
foreach($this->options as $key => $option) {
foreach ($this->options as $key => $option) {
$query = new Builder($this->connection);
$sql = $query->update($this->connection->prefix . static::$table)
->set([static::$columns[1] => $option])

View File

@ -85,5 +85,4 @@ interface ConnectionInterface
* @since 1.0.0
*/
public function getSchemaGrammar() : SchemaGrammar;
}

View File

@ -72,4 +72,4 @@ class SqlServerConnection extends ConnectionAbstract
$this->dbdata['password'] = '****';
}
}
}
}

View File

@ -648,8 +648,8 @@ class DataMapperAbstract implements DataMapperInterface
}
/** @var string $mapper */
$mapper = static::$hasMany[$propertyName]['mapper'];
$objsIds = [];
$mapper = static::$hasMany[$propertyName]['mapper'];
$objsIds = [];
foreach ($values as $key => &$value) {
if (!is_object($value)) {
@ -817,8 +817,7 @@ class DataMapperAbstract implements DataMapperInterface
private static function createRelationTable(string $propertyName, array $objsIds, $objId)
{
/** @var string $table */
if (
!empty($objsIds)
if (!empty($objsIds)
&& static::$hasMany[$propertyName]['table'] !== static::$table
&& static::$hasMany[$propertyName]['table'] !== static::$hasMany[$propertyName]['mapper']::$table
) {
@ -908,8 +907,8 @@ class DataMapperAbstract implements DataMapperInterface
}
/** @var string $mapper */
$mapper = static::$hasMany[$propertyName]['mapper'];
$relReflectionClass = null;
$mapper = static::$hasMany[$propertyName]['mapper'];
$relReflectionClass = null;
$objsIds[$propertyName] = [];
foreach ($values as $key => &$value) {
@ -1003,8 +1002,7 @@ class DataMapperAbstract implements DataMapperInterface
private static function deleteRelationTable(string $propertyName, array $objsIds, $objId)
{
/** @var string $table */
if (
!empty($objsIds)
if (!empty($objsIds)
&& static::$hasMany[$propertyName]['table'] !== static::$table
&& static::$hasMany[$propertyName]['table'] !== static::$hasMany[$propertyName]['mapper']::$table
) {
@ -1515,7 +1513,7 @@ class DataMapperAbstract implements DataMapperInterface
/** @var string $mapper */
$mapper = static::$hasMany[$member]['mapper'];
$objects = $mapper::getArray($values, RelationType::ALL, $depth);
$objects = $mapper::getArray($values, RelationType::ALL, $depth);
$obj[$member] = $objects;
}
}
@ -1548,13 +1546,13 @@ class DataMapperAbstract implements DataMapperInterface
/** @var string $mapper */
$mapper = static::$hasOne[$member]['mapper'];
$id = $reflectionProperty->getValue($obj);
$id = $reflectionProperty->getValue($obj);
if (self::isNullObject($id)) {
continue;
}
$id = is_object($id) ? self::getObjectId($id) : $id;
$id = is_object($id) ? self::getObjectId($id) : $id;
$value = self::getInitialized($mapper, $id) ?? $mapper::get($id, RelationType::ALL, null, $depth);
$reflectionProperty->setValue($obj, $value);
@ -1582,7 +1580,7 @@ class DataMapperAbstract implements DataMapperInterface
{
foreach (static::$hasOne as $member => $one) {
/** @var string $mapper */
$mapper = static::$hasOne[$member]['mapper'];
$mapper = static::$hasOne[$member]['mapper'];
$obj[$member] = self::getInitialized($mapper, $obj['member']) ?? $mapper::getArray($obj[$member], RelationType::ALL, $depth);
}
}
@ -1614,13 +1612,13 @@ class DataMapperAbstract implements DataMapperInterface
/** @var string $mapper */
$mapper = static::$ownsOne[$member]['mapper'];
$id = $reflectionProperty->getValue($obj);
$id = $reflectionProperty->getValue($obj);
if (self::isNullObject($id)) {
continue;
}
$id = is_object($id) ? self::getObjectId($id) : $id;
$id = is_object($id) ? self::getObjectId($id) : $id;
$value = self::getInitialized($mapper, $id) ?? $mapper::get($id, RelationType::ALL, null, $depth);
$reflectionProperty->setValue($obj, $value);
@ -1648,7 +1646,7 @@ class DataMapperAbstract implements DataMapperInterface
{
foreach (static::$ownsOne as $member => $one) {
/** @var string $mapper */
$mapper = static::$ownsOne[$member]['mapper'];
$mapper = static::$ownsOne[$member]['mapper'];
$obj[$member] = self::getInitialized($mapper, $obj[$member]) ?? $mapper::getArray($obj[$member], RelationType::ALL, $depth);
}
}
@ -1680,13 +1678,13 @@ class DataMapperAbstract implements DataMapperInterface
/** @var string $mapper */
$mapper = static::$belongsTo[$member]['mapper'];
$id = $reflectionProperty->getValue($obj);
$id = $reflectionProperty->getValue($obj);
if (self::isNullObject($id)) {
continue;
}
$id = is_object($id) ? self::getObjectId($id) : $id;
$id = is_object($id) ? self::getObjectId($id) : $id;
$value = self::getInitialized($mapper, $id) ?? $mapper::get($id, RelationType::ALL, null, $depth);
$reflectionProperty->setValue($obj, $value);
@ -1714,7 +1712,7 @@ class DataMapperAbstract implements DataMapperInterface
{
foreach (static::$belongsTo as $member => $one) {
/** @var string $mapper */
$mapper = static::$belongsTo[$member]['mapper'];
$mapper = static::$belongsTo[$member]['mapper'];
$obj[$member] = self::getInitialized($mapper, $obj[$member]) ?? $mapper::get($obj[$member], RelationType::ALL, null, $depth);
}
}
@ -1971,7 +1969,7 @@ class DataMapperAbstract implements DataMapperInterface
$toLoad = self::getPrimaryKeysBy($value, self::getColumnByMember($ref));
}
$obj[$value] = self::get($toLoad, $relations, $fill, isset($depth) ? --$depth : null);
$obj[$value] = self::get($toLoad, $relations, $fill, isset($depth) ? --$depth : null);
}
$countResulsts = count($obj);

View File

@ -1,40 +1,40 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package TBD
* @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\Exception;
/**
* Permission exception class.
*
* @package Framework
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class InvalidDatabaseTypeException extends \InvalidArgumentException
{
/**
* Constructor.
*
* @param string $message Exception message
* @param int $code Exception code
* @param \Exception $previous Previous exception
*
* @since 1.0.0
*/
public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
{
parent::__construct('Invalid database type "' . $message . '".', $code, $previous);
}
}
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package TBD
* @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\Exception;
/**
* Permission exception class.
*
* @package Framework
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class InvalidDatabaseTypeException extends \InvalidArgumentException
{
/**
* Constructor.
*
* @param string $message Exception message
* @param int $code Exception code
* @param \Exception $previous Previous exception
*
* @since 1.0.0
*/
public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
{
parent::__construct('Invalid database type "' . $message . '".', $code, $previous);
}
}

View File

@ -237,7 +237,7 @@ abstract class GrammarAbstract
foreach ($this->specialKeywords as $keyword) {
if (strrpos($system, $keyword, -strlen($system)) !== false) {
$prefix = '';
$prefix = '';
$identifier = '';
}
}

View File

@ -479,10 +479,10 @@ class Builder extends BuilderAbstract
}
if (is_string($columns)) {
$columns = [$columns];
$columns = [$columns];
$operator = [$operator];
$values = [$values];
$boolean = [$boolean];
$values = [$values];
$boolean = [$boolean];
}
$i = 0;

View File

@ -17,4 +17,4 @@ namespace phpOMS\DataStorage\Database\Query;
class Expression
{
}
}

View File

@ -30,6 +30,6 @@ abstract class QueryType extends Enum
{
/* public */ const SELECT = 0;
/* public */ const CREATE = 1;
/* public */ const DROP = 2;
/* public */ const ALTER = 3;
/* public */ const DROP = 2;
/* public */ const ALTER = 3;
}

View File

@ -32,7 +32,7 @@ class Builder extends DatabaseQueryBuilder
private function download($uri)
{
$finder = [];
$l11n = new Localization();
$l11n = new Localization();
foreach ($this->from as $from) {
$doc = new \DOMDocument();
@ -52,7 +52,7 @@ class Builder extends DatabaseQueryBuilder
{
$finder = $this->download();
$result = [];
$table = null;
$table = null;
foreach ($this->wheres as $column => $where) {
if ($column === 'xpath') {
@ -86,7 +86,7 @@ class Builder extends DatabaseQueryBuilder
private function createTableFromList($node) : array
{
$table = [];
$table = [];
$children = $node->childNodes;
foreach ($children as $child) {

View File

@ -198,4 +198,4 @@ class Dispatcher
{
$this->controllers[$name] = $controller;
}
}
}

View File

@ -51,7 +51,7 @@ class Fibunacci
*
* @since 1.0.0
*/
public static function fibunacci(int $n, int $start = 1) : int
public static function fib(int $n, int $start = 1) : int
{
if ($n < 3) {
return $start;
@ -83,4 +83,4 @@ class Fibunacci
{
return (int) (((1 + sqrt(5)) ** $n - (1 - sqrt(5)) ** $n) / (2 ** $n * sqrt(5)));
}
}
}

View File

@ -67,8 +67,9 @@ class Polygon implements D2ShapeInterface
*/
public function pointInPolygon(array $point) : int
{
$coord = $this->coord;
$coord = $this->coord;
$coord[] = $this->coord[0];
return self::isPointInPolygon($point, $coord);
}
@ -196,7 +197,7 @@ class Polygon implements D2ShapeInterface
*/
private function getSignedSurface() : float
{
$count = count($this->coord);
$count = count($this->coord);
$surface = 0;
for ($i = 0; $i < $count - 1; $i++) {
@ -204,7 +205,6 @@ class Polygon implements D2ShapeInterface
}
$surface += $this->coord[$count - 1]['x'] * $this->coord[0]['y'] - $this->coord[0]['x'] * $this->coord[$count - 1]['y'];
$surface /= 2;
return $surface;
@ -219,7 +219,7 @@ class Polygon implements D2ShapeInterface
*/
public function getPerimeter() : float
{
$count = count($this->coord);
$count = count($this->coord);
$perimeter = sqrt(($this->coord[0]['x'] - $this->coord[$count - 1]['x']) ** 2 + ($this->coord[0]['y'] - $this->coord[$count - 1]['y']) ** 2);
for ($i = 0; $i < $count - 1; $i++) {
@ -239,15 +239,15 @@ class Polygon implements D2ShapeInterface
public function getBarycenter() : array
{
$barycenter = ['x' => 0, 'y' => 0];
$count = count($this->coord);
$count = count($this->coord);
for ($i = 0; $i < $count - 1; $i++) {
$mult = ($this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']);
$mult = ($this->coord[$i]['x'] * $this->coord[$i + 1]['y'] - $this->coord[$i + 1]['x'] * $this->coord[$i]['y']);
$barycenter['x'] += ($this->coord[$i]['x'] + $this->coord[$i + 1]['x']) * $mult;
$barycenter['y'] += ($this->coord[$i]['y'] + $this->coord[$i + 1]['y']) * $mult;
}
$mult = ($this->coord[$count - 1]['x'] * $this->coord[0]['y'] - $this->coord[0]['x'] * $this->coord[$count - 1]['y']);
$mult = ($this->coord[$count - 1]['x'] * $this->coord[0]['y'] - $this->coord[0]['x'] * $this->coord[$count - 1]['y']);
$barycenter['x'] += ($this->coord[$count - 1]['x'] + $this->coord[0]['x']) * $mult;
$barycenter['y'] += ($this->coord[$count - 1]['y'] + $this->coord[0]['y']) * $mult;

View File

@ -16,4 +16,4 @@ namespace phpOMS\Math\Geometry\Shape\D3;
class Prism implements D3ShapeInterface
{
}
}

View File

@ -17,4 +17,4 @@ namespace phpOMS\Math\Integral;
class Gauss
{
}
}

View File

@ -39,4 +39,4 @@ class IdentityMatrix extends Matrix
$this->matrix[$i][$i] = 1;
}
}
}
}

View File

@ -181,8 +181,8 @@ class Matrix implements \ArrayAccess, \Iterator
*/
public function setMatrix(array $matrix) : Matrix
{
$this->m = count($matrix);
$this->n = count($matrix[0] ?? 1);
$this->m = count($matrix);
$this->n = count($matrix[0] ?? 1);
$this->matrix = $matrix;
return $this;
@ -568,30 +568,30 @@ class Matrix implements \ArrayAccess, \Iterator
private function gaussElimination($b) : Matrix
{
$mDim = count($b);
$mDim = count($b);
$matrix = $this->matrix;
for ($col = 0; $col < $mDim; $col++) {
$j = $col;
$j = $col;
$max = $matrix[$j][$j];
for ($i = $col + 1; $i < $mDim; $i++) {
$temp = abs($matrix[$i][$col]);
if ($temp > $max) {
$j = $i;
$j = $i;
$max = $temp;
}
}
if ($col != $j) {
$temp = $matrix[$col];
$temp = $matrix[$col];
$matrix[$col] = $matrix[$j];
$matrix[$j] = $temp;
$matrix[$j] = $temp;
$temp = $b[$col];
$temp = $b[$col];
$b[$col] = $b[$j];
$b[$j] = $temp;
$b[$j] = $temp;
}
for ($i = $col + 1; $i < $mDim; $i++) {
@ -602,7 +602,7 @@ class Matrix implements \ArrayAccess, \Iterator
}
$matrix[$i][$col] = 0;
$b[$i] -= $temp * $b[$col];
$b[$i] -= $temp * $b[$col];
}
}
@ -752,4 +752,4 @@ class Matrix implements \ArrayAccess, \Iterator
$row = (int) ($offset / $this->m);
unset($this->matrix[$row][$offset - $row * $this->n]);
}
}
}

View File

@ -190,4 +190,4 @@ class QRDecomposition
return $matrix;
}
}
}

View File

@ -16,4 +16,4 @@ namespace phpOMS\Math\Matrix;
class SingularValueDecomposition
{
}
}

View File

@ -24,15 +24,4 @@ namespace phpOMS\Math\Matrix;
*/
class Vector extends Matrix
{
/**
* Constructor.
*
* @param int $m Columns
*
* @since 1.0.0
*/
public function __construct(int $m = 1)
{
parent::__construct($m);
}
}
}

View File

@ -63,7 +63,7 @@ class Integer
while ($value % $prime === 0) {
$factors[] = $prime;
$value /= $prime;
$value /= $prime;
}
}
@ -98,7 +98,7 @@ class Integer
}
$cycleSize *= 2;
$y = $x;
$y = $x;
}
return $factor;
@ -160,4 +160,4 @@ class Integer
return [(int) round($a - sqrt($b2)), (int) round($a + sqrt($b2))];
}
}
}

View File

@ -37,4 +37,4 @@ class Natural
{
return is_int($value) && $value >= 0;
}
}
}

View File

@ -35,4 +35,4 @@ abstract class NumberType extends Enum
/* public */ const N_RATIONAL = 32;
/* public */ const N_IRRATIONAL = 64;
/* public */ const N_COMPLEX = 128;
}
}

View File

@ -69,4 +69,4 @@ interface EdgeInterface
* @since 1.0.0
*/
public function setVertices(VerticeInterface $a, VerticeInterface $b);
}
}

View File

@ -16,4 +16,4 @@ namespace phpOMS\Math\Optimization\Graph;
class FloydWarshall
{
}
}

View File

@ -28,15 +28,15 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class BrowserType extends Enum
{
/* public */ const IE = 'msie'; /* Internet Explorer */
/* public */ const EDGE = 'edge'; /* Internet Explorer Edge 20+ */
/* public */ const FIREFOX = 'firefox'; /* Firefox */
/* public */ const SAFARI = 'safari'; /* Safari */
/* public */ const CHROME = 'chrome'; /* Chrome */
/* public */ const OPERA = 'opera'; /* Opera */
/* public */ const NETSCAPE = 'netscape'; /* Netscape */
/* public */ const MAXTHON = 'maxthon'; /* Maxthon */
/* public */ const IE = 'msie'; /* Internet Explorer */
/* public */ const EDGE = 'edge'; /* Internet Explorer Edge 20+ */
/* public */ const FIREFOX = 'firefox'; /* Firefox */
/* public */ const SAFARI = 'safari'; /* Safari */
/* public */ const CHROME = 'chrome'; /* Chrome */
/* public */ const OPERA = 'opera'; /* Opera */
/* public */ const NETSCAPE = 'netscape'; /* Netscape */
/* public */ const MAXTHON = 'maxthon'; /* Maxthon */
/* public */ const KONQUEROR = 'konqueror'; /* Konqueror */
/* public */ const HANDHELD = 'mobile'; /* Handheld Browser */
/* public */ const BLINK = 'blink'; /* Blink Browser */
/* public */ const HANDHELD = 'mobile'; /* Handheld Browser */
/* public */ const BLINK = 'blink'; /* Blink Browser */
}

View File

@ -118,9 +118,9 @@ class Request extends RequestAbstract
*/
private function initCurrentRequest() /* : void */
{
$this->uri = new Http(Http::getCurrent());
$this->data = $_GET ?? [];
$this->files = $_FILES ?? [];
$this->uri = new Http(Http::getCurrent());
$this->data = $_GET ?? [];
$this->files = $_FILES ?? [];
$this->header->getL11n()->setLanguage($this->loadRequestLanguage());
if (isset($_SERVER['CONTENT_TYPE'])) {
@ -227,7 +227,7 @@ class Request extends RequestAbstract
public function createRequestHashs(int $start = 0) /* : void */
{
$this->hash = [];
$pathArray = $this->uri->getPathElements();
$pathArray = $this->uri->getPathElements();
foreach ($pathArray as $key => $path) {
$paths = [];
@ -372,8 +372,7 @@ class Request extends RequestAbstract
throw new \OutOfRangeException('Value "' . $port . '" is out of range.');
}
return
(!empty($_SERVER['HTTPS'] ?? '') && ($_SERVER['HTTPS'] ?? '') !== 'off')
return (!empty($_SERVER['HTTPS'] ?? '') && ($_SERVER['HTTPS'] ?? '') !== 'off')
|| (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https')
|| (($_SERVER['HTTP_X_FORWARDED_SSL'] ?? '') === 'on')
|| ($_SERVER['SERVER_PORT'] ?? '') == $port;

View File

@ -76,10 +76,10 @@ class EmailAbstract
*/
public function __construct(string $host = 'localhost', int $port = 25, int $timeout = 30, bool $ssl = false)
{
$this->host = $host;
$this->port = $port;
$this->host = $host;
$this->port = $port;
$this->timeout = $timeout;
$this->ssl = $ssl;
$this->ssl = $ssl;
imap_timeout(IMAP_OPENTIMEOUT, $timeout);
imap_timeout(IMAP_READTIMEOUT, $timeout);
@ -488,7 +488,7 @@ class EmailAbstract
public function getMessageOverview(int $length = 0, int $start = 1) : array
{
if ($length === 0) {
$info = imap_check($this->con);
$info = imap_check($this->con);
$length = $info->Nmsgs;
}

View File

@ -26,8 +26,8 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class RequestSource extends Enum
{
/* public */ const WEB = 0; /* This is a http request */
/* public */ const CONSOLE = 1; /* Request is a console command */
/* public */ const SOCKET = 2; /* Request through socket connection */
/* public */ const UNDEFINED = 3; /* Request through socket connection */
/* public */ const WEB = 0; /* This is a http request */
/* public */ const CONSOLE = 1; /* Request is a console command */
/* public */ const SOCKET = 2; /* Request through socket connection */
/* public */ const UNDEFINED = 3;
}

View File

@ -26,7 +26,7 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class ResponseType extends Enum
{
/* public */ const HTTP = 0; /* HTTP */
/* public */ const SOCKET = 1; /* Socket */
/* public */ const HTTP = 0; /* HTTP */
/* public */ const SOCKET = 1; /* Socket */
/* public */ const CONSOLE = 2; /* Console */
}

View File

@ -185,7 +185,7 @@ class Head implements RenderableInterface
*/
public function render() : string
{
$head = '';
$head = '';
$head .= $this->meta->render();
$head .= $this->renderStyle();
$head .= $this->renderScript();

View File

@ -102,7 +102,7 @@ class ModuleManager
*/
public function __construct(ApplicationAbstract $app, string $modulePath = '')
{
$this->app = $app;
$this->app = $app;
$this->modulePath = $modulePath;
}
@ -435,7 +435,7 @@ class ModuleManager
*/
public function reInit(string $module) /* : void */
{
$info = $this->loadInfo($module);
$info = $this->loadInfo($module);
$class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer';
if (!Autoloader::exists($class)) {

View File

@ -25,6 +25,6 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class ModuleStatus extends Enum
{
/* public */ const ACTIVE = 1;
/* public */ const ACTIVE = 1;
/* public */ const INACTIVE = 2;
}

View File

@ -26,9 +26,9 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class RouteVerb extends Enum
{
/* public */ const GET = 1;
/* public */ const PUT = 2;
/* public */ const SET = 4;
/* public */ const GET = 1;
/* public */ const PUT = 2;
/* public */ const SET = 4;
/* public */ const DELETE = 8;
/* public */ const ANY = 16;
/* public */ const ANY = 16;
}

View File

@ -1,78 +1,78 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package phpOMS\Security
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types = 1);
namespace phpOMS\Security;
/**
* Php code security class.
*
* @package phpOMS\Security
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class PhpCode
{
public static $deprecatedFunctions = [
'apache_child_terminate', 'apache_setenv', 'define_syslog_variables', 'escapeshellarg', 'escapeshellcmd', 'eval',
'exec', 'fp', 'fput', 'ftp_connect', 'ftp_exec', 'ftp_get', 'ftp_login', 'ftp_nb_fput', 'ftp_put', 'ftp_raw',
'ftp_rawlist', 'highlight_file', 'ini_alter', 'ini_get_all', 'ini_restore', 'inject_code', 'mysql_pconnect',
'openlog', 'passthru', 'php_uname', 'phpAds_remoteInfo', 'phpAds_XmlRpc', 'phpAds_xmlrpcDecode',
'phpAds_xmlrpcEncode', 'popen', 'posix_getpwuid', 'posix_kill', 'posix_mkfifo', 'posix_setpgid', 'posix_setsid',
'posix_setuid', 'posix_uname', 'proc_close', 'proc_get_status',
];
private static function normalizeSource(string $source) : string
{
return str_replace(["\n", "\r\n", "\r", "\t"], ['', '', '', ' '], $source);
}
public static function hasUnicode(string $source) : bool
{
return (bool) preg_match('/[^\x20-\x7f]/', $source) || !mb_check_encoding($source, 'ASCII');
}
public static function isDisabled(array $functions) : bool
{
$disabled = ini_get('disable_functions');
$disabled = str_replace(' ', '', $disabled);
$disabled = explode(',', $disabled);
foreach ($functions as $function) {
if (!in_array($function, $disabled)) {
return false;
}
}
return true;
}
public static function hasDeprecatedFunction(string $source) : bool
{
$source = self::normalizeSource($source);
foreach (self::$deprecatedFunctions as $function) {
if (preg_match('/' . $function . '\s*\(' . '/', $source) === 1) {
return true;
}
}
return false;
}
public static function validateFileIntegrity(string $source, string $hash) : array
{
}
}
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package phpOMS\Security
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types = 1);
namespace phpOMS\Security;
/**
* Php code security class.
*
* @package phpOMS\Security
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class PhpCode
{
public static $deprecatedFunctions = [
'apache_child_terminate', 'apache_setenv', 'define_syslog_variables', 'escapeshellarg', 'escapeshellcmd', 'eval',
'exec', 'fp', 'fput', 'ftp_connect', 'ftp_exec', 'ftp_get', 'ftp_login', 'ftp_nb_fput', 'ftp_put', 'ftp_raw',
'ftp_rawlist', 'highlight_file', 'ini_alter', 'ini_get_all', 'ini_restore', 'inject_code', 'mysql_pconnect',
'openlog', 'passthru', 'php_uname', 'phpAds_remoteInfo', 'phpAds_XmlRpc', 'phpAds_xmlrpcDecode',
'phpAds_xmlrpcEncode', 'popen', 'posix_getpwuid', 'posix_kill', 'posix_mkfifo', 'posix_setpgid', 'posix_setsid',
'posix_setuid', 'posix_uname', 'proc_close', 'proc_get_status',
];
private static function normalizeSource(string $source) : string
{
return str_replace(["\n", "\r\n", "\r", "\t"], ['', '', '', ' '], $source);
}
public static function hasUnicode(string $source) : bool
{
return (bool) preg_match('/[^\x20-\x7f]/', $source) || !mb_check_encoding($source, 'ASCII');
}
public static function isDisabled(array $functions) : bool
{
$disabled = ini_get('disable_functions');
$disabled = str_replace(' ', '', $disabled);
$disabled = explode(',', $disabled);
foreach ($functions as $function) {
if (!in_array($function, $disabled)) {
return false;
}
}
return true;
}
public static function hasDeprecatedFunction(string $source) : bool
{
$source = self::normalizeSource($source);
foreach (self::$deprecatedFunctions as $function) {
if (preg_match('/' . $function . '\s*\(' . '/', $source) === 1) {
return true;
}
}
return false;
}
public static function validateFileIntegrity(string $source, string $hash) : array
{
}
}

View File

@ -26,15 +26,15 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class PacketType extends Enum
{
/* public */ const CONNECT = 0; /* Client connection (server/sender) */
/* public */ const CONNECT = 0; /* Client connection (server/sender) */
/* public */ const DISCONNECT = 1; /* Client disconnection (server/sender) */
/* public */ const KICK = 2; /* Kick (server/client/sender) */
/* public */ const PING = 3; /* Ping (server/sender) */
/* public */ const HELP = 4; /* Help (server/sender) */
/* public */ const RESTART = 5; /* Restart server (server/all clients/client) */
/* public */ const MSG = 6; /* Message (server/sender/client/all clients?) */
/* public */ const LOGIN = 7; /* Login (server/sender) */
/* public */ const LOGOUT = 8; /* Logout (server/sender) */
/* public */ const ACCMODIFY = 9; /* Account modification (server/sender (admin)/user) */
/* public */ const MODULE = 999999999; /* Module packet ??? */
/* public */ const KICK = 2; /* Kick (server/client/sender) */
/* public */ const PING = 3; /* Ping (server/sender) */
/* public */ const HELP = 4; /* Help (server/sender) */
/* public */ const RESTART = 5; /* Restart server (server/all clients/client) */
/* public */ const MSG = 6; /* Message (server/sender/client/all clients?) */
/* public */ const LOGIN = 7; /* Login (server/sender) */
/* public */ const LOGOUT = 8; /* Logout (server/sender) */
/* public */ const CMD = 9; /* Other command */
/* public */ const MODULE = 999999999; /* Module packet ??? */
}

View File

@ -24,11 +24,11 @@ namespace phpOMS\Stdlib\Base;
*/
abstract class AddressType extends Enum
{
/* public */ const HOME = 1;
/* public */ const HOME = 1;
/* public */ const BUSINESS = 2;
/* public */ const SHIPPING = 3;
/* public */ const BILLING = 4;
/* public */ const WORK = 5;
/* public */ const BILLING = 4;
/* public */ const WORK = 5;
/* public */ const CONTRACT = 6;
/* public */ const OTHER = 7;
/* public */ const OTHER = 7;
}

View File

@ -284,4 +284,4 @@ class Iban implements \Serializable
{
$this->parse($serialized);
}
}
}

View File

@ -24,8 +24,8 @@ namespace phpOMS\Stdlib\Base;
*/
abstract class PhoneType extends Enum
{
/* public */ const HOME = 1;
/* public */ const HOME = 1;
/* public */ const BUSINESS = 2;
/* public */ const MOBILE = 3;
/* public */ const WORK = 4;
/* public */ const MOBILE = 3;
/* public */ const WORK = 4;
}

View File

@ -44,14 +44,6 @@ class SmartDateTime extends \DateTime
*/
/* public */ const TIMEZONE = 'UTC';
/**
* {@inheritdoc}
*/
public function __construct($time = 'now', $timezone = null)
{
parent::__construct($time, $timezone);
}
/**
* Create object from DateTime
*
@ -264,7 +256,7 @@ class SmartDateTime extends \DateTime
$diffToWeekStart = $diffToWeekStart === 0 ? 7 : $diffToWeekStart;
// get days of previous month
$previousMonth = $this->createModify(0, -1);
$previousMonth = $this->createModify(0, -1);
$daysPreviousMonth = $previousMonth->getDaysOfMonth();
// add difference to $weekStartsWith counting backwards from days of previous month (reorder so that lowest value first)
@ -280,7 +272,8 @@ class SmartDateTime extends \DateTime
// add remaining days to next month (7*6 - difference+count of current month)
$remainingDays = 42 - $diffToWeekStart - $daysMonth;
$nextMonth = $this->createModify(0, 1);
$nextMonth = $this->createModify(0, 1);
for ($i = 1; $i <= $remainingDays; $i++) {
$days[] = new \DateTime($nextMonth->format('Y') . '-' . $nextMonth->format('m') . '-' . ($i));
}

View File

@ -32,8 +32,8 @@ class Edge
public function __construct(Node $node1, Node $node2, bool $directed = false)
{
$this->node1 = $node1;
$this->node2 = $node2;
$this->node1 = $node1;
$this->node2 = $node2;
$this->directed = $directed;
}
@ -46,4 +46,4 @@ class Edge
{
return $this->directed;
}
}
}

View File

@ -461,4 +461,4 @@ class Graph
// todo: implement
return true;
}
}
}

View File

@ -26,4 +26,4 @@ namespace phpOMS\Stdlib\Graph;
*/
class Node
{
}
}

View File

@ -26,6 +26,6 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class KeyType extends Enum
{
/* public */ const SINGLE = 0;
/* public */ const SINGLE = 0;
/* public */ const MULTIPLE = 1;
}

View File

@ -298,7 +298,7 @@ class MultiMap implements \Countable
return $this->remove(implode(':', $key));
}
$keys = Permutation::permut($key);
$keys = Permutation::permut($key);
$found = true;
foreach ($keys as $key => $value) {

View File

@ -26,6 +26,6 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class OrderType extends Enum
{
/* public */ const LOOSE = 0;
/* public */ const LOOSE = 0;
/* public */ const STRICT = 1;
}

View File

@ -26,10 +26,10 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class PriorityMode extends Enum
{
/* public */ const FIFO = 1;
/* public */ const LIFO = 2;
/* public */ const FIFO = 1;
/* public */ const LIFO = 2;
/* public */ const EARLIEST_DEADLINE = 4;
/* public */ const SHORTEST_JOB = 8;
/* public */ const HIGHEST = 16;
/* public */ const LOWEST = 32;
/* public */ const SHORTEST_JOB = 8;
/* public */ const HIGHEST = 16;
/* public */ const LOWEST = 32;
}

View File

@ -32,4 +32,4 @@ abstract class ContentPutMode extends Enum
/* public */ const PREPEND = 2;
/* public */ const REPLACE = 4;
/* public */ const CREATE = 8;
}
}

View File

@ -38,4 +38,4 @@ abstract class ExtensionType extends Enum
/* public */ const ARCHIVE = 128;
/* public */ const PRESENTATION = 256;
/* public */ const IMAGE = 512;
}
}

View File

@ -95,7 +95,7 @@ class FileUtils
if (!file_exists($origPath)) {
$startsWithSlash = strpos($origPath, '/') === 0 ? '/' : '';
$path = [];
$path = [];
$parts = explode('/', $origPath);
foreach ($parts as $part) {
@ -117,4 +117,4 @@ class FileUtils
return realpath($origPath);
}
}
}

View File

@ -214,8 +214,8 @@ class Directory extends FileAbstract implements DirectoryInterface
public function addNode($file) : bool
{
$this->count += $file->getCount();
$this->size += $file->getSize();
$this->count += $file->getCount();
$this->size += $file->getSize();
$this->nodes[$file->getName()] = $file;
return $file->createNode();
@ -338,4 +338,4 @@ class Directory extends FileAbstract implements DirectoryInterface
{
// TODO: Implement offsetGet() method.
}
}
}

View File

@ -83,7 +83,7 @@ class File extends FileAbstract implements FileInterface
public static function put(string $path, string $content, int $mode = ContentPutMode::REPLACE | ContentPutMode::CREATE) : bool
{
$http = new Http($path);
$con = self::ftpConnect($http);
$con = self::ftpConnect($http);
if (ftp_pwd($con) !== $http->getPath()) {
return false;
@ -561,4 +561,4 @@ class File extends FileAbstract implements FileInterface
{
// TODO: Implement getExtension() method.
}
}
}

View File

@ -32,7 +32,8 @@ class FtpStorage extends StorageAbstract
{
private static $instance = null;
public function __construct() {
public function __construct()
{
}
@ -141,4 +142,4 @@ class FtpStorage extends StorageAbstract
return File::extension($path);
}
}
}

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\System\File\Local;
use phpOMS\System\File\StorageAbstract;
use phpOMS\System\File\PathException;
@ -166,4 +167,4 @@ class LocalStorage extends StorageAbstract
return File::extension($path);
}
}
}

View File

@ -278,9 +278,9 @@ abstract class C128Abstract
$checksum = static::$CHECKSUM;
for ($pos = 1; $pos <= $length; $pos++) {
$activeKey = substr($this->content, ($pos - 1), 1);
$activeKey = substr($this->content, ($pos - 1), 1);
$codeString .= static::$CODEARRAY[$activeKey];
$checksum += $values[$activeKey] * $pos;
$checksum += $values[$activeKey] * $pos;
}
$codeString .= static::$CODEARRAY[$keys[($checksum - (intval($checksum / 103) * 103))]];
@ -348,7 +348,9 @@ abstract class C128Abstract
private function calculateCodeLength(string $codeString) : int
{
$codeLength = 0;
for ($i = 1; $i <= strlen($codeString); $i++) {
$length = strlen($codeString);
for ($i = 1; $i <= $length; $i++) {
$codeLength = $codeLength + (int) (substr($codeString, ($i - 1), 1));
}

View File

@ -61,23 +61,6 @@ class C39 extends C128Abstract
*/
protected static $CODE_END = '121121211';
/**
* Constructor
*
* @param string $content Content to encrypt
* @param int $width Barcode width
* @param int $height Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo : add mirror parameter
*
* @since 1.0.0
*/
public function __construct(string $content = '', int $width = 100, int $height = 20, int $orientation = OrientationType::HORIZONTAL)
{
parent::__construct($content, $width, $height, $orientation);
}
/**
* Set content to encrypt
*

View File

@ -238,7 +238,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
public function testDiscountedPaybackPeriod()
{
$O1 = 5000;
$r = 0.05;
$r = 0.05;
$CF = 1000;
self::assertTrue(abs(5.896 - FinanceFormulas::getDiscountedPaybackPeriod($CF, $O1, $r)) < 0.01);

View File

@ -25,11 +25,11 @@ class FibunacciTest extends \PHPUnit\Framework\TestCase
self::assertFalse(Fibunacci::isFibunacci(6));
self::assertFalse(Fibunacci::isFibunacci(87));
self::assertEquals(1, Fibunacci::fibunacci(1));
self::assertEquals(1, Fibunacci::fib(1));
self::assertTrue(Fibunacci::isFibunacci(Fibunacci::binet(3)));
self::assertTrue(Fibunacci::isFibunacci(Fibunacci::binet(6)));
self::assertEquals(Fibunacci::binet(6), Fibunacci::fibunacci(6));
self::assertEquals(Fibunacci::binet(8), Fibunacci::fibunacci(8));
self::assertEquals(Fibunacci::binet(6), Fibunacci::fib(6));
self::assertEquals(Fibunacci::binet(8), Fibunacci::fib(8));
}
}

View File

@ -19,7 +19,7 @@ class LZWTest extends \PHPUnit\Framework\TestCase
{
public function testLZW()
{
$expected = 'This is a test';
$expected = 'This is a test';
$compression = new LZW();
self::assertEquals($expected, $compression->decompress($compression->compress($expected)));
}

View File

@ -21,4 +21,4 @@ class SchedulerAbstractTest extends \PHPUnit\Framework\TestCase
{
self::assertEquals('', SchedulerAbstract::getBin());
}
}
}