0

Problem solved, its a bug, see https://github.com/docker-library/php/issues/133

What is really weird about this is that Im using this all the time in my framework, but suddenly it stops working for this particular example.

Before executing this part of logic, its used many times without a problem...no idea why this part does not work.

class DailyCompetitionWinnersFactory extends Factory
{
    public static $table = 'tf_dc_winners';
    public static $child_item_class_name = DailyCompetitionWinnersItem::class;
}
abstract class Factory extends coreClass
{
    static $factory_instance_counter = 0;
    static $child_item_class_name = null;
    static $table = null;

    protected $orig_handled_obj_array = null;
    protected $handled_obj_array = null;

    public static function Create()
    {
        return new static();
    }
}

Create new instance

DailyCompetitionWinnersFactory::Create()

I get instance of DailyCompetitionWinnersFactory, but it doesnt have any static properties that are defined.

enter image description here

Honza
  • 323
  • 3
  • 14
  • https://3v4l.org/ZlKHE - seems like it has all the static properties that are referenced in this code. What are you trying to reference that isn't defined? – iainn Mar 08 '20 at 14:58
  • Because this is what xdebug shows: https://imgur.com/0nB3EqM The object has no static properties, eg. $table – Honza Mar 08 '20 at 15:08
  • In your example, you are not using the object. If you dump the object, you will see its not there. var_dump($obj); – Honza Mar 08 '20 at 15:13
  • [Static properties don't show up in `var_dump`](https://3v4l.org/dQTFW). Like I say, what are you actually trying to do that doesn't work? Ignore the debug output, what *problem* are you having? – iainn Mar 08 '20 at 15:29
  • This is the problem: https://3v4l.org/PNS9S It works here, but in my case it returns null, because my object doesnt have 'child_item_class_name' property. – Honza Mar 08 '20 at 15:31
  • Ok, so...the problem is somewhere else. See https://3v4l.org/PDIPY The xdebug actually shows static variables inside the object, but as soon as I move one line further, it resets the object and removes all static variable. I guess it has something to do with the fact that I create instance of the object inside static method of the same class... – Honza Mar 08 '20 at 16:00
  • @iainn found the problem, its a bug lol. https://github.com/docker-library/php/issues/133. Finally the problem is not in me haha. – Honza Mar 13 '20 at 11:16

1 Answers1

0

Its a bug, see https://github.com/docker-library/php/issues/133


Writing more characters so I can post this answer.

Honza
  • 323
  • 3
  • 14