mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Remove Name::append() and Name::prepend()
This commit is contained in:
parent
8489364528
commit
7672b974ff
@ -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`.
|
||||
|
@ -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.
|
||||
|
@ -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).
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user