8000 Add stubs for PDO by kocsismate · Pull Request #4803 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

Add stubs for PDO #4803

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions Zend/tests/bug71428.2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ bug #71428.2: inheritance of ye olde dynamic interfaces
--FILE--
<?php
interface StatementInterface {
public function fetch($first = null, $second, $third);
public function fetch(int $first = PDO::FETCH_BOTH, int $second = PDO::FETCH_ORI_NEXT, int $third = 0);
}

class Statement extends PDOStatement implements StatementInterface {}

interface StatementInterface1 {
public function fetch($first = null, $second = null, $third = null);
public function fetch(int $first = PDO::FETCH_ASSOC, int $second = PDO::FETCH_ORI_PRIOR, int $third = 1);
}

class Statement1 extends PDOStatement implements StatementInterface1 {}
Expand Down
6 changes: 1 addition & 5 deletions ext/pdo/pdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "php_pdo_int.h"
#include "zend_exceptions.h"
#include "ext/spl/spl_exceptions.h"
#include "pdo_arginfo.h"

zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce;

Expand Down Expand Up @@ -96,11 +97,6 @@ PHP_FUNCTION(pdo_drivers)
}
/* }}} */

/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_pdo_drivers, 0)
ZEND_END_ARG_INFO()
/* }}} */

/* {{{ pdo_functions[] */
const zend_function_entry pdo_functions[] = {
PHP_FE(pdo_drivers, arginfo_pdo_drivers)
Expand Down
135 changes: 135 additions & 0 deletions ext/pdo/pdo.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php

/* pdo.c */

function pdo_drivers(): array {}

/* pdo_dbh.c */

class PDO {
public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {}

/** @return bool */
public function beginTransaction() {}

/** @return bool */
public function commit() {}

/** @return string|null */
public function errorCode() {}

/** @return array */
public function errorInfo() {}

/** @return int|false */
public function exec(string $statement) {}

/** @return mixed */
public function getAttribute(int $attribute) {}

/** @return array */
public static function getAvailableDrivers() {}

/** @return bool */
public function inTransaction() {}

/** @return string|false */
public function lastInsertId(?string $name = null) {}

/** @return PDOStatement|false */
public function prepare(string $statement, array $driver_options = []) {}

/** @return PDOStatement|false */
public function query(string $statement) {}

/** @return string|false */
public function quote(string $string, int $parameter_type = PDO::PARAM_STR) {}

/** @return bool */
public function rollBack() {}

/**
* @param mixed $value
* @return bool
*/
public function setAttribute(int $attribute, $value) {}
}

/* pdo_stmt.c */

class PDOStatement implements Traversable {
/**
* @param mixed $column
* @param mixed $driverdata
* @return bool
*/
public function bindColumn($column, &$param = null, int $type = 0, int $maxlen = 0, $driverdata = "") {}

/**
* @param int|string $parameter
* @param mixed $driver_options
* @return bool
*/
public function bindParam($parameter, &$variable, int $data_type = PDO::PARAM_STR, ?int $length = null, $driver_options = null) {}

/**
* @param int|string $parameter
* @param mixed $value
* @return bool
*/
public function bindValue($parameter, $value, int $data_type = PDO::PARAM_STR) {}

/** @return bool */
public function closeCursor() {}

/** @return int */
public function columnCount() {}

/** @return void */
public function debugDumpParams() {}

/** @return string|null */
public function errorCode() {}

/** @return array */
public function errorInfo() {}

/** @return bool */
public function execute(?array $input_parameters = null) {}

/** @return mixed */
public function fetch(int $fetch_style = PDO::FETCH_BOTH, int $cursor_orientation = PDO::FETCH_ORI_NEXT, int $cursor_offset = 0) {}

/**
* @param mixed $fetch_argument
* @return array|false
*/
public function fetchAll(int $fetch_style = PDO::FETCH_BOTH, $fetch_argument = null, array $ctor_args = []) {}

/** @return mixed */
public function fetchColumn(int $column_number = 0) {}

/** @return mixed */
public function fetchObject(string $class_name = "stdClass", ?array $ctor_args = null) {}

/** @return int|bool|string|array */
public function getAttribute(int $attribute) {}

/** @return array|false */
public function getColumnMeta(int $column) {}

/** @return bool */
public function nextRowset() {}

/** @return int */
public function rowCount() {}

/**
* @param mixed $value
* @return bool
*/
public function setAttribute(int $attribute, $value) {}

/** @return bool */
public function setFetchMode(int $mode) {}
}
128 changes: 128 additions & 0 deletions ext/pdo/pdo_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/* This is a generated file, edit the .stub.php file instead. */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pdo_drivers, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, username, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, passwd, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_beginTransaction, 0, 0, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_PDO_commit arginfo_class_PDO_beginTransaction

#define arginfo_class_PDO_errorCode arginfo_class_PDO_beginTransaction

#define arginfo_class_PDO_errorInfo arginfo_class_PDO_beginTransaction

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_exec, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_getAttribute, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, attribute, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_PDO_getAvailableDrivers arginfo_class_PDO_beginTransaction

#define arginfo_class_PDO_inTransaction arginfo_class_PDO_beginTransaction

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_lastInsertId, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_prepare, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, driver_options, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_PDO_query arginfo_class_PDO_exec

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_quote, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, parameter_type, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_PDO_rollBack arginfo_class_PDO_beginTransaction

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_setAttribute, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, attribute, IS_LONG, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 1)
ZEND_ARG_INFO(0, column)
ZEND_ARG_INFO(1, param)
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, maxlen, IS_LONG, 0)
ZEND_ARG_INFO(0, driverdata)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindParam, 0, 0, 2)
ZEND_ARG_INFO(0, parameter)
ZEND_ARG_INFO(1, variable)
ZEND_ARG_TYPE_INFO(0, data_type, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 1)
ZEND_ARG_INFO(0, driver_options)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindValue, 0, 0, 2)
ZEND_ARG_INFO(0, parameter)
ZEND_ARG_INFO(0, value)
ZEND_ARG_TYPE_INFO(0, data_type, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_PDOStatement_closeCursor arginfo_class_PDO_beginTransaction

#define arginfo_class_PDOStatement_columnCount arginfo_class_PDO_beginTransaction

#define arginfo_class_PDOStatement_debugDumpParams arginfo_class_PDO_beginTransaction

#define arginfo_class_PDOStatement_errorCode arginfo_class_PDO_beginTransaction

#define arginfo_class_PDOStatement_errorInfo arginfo_class_PDO_beginTransaction

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_execute, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, input_parameters, IS_ARRAY, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetch, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, fetch_style, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, cursor_orientation, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, cursor_offset, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchAll, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, fetch_style, IS_LONG, 0)
ZEND_ARG_INFO(0, fetch_argument)
ZEND_ARG_TYPE_INFO(0, ctor_args, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchColumn, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, column_number, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchObject, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, ctor_args, IS_ARRAY, 1)
ZEND_END_ARG_INFO()

#define arginfo_class_PDOStatement_getAttribute arginfo_class_PDO_getAttribute

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_getColumnMeta, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, column, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_PDOStatement_nextRowset arginfo_class_PDO_beginTransaction

#define arginfo_class_PDOStatement_rowCount arginfo_class_PDO_beginTransaction

#define arginfo_class_PDOStatement_setAttribute arginfo_class_PDO_setAttribute

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setFetchMode, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
ZEND_END_ARG_INFO()
Loading
0