Web lists-archives.com

Re: [PHP] Missing something ...




On Sun, Dec 27, 2015 at 10:00 AM, Lester Caine <lester@xxxxxxxxxxx> wrote:

> On 27/12/15 16:52, Aziz Saleh wrote:
> > What does get_class_methods give you? Does it list those functions part
> of
> > of the list?
>
> Good point ...
> Fatal error: Call to undefined method GedcomRecord::get_class_methods()


get_class_methods [1] is a global function--not a method. Pass it the name
of the class to inspect.

    print_r(get_class_methods('GedcomRecord'));

Note that I passed 'GedcomRecord' instead of 'Person' because that's what
PHP says you have in the error message. You're trying to call
GedcomRecord::getChildFamilies(). If Person::getInstance() returned a
Person instance, the error message would read

    Fatal error: Call to undefined method Person::getChildFamilies()

For example:

    $ php --version
    PHP 5.6.5-1+deb.sury.org~trusty+1 (cli) (built: Jan 26 2015 11:42:37)

    php > class Record { function foo() { echo "Hi!\n"; } }
    php > class Person extends Record { function bar() { echo "Bye!\n"; } }
    php > $p = new Person;
    php > $p->foo();
    Hi!
    php > $p->bar();
    Bye!
    php > $p->baz();
    PHP Fatal error:  Call to undefined method Person::baz() in php shell
code on line 1

You need to figure out why Person::getInstance() is returning a base
GedcomRecord instance instead of a Person instance.

David

[1] http://php.net/manual/en/function.get-class-methods.php