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

Events.php on method $callable parameter accepts only callable #1835

Closed
d4mn opened this issue Mar 14, 2019 · 3 comments
Closed

Events.php on method $callable parameter accepts only callable #1835

d4mn opened this issue Mar 14, 2019 · 3 comments

Comments

@d4mn
Copy link

d4mn commented Mar 14, 2019


name: Bug report
about: Help us improve the framework by reporting bugs!


Describe the bug
All these methods:

  • Events::on('create', 'myFunction'); // procedural function
  • Events::on('create', ['myClass', 'myMethod']); // Class::method
  • Events::on('create', [$myInstance, 'myMethod']); // Method on an existing instance
    Throws an error because argument $callable in function public static function on($event_name, callable $callback, $priority = EVENT_PRIORITY_NORMAL) must be of type callable string and array throws an error

CodeIgniter 4 version
Codeigniter 4 beta 1

Affected module(s)
Events.php

Expected behavior, and steps to reproduce if appropriate
method should not be strict checked in functions attribute

Context

  • OS: Debian
  • Web server nginx 1.15
  • PHP version v7.3.2
@d4mn
Copy link
Author

d4mn commented Mar 15, 2019

I tried to look deeper into this and found this article https://wiki.php.net/rfc/consistent_callables First example of problem i think is it

@bangbangda
Copy link
Contributor

I tested it, is OK. @d4mn

$testEvent = new \App\Libraries\TestEvent();
Events::on('pre_system', [$testEvent, 'hello']);
class TestEvent
{
    public function hello()
    {
        log_message('debug', 'TestEvent hello....');
        return true;
    }
}

@atishhamte
Copy link
Contributor

Is it working as expected?

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