phpstan fixes and install bug

This commit is contained in:
Dennis Eichhorn 2020-02-27 19:01:55 +01:00
parent 25f7f534d5
commit a2a70e28eb
7 changed files with 56 additions and 9 deletions

View File

@ -98,6 +98,7 @@ class MazeGenerator
if ($pos === null) { if ($pos === null) {
$n = 0; $n = 0;
break;
} }
} }
} }

View File

@ -36,7 +36,13 @@ trait OptionsTrait
private array $options = []; private array $options = [];
/** /**
* {@inheritdoc} * Is this key set.
*
* @param mixed $key Key to check for existence
*
* @return bool
*
* @since 1.0.0
*/ */
public function exists($key) : bool public function exists($key) : bool
{ {
@ -44,7 +50,13 @@ trait OptionsTrait
} }
/** /**
* {@inheritdoc} * Get option by key.
*
* @param mixed $key Unique option key
*
* @return mixed Option value
*
* @since 1.0.0
*/ */
public function getOption($key) public function getOption($key)
{ {
@ -52,7 +64,13 @@ trait OptionsTrait
} }
/** /**
* {@inheritdoc} * Get options by keys.
*
* @param mixed $key Unique option key
*
* @return array Option values
*
* @since 1.0.0
*/ */
public function getOptions(array $key) public function getOptions(array $key)
{ {
@ -68,7 +86,15 @@ trait OptionsTrait
} }
/** /**
* {@inheritdoc} * Updating or adding settings.
*
* @param mixed $key Unique option key
* @param mixed $value Option value
* @param bool $overwrite Overwrite existing value
*
* @return bool
*
* @since 1.0.0
*/ */
public function setOption($key, $value, bool $overwrite = true) : bool public function setOption($key, $value, bool $overwrite = true) : bool
{ {
@ -82,7 +108,14 @@ trait OptionsTrait
} }
/** /**
* {@inheritdoc} * Updating or adding settings.
*
* @param array $pair Key value pair
* @param bool $overwrite Overwrite existing value
*
* @return bool
*
* @since 1.0.0
*/ */
public function setOptions(array $pair, bool $overwrite = true) : bool public function setOptions(array $pair, bool $overwrite = true) : bool
{ {

View File

@ -23,13 +23,16 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
* @license OMS License 1.0 * @license OMS License 1.0
* @link https://orange-management.org * @link https://orange-management.org
* @since 1.0.0 * @since 1.0.0
*
* @phpstan-implements \ArrayAccess<string, mixed>
* @phpstan-implements \Iterator<string, mixed>
*/ */
class Matrix implements \ArrayAccess, \Iterator class Matrix implements \ArrayAccess, \Iterator
{ {
/** /**
* Matrix. * Matrix.
* *
* @var array * @var array<int, array<int, int|float>>
* @since 1.0.0 * @since 1.0.0
*/ */
protected array $matrix = []; protected array $matrix = [];

View File

@ -141,7 +141,10 @@ final class NaiveBayesClassifier
} }
if (\is_array($value)) { if (\is_array($value)) {
/** @var string[] $value */ /**
* @var string[] $value
* @var string $word
*/
foreach ($value as $word) { foreach ($value as $word) {
if (isset($this->dict[$criteria][$attr]['data'][$word]) if (isset($this->dict[$criteria][$attr]['data'][$word])
&& $this->dict[$criteria][$attr]['data'][$word] >= $minimum && $this->dict[$criteria][$attr]['data'][$word] >= $minimum

View File

@ -665,6 +665,10 @@ final class ModuleManager
*/ */
public function installApplications(string $from) : void public function installApplications(string $from) : void
{ {
if (!\file_exists($this->modulePath . '/' . $from . '/Application')) {
return;
}
$dirs = \scandir($this->modulePath . '/' . $from . '/Application'); $dirs = \scandir($this->modulePath . '/' . $from . '/Application');
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
if ($dir === '.' || $dir === '..') { if ($dir === '.' || $dir === '..') {

View File

@ -23,6 +23,9 @@ namespace phpOMS\System\File;
* @license OMS License 1.0 * @license OMS License 1.0
* @link https://orange-management.org * @link https://orange-management.org
* @since 1.0.0 * @since 1.0.0
*
* @phpstan-extends \ArrayAccess<string, mixed>
* @phpstan-extends \Iterator<string, mixed>
*/ */
interface DirectoryInterface extends ContainerInterface, \Iterator, \ArrayAccess interface DirectoryInterface extends ContainerInterface, \Iterator, \ArrayAccess
{ {

View File

@ -63,8 +63,8 @@ class Phone
$numberString = \str_replace( $numberString = \str_replace(
'$' . $i, '$' . $i,
StringUtils::generateString( StringUtils::generateString(
$size[$i - 1][0], $size[$i - 1][0] ?? 0,
$size[$i - 1][1], $size[$i - 1][1] ?? 0,
'0123456789' '0123456789'
), ),
$numberString $numberString