Skip to content

Commit 199b249

Browse files
authored
Update param and return type for db2_autocommit()
1 parent 28565ff commit 199b249

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

conf/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ parameters:
146146
- ../stubs/ImagickPixel.stub
147147
- ../stubs/PDOStatement.stub
148148
- ../stubs/date.stub
149+
- ../stubs/ibm_db2.stub
149150
- ../stubs/mysqli.stub
150151
- ../stubs/zip.stub
151152
- ../stubs/dom.stub

resources/functionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@
16441644
'DateTimeZone::getTransitions' => ['list<array{ts: int, time: string, offset: int, isdst: bool, abbr: string}>', 'timestamp_begin='=>'int', 'timestamp_end='=>'int'],
16451645
'DateTimeZone::listAbbreviations' => ['array<string, list<array{dst: bool, offset: int, timezone_id: string|null}>>'],
16461646
'DateTimeZone::listIdentifiers' => ['list<string>', 'what='=>'int', 'country='=>'string'],
1647-
'db2_autocommit' => ['mixed', 'connection'=>'resource', 'value='=>'int'],
1647+
'db2_autocommit' => ['DB2_AUTOCOMMIT_OFF|DB2_AUTOCOMMIT_ON|bool', 'connection'=>'resource', 'value='=>'DB2_AUTOCOMMIT_OFF|DB2_AUTOCOMMIT_ON'],
16481648
'db2_bind_param' => ['bool', 'stmt'=>'resource', 'parameter_number'=>'int', 'variable_name'=>'string', 'parameter_type='=>'int', 'data_type='=>'int', 'precision='=>'int', 'scale='=>'int'],
16491649
'db2_client_info' => ['object|false', 'connection'=>'resource'],
16501650
'db2_close' => ['bool', 'connection'=>'resource'],

stubs/ibm_db2.stub

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
/**
4+
* @param resource $connection
5+
* @param \DB2_AUTOCOMMIT_OFF|\DB2_AUTOCOMMIT_ON $value
6+
*
7+
* @return ($value is null ? \DB2_AUTOCOMMIT_OFF|\DB2_AUTOCOMMIT_ON : bool)
8+
*/
9+
function db2_autocommit($connection, int $value = null) {}

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,7 @@ public function dataFileAsserts(): iterable
12001200
yield from $this->gatherAssertTypes(__DIR__ . '/data/mysql-stmt.php');
12011201
yield from $this->gatherAssertTypes(__DIR__ . '/data/list-shapes.php');
12021202
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7607.php');
1203+
yield from $this->gatherAssertTypes(__DIR__ . '/data/ibm_db2.php');
12031204
}
12041205

12051206
/**
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace IBMDB2;
4+
5+
use function db2_autocommit;
6+
use function db2_connect;
7+
use function PHPStan\Testing\assertType;
8+
9+
use const DB2_AUTOCOMMIT_OFF;
10+
use const DB2_AUTOCOMMIT_ON;
11+
12+
final class IBMDB2
13+
{
14+
public function testAutocommit(): void
15+
{
16+
assertType('0|1', db2_autocommit(db2_connect()));
17+
assertType('bool', db2_autocommit(db2_connect(), DB2_AUTOCOMMIT_OFF));
18+
assertType('bool', db2_autocommit(db2_connect(), DB2_AUTOCOMMIT_ON));
19+
}
20+
}

0 commit comments

Comments
 (0)