1 | <?php |
||
11 | class UseSortingManager implements UseSortingManagerInterface |
||
12 | { |
||
13 | /** |
||
14 | * Use statement regex |
||
15 | */ |
||
16 | const USE_STATEMENT_REGEX = '^(use .*)$'; |
||
17 | |||
18 | /** |
||
19 | * Constructor |
||
20 | * |
||
21 | * @param FileManagerInterface $fileManager |
||
22 | */ |
||
23 | public function __construct(FileManagerInterface $fileManager) |
||
27 | |||
28 | /** |
||
29 | * Search and sort alphabetically use statements in a class file |
||
30 | * |
||
31 | * @param string $filepath |
||
32 | * |
||
33 | * @throws Exception |
||
34 | */ |
||
35 | public function sort($filepath) |
||
49 | |||
50 | /** |
||
51 | * Find use statements |
||
52 | * |
||
53 | * @param string $filepath |
||
54 | * |
||
55 | * @return UseStatementBlock |
||
56 | */ |
||
57 | private function findUseStatements($filepath) |
||
78 | |||
79 | /** |
||
80 | * Sort use lines in new created file |
||
81 | * |
||
82 | * @param string $filepath |
||
83 | * @param UseStatementBlock $statementBlock |
||
84 | */ |
||
85 | private function createCleanedFile($filepath, UseStatementBlock $statementBlock) |
||
101 | } |
||
102 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: