-
Notifications
You must be signed in to change notification settings - Fork 248
BugFix in DataObject::__construct() #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were going to call $this->populate($data)
only if $data['subdir']
is not set, or have I misunderstood?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because pseudo-directory structures only contain two attributes. Both of which are populated using the methods above. For normal objects, you need to call populate so that the entire object is correctly stocked.
@claudio-dalicandro Could you outline what the bug is and how your code fixes it? |
|
Ok, I've seen, you can not know what is $date... It could be an object or an array... |
@claudio-dalicandro To answer your points:
class Person
{
private $name;
private $age;
} although there are no concrete methods for accessing/mutating these properties, this will work: $person = new Person();
$person->setName('Jamie');
echo $person->getName(); // Jamie
echo $person->getAge(); // NULL
echo $person->getHeight(); // throws RuntimeException "no method" Concrete setter/getters are only used for specific pieces of business logic. |
My PHP version: $ php -v
PHP 5.4.17-1~precise+1 (cli) (built: Jul 17 2013 18:14:06) Test <?php
// test.php
class test {
private $a;
private $b;
}
$test = new test();
$test->setA('testing');
echo $test->getA(); error... $ php test.php
PHP Fatal error: Call to undefined method test::setA() in ./test.php on line 8
PHP Stack trace:
PHP 1. {main}() ./test.php:0 |
@claudio-dalicandro Sorry, you're right. This functionality only happens when the visibility of a property is |
@jamiehannaford I'm sorry, but I think it does not work right: AFAIK overloading works if implements magic methods
Surely I could be wrong, I never use the overload because
|
@claudio-dalicandro I'm not sure I understand your two points... Please see my response to #215. I'm not familiar with Juozas Kaziukėnas's blog entry where he warns about method overloading, but I'm always somewhat skeptical when people make generalized statements like "doing x is bad". There are almost always certain use cases where implementing a particular language feature is useful. Method overloading is one of them, at least for the current state of the SDK. I'd love to have concrete methods for every resource model, but we're not there yet. It's a gradual compromise between understanding what you want, what's realistically possible for the next release, and what you need to do to make things as backwards possible as possible. |
@claudio-dalicandro Methods have been added to |
BugFix in \OpenCloud\ObjectStore\Resource\DataObject::__construct()