From 1400e5b73a79cada7e2433bc7b25fc70c932e649 Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Sun, 3 Sep 2023 15:02:50 +0200 Subject: [PATCH] refactor: remove thecodingmachine/safe dependency (#440) --- composer.json | 4 +--- phpstan.neon | 1 - src/Models/Casts/TrustPath.php | 7 ++----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index e797f7ca..9ab20424 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "php": ">=8.1", "illuminate/support": "^9.0 || ^10.0", "psr/http-factory-implementation": "1.0", - "thecodingmachine/safe": "^2.0", "web-auth/cose-lib": "^4.0", "web-auth/webauthn-lib": "^4.0", "web-token/jwt-signature": "^3.0" @@ -38,8 +37,7 @@ "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", - "thecodingmachine/phpstan-safe-rule": "^1.0" + "phpunit/phpunit": "^9.5" }, "suggest": { "guzzlehttp/psr7": "To provide a psr/http-factory-implementation implementation", diff --git a/phpstan.neon b/phpstan.neon index 47f65e03..4b046fea 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,5 @@ includes: - ./vendor/nunomaduro/larastan/extension.neon - - ./vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon - ./vendor/phpstan/phpstan-deprecation-rules/rules.neon - ./vendor/phpstan/phpstan-strict-rules/rules.neon diff --git a/src/Models/Casts/TrustPath.php b/src/Models/Casts/TrustPath.php index b2eac997..089652c5 100644 --- a/src/Models/Casts/TrustPath.php +++ b/src/Models/Casts/TrustPath.php @@ -5,9 +5,6 @@ use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Webauthn\TrustPath\TrustPathLoader; -use function Safe\json_decode; -use function Safe\json_encode; - class TrustPath implements CastsAttributes { /** @@ -21,7 +18,7 @@ class TrustPath implements CastsAttributes */ public function get($model, $key, $value, $attributes): ?\Webauthn\TrustPath\TrustPath { - return $value !== null ? TrustPathLoader::loadTrustPath(json_decode($value, true)) : null; + return $value !== null ? TrustPathLoader::loadTrustPath(json_decode($value, true, flags: JSON_THROW_ON_ERROR)) : null; } /** @@ -35,6 +32,6 @@ public function get($model, $key, $value, $attributes): ?\Webauthn\TrustPath\Tru */ public function set($model, $key, $value, $attributes): string { - return json_encode($value); + return json_encode($value, flags: JSON_THROW_ON_ERROR); } }