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

Class 'Arr' not found #3

Open
sagikazarmark opened this issue May 3, 2014 · 7 comments
Open

Class 'Arr' not found #3

sagikazarmark opened this issue May 3, 2014 · 7 comments

Comments

@sagikazarmark
Copy link
Contributor

call_user_func_array() expects parameter 1 to be a valid callback, class 'Arr' not found

I get this message related to this line.

@WanWizard
Copy link
Member

Arr is expected to be present in the global namespace. This is done in the Framework via the Facade classes. If you use this repo on it's own, outside the framework, you need to make sure Arr is available like it is done in phpunit:

// make Arr available in the global namespace
class_alias('Fuel\Common\Arr', 'Arr');

The correct solution is to have a DiC extension definition (like "getArrInstance') that can be attached to a class that needs Arr, so it can fetch an instance itself. This is how v2 handles it for all other dependencies.

@sagikazarmark
Copy link
Contributor Author

Does that mean that I can do this in my package and use this package later with Fuel's DiC? You talked about extensibility, doesn't this break it?

What about this?

if( ! class_exists('Arr'))
{
    // make Arr available in the global namespace
    class_alias('Fuel\Common\Arr', 'Arr');
}

@emlynwest
Copy link
Contributor

Personally I feel this should not be the case. It should be possible to use as much of the common package without having to set up little bits and pieces like this. It should be possible to inject an instance of Arr or to have the class constructed for you if one is not passed.

@sagikazarmark
Copy link
Contributor Author

@stevewest The actual problem is that DataContainer uses Arr, and it assumes it exists in the root namespace. So it is OK to inject it in YOUR class, but in the actual case, it does not matter.

@emlynwest
Copy link
Contributor

Yes, I know that. What I propose is a solution to that. You should not have to alias a class to set up the data container like that.

@WanWizard
Copy link
Member

Which is what I wrote as "the correct solution" ;)

@sagikazarmark
Copy link
Contributor Author

First step to the correct solution:

https://github.com/fuelphp/common/blob/master/src/Providers/FuelServiceProvider.php#L45

Arr Proxy uses an instance of Arr class resolved from the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants