Skip to content

Commit

Permalink
Closures made static, comment added
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Feb 28, 2024
1 parent cbf8efd commit cad47cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Attribute/OnEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
public string $event;
public int $priority;

/**
* @param class-string<Event> $event
*/
public function __construct(string $event, int $priority = 0)
{
$this->event = $event;
Expand Down
2 changes: 1 addition & 1 deletion src/LongPollingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setTimeLimit(int $timeLimit): void
public function cunsumeUpdates(): \Generator
{
$start = \hrtime()[0];
$checkTimeLimit = fn() => $this->timeLimit > 0 && \hrtime()[0] - $start >= $this->timeLimit;
$checkTimeLimit = static fn() => $this->timeLimit > 0 && \hrtime()[0] - $start >= $this->timeLimit;

Check failure on line 43 in src/LongPollingService.php

View workflow job for this annotation

GitHub Actions / Tests

InvalidScope

src/LongPollingService.php:43:42: InvalidScope: Invalid reference to $this in a static context (see https://psalm.dev/013)

while (true) {
foreach ($this->getUpdates() as $update) {
Expand Down
4 changes: 2 additions & 2 deletions src/config/compilerpass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function process(ContainerBuilder $container): void
}

// Commands have the highest priority by default
\usort($controllersMap, fn(array $a, array $b) => \str_starts_with($a['value'], '/') ? -1 : 1);
\usort($controllersMap, static fn(array $a, array $b) => \str_starts_with($a['value'], '/') ? -1 : 1);

// Sort by priority
\usort($controllersMap, fn(array $a, array $b) => $b['priority'] <=> $a['priority']);
\usort($controllersMap, static fn(array $a, array $b) => $b['priority'] <=> $a['priority']);

foreach ($controllersMap as $id => $row) {
unset($controllersMap[$id]['priority']);
Expand Down

0 comments on commit cad47cd

Please sign in to comment.