[wp-trac] [WordPress Trac] #21601: Introduce WP_User::has_prop_val() magic method
WordPress Trac
wp-trac at lists.automattic.com
Thu Aug 16 00:59:08 UTC 2012
#21601: Introduce WP_User::has_prop_val() magic method
------------------------------------------------+--------------------------
Reporter: wpsmith | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
Component: Users | Review
Severity: normal | Version:
Keywords: has-patch 2nd-opinion dev-feedback | Resolution:
------------------------------------------------+--------------------------
Old description:
> When using WP_User::has_prop( $key ), I believe the expectation is that
> if the property has a value, it would return true. However, it is
> returning true if the key is set or if the key exists. So if one uses it
> like WP_User::has_prop( 'user_url' ), it returns true regardless, simply
> because that's a standard WordPress user field.
>
> So, keeping that functionality for checking even custom properties, I
> thought it may be beneficial to add a magic method for checking whether a
> property is set ( WP_User::has_prop( $key ) ) and has a value (
> WP_User::get( $key ) ).
>
> Thus, this ticket desires to add two methods: has_prop_val() & __hasval()
New description:
When using WP_User::has_prop( $key ), I believe the expectation is that if
the property has a value, it would return true. However, it is returning
true if the key is set or if the key exists. So if one uses it like
WP_User::has_prop( 'user_url' ), it returns true regardless, simply
because that's a standard WordPress user field.
So, keeping that functionality for checking even custom properties, I
thought it may be beneficial to add a magic method for checking whether a
property is set ( WP_User::has_prop( $key ) ) and has a value (
WP_User::get( $key ) ).
Thus, this ticket desires to add two methods: `has_prop_val()` &
`__hasval()`
--
Comment (by scribu):
Magic methods aren't something you can arbitrarily create. They're a
predefined set of special constructs in the PHP language. `__hasval()` is
not one of them: http://php.net/manual/en/language.oop5.magic.php
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21601#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list