Merge pull request #14379 from mfn/mfn-curly-braces

[2.x] php-7.4-compact: replace deprecated curly brace offset access
This commit is contained in:
othercorey 2020-03-20 17:27:05 -05:00 committed by GitHub
commit d65ad7bd92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 20 additions and 20 deletions

View file

@ -388,7 +388,7 @@ class ModelTask extends BakeTask {
sort($options); sort($options);
$default = 1; $default = 1;
foreach ($options as $option) { foreach ($options as $option) {
if ($option{0} !== '_') { if ($option[0] !== '_') {
$choices[$default] = $option; $choices[$default] = $option;
$default++; $default++;
} }

View file

@ -237,7 +237,7 @@ class UpgradeShell extends AppShell {
foreach ($helpers as $helper) { foreach ($helpers as $helper) {
$helper = preg_replace('/Helper$/', '', $helper); $helper = preg_replace('/Helper$/', '', $helper);
$oldHelper = $helper; $oldHelper = $helper;
$oldHelper{0} = strtolower($oldHelper{0}); $oldHelper[0] = strtolower($oldHelper[0]);
$patterns[] = array( $patterns[] = array(
"\${$oldHelper} to \$this->{$helper}", "\${$oldHelper} to \$this->{$helper}",
"/\\\${$oldHelper}->/", "/\\\${$oldHelper}->/",

View file

@ -620,8 +620,8 @@ class ConsoleOptionParser {
if (substr($name, 0, 2) === '--') { if (substr($name, 0, 2) === '--') {
return isset($this->_options[substr($name, 2)]); return isset($this->_options[substr($name, 2)]);
} }
if ($name{0} === '-' && $name{1} !== '-') { if ($name[0] === '-' && $name[1] !== '-') {
return isset($this->_shortOptions[$name{1}]); return isset($this->_shortOptions[$name[1]]);
} }
return false; return false;
} }

View file

@ -306,7 +306,7 @@ class ContainableBehavior extends ModelBehavior {
if (!$optionKey && is_string($key) && preg_match('/^[a-z(]/', $key) && (!isset($Model->{$key}) || !is_object($Model->{$key}))) { if (!$optionKey && is_string($key) && preg_match('/^[a-z(]/', $key) && (!isset($Model->{$key}) || !is_object($Model->{$key}))) {
$option = 'fields'; $option = 'fields';
$val = array($key); $val = array($key);
if ($key{0} === '(') { if ($key[0] === '(') {
$val = preg_split('/\s*,\s*/', substr($key, 1, -1)); $val = preg_split('/\s*,\s*/', substr($key, 1, -1));
} elseif (preg_match('/ASC|DESC$/', $key)) { } elseif (preg_match('/ASC|DESC$/', $key)) {
$option = 'order'; $option = 'order';

View file

@ -190,7 +190,7 @@ class Permission extends AppModel {
$actions = array('_' . $actions); $actions = array('_' . $actions);
} }
foreach ($actions as $action) { foreach ($actions as $action) {
if ($action{0} !== '_') { if ($action[0] !== '_') {
$action = '_' . $action; $action = '_' . $action;
} }
if (!in_array($action, $permKeys, true)) { if (!in_array($action, $permKeys, true)) {

View file

@ -589,7 +589,7 @@ class HttpSocket extends CakeSocket {
if (is_array($port)) { if (is_array($port)) {
$port = $port[0]; $port = $port[0];
} }
if ($url{0} === '/') { if ($url[0] === '/') {
$url = $this->config['request']['uri']['host'] . ':' . $port . $url; $url = $this->config['request']['uri']['host'] . ':' . $port . $url;
} }
if (!preg_match('/^.+:\/\/|\*|^\//', $url)) { if (!preg_match('/^.+:\/\/|\*|^\//', $url)) {

View file

@ -401,7 +401,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
$tags = (string)$tags; $tags = (string)$tags;
} }
$i++; $i++;
if (is_string($tags) && $tags{0} === '<') { if (is_string($tags) && $tags[0] === '<') {
$tags = array(substr($tags, 1) => array()); $tags = array(substr($tags, 1) => array());
} elseif (is_string($tags)) { } elseif (is_string($tags)) {
$tagsTrimmed = preg_replace('/\s+/m', '', $tags); $tagsTrimmed = preg_replace('/\s+/m', '', $tags);

View file

@ -520,7 +520,7 @@ class Folder {
foreach ($iterator as $itemPath => $fsIterator) { foreach ($iterator as $itemPath => $fsIterator) {
if ($skipHidden) { if ($skipHidden) {
$subPathName = $fsIterator->getSubPathname(); $subPathName = $fsIterator->getSubPathname();
if ($subPathName{0} === '.' || strpos($subPathName, DS . '.') !== false) { if ($subPathName[0] === '.' || strpos($subPathName, DS . '.') !== false) {
continue; continue;
} }
} }

View file

@ -72,7 +72,7 @@ class Sanitize {
$db = ConnectionManager::getDataSource($connection); $db = ConnectionManager::getDataSource($connection);
$string = $db->value($string, 'string'); $string = $db->value($string, 'string');
$start = 1; $start = 1;
if ($string{0} === 'N') { if ($string[0] === 'N') {
$start = 2; $start = 2;
} }

View file

@ -500,7 +500,7 @@ class Set {
$val = $data[$key]; $val = $data[$key];
if ($op === '=' && $expected && $expected{0} === '/') { if ($op === '=' && $expected && $expected[0] === '/') {
return preg_match($expected, $val); return preg_match($expected, $val);
} }
if ($op === '=' && $val != $expected) { if ($op === '=' && $val != $expected) {

View file

@ -2060,7 +2060,7 @@ class FormHelper extends AppHelper {
$tag = $this->Html->useTag('submitimage', $caption, $options); $tag = $this->Html->useTag('submitimage', $caption, $options);
} elseif ($isImage) { } elseif ($isImage) {
unset($options['type']); unset($options['type']);
if ($caption{0} !== '/') { if ($caption[0] !== '/') {
$url = $this->webroot(Configure::read('App.imageBaseUrl') . $caption); $url = $this->webroot(Configure::read('App.imageBaseUrl') . $caption);
} else { } else {
$url = $this->webroot(trim($caption, '/')); $url = $this->webroot(trim($caption, '/'));

View file

@ -196,7 +196,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
$length = strlen($string); $length = strlen($string);
$return = ''; $return = '';
for ($i = 0; $i < $length; ++$i) { for ($i = 0; $i < $length; ++$i) {
$ord = ord($string{$i}); $ord = ord($string[$i]);
switch (true) { switch (true) {
case $ord == 0x08: case $ord == 0x08:
$return .= '\b'; $return .= '\b';
@ -216,10 +216,10 @@ abstract class JsBaseEngineHelper extends AppHelper {
case $ord == 0x22: case $ord == 0x22:
case $ord == 0x2F: case $ord == 0x2F:
case $ord == 0x5C: case $ord == 0x5C:
$return .= '\\' . $string{$i}; $return .= '\\' . $string[$i];
break; break;
case (($ord >= 0x20) && ($ord <= 0x7F)): case (($ord >= 0x20) && ($ord <= 0x7F)):
$return .= $string{$i}; $return .= $string[$i];
break; break;
case (($ord & 0xE0) == 0xC0): case (($ord & 0xE0) == 0xC0):
if ($i + 1 >= $length) { if ($i + 1 >= $length) {
@ -227,7 +227,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
$return .= '?'; $return .= '?';
break; break;
} }
$charbits = $string{$i} . $string{$i + 1}; $charbits = $string[$i] . $string[$i + 1];
$char = Multibyte::utf8($charbits); $char = Multibyte::utf8($charbits);
$return .= sprintf('\u%04s', dechex($char[0])); $return .= sprintf('\u%04s', dechex($char[0]));
$i += 1; $i += 1;
@ -238,7 +238,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
$return .= '?'; $return .= '?';
break; break;
} }
$charbits = $string{$i} . $string{$i + 1} . $string{$i + 2}; $charbits = $string[$i] . $string[$i + 1] . $string[$i + 2];
$char = Multibyte::utf8($charbits); $char = Multibyte::utf8($charbits);
$return .= sprintf('\u%04s', dechex($char[0])); $return .= sprintf('\u%04s', dechex($char[0]));
$i += 2; $i += 2;
@ -249,7 +249,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
$return .= '?'; $return .= '?';
break; break;
} }
$charbits = $string{$i} . $string{$i + 1} . $string{$i + 2} . $string{$i + 3}; $charbits = $string[$i] . $string[$i + 1] . $string[$i + 2] . $string[$i + 3];
$char = Multibyte::utf8($charbits); $char = Multibyte::utf8($charbits);
$return .= sprintf('\u%04s', dechex($char[0])); $return .= sprintf('\u%04s', dechex($char[0]));
$i += 3; $i += 3;
@ -260,7 +260,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
$return .= '?'; $return .= '?';
break; break;
} }
$charbits = $string{$i} . $string{$i + 1} . $string{$i + 2} . $string{$i + 3} . $string{$i + 4}; $charbits = $string[$i] . $string[$i + 1] . $string[$i + 2] . $string[$i + 3] . $string[$i + 4];
$char = Multibyte::utf8($charbits); $char = Multibyte::utf8($charbits);
$return .= sprintf('\u%04s', dechex($char[0])); $return .= sprintf('\u%04s', dechex($char[0]));
$i += 4; $i += 4;
@ -271,7 +271,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
$return .= '?'; $return .= '?';
break; break;
} }
$charbits = $string{$i} . $string{$i + 1} . $string{$i + 2} . $string{$i + 3} . $string{$i + 4} . $string{$i + 5}; $charbits = $string[$i] . $string[$i + 1] . $string[$i + 2] . $string[$i + 3] . $string[$i + 4] . $string[$i + 5];
$char = Multibyte::utf8($charbits); $char = Multibyte::utf8($charbits);
$return .= sprintf('\u%04s', dechex($char[0])); $return .= sprintf('\u%04s', dechex($char[0]));
$i += 5; $i += 5;