geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.95k stars 519 forks source link

Compile Error: Class Ivory\GoogleMap\Services\Geocoding\Geocoder cannot extend from interface Geocoder\Geocoder #390

Closed sdecandelario closed 9 years ago

sdecandelario commented 9 years ago

Seems that the class Ivory\GoogleMap\Services\Geocoding\Geocoder use an interface called BaseGeocoder, and uses like an extends, and not an implements

<?php

/*
 * This file is part of the Ivory Google Map package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\GoogleMap\Services\Geocoding;

use Geocoder\Geocoder as BaseGeocoder;

/**
 * Geocoder which describes a google map geocoder.
 *
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Geocoder
 * @author GeLo <geloen.eric@gmail.com>
 */
class Geocoder extends BaseGeocoder
{
    /**
     * {@inheritdoc}
     */
    public function geocode($request)
    {
        if ($this->getProvider() instanceof GeocoderProvider) {
            return $this->getProvider()->getGeocodedData($request);
        }

        return parent::geocode($request);
    }

    /**
     * {@inheritdoc}
     */
    public function reverse($latitude, $longitude)
    {
        if ($this->getProvider() instanceof GeocoderProvider) {
            return $this->getProvider()->getReversedData(array($latitude, $longitude));
        }

        return parent::reverse($latitude, $longitude);
    }
}

And if you see the class refered, have two methods that not are in the Geocoder original class:

<?php

/**
 * This file is part of the Geocoder package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @license    MIT License
 */

namespace Geocoder;

use Geocoder\Model\Address;

/**
 * @author William Durand <william.durand1@gmail.com>
 */
interface Geocoder
{
    /**
     * Version
     */
    const VERSION = '3.0.0-dev';

    /**
     * Geocodes a given value.
     *
     * @param string $value
     *
     * @return Address[]
     */
    public function geocode($value);

    /**
     * Reverses geocode given latitude and longitude values.
     *
     * @param double $latitude.
     * @param double $longitude
     *
     * @return Address[]
     */
    public function reverse($latitude, $longitude);

    /**
     * Returns the maximum number of Address objects that can be
     * returned by `geocode()` or `reverse()` methods.
     *
     * @return integer
     */
    public function getLimit();

    /**
     * Sets the maximum number of `Address` objects that can be
     * returned by `geocode()` or `reverse()` methods.
     *
     * @param integer $limit
     *
     * @return Geocoder
     */
    public function limit($limit);
}

I don't know if is anyithing about some upgrade of doctrine or whatever.

toin0u commented 9 years ago

Hi @hades87

You get this error because you're using ivory-google-map package from @egeloen which is based on Geocoder 2.x as you can the composer.json file.

It looks like you're using dev-master. Can you copy/paste the composer show -i output please ?

sdecandelario commented 9 years ago

doctrine/annotations v1.2.2 Docblock Annotations Parser doctrine/cache v1.3.1 Caching library offering an object-oriented API for many cache backends doctrine/collections v1.2 Collections Abstraction library doctrine/common v2.4.2 Common Library for Doctrine projects doctrine/dbal v2.5.0 Database Abstraction Layer doctrine/doctrine-bundle v1.3.0 Symfony DoctrineBundle doctrine/doctrine-cache-bundle v1.0.1 Symfony2 Bundle for Doctrine Cache doctrine/inflector v1.0 Common String Manipulations with regard to casing and singular/plural rules. doctrine/lexer v1.0 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers. doctrine/orm v2.4.7 Object-Relational-Mapper for PHP egeloen/google-map 1.4.1 Google Map API v3 integration for PHP 5.3+ egeloen/google-map-bundle 2.2.1 Provides a google map integration for your Symfony2 Project. egeloen/http-adapter 0.5.0 Issue HTTP request for PHP 5.3+. egeloen/json-builder 1.0.3 JSON builder with escaping control for PHP 5.3+ igorw/get-in v1.0.3 Functions for for hash map (assoc array) traversal. incenteev/composer-parameter-handler v2.1.0 Composer script handling your ignored parameter file jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library knplabs/knp-menu v1.1.2 An object oriented menu library knplabs/knp-menu-bundle 1.1.x-dev 2fecac0 This bundle provides an integration of the KnpMenu library kriswallsmith/assetic v1.2.1 Asset Management for PHP monolog/monolog 1.11.0 Sends your logs to files, sockets, inboxes, databases and various web services psr/http-message 0.5.1 Common interface for HTTP messages psr/log 1.0.0 Common interface for logging libraries ptachoire/cssembed v1.0.2 Css url embed library. raulfraile/ladybug v1.0.11 Simple and Extensible PHP Dumper raulfraile/ladybug-bundle v1.0.6 Symfony2 bundle for Ladybug library (Simple and Extensible PHP Dumper) raulfraile/ladybug-installer v1.0.1 Unified installer for ladybug addons raulfraile/ladybug-plugin-extra v1.0.1 Extra plugin for ladybug raulfraile/ladybug-plugin-symfony2 v1.0.1 Symfony2 plugin for ladybug raulfraile/ladybug-theme-modern v1.0.7 Theme 'modern' for ladybug sensio/distribution-bundle v3.0.13 Base bundle for Symfony Distributions sensio/framework-extra-bundle v3.0.4 This bundle provides a way to configure your controllers with annotations sensio/generator-bundle v2.5.0 This bundle generates code for you sensiolabs/security-checker v2.0.0 A security checker for your composer.lock simplethings/entity-audit-bundle dev-master 775a1ff Audit for Doctrine Entities swiftmailer/swiftmailer v5.3.1 Swiftmailer, free feature-rich PHP mailer symfony/assetic-bundle v2.5.0 Integrates Assetic into Symfony2 symfony/monolog-bundle v2.6.1 Symfony MonologBundle symfony/swiftmailer-bundle v2.3.8 Symfony SwiftmailerBundle symfony/symfony v2.6.1 The Symfony PHP framework twbs/bootstrap v3.0.3 Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development. twig/extensions v1.2.0 Common additional features for Twig that do not directly belong in core twig/twig v1.16.2 Twig, the flexible, fast, and secure template language for PHP willdurand/geocoder dev-master 0792a1a The almost missing Geocoder PHP 5.4 library.

toin0u commented 9 years ago

As you can see you're using the dev-master. I think you need to fix it in your composer.json and it should work as expected :)

sdecandelario commented 9 years ago

Puting the 2.8.1 is right?

toin0u commented 9 years ago

@hades87 Exactly :) https://packagist.org/packages/willdurand/geocoder#2.8.1

toin0u commented 9 years ago

I will close the issue as this is not "directly" related to the library and it's "fixed" :) But feel free to ask if you have any issue :)

sdecandelario commented 9 years ago

Ok, now all works fine, thanks for all the info :)