#!/bin/bash if [ ! -x vendor/bin/phpstan ]; then if which composer >/dev/null 2>&1; then echo "Running Composer to install phpstan." composer require --dev phpstan/phpstan else echo "Please install php composer!" fi fi 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