From 6bb6b01104963475015d3cbca2b9718d48a2337f Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 16 Dec 2023 15:51:29 -0500 Subject: [PATCH] make baseline prompter. --- .gitignore | 1 + app/neato_common.php | 2 +- app/neato_enc.php | 2 +- phpstan.neon.dist | 3 +++ static_tests.sh | 52 +++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 57 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index ca2af4a..b829736 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ neato_deploy.tar.gz neatoDeploy.phar neato_deploy.tar.gz.self phpstan.neon +phpstan-baseline*.neon composer.lock app/sumfiles.sig build/neatoDeploy.phar.pubkey diff --git a/app/neato_common.php b/app/neato_common.php index 22cbbb6..3e2b6b4 100644 --- a/app/neato_common.php +++ b/app/neato_common.php @@ -154,7 +154,7 @@ function make_password($length = 12) { $did_special_chr = false; $did_number = false; - srand((double) microtime() * 1000000); + srand((int) microtime() * 1000000); if (rand(0, 100) > 50) { $password .= $special[rand(0, 6)]; diff --git a/app/neato_enc.php b/app/neato_enc.php index 8225a7f..cb55898 100644 --- a/app/neato_enc.php +++ b/app/neato_enc.php @@ -113,7 +113,7 @@ class enc { $my_bin = $hex[$c]; $my_hex = bin2hex($my_bin); $my_dec = hexdec($my_hex); - $ooh = (int) ord($my_dec); + $ooh = (int) ord((string) $my_dec); if ($ooh + 62 < 255) { $decoded .= chr($my_dec - 62); } else { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 82df8d3..54d8b4f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,7 @@ +includes: + - phpstan-baseline.neon parameters: level: 4 paths: - app + - tests diff --git a/static_tests.sh b/static_tests.sh index a8ace00..202c4be 100755 --- a/static_tests.sh +++ b/static_tests.sh @@ -8,4 +8,54 @@ if [ ! -x vendor/bin/phpstan ]; then fi fi -./vendor/bin/phpstan analyse \ No newline at end of file +check_file_size() { + # Get the size of the file + local size=$(stat -c%s "phpstan-baseline.neon") + + # Check if the file size is zero + if [ "$size" -eq 0 ]; then + return 0 + else + current_date=$(date +"%Y-%m-%d_%H_%M") + mv phpstan-baseline.neon phpstan-baseline_$current_date.neon + touch phpstan-baseline.neon + return 1 + fi +} + +if [ ! -f phpstan-baseline.neon ]; then + read -p "Do you want to Generate-baseline? (yes/empty for default): " choice + case "$choice" in + "yes") + echo "Making baseline..." + command_params="--generate-baseline" + ;; + "") + command_params="" + touch phpstan-baseline.neon + ;; + *) + command_params="" + ;; + esac +else + read -p "What do you want to do to the baseline? (make/delete/empty for default): " choice + case "$choice" in + "delete") + echo "Removing existing baseline..." + check_file_size + command_params="" + ;; + "make") + echo "Making new baseline" + check_file_size + command_params="--generate-baseline" + ;; + *) + echo "Using existing baseline..." + command_params="" + ;; + esac +fi + +./vendor/bin/phpstan analyse $@ $command_params \ No newline at end of file