-
Notifications
You must be signed in to change notification settings - Fork 5
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
PHPStan level 9 progress #155
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resolves these errors: ``` ------ ------------------------------------------------- Line app/Www/Presenters/ErrorPresenter.php ------ ------------------------------------------------- 76 Cannot call method getParameter() on mixed. 76 Cannot call method getPresenterName() on mixed. 91 Cannot call method getParameters() on mixed. ------ ------------------------------------------------- ```
Resolves these errors: ``` ------ ------------------------------------------- Line app/Www/Presenters/BaseErrorPresenter.php ------ ------------------------------------------- 58 Cannot call method getCode() on mixed. 58 Cannot call method getFile() on mixed. 58 Cannot call method getLine() on mixed. 58 Cannot call method getMessage() on mixed. ------ ------------------------------------------- ```
…st what's needed at the moment Resolves these errors: ``` ------ ------------------------------------------------------------------------------------------------------------------ Line app/Tls/CertificateFactory.php ------ ------------------------------------------------------------------------------------------------------------------ 50 Cannot access offset 'commonName' on mixed. 50 Parameter #1 $commonName of class MichalSpacekCz\Tls\Certificate constructor expects string, mixed given. 52 Cannot cast mixed to string. 53 Cannot cast mixed to string. 55 Parameter #6 $serialNumber of class MichalSpacekCz\Tls\Certificate constructor expects string|null, mixed given. ------ ------------------------------------------------------------------------------------------------------------------ ```
…ette\Schema Resolves ``` ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Line app/Tls/CertificatesApiClient.php ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 69 Parameter #1 $details of method MichalSpacekCz\Tls\CertificateFactory::fromArray() expects array{commonName: string, commonNameExt: string|null, notBefore: string, notBeforeTz: string, notAfter: string, notAfterTz: string, expiringThreshold: int, serialNumber: string|null, ...}, mixed given. ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ```
This was easy, removes this: ``` ------ ------------------------------------------------------------------------------------------------ Line app/Test/NoOpTranslator.php ------ ------------------------------------------------------------------------------------------------ 36 Method MichalSpacekCz\Test\NoOpTranslator::translate() should return string but returns mixed. ------ ------------------------------------------------------------------------------------------------ ```
This is sort of a duplication of what's already defined in the schema but here we are. Solves these: ``` ------ ---------------------------------------------------- Line app/Pulse/Passwords/AlgorithmAttributesFactory.php ------ ---------------------------------------------------- 37 Cannot access property $inner on mixed. 37 Cannot access property $outer on mixed. 37 Cannot access property $params on mixed. ------ ---------------------------------------------------- ```
…the future Right now, `Nette\Http\Request::getCookie()` returns mixed and would require we check for strings all the time
Currently, `$form->onValidate` and `$form->onSuccess` types for `$values` are specified as `mixed` and the type in the callbacks cannot be narrower as seen in errors like: ``` ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Line app/Form/TrainingApplicationAdminFormFactory.php ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 96 Property Nette\Forms\Form::$onSuccess (array<callable(Nette\Application\UI\Form, mixed): void>) does not accept non-empty-array<(callable(Nette\Application\UI\Form, mixed): void)|(Closure(Nette\Application\UI\Form, stdClass): void)>. 💡 Type stdClass of parameter #2 $values of passed callable needs to be same or wider than parameter type mixed of accepting callable. ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ```
Resolves: ``` ------ ----------------------------------------------------------------------- Line app/UpcKeys/Technicolor.php ------ ----------------------------------------------------------------------- 88 Parameter #2 $string of function explode expects string, mixed given. ------ ----------------------------------------------------------------------- ```
This is kinda unrelated but I still like it.
Fix ``` ------ --------------------------------------------------------------- Line app/Test/Application/ApplicationPresenter.php ------ --------------------------------------------------------------- 38 Parameter #2 $ of closure expects array<string>, array given. ------ --------------------------------------------------------------- ```
Fixes these errors: ``` ------ -------------------------------------------------------------------------------------------- Line app/Training/Dates/TrainingDatesFormValidator.php ------ -------------------------------------------------------------------------------------------- 18 Parameter #1 $datetime of class DateTimeImmutable constructor expects string, mixed given. 19 Parameter #1 $datetime of class DateTimeImmutable constructor expects string, mixed given. ------ -------------------------------------------------------------------------------------------- ```
It was either PhpStorm complaining that the right part of `$slideNumber ?? ...` is useless, or PHPStan complaining that "Cannot access property $number on mixed." Or both.
Don't care if not because it's gonna be a string, trust me.
Closed
This was referenced Jul 1, 2023
spaze
added a commit
that referenced
this pull request
Jul 2, 2023
…ust Exception Introduced somewhere in #155
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From 84 errors down to 25.
For #147