ethanbeyer Posted May 4, 2017 Share Posted May 4, 2017 Why don't Processwire Objects have all their properties visible? Here's what I mean. Take this super stripped-down class for example: class MyClass { public $public = 'Public'; protected $protected = 'Protected'; private $private = 'Private'; } $obj = new MyClass(); dump($obj); die; Output: MyClass {#244 ▼ +public: "Public" #protected: "Protected" -private: "Private" } This is straight from PHP's manual on Property Visibility. Now, if I do this with two different Processwire Modules, this is what happens. $soc = new Socicons(); $other = new InputfieldSimpleMDE(); dump($soc, $other); die; Output: Socicons {#248} InputfieldSimpleMDE {#113 ▼ +data: array:20 [▼ "label" => "" "description" => "" "icon" => "" "notes" => "" "head" => "" "required" => 0 "requiredIf" => "" "collapsed" => 0 "showIf" => "" "columnWidth" => "" "skipLabel" => false "wrapClass" => "" "headerClass" => "" "contentClass" => "" "textFormat" => 4 "renderValueFlags" => 0 "requiredAttr" => 0 "initValue" => "" "stripTags" => false "showCount" => 0 ] } Now, Socicons is a module I am currently writing, and it has about a dozen public properties. In the first example, the dump of the $obj class included all of that class' properties - so why don't I see all of the properties encased within Socicons? Secondly, why are all the properties of the InputfieldSimpleMDE within a data array? I'm sure this is part of the way that Processwire is written or configured, but I am often scratching my head over this. So again, I am hoping that someone can answer this for me. Why don't Processwire Objects have all their properties visible? Thank you! Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 5, 2017 Share Posted May 5, 2017 Take a look at the __debugInfo() method. 4 Link to comment Share on other sites More sharing options...
abdus Posted May 5, 2017 Share Posted May 5, 2017 Also here's a relevant post from the blog on why it's implemented. https://processwire.com/blog/posts/processwire-core-updates-2.5.27/#php-5.6-and-debuginfo 5 Link to comment Share on other sites More sharing options...
ethanbeyer Posted May 8, 2017 Author Share Posted May 8, 2017 Thank you both, @LostKobrakai and @abdus ! Hugely revealing - and a good refresher on some Magic Methods! <3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now