Skip to content

Commit b740076

Browse files
committed
Remove deprecated Name::set*() methods
1 parent c9fea2e commit b740076

File tree

3 files changed

+4
-77
lines changed

3 files changed

+4
-77
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Version 3.0.0-dev
1717
to `items` and now contains `ArrayItem`s instead of plain variables.
1818
* [7.1] Added support for multi-catch. The `Catch` subnode `type` has been renamed to `types` and
1919
is now an array of `Name`s.
20+
* `Name::slice()` now supports lengths and negative offsets. This brings it in line with
21+
`array_slice()` functionality.
2022

2123
### Changed
2224

@@ -47,6 +49,7 @@ Additionally the following changes were made:
4749
* Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2-5.4 code
4850
while running on a newer version.
4951
* The deprecated `Comment::setLine()` and `Comment::setText()` methods have been removed.
52+
* The deprecated `Name::set()`, `Name::setFirst()` and `Name::setLast()` methods have been removed.
5053

5154
Version 2.1.0 (2016-04-19)
5255
--------------------------

lib/PhpParser/Node/Name.php

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

106-
/**
107-
* Sets the whole name.
108-
*
109-
* @deprecated Create a new Name instead, or manually modify the $parts property
110-
*
111-
* @param string|array|self $name The name to set the whole name to
112-
*/
113-
public function set($name) {
114-
$this->parts = self::prepareName($name);
115-
}
116-
117106
/**
118107
* Prepends a name to this name.
119108
*
@@ -136,26 +125,6 @@ public function append($name) {
136125
$this->parts = array_merge($this->parts, self::prepareName($name));
137126
}
138127

139-
/**
140-
* Sets the first part of the name.
141-
*
142-
* @deprecated Use concat($first, $name->slice(1)) instead
143-
*
144-
* @param string|array|self $name The name to set the first part to
145-
*/
146-
public function setFirst($name) {
147-
array_splice($this->parts, 0, 1, self::prepareName($name));
148-
}
149-
150-
/**
151-
* Sets the last part of the name.
152-
*
153-
* @param string|array|self $name The name to set the last part to
154-
*/
155-
public function setLast($name) {
156-
array_splice($this->parts, -1, 1, self::prepareName($name));
157-
}
158-
159128
/**
160129
* Gets a slice of a name (similar to array_slice).
161130
*

test/PhpParser/Node/NameTest.php

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,51 +30,6 @@ public function testToString() {
3030
$this->assertSame('foo_bar', $name->toString('_'));
3131
}
3232

33-
public function testSet() {
34-
$name = new Name('foo');
35-
36-
$name->set('foo\bar');
37-
$this->assertSame('foo\bar', $name->toString());
38-
39-
$name->set(array('foo', 'bar'));
40-
$this->assertSame('foo\bar', $name->toString());
41-
42-
$name->set(new Name('foo\bar'));
43-
$this->assertSame('foo\bar', $name->toString());
44-
}
45-
46-
public function testSetFirst() {
47-
$name = new Name('foo');
48-
49-
$name->setFirst('bar');
50-
$this->assertSame('bar', $name->toString());
51-
52-
$name->setFirst('A\B');
53-
$this->assertSame('A\B', $name->toString());
54-
55-
$name->setFirst('C');
56-
$this->assertSame('C\B', $name->toString());
57-
58-
$name->setFirst('D\E');
59-
$this->assertSame('D\E\B', $name->toString());
60-
}
61-
62-
public function testSetLast() {
63-
$name = new Name('foo');
64-
65-
$name->setLast('bar');
66-
$this->assertSame('bar', $name->toString());
67-
68-
$name->setLast('A\B');
69-
$this->assertSame('A\B', $name->toString());
70-
71-
$name->setLast('C');
72-
$this->assertSame('A\C', $name->toString());
73-
74-
$name->setLast('D\E');
75-
$this->assertSame('A\D\E', $name->toString());
76-
}
77-
7833
public function testAppend() {
7934
$name = new Name('foo');
8035

@@ -192,6 +147,6 @@ public function testIs() {
192147
*/
193148
public function testInvalidArg() {
194149
$name = new Name('foo');
195-
$name->set(new \stdClass);
150+
$name->append(new \stdClass);
196151
}
197152
}

0 commit comments

Comments
 (0)