Edit report at http://bugs.php.net/bug.php?id=54171&edit=1

 ID:                 54171
 Comment by:         hellosexyprout at gmail dot com
 Reported by:        hellosexyprout at gmail dot com
 Summary:            is_callable() returns false on callable functions
                     when not specifying namespace
 Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Ubuntu 10.10
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

Damn it, thanks!

Well, sorry to have bothered you and thank you for answering my 

questions. ;)


Previous Comments:
------------------------------------------------------------------------
[2011-03-05 23:08:57] fel...@php.net

You mistyped 'world' on function call :-)

------------------------------------------------------------------------
[2011-03-05 23:06:16] hellosexyprout at gmail dot com

Great, I'm okay with that.



But how do explain this?



<?php

namespace Foo;



function bar() {}

function hello_world() {}



bar(); // works

hello_word(); // fails

------------------------------------------------------------------------
[2011-03-05 22:49:47] fel...@php.net

It is not incoherent, see...



"How does an unqualified function name or unqualified constant name like
name resolve?



Function or constant names that do not contain a backslash like name can
be resolved in 2 different ways. 



First, the current namespace name is prepended to name. 



Finally, if the constant or function name does not exist in the current
namespace, a global constant or function name is used if it exists."



-- http://docs.php.net/manual/en/language.namespaces.faq.php



namespace foo;

function bar() { }



bar(); // foo\ is prepended in compile-time



$x = 'bar'; // obviously foo\ will not be prepended

$x(); // hence 'bar' is not found

------------------------------------------------------------------------
[2011-03-05 22:33:26] hellosexyprout at gmail dot com

But then PHP's behavior is incoherent because:



<?php

namespace NS;



class HelloWorld {}

function hello_world() {}



// This will work

new HelloWorld;



// This will fail

hello_word();

?>



And anyway, being able to call bar() while 'bar' isn't 

considered callable by is_callable() (see report) is totally 

incoherent. Or I'm missing something big.

------------------------------------------------------------------------
[2011-03-05 22:05:28] fel...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected, see #51651

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=54171


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54171&edit=1

Reply via email to