Skip to content

Commit c13cde5

Browse files
committed
Less deprecations
1 parent 0c49028 commit c13cde5

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

bin/pre-commit.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
pass=true
4+
5+
files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(php|phtml)$')
6+
if [ "$files" != "" ]; then
7+
8+
# Run php syntax check before commit
9+
for file in ${files}; do
10+
php -l ${file}
11+
if [ $? -ne 0 ]; then
12+
pass=false
13+
fi
14+
done
15+
16+
# Run php-cs-fixer validation before commit
17+
echo "$files" | xargs php ./vendor/bin/php-cs-fixer fix --diff --config .php-cs-fixer.dist.php
18+
if [ $? -ne 0 ]; then
19+
pass=false
20+
fi
21+
22+
# Automatically add files that may have been fixed by php-cs-fixer
23+
echo "$files" | xargs git add
24+
fi
25+
26+
if $pass; then
27+
exit 0
28+
else
29+
echo ""
30+
echo "PRE-COMMIT HOOK FAILED:"
31+
echo "Code style validation failed. Please fix errors and try committing again."
32+
exit 1
33+
fi

library/Zend/Controller/Router/Rewrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ public function assemble($userParams, $name = null, $reset = false, $encode = tr
485485
$url = $route->assemble($params, $reset, $encode);
486486

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

491491
return $url;

library/Zend/Controller/Router/Route.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function match($path, $partial = false)
280280
}
281281
}
282282

283-
if (substr($part, 0, 2) === '@@') {
283+
if (substr($part ?? '', 0, 2) === '@@') {
284284
$part = substr($part, 1);
285285
}
286286

library/Zend/Form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,6 +2282,7 @@ protected function _dissolveArrayUnsetKey($array, $arrayPath, $key)
22822282
*/
22832283
protected function _attachToArray($value, $arrayPath)
22842284
{
2285+
$arrayPath = (string) $arrayPath;
22852286
// As long as we have more levels
22862287
while ($arrayPos = strrpos($arrayPath, '[')) {
22872288
// Get the next key in the path

library/Zend/View/Helper/BaseUrl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function baseUrl($file = null)
6565
*/
6666
public function setBaseUrl($base)
6767
{
68-
$this->_baseUrl = rtrim($base, '/\\');
68+
$this->_baseUrl = rtrim($base ?? '', '/\\');
6969

7070
return $this;
7171
}
@@ -105,7 +105,7 @@ protected function _removeScriptName($url)
105105
return $url;
106106
}
107107

108-
if (($pos = strripos($url, basename($_SERVER['SCRIPT_NAME']))) !== false) {
108+
if (($pos = strripos($url ?? '', basename($_SERVER['SCRIPT_NAME']))) !== false) {
109109
$url = substr($url, 0, $pos);
110110
}
111111

0 commit comments

Comments
 (0)