Skip to content

Commit

Permalink
Less deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Feb 17, 2022
1 parent 0c49028 commit c13cde5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
33 changes: 33 additions & 0 deletions bin/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

pass=true

files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(php|phtml)$')
if [ "$files" != "" ]; then

# Run php syntax check before commit
for file in ${files}; do
php -l ${file}
if [ $? -ne 0 ]; then
pass=false
fi
done

# Run php-cs-fixer validation before commit
echo "$files" | xargs php ./vendor/bin/php-cs-fixer fix --diff --config .php-cs-fixer.dist.php
if [ $? -ne 0 ]; then
pass=false
fi

# Automatically add files that may have been fixed by php-cs-fixer
echo "$files" | xargs git add
fi

if $pass; then
exit 0
else
echo ""
echo "PRE-COMMIT HOOK FAILED:"
echo "Code style validation failed. Please fix errors and try committing again."
exit 1
fi
2 changes: 1 addition & 1 deletion library/Zend/Controller/Router/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public function assemble($userParams, $name = null, $reset = false, $encode = tr
$url = $route->assemble($params, $reset, $encode);

if (!preg_match('|^[a-z]+://|', $url)) {
$url = rtrim($this->getFrontController()->getBaseUrl(), self::URI_DELIMITER) . self::URI_DELIMITER . $url;
$url = rtrim($this->getFrontController()->getBaseUrl() ?? '', self::URI_DELIMITER) . self::URI_DELIMITER . $url;
}

return $url;
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Controller/Router/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function match($path, $partial = false)
}
}

if (substr($part, 0, 2) === '@@') {
if (substr($part ?? '', 0, 2) === '@@') {
$part = substr($part, 1);
}

Expand Down
1 change: 1 addition & 0 deletions library/Zend/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,7 @@ protected function _dissolveArrayUnsetKey($array, $arrayPath, $key)
*/
protected function _attachToArray($value, $arrayPath)
{
$arrayPath = (string) $arrayPath;
// As long as we have more levels
while ($arrayPos = strrpos($arrayPath, '[')) {
// Get the next key in the path
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/View/Helper/BaseUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function baseUrl($file = null)
*/
public function setBaseUrl($base)
{
$this->_baseUrl = rtrim($base, '/\\');
$this->_baseUrl = rtrim($base ?? '', '/\\');

return $this;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ protected function _removeScriptName($url)
return $url;
}

if (($pos = strripos($url, basename($_SERVER['SCRIPT_NAME']))) !== false) {
if (($pos = strripos($url ?? '', basename($_SERVER['SCRIPT_NAME']))) !== false) {
$url = substr($url, 0, $pos);
}

Expand Down

0 comments on commit c13cde5

Please sign in to comment.