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 ApiPageSet 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 ApiPageSet, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 41 | class ApiPageSet extends ApiBase { |
||
| 42 | /** |
||
| 43 | * Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter |
||
| 44 | * @since 1.21 |
||
| 45 | */ |
||
| 46 | const DISABLE_GENERATORS = 1; |
||
| 47 | |||
| 48 | private $mDbSource; |
||
| 49 | private $mParams; |
||
| 50 | private $mResolveRedirects; |
||
| 51 | private $mConvertTitles; |
||
| 52 | private $mAllowGenerator; |
||
| 53 | |||
| 54 | private $mAllPages = []; // [ns][dbkey] => page_id or negative when missing |
||
| 55 | private $mTitles = []; |
||
| 56 | private $mGoodAndMissingPages = []; // [ns][dbkey] => page_id or negative when missing |
||
| 57 | private $mGoodPages = []; // [ns][dbkey] => page_id |
||
| 58 | private $mGoodTitles = []; |
||
| 59 | private $mMissingPages = []; // [ns][dbkey] => fake page_id |
||
| 60 | private $mMissingTitles = []; |
||
| 61 | /** @var array [fake_page_id] => array( 'title' => $title, 'invalidreason' => $reason ) */ |
||
| 62 | private $mInvalidTitles = []; |
||
| 63 | private $mMissingPageIDs = []; |
||
| 64 | private $mRedirectTitles = []; |
||
| 65 | private $mSpecialTitles = []; |
||
| 66 | private $mNormalizedTitles = []; |
||
| 67 | private $mInterwikiTitles = []; |
||
| 68 | /** @var Title[] */ |
||
| 69 | private $mPendingRedirectIDs = []; |
||
| 70 | private $mResolvedRedirectTitles = []; |
||
| 71 | private $mConvertedTitles = []; |
||
| 72 | private $mGoodRevIDs = []; |
||
| 73 | private $mLiveRevIDs = []; |
||
| 74 | private $mDeletedRevIDs = []; |
||
| 75 | private $mMissingRevIDs = []; |
||
| 76 | private $mGeneratorData = []; // [ns][dbkey] => data array |
||
| 77 | private $mFakePageId = -1; |
||
| 78 | private $mCacheMode = 'public'; |
||
| 79 | private $mRequestedPageFields = []; |
||
| 80 | /** @var int */ |
||
| 81 | private $mDefaultNamespace = NS_MAIN; |
||
| 82 | /** @var callable|null */ |
||
| 83 | private $mRedirectMergePolicy; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Add all items from $values into the result |
||
| 87 | * @param array $result Output |
||
| 88 | * @param array $values Values to add |
||
| 89 | * @param string $flag The name of the boolean flag to mark this element |
||
| 90 | * @param string $name If given, name of the value |
||
| 91 | */ |
||
| 92 | View Code Duplication | private static function addValues( array &$result, $values, $flag = null, $name = null ) { |
|
| 108 | |||
| 109 | /** |
||
| 110 | * @param ApiBase $dbSource Module implementing getDB(). |
||
| 111 | * Allows PageSet to reuse existing db connection from the shared state like ApiQuery. |
||
| 112 | * @param int $flags Zero or more flags like DISABLE_GENERATORS |
||
| 113 | * @param int $defaultNamespace The namespace to use if none is specified by a prefix. |
||
| 114 | * @since 1.21 accepts $flags instead of two boolean values |
||
| 115 | */ |
||
| 116 | public function __construct( ApiBase $dbSource, $flags = 0, $defaultNamespace = NS_MAIN ) { |
||
| 126 | |||
| 127 | /** |
||
| 128 | * In case execute() is not called, call this method to mark all relevant parameters as used |
||
| 129 | * This prevents unused parameters from being reported as warnings |
||
| 130 | */ |
||
| 131 | public function executeDryRun() { |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Populate the PageSet from the request parameters. |
||
| 137 | */ |
||
| 138 | public function execute() { |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Populate the PageSet from the request parameters. |
||
| 144 | * @param bool $isDryRun If true, instantiates generator, but only to mark |
||
| 145 | * relevant parameters as used |
||
| 146 | */ |
||
| 147 | private function executeInternal( $isDryRun ) { |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Check whether this PageSet is resolving redirects |
||
| 235 | * @return bool |
||
| 236 | */ |
||
| 237 | public function isResolvingRedirects() { |
||
| 240 | |||
| 241 | /** |
||
| 242 | * Return the parameter name that is the source of data for this PageSet |
||
| 243 | * |
||
| 244 | * If multiple source parameters are specified (e.g. titles and pageids), |
||
| 245 | * one will be named arbitrarily. |
||
| 246 | * |
||
| 247 | * @return string|null |
||
| 248 | */ |
||
| 249 | public function getDataSource() { |
||
| 265 | |||
| 266 | /** |
||
| 267 | * Request an additional field from the page table. |
||
| 268 | * Must be called before execute() |
||
| 269 | * @param string $fieldName Field name |
||
| 270 | */ |
||
| 271 | public function requestField( $fieldName ) { |
||
| 274 | |||
| 275 | /** |
||
| 276 | * Get the value of a custom field previously requested through |
||
| 277 | * requestField() |
||
| 278 | * @param string $fieldName Field name |
||
| 279 | * @return mixed Field value |
||
| 280 | */ |
||
| 281 | public function getCustomField( $fieldName ) { |
||
| 284 | |||
| 285 | /** |
||
| 286 | * Get the fields that have to be queried from the page table: |
||
| 287 | * the ones requested through requestField() and a few basic ones |
||
| 288 | * we always need |
||
| 289 | * @return array Array of field names |
||
| 290 | */ |
||
| 291 | public function getPageTableFields() { |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Returns an array [ns][dbkey] => page_id for all requested titles. |
||
| 322 | * page_id is a unique negative number in case title was not found. |
||
| 323 | * Invalid titles will also have negative page IDs and will be in namespace 0 |
||
| 324 | * @return array |
||
| 325 | */ |
||
| 326 | public function getAllTitlesByNamespace() { |
||
| 329 | |||
| 330 | /** |
||
| 331 | * All Title objects provided. |
||
| 332 | * @return Title[] |
||
| 333 | */ |
||
| 334 | public function getTitles() { |
||
| 337 | |||
| 338 | /** |
||
| 339 | * Returns the number of unique pages (not revisions) in the set. |
||
| 340 | * @return int |
||
| 341 | */ |
||
| 342 | public function getTitleCount() { |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Returns an array [ns][dbkey] => page_id for all good titles. |
||
| 348 | * @return array |
||
| 349 | */ |
||
| 350 | public function getGoodTitlesByNamespace() { |
||
| 353 | |||
| 354 | /** |
||
| 355 | * Title objects that were found in the database. |
||
| 356 | * @return Title[] Array page_id (int) => Title (obj) |
||
| 357 | */ |
||
| 358 | public function getGoodTitles() { |
||
| 361 | |||
| 362 | /** |
||
| 363 | * Returns the number of found unique pages (not revisions) in the set. |
||
| 364 | * @return int |
||
| 365 | */ |
||
| 366 | public function getGoodTitleCount() { |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Returns an array [ns][dbkey] => fake_page_id for all missing titles. |
||
| 372 | * fake_page_id is a unique negative number. |
||
| 373 | * @return array |
||
| 374 | */ |
||
| 375 | public function getMissingTitlesByNamespace() { |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Title objects that were NOT found in the database. |
||
| 381 | * The array's index will be negative for each item |
||
| 382 | * @return Title[] |
||
| 383 | */ |
||
| 384 | public function getMissingTitles() { |
||
| 387 | |||
| 388 | /** |
||
| 389 | * Returns an array [ns][dbkey] => page_id for all good and missing titles. |
||
| 390 | * @return array |
||
| 391 | */ |
||
| 392 | public function getGoodAndMissingTitlesByNamespace() { |
||
| 395 | |||
| 396 | /** |
||
| 397 | * Title objects for good and missing titles. |
||
| 398 | * @return array |
||
| 399 | */ |
||
| 400 | public function getGoodAndMissingTitles() { |
||
| 403 | |||
| 404 | /** |
||
| 405 | * Titles that were deemed invalid by Title::newFromText() |
||
| 406 | * The array's index will be unique and negative for each item |
||
| 407 | * @deprecated since 1.26, use self::getInvalidTitlesAndReasons() |
||
| 408 | * @return string[] Array of strings (not Title objects) |
||
| 409 | */ |
||
| 410 | public function getInvalidTitles() { |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Titles that were deemed invalid by Title::newFromText() |
||
| 419 | * The array's index will be unique and negative for each item |
||
| 420 | * @return array[] Array of arrays with 'title' and 'invalidreason' properties |
||
| 421 | */ |
||
| 422 | public function getInvalidTitlesAndReasons() { |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Page IDs that were not found in the database |
||
| 428 | * @return array Array of page IDs |
||
| 429 | */ |
||
| 430 | public function getMissingPageIDs() { |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Get a list of redirect resolutions - maps a title to its redirect |
||
| 436 | * target, as an array of output-ready arrays |
||
| 437 | * @return Title[] |
||
| 438 | */ |
||
| 439 | public function getRedirectTitles() { |
||
| 442 | |||
| 443 | /** |
||
| 444 | * Get a list of redirect resolutions - maps a title to its redirect |
||
| 445 | * target. Includes generator data for redirect source when available. |
||
| 446 | * @param ApiResult $result |
||
| 447 | * @return array Array of prefixed_title (string) => Title object |
||
| 448 | * @since 1.21 |
||
| 449 | */ |
||
| 450 | public function getRedirectTitlesAsResult( $result = null ) { |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Get a list of title normalizations - maps a title to its normalized |
||
| 483 | * version. |
||
| 484 | * @return array Array of raw_prefixed_title (string) => prefixed_title (string) |
||
| 485 | */ |
||
| 486 | public function getNormalizedTitles() { |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Get a list of title normalizations - maps a title to its normalized |
||
| 492 | * version in the form of result array. |
||
| 493 | * @param ApiResult $result |
||
| 494 | * @return array Array of raw_prefixed_title (string) => prefixed_title (string) |
||
| 495 | * @since 1.21 |
||
| 496 | */ |
||
| 497 | View Code Duplication | public function getNormalizedTitlesAsResult( $result = null ) { |
|
| 511 | |||
| 512 | /** |
||
| 513 | * Get a list of title conversions - maps a title to its converted |
||
| 514 | * version. |
||
| 515 | * @return array Array of raw_prefixed_title (string) => prefixed_title (string) |
||
| 516 | */ |
||
| 517 | public function getConvertedTitles() { |
||
| 520 | |||
| 521 | /** |
||
| 522 | * Get a list of title conversions - maps a title to its converted |
||
| 523 | * version as a result array. |
||
| 524 | * @param ApiResult $result |
||
| 525 | * @return array Array of (from, to) strings |
||
| 526 | * @since 1.21 |
||
| 527 | */ |
||
| 528 | View Code Duplication | public function getConvertedTitlesAsResult( $result = null ) { |
|
| 542 | |||
| 543 | /** |
||
| 544 | * Get a list of interwiki titles - maps a title to its interwiki |
||
| 545 | * prefix. |
||
| 546 | * @return array Array of raw_prefixed_title (string) => interwiki_prefix (string) |
||
| 547 | */ |
||
| 548 | public function getInterwikiTitles() { |
||
| 551 | |||
| 552 | /** |
||
| 553 | * Get a list of interwiki titles - maps a title to its interwiki |
||
| 554 | * prefix as result. |
||
| 555 | * @param ApiResult $result |
||
| 556 | * @param bool $iwUrl |
||
| 557 | * @return array Array of raw_prefixed_title (string) => interwiki_prefix (string) |
||
| 558 | * @since 1.21 |
||
| 559 | */ |
||
| 560 | public function getInterwikiTitlesAsResult( $result = null, $iwUrl = false ) { |
||
| 579 | |||
| 580 | /** |
||
| 581 | * Get an array of invalid/special/missing titles. |
||
| 582 | * |
||
| 583 | * @param array $invalidChecks List of types of invalid titles to include. |
||
| 584 | * Recognized values are: |
||
| 585 | * - invalidTitles: Titles and reasons from $this->getInvalidTitlesAndReasons() |
||
| 586 | * - special: Titles from $this->getSpecialTitles() |
||
| 587 | * - missingIds: ids from $this->getMissingPageIDs() |
||
| 588 | * - missingRevIds: ids from $this->getMissingRevisionIDs() |
||
| 589 | * - missingTitles: Titles from $this->getMissingTitles() |
||
| 590 | * - interwikiTitles: Titles from $this->getInterwikiTitlesAsResult() |
||
| 591 | * @return array Array suitable for inclusion in the response |
||
| 592 | * @since 1.23 |
||
| 593 | */ |
||
| 594 | public function getInvalidTitlesAndRevisions( $invalidChecks = [ 'invalidTitles', |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Get the list of valid revision IDs (requested with the revids= parameter) |
||
| 622 | * @return array Array of revID (int) => pageID (int) |
||
| 623 | */ |
||
| 624 | public function getRevisionIDs() { |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Get the list of non-deleted revision IDs (requested with the revids= parameter) |
||
| 630 | * @return array Array of revID (int) => pageID (int) |
||
| 631 | */ |
||
| 632 | public function getLiveRevisionIDs() { |
||
| 635 | |||
| 636 | /** |
||
| 637 | * Get the list of revision IDs that were associated with deleted titles. |
||
| 638 | * @return array Array of revID (int) => pageID (int) |
||
| 639 | */ |
||
| 640 | public function getDeletedRevisionIDs() { |
||
| 643 | |||
| 644 | /** |
||
| 645 | * Revision IDs that were not found in the database |
||
| 646 | * @return array Array of revision IDs |
||
| 647 | */ |
||
| 648 | public function getMissingRevisionIDs() { |
||
| 651 | |||
| 652 | /** |
||
| 653 | * Revision IDs that were not found in the database as result array. |
||
| 654 | * @param ApiResult $result |
||
| 655 | * @return array Array of revision IDs |
||
| 656 | * @since 1.21 |
||
| 657 | */ |
||
| 658 | public function getMissingRevisionIDsAsResult( $result = null ) { |
||
| 671 | |||
| 672 | /** |
||
| 673 | * Get the list of titles with negative namespace |
||
| 674 | * @return Title[] |
||
| 675 | */ |
||
| 676 | public function getSpecialTitles() { |
||
| 679 | |||
| 680 | /** |
||
| 681 | * Returns the number of revisions (requested with revids= parameter). |
||
| 682 | * @return int Number of revisions. |
||
| 683 | */ |
||
| 684 | public function getRevisionCount() { |
||
| 687 | |||
| 688 | /** |
||
| 689 | * Populate this PageSet from a list of Titles |
||
| 690 | * @param array $titles Array of Title objects |
||
| 691 | */ |
||
| 692 | public function populateFromTitles( $titles ) { |
||
| 695 | |||
| 696 | /** |
||
| 697 | * Populate this PageSet from a list of page IDs |
||
| 698 | * @param array $pageIDs Array of page IDs |
||
| 699 | */ |
||
| 700 | public function populateFromPageIDs( $pageIDs ) { |
||
| 703 | |||
| 704 | /** |
||
| 705 | * Populate this PageSet from a rowset returned from the database |
||
| 706 | * |
||
| 707 | * Note that the query result must include the columns returned by |
||
| 708 | * $this->getPageTableFields(). |
||
| 709 | * |
||
| 710 | * @param IDatabase $db |
||
| 711 | * @param ResultWrapper $queryResult Query result object |
||
| 712 | */ |
||
| 713 | public function populateFromQueryResult( $db, $queryResult ) { |
||
| 716 | |||
| 717 | /** |
||
| 718 | * Populate this PageSet from a list of revision IDs |
||
| 719 | * @param array $revIDs Array of revision IDs |
||
| 720 | */ |
||
| 721 | public function populateFromRevisionIDs( $revIDs ) { |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Extract all requested fields from the row received from the database |
||
| 727 | * @param stdClass $row Result row |
||
| 728 | */ |
||
| 729 | public function processDbRow( $row ) { |
||
| 749 | |||
| 750 | /** |
||
| 751 | * This method populates internal variables with page information |
||
| 752 | * based on the given array of title strings. |
||
| 753 | * |
||
| 754 | * Steps: |
||
| 755 | * #1 For each title, get data from `page` table |
||
| 756 | * #2 If page was not found in the DB, store it as missing |
||
| 757 | * |
||
| 758 | * Additionally, when resolving redirects: |
||
| 759 | * #3 If no more redirects left, stop. |
||
| 760 | * #4 For each redirect, get its target from the `redirect` table. |
||
| 761 | * #5 Substitute the original LinkBatch object with the new list |
||
| 762 | * #6 Repeat from step #1 |
||
| 763 | * |
||
| 764 | * @param array $titles Array of Title objects or strings |
||
| 765 | */ |
||
| 766 | private function initFromTitles( $titles ) { |
||
| 786 | |||
| 787 | /** |
||
| 788 | * Does the same as initFromTitles(), but is based on page IDs instead |
||
| 789 | * @param array $pageids Array of page IDs |
||
| 790 | */ |
||
| 791 | private function initFromPageIds( $pageids ) { |
||
| 818 | |||
| 819 | /** |
||
| 820 | * Iterate through the result of the query on 'page' table, |
||
| 821 | * and for each row create and store title object and save any extra fields requested. |
||
| 822 | * @param ResultWrapper $res DB Query result |
||
| 823 | * @param array $remaining Array of either pageID or ns/title elements (optional). |
||
| 824 | * If given, any missing items will go to $mMissingPageIDs and $mMissingTitles |
||
| 825 | * @param bool $processTitles Must be provided together with $remaining. |
||
| 826 | * If true, treat $remaining as an array of [ns][title] |
||
| 827 | * If false, treat it as an array of [pageIDs] |
||
| 828 | */ |
||
| 829 | private function initFromQueryResult( $res, &$remaining = null, $processTitles = null ) { |
||
| 892 | |||
| 893 | /** |
||
| 894 | * Does the same as initFromTitles(), but is based on revision IDs |
||
| 895 | * instead |
||
| 896 | * @param array $revids Array of revision IDs |
||
| 897 | */ |
||
| 898 | private function initFromRevIDs( $revids ) { |
||
| 975 | |||
| 976 | /** |
||
| 977 | * Resolve any redirects in the result if redirect resolution was |
||
| 978 | * requested. This function is called repeatedly until all redirects |
||
| 979 | * have been resolved. |
||
| 980 | */ |
||
| 981 | private function resolvePendingRedirects() { |
||
| 1010 | |||
| 1011 | /** |
||
| 1012 | * Get the targets of the pending redirects from the database |
||
| 1013 | * |
||
| 1014 | * Also creates entries in the redirect table for redirects that don't |
||
| 1015 | * have one. |
||
| 1016 | * @return LinkBatch |
||
| 1017 | */ |
||
| 1018 | private function getRedirectTargets() { |
||
| 1072 | |||
| 1073 | /** |
||
| 1074 | * Get the cache mode for the data generated by this module. |
||
| 1075 | * All PageSet users should take into account whether this returns a more-restrictive |
||
| 1076 | * cache mode than the using module itself. For possible return values and other |
||
| 1077 | * details about cache modes, see ApiMain::setCacheMode() |
||
| 1078 | * |
||
| 1079 | * Public caching will only be allowed if *all* the modules that supply |
||
| 1080 | * data for a given request return a cache mode of public. |
||
| 1081 | * |
||
| 1082 | * @param array|null $params |
||
| 1083 | * @return string |
||
| 1084 | * @since 1.21 |
||
| 1085 | */ |
||
| 1086 | public function getCacheMode( $params = null ) { |
||
| 1089 | |||
| 1090 | /** |
||
| 1091 | * Given an array of title strings, convert them into Title objects. |
||
| 1092 | * Alternatively, an array of Title objects may be given. |
||
| 1093 | * This method validates access rights for the title, |
||
| 1094 | * and appends normalization values to the output. |
||
| 1095 | * |
||
| 1096 | * @param array $titles Array of Title objects or strings |
||
| 1097 | * @return LinkBatch |
||
| 1098 | */ |
||
| 1099 | private function processTitlesArray( $titles ) { |
||
| 1176 | |||
| 1177 | /** |
||
| 1178 | * Set data for a title. |
||
| 1179 | * |
||
| 1180 | * This data may be extracted into an ApiResult using |
||
| 1181 | * self::populateGeneratorData. This should generally be limited to |
||
| 1182 | * data that is likely to be particularly useful to end users rather than |
||
| 1183 | * just being a dump of everything returned in non-generator mode. |
||
| 1184 | * |
||
| 1185 | * Redirects here will *not* be followed, even if 'redirects' was |
||
| 1186 | * specified, since in the case of multiple redirects we can't know which |
||
| 1187 | * source's data to use on the target. |
||
| 1188 | * |
||
| 1189 | * @param Title $title |
||
| 1190 | * @param array $data |
||
| 1191 | */ |
||
| 1192 | public function setGeneratorData( Title $title, array $data ) { |
||
| 1197 | |||
| 1198 | /** |
||
| 1199 | * Controls how generator data about a redirect source is merged into |
||
| 1200 | * the generator data for the redirect target. When not set no data |
||
| 1201 | * is merged. Note that if multiple titles redirect to the same target |
||
| 1202 | * the order of operations is undefined. |
||
| 1203 | * |
||
| 1204 | * Example to include generated data from redirect in target, prefering |
||
| 1205 | * the data generated for the destination when there is a collision: |
||
| 1206 | * @code |
||
| 1207 | * $pageSet->setRedirectMergePolicy( function( array $current, array $new ) { |
||
| 1208 | * return $current + $new; |
||
| 1209 | * } ); |
||
| 1210 | * @endcode |
||
| 1211 | * |
||
| 1212 | * @param callable|null $callable Recieves two array arguments, first the |
||
| 1213 | * generator data for the redirect target and second the generator data |
||
| 1214 | * for the redirect source. Returns the resulting generator data to use |
||
| 1215 | * for the redirect target. |
||
| 1216 | */ |
||
| 1217 | public function setRedirectMergePolicy( $callable ) { |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * Populate the generator data for all titles in the result |
||
| 1223 | * |
||
| 1224 | * The page data may be inserted into an ApiResult object or into an |
||
| 1225 | * associative array. The $path parameter specifies the path within the |
||
| 1226 | * ApiResult or array to find the "pages" node. |
||
| 1227 | * |
||
| 1228 | * The "pages" node itself must be an associative array mapping the page ID |
||
| 1229 | * or fake page ID values returned by this pageset (see |
||
| 1230 | * self::getAllTitlesByNamespace() and self::getSpecialTitles()) to |
||
| 1231 | * associative arrays of page data. Each of those subarrays will have the |
||
| 1232 | * data from self::setGeneratorData() merged in. |
||
| 1233 | * |
||
| 1234 | * Data that was set by self::setGeneratorData() for pages not in the |
||
| 1235 | * "pages" node will be ignored. |
||
| 1236 | * |
||
| 1237 | * @param ApiResult|array &$result |
||
| 1238 | * @param array $path |
||
| 1239 | * @return bool Whether the data fit |
||
| 1240 | */ |
||
| 1241 | public function populateGeneratorData( &$result, array $path = [] ) { |
||
| 1326 | |||
| 1327 | /** |
||
| 1328 | * Get the database connection (read-only) |
||
| 1329 | * @return DatabaseBase |
||
| 1330 | */ |
||
| 1331 | protected function getDB() { |
||
| 1334 | |||
| 1335 | /** |
||
| 1336 | * Returns the input array of integers with all values < 0 removed |
||
| 1337 | * |
||
| 1338 | * @param array $array |
||
| 1339 | * @return array |
||
| 1340 | */ |
||
| 1341 | private static function getPositiveIntegers( $array ) { |
||
| 1353 | |||
| 1354 | public function getAllowedParams( $flags = 0 ) { |
||
| 1405 | |||
| 1406 | private static $generators = null; |
||
| 1407 | |||
| 1408 | /** |
||
| 1409 | * Get an array of all available generators |
||
| 1410 | * @return array |
||
| 1411 | */ |
||
| 1412 | private function getGenerators() { |
||
| 1434 | } |
||
| 1435 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: