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

Commit 947b069

Browse files
authored
Merge pull request #14 from pinepain/fix_inheritance
Bugs and doc liks fixes
2 parents 6e537e4 + afc95bf commit 947b069

File tree

5 files changed

+93
-18
lines changed

5 files changed

+93
-18
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ $ php --ri v8
8888
$ brew tap homebrew/dupes
8989
$ brew tap homebrew/php
9090
$ brew install php70
91-
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
92-
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/php70-v8.rb
91+
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/v8.rb
92+
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/php70-v8.rb
9393
$ php --ri v8
9494
```
9595

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

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

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

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

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

187187
[v8-hello-world]: https://chromium.googlesource.com/v8/v8/+/master/samples/hello-world.cc
188188
[v8-intro]: https://developers.google.com/v8/intro
189-
[php70-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php70-v8.rb
190-
[php71-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php71-v8.rb
189+
[v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/v8.rb
190+
[php70-v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/php70-v8.rb
191+
[php71-v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/php71-v8.rb
191192
[php-v8-stubs]: https://github.com/pinepain/php-v8-stubs

src/php_v8_object.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,8 @@ ZEND_END_ARG_INFO()
15401540
//void method
15411541
ZEND_BEGIN_ARG_INFO_EX(arginfo_php_v8_object_SetAccessorProperty, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
15421542
ZEND_ARG_OBJ_INFO(0, name, V8\\NameValue, 0)
1543-
ZEND_ARG_OBJ_INFO(0, getter, V8\\Function, 0)
1544-
ZEND_ARG_OBJ_INFO(0, setter, V8\\Function, 0)
1543+
ZEND_ARG_OBJ_INFO(0, getter, V8\\FunctionObject, 0)
1544+
ZEND_ARG_OBJ_INFO(0, setter, V8\\FunctionObject, 0)
15451545
ZEND_ARG_TYPE_INFO(0, attributes, IS_LONG, 0)
15461546
ZEND_ARG_TYPE_INFO(0, settings, IS_LONG, 0)
15471547
ZEND_END_ARG_INFO()

stubs/src/ObjectValue.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,20 @@ public function SetAccessor(
221221
}
222222

223223
/**
224-
* @param NameValue $name
225-
* @param callable $getter
226-
* @param callable|null $setter
227-
* @param int $attributes
228-
* @param int $settings
224+
* @param NameValue $name
225+
* @param FunctionObject $getter
226+
* @param FunctionObject|null $setter
227+
* @param int $attributes
228+
* @param int $settings
229229
*/
230230
public function SetAccessorProperty(
231231
NameValue $name,
232-
callable $getter,
233-
callable $setter = null,
232+
FunctionObject $getter,
233+
FunctionObject $setter = null,
234234
int $attributes = PropertyAttribute::None,
235235
int $settings = AccessControl::DEFAULT_ACCESS
236-
) {
236+
)
237+
{
237238
}
238239

239240
/**
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
--TEST--
2+
Check whether all method parameters have valid type
3+
--SKIPIF--
4+
<?php if (!extension_loaded("v8")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$re = new ReflectionExtension('v8');
8+
9+
$classes = $re->getClasses();
10+
11+
12+
class Verifier
13+
{
14+
private $invalid = [];
15+
16+
public function verifyClass(ReflectionClass $class)
17+
{
18+
foreach ($class->getMethods() as $m) {
19+
$this->verifyMethod($m);
20+
}
21+
}
22+
23+
public function verifyMethod(ReflectionMethod $method)
24+
{
25+
foreach ($method->getParameters() as $p) {
26+
$this->verifyParameter($p);
27+
}
28+
}
29+
30+
public function verifyParameter(ReflectionParameter $parameter)
31+
{
32+
$type = $parameter->getType();
33+
34+
if (!$type || $type->isBuiltin()) {
35+
return;
36+
}
37+
38+
if (!(class_exists($type))) {
39+
$method_name = $parameter->getDeclaringClass()->getName() . '::' . $parameter->getDeclaringFunction()->getName();
40+
$param_name = $parameter->getName();
41+
42+
$shortcut = $method_name . '/' . $param_name;
43+
44+
if (isset($this->invalid[$shortcut])) {
45+
return;
46+
}
47+
48+
$this->invalid[$shortcut] = true;
49+
50+
echo "{$method_name}() method's parameter {$parameter->getName()} has invalid type ($type)", PHP_EOL;
51+
}
52+
}
53+
54+
public function isValid()
55+
{
56+
return empty($this->invalid);
57+
}
58+
}
59+
60+
$v = new Verifier();
61+
62+
63+
foreach ($classes as $c) {
64+
$v->verifyClass($c);
65+
}
66+
67+
if ($v->isValid()) {
68+
echo 'All method parameters are valid', PHP_EOL;
69+
}
70+
71+
?>
72+
--EXPECT--
73+
All method parameters are valid

tests/V8Script_Run.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $file_name = 'test.js';
2727
$script = new V8\Script($context, new \V8\StringValue($isolate, $source), new \V8\ScriptOrigin($file_name));
2828
$res = $script->Run($context);
2929

30-
$v8_helper->run_checks($value);
30+
$v8_helper->run_checks($res);
3131

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

0 commit comments

Comments
 (0)