Skip to content

Commit f3a7a8f

Browse files
committed
PoC modules
1 parent 2834f47 commit f3a7a8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2195
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Makefile.objects
8181
# Directories for shared object files generated by `./configure`
8282
libs/
8383
modules/
84+
!Zend/tests/modules/
8485

8586
# Used by build/gen_stub.php
8687
build/PHP-Parser-*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Modules: classes that are never declared are not checked
3+
--ENV--
4+
THIS_IS_DEFINED=1
5+
--FILE--
6+
<?php
7+
8+
require_modules([__DIR__.'/check_deps_001/module.ini']);
9+
10+
?>
11+
==DONE==
12+
--EXPECT--
13+
==DONE==
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
module Test;
4+
5+
// Early bound, and may not have a DECLARE opcode
6+
class A {}
7+
8+
interface I {}
9+
10+
if (getenv('THIS_IS_DEFINED')) {
11+
// Declared at runtime
12+
class B {
13+
function f() {
14+
// Anon class is usable
15+
return new class implements I {};
16+
}
17+
function g() {
18+
// Anon function is usable
19+
return function (): I {};
20+
}
21+
}
22+
}
23+
24+
// Early bound
25+
function f() {}
26+
27+
if (getenv('THIS_IS_DEFINED')) {
28+
// Declared at runtime
29+
function g() {}
30+
}
31+
32+
if (getenv('THIS_IS_NOT_DEFINED')) {
33+
// Never declared (should not generate an error)
34+
class C implements J {
35+
function f() {
36+
// Anon class is not usable (should not generate an error)
37+
return new class implements J {};
38+
}
39+
function g() {
40+
// Anon function is not usable (should not generate an error)
41+
return function (): J {};
42+
}
43+
44+
}
45+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module=Test
2+
files=*.inc
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Modules: classes with invalid dependencies are not allowed
3+
--FILE--
4+
<?php
5+
6+
require __DIR__ . '/helpers.inc';
7+
8+
try {
9+
require_modules([__DIR__.'/check_deps_002/module.ini']);
10+
} catch (Error $e) {
11+
printf("%s: %s\n", $e::class, $e->getMessage());
12+
}
13+
14+
?>
15+
==DONE==
16+
--EXPECTF--
17+
Error: Class Test\I not found while compiling module Test%s
18+
==DONE==
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
module Test;
4+
5+
class A implements I {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module=Test
2+
files=*.inc
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Modules: classes with invalid dependencies are not allowed
3+
--ENV--
4+
THIS_IS_DEFINED=1
5+
--FILE--
6+
<?php
7+
8+
require __DIR__ . '/helpers.inc';
9+
10+
try {
11+
require_modules([__DIR__.'/check_deps_003/module.ini']);
12+
} catch (Error $e) {
13+
printf("%s: %s\n", $e::class, $e->getMessage());
14+
}
15+
16+
?>
17+
==DONE==
18+
--EXPECTF--
19+
Error: Class Test\I not found while compiling module Test%s
20+
==DONE==
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
module Test;
4+
5+
if (getenv('THIS_IS_DEFINED')) {
6+
class A implements I {}
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module=Test
2+
files=*.inc

0 commit comments

Comments
 (0)