Skip to content

Commit

Permalink
Unify and clean string based merges.
Browse files Browse the repository at this point in the history
Correct doc blocks.
  • Loading branch information
euromark committed Sep 5, 2014
1 parent b35cc28 commit 49ca2b2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/Auth/BasicAuthenticate.php
Expand Up @@ -82,8 +82,8 @@ public function getUser(Request $request) {
/**
* Handles an unauthenticated access attempt by sending appropriate login headers
*
* @param Request $request A request object.
* @param Response $response A response object.
* @param \Cake\Network\Request $request A request object.
* @param \Cake\Network\Response $response A response object.
* @return void
* @throws \Cake\Network\Exception\UnauthorizedException
*/
Expand Down
18 changes: 9 additions & 9 deletions src/Controller/Component/FlashComponent.php
Expand Up @@ -73,26 +73,26 @@ public function __construct(ComponentRegistry $collection, array $config = []) {
* @return void
*/
public function set($message, array $options = []) {
$opts = array_merge($this->config(), $options);
$options += $this->config();

if ($message instanceof \Exception) {
$opts['params'] += ['code' => $message->getCode()];
$options['params'] += ['code' => $message->getCode()];
$message = $message->getMessage();
}

list($plugin, $element) = pluginSplit($opts['element']);
list($plugin, $element) = pluginSplit($options['element']);

if ($plugin) {
$opts['element'] = $plugin . '.Flash/' . $element;
$options['element'] = $plugin . '.Flash/' . $element;
} else {
$opts['element'] = 'Flash/' . $element;
$options['element'] = 'Flash/' . $element;
}

$this->_session->write('Flash.' . $opts['key'], [
$this->_session->write('Flash.' . $options['key'], [
'message' => $message,
'key' => $opts['key'],
'element' => $opts['element'],
'params' => $opts['params']
'key' => $options['key'],
'element' => $options['element'],
'params' => $options['params']
]);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Error/Debugger.php
Expand Up @@ -300,11 +300,11 @@ public static function trace(array $options = array()) {
);

for ($i = $options['start']; $i < $count && $i < $options['depth']; $i++) {
$trace = array_merge(array('file' => '[internal]', 'line' => '??'), $backtrace[$i]);
$trace = $backtrace[$i] + array('file' => '[internal]', 'line' => '??');
$signature = $reference = '[main]';

if (isset($backtrace[$i + 1])) {
$next = array_merge($_trace, $backtrace[$i + 1]);
$next = $backtrace[$i + 1] + $_trace;
$signature = $reference = $next['function'];

if (!empty($next['class'])) {
Expand Down Expand Up @@ -689,7 +689,7 @@ public static function addFormat($format, array $strings) {
);
unset($strings['links']);
}
$self->_templates[$format] = array_merge($self->_templates[$format], $strings);
$self->_templates[$format] = $strings + $self->_templates[$format];
} else {
$self->_templates[$format] = $strings;
}
Expand Down Expand Up @@ -779,7 +779,7 @@ public function outputError($data) {

$data['trace'] = $trace;
$data['id'] = 'cakeErr' . uniqid();
$tpl = array_merge($this->_templates['base'], $this->_templates[$this->_outputFormat]);
$tpl = $this->_templates[$this->_outputFormat] + $this->_templates['base'];

if (isset($tpl['links'])) {
foreach ($tpl['links'] as $key => $val) {
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Http/Client.php
Expand Up @@ -425,7 +425,7 @@ protected function _typeHeaders($type) {
* Uses the authentication type to choose the correct strategy
* and use its methods to add headers.
*
* @param Request $request The request to modify.
* @param \Cake\Network\Http\Request $request The request to modify.
* @param array $options Array of options containing the 'auth' key.
* @return void
*/
Expand All @@ -441,7 +441,7 @@ protected function _addAuthentication(Request $request, $options) {
* Uses the authentication type to choose the correct strategy
* and use its methods to add headers.
*
* @param Request $request The request to modify.
* @param \Cake\Network\Http\Request $request The request to modify.
* @param array $options Array of options containing the 'proxy' key.
* @return void
*/
Expand Down
27 changes: 8 additions & 19 deletions src/View/Helper/PaginatorHelper.php
Expand Up @@ -343,10 +343,7 @@ public function next($title = 'Next >>', array $options = []) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::sort
*/
public function sort($key, $title = null, array $options = []) {
$options = array_merge(
['url' => array(), 'model' => null, 'escape' => true],
$options
);
$options += ['url' => array(), 'model' => null, 'escape' => true];
$url = $options['url'];
unset($options['url']);

Expand Down Expand Up @@ -519,6 +516,7 @@ public function defaultModel() {
* custom content you would like.
*
* @param string|array $options Options for the counter string. See #options for list of keys.
* If string it will be used as format.
* @return string Counter string.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::counter
*/
Expand All @@ -527,12 +525,10 @@ public function counter($options = []) {
$options = array('format' => $options);
}

$options = array_merge(
[
'model' => $this->defaultModel(),
'format' => 'pages',
],
$options);
$options += [
'model' => $this->defaultModel(),
'format' => 'pages',
];

$paging = $this->params($options['model']);
if (!$paging['pageCount']) {
Expand Down Expand Up @@ -737,10 +733,7 @@ public function numbers(array $options = array()) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::first
*/
public function first($first = '<< first', array $options = []) {
$options = array_merge(
['model' => $this->defaultModel(), 'escape' => true],
$options
);
$options += ['model' => $this->defaultModel(), 'escape' => true];

$params = $this->params($options['model']);

Expand Down Expand Up @@ -789,11 +782,7 @@ public function first($first = '<< first', array $options = []) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::last
*/
public function last($last = 'last >>', array $options = array()) {
$options = array_merge(
['model' => $this->defaultModel(), 'escape' => true],
$options
);

$options += ['model' => $this->defaultModel(), 'escape' => true];
$params = $this->params($options['model']);

if ($params['pageCount'] <= 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/TextHelper.php
Expand Up @@ -220,7 +220,7 @@ public function autoLinkEmails($text, array $options = array()) {
*/
public function autoLink($text, array $options = array()) {
$text = $this->autoLinkUrls($text, $options);
return $this->autoLinkEmails($text, array_merge($options, array('escape' => false)));
return $this->autoLinkEmails($text, array('escape' => false) + $options);
}

/**
Expand Down

0 comments on commit 49ca2b2

Please sign in to comment.