Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Nov 18, 2017
1 parent 916364b commit 640a892
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
18 changes: 9 additions & 9 deletions demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
require 'vendor/autoload.php';

if ('save' == ($_GET['action'] ?? null)) {
echo 'OK'; exit;
echo 'OK'; exit;
} else if ('marriage' == ($_GET['action'] ?? null)) {
$groups = array(
array('value' => 0, 'text' => 'Unmarried 未婚'),
array('value' => 1, 'text' => 'Marriaged 已婚'),
array('value' => 2, 'text' => 'Divorced 离异'),
array('value' => 3, 'text' => 'Widowed 丧偶'),
);
echo json_encode($groups);
exit;
$groups = array(
array('value' => 0, 'text' => 'Unmarried 未婚'),
array('value' => 1, 'text' => 'Marriaged 已婚'),
array('value' => 2, 'text' => 'Divorced 离异'),
array('value' => 3, 'text' => 'Widowed 丧偶'),
);
echo json_encode($groups);
exit;
}
?>
<!DOCTYPE html>
Expand Down
72 changes: 36 additions & 36 deletions src/Editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Editable\Integrates\EditableException;
use AvpLab\PhpHtmlBuilder;

class Editable implements Interfaces\EditableInterface{
class Editable implements Interfaces\EditableInterface {
/**
* @var array 已声明使用的类型, 用于加载JS
*/
Expand Down Expand Up @@ -100,7 +100,7 @@ class Editable implements Interfaces\EditableInterface{
*/
public function __construct($row = null, $pk = "id", $hidden = [], $ajax = '')
{
if(!$row) {
if (!$row) {
throw new EditableException(null, EditableException::NO_DATA);
}

Expand All @@ -109,13 +109,13 @@ public function __construct($row = null, $pk = "id", $hidden = [], $ajax = '')
$this->hidden = array_flip($hidden);
$this->ajax = $ajax;

$this->hidden[$pk] = 1;
$this->hidden[$pk] = 1;

if(class_exists('\Editable\Assets\LocalAssets')) {
if (class_exists('\Editable\Assets\LocalAssets')) {
$this->vendor_assets = \Editable\Assets\LocalAssets::instance()->getVendorAssetsRoutingUrl();
}

foreach($this->row as $key => $value) {
foreach ($this->row as $key => $value) {
$this->input($key, $value);
}
}
Expand Down Expand Up @@ -143,8 +143,8 @@ public function registerComponent($type, $key, $value = null, $options = [], $in
*/
public function protect($key)
{
if(is_array($key)) {
foreach($key as $each) {
if (is_array($key)) {
foreach ($key as $each) {
$this->protect($each);
}
} else {
Expand Down Expand Up @@ -287,45 +287,45 @@ protected function __every_element($each)

$type = $each[0];
$key = $each[1];
if($each[2] === null && isset($this->row[$key]) && $this->row[$key] != null) {
if ($each[2] === null && isset($this->row[$key]) && $this->row[$key] != null) {
$each[2] = $this->row[$key];
}
$value = $each[2];
$value = $each[2];
$show_name = ucfirst(preg_replace_callback('/(_([a-zA-Z0-9]))/', function($a) {
if(isset($a[2])) {
if (isset($a[2])) {
return ' '.strtoupper($a[2]);
}
return $a;
}, $key));
$title = 'Type the '.$show_name;
$title = 'Type the '.$show_name;
$show_type = $type;

$show_value = $value;
if($type == 'select') {
if ($type == 'select') {
$show_value = '';
if(is_array($each[3])) {
foreach($each[3] as $option) {
$option_value = isset($option['value']) ? $option['value']: null;
if($value == $option_value) {
if (is_array($each[3])) {
foreach ($each[3] as $option) {
$option_value = isset($option['value']) ? $option['value'] : null;
if ($value == $option_value) {
$show_value = $option['text'];
break;
}
}
} else if(is_string($each[3])) {
} else if (is_string($each[3])) {

}
} else if($type == 'typeaheadjs') {
} else if ($type == 'typeaheadjs') {
$show_value = '';
foreach($each[3] as $option) {
$option_value = isset($option['value']) ? $option['value']: null;
if($value == $option_value) {
$show_value = $option['text'] . ' (' . $value . ') ';
foreach ($each[3] as $option) {
$option_value = isset($option['value']) ? $option['value'] : null;
if ($value == $option_value) {
$show_value = $option['text'].' ('.$value.') ';
break;
}
}
} else if($type == 'wysiwyg') {
} else if ($type == 'wysiwyg') {
$show_type = 'wysihtml5';
} else if($type == 'tag') {
} else if ($type == 'tag') {
$show_type = 'select2';
}

Expand All @@ -341,24 +341,24 @@ protected function __every_element($each)
/**//**//**/->setDataType($show_type)
/**//**//**/->setDataValue($value)
/**//**//**/->setDataPlacement('bottom');
/**//**//**/if(!isset($this->hidden[$key])) {
/**//**//**/if (!isset($this->hidden[$key])) {
/**//**//**//**/$this->builder->setClass('editable-link');
/**//**//**/}
/**//**//**/if($type == 'select' || $type == 'tag' || $type == 'checklist') {
/**//**//**//**/$this->builder->setDataSource(is_string($each[3])?$each[3]:json_encode($each[3]));
/**//**//**/} else if($type == 'typeaheadjs') {
/**//**//**/if ($type == 'select' || $type == 'tag' || $type == 'checklist') {
/**//**//**//**/$this->builder->setDataSource(is_string($each[3]) ? $each[3] : json_encode($each[3]));
/**//**//**/} else if ($type == 'typeaheadjs') {
/**//**//**//**/$this->builder->setDataTypeahead( # @todo: template
/**//**//**//**//**/json_encode([
/**//**//**//**//**/'name' => $key,
/**//**//**//**//**/'local' => $each[3],
/**//**//**//**//**/])
/**//**//**//**/);
/**//**//**/} else if($type == 'date') {
/**//**//**/} else if ($type == 'date') {
/**//**//**//**/$this->builder->setDataType('combodate')
/**//**//**//**//**//**/->setDataTemplate('YYYY/MM/DD')
/**//**//**//**//**//**/->setDataFormat('YYYY-MM-DD')
/**//**//**//**//**//**/->setDataViewformat('YYYY-MM-DD');
/**//**//**/} else if($type == 'datetime') {
/**//**//**/} else if ($type == 'datetime') {
/**//**//**//**/$this->builder->setDataType('combodate')
/**//**//**//**//**//**/->setDataTemplate('YYYY/MM/DD HH:mm:ss')
/**//**//**//**//**//**/->setDataFormat('YYYY-MM-DD HH:mm:ss')
Expand Down Expand Up @@ -479,8 +479,8 @@ public function render($and_destroy = true)
$this->builder->div()->setClass('table-wrapper')->setId('table-wrapper-'.$this->uuid);
/**/$this->builder->link()->setRel('stylesheet')->setHref($this->vendor_assets['xeditable']['css'][0])->end();
/**/$this->builder->link()->setRel('stylesheet')->setHref($this->vendor_assets['xeditable']['css'][1])->end();
foreach($this->existed_dom_type as $dom_type => $one) {
foreach($this->vendor_assets[$dom_type]['css'] as $css) {
foreach ($this->existed_dom_type as $dom_type => $one) {
foreach ($this->vendor_assets[$dom_type]['css'] as $css) {
/**/$this->builder->link()->setRel('stylesheet')->setHref($css)->end();
}
}
Expand All @@ -493,7 +493,7 @@ public function render($and_destroy = true)
/**//**/$this->builder->end();
/**//**/$this->builder->tbody();

foreach($this->data as $component) {
foreach ($this->data as $component) {
$this->__every_element($component);
}

Expand All @@ -504,8 +504,8 @@ public function render($and_destroy = true)
/**/$this->builder->script()->setType('application/javascript')->setSrc($this->vendor_assets['xeditable']['js'][1])->end();
/**/$this->builder->script()->setType('application/javascript')->setSrc($this->vendor_assets['xeditable']['js'][2])->end();

foreach($this->existed_dom_type as $dom_type => $one) {
foreach($this->vendor_assets[$dom_type]['js'] as $js) {
foreach ($this->existed_dom_type as $dom_type => $one) {
foreach ($this->vendor_assets[$dom_type]['js'] as $js) {
/**/$this->builder->script()->setType('application/javascript')->setSrc($js)->end();
}
}
Expand All @@ -516,7 +516,7 @@ public function render($and_destroy = true)

$response = new EditableResponse(200, $html);

if($and_destroy){
if ($and_destroy) {
$this->existed_dom_type = [];
$this->data = [];
$this->builder = null;
Expand Down
4 changes: 2 additions & 2 deletions src/Integrates/EditableException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Editable\Integrates;

class EditableException extends \Exception{
class EditableException extends \Exception {
const NO_DATA = -1;

static $messages = [
Expand All @@ -10,7 +10,7 @@ class EditableException extends \Exception{

public function __construct($message = null, $code, $previous = null)
{
if($message === null) {
if ($message === null) {
$message = self::$messages[$code];
}

Expand Down
30 changes: 15 additions & 15 deletions src/Integrates/EditableResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

class EditableResponse implements ResponseInterface{
class EditableResponse implements ResponseInterface {
/**
* @var int 状态码
*/
Expand All @@ -21,8 +21,8 @@ class EditableResponse implements ResponseInterface{
*/
public function __construct($status_code = null, $body = null)
{
if($status_code !== null) $this->status_code = $status_code;
if($body !== null) $this->body = $body;
if ($status_code !== null) $this->status_code = $status_code;
if ($body !== null) $this->body = $body;
}


Expand Down Expand Up @@ -51,16 +51,16 @@ public function getBody()
return $this->body;
}

public function getProtocolVersion(){}
public function withProtocolVersion($version){}
public function getHeaders(){}
public function hasHeader($name){}
public function getHeader($name){}
public function getHeaderLine($name){}
public function withHeader($name, $value){}
public function withAddedHeader($name, $value){}
public function withoutHeader($name){}
public function withBody(StreamInterface $body){}
public function withStatus($code, $reasonPhrase = ''){}
public function getReasonPhrase(){}
public function getProtocolVersion() {}
public function withProtocolVersion($version) {}
public function getHeaders() {}
public function hasHeader($name) {}
public function getHeader($name) {}
public function getHeaderLine($name) {}
public function withHeader($name, $value) {}
public function withAddedHeader($name, $value) {}
public function withoutHeader($name) {}
public function withBody(StreamInterface $body) {}
public function withStatus($code, $reasonPhrase = '') {}
public function getReasonPhrase() {}
}

0 comments on commit 640a892

Please sign in to comment.