|
81 | 81 | ], |
82 | 82 | ], |
83 | 83 | 'Collection' => [ |
84 | | - // _extract can't be easily renamed to extract as it conflicts with the CollectionTrait::extract() method |
85 | 84 | 'Cake\Collection\ExtractTrait' => [ |
86 | 85 | '_propertyExtractor', '_simpleExtract', '_createMatcherFilter', |
87 | 86 | ], |
|
109 | 108 | 'Console' => [ |
110 | 109 | 'Cake\Console\HelpFormatter' => ['_generateUsage', '_getMaxLength'], |
111 | 110 | 'Cake\Console\ConsoleIo' => ['_getInput'], |
112 | | - // _write can't be renamed to write as it conflicts with the ConsoleOutput::write() method |
113 | 111 | 'Cake\Console\ConsoleOutput' => ['_replaceTags'], |
114 | 112 | 'Cake\Console\ConsoleOptionParser' => [ |
115 | 113 | '_parseLongOption', '_parseShortOption', '_parseOption', '_optionExists', '_parseArg', '_nextToken', |
|
244 | 242 | ], |
245 | 243 |
|
246 | 244 | 'Form' => [ |
247 | | - // Can't rename _execute as it conflicts with the Form::execute() method |
248 | 245 | 'Cake\Form\Form' => ['_buildSchema'], |
249 | 246 | 'Cake\Form\Schema' => ['_addField'], |
250 | 247 | ], |
251 | 248 |
|
252 | 249 | 'Http' => [ |
253 | 250 | 'Cake\Http\CorsBuilder' => ['_normalizeDomains'], |
254 | 251 | 'Cake\Http\Session' => ['_defaultConfig', '_overwrite', '_hasSession', '_timedOut'], |
255 | | - // Can't rename _sendRequest as it conflicts with the Client::sendRequest() method |
256 | 252 | 'Cake\Http\Client' => [ |
257 | 253 | '_doRequest', '_mergeOptions', '_createRequest', '_typeHeaders', |
258 | 254 | '_addAuthentication', '_addProxy', '_createAuth', |
259 | 255 | ], |
260 | 256 |
|
261 | | - // Can't rename _is as it conflicts with the ServerRequest::is() method |
262 | 257 | 'Cake\Http\ServerRequest' => [ |
263 | 258 | '_setConfig', '_acceptHeaderDetector', '_headerDetector', |
264 | 259 | '_paramDetector', '_environmentDetector', |
|
289 | 284 | '_encode', |
290 | 285 | ], |
291 | 286 |
|
292 | | - // Can't rename _send as it conflicts with the Stream::send() method |
293 | 287 | 'Cake\Http\Client\Adapter\Stream' => [ |
294 | 288 | '_buildContext', '_buildHeaders', '_buildContent', '_buildOptions', |
295 | 289 | '_buildSslContext', '_buildResponse', '_open', |
|
302 | 296 | ], |
303 | 297 |
|
304 | 298 | 'I18n' => [ |
305 | | - // Can't rename _parseDateTime as it conflicts with the DateTime::parseDateTime() method |
306 | 299 | 'Cake\I18n\DateFormatTrait' => ['_formatObject'], |
307 | 300 | 'Cake\I18n\Number' => ['_setAttributes'], |
308 | 301 | 'Cake\I18n\RelativeTimeFormatter' => ['_options', '_diffData'], |
|
319 | 312 | 'Mailer' => [ |
320 | 313 | 'Cake\Mailer\TransportFactory' => ['_buildTransport'], |
321 | 314 | 'Cake\Mailer\Transport\MailTransport' => ['_mail'], |
322 | | - // Can't rename _connect as it conflicts with the SmtpTransport::connect() method |
323 | | - // Can't rename _disconnect as it conflicts with the SmtpTransport::disconnect() method |
324 | 315 | 'Cake\Mailer\Transport\SmtpTransport' => [ |
325 | 316 | '_bufferResponseLines', '_parseAuthType', |
326 | 317 | '_auth', '_authPlain', '_authLogin', '_authXoauth2', |
|
349 | 340 | '_mergeJoinData', |
350 | 341 | ], |
351 | 342 | 'Cake\ORM\Table' => [ |
352 | | - // Can't rename _saveMany as it conflicts with the Table::saveMany() method |
353 | | - // Can't rename _deleteMany as it conflicts with the Table::deleteMany() method |
354 | 343 | '_setFieldMatchers', '_executeTransaction', '_transactionCommitted', |
355 | 344 | '_processFindOrCreate', '_getFindOrCreateQuery', '_processSave', |
356 | 345 | '_onSaveSuccess', '_insert', '_newId', '_update', '_processDelete', '_dynamicFinder', |
|
359 | 348 | // Behaviors |
360 | 349 | 'Cake\ORM\Behavior' => ['_resolveMethodAliases', '_reflectionCache'], |
361 | 350 | 'Cake\ORM\Behavior\TreeBehavior' => [ |
362 | | - // Can't rename _moveUp/_moveDown as it conflicts with the TreeBehavior::moveUp()/moveDown() methods |
363 | | - // Can't rename _removeFromTree as it conflicts with the TreeBehavior::removeFromTree() method |
364 | 351 | '_setChildrenLevel', '_setParent', '_setAsRoot', '_unmarkInternalTree', |
365 | 352 | '_getNode', '_recoverTree', '_getMax', '_sync', '_scope', '_ensureFields', '_getPrimaryKey', |
366 | 353 | ], |
|
376 | 363 | '_bindNewAssociations', '_joinCondition', '_extractFinder', |
377 | 364 | ], |
378 | 365 | 'Cake\ORM\Association\HasMany' => [ |
379 | | - // Can't rename _unlink as it conflicts with the HasMany::unlink() method |
380 | 366 | '_saveTarget', '_unlinkAssociated', '_foreignKeyAcceptsNull', |
381 | 367 | ], |
382 | 368 | 'Cake\ORM\Association\BelongsToMany' => [ |
|
400 | 386 |
|
401 | 387 | // Query |
402 | 388 | 'Cake\ORM\Query\SelectQuery' => [ |
403 | | - // Can't rename _decorateResults as it conflicts with the DB\SelectQuery::decorateResults() method |
404 | | - // Can't rename _execute as it conflicts with the DB\Query::execute() method |
405 | 389 | '_dirty', '_addAssociationsToTypeMap', |
406 | 390 | '_performCount', '_transformQuery', |
407 | 391 | '_addDefaultFields', '_addDefaultSelectTypes', |
|
448 | 432 | '_decrypt', '_decode', '_implode', '_explode', |
449 | 433 | ], |
450 | 434 | 'Cake\Utility\Hash' => [ |
451 | | - // Can't rename _filter as it conflicts with the Hash::filter() method |
452 | | - // Can't rename _merge as it conflicts with the Hash::merge() method |
453 | 435 | '_splitConditions', '_matchToken', '_matches', '_simpleOp', '_squash', |
454 | 436 | ], |
455 | | - // Can't rename _wordWrap as it conflicts with the Text::wordWrap() method |
456 | 437 | 'Cake\Utility\Text' => ['_strlen', '_substr', '_removeLastWord'], |
457 | | - // Can't rename _fromArray as it conflicts with the Xml::fromArray() method |
458 | | - // Can't rename _toArray as it conflicts with the Xml::toArray() method |
459 | 438 | 'Cake\Utility\Xml' => ['_loadXml', '_createChild'], |
460 | 439 | 'Cake\Utility\MergeVariablesTrait' => ['_mergeVars', '_mergeProperty', '_mergePropertyData'], |
461 | 440 | 'Cake\Utility\Inflector' => ['_cache'], |
|
472 | 451 |
|
473 | 452 | 'View' => [ |
474 | 453 | 'Cake\View\View' => [ |
475 | | - // Can't rename _render as it conflicts with the View::render() method |
476 | 454 | '_evaluate', '_getTemplateFileName', '_inflectTemplateFileName', |
477 | 455 | '_checkFilePath', '_getLayoutFileName', '_getElementFileName', '_getSubPaths', |
478 | 456 | '_paths', '_elementCache', '_renderElement', |
|
494 | 472 | ], |
495 | 473 | 'Cake\View\Helper\HtmlHelper' => ['_renderCells', '_nestedListItem'], |
496 | 474 | 'Cake\View\Helper\PaginatorHelper' => [ |
497 | | - // Can't rename _numbers as it conflicts with the PaginatorHelper::numbers() method |
498 | 475 | '_toggledLink', '_removeAlias', '_getNumbersStartAndEnd', '_formatNumber', |
499 | 476 | '_modulusNumbers', '_firstNumber', '_lastNumber', |
500 | 477 | ], |
|
532 | 509 | } |
533 | 510 | } |
534 | 511 | } |
| 512 | + |
| 513 | + // Rename methods that start with an underscore to a new, non-conflicting name. |
| 514 | + |
| 515 | + $map = [ |
| 516 | + 'Console' => [ |
| 517 | + 'Cake\Console\ConsoleOutput' => [ |
| 518 | + '_write' => 'writeStream', |
| 519 | + ], |
| 520 | + ], |
| 521 | + 'Form' => [ |
| 522 | + 'Cake\Form\Form' => [ |
| 523 | + '_execute' => 'process', |
| 524 | + ], |
| 525 | + ], |
| 526 | + 'Http' => [ |
| 527 | + 'Cake\Http\Client' => [ |
| 528 | + '_sendRequest' => 'processRequest', |
| 529 | + ], |
| 530 | + 'Cake\Http\ServerRequest' => [ |
| 531 | + '_is' => 'isType', |
| 532 | + ], |
| 533 | + 'Cake\Http\Client\Adapter\Stream' => [ |
| 534 | + '_send' => 'processRequest', |
| 535 | + ], |
| 536 | + ], |
| 537 | + 'I18n' => [ |
| 538 | + 'Cake\I18n\DateFormatTrait' => [ |
| 539 | + '_parseDateTime' => 'processDateTime', |
| 540 | + ], |
| 541 | + ], |
| 542 | + 'Mailer' => [ |
| 543 | + 'Cake\Mailer\Transport\SmtpTransport' => [ |
| 544 | + '_connect' => 'connectSmtp', |
| 545 | + '_disconnect' => 'disconnectSmtp', |
| 546 | + ], |
| 547 | + ], |
| 548 | + 'ORM' => [ |
| 549 | + 'Cake\ORM\Table' => [ |
| 550 | + '_saveMany' => 'doSaveMany', |
| 551 | + '_deleteMany' => 'doDeleteMany', |
| 552 | + ], |
| 553 | + 'Cake\ORM\Behavior\TreeBehavior' => [ |
| 554 | + '_moveUp' => 'doMoveUp', |
| 555 | + '_moveDown' => 'doMoveDown', |
| 556 | + '_removeFromTree' => 'doRemoveFromTree', |
| 557 | + ], |
| 558 | + 'Cake\ORM\Association\HasMany' => [ |
| 559 | + '_unlink' => 'doUnlink', |
| 560 | + ], |
| 561 | + 'Cake\ORM\Query\SelectQuery' => [ |
| 562 | + '_decorateResults' => 'ormDecorateResults', |
| 563 | + '_execute' => 'ormExecute', |
| 564 | + ], |
| 565 | + ], |
| 566 | + 'Utility' => [ |
| 567 | + 'Cake\Utility\Hash' => [ |
| 568 | + '_filter' => 'doFilter', |
| 569 | + '_merge' => 'doMerge', |
| 570 | + ], |
| 571 | + 'Cake\Utility\Text' => [ |
| 572 | + '_wordWrap' => 'doWordWrap', |
| 573 | + ], |
| 574 | + 'Cake\Utility\Xml' => [ |
| 575 | + '_fromArray' => 'doFromArray', |
| 576 | + '_toArray' => 'doToArray', |
| 577 | + ], |
| 578 | + ], |
| 579 | + 'View' => [ |
| 580 | + 'Cake\View\View' => [ |
| 581 | + '_render' => 'renderFile', |
| 582 | + ], |
| 583 | + 'Cake\View\Helper\PaginatorHelper' => [ |
| 584 | + '_numbers' => 'buildNumbers', |
| 585 | + ], |
| 586 | + ], |
| 587 | + ]; |
| 588 | + |
| 589 | + foreach ($map as $definitions) { |
| 590 | + foreach ($definitions as $className => $methods) { |
| 591 | + foreach ($methods as $oldMethod => $newMethod) { |
| 592 | + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ |
| 593 | + new MethodCallRename($className, $oldMethod, $newMethod), |
| 594 | + ]); |
| 595 | + } |
| 596 | + } |
| 597 | + } |
535 | 598 | }; |
0 commit comments