simple
simple

Reputation: 1091

How to find where implementation of a function is located in PHP in this case?

I was just traversing the workflow of zend framework and cant really find where the function "findByUri()" is located, I found the class it belongs , simply dumping it, but going through the hierarchy of that class(parents , interfaces and so forth) I cant really find it. I found where it is called from

....
 call_user_func_array(
            array($this->getContainer(), $method),
            $arguments);
    ...

but it is not in there (the class that GetContainer() returns)

any Idea, I know u can assign a variable to class simple by $class->someVar =...; But never had done it with class functions... Thanks

Upvotes: 1

Views: 677

Answers (4)

Gordon
Gordon

Reputation: 316969

There is no method by this name in the entire ZF. It's probably a magic accessor done within a __call method of $this->container. I take the snippet you provided is from Zend_View_Helper_Navigation_HelperAbstract, so it should be any of the classes belonging to the Zend_Navigation package.

EDIT
From the ZF Reference Manual on Zend_Navigation containers:

Containers have finder methods for retrieving pages. They are findOneBy($property, $value), findAllBy($property, $value), and findBy($property, $value, $all = false). Those methods will recursively search the container for pages matching the given $page->$property == $value. The first method, findOneBy(), will return a single page matching the property with the given value, or NULL if it cannot be found. The second method will return all pages with a property matching the given value. The third method will call one of the two former methods depending on the $all flag.

The finder methods can also be used magically by appending the property name to findBy, findOneBy, or findAllBy, e.g. findOneByLabel('Home') to return the first matching page with label Home. Other combinations are findByLabel(...), findOnyByTitle(...), findAllByController(...), etc. Finder methods also work on custom properties, such as findByFoo('bar').

Upvotes: 1

Pekka
Pekka

Reputation: 449415

If it's really the implementation of a function you're looking for, I'd say that's what a PHP IDE is for. Every decent PHP IDE can find out where a function was defined.

Related: Any good PHP IDE, preferably free or cheap?

Upvotes: 0

Roberto Aloi
Roberto Aloi

Reputation: 30985

grep is your friend.

From a shell:

grep -ir "function findByUri" .

More about the grep command:

http://unixhelp.ed.ac.uk/CGI/man-cgi?grep

Upvotes: 0

raveren
raveren

Reputation: 18542

I use Agent Ransack to search through codebases that are not my own. You'd be looking for this string:

"function findByUri"

Upvotes: 1

Related Questions