PHP Class Cake\Upgrade\Shell\Task\AppUsesTask

Updates App::uses() calls.
Inheritance: extends BaseTask, use trait ChangeTrait
Show file Open project: cakephp/upgrade

Public Properties

Property Type Description
$implicitMap array A map of old => new for use statements that are missing
$rename mixed A list of classes which have had the Cake prefix removed
$tasks

Protected Methods

Method Description
_addImplicitUses ( string $contents ) : string Add implicit uses
_mapClassName ( array $matches ) : array Convert old classnames to new ones.
_orderUses ( string $contents ) : string Order use statements
_process ( $path ) : void Convert App::uses() to normal use statements.
_removeDynamicAppUses ( string $contents ) : string _removeDynamicAppUses
_replaceAppUses ( string $contents ) : string Replace App::uses with use ;
_replaceReferences ( string $contents ) : string Replace references to old classes
_shouldProcess ( string $path ) : boolean _shouldProcess

Method Details

_addImplicitUses() protected method

Account for: + parent classes and interfaces are frequently just assumed to exist in useland code + also in function arguments + static class calls for basic Cake classes
protected _addImplicitUses ( string $contents ) : string
$contents string
return string

_mapClassName() protected method

Strips the Cake prefix off of classes that no longer have it.
protected _mapClassName ( array $matches ) : array
$matches array
return array

_orderUses() protected method

For code standards, use statements should be alphabetical but in addition, this Moves all use statements to the top of the class
protected _orderUses ( string $contents ) : string
$contents string
return string

_process() protected method

Order App::uses statements and replace the class in the source if it appears
protected _process ( $path ) : void
return void

_removeDynamicAppUses() protected method

_removeDynamicAppUses
protected _removeDynamicAppUses ( string $contents ) : string
$contents string
return string

_replaceAppUses() protected method

Replace App::uses with use ;
protected _replaceAppUses ( string $contents ) : string
$contents string
return string

_replaceReferences() protected method

Replace references to old classes
protected _replaceReferences ( string $contents ) : string
$contents string
return string

_shouldProcess() protected method

If App::uses is nowhere - bail, otherwise use the default (php files only)
protected _shouldProcess ( string $path ) : boolean
$path string
return boolean

Property Details

$implicitMap public property

A map of old => new for use statements that are missing
public array $implicitMap
return array

$rename public property

A list of classes which have had the Cake prefix removed
public mixed $rename
return mixed

$tasks public property

public $tasks