From 4e0e5e58191cf89e3fc2d90e6c64721f0e952ef1 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 18:45:34 -0400 Subject: [PATCH 01/11] add more phpstan options --- phpstan.dist.neon | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index c275599..595d172 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -1,10 +1,15 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/fadrian06/phpstan/refs/heads/add-schema/schema.json includes: - vendor/phpstan/phpstan/conf/bleedingEdge.neon - phpstan-baseline.neon parameters: + errorFormat: table + excludePaths: + - tests level: 8 paths: - src - - tests - treatPhpDocTypesAsCertain: false + reportIgnoresWithoutComments: true + reportUnmatchedIgnoredErrors: true + treatPhpDocTypesAsCertain: true From 858f49e40843db0eaab8f24d3399b84ca07175c9 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 18:46:45 -0400 Subject: [PATCH 02/11] PHPDoc tag @return has invalid value ($this;): Unexpected token ";", expected TOKEN_HORIZONTAL_WS at offset 145 on line 5 --- src/Auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth.php b/src/Auth.php index 2d4b3ee..08b47e3 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -152,7 +152,7 @@ public function autoConnect(array $pdoOptions = []) * Pass in db connection instance directly * * @param PDO $connection A connection instance of your db - * @return $this; + * @return $this */ public function dbConnection(PDO $connection) { From 9d8e6ec87e5ad95a9acb34701dc5ad01f9af7177 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 18:47:34 -0400 Subject: [PATCH 03/11] Access to an undefined property Leaf\Auth\User::$email. --- src/Auth/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Auth/User.php b/src/Auth/User.php index df6f3ae..9b09627 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -14,6 +14,7 @@ * * @since 3.0.0 * @version 1.0.0 + * @property mixed $email */ class User { From f6196830f59c9b0c7d42977d20a0c5fc47027e3b Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 18:49:08 -0400 Subject: [PATCH 04/11] Negated boolean expression is always false. --- src/Auth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index 08b47e3..fb5fbb3 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -33,9 +33,9 @@ class Auth /** * Internal instance of Leaf DB - * @var Db + * @var ?Db */ - protected $db; + protected $db = null; /** * All errors caught From ab6bf4bb1dee25b38138d9fba92abcd532bf011d Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 18:58:25 -0400 Subject: [PATCH 05/11] Cannot call method select() on Leaf\Db|null. --- src/Auth.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Auth.php b/src/Auth.php index fb5fbb3..9c5c8ca 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -930,6 +930,7 @@ public function db() return $this->db; } + /** @phpstan-assert Db $this->db */ protected function checkDbConnection(): void { if (!$this->db && function_exists('db')) { From d701d243d5af538a4d2117e34976229397473b01 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 19:03:53 -0400 Subject: [PATCH 06/11] Property Leaf\Auth\User::$errorsArray type has no value type specified in iterable type array. --- src/Auth/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth/User.php b/src/Auth/User.php index 9b09627..2a2b106 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -46,7 +46,7 @@ class User /** * All errors caught - * @var array + * @var array */ protected $errorsArray = []; From 08d9b39b82fb82e3545d7e21afcc78fed890f8f2 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 19:06:47 -0400 Subject: [PATCH 07/11] Method Leaf\Auth\User::update() has parameter $userData with no value type specified in iterable type array. --- src/Auth/User.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Auth/User.php b/src/Auth/User.php index 2a2b106..df6aaf1 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -119,7 +119,9 @@ public function id() * --- * Update user data in the database * - * @param array $userData User data + * @param array{ + * email?: string, + * } | array $userData User data * @return bool */ public function update(array $userData): bool From b9d54bd546f2557aafb49e56ff60c591fe15253b Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 19:09:12 -0400 Subject: [PATCH 08/11] Property Leaf\Auth\User::$roles (array) on left side of ?? is not nullable. --- src/Auth/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth/User.php b/src/Auth/User.php index df6aaf1..5bf203c 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -292,7 +292,7 @@ public function getAuthInfo(): object 'refreshToken' => $this->tokens['refresh'] ?? null, ]; - if (count($this->roles ?? [])) { + if (count($this->roles)) { $dataToReturn->roles = $this->roles; } From c4f3fa93c59e05da45e58daa7ed3e9380a44adb7 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 19:09:31 -0400 Subject: [PATCH 09/11] Property Leaf\Auth\User::$permissions (array) on left side of ?? is not nullable. --- src/Auth/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth/User.php b/src/Auth/User.php index 5bf203c..143c15d 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -296,7 +296,7 @@ public function getAuthInfo(): object $dataToReturn->roles = $this->roles; } - if (count($this->permissions ?? [])) { + if (count($this->permissions)) { $dataToReturn->permissions = $this->permissions; } From 0dcba935ef6d1e46aa5dbc416f02944bd1f346d7 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 19:13:26 -0400 Subject: [PATCH 10/11] Method Leaf\Auth\User::errors() return type has no value type specified in iterable type array. --- phpstan.dist.neon | 2 +- src/Auth/User.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 595d172..33c9829 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -12,4 +12,4 @@ parameters: - src reportIgnoresWithoutComments: true reportUnmatchedIgnoredErrors: true - treatPhpDocTypesAsCertain: true + treatPhpDocTypesAsCertain: false diff --git a/src/Auth/User.php b/src/Auth/User.php index 143c15d..75beeb3 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -46,7 +46,9 @@ class User /** * All errors caught - * @var array + * @var array{ + * password?: string, + * } | array */ protected $errorsArray = []; @@ -440,7 +442,9 @@ public function setDb($db) /** * Get user errors - * @return array + * @return array{ + * password?: string, + * } | array */ public function errors() { From 8eb2160336c62f7495529e5d70ff03dd15b14b62 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 21 Jun 2026 19:33:16 -0400 Subject: [PATCH 11/11] save others errors for later --- phpstan-baseline.neon | 472 +----------------------------------------- 1 file changed, 8 insertions(+), 464 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b7260f7..93867b4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,475 +1,19 @@ parameters: ignoreErrors: - - rawMessage: Access to an undefined property Leaf\Auth\User::$email. - identifier: property.notFound + rawMessage: 'Method Leaf\Auth::db() should return Leaf\Db but returns Leaf\Db|null.' + identifier: return.type count: 1 path: src/Auth.php - - rawMessage: 'Variable $credentials in isset() is never defined.' - identifier: isset.variable - count: 2 - path: src/Auth.php - - - - rawMessage: 'Function createTableForUsers() has parameter $table with no type specified.' - identifier: missingType.parameter - count: 1 - path: tests/Pest.php - - - - rawMessage: 'Function deleteUser() has no return type specified.' - identifier: missingType.return - count: 1 - path: tests/Pest.php - - - - rawMessage: 'Function deleteUser() has parameter $table with no type specified.' - identifier: missingType.parameter - count: 1 - path: tests/Pest.php - - - - rawMessage: 'Function getDatabaseConnection() return type has no value type specified in iterable type array.' - identifier: missingType.iterableValue - count: 1 - path: tests/Pest.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::not().' - identifier: method.notFound - count: 1 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBe().' - identifier: method.notFound - count: 4 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeFalse().' - identifier: method.notFound - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeInstanceOf().' - identifier: method.notFound - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeNull().' - identifier: method.notFound - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeString().' - identifier: method.notFound - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeTrue().' - identifier: method.notFound - count: 3 - path: tests/login.test.php - - - - rawMessage: 'Call to method not() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 4 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBeFalse() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBeInstanceOf() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBeNull() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBeNull() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBeString() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to method toBeTrue() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 3 - path: tests/login.test.php - - - - rawMessage: Cannot access property $accessToken on object|null. - identifier: property.nonObject - count: 1 - path: tests/login.test.php - - - - rawMessage: Cannot access property $refreshToken on object|null. - identifier: property.nonObject - count: 1 - path: tests/login.test.php - - - - rawMessage: Cannot access property $username on Leaf\Auth\User|null. - identifier: property.nonObject - count: 2 - path: tests/login.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::not().' - identifier: method.notFound - count: 1 - path: tests/register.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBe().' - identifier: method.notFound - count: 3 - path: tests/register.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeFalse().' - identifier: method.notFound - count: 1 - path: tests/register.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeInstanceOf().' - identifier: method.notFound - count: 2 - path: tests/register.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeTrue().' - identifier: method.notFound - count: 6 - path: tests/register.test.php - - - - rawMessage: 'Call to method not() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/register.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 3 - path: tests/register.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/register.test.php - - - - rawMessage: 'Call to method toBeFalse() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/register.test.php - - - - rawMessage: 'Call to method toBeInstanceOf() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/register.test.php - - - - rawMessage: 'Call to method toBeTrue() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 6 - path: tests/register.test.php - - - - rawMessage: Cannot access property $password on Leaf\Auth\User|null. - identifier: property.nonObject - count: 2 - path: tests/register.test.php - - - - rawMessage: Cannot access property $username on Leaf\Auth\User|null. - identifier: property.nonObject - count: 2 - path: tests/register.test.php - - - - rawMessage: 'Undefined variable: $this' - identifier: variable.undefined - count: 1 - path: tests/register.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::not().' - identifier: method.notFound - count: 1 - path: tests/session.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBe().' - identifier: method.notFound - count: 20 - path: tests/session.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeGreaterThan().' - identifier: method.notFound - count: 1 - path: tests/session.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeInstanceOf().' - identifier: method.notFound - count: 8 - path: tests/session.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeNull().' - identifier: method.notFound - count: 6 - path: tests/session.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeTrue().' - identifier: method.notFound - count: 8 - path: tests/session.test.php - - - - rawMessage: 'Call to method not() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/session.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 20 - path: tests/session.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/session.test.php - - - - rawMessage: 'Call to method toBeGreaterThan() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/session.test.php - - - - rawMessage: 'Call to method toBeInstanceOf() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 8 - path: tests/session.test.php - - - - rawMessage: 'Call to method toBeNull() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 6 - path: tests/session.test.php - - - - rawMessage: 'Call to method toBeTrue() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 8 - path: tests/session.test.php - - - - rawMessage: Cannot access property $username on Leaf\Auth\User|null. - identifier: property.nonObject - count: 6 - path: tests/session.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBe().' - identifier: method.notFound - count: 5 - path: tests/table.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 5 - path: tests/table.test.php - - - - rawMessage: Cannot access offset 'user' on bool. - identifier: offsetAccess.nonOffsetAccessible - count: 3 - path: tests/table.test.php - - - - rawMessage: Cannot access property $username on Leaf\Auth\User|null. - identifier: property.nonObject - count: 2 - path: tests/table.test.php - - - - rawMessage: Function createUsersTable not found. - identifier: function.notFound - count: 1 - path: tests/table.test.php - - - - rawMessage: 'Undefined variable: $this' - identifier: variable.undefined - count: 5 - path: tests/table.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::not().' - identifier: method.notFound - count: 2 - path: tests/update.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBe().' - identifier: method.notFound - count: 3 - path: tests/update.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeFalse().' - identifier: method.notFound - count: 1 - path: tests/update.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeTrue().' - identifier: method.notFound - count: 1 - path: tests/update.test.php - - - - rawMessage: 'Call to method not() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/update.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 3 - path: tests/update.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/update.test.php - - - - rawMessage: 'Call to method toBeFalse() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/update.test.php - - - - rawMessage: 'Call to method toBeTrue() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass + rawMessage: 'Parameter #1 $db of method Leaf\Auth\User::setDb() expects Leaf\Db, Leaf\Db|null given.' + identifier: argument.type count: 1 - path: tests/update.test.php - - - - rawMessage: Cannot access property $username on Leaf\Auth\User|null. - identifier: property.nonObject - count: 2 - path: tests/update.test.php - - - - rawMessage: 'Undefined variable: $this' - identifier: variable.undefined - count: 7 - path: tests/update.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBe().' - identifier: method.notFound - count: 2 - path: tests/user.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeInstanceOf().' - identifier: method.notFound - count: 3 - path: tests/user.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeNull().' - identifier: method.notFound - count: 1 - path: tests/user.test.php - - - - rawMessage: 'Call to an undefined method Pest\Expectation|Pest\Support\Extendable::toBeTrue().' - identifier: method.notFound - count: 2 - path: tests/user.test.php - - - - rawMessage: 'Call to method toBe() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/user.test.php - - - - rawMessage: 'Call to method toBeInstanceOf() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 3 - path: tests/user.test.php - - - - rawMessage: 'Call to method toBeNull() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 1 - path: tests/user.test.php - - - - rawMessage: 'Call to method toBeTrue() of internal class Pest\Expectation from outside its root namespace Pest.' - identifier: method.internalClass - count: 2 - path: tests/user.test.php - - - - rawMessage: Cannot access property $username on Leaf\Auth\User|null. - identifier: property.nonObject - count: 2 - path: tests/user.test.php + path: src/Auth.php - - rawMessage: 'Undefined variable: $this' - identifier: variable.undefined + rawMessage: 'Offset ''status'' might not exist on array|null.' + identifier: offsetAccess.notFound count: 2 - path: tests/user.test.php + path: src/Auth/User.php