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:
Complex classes like PhpQuery often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PhpQuery, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 41 | abstract class PhpQuery |
||
| 42 | { |
||
| 43 | /** |
||
| 44 | * XXX: Workaround for mbstring problems |
||
| 45 | * |
||
| 46 | * @var bool |
||
| 47 | */ |
||
| 48 | public static $mbstringSupport = true; |
||
| 49 | public static $debug = false; |
||
| 50 | public static $documents = array(); |
||
| 51 | public static $defaultDocumentID = null; |
||
| 52 | // public static $defaultDoctype = 'html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"'; |
||
| 53 | /** |
||
| 54 | * Applies only to HTML. |
||
| 55 | * |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | public static $defaultDoctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
||
| 59 | "http://www.w3.org/TR/html4/loose.dtd">'; |
||
| 60 | public static $defaultCharset = 'UTF-8'; |
||
| 61 | /** |
||
| 62 | * Static namespace for plugins. |
||
| 63 | * |
||
| 64 | * @var object |
||
| 65 | */ |
||
| 66 | public static $plugins = array(); |
||
| 67 | /** |
||
| 68 | * List of loaded plugins. |
||
| 69 | * |
||
| 70 | * @var array |
||
| 71 | */ |
||
| 72 | public static $pluginsLoaded = array(); |
||
| 73 | public static $pluginsMethods = array(); |
||
| 74 | public static $pluginsStaticMethods = array(); |
||
| 75 | public static $extendMethods = array(); |
||
| 76 | /** |
||
| 77 | * @TODO implement |
||
| 78 | */ |
||
| 79 | public static $extendStaticMethods = array(); |
||
| 80 | /** |
||
| 81 | * Hosts allowed for AJAX connections. |
||
| 82 | * Dot '.' means $_SERVER['HTTP_HOST'] (if any). |
||
| 83 | * |
||
| 84 | * @var array |
||
| 85 | */ |
||
| 86 | public static $ajaxAllowedHosts = array( |
||
| 87 | '.' |
||
| 88 | ); |
||
| 89 | /** |
||
| 90 | * AJAX settings. |
||
| 91 | * |
||
| 92 | * @var array |
||
| 93 | * XXX should it be static or not ? |
||
| 94 | */ |
||
| 95 | public static $ajaxSettings = array( |
||
| 96 | 'url' => '', |
||
| 97 | //TODO |
||
| 98 | 'global' => true, |
||
| 99 | 'type' => "GET", |
||
| 100 | 'timeout' => null, |
||
| 101 | 'contentType' => "application/x-www-form-urlencoded", |
||
| 102 | 'processData' => true, |
||
| 103 | // 'async' => true, |
||
| 104 | 'data' => null, |
||
| 105 | 'username' => null, |
||
| 106 | 'password' => null, |
||
| 107 | 'dataType' => null, |
||
| 108 | 'ifModified' => null, |
||
| 109 | 'accepts' => array( |
||
| 110 | 'xml' => "application/xml, text/xml", |
||
| 111 | 'html' => "text/html", |
||
| 112 | 'script' => "text/javascript, application/javascript", |
||
| 113 | 'json' => "application/json, text/javascript", |
||
| 114 | 'text' => "text/plain", |
||
| 115 | '_default' => "*/*" |
||
| 116 | ) |
||
| 117 | ); |
||
| 118 | public static $lastModified = null; |
||
| 119 | public static $active = 0; |
||
| 120 | public static $dumpCount = 0; |
||
| 121 | public static $enableCssShorthand = false; |
||
| 122 | |||
| 123 | public static function use_function($ns = '\\', $func = 'pq') |
||
| 137 | |||
| 138 | |||
| 139 | /** |
||
| 140 | * Multi-purpose function. |
||
| 141 | * Use pq() as shortcut. |
||
| 142 | * |
||
| 143 | * In below examples, $pq is any result of pq(); function. |
||
| 144 | * |
||
| 145 | * 1. Import markup into existing document (without any attaching): |
||
| 146 | * - Import into selected document: |
||
| 147 | * pq('<div/>') // DOESNT accept text nodes at beginning of input string ! |
||
| 148 | * - Import into document with ID from $pq->getDocumentID(): |
||
| 149 | * pq('<div/>', $pq->getDocumentID()) |
||
| 150 | * - Import into same document as \DOMNode belongs to: |
||
| 151 | * pq('<div/>', \DOMNode) |
||
| 152 | * - Import into document from PhpQuery object: |
||
| 153 | * pq('<div/>', $pq) |
||
| 154 | * |
||
| 155 | * 2. Run query: |
||
| 156 | * - Run query on last selected document: |
||
| 157 | * pq('div.myClass') |
||
| 158 | * - Run query on document with ID from $pq->getDocumentID(): |
||
| 159 | * pq('div.myClass', $pq->getDocumentID()) |
||
| 160 | * - Run query on same document as \DOMNode belongs to and use node(s)as root for query: |
||
| 161 | * pq('div.myClass', \DOMNode) |
||
| 162 | * - Run query on document from PhpQuery object |
||
| 163 | * and use object's stack as root node(s) for query: |
||
| 164 | * pq('div.myClass', $pq) |
||
| 165 | * |
||
| 166 | * @param string|\DOMNode|\DOMNodeList|array $arg1 HTML markup, CSS Selector, \DOMNode or array of \DOMNodes |
||
| 167 | * @param string|PhpQueryObject|\DOMNode $context DOM ID from $pq->getDocumentID(), PhpQuery object (determines also query root) or \DOMNode (determines also query root) |
||
| 168 | * |
||
| 169 | * @throws \Exception |
||
| 170 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery|QueryTemplatesPhpQuery|false |
||
| 171 | * PhpQuery object or false in case of error. |
||
| 172 | */ |
||
| 173 | public static function pq($arg1, $context = null) |
||
| 288 | |||
| 289 | /** |
||
| 290 | * Sets default document to $id. Document has to be loaded prior |
||
| 291 | * to using this method. |
||
| 292 | * $id can be retrived via getDocumentID() or getDocumentIDRef(). |
||
| 293 | * |
||
| 294 | * @param string $id |
||
| 295 | */ |
||
| 296 | public static function selectDocument($id) |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Returns document with id $id or last used as PhpQueryObject. |
||
| 305 | * $id can be retrived via getDocumentID() or getDocumentIDRef(). |
||
| 306 | * Chainable. |
||
| 307 | * |
||
| 308 | * @see PhpQuery::selectDocument() |
||
| 309 | * @param null $id |
||
| 310 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 311 | */ |
||
| 312 | public static function getDocument($id = null) |
||
| 320 | |||
| 321 | /** |
||
| 322 | * Creates new document from markup. |
||
| 323 | * Chainable. |
||
| 324 | * |
||
| 325 | * @param null $markup |
||
| 326 | * @param null $contentType |
||
| 327 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 328 | */ |
||
| 329 | public static function newDocument($markup = null, $contentType = null) |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Creates new document from markup. |
||
| 339 | * Chainable. |
||
| 340 | * |
||
| 341 | * @param null $markup |
||
| 342 | * @param null $charset |
||
| 343 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 344 | */ |
||
| 345 | public static function newDocumentHTML($markup = null, $charset = null) |
||
| 350 | |||
| 351 | /** |
||
| 352 | * Creates new document from markup. |
||
| 353 | * Chainable. |
||
| 354 | * |
||
| 355 | * @param null $markup |
||
| 356 | * @param null $charset |
||
| 357 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 358 | */ |
||
| 359 | public static function newDocumentXML($markup = null, $charset = null) |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Creates new document from markup. |
||
| 367 | * Chainable. |
||
| 368 | * |
||
| 369 | * @param null $markup |
||
| 370 | * @param null $charset |
||
| 371 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 372 | */ |
||
| 373 | public static function newDocumentXHTML($markup = null, $charset = null) |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Creates new document from markup. |
||
| 381 | * Chainable. |
||
| 382 | * |
||
| 383 | * @param null $markup |
||
| 384 | * @param string $contentType |
||
| 385 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 386 | */ |
||
| 387 | public static function newDocumentPHP($markup = null, $contentType = "text/html") |
||
| 393 | |||
| 394 | public static function phpToMarkup($php, $charset = 'utf-8') |
||
| 424 | |||
| 425 | public static function _phpToMarkupCallback($m, $charset = 'utf-8') |
||
| 435 | |||
| 436 | public static function _markupToPHPCallback($m) |
||
| 440 | |||
| 441 | /** |
||
| 442 | * Converts document markup containing PHP code generated by PhpQuery::php() |
||
| 443 | * into valid (executable) PHP code syntax. |
||
| 444 | * |
||
| 445 | * @param string|PhpQueryObject $content |
||
| 446 | * @return string PHP code. |
||
| 447 | */ |
||
| 448 | public static function markupToPHP($content) |
||
| 487 | |||
| 488 | /** |
||
| 489 | * Creates new document from file $file. |
||
| 490 | * Chainable. |
||
| 491 | * |
||
| 492 | * @param string $file URLs allowed. See File wrapper page at php.net for more supported sources. |
||
| 493 | * @param null $contentType |
||
| 494 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 495 | */ |
||
| 496 | public static function newDocumentFile($file, $contentType = null) |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Creates new document from markup. |
||
| 504 | * Chainable. |
||
| 505 | * |
||
| 506 | * @param $file |
||
| 507 | * @param null $charset |
||
| 508 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 509 | */ |
||
| 510 | public static function newDocumentFileHTML($file, $charset = null) |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Creates new document from markup. |
||
| 518 | * Chainable. |
||
| 519 | * |
||
| 520 | * @param $file |
||
| 521 | * @param null $charset |
||
| 522 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 523 | */ |
||
| 524 | public static function newDocumentFileXML($file, $charset = null) |
||
| 529 | |||
| 530 | /** |
||
| 531 | * Creates new document from markup. |
||
| 532 | * Chainable. |
||
| 533 | * |
||
| 534 | * @param $file |
||
| 535 | * @param null $charset |
||
| 536 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 537 | */ |
||
| 538 | public static function newDocumentFileXHTML($file, $charset = null) |
||
| 543 | |||
| 544 | /** |
||
| 545 | * Creates new document from markup. |
||
| 546 | * Chainable. |
||
| 547 | * |
||
| 548 | * @param $file |
||
| 549 | * @param null $contentType |
||
| 550 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 551 | */ |
||
| 552 | public static function newDocumentFilePHP($file, $contentType = null) |
||
| 556 | |||
| 557 | /** |
||
| 558 | * Reuses existing \DOMDocument object. |
||
| 559 | * Chainable. |
||
| 560 | * |
||
| 561 | * @param $document \DOMDocument |
||
| 562 | * @return PhpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery |
||
| 563 | * @TODO support \DOMDocument |
||
| 564 | */ |
||
| 565 | public static function loadDocument($document) |
||
| 570 | |||
| 571 | /** |
||
| 572 | * Enter description here... |
||
| 573 | * |
||
| 574 | * @param $html |
||
| 575 | * @param null $contentType |
||
| 576 | * @param null $documentID |
||
| 577 | * @return null|string |
||
| 578 | * @throws \Exception |
||
| 579 | * @todo support PHP tags in input |
||
| 580 | * @todo support passing \DOMDocument object from self::loadDocument |
||
| 581 | */ |
||
| 582 | protected static function createDocumentWrapper($html, $contentType = null, $documentID = null) |
||
| 608 | |||
| 609 | /** |
||
| 610 | * Extend class namespace. |
||
| 611 | * |
||
| 612 | * @param string|array $target |
||
| 613 | * @param array $source |
||
| 614 | * @throws \Exception |
||
| 615 | * @return bool |
||
| 616 | * @TODO support string $source |
||
| 617 | */ |
||
| 618 | public static function extend($target, $source) |
||
| 654 | |||
| 655 | /** |
||
| 656 | * Extend PhpQuery with $class from $file. |
||
| 657 | * |
||
| 658 | * @param string $class Extending class name. Real class name can be prepended PhpQuery_. |
||
| 659 | * @param string $file Filename to include. Defaults to "{$class}.php". |
||
| 660 | * @throws \Exception |
||
| 661 | * @return bool |
||
| 662 | */ |
||
| 663 | public static function plugin($class, $file = null) |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Unloades all or specified document from memory. |
||
| 739 | * |
||
| 740 | * @param null $id |
||
| 741 | * @internal param mixed $documentID @see PhpQuery::getDocumentID() for supported types. |
||
| 742 | */ |
||
| 743 | public static function unloadDocuments($id = null) |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Parses PhpQuery object or HTML result against PHP tags and makes them active. |
||
| 757 | * |
||
| 758 | * @param PhpQuery|string $content |
||
| 759 | * @deprecated |
||
| 760 | * @return string |
||
| 761 | */ |
||
| 762 | public static function unsafePHPTags($content) |
||
| 766 | |||
| 767 | public static function DOMNodeListToArray($DOMNodeList) |
||
| 776 | |||
| 777 | /** |
||
| 778 | * Checks if $input is HTML string, which has to start with '<'. |
||
| 779 | * |
||
| 780 | * @deprecated |
||
| 781 | * @param String $input |
||
| 782 | * @return Bool |
||
| 783 | * @todo still used ? |
||
| 784 | */ |
||
| 785 | public static function isMarkup($input) |
||
| 789 | |||
| 790 | public static function debug($text) |
||
| 795 | |||
| 796 | /** |
||
| 797 | * Make an AJAX request. |
||
| 798 | * |
||
| 799 | * @param array $options |
||
| 800 | * @param null $xhr |
||
| 801 | * @throws \Exception |
||
| 802 | * @internal param \PhpQuery\See $array $options http://docs.jquery.com/Ajax/jQuery.ajax#toptions |
||
| 803 | * Additional options are: |
||
| 804 | * 'document' - document for global events, @see PhpQuery::getDocumentID() |
||
| 805 | * 'referer' - implemented |
||
| 806 | * 'requested_with' - TODO; not implemented (X-Requested-With) |
||
| 807 | * @return \Zend_Http_Client |
||
| 808 | * @link http://docs.jquery.com/Ajax/jQuery.ajax |
||
| 809 | * |
||
| 810 | * @TODO $options['cache'] |
||
| 811 | * @TODO $options['processData'] |
||
| 812 | * @TODO $options['xhr'] |
||
| 813 | * @TODO $options['data'] as string |
||
| 814 | * @TODO XHR interface |
||
| 815 | */ |
||
| 816 | public static function ajax($options = array(), $xhr = null) |
||
| 1039 | |||
| 1040 | protected static function httpData($data, $type, $options) |
||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * Enter description here... |
||
| 1063 | * |
||
| 1064 | * @param array|PhpQuery $data |
||
| 1065 | * |
||
| 1066 | * @return string |
||
| 1067 | */ |
||
| 1068 | public static function param($data) |
||
| 1072 | |||
| 1073 | View Code Duplication | public static function get($url, $data = null, $callback = null, $type = null) |
|
| 1090 | |||
| 1091 | View Code Duplication | public static function post($url, $data = null, $callback = null, $type = null) |
|
| 1107 | |||
| 1108 | View Code Duplication | public static function getJSON($url, $data = null, $callback = null) |
|
| 1125 | |||
| 1126 | public static function ajaxSetup($options) |
||
| 1130 | |||
| 1131 | public static function ajaxAllowHost($host1, $host2 = null, $host3 = null) |
||
| 1140 | |||
| 1141 | public static function ajaxAllowURL($url1, $url2 = null, $url3 = null) |
||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * Returns JSON representation of $data. |
||
| 1150 | * |
||
| 1151 | * @static |
||
| 1152 | * @param mixed $data |
||
| 1153 | * @return string |
||
| 1154 | */ |
||
| 1155 | public static function toJSON($data) |
||
| 1162 | |||
| 1163 | /** |
||
| 1164 | * Parses JSON into proper PHP type. |
||
| 1165 | * |
||
| 1166 | * @static |
||
| 1167 | * @param string $json |
||
| 1168 | * @return mixed |
||
| 1169 | */ |
||
| 1170 | public static function parseJSON($json) |
||
| 1181 | |||
| 1182 | /** |
||
| 1183 | * Returns source's document ID. |
||
| 1184 | * |
||
| 1185 | * @param $source \DOMNode|PhpQueryObject |
||
| 1186 | * @return string |
||
| 1187 | */ |
||
| 1188 | public static function getDocumentID($source) |
||
| 1205 | |||
| 1206 | /** |
||
| 1207 | * Get \DOMDocument object related to $source. |
||
| 1208 | * Returns null if such document doesn't exist. |
||
| 1209 | * |
||
| 1210 | * @param $source \DOMNode|PhpQueryObject|string |
||
| 1211 | * @return string |
||
| 1212 | */ |
||
| 1213 | public static function getDOMDocument($source) |
||
| 1220 | |||
| 1221 | // UTILITIES |
||
| 1222 | // http://docs.jquery.com/Utilities |
||
| 1223 | |||
| 1224 | /** |
||
| 1225 | * |
||
| 1226 | * @link http://docs.jquery.com/Utilities/jQuery.makeArray |
||
| 1227 | * @param $object |
||
| 1228 | * @return array |
||
| 1229 | */ |
||
| 1230 | public static function makeArray($object) |
||
| 1245 | |||
| 1246 | public static function inArray($value, $array) |
||
| 1250 | |||
| 1251 | /** |
||
| 1252 | * |
||
| 1253 | * @param $object |
||
| 1254 | * @param $callback |
||
| 1255 | * @param null $param1 |
||
| 1256 | * @param null $param2 |
||
| 1257 | * @param null $param3 |
||
| 1258 | * @link http://docs.jquery.com/Utilities/jQuery.each |
||
| 1259 | */ |
||
| 1260 | public static function each($object, $callback, $param1 = null, $param2 = null, $param3 = null) |
||
| 1289 | |||
| 1290 | /** |
||
| 1291 | * |
||
| 1292 | * @link http://docs.jquery.com/Utilities/jQuery.map |
||
| 1293 | */ |
||
| 1294 | public static function map($array, $callback, $param1 = null, $param2 = null, $param3 = null) |
||
| 1326 | |||
| 1327 | /** |
||
| 1328 | * |
||
| 1329 | * @param $callback Callback |
||
| 1330 | * @param $params |
||
| 1331 | * @param $paramStructure |
||
| 1332 | * @return bool|mixed |
||
| 1333 | */ |
||
| 1334 | public static function callbackRun($callback, $params = array(), $paramStructure = null) |
||
| 1356 | |||
| 1357 | /** |
||
| 1358 | * Merge 2 PhpQuery objects. |
||
| 1359 | * @param array $one |
||
| 1360 | * @param array $two |
||
| 1361 | * @return array |
||
| 1362 | * @protected |
||
| 1363 | * @todo node lists, PhpQueryObject |
||
| 1364 | */ |
||
| 1365 | public static function merge($one, $two) |
||
| 1382 | |||
| 1383 | /** |
||
| 1384 | * |
||
| 1385 | * @param $array |
||
| 1386 | * @param $callback |
||
| 1387 | * @param $invert |
||
| 1388 | * @return array |
||
| 1389 | * @link http://docs.jquery.com/Utilities/jQuery.grep |
||
| 1390 | */ |
||
| 1391 | public static function grep($array, $callback, $invert = false) |
||
| 1407 | |||
| 1408 | public static function unique($array) |
||
| 1412 | |||
| 1413 | /** |
||
| 1414 | * |
||
| 1415 | * @param $function |
||
| 1416 | * @return bool |
||
| 1417 | * @TODO there are problems with non-static methods, second parameter pass it |
||
| 1418 | * but doesnt verify is method is really callable |
||
| 1419 | */ |
||
| 1420 | public static function isFunction($function) |
||
| 1424 | |||
| 1425 | public static function trim($str) |
||
| 1429 | /* PLUGINS NAMESPACE */ |
||
| 1430 | /** |
||
| 1431 | * |
||
| 1432 | * @param $url |
||
| 1433 | * @param $callback |
||
| 1434 | * @param $param1 |
||
| 1435 | * @param $param2 |
||
| 1436 | * @param $param3 |
||
| 1437 | * @return PhpQueryObject |
||
| 1438 | */ |
||
| 1439 | View Code Duplication | public static function browserGet($url, $callback, $param1 = null, $param2 = null, $param3 = null) |
|
| 1454 | |||
| 1455 | /** |
||
| 1456 | * |
||
| 1457 | * @param $url |
||
| 1458 | * @param $data |
||
| 1459 | * @param $callback |
||
| 1460 | * @param $param1 |
||
| 1461 | * @param $param2 |
||
| 1462 | * @param $param3 |
||
| 1463 | * @return PhpQueryObject |
||
| 1464 | */ |
||
| 1465 | View Code Duplication | public static function browserPost($url, $data, $callback, $param1 = null, $param2 = null, $param3 = null) |
|
| 1480 | |||
| 1481 | /** |
||
| 1482 | * |
||
| 1483 | * @param $ajaxSettings |
||
| 1484 | * @param $callback |
||
| 1485 | * @param $param1 |
||
| 1486 | * @param $param2 |
||
| 1487 | * @param $param3 |
||
| 1488 | * @return PhpQueryObject |
||
| 1489 | */ |
||
| 1490 | View Code Duplication | public static function browser($ajaxSettings, $callback, $param1 = null, $param2 = null, $param3 = null) |
|
| 1505 | |||
| 1506 | /** |
||
| 1507 | * |
||
| 1508 | * @param $code |
||
| 1509 | * @return string |
||
| 1510 | */ |
||
| 1511 | public static function php($code) |
||
| 1515 | |||
| 1516 | /** |
||
| 1517 | * |
||
| 1518 | * @param $type |
||
| 1519 | * @param $code |
||
| 1520 | * @return string |
||
| 1521 | */ |
||
| 1522 | public static function code($type, $code) |
||
| 1526 | |||
| 1527 | public static function __callStatic($method, $params) |
||
| 1537 | |||
| 1538 | protected static function dataSetupNode($node, $documentID) |
||
| 1549 | |||
| 1550 | protected static function dataRemoveNode($node, $documentID) |
||
| 1560 | |||
| 1561 | public static function data($node, $name, $data, $documentID = null) |
||
| 1581 | |||
| 1582 | public static function removeData($node, $name, $documentID) |
||
| 1602 | } |
||
| 1603 | |||
| 1633 | PhpQuery::$plugins = new PhpQueryPlugins(); |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.