访问PHP保护的属性

Hi there I have a class : AbstractEntityType with a protected property :

abstract class AbstractEntityType extends AbstractType {
  protected static $lists = null;

  public function __construct($lists = array()) {
    AbstractEntityType::$lists = $lists;
  }

  public function configureOptions(OptionsResolver $resolver) {
    $resolver->setRequired(array(
        'temp', 'statut'
    ));
  }
}

Here is another class extending the previous one :

class MyType extends AbstractEntityType {
   ....
}

I use a factory to create MyType class:

class SimpleFormTypeFactory {
  public function createType($entity_type, $entity_stub, $lists = null) {
      $type = null;

      switch($entity_type) {
           ....
           case SOMENUMTYP:
            $type = new MyType($lists);
            break;
      }
  }

I tested it locally with php 5.4 and windows with no problem but on the server (linux and php 5.3) I have this error :

Error: Cannot access protected property MyType::$lists

What is going on ? a php bug ?

Thank you

The property is protected, so you can never do this:

public function __construct($lists = array()) {
    AbstractEntityType::$lists = $lists;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^ Not allowed for a protected property, regardless where you are
}

However, when you are inside your class, you can access it directly:

public function __construct($lists = array()) {
    self::$lists = $lists;
}