Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 6c370a7

Browse files
committed
Make V8\Isolate::ThrowException() method void
Internally it always returns an undefined value, so return result in userland is useless
1 parent 6b849bd commit 6c370a7

8 files changed

+10
-24
lines changed

src/php_v8_isolate.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,8 @@ static PHP_METHOD(V8Isolate, ThrowException) {
396396
PHP_V8_ENTER_CONTEXT(php_v8_context);
397397

398398
v8::Local<v8::Value> local_value = php_v8_value_get_local(php_v8_value);
399-
v8::Local<v8::Value> local_return_value = isolate->ThrowException(local_value);
400399

401-
/* From v8 source code, Isolate::ThrowException() returns v8::Undefined() */
402-
php_v8_get_or_create_value(return_value, local_return_value, php_v8_value->php_v8_isolate);
400+
isolate->ThrowException(local_value);
403401
}
404402

405403
static PHP_METHOD(V8Isolate, IdleNotificationDeadline) {
@@ -552,7 +550,7 @@ ZEND_END_ARG_INFO()
552550
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_v8_isolate_GetEnteredContext, ZEND_RETURN_VALUE, 0, V8\\Context, 0)
553551
ZEND_END_ARG_INFO()
554552

555-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_v8_isolate_ThrowException, ZEND_RETURN_VALUE, 2, V8\\Value, 0)
553+
ZEND_BEGIN_ARG_INFO_EX(arginfo_v8_isolate_ThrowException, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
556554
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
557555
ZEND_ARG_OBJ_INFO(0, value, V8\\Value, 0)
558556
ZEND_END_ARG_INFO()

stubs/src/Isolate.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public function GetEnteredContext(): Context
9898
* @param Context $context
9999
* @param Value $value
100100
*
101-
* @return Value
101+
* @return void
102102
*/
103-
public function ThrowException(Context $context, Value $value): Value
103+
public function ThrowException(Context $context, Value $value)
104104
{
105105
}
106106

tests/V8Exception_Error.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ $helper->line();
2424
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
2525
$value = count($info->Arguments()) ? $info->Arguments()[0] : new \V8\StringValue($info->GetIsolate(), "exception");
2626

27-
$e = $info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::Error($info->GetContext(), $value));
28-
29-
$info->GetReturnValue()->Set($e);
27+
$info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::Error($info->GetContext(), $value));
3028
});
3129

3230
$func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) {

tests/V8Exception_RangeError.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ $helper->line();
2525
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
2626
$value = count($info->Arguments()) ? $info->Arguments()[0] : new \V8\StringValue($info->GetIsolate(), "exception");
2727

28-
$e = $info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::RangeError($info->GetContext(), $value));
29-
30-
$info->GetReturnValue()->Set($e);
28+
$info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::RangeError($info->GetContext(), $value));
3129
});
3230

3331
$func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) {

tests/V8Exception_ReferenceError.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ $helper->line();
2525
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
2626
$value = count($info->Arguments()) ? $info->Arguments()[0] : new \V8\StringValue($info->GetIsolate(), "exception");
2727

28-
$e = $info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::ReferenceError($info->GetContext(), $value));
29-
30-
$info->GetReturnValue()->Set($e);
28+
$info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::ReferenceError($info->GetContext(), $value));
3129
});
3230

3331
$func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) {

tests/V8Exception_SyntaxError.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ $helper->line();
2525
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
2626
$value = count($info->Arguments()) ? $info->Arguments()[0] : new \V8\StringValue($info->GetIsolate(), "exception");
2727

28-
$e = $info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::SyntaxError($info->GetContext(), $value));
29-
30-
$info->GetReturnValue()->Set($e);
28+
$info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::SyntaxError($info->GetContext(), $value));
3129
});
3230

3331
$func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) {

tests/V8Exception_TypeError.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ $helper->line();
2525
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
2626
$value = count($info->Arguments()) ? $info->Arguments()[0] : new \V8\StringValue($info->GetIsolate(), "exception");
2727

28-
$e = $info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::TypeError($info->GetContext(), $value));
29-
30-
$info->GetReturnValue()->Set($e);
28+
$info->GetIsolate()->ThrowException($info->GetContext(), V8\Exception::TypeError($info->GetContext(), $value));
3129
});
3230

3331
$func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) {

tests/V8Isolate_ThrowException.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ $isolate = new \V8\Isolate();
1616
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
1717
$value = count($info->Arguments()) ? $info->Arguments()[0] : new \V8\StringValue($info->GetIsolate(), "exception");
1818

19-
$e = $info->GetIsolate()->ThrowException($info->GetContext(), $value);
20-
21-
$info->GetReturnValue()->Set($e);
19+
$info->GetIsolate()->ThrowException($info->GetContext(), $value);
2220
});
2321

2422

0 commit comments

Comments
 (0)