Skip to content

Commit 76ef188

Browse files
authored
Merge pull request #45 from kleisauke/add-type-hints
Add type hints
2 parents 310b029 + 3cbd72c commit 76ef188

File tree

6 files changed

+333
-244
lines changed

6 files changed

+333
-244
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ missing
3030
mkinstalldirs
3131
modules
3232
run-tests.php
33+
gen_stub.php
3334
tests/*/*.diff
3435
tests/*/*.out
3536
tests/*/*.php
3637
tests/*/*.exp
3738
tests/*/*.log
3839
tests/*/*.sh
40+
41+
# Used by gen_stub.php
42+
PHP-Parser-*

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ $ make install
143143
Add `extension=vips.so` to `php.ini`, perhaps in `~/vips/lib/php.ini`,
144144
if you configured php as above.
145145

146+
### Development: regenerate `vips_arginfo.h`
147+
148+
Run:
149+
150+
```
151+
$ curl -LO https://github.com/php/php-src/raw/ffacda14b88be797a466f472359f306d626e698f/build/gen_stub.php
152+
$ php gen_stub.php
153+
```
154+
146155
### Links
147156

148157
http://php.net/manual/en/internals2.php

config.h.in~

Lines changed: 0 additions & 58 deletions
This file was deleted.

vips.c

Lines changed: 14 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
ZEND_DECLARE_MODULE_GLOBALS(vips)
2525
*/
2626

27+
#include "vips_arginfo.h"
28+
2729
/* True global resources - no need for thread safety here */
2830
static int le_gobject;
2931

@@ -1047,7 +1049,7 @@ vips_php_call_array(const char *operation_name, zval *instance,
10471049

10481050
/* }}} */
10491051

1050-
/* {{{ proto mixed vips_php_call(string operation_name, resource instance [, more])
1052+
/* {{{ proto array|long vips_call(string operation_name, resource instance [, mixed args])
10511053
Call any vips operation */
10521054

10531055
PHP_FUNCTION(vips_call)
@@ -1094,7 +1096,7 @@ PHP_FUNCTION(vips_call)
10941096
}
10951097
/* }}} */
10961098

1097-
/* {{{ proto resource vips_image_new_from_file(string filename [, array options])
1099+
/* {{{ proto array|long vips_image_new_from_file(string filename [, array options])
10981100
Open an image from a filename */
10991101
PHP_FUNCTION(vips_image_new_from_file)
11001102
{
@@ -1138,7 +1140,7 @@ PHP_FUNCTION(vips_image_new_from_file)
11381140
}
11391141
/* }}} */
11401142

1141-
/* {{{ proto resource vips_image_new_from_buffer(string buffer [, string option_string, array options])
1143+
/* {{{ proto array|long vips_image_new_from_buffer(string buffer [, string option_string, array options])
11421144
Open an image from a string */
11431145
PHP_FUNCTION(vips_image_new_from_buffer)
11441146
{
@@ -1237,7 +1239,7 @@ PHP_FUNCTION(vips_image_new_from_array)
12371239
}
12381240
/* }}} */
12391241

1240-
/* {{{ proto resource vips_interpolate_new(string name])
1242+
/* {{{ proto resource vips_interpolate_new(string name)
12411243
make a new interpolator */
12421244
PHP_FUNCTION(vips_interpolate_new)
12431245
{
@@ -1260,7 +1262,7 @@ PHP_FUNCTION(vips_interpolate_new)
12601262
}
12611263
/* }}} */
12621264

1263-
/* {{{ proto long vips_image_write_to_file(resource image, string filename [, array options])
1265+
/* {{{ proto array|long vips_image_write_to_file(resource image, string filename [, array options])
12641266
Write an image to a filename */
12651267
PHP_FUNCTION(vips_image_write_to_file)
12661268
{
@@ -1311,7 +1313,7 @@ PHP_FUNCTION(vips_image_write_to_file)
13111313
}
13121314
/* }}} */
13131315

1314-
/* {{{ proto string|long vips_image_write_to_buffer(resource image, string suffix [, array options])
1316+
/* {{{ proto array|long vips_image_write_to_buffer(resource image, string suffix [, array options])
13151317
Write an image to a string */
13161318
PHP_FUNCTION(vips_image_write_to_buffer)
13171319
{
@@ -1354,7 +1356,7 @@ PHP_FUNCTION(vips_image_write_to_buffer)
13541356
}
13551357
/* }}} */
13561358

1357-
/* {{{ proto resource vips_image_copy_memory(resource image)
1359+
/* {{{ proto array|long vips_image_copy_memory(resource image)
13581360
Copy an image to a memory image */
13591361
PHP_FUNCTION(vips_image_copy_memory)
13601362
{
@@ -1388,7 +1390,7 @@ PHP_FUNCTION(vips_image_copy_memory)
13881390
}
13891391
/* }}} */
13901392

1391-
/* {{{ proto resource vips_image_new_from_memory(string data, integer width, integer height, integer bands, string format)
1393+
/* {{{ proto array|long vips_image_new_from_memory(string memory, integer width, integer height, integer bands, string format)
13921394
Wrap an image around a memory array. */
13931395
PHP_FUNCTION(vips_image_new_from_memory)
13941396
{
@@ -1431,7 +1433,7 @@ PHP_FUNCTION(vips_image_new_from_memory)
14311433
}
14321434
/* }}} */
14331435

1434-
/* {{{ proto string vips_image_write_to_memory(resource image)
1436+
/* {{{ proto string|long vips_image_write_to_memory(resource image)
14351437
Write an image to a memory array. */
14361438
PHP_FUNCTION(vips_image_write_to_memory)
14371439
{
@@ -1469,7 +1471,7 @@ PHP_FUNCTION(vips_image_write_to_memory)
14691471
APPEND(return_value, p[i]); \
14701472
}
14711473

1472-
/* {{{ proto array vips_image_write_to_array(resource image)
1474+
/* {{{ proto array|long vips_image_write_to_array(resource image)
14731475
Write an image to a PHP array. */
14741476
PHP_FUNCTION(vips_image_write_to_array)
14751477
{
@@ -1588,7 +1590,7 @@ PHP_FUNCTION(vips_foreign_find_load_buffer)
15881590
}
15891591
/* }}} */
15901592

1591-
/* {{{ proto array vips_image_get(resource image, string field)
1593+
/* {{{ proto array|long vips_image_get(resource image, string field)
15921594
Fetch field from image */
15931595
PHP_FUNCTION(vips_image_get)
15941596
{
@@ -2195,186 +2197,12 @@ PHP_MINFO_FUNCTION(vips)
21952197
}
21962198
/* }}} */
21972199

2198-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_file, 0)
2199-
ZEND_ARG_INFO(0, filename)
2200-
ZEND_ARG_INFO(0, options)
2201-
ZEND_END_ARG_INFO()
2202-
2203-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_buffer, 0)
2204-
ZEND_ARG_INFO(0, buffer)
2205-
ZEND_ARG_INFO(0, option_string)
2206-
ZEND_ARG_INFO(0, options)
2207-
ZEND_END_ARG_INFO()
2208-
2209-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_array, 0)
2210-
ZEND_ARG_INFO(0, array)
2211-
ZEND_ARG_INFO(0, scale)
2212-
ZEND_ARG_INFO(0, offset)
2213-
ZEND_END_ARG_INFO()
2214-
2215-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_file, 0)
2216-
ZEND_ARG_INFO(0, image)
2217-
ZEND_ARG_INFO(0, filename)
2218-
ZEND_ARG_INFO(0, options)
2219-
ZEND_END_ARG_INFO()
2220-
2221-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_buffer, 0)
2222-
ZEND_ARG_INFO(0, image)
2223-
ZEND_ARG_INFO(0, options)
2224-
ZEND_END_ARG_INFO()
2225-
2226-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_copy_memory, 0)
2227-
ZEND_ARG_INFO(0, image)
2228-
ZEND_END_ARG_INFO()
2229-
2230-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_memory, 0)
2231-
ZEND_ARG_INFO(0, array)
2232-
ZEND_ARG_INFO(0, width)
2233-
ZEND_ARG_INFO(0, height)
2234-
ZEND_ARG_INFO(0, bands)
2235-
ZEND_ARG_INFO(0, format)
2236-
ZEND_END_ARG_INFO()
2237-
2238-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_memory, 0)
2239-
ZEND_ARG_INFO(0, image)
2240-
ZEND_END_ARG_INFO()
2241-
2242-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_array, 0)
2243-
ZEND_ARG_INFO(0, image)
2244-
ZEND_END_ARG_INFO()
2245-
2246-
ZEND_BEGIN_ARG_INFO(arginfo_vips_foreign_find_load, 0)
2247-
ZEND_ARG_INFO(0, filename)
2248-
ZEND_END_ARG_INFO()
2249-
2250-
ZEND_BEGIN_ARG_INFO(arginfo_vips_interpolate_new, 0)
2251-
ZEND_ARG_INFO(0, name)
2252-
ZEND_END_ARG_INFO()
2253-
2254-
ZEND_BEGIN_ARG_INFO(arginfo_vips_foreign_find_load_buffer, 0)
2255-
ZEND_ARG_INFO(0, buffer)
2256-
ZEND_END_ARG_INFO()
2257-
2258-
ZEND_BEGIN_ARG_INFO(arginfo_vips_call, 0)
2259-
ZEND_ARG_INFO(0, operation_name)
2260-
ZEND_ARG_INFO(0, instance)
2261-
ZEND_END_ARG_INFO()
2262-
2263-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_get, 0)
2264-
ZEND_ARG_INFO(0, image)
2265-
ZEND_ARG_INFO(0, field)
2266-
ZEND_END_ARG_INFO()
2267-
2268-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_get_typeof, 0)
2269-
ZEND_ARG_INFO(0, image)
2270-
ZEND_ARG_INFO(0, field)
2271-
ZEND_END_ARG_INFO()
2272-
2273-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_set, 0)
2274-
ZEND_ARG_INFO(0, image)
2275-
ZEND_ARG_INFO(0, field)
2276-
ZEND_ARG_INFO(0, value)
2277-
ZEND_END_ARG_INFO()
2278-
2279-
ZEND_BEGIN_ARG_INFO(arginfo_vips_type_from_name, 0)
2280-
ZEND_ARG_INFO(0, name)
2281-
ZEND_END_ARG_INFO()
2282-
2283-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_set_type, 0)
2284-
ZEND_ARG_INFO(0, image)
2285-
ZEND_ARG_INFO(0, type)
2286-
ZEND_ARG_INFO(0, field)
2287-
ZEND_ARG_INFO(0, value)
2288-
ZEND_END_ARG_INFO()
2289-
2290-
ZEND_BEGIN_ARG_INFO(arginfo_vips_image_remove, 0)
2291-
ZEND_ARG_INFO(0, image)
2292-
ZEND_ARG_INFO(0, field)
2293-
ZEND_END_ARG_INFO()
2294-
2295-
ZEND_BEGIN_ARG_INFO(arginfo_vips_error_buffer, 0)
2296-
ZEND_END_ARG_INFO()
2297-
2298-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_set_max, 0)
2299-
ZEND_ARG_INFO(0, value)
2300-
ZEND_END_ARG_INFO()
2301-
2302-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_set_max_mem, 0)
2303-
ZEND_ARG_INFO(0, value)
2304-
ZEND_END_ARG_INFO()
2305-
2306-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_set_max_files, 0)
2307-
ZEND_ARG_INFO(0, value)
2308-
ZEND_END_ARG_INFO()
2309-
2310-
ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_set, 0)
2311-
ZEND_ARG_INFO(0, value)
2312-
ZEND_END_ARG_INFO()
2313-
2314-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max, 0)
2315-
ZEND_END_ARG_INFO()
2316-
2317-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_mem, 0)
2318-
ZEND_END_ARG_INFO()
2319-
2320-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_files, 0)
2321-
ZEND_END_ARG_INFO()
2322-
2323-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_size, 0)
2324-
ZEND_END_ARG_INFO()
2325-
2326-
ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_get, 0)
2327-
ZEND_END_ARG_INFO()
2328-
2329-
ZEND_BEGIN_ARG_INFO(arginfo_vips_version, 0)
2330-
ZEND_END_ARG_INFO()
2331-
/* {{{ vips_functions[]
2332-
*
2333-
* Every user visible function must have an entry in vips_functions[].
2334-
*/
2335-
const zend_function_entry vips_functions[] = {
2336-
PHP_FE(vips_image_new_from_file, arginfo_vips_image_new_from_file)
2337-
PHP_FE(vips_image_new_from_buffer, arginfo_vips_image_new_from_buffer)
2338-
PHP_FE(vips_image_new_from_array, arginfo_vips_image_new_from_array)
2339-
PHP_FE(vips_image_write_to_file, arginfo_vips_image_write_to_file)
2340-
PHP_FE(vips_image_write_to_buffer, arginfo_vips_image_write_to_buffer)
2341-
PHP_FE(vips_image_copy_memory, arginfo_vips_image_copy_memory)
2342-
PHP_FE(vips_image_new_from_memory, arginfo_vips_image_new_from_memory)
2343-
PHP_FE(vips_image_write_to_memory, arginfo_vips_image_write_to_memory)
2344-
PHP_FE(vips_image_write_to_array, arginfo_vips_image_write_to_array)
2345-
PHP_FE(vips_foreign_find_load, arginfo_vips_foreign_find_load)
2346-
PHP_FE(vips_foreign_find_load_buffer, arginfo_vips_foreign_find_load_buffer)
2347-
PHP_FE(vips_interpolate_new, arginfo_vips_interpolate_new)
2348-
2349-
PHP_FE(vips_call, arginfo_vips_call)
2350-
PHP_FE(vips_image_get, arginfo_vips_image_get)
2351-
PHP_FE(vips_image_get_typeof, arginfo_vips_image_get_typeof)
2352-
PHP_FE(vips_image_set, arginfo_vips_image_set)
2353-
PHP_FE(vips_type_from_name, arginfo_vips_type_from_name)
2354-
PHP_FE(vips_image_set_type, arginfo_vips_image_set_type)
2355-
PHP_FE(vips_image_remove, arginfo_vips_image_remove)
2356-
PHP_FE(vips_error_buffer, arginfo_vips_error_buffer)
2357-
PHP_FE(vips_cache_set_max, arginfo_vips_cache_set_max)
2358-
PHP_FE(vips_cache_set_max_mem, arginfo_vips_cache_set_max_mem)
2359-
PHP_FE(vips_cache_set_max_files, arginfo_vips_cache_set_max_files)
2360-
PHP_FE(vips_concurrency_set, arginfo_vips_concurrency_set)
2361-
PHP_FE(vips_cache_get_max, arginfo_vips_cache_get_max)
2362-
PHP_FE(vips_cache_get_max_mem, arginfo_vips_cache_get_max_mem)
2363-
PHP_FE(vips_cache_get_max_files, arginfo_vips_cache_get_max_files)
2364-
PHP_FE(vips_cache_get_size, arginfo_vips_cache_get_size)
2365-
PHP_FE(vips_concurrency_get, arginfo_vips_concurrency_get)
2366-
PHP_FE(vips_version, arginfo_vips_version)
2367-
2368-
PHP_FE_END /* Must be the last line in vips_functions[] */
2369-
};
2370-
/* }}} */
2371-
23722200
/* {{{ vips_module_entry
23732201
*/
23742202
zend_module_entry vips_module_entry = {
23752203
STANDARD_MODULE_HEADER,
23762204
"vips",
2377-
vips_functions,
2205+
ext_functions,
23782206
PHP_MINIT(vips),
23792207
PHP_MSHUTDOWN(vips),
23802208
PHP_RINIT(vips), /* Replace with NULL if there's nothing to do at request start */

0 commit comments

Comments
 (0)