Skip to content

Commit

Permalink
apply php cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Jun 12, 2018
1 parent db153d8 commit 246eecc
Show file tree
Hide file tree
Showing 32 changed files with 209 additions and 209 deletions.
2 changes: 1 addition & 1 deletion examples/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function (ActionEvent $actionEvent): void {
$recordedEvents = $actionEvent->getParam('streamEvents');

foreach ($recordedEvents as $recordedEvent) {
echo sprintf(
echo \sprintf(
"Event with name %s was recorded. It occurred on %s ///\n\n",
$recordedEvent->messageName(),
$recordedEvent->createdAt()->format('Y-m-d H:i:s')
Expand Down
2 changes: 1 addition & 1 deletion src/ActionEventEmitterEventStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function fetchStreamMetadata(StreamName $streamName): array

$metadata = $event->getParam('metadata', false);

if (! is_array($metadata)) {
if (! \is_array($metadata)) {
throw StreamNotFound::with($streamName);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Container/InMemoryEventStoreFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function __callStatic(string $name, array $arguments): ReadOnlyEve
{
if (! isset($arguments[0]) || ! $arguments[0] instanceof ContainerInterface) {
throw new InvalidArgumentException(
sprintf('The first argument must be of type %s', ContainerInterface::class)
\sprintf('The first argument must be of type %s', ContainerInterface::class)
);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public function __invoke(ContainerInterface $container): ReadOnlyEventStore

if (! $plugin instanceof Plugin) {
throw ConfigurationException::configurationError(
sprintf(
\sprintf(
'Plugin %s does not implement the Plugin interface',
$pluginAlias
)
Expand All @@ -125,15 +125,15 @@ public function __invoke(ContainerInterface $container): ReadOnlyEventStore
$plugin->attachToEventStore($wrapper);
}

if (count($config['metadata_enrichers']) > 0) {
if (\count($config['metadata_enrichers']) > 0) {
$metadataEnrichers = [];

foreach ($config['metadata_enrichers'] as $metadataEnricherAlias) {
$metadataEnricher = $container->get($metadataEnricherAlias);

if (! $metadataEnricher instanceof MetadataEnricher) {
throw ConfigurationException::configurationError(
sprintf(
\sprintf(
'Metadata enricher %s does not implement the MetadataEnricher interface',
$metadataEnricherAlias
)
Expand Down
2 changes: 1 addition & 1 deletion src/Container/InMemoryProjectionManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function __callStatic(string $name, array $arguments): InMemoryPro
{
if (! isset($arguments[0]) || ! $arguments[0] instanceof ContainerInterface) {
throw new InvalidArgumentException(
sprintf('The first argument must be of type %s', ContainerInterface::class)
\sprintf('The first argument must be of type %s', ContainerInterface::class)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/StreamExistsAlready.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class StreamExistsAlready extends RuntimeException
public static function with(StreamName $streamName): StreamExistsAlready
{
return new self(
sprintf(
\sprintf(
'A stream with name %s exists already',
$streamName->toString()
)
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/StreamNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class StreamNotFound extends RuntimeException
public static function with(StreamName $streamName): StreamNotFound
{
return new self(
sprintf(
\sprintf(
'A stream with name %s could not be found',
$streamName->toString()
)
Expand Down
46 changes: 23 additions & 23 deletions src/InMemoryEventStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public function create(Stream $stream): void
}

if ($this->inTransaction) {
$this->cachedStreams[$streamNameString]['events'] = iterator_to_array($stream->streamEvents());
$this->cachedStreams[$streamNameString]['events'] = \iterator_to_array($stream->streamEvents());
$this->cachedStreams[$streamNameString]['metadata'] = $stream->metadata();
} else {
$this->streams[$streamNameString]['events'] = iterator_to_array($stream->streamEvents());
$this->streams[$streamNameString]['events'] = \iterator_to_array($stream->streamEvents());
$this->streams[$streamNameString]['metadata'] = $stream->metadata();
}
}
Expand Down Expand Up @@ -153,7 +153,7 @@ public function loadReverse(
$found = 0;
$streamEvents = [];

foreach (array_reverse($this->streams[$streamName->toString()]['events'], true) as $key => $streamEvent) {
foreach (\array_reverse($this->streams[$streamName->toString()]['events'], true) as $key => $streamEvent) {
/* @var Message $streamEvent */
if (($key + 1) <= $fromNumber
&& $this->matchesMetadata($metadataMatcher, $streamEvent->metadata())
Expand Down Expand Up @@ -287,7 +287,7 @@ public function fetchStreamNames(
$streams = $this->streams;

if ($filter
&& array_key_exists($filter, $streams)
&& \array_key_exists($filter, $streams)
&& (
! $metadataMatcher
|| $metadataMatcher && $this->matchesMetadata($metadataMatcher, $streams[$filter]['metadata'])
Expand All @@ -296,7 +296,7 @@ public function fetchStreamNames(
return [$filter];
}

ksort($streams);
\ksort($streams);

foreach ($streams as $streamName => $data) {
if (null === $filter || $filter === $streamName) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public function fetchStreamNamesRegex(
int $limit = 20,
int $offset = 0
): array {
if (false === @preg_match("/$filter/", '')) {
if (false === @\preg_match("/$filter/", '')) {
throw new Exception\InvalidArgumentException('Invalid regex pattern given');
}

Expand All @@ -337,10 +337,10 @@ public function fetchStreamNamesRegex(
$found = 0;

$streams = $this->streams;
ksort($streams);
\ksort($streams);

foreach ($streams as $streamName => $data) {
if (! preg_match("/$filter/", $streamName)) {
if (! \preg_match("/$filter/", $streamName)) {
continue;
}

Expand All @@ -366,10 +366,10 @@ public function fetchCategoryNames(?string $filter, int $limit = 20, int $offset
$skipped = 0;
$found = 0;

$categories = array_unique(array_reduce(
array_keys($this->streams),
$categories = \array_unique(\array_reduce(
\array_keys($this->streams),
function (array $result, string $streamName): array {
if (preg_match('/^(.+)-.+$/', $streamName, $matches)) {
if (\preg_match('/^(.+)-.+$/', $streamName, $matches)) {
$result[] = $matches[1];
}

Expand All @@ -378,11 +378,11 @@ function (array $result, string $streamName): array {
[]
));

if ($filter && in_array($filter, $categories, true)) {
if ($filter && \in_array($filter, $categories, true)) {
return [$filter];
}

ksort($categories);
\ksort($categories);

foreach ($categories as $category) {
if (null === $filter || $filter === $category) {
Expand All @@ -405,7 +405,7 @@ function (array $result, string $streamName): array {

public function fetchCategoryNamesRegex(string $filter, int $limit = 20, int $offset = 0): array
{
if (false === @preg_match("/$filter/", '')) {
if (false === @\preg_match("/$filter/", '')) {
throw new Exception\InvalidArgumentException('Invalid regex pattern given');
}

Expand All @@ -414,10 +414,10 @@ public function fetchCategoryNamesRegex(string $filter, int $limit = 20, int $of
$skipped = 0;
$found = 0;

$categories = array_unique(array_reduce(
array_keys($this->streams),
$categories = \array_unique(\array_reduce(
\array_keys($this->streams),
function (array $result, string $streamName): array {
if (preg_match('/^(.+)-.+$/', $streamName, $matches)) {
if (\preg_match('/^(.+)-.+$/', $streamName, $matches)) {
$result[] = $matches[1];
}

Expand All @@ -426,10 +426,10 @@ function (array $result, string $streamName): array {
[]
));

ksort($categories);
\ksort($categories);

foreach ($categories as $category) {
if (! preg_match("/$filter/", $category)) {
if (! \preg_match("/$filter/", $category)) {
continue;
}

Expand Down Expand Up @@ -490,7 +490,7 @@ private function matchesMessagesProperty(MetadataMatcher $metadataMatcher, Messa
$value = $message->createdAt()->format('Y-m-d\TH:i:s.u');
break;
default:
throw new \UnexpectedValueException(sprintf('Unexpected field "%s" given', $match['field']));
throw new \UnexpectedValueException(\sprintf('Unexpected field "%s" given', $match['field']));
}

if (! $this->match($match['operator'], $value, $match['value'])) {
Expand Down Expand Up @@ -520,7 +520,7 @@ private function match(Operator $operator, $value, $expected): bool
}
break;
case Operator::IN():
if (! in_array($value, $expected, true)) {
if (! \in_array($value, $expected, true)) {
return false;
}
break;
Expand All @@ -540,12 +540,12 @@ private function match(Operator $operator, $value, $expected): bool
}
break;
case Operator::NOT_IN():
if (in_array($value, $expected, true)) {
if (\in_array($value, $expected, true)) {
return false;
}
break;
case Operator::REGEX():
if (! preg_match('/' . $expected . '/', $value)) {
if (! \preg_match('/' . $expected . '/', $value)) {
return false;
}
break;
Expand Down
10 changes: 5 additions & 5 deletions src/Metadata/MetadataMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ private function validateValue(Operator $operator, $value): void
{
if ($operator->is(Operator::IN()) || $operator->is(Operator::NOT_IN())
) {
if (is_array($value)) {
if (\is_array($value)) {
return;
}

throw new InvalidArgumentException(sprintf(
throw new InvalidArgumentException(\sprintf(
'Value must be an array for the operator %s.',
$operator->getName()
));
}

if ($operator->is(Operator::REGEX()) && ! is_string($value)) {
if ($operator->is(Operator::REGEX()) && ! \is_string($value)) {
throw new InvalidArgumentException('Value must be a string for the regex operator.');
}

if (! is_scalar($value)) {
throw new InvalidArgumentException(sprintf(
if (! \is_scalar($value)) {
throw new InvalidArgumentException(\sprintf(
'Value must have a scalar type for the operator %s.',
$operator->getName()
));
Expand Down
Loading

0 comments on commit 246eecc

Please sign in to comment.