Skip to content

Commit afd3a5e

Browse files
committed
fix cs: import global namespace class
1 parent 43bc7b9 commit afd3a5e

8 files changed

Lines changed: 30 additions & 15 deletions

src/Exception/QueryNumException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Ray\Query\Exception;
66

7-
class QueryNumException extends \InvalidArgumentException
7+
use InvalidArgumentException;
8+
9+
class QueryNumException extends InvalidArgumentException
810
{
911
}

src/Exception/WebQueryException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Ray\Query\Exception;
66

7-
class WebQueryException extends \RuntimeException
7+
use RuntimeException;
8+
9+
class WebQueryException extends RuntimeException
810
{
911
}

src/Iso8601Interceptor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Ray\Query;
66

7+
use DateTime;
8+
use DateTimeImmutable;
79
use function is_array;
810
use Ray\Aop\MethodInterceptor;
911
use Ray\Aop\MethodInvocation;
@@ -50,7 +52,7 @@ private function convert(array $list) : array
5052
foreach ($list as &$row) {
5153
foreach ($row as $column => &$value) {
5254
if (in_array($column, $this->datetimeColumns, true)) {
53-
$value = (new \DateTime($value))->format(\DateTime::ATOM);
55+
$value = (new DateTimeImmutable($value))->format(DateTime::ATOM);
5456
}
5557
}
5658
}

src/PhpQueryModule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Ray\Query;
66

77
use Ray\Di\AbstractModule;
8+
use ReflectionClass;
89

910
class PhpQueryModule extends AbstractModule
1011
{
@@ -35,7 +36,7 @@ protected function configure() : void
3536
*/
3637
private function bindQuery(string $name, $binding) : void
3738
{
38-
if (is_string($binding) && class_exists($binding) && (new \ReflectionClass($binding))->implementsInterface(QueryInterface::class)) {
39+
if (is_string($binding) && class_exists($binding) && (new ReflectionClass($binding))->implementsInterface(QueryInterface::class)) {
3940
$this->bind(QueryInterface::class)->annotatedWith($name)->to($binding);
4041
}
4142
}

src/QueryInterceptor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Ray\Query;
66

77
use BEAR\Resource\ResourceObject;
8+
use InvalidArgumentException;
89
use Ray\Aop\MethodInterceptor;
910
use Ray\Aop\MethodInvocation;
1011
use Ray\Aop\ReflectionMethod;
@@ -86,7 +87,7 @@ private function templated(Query $query, array $namedArguments) : array
8687
{
8788
$url = parse_url(uri_template($query->id, $namedArguments));
8889
if (! isset($url['path'])) { // @phpstan-ignore-line
89-
throw new \InvalidArgumentException($query->id);
90+
throw new InvalidArgumentException($query->id);
9091
}
9192
$queryId = $url['path'];
9293
isset($url['query']) ? parse_str($url['query'], $params) : $params = $namedArguments;

src/SqlQueryModule.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55
namespace Ray\Query;
66

7+
use FilesystemIterator;
78
use Ray\Di\AbstractModule;
89
use Ray\Query\Annotation\AliasQuery;
910
use Ray\Query\Annotation\Query;
11+
use RecursiveDirectoryIterator;
12+
use RecursiveIteratorIterator;
13+
use RecursiveRegexIterator;
14+
use RegexIterator;
1015

1116
class SqlQueryModule extends AbstractModule
1217
{
@@ -81,19 +86,19 @@ protected function bindCallableList(string $name, string $sqlId) : void
8186
);
8287
}
8388

84-
private function files(string $dir) : \RegexIterator
89+
private function files(string $dir) : RegexIterator
8590
{
8691
return
87-
new \RegexIterator(
88-
new \RecursiveIteratorIterator(
89-
new \RecursiveDirectoryIterator(
92+
new RegexIterator(
93+
new RecursiveIteratorIterator(
94+
new RecursiveDirectoryIterator(
9095
$dir,
91-
\FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS
96+
FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::SKIP_DOTS
9297
),
93-
\RecursiveIteratorIterator::LEAVES_ONLY
98+
RecursiveIteratorIterator::LEAVES_ONLY
9499
),
95100
'/^.+\.sql$/',
96-
\RecursiveRegexIterator::MATCH
101+
RecursiveRegexIterator::MATCH
97102
);
98103
}
99104
}

src/SqlQueryRowList.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Aura\Sql\ExtendedPdoInterface;
88
use function count;
99
use function explode;
10+
use PDO;
11+
use PDOStatement;
1012
use Ray\Query\Exception\QueryNumException;
1113
use function strpos;
1214

@@ -48,8 +50,8 @@ public function __invoke(array ...$queries) : iterable
4850
$lastQuery = $result
4951
? strtolower(trim($result->queryString, "\\ \t\n\r\0\x0B"))
5052
: '';
51-
if ($result instanceof \PDOStatement && strpos($lastQuery, 'select') === 0) {
52-
return (array) $result->fetchAll(\PDO::FETCH_ASSOC);
53+
if ($result instanceof PDOStatement && strpos($lastQuery, 'select') === 0) {
54+
return (array) $result->fetchAll(PDO::FETCH_ASSOC);
5355
}
5456

5557
return [];

tests/WebQueryModuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testQueryInterface() : void
3636
public function testCallable() : void
3737
{
3838
$foo = (new Injector($this->module, __DIR__ . '/tmp'))->getInstance('', 'foo');
39-
$this->assertInternalType('callable', $foo);
39+
$this->assertIsCallable($foo);
4040
$result = $foo([]);
4141
$this->assertSame('https://httpbin.org/anything/foo', $result['url']);
4242
}

0 commit comments

Comments
 (0)