Skip to content

Commit 3cbbf33

Browse files
author
Martijn Otto
committed
Updated PHP-JS to use the new PHP-CPP extension API and made booleans work correctly for PHP 7
1 parent 4012902 commit 3cbbf33

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

extension.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ extern "C" {
5151
Php::Class<JS::Context> context("JS\\Context");
5252

5353
// properties can be assigned
54-
context.method("assign", &JS::Context::assign, {
54+
context.method<&JS::Context::assign>("assign", {
5555
Php::ByVal("name", Php::Type::String, true),
5656
Php::ByVal("value", Php::Type::Null, true),
5757
Php::ByVal("attribute", Php::Type::Numeric, false)
5858
});
5959

6060
// add a method to execute some script
61-
context.method("evaluate", &JS::Context::evaluate, {
61+
context.method<&JS::Context::evaluate>("evaluate", {
6262
Php::ByVal("script", Php::Type::String, true),
6363
Php::ByVal("timeout", Php::Type::Numeric, false)
6464
});

value.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ v8::Handle<v8::Value> value(const Php::Value &input)
9292
case Php::Type::Callable: result = v8::FunctionTemplate::New(Isolate::get(), callback, Handle(input))->GetFunction(); break;
9393
case Php::Type::Array: result = Array(input); break;
9494
default:
95+
// php 7 does not return the Bool type anymore, but rather True and False
96+
// types, which would not compile with our legacy code, so we check if it
97+
// is boolean here again, using a function that works identically for both
98+
if (input.isBool()) result = v8::Boolean::New(Isolate::get(), input);
9599
break;
96100
}
97101
}

0 commit comments

Comments
 (0)