Skip to content

fix(php): ignore warnings in CLI parsing #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion find-usable-php.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// First, check if the system's linked "php" is 8+; if so, return that. This
// is the most likely, most ideal, and fastest possible case
$linkedPhpVersion = shell_exec('php -r "echo phpversion();"');
$linkedPhpVersion = shell_exec('php -d error_reporting=1 -r "echo phpversion();"');

if (version_compare($linkedPhpVersion, $minimumPhpVersion) >= 0) {
echo exec('which php');
Expand Down
20 changes: 10 additions & 10 deletions valet
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SOURCE="${BASH_SOURCE[0]}"
# do it in pure Bash. So, we'll call into PHP CLI here to resolve.
if [[ -L "$SOURCE" ]]
then
DIR=$(php -r "echo dirname(realpath('$SOURCE'));")
DIR=$(php -d error_reporting=1 -r "echo dirname(realpath('$SOURCE'));")
else
DIR="$( cd "$( dirname "$SOURCE" )" && pwd )"
fi
Expand All @@ -17,15 +17,15 @@ fi
# Valet CLI script which is written in PHP. Will use PHP to do it.
if [ ! -f "$DIR/cli/valet.php" ]
then
DIR=$(php -r "echo realpath('$DIR/../laravel/valet');")
DIR=$(php -d error_reporting=1 -r "echo realpath('$DIR/../laravel/valet');")
fi

# Get a command-line executable we can use for php that's 8+; if this
# is the inside loop (Valet runs itself 2x in some settings), skip
# checking and pulling again by reading the exported env var
if [[ "$PHP_EXECUTABLE" = "" ]]
then
PHP="$(php $DIR/find-usable-php.php)"
PHP="$(php -d error_reporting=1 $DIR/find-usable-php.php)"

# Validate output before running it on the CLI
if [[ ! -f "$PHP" ]]; then
Expand All @@ -45,7 +45,7 @@ fi
# process to retrieve the live the share tool tunnel URL in the background.
if [[ "$1" = "share" ]]
then
SHARETOOL="$("$PHP" "$DIR/cli/valet.php" share-tool)"
SHARETOOL="$("$PHP" -d error_reporting=1 "$DIR/cli/valet.php" share-tool)"

# Check for parameters to pass through to share tool (these will start with '-' or '--')
PARAMS=(${@:2})
Expand All @@ -72,7 +72,7 @@ then

# Lowercase the host to match how the rest of our domains are looked up
HOST=$(echo "$HOST" | tr '[:upper:]' '[:lower:]')
TLD=$("$PHP" "$DIR/cli/valet.php" tld)
TLD=$("$PHP" -d error_reporting=1 "$DIR/cli/valet.php" tld)
$(grep --quiet --no-messages 443 ~/.config/valet/Nginx/$HOST*)
SECURED=$?

Expand Down Expand Up @@ -140,9 +140,9 @@ elif [[ "$1" = "php" ]]
then
if [[ $2 == *"--site="* ]]; then
SITE=${2#*=}
$("$PHP" "$DIR/cli/valet.php" which-php $SITE) "${@:3}"
$("$PHP" -d error_reporting=1 "$DIR/cli/valet.php" which-php $SITE) "${@:3}"
else
$("$PHP" "$DIR/cli/valet.php" which-php) "${@:2}"
$("$PHP" -d error_reporting=1 "$DIR/cli/valet.php" which-php) "${@:2}"
fi

exit
Expand All @@ -152,9 +152,9 @@ elif [[ "$1" = "composer" ]]
then
if [[ $2 == *"--site="* ]]; then
SITE=${2#*=}
$("$PHP" "$DIR/cli/valet.php" which-php $SITE) $(which composer) "${@:3}"
$("$PHP" -d error_reporting=1 "$DIR/cli/valet.php" which-php $SITE) $(which composer) "${@:3}"
else
$("$PHP" "$DIR/cli/valet.php" which-php) $(which composer) "${@:2}"
$("$PHP" -d error_reporting=1 "$DIR/cli/valet.php" which-php) $(which composer) "${@:2}"
fi

exit
Expand All @@ -169,5 +169,5 @@ else
exit
fi

"$PHP" "$DIR/cli/valet.php" "$@"
"$PHP" -d error_reporting=1 "$DIR/cli/valet.php" "$@"
fi
Loading