Skip to content

Commit 1e615d3

Browse files
committed
Replace usage of is_null() with strict comparison operator
1 parent 03d4ffe commit 1e615d3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Curl/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function absolutizeUrl()
9595
if (!isset($b['path'])) {
9696
$b['path'] = '/';
9797
}
98-
if (is_null($this->relativeUrl)) {
98+
if ($this->relativeUrl === null) {
9999
return $this->unparseUrl($b);
100100
}
101101
$r = $this->parseUrl($this->relativeUrl);

tests/script.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ if [[ ! -z "${elses}" ]]; then
122122
((errors++))
123123
fi
124124

125+
# Prohibit use of "is_null" and suggest using the strict comparison operator.
126+
is_null=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --color=always --line-number -H -e "is_null" {} \;)
127+
if [[ ! -z "${is_null}" ]]; then
128+
echo -e "${is_null}" | perl -pe 's/^(.*)$/is_null found in \1. Replace with strict comparison (e.g. "\$x === null")./'
129+
((errors++))
130+
fi
131+
125132
# Detect coding standard violations.
126133
phpcs --version
127134
phpcs \

0 commit comments

Comments
 (0)