@@ -12,23 +12,38 @@ server
12
12
13
13
$ interfaceFile = __DIR__ .'/optional_interfaces_interface.inc ' ;
14
14
15
- file_put_contents (__DIR__ .'/optional_interfaces_script.php ' , <<<SCRIPT
15
+ file_put_contents (__DIR__ .'/optional_interfaces_script.php ' , <<<' SCRIPT'
16
16
<?php
17
17
18
- @(include __DIR__.'/optional_interfaces_interface.inc');
18
+ $classFile = __DIR__.'/optional_interfaces_class.inc';
19
+ $interfaceFile = __DIR__.'/optional_interfaces_interface.inc';
20
+
21
+ if (opcache_is_script_cached($classFile))
22
+ echo "Class is cached\n";
23
+ else
24
+ echo "Class is not cached\n";
25
+
26
+ @(include $interfaceFile);
19
27
20
28
if (interface_exists('OpcachedInterface'))
21
29
echo "OpcachedInterface is defined\n";
22
30
else
23
31
echo "OpcachedInterface is not defined\n";
24
32
25
- include __DIR__.'/optional_interfaces_class.inc';
33
+ $hitsBefore = opcache_get_status()['opcache_statistics']['hits'];
34
+
35
+ include $classFile;
36
+
37
+ if (opcache_get_status()['opcache_statistics']['hits'] > $hitsBefore)
38
+ echo "Class loaded from OPCache\n";
39
+ else
40
+ echo "Class loaded from file\n";
26
41
27
42
echo "OpcachedClass implements:".implode(', ', class_implements('OpcachedClass'))."\n\n";
28
43
SCRIPT);
29
44
30
45
include __DIR__ .'/php_cli_server.inc ' ;
31
- php_cli_server_start ('-d opcache.enable=1 -d opcache.enable_cli=1 ' );
46
+ php_cli_server_start ('-d opcache.enable=1 -d opcache.enable_cli=1 -d zend_extension=opcache ' );
32
47
33
48
$ uri = 'http:// ' . PHP_CLI_SERVER_ADDRESS . '/optional_interfaces_script.php ' ;
34
49
@@ -46,11 +61,17 @@ unlink(__DIR__.'/optional_interfaces_script.php');
46
61
47
62
?>
48
63
--EXPECT--
64
+ Class is not cached
49
65
OpcachedInterface is not defined
66
+ Class loaded from file
50
67
OpcachedClass implements:
51
68
69
+ Class is cached
52
70
OpcachedInterface is defined
71
+ Class loaded from OPCache
53
72
OpcachedClass implements:OpcachedInterface
54
73
74
+ Class is cached
55
75
OpcachedInterface is not defined
76
+ Class loaded from OPCache
56
77
OpcachedClass implements:
0 commit comments