summaryrefslogtreecommitdiff
path: root/ext/sysvshm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sysvshm')
-rw-r--r--ext/sysvshm/php_sysvshm.h2
-rw-r--r--ext/sysvshm/sysvshm.c40
-rw-r--r--ext/sysvshm/sysvshm.stub.php35
-rw-r--r--ext/sysvshm/sysvshm_arginfo.h31
-rw-r--r--ext/sysvshm/tests/001.phpt13
-rw-r--r--ext/sysvshm/tests/002.phpt23
-rw-r--r--ext/sysvshm/tests/003.phpt42
-rw-r--r--ext/sysvshm/tests/004.phpt13
-rw-r--r--ext/sysvshm/tests/005.phpt14
-rw-r--r--ext/sysvshm/tests/006.phpt8
-rw-r--r--ext/sysvshm/tests/007.phpt28
11 files changed, 91 insertions, 158 deletions
diff --git a/ext/sysvshm/php_sysvshm.h b/ext/sysvshm/php_sysvshm.h
index c2c5036245..8ff2e26b37 100644
--- a/ext/sysvshm/php_sysvshm.h
+++ b/ext/sysvshm/php_sysvshm.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
index 6526efa250..dbf907e945 100644
--- a/ext/sysvshm/sysvshm.c
+++ b/ext/sysvshm/sysvshm.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -33,48 +31,12 @@
#include <errno.h>
#include "php_sysvshm.h"
+#include "sysvshm_arginfo.h"
#include "ext/standard/info.h"
#include "ext/standard/php_var.h"
#include "zend_smart_str.h"
#include "php_ini.h"
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_attach, 0, 0, 1)
- ZEND_ARG_INFO(0, key)
- ZEND_ARG_INFO(0, memsize)
- ZEND_ARG_INFO(0, perm)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_detach, 0, 0, 1)
- ZEND_ARG_INFO(0, shm_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_has_var, 0, 0, 2)
- ZEND_ARG_INFO(0, id)
- ZEND_ARG_INFO(0, variable_key)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_remove, 0, 0, 1)
- ZEND_ARG_INFO(0, shm_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_put_var, 0, 0, 3)
- ZEND_ARG_INFO(0, shm_identifier)
- ZEND_ARG_INFO(0, variable_key)
- ZEND_ARG_INFO(0, variable)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_get_var, 0, 0, 2)
- ZEND_ARG_INFO(0, id)
- ZEND_ARG_INFO(0, variable_key)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_remove_var, 0, 0, 2)
- ZEND_ARG_INFO(0, id)
- ZEND_ARG_INFO(0, variable_key)
-ZEND_END_ARG_INFO()
-/* }}} */
-
/* {{{ sysvshm_functions[]
*/
static const zend_function_entry sysvshm_functions[] = {
diff --git a/ext/sysvshm/sysvshm.stub.php b/ext/sysvshm/sysvshm.stub.php
new file mode 100644
index 0000000000..673f9c6f04
--- /dev/null
+++ b/ext/sysvshm/sysvshm.stub.php
@@ -0,0 +1,35 @@
+<?php
+
+/** @return resource|false */
+function shm_attach(int $key, int $memsize = UNKNOWN, int $perm = 0666) {}
+
+/**
+ * @param resource $shm_identifier
+ */
+function shm_detach($shm_identifier): bool {}
+
+/**
+ * @param resource $id
+ */
+function shm_has_var($id, int $variable_key): bool {}
+
+/**
+ * @param resource $shm_identifier
+ */
+function shm_remove($shm_identifier): bool {}
+
+/**
+ * @param resource $shm_identifier
+ */
+function shm_put_var($shm_identifier, int $variable_key, $variable): bool {}
+
+/**
+ * @param resource $id
+ * @return mixed
+ */
+function shm_get_var($id, int $variable_key) {}
+
+/**
+ * @param resource $id
+ */
+function shm_remove_var($id, int $variable_key): bool {}
diff --git a/ext/sysvshm/sysvshm_arginfo.h b/ext/sysvshm/sysvshm_arginfo.h
new file mode 100644
index 0000000000..dd00aa6349
--- /dev/null
+++ b/ext/sysvshm/sysvshm_arginfo.h
@@ -0,0 +1,31 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_attach, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, key, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, memsize, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, perm, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shm_detach, 0, 1, _IS_BOOL, 0)
+ ZEND_ARG_INFO(0, shm_identifier)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shm_has_var, 0, 2, _IS_BOOL, 0)
+ ZEND_ARG_INFO(0, id)
+ ZEND_ARG_TYPE_INFO(0, variable_key, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_shm_remove arginfo_shm_detach
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shm_put_var, 0, 3, _IS_BOOL, 0)
+ ZEND_ARG_INFO(0, shm_identifier)
+ ZEND_ARG_TYPE_INFO(0, variable_key, IS_LONG, 0)
+ ZEND_ARG_INFO(0, variable)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_shm_get_var, 0, 0, 2)
+ ZEND_ARG_INFO(0, id)
+ ZEND_ARG_TYPE_INFO(0, variable_key, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_shm_remove_var arginfo_shm_has_var
diff --git a/ext/sysvshm/tests/001.phpt b/ext/sysvshm/tests/001.phpt
index 55fd8eec1d..55d5444b98 100644
--- a/ext/sysvshm/tests/001.phpt
+++ b/ext/sysvshm/tests/001.phpt
@@ -8,10 +8,6 @@ if (!function_exists('ftok')){ print 'skip'; }
--FILE--
<?php
-var_dump(ftok());
-var_dump(ftok(1));
-var_dump(ftok(1,1,1));
-
var_dump(ftok("",""));
var_dump(ftok(-1, -1));
var_dump(ftok("qwertyu","qwertyu"));
@@ -23,15 +19,6 @@ var_dump(ftok(__FILE__,"q"));
echo "Done\n";
?>
--EXPECTF--
-Warning: ftok() expects exactly 2 parameters, 0 given in %s on line %d
-NULL
-
-Warning: ftok() expects exactly 2 parameters, 1 given in %s on line %d
-NULL
-
-Warning: ftok() expects exactly 2 parameters, 3 given in %s on line %d
-NULL
-
Warning: ftok(): Pathname is invalid in %s on line %d
int(-1)
diff --git a/ext/sysvshm/tests/002.phpt b/ext/sysvshm/tests/002.phpt
index 3bfb28e5c6..d558623242 100644
--- a/ext/sysvshm/tests/002.phpt
+++ b/ext/sysvshm/tests/002.phpt
@@ -10,19 +10,14 @@ if (!function_exists('ftok')){ print 'skip'; }
$key = ftok(__FILE__, 't');
-var_dump(shm_attach());
-var_dump(shm_attach(1,2,3,4));
-
var_dump(shm_attach(-1, 0));
var_dump(shm_attach(0, -1));
var_dump(shm_attach(123, -1));
-var_dump($s = shm_attach($key, -1));
-shm_remove($s);
-var_dump($s = shm_attach($key, 0));
-shm_remove($s);
+var_dump(shm_attach($key, -1));
+var_dump(shm_attach($key, 0));
var_dump($s = shm_attach($key, 1024));
-shm_remove($key);
+shm_remove($s);
var_dump($s = shm_attach($key, 1024));
shm_remove($s);
var_dump($s = shm_attach($key, 1024, 0666));
@@ -36,12 +31,6 @@ shm_remove($s);
echo "Done\n";
?>
--EXPECTF--
-Warning: shm_attach() expects at least 1 parameter, 0 given in %s on line %d
-NULL
-
-Warning: shm_attach() expects at most 3 parameters, 4 given in %s on line %d
-NULL
-
Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
bool(false)
@@ -54,15 +43,9 @@ bool(false)
Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
bool(false)
-Warning: shm_remove() expects parameter 1 to be resource, bool given in %s on line %d
-
Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
bool(false)
-
-Warning: shm_remove() expects parameter 1 to be resource, bool given in %s on line %d
resource(%d) of type (sysvshm)
-
-Warning: shm_remove() expects parameter 1 to be resource, int given in %s on line %d
resource(%d) of type (sysvshm)
resource(%d) of type (sysvshm)
resource(%d) of type (sysvshm)
diff --git a/ext/sysvshm/tests/003.phpt b/ext/sysvshm/tests/003.phpt
index e141353dec..a7fe128aa5 100644
--- a/ext/sysvshm/tests/003.phpt
+++ b/ext/sysvshm/tests/003.phpt
@@ -10,18 +10,19 @@ if (!function_exists('ftok')){ print 'skip'; }
$key = ftok(__DIR__."/003.phpt", 'q');
-var_dump(shm_detach());
-var_dump(shm_detach(1,1));
-
$s = shm_attach($key);
var_dump(shm_detach($s));
-var_dump(shm_detach($s));
-shm_remove($s);
-
-var_dump(shm_detach(0));
-var_dump(shm_detach(1));
-var_dump(shm_detach(-1));
+try {
+ var_dump(shm_detach($s));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ shm_remove($s);
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
echo "Done\n";
?>
@@ -33,25 +34,8 @@ $s = shm_attach($key);
shm_remove($s);
?>
---EXPECTF--
-Warning: shm_detach() expects exactly 1 parameter, 0 given in %s003.php on line %d
-NULL
-
-Warning: shm_detach() expects exactly 1 parameter, 2 given in %s003.php on line %d
-NULL
+--EXPECT--
bool(true)
-
-Warning: shm_detach(): supplied resource is not a valid sysvshm resource in %s003.php on line %d
-bool(false)
-
-Warning: shm_remove(): supplied resource is not a valid sysvshm resource in %s003.php on line %d
-
-Warning: shm_detach() expects parameter 1 to be resource, int given in %s003.php on line %d
-NULL
-
-Warning: shm_detach() expects parameter 1 to be resource, int given in %s003.php on line %d
-NULL
-
-Warning: shm_detach() expects parameter 1 to be resource, int given in %s003.php on line %d
-NULL
+shm_detach(): supplied resource is not a valid sysvshm resource
+shm_remove(): supplied resource is not a valid sysvshm resource
Done
diff --git a/ext/sysvshm/tests/004.phpt b/ext/sysvshm/tests/004.phpt
index ee64491840..23496f5c1c 100644
--- a/ext/sysvshm/tests/004.phpt
+++ b/ext/sysvshm/tests/004.phpt
@@ -11,9 +11,6 @@ if (!function_exists('ftok')){ print 'skip'; }
$key = ftok(__FILE__, 't');
$s = shm_attach($key, 1024);
-var_dump(shm_put_var());
-var_dump(shm_put_var(-1, -1, -1));
-var_dump(shm_put_var(-1, 10, "qwerty"));
var_dump(shm_put_var($s, -1, "qwerty"));
var_dump(shm_put_var($s, 10, "qwerty"));
var_dump(shm_put_var($s, 10, "qwerty"));
@@ -26,18 +23,10 @@ shm_remove($s);
echo "Done\n";
?>
--EXPECTF--
-Warning: shm_put_var() expects exactly 3 parameters, 0 given in %s004.php on line %d
-NULL
-
-Warning: shm_put_var() expects parameter 1 to be resource, int given in %s004.php on line %d
-NULL
-
-Warning: shm_put_var() expects parameter 1 to be resource, int given in %s004.php on line %d
-NULL
bool(true)
bool(true)
bool(true)
-Warning: shm_put_var(): not enough shared memory left in %s004.php on line 14
+Warning: shm_put_var(): not enough shared memory left in %s004.php on line %d
bool(false)
Done
diff --git a/ext/sysvshm/tests/005.phpt b/ext/sysvshm/tests/005.phpt
index 0a3d3422e8..879be31c13 100644
--- a/ext/sysvshm/tests/005.phpt
+++ b/ext/sysvshm/tests/005.phpt
@@ -17,14 +17,9 @@ shm_put_var($s, 1, array(1,2,3));
shm_put_var($s, 2, false);
shm_put_var($s, 3, null);
-var_dump(shm_get_var());
-
-var_dump(shm_get_var(-1, -1));
-
var_dump(shm_get_var($s, 1000));
var_dump(shm_get_var($s, -10000));
-var_dump(shm_get_var($s, array()));
var_dump(shm_get_var($s, -1));
var_dump(shm_get_var($s, 0));
var_dump(shm_get_var($s, 1));
@@ -41,20 +36,11 @@ shm_remove($s);
echo "Done\n";
?>
--EXPECTF--
-Warning: shm_get_var() expects exactly 2 parameters, 0 given in %s005.php on line %d
-NULL
-
-Warning: shm_get_var() expects parameter 1 to be resource, int given in %s005.php on line %d
-NULL
-
Warning: shm_get_var(): variable key 1000 doesn't exist in %s005.php on line %d
bool(false)
Warning: shm_get_var(): variable key -10000 doesn't exist in %s005.php on line %d
bool(false)
-
-Warning: shm_get_var() expects parameter 2 to be int, array given in %s005.php on line %d
-NULL
string(11) "test string"
object(stdClass)#%d (0) {
}
diff --git a/ext/sysvshm/tests/006.phpt b/ext/sysvshm/tests/006.phpt
index b38aee02a1..278838f063 100644
--- a/ext/sysvshm/tests/006.phpt
+++ b/ext/sysvshm/tests/006.phpt
@@ -13,8 +13,6 @@ $s = shm_attach($key, 1024);
shm_put_var($s, 1, "test string");
-var_dump(shm_remove_var());
-var_dump(shm_remove_var(-1, -1));
var_dump(shm_remove_var($s, -10));
var_dump(shm_get_var($s, 1));
@@ -29,12 +27,6 @@ shm_remove($s);
echo "Done\n";
?>
--EXPECTF--
-Warning: shm_remove_var() expects exactly 2 parameters, 0 given in %s006.php on line %d
-NULL
-
-Warning: shm_remove_var() expects parameter 1 to be resource, int given in %s006.php on line %d
-NULL
-
Warning: shm_remove_var(): variable key -10 doesn't exist in %s006.php on line %d
bool(false)
string(11) "test string"
diff --git a/ext/sysvshm/tests/007.phpt b/ext/sysvshm/tests/007.phpt
index a165a8bfbf..730e9a3fbd 100644
--- a/ext/sysvshm/tests/007.phpt
+++ b/ext/sysvshm/tests/007.phpt
@@ -11,32 +11,18 @@ if (!function_exists('ftok')){ print 'skip'; }
$key = ftok(__FILE__, 't');
$s = shm_attach($key, 1024);
-var_dump(shm_remove());
-var_dump(shm_remove(-1));
-var_dump(shm_remove(0));
-var_dump(shm_remove(""));
-
var_dump(shm_remove($s));
shm_detach($s);
-var_dump(shm_remove($s));
+try {
+ var_dump(shm_remove($s));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
echo "Done\n";
?>
---EXPECTF--
-Warning: shm_remove() expects exactly 1 parameter, 0 given in %s007.php on line %d
-NULL
-
-Warning: shm_remove() expects parameter 1 to be resource, int given in %s007.php on line %d
-NULL
-
-Warning: shm_remove() expects parameter 1 to be resource, int given in %s007.php on line %d
-NULL
-
-Warning: shm_remove() expects parameter 1 to be resource, string given in %s007.php on line %d
-NULL
+--EXPECT--
bool(true)
-
-Warning: shm_remove(): supplied resource is not a valid sysvshm resource in %s007.php on line %d
-bool(false)
+shm_remove(): supplied resource is not a valid sysvshm resource
Done