php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78126 PDO::sqliteCreateFunction is not exposed via reflection
Submitted: 2019-06-07 23:32 UTC Modified: 2025-01-02 12:18 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: morozov at tut dot by Assigned: cmb (profile)
Status: Closed Package: PDO SQLite
PHP Version: 7.3.6 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: morozov at tut dot by
New email:
PHP Version: OS:

 

 [2019-06-07 23:32 UTC] morozov at tut dot by
Description:
------------
Despite being available at runtime, PDO::sqliteCreateFunction is not exposed via reflection: neither via the Reflection API, nor via the command line (php --rc).

Test script:
---------------
$conn = new PDO('sqlite::memory:');
var_dump(method_exists($conn, 'sqliteCreateFunction'));

try {
    $re = new ReflectionMethod($conn, 'sqliteCreateFunction');
} catch (ReflectionException $e) {
    echo $e->getMessage(), PHP_EOL;
}



Expected result:
----------------
Method reflection is created

Actual result:
--------------
bool(true)
Method PDO::sqliteCreateFunction() does not exist


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-08 00:46 UTC] morozov at tut dot by
The same is true for other PDO::sqlite*() and PDO::pgsql*() functions.
 [2019-06-16 03:27 UTC] camporter1 at gmail dot com
The issue here as far as I can tell is that driver methods are not defined directly on the PDO class entry. Instead, an object handler is used to get these methods. From what I can tell, reflection seems to rely only on the class entry.

Since I was curious, I opened https://github.com/php/php-src/pull/4271 as an experimental solution.

This still wouldn't solve listing all of the available methods under get_method, and it's clunky.
 [2019-06-16 03:28 UTC] camporter1 at gmail dot com
The following pull request has been associated:

Patch Name: Change ReflectionMethod object construction to support get_method-based methods
On GitHub:  https://github.com/php/php-src/pull/4271
Patch:      https://github.com/php/php-src/pull/4271.patch
 [2021-09-13 14:44 UTC] cmb@php.net
In my opinion, we should not add support for this to reflection,
but rather get rid of the magic methods, one way or another.
 [2025-01-02 12:18 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2025-01-02 12:18 UTC] cmb@php.net
This is basically resolved by the introduction of driver specific
PDO subclasses[1].  Slightly modified test script:

<?php
$conn = new Pdo\Sqlite('sqlite::memory:');
var_dump(method_exists($conn, 'createFunction'));

try {
    $re = new ReflectionMethod($conn, 'createFunction');
} catch (ReflectionException $e) {
    echo $e->getMessage(), PHP_EOL;
}
?>

outputs

bool(true)

I think this is as good as it gets.

[1] <https://wiki.php.net/rfc/pdo_driver_specific_subclasses>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jan 14 05:01:28 2025 UTC