From 62be6875a7723b0b2b6af0fe36197d4db5871eb7 Mon Sep 17 00:00:00 2001 From: Dmitry Krokhin Date: Thu, 25 Jun 2020 14:00:47 +0300 Subject: [PATCH] cs fix --- php/Job/Admin/Configuration.php | 2 +- php/Job/Database/Info.php | 3 ++- php/Job/Database/Job.php | 16 ++++++++-------- php/Job/Entity/Create.php | 4 +--- php/Job/Entity/Remove.php | 4 +--- php/Job/Entity/Update.php | 3 +-- php/Job/Space/Create.php | 2 +- php/Job/Space/CreateIndex.php | 5 ++--- php/Job/Space/Drop.php | 2 +- php/Job/Space/Info.php | 2 +- php/Job/Space/Job.php | 8 ++++---- php/Job/Space/Select.php | 9 ++++----- php/Job/Space/Truncate.php | 2 +- public/index.php | 5 ++++- 14 files changed, 32 insertions(+), 35 deletions(-) diff --git a/php/Job/Admin/Configuration.php b/php/Job/Admin/Configuration.php index 6125c93..adb7538 100644 --- a/php/Job/Admin/Configuration.php +++ b/php/Job/Admin/Configuration.php @@ -49,7 +49,7 @@ protected function getLatest() $tag = @json_decode(file_get_contents($url, false, $context))->tag_name; $timestamp = time(); - file_put_contents('latest.php', ' $function) { try { $info[$k] = $client->call($function)[0]; - } catch (Exception $e) {} + } catch (Exception $e) { + } } return $info; diff --git a/php/Job/Database/Job.php b/php/Job/Database/Job.php index eb7c242..4e15e2c 100644 --- a/php/Job/Database/Job.php +++ b/php/Job/Database/Job.php @@ -16,12 +16,12 @@ abstract class Job public $username; public $password; - private $_client; - private $_mapper; + private $client; + private $mapper; public function getClient() { - if (!$this->_client) { + if (!$this->client) { if (!$this->hostname || !$this->port) { if (!$this->socket) { throw new Exception("Invalid params"); @@ -29,20 +29,20 @@ public function getClient() } $dsn = $this->socket ?: 'tcp://'.$this->hostname.':'.$this->port; - $this->_client = Client::fromDsn($dsn)->withMiddleware( + $this->client = Client::fromDsn($dsn)->withMiddleware( new AuthenticationMiddleware($this->username ?: 'guest', $this->password), ); } - return $this->_client; + return $this->client; } public function getMapper() { - if (!$this->_mapper) { - $this->_mapper = new Mapper($this->getClient()); + if (!$this->mapper) { + $this->mapper = new Mapper($this->getClient()); } - return $this->_mapper; + return $this->mapper; } } diff --git a/php/Job/Entity/Create.php b/php/Job/Entity/Create.php index 9e668cf..9350680 100644 --- a/php/Job/Entity/Create.php +++ b/php/Job/Entity/Create.php @@ -14,13 +14,12 @@ public function run() $space = $this->getSpace(); if (!count($space->getFormat())) { - $data = []; foreach ($this->values as $k => $v) { if (!is_numeric($k)) { throw new Exception("Named property $k without format definition"); } - $data[$k-1] = $v; + $data[$k - 1] = $v; } if (array_values($data) == $data) { @@ -37,7 +36,6 @@ public function run() ->insert($data); return ['entity' => $data]; - } else { $entity = $space->getRepository()->create(get_object_vars($this->values)); $this->getMapper()->save($entity); diff --git a/php/Job/Entity/Remove.php b/php/Job/Entity/Remove.php index b4434d7..80e8005 100644 --- a/php/Job/Entity/Remove.php +++ b/php/Job/Entity/Remove.php @@ -18,7 +18,7 @@ public function run() if (!is_numeric($k)) { throw new Exception("Named property $k without format definition"); } - $data[$k-1] = $v; + $data[$k - 1] = $v; } $pk = []; @@ -29,13 +29,11 @@ public function run() $space->getMapper()->getClient() ->getSpace($space->getName()) ->delete($pk); - } else { $entity = $space->getRepository() ->findOne(get_object_vars($this->id)); $this->getMapper()->remove($entity); } - } } diff --git a/php/Job/Entity/Update.php b/php/Job/Entity/Update.php index 64c32fa..65c1379 100644 --- a/php/Job/Entity/Update.php +++ b/php/Job/Entity/Update.php @@ -22,7 +22,7 @@ public function run(Converter $converter) if (!is_numeric($k)) { throw new Exception("Named property $k without format definition"); } - $data[$k-1] = $v; + $data[$k - 1] = $v; } $pk = []; @@ -47,7 +47,6 @@ public function run(Converter $converter) $space->getMapper()->getClient() ->getSpace($space->getName()) ->update($pk, $operations); - } else { foreach ($space->getPrimaryIndex()['parts'] as $part) { $pk[] = $this->values->{$space->getFormat()[$part[0]]['name']}; diff --git a/php/Job/Space/Create.php b/php/Job/Space/Create.php index f9df11c..f572a03 100644 --- a/php/Job/Space/Create.php +++ b/php/Job/Space/Create.php @@ -11,7 +11,7 @@ public function run() $schema = $this->getMapper()->getSchema(); if ($schema->hasSpace($this->space)) { - throw new Exception('Space '.$this->space.' exists'); + throw new Exception('Space ' . $this->space . ' exists'); } $schema->createSpace($this->space); diff --git a/php/Job/Space/CreateIndex.php b/php/Job/Space/CreateIndex.php index 83bf0ba..a2c4279 100644 --- a/php/Job/Space/CreateIndex.php +++ b/php/Job/Space/CreateIndex.php @@ -24,12 +24,11 @@ public function run() 'parts' => $this->parts, ]; $space->getMapper()->getClient()->call("box.space[$spaceId]:create_index", $this->name, [$options]); - } elseif (is_array($this->fields)) { $format = $space->getFormat(); $fields = []; - foreach($this->fields as $index) { + foreach ($this->fields as $index) { $fields[] = $format[$index]['name']; } @@ -40,7 +39,7 @@ public function run() 'type' => $this->type, ]); } else { - throw new Exception("Invalid index configuration: ".json_encode([ + throw new Exception("Invalid index configuration: " . json_encode([ 'name' => $this->name, 'type' => $this->type, ])); diff --git a/php/Job/Space/Drop.php b/php/Job/Space/Drop.php index 8c29794..cb28d19 100644 --- a/php/Job/Space/Drop.php +++ b/php/Job/Space/Drop.php @@ -11,6 +11,6 @@ public function run() throw new Exception('Disabled for system spaces'); } - $this->getClient()->call('box.space.'.$space->getName().':drop'); + $this->getClient()->call('box.space.' . $space->getName() . ':drop'); } } diff --git a/php/Job/Space/Info.php b/php/Job/Space/Info.php index 59c5b9f..c4a4e33 100644 --- a/php/Job/Space/Info.php +++ b/php/Job/Space/Info.php @@ -21,7 +21,7 @@ public function run() $count = $count ?: 20; // default max columns foreach (range(1, $count) as $value) { $format[] = [ - 'name' => "".$value, + 'name' => "" . $value, 'type' => 'str', ]; } diff --git a/php/Job/Space/Job.php b/php/Job/Space/Job.php index 1ad5c99..09a7f5b 100644 --- a/php/Job/Space/Job.php +++ b/php/Job/Space/Job.php @@ -7,15 +7,15 @@ abstract class Job extends DatabaseJob { - private $_space; + private $space; public function getSpace() { - if (!$this->_space) { + if (!$this->space) { if (!$this->space) { throw new Exception("Invalid params"); } - $this->_space = $this->getMapper()->getSchema()->getSpace($this->space); + $this->space = $this->getMapper()->getSchema()->getSpace($this->space); } - return $this->_space; + return $this->space; } } diff --git a/php/Job/Space/Select.php b/php/Job/Space/Select.php index ba49bf4..f93a6b1 100644 --- a/php/Job/Space/Select.php +++ b/php/Job/Space/Select.php @@ -18,7 +18,7 @@ public function run() { $key = []; foreach ($this->key as $value) { - if (is_null($value)) { + if ($value === null) { break; } $key[] = $value; @@ -46,7 +46,7 @@ public function run() if (is_object($value) && get_class($value) == Decimal::class) { $value = $value->toString(); } - if (is_numeric($value) && $value > 2^32 -1) { + if (is_numeric($value) && $value > 2 ^ 32 - 1) { $data[$x][$y] = (string) $value; } } @@ -63,13 +63,12 @@ public function run() [$total] = $this->getMapper()->getClient() ->call("box.space.$this->space.index.$indexName:count", $key); } catch (Exception $e) { - $criteria = $criteria->andLimit($this->limit+1); + $criteria = $criteria->andLimit($this->limit + 1); $extra = $this->getMapper()->getClient()->getSpace($this->space) ->select($criteria); // next page flag $next = count($extra) > count($data); } - } catch (Exception $e) { if (!$data) { throw $e; @@ -80,7 +79,7 @@ public function run() foreach ($data as $i => $tuple) { foreach ($tuple as $k => $v) { if (is_string($v) && !json_encode($v)) { - $data[$i][$k] = '!!binary '.base64_encode($v); + $data[$i][$k] = '!!binary ' . base64_encode($v); } } } diff --git a/php/Job/Space/Truncate.php b/php/Job/Space/Truncate.php index aaf0aba..5b80651 100644 --- a/php/Job/Space/Truncate.php +++ b/php/Job/Space/Truncate.php @@ -11,6 +11,6 @@ public function run() throw new Exception('Disabled for system spaces'); } - $this->getClient()->call('box.space.'.$space->getName().':truncate'); + $this->getClient()->call('box.space.' . $space->getName() . ':truncate'); } } diff --git a/public/index.php b/public/index.php index d26bf68..bfe1c80 100644 --- a/public/index.php +++ b/public/index.php @@ -1,10 +1,13 @@