Skip to content

Commit 3d956a7

Browse files
committed
fixed #4 print arginfo warning on PHP 8
1 parent 939e986 commit 3d956a7

14 files changed

+314
-41
lines changed

manage.sh

+14
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ case "${mode}" in
147147

148148
exit $?
149149
;;
150+
stub)
151+
# stub tagging
152+
# /** @generate-function-entries **/ build with function entryies
153+
# /** @generate-legacy-arginfo **/ build with legacy style
154+
if [[ ! -f build/gen_stub.php ]]; then
155+
cat <<-EOL
156+
ERROR: execute before PHP 8 build environment or before execute phpize
157+
EOL
158+
exit 1
159+
fi
160+
phpcmd="/usr/bin/php80"
161+
perl -pi -e 's/ext_functions/korean_functions/g' build/gen_stub.php
162+
${phpcmd} build/gen_stub.php -f *.stub.php
163+
;;
150164
*)
151165
errmsg "Unsupport mode '${1}'"
152166
exit 1

package.xml.tmpl

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
</stability>
2424
<license uri="http://www.php.net/license">PHP</license>
2525
<notes>
26-
- Change license to PHP v3.0.1
26+
- Change license to PHP v3.01
2727
- #3 Build failure on PHP 8
28+
- #4 print arginfo warning on PHP 8
2829
</notes>
2930
<contents>
3031
<dir name="/">
@@ -63,8 +64,9 @@
6364
<version><release>3.0.5</release><api>2.1.2</api></version>
6465
<date>@curdate@</date>
6566
<notes>
66-
- Change license to PHP v3.0.1
67+
- Change license to PHP v3.01
6768
- #3 Build failure on PHP 8
69+
- #4 print arginfo warning on PHP 8
6870
</notes>
6971
</release>
7072
<release>

php_krisp.c

+28-32
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,28 @@ ZEND_DECLARE_MODULE_GLOBALS(krisp)
6868
/* True global resources - no need for thread safety here */
6969
static int le_krisp;
7070

71-
ZEND_BEGIN_ARG_INFO_EX(arginfo_krisp_open, 0, 0, 0)
72-
ZEND_ARG_INFO(0, database)
73-
ZEND_ARG_INFO(1, error)
74-
ZEND_END_ARG_INFO()
75-
71+
#include "php_krisp_arginfo.h"
7672
#include "php_krisp_class.h"
7773

7874
/* {{{ krisp_functions[]
7975
*
8076
* Every user visible function must have an entry in krisp_functions[].
8177
*/
8278
const zend_function_entry krisp_functions[] = {
83-
PHP_FE(krisp_buildver, NULL)
84-
PHP_FE(krisp_version, NULL)
85-
PHP_FE(krisp_uversion, NULL)
79+
PHP_FE(krisp_buildver, arginfo_krisp_buildver)
80+
PHP_FE(krisp_version, arginfo_krisp_version)
81+
PHP_FE(krisp_uversion, arginfo_krisp_uversion)
8682
PHP_FE(krisp_open, arginfo_krisp_open)
87-
PHP_FE(krisp_search, NULL)
88-
PHP_FE(krisp_search_ex, NULL)
89-
PHP_FE(krisp_close, NULL)
90-
PHP_FE(krisp_netmask, NULL)
91-
PHP_FE(krisp_network, NULL)
92-
PHP_FE(krisp_broadcast, NULL)
93-
PHP_FE(krisp_prefix2mask, NULL)
94-
PHP_FE(krisp_mask2prefix, NULL)
95-
PHP_FE(krisp_set_mtime_interval, NULL)
96-
PHP_FE(krisp_set_debug, NULL)
83+
PHP_FE(krisp_search, arginfo_krisp_search)
84+
PHP_FE(krisp_search_ex, arginfo_krisp_search_ex)
85+
PHP_FE(krisp_close, arginfo_krisp_close)
86+
PHP_FE(krisp_netmask, arginfo_krisp_netmask)
87+
PHP_FE(krisp_network, arginfo_krisp_netmask)
88+
PHP_FE(krisp_broadcast, arginfo_krisp_broadcast)
89+
PHP_FE(krisp_prefix2mask, arginfo_krisp_prefix2mask)
90+
PHP_FE(krisp_mask2prefix, arginfo_krisp_mask2prefix)
91+
PHP_FE(krisp_set_mtime_interval, arginfo_krisp_set_mtime_interval)
92+
PHP_FE(krisp_set_debug, arginfo_krisp_set_debug)
9793
PHP_FE_END
9894
};
9995
/* }}} */
@@ -202,31 +198,31 @@ PHP_MINFO_FUNCTION(krisp)
202198
}
203199
/* }}} */
204200

205-
/* {{{ proto (string) krisp_buildver (void)
201+
/* {{{ proto krisp_buildver (void): string
206202
* print krisp extension build number */
207203
PHP_FUNCTION(krisp_buildver)
208204
{
209205
RETURN_STRING (BUILDNO);
210206
}
211207
/* }}} */
212208

213-
/* {{{ proto (string) krisp_version (void)
209+
/* {{{ proto krisp_version (void): string
214210
* print krisp library version */
215211
PHP_FUNCTION(krisp_version)
216212
{
217213
RETURN_STRING (KRISP_VERSION);
218214
}
219215
/* }}} */
220216

221-
/* {{{ proto (string) krisp_uversion (void)
217+
/* {{{ proto krisp_uversion (void): string
222218
* print krisp library uversion */
223219
PHP_FUNCTION(krisp_uversion)
224220
{
225221
RETURN_STRING (KRISP_UVERSION);
226222
}
227223
/* }}} */
228224

229-
/* {{{ proto (resource) krisp_open (string datafile)
225+
/* {{{ proto krisp_open (string datafile): resource
230226
* return krisp database open resource */
231227
PHP_FUNCTION(krisp_open)
232228
{
@@ -289,7 +285,7 @@ PHP_FUNCTION(krisp_open)
289285
}
290286
/* }}} */
291287

292-
/* {{{ proto (object|false) krisp_search (resource link, string host)
288+
/* {{{ proto krisp_search (resource link, string host): object|false
293289
* return isp information array */
294290
PHP_FUNCTION(krisp_search)
295291
{
@@ -367,7 +363,7 @@ PHP_FUNCTION(krisp_search)
367363
}
368364
/* }}} */
369365

370-
/* {{{ proto (object|false) krisp_search_ex (resource link, string host)
366+
/* {{{ proto krisp_search_ex (resource link, string host): object|false
371367
* return isp information array */
372368
PHP_FUNCTION(krisp_search_ex)
373369
{
@@ -470,7 +466,7 @@ PHP_FUNCTION(krisp_search_ex)
470466
}
471467
/* }}} */
472468

473-
/* {{{ proto (bool) krisp_close (resource link)
469+
/* {{{ proto krisp_close (resource link): bool
474470
* close krisp database */
475471
PHP_FUNCTION(krisp_close)
476472
{
@@ -515,7 +511,7 @@ PHP_FUNCTION(krisp_close)
515511
}
516512
/* }}} */
517513

518-
/* {{{ proto (object) krisp_netmask (string start, string end)
514+
/* {{{ proto krisp_netmask (string start, string end): object
519515
* return netmask and prefix about given ip range */
520516
PHP_FUNCTION(krisp_netmask)
521517
{
@@ -581,23 +577,23 @@ static void krisp_network_broadcast (INTERNAL_FUNCTION_PARAMETERS, zend_bool typ
581577
);
582578
} // }}}
583579

584-
/* {{{ proto (string|false) krisp_network (string ip, string mask)
580+
/* {{{ proto krisp_network (string ip, string mask): string|false
585581
* reuturn network address about given ip and network mask */
586582
PHP_FUNCTION(krisp_network)
587583
{
588584
krisp_network_broadcast (INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
589585
}
590586
/* }}} */
591587

592-
/* {{{ proto (string|false) krisp_broadcast (string ip, string mask)
588+
/* {{{ proto krisp_broadcast (string ip, string mask): string|false
593589
* reuturn broadcast address about given ip and network mask */
594590
PHP_FUNCTION(krisp_broadcast)
595591
{
596592
krisp_network_broadcast (INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
597593
}
598594
/* }}} */
599595

600-
/* {{{ proto (string) krisp_prefix2mask (int prefix)
596+
/* {{{ proto krisp_prefix2mask (int prefix): string
601597
* return unsigned long value for given network prefix */
602598
PHP_FUNCTION(krisp_prefix2mask)
603599
{
@@ -611,7 +607,7 @@ PHP_FUNCTION(krisp_prefix2mask)
611607
}
612608
/* }}} */
613609

614-
/* {{{ proto (int) krisp_mask2prefix (string mask)
610+
/* {{{ proto krisp_mask2prefix (string mask): long
615611
* return short network prefix for given long network mask */
616612
PHP_FUNCTION(krisp_mask2prefix)
617613
{
@@ -624,7 +620,7 @@ PHP_FUNCTION(krisp_mask2prefix)
624620
}
625621
/* }}} */
626622

627-
/* {{{ proto (bool) krisp_set_mtime_interval (resoruce link, int sec)
623+
/* {{{ proto krisp_set_mtime_interval (resource link, int sec): bool
628624
* set krisp database mtime check interval */
629625
PHP_FUNCTION(krisp_set_mtime_interval)
630626
{
@@ -665,7 +661,7 @@ PHP_FUNCTION(krisp_set_mtime_interval)
665661
}
666662
/* }}} */
667663

668-
/* {{{ proto (bool) krisp_set_debug (resoruce link[, int switch = true])
664+
/* {{{ proto krisp_set_debug (resource link, int switch = true): bool
669665
* print libkrisp debug messages */
670666
PHP_FUNCTION(krisp_set_debug)
671667
{

php_krisp.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,24 @@ ZEND_END_MODULE_GLOBALS(krisp)
8686
* Compatible legacy version
8787
*/
8888
#if PHP_VERSION_ID >= 80000
89-
# define TSRMLS_CC
89+
# define TSRMLS_CC
90+
#else
91+
# undef ZEND_ARG_OBJ_INFO
92+
# define ZEND_ARG_OBJ_INFO(a,b,c,d) ZEND_ARG_TYPE_INFO(a,b,IS_RESOURCE,d)
93+
# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(a,b,c,d) ZEND_BEGIN_ARG_INFO_EX(a,0,b,c)
94+
# define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(a,b,c,d,e) ZEND_ARG_TYPE_INFO(a,b,c,d)
95+
#endif
96+
97+
#if PHP_VERSION_ID < 70400
98+
# ifdef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX
99+
# undef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX
100+
# endif
101+
# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(a,b,c,d,e) ZEND_BEGIN_ARG_INFO_EX(a,0,b,c)
90102
#endif
91103

104+
#if PHP_VERSION_ID < 70200
105+
# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(a,b,c,d,e) ZEND_BEGIN_ARG_INFO_EX(a,0,b,c)
106+
#endif
92107

93108
/*
94109
* KRISP library header

php_krisp.stub.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/** @--generate-function-entries **/
3+
4+
function krisp_buildver (): string { }
5+
function krisp_version (): string { }
6+
function krisp_uversion (): string { }
7+
function krisp_open (?string $datafile = null, ?string &$err = null): KRISP { }
8+
function krisp_search (KRISP $link, string $host): object|false { }
9+
function krisp_search_ex (KRISP $link, string $host): object|false { }
10+
function krisp_close (KRISP $link): bool { }
11+
function krisp_netmask (string $start, string $end): object { }
12+
function krisp_network (string $ip, string $mask): string|false { }
13+
function krisp_broadcast (string $ip, string $mask): string|false { }
14+
function krisp_prefix2mask (int $prefix): string { }
15+
function krisp_mask2prefix (string $mask): int { }
16+
function krisp_set_mtime_interval (resource $link, int $sec): bool { }
17+
function krisp_set_debug (resource $link, int $switch = true): bool { }
18+
19+
class KRISP {
20+
/**
21+
* @return KRISP
22+
* @alias krisp_open
23+
*/
24+
public function __construct (?string $datafile = null) { }
25+
/**
26+
* @return object|false
27+
* @alias krisp_search
28+
*/
29+
public function search (string $host): object|false { }
30+
/**
31+
* @return object|false
32+
* @alias krisp_search_ex
33+
*/
34+
public function search_ex (string $host): object|false { }
35+
/**
36+
* @return bool
37+
* @alias krisp_close
38+
*/
39+
public function close (): bool { }
40+
/**
41+
* @return bool
42+
* @alias krisp_set_mtime_interval
43+
*/
44+
public function mtimeInterval (int $sec): bool { }
45+
/**
46+
* @return bool
47+
* @alias krisp_set_debug
48+
*/
49+
public function debug (int $switch = true): bool { }
50+
}
51+
?>

php_krisp_arginfo.h

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* This is a generated file, edit the .stub.php file instead.
2+
* Stub hash: 0d995f370bde364a9df7d065b51e11d4105beae5 */
3+
4+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_buildver, 0, 0, IS_STRING, 0)
5+
ZEND_END_ARG_INFO()
6+
7+
#define arginfo_krisp_version arginfo_krisp_buildver
8+
9+
#define arginfo_krisp_uversion arginfo_krisp_buildver
10+
11+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_krisp_open, 0, 0, KRISP, 0)
12+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, datafile, IS_STRING, 1, "null")
13+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(1, err, IS_STRING, 1, "null")
14+
ZEND_END_ARG_INFO()
15+
16+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_krisp_search, 0, 2, MAY_BE_OBJECT|MAY_BE_FALSE)
17+
ZEND_ARG_OBJ_INFO(0, link, KRISP, 0)
18+
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
19+
ZEND_END_ARG_INFO()
20+
21+
#define arginfo_krisp_search_ex arginfo_krisp_search
22+
23+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_close, 0, 1, _IS_BOOL, 0)
24+
ZEND_ARG_OBJ_INFO(0, link, KRISP, 0)
25+
ZEND_END_ARG_INFO()
26+
27+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_netmask, 0, 2, IS_OBJECT, 0)
28+
ZEND_ARG_TYPE_INFO(0, start, IS_STRING, 0)
29+
ZEND_ARG_TYPE_INFO(0, end, IS_STRING, 0)
30+
ZEND_END_ARG_INFO()
31+
32+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_krisp_network, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
33+
ZEND_ARG_TYPE_INFO(0, ip, IS_STRING, 0)
34+
ZEND_ARG_TYPE_INFO(0, mask, IS_STRING, 0)
35+
ZEND_END_ARG_INFO()
36+
37+
#define arginfo_krisp_broadcast arginfo_krisp_network
38+
39+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_prefix2mask, 0, 1, IS_STRING, 0)
40+
ZEND_ARG_TYPE_INFO(0, prefix, IS_LONG, 0)
41+
ZEND_END_ARG_INFO()
42+
43+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_mask2prefix, 0, 1, IS_LONG, 0)
44+
ZEND_ARG_TYPE_INFO(0, mask, IS_STRING, 0)
45+
ZEND_END_ARG_INFO()
46+
47+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_set_mtime_interval, 0, 2, _IS_BOOL, 0)
48+
ZEND_ARG_OBJ_INFO(0, link, resource, 0)
49+
ZEND_ARG_TYPE_INFO(0, sec, IS_LONG, 0)
50+
ZEND_END_ARG_INFO()
51+
52+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krisp_set_debug, 0, 1, _IS_BOOL, 0)
53+
ZEND_ARG_OBJ_INFO(0, link, resource, 0)
54+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, switch, IS_LONG, 0, "true")
55+
ZEND_END_ARG_INFO()
56+
57+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_KRISP___construct, 0, 0, 0)
58+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, datafile, IS_STRING, 1, "null")
59+
ZEND_END_ARG_INFO()
60+
61+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_KRISP_search, 0, 1, MAY_BE_OBJECT|MAY_BE_FALSE)
62+
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
63+
ZEND_END_ARG_INFO()
64+
65+
#define arginfo_class_KRISP_search_ex arginfo_class_KRISP_search
66+
67+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_KRISP_close, 0, 0, _IS_BOOL, 0)
68+
ZEND_END_ARG_INFO()
69+
70+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_KRISP_mtimeInterval, 0, 1, _IS_BOOL, 0)
71+
ZEND_ARG_TYPE_INFO(0, sec, IS_LONG, 0)
72+
ZEND_END_ARG_INFO()
73+
74+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_KRISP_debug, 0, 0, _IS_BOOL, 0)
75+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, switch, IS_LONG, 0, "true")
76+
ZEND_END_ARG_INFO()

php_krisp_class.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ const zend_module_dep krisp_deps[] = {
6363
/* }}} */
6464

6565
/* {{{ For Class declears */
66+
/* {{{ const zend_function_entry krisp_methods[] */
6667
const zend_function_entry krisp_methods[] = {
67-
PHP_ME_MAPPING (__construct, krisp_open, arginfo_krisp_open, ZEND_ACC_PUBLIC)
68-
PHP_ME_MAPPING (close, krisp_close, NULL, ZEND_ACC_PUBLIC)
69-
PHP_ME_MAPPING (search, krisp_search, NULL, ZEND_ACC_PUBLIC)
70-
PHP_ME_MAPPING (searchEx, krisp_search_ex, NULL, ZEND_ACC_PUBLIC)
71-
PHP_ME_MAPPING (mtimeInterval, krisp_set_mtime_interval, NULL, ZEND_ACC_PUBLIC)
72-
PHP_ME_MAPPING (debug, krisp_set_debug, NULL, ZEND_ACC_PUBLIC)
68+
PHP_ME_MAPPING (__construct, krisp_open, arginfo_class_KRISP___construct, ZEND_ACC_PUBLIC)
69+
PHP_ME_MAPPING (search, krisp_search, arginfo_class_KRISP_search, ZEND_ACC_PUBLIC)
70+
PHP_ME_MAPPING (searchEx, krisp_search_ex, arginfo_class_KRISP_search_ex, ZEND_ACC_PUBLIC)
71+
PHP_ME_MAPPING (close, krisp_close, arginfo_class_KRISP_close, ZEND_ACC_PUBLIC)
72+
PHP_ME_MAPPING (mtimeInterval, krisp_set_mtime_interval, arginfo_class_KRISP_mtimeInterval, ZEND_ACC_PUBLIC)
73+
PHP_ME_MAPPING (debug, krisp_set_debug, arginfo_class_KRISP_debug, ZEND_ACC_PUBLIC)
7374
{NULL, NULL, NULL}
7475
};
76+
/* }}} */
7577

7678
#define krisp_method_parameters(...) \
7779
zend_parse_parameters (ZEND_NUM_ARGS (), getThis (), __VA_ARGS__)

0 commit comments

Comments
 (0)