mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix more coding standards problems.
This commit is contained in:
parent
c2f42343a3
commit
664b0538b8
11 changed files with 86 additions and 68 deletions
|
@ -111,7 +111,7 @@ class ProjectTask extends AppShell {
|
||||||
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
|
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
|
||||||
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
|
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
|
||||||
} else {
|
} else {
|
||||||
$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS .'index.php'));
|
$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php'));
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
if ($success && $hardCode) {
|
if ($success && $hardCode) {
|
||||||
|
@ -120,8 +120,8 @@ class ProjectTask extends AppShell {
|
||||||
|
|
||||||
$Folder = new Folder($path);
|
$Folder = new Folder($path);
|
||||||
if (!$Folder->chmod($path . 'tmp', 0777)) {
|
if (!$Folder->chmod($path . 'tmp', 0777)) {
|
||||||
$this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS .'tmp'));
|
$this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS . 'tmp'));
|
||||||
$this->out(__d('cake_console', 'chmod -R 0777 %s', $path . DS .'tmp'));
|
$this->out(__d('cake_console', 'chmod -R 0777 %s', $path . DS . 'tmp'));
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
if ($success) {
|
if ($success) {
|
||||||
|
@ -229,7 +229,7 @@ class ProjectTask extends AppShell {
|
||||||
public function createHome($dir) {
|
public function createHome($dir) {
|
||||||
$app = basename($dir);
|
$app = basename($dir);
|
||||||
$path = $dir . 'View' . DS . 'Pages' . DS;
|
$path = $dir . 'View' . DS . 'Pages' . DS;
|
||||||
$source = CAKE . 'Console' . DS . 'Templates' . DS .'default' . DS . 'views' . DS . 'home.ctp';
|
$source = CAKE . 'Console' . DS . 'Templates' . DS . 'default' . DS . 'views' . DS . 'home.ctp';
|
||||||
include $source;
|
include $source;
|
||||||
return $this->createFile($path . 'home.ctp', $output);
|
return $this->createFile($path . 'home.ctp', $output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
/**
|
/**
|
||||||
* Use the DS to separate the directories in other defines
|
* Use the DS to separate the directories in other defines
|
||||||
*/
|
*/
|
||||||
if (!defined('DS')) {
|
if (!defined('DS')) {
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These defines should only be edited if you have cake installed in
|
* These defines should only be edited if you have cake installed in
|
||||||
|
@ -35,17 +35,17 @@
|
||||||
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!defined('ROOT')) {
|
if (!defined('ROOT')) {
|
||||||
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual directory name for the "app".
|
* The actual directory name for the "app".
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!defined('APP_DIR')) {
|
if (!defined('APP_DIR')) {
|
||||||
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
|
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
|
||||||
|
@ -58,41 +58,44 @@
|
||||||
*
|
*
|
||||||
* Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
|
* Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
|
||||||
*/
|
*/
|
||||||
//define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__);
|
//define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editing below this line should NOT be necessary.
|
* Editing below this line should NOT be necessary.
|
||||||
* Change at your own risk.
|
* Change at your own risk.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!defined('WEBROOT_DIR')) {
|
if (!defined('WEBROOT_DIR')) {
|
||||||
define('WEBROOT_DIR', basename(dirname(__FILE__)));
|
define('WEBROOT_DIR', basename(dirname(__FILE__)));
|
||||||
}
|
}
|
||||||
if (!defined('WWW_ROOT')) {
|
if (!defined('WWW_ROOT')) {
|
||||||
define('WWW_ROOT', dirname(__FILE__) . DS);
|
define('WWW_ROOT', dirname(__FILE__) . DS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
||||||
if (function_exists('ini_set')) {
|
if (function_exists('ini_set')) {
|
||||||
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
|
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
|
||||||
}
|
|
||||||
if (!include('Cake' . DS . 'bootstrap.php')) {
|
|
||||||
$failed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
|
|
||||||
$failed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!empty($failed)) {
|
if (!include 'Cake' . DS . 'bootstrap.php') {
|
||||||
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
$failed = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/favicon.ico') {
|
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
|
||||||
return;
|
$failed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!empty($failed)) {
|
||||||
|
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
App::uses('Dispatcher', 'Routing');
|
if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/favicon.ico') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$Dispatcher = new Dispatcher();
|
App::uses('Dispatcher', 'Routing');
|
||||||
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
|
|
||||||
|
$Dispatcher = new Dispatcher();
|
||||||
|
$Dispatcher->dispatch(
|
||||||
|
new CakeRequest(),
|
||||||
|
new CakeResponse(array('charset' => Configure::read('App.encoding')))
|
||||||
|
);
|
||||||
|
|
|
@ -21,9 +21,9 @@ ini_set('display_errors', 1);
|
||||||
/**
|
/**
|
||||||
* Use the DS to separate the directories in other defines
|
* Use the DS to separate the directories in other defines
|
||||||
*/
|
*/
|
||||||
if (!defined('DS')) {
|
if (!defined('DS')) {
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These defines should only be edited if you have cake installed in
|
* These defines should only be edited if you have cake installed in
|
||||||
|
@ -35,17 +35,17 @@ ini_set('display_errors', 1);
|
||||||
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!defined('ROOT')) {
|
if (!defined('ROOT')) {
|
||||||
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual directory name for the "app".
|
* The actual directory name for the "app".
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!defined('APP_DIR')) {
|
if (!defined('APP_DIR')) {
|
||||||
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
|
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
|
||||||
|
@ -55,7 +55,7 @@ ini_set('display_errors', 1);
|
||||||
*
|
*
|
||||||
* Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
|
* Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
|
||||||
*/
|
*/
|
||||||
//define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__);
|
//define('CAKE_CORE_INCLUDE_PATH', __CAKE_PATH__);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editing below this line should not be necessary.
|
* Editing below this line should not be necessary.
|
||||||
|
@ -73,11 +73,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
||||||
if (function_exists('ini_set')) {
|
if (function_exists('ini_set')) {
|
||||||
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
|
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
|
||||||
}
|
}
|
||||||
if (!include('Cake' . DS . 'bootstrap.php')) {
|
if (!include 'Cake' . DS . 'bootstrap.php') {
|
||||||
$failed = true;
|
$failed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
|
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
|
||||||
$failed = true;
|
$failed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,6 +404,8 @@ class I18n {
|
||||||
public static function loadMo($filename) {
|
public static function loadMo($filename) {
|
||||||
$translations = false;
|
$translations = false;
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
// Binary files extracted makes non-standard local variables
|
||||||
if ($data = file_get_contents($filename)) {
|
if ($data = file_get_contents($filename)) {
|
||||||
$translations = array();
|
$translations = array();
|
||||||
$header = substr($data, 0, 20);
|
$header = substr($data, 0, 20);
|
||||||
|
@ -433,6 +435,7 @@ class I18n {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
return $translations;
|
return $translations;
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,6 +442,8 @@ class Mysql extends DboSource {
|
||||||
$old = version_compare($this->getVersion(), '4.1', '<=');
|
$old = version_compare($this->getVersion(), '4.1', '<=');
|
||||||
if ($table) {
|
if ($table) {
|
||||||
$indices = $this->_execute('SHOW INDEX FROM ' . $table);
|
$indices = $this->_execute('SHOW INDEX FROM ' . $table);
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
// MySQL columns don't match the cakephp conventions.
|
||||||
while ($idx = $indices->fetch(PDO::FETCH_OBJ)) {
|
while ($idx = $indices->fetch(PDO::FETCH_OBJ)) {
|
||||||
if ($old) {
|
if ($old) {
|
||||||
$idx = (object)current((array)$idx);
|
$idx = (object)current((array)$idx);
|
||||||
|
@ -458,6 +460,7 @@ class Mysql extends DboSource {
|
||||||
$index[$idx->Key_name]['column'] = $col;
|
$index[$idx->Key_name]['column'] = $col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
$indices->closeCursor();
|
$indices->closeCursor();
|
||||||
}
|
}
|
||||||
return $index;
|
return $index;
|
||||||
|
|
|
@ -200,6 +200,8 @@ class Postgres extends DboSource {
|
||||||
array($table, $this->config['schema'])
|
array($table, $this->config['schema'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
// Postgres columns don't match the coding standards.
|
||||||
foreach ($cols as $c) {
|
foreach ($cols as $c) {
|
||||||
$type = $c->type;
|
$type = $c->type;
|
||||||
if (!empty($c->oct_length) && $c->char_length === null) {
|
if (!empty($c->oct_length) && $c->char_length === null) {
|
||||||
|
@ -257,6 +259,8 @@ class Postgres extends DboSource {
|
||||||
}
|
}
|
||||||
$this->_cacheDescription($table, $fields);
|
$this->_cacheDescription($table, $fields);
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
if (isset($model->sequence)) {
|
if (isset($model->sequence)) {
|
||||||
$this->_sequenceMap[$table][$model->primaryKey] = $model->sequence;
|
$this->_sequenceMap[$table][$model->primaryKey] = $model->sequence;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2833,7 +2833,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
$field = $this->alias . '.' . $this->primaryKey;
|
$field = $this->alias . '.' . $this->primaryKey;
|
||||||
$value = $this->id;
|
$value = $this->id;
|
||||||
}
|
}
|
||||||
$query['conditions'] = array_merge($conditions, array($field . ' <' => $value));
|
$query['conditions'] = array_merge($conditions, array($field . ' <' => $value));
|
||||||
$query['order'] = $field . ' DESC';
|
$query['order'] = $field . ' DESC';
|
||||||
$query['limit'] = 1;
|
$query['limit'] = 1;
|
||||||
$query['field'] = $field;
|
$query['field'] = $field;
|
||||||
|
|
|
@ -175,9 +175,11 @@ class Set {
|
||||||
}
|
}
|
||||||
} elseif (is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
if ($primary === true) {
|
if ($primary === true) {
|
||||||
|
// @codingStandardsIgnoreStart Legacy junk
|
||||||
if (!isset($out->_name_)) {
|
if (!isset($out->_name_)) {
|
||||||
$out->_name_ = $key;
|
$out->_name_ = $key;
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
$primary = false;
|
$primary = false;
|
||||||
foreach ($value as $key2 => $value2) {
|
foreach ($value as $key2 => $value2) {
|
||||||
$out->{$key2} = Set::_map($value2, true);
|
$out->{$key2} = Set::_map($value2, true);
|
||||||
|
@ -975,11 +977,13 @@ class Set {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$new[$key] = (array)Set::reverse($value);
|
$new[$key] = (array)Set::reverse($value);
|
||||||
} else {
|
} else {
|
||||||
|
// @codingStandardsIgnoreStart Legacy junk
|
||||||
if (isset($value->_name_)) {
|
if (isset($value->_name_)) {
|
||||||
$new = array_merge($new, Set::reverse($value));
|
$new = array_merge($new, Set::reverse($value));
|
||||||
} else {
|
} else {
|
||||||
$new[$key] = Set::reverse($value);
|
$new[$key] = Set::reverse($value);
|
||||||
}
|
}
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($identity)) {
|
if (isset($identity)) {
|
||||||
|
|
|
@ -229,7 +229,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
||||||
$name = ($name == 'slideIn') ? 'slideDown' : 'slideUp';
|
$name = ($name == 'slideIn') ? 'slideDown' : 'slideUp';
|
||||||
case 'hide':
|
case 'hide':
|
||||||
case 'show':
|
case 'show':
|
||||||
case 'fadeIn':
|
case 'fadeIn':
|
||||||
case 'fadeOut':
|
case 'fadeOut':
|
||||||
case 'slideDown':
|
case 'slideDown':
|
||||||
case 'slideUp':
|
case 'slideUp':
|
||||||
|
|
|
@ -44,7 +44,7 @@ function config() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
foreach ($args as $arg) {
|
foreach ($args as $arg) {
|
||||||
if (file_exists(APP . 'Config' . DS . $arg . '.php')) {
|
if (file_exists(APP . 'Config' . DS . $arg . '.php')) {
|
||||||
include_once(APP . 'Config' . DS . $arg . '.php');
|
include_once APP . 'Config' . DS . $arg . '.php';
|
||||||
|
|
||||||
if (count($args) == 1) {
|
if (count($args) == 1) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -118,16 +118,16 @@ TEXT;
|
||||||
|
|
||||||
if (!function_exists('sortByKey')) {
|
if (!function_exists('sortByKey')) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts given $array by key $sortby.
|
* Sorts given $array by key $sortby.
|
||||||
*
|
*
|
||||||
* @param array $array Array to sort
|
* @param array $array Array to sort
|
||||||
* @param string $sortby Sort by this key
|
* @param string $sortby Sort by this key
|
||||||
* @param string $order Sort order asc/desc (ascending or descending).
|
* @param string $order Sort order asc/desc (ascending or descending).
|
||||||
* @param integer $type Type of sorting to perform
|
* @param integer $type Type of sorting to perform
|
||||||
* @return mixed Sorted array
|
* @return mixed Sorted array
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#sortByKey
|
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#sortByKey
|
||||||
*/
|
*/
|
||||||
function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
|
function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
|
||||||
if (!is_array($array)) {
|
if (!is_array($array)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -170,7 +170,7 @@ function h($text, $double = true, $charset = null) {
|
||||||
return $texts;
|
return $texts;
|
||||||
} elseif (is_object($text)) {
|
} elseif (is_object($text)) {
|
||||||
if (method_exists($text, '__toString')) {
|
if (method_exists($text, '__toString')) {
|
||||||
$text = (string) $text;
|
$text = (string)$text;
|
||||||
} else {
|
} else {
|
||||||
$text = '(object)' . get_class($text);
|
$text = '(object)' . get_class($text);
|
||||||
}
|
}
|
||||||
|
@ -752,3 +752,4 @@ function convertSlash($string) {
|
||||||
$string = str_replace('/', '_', $string);
|
$string = str_replace('/', '_', $string);
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ if (!defined('WEBROOT_DIR')) {
|
||||||
* Path to the application's directory.
|
* Path to the application's directory.
|
||||||
*/
|
*/
|
||||||
if (!defined('APP')) {
|
if (!defined('APP')) {
|
||||||
define('APP', ROOT . DS . APP_DIR.DS);
|
define('APP', ROOT . DS . APP_DIR . DS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ if (!defined('JS_URL')) {
|
||||||
|
|
||||||
|
|
||||||
require CAKE . 'basics.php';
|
require CAKE . 'basics.php';
|
||||||
require CAKE . 'Core' . DS .'App.php';
|
require CAKE . 'Core' . DS . 'App.php';
|
||||||
require CAKE . 'Error' . DS . 'exceptions.php';
|
require CAKE . 'Error' . DS . 'exceptions.php';
|
||||||
|
|
||||||
spl_autoload_register(array('App', 'load'));
|
spl_autoload_register(array('App', 'load'));
|
||||||
|
|
Loading…
Reference in a new issue