Issues

ZF2-35: Zend\OAuth\Signature and Zend\OAuth\AbstractSignature throw fatal error

Description

Attempting to create an OAuth request with Zend\OAuth throws a fatal error. I'm not a git master, so can't tell you exactly the revision I'm working with, but I did a 'git pull' immediately prior to filing this ticket, and the problem was happening there. 'git show' shows: d010912 fixed s/__construct/initialize/ for Initializable


function zflite_autoload($class)
{
    echo "zflite_autoload: $class\n";
    $class = str_replace(array('_','\\'), '/', $class);
    if (file_exists(__DIR__.'/../src/'.$class.'.php')) {
        include __DIR__.'/../src/'.$class.'.php';
    }
}
spl_autoload_register('zflite_autoload');

$termie = 'http://term.ie/oauth/example';
$config = array(
  'consumerKey' => 'key',
  'consumerSecret' => 'secret',
  'siteUrl' => $termie,
  'requestTokenUrl' => "$termie/request_token.php",
  'accessTokenUrl' => "$termie/access_token.php"
);

$consumer = new Zend\OAuth\Consumer($config);

// fetch request token
$token = $consumer->getRequestToken();
var_dump($token);


PHP Fatal error:  Can't inherit abstract function Zend\OAuth\Signature::sign() (previously declared abstract in Zend\OAuth\Signature\AbstractSignature) in /Users/clay/Desktop/zf2test/src/Zend/OAuth/Signature/AbstractSignature.php on line 39
PHP Stack trace:
PHP   1. {main}() /Users/clay/Desktop/zf2test/tests/scratch.inc:0
PHP   2. Zend\OAuth\Consumer->getRequestToken() /Users/clay/Desktop/zf2test/tests/scratch.inc:62
PHP   3. Zend\OAuth\Http\RequestToken->execute() /Users/clay/Desktop/zf2test/src/Zend/OAuth/Consumer.php:106
PHP   4. Zend\OAuth\Http\RequestToken->assembleParams() /Users/clay/Desktop/zf2test/src/Zend/OAuth/Http/RequestToken.php:55
PHP   5. Zend\OAuth\Http\Utility->sign() /Users/clay/Desktop/zf2test/src/Zend/OAuth/Http/RequestToken.php:94
PHP   6. zflite_autoload() /Users/clay/Desktop/zf2test/tests/scratch.inc:0
PHP   7. include() /Users/clay/Desktop/zf2test/tests/scratch.inc:45
PHP   8. zflite_autoload() /Users/clay/Desktop/zf2test/tests/scratch.inc:0
PHP   9. include() /Users/clay/Desktop/zf2test/tests/scratch.inc:45

Comments

You can delete the function definition from /Zend/OAuth/Signature/AbstractSignature.php:

@@ -82,16 +82,6 @@
     }
 
     /**
-     * Sign a request
-     * 
-     * @param  array $params 
-     * @param  null|string $method 
-     * @param  null|string $url 
-     * @return string
-     */
-    public abstract function sign(array $params, $method = null, $url = null);
-
-    /**
      * Normalize the base signature URL
      * 
      * @param  string $url 

Assigned to wrong person.

Fixed all fatal errors (due to Zend\URI change and fudgy interface inheritance issues). Sent as pull request and fixed on local zend-oauth-cleanup branch on my fork.