From a67ddd953bd1536c49f0ce755f22dec7d60e7933 Mon Sep 17 00:00:00 2001
From: Philipp Scheit
Date: Wed, 25 Jun 2025 16:55:55 +0200
Subject: [PATCH 1/2] add missing test for StringDescription:: toString
---
tests/Hamcrest/StringDescriptionTest.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/Hamcrest/StringDescriptionTest.php b/tests/Hamcrest/StringDescriptionTest.php
index b42b9b469..4a403e994 100644
--- a/tests/Hamcrest/StringDescriptionTest.php
+++ b/tests/Hamcrest/StringDescriptionTest.php
@@ -162,4 +162,10 @@ public function testSelfDescribingObjectsCanBeAppendedAsIterators()
$this->_description->appendList('@start@', '@sep@ ', '@end@', $items->getIterator());
$this->assertEquals('@start@foo@sep@ bar@end@', (string) $this->_description);
}
+
+ public function testToStringAppendsSelfDescribing()
+ {
+ $description = $this->_description->toString(new \Hamcrest\SampleSelfDescriber('foo'));
+ $this->assertEquals('foo', $description);
+ }
}
From b99703b92d5203d90559ed8918fbf52f29d95044 Mon Sep 17 00:00:00 2001
From: Philipp Scheit
Date: Wed, 25 Jun 2025 20:24:48 +0200
Subject: [PATCH 2/2] Change return docblocks to static to reflect that $this
is returned
---
hamcrest/Hamcrest/Description.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hamcrest/Hamcrest/Description.php b/hamcrest/Hamcrest/Description.php
index 266bc1c44..b09554b28 100644
--- a/hamcrest/Hamcrest/Description.php
+++ b/hamcrest/Hamcrest/Description.php
@@ -19,7 +19,7 @@ interface Description
*
* @param string $text
*
- * @return \Hamcrest\Description
+ * @return static
*/
public function appendText($text);
@@ -29,7 +29,7 @@ public function appendText($text);
*
* @param \Hamcrest\SelfDescribing $value
*
- * @return \Hamcrest\Description
+ * @return static
*/
public function appendDescriptionOf(SelfDescribing $value);
@@ -38,7 +38,7 @@ public function appendDescriptionOf(SelfDescribing $value);
*
* @param mixed $value
*
- * @return \Hamcrest\Description
+ * @return static
*/
public function appendValue($value);
@@ -50,7 +50,7 @@ public function appendValue($value);
* @param string $end
* @param array|\IteratorAggregate|\Iterator $values
*
- * @return \Hamcrest\Description
+ * @return static
*/
public function appendValueList($start, $separator, $end, $values);
@@ -64,7 +64,7 @@ public function appendValueList($start, $separator, $end, $values);
* @param array|\\IteratorAggregate|\\Iterator $values
* must be instances of {@link Hamcrest\SelfDescribing}
*
- * @return \Hamcrest\Description
+ * @return static
*/
public function appendList($start, $separator, $end, $values);
}