Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ $ php --ri v8
$ brew tap homebrew/dupes
$ brew tap homebrew/php
$ brew install php70
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/php70-v8.rb
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/v8.rb
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/php70-v8.rb
$ php --ri v8
```

Expand All @@ -106,11 +106,11 @@ You will need a recent v8 Google JavaScript engine version installed. At this ti
$ sudo apt-get update -y
$ sudo apt-get install -y libv8-5.4-dev
```
- For OS X there is the [v8.rb](https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/v8.rb) homebrew formula.
- For OS X there is the [v8.rb][v8.rb] homebrew formula.
To install libv8:

```
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/v8.rb
```

#### PHP 7
Expand Down Expand Up @@ -151,7 +151,7 @@ You will need a recent v8 Google JavaScript engine version installed. At this ti
To install `php70-v8` do:

```
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/php70-v8.rb
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/php70-v8.rb
```

### Building php-v8 from sources
Expand Down Expand Up @@ -186,6 +186,7 @@ Copyright (c) 2015-2016 Bogdan Padalko <pinepain@gmail.com>

[v8-hello-world]: https://chromium.googlesource.com/v8/v8/+/master/samples/hello-world.cc
[v8-intro]: https://developers.google.com/v8/intro
[php70-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php70-v8.rb
[php71-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php71-v8.rb
[v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/v8.rb
[php70-v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/php70-v8.rb
[php71-v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/php71-v8.rb
[php-v8-stubs]: https://github.com/pinepain/php-v8-stubs
4 changes: 2 additions & 2 deletions src/php_v8_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1540,8 +1540,8 @@ ZEND_END_ARG_INFO()
//void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_php_v8_object_SetAccessorProperty, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
ZEND_ARG_OBJ_INFO(0, name, V8\\NameValue, 0)
ZEND_ARG_OBJ_INFO(0, getter, V8\\Function, 0)
ZEND_ARG_OBJ_INFO(0, setter, V8\\Function, 0)
ZEND_ARG_OBJ_INFO(0, getter, V8\\FunctionObject, 0)
ZEND_ARG_OBJ_INFO(0, setter, V8\\FunctionObject, 0)
ZEND_ARG_TYPE_INFO(0, attributes, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, settings, IS_LONG, 0)
ZEND_END_ARG_INFO()
Expand Down
17 changes: 9 additions & 8 deletions stubs/src/ObjectValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,20 @@ public function SetAccessor(
}

/**
* @param NameValue $name
* @param callable $getter
* @param callable|null $setter
* @param int $attributes
* @param int $settings
* @param NameValue $name
* @param FunctionObject $getter
* @param FunctionObject|null $setter
* @param int $attributes
* @param int $settings
*/
public function SetAccessorProperty(
NameValue $name,
callable $getter,
callable $setter = null,
FunctionObject $getter,
FunctionObject $setter = null,
int $attributes = PropertyAttribute::None,
int $settings = AccessControl::DEFAULT_ACCESS
) {
)
{
}

/**
Expand Down
73 changes: 73 additions & 0 deletions tests/001-verify-method-parameters-type.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
--TEST--
Check whether all method parameters have valid type
--SKIPIF--
<?php if (!extension_loaded("v8")) print "skip"; ?>
--FILE--
<?php
$re = new ReflectionExtension('v8');

$classes = $re->getClasses();


class Verifier
{
private $invalid = [];

public function verifyClass(ReflectionClass $class)
{
foreach ($class->getMethods() as $m) {
$this->verifyMethod($m);
}
}

public function verifyMethod(ReflectionMethod $method)
{
foreach ($method->getParameters() as $p) {
$this->verifyParameter($p);
}
}

public function verifyParameter(ReflectionParameter $parameter)
{
$type = $parameter->getType();

if (!$type || $type->isBuiltin()) {
return;
}

if (!(class_exists($type))) {
$method_name = $parameter->getDeclaringClass()->getName() . '::' . $parameter->getDeclaringFunction()->getName();
$param_name = $parameter->getName();

$shortcut = $method_name . '/' . $param_name;

if (isset($this->invalid[$shortcut])) {
return;
}

$this->invalid[$shortcut] = true;

echo "{$method_name}() method's parameter {$parameter->getName()} has invalid type ($type)", PHP_EOL;
}
}

public function isValid()
{
return empty($this->invalid);
}
}

$v = new Verifier();


foreach ($classes as $c) {
$v->verifyClass($c);
}

if ($v->isValid()) {
echo 'All method parameters are valid', PHP_EOL;
}

?>
--EXPECT--
All method parameters are valid
2 changes: 1 addition & 1 deletion tests/V8Script_Run.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $file_name = 'test.js';
$script = new V8\Script($context, new \V8\StringValue($isolate, $source), new \V8\ScriptOrigin($file_name));
$res = $script->Run($context);

$v8_helper->run_checks($value);
$v8_helper->run_checks($res);

$helper->dump($res->Value());

Expand Down