automated rector fixes

This commit is contained in:
Dennis Eichhorn 2023-09-21 02:02:27 +00:00
parent 7bf216708b
commit af38754915
34 changed files with 114 additions and 192 deletions

View File

@ -114,7 +114,9 @@ final class Weighted
return $jobs;
}
\usort($jobs, [self::class, 'sortByEnd']);
\usort($jobs, function (\phpOMS\Algorithm\JobScheduling\JobInterface $j1, \phpOMS\Algorithm\JobScheduling\JobInterface $j2) : int {
return self::sortByEnd($j1, $j2);
});
$valueTable = [$jobs[0]->getValue()];

View File

@ -120,7 +120,7 @@ final class Glicko2
$tau = $this->tau;
// Step 0:
$rdOld = $rdOld / self::Q;
$rdOld /= self::Q;
$elo = ($elo - $this->DEFAULT_ELO) / self::Q;
foreach ($oElo as $idx => $value) {

View File

@ -207,8 +207,7 @@ final class MemoryCF
}
\asort($matches);
$matches = \array_reverse($matches, true);
return $matches;
return \array_reverse($matches, true);
}
}

View File

@ -193,7 +193,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
*/
public function isInitialized() : bool
{
return isset($this->con) && !($this->con instanceof NullPDO);
return $this->con !== null && !($this->con instanceof NullPDO);
}
/**
@ -207,7 +207,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
*/
public function __get(string $name) : mixed
{
if ($name === 'con' && !isset($this->con)) {
if ($name === 'con' && $this->con === null) {
$this->connect($this->dbdata);
}

View File

@ -171,11 +171,7 @@ final class DeleteMapper extends DataMapperAbstract
$objIds = [];
$refProp = $refClass->getProperty($member);
if (!$refProp->isPublic()) {
$values = $refProp->getValue($obj);
} else {
$values = $obj->{$member};
}
$values = $refProp->isPublic() ? $obj->{$member} : $refProp->getValue($obj);
if (!\is_array($values)) {
// conditionals

View File

@ -263,7 +263,7 @@ final class ReadMapper extends DataMapperAbstract
return [];
}
return !\is_array($result) ? [$result] : $result;
return \is_array($result) ? $result : [$result];
}
/**
@ -315,10 +315,8 @@ final class ReadMapper extends DataMapperAbstract
foreach ($columns as $key => $values) {
if (\is_string($values)) {
$query->selectAs($key, $values);
} else {
if (($values['writeonly'] ?? false) === false || isset($this->with[$values['internal']])) {
$query->selectAs($this->mapper::TABLE . '_d' . $this->depth . '.' . $key, $key . '_d' . $this->depth);
}
} elseif (($values['writeonly'] ?? false) === false || isset($this->with[$values['internal']])) {
$query->selectAs($this->mapper::TABLE . '_d' . $this->depth . '.' . $key, $key . '_d' . $this->depth);
}
}

View File

@ -118,8 +118,8 @@ final class UpdateMapper extends DataMapperAbstract
$propertyName = \stripos($column['internal'], '/') !== false ? \explode('/', $column['internal'])[0] : $column['internal'];
if (isset($this->mapper::HAS_MANY[$propertyName])
|| $column['internal'] === $this->mapper::PRIMARYFIELD
|| (($column['readonly'] ?? false) === true && !isset($this->with[$propertyName]))
|| (($column['writeonly'] ?? false) === true && !isset($this->with[$propertyName]))
|| (($column['readonly'] ?? false) && !isset($this->with[$propertyName]))
|| (($column['writeonly'] ?? false) && !isset($this->with[$propertyName]))
) {
continue;
}
@ -127,11 +127,7 @@ final class UpdateMapper extends DataMapperAbstract
$refClass = $refClass ?? new \ReflectionClass($obj);
$property = $refClass->getProperty($propertyName);
if (!($property->isPublic())) {
$tValue = $property->getValue($obj);
} else {
$tValue = $obj->{$propertyName};
}
$tValue = $property->isPublic() ? $obj->{$propertyName} : $property->getValue($obj);
if (isset($this->mapper::OWNS_ONE[$propertyName])) {
$id = \is_object($tValue) ? $this->updateOwnsOne($propertyName, $tValue) : $tValue;
@ -246,11 +242,7 @@ final class UpdateMapper extends DataMapperAbstract
$property = $refClass->getProperty($propertyName);
if (!($isPublic = $property->isPublic())) {
$values = $property->getValue($obj);
} else {
$values = $obj->{$propertyName};
}
$values = ($isPublic = $property->isPublic()) ? $obj->{$propertyName} : $property->getValue($obj);
if (!\is_array($values) || empty($values)) {
continue;

View File

@ -230,11 +230,7 @@ final class WriteMapper extends DataMapperAbstract
$refClass = new \ReflectionClass($obj);
$refProp = $refClass->getProperty($this->mapper::BELONGS_TO[$propertyName]['by']);
if (!$refProp->isPublic()) {
$obj = $refProp->getValue($obj);
} else {
$obj = $obj->{$this->mapper::BELONGS_TO[$propertyName]['by']};
}
$obj = $refProp->isPublic() ? $obj->{$this->mapper::BELONGS_TO[$propertyName]['by']} : $refProp->getValue($obj);
}
/** @var class-string<DataMapperFactory> $mapper */
@ -266,11 +262,7 @@ final class WriteMapper extends DataMapperAbstract
}
$property = $refClass->getProperty($propertyName);
if (!$property->isPublic()) {
$values = $property->getValue($obj);
} else {
$values = $obj->{$propertyName};
}
$values = $property->isPublic() ? $obj->{$propertyName} : $property->getValue($obj);
/** @var class-string<DataMapperFactory> $mapper */
$mapper = $this->mapper::HAS_MANY[$propertyName]['mapper'];
@ -301,7 +293,7 @@ final class WriteMapper extends DataMapperAbstract
}
$objsIds = [];
$relReflectionClass = !empty($values) ? new \ReflectionClass(\reset($values)) : null;
$relReflectionClass = empty($values) ? null : new \ReflectionClass(\reset($values));
foreach ($values as $key => $value) {
if (!\is_object($value)) {
@ -328,19 +320,16 @@ final class WriteMapper extends DataMapperAbstract
// todo maybe consider to just set the column type to object, and then check for that (might be faster)
if (isset($mapper::BELONGS_TO[$internalName])
|| isset($mapper::OWNS_ONE[$internalName])
) {
|| isset($mapper::OWNS_ONE[$internalName])) {
if (!$isRelPublic) {
$relProperty->setValue($value, $this->mapper::createNullModel($objId));
} else {
$value->{$internalName} = $this->mapper::createNullModel($objId);
}
} elseif (!$isRelPublic) {
$relProperty->setValue($value, $objId);
} else {
if (!$isRelPublic) {
$relProperty->setValue($value, $objId);
} else {
$value->{$internalName} = $objId;
}
$value->{$internalName} = $objId;
}
if (!$isRelPublic) {

View File

@ -83,11 +83,11 @@ class Grammar extends GrammarAbstract
}
if (!empty($query->unions)) {
$sql[] = $this->compileUnions($query, $query->unions);
$sql[] = $this->compileUnions();
}
if (!empty($query->lock)) {
$sql[] = $this->compileLock($query, $query->lock);
$sql[] = $this->compileLock();
}
break;
@ -399,9 +399,7 @@ class Grammar extends GrammarAbstract
$expression .= $this->compileOn($query, $query->ons[$join['alias'] ?? $table]) . ' ';
}
$expression = \rtrim($expression, ', ');
return $expression;
return \rtrim($expression, ', ');
}
/**

View File

@ -49,10 +49,7 @@ final class JWT
$payload64 = Base64Url::encode(\json_encode($payload));
$algorithm = '';
switch (\strtolower($header['alg'])) {
default:
$algorithm = 'sha256';
}
$algorithm = 'sha256';
return \hash_hmac($algorithm, $header64 . '.' . $payload64, $secret, false);
}

View File

@ -848,11 +848,7 @@ class Matrix implements \ArrayAccess, \Iterator
for ($i = 0; $i < $this->m; ++$i) {
$row = [];
for ($j = 0; $j < $this->m; ++$j) {
if ($i === $j) {
$row[] = \pow($this->matrix[$i][$j], $exponent);
} else {
$row[] = 0;
}
$row[] = $i === $j ? \pow($this->matrix[$i][$j], $exponent) : 0;
}
$matrix[] = $row;

View File

@ -153,10 +153,7 @@ final class CliHeader extends HeaderAbstract
*/
public function generate(int $code) : void
{
switch ($code) {
default:
$this->generate500();
}
$this->generate500();
}
public function getRequestTime() : int

View File

@ -160,7 +160,7 @@ final class HttpHeader extends HeaderAbstract
return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '';
}
public function getBrowserName() {
public function getBrowserName(): string {
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (\strpos($userAgent, 'Opera') !== false || \strpos($userAgent, 'OPR/') !== false) {

View File

@ -80,9 +80,14 @@ final class FormElementGenerator
$element .= ($json['subtype'] === 'checkbox' || $json['subtype'] === 'radio') && $json['default']['checked'] ? ' checked' : '';
$element .= '>';
$element .= $json['subtype'] === 'checkbox' || $json['subtype'] === 'radio' ? '<label for="' . $json['attributes']['id'] . '">' . ($lang[$json['default']['content']] ?? $json['default']['content']) . '</label>' : '';
return $element;
return $element
. ($json['subtype'] === 'checkbox' || $json['subtype'] === 'radio'
? '<label for="' . $json['attributes']['id'] . '">'
. ($lang[$json['default']['content']] ?? $json['default']['content'])
. '</label>'
: ''
);
}
/**
@ -108,12 +113,12 @@ final class FormElementGenerator
$value ??= $json['default']['value'];
foreach ($json['options'] as $val => $text) {
$element .= '<option value="' . $val . '"' . (isset($json['default']) && $val === $value ? ' selected' : '') . '>' . ($lang[$text] ?? $text) . '</option>';
$element .= '<option value="' . $val . '"' . (isset($json['default']) && $val === $value ? ' selected' : '') . '>'
. ($lang[$text] ?? $text)
. '</option>';
}
$element .= '</select>';
return $element;
return $element . '</select>';
}
/**
@ -137,9 +142,8 @@ final class FormElementGenerator
$element .= '>';
$element .= isset($json['default']) ? $value : '';
$element .= '</textarea>';
return $element;
return $element . '</textarea>';
}
/**
@ -161,8 +165,7 @@ final class FormElementGenerator
$element .= '>';
$element .= $lang[$json['default']['value']] ?? $json['default']['value'];
$element .= '</label>';
return $element;
return $element . '</label>';
}
}

View File

@ -81,7 +81,7 @@ abstract class SocketAbstract implements SocketInterface
*/
public function close() : void
{
if (isset($this->sock)) {
if ($this->sock !== null) {
\socket_shutdown($this->sock, 2);
\socket_close($this->sock);
$this->sock = null;

View File

@ -120,11 +120,7 @@ class SmartDateTime extends \DateTime
$dayMonthNew = \cal_days_in_month($calendar, $monthNew, $yearNew);
$dayOld = (int) $this->format('d');
if ($dayOld > $dayMonthNew || $dayOld === $dayMonthOld) {
$dayNew = $dayMonthNew;
} else {
$dayNew = $dayOld;
}
$dayNew = $dayOld > $dayMonthNew || $dayOld === $dayMonthOld ? $dayMonthNew : $dayOld;
$this->setDate($yearNew, $monthNew, $dayNew);

View File

@ -269,7 +269,7 @@ class Graph
$edges = $this->nodes[$id]->getEdges();
foreach ($edges as $edge) {
$neighbor = !$edge->node1->isEqual($node) ? $edge->node1 : $edge->node2;
$neighbor = $edge->node1->isEqual($node) ? $edge->node2 : $edge->node1;
if (!isset($visited[$neighbor->getId()]) || !$visited[$neighbor->getId()]) {
$parent[$neighbor->getId()] = $node;
@ -583,7 +583,7 @@ class Graph
while (!empty($stack)) {
$cNode = \array_pop($stack);
if (isset($visited[$cNode->getId()]) && $visited[$cNode->getId()] === true) {
if (isset($visited[$cNode->getId()]) && $visited[$cNode->getId()]) {
continue;
}
@ -592,7 +592,7 @@ class Graph
$neighbors = $cNode->getNeighbors();
foreach ($neighbors as $neighbor) {
if (!isset($visited[$neighbor->getId()]) || $visited[$neighbor->getId()] === false) {
if (!isset($visited[$neighbor->getId()]) || !$visited[$neighbor->getId()]) {
$stack[] = $neighbor;
}
}

View File

@ -295,8 +295,7 @@ final class FileUtils
$name = \preg_replace("/[^A-Za-z0-9\-_.]/", '_', $name);
$name = \preg_replace("/_+/", '_', $name ?? '');
$name = \trim($name ?? '', '_');
$name = \strtolower($name);
return $name;
return \strtolower($name);
}
}

View File

@ -139,7 +139,7 @@ class File extends FileAbstract implements FileInterface
if (ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists) {
$content .= self::get($con, $path);
} elseif (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists) {
$content = $content . self::get($con, $path);
$content .= self::get($con, $path);
} elseif (!Directory::exists($con, \dirname($path))) {
Directory::create($con, \dirname($path), 0755, true);
}

View File

@ -437,6 +437,6 @@ final class HttpUri implements UriInterface
*/
public function getUserInfo() : string
{
return $this->user . (!empty($this->pass) ? ':' . $this->pass : '');
return $this->user . (empty($this->pass) ? '' : ':' . $this->pass);
}
}

View File

@ -613,8 +613,7 @@ class Datamatrix extends TwoDAbstract
if ($this->isCharMode($tmpchr, self::ENC_X12)) {
return self::ENC_X12;
} elseif (!($this->isCharMode($tmpchr, self::ENC_X12)
|| $this->isCharMode($tmpchr, self::ENC_C40))
} elseif (!$this->isCharMode($tmpchr, self::ENC_X12) && !$this->isCharMode($tmpchr, self::ENC_C40)
) {
break;
}

View File

@ -105,7 +105,7 @@ final class Currency
try {
$xml = new \SimpleXMLElement(Rest::request($request)->getBody());
if (!isset($xml->Cube)) {
if (!(property_exists($xml, 'Cube') && $xml->Cube !== null)) {
throw new \Exception('Invalid xml path'); // @codeCoverageIgnore
}

View File

@ -325,19 +325,12 @@ class Markdown
$methodName = 'block' . $CurrentBlock['type'] . 'Continue';
$Block = $this->{$methodName}($Line, $CurrentBlock);
if (isset($Block))
{
if (isset($Block)) {
$CurrentBlock = $Block;
continue;
}
else
{
if ($this->isBlockCompletable($CurrentBlock['type']))
{
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
$CurrentBlock = $this->{$methodName}($CurrentBlock);
}
} elseif ($this->isBlockCompletable($CurrentBlock['type'])) {
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
$CurrentBlock = $this->{$methodName}($CurrentBlock);
}
}
@ -450,12 +443,12 @@ class Markdown
return $Component['element'];
}
protected function isBlockContinuable($Type)
protected function isBlockContinuable($Type): bool
{
return \method_exists($this, 'block' . $Type . 'Continue');
}
protected function isBlockCompletable($Type)
protected function isBlockCompletable($Type): bool
{
return \method_exists($this, 'block' . $Type . 'Complete');
}
@ -474,7 +467,7 @@ class Markdown
{
$text = \substr($Line['body'], 4);
$Block = [
return [
'element' => [
'name' => 'pre',
'element' => [
@ -483,8 +476,6 @@ class Markdown
],
],
];
return $Block;
}
}
@ -604,7 +595,7 @@ class Markdown
$Element['attributes'] = ['class' => "language-{$language}"];
}
$Block = [
return [
'char' => $marker,
'openerLength' => $openerLength,
'element' => [
@ -612,8 +603,6 @@ class Markdown
'element' => $Element,
],
];
return $Block;
}
protected function blockFencedCodeContinue($Line, $Block)
@ -656,11 +645,9 @@ class Markdown
{
$this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2];
$Block = [
return [
'hidden' => true,
];
return $Block;
}
}
@ -671,13 +658,11 @@ class Markdown
{
if (\preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches))
{
$Block = [
return [
'label' => $matches[1],
'text' => $matches[2],
'hidden' => true,
];
return $Block;
}
}
@ -747,18 +732,14 @@ class Markdown
$Block['element'] = $Element;
$Block = $this->addDdElement($Line, $Block);
return $Block;
return $this->addDdElement($Line, $Block);
}
protected function blockDefinitionListContinue($Line, array $Block)
{
if ($Line['text'][0] === ':')
{
$Block = $this->addDdElement($Line, $Block);
return $Block;
return $this->addDdElement($Line, $Block);
}
else
{
@ -918,7 +899,7 @@ class Markdown
'name' => 'li',
'handler' => [
'function' => 'li',
'argument' => !empty($matches[3]) ? [$matches[3]] : [],
'argument' => empty($matches[3]) ? [] : [$matches[3]],
'destination' => 'elements',
],
];
@ -1038,7 +1019,7 @@ class Markdown
{
if (\preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches))
{
$Block = [
return [
'element' => [
'name' => 'blockquote',
'handler' => [
@ -1048,8 +1029,6 @@ class Markdown
],
],
];
return $Block;
}
}
@ -1084,13 +1063,11 @@ class Markdown
if (\substr_count($Line['text'], $marker) >= 3 && \rtrim($Line['text'], " {$marker}") === '')
{
$Block = [
return [
'element' => [
'name' => 'hr',
],
];
return $Block;
}
}
@ -1307,9 +1284,8 @@ class Markdown
$DOMDocument->documentElement->nodeValue = 'placeholder\x1A';
$markup = $DOMDocument->saveHTML($DOMDocument->documentElement);
$markup = \str_replace('placeholder\x1A', $elementText, $markup);
return $markup;
return \str_replace('placeholder\x1A', $elementText, $markup);
}
#
@ -1329,11 +1305,9 @@ class Markdown
$this->DefinitionData['Reference'][$id] = $Data;
$Block = [
return [
'element' => [],
];
return $Block;
}
}
@ -1892,7 +1866,7 @@ class Markdown
{
if (\preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
{
$definition = \strlen($matches[1]) ? $matches[1] : $Element['handler']['argument'];
$definition = \strlen($matches[1]) !== 0 ? $matches[1] : $Element['handler']['argument'];
$definition = \strtolower($definition);
$extent += \strlen($matches[0]);
@ -2053,7 +2027,7 @@ class Markdown
protected function inlineUrl($Excerpt)
{
if ($this->urlsLinked !== true || ! isset($Excerpt['text'][2]) || $Excerpt['text'][2] !== '/')
if (!$this->urlsLinked || ! isset($Excerpt['text'][2]) || $Excerpt['text'][2] !== '/')
{
return;
}
@ -2063,7 +2037,7 @@ class Markdown
) {
$url = $matches[0][0];
$Inline = [
return [
'extent' => \strlen($matches[0][0]),
'position' => $matches[0][1],
'element' => [
@ -2074,8 +2048,6 @@ class Markdown
],
],
];
return $Inline;
}
}
@ -2183,9 +2155,7 @@ class Markdown
$Element['element'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['element']);
}
$Element = $closure($Element);
return $Element;
return $closure($Element);
}
protected function elementsApplyRecursive($closure, array $Elements)
@ -2269,17 +2239,12 @@ class Markdown
elseif (isset($Element['element']))
{
$markup .= $this->element($Element['element']);
} elseif (!$permitRawHtml) {
$markup .= self::escape($text, true);
}
else
{
if (!$permitRawHtml)
{
$markup .= self::escape($text, true);
}
else
{
$markup .= $text;
}
$markup .= $text;
}
$markup .= $hasName ? '</' . $Element['name'] . '>' : '';
@ -2292,7 +2257,7 @@ class Markdown
return $markup;
}
protected function elements(array $Elements)
protected function elements(array $Elements): string
{
$markup = '';
@ -2309,15 +2274,13 @@ class Markdown
? $Element['autobreak'] : isset($Element['name'])
);
// (autobreak === false) covers both sides of an element
$autoBreak = !$autoBreak ? $autoBreak : $autoBreakNext;
$autoBreak = $autoBreak ? $autoBreakNext : $autoBreak;
$markup .= ($autoBreak ? "\n" : '') . $this->element($Element);
$autoBreak = $autoBreakNext;
}
$markup .= $autoBreak ? "\n" : '';
return $markup;
return $markup . ($autoBreak ? "\n" : '');
}
# ~
@ -2377,9 +2340,7 @@ class Markdown
{
$parsedown = new self();
$markup = $parsedown->text($text);
return $markup;
return $parsedown->text($text);
}
protected function sanitiseElement(array $Element)
@ -2440,7 +2401,7 @@ class Markdown
# Static Methods
#
protected static function escape($text, $allowQuotes = false)
protected static function escape($text, $allowQuotes = false): string
{
return \htmlspecialchars($text, $allowQuotes ? \ENT_NOQUOTES : \ENT_QUOTES, 'UTF-8');
}

View File

@ -178,8 +178,8 @@ final class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testInvalidSourceUninstallPath() : void
{
self::assertFalse($this->appManager->uninstall(__DIR__ . '/invalid', __DIR__));
self::assertFalse($this->appManager->uninstall(__DIR__, __DIR__));
self::assertFalse($this->appManager->uninstall(__DIR__ . '/invalid'));
self::assertFalse($this->appManager->uninstall(__DIR__));
}
/**

View File

@ -8,9 +8,9 @@ declare(strict_types=1);
\setlocale(\LC_ALL, 'en_US.UTF-8');
if (\is_file('vendor/autoload.php')) {
include_once 'vendor/autoload.php';
include_once __DIR__ . '/vendor/autoload.php';
} elseif (\is_file('../../vendor/autoload.php')) {
include_once '../../vendor/autoload.php';
include_once __DIR__ . '/../../vendor/autoload.php';
}
require_once __DIR__ . '/../Autoloader.php';
@ -455,7 +455,7 @@ function phpServe() : void
// Execute the command and store the process ID
$output = [];
echo \sprintf('Starting server...') . \PHP_EOL;
echo 'Starting server...' . \PHP_EOL;
echo \sprintf(' Current directory: %s', \getcwd()) . \PHP_EOL;
echo \sprintf(' %s', $command);
\exec($command, $output);
@ -480,7 +480,7 @@ function phpServe() : void
// Kill the web server when the process ends
\register_shutdown_function(function() use ($killCommand, $pid) : void {
echo \PHP_EOL . \sprintf('Stopping server...') . \PHP_EOL;
echo \PHP_EOL . 'Stopping server...' . \PHP_EOL;
echo \sprintf(' %s - Killing process with ID %d', \date('r'), $pid) . \PHP_EOL;
\exec($killCommand . $pid);
});

View File

@ -85,7 +85,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
self::assertTrue(
!empty(
$this->app->dispatcher->dispatch(
function($req, $resp, $data = null) { return true; },
function($req, $resp, $data = null): bool { return true; },
new HttpRequest(new HttpUri(''), $localization),
new HttpResponse($localization)
)
@ -95,7 +95,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
self::assertTrue(
!empty(
$this->app->dispatcher->dispatch(
function($req) { return true; }
function($req): bool { return true; }
)
)
);
@ -182,7 +182,7 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
!empty(
$this->app->dispatcher->dispatch(
[
function($app, $req, $resp, $data = null) { return true; },
function($app, $req, $resp, $data = null): bool { return true; },
'phpOMS\tests\Dispatcher\TestController:testFunction',
'phpOMS\tests\Dispatcher\TestController::testFunctionStatic',
],

View File

@ -16,17 +16,17 @@ namespace phpOMS\tests\Dispatcher;
class TestController
{
public function testFunction($req, $resp, $data = null)
public function testFunction($req, $resp, $data = null): bool
{
return true;
}
public function testFunctionNoPara()
public function testFunctionNoPara(): bool
{
return true;
}
public static function testFunctionStatic($req, $resp, $data = null)
public static function testFunctionStatic($req, $resp, $data = null): bool
{
return true;
}

View File

@ -52,7 +52,7 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testAdd() : void
{
self::assertTrue($this->event->attach('group', function() { return true; }, false, false));
self::assertTrue($this->event->attach('group', function(): bool { return true; }, false, false));
self::assertEquals(1, $this->event->count());
}
@ -63,7 +63,7 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testClear() : void
{
self::assertTrue($this->event->attach('group', function() { return true; }, false, false));
self::assertTrue($this->event->attach('group', function(): bool { return true; }, false, false));
self::assertEquals(1, $this->event->count());
$this->event->clear();
@ -77,8 +77,8 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testAddMultiple() : void
{
self::assertTrue($this->event->attach('group', function() { return true; }, false, false));
self::assertTrue($this->event->attach('group', function() { return true; }, false, false));
self::assertTrue($this->event->attach('group', function(): bool { return true; }, false, false));
self::assertTrue($this->event->attach('group', function(): bool { return true; }, false, false));
self::assertEquals(1, $this->event->count());
}
@ -185,7 +185,7 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testReset() : void
{
self::assertTrue($this->event->attach('group', function() { return true; }, false, true));
self::assertTrue($this->event->attach('group', function(): bool { return true; }, false, true));
$this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2');
@ -201,7 +201,7 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testNoReset() : void
{
self::assertTrue($this->event->attach('group', function() { return true; }, false, false));
self::assertTrue($this->event->attach('group', function(): bool { return true; }, false, false));
$this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2');
@ -217,7 +217,7 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testDetach() : void
{
$this->event->attach('group', function() { return true; }, false, true);
$this->event->attach('group', function(): bool { return true; }, false, true);
$this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2');
@ -234,7 +234,7 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testInvalidDetach() : void
{
$this->event->attach('group', function() { return true; }, false, true);
$this->event->attach('group', function(): bool { return true; }, false, true);
$this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2');
@ -249,8 +249,8 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
*/
public function testRemove() : void
{
self::assertTrue($this->event->attach('group1', function() { return true; }, true, false));
self::assertTrue($this->event->attach('group2', function() { return true; }, true, false));
self::assertTrue($this->event->attach('group1', function(): bool { return true; }, true, false));
self::assertTrue($this->event->attach('group2', function(): bool { return true; }, true, false));
self::assertEquals(2, $this->event->count());
$this->event->trigger('group1');

View File

@ -87,7 +87,7 @@ final class MoneyTest extends \PHPUnit\Framework\TestCase
public function testMoneyLocalization() : void
{
$money = new Money(12345678);
self::assertEquals('€ 9.992,30', $money->setInt(99923000)->setLocalization('.', ',', ISO4217SymbolEnum::_EUR, 0)->getCurrency());
self::assertEquals('€ 9.992,30', $money->setInt(99923000)->setLocalization('.', ',')->getCurrency());
}
/**

View File

@ -57,7 +57,7 @@ final class GammaTest extends \PHPUnit\Framework\TestCase
];
for ($i = 1; $i <= 10; ++$i) {
if (!(\abs($spouge[$i - 1] - Gamma::spougeApproximation($i / 3)) < 0.01)) {
if (\abs($spouge[$i - 1] - Gamma::spougeApproximation($i / 3)) >= 0.01) {
self::assertTrue(false);
}
}
@ -77,7 +77,7 @@ final class GammaTest extends \PHPUnit\Framework\TestCase
];
for ($i = 1; $i <= 10; ++$i) {
if (!(\abs($stirling[$i - 1] - Gamma::stirlingApproximation($i / 3)) < 0.01)) {
if (\abs($stirling[$i - 1] - Gamma::stirlingApproximation($i / 3)) >= 0.01) {
self::assertTrue(false);
}
}
@ -97,7 +97,7 @@ final class GammaTest extends \PHPUnit\Framework\TestCase
];
for ($i = 1; $i <= 10; ++$i) {
if (!(\abs($gsl[$i - 1] - Gamma::lanczosApproximationReal($i / 3)) < 0.01)) {
if (\abs($gsl[$i - 1] - Gamma::lanczosApproximationReal($i / 3)) >= 0.01) {
self::assertTrue(false);
}
}
@ -117,7 +117,7 @@ final class GammaTest extends \PHPUnit\Framework\TestCase
];
for ($i = 1; $i <= 10; ++$i) {
if (!(\abs($gsl[$i - 1] - Gamma::logGamma($i)) < 0.01)) {
if (\abs($gsl[$i - 1] - Gamma::logGamma($i)) >= 0.01) {
self::assertTrue(false);
}
}

View File

@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
function has𠀊Unicode()
function has𠀊Unicode(): bool
{
return true;
}

View File

@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
function noDeprecated()
function noDeprecated(): string
{
return \is_string('');
}

View File

@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
function noUnicode()
function noUnicode(): bool
{
return true;
}

View File

@ -51,7 +51,7 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->graph->getCircuitRank());
self::assertTrue($this->graph->isConnected());
self::assertTrue($this->graph->isBipartite(1));
self::assertTrue($this->graph->isBipartite());
self::assertFalse($this->graph->isDirected());
self::assertFalse($this->graph->hasCycle());
@ -639,7 +639,7 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
$node3->setNodeRelative($node5);
$node4->setNodeRelative($node5);
$paths = $this->graph->getFloydWarshallShortestPath($node0, $node5);
$paths = $this->graph->getFloydWarshallShortestPath();
self::assertGreaterThan(1, $paths);
}
@ -679,7 +679,7 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
$node3->setNodeRelative($node5);
$node4->setNodeRelative($node5);
$paths = $this->graph->longestPath($node0, $node5);
$paths = $this->graph->longestPath();
self::assertGreaterThan(1, $paths);
}