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

Update param and return type for db2_autocommit() #2239

Merged
merged 2 commits into from
Feb 18, 2023

Conversation

phansys
Copy link
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
Collaborator

This pull request has been marked as ready for review.

@@ -1644,7 +1644,7 @@
'DateTimeZone::getTransitions' => ['list<array{ts: int, time: string, offset: int, isdst: bool, abbr: string}>', 'timestamp_begin='=>'int', 'timestamp_end='=>'int'],
'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
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
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
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.

None yet

3 participants