mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Remove deprecated Name::set*() methods
This commit is contained in:
parent
c9fea2ef67
commit
b740076ab1
@ -17,6 +17,8 @@ Version 3.0.0-dev
|
||||
to `items` and now contains `ArrayItem`s instead of plain variables.
|
||||
* [7.1] Added support for multi-catch. The `Catch` subnode `type` has been renamed to `types` and
|
||||
is now an array of `Name`s.
|
||||
* `Name::slice()` now supports lengths and negative offsets. This brings it in line with
|
||||
`array_slice()` functionality.
|
||||
|
||||
### Changed
|
||||
|
||||
@ -47,6 +49,7 @@ Additionally the following changes were made:
|
||||
* Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2-5.4 code
|
||||
while running on a newer version.
|
||||
* The deprecated `Comment::setLine()` and `Comment::setText()` methods have been removed.
|
||||
* The deprecated `Name::set()`, `Name::setFirst()` and `Name::setLast()` methods have been removed.
|
||||
|
||||
Version 2.1.0 (2016-04-19)
|
||||
--------------------------
|
||||
|
@ -103,17 +103,6 @@ class Name extends NodeAbstract
|
||||
return implode('\\', $this->parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the whole name.
|
||||
*
|
||||
* @deprecated Create a new Name instead, or manually modify the $parts property
|
||||
*
|
||||
* @param string|array|self $name The name to set the whole name to
|
||||
*/
|
||||
public function set($name) {
|
||||
$this->parts = self::prepareName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends a name to this name.
|
||||
*
|
||||
@ -136,26 +125,6 @@ class Name extends NodeAbstract
|
||||
$this->parts = array_merge($this->parts, self::prepareName($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the first part of the name.
|
||||
*
|
||||
* @deprecated Use concat($first, $name->slice(1)) instead
|
||||
*
|
||||
* @param string|array|self $name The name to set the first part to
|
||||
*/
|
||||
public function setFirst($name) {
|
||||
array_splice($this->parts, 0, 1, self::prepareName($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last part of the name.
|
||||
*
|
||||
* @param string|array|self $name The name to set the last part to
|
||||
*/
|
||||
public function setLast($name) {
|
||||
array_splice($this->parts, -1, 1, self::prepareName($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a slice of a name (similar to array_slice).
|
||||
*
|
||||
|
@ -30,51 +30,6 @@ class NameTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('foo_bar', $name->toString('_'));
|
||||
}
|
||||
|
||||
public function testSet() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->set('foo\bar');
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
|
||||
$name->set(array('foo', 'bar'));
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
|
||||
$name->set(new Name('foo\bar'));
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
}
|
||||
|
||||
public function testSetFirst() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->setFirst('bar');
|
||||
$this->assertSame('bar', $name->toString());
|
||||
|
||||
$name->setFirst('A\B');
|
||||
$this->assertSame('A\B', $name->toString());
|
||||
|
||||
$name->setFirst('C');
|
||||
$this->assertSame('C\B', $name->toString());
|
||||
|
||||
$name->setFirst('D\E');
|
||||
$this->assertSame('D\E\B', $name->toString());
|
||||
}
|
||||
|
||||
public function testSetLast() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->setLast('bar');
|
||||
$this->assertSame('bar', $name->toString());
|
||||
|
||||
$name->setLast('A\B');
|
||||
$this->assertSame('A\B', $name->toString());
|
||||
|
||||
$name->setLast('C');
|
||||
$this->assertSame('A\C', $name->toString());
|
||||
|
||||
$name->setLast('D\E');
|
||||
$this->assertSame('A\D\E', $name->toString());
|
||||
}
|
||||
|
||||
public function testAppend() {
|
||||
$name = new Name('foo');
|
||||
|
||||
@ -192,6 +147,6 @@ class NameTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testInvalidArg() {
|
||||
$name = new Name('foo');
|
||||
$name->set(new \stdClass);
|
||||
$name->append(new \stdClass);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user