Skip to content

Commit 3c7473c

Browse files
author
Anton
authored
Merge pull request #470 from bluzphp/develop
Move `Collection` to independent component Prepare for new version of PHPUnit Updated codestyle
2 parents 624f04f + 9879fbd commit 3c7473c

109 files changed

Lines changed: 416 additions & 809 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: php
22
php:
3-
- 7.1
43
- 7.2
54
- 7.3
65
- master
@@ -31,7 +30,7 @@ script:
3130
- php vendor/bin/phpcs ./src --standard=PSR1,PSR2 --encoding=utf-8
3231
# Complexity of code
3332
- php vendor/bin/phploc ./src
34-
# Run CodeCeption tests
33+
# Run Codeception tests
3534
- php vendor/bin/codecept run --coverage --coverage-xml
3635
after_success:
3736
# Upload coverage report

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"ext-pdo_mysql": "*",
99
"ext-json": "*",
1010
"ext-ctype": "*",
11+
"bluzphp/collection": "~1.0",
1112
"cache/cache": "~1.0",
1213
"psr/log": "~1.0",
1314
"zendframework/zend-diactoros": "~2.1.1",

src/Application/Application.php

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
namespace Bluz\Application;
1212

1313
use Bluz\Application\Exception\ApplicationException;
14+
use Bluz\Config\ConfigException;
1415
use Bluz\Config\ConfigLoader;
1516
use Bluz\Http\Exception\ForbiddenException;
16-
use Bluz\Http\Exception\NotAcceptableException;
17-
use Bluz\Http\Exception\NotAllowedException;
1817
use Bluz\Http\Exception\RedirectException;
1918
use Bluz\Common;
2019
use Bluz\Common\Exception\CommonException;
@@ -32,6 +31,10 @@
3231
use Bluz\Proxy\Translator;
3332
use Bluz\Request\RequestFactory;
3433
use Bluz\Response\Response as ResponseInstance;
34+
use Exception;
35+
use InvalidArgumentException;
36+
use ReflectionClass;
37+
use ReflectionException;
3538
use Zend\Diactoros\ServerRequest;
3639

3740
/**
@@ -42,7 +45,7 @@
4245
* @author Anton Shevchuk
4346
* @created 06.07.11 16:25
4447
*
45-
* @method Controller error(\Exception $exception)
48+
* @method Controller error(Exception $exception)
4649
* @method mixed forbidden(ForbiddenException $exception)
4750
* @method null redirect(RedirectException $url)
4851
*/
@@ -85,17 +88,17 @@ public function getEnvironment(): string
8588
* Get path to Application
8689
*
8790
* @return string
88-
* @throws \ReflectionException
91+
* @throws ReflectionException
8992
*/
9093
public function getPath(): string
9194
{
9295
if (!$this->path) {
93-
if (\defined('PATH_APPLICATION')) {
96+
if (defined('PATH_APPLICATION')) {
9497
$this->path = PATH_APPLICATION;
9598
} else {
96-
$reflection = new \ReflectionClass($this);
99+
$reflection = new ReflectionClass($this);
97100
// 3 level up
98-
$this->path = \dirname($reflection->getFileName(), 3);
101+
$this->path = dirname($reflection->getFileName(), 3);
99102
}
100103
}
101104
return $this->path;
@@ -120,7 +123,7 @@ public function isDebug(): bool
120123
*/
121124
public function useLayout($flag = null): bool
122125
{
123-
if (\is_bool($flag)) {
126+
if (is_bool($flag)) {
124127
$this->layoutFlag = $flag;
125128
}
126129

@@ -166,7 +169,7 @@ public function init($environment = 'production'): void
166169

167170
// init Router
168171
$this->initRouter();
169-
} catch (\Exception $e) {
172+
} catch (Exception $e) {
170173
throw new ApplicationException("Application can't be loaded: " . $e->getMessage());
171174
}
172175
}
@@ -175,8 +178,8 @@ public function init($environment = 'production'): void
175178
* Initial Request instance
176179
*
177180
* @return void
178-
* @throws \Bluz\Config\ConfigException
179-
* @throws \ReflectionException
181+
* @throws ConfigException
182+
* @throws ReflectionException
180183
*/
181184
protected function initConfig(): void
182185
{
@@ -208,7 +211,7 @@ protected function initConfig(): void
208211
* Initial Request instance
209212
*
210213
* @return void
211-
* @throws \InvalidArgumentException
214+
* @throws InvalidArgumentException
212215
*/
213216
protected function initRequest(): void
214217
{
@@ -232,7 +235,7 @@ protected function initResponse(): void
232235
/**
233236
* Get Response instance
234237
*
235-
* @return \Bluz\Response\Response
238+
* @return ResponseInstance
236239
*/
237240
public function getResponse(): ResponseInstance
238241
{
@@ -242,7 +245,7 @@ public function getResponse(): ResponseInstance
242245
/**
243246
* Get Request instance
244247
*
245-
* @return \Zend\Diactoros\ServerRequest
248+
* @return ServerRequest
246249
*/
247250
public function getRequest(): ServerRequest
248251
{
@@ -354,7 +357,7 @@ protected function doProcess(): void
354357
} catch (RedirectException $e) {
355358
// should return `null` for disable output and setup redirect headers
356359
$result = $this->redirect($e);
357-
} catch (\Exception $e) {
360+
} catch (Exception $e) {
358361
// dispatch default error controller
359362
$result = $this->error($e);
360363
}
@@ -386,17 +389,15 @@ protected function postProcess(): void
386389
* Call dispatch from any \Bluz\Package
387390
* Application::getInstance()->dispatch($module, $controller, array $params);
388391
*
389-
* @param string $module
390-
* @param string $controller
391-
* @param array $params
392+
* @param string $module
393+
* @param string $controller
394+
* @param array $params
392395
*
393396
* @return Controller
394-
* @throws ComponentException
395397
* @throws CommonException
398+
* @throws ComponentException
396399
* @throws ControllerException
397-
* @throws ForbiddenException
398-
* @throws NotAcceptableException
399-
* @throws NotAllowedException
400+
* @throws ReflectionException
400401
*/
401402
public function dispatch($module, $controller, array $params = []): Controller
402403
{
@@ -436,11 +437,12 @@ protected function preDispatch($controller): void
436437
/**
437438
* Do dispatch
438439
*
439-
* @param Controller $controller
440+
* @param Controller $controller
440441
*
441442
* @return void
442443
* @throws ComponentException
443444
* @throws ControllerException
445+
* @throws ReflectionException
444446
*/
445447
protected function doDispatch($controller): void
446448
{
@@ -461,7 +463,7 @@ protected function postDispatch($controller): void
461463
}
462464

463465
/**
464-
* Render, is send Response
466+
* Render send Response
465467
*
466468
* @return void
467469
*/
@@ -477,6 +479,6 @@ public function render(): void
477479
*/
478480
public function end(): void
479481
{
480-
// nothing
482+
// nothing by default
481483
}
482484
}

src/Application/Helper/Redirect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ function ($exception) {
3535

3636
if (Request::isXmlHttpRequest()) {
3737
Response::setStatusCode(StatusCode::NO_CONTENT);
38-
Response::setHeader('Bluz-Redirect', (string) $exception->getUrl());
38+
Response::setHeader('Bluz-Redirect', $exception->getUrl());
3939
} else {
4040
Response::setStatusCode(StatusCode::FOUND);
41-
Response::setHeader('Location', (string) $exception->getUrl());
41+
Response::setHeader('Location', $exception->getUrl());
4242
}
4343

4444
return null;

src/Auth/AbstractIdentity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public function hasPrivilege($module, $privilege): bool
4343
{
4444
$privileges = $this->getPrivileges();
4545

46-
return \in_array("$module:$privilege", $privileges, true);
46+
return in_array("$module:$privilege", $privileges, true);
4747
}
4848
}

src/Auth/Model/AbstractTable.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111
namespace Bluz\Auth\Model;
1212

13+
use Bluz\Db\Exception\DbException;
14+
use Bluz\Db\Exception\InvalidPrimaryKeyException;
1315
use Bluz\Db\RowInterface;
1416
use Bluz\Db\Table;
17+
use InvalidArgumentException;
1518

1619
/**
1720
* Abstract class for Auth\Table
@@ -58,9 +61,9 @@ abstract class AbstractTable extends Table
5861
* @param string $foreignKey
5962
*
6063
* @return RowInterface
61-
* @throws \InvalidArgumentException
62-
* @throws \Bluz\Db\Exception\DbException
63-
* @throws \Bluz\Db\Exception\InvalidPrimaryKeyException
64+
* @throws InvalidArgumentException
65+
* @throws DbException
66+
* @throws InvalidPrimaryKeyException
6467
*/
6568
public static function getAuthRow($provider, $foreignKey): ?RowInterface
6669
{

src/Common/Collection.php

Lines changed: 0 additions & 126 deletions
This file was deleted.

src/Common/Container/ArrayAccess.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace Bluz\Common\Container;
1212

13+
use InvalidArgumentException;
14+
1315
/**
1416
* Container implements ArrayAccess
1517
*
@@ -30,12 +32,12 @@ trait ArrayAccess
3032
* @param mixed $offset
3133
* @param mixed $value
3234
*
33-
* @throws \InvalidArgumentException
35+
* @throws InvalidArgumentException
3436
*/
3537
public function offsetSet($offset, $value): void
3638
{
3739
if (null === $offset) {
38-
throw new \InvalidArgumentException('Class `Common\Container\ArrayAccess` support only associative arrays');
40+
throw new InvalidArgumentException('Class `Common\Container\ArrayAccess` support only associative arrays');
3941
}
4042
$this->doSetContainer($offset, $value);
4143
}

0 commit comments

Comments
 (0)