mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 01:38:41 +00:00
Fixes
This commit is contained in:
parent
b286fa4de1
commit
905d04957d
|
|
@ -39,7 +39,7 @@ final class Loan
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getPaymentsOnBalloonLoan(float $PV, float $r, int $n, float $balloon = 0) : float
|
||||
public static function getPaymentsOnBalloonLoan(float $PV, float $r, int $n, float $balloon = 0.0) : float
|
||||
{
|
||||
return ($PV - $balloon / \pow(1 + $r, $n)) * $r / (1 - \pow(1 + $r, -$n));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1157,4 +1157,4 @@ final class JsonBuilder
|
|||
{
|
||||
return $this->grammar->compileQuery($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ final class Money implements \Serializable
|
|||
*/
|
||||
public function add($value) : self
|
||||
{
|
||||
if (\is_string($value) || is_float($value)) {
|
||||
if (\is_string($value) || \is_float($value)) {
|
||||
$this->value += self::toInt((string) $value, $this->thousands, $this->decimal);
|
||||
} elseif (\is_int($value)) {
|
||||
$this->value += $value;
|
||||
|
|
@ -251,7 +251,7 @@ final class Money implements \Serializable
|
|||
*/
|
||||
public function sub($value) : self
|
||||
{
|
||||
if (\is_string($value) || is_float($value)) {
|
||||
if (\is_string($value) || \is_float($value)) {
|
||||
$this->value -= self::toInt((string) $value, $this->thousands, $this->decimal);
|
||||
} elseif (\is_int($value)) {
|
||||
$this->value -= $value;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,9 @@ final class Response extends ResponseAbstract implements RenderableInterface
|
|||
{
|
||||
$types = $this->header->get('Content-Type');
|
||||
if (\stripos($types[0], MimeType::M_HTML) !== false) {
|
||||
return \trim(\preg_replace('/(?s)<pre[^<]*>.*?<\/pre>(*SKIP)(*F)|(\s{2,}|\n|\t)/', ' ', $render));
|
||||
$clean = \preg_replace('/(?s)<pre[^<]*>.*?<\/pre>(*SKIP)(*F)|(\s{2,}|\n|\t)/', ' ', $render);
|
||||
|
||||
return \trim($clean ?? '');
|
||||
}
|
||||
|
||||
return $render;
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ final class ModuleFactory
|
|||
self::registerRequesting($obj);
|
||||
self::registerProvided($obj);
|
||||
} catch (\Throwable $e) {
|
||||
self::$loaded[$module] = new NullModule($app);
|
||||
self::$loaded[$module] = new NullModule();
|
||||
}
|
||||
} else {
|
||||
self::$loaded[$module] = new NullModule($app);
|
||||
self::$loaded[$module] = new NullModule();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function insert($data, $priority = 1) : int
|
||||
public function insert($data, float $priority = 1.0) : int
|
||||
{
|
||||
do {
|
||||
$key = \mt_rand();
|
||||
|
|
@ -104,9 +104,11 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws InvalidEnumValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function getInsertPosition($priority) : int
|
||||
private function getInsertPosition(float $priority) : int
|
||||
{
|
||||
switch($this->type) {
|
||||
case PriorityMode::FIFO:
|
||||
|
|
@ -131,7 +133,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function getInsertFIFO($priority) : int
|
||||
private function getInsertFIFO(float $priority) : int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -145,7 +147,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function getInsertLIFO($priority) : int
|
||||
private function getInsertLIFO(float $priority) : int
|
||||
{
|
||||
return \count($this->queue);
|
||||
}
|
||||
|
|
@ -159,7 +161,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function getInsertHighest($priority) : int
|
||||
private function getInsertHighest(float $priority) : int
|
||||
{
|
||||
$pos = 0;
|
||||
foreach ($this->queue as $ele) {
|
||||
|
|
@ -182,7 +184,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function getInsertLowest($priority) : int
|
||||
private function getInsertLowest(float $priority) : int
|
||||
{
|
||||
$pos = 0;
|
||||
foreach ($this->queue as $ele) {
|
||||
|
|
@ -205,7 +207,7 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function increaseAll($increase = 1) : void
|
||||
public function increaseAll(float $increase = 1.0) : void
|
||||
{
|
||||
foreach ($this->queue as $key => &$ele) {
|
||||
$ele['priority'] += $increase;
|
||||
|
|
@ -248,13 +250,13 @@ class PriorityQueue implements \Countable, \Serializable
|
|||
* Set element priority.
|
||||
*
|
||||
* @param mixed $id Element ID
|
||||
* @param mixed $priority Element priority
|
||||
* @param float $priority Element priority
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setPriority($id, $priority) : void
|
||||
public function setPriority($id, float $priority) : void
|
||||
{
|
||||
if ($this->type === PriorityMode::FIFO || $this->type === PriorityMode::LIFO) {
|
||||
$this->queue[$id]['priority'] = $priority;
|
||||
|
|
|
|||
|
|
@ -130,12 +130,14 @@ final class FileUtils
|
|||
*/
|
||||
public static function changeFileEncoding(string $file, string $encoding) : void
|
||||
{
|
||||
$content = \file_get_contents($file);
|
||||
$detected = \mb_detect_encoding($content);
|
||||
$content = \file_get_contents($file);
|
||||
|
||||
if ($content !== false) {
|
||||
\file_put_contents($file, \mb_convert_encoding($content, $encoding, $detected === false ? \mb_list_encodings() : $detected));
|
||||
if ($content === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$detected = \mb_detect_encoding($content);
|
||||
\file_put_contents($file, \mb_convert_encoding($content, $encoding, $detected === false ? \mb_list_encodings() : $detected));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ class Directory extends FileAbstract implements FtpContainerInterface, Directory
|
|||
|
||||
if ($filename['type'] === 'dir' && $recursive) {
|
||||
$countSize += self::size($con, $key, $recursive);
|
||||
} elseif ($filename['type'] === 'file' ) {
|
||||
} elseif ($filename['type'] === 'file') {
|
||||
$countSize += \ftp_size($con, $key);
|
||||
}
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ class Directory extends FileAbstract implements FtpContainerInterface, Directory
|
|||
$e['month'],
|
||||
$e['day'],
|
||||
$e['time']
|
||||
) = $chunks;
|
||||
) = $chunks;
|
||||
|
||||
$e['permission'] = FileUtils::permissionToOctal(\substr($e['permission'], 1));
|
||||
$e['type'] = $chunks[0]{0} === 'd' ? 'dir' : 'file';
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class File extends FileAbstract implements FileInterface
|
|||
*/
|
||||
public static function put($con, string $path, string $content, int $mode = ContentPutMode::REPLACE | ContentPutMode::CREATE) : bool
|
||||
{
|
||||
$exists = self::exists($con, $path);
|
||||
$exists = self::exists($con, $path);
|
||||
|
||||
if ((ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|
||||
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ final class Directory extends FileAbstract implements LocalContainerInterface, D
|
|||
*/
|
||||
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;:\[\]\(\]\/]/') : string
|
||||
{
|
||||
return \preg_replace($invalid, $replace, $path);
|
||||
return \preg_replace($invalid, $replace, $path) ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ final class File extends FileAbstract implements LocalContainerInterface, FileIn
|
|||
*/
|
||||
public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;\/\[\]\(\]]/') : string
|
||||
{
|
||||
return \preg_replace($invalid, $replace, $path);
|
||||
return \preg_replace($invalid, $replace, $path) ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -163,6 +163,10 @@ final class Http implements UriInterface
|
|||
$this->uri = $uri;
|
||||
$url = \parse_url($this->uri);
|
||||
|
||||
if ($url === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->scheme = $url['scheme'] ?? '';
|
||||
$this->host = $url['host'] ?? '';
|
||||
$this->port = $url['port'] ?? 80;
|
||||
|
|
|
|||
|
|
@ -241,6 +241,6 @@ final class UriFactory
|
|||
return $toMatch[$match] ?? self::$uri[$match] ?? $match;
|
||||
}, $uri);
|
||||
|
||||
return self::unique($parsed);
|
||||
return self::unique($parsed ?? '');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,21 +62,6 @@ class C25 extends C128Abstract
|
|||
*/
|
||||
protected static $CODE_END = '311';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $content Content to encrypt
|
||||
* @param int $width Barcode width
|
||||
* @param int $height Barcode height
|
||||
* @param int $orientation Orientation of the barcode
|
||||
*
|
||||
* @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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Numeric
|
|||
*/
|
||||
public static function convertBase(string $numberInput, string $fromBaseInput, string $toBaseInput) : string
|
||||
{
|
||||
if ($fromBaseInput == $toBaseInput) {
|
||||
if ($fromBaseInput === $toBaseInput) {
|
||||
return $numberInput;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,10 +201,10 @@ class Repository
|
|||
$status = \proc_close($resource);
|
||||
|
||||
if ($status == -1) {
|
||||
throw new \Exception($stderr);
|
||||
throw new \Exception((string) $stderr);
|
||||
}
|
||||
|
||||
return $this->parseLines(\trim($stdout));
|
||||
return $this->parseLines(\trim($stdout === false ? '' : $stdout));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ final class Permutation
|
|||
*/
|
||||
public static function isPalindrome(string $a, string $filter = 'a-zA-Z0-9') : bool
|
||||
{
|
||||
$a = \strtolower(\preg_replace('/[^' . $filter . ']/', '', $a));
|
||||
$a = \strtolower(\preg_replace('/[^' . $filter . ']/', '', $a) ?? '');
|
||||
|
||||
return $a === \strrev($a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ final class StringUtils
|
|||
} else {
|
||||
$charlist = \str_replace('/', '\/', \preg_quote($charlist));
|
||||
|
||||
return \preg_replace('/(^[' . $charlist . ']+)|([ ' . $charlist . ']+$)/us', '', $string);
|
||||
return \preg_replace('/(^[' . $charlist . ']+)|([ ' . $charlist . ']+$)/us', '', $string) ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ final class StringUtils
|
|||
} else {
|
||||
$charlist = \str_replace('/', '\/', \preg_quote($charlist));
|
||||
|
||||
return \preg_replace('/([' . $charlist . ']+$)/us', '', $string);
|
||||
return \preg_replace('/([' . $charlist . ']+$)/us', '', $string) ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ final class StringUtils
|
|||
} else {
|
||||
$charlist = \str_replace('/', '\/', \preg_quote($charlist));
|
||||
|
||||
return \preg_replace('/(^[' . $charlist . ']+)/us', '', $string);
|
||||
return \preg_replace('/(^[' . $charlist . ']+)/us', '', $string) ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -472,7 +472,7 @@ final class StringUtils
|
|||
}
|
||||
|
||||
switch ($mc) {
|
||||
case -1:
|
||||
case -1:
|
||||
$result .= '<del>';
|
||||
break;
|
||||
case 1:
|
||||
|
|
|
|||
|
|
@ -164,10 +164,10 @@ abstract class SchedulerAbstract
|
|||
$status = \proc_close($resource);
|
||||
|
||||
if ($status === -1) {
|
||||
throw new \Exception($stderr);
|
||||
throw new \Exception((string) $stderr);
|
||||
}
|
||||
|
||||
return \trim($stdout);
|
||||
return $stdout === false ? '' : \trim($stdout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,11 @@ final class CreditCard extends ValidatorAbstract
|
|||
*/
|
||||
public static function isValid($value, array $constraints = null) : bool
|
||||
{
|
||||
$value = preg_replace('/\D/', '', $value);
|
||||
if (!\is_string($value)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
$value = \preg_replace('/\D/', '', $value) ?? '';
|
||||
|
||||
// Set the string length and parity
|
||||
$numberLength = \strlen($value);
|
||||
|
|
|
|||
31
Views/TableView.php
Normal file
31
Views/TableView.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package phpOMS\Views
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Views;
|
||||
|
||||
/**
|
||||
* Basic table view which can be used as basis for specific implementations.
|
||||
*
|
||||
* @package phpOMS\Views
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TableView extends View
|
||||
{
|
||||
public function renderHeaderColumn(string $inner, bool $sortable = true, bool $filterable = true)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user