Skip to content

Does not play well with PHP Scoper #194

@andrewjmead

Description

@andrewjmead

I'm using this library in a WordPress plugin that uses PHP Scoper to scope all dependencies.

I noticed that this library does not support PHP Scoper out of the box due to its use of string class names as seen here, here, and here.

I was able to patch this in PHP Scoper using the following patcher, but it would be awesome to see built-in support. Keep in mind this just patches the two instances in Reader.php and doesn't attempt to patch the instance in Client.php:

    'patchers' => [
        static function (string $filePath, string $prefix, string $contents): string {
            $parts = explode('vendor', $filePath);

            // Fix an issue with geoip2 where the reader has string class names
            if ($parts[1] === '/geoip2/geoip2/src/Database/Reader.php') {
                return preg_replace(
                    '%\$class = \'GeoIp2%',
                    '$class = \'' . $prefix . '\\\\GeoIp2',
                    $contents
                );
            }

            return $contents;
        },
    ],

I was encourage to open a separate issue by @oschwald in #170. Thanks!

😁

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions