diff --git a/Algorithm/Clustering/PointInterface.php b/Algorithm/Clustering/PointInterface.php index 9d7eb1b0c..99b6ea524 100644 --- a/Algorithm/Clustering/PointInterface.php +++ b/Algorithm/Clustering/PointInterface.php @@ -18,6 +18,9 @@ namespace phpOMS\Algorithm\Clustering; /** * Point interface. * + * @property int $group Group + * @property string $name Name + * * @package phpOMS\Algorithm\Clustering; * @license OMS License 1.0 * @link https://orange-management.org diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 9490f6db4..f2a805a1a 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -813,8 +813,6 @@ class DataMapperAbstract implements DataMapperInterface } // Setting relation value (id) for relation (since the relation is not stored in an extra relation table) - /** @var string $table */ - /** @var array $columns */ if (!isset(static::$hasMany[$propertyName]['external'])) { $relProperty = $relReflectionClass->getProperty($mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']); @@ -893,8 +891,6 @@ class DataMapperAbstract implements DataMapperInterface } // Setting relation value (id) for relation (since the relation is not stored in an extra relation table) - /** @var string $table */ - /** @var array $columns */ if (static::$hasMany[$propertyName]['table'] === static::$hasMany[$propertyName]['mapper']::$table && isset($mapper::$columns[static::$hasMany[$propertyName]['self']]) ) { @@ -1153,8 +1149,6 @@ class DataMapperAbstract implements DataMapperInterface } // create if not existing - /** @var string $table */ - /** @var array $columns */ if (static::$hasMany[$propertyName]['table'] === static::$hasMany[$propertyName]['mapper']::$table && isset($mapper::$columns[static::$hasMany[$propertyName]['self']]) ) { @@ -1235,8 +1229,6 @@ class DataMapperAbstract implements DataMapperInterface } // create if not existing - /** @var string $table */ - /** @var array $columns */ if (static::$hasMany[$propertyName]['table'] === static::$hasMany[$propertyName]['mapper']::$table && isset($mapper::$columns[static::$hasMany[$propertyName]['self']]) ) { @@ -1293,7 +1285,6 @@ class DataMapperAbstract implements DataMapperInterface */ private static function deleteRelationTable(string $propertyName, array $objsIds, $objId) : void { - /** @var string $table */ if (empty($objsIds) || static::$hasMany[$propertyName]['table'] === static::$table || static::$hasMany[$propertyName]['table'] === static::$hasMany[$propertyName]['mapper']::$table @@ -2879,7 +2870,7 @@ class DataMapperAbstract implements DataMapperInterface $query->random(static::$primaryField) ->limit($amount); - return self::getAllByQuery($query, $relations, $depth, null, $query); + return self::getAllByQuery($query, $relations, $depth); } /** @@ -3103,7 +3094,6 @@ class DataMapperAbstract implements DataMapperInterface $query = new Builder(self::$db); if (self::$relations === RelationType::ALL) { - /** @var string $primaryField */ $src = $value['external'] ?? $value['mapper']::$primaryField; $query->select($value['table'] . '.' . $src) diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index a532584e0..724021e80 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -143,7 +143,7 @@ class Builder extends BuilderAbstract /** * Group. * - * @var string[] + * @var string[]|self[] * @since 1.0.0 */ public array $groups = []; @@ -274,6 +274,8 @@ class Builder extends BuilderAbstract { $this->type = QueryType::SELECT; + /** @var mixed[] $columns */ + /** @var mixed $column */ foreach ($columns as $column) { if (\is_string($column) || $column instanceof self) { $this->selects[] = $column; @@ -489,7 +491,7 @@ class Builder extends BuilderAbstract /** * From. * - * @param array ...$tables Tables + * @param mixed ...$tables Tables * * @return Builder * @@ -497,6 +499,8 @@ class Builder extends BuilderAbstract */ public function from(...$tables) : self { + /** @var mixed[] $tables */ + /** @var mixed $table */ foreach ($tables as $key => $table) { if (\is_string($table) || $table instanceof self) { $this->from[] = $table; @@ -654,7 +658,7 @@ class Builder extends BuilderAbstract /** * Group by. * - * @param array|string ...$columns Grouping result + * @param mixed ...$columns Grouping result * * @return Builder * @@ -662,6 +666,8 @@ class Builder extends BuilderAbstract */ public function groupBy(...$columns) : self { + /** @var mixed[] $columns */ + /** @var mixed $column */ foreach ($columns as $column) { if (\is_string($column) || $column instanceof self) { $this->groups[] = $column; @@ -998,7 +1004,7 @@ class Builder extends BuilderAbstract /** * Values to insert. * - * @param array ...$sets Values + * @param mixed ...$sets Values * * @return Builder * @@ -1030,7 +1036,7 @@ class Builder extends BuilderAbstract /** * Update columns. * - * @param array ...$tables Column names to update + * @param mixed ...$tables Column names to update * * @return Builder * @@ -1046,6 +1052,8 @@ class Builder extends BuilderAbstract $this->type = QueryType::UPDATE; + /** @var mixed[] $tables */ + /** @var mixed $table */ foreach ($tables as $table) { if (\is_string($table) || $table instanceof self) { $this->updates[] = $table; @@ -1100,7 +1108,7 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $table Join query + * @param string|self $table Join query * @param string $type Join type * @param null|string $alias Alias name (empty = none) * @@ -1110,7 +1118,9 @@ class Builder extends BuilderAbstract */ public function join($table, string $type = JoinType::JOIN, string $alias = null) : self { - if (!\is_string($table) && !($table instanceof self)) { + if ((!\is_string($table) && !($table instanceof self)) + || ($alias === null && !\is_string($table)) + ) { throw new \InvalidArgumentException(); } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 8a656c6c5..d775c10c2 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -704,7 +704,7 @@ class Matrix implements \ArrayAccess, \Iterator /** * {@inheritdoc} */ - public function current() + public function current() : int { return $this->offsetGet($this->position); } diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index d7df1a80e..4ddc38ad3 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -146,4 +146,16 @@ abstract class HeaderAbstract * @since 1.0.0 */ abstract public function has(string $key) : bool; + + /** + * Push all headers. + * + * @return void + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function push() : void + { + } } diff --git a/Message/Http/HttpResponse.php b/Message/Http/HttpResponse.php index 5ec47ba08..51f8e2f35 100644 --- a/Message/Http/HttpResponse.php +++ b/Message/Http/HttpResponse.php @@ -25,6 +25,8 @@ use phpOMS\Views\View; /** * Response class. * + * @property \phpOMS\Message\Http\HttpHeader $header Http header + * * @package phpOMS\Message\Http * @license OMS License 1.0 * @link https://orange-management.org diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 6e0c1cd65..bb5c0917a 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -198,6 +198,7 @@ abstract class InstallerAbstract { $directories = new Directory(\dirname($info->getPath()) . '/Admin/Routes'); + /** @var Directory|File $child */ foreach ($directories as $child) { if ($child instanceof Directory) { foreach ($child as $file) { @@ -277,6 +278,7 @@ abstract class InstallerAbstract { $directories = new Directory(\dirname($info->getPath()) . '/Admin/Hooks'); + /** @var Directory|File $child */ foreach ($directories as $child) { if ($child instanceof Directory) { foreach ($child as $file) { diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 5e70be550..af03bc454 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -97,7 +97,7 @@ final class ModuleManager /** * All modules in the module directory. * - * @var array + * @var array * @since 1.0.0 */ private array $all = []; @@ -252,7 +252,7 @@ final class ModuleManager /** * Get all modules in the module directory. * - * @return array + * @return array * * @since 1.0.0 */ @@ -268,10 +268,10 @@ final class ModuleManager $c = $files === false ? 0 : \count($files); for ($i = 0; $i < $c; ++$i) { - $module = $this->loadInfo($files[$i]); + $info = $this->loadInfo($files[$i]); - if ($module !== null) { - $this->all[$files[$i]] = $module; + if ($info !== null) { + $this->all[$files[$i]] = $info; } } } @@ -311,7 +311,11 @@ final class ModuleManager $installed = $sth->fetchAll(\PDO::FETCH_COLUMN); foreach ($installed as $module) { - $this->installed[$module] = $this->loadInfo($module); + $info = $this->loadInfo($module); + + if ($info !== null) { + $this->installed[$module] = $info; + } } } @@ -361,6 +365,10 @@ final class ModuleManager try { $info = $this->loadInfo($module); + if ($info === null) { + return false; + } + $this->deactivateModule($info); return true; @@ -412,6 +420,10 @@ final class ModuleManager try { $info = $this->loadInfo($module); + if ($info === null) { + return false; + } + $this->activateModule($info); return true; @@ -457,7 +469,11 @@ final class ModuleManager */ public function reInit(string $module, ApplicationInfo $appInfo = null) : void { - $info = $this->loadInfo($module); + $info = $this->loadInfo($module); + if ($info === null) { + return; + } + $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; if (!Autoloader::exists($class)) { @@ -491,6 +507,9 @@ final class ModuleManager try { $info = $this->loadInfo($module); + if ($info === null) { + return false; + } $this->installed[$module] = $info; $this->installDependencies($info->getDependencies()); @@ -541,6 +560,9 @@ final class ModuleManager try { $info = $this->loadInfo($module); + if ($info === null) { + return false; + } $this->installed[$module] = $info; // uninstall dependencies if not used by others diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index 7813165ef..85e353bb4 100644 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -32,16 +32,8 @@ use phpOMS\Utils\StringUtils; * @link https://orange-management.org * @since 1.0.0 */ -class Directory extends FileAbstract implements DirectoryInterface, FtpContainerInterface +class Directory extends FileAbstract implements DirectoryInterface { - /** - * Directory nodes (files and directories). - * - * @var FileAbstract[] - * @since 1.0.0 - */ - private array $nodes = []; - /** * Filter for directory listing * @@ -50,6 +42,14 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer */ private string $filter = '*'; + /** + * Directory nodes (files and directories). + * + * @var array + * @since 1.0.0 + */ + private array $nodes = []; + /** * Create ftp connection. * @@ -385,6 +385,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer $data[$names[$key]] = $e; } + /** @var array */ return $data; } @@ -499,7 +500,11 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer if (\is_dir($item)) { self::put($con, $item, $to . '/' . self::name($item)); } else { - File::put($con, $to . '/' . self::name($item), \file_get_contents($item)); + $content = \file_get_contents($item); + + if ($content !== false) { + File::put($con, $to . '/' . self::name($item), $content); + } } } @@ -682,7 +687,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer /** * {@inheritdoc} */ - public function key() + public function key() : ?string { return \key($this->nodes); } @@ -690,7 +695,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer /** * {@inheritdoc} */ - public function next() + public function next() : FileAbstract { $next = \next($this->nodes); @@ -704,7 +709,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer /** * {@inheritdoc} */ - public function valid() + public function valid() : bool { $key = \key($this->nodes); diff --git a/System/File/Ftp/FileAbstract.php b/System/File/Ftp/FileAbstract.php index 8675688f5..2237b3805 100644 --- a/System/File/Ftp/FileAbstract.php +++ b/System/File/Ftp/FileAbstract.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace phpOMS\System\File\Ftp; -use phpOMS\System\File\ContainerInterface; use phpOMS\Uri\HttpUri; /** @@ -27,7 +26,7 @@ use phpOMS\Uri\HttpUri; * @link https://orange-management.org * @since 1.0.0 */ -abstract class FileAbstract implements ContainerInterface +abstract class FileAbstract implements FtpContainerInterface { /** * Ftp connection diff --git a/System/File/Ftp/FtpContainerInterface.php b/System/File/Ftp/FtpContainerInterface.php index a7b0b03c6..14da4bcb9 100644 --- a/System/File/Ftp/FtpContainerInterface.php +++ b/System/File/Ftp/FtpContainerInterface.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace phpOMS\System\File\Ftp; +use phpOMS\System\File\ContainerInterface; + /** * Filesystem class. * @@ -24,7 +26,7 @@ namespace phpOMS\System\File\Ftp; * @link https://orange-management.org * @since 1.0.0 */ -interface FtpContainerInterface +interface FtpContainerInterface extends ContainerInterface { /** * Get the datetime when the resource got created. diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 11af19f81..2ed55a324 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -29,7 +29,7 @@ use phpOMS\Utils\StringUtils; * @link https://orange-management.org * @since 1.0.0 */ -final class Directory extends FileAbstract implements DirectoryInterface, LocalContainerInterface +final class Directory extends FileAbstract implements DirectoryInterface { /** * Directory list filter. @@ -42,7 +42,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC /** * Directory nodes (files and directories). * - * @var ContainerInterface[] + * @var array * @since 1.0.0 */ private array $nodes = []; @@ -163,7 +163,12 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC parent::index(); - foreach (\glob($this->path . \DIRECTORY_SEPARATOR . $this->filter) as $filename) { + $files = \glob($this->path . \DIRECTORY_SEPARATOR . $this->filter); + if ($files === false) { + return; + } + + foreach ($files as $filename) { if (!StringUtils::endsWith(\trim($filename), '.')) { $file = \is_dir($filename) ? new self($filename, '*', false) : new File($filename); @@ -493,7 +498,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC /** * {@inheritdoc} */ - public function current() + public function current() : self { $current = \current($this->nodes); @@ -507,7 +512,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC /** * {@inheritdoc} */ - public function key() + public function key() : ?string { return \key($this->nodes); } @@ -515,7 +520,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC /** * {@inheritdoc} */ - public function next() + public function next() : FileAbstract { $next = \next($this->nodes); diff --git a/System/File/Local/File.php b/System/File/Local/File.php index 04d5820e7..7fd5d8db4 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -29,7 +29,7 @@ use phpOMS\System\File\PathException; * @link https://orange-management.org * @since 1.0.0 */ -final class File extends FileAbstract implements FileInterface, LocalContainerInterface +final class File extends FileAbstract implements FileInterface { /** * Constructor. diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index 31dbd1a99..b6c73a013 100644 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace phpOMS\System\File\Local; -use phpOMS\System\File\ContainerInterface; +use phpOMS\System\File\PathException; /** * Filesystem class. @@ -26,7 +26,7 @@ use phpOMS\System\File\ContainerInterface; * @link https://orange-management.org * @since 1.0.0 */ -abstract class FileAbstract implements ContainerInterface +abstract class FileAbstract implements LocalContainerInterface { /** * Path. diff --git a/System/File/Local/LocalContainerInterface.php b/System/File/Local/LocalContainerInterface.php index 3689e39c1..b0379ddc2 100644 --- a/System/File/Local/LocalContainerInterface.php +++ b/System/File/Local/LocalContainerInterface.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace phpOMS\System\File\Local; +use phpOMS\System\File\ContainerInterface; + /** * Filesystem class. * @@ -24,7 +26,7 @@ namespace phpOMS\System\File\Local; * @link https://orange-management.org * @since 1.0.0 */ -interface LocalContainerInterface +interface LocalContainerInterface extends ContainerInterface { /** * Get the datetime when the resource got created. diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index a4731bfaf..5746dc2f1 100644 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -17,6 +17,13 @@ namespace phpOMS\Uri; /** * Uri interface. * + * @property string $scheme Scheme + * @property string $host Host + * @property int $port Port + * @property string $fragment Fragment + * @property string $user User + * @property string $pass Password + * * @package phpOMS\Uri * @license OMS License 1.0 * @link https://orange-management.org diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index d4f98ef30..646df8210 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -429,7 +429,7 @@ class Repository */ public function createBranch(Branch $branch, bool $force = false) : string { - return \implode("\n", $this->run('branch ' . ($force ? '-D' : '-d') . ' ' . $branch->getName())); + return \implode("\n", $this->run('branch ' . ($force ? '-D' : '-d') . ' ' . $branch->name)); } /** @@ -497,7 +497,7 @@ class Repository */ public function checkout(Branch $branch) : string { - $result = \implode("\n", $this->run('checkout ' . $branch->getName())); + $result = \implode("\n", $this->run('checkout ' . $branch->name)); $this->branch = $branch; return $result; @@ -514,7 +514,7 @@ class Repository */ public function merge(Branch $branch) : string { - return \implode("\n", $this->run('merge ' . $branch->getName() . ' --no-ff')); + return \implode("\n", $this->run('merge ' . $branch->name . ' --no-ff')); } /** @@ -579,7 +579,7 @@ class Repository { $remote = \escapeshellarg($remote); - return \implode("\n", $this->run('push --tags ' . $remote . ' ' . $branch->getName())); + return \implode("\n", $this->run('push --tags ' . $remote . ' ' . $branch->name)); } /** @@ -596,7 +596,7 @@ class Repository { $remote = \escapeshellarg($remote); - return \implode("\n", $this->run('pull ' . $remote . ' ' . $branch->getName())); + return \implode("\n", $this->run('pull ' . $remote . ' ' . $branch->name)); } /** @@ -711,7 +711,7 @@ class Repository $author = \substr($line, \strlen($matches[0]) + 1); $contributor = new Author($author === false ? '' : $author); - $contributor->setCommitCount($this->getCommitsCount($start, $end)[$contributor->getName()]); + $contributor->setCommitCount($this->getCommitsCount($start, $end)[$contributor->name]); $addremove = $this->getAdditionsRemovalsByContributor($contributor, $start, $end); $contributor->setAdditionCount($addremove['added']); @@ -781,7 +781,7 @@ class Repository $addremove = ['added' => 0, 'removed' => 0]; $lines = $this->run( - 'log --author=' . \escapeshellarg($author->getName()) + 'log --author=' . \escapeshellarg($author->name) . ' --since="' . $start->format('Y-m-d') . '" --before="' . $end->format('Y-m-d') . '" --pretty=tformat: --numstat' @@ -833,7 +833,7 @@ class Repository if ($author === null) { $author = ''; } else { - $author = ' --author=' . \escapeshellarg($author->getName()) . ''; + $author = ' --author=' . \escapeshellarg($author->name) . ''; } $lines = $this->run(