diff --git a/CHANGELOG.md b/CHANGELOG.md index 51fed7b..57ca173 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ This release primarily improves our support for error recovery. ### Removed +* Removed `Name::append()` and `Name::prepend()`. These mutable methods have been superseded by + the immutable `Name::concat()`. * Removed `Error::getRawLine()` and `Error::setRawLine()`. These methods have been superseded by `Error::getStartLine()` and `Error::setStartLine()`. * Removed support for node cloning in the `NodeTraverser`. diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 1e1e91e..92fd4da 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -132,8 +132,8 @@ This means that certain error conditions are no longer checked for manually cons The following methods, arguments or options have been removed: * `Comment::setLine()`, `Comment::setText()`: Create new `Comment` instances instead. - * `Name::set()`, `Name::setFirst()`, `Name::setLast()`: Create new `Name` instances instead. For - the latter two a combination of `Name::concat()` and `Name::slice()` can be used. + * `Name::set()`, `Name::setFirst()`, `Name::setLast()`, `Name::append()`, `Name::prepend()`: + Use `Name::concat()` in combination with `Name::slice()` instead. * `Error::getRawLine()`, `Error::setRawLine()`. Use `Error::getStartLine()` and `Error::setStartLine()` instead. * `Parser::getErrors()`. Use `ErrorHandler\Collecting` instead. diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index efe8e93..f3e64dc 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -102,28 +102,6 @@ class Name extends NodeAbstract return implode('\\', $this->parts); } - /** - * Prepends a name to this name. - * - * @deprecated Use Name::concat($name1, $name2) instead - * - * @param string|array|self $name Name to prepend - */ - public function prepend($name) { - $this->parts = array_merge(self::prepareName($name), $this->parts); - } - - /** - * Appends a name to this name. - * - * @deprecated Use Name::concat($name1, $name2) instead - * - * @param string|array|self $name Name to append - */ - public function append($name) { - $this->parts = array_merge($this->parts, self::prepareName($name)); - } - /** * Gets a slice of a name (similar to array_slice). * diff --git a/test/PhpParser/Node/NameTest.php b/test/PhpParser/Node/NameTest.php index 4fa96c6..b236bc0 100644 --- a/test/PhpParser/Node/NameTest.php +++ b/test/PhpParser/Node/NameTest.php @@ -29,26 +29,6 @@ class NameTest extends \PHPUnit_Framework_TestCase $this->assertSame('foo\bar', $name->toString()); } - public function testAppend() { - $name = new Name('foo'); - - $name->append('bar'); - $this->assertSame('foo\bar', $name->toString()); - - $name->append('bar\foo'); - $this->assertSame('foo\bar\bar\foo', $name->toString()); - } - - public function testPrepend() { - $name = new Name('foo'); - - $name->prepend('bar'); - $this->assertSame('bar\foo', $name->toString()); - - $name->prepend('foo\bar'); - $this->assertSame('foo\bar\bar\foo', $name->toString()); - } - public function testSlice() { $name = new Name('foo\bar\baz'); $this->assertEquals(new Name('foo\bar\baz'), $name->slice(0)); @@ -145,7 +125,6 @@ class NameTest extends \PHPUnit_Framework_TestCase * @expectedExceptionMessage When changing a name you need to pass either a string, an array or a Name node */ public function testInvalidArg() { - $name = new Name('foo'); - $name->append(new \stdClass); + Name::concat('foo', new \stdClass); } } \ No newline at end of file