Skip to content

Commit

Permalink
log level changes; static analize
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasiukevich committed Aug 14, 2018
1 parent 3aa9f03 commit 1ff9683
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 17 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"require": {
"php": ">=7.2",
"ext-amqp": "*",
"amphp/amp": "^2.0",
"amphp/log": "^1",
"amphp/file": "^0.3",
Expand Down
2 changes: 2 additions & 0 deletions src/Application/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public function addExtensions(Extension ...$extensions): self
}

/**
* @noinspection PhpDocSignatureInspection
*
* @param CompilerPassInterface ...$compilerPassInterfaces
*
* @return $this
Expand Down
8 changes: 5 additions & 3 deletions src/Application/ServiceBusKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ private function buildMessageBus(ContainerInterface $globalContainer): MessageBu
/** @var MessageBusBuilder $messagesBusBuilder */
$messagesBusBuilder = $this->kernelContainer->get(MessageBusBuilder::class);

/** @psalm-suppress UndefinedMethod */
$this->registerServices(
$globalContainer->getParameter('service_bus.services_map'),
$messagesBusBuilder,
$globalContainer->get(self::SERVICES_LOCATOR)
);

/** @psalm-suppress UndefinedMethod */
$this->registerSagas(
$globalContainer->getParameter('service_bus.sagas'),
$messagesBusBuilder
Expand Down Expand Up @@ -179,7 +181,7 @@ private function registerServices(
}

/**
* Reguster sagas listeners
* Register sagas listeners
*
* @param array $sagas
* @param MessageBusBuilder $messageBusBuilder
Expand Down Expand Up @@ -338,7 +340,7 @@ private static function createOutboundEnvelope(
*/
private static function beforeDispatch(IncomingEnvelope $envelope, LoggerInterface $logger): void
{
$logger->info('Dispatching the message "{messageClass}"', [
$logger->debug('Dispatching the message "{messageClass}"', [
'messageClass' => \get_class($envelope->denormalized()),
'operationId' => $envelope->operationId(),
]
Expand Down Expand Up @@ -403,7 +405,7 @@ private static function beforeMessageSend(
OutboundEnvelope $outboundEnvelope
): void
{
$logger->info(
$logger->debug(
'Sending a "{messageClass}" message to "{destinationTopic}/{destinationRoutingKey}"', [
'messageClass' => $messageClass,
'destinationTopic' => $destination->topicName(),
Expand Down
4 changes: 4 additions & 0 deletions src/Application/TransportConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function __construct(Transport $transport, OutboundMessageRoutes $outboun
* Configure default destinations
* In them, messages will be sent regardless of the availability of individual routes
*
* @noinspection PhpDocSignatureInspection
*
* @param Destination ...$destinations
*
* @return $this
Expand All @@ -66,6 +68,8 @@ public function addDefaultDestinations(Destination ...$destinations): self
/**
* Add directions for a specific message (in addition to the default directions)
*
* @noinspection PhpDocSignatureInspection
*
* @param string $message
* @param Destination ...$destinations
*
Expand Down
13 changes: 8 additions & 5 deletions src/DependencyInjection/Compiler/ServicesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ public function process(ContainerBuilder $container): void
{
$serviceClass = $container->getDefinition($id)->getClass();

$this->collectServiceDependencies($serviceClass, $container, $servicesReference);
if(null !== $serviceClass)
{
$this->collectServiceDependencies($serviceClass, $container, $servicesReference);

$serviceIds[] = $serviceClass;
$serviceIds[] = $serviceClass;

$servicesReference[\sprintf('%s_service', $serviceClass)] = new ServiceClosureArgument(
new Reference($id)
);
$servicesReference[\sprintf('%s_service', $serviceClass)] = new ServiceClosureArgument(
new Reference($id)
);
}
}

$container->setParameter('service_bus.services_map', $serviceIds);
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/ContainerBuilder/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public function __construct(string $entryPointName, Environment $environment)
/**
* Add customer compiler pass
*
* @noinspection PhpDocSignatureInspection
*
* @param CompilerPassInterface ...$compilerPasses
*
* @return void
Expand All @@ -105,6 +107,8 @@ public function addCompilerPasses(CompilerPassInterface ...$compilerPasses): voi
/**
* Add customer extension
*
* @noinspection PhpDocSignatureInspection
*
* @param Extension ...$extensions
*
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ final class ContainerCompilerPassCollection implements \IteratorAggregate
private $collection = [];

/**
* @noinspection PhpDocSignatureInspection
*
* @param CompilerPassInterface ...$compilerPasses
*
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ final class ContainerExtensionCollection implements \IteratorAggregate
private $collection = [];

/**
* @noinspection PhpDocSignatureInspection
*
* @param Extension ...$extensions
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion src/EventSourcingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ private static function restoreStream(

if(null === $aggregate)
{
/** @var Aggregate $aggregate */
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
/** @var Aggregate $aggregate */
$aggregate = createWithoutConstructor($storedEventStream->aggregateClass());
}

Expand Down
5 changes: 5 additions & 0 deletions src/MessageBus/MessageBusBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public function __construct(
/**
* Add saga listeners to messages bus
*
* @noinspection PhpDocSignatureInspection
*
* @param string $sagaClass
* @param ArgumentResolver ...$argumentResolvers
*
* @return void
*
Expand All @@ -93,6 +96,8 @@ public function addSaga(string $sagaClass, ArgumentResolver ... $argumentResolve
/**
* Add service messages (command\event) handlers
*
* @noinspection PhpDocSignatureInspection
*
* @param object $service
* @param ArgumentResolver ...$argumentResolvers
*
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Configuration/ServiceHandlersLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface ServiceHandlersLoader
/**
* Load specified saga listeners
*
* @param string $sagaClass
* @param object $service
*
* @return HandlerCollection
*
Expand Down
1 change: 0 additions & 1 deletion src/Storage/SQL/AmpPostgreSQL/AmpPostgreSQLAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Desperado\ServiceBus\Storage\SQL\AmpPostgreSQL;

use function Amp\call;
use Amp\Postgres\Connection;
use Amp\Postgres\ConnectionConfig;
use function Amp\Postgres\pool;
use Amp\Postgres\Pool;
Expand Down
3 changes: 2 additions & 1 deletion src/Storage/SQL/DoctrineDBAL/DoctrineDBALResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ final class DoctrineDBALResultSet implements ResultSet
private $connection;

/**
* @param Statement $wrappedStmt
* @param Connection $connection
* @param Statement $wrappedStmt
*/
public function __construct(Connection $connection, Statement $wrappedStmt)
{
Expand Down
15 changes: 10 additions & 5 deletions src/Storage/SQL/queryBuilderFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ function getObjectVars(object $object): array
$closure = \Closure::bind(
function(): array
{
/** @psalm-suppress InvalidScope */
return \get_object_vars($this);
},
$object,
Expand All @@ -188,6 +189,7 @@ function toSnakeCase(string $string): string
* @param string $key
* @param mixed $value
*
* @psalm-return scalar|null
* @return int|float|null|string
*
* @throws \LogicException
Expand Down Expand Up @@ -219,15 +221,18 @@ function cast(string $key, $value)
* @param object $object
*
* @return string
*
* @throws \LogicException
*/
function castObjectToString(object $object): string
{
if(false === \method_exists($object, '__toString'))
if(true === \method_exists($object, '__toString'))
{
throw new \LogicException(
\sprintf('"%s" must implements "__toString" method', \get_class($object))
);
/** @psalm-suppress InvalidCast */
return (string) $object;
}

return (string) $object;
throw new \LogicException(
\sprintf('"%s" must implements "__toString" method', \get_class($object))
);
}

0 comments on commit 1ff9683

Please sign in to comment.