Skip to content

Commit 7672b97

Browse files
committed
Remove Name::append() and Name::prepend()
1 parent 8489364 commit 7672b97

File tree

4 files changed

+5
-46
lines changed

4 files changed

+5
-46
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ This release primarily improves our support for error recovery.
3030

3131
### Removed
3232

33+
* Removed `Name::append()` and `Name::prepend()`. These mutable methods have been superseded by
34+
the immutable `Name::concat()`.
3335
* Removed `Error::getRawLine()` and `Error::setRawLine()`. These methods have been superseded by
3436
`Error::getStartLine()` and `Error::setStartLine()`.
3537
* Removed support for node cloning in the `NodeTraverser`.

UPGRADE-3.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ This means that certain error conditions are no longer checked for manually cons
132132
The following methods, arguments or options have been removed:
133133

134134
* `Comment::setLine()`, `Comment::setText()`: Create new `Comment` instances instead.
135-
* `Name::set()`, `Name::setFirst()`, `Name::setLast()`: Create new `Name` instances instead. For
136-
the latter two a combination of `Name::concat()` and `Name::slice()` can be used.
135+
* `Name::set()`, `Name::setFirst()`, `Name::setLast()`, `Name::append()`, `Name::prepend()`:
136+
Use `Name::concat()` in combination with `Name::slice()` instead.
137137
* `Error::getRawLine()`, `Error::setRawLine()`. Use `Error::getStartLine()` and
138138
`Error::setStartLine()` instead.
139139
* `Parser::getErrors()`. Use `ErrorHandler\Collecting` instead.

lib/PhpParser/Node/Name.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,6 @@ public function __toString() {
102102
return implode('\\', $this->parts);
103103
}
104104

105-
/**
106-
* Prepends a name to this name.
107-
*
108-
* @deprecated Use Name::concat($name1, $name2) instead
109-
*
110-
* @param string|array|self $name Name to prepend
111-
*/
112-
public function prepend($name) {
113-
$this->parts = array_merge(self::prepareName($name), $this->parts);
114-
}
115-
116-
/**
117-
* Appends a name to this name.
118-
*
119-
* @deprecated Use Name::concat($name1, $name2) instead
120-
*
121-
* @param string|array|self $name Name to append
122-
*/
123-
public function append($name) {
124-
$this->parts = array_merge($this->parts, self::prepareName($name));
125-
}
126-
127105
/**
128106
* Gets a slice of a name (similar to array_slice).
129107
*

test/PhpParser/Node/NameTest.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,6 @@ public function testToString() {
2929
$this->assertSame('foo\bar', $name->toString());
3030
}
3131

32-
public function testAppend() {
33-
$name = new Name('foo');
34-
35-
$name->append('bar');
36-
$this->assertSame('foo\bar', $name->toString());
37-
38-
$name->append('bar\foo');
39-
$this->assertSame('foo\bar\bar\foo', $name->toString());
40-
}
41-
42-
public function testPrepend() {
43-
$name = new Name('foo');
44-
45-
$name->prepend('bar');
46-
$this->assertSame('bar\foo', $name->toString());
47-
48-
$name->prepend('foo\bar');
49-
$this->assertSame('foo\bar\bar\foo', $name->toString());
50-
}
51-
5232
public function testSlice() {
5333
$name = new Name('foo\bar\baz');
5434
$this->assertEquals(new Name('foo\bar\baz'), $name->slice(0));
@@ -145,7 +125,6 @@ public function testIs() {
145125
* @expectedExceptionMessage When changing a name you need to pass either a string, an array or a Name node
146126
*/
147127
public function testInvalidArg() {
148-
$name = new Name('foo');
149-
$name->append(new \stdClass);
128+
Name::concat('foo', new \stdClass);
150129
}
151130
}

0 commit comments

Comments
 (0)