Skip to content
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 21 commits into from
Jun 27, 2023
Merged

PHPStan level 9 progress #155

merged 21 commits into from
Jun 27, 2023

Commits on Jun 24, 2023

  1. Get original request in a special service

    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.
     ------ -------------------------------------------------
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    6ad269e View commit details
    Browse the repository at this point in the history
  2. Get exception in the same service

    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.
     ------ -------------------------------------------
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    65eb8cf View commit details
    Browse the repository at this point in the history
  3. Document and check x509parse return array, though not extensively, ju…

    …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.
     ------ ------------------------------------------------------------------------------------------------------------------
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    a2f51dd View commit details
    Browse the repository at this point in the history
  4. Pass individual values to CertificateFactory and validate them with N…

    …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.
     ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    fb4cc4f View commit details
    Browse the repository at this point in the history
  5. Add type to NoOpTranslator

    This was easy, removes this:
    ```
     ------ ------------------------------------------------------------------------------------------------
      Line   app/Test/NoOpTranslator.php
     ------ ------------------------------------------------------------------------------------------------
      36     Method MichalSpacekCz\Test\NoOpTranslator::translate() should return string but returns mixed.
     ------ ------------------------------------------------------------------------------------------------
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    09531a7 View commit details
    Browse the repository at this point in the history
  6. Add type to Nette\Schema validation output

    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.
     ------ ----------------------------------------------------
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    e2ddce8 View commit details
    Browse the repository at this point in the history
  7. Add HttpInput service to get cookies as strings and possibly more in …

    …the future
    
    Right now, `Nette\Http\Request::getCookie()` returns mixed and would require we check for strings all the time
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    6e9af53 View commit details
    Browse the repository at this point in the history
  8. Can remove the test type

    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    ca4edc6 View commit details
    Browse the repository at this point in the history
  9. Get form values from the form, not via params

    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.
     ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    ```
    spaze committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    a548983 View commit details
    Browse the repository at this point in the history

Commits on Jun 25, 2023

  1. Configuration menu
    Copy the full SHA
    79c2cc1 View commit details
    Browse the repository at this point in the history
  2. Make sure we explode strings

    Resolves:
    ```
     ------ -----------------------------------------------------------------------
      Line   app/UpcKeys/Technicolor.php
     ------ -----------------------------------------------------------------------
      88     Parameter #2 $string of function explode expects string, mixed given.
     ------ -----------------------------------------------------------------------
    ```
    spaze committed Jun 25, 2023
    Configuration menu
    Copy the full SHA
    697dd58 View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2023

  1. Configuration menu
    Copy the full SHA
    f4a796e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a3dfcc1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f1a8b3b View commit details
    Browse the repository at this point in the history
  4. Throw specific exception instead of RuntimeException

    This is kinda unrelated but I still like it.
    spaze committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    4ce4239 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    da519cb View commit details
    Browse the repository at this point in the history
  6. Align types in link() in tests

    Fix
    ```
     ------ ---------------------------------------------------------------
      Line   app/Test/Application/ApplicationPresenter.php
     ------ ---------------------------------------------------------------
      38     Parameter #2 $ of closure expects array<string>, array given.
     ------ ---------------------------------------------------------------
    ```
    spaze committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    d7d6499 View commit details
    Browse the repository at this point in the history
  7. Only a string goes to DateTimeImmutable constructor

    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.
     ------ --------------------------------------------------------------------------------------------
    ```
    spaze committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    f8292af View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    51ba665 View commit details
    Browse the repository at this point in the history
  9. Let PHPStan know that updating the row may throw an exception

    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.
    spaze committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    c3d3f15 View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2023

  1. Ensure the input value is a string

    Don't care if not because it's gonna be a string, trust me.
    spaze committed Jun 27, 2023
    Configuration menu
    Copy the full SHA
    f30c4ef View commit details
    Browse the repository at this point in the history