Skip to content

Commit

Permalink
cs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Jun 25, 2020
1 parent c9eab9c commit 62be687
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion php/Job/Admin/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<?php return '.var_export(compact('tag', 'timestamp'), true) .';');
file_put_contents('latest.php', '<?php return ' . var_export(compact('tag', 'timestamp'), true) . ';');
return $tag;
}
}
3 changes: 2 additions & 1 deletion php/Job/Database/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function run()
foreach ($stats as $k => $function) {
try {
$info[$k] = $client->call($function)[0];
} catch (Exception $e) {}
} catch (Exception $e) {
}
}

return $info;
Expand Down
16 changes: 8 additions & 8 deletions php/Job/Database/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ 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");
}
}

$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;
}
}
4 changes: 1 addition & 3 deletions php/Job/Entity/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions php/Job/Entity/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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);
}

}
}
3 changes: 1 addition & 2 deletions php/Job/Entity/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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']};
Expand Down
2 changes: 1 addition & 1 deletion php/Job/Space/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions php/Job/Space/CreateIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand All @@ -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,
]));
Expand Down
2 changes: 1 addition & 1 deletion php/Job/Space/Drop.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 1 addition & 1 deletion php/Job/Space/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
}
Expand Down
8 changes: 4 additions & 4 deletions php/Job/Space/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
9 changes: 4 additions & 5 deletions php/Job/Space/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function run()
{
$key = [];
foreach ($this->key as $value) {
if (is_null($value)) {
if ($value === null) {
break;
}
$key[] = $value;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
Expand All @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion php/Job/Space/Truncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
5 changes: 4 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

$version = null;
$filename = __DIR__.'/version.php';
$filename = __DIR__ . '/version.php';

if (file_exists($filename)) {
$version = include $filename;
$version = $version['tag'] ?: $version['short_sha'];
}

?>
<!DOCTYPE html>
<html>
Expand Down

0 comments on commit 62be687

Please sign in to comment.