manual cs fixes

This commit is contained in:
Dennis Eichhorn 2020-09-01 20:57:48 +02:00
parent 28c9ec6a6c
commit b419139a45
6 changed files with 61 additions and 25 deletions

View File

@ -83,13 +83,31 @@ final class BasicOcr
throw new \Exception();
}
$magicNumber = \unpack('l', \fread($fp, 4))[1];
$numberOfImages = \unpack('l', \fread($fp, 4))[1];
$numberOfRows = \unpack('l', \fread($fp, 4))[1];
$numberOfColumns = \unpack('l', \fread($fp, 4))[1];
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$magicNumber = \unpack('l', $read)[1];
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$numberOfImages = \unpack('l', $read)[1];
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$numberOfRows = \unpack('l', $read)[1];
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$numberOfColumns = \unpack('l', $read)[1];
$images = [];
for ($i = 0; $i < $numberOfImages; ++$i) {
$image = [];
@ -97,7 +115,11 @@ final class BasicOcr
$rows = [];
for ($col = 0; $col < $numberOfColumns; ++$col) {
$rows[] = \unpack('l', \fread($fp, 1))[1]; //fread($fp, 1);
$read = \fread($fp, 1);
if (!$read) {
return [];
}
$rows[] = \unpack('l', $read)[1]; //fread($fp, 1);
}
$image[] = $rows;
@ -125,13 +147,25 @@ final class BasicOcr
throw new \Exception();
}
$magicNumber = \unpack('l', \fread($fp, 4))[1];
$numberOfLabels = \unpack('l', \fread($fp, 4))[1];
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$magicNumber = \unpack('l', $read)[1];
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$numberOfLabels = \unpack('l', $read)[1];
$labels = [];
for ($i = 0; $i < $numberOfLabels; ++$i) {
$labels[] = \unpack('l', \fread($fp, 1))[1]; //fread($fp, 1);
$read = \fread($fp, 4);
if (!$read) {
return [];
}
$labels[] = \unpack('l', $read)[1]; //fread($fp, 1);
}
return $labels;
@ -161,7 +195,7 @@ final class BasicOcr
*
* @param array $data Image data and labell information to flatten
*
* @return arry
* @return array
*
* @sicne 1.0.0
*/
@ -182,7 +216,7 @@ final class BasicOcr
*
* @param array $Xtrain Image data used for training
* @param array $ytrain Labels associated with the trained data
* @param array $Xtrain Image data from the image to categorize
* @param array $Xtest Image data from the image to categorize
* @param int $k Amount of best fits that should be found
*/
private function kNearest(array $Xtrain, array $ytrain, array $Xtest, int $k = 3) : array

View File

@ -277,7 +277,7 @@ abstract class EmailAbstract
$this->setMessageType();
if($this->submitType === SubmitType::MAIL) {
if ($this->submitType === SubmitType::MAIL) {
$this->header .= 'to: ' . $this->addrAppend('to', $this->to);
$this->header .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->subject)));
}

View File

@ -202,13 +202,13 @@ class Mail
*/
protected bool $confirmReading = false;
private string $signKeyFile = '';
private string $signKeyFile = '';
private string $signCertFile = '';
private string $signCertFile = '';
private string $signExtraFile = '';
private string $signKeyPass = '';
private string $signKeyPass = '';
/**
* Constructor.
@ -1335,12 +1335,13 @@ class Mail
private function encodeQ(string $text, int $context = HeaderContext::TEXT) : string
{
$pattern = '';
switch ($context) {
switch ($context) {
case HeaderContext::PHRASE:
$pattern = '^A-Za-z0-9!*+\/ -';
break;
case HeaderContext::COMMENT:
$pattern = '\(\)"';
break;
case HeaderContext::TEXT:
default:
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;

View File

@ -267,7 +267,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [
$account,
null, $obj,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0,
StringUtils::intHash($mapper), 0,
static::MODULE_NAME,
(string) $id,
'',
@ -296,7 +296,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [
$account,
null, $obj,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0,
StringUtils::intHash($mapper), 0,
static::MODULE_NAME,
(string) $id,
'',
@ -359,7 +359,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-delete', '', [
$account,
$obj, null,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0,
StringUtils::intHash($mapper), 0,
static::MODULE_NAME,
(string) $id,
'',
@ -389,7 +389,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-relation', '', [
$account,
$rel1, $rel2,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0,
StringUtils::intHash($mapper), 0,
static::MODULE_NAME,
'0',
'',

View File

@ -26,13 +26,13 @@ use phpOMS\Account\Account;
*/
class ClientConnection
{
private $id = 0;
private $id = 0;
private $socket = null;
private $socket = null;
private $handshake = false;
private $pid = null;
private $pid = null;
private $connected = true;

View File

@ -199,6 +199,7 @@ final class UriFactory
$url
);
/** @var array $urlStructure */
$urlStructure = \parse_url($url);
if ($urlStructure === false) {
@ -206,7 +207,7 @@ final class UriFactory
}
if (isset($urlStructure['query'])) {
\parse_str($urlStructure['query'] ?? '', $urlStructure['query']);
\parse_str($urlStructure['query'] ?? [], $urlStructure['query']);
}
$escaped =