Skip to content

Commit

Permalink
Update dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Jul 27, 2018
1 parent 280bbe7 commit 1109d28
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 26 deletions.
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"require": {
"php": "^7.1.0",
"arachne/service-collections": "^0.1.0 || ^0.2.0",
"contributte/cache": "^0.1.0",
"contributte/cache": "^0.1.0 || ^0.2.0",
"contributte/event-dispatcher-extra": "^0.4.0",
"contributte/event-dispatcher": "^0.3.0 || ^0.4.0",
"nette/application": "^2.4.0",
Expand All @@ -25,15 +25,16 @@
},
"require-dev": {
"arachne/codeception": "^0.8.0",
"codeception/codeception": "^2.3.2",
"codeception/codeception": "^2.4.3",
"eloquent/phony": "^3.0.0",
"eloquent/phony-phpunit": "^4.0.0",
"eloquent/phpstan-phony": "^0.1.0",
"eloquent/phpstan-phony": "^0.3.0",
"friendsofphp/php-cs-fixer": "^2.8.0",
"nette/security": "^2.4.0",
"nextras/secured-links": "^1.3.0",
"phpstan/phpstan": "^0.9.1",
"phpstan/phpstan-nette": "^0.9.0"
"phpstan/phpstan": "^0.10.0",
"phpstan/phpstan-nette": "^0.10.0",
"phpstan/phpstan-strict-rules": "^0.10.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 4 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
includes:
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/eloquent/phpstan-phony/phony.neon
- vendor/arachne/codeception/extension.neon

Expand All @@ -12,6 +13,7 @@ parameters:
- '#^Parameter \$[a-zA-Z]++ of method Tests\\Unit\\Classes\\[a-zA-Z]++::[a-zA-Z]++\(\) has invalid typehint type Tests\\Unit\\Classes\\[a-zA-Z0-9]++#'
- '#^Property Tests\\Unit\\Classes\\[a-zA-Z]++::\$[a-zA-Z0-9]++ has unknown class Tests\\Unit\\Classes\\[a-zA-Z0-9]++ as its type#'
- '#^Return typehint of method Tests\\Unit\\Classes\\TestPresenter::createComponentNonexistentComponent\(\) has invalid type Tests\\Unit\\Classes\\NonexistentComponent#'
- '#^Cannot clone non-object variable \$request of type Nette\\Application\\Request\|null#'
- '#^Method Nette\\Http\\Session::setExpiration\(\) invoked with 2 parameters, 1 required#'
- '#^Access to an undefined property object::\$value#'
- '#^Method Tests\\Unit\\Classes\\TestPresenter::#'
- '#^Method Tests\\Functional\\Fixtures\\ArticlePresenter::#'
- '#^Strict comparison using !== between ReflectionType and null will always evaluate to true#'
9 changes: 5 additions & 4 deletions src/Application/EntityLoaderPresenterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ final public function injectEntityLoader(RequestEntityLoader $loader, RequestEnt
/**
* Stores request to session.
*
* @param Request|null $request
* @param mixed $expiration
* @param mixed $request
* @param mixed $expiration
*
* @return string
*/
Expand All @@ -55,6 +55,7 @@ public function storeRequest($request = null, $expiration = '+ 10 minutes'): str
$request = $this->getRequest();
}

assert($request instanceof Request);
$request = clone $request;
$this->unloader->filterOut($request);

Expand All @@ -63,7 +64,7 @@ public function storeRequest($request = null, $expiration = '+ 10 minutes'): str
$key = Random::generate(5);
} while (isset($session[$key]));

$session[$key] = [$this->user ? $this->user->getId() : null, $request];
$session[$key] = [$this->user !== null ? $this->user->getId() : null, $request];
$session->setExpiration($expiration, $key);

return $key;
Expand All @@ -77,7 +78,7 @@ public function storeRequest($request = null, $expiration = '+ 10 minutes'): str
public function restoreRequest($key): void
{
$session = $this->getSession('Arachne.Application/requests');
if (!isset($session[$key]) || ($this->user && $session[$key][0] !== null && $session[$key][0] !== $this->user->getId())) {
if (!isset($session[$key]) || ($this->user !== null && $session[$key][0] !== null && $session[$key][0] !== $this->user->getId())) {
return;
}
$request = clone $session[$key][1];
Expand Down
16 changes: 8 additions & 8 deletions src/Application/ParameterFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ private function loadMapping(string $presenter, array $parameters, array &$depen
$action = isset($parameters[Presenter::ACTION_KEY]) ? $parameters[Presenter::ACTION_KEY] : Presenter::DEFAULT_ACTION;
$method = 'action'.$action;
$element = $presenterReflection->hasCallableMethod($method) ? $presenterReflection->getMethod($method) : null;
if (!$element) {
if ($element === null) {
$method = 'render'.$action;
$element = $presenterReflection->hasCallableMethod($method) ? $presenterReflection->getMethod($method) : null;
}
if ($element) {
if ($element !== null) {
$info += $this->getMethodParameters($element);
$files[] = $element->getFileName();
}
Expand All @@ -106,7 +106,7 @@ private function loadMapping(string $presenter, array $parameters, array &$depen
}
$reflection = $this->createReflection($presenterReflection, $component);
$components[$component] = true;
if (!$reflection) {
if ($reflection === null) {
continue;
}
$files[] = $reflection->getFileName();
Expand All @@ -127,7 +127,7 @@ private function loadMapping(string $presenter, array $parameters, array &$depen
$prefix = '';
}
$method = 'handle'.ucfirst($signal);
if ($reflection && $reflection->hasCallableMethod($method)) {
if ($reflection !== null && $reflection->hasCallableMethod($method)) {
$element = $reflection->getMethod($method);
$info += $this->getMethodParameters($element, $prefix);
$files[] = $element->getFileName();
Expand Down Expand Up @@ -159,7 +159,7 @@ private function createReflection(ReflectionClass $reflection, string $component
if ($reflection->hasMethod($method)) {
$element = $reflection->getMethod($method);
$type = $element->getReturnType();
if (!$type) {
if ($type === null) {
throw new TypeHintException(sprintf('Method %s::%s has no return type.', $reflection->name, $method));
}
if ($type->isBuiltin()) {
Expand All @@ -183,7 +183,7 @@ private function getMethodParameters(ReflectionMethod $reflection, string $prefi
{
$info = [];
foreach ($reflection->getParameters() as $parameter) {
$type = $parameter->getType() ? (string) $parameter->getType() : 'mixed';
$type = $parameter->getType() !== null ? (string) $parameter->getType() : 'mixed';
$optional = $parameter->isOptional();
$info[$prefix.$parameter->getName()] = $this->createInfoObject($type, $optional);
}
Expand All @@ -198,8 +198,8 @@ private function getPersistentParameters(ComponentReflection $reflection, string
$parameter = new ReflectionProperty($reflection->getName(), $persistent);
if (!$parameter->isStatic()) {
$type = (string) PhpReflection::parseAnnotation($parameter, 'var');
if ($type) {
if (!Strings::match($type, '/^[[:alnum:]_\\\\]++$/')) {
if ($type !== '') {
if (!(bool) Strings::match($type, '/^[[:alnum:]_\\\\]++$/')) {
throw new TypeHintException(sprintf('Type hint "%s" is not valid. Only alphanumeric characters, "_" and "\" are allowed.', $type));
}
$info[$prefix.$persistent] = $this->createInfoObject($this->normalizeType($type, $parameter->getDeclaringClass()), true);
Expand Down
9 changes: 6 additions & 3 deletions src/DI/EntityLoaderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ class EntityLoaderExtension extends CompilerExtension
const TAG_FILTER_OUT = 'arachne.entityLoader.filterOut';

/**
* @var array
* @var mixed[]
*/
public $defaults = [
'envelopes' => false,
];

/**
* @var string[]
*/
private $filters = [
ArrayFilterIn::class => 'array',
BooleanFilterIn::class => 'bool',
Expand Down Expand Up @@ -118,7 +121,7 @@ public function beforeCompile(): void

$router = $builder->getByType(IRouter::class);

if ($router) {
if ($router !== null) {
$routerDefinition = $builder->getDefinition($router);

if ($routerDefinition->getClass() !== RouterWrapper::class) {
Expand All @@ -140,7 +143,7 @@ private function getExtension(string $class): CompilerExtension
{
$extensions = $this->compiler->getExtensions($class);

if (!$extensions) {
if ($extensions === []) {
throw new AssertionException(
sprintf('Extension "%s" requires "%s" to be installed.', get_class($this), $class)
);
Expand Down
6 changes: 4 additions & 2 deletions src/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
class Route extends BaseRoute
{
/**
* {@inheritdoc}
* @param string $mask
* @param mixed $metadata
* @param int $flags
*/
public function __construct($mask, $metadata = [], $flags = 0)
{
// Copied from Nette\Application\Routers\Route::__construct().
if (is_string($metadata)) {
$pos = strrpos($metadata, ':');
if (!$pos) {
if ($pos === false) {
throw new InvalidArgumentException(sprintf('Second argument must be array or string in format Presenter:action, %s given.', $metadata));
}
$metadata = [
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/src/Fixtures/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
*/
class Article
{
/**
* @var mixed
*/
private $value;

/**
* @param mixed $value
*/
public function __construct($value)
{
$this->value = $value;
}

/**
* @return mixed
*/
public function getValue()
{
return $this->value;
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/src/Fixtures/ArticleFilterIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public function supports(string $type): bool
return $type === Article::class;
}

public function filterIn($value, string $type)
/**
* {@inheritdoc}
*/
public function filterIn($value, string $type): Article
{
return new Article($value);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/src/Fixtures/ArticleFilterOut.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function supports(string $class): bool
return $class === Article::class;
}

/**
* {@inheritdoc}
*/
public function filterOut($value)
{
if (!$value instanceof Article) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testGlobalFilterOut(): void
/**
* @return object
*/
private function createObject($value)
private function createObject(string $value)
{
return (object) ['value' => $value];
}
Expand Down

0 comments on commit 1109d28

Please sign in to comment.