? Failure

User tests: Successful: Unsuccessful:

avatar nibra
nibra
19 Oct 2014

Refactored JObject to transparently remove leading underscores from property names on access, if needed.

In PHP4, the visibility of all properties was public, so it was agreed on to signal private properties by prefixing its name with an underscore. Since PHP5 supports visibility scopes, this no longer is appropriate, and property names shall not start with an underscore.

In order to achieve that, requesting a non-existing underscored property on the refactored JObject will return the value of the corresponding property without the underscore.

JObject now has these features:
[x] Properties can be set in a bulk
[x] Properties can be set during construction
[x] Set properties returns false on unsuitable parameter
[x] Set properties returns true on array parameter
[x] Set properties returns true on object parameter
[x] Setting a single property returns the previous value
[x] A single property can be set directly
[x] By default, getProperties() returns only public properties
[x] With RETURN_ALL set, getProperties() also returns protected properties
[x] Even with RETURN_ALL set, getProperties() does not return static properties
[x] Even with RETURN_ALL set, getProperties() does not return private properties
[x] A non-existent property defaults to null
[x] A non-existent property defaults to the provided default value
[x] A defined value will not get overwritten by get()
[x] A property can be accessed directly
[x] A default can be defined for a property
[x] A defined value will not get overwritten by def()
[x] isset() works on JObject as on stdClass
[x] isset() works on JObject as on stdClass with multiple levels
[x] empty() works on JObject as on stdClass
[x] empty() works on JObject as on stdClass with multiple levels
[x] unset() of existing properties works on JObject as on stdClass
[x] unset() of non-existing properties works on JObject as on stdClass
[x] [deprecated] Errors can be set
[x] [deprecated] getError() returns the last error by default
[x] [deprecated] Errors can be retrieved by index
[x] [deprecated] Accessing an undefined error index returns 0
[x] [deprecated] Numerical errors can be retrieved unchanged
[x] [deprecated] Numerical errors can be retrieved as string
[x] [deprecated] Exceptions can be retrieved unchanged
[x] [deprecated] Exceptions can be retrieved as string
[x] [deprecated] Underscored properties are redirected correctly
[x] [deprecated] Not underscored properties are redirected correctly

as proved by the accompanied tests.

avatar nibra nibra - open - 19 Oct 2014
avatar jissues-bot jissues-bot - change - 19 Oct 2014
Labels Added: ?
avatar nibra
nibra - comment - 19 Oct 2014

Sorry, wrong branch

avatar nibra nibra - close - 19 Oct 2014
avatar nibra nibra - change - 19 Oct 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-10-19 15:18:15

Add a Comment

Login with GitHub to post a comment