Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix. HTMLhelper ul and ol attributes type #2488

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions system/Helpers/html_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
* multi-dimensional array.
*
* @param array $list
* @param string $attributes HTML attributes
* @param array $attributes HTML attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param mixed   $attributes string, array, object HTML attributes

* @return string
*/
function ul(array $list, string $attributes = ''): string
function ul(array $list, array $attributes = []): string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function ul(array $list, $attributes = ''): string

{
return _list('ul', $list, $attributes);
}
Expand All @@ -71,10 +71,10 @@ function ul(array $list, string $attributes = ''): string
* Generates an HTML ordered list from an single or multi-dimensional array.
*
* @param array $list
* @param string $attributes HTML attributes
* @param array $attributes HTML attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param mixed   $attributes string, array, object HTML attributes

* @return string
*/
function ol(array $list, string $attributes = ''): string
function ol(array $list, array $attributes = []): string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function ol(array $list, $attributes = ''): string

{
return _list('ol', $list, $attributes);
}
Expand All @@ -91,11 +91,11 @@ function ol(array $list, string $attributes = ''): string
*
* @param string $type
* @param mixed $list
* @param string $attributes
* @param array $attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param mixed   $attributes string, array, object HTML attributes

* @param integer $depth
* @return string
*/
function _list(string $type = 'ul', $list = [], string $attributes = '', int $depth = 0): string
function _list(string $type = 'ul', $list = [], array $attributes = [], int $depth = 0): string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function _list(string $type = 'ul', $list = [], $attributes = [], int $depth = 0): string

{
// Set the indentation based on the depth
$out = str_repeat(' ', $depth)
Expand All @@ -120,7 +120,7 @@ function _list(string $type = 'ul', $list = [], string $attributes = '', int $de
{
$out .= $_last_list_item
. "\n"
. _list($type, $val, '', $depth + 4)
. _list($type, $val, [], $depth + 4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed change

. str_repeat(' ', $depth + 2);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/system/Helpers/HTMLHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testBasicUL()
public function testULWithClass()
{
$expected = <<<EOH
<ul class="test">
<ul id="testID" class="test">
<li>foo</li>
<li>bar</li>
</ul>
Expand All @@ -57,7 +57,7 @@ public function testULWithClass()
'bar',
];

$this->assertEquals($expected, ul($list, 'class="test"'));
$this->assertEquals($expected, ul($list, ['id' => 'testID', 'class' => 'test']));
}

public function testMultiLevelUL()
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testBasicOL()
public function testOLWithClass()
{
$expected = <<<EOH
<ol class="test">
<ol id="testID" class="test">
<li>foo</li>
<li>bar</li>
</ol>
Expand All @@ -126,7 +126,7 @@ public function testOLWithClass()
'bar',
];

$this->assertEquals($expected, ol($list, 'class="test"'));
$this->assertEquals($expected, ol($list, ['id' => 'testID', 'class' => 'test']));
}

public function testMultiLevelOL()
Expand Down