diff --git a/app/Console/Commands/LdapTroubleshooter.php b/app/Console/Commands/LdapTroubleshooter.php index 6921e46499..7183dc3c75 100644 --- a/app/Console/Commands/LdapTroubleshooter.php +++ b/app/Console/Commands/LdapTroubleshooter.php @@ -27,7 +27,7 @@ function ip_in_range($ip, $range) $wildcard_decimal = pow(2, (32 - $netmask)) - 1; $netmask_decimal = ~$wildcard_decimal; - return ($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal); + return ($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal); } // NOTE - this function was shamelessly stolen from this gist: https://gist.github.com/tott/7684443 @@ -170,7 +170,7 @@ class LdapTroubleshooter extends Command $output[] = '-D '.escapeshellarg($settings->ldap_uname); try { - $w = Crypt::Decrypt($settings->ldap_pword); + $w = Crypt::decrypt($settings->ldap_pword); } catch (Exception $e) { $this->warn('Could not decrypt password. This usually means an LDAP password was not set or the APP_KEY was changed since the LDAP pasword was last saved. Aborting.'); exit(0); @@ -384,7 +384,7 @@ class LdapTroubleshooter extends Command $this->line('STAGE 4: Test Administrative Bind for LDAP Sync'); foreach ($ldap_urls as $ldap_url) { try { - $w = Crypt::Decrypt($settings->ldap_pword); + $w = Crypt::decrypt($settings->ldap_pword); } catch (Exception $e) { $this->warn('Could not decrypt password. This usually means an LDAP password was not set or the APP_KEY was changed since the LDAP pasword was last saved. Aborting.'); exit(0); @@ -405,7 +405,7 @@ class LdapTroubleshooter extends Command foreach ($ldap_urls as $ldap_url) { try { - $w = Crypt::Decrypt($settings->ldap_pword); + $w = Crypt::decrypt($settings->ldap_pword); } catch (Exception $e) { $this->warn('Could not decrypt password. This usually means an LDAP password was not set or the APP_KEY was changed since the LDAP pasword was last saved. Aborting.'); exit(0); diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 06f9ab9e99..3ba06090b7 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -65,7 +65,15 @@ class ResetPasswordController extends Controller $credentials = $request->only('email', 'token'); - if (is_null($this->broker()->getUser($credentials))) { + // Password::broker() is typed to return the interface + // Illuminate\Contracts\Auth\PasswordBroker, which doesn't + // declare getUser(). The concrete Illuminate\Auth\Passwords\ + // PasswordBroker does. Narrow the type locally so PHPStan can + // resolve the method against the concrete class. + /** @var \Illuminate\Auth\Passwords\PasswordBroker $broker */ + $broker = $this->broker(); + + if (is_null($broker->getUser($credentials))) { Log::debug('Password reset form FAILED - this token is not valid.'); return redirect()->route('password.request')->with('error', trans('passwords.token')); diff --git a/app/Models/Labels/RectangleSheet.php b/app/Models/Labels/RectangleSheet.php index e5dd0cb8fd..b44e5d6641 100644 --- a/app/Models/Labels/RectangleSheet.php +++ b/app/Models/Labels/RectangleSheet.php @@ -19,16 +19,22 @@ abstract class RectangleSheet extends Sheet abstract public function getRows(); /** - * Returns the spacing between columns + * Returns the spacing between columns. Docblock only (no PHP + * native return type) so subclasses that don't declare return + * types stay compatible. Widened from int to int|float because + * some sheet layouts (Hema/_14130046, Hema/_38310012) define + * fractional spacings (2.0, 3.0, 4.0 mm) that would round + * incorrectly if coerced to int. * - * @return int + * @return int|float */ abstract public function getLabelColumnSpacing(); /** - * Returns the spacing between rows + * Returns the spacing between rows. See getLabelColumnSpacing for + * the int|float rationale. * - * @return int + * @return int|float */ abstract public function getLabelRowSpacing(); diff --git a/app/Notifications/WelcomeNotification.php b/app/Notifications/WelcomeNotification.php index 76c070246e..aa1398a93b 100644 --- a/app/Notifications/WelcomeNotification.php +++ b/app/Notifications/WelcomeNotification.php @@ -23,7 +23,15 @@ class WelcomeNotification extends Notification */ public function __construct(public User $user) { - $this->user->token = Password::broker('invites')->createToken($user); + // Password::broker() is typed to return the interface + // Illuminate\Contracts\Auth\PasswordBroker, which doesn't + // declare createToken(). The concrete Illuminate\Auth\Passwords\ + // PasswordBroker does. Narrow the type locally so PHPStan can + // resolve the method against the concrete class. + /** @var \Illuminate\Auth\Passwords\PasswordBroker $broker */ + $broker = Password::broker('invites'); + + $this->user->token = $broker->createToken($user); $this->user->expire_date = now()->addMinutes((int) config('auth.passwords.invites.expire', 2880))->format('F j, Y, g:i a'); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a752a90693..6ca560d5a3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7752,18 +7752,6 @@ parameters: count: 4 path: app/Models/Group.php - - - message: '#^Method App\\Models\\Labels\\DefaultLabel\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/DefaultLabel.php - - - - message: '#^Method App\\Models\\Labels\\DefaultLabel\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/DefaultLabel.php - - message: '#^Access to an undefined property App\\Models\\Asset\:\:\$assigned\.$#' identifier: property.notFound @@ -7890,18 +7878,6 @@ parameters: count: 1 path: app/Models/Labels/Sheet.php - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L4736\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L4736.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L4736\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L4736.php - - message: '#^Constant App\\Models\\Labels\\Sheets\\Avery\\L4736_A\:\:LABEL_MARGIN is unused\.$#' identifier: classConstant.unused @@ -7914,18 +7890,6 @@ parameters: count: 1 path: app/Models/Labels/Sheets/Avery/L4736_A.php - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L6009\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L6009.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L6009\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L6009.php - - message: '#^Constant App\\Models\\Labels\\Sheets\\Avery\\L6009_A\:\:LABEL_MARGIN is unused\.$#' identifier: classConstant.unused @@ -7938,66 +7902,18 @@ parameters: count: 1 path: app/Models/Labels/Sheets/Avery/L6009_A.php - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L7162\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L7162.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L7162\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L7162.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L7163\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L7163.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\L7163\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/L7163.php - - message: '#^Constant App\\Models\\Labels\\Sheets\\Avery\\L7163_A\:\:LABEL_MARGIN is unused\.$#' identifier: classConstant.unused count: 1 path: app/Models/Labels/Sheets/Avery/L7163_A.php - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\_3490\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/_3490.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\_3490\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/_3490.php - - message: '#^Constant App\\Models\\Labels\\Sheets\\Avery\\_3490_A\:\:TAG_SIZE is unused\.$#' identifier: classConstant.unused count: 1 path: app/Models/Labels/Sheets/Avery/_3490_A.php - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\_5267\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/_5267.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\_5267\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/_5267.php - - message: '#^Constant App\\Models\\Labels\\Sheets\\Avery\\_5267_A\:\:FIELD_MARGIN is unused\.$#' identifier: classConstant.unused @@ -8010,18 +7926,6 @@ parameters: count: 1 path: app/Models/Labels/Sheets/Avery/_5267_A.php - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\_5520\:\:getLabelColumnSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/_5520.php - - - - message: '#^Method App\\Models\\Labels\\Sheets\\Avery\\_5520\:\:getLabelRowSpacing\(\) should return int but returns float\.$#' - identifier: return.type - count: 1 - path: app/Models/Labels/Sheets/Avery/_5520.php - - message: '#^Constant App\\Models\\Labels\\Sheets\\Avery\\_5520_A\:\:TAG_SIZE is unused\.$#' identifier: classConstant.unused @@ -12204,31 +12108,3 @@ parameters: count: 2 path: routes/web.php - # Added manually. These five findings show up on the PHP 8.5 CI - # runner but not on a long-lived local composer install, most - # likely because a fresh vendor resolves larastan's facade / - # interface class map slightly differently. Real findings worth - # fixing later, not this PR's scope: - # Crypt::Decrypt should be Crypt::decrypt (Laravel facade - # camelCase convention; runtime still works via PHP's case- - # insensitive method dispatch). PasswordBroker::getUser and - # ::createToken live on the concrete Illuminate\Auth\Passwords\ - # PasswordBroker but not on the Illuminate\Contracts\Auth\ - # PasswordBroker interface that broker() is typed to return. - - - message: '#^Call to an undefined static method Illuminate\\Support\\Facades\\Crypt\:\:Decrypt\(\)\.$#' - identifier: staticMethod.notFound - count: 3 - path: app/Console/Commands/LdapTroubleshooter.php - - - - message: '#^Call to an undefined method Illuminate\\Contracts\\Auth\\PasswordBroker\:\:getUser\(\)\.$#' - identifier: method.notFound - count: 1 - path: app/Http/Controllers/Auth/ResetPasswordController.php - - - - message: '#^Call to an undefined method Illuminate\\Contracts\\Auth\\PasswordBroker\:\:createToken\(\)\.$#' - identifier: method.notFound - count: 1 - path: app/Notifications/WelcomeNotification.php