Skip to content

Update ext/odbc parameter names #6303

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 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
170 changes: 85 additions & 85 deletions ext/odbc/odbc.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,193 +4,193 @@

function odbc_close_all(): void {}

/** @param resource $result_id */
function odbc_binmode($result_id, int $mode): bool {}
/** @param resource $statement */
function odbc_binmode($statement, int $mode): bool {}

/** @param resource $result_id */
function odbc_longreadlen($result_id, int $length): bool {}
/** @param resource $statement */
function odbc_longreadlen($statement, int $length): bool {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_prepare($connection_id, string $query) {}
function odbc_prepare($odbc, string $query) {}

/** @param resource $result_id */
function odbc_execute($result_id, array $parameters_array = []): bool {}
/** @param resource $statement */
function odbc_execute($statement, array $params = []): bool {}

/** @param resource $result_id */
function odbc_cursor($result_id): string|false {}
/** @param resource $statement */
function odbc_cursor($statement): string|false {}

#ifdef HAVE_SQLDATASOURCES
/** @param resource $connection_id */
function odbc_data_source($connection_id, int $fetch_type): array|false {}
/** @param resource $odbc */
function odbc_data_source($odbc, int $fetch_type): array|false {}
#endif

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_exec($connection_id, string $query) {}
function odbc_exec($odbc, string $query) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
* @alias odbc_exec
*/
function odbc_do($connection_id, string $query) {}
function odbc_do($odbc, string $query) {}

#ifdef PHP_ODBC_HAVE_FETCH_HASH
/** @param resource $result */
function odbc_fetch_object($result, int $rownumber = -1): stdClass|false {}
/** @param resource $statement */
function odbc_fetch_object($statement, int $row = -1): stdClass|false {}

/** @param resource $result */
function odbc_fetch_array($result, int $rownumber = -1): array|false {}
/** @param resource $statement */
function odbc_fetch_array($statement, int $row = -1): array|false {}
#endif

/**
* @param resource $result_id
* @param array $result_array
* @param resource $statement
* @param array $array
*/
function odbc_fetch_into($result_id, &$result_array, int $rownumber = 0): int|false {}
function odbc_fetch_into($statement, &$array, int $row = 0): int|false {}

/** @param resource $result_id */
function odbc_fetch_row($result_id, ?int $row_number = null): bool {}
/** @param resource $statement */
function odbc_fetch_row($statement, ?int $row = null): bool {}

/** @param resource $result_id */
function odbc_result($result_id, string|int $field): string|bool|null {}
/** @param resource $statement */
function odbc_result($statement, string|int $field): string|bool|null {}

/** @param resource $result_id */
function odbc_result_all($result_id, string $format = ""): int|false {}
/** @param resource $statement */
function odbc_result_all($statement, string $format = ""): int|false {}

/** @param resource $result_id */
function odbc_free_result($result_id): bool {}
/** @param resource $statement */
function odbc_free_result($statement): bool {}

/** @return resource|false */
function odbc_connect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function odbc_connect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}
function odbc_connect(string $dsn, string $user, string $password, int $cursor_type = SQL_CUR_USE_DRIVER) {}

More in line with $fetch_type above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$cursor_type appears to be misleading; this is not about SQL_CURSOR_FORWARD_ONLY, SQL_CURSOR_KEYSET_DRIVEN, SQL_CURSOR_DYNAMIC or SQL_CURSOR_STATIC, but rather whether the ODBC cursor library (a compat layer for minimal drivers, which is deprecated at least on Windows) should be used. I don't have a better idea, so would be okay with $cursor_type).


/** @return resource|false */
function odbc_pconnect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}

/** @param resource $connection_id */
function odbc_close($connection_id): void {}
/** @param resource $odbc */
function odbc_close($odbc): void {}

/** @param resource $result_id */
function odbc_num_rows($result_id): int {}
/** @param resource $statement */
function odbc_num_rows($statement): int {}

#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30)
/** @param resource $result_id */
function odbc_next_result($result_id): bool {}
/** @param resource $statement */
function odbc_next_result($statement): bool {}
#endif

/** @param resource $result_id */
function odbc_num_fields($result_id): int {}
/** @param resource $statement */
function odbc_num_fields($statement): int {}

/** @param resource $result_id */
function odbc_field_name($result_id, int $field_number): string|false {}
/** @param resource $statement */
function odbc_field_name($statement, int $field_number): string|false {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere we do not make a distinction between $field_number and $field_name and just use $field (or $column depending on DB) for both. Whether it's a number or a name (a lot of APIs also accept both) is determined by the type.

(If we want to keep the distinction here, we should $field_number -> $field_num to keep the abbreviation consistent.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure here. Only odbc_field_num() accepts a name; all other odbc_field_*() functions expect the number (which looks strange to me). (ah, odbc_result() accepts either) But since we have the type, just $field looks good to me.


/** @param resource $result_id */
function odbc_field_type($result_id, int $field_number): string|false {}
/** @param resource $statement */
function odbc_field_type($statement, int $field_number): string|false {}

/** @param resource $result_id */
function odbc_field_len($result_id, int $field_number): int|false {}
/** @param resource $statement */
function odbc_field_len($statement, int $field_number): int|false {}

/**
* @param resource $result_id
* @param resource $statement
* @alias odbc_field_len
*/
function odbc_field_precision($result_id, int $field_number): int|false {}
function odbc_field_precision($statement, int $field_number): int|false {}

/** @param resource $result_id */
function odbc_field_scale($result_id, int $field_number): int|false {}
/** @param resource $statement */
function odbc_field_scale($statement, int $field_number): int|false {}

/** @param resource $result_id */
function odbc_field_num($result_id, string $field_name): int|false {}
/** @param resource $statement */
function odbc_field_num($statement, string $field_name): int|false {}

/** @param resource $connection_id */
function odbc_autocommit($connection_id, bool $onoff = false): int|bool {}
/** @param resource $odbc */
function odbc_autocommit($odbc, bool $enable = false): int|bool {}

/** @param resource $connection_id */
function odbc_commit($connection_id): bool {}
/** @param resource $odbc */
function odbc_commit($odbc): bool {}

/** @param resource $connection_id */
function odbc_rollback($connection_id): bool {}
/** @param resource $odbc */
function odbc_rollback($odbc): bool {}

/** @param resource|null $connection_id */
function odbc_error($connection_id = null): string {}
/** @param resource|null $odbc */
function odbc_error($odbc = null): string {}

/** @param resource|null $connection_id */
function odbc_errormsg($connection_id = null): string {}
/** @param resource|null $odbc */
function odbc_errormsg($odbc = null): string {}

/** @param resource $conn_id */
function odbc_setoption($conn_id, int $which, int $option, int $value): bool {}
/** @param resource $odbc */
function odbc_setoption($odbc, int $which, int $option, int $value): bool {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_tables($connection_id, ?string $catalog = null, ?string $schema = null, ?string $name = null, ?string $table_types = null) {}
function odbc_tables($odbc, ?string $catalog = null, ?string $schema = null, ?string $table = null, ?string $types = null) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_columns($connection_id, ?string $catalog = null, ?string $schema = null, ?string $table_name = null, ?string $column_name = null) {}
function odbc_columns($odbc, ?string $catalog = null, ?string $schema = null, ?string $table = null, ?string $column = null) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_gettypeinfo($connection_id, int $data_type = 0) {}
function odbc_gettypeinfo($odbc, int $data_type = 0) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_primarykeys($connection_id, ?string $catalog, string $schema, string $table) {}
function odbc_primarykeys($odbc, ?string $catalog, string $schema, string $table) {}

#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_procedurecolumns($connection_id, ?string $catalog = null, ?string $schema = null, ?string $proc = null, ?string $column = null) {}
function odbc_procedurecolumns($odbc, ?string $catalog = null, ?string $schema = null, ?string $procedure = null, ?string $column = null) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_procedures($connection_id, ?string $catalog = null, ?string $schema = null, ?string $name = null) {}
function odbc_procedures($odbc, ?string $catalog = null, ?string $schema = null, ?string $procedure = null) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_foreignkeys($connection_id, ?string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table) {}
function odbc_foreignkeys($odbc, ?string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table) {}
#endif

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_specialcolumns($connection_id, int $type, ?string $catalog, string $schema, string $table, int $scope, int $nullable) {}
function odbc_specialcolumns($odbc, int $type, ?string $catalog, string $schema, string $table, int $scope, int $nullable) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_statistics($connection_id, ?string $catalog, string $schema, string $name, int $unique, int $accuracy) {}
function odbc_statistics($odbc, ?string $catalog, string $schema, string $table, int $unique, int $accuracy) {}

#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35)
/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_tableprivileges($connection_id, ?string $catalog, string $schema, string $name) {}
function odbc_tableprivileges($odbc, ?string $catalog, string $schema, string $table) {}

/**
* @param resource $connection_id
* @param resource $odbc
* @return resource|false
*/
function odbc_columnprivileges($connection_id, ?string $catalog, string $schema, string $table, string $column) {}
function odbc_columnprivileges($odbc, ?string $catalog, string $schema, string $table, string $column) {}
#endif
Loading