Skip to content

Commit

Permalink
Add stubs for zend_test
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Feb 13, 2020
1 parent 8039225 commit e99d5d3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
26 changes: 3 additions & 23 deletions ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,14 @@
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_test.h"
#include "test_arginfo.h"

static zend_class_entry *zend_test_interface;
static zend_class_entry *zend_test_class;
static zend_class_entry *zend_test_child_class;
static zend_class_entry *zend_test_trait;
static zend_object_handlers zend_test_class_handlers;

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_array_return, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_nullable_array_return, IS_ARRAY, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_void_return, IS_VOID, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_deprecated, IS_VOID, 0)
ZEND_ARG_INFO(0, arg1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_terminate_string, 0, 0, 1)
ZEND_ARG_INFO(1, str)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_leak_variable, 0, 0, 1)
ZEND_ARG_INFO(0, variable)
ZEND_END_ARG_INFO()

ZEND_FUNCTION(zend_test_func)
{
RETVAL_STR_COPY(EX(func)->common.function_name);
Expand Down Expand Up @@ -336,9 +316,9 @@ static const zend_function_entry zend_test_functions[] = {
ZEND_FE(zend_test_nullable_array_return, arginfo_zend_test_nullable_array_return)
ZEND_FE(zend_test_void_return, arginfo_zend_test_void_return)
ZEND_DEP_FE(zend_test_deprecated, arginfo_zend_test_deprecated)
ZEND_FE(zend_create_unterminated_string, NULL)
ZEND_FE(zend_create_unterminated_string, arginfo_zend_create_unterminated_string)
ZEND_FE(zend_terminate_string, arginfo_zend_terminate_string)
ZEND_FE(zend_leak_bytes, NULL)
ZEND_FE(zend_leak_bytes, arginfo_zend_leak_bytes)
ZEND_FE(zend_leak_variable, arginfo_zend_leak_variable)
ZEND_FE_END
};
Expand Down
18 changes: 18 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

function zend_test_array_return(): array {}

function zend_test_nullable_array_return(): ?array {}

function zend_test_void_return(): void {}

function zend_test_deprecated(): void {}

function zend_create_unterminated_string(string $str): string {}

function zend_terminate_string(string &$str) {}

/** @param mixed $variable */
function zend_leak_variable($variable): void {}

function zend_leak_bytes(int $bytes = 3): void {}
28 changes: 28 additions & 0 deletions ext/zend_test/test_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* This is a generated file, edit the .stub.php file instead. */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

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

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_void_return, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()

#define arginfo_zend_test_deprecated arginfo_zend_test_void_return

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_create_unterminated_string, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_terminate_string, 0, 0, 1)
ZEND_ARG_TYPE_INFO(1, str, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_leak_variable, 0, 1, IS_VOID, 0)
ZEND_ARG_INFO(0, variable)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_leak_bytes, 0, 0, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, bytes, IS_LONG, 0)
ZEND_END_ARG_INFO()

0 comments on commit e99d5d3

Please sign in to comment.