Up until recently this is how I created objects on the fly.
$someObj = json_decode("{}");
Then:
$someObj->someProperty = someValue;
But now I go with:
$someObj = (object)[];
Then like before:
$someObj->someProperty = someValue;
Of course if you already know the properties and values you can set them inside as has been mentioned:
$someObj = (object)['prop1' => 'value1','prop2' => 'value2'];
NB: I don't know which versions of PHP this works on so you would need to be mindful of that. But I think the first approach (which is also short if there are no properties to set at construction) should work for all versions that have json_encode/json_decode