forked from rectorphp/rector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcakephp-fluent-options.php
90 lines (86 loc) · 4.11 KB
/
cakephp-fluent-options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
declare(strict_types=1);
use Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector;
use Rector\CakePHP\ValueObject\ArrayToFluentCall;
use Rector\CakePHP\ValueObject\FactoryMethod;
use function Rector\SymfonyPhpConfig\inline_value_objects;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArrayToFluentCallRector::class)
->call('configure', [[
ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => inline_value_objects([
new ArrayToFluentCall('Cake\ORM\Association', [
'bindingKey' => 'setBindingKey',
'cascadeCallbacks' => 'setCascadeCallbacks',
'className' => 'setClassName',
'conditions' => 'setConditions',
'dependent' => 'setDependent',
'finder' => 'setFinder',
'foreignKey' => 'setForeignKey',
'joinType' => 'setJoinType',
'propertyName' => 'setProperty',
'sourceTable' => 'setSource',
'strategy' => 'setStrategy',
'targetTable' => 'setTarget',
# BelongsToMany and HasMany only
'saveStrategy' => 'setSaveStrategy',
'sort' => 'setSort',
# BelongsToMany only
'targetForeignKey' => 'setTargetForeignKey',
'through' => 'setThrough',
]),
new ArrayToFluentCall('Cake\ORM\Query', [
'fields' => 'select',
'conditions' => 'where',
'join' => 'join',
'order' => 'order',
'limit' => 'limit',
'offset' => 'offset',
'group' => 'group',
'having' => 'having',
'contain' => 'contain',
'page' => 'page',
]),
new ArrayToFluentCall('Cake\ORM\Association', [
'bindingKey' => 'setBindingKey',
'cascadeCallbacks' => 'setCascadeCallbacks',
'className' => 'setClassName',
'conditions' => 'setConditions',
'dependent' => 'setDependent',
'finder' => 'setFinder',
'foreignKey' => 'setForeignKey',
'joinType' => 'setJoinType',
'propertyName' => 'setProperty',
'sourceTable' => 'setSource',
'strategy' => 'setStrategy',
'targetTable' => 'setTarget',
# BelongsToMany and HasMany only
'saveStrategy' => 'setSaveStrategy',
'sort' => 'setSort',
# BelongsToMany only
'targetForeignKey' => 'setTargetForeignKey',
'through' => 'setThrough',
]),
new ArrayToFluentCall('Cake\ORM\Query', [
'fields' => 'select',
'conditions' => 'where',
'join' => 'join',
'order' => 'order',
'limit' => 'limit',
'offset' => 'offset',
'group' => 'group',
'having' => 'having',
'contain' => 'contain',
'page' => 'page',
]),
]),
ArrayToFluentCallRector::FACTORY_METHODS => inline_value_objects([
new FactoryMethod('Cake\ORM\Table', 'belongsTo', 'Cake\ORM\Association', 2),
new FactoryMethod('Cake\ORM\Table', 'belongsToMany', 'Cake\ORM\Association', 2),
new FactoryMethod('Cake\ORM\Table', 'hasMany', 'Cake\ORM\Association', 2),
new FactoryMethod('Cake\ORM\Table', 'hasOne', 'Cake\ORM\Association', 2),
new FactoryMethod('Cake\ORM\Table', 'find', 'Cake\ORM\Query', 2),
]),
]]);
};