Skip to content

Commit

Permalink
Merge pull request #23 from nutama/php7.4
Browse files Browse the repository at this point in the history
php 7.4 compatibility
  • Loading branch information
nutama authored Dec 18, 2020
2 parents dda5ae7 + 79e36ce commit b5c96fb
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 86 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
language: php
php:
- 7.4
- 7.3
- 7.2
- 7.1
- 7.0
- 5.6

before_script:
- composer install --dev
Expand Down
4 changes: 1 addition & 3 deletions lib/cache/sfFileCache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ protected function read($path, $type = self::READ_DATA)
@flock($fp, LOCK_SH);
clearstatcache(); // because the filesize can be cached by PHP itself...
$length = @filesize($path);
$mqr = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);

switch ($type)
{
case self::READ_TIMEOUT:
Expand All @@ -240,7 +239,6 @@ protected function read($path, $type = self::READ_DATA)
default:
throw new sfConfigurationException(sprintf('Unknown type "%s".', $type));
}
set_magic_quotes_runtime($mqr);
@flock($fp, LOCK_UN);
@fclose($fp);

Expand Down
2 changes: 1 addition & 1 deletion lib/helper/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function _encodeText($text)

for ($i = 0; $i < strlen($text); $i++)
{
$char = $text{$i};
$char = $text[$i];
$r = rand(0, 100);

# roughly 10% raw, 45% hex, 45% dec
Expand Down
20 changes: 10 additions & 10 deletions lib/i18n/sfDateFormat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function format($time, $pattern = 'F', $inputPattern = null, $charset = '
for ($i = 0, $max = count($tokens); $i < $max; $i++)
{
$pattern = $tokens[$i];
if ($pattern{0} == "'" && $pattern{strlen($pattern) - 1} == "'")
if ($pattern[0] == "'" && $pattern[strlen($pattern) - 1] == "'")
{
$tokens[$i] = str_replace('``````', '\'', preg_replace('/(^\')|(\'$)/', '', $pattern));
}
Expand Down Expand Up @@ -258,9 +258,9 @@ public function format($time, $pattern = 'F', $inputPattern = null, $charset = '
*/
protected function getFunctionName($token)
{
if (isset($this->tokens[$token{0}]))
if (isset($this->tokens[$token[0]]))
{
return $this->tokens[$token{0}];
return $this->tokens[$token[0]];
}
}

Expand Down Expand Up @@ -389,30 +389,30 @@ protected function getTokens($pattern)

for ($i = 0, $max = strlen($pattern); $i < $max; $i++)
{
if ($char == null || $pattern{$i} == $char || $text)
if ($char == null || $pattern[$i] == $char || $text)
{
$token .= $pattern{$i};
$token .= $pattern[$i];
}
else
{
$tokens[] = str_replace("''", "'", $token);
$token = $pattern{$i};
$token = $pattern[$i];
}

if ($pattern{$i} == "'" && $text == false)
if ($pattern[$i] == "'" && $text == false)
{
$text = true;
}
else if ($text && $pattern{$i} == "'" && $char == "'")
else if ($text && $pattern[$i] == "'" && $char == "'")
{
$text = true;
}
else if ($text && $char != "'" && $pattern{$i} == "'")
else if ($text && $char != "'" && $pattern[$i] == "'")
{
$text = false;
}

$char = $pattern{$i};
$char = $pattern[$i];

}
$tokens[] = $token;
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/sfNumberFormat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected function formatInteger($string)
// now for the integer groupings
for ($i = 0; $i < $len; $i++)
{
$char = $string{$len - $i - 1};
$char = $string[$len - $i - 1];

if ($multiGroup && $count == 0)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/sfNumberFormatInfo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ protected function parsePattern($pattern)
// to find the groupsize 1.
for ($i = strlen($pattern) - 1; $i >= 0; $i--)
{
if ($pattern{$i} == $digit || $pattern{$i} == $hash)
if ($pattern[$i] == $digit || $pattern[$i] == $hash)
{
$groupSize1 = $i - $groupPos1;
break;
Expand All @@ -330,11 +330,11 @@ protected function parsePattern($pattern)
{
for ($i = strlen($pattern) - 1; $i >= 0; $i--)
{
if ($pattern{$i} == $dot)
if ($pattern[$i] == $dot)
{
break;
}
if ($pattern{$i} == $digit)
if ($pattern[$i] == $digit)
{
$decimalPoints = $i - $decimalPos;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function strToArray($str)
$res[] = $this->strToArray(implode(',', $subarr[$in_subarr]));
$in_subarr--;
}
} elseif ($tok{0} === '{') { // we're inside a new sub-array
} elseif ($tok[0] === '{') { // we're inside a new sub-array
if ('}' !== substr($tok, -1, 1)) {
$in_subarr++;
// if sub-array has more than one element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected static function substring($string, $startpos, $endpos = -1) {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR);
}
if ($startpos === $endpos) {
return (string) $string{$startpos};
return (string) $string[$startpos];
} else {
$len = $endpos-$startpos;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/sfPropelPlugin/lib/vendor/phing/Phing.php
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ public static function getResourcePath($path) {
// This is a bit of a hack, but works better than previous solution of assuming
// data_dir is on the include_path.
$data_dir = '@DATA-DIR@';
if ($data_dir{0} != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted.
if ($data_dir[0] != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted.
$data_path = $data_dir . DIRECTORY_SEPARATOR . $path;
if (file_exists($data_path)) {
return $data_path;
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/sfPropelPlugin/lib/vendor/phing/lib/Capsule.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ function parse($template, $outputFile = null, $append = false) {
* @return string "Best guess" path for this file.
*/
protected function resolvePath($file, $basepath) {
if ( !($file{0} == DIRECTORY_SEPARATOR || $file{0} == '/')
if ( !($file[0] == DIRECTORY_SEPARATOR || $file[0] == '/')
// also account for C:\ style path
&& !($file{1} == ':' && ($file{2} == DIRECTORY_SEPARATOR || $file{2} == '/'))) {
&& !($file[1] == ':' && ($file[2] == DIRECTORY_SEPARATOR || $file[2] == '/'))) {
if ($basepath != null) {
$file = $basepath . DIRECTORY_SEPARATOR . $file;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function normalize($strPathname) {
// Resolve home directories. We assume /home is where all home
// directories reside, b/c there is no other way to do this with
// PHP AFAIK.
if ($strPathname{0} === "~") {
if ($strPathname{1} === "/") { // like ~/foo => /home/user/foo
if ($strPathname[0] === "~") {
if ($strPathname[1] === "/") { // like ~/foo => /home/user/foo
$strPathname = "/home/" . get_current_user() . substr($strPathname, 1);
} else { // like ~foo => /home/foo
$pos = strpos($strPathname, "/");
Expand All @@ -88,7 +88,7 @@ function normalize($strPathname) {
$n = strlen($strPathname);
$prevChar = 0;
for ($i=0; $i < $n; $i++) {
$c = $strPathname{$i};
$c = $strPathname[$i];
if (($prevChar === '/') && ($c === '/')) {
return self::normalizer($strPathname, $n, $i - 1);
}
Expand All @@ -109,7 +109,7 @@ protected function normalizer($pathname, $len, $offset) {
return $pathname;
}
$n = (int) $len;
while (($n > 0) && ($pathname{$n-1} === '/')) {
while (($n > 0) && ($pathname[$n-1] === '/')) {
$n--;
}
if ($n === 0) {
Expand All @@ -122,7 +122,7 @@ protected function normalizer($pathname, $len, $offset) {
}
$prevChar = 0;
for ($i = $offset; $i < $n; $i++) {
$c = $pathname{$i};
$c = $pathname[$i];
if (($prevChar === '/') && ($c === '/')) {
continue;
}
Expand All @@ -140,7 +140,7 @@ function prefixLength($pathname) {
if (strlen($pathname === 0)) {
return 0;
}
return (($pathname{0} === '/') ? 1 : 0);
return (($pathname[0] === '/') ? 1 : 0);
}

/**
Expand All @@ -154,7 +154,7 @@ function resolve($parent, $child) {
return $parent;
}

if ($child{0} === '/') {
if ($child[0] === '/') {
if ($parent === '/') {
return $child;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ function resolveFile(PhingFile $f) {
function getBooleanAttributes(&$f) {
//$rv = getBooleanAttributes0($f);
$name = $f->getName();
$hidden = (strlen($name) > 0) && ($name{0} == '.');
$hidden = (strlen($name) > 0) && ($name[0] == '.');
return ($hidden ? $this->BA_HIDDEN : 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function isLetter($c) {
}

function slashify($p) {
if ((strlen($p) > 0) && ($p{0} != $this->slash)) {
if ((strlen($p) > 0) && ($p[0] != $this->slash)) {
return $this->slash.$p;
}
else {
Expand Down Expand Up @@ -81,13 +81,13 @@ function getPathSeparator() {
*/
function normalizePrefix($strPath, $len, $sb) {
$src = 0;
while (($src < $len) && $this->isSlash($strPath{$src})) {
while (($src < $len) && $this->isSlash($strPath[$src])) {
$src++;
}
$c = "";
if (($len - $src >= 2)
&& $this->isLetter($c = $strPath{$src})
&& $strPath{$src + 1} === ':') {
&& $this->isLetter($c = $strPath[$src])
&& $strPath[$src + 1] === ':') {
/* Remove leading slashes if followed by drive specifier.
* This hack is necessary to support file URLs containing drive
* specifiers (e.g., "file://c:/path"). As a side effect,
Expand All @@ -99,8 +99,8 @@ function normalizePrefix($strPath, $len, $sb) {
else {
$src = 0;
if (($len >= 2)
&& $this->isSlash($strPath{0})
&& $this->isSlash($strPath{1})) {
&& $this->isSlash($strPath[0])
&& $this->isSlash($strPath[1])) {
/* UNC pathname: Retain first slash; leave src pointed at
* second slash so that further slashes will be collapsed
* into the second slash. The result will be a pathname
Expand Down Expand Up @@ -138,15 +138,15 @@ protected function normalizer($strPath, $len, $offset) {
// Remove redundant slashes from the remainder of the path, forcing all
// slashes into the preferred slash
while ($src < $len) {
$c = $strPath{$src++};
$c = $strPath[$src++];
if ($this->isSlash($c)) {
while (($src < $len) && $this->isSlash($strPath{$src})) {
while (($src < $len) && $this->isSlash($strPath[$src])) {
$src++;
}
if ($src === $len) {
/* Check for trailing separator */
$sn = (int) strlen($sb);
if (($sn == 2) && ($sb{1} === ':')) {
if (($sn == 2) && ($sb[1] === ':')) {
// "z:\\"
$sb .= $slash;
break;
Expand All @@ -156,7 +156,7 @@ protected function normalizer($strPath, $len, $offset) {
$sb .= $slash;
break;
}
if (($sn === 1) && ($this->isSlash($sb{0}))) {
if (($sn === 1) && ($this->isSlash($sb[0]))) {
/* "\\\\" is not collapsed to "\\" because "\\\\" marks
the beginning of a UNC pathname. Even though it is
not, by itself, a valid UNC pathname, we leave it as
Expand Down Expand Up @@ -194,7 +194,7 @@ function normalize($strPath) {
$altSlash = $this->altSlash;
$prev = 0;
for ($i = 0; $i < $n; $i++) {
$c = $strPath{$i};
$c = $strPath[$i];
if ($c === $altSlash) {
return $this->normalizer($strPath, $n, ($prev === $slash) ? $i - 1 : $i);
}
Expand All @@ -219,8 +219,8 @@ function prefixLength($strPath) {
if ($n === 0) {
return 0;
}
$c0 = $path{0};
$c1 = ($n > 1) ? $path{1} :
$c0 = $path[0];
$c1 = ($n > 1) ? $path[1] :
0;
if ($c0 === $slash) {
if ($c1 === $slash) {
Expand All @@ -230,7 +230,7 @@ function prefixLength($strPath) {
}

if ($this->isLetter($c0) && ($c1 === ':')) {
if (($n > 2) && ($path{2}) === $slash) {
if (($n > 2) && ($path[2]) === $slash) {
return 3; // Absolute local pathname "z:\\foo" */
}
return 2; // Directory-relative "z:foo"
Expand All @@ -253,8 +253,8 @@ function resolve($parent, $child) {
}

$c = $child;
if (($cn > 1) && ($c{0} === $slash)) {
if ($c{1} === $slash) {
if (($cn > 1) && ($c[0] === $slash)) {
if ($c[1] === $slash) {
// drop prefix when child is a UNC pathname
$c = substr($c, 2);
}
Expand All @@ -265,7 +265,7 @@ function resolve($parent, $child) {
}

$p = $parent;
if ($p{$pn - 1} === $slash) {
if ($p[$pn - 1] === $slash) {
$p = substr($p, 0, $pn - 1);
}
return $p.$this->slashify($c);
Expand All @@ -277,7 +277,7 @@ function getDefaultParent() {

function fromURIPath($strPath) {
$p = (string) $strPath;
if ((strlen($p) > 2) && ($p{2} === ':')) {
if ((strlen($p) > 2) && ($p[2] === ':')) {

// "/c:/foo" --> "c:/foo"
$p = substr($p,1);
Expand All @@ -299,12 +299,12 @@ function fromURIPath($strPath) {
function isAbsolute(PhingFile $f) {
$pl = (int) $f->getPrefixLength();
$p = (string) $f->getPath();
return ((($pl === 2) && ($p{0} === $this->slash)) || ($pl === 3) || ($pl === 1 && $p{0} === $this->slash));
return ((($pl === 2) && ($p[0] === $this->slash)) || ($pl === 3) || ($pl === 1 && $p[0] === $this->slash));
}

/** private */
function _driveIndex($d) {
$d = (string) $d{0};
$d = (string) $d[0];
if ((ord($d) >= ord('a')) && (ord($d) <= ord('z'))) {
return ord($d) - ord('a');
}
Expand All @@ -316,7 +316,7 @@ function _driveIndex($d) {

/** private */
function _getDriveDirectory($drive) {
$drive = (string) $drive{0};
$drive = (string) $drive[0];
$i = (int) $this->_driveIndex($drive);
if ($i < 0) {
return null;
Expand Down Expand Up @@ -348,7 +348,7 @@ function resolveFile(PhingFile $f) {
$path = $f->getPath();
$pl = (int) $f->getPrefixLength();

if (($pl === 2) && ($path{0} === $this->slash)) {
if (($pl === 2) && ($path[0] === $this->slash)) {
return path; // UNC
}

Expand All @@ -375,7 +375,7 @@ function resolveFile(PhingFile $f) {
if (($ud !== null) && StringHelper::startsWith($ud, $path)) {
return (string) ($up . $this->slashify(substr($path,2)));
}
$drive = (string) $path{0};
$drive = (string) $path[0];
$dir = (string) $this->_getDriveDirectory($drive);

$np = (string) "";
Expand Down
Loading

0 comments on commit b5c96fb

Please sign in to comment.