diff --git a/QueryGenerator.php b/QueryGenerator.php index 59ad380..ded9a70 100644 --- a/QueryGenerator.php +++ b/QueryGenerator.php @@ -232,7 +232,7 @@ class QueryGenerator { 'STRAIGHT_JOIN', 'SQL_SMALL_RESULT', 'SQL_BIG_RESULT', 'SQL_BUFFER_RESULT', 'SQL_CACHE', 'SQL_NO_CACHE', - 'SQL_CALC_FOUND_ROWS' + 'SQL_CALC_FOUND_ROWS', ], 'insert' => ['LOW_PRIORITY', 'DELAYED', 'HIGH_PRIORITY', 'IGNORE'], 'replace' => ['LOW_PRIORITY', 'DELAYED'], @@ -263,8 +263,9 @@ public function __call(string $method, array $args) { throw new Exception("Method \"$method\" does not exist."); } - $requiresArgument = (isset(self::$methods[$method]['requiresArgument']) ? - self::$methods[$method]['requiresArgument'] : false); + $requiresArgument = (isset(self::$methods[$method]['requiresArgument']) + ? self::$methods[$method]['requiresArgument'] + : false); if ($requiresArgument && count($args) < 1) { throw new Exception("Missing argument 1 (\$clauses) for $method()"); @@ -272,12 +273,12 @@ public function __call(string $method, array $args) { $clauses = reset($args); $params = []; } else { - list($clauses, $params) = $args; + [$clauses, $params] = $args; } - if ($clauses instanceOf QueryGenerator) { + if ($clauses instanceof self) { $clauses->skipValidation(); - list($clauses, $params) = $clauses->build(/* $skipClauses = */ true); + [$clauses, $params] = $clauses->build(/* $skipClauses = */ true); } if (!is_array($clauses)) { @@ -369,7 +370,8 @@ private function assertCompleteQuery(): void { if (!$primaryMethod) { $primaryClauseStr = implode("', '", $this->getPrimaryClauses()); throw new MissingPrimaryClauseException( - "Missing primary clause. One of '$primaryClauseStr' needed."); + "Missing primary clause. One of '$primaryClauseStr' needed." + ); } $minimumClauses = self::$minimumClauses[$primaryMethod]; diff --git a/QueryGeneratorTest.php b/QueryGeneratorTest.php index c3b8b3c..b19850c 100644 --- a/QueryGeneratorTest.php +++ b/QueryGeneratorTest.php @@ -1,6 +1,6 @@ from(['table1', 'table2']); $qGen->join([ 'INNER JOIN table3 USING (asdf)', - 'OUTER JOIN table4 ON foo = bar' + 'OUTER JOIN table4 ON foo = bar', ]); $qGen->where(['where1', 'where2 OR where3']); $qGen->group(['group1', 'group2']); @@ -242,11 +242,11 @@ public function testOnDuplicate(): void { } public function assertQuery(QueryGenerator $qGen, string $expectedQuery, array $expectedParams): void { - list($actualQuery, $actualParams) = $qGen->build(); + [$actualQuery, $actualParams] = $qGen->build(); $this->assertEquals($expectedQuery, $actualQuery); $this->assertEquals($expectedParams, $actualParams); - list($actualQuery, $actualParams) = $qGen->skipValidation()->build(); + [$actualQuery, $actualParams] = $qGen->skipValidation()->build(); $this->assertEquals($expectedQuery, $actualQuery); $this->assertEquals($expectedParams, $actualParams); }