In the case of the following example,
I can not easily find the places where get() of Book class
is called by searching files with get
.
Because there are a lot of get
which do not belong to Book class
.
class Book {
function get() {
}
}
class Pen {
function get() {
}
}
$obj = new Pen;
$obj->get();
$obj = new Book;
$obj->get();
But if I use just functions or static methods like the following codes,
I can easily find the places by searching files with Book_get
or Book::get
.
And if I use functions, I can find both where the function is called
and where the function is defined
by searching only with Book_get
.
function Book_get() {
}
function Pen_get() {
}
Book_get();
Pen_get();
class Book {
static function get() {
}
}
class Pen {
static function get() {
}
}
Book::get();
Pen::get();
When I use non-static methods, how can I easily find the places where they are called?
Or is it better to use functions or static methods instead of non-static methods as possible?