Skip to content

Update param and return type for db2_autocommit()#2239

Merged
ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
phansys:db2_autocommit
Feb 18, 2023
Merged

Update param and return type for db2_autocommit()#2239
ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
phansys:db2_autocommit

Conversation

@phansys
Copy link
Copy Markdown
Contributor

@phansys phansys commented Feb 15, 2023

Prior to version ibm_db2 2.1, the db2_autocommit() function was expecting a boolean as argument 2.

See:

Additionally, the return type of this function can be DB2_AUTOCOMMIT_OFF|DB2_AUTOCOMMIT_ON|bool depending on the received arguments:

When db2_autocommit() receives only the connection parameter, it returns the current state of AUTOCOMMIT for the requested connection as an integer value. A value of DB2_AUTOCOMMIT_OFF indicates that AUTOCOMMIT is off, while a value of DB2_AUTOCOMMIT_ON indicates that AUTOCOMMIT is on.

When db2_autocommit() receives both the connection parameter and autocommit parameter, it attempts to set the AUTOCOMMIT state of the requested connection to the corresponding state. Returns true on success or false on failure.

@phansys phansys marked this pull request as ready for review February 15, 2023 23:59
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

'DateTimeZone::listAbbreviations' => ['array<string, list<array{dst: bool, offset: int, timezone_id: string|null}>>'],
'DateTimeZone::listIdentifiers' => ['list<string>', 'what='=>'int', 'country='=>'string'],
'db2_autocommit' => ['mixed', 'connection'=>'resource', 'value='=>'int'],
'db2_autocommit' => ['DB2_AUTOCOMMIT_OFF|DB2_AUTOCOMMIT_ON|bool', 'connection'=>'resource', 'value='=>'DB2_AUTOCOMMIT_OFF|DB2_AUTOCOMMIT_ON'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does the function do if it receives something that isn't \DB2_AUTOCOMMIT_OFF|\DB2_AUTOCOMMIT_ON? Like 1337 for example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A warning is emitted and the function returns false:

Warning: db2_autocommit(): value must be one of DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF

See https://github.com/php/pecl-database-ibm_db2/blob/4eebfe146a873e25af26fbca30f480747cd237af/ibm_db2.c#L3522-L3525.

@phansys phansys requested a review from ondrejmirtes February 17, 2023 18:59
@ondrejmirtes ondrejmirtes merged commit 199b249 into phpstan:1.10.x Feb 18, 2023
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you.

@phansys phansys deleted the db2_autocommit branch February 18, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants