1--TEST--
2Test Pdo\Sqlite::createFunction() arguments error
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7
8declare(strict_types=1);
9
10$db = new Pdo\Sqlite('sqlite::memory:');
11
12class TrampolineTest {
13    public function __call(string $name, array $arguments) {
14        return '';
15    }
16}
17
18try {
19    $db->createFunction(null, [new TrampolineTest(), 'strtoupper']);
20} catch (Throwable $e) {
21    echo $e->getMessage() . "\n";
22}
23
24try {
25    $db->createFunction('strtoupper', null);
26} catch (Throwable $e) {
27    echo $e->getMessage() . "\n";
28}
29
30try {
31    $db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'], null);
32} catch (Throwable $e) {
33    echo $e->getMessage() . "\n";
34}
35
36try {
37    $db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'], 1, null);
38} catch (Throwable $e) {
39    echo $e->getMessage() . "\n";
40}
41
42echo 'done!';
43?>
44--EXPECT--
45Pdo\Sqlite::createFunction(): Argument #1 ($function_name) must be of type string, null given
46Pdo\Sqlite::createFunction(): Argument #2 ($callback) must be a valid callback, no array or string given
47Pdo\Sqlite::createFunction(): Argument #3 ($num_args) must be of type int, null given
48Pdo\Sqlite::createFunction(): Argument #4 ($flags) must be of type int, null given
49done!
50