Skip to content

Commit 60b6598

Browse files
author
Nikita Chernyi
committed
updated codestyle
1 parent b0dcd55 commit 60b6598

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

.php_cs.dist

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ $finder = \PhpCsFixer\Finder::create()
66
return \PhpCsFixer\Config::create()
77
->setRiskyAllowed(true)
88
->setRules(array(
9+
'@PHP71Migration' => true,
10+
'@PHP71Migration:risky' => true,
911
'@PSR1' => true,
1012
'@PSR2' => true,
1113
'@Symfony' => true,
1214
'@Symfony:risky' => true,
13-
'@PHP71Migration' => true,
14-
'@PHP71Migration:risky' => true,
1515
'array_syntax' => ['syntax' => 'short'],
1616
'list_syntax' => ['syntax' => 'short'],
17-
'no_short_echo_tag' => true,
17+
'native_function_invocation' => true,
1818
'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
1919
'no_null_property_initialization' => true,
2020
'no_short_echo_tag' => true,
21+
'no_short_echo_tag' => true,
2122
'no_superfluous_elseif' => true,
2223
'no_unneeded_curly_braces' => true,
2324
'no_unneeded_final_method' => true,

src/Entity.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class Entity extends \Wtf\Root
2121
*/
2222
protected function __getEntityName(): string
2323
{
24-
return ($pos = strrpos(get_class($this), '\\')) ? substr(get_class($this), $pos + 1) : get_class($this);
24+
return ($pos = \strrpos(\get_class($this), '\\')) ? \substr(\get_class($this), $pos + 1) : \get_class($this);
2525
}
2626

2727
/**
@@ -32,9 +32,9 @@ protected function __getEntityName(): string
3232
*/
3333
public function __call(?string $method = null, array $params = [])
3434
{
35-
$parts = preg_split('/([A-Z][^A-Z]*)/', $method, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
36-
$type = array_shift($parts);
37-
$relation = strtolower(implode('_', $parts));
35+
$parts = \preg_split('/([A-Z][^A-Z]*)/', $method, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
36+
$type = \array_shift($parts);
37+
$relation = \strtolower(\implode('_', $parts));
3838

3939
if ('get' === $type && isset($this->getRelations()[$relation])) {
4040
return $this->loadRelation($relation);
@@ -80,7 +80,7 @@ public function getData(): array
8080
*/
8181
public function setData(array $data)
8282
{
83-
$this->data = array_merge($this->data, $data);
83+
$this->data = \array_merge($this->data, $data);
8484

8585
return $this;
8686
}
@@ -149,9 +149,9 @@ public function validate(string $method = 'save'): array
149149
public function load($value, $field = 'id', array $fields = null): self
150150
{
151151
$data = $this->medoo->get($this->getTable(), $fields ?? '*', [$field => $value]);
152-
$this->data = is_array($data) ? $data : []; //handle empty result gracefuly
152+
$this->data = \is_array($data) ? $data : []; //handle empty result gracefuly
153153
$this->sentry->breadcrumbs->record([
154-
'message' => 'Entity '.$this->__getEntityName().'::load('.$value.', '.$field.', ['.implode(', ', $fields ?? []).')',
154+
'message' => 'Entity '.$this->__getEntityName().'::load('.$value.', '.$field.', ['.\implode(', ', $fields ?? []).')',
155155
'data' => ['query' => $this->medoo->last()],
156156
'category' => 'Database',
157157
'level' => 'info',
@@ -172,7 +172,7 @@ public function loadAll(array $where = [], bool $assoc = false): Collection
172172
{
173173
$allData = $this->medoo->select($this->getTable(), '*', $where);
174174
$this->sentry->breadcrumbs->record([
175-
'message' => 'Entity '.$this->__getEntityName().'::loadAll('.print_r($where, true).')',
175+
'message' => 'Entity '.$this->__getEntityName().'::loadAll('.\print_r($where, true).')',
176176
'data' => ['query' => $this->medoo->last()],
177177
'category' => 'Database',
178178
'level' => 'info',

src/Provider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ protected function setMedoo(Container $container): callable
4444
protected function setEntityLoader(Container $container): callable
4545
{
4646
return $container->protect(function (string $name) use ($container) {
47-
$parts = explode('_', $name);
47+
$parts = \explode('_', $name);
4848
$class = $container['config']('medoo.namespace');
4949
foreach ($parts as $part) {
50-
$class .= ucfirst($part);
50+
$class .= \ucfirst($part);
5151
}
5252
if (!$container->has('entity_'.$class)) {
5353
$container['entity_'.$class] = $container->factory(function ($container) use ($class) {

tests/EntityTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ protected function setUp(): void
1717
$app = new \Wtf\App(['config_dir' => $dir]);
1818
$this->container = $app->getContainer();
1919
//Init db
20-
ob_start();
20+
\ob_start();
2121
include $dir.'/../dump.sql';
22-
$query = ob_get_clean();
22+
$query = \ob_get_clean();
2323
$this->container->medoo->pdo->exec($query);
2424
}
2525

@@ -115,7 +115,7 @@ public function testLoadRelation(): void
115115
'title' => 'Test',
116116
'description' => 'test',
117117
]);
118-
foreach (range(1, 5) as $i) {
118+
foreach (\range(1, 5) as $i) {
119119
$article->setId(null);
120120
$article->save();
121121
}

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44
// Enable Composer autoloader
55
/** @var \Composer\Autoload\ClassLoader $autoloader */
6-
$autoloader = require dirname(__DIR__).'/vendor/autoload.php';
6+
$autoloader = require \dirname(__DIR__).'/vendor/autoload.php';
77
// Register test classes
88
$autoloader->addPsr4('Wtf\\ORM\\Tests\\', __DIR__);
99
$autoloader->addPsr4('Wtf\\ORM\\Tests\\Dummy\\', __DIR__.'/data/dummy');

0 commit comments

Comments
 (0)