1 | <?php |
||
27 | class QueryBuilderFactory |
||
28 | { |
||
29 | /** |
||
30 | * @var Container $container |
||
31 | */ |
||
32 | private $container; |
||
33 | |||
34 | /** |
||
35 | * @param Container|null $container |
||
36 | */ |
||
37 | public function __construct(Container $container = null) |
||
38 | { |
||
39 | $this->container = $container ?: (new ContainerFactory())->create(); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return Container |
||
44 | */ |
||
45 | public function getContainer() |
||
46 | { |
||
47 | return $this->container; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param ConnectionInterface $connection |
||
52 | * @param string $name |
||
53 | */ |
||
54 | public function registerConnection(ConnectionInterface $connection, $name = 'default') |
||
55 | { |
||
56 | $this->container['phuria.sql_builder.connection_manager']->registerConnection( |
||
57 | $connection, $name |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param string $class |
||
63 | * |
||
64 | * @return QueryCompilerInterface |
||
65 | */ |
||
66 | private function createQueryBuilder($class) |
||
67 | { |
||
68 | $parameterClass = $this->container['phuria.sql_builder.parameter_manager.class']; |
||
69 | |||
70 | return new $class( |
||
71 | $this->container['phuria.sql_builder.table_factory'], |
||
72 | $this->container['phuria.sql_builder.query_compiler'], |
||
73 | new $parameterClass, |
||
74 | $this->container['phuria.sql_builder.query_factory'] |
||
75 | ); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return SelectBuilder |
||
|
|||
80 | */ |
||
81 | public function createSelect() |
||
85 | |||
86 | /** |
||
87 | * @return UpdateBuilder |
||
88 | */ |
||
89 | public function createUpdate() |
||
90 | { |
||
91 | return $this->createQueryBuilder(UpdateBuilder::class); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return DeleteBuilder |
||
96 | */ |
||
97 | public function createDelete() |
||
101 | |||
102 | /** |
||
103 | * @return InsertBuilder |
||
104 | */ |
||
105 | public function createInsert() |
||
106 | { |
||
107 | return $this->createQueryBuilder(InsertBuilder::class); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * @return InsertSelectBuilder |
||
112 | */ |
||
113 | public function createInsertSelect() |
||
117 | } |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.