techfromsage / tripod-php

Object Graph Mapper for managing RDF data in Mongo
MIT License
29 stars 4 forks source link

PLT-72 MongoDB extension and library upgrade #143

Closed mrliptontea closed 1 year ago

mrliptontea commented 1 year ago
mrliptontea commented 1 year ago

Just so I can leave that somewhere - I wanted to also include PHP 7.4 but with current code it won't work.

I haven't looked further than that, but an issue I found while running unit tests is that Tripod\Mongo\Jobs\JobBase class, and classes inheriting from it, on numerous occasions are referencing $this->job and $this->args properties but they're never set anywhere and are not defined in the class.

The only way it kind of works in PHP 7.3 still is there seems to be some nuance around setting such properties as if they're arrays vs if they're just a string value. Better explained with code below:

# Works ('foo' is created as stdClass with 'bar' array)
php73 -r '$obj = new \stdClass(); $obj->foo->bar["baz"] = uniqid(); var_dump($obj);'
# Warning: Creating default object from empty value
php74 -r '$obj = new \stdClass(); $obj->foo->bar["baz"] = uniqid(); var_dump($obj);'

# BUT!

# Warning: Creating default object from empty value
php73 -r '$obj = new \stdClass(); $obj->foo->bar = uniqid(); var_dump($obj);'
# Warning: Creating default object from empty value
php74 -r '$obj = new \stdClass(); $obj->foo->bar = uniqid(); var_dump($obj);'

Granted, this produces only a warning, but whether that stops the app depends on how errors are handled within the app. PHPUnit fails on this, for example.