fixing phpstan errors

This commit is contained in:
Dennis Eichhorn 2022-09-27 18:08:15 +02:00
parent 9e60c0e552
commit d245e8d184
21 changed files with 53 additions and 32 deletions

View File

@ -64,7 +64,17 @@ class Neuron
$this->bias = $bias; $this->bias = $bias;
} }
public function addInput($input, float $weight) : void /**
* Add neuron input
*
* @param mixed $input Input
* @param float $weight Weight of input
*
* @return void
*
* @since 1.0.0
*/
public function addInput(mixed $input, float $weight) : void
{ {
$this->inputs[] = $input; $this->inputs[] = $input;
$this->weights[] = $weight; $this->weights[] = $weight;

View File

@ -36,5 +36,5 @@ interface RenderableInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string; public function render(mixed ...$data) : string;
} }

View File

@ -422,5 +422,5 @@ abstract class DataMapperAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
abstract public function execute(...$options) : mixed; abstract public function execute(mixed ...$options) : mixed;
} }

View File

@ -49,7 +49,7 @@ final class DeleteMapper extends DataMapperAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function execute(...$options) : mixed public function execute(mixed ...$options) : mixed
{ {
switch($this->type) { switch($this->type) {
case MapperType::DELETE: case MapperType::DELETE:

View File

@ -136,7 +136,7 @@ final class ReadMapper extends DataMapperAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function execute(...$options) : mixed public function execute(mixed ...$options) : mixed
{ {
switch($this->type) { switch($this->type) {
case MapperType::GET: case MapperType::GET:
@ -577,7 +577,7 @@ final class ReadMapper extends DataMapperAbstract
$refProp->setValue($obj, $value); $refProp->setValue($obj, $value);
} elseif (\in_array($def['type'], ['string', 'compress', 'int', 'float', 'bool'])) { } elseif (\in_array($def['type'], ['string', 'compress', 'int', 'float', 'bool'])) {
if ($value !== null && $def['type'] === 'compress') { if ($value !== null && $def['type'] === 'compress') {
$def['type'] = 'string'; $def['type'] = 'string';
$value = \gzinflate($value); $value = \gzinflate($value);
} }

View File

@ -51,7 +51,7 @@ final class UpdateMapper extends DataMapperAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function execute(...$options) : mixed public function execute(mixed ...$options) : mixed
{ {
switch($this->type) { switch($this->type) {
case MapperType::UPDATE: case MapperType::UPDATE:

View File

@ -52,7 +52,7 @@ final class WriteMapper extends DataMapperAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function execute(...$options) : mixed public function execute(mixed ...$options) : mixed
{ {
switch($this->type) { switch($this->type) {
case MapperType::CREATE: case MapperType::CREATE:

View File

@ -279,7 +279,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function select(...$columns) : self public function select(mixed ...$columns) : self
{ {
$this->type = QueryType::SELECT; $this->type = QueryType::SELECT;
@ -323,7 +323,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function random(...$columns) : self public function random(mixed ...$columns) : self
{ {
$this->select(...$columns); $this->select(...$columns);
@ -498,7 +498,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function from(...$tables) : self public function from(mixed ...$tables) : self
{ {
/** @var mixed[] $tables */ /** @var mixed[] $tables */
/** @var mixed $table */ /** @var mixed $table */
@ -665,7 +665,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function groupBy(...$columns) : self public function groupBy(mixed ...$columns) : self
{ {
/** @var mixed[] $columns */ /** @var mixed[] $columns */
/** @var mixed $column */ /** @var mixed $column */
@ -908,7 +908,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function insert(...$columns) : self public function insert(mixed ...$columns) : self
{ {
if ($this->isReadOnly) { if ($this->isReadOnly) {
throw new \Exception(); throw new \Exception();
@ -948,7 +948,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function values(...$values) : self public function values(mixed ...$values) : self
{ {
$this->values[] = $values; $this->values[] = $values;
@ -1003,7 +1003,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function sets(...$sets) : self public function sets(mixed ...$sets) : self
{ {
$this->sets[$sets[0]] = $sets[1] ?? null; $this->sets[$sets[0]] = $sets[1] ?? null;
@ -1037,7 +1037,7 @@ class Builder extends BuilderAbstract
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function update(...$tables) : self public function update(mixed ...$tables) : self
{ {
if ($this->isReadOnly) { if ($this->isReadOnly) {
throw new \Exception(); throw new \Exception();

View File

@ -62,7 +62,7 @@ final class Dispatcher implements DispatcherInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dispatch(array | string | \Closure $controller, ...$data) : array public function dispatch(array | string | \Closure $controller, mixed ...$data) : array
{ {
$views = []; $views = [];
$data = \array_values($data); $data = \array_values($data);

View File

@ -28,7 +28,7 @@ interface DispatcherInterface
* Dispatch controller. * Dispatch controller.
* *
* @param array|\Closure|string $controller Controller * @param array|\Closure|string $controller Controller
* @param null|array|mixed ...$data Data * @param mixed ...$data Data
* *
* @return array Returns array of all dispatched results * @return array Returns array of all dispatched results
* *
@ -36,5 +36,5 @@ interface DispatcherInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function dispatch(array | string | \Closure $controller, ...$data) : array; public function dispatch(array | string | \Closure $controller, mixed ...$data) : array;
} }

View File

@ -70,7 +70,7 @@ final class EventManager implements \Countable
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dispatch(array | string | \Closure $func, ...$data) : array public function dispatch(array | string | \Closure $func, mixed ...$data) : array
{ {
if (!($func instanceof \Closure)) { if (!($func instanceof \Closure)) {
return []; return [];

View File

@ -85,7 +85,7 @@ final class Triangle implements D2ShapeInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function getHypot(...$vec) : float public static function getHypot(mixed ...$vec) : float
{ {
$hypot = 0.0; $hypot = 0.0;
foreach ($vec as $val) { foreach ($vec as $val) {

View File

@ -105,7 +105,7 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
$types = $this->header->get('Content-Type'); $types = $this->header->get('Content-Type');

View File

@ -108,7 +108,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
$types = $this->header->get('Content-Type'); $types = $this->header->get('Content-Type');
foreach ($types as $type) { foreach ($types as $type) {

View File

@ -90,7 +90,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
$types = $this->header->get('Content-Type'); $types = $this->header->get('Content-Type');

View File

@ -140,7 +140,7 @@ final class Head implements RenderableInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
$head = ''; $head = '';
$head .= $this->meta->render(); $head .= $this->meta->render();

View File

@ -227,7 +227,7 @@ final class Meta implements RenderableInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
return (\count($this->keywords) > 0 ? '<meta name="keywords" content="' . ViewAbstract::html(\implode(',', $this->keywords)) . '">' : '') return (\count($this->keywords) > 0 ? '<meta name="keywords" content="' . ViewAbstract::html(\implode(',', $this->keywords)) . '">' : '')
. (!empty($this->author) ? '<meta name="author" content="' . ViewAbstract::html($this->author) . '">' : '') . (!empty($this->author) ? '<meta name="author" content="' . ViewAbstract::html($this->author) . '">' : '')

View File

@ -260,12 +260,22 @@ abstract class ViewAbstract implements RenderableInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
return $this->renderTemplate($this->template, ...$data); return $this->renderTemplate($this->template, ...$data);
} }
protected function renderTemplate(string $template, ...$data) : string /**
* Render a template file
*
* @param string $template Template path
* @param mixed ...$data Data to pass to renderer
*
* @return string
*
* @since 1.0.0
*/
protected function renderTemplate(string $template, mixed ...$data) : string
{ {
$ob = ''; $ob = '';
@ -310,7 +320,7 @@ abstract class ViewAbstract implements RenderableInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function build(...$data) : mixed public function build(mixed ...$data) : mixed
{ {
$ob = ''; $ob = '';

View File

@ -218,7 +218,7 @@ final class HttpResponseTest extends \PHPUnit\Framework\TestCase
public function testMinimizedRender() : void public function testMinimizedRender() : void
{ {
$this->response->set('view', new class() extends \phpOMS\Views\View { $this->response->set('view', new class() extends \phpOMS\Views\View {
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
return " view_string with <div> text</div> that has \n whitespaces and \n\nnew lines\n "; return " view_string with <div> text</div> that has \n whitespaces and \n\nnew lines\n ";
} }
@ -236,7 +236,7 @@ final class HttpResponseTest extends \PHPUnit\Framework\TestCase
public function testInvalidMinimizedRender() : void public function testInvalidMinimizedRender() : void
{ {
$this->response->set('view', new class() extends \phpOMS\Views\View { $this->response->set('view', new class() extends \phpOMS\Views\View {
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
return " view_string with <div> text</div> that has \n whitespaces and \n\nnew lines\n "; return " view_string with <div> text</div> that has \n whitespaces and \n\nnew lines\n ";
} }

View File

@ -160,7 +160,7 @@ final class StringUtilsTest extends \PHPUnit\Framework\TestCase
})); }));
self::assertEquals('abc', StringUtils::stringify(new class() implements RenderableInterface { self::assertEquals('abc', StringUtils::stringify(new class() implements RenderableInterface {
public function render(...$data) : string public function render(mixed ...$data) : string
{ {
return 'abc'; return 'abc';
} }

View File

@ -25,6 +25,7 @@
<exclude>./vendor</exclude> <exclude>./vendor</exclude>
<exclude>./Build</exclude> <exclude>./Build</exclude>
<exclude>./Resources</exclude> <exclude>./Resources</exclude>
<directory>./Application/Testapp*</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<groups> <groups>