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

Scrutinizer Auto-Fixes #1

Merged
merged 1 commit into from
Nov 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions demo.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
require 'vendor/autoload.php';

if('save' == ($_GET['action'] ?? null)) {
echo 'OK';exit;
} else if('marriage' == ($_GET['action'] ?? null)) {
if ('save' == ($_GET['action'] ?? null)) {
echo 'OK'; exit;
} else if ('marriage' == ($_GET['action'] ?? null)) {
$groups = array(
array('value' => 0, 'text' => 'Unmarried 未婚'),
array('value' => 1, 'text' => 'Marriaged 已婚'),
Expand All @@ -22,7 +22,7 @@
<body>
<div class="col-md-6 col-md-offset-3">
<h1>PHP Editable Demo</h1>
<?php echo Editable\Example\Editable::test();?>
<?php echo Editable\Example\Editable::test(); ?>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion example/Editable.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Editable\Example;

class Editable{
class Editable {
public static function test() {
$editable = new \Editable\Editable(
[
Expand Down
43 changes: 24 additions & 19 deletions src/Editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ class Editable implements Interfaces\EditableInterface{
*/
public function __construct($row = null, $pk = "id", $hidden = [], $ajax = '')
{
if(!$row)
throw new EditableException(null, EditableException::NO_DATA);
if(!$row) {
throw new EditableException(null, EditableException::NO_DATA);
}

$this->row = $row;
$this->pk = isset($this->row[$pk]) ? $this->row[$pk] : null;
Expand All @@ -110,11 +111,13 @@ public function __construct($row = null, $pk = "id", $hidden = [], $ajax = '')

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

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

foreach($this->row as $key => $value)
$this->input($key, $value);
foreach($this->row as $key => $value) {
$this->input($key, $value);
}
}


Expand All @@ -140,13 +143,13 @@ 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
$this->hidden[$key] = 1;
}
} else {
$this->hidden[$key] = 1;
}

return $this;
}
Expand Down Expand Up @@ -289,7 +292,9 @@ protected function __every_element($each)
}
$value = $each[2];
$show_name = ucfirst(preg_replace_callback('/(_([a-zA-Z0-9]))/', function($a) {
if(isset($a[2])) return ' '.strtoupper($a[2]);
if(isset($a[2])) {
return ' '.strtoupper($a[2]);
}
return $a;
}, $key));
$title = 'Type the '.$show_name;
Expand All @@ -309,7 +314,7 @@ protected function __every_element($each)
} 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;
Expand All @@ -318,9 +323,9 @@ protected function __every_element($each)
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,19 +346,19 @@ protected function __every_element($each)
/**//**//**/}
/**//**//**/if($type == 'select' || $type == 'tag' || $type == 'checklist') {
/**//**//**//**/$this->builder->setDataSource(is_string($each[3])?$each[3]:json_encode($each[3]));
/**//**//**/}else if($type == 'typeaheadjs') {
/**//**//**/} 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
5 changes: 3 additions & 2 deletions src/Integrates/EditableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class EditableException extends \Exception{

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

call_user_func_array([parent::class, __FUNCTION__], func_get_args());
}
Expand Down
8 changes: 4 additions & 4 deletions src/Integrates/EditableResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function __construct($status_code = null, $body = null)
*
* @return int
*/
public function getStatusCode()
{
return $this->status_code;
}
public function getStatusCode()
{
return $this->status_code;
}


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/EditableInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Editable\Interfaces;

interface EditableInterface{
interface EditableInterface {

/**
* 登记输入框
Expand Down