Code style fixes

This commit is contained in:
Dmitry Khomutov 2017-01-13 22:35:41 +07:00
commit 1237bf450c
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
88 changed files with 205 additions and 261 deletions

1
src/B8Framework/Application.php Executable file → Normal file
View file

@ -4,7 +4,6 @@ namespace b8;
use b8\Exception\HttpException\NotFoundException;
use b8\Http;
use b8\View;
use b8\Http\Response;
use b8\Http\Request;

0
src/B8Framework/Cache.php Executable file → Normal file
View file

0
src/B8Framework/Cache/ApcCache.php Executable file → Normal file
View file

0
src/B8Framework/Cache/RequestCache.php Executable file → Normal file
View file

0
src/B8Framework/Config.php Executable file → Normal file
View file

0
src/B8Framework/Controller.php Executable file → Normal file
View file

0
src/B8Framework/Database.php Executable file → Normal file
View file

0
src/B8Framework/Exception/HttpException.php Executable file → Normal file
View file

View file

View file

View file

View file

View file

View file

4
src/B8Framework/Form.php Executable file → Normal file
View file

@ -29,12 +29,12 @@ class Form extends FieldSet
$this->_method = $method;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
$view->action = $this->getAction();
$view->method = $this->getMethod();
parent::_onPreRender($view);
parent::onPreRender($view);
}
public function __toString()

0
src/B8Framework/Form/ControlGroup.php Executable file → Normal file
View file

4
src/B8Framework/Form/Element.php Executable file → Normal file
View file

@ -104,10 +104,10 @@ abstract class Element
$view->ccss = $this->getContainerClass();
$view->parent = $this->_parent;
$this->_onPreRender($view);
$this->onPreRender($view);
return $view->render();
}
abstract protected function _onPreRender(View &$view);
abstract protected function onPreRender(View &$view);
}

4
src/B8Framework/Form/Element/Button.php Executable file → Normal file
View file

@ -11,9 +11,9 @@ class Button extends Input
return true;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->type = 'button';
}
}

12
src/B8Framework/Form/Element/Checkbox.php Executable file → Normal file
View file

@ -21,14 +21,14 @@ class Checkbox extends Input
public function setValue($value)
{
if (is_bool($value) && $value == true) {
$this->_value = $this->getCheckedValue();
if (is_bool($value) && $value === true) {
$this->_value = $this->getCheckedValue();
$this->_checked = true;
return;
}
if ($value == $this->getCheckedValue()) {
$this->_value = $this->getCheckedValue();
$this->_value = $this->getCheckedValue();
$this->_checked = true;
return;
}
@ -37,10 +37,10 @@ class Checkbox extends Input
$this->_checked = false;
}
public function _onPreRender(View &$view)
public function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->checkedValue = $this->getCheckedValue();
$view->checked = $this->_checked;
$view->checked = $this->_checked;
}
}

0
src/B8Framework/Form/Element/CheckboxGroup.php Executable file → Normal file
View file

4
src/B8Framework/Form/Element/Csrf.php Executable file → Normal file
View file

@ -17,9 +17,9 @@ class Csrf extends Hidden
return true;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$csrf = md5(microtime(true));
$view->csrf = $csrf;
setcookie($this->getName(), $csrf);

4
src/B8Framework/Form/Element/Email.php Executable file → Normal file
View file

@ -11,9 +11,9 @@ class Email extends Text
return parent::render(($viewFile ? $viewFile : 'Text'));
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->type = 'email';
}
}

2
src/B8Framework/Form/Element/Hidden.php Executable file → Normal file
View file

@ -2,7 +2,7 @@
namespace b8\Form\Element;
use b8\Form\Input, b8\View;
use b8\Form\Input;
class Hidden extends Input
{

4
src/B8Framework/Form/Element/Password.php Executable file → Normal file
View file

@ -11,9 +11,9 @@ class Password extends Text
return parent::render(($viewFile ? $viewFile : 'Text'));
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->type = 'password';
}
}

0
src/B8Framework/Form/Element/Radio.php Executable file → Normal file
View file

4
src/B8Framework/Form/Element/Select.php Executable file → Normal file
View file

@ -13,9 +13,9 @@ class Select extends Input
$this->_options = $options;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->options = $this->_options;
}
}

4
src/B8Framework/Form/Element/Submit.php Executable file → Normal file
View file

@ -13,9 +13,9 @@ class Submit extends Button
return parent::render(($viewFile ? $viewFile : 'Button'));
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->type = 'submit';
}
}

4
src/B8Framework/Form/Element/Text.php Executable file → Normal file
View file

@ -6,9 +6,9 @@ use b8\Form\Input, b8\View;
class Text extends Input
{
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->type = 'text';
}
}

4
src/B8Framework/Form/Element/TextArea.php Executable file → Normal file
View file

@ -18,9 +18,9 @@ class TextArea extends Text
$this->_rows = $rows;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->rows = $this->getRows();
}
}

4
src/B8Framework/Form/Element/Url.php Executable file → Normal file
View file

@ -11,9 +11,9 @@ class Url extends Text
return parent::render(($viewFile ? $viewFile : 'Text'));
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
parent::_onPreRender($view);
parent::onPreRender($view);
$view->type = 'url';
}
}

2
src/B8Framework/Form/FieldSet.php Executable file → Normal file
View file

@ -70,7 +70,7 @@ class FieldSet extends Element
return $rtn;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
$rendered = [];
foreach ($this->_children as $child) {

2
src/B8Framework/Form/Input.php Executable file → Normal file
View file

@ -107,7 +107,7 @@ class Input extends Element
return $this;
}
protected function _onPreRender(View &$view)
protected function onPreRender(View &$view)
{
$view->value = $this->getValue();
$view->error = $this->_error;

0
src/B8Framework/Form/View/Button.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Checkbox.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/CheckboxGroup.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/ControlGroup.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Csrf.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/FieldSet.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Form.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Hidden.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Radio.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Select.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/Text.phtml Executable file → Normal file
View file

0
src/B8Framework/Form/View/TextArea.phtml Executable file → Normal file
View file

0
src/B8Framework/Http/Request.php Executable file → Normal file
View file

0
src/B8Framework/Http/Response.php Executable file → Normal file
View file

0
src/B8Framework/Http/Response/JsonResponse.php Executable file → Normal file
View file

2
src/B8Framework/Http/Response/RedirectResponse.php Executable file → Normal file
View file

@ -22,6 +22,6 @@ class RedirectResponse extends Response
public function flush()
{
parent::flush();
die;
exit(1);
}
}

0
src/B8Framework/Http/Router.php Executable file → Normal file
View file

10
src/B8Framework/HttpClient.php Executable file → Normal file
View file

@ -64,7 +64,7 @@ class HttpClient
$res['headers'] = $http_response_header;
$res['code'] = (int)preg_replace('/HTTP\/1\.[0-1] ([0-9]+)/', '$1', $res['headers'][0]);
$res['success'] = false;
$res['body'] = $this->_decodeResponse($result);
$res['body'] = $this->decodeResponse($result);
if ($res['code'] >= 200 && $res['code'] < 300) {
$res['success'] = true;
@ -103,13 +103,13 @@ class HttpClient
return $this->request('DELETE', $uri, $params);
}
protected function _decodeResponse($originalResponse)
protected function decodeResponse($originalResponse)
{
$response = $originalResponse;
$body = '';
do {
$line = $this->_readChunk($response);
$line = $this->readChunk($response);
if ($line == PHP_EOL) {
continue;
@ -122,7 +122,7 @@ class HttpClient
}
do {
$data = $this->_readChunk($response, $length);
$data = $this->readChunk($response, $length);
// remove the amount received from the total length on the next loop
// it'll attempt to read that much less data
@ -145,7 +145,7 @@ class HttpClient
return $body;
}
protected function _readChunk(&$string, $len = 4096)
protected function readChunk(&$string, $len = 4096)
{
$rtn = '';
for ($i = 0; $i <= $len; $i++) {

4
src/B8Framework/Image.php Executable file → Normal file
View file

@ -65,7 +65,7 @@ class Image
$sourceRatio = $sourceWidth / $sourceHeight;
$targetRatio = $height != 'auto' ? $width / $height : $sourceRatio;
$quads = $this->_getQuadrants($sourceWidth, $sourceHeight);
$quads = $this->getQuadrants($sourceWidth, $sourceHeight);
foreach($quads as $name => $l)
{
@ -133,7 +133,7 @@ class Image
return $source;
}
protected function _getQuadrants($x, $y)
protected function getQuadrants($x, $y)
{
$rtn = [];
$rtn['top_left'] = [0, $x / 2, 0, $y / 3];

22
src/B8Framework/Model.php Executable file → Normal file
View file

@ -39,13 +39,13 @@ class Model
$rtn = [];
foreach ($sleepable as $property) {
$rtn[$property] = $this->_propertyToArray($property, $currentDepth, $depth);
$rtn[$property] = $this->propertyToArray($property, $currentDepth, $depth);
}
return $rtn;
}
protected function _propertyToArray($property, $currentDepth, $depth)
protected function propertyToArray($property, $currentDepth, $depth)
{
$rtn = null;
@ -54,14 +54,14 @@ class Model
$rtn = $this->{$method}();
if (is_object($rtn) || is_array($rtn)) {
$rtn = ($depth > $currentDepth) ? $this->_valueToArray($rtn, $currentDepth, $depth) : null;
$rtn = ($depth > $currentDepth) ? $this->valueToArray($rtn, $currentDepth, $depth) : null;
}
}
return $rtn;
}
protected function _valueToArray($value, $currentDepth, $depth)
protected function valueToArray($value, $currentDepth, $depth)
{
$rtn = null;
if (!is_null($value)) {
@ -71,7 +71,7 @@ class Model
$childArray = [];
foreach ($value as $k => $v) {
$childArray[$k] = $this->_valueToArray($v, $currentDepth + 1, $depth);
$childArray[$k] = $this->valueToArray($v, $currentDepth + 1, $depth);
}
$rtn = $childArray;
@ -113,19 +113,19 @@ class Model
}
}
protected function _setModified($column)
protected function setModified($column)
{
$this->modified[$column] = $column;
}
protected function _validateString($name, $value)
protected function validateString($name, $value)
{
if (!is_string($value) && !is_null($value)) {
throw new HttpException\ValidationException($name . ' must be a string.');
}
}
protected function _validateInt($name, &$value)
protected function validateInt($name, &$value)
{
if (is_bool($value)) {
$value = $value ? 1 : 0;
@ -140,7 +140,7 @@ class Model
}
}
protected function _validateFloat($name, &$value)
protected function validateFloat($name, &$value)
{
if (!is_numeric($value) && !is_null($value)) {
throw new HttpException\ValidationException($name . ' must be a float.');
@ -151,7 +151,7 @@ class Model
}
}
protected function _validateDate($name, &$value)
protected function validateDate($name, &$value)
{
if (is_string($value)) {
$value = empty($value) ? null : new \DateTime($value);
@ -165,7 +165,7 @@ class Model
$value = empty($value) ? null : $value->format('Y-m-d H:i:s');
}
protected function _validateNotNull($name, &$value)
protected function validateNotNull($name, &$value)
{
if (is_null($value)) {
throw new HttpException\ValidationException($name . ' must not be null.');

0
src/B8Framework/Store.php Executable file → Normal file
View file

0
src/B8Framework/Store/Factory.php Executable file → Normal file
View file

0
src/B8Framework/Type/CacheInterface.php Executable file → Normal file
View file

View file

@ -1,8 +0,0 @@
<?php
namespace b8\Type;
interface RestUser
{
public function checkPermission($permission, $resource);
}

4
src/B8Framework/View.php Executable file → Normal file
View file

@ -2,8 +2,6 @@
namespace b8;
class ViewRuntimeException extends \RuntimeException {}
class View
{
protected $_vars = [];
@ -13,7 +11,7 @@ class View
public function __construct($file, $path = null)
{
if (!self::exists($file, $path)) {
throw new ViewRuntimeException('View file does not exist: ' . $file);
throw new \RuntimeException('View file does not exist: ' . $file);
}
$this->viewFile = self::getViewFile($file, $path);

View file

@ -1,11 +0,0 @@
<?php
namespace b8\View\Helper;
class Format
{
public function Currency($number, $symbol = true)
{
return ($symbol ? '£' : '') . number_format($number, 2, '.', ',');
}
}

0
src/B8Framework/View/Template.php Executable file → Normal file
View file