Type fixes

This commit is contained in:
Dennis Eichhorn 2018-07-17 18:49:46 +02:00
parent c688f12c06
commit d633d96462
4 changed files with 52 additions and 21 deletions

View File

@ -159,7 +159,7 @@ final class Complex
throw new \InvalidArgumentException();
}
public function powComplex() : Complex
public function powComplex(Complex $value) : Complex
{
}
@ -184,7 +184,7 @@ final class Complex
return $this->multComplex($this->powInteger(--$value));
}
public function powScalar() : Complex
public function powScalar($value) : Complex
{
}

View File

@ -26,6 +26,13 @@ namespace phpOMS\Stdlib\Base;
*/
abstract class EnumArray
{
/**
* Constants.
*
* @var array
* @since 1.0.0
*/
protected static $constants = [];
/**
* Checking enum name.

View File

@ -71,7 +71,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
* @param string $path Path
* @param string $filter Filter
*
* @return string[]
* @return array
*
* @since 1.0.0
*/
@ -105,7 +105,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
* @param string $extension Extension
* @param string $exclude Pattern to exclude
*
* @return string[]
* @return array
*
* @since 1.0.0
*/
@ -168,6 +168,10 @@ final class Directory extends FileAbstract implements DirectoryInterface
$countSize = 0;
$directories = \scandir($dir);
if ($directories === false) {
return $countSize;
}
foreach ($directories as $key => $filename) {
if ($filename === ".." || $filename === ".") {
continue;
@ -181,7 +185,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
}
}
return (int) $countSize;
return $countSize;
}
/**
@ -198,6 +202,10 @@ final class Directory extends FileAbstract implements DirectoryInterface
$ignore[] = '.';
$ignore[] = '..';
if ($files === false) {
return $size;
}
foreach ($files as $t) {
if (\in_array($t, $ignore)) {
continue;
@ -221,6 +229,10 @@ final class Directory extends FileAbstract implements DirectoryInterface
{
$files = \scandir($path);
if ($files === false) {
return false;
}
/* Removing . and .. */
unset($files[1]);
unset($files[0]);
@ -260,7 +272,9 @@ final class Directory extends FileAbstract implements DirectoryInterface
}
$created = new \DateTime('now');
$created->setTimestamp(\filemtime($path));
$time = \filemtime($path);
$created->setTimestamp($time === false ? 0 : $time);
return $created;
}
@ -275,7 +289,9 @@ final class Directory extends FileAbstract implements DirectoryInterface
}
$changed = new \DateTime();
$changed->setTimestamp(\filectime($path));
$time = \filectime($path);
$changed->setTimestamp($time === false ? 0 : $time);
return $changed;
}
@ -289,7 +305,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
throw new PathException($path);
}
return \fileowner($path);
return (int) \fileowner($path);
}
/**
@ -301,7 +317,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
throw new PathException($path);
}
return \fileperms($path);
return (int) \fileperms($path);
}
/**

View File

@ -56,7 +56,7 @@ final class File extends FileAbstract implements FileInterface
{
parent::index();
$this->size = \filesize($this->path);
$this->size = (int) \filesize($this->path);
}
/**
@ -98,7 +98,9 @@ final class File extends FileAbstract implements FileInterface
throw new PathException($path);
}
return \file_get_contents($path);
$contents = \file_get_contents($path);
return $contents === false ? '' : $contents;
}
/**
@ -166,7 +168,9 @@ final class File extends FileAbstract implements FileInterface
throw new PathException($path);
}
return self::createFileTime(\filemtime($path));
$time = \filemtime($path);
return self::createFileTime($time === false ? 0 : $time);
}
/**
@ -178,7 +182,9 @@ final class File extends FileAbstract implements FileInterface
throw new PathException($path);
}
return self::createFileTime(\filemtime($path));
$time = \filemtime($path);
return self::createFileTime($time === false ? 0 : $time);
}
/**
@ -207,7 +213,7 @@ final class File extends FileAbstract implements FileInterface
throw new PathException($path);
}
return filesize($path);
return (int) \filesize($path);
}
/**
@ -219,7 +225,7 @@ final class File extends FileAbstract implements FileInterface
throw new PathException($path);
}
return \fileowner($path);
return (int) \fileowner($path);
}
/**
@ -231,7 +237,7 @@ final class File extends FileAbstract implements FileInterface
throw new PathException($path);
}
return \fileperms($path);
return (int) \fileperms($path);
}
/**
@ -245,7 +251,7 @@ final class File extends FileAbstract implements FileInterface
*/
public static function dirname(string $path) : string
{
return basename(\dirname($path));
return \basename(\dirname($path));
}
/**
@ -259,7 +265,7 @@ final class File extends FileAbstract implements FileInterface
*/
public static function dirpath(string $path) : string
{
return dirname($path);
return \dirname($path);
}
/**
@ -267,7 +273,7 @@ final class File extends FileAbstract implements FileInterface
*/
public static function copy(string $from, string $to, bool $overwrite = false) : bool
{
if (!is_file($from)) {
if (!\is_file($from)) {
throw new PathException($from);
}
@ -325,7 +331,7 @@ final class File extends FileAbstract implements FileInterface
*/
public function getDirName() : string
{
return basename(\dirname($this->path));
return \basename(\dirname($this->path));
}
/**
@ -375,7 +381,9 @@ final class File extends FileAbstract implements FileInterface
*/
public function getContent() : string
{
return \file_get_contents($this->path);
$contents = \file_get_contents($this->path);
return $contents === false ? '' : $contents;
}
/**