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

ci: Add PHPStan check #1409

Merged
merged 10 commits into from
Feb 9, 2023
Merged

ci: Add PHPStan check #1409

merged 10 commits into from
Feb 9, 2023

Commits on Feb 8, 2023

  1. Configuration menu
    Copy the full SHA
    db92814 View commit details
    Browse the repository at this point in the history
  2. Add type hints

    Had to disable php-cs-fixer phpdoc rules since it would try to add invalid typehints.
    jtojnar committed Feb 8, 2023
    Configuration menu
    Copy the full SHA
    271577a View commit details
    Browse the repository at this point in the history

Commits on Feb 9, 2023

  1. daos: Make nullability explicit

    All three supported database engines will return `null` PHP value for a `NULL` value in database.
    Previously all ensured values would be cast to the expected type (except for `DateTime` which had a special case for `NULL`), possibly replacing `NULL` value with 0 or other incorrect value.
    Let’s make the `null` part of the “type system” using binary or.
    It will also be useful once we start adding return type hints for daos methods.
    
    ----
    
    ```php
    $c = $dice->create(helpers\DatabaseConnection::class);
    $v = $c->exec('select NULL as "null", 42 as "int", 3.14 as "decimal", CURRENT_TIMESTAMP as "timestamp", \'test\' as "string", true as "true", false as "false";');
    var_dump($v);
    ```
    
    ## PHP 8.2
    ### SQLite
    ```php
    array(1) {
      [0]=>
      array(7) {
        ["null"]=>
        NULL
        ["int"]=>
        int(42)
        ["decimal"]=>
        float(3.14)
        ["timestamp"]=>
        string(19) "2023-02-08 23:07:00"
        ["string"]=>
        string(4) "test"
        ["true"]=>
        int(1)
        ["false"]=>
        int(0)
      }
    }
    ```
    
    ### MariaDB 10.6.11
    ```php
    array(1) {
      [0]=>
      array(7) {
        ["null"]=>
        NULL
        ["int"]=>
        int(42)
        ["decimal"]=>
        string(4) "3.14"
        ["timestamp"]=>
        string(19) "2023-02-09 00:06:47"
        ["string"]=>
        string(4) "test"
        ["true"]=>
        int(1)
        ["false"]=>
        int(0)
      }
    }
    ```
    
    ### PostgreSQL 14.6
    ```php
    array(1) {
      [0]=>
      array(7) {
        ["null"]=>
        NULL
        ["int"]=>
        int(42)
        ["decimal"]=>
        string(4) "3.14"
        ["timestamp"]=>
        string(29) "2023-02-08 23:06:57.433412+00"
        ["string"]=>
        string(4) "test"
        ["true"]=>
        bool(true)
        ["false"]=>
        bool(false)
      }
    }
    ```
    
    ## PHP 7.2
    ### SQLite
    ```php
    array(1) {
      [0]=>
      array(7) {
        ["null"]=>
        NULL
        ["int"]=>
        string(2) "42"
        ["decimal"]=>
        string(4) "3.14"
        ["timestamp"]=>
        string(19) "2023-02-08 23:23:54"
        ["string"]=>
        string(4) "test"
        ["true"]=>
        string(1) "1"
        ["false"]=>
        string(1) "0"
      }
    }
    ```
    
    ### MariaDB 10.6.11
    ```php
    array(1) {
      [0]=>
      array(7) {
        ["null"]=>
        NULL
        ["int"]=>
        string(2) "42"
        ["decimal"]=>
        string(4) "3.14"
        ["timestamp"]=>
        string(19) "2023-02-09 00:24:33"
        ["string"]=>
        string(4) "test"
        ["true"]=>
        string(1) "1"
        ["false"]=>
        string(1) "0"
      }
    }
    ```
    
    ### PostgreSQL 14.6
    ```php
    array(1) {
      [0]=>
      array(7) {
        ["null"]=>
        NULL
        ["int"]=>
        int(42)
        ["decimal"]=>
        string(4) "3.14"
        ["timestamp"]=>
        string(29) "2023-02-08 23:24:30.032842+00"
        ["string"]=>
        string(4) "test"
        ["true"]=>
        bool(true)
        ["false"]=>
        bool(false)
      }
    }
    ```
    jtojnar committed Feb 9, 2023
    Configuration menu
    Copy the full SHA
    57bf6e8 View commit details
    Browse the repository at this point in the history
  2. Avoid auxiliary static::$stmt variable

    It is not needed since PHP 7.0.
    jtojnar committed Feb 9, 2023
    Configuration menu
    Copy the full SHA
    ec53c94 View commit details
    Browse the repository at this point in the history
  3. Enable strict typing

    jtojnar committed Feb 9, 2023
    Configuration menu
    Copy the full SHA
    d9d6b37 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b2f2a18 View commit details
    Browse the repository at this point in the history
  5. Fix some PHPStan issues

    Up to level 5.
    jtojnar committed Feb 9, 2023
    Configuration menu
    Copy the full SHA
    e6c3f08 View commit details
    Browse the repository at this point in the history
  6. ci: Add PHPStan check

    jtojnar committed Feb 9, 2023
    Configuration menu
    Copy the full SHA
    cbba90d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    17ecff9 View commit details
    Browse the repository at this point in the history
  8. Initial fixes for raising PHPStan level to 6

    Will still require more work on filling in array item types.
    jtojnar committed Feb 9, 2023
    Configuration menu
    Copy the full SHA
    e88cb72 View commit details
    Browse the repository at this point in the history