Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate arginfo from stub #83

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ cache:
environment:
BIN_SDK_VER: 2.2.0
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ARCH: x64
VC: vc14
PHP_VER: 7.1.33
TS: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ARCH: x86
VC: vc14
PHP_VER: 7.1.33
TS: 0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: x64
VC: vc15
Expand Down
62 changes: 21 additions & 41 deletions pcov.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@

#include "php_pcov.h"

/* Compatibility for PHP < 8 */
#ifndef ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE
#define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \
ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
#endif

#include "pcov_arginfo.h"

#define PCOV_FILTER_ALL 0
#define PCOV_FILTER_INCLUDE 1
#define PCOV_FILTER_EXCLUDE 2
Expand Down Expand Up @@ -671,8 +679,8 @@ static zend_always_inline void php_pcov_clean(HashTable *table) { /* {{{ */
}
} /* }}} */

/* {{{ array \pcov\collect(int $type = \pcov\all, array $filter = []); */
PHP_NAMED_FUNCTION(php_pcov_collect)
/* {{{ array \pcov\collect(int $type = \pcov\all, array $filter = []): ?array; */
ZEND_FUNCTION(collect)
{
zend_long type = PCOV_FILTER_ALL;
zval *filter = NULL;
Expand Down Expand Up @@ -744,8 +752,8 @@ PHP_NAMED_FUNCTION(php_pcov_collect)
php_pcov_report(PCG(start), return_value);
} /* }}} */

/* {{{ void \pcov\start(void) */
PHP_NAMED_FUNCTION(php_pcov_start)
/* {{{ void \pcov\start(void): void */
ZEND_FUNCTION(start)
{
if (zend_parse_parameters_none() != SUCCESS) {
return;
Expand All @@ -756,8 +764,8 @@ PHP_NAMED_FUNCTION(php_pcov_start)
PCG(enabled) = 1;
} /* }}} */

/* {{{ void \pcov\stop(void) */
PHP_NAMED_FUNCTION(php_pcov_stop)
/* {{{ void \pcov\stop(void): void */
ZEND_FUNCTION(stop)
{
if (zend_parse_parameters_none() != SUCCESS) {
return;
Expand All @@ -768,8 +776,8 @@ PHP_NAMED_FUNCTION(php_pcov_stop)
PCG(enabled) = 0;
} /* }}} */

/* {{{ void \pcov\clear(bool $files = 0) */
PHP_NAMED_FUNCTION(php_pcov_clear)
/* {{{ void \pcov\clear(bool $files = 0): void */
ZEND_FUNCTION(clear)
{
zend_bool files = 0;

Expand Down Expand Up @@ -798,8 +806,8 @@ PHP_NAMED_FUNCTION(php_pcov_clear)
php_pcov_clean(&PCG(covered));
} /* }}} */

/* {{{ array \pcov\waiting(void) */
PHP_NAMED_FUNCTION(php_pcov_waiting)
/* {{{ array \pcov\waiting(void): ?array */
ZEND_FUNCTION(waiting)
{
zend_string *waiting;

Expand All @@ -818,8 +826,8 @@ PHP_NAMED_FUNCTION(php_pcov_waiting)
} ZEND_HASH_FOREACH_END();
} /* }}} */

/* {{{ int \pcov\memory(void) */
PHP_NAMED_FUNCTION(php_pcov_memory)
/* {{{ int \pcov\memory(void); ?long */
ZEND_FUNCTION(memory)
{
zend_arena *arena = PCG(mem);

Expand All @@ -836,34 +844,6 @@ PHP_NAMED_FUNCTION(php_pcov_memory)
} while ((arena = arena->prev));
} /* }}} */

/* {{{ */
ZEND_BEGIN_ARG_INFO_EX(php_pcov_collect_arginfo, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, filter, IS_ARRAY, 0)
ZEND_END_ARG_INFO() /* }}} */

/* {{{ */
ZEND_BEGIN_ARG_INFO_EX(php_pcov_clear_arginfo, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, files, _IS_BOOL, 0)
ZEND_END_ARG_INFO() /* }}} */

/* {{{ */
ZEND_BEGIN_ARG_INFO_EX(php_pcov_no_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO() /* }}} */

/* {{{ php_pcov_functions[]
*/
const zend_function_entry php_pcov_functions[] = {
ZEND_NS_FENTRY("pcov", start, php_pcov_start, php_pcov_no_arginfo, 0)
ZEND_NS_FENTRY("pcov", stop, php_pcov_stop, php_pcov_no_arginfo, 0)
ZEND_NS_FENTRY("pcov", collect, php_pcov_collect, php_pcov_collect_arginfo, 0)
ZEND_NS_FENTRY("pcov", clear, php_pcov_clear, php_pcov_clear_arginfo, 0)
ZEND_NS_FENTRY("pcov", waiting, php_pcov_waiting, php_pcov_no_arginfo, 0)
ZEND_NS_FENTRY("pcov", memory, php_pcov_memory, php_pcov_no_arginfo, 0)
PHP_FE_END
};
/* }}} */

/* {{{ pcov_module_deps[] */
static const zend_module_dep pcov_module_deps[] = {
ZEND_MOD_REQUIRED("pcre")
Expand All @@ -877,7 +857,7 @@ zend_module_entry pcov_module_entry = {
NULL,
pcov_module_deps,
"pcov",
php_pcov_functions,
ext_functions,
PHP_MINIT(pcov),
PHP_MSHUTDOWN(pcov),
PHP_RINIT(pcov),
Expand Down
18 changes: 18 additions & 0 deletions pcov.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/** @generate-function-entries */

namespace pcov;

function start(): void {}

function stop(): void {}

function collect(int $type=\pcov\all, array $filter = []): ?array {}

function clear(bool $files = false): void {}

function waiting(): ?array {}

function memory(): ?int {}

41 changes: 41 additions & 0 deletions pcov_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: d2cebacd7516b58ebb9ce549595ee2b8ce3c3d6d */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcov_start, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()

#define arginfo_pcov_stop arginfo_pcov_start

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcov_collect, 0, 0, IS_ARRAY, 1)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "pcov\\all")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filter, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcov_clear, 0, 0, IS_VOID, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, files, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcov_waiting, 0, 0, IS_ARRAY, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcov_memory, 0, 0, IS_LONG, 1)
ZEND_END_ARG_INFO()


ZEND_FUNCTION(start);
ZEND_FUNCTION(stop);
ZEND_FUNCTION(collect);
ZEND_FUNCTION(clear);
ZEND_FUNCTION(waiting);
ZEND_FUNCTION(memory);


static const zend_function_entry ext_functions[] = {
remicollet marked this conversation as resolved.
Show resolved Hide resolved
ZEND_NS_FE("pcov", start, arginfo_pcov_start)
ZEND_NS_FE("pcov", stop, arginfo_pcov_stop)
ZEND_NS_FE("pcov", collect, arginfo_pcov_collect)
ZEND_NS_FE("pcov", clear, arginfo_pcov_clear)
ZEND_NS_FE("pcov", waiting, arginfo_pcov_waiting)
ZEND_NS_FE("pcov", memory, arginfo_pcov_memory)
ZEND_FE_END
};