mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
remove undocumented code and uncessary in_array() checks + cleanup
This commit is contained in:
parent
2dd423644b
commit
fc2d28974b
10 changed files with 25 additions and 20 deletions
|
@ -94,7 +94,7 @@ class ComponentCollection extends ObjectCollection implements CakeEventListener
|
|||
* @throws MissingComponentException when the component could not be found
|
||||
*/
|
||||
public function load($component, $settings = array()) {
|
||||
if (is_array($settings) && isset($settings['className'])) {
|
||||
if (isset($settings['className'])) {
|
||||
$alias = $component;
|
||||
$component = $settings['className'];
|
||||
}
|
||||
|
|
|
@ -418,7 +418,8 @@ class L10n {
|
|||
if (isset($this->_l10nCatalog[$langKey])) {
|
||||
$this->_setLanguage($langKey);
|
||||
return true;
|
||||
} elseif (strpos($langKey, '-') !== false) {
|
||||
}
|
||||
if (strpos($langKey, '-') !== false) {
|
||||
$langKey = substr($langKey, 0, 2);
|
||||
if (isset($this->_l10nCatalog[$langKey])) {
|
||||
$this->_setLanguage($langKey);
|
||||
|
@ -445,10 +446,12 @@ class L10n {
|
|||
}
|
||||
}
|
||||
return $result;
|
||||
} elseif (is_string($mixed)) {
|
||||
}
|
||||
if (is_string($mixed)) {
|
||||
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
|
||||
return array_search($mixed, $this->_l10nMap);
|
||||
} elseif (isset($this->_l10nMap[$mixed])) {
|
||||
}
|
||||
if (isset($this->_l10nMap[$mixed])) {
|
||||
return $this->_l10nMap[$mixed];
|
||||
}
|
||||
return false;
|
||||
|
@ -472,10 +475,12 @@ class L10n {
|
|||
}
|
||||
}
|
||||
return $result;
|
||||
} elseif (is_string($language)) {
|
||||
}
|
||||
if (is_string($language)) {
|
||||
if (isset($this->_l10nCatalog[$language])) {
|
||||
return $this->_l10nCatalog[$language];
|
||||
} elseif (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
|
||||
}
|
||||
if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
|
||||
return $this->_l10nCatalog[$this->_l10nMap[$language]];
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -103,7 +103,7 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener {
|
|||
* @throws MissingBehaviorException when a behavior could not be found.
|
||||
*/
|
||||
public function load($behavior, $config = array()) {
|
||||
if (is_array($config) && isset($config['className'])) {
|
||||
if (isset($config['className'])) {
|
||||
$alias = $behavior;
|
||||
$behavior = $config['className'];
|
||||
}
|
||||
|
|
|
@ -1832,9 +1832,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$result = $this->Html->tag('div', 'text');
|
||||
$this->assertTags($result, '<div', 'text', '/div');
|
||||
|
||||
$result = $this->Html->tag('div', '<text>', 'class-name');
|
||||
$this->assertTags($result, array('div' => array('class' => 'class-name'), 'preg:/<text>/', '/div'));
|
||||
|
||||
$result = $this->Html->tag('div', '<text>', array('class' => 'class-name', 'escape' => true));
|
||||
$this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div'));
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class TimeHelperTest extends CakeTestCase {
|
|||
'nice', 'niceShort', 'daysAsSql', 'dayAsSql',
|
||||
'isToday', 'isThisMonth', 'isThisYear', 'wasYesterday',
|
||||
'isTomorrow', 'toQuarter', 'toUnix', 'toAtom', 'toRSS',
|
||||
'timeAgoInWords', 'wasWithinLast', 'gmt', 'format', 'i18nFormat',
|
||||
'wasWithinLast', 'gmt', 'format', 'i18nFormat',
|
||||
);
|
||||
$CakeTime = $this->getMock('CakeTimeMock', $methods);
|
||||
$Time = new TimeHelperTestObject($this->View, array('engine' => 'CakeTimeMock'));
|
||||
|
@ -96,6 +96,12 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$CakeTime->expects($this->at(0))->method($method);
|
||||
$Time->{$method}('who', 'what', 'when', 'where', 'how');
|
||||
}
|
||||
|
||||
$CakeTime = $this->getMock('CakeTimeMock', array('timeAgoInWords'));
|
||||
$Time = new TimeHelperTestObject($this->View, array('engine' => 'CakeTimeMock'));
|
||||
$Time->attach($CakeTime);
|
||||
$CakeTime->expects($this->at(0))->method('timeAgoInWords');
|
||||
$Time->timeAgoInWords('who', array('what'), array('when'), array('where'), array('how'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -918,13 +918,10 @@ class HtmlHelper extends AppHelper {
|
|||
if (empty($name)) {
|
||||
return $text;
|
||||
}
|
||||
if (is_array($options) && isset($options['escape']) && $options['escape']) {
|
||||
if (isset($options['escape']) && $options['escape']) {
|
||||
$text = h($text);
|
||||
unset($options['escape']);
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
$options = array('class' => $options);
|
||||
}
|
||||
if ($text === null) {
|
||||
$tag = 'tagstart';
|
||||
} else {
|
||||
|
|
|
@ -82,7 +82,7 @@ class JsHelper extends AppHelper {
|
|||
* Constructor - determines engine helper
|
||||
*
|
||||
* @param View $View the view object the helper is attached to.
|
||||
* @param array $settings Settings array contains name of engine helper.
|
||||
* @param string|array $settings Settings array contains name of engine helper.
|
||||
*/
|
||||
public function __construct(View $View, $settings = array()) {
|
||||
$className = 'Jquery';
|
||||
|
|
|
@ -361,7 +361,7 @@ class TimeHelper extends AppHelper {
|
|||
public function timeAgoInWords($dateTime, $options = array()) {
|
||||
$element = null;
|
||||
|
||||
if (is_array($options) && !empty($options['element'])) {
|
||||
if (!empty($options['element'])) {
|
||||
$element = array(
|
||||
'tag' => 'span',
|
||||
'class' => 'time-ago-in-words',
|
||||
|
|
|
@ -113,7 +113,7 @@ class HelperCollection extends ObjectCollection implements CakeEventListener {
|
|||
* @throws MissingHelperException when the helper could not be found
|
||||
*/
|
||||
public function load($helper, $settings = array()) {
|
||||
if (is_array($settings) && isset($settings['className'])) {
|
||||
if (isset($settings['className'])) {
|
||||
$alias = $helper;
|
||||
$helper = $settings['className'];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue