-
Notifications
You must be signed in to change notification settings - Fork 2
Modernize code #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: support-php-85
Are you sure you want to change the base?
Modernize code #63
Conversation
Errors like: - Deprecated: ipl\Stdlib\Str::trimSplit(): Implicitly marking parameter $limit as nullable is deprecated, the explicit nullable type must be used instead
52f1357 to
415ad2b
Compare
4bc935f to
422c34e
Compare
BastianLedererIcinga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type of BaseFilter::setBaseFilter can be changed to static.
- #62 makes it superfluous for github actions
01fc4fa to
2030a2d
Compare
src/Filter.php
Outdated
| * @return Condition | ||
| */ | ||
| public static function equal($column, $value) | ||
| public static function equal(string $column, array|bool|float|int|string|DateTime|null $value): Condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the param types for $value. The phpDoc is fine.
Please remove this from other methods where DateTime can be specified as a parameter.
src/Filter.php
Outdated
| if (! $rule instanceof Equal && ! $rule instanceof Unequal) { | ||
| throw new InvalidArgumentException(sprintf( | ||
| 'Rule must be of type %s or %s, got %s instead', | ||
| Equal::class, | ||
| Unequal::class, | ||
| get_php_type($rule) | ||
| )); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed now.
src/Filter.php
Outdated
| if (! $rule instanceof Like && ! $rule instanceof Unlike) { | ||
| throw new InvalidArgumentException(sprintf( | ||
| 'Rule must be of type %s or %s, got %s instead', | ||
| Like::class, | ||
| Unlike::class, | ||
| get_php_type($rule) | ||
| )); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is superfluous and can be removed now.
src/Filter.php
Outdated
| switch (true) { | ||
| case $rule instanceof All: | ||
| return $this->matchAll($rule, $row); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use match() instead of switch() and then remove the default case.
PhpUnit Test:
```
- 1 test triggered 2 PHP warnings:
1) /home/runner/work/ipl-stdlib/ipl-stdlib/src/Filter.php:540
Undefined property: stdClass::$foo
Triggered by:
* ipl\Tests\Stdlib\FilterTest::testConditionsHandleMissingColumnsProperly (6 times)
/home/runner/work/ipl-stdlib/ipl-stdlib/tests/FilterTest.php:624
...
```
properties, parameters and returntypes
extended in ipl/Sql/Filter/...
In, NotIn, Exists, NotExists
implemented in ipl/Sql/Filter/...
In, NotIn, Exists, NotExists
prevent the error:
Typed property
Icinga\Module\Icingadb\Widget\Detail\ObjectStatistics::$baseFilter
must not be accessed before initialization
e.g. ipl\Html\FormElement::addElementLoader() allows to call the method with null
Depends on removing the ipl\Sql\Filter\InAndNotInUtils trait
removing parameter uniontypes & unnecessary typechecking, change switch to match
5c7ad36 to
0e8fbc5
Compare
6408fa8 to
d67ed2a
Compare
No description provided.