Skip to content

Commit

Permalink
Updated PHP-JS to use the new PHP-CPP extension API and made booleans…
Browse files Browse the repository at this point in the history
… work correctly for PHP 7
  • Loading branch information
Martijn Otto committed Jul 20, 2016
1 parent 4012902 commit 3cbbf33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions extension.cpp
Expand Up @@ -51,14 +51,14 @@ extern "C" {
Php::Class<JS::Context> context("JS\\Context");

// properties can be assigned
context.method("assign", &JS::Context::assign, {
context.method<&JS::Context::assign>("assign", {
Php::ByVal("name", Php::Type::String, true),
Php::ByVal("value", Php::Type::Null, true),
Php::ByVal("attribute", Php::Type::Numeric, false)
});

// add a method to execute some script
context.method("evaluate", &JS::Context::evaluate, {
context.method<&JS::Context::evaluate>("evaluate", {
Php::ByVal("script", Php::Type::String, true),
Php::ByVal("timeout", Php::Type::Numeric, false)
});
Expand Down
4 changes: 4 additions & 0 deletions value.cpp
Expand Up @@ -92,6 +92,10 @@ v8::Handle<v8::Value> value(const Php::Value &input)
case Php::Type::Callable: result = v8::FunctionTemplate::New(Isolate::get(), callback, Handle(input))->GetFunction(); break;
case Php::Type::Array: result = Array(input); break;
default:
// php 7 does not return the Bool type anymore, but rather True and False
// types, which would not compile with our legacy code, so we check if it
// is boolean here again, using a function that works identically for both
if (input.isBool()) result = v8::Boolean::New(Isolate::get(), input);
break;
}
}
Expand Down

0 comments on commit 3cbbf33

Please sign in to comment.