Skip to content
Open
Changes from 1 commit
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
33 changes: 33 additions & 0 deletions test/Horde/Url/StringableParamTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* @author Torben Dannhauer / GPT-5
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @category Horde
* @package Url
* @subpackage UnitTests
*/

namespace Horde\Url;
use \PHPUnit\Framework\TestCase;
use \Horde_Url;

class StringableParamTest extends TestCase
{
private function getStringableObject($value)
{
return new class($value) {
private $value;
public function __construct($value) { $this->value = $value; }
public function __toString() { return (string)$this->value; }
};
}
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Method uses tabs for indentation which is inconsistent with PSR-12 coding standards that recommend 4 spaces.

Suggested change
}
private function getStringableObject($value)
{
return new class($value) {
private $value;
public function __construct($value) { $this->value = $value; }
public function __toString() { return (string)$this->value; }
};
}

Copilot uses AI. Check for mistakes.

public function testStringableObjectAsParamValue()
{
$this->markTestIncomplete('Generalized normalization for all stringable objects may be implemented later.');
$url = new Horde_Url('test');
$url->add('s', $this->getStringableObject('a&b'));
// Current implementation only normalizes Horde_Url instances; generic stringables are not cast explicitly.
// Keep test incomplete until generalized handling is agreed upon.
}
Copy link
Contributor

@amulet1 amulet1 Aug 13, 2025

Choose a reason for hiding this comment

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

Do we want to make it truly universal? Then I guess we need to check for presence of __toString method (see my other comments also). Are we okay with using ReflectionClass::hasMethodor method_exists (instead of explicit conversion)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest PHP is not my home run, so I do not feel experienced enough for the decisions there. @ralflang what do you think?

}
Loading