Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with callback and namespaces #99

Open
ecow opened this issue Oct 27, 2013 · 1 comment
Open

Problems with callback and namespaces #99

ecow opened this issue Oct 27, 2013 · 1 comment
Labels
Milestone

Comments

@ecow
Copy link

ecow commented Oct 27, 2013

Hi,
I got a strange problem that I can't understand. This snippet:

<?php
namespace test;
require 'vendor/autoload.php';
use Respect\Rest\Router;


$r3 = new Router('/tools/test.php');
    $r3->get('/', function() {
        return array('v' => 2.0);
    })->accept( array( 'text/html' => array( 'myns\\Standard', 'htmlRenderer')));

namespace myns;
class Standard
{
        public static function htmlRenderer($data)
        {
            return 'OK';
        }
}

works on window with php 5.4 and fails (Fatal error: Function name must be a string ) in ubuntu with php 5.3.

If in ubuntu I change the line 67 in file request.php from:

$response = $proxyCallback($response);

to

$response = call_user_func($proxyCallback,$response);

it works!
The problem seams related to namespace because if I remove namespace it works in both environments.
Can someone figure why?

This is a great library!!! Thank you

UPDATE:

It seams that the problem is related to a change in php 5.4.:

$callback = array($object, 'methodName');
$callback(); // prior to PHP 5.4 you need call_user_func()

Is php 5.4 a requirement for Respect\Rest?

@nickl-
Copy link
Member

nickl- commented Nov 22, 2013

@botk thank you for bringing this under our attention. =)

@augustohp augustohp added this to the 1.0 milestone May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants