Skip to content

Commit

Permalink
Merge pull request #154 from cygnite/analysis-qo0JwP
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
sanjoydesk committed Mar 14, 2017
2 parents 6413b18 + ad04372 commit b3a7347
Show file tree
Hide file tree
Showing 33 changed files with 37 additions and 73 deletions.
4 changes: 2 additions & 2 deletions src/Cygnite/Bootstrappers/Bootstrapper.php
Expand Up @@ -21,7 +21,7 @@ class Bootstrapper
* Constructor
* @param Paths $paths The paths to various folders
*/
public final function __construct(Paths $paths)
final public function __construct(Paths $paths)
{
$this->paths = $paths;
}
Expand Down Expand Up @@ -58,4 +58,4 @@ public function all() : array
{
return $this->bootstrappers;
}
}
}
2 changes: 1 addition & 1 deletion src/Cygnite/Bootstrappers/BootstrapperDispatcher.php
Expand Up @@ -68,4 +68,4 @@ public function create(string $class) : BootstrapperInterface

return $this->instances[$class];
}
}
}
Expand Up @@ -6,4 +6,4 @@ interface BootstrapperDispatcherInterface
public function execute();

public function create(string $class);
}
}
2 changes: 1 addition & 1 deletion src/Cygnite/Bootstrappers/BootstrapperInterface.php
Expand Up @@ -9,4 +9,4 @@ interface BootstrapperInterface
*
*/
public function run();
}
}
2 changes: 1 addition & 1 deletion src/Cygnite/Bootstrappers/Paths.php
Expand Up @@ -69,4 +69,4 @@ public function all() : array
{
return $this->paths;
}
}
}
4 changes: 2 additions & 2 deletions src/Cygnite/Common/UrlManager/Url.php
Expand Up @@ -40,7 +40,7 @@ public function __construct(Manager $urlManager)
*/
public static function __callStatic($method, $arguments = [])
{
if (method_exists(static::$urlManager, $method)){
if (method_exists(static::$urlManager, $method)) {
return call_user_func_array([static::$urlManager, $method], $arguments);
}

Expand All @@ -53,7 +53,7 @@ public static function __callStatic($method, $arguments = [])
*/
public function __call($method, $arguments)
{
if (method_exists(static::$urlManager, $method)){
if (method_exists(static::$urlManager, $method)) {
return call_user_func_array([static::$urlManager, $method], $arguments);
}

Expand Down
1 change: 0 additions & 1 deletion src/Cygnite/Container/Container.php
Expand Up @@ -588,6 +588,5 @@ public function makeInstance(string $namespace, $arguments = [])
*/
public function createProxy($namespace)
{

}
}
2 changes: 1 addition & 1 deletion src/Cygnite/Container/ContainerAwareInterface.php
Expand Up @@ -18,7 +18,7 @@
*/
interface ContainerAwareInterface
{
/**
/**
* Set value to container.
*
* @param $key
Expand Down
1 change: 0 additions & 1 deletion src/Cygnite/Container/Dependency/Builder.php
Expand Up @@ -167,7 +167,6 @@ public function propertyInjection($classInstance, $controller)
$controller = "\\\\";

if (array_key_exists($controller, $this->definitions)) {

list($reflection, $reflectionClass) = $this->setReflectionClassAttributes($controller);

foreach ($dependencies as $classProperty => $class) {
Expand Down
2 changes: 1 addition & 1 deletion src/Cygnite/Container/Injector.php
Expand Up @@ -99,4 +99,4 @@ public function setContainer($container)

return $this;
}
}
}
7 changes: 3 additions & 4 deletions src/Cygnite/FormBuilder/Form.php
Expand Up @@ -144,7 +144,7 @@ public function addElement(string $type, string $key, array $array = []) : FormI

if ($type == 'openTag') {
$key = $key.'_'.mt_rand(1, 2000);
} else if ($type == 'closeTag') {
} elseif ($type == 'closeTag') {
$key = $key.'_'.mt_rand(2000, 4000);
}

Expand Down Expand Up @@ -174,18 +174,17 @@ public function addElements(array $elements = []) : FormInterface
public function createForm() : FormInterface
{
foreach ($this->value as $key => $val) {

if (in_array($val['type'], $this->validMethods)) {
$method = $val['type'];
unset($val['type']);
(!method_exists($this, $method)) ?: $this->{$method}($key, $val);
} else {
$this->input($key, $val);
$this->input($key, $val);
}

if (isset($val['type']) && in_array($val['type'], $this->validArray)) {
$this->setValidationError($key, $val);
} else if (!isset($val['type']) && in_array($method, $this->validArray)) {
} elseif (!isset($val['type']) && in_array($method, $this->validArray)) {
$this->setValidationError($key, $val);
}
}
Expand Down
9 changes: 2 additions & 7 deletions src/Cygnite/FormBuilder/Html/Elements.php
Expand Up @@ -157,12 +157,10 @@ private function composeElement($key, $attributes, $extra = [], $hasCloseTag = f

$val = '';
if ($hasCloseTag) {

if (is_object($this->entity)) {

if (method_exists($this->entity, 'get'.Inflector::camelize($key))) {
$val = $this->entity->{'get'.Inflector::camelize($key)}();
} else if (property_exists($this->entity, $key)) {
} elseif (property_exists($this->entity, $key)) {
$property = (new \ReflectionClass($this->entity))->getProperty($key);
if ($property->isPublic()) {
$val = $property->getValue();
Expand Down Expand Up @@ -288,9 +286,7 @@ protected function attributes($attributes)
$elementStr = '';

foreach ($attributes as $key => $value) {

$elementStr .= ($key !== 0) ? "{$key}='{$value}' " : $value;

$elementStr .= ($key !== 0) ? "{$key}='{$value}' " : $value;
}

return $elementStr;
Expand Down Expand Up @@ -336,7 +332,6 @@ protected function highlightErrorElement($key, $attributes)
$this->validator instanceof ValidatorInterface &&
$this->validator->hasError($key)
) {

preg_match_all("#class='([^\s]+)'#", $this->attributes($attributes), $matches);
$elClass = "class='".implode(' ', array_merge([$this->errorInputClass], $matches[1]))."'";
unset($attributes['class']);
Expand Down
4 changes: 2 additions & 2 deletions src/Cygnite/Foundation/Application.php
Expand Up @@ -437,7 +437,7 @@ public function attachEvents()
*/
public function beforeBootingApplication()
{
if (!$this->activateEventMiddleWare() ) {
if (!$this->activateEventMiddleWare()) {
return false;
}

Expand All @@ -458,7 +458,7 @@ public function beforeBootingApplication()
*/
public function afterBootingApplication()
{
if (!$this->activateEventMiddleWare() ) {
if (!$this->activateEventMiddleWare()) {
return false;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Cygnite/Foundation/Http/Kernel.php
Expand Up @@ -64,7 +64,7 @@ public function setRouter($request)
$this->container->set('request', $request);
$this->container->make(\Cygnite\Router\Router::class);
$this->container->get('router')->setRequest($request);
$this->router = $this->container->get('router');
$this->router = $this->container->get('router');
}

/**
Expand Down Expand Up @@ -169,7 +169,6 @@ public function getMiddleware() : array

public function registerBootstrappers()
{

}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Cygnite/Mvc/Controller/ServiceController.php
Expand Up @@ -28,7 +28,6 @@ class ServiceController extends AbstractBaseController implements ServiceControl

public function __construct()
{

}


Expand Down
1 change: 0 additions & 1 deletion src/Cygnite/Mvc/View/Composer.php
Expand Up @@ -209,7 +209,6 @@ public function template($view, array $param = [], $return = false)
| then we will render twig template with parameters
*/
if (is_object(static::$twigEnvironment) && is_object($this->get('twig_template'))) {

return ($return) ?
$this->get('twig_template')->render($param) :
$this->get('twig_template')->display($param);
Expand Down
3 changes: 1 addition & 2 deletions src/Cygnite/Mvc/View/View.php
Expand Up @@ -27,7 +27,7 @@
*
* @author Sanjoy Dey <dey.sanjoy0@gmail.com>
*/
class View extends Composer implements ViewInterface,\ArrayAccess
class View extends Composer implements ViewInterface, \ArrayAccess
{
use ControllerViewBridgeTrait;

Expand Down Expand Up @@ -467,7 +467,6 @@ public function widget() : Widget
public function createAssetCollection($class) : Asset
{
$a = AssetCollection::make($this->getContainer(), function ($collection) use ($class) {

(new $class($collection->asset()))->register();

return $collection->asset();
Expand Down
3 changes: 2 additions & 1 deletion src/Cygnite/Mvc/View/Widget.php
Expand Up @@ -135,7 +135,8 @@ protected function setupModule()
if (string_has($this->getWidgetName(), ':')) {
$exp = [];
$exp = explode(':', $this->getWidgetName());
$moduleName = $exp[0]; $view = $exp[1];
$moduleName = $exp[0];
$view = $exp[1];
$path = $this->getWidgetPath($view, $moduleName, true);
$this->setWidgetName(null);
$this->setModule(false);
Expand Down
8 changes: 5 additions & 3 deletions src/Cygnite/Router/Router.php
Expand Up @@ -14,7 +14,9 @@
use Cygnite\Pipeline\Pipeline;
use Cygnite\Http\Requests\Request;
use Cygnite\Container\ContainerAwareInterface;
use Cygnite\Router\Controller\{ControllerController, RouteController, ResourceController};
use Cygnite\Router\Controller\ControllerController;
use Cygnite\Router\Controller\RouteController;
use Cygnite\Router\Controller\ResourceController;

/*
* Cygnite Router
Expand Down Expand Up @@ -72,7 +74,8 @@ class Router implements RouterInterface
private $afterRouter;
private $routeBasePath = '';
private $after = [];
protected $resourceController, $routeController;
protected $resourceController;
protected $routeController;
protected $middleware;

/**
Expand Down Expand Up @@ -792,7 +795,6 @@ public function dispatch($request)
$this->getCurrentUri() == '/' . self::$indexPage
) {
if ($defaultController != '') {

$this->getRouteControllerInstance();

list($controller, $action) = $this->getControllerAndAction(
Expand Down
6 changes: 3 additions & 3 deletions src/Cygnite/Validation/Validator.php
Expand Up @@ -167,7 +167,7 @@ public function run()
// Executes rule for min and max validation.
if (string_has($rule, ':') && strstr($rule, 'max') || strstr($rule, 'min')) {
$isValid = $this->doValidateMinMax($rule, $key, $isValid);
} else if (string_has($rule, ':') && (!strstr($rule, 'max') && !strstr($rule, 'min'))) {
} elseif (string_has($rule, ':') && (!strstr($rule, 'max') && !strstr($rule, 'min'))) {
// Executes rule for other than min, max validation with ":" keyword in rule.
$isValid = $this->validateRulesHasPlaceHolder($key, $rule, $isValid);
} else {
Expand Down Expand Up @@ -287,7 +287,7 @@ protected function required(string $key) : bool
ucfirst($this->convertToFieldName($key)).' is required';

return false;
} else if (is_array($val) && count($val) < 1) {
} elseif (is_array($val) && count($val) < 1) {
$this->errors[$key.self::ERROR] =
ucfirst($this->convertToFieldName($key)).' is required';

Expand Down Expand Up @@ -777,7 +777,7 @@ protected function isDate($key) : bool
if ((!is_string($value) && !is_numeric($value)) || strtotime($value) === false) {
$this->errors[$key.self::ERROR] = $this->convertToFieldName($key).' must be a valid date.';
return false;
} else if (checkdate($date['month'], $date['day'], $date['year'])) {
} elseif (checkdate($date['month'], $date['day'], $date['year'])) {
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Cygnite/Alias/AliasManagerTest.php
Expand Up @@ -56,5 +56,3 @@ public function testRemoveMethod()
$this->assertFalse($alias->has('bar'));
}
}


4 changes: 2 additions & 2 deletions tests/Cygnite/AssetManager/AssetTest.php
Expand Up @@ -54,8 +54,8 @@ public function testStaticCallToJsScript()
public function testStaticCallToCss()
{
$css = $this->asset->style('public/assets/cygnite.css', 'static');
$this->assertEquals(trim(preg_replace('/\s+/',' ', '<link rel="stylesheet" type="text/css" static
title= "" href="http://localhost/cygnite/public/assets/cygnite.css" />')), trim(preg_replace('/\s+/',' ', $css)));
$this->assertEquals(trim(preg_replace('/\s+/', ' ', '<link rel="stylesheet" type="text/css" static
title= "" href="http://localhost/cygnite/public/assets/cygnite.css" />')), trim(preg_replace('/\s+/', ' ', $css)));
}


Expand Down
3 changes: 0 additions & 3 deletions tests/Cygnite/Bootstrappers/BootstrapperDispatcherTest.php
Expand Up @@ -20,7 +20,6 @@ public function setUp()

public function testPathInstance()
{

$bootDispatcher = $this->getMockBuilder('Cygnite\Bootstrappers\BootstrapperDispatcher')->setConstructorArgs([$this->container, new Paths([])])->getMock();
$this->assertInstanceOf('Cygnite\Bootstrappers\BootstrapperDispatcher', $bootDispatcher);
}
Expand Down Expand Up @@ -49,5 +48,3 @@ public function testBootstrapperDispatcherReturnsBootstrapperObject()
$this->assertInstanceOf('\Cygnite\Bootstrappers\Bootstrapper', $dispatcher->getBootstrapper());
}
}


2 changes: 0 additions & 2 deletions tests/Cygnite/Bootstrappers/BootstrapperTest.php
Expand Up @@ -34,5 +34,3 @@ public function testReturnsPathsObject()
$this->assertInstanceof(\Cygnite\Bootstrappers\Paths::class, $bootstrapper->getPaths());
}
}


4 changes: 0 additions & 4 deletions tests/Cygnite/Bootstrappers/PathsTest.php
Expand Up @@ -32,8 +32,4 @@ public function testAllMethodReturnsArrayOfPaths()
"baz" => 'baz bar'
], $p->all());
}


}


2 changes: 0 additions & 2 deletions tests/Cygnite/Common/EncryptTest.php
Expand Up @@ -12,9 +12,7 @@ class EncryptTest extends TestCase

public function setUp()
{

if (version_compare(PHP_VERSION, '7.0.0') <= 0) {

$this->markTestSkipped(
'mcrypt_create_iv() function deprecated in PHP 7.1'
);
Expand Down
4 changes: 0 additions & 4 deletions tests/Cygnite/Console/Commands/GreetCommand.php
Expand Up @@ -54,8 +54,4 @@ public function process()

$this->info("Hello $name!!".PHP_EOL);
}

}



3 changes: 0 additions & 3 deletions tests/Cygnite/Console/ConsoleApplicationTest.php
Expand Up @@ -42,6 +42,3 @@ public function resetCommandStack()
$this->commandsStack = [];
}
}



0 comments on commit b3a7347

Please sign in to comment.