PHP class inheritance bug?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    #1

    PHP class inheritance bug?



    I can't explain it better than to show you my thread

    Environments: PHP 4.1.2 and 4.3.2

    Scenario:

    I have a script ../classes.inc.php which serves as a "JAR" file of PHP
    classes that pertain to the entire application at application-level
    scope. The script consists of about 25 different classes, of which
    any class that extends OptionsView fails and produces this error:

    Fatal error: Class fooview: Cannot inherit from undefined class
    optionsview in /classes/classes.inc.php in line 2836

    Here is code that consists of line 2836:

    [PHP]

    class AlbumOptionsVie w extends PaginationView { // THIS ONE IS JUST
    FINE!

    }

    class FooView extends OptionsView { // BOMBS THIS IS LINE 2836

    }

    class OptionsView extends PaginationView {

    }

    class BlahView extends OptionsView { // THIS ONE IS JUST FINE

    }

    class Blah2View extends PaginationView { // THIS ONE IS FINE TOO!

    }

    class PaginationView extends View {

    }
    [/PHP]


    However, if any class exists *physically placed after* OptionsView in
    the script, and it extends OptionsView, everything is ok.

    NOTE: This does not occur with any other class. If any class extends
    any other class in the same script, no matter where it's placed,
    everything is just fine.

    I went so far as to literally strip out all code from OptionsView - to
    no avail, same error.
  • Zurab Davitiani

    #2
    Re: PHP class inheritance bug?

    Phil Powell wrote:
    [color=blue]
    > class AlbumOptionsVie w extends PaginationView { // THIS ONE IS JUST
    > FINE!
    >
    > }
    >
    > class FooView extends OptionsView { // BOMBS THIS IS LINE 2836
    >
    > }
    >
    > class OptionsView extends PaginationView {
    >
    > }[/color]

    Define OptionsView *before* FooView.

    Comment

    Working...