Skip to content

Commit

Permalink
Merge 066194f into 129ec0d
Browse files Browse the repository at this point in the history
  • Loading branch information
adaamz committed Mar 22, 2019
2 parents 129ec0d + 066194f commit 76839f8
Show file tree
Hide file tree
Showing 60 changed files with 449 additions and 425 deletions.
10 changes: 1 addition & 9 deletions composer.json
Expand Up @@ -12,12 +12,6 @@
"email": "filip@prochazka.su"
}
],
"repositories": [
{
"type": "git",
"url": "https://github.com/CZechBoY/Kdyby-CodingStandard.git"
}
],
"support": {
"email": "filip@prochazka.su",
"issues": "https://github.com/kdyby/events/issues"
Expand All @@ -30,16 +24,14 @@
"kdyby/strict-objects": "^1.0"
},
"require-dev": {
"kdyby/coding-standard": "^1.0@dev",
"kdyby/coding-standard": "^2.0@dev",
"nette/application": "^2.4@dev",
"nette/bootstrap": "^2.4@dev",
"nette/caching": "^2.5@dev",
"nette/security": "^2.4@dev",
"nette/http": "^2.4.7@dev",
"tracy/tracy": "^2.4@dev",

"symfony/event-dispatcher": "^3.0 || ^4.0",

"nette/tester": "2.2.*",
"phpstan/phpstan-shim": "^0.11",
"jakub-onderka/php-parallel-lint": "^1.0"
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Expand Up @@ -3,3 +3,10 @@ parameters:
paths:
- src
- tests/KdybyTests
ignoreErrors:
-
message: '~^$Return type \(void\) of method Kdyby\\Events\\SymfonyDispatcher::dispatch\(\) should be compatible with return type \(Symfony\\Component\\EventDispatcher\\Event\) of method Symfony\\Component\\EventDispatcher\\EventDispatcherInterface::dispatch\\(\\)\\.~'
path: '*/src/Events/SymfonyDispatcher.php'
-
message: '~^Return type \(void\) of method Kdyby\\Events\\SymfonyDispatcher::getListenerPriority\(\) should be compatible with return type \(int\|null\) of method Symfony\\Component\\EventDispatcher\\EventDispatcherInterface::getListener Priority\(\) $~'
path: '*/src/Events/SymfonyDispatcher.php'
15 changes: 8 additions & 7 deletions ruleset.xml
@@ -1,6 +1,13 @@
<?xml version="1.0"?>
<ruleset name="Kdyby/Events">
<rule ref="vendor/kdyby/coding-standard/KdybyCodingStandard/ruleset-5.6.xml"/>
<rule ref="vendor/kdyby/coding-standard/KdybyCodingStandard/ruleset-7.1.xml">
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException"/>
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilitySymbolRequired"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
</rule>

<rule ref="Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase">
<!-- BC -->
Expand All @@ -12,12 +19,6 @@
<exclude-pattern>src/Events/EventManager.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName">
<exclude-pattern>src/Events/EventManager.php</exclude-pattern>
<exclude-pattern>src/Events/Diagnostics/Panel.php</exclude-pattern>
<exclude-pattern>src/Events/LazyEventManager.php</exclude-pattern>
</rule>

<!-- compatibility classes, they're a mess, just ignore them -->
<exclude-pattern>src/Doctrine/*</exclude-pattern>
<exclude-pattern>src/Symfony/*</exclude-pattern>
Expand Down
2 changes: 2 additions & 0 deletions src/Doctrine/aliases.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
Expand Down
2 changes: 2 additions & 0 deletions src/Events/CallableSubscriber.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
Expand Down
49 changes: 20 additions & 29 deletions src/Events/DI/EventsExtension.php
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
Expand Down Expand Up @@ -39,14 +41,14 @@ class EventsExtension extends \Nette\DI\CompilerExtension
use \Kdyby\StrictObjects\Scream;

/** @deprecated */
const EVENT_TAG = self::TAG_EVENT;
public const EVENT_TAG = self::TAG_EVENT;
/** @deprecated */
const SUBSCRIBER_TAG = self::TAG_SUBSCRIBER;
public const SUBSCRIBER_TAG = self::TAG_SUBSCRIBER;

const TAG_EVENT = 'kdyby.event';
const TAG_SUBSCRIBER = 'kdyby.subscriber';
public const TAG_EVENT = 'kdyby.event';
public const TAG_SUBSCRIBER = 'kdyby.subscriber';

const PANEL_COUNT_MODE = 'count';
public const PANEL_COUNT_MODE = 'count';

/**
* @var array
Expand Down Expand Up @@ -76,7 +78,7 @@ class EventsExtension extends \Nette\DI\CompilerExtension
*/
private $allowedManagerSetup = [];

public function loadConfiguration()
public function loadConfiguration(): void
{
$this->listeners = [];
$this->allowedManagerSetup = [];
Expand Down Expand Up @@ -137,7 +139,7 @@ public function loadConfiguration()
$this->loadedConfig = $config;
}

public function beforeCompile()
public function beforeCompile(): void
{
$builder = $this->getContainerBuilder();
$config = $this->loadedConfig;
Expand Down Expand Up @@ -168,7 +170,7 @@ public function beforeCompile()
}
}

public function afterCompile(ClassTypeGenerator $class)
public function afterCompile(ClassTypeGenerator $class): void
{
$init = $class->getMethod('initialize');

Expand Down Expand Up @@ -208,11 +210,9 @@ public function afterCompile(ClassTypeGenerator $class)
}

/**
* @param \Nette\DI\ContainerBuilder $builder
* @param \Nette\DI\ServiceDefinition $manager
* @throws \Nette\Utils\AssertionException
*/
private function validateSubscribers(DIContainerBuilder $builder, ServiceDefinition $manager)
private function validateSubscribers(DIContainerBuilder $builder, ServiceDefinition $manager): void
{
foreach ($manager->getSetup() as $stt) {
if ($stt->getEntity() !== 'addEventSubscriber') {
Expand Down Expand Up @@ -303,18 +303,15 @@ private function validateSubscribers(DIContainerBuilder $builder, ServiceDefinit
}
}

private function isAlias(ServiceDefinition $definition)
private function isAlias(ServiceDefinition $definition): bool
{
return $definition->getFactory() && (
$definition->getEntity() instanceof ServiceDefinition
|| (is_string($definition->getEntity()) && substr($definition->getEntity(), 0, 1) === '@')
);
}

/**
* @param \Nette\DI\ContainerBuilder $builder
*/
private function autowireEvents(DIContainerBuilder $builder)
private function autowireEvents(DIContainerBuilder $builder): void
{
foreach ($builder->getDefinitions() as $def) {
/** @var \Nette\DI\ServiceDefinition $def */
Expand Down Expand Up @@ -345,7 +342,7 @@ private function autowireEvents(DIContainerBuilder $builder)
}
}

protected function bindEventProperties(ServiceDefinition $def, ClassTypeReflection $class)
protected function bindEventProperties(ServiceDefinition $def, ClassTypeReflection $class): void
{
foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
Expand All @@ -370,10 +367,7 @@ protected function bindEventProperties(ServiceDefinition $def, ClassTypeReflecti
}
}

/**
* @param \Nette\DI\ContainerBuilder $builder
*/
private function optimizeListeners(DIContainerBuilder $builder)
private function optimizeListeners(DIContainerBuilder $builder): void
{
$listeners = [];
foreach ($this->listeners as $serviceName => $eventNames) {
Expand Down Expand Up @@ -412,26 +406,23 @@ private function optimizeListeners(DIContainerBuilder $builder)
* @param string|\stdClass $statement
* @return \Nette\DI\Statement[]
*/
private function filterArgs($statement)
private function filterArgs($statement): array
{
return Compiler::filterArguments([is_string($statement) ? new Statement($statement) : $statement]);
}

/**
* @param \Nette\Configurator $configurator
*/
public static function register(Configurator $configurator)
public static function register(Configurator $configurator): void
{
$configurator->onCompile[] = static function ($config, Compiler $compiler) {
$configurator->onCompile[] = static function ($config, Compiler $compiler): void {
$compiler->addExtension('events', new EventsExtension());
};
}

/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
* @param string|NULL $class
* @return \Doctrine\Common\EventSubscriber
*/
private static function createEventSubscriberInstanceWithoutConstructor($class)
private static function createEventSubscriberInstanceWithoutConstructor($class): EventSubscriber
{
if ($class === NULL) {
throw new \InvalidArgumentException('Given class cannot be NULL');
Expand Down

0 comments on commit 76839f8

Please sign in to comment.