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

View File

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

View File

@ -202,13 +202,13 @@ class Mail
*/ */
protected bool $confirmReading = false; protected bool $confirmReading = false;
private string $signKeyFile = ''; private string $signKeyFile = '';
private string $signCertFile = ''; private string $signCertFile = '';
private string $signExtraFile = ''; private string $signExtraFile = '';
private string $signKeyPass = ''; private string $signKeyPass = '';
/** /**
* Constructor. * Constructor.
@ -1335,12 +1335,13 @@ class Mail
private function encodeQ(string $text, int $context = HeaderContext::TEXT) : string private function encodeQ(string $text, int $context = HeaderContext::TEXT) : string
{ {
$pattern = ''; $pattern = '';
switch ($context) { switch ($context) {
case HeaderContext::PHRASE: case HeaderContext::PHRASE:
$pattern = '^A-Za-z0-9!*+\/ -'; $pattern = '^A-Za-z0-9!*+\/ -';
break; break;
case HeaderContext::COMMENT: case HeaderContext::COMMENT:
$pattern = '\(\)"'; $pattern = '\(\)"';
break;
case HeaderContext::TEXT: case HeaderContext::TEXT:
default: default:
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; $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', '', [ $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [
$account, $account,
null, $obj, null, $obj,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, StringUtils::intHash($mapper), 0,
static::MODULE_NAME, static::MODULE_NAME,
(string) $id, (string) $id,
'', '',
@ -296,7 +296,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [ $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [
$account, $account,
null, $obj, null, $obj,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, StringUtils::intHash($mapper), 0,
static::MODULE_NAME, static::MODULE_NAME,
(string) $id, (string) $id,
'', '',
@ -359,7 +359,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-delete', '', [ $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-delete', '', [
$account, $account,
$obj, null, $obj, null,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, StringUtils::intHash($mapper), 0,
static::MODULE_NAME, static::MODULE_NAME,
(string) $id, (string) $id,
'', '',
@ -389,7 +389,7 @@ abstract class ModuleAbstract
$this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-relation', '', [ $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-relation', '', [
$account, $account,
$rel1, $rel2, $rel1, $rel2,
StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, StringUtils::intHash($mapper), 0,
static::MODULE_NAME, static::MODULE_NAME,
'0', '0',
'', '',

View File

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

View File

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