Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts

    PHP Bug: Property Class __invoke

    PHP Code:
    class {
      function 
    __construct() { }
      function 
    __invoke() { echo("Invoked\n"); }
    }

    $a = new a();
    $a();
    // Prints: Invoked

    class {
      private 
    $x;

      function 
    __construct() {
        
    $this->= new a();
        
    $this->x();
      }
    }

    $b = new b();
    // Issues error: undefined method b::x 
    Bug, yes?

    Workaround?
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • #2
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Maybe should have mentioned that's on 5.3.0.

    On 5.2.11 ionCube/Suhosin I get:

    Function name must be a string on line 9

    ----
    Edit: I'll clarify.

    This is important to me because I have a complex self-sanitising database class that has an invoke method. The invoke method takes a sql string, resource or a iterating result class. Lets me do stuff like try { $row = $db($db('query')); } or try { foreach($db('query') as $row) ... } - IF I can get the damn invoke working...
    Last edited by Lamped; 10-29-2009 at 01:56 AM.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    $this->x declares itself as a callable method which refuses to execute and instead focuses on the missing b::x() method. It doesn't really matter which way they sway (I would pass any callback into a method for assignment rather than to declare it within a class), but if this is the route that the PHP team plans to take they will still need to correct that is_callable returns true on it.
    I'd say report it anyway.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #4
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    I have reported it, if only to see what they say
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •