From d1ad02e3bed4c19819dc95e9aac695a6bf36410d Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 13 May 2024 15:22:26 -0500 Subject: [PATCH] Remove CoreFunctions.php file, as PHPStan no longer complains about having all helper functions in Core.php --- composer.json | 2 +- composer.lock | 10 +++++----- lib/Core.php | 27 ++++++++++++++++++++++++++- lib/CoreFunctions.php | 29 ----------------------------- 4 files changed, 32 insertions(+), 36 deletions(-) delete mode 100644 lib/CoreFunctions.php diff --git a/composer.json b/composer.json index babbf263..50df169a 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ }, "autoload": { "psr-4": {"": "lib/"}, - "files": ["lib/Constants.php", "lib/CoreFunctions.php"] + "files": ["lib/Constants.php"] }, "platform":{ "php": "8.1.2" diff --git a/composer.lock b/composer.lock index 422c53d6..d9199502 100644 --- a/composer.lock +++ b/composer.lock @@ -1138,16 +1138,16 @@ "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "666cb1703742cea9cc80fee631f0940e1592fa6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/666cb1703742cea9cc80fee631f0940e1592fa6e", + "reference": "666cb1703742cea9cc80fee631f0940e1592fa6e", "shasum": "" }, "require": { @@ -1192,7 +1192,7 @@ "type": "github" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-05-13T06:02:22+00:00" }, { "name": "thecodingmachine/phpstan-safe-rule", diff --git a/lib/Core.php b/lib/Core.php index aa34cf6e..5662b996 100644 --- a/lib/Core.php +++ b/lib/Core.php @@ -2,14 +2,39 @@ // Composer auto-loads the lib/ directory in composer.json require __DIR__ . '/../vendor/autoload.php'; +use function Safe\error_log; use function Safe\mb_internal_encoding; use function Safe\mb_http_output; -use function Safe\error_log; +use function Safe\ob_end_clean; +use function Safe\ob_start; mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); date_default_timezone_set('UTC'); +// Convenience alias of var_dump. +function vd(mixed $var): void{ + var_dump($var); +} + +// var_dump($var) then die(). +function vdd(mixed $var): void{ + var_dump($var); + die(); +} + +// var_dump into a string. +function vds(mixed $var): string{ + ob_start(); + var_dump($var); + $str = ob_get_contents(); + if($str === false){ + $str = ''; + } + ob_end_clean(); + return $str; +} + // Custom error handler to output more details about the specific Apache request that caused an exception. if(SITE_STATUS == SITE_STATUS_LIVE){ set_exception_handler(function(Throwable $ex): void{ diff --git a/lib/CoreFunctions.php b/lib/CoreFunctions.php deleted file mode 100644 index 53c3367c..00000000 --- a/lib/CoreFunctions.php +++ /dev/null @@ -1,29 +0,0 @@ -