From 474a0392aa352411ae8cab1c3f61c875fc645e88 Mon Sep 17 00:00:00 2001 From: Dan Shepherd Date: Thu, 25 Sep 2025 19:43:05 +0100 Subject: [PATCH 1/2] Add MaxMindDb stub --- PhpStormStubsMap.php | 3 + maxminddb/maxminddb.php | 179 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 maxminddb/maxminddb.php diff --git a/PhpStormStubsMap.php b/PhpStormStubsMap.php index 1692e74a1..eee7e5940 100644 --- a/PhpStormStubsMap.php +++ b/PhpStormStubsMap.php @@ -662,6 +662,9 @@ final class PhpStormStubsMap 'LuaSandboxRuntimeError' => 'LuaSandbox/LuaSandbox.php', 'LuaSandboxSyntaxError' => 'LuaSandbox/LuaSandbox.php', 'LuaSandboxTimeoutError' => 'LuaSandbox/LuaSandbox.php', + 'MaxMind\\Db\\InvalidDatabaseException' => 'maxminddb/maxminddb.php', + 'MaxMind\\Db\\Metadata' => 'maxminddb/maxminddb.php', + 'MaxMind\\Db\\Reader' => 'maxminddb/maxminddb.php', 'Memcache' => 'memcache/memcache.php', 'MemcachePool' => 'memcache/memcache.php', 'Memcached' => 'memcached/memcached.php', diff --git a/maxminddb/maxminddb.php b/maxminddb/maxminddb.php new file mode 100644 index 000000000..0cebefa92 --- /dev/null +++ b/maxminddb/maxminddb.php @@ -0,0 +1,179 @@ + + */ + public array $description; + + /** + * This is an unsigned 16-bit integer which is always 4 or 6. It indicates + * whether the database contains IPv4 or IPv6 address data. + * + * @var int + */ + public int $ipVersion; + + /** + * An array of strings, each of which is a language code. A given record + * may contain data items that have been localized to some or all of + * these languages. This may be undefined. + * + * @var array + */ + public array $languages; + + /** + * @var int + */ + public int $nodeByteSize; + + /** + * This is an unsigned 32-bit integer indicating the number of nodes in + * the search tree. + * + * @var int + */ + public int $nodeCount; + + /** + * This is an unsigned 16-bit integer. It indicates the number of bits in a + * record in the search tree. Note that each node consists of two records. + * + * @var int + */ + public int $recordSize; + + /** + * @var int + */ + public int $searchTreeSize; +} \ No newline at end of file From 9221bd701a0a7ee360e696719f248cad097b37b8 Mon Sep 17 00:00:00 2001 From: Dan Shepherd Date: Thu, 25 Sep 2025 21:50:02 +0100 Subject: [PATCH 2/2] Fixes for tests Added 'maxminddb' directory to 'PhpCoreStubsProvider::StubDirectoryMap' Fixed formatting --- maxminddb/maxminddb.php | 26 +++++-------------- .../Providers/Stubs/PhpCoreStubsProvider.php | 1 + 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/maxminddb/maxminddb.php b/maxminddb/maxminddb.php index 0cebefa92..e8c052e49 100644 --- a/maxminddb/maxminddb.php +++ b/maxminddb/maxminddb.php @@ -19,9 +19,7 @@ class Reader * if the database is invalid or there is an error reading * from it */ - public function __construct(string $database) - { - } + public function __construct(string $database) {} /** * Retrieves the record for the IP address. @@ -36,9 +34,7 @@ public function __construct(string $database) * * @throws \BadMethodCallException if this method is called on a closed database */ - public function get(string $ipAddress): mixed - { - } + public function get(string $ipAddress): mixed {} /** * Retrieves the record for the IP address and its associated network prefix length. @@ -54,9 +50,7 @@ public function get(string $ipAddress): mixed * * @throws \BadMethodCallException if this method is called on a closed database */ - public function getWithPrefixLen(string $ipAddress): array - { - } + public function getWithPrefixLen(string $ipAddress): array {} /** * @return Metadata object for the database @@ -64,9 +58,7 @@ public function getWithPrefixLen(string $ipAddress): array * * @throws \InvalidArgumentException if arguments are passed to the method */ - public function metadata(): Metadata - { - } + public function metadata(): Metadata {} /** * Closes the MaxMind DB and returns resources to the system. @@ -74,17 +66,13 @@ public function metadata(): Metadata * @throws \Exception * if an I/O error occurs */ - public function close(): void - { - } + public function close(): void {} } /** * This class should be thrown when unexpected data is found in the database. */ -class InvalidDatabaseException extends \Exception -{ -} +class InvalidDatabaseException extends \Exception {} /** * This class provides the metadata for the MaxMind DB file. @@ -176,4 +164,4 @@ class Metadata * @var int */ public int $searchTreeSize; -} \ No newline at end of file +} diff --git a/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php b/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php index 02b5f9b2e..08591829d 100644 --- a/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php +++ b/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php @@ -117,6 +117,7 @@ class PhpCoreStubsProvider 'libevent', 'LuaSandbox', 'lzf', + 'maxminddb', 'mailparse', 'memcache', 'memcached',