Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 18 | class Social extends SEOstats |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * For backward compatibility |
||
| 22 | * @deprecated |
||
| 23 | */ |
||
| 24 | public static function getGoogleShares($url = false) { |
||
| 27 | /** |
||
| 28 | * Returns the total count of +1s for $url on Google+. |
||
| 29 | * |
||
| 30 | * @access public |
||
| 31 | * @param url string The URL to check. |
||
| 32 | * @return integer Returns the total count of Plus Ones for a URL. |
||
| 33 | */ |
||
| 34 | public static function getGooglePlusShares($url = false) |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Returns an array of interaction counts (shares, likes, comments, clicks) for $url on Facebook. |
||
| 46 | * |
||
| 47 | * @access public |
||
| 48 | * @link http://developers.facebook.com/docs/reference/fql/link_stat/ |
||
| 49 | * @param url string The URL to check. |
||
| 50 | * @return array Returns an array of total counts for 1. all Facebook interactions, |
||
| 51 | * 2. FB shares, 3. FB likes, 4. FB comments and 5. outgoing clicks for a URL. |
||
| 52 | */ |
||
| 53 | View Code Duplication | public static function getFacebookShares($url = false) |
|
| 64 | |||
| 65 | /** |
||
| 66 | * Returns the total count of mentions of $url on Twitter. |
||
| 67 | * |
||
| 68 | * @access public |
||
| 69 | * @param url string The URL to check. |
||
| 70 | * @return integer Returns the total count of Twitter mentions for a URL. |
||
| 71 | * @link https://dev.twitter.com/discussions/5653#comment-11514 |
||
| 72 | */ |
||
| 73 | View Code Duplication | public static function getTwitterShares($url = false) |
|
| 83 | |||
| 84 | /** |
||
| 85 | * Returns the total count of shares for $url via Delicious. |
||
| 86 | * |
||
| 87 | * @access public |
||
| 88 | * @param url string The URL to check. |
||
| 89 | * @return integer Returns the total count of URL shares. |
||
| 90 | */ |
||
| 91 | View Code Duplication | public static function getDeliciousShares($url = false) |
|
| 101 | |||
| 102 | /** |
||
| 103 | * Returns the Top10 tags for $url from Delicious. |
||
| 104 | * |
||
| 105 | * @access public |
||
| 106 | * @param url string The URL to check. |
||
| 107 | * @return array Returns the top ten delicious tags for a URL (if exist; else an empty array). |
||
| 108 | */ |
||
| 109 | public static function getDeliciousTopTags($url = false) |
||
| 125 | |||
| 126 | /** |
||
| 127 | * Returns the total count of shares for $url via Digg. |
||
| 128 | * |
||
| 129 | * @access public |
||
| 130 | * @param url string The URL to check. |
||
| 131 | * @return integer Returns the total count of URL shares. |
||
| 132 | */ |
||
| 133 | View Code Duplication | public static function getDiggShares($url = false) |
|
| 143 | |||
| 144 | /** |
||
| 145 | * Returns the total count of shares for $url via LinkedIn. |
||
| 146 | * |
||
| 147 | * @access public |
||
| 148 | * @param url string The URL to check. |
||
| 149 | * @return integer Returns the total count of URL shares. |
||
| 150 | */ |
||
| 151 | View Code Duplication | public static function getLinkedInShares($url = false) |
|
| 161 | |||
| 162 | /** |
||
| 163 | * Returns the total count of shares for $url via Pinterest. |
||
| 164 | * |
||
| 165 | * @access public |
||
| 166 | * @param url string The URL to check. |
||
| 167 | * @return integer Returns the total count of URL shares. |
||
| 168 | */ |
||
| 169 | View Code Duplication | public static function getPinterestShares($url = false) |
|
| 179 | |||
| 180 | /** |
||
| 181 | * Returns the total count of shares for $url via StumpleUpon. |
||
| 182 | * |
||
| 183 | * @access public |
||
| 184 | * @param url string The URL to check. |
||
| 185 | * @return integer Returns the total count of URL shares. |
||
| 186 | */ |
||
| 187 | public static function getStumbleUponShares($url = false) |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Returns the total count of shares for $url via VKontakte. |
||
| 201 | * |
||
| 202 | * @access public |
||
| 203 | * @param url string The URL to check. |
||
| 204 | * @return integer Returns the total count of URL shares. |
||
| 205 | */ |
||
| 206 | View Code Duplication | public static function getVKontakteShares($url = false) |
|
| 216 | |||
| 217 | /** |
||
| 218 | * Returns an array of interaction counts (shares, comments, clicks, reach) for host of $url on Xing. |
||
| 219 | * |
||
| 220 | * @access public |
||
| 221 | * @param url string The URL to check. |
||
| 222 | * @return array Returns URL shares, comments, clicks and 'reach'. |
||
| 223 | * @link https://blog.xing.com/2012/01/xing-share-button/ Return values explained (German) |
||
| 224 | */ |
||
| 225 | public static function getXingShares($url = false) |
||
| 244 | } |
||
| 245 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: