From 3cbbf3343caedca3984c2cef96c265ef9840d1a1 Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Wed, 20 Jul 2016 13:17:07 +0200 Subject: [PATCH] Updated PHP-JS to use the new PHP-CPP extension API and made booleans work correctly for PHP 7 --- extension.cpp | 4 ++-- value.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extension.cpp b/extension.cpp index 36e7140..b80d984 100644 --- a/extension.cpp +++ b/extension.cpp @@ -51,14 +51,14 @@ extern "C" { Php::Class 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) }); diff --git a/value.cpp b/value.cpp index 8152fea..e4a5649 100644 --- a/value.cpp +++ b/value.cpp @@ -92,6 +92,10 @@ v8::Handle 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; } }