Skip to content

Commit 9b9d2b5

Browse files
committed
Remove PHP 5 specific exception handling from lang.Throwable::wrap()
1 parent 1fc79d6 commit 9b9d2b5

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

ChangeLog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ XP Framework Core ChangeLog
55

66
### Features
77

8-
* Suppress *implicitly nullable parameter types* deprecation warning as
8+
* Removed PHP 5 specific exception handling from `lang.Throwable::wrap()`
9+
(@thekid)
10+
* Suppressed *implicitly nullable parameter types* deprecation warning as
911
there is no way of fixing these syntactically as long as we support
1012
PHP 7.0. See issue #336 and xp-framework/rfc#343
1113
(@thekid)

src/main/php/lang/Throwable.class.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@ public function __construct($message, $cause= null, $fill= true) {
3737
/**
3838
* Wraps an exception inside a throwable
3939
*
40-
* @param lang.Throwable|php.Throwable|php.Exception $e
40+
* @param lang.Throwable|php.Throwable $e
4141
* @return self
4242
* @throws lang.IllegalArgumentException
4343
*/
4444
public static function wrap($e): self {
4545
if ($e instanceof self) {
4646
return $e;
47-
} else if ($e instanceof \BadMethodCallException) {
48-
$wrapped= new Error($e->getMessage(), $e->getPrevious(), false);
49-
} else if ($e instanceof \Exception) {
50-
$wrapped= new XPException($e->getMessage(), $e->getPrevious(), false);
5147
} else if ($e instanceof \Throwable) {
5248
$wrapped= new Error($e->getMessage(), $e->getPrevious(), false);
5349
} else {

src/test/php/lang/unittest/ExceptionsTest.class.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use io\streams\{MemoryOutputStream, Streams};
44
use lang\{Error, IllegalArgumentException, Throwable, XPClass, XPException};
5-
use test\verify\Runtime;
65
use test\{Action, Assert, Expect, Test};
76

87
class ExceptionsTest {
@@ -132,13 +131,7 @@ public function wrap_xp_exceptions() {
132131
}
133132

134133
#[Test]
135-
public function wrap_php5_exceptions() {
136-
$e= new \Exception('Test');
137-
Assert::instance(XPException::class, Throwable::wrap($e));
138-
}
139-
140-
#[Test, Runtime(php: '>=7.0.0')]
141-
public function wrap_php7_exceptions() {
134+
public function wrap_php_exceptions() {
142135
$e= new \TypeError('Test');
143136
Assert::instance(Error::class, Throwable::wrap($e));
144137
}

0 commit comments

Comments
 (0)