Browse Source

changed parameter ordering.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
c3df0beecd
  1. 6
      framework/yii/helpers/base/Html.php
  2. 4
      tests/unit/framework/helpers/HtmlTest.php

6
framework/yii/helpers/base/Html.php

@ -855,7 +855,7 @@ class Html
* The signature of this callback must be: * The signature of this callback must be:
* *
* ~~~ * ~~~
* function ($index, $item) * function ($item, $index)
* ~~~ * ~~~
* *
* where $index is the array key corresponding to `$item` in `$items`. The callback should return * where $index is the array key corresponding to `$item` in `$items`. The callback should return
@ -876,7 +876,7 @@ class Html
$results = array(); $results = array();
foreach ($items as $index => $item) { foreach ($items as $index => $item) {
if ($formatter !== null) { if ($formatter !== null) {
$results[] = call_user_func($formatter, $index, $item); $results[] = call_user_func($formatter, $item, $index);
} else { } else {
$results[] = static::tag('li', $encode ? static::encode($item) : $item, $itemOptions); $results[] = static::tag('li', $encode ? static::encode($item) : $item, $itemOptions);
} }
@ -897,7 +897,7 @@ class Html
* The signature of this callback must be: * The signature of this callback must be:
* *
* ~~~ * ~~~
* function ($index, $item) * function ($item, $index)
* ~~~ * ~~~
* *
* where $index is the array key corresponding to `$item` in `$items`. The callback should return * where $index is the array key corresponding to `$item` in `$items`. The callback should return

4
tests/unit/framework/helpers/HtmlTest.php

@ -388,7 +388,7 @@ EOD;
EOD; EOD;
$this->assertEqualsWithoutLE($expected, Html::ul($data, array( $this->assertEqualsWithoutLE($expected, Html::ul($data, array(
'class' => 'test', 'class' => 'test',
'item' => function($index, $item) { 'item' => function($item, $index) {
return "<li class=\"item-$index\">$item</li>"; return "<li class=\"item-$index\">$item</li>";
} }
))); )));
@ -418,7 +418,7 @@ EOD;
EOD; EOD;
$this->assertEqualsWithoutLE($expected, Html::ol($data, array( $this->assertEqualsWithoutLE($expected, Html::ol($data, array(
'class' => 'test', 'class' => 'test',
'item' => function($index, $item) { 'item' => function($item, $index) {
return "<li class=\"item-$index\">$item</li>"; return "<li class=\"item-$index\">$item</li>";
} }
))); )));

Loading…
Cancel
Save