-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
85a7992
commit 5d2388a
Showing
1 changed file
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,67 @@ | ||
# 3 Rules Overview | ||
|
||
## AddConfigPropertiesRector | ||
<br> | ||
|
||
## Categories | ||
|
||
- [Rector](#rector) (3) | ||
|
||
<br> | ||
|
||
## Rector | ||
|
||
### AddConfigPropertiesRector | ||
|
||
Adds `@config` property to predefined private statics, e.g. `$db` or `$allowed_actions` | ||
|
||
:wrench: **configure it!** | ||
|
||
- class: [`Netwerkstatt\SilverstripeRector\Rector\Misc\AddConfigPropertiesRector`](../src/Rector/Misc/AddConfigPropertiesRector.php) | ||
|
||
```diff | ||
class SomeClass extends \SilverStripe\ORM\DataObject | ||
{ | ||
+ /** | ||
+ * @config | ||
+ */ | ||
private static $db = []; | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
## EnsureTableNameIsSetRector | ||
### EnsureTableNameIsSetRector | ||
|
||
DataObject subclasses must have "$table_name" defined | ||
|
||
- class: [`Netwerkstatt\SilverstripeRector\Rector\DataObject\EnsureTableNameIsSetRector`](../src/Rector/DataObject/EnsureTableNameIsSetRector.php) | ||
|
||
```diff | ||
class SomeClass extends \SilverStripe\ORM\DataObject | ||
{ | ||
+ private static $table_name = 'SomeClass'; | ||
+ | ||
private static $db = []; | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
## UseCreateRector | ||
### UseCreateRector | ||
|
||
Change new Object to static call for classes that use Injectable trait | ||
|
||
- class: [`Netwerkstatt\SilverstripeRector\Rector\Injector\UseCreateRector`](../src/Rector/Injector/UseCreateRector.php) | ||
|
||
```diff | ||
class SomeClass | ||
{ | ||
public function run() | ||
{ | ||
- new InjectableClass($name); | ||
+ InjectableClass::create($name); | ||
} | ||
} | ||
``` | ||
|
||
<br> |