]> git.joonet.de Git - adminer.git/commitdiff
PHPStan: Check level 8 without level 7
authorJakub Vrana <jakub@vrana.cz>
Wed, 26 Mar 2025 20:16:14 +0000 (21:16 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 26 Mar 2025 20:54:17 +0000 (21:54 +0100)
developing.md
phpstan.neon

index ecccf1d4e3cda6bc971f650897f8c89b1d1ce8f4..160b125a0926b9033efe20ed2f169caa1a113124 100644 (file)
@@ -81,11 +81,11 @@ All functions have doc-comments, but redundancy is avoided. For example, `Db` me
 
 Inline comments are useful for linking specifications but are generally avoided for explaining self-explanatory code. They start with a lowercase letter and do not end with a period, though I am not entirely happy with this convention.
 
-Comments starting with `//!` mean TODO.
+Comments starting with `//!` mean TODO. Comments starting with `//~` are meant for debugging.
 
 ## Error Handling
 
-Adminer strictly initializes all variables before use, which is [verified](https://github.com/vrana/php-initialized). However, Adminer relies on the default value of uninitialized array items. This approach leads to more readable code. Consider the following examples:
+Adminer strictly initializes all variables before use, which is [verified](/phpstan.neon). However, Adminer relies on the default value of uninitialized array items. This approach leads to more readable code. Consider the following examples:
 
 ```php
 // Adminer style
@@ -110,7 +110,7 @@ function idx($array, $key, $default = null) {
 }
 ```
 
-Although it would be possible to use such a function in Adminer, the code would still be less readable than the current approach. Using `isset` can introduce bugs, such as in this case: `isset($rw["name"])`. Here, I intended to check if `$row` contains `name`, but a typo in the variable name is silently ignored. `empty()` is even worse and should be avoided in most cases.
+Although it would be possible to use such a function in Adminer, the code would still be less readable than the current approach. Using `isset` can introduce bugs, such as in this case: `isset($rw["name"])`. Here, I intended to check if `$row` contains `name`, but a typo in the variable name is silently ignored. The same is true for `??`. `empty()` is even worse and should be avoided in most cases.
 
 Adminer uses `@` only where an error is unavoidable, such as when writing to files. Even if you check whether a file is writable, a race condition exists between the check and the actual write operation.
 
index f6527337bff6fafeee2480f487e84b172aee0a39..ea25c2b0970b07bb78d37065ef975a454be93333 100644 (file)
@@ -1,12 +1,13 @@
 parameters:
        level: 6
-       
+       checkNullables: true # level 8
+
        ignoreErrors:
                # need to fix
                - "~^Function Adminer\\\\fields_from_edit\\(\\) should return~" # Mongo and SimpleDB
                - "~Adminer\\\\Result.*mysqli_result~" # mysqli_result
                - "~expects array~" # different shape of array
-               
+
                # not real problems
                - identifier: include.fileNotFound # relative includes
                - identifier: includeOnce.fileNotFound # ./adminer-plugins.php
@@ -39,12 +40,13 @@ parameters:
                - identifier: while.alwaysTrue
                - identifier: isset.offset
                - identifier: deadCode.unreachable
-               
+
        paths:
                - adminer/
        scanFiles:
                - compile.php # compile_file()
        excludePaths:
+               - adminer/adminer-plugins.php
                - adminer/designs.php
                - adminer/elastic.php
                - adminer/sqlite.php
@@ -52,11 +54,11 @@ parameters:
                - adminer/drivers/oracle.inc.php
                - adminer/drivers/pgsql.inc.php
                - adminer/drivers/sqlite.inc.php
-       
+
        phpVersion:
                min: 70100
                max: 80499
-               
+
        typeAliases:
                TableStatus: "array{Name:string, Engine?:?string, Comment?:string, Oid?:numeric-string, Rows?:?numeric-string, Collation?:string, Auto_increment?:?numeric-string, Data_length?:numeric-string, Index_length?:numeric-string, Data_free?:numeric-string, Create_options?:string, nspname?:string}"
                Field: "array{field:?string, full_type:string, type:string, length:numeric-string, unsigned:string, default:?string, null:bool, auto_increment:bool, collation:string, privileges:int[], comment:string, primary:bool, generated:string, orig?:string, on_update:?string, on_delete?:string, inout?:string}"