markrogoyski / math-php

Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
MIT License
2.32k stars 238 forks source link

PHPdoc annotations added, phpstan works without errors now #465

Closed Smoren closed 1 year ago

Smoren commented 1 year ago

Hi @markrogoyski,

I wrote PHPdoc annotations for library components.

Now PHPstan works without errors.

In some places, I needed to slightly modify the code (mainly typecasting).

Places that I considered controversial, I marked FIXME in the comments. Look, please, these places especially attentively.

I hope this work will be useful for the library and its users.

coveralls commented 1 year ago

Coverage Status

Coverage: 99.924% (+0.004%) from 99.92% when pulling 62eb4a8dbe7297a6f19115bd374255e2beea676d on Smoren:phpstan into 7795af2a20cc24af11766c56356fe003689a9ede on markrogoyski:develop.

markrogoyski commented 1 year ago

Hi @Smoren,

Wow, thank you for the PR and adding meta data annotations for types and such. This was a long term goal of mine to get the static analysis suggestions implemented from PHPStan.

This is a large PR with a lot of changes, so give me some time to review it. Glancing at it it looks like good stuff.

Just curious, what version of PHP and version of PHPStan did you use for testing?

Thanks again! Mark

Smoren commented 1 year ago

Hi @markrogoyski,

PHP 7.4.33 (cli) (built: Jan 13 2023 10:42:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
    with Xdebug v3.1.6, Copyright (c) 2002-2022, by Derick Rethans
Smoren commented 1 year ago

BTW, also pay attention to the places where I had to use @phpstan-ignore-next-line. Maybe you can figure out how to avoid using it in some places. I used this operator only in the most extreme cases.

Smoren commented 1 year ago

Hi @markrogoyski,

This branch is rebased from develop and added tasks for static analisys to workflows. Fixed several PHPstan errors for PHP 8+.

Now PHPstan succeed for PHP versions from 7.2 to 8.2.

markrogoyski commented 1 year ago

@Smoren,

Thank you for your hard work adding all the type annotations and comments to provide better static analysis during development!

Smoren commented 1 year ago

Thank you @markrogoyski for merging this PR!