From 3e3aa9077e4190b783cd7a164c1f86f454d5f840 Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Wed, 21 Apr 2021 23:22:15 +0200 Subject: [PATCH] Revert "Fix StringBlade errors with a stub file" (#12776) This reverts parts of commit 165c4fd53cfb732f4a47e40da39d7372b2346c17. --- LibreNMS/Alert/Template.php | 9 ++++----- app/Http/Controllers/DeviceController.php | 3 +-- phpstan-baseline.neon | 15 +++++++++++++++ phpstan.neon | 3 --- tests/stubs/StringBlade.stub | 11 ----------- 5 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 tests/stubs/StringBlade.stub diff --git a/LibreNMS/Alert/Template.php b/LibreNMS/Alert/Template.php index 4f4fbd721b..8bb782be11 100644 --- a/LibreNMS/Alert/Template.php +++ b/LibreNMS/Alert/Template.php @@ -26,7 +26,6 @@ namespace LibreNMS\Alert; use App\Models\AlertTemplate; use LibreNMS\Enum\AlertState; -use Wpb\String_Blade_Compiler\Facades\StringBlade as View; class Template { @@ -74,9 +73,9 @@ class Template { $alert['alert'] = new AlertData($data['alert']); try { - return View::make(['template' => $data['template']->template], $alert)->__toString(); + return view(['template' => $data['template']->template], $alert)->__toString(); } catch (\Exception $e) { - return View::make(['template' => $this->getDefaultTemplate()], $alert)->__toString(); + return view(['template' => $this->getDefaultTemplate()], $alert)->__toString(); } } @@ -90,9 +89,9 @@ class Template { $alert['alert'] = new AlertData($data['alert']); try { - return View::make(['template' => $data['title']], $alert)->__toString(); + return view(['template' => $data['title']], $alert)->__toString(); } catch (\Exception $e) { - return $data['title'] ?: View::make(['template' => 'Template ' . $data['name']], $alert)->__toString(); + return $data['title'] ?: view(['template' => 'Template ' . $data['name']], $alert)->__toString(); } } diff --git a/app/Http/Controllers/DeviceController.php b/app/Http/Controllers/DeviceController.php index b6854c42d8..90f5725288 100644 --- a/app/Http/Controllers/DeviceController.php +++ b/app/Http/Controllers/DeviceController.php @@ -13,7 +13,6 @@ use Illuminate\Support\Facades\Auth; use LibreNMS\Config; use LibreNMS\Util\Graph; use LibreNMS\Util\Url; -use Wpb\String_Blade_Compiler\Facades\StringBlade as View; class DeviceController extends Controller { @@ -166,7 +165,7 @@ class DeviceController extends Controller foreach (array_values(Arr::wrap(Config::get('html.device.links'))) as $index => $link) { $device_links['custom' . ($index + 1)] = [ 'icon' => $link['icon'] ?? 'fa-external-link', - 'url' => View::make(['template' => $link['url']], ['device' => $device])->__toString(), + 'url' => view(['template' => $link['url']], ['device' => $device])->__toString(), 'title' => $link['title'], 'external' => $link['external'] ?? true, ]; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4f49ce269c..7d80d6c008 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,15 @@ parameters: ignoreErrors: + - + message: "#^Parameter \\#1 \\$view of function view expects view\\-string\\|null, array\\ given\\.$#" + count: 2 + path: LibreNMS/Alert/Template.php + + - + message: "#^Parameter \\#1 \\$view of function view expects view\\-string\\|null, array\\ given\\.$#" + count: 2 + path: LibreNMS/Alert/Template.php + - message: "#^Call to function is_null\\(\\) with string will always evaluate to false\\.$#" count: 1 @@ -215,6 +225,11 @@ parameters: count: 1 path: app/Console/LnmsCommand.php + - + message: "#^Parameter \\#1 \\$view of function view expects view\\-string\\|null, array\\ given\\.$#" + count: 1 + path: app/Http/Controllers/DeviceController.php + - message: "#^Call to function is_null\\(\\) with PDO will always evaluate to false\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index 8853fa391a..ffc88546c2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -26,6 +26,3 @@ parameters: parallel: processTimeout: 300.0 - - stubFiles: - - tests/stubs/StringBlade.stub diff --git a/tests/stubs/StringBlade.stub b/tests/stubs/StringBlade.stub deleted file mode 100644 index 45abe8436a..0000000000 --- a/tests/stubs/StringBlade.stub +++ /dev/null @@ -1,11 +0,0 @@ -