mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adhering to coding standards
This commit is contained in:
parent
32a3737cca
commit
5876744709
31 changed files with 51 additions and 52 deletions
|
@ -79,7 +79,7 @@ class BakeTask extends AppShell {
|
|||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
foreach($this->args as $i => $arg) {
|
||||
foreach ($this->args as $i => $arg) {
|
||||
if (strpos($arg, '.')) {
|
||||
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
|
||||
break;
|
||||
|
|
|
@ -159,8 +159,8 @@ class PluginTask extends AppShell {
|
|||
*/
|
||||
public function findPath($pathOptions) {
|
||||
$valid = false;
|
||||
foreach ($pathOptions as $i =>$path) {
|
||||
if(!is_dir($path)) {
|
||||
foreach ($pathOptions as $i => $path) {
|
||||
if (!is_dir($path)) {
|
||||
array_splice($pathOptions, $i, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class UpgradeShell extends AppShell {
|
|||
* @return void
|
||||
*/
|
||||
public function all() {
|
||||
foreach($this->OptionParser->subcommands() as $command) {
|
||||
foreach ($this->OptionParser->subcommands() as $command) {
|
||||
$name = $command->name();
|
||||
if ($name === 'all') {
|
||||
continue;
|
||||
|
@ -135,7 +135,7 @@ class UpgradeShell extends AppShell {
|
|||
if (is_dir('plugins')) {
|
||||
$Folder = new Folder('plugins');
|
||||
list($plugins) = $Folder->read();
|
||||
foreach($plugins as $plugin) {
|
||||
foreach ($plugins as $plugin) {
|
||||
chdir($cwd . DS . 'plugins' . DS . $plugin);
|
||||
$this->locations();
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class UpgradeShell extends AppShell {
|
|||
'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
|
||||
'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
|
||||
);
|
||||
foreach($moves as $old => $new) {
|
||||
foreach ($moves as $old => $new) {
|
||||
if (is_dir($old)) {
|
||||
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
|
||||
if (!$this->params['dry-run']) {
|
||||
|
@ -190,7 +190,7 @@ class UpgradeShell extends AppShell {
|
|||
'checkFolder' => true,
|
||||
'regex' => '@class (\S*) .*{@i'
|
||||
);
|
||||
foreach($sourceDirs as $dir => $options) {
|
||||
foreach ($sourceDirs as $dir => $options) {
|
||||
if (is_numeric($dir)) {
|
||||
$dir = $options;
|
||||
$options = array();
|
||||
|
@ -614,7 +614,7 @@ class UpgradeShell extends AppShell {
|
|||
$this->_findFiles('php');
|
||||
} else {
|
||||
$this->_files = scandir($path);
|
||||
foreach($this->_files as $i => $file) {
|
||||
foreach ($this->_files as $i => $file) {
|
||||
if (strlen($file) < 5 || substr($file, -4) !== '.php') {
|
||||
unset($this->_files[$i]);
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class HelpFormatter {
|
|||
foreach ($this->_parser->options() as $option) {
|
||||
$options[] = $option->usage();
|
||||
}
|
||||
if (count($options) > $this->_maxOptions){
|
||||
if (count($options) > $this->_maxOptions) {
|
||||
$options = array('[options]');
|
||||
}
|
||||
$usage = array_merge($usage, $options);
|
||||
|
|
|
@ -55,7 +55,7 @@ class CakeErrorController extends AppController {
|
|||
public function beforeRender() {
|
||||
parent::beforeRender();
|
||||
foreach ($this->viewVars as $key => $value) {
|
||||
if (!is_object($value)){
|
||||
if (!is_object($value)) {
|
||||
$this->viewVars[$key] = h($value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -567,7 +567,7 @@ class Mysql extends DboSource {
|
|||
protected function _alterIndexes($table, $indexes) {
|
||||
$alter = array();
|
||||
if (isset($indexes['drop'])) {
|
||||
foreach($indexes['drop'] as $name => $value) {
|
||||
foreach ($indexes['drop'] as $name => $value) {
|
||||
$out = 'DROP ';
|
||||
if ($name == 'PRIMARY') {
|
||||
$out .= 'PRIMARY KEY';
|
||||
|
|
|
@ -409,7 +409,7 @@ class Postgres extends DboSource {
|
|||
|
||||
if (!$constant && strpos($match[1], '.') === false) {
|
||||
$match[1] = $this->name($match[1]);
|
||||
} elseif (!$constant){
|
||||
} elseif (!$constant) {
|
||||
$parts = explode('.', $match[1]);
|
||||
if (!Set::numeric($parts)) {
|
||||
$match[1] = $this->name($match[1]);
|
||||
|
@ -550,7 +550,7 @@ class Postgres extends DboSource {
|
|||
protected function _alterIndexes($table, $indexes) {
|
||||
$alter = array();
|
||||
if (isset($indexes['drop'])) {
|
||||
foreach($indexes['drop'] as $name => $value) {
|
||||
foreach ($indexes['drop'] as $name => $value) {
|
||||
$out = 'DROP ';
|
||||
if ($name == 'PRIMARY') {
|
||||
continue;
|
||||
|
|
|
@ -286,9 +286,9 @@ class Sqlite extends DboSource {
|
|||
}
|
||||
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
|
||||
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
|
||||
} elseif(strpos($querystring, 'PRAGMA index_list') === 0) {
|
||||
} elseif (strpos($querystring, 'PRAGMA index_list') === 0) {
|
||||
$selects = array('seq', 'name', 'unique');
|
||||
} elseif(strpos($querystring, 'PRAGMA index_info') === 0) {
|
||||
} elseif (strpos($querystring, 'PRAGMA index_info') === 0) {
|
||||
$selects = array('seqno', 'cid', 'name');
|
||||
}
|
||||
while ($j < $num_fields) {
|
||||
|
|
|
@ -1947,7 +1947,7 @@ class DboSource extends DataSource {
|
|||
if (!isset($params[1])) {
|
||||
$params[1] = 'count';
|
||||
}
|
||||
if (is_object($model) && $model->isVirtualField($params[0])){
|
||||
if (is_object($model) && $model->isVirtualField($params[0])) {
|
||||
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
|
||||
} else {
|
||||
$arg = $this->name($params[0]);
|
||||
|
@ -2191,7 +2191,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
if (is_object($fields[$i]) && isset($fields[$i]->type) && $fields[$i]->type === 'expression') {
|
||||
$fields[$i] = $fields[$i]->value;
|
||||
} elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])){
|
||||
} elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])) {
|
||||
continue;
|
||||
} elseif (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
|
||||
$prepend = '';
|
||||
|
@ -2622,7 +2622,7 @@ class DboSource extends DataSource {
|
|||
if (!is_array($group)) {
|
||||
$group = array($group);
|
||||
}
|
||||
foreach($group as $index => $key) {
|
||||
foreach ($group as $index => $key) {
|
||||
if (is_object($model) && $model->isVirtualField($key)) {
|
||||
$group[$index] = '(' . $model->getVirtualField($key) . ')';
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
|
||||
if (empty($modelName)) {
|
||||
$settings = array(
|
||||
'class' =>'Session',
|
||||
'class' => 'Session',
|
||||
'alias' => 'Session',
|
||||
'table' => 'cake_sessions',
|
||||
);
|
||||
} else {
|
||||
$settings = array(
|
||||
'class' =>$modelName,
|
||||
'class' => $modelName,
|
||||
'alias' => 'Session',
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2136,7 +2136,7 @@ class Model extends Object {
|
|||
if (in_array($associations[$association], array('belongsTo', 'hasOne'))) {
|
||||
$validates = $this->{$association}->create($values) && $this->{$association}->validates($options);
|
||||
$return[$association][] = $validates;
|
||||
} elseif($associations[$association] === 'hasMany') {
|
||||
} elseif ($associations[$association] === 'hasMany') {
|
||||
$validates = $this->{$association}->validateMany($values, $options);
|
||||
$return[$association] = $validates;
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ class CakeRoute {
|
|||
// restructure 'pass' key route params
|
||||
if (isset($this->options['pass'])) {
|
||||
$j = count($this->options['pass']);
|
||||
while($j--) {
|
||||
while ($j--) {
|
||||
if (isset($route[$this->options['pass'][$j]])) {
|
||||
array_unshift($route['pass'], $route[$this->options['pass'][$j]]);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
$available = true;
|
||||
$Memcache = new Memcache();
|
||||
|
||||
foreach($servers as $server) {
|
||||
foreach ($servers as $server) {
|
||||
list($host, $port) = explode(':', $server);
|
||||
if (!@$Memcache->connect($host, $port)) {
|
||||
$available = false;
|
||||
|
|
|
@ -2603,7 +2603,7 @@ class I18nTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testTimeDefinitionJapanese(){
|
||||
public function testTimeDefinitionJapanese() {
|
||||
Configure::write('Config.language', 'ja_jp');
|
||||
$result = __c('d_fmt', 5);
|
||||
|
||||
|
|
|
@ -2921,8 +2921,8 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
'order' => array('Article.id' => 'ASC')
|
||||
));
|
||||
if (!empty($result)) {
|
||||
foreach($result as $i=>$article) {
|
||||
foreach($article['Comment'] as $j=>$comment) {
|
||||
foreach ($result as $i => $article) {
|
||||
foreach ($article['Comment'] as $j => $comment) {
|
||||
$result[$i]['Comment'][$j] = array_diff_key($comment, array('id'=>true));
|
||||
}
|
||||
}
|
||||
|
@ -3628,7 +3628,7 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
return $this->__containments($result['models']);
|
||||
} else {
|
||||
$result = $Model;
|
||||
foreach($result as $i => $containment) {
|
||||
foreach ($result as $i => $containment) {
|
||||
$result[$i] = array_diff_key($containment, array('instance' => true));
|
||||
}
|
||||
}
|
||||
|
@ -3646,7 +3646,7 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
function __assertBindings(&$Model, $expected = array()) {
|
||||
$expected = array_merge(array('belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array()), $expected);
|
||||
|
||||
foreach($expected as $binding => $expect) {
|
||||
foreach ($expected as $binding => $expect) {
|
||||
$this->assertEquals(array_keys($Model->$binding), $expect);
|
||||
}
|
||||
}
|
||||
|
@ -3664,14 +3664,14 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
|
||||
$debug = '[';
|
||||
$lines = array();
|
||||
foreach($relationTypes as $binding) {
|
||||
foreach ($relationTypes as $binding) {
|
||||
if (!empty($Model->$binding)) {
|
||||
$models = array_keys($Model->$binding);
|
||||
foreach($models as $linkedModel) {
|
||||
foreach ($models as $linkedModel) {
|
||||
$line = $linkedModel;
|
||||
if (!empty($extra) && !empty($Model->{$binding}[$linkedModel])) {
|
||||
$extraData = array();
|
||||
foreach(array_intersect_key($Model->{$binding}[$linkedModel], array_flip($extra)) as $key => $value) {
|
||||
foreach (array_intersect_key($Model->{$binding}[$linkedModel], array_flip($extra)) as $key => $value) {
|
||||
$extraData[] = $key . ': ' . (is_array($value) ? '(' . implode(', ', $value) . ')' : $value);
|
||||
}
|
||||
$line .= ' {' . implode(' - ', $extraData) . '}';
|
||||
|
|
|
@ -131,7 +131,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'fields' => array('Thread.project_id', 'COUNT(*) AS total')
|
||||
));
|
||||
$result = array();
|
||||
foreach($rows as $row) {
|
||||
foreach ($rows as $row) {
|
||||
$result[$row['Thread']['project_id']] = $row[0]['total'];
|
||||
}
|
||||
$expected = array(
|
||||
|
@ -146,7 +146,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'order'=> 'Thread.project_id'
|
||||
));
|
||||
$result = array();
|
||||
foreach($rows as $row) {
|
||||
foreach ($rows as $row) {
|
||||
$result[$row['Thread']['project_id']] = $row[0]['total'];
|
||||
}
|
||||
$expected = array(
|
||||
|
|
|
@ -899,7 +899,7 @@ class ModifiedAuthor extends Author {
|
|||
* @return void
|
||||
*/
|
||||
public function afterFind($results, $primary = false) {
|
||||
foreach($results as $index => $result) {
|
||||
foreach ($results as $index => $result) {
|
||||
$results[$index]['Author']['user'] .= ' (CakePHP)';
|
||||
}
|
||||
return $results;
|
||||
|
|
|
@ -20,7 +20,7 @@ App::uses('Dispatcher', 'Routing');
|
|||
|
||||
if (!class_exists('AppController', false)) {
|
||||
require_once CAKE . 'Controller' . DS . 'AppController.php';
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')){
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
}
|
||||
|
||||
|
|
|
@ -2403,7 +2403,7 @@ class SetTest extends CakeTestCase {
|
|||
$mapped = Set::map($expected);
|
||||
$ids = array();
|
||||
|
||||
foreach($mapped as $object) {
|
||||
foreach ($mapped as $object) {
|
||||
$ids[] = $object->id;
|
||||
}
|
||||
$this->assertEquals($ids, array(1, 2));
|
||||
|
@ -2451,7 +2451,7 @@ class SetTest extends CakeTestCase {
|
|||
|
||||
$ids = array();
|
||||
|
||||
foreach($mapped as $object) {
|
||||
foreach ($mapped as $object) {
|
||||
$ids[] = $object->id;
|
||||
}
|
||||
$this->assertEquals($ids, array(1, 2));
|
||||
|
|
|
@ -47,7 +47,7 @@ class StringTest extends CakeTestCase {
|
|||
$count = mt_rand(10, 1000);
|
||||
$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
|
||||
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$result = String::uuid();
|
||||
$match = (bool) preg_match($pattern, $result);
|
||||
$this->assertTrue($match);
|
||||
|
|
|
@ -868,7 +868,7 @@ class XmlTest extends CakeTestCase {
|
|||
|
||||
//multiple model results - without a records key it would fatal error
|
||||
$data = $user->find('all', array('limit'=>2));
|
||||
$data = array('records'=>$data);
|
||||
$data = array('records' => $data);
|
||||
$obj = Xml::build(compact('data'));
|
||||
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><data>';
|
||||
$expected .= '<records>';
|
||||
|
|
|
@ -279,7 +279,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSortLinksUsingDirectionOption(){
|
||||
public function testSortLinksUsingDirectionOption() {
|
||||
Router::reload();
|
||||
Router::parse('/');
|
||||
Router::setRequestInfo(array(
|
||||
|
|
|
@ -116,7 +116,7 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$result = $this->Time->timeAgoInWords(strtotime('+1 month +1 week +6 days'), array('end' => '8 years'), true);
|
||||
$this->assertEquals($result, '1 month, 1 week, 6 days');
|
||||
|
||||
for($i = 0; $i < 200; $i ++) {
|
||||
for ($i = 0; $i < 200; $i ++) {
|
||||
$years = mt_rand(0, 3);
|
||||
$months = mt_rand(0, 11);
|
||||
$weeks = mt_rand(0, 3);
|
||||
|
@ -411,7 +411,7 @@ class TimeHelperTest extends CakeTestCase {
|
|||
|
||||
if (!$this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
|
||||
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
|
||||
foreach($timezones as $timezone) {
|
||||
foreach ($timezones as $timezone) {
|
||||
$yourTimezone = new DateTimeZone($timezone);
|
||||
$yourTime = new DateTime('now', $yourTimezone);
|
||||
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
|
||||
|
|
|
@ -228,7 +228,7 @@ class CakeTestSuiteDispatcher {
|
|||
function _runTestCase() {
|
||||
$commandArgs = array(
|
||||
'case' => $this->params['case'],
|
||||
'core' =>$this->params['core'],
|
||||
'core' => $this->params['core'],
|
||||
'app' => $this->params['app'],
|
||||
'plugin' => $this->params['plugin'],
|
||||
'codeCoverage' => $this->params['codeCoverage'],
|
||||
|
|
|
@ -144,7 +144,7 @@ class CakeTestFixture {
|
|||
|
||||
if (empty($this->fields['tableParameters']['engine'])) {
|
||||
$canUseMemory = true;
|
||||
foreach($this->fields as $field => $args) {
|
||||
foreach ($this->fields as $field => $args) {
|
||||
|
||||
if (is_string($args)) {
|
||||
$type = $args;
|
||||
|
@ -205,7 +205,7 @@ class CakeTestFixture {
|
|||
$values = array();
|
||||
if (isset($this->records) && !empty($this->records)) {
|
||||
$fields = array();
|
||||
foreach($this->records as $record) {
|
||||
foreach ($this->records as $record) {
|
||||
$fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields)));
|
||||
}
|
||||
$fields = array_unique($fields);
|
||||
|
|
|
@ -39,7 +39,7 @@ class CakeTestModel extends Model {
|
|||
public function beforeFind($queryData) {
|
||||
$pk = $this->primaryKey;
|
||||
$aliasedPk = $this->alias . '.' . $this->primaryKey;
|
||||
switch(true) {
|
||||
switch (true) {
|
||||
case !$pk:
|
||||
case !$this->useTable:
|
||||
case !$this->schema('id'):
|
||||
|
|
|
@ -30,7 +30,7 @@ if (!empty($plugins)):
|
|||
?>
|
||||
<li style="padding-top: 10px">
|
||||
<span style="font-size: 18px">Plugins</span>
|
||||
<?php foreach($plugins as $plugin): ?>
|
||||
<?php foreach ($plugins as $plugin): ?>
|
||||
<ul>
|
||||
<li style="padding-top: 10px">
|
||||
<span style="font-size: 18px"><?php echo $plugin;?></span>
|
||||
|
|
|
@ -1208,7 +1208,7 @@ class FormHelper extends AppHelper {
|
|||
*/
|
||||
public function checkbox($fieldName, $options = array()) {
|
||||
$valueOptions = array();
|
||||
if(isset($options['default'])){
|
||||
if (isset($options['default'])) {
|
||||
$valueOptions['default'] = $options['default'];
|
||||
unset($options['default']);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
|||
if (isset($options['update'])) {
|
||||
$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
|
||||
$success = '';
|
||||
if(isset($options['success']) AND !empty($options['success'])) {
|
||||
if (isset($options['success']) AND !empty($options['success'])) {
|
||||
$success .= $options['success'];
|
||||
}
|
||||
$success .= $this->jQueryObject . '("' . $options['update'] . '").html(data);';
|
||||
|
|
|
@ -459,8 +459,8 @@ class TimeHelper extends AppHelper {
|
|||
public function toRSS($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
||||
if(!is_null($userOffset)) {
|
||||
if($userOffset == 0) {
|
||||
if (!is_null($userOffset)) {
|
||||
if ($userOffset == 0) {
|
||||
$timezone = '+0000';
|
||||
} else {
|
||||
$hours = (int) floor(abs($userOffset));
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Basic Cake functionality.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue