Skip to content

Commit

Permalink
beautified
Browse files Browse the repository at this point in the history
  • Loading branch information
n0nag0n committed Jan 28, 2024
1 parent aaf6a44 commit 4c60454
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"test-coverage": "rm clover.xml && XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage --coverage-clover=clover.xml && vendor/bin/coverage-check clover.xml 100",
"lint": "phpstan --no-progress -cphpstan.neon",
"beautify": "phpcbf --standard=phpcs.xml",
"phpcs": "phpcs --standard=phpcs.xml"
"phpcs": "phpcs --standard=phpcs.xml -n"
},
"suggest": {
"latte/latte": "Latte template engine",
Expand Down
44 changes: 22 additions & 22 deletions flight/database/PdoWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,36 +106,36 @@ public function fetchAll(string $sql, array $params = []): array
protected function processInStatementSql(string $sql, array $params = []): array
{
// Replace "IN(?)" with "IN(?,?,?)"
$sql = preg_replace('/IN\s*\(\s*\?\s*\)/i', 'IN(?)', $sql);
$sql = preg_replace('/IN\s*\(\s*\?\s*\)/i', 'IN(?)', $sql);

$current_index = 0;
while (($current_index = strpos($sql, 'IN(?)', $current_index)) !== false) {
$preceeding_count = substr_count($sql, '?', 0, $current_index - 1);
$current_index = 0;
while (($current_index = strpos($sql, 'IN(?)', $current_index)) !== false) {
$preceeding_count = substr_count($sql, '?', 0, $current_index - 1);

$param = $params[$preceeding_count];
$question_marks = '?';
$param = $params[$preceeding_count];
$question_marks = '?';

if (is_string($param) || is_array($param)) {
$params_to_use = $param;
if (is_string($param)) {
$params_to_use = explode(',', $param);
}
if (is_string($param) || is_array($param)) {
$params_to_use = $param;
if (is_string($param)) {
$params_to_use = explode(',', $param);
}

foreach ($params_to_use as $key => $value) {
if (is_string($value)) {
$params_to_use[$key] = trim($value);
foreach ($params_to_use as $key => $value) {
if (is_string($value)) {
$params_to_use[$key] = trim($value);
}
}
}

$question_marks = join(',', array_fill(0, count($params_to_use), '?'));
$sql = substr_replace($sql, $question_marks, $current_index + 3, 1);
$question_marks = join(',', array_fill(0, count($params_to_use), '?'));
$sql = substr_replace($sql, $question_marks, $current_index + 3, 1);

array_splice($params, $preceeding_count, 1, $params_to_use);
}
array_splice($params, $preceeding_count, 1, $params_to_use);
}

$current_index += strlen($question_marks) + 4;
}
$current_index += strlen($question_marks) + 4;
}

return [ 'sql' => $sql, 'params' => $params ];
return [ 'sql' => $sql, 'params' => $params ];
}
}
6 changes: 3 additions & 3 deletions flight/net/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ public function hydrateUrl(array $params = []): string
// catches potential optional parameter
$url = str_replace('(/', '/', $url);
// trim any trailing slashes
if($url !== '/') {
$url = rtrim($url, '/');
}
if ($url !== '/') {
$url = rtrim($url, '/');
}
return $url;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public function testRewindAndValid()
$this->assertTrue($result);
}

public function testGetRootUrlByAlias()
public function testGetRootUrlByAlias()
{
$this->router->map('/', [$this, 'ok'], false, 'path1');
$url = $this->router->getUrlByAlias('path1');
Expand Down

0 comments on commit 4c60454

Please sign in to comment.