Skip to content

Commit

Permalink
more phpstan 2.0 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Dec 12, 2024
1 parent 161d90e commit 6e709e8
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/imageboard/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static function implode(array $tags): string
/**
* Turn a human-supplied string into a valid tag array.
*
* @return string[]
* @return list<string>
*/
public static function explode(string $tags, bool $tagme = true): array
{
Expand Down
2 changes: 1 addition & 1 deletion ext/index/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(int $id, ?string $term = null, array $context = [])

if ($term !== null) {
// pull any operands off the start of the search term
while (is_string($term) && !empty($term) && array_key_exists($term[0], TAG_OPERANDS)) {
while (!empty($term) && array_key_exists($term[0], TAG_OPERANDS)) {
$operand = TAG_OPERANDS[$term[0]];
$term = substr($term, 1);
$this->$operand = true;
Expand Down
3 changes: 0 additions & 3 deletions ext/ouroboros_api/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,6 @@ protected function postIndex(int $limit, int $page, array $tags): void
$results = Search::find_images(max($start, 0), min($limit, 100), $tags);
$posts = [];
foreach ($results as $img) {
if (!is_object($img)) {
continue;
}
$posts[] = new _SafeOuroborosImage($img);
}
$this->sendData('post', $posts, max($start, 0));
Expand Down
2 changes: 1 addition & 1 deletion ext/post_tags/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function matches(string $regex): ?array
{
$matches = [];
if (\Safe\preg_match($regex, $this->term, $matches) === 1) {
return $matches;
return array_values($matches);
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/random_image/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testRandom(): void
$this->assertEquals("Post $image_id: test", $page->title);

$page = $this->get_page("random_image/download");
$this->assertNotNull($page->data);
$this->assertEquals($page->mode, PageMode::FILE);
# FIXME: assert($raw == file(blah.jpg))
}

Expand All @@ -37,7 +37,7 @@ public function testPostListBlock(): void
# enabled, image = text
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
$page = $this->get_page("post/list");
$this->assertNotNull($page->find_block("Random Post"));
$page->find_block("Random Post"); // will throw if missing

# disabled, image = no text
$config->set_bool("show_random_block", false);
Expand Down
2 changes: 1 addition & 1 deletion ext/user/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(

class UserCreationEvent extends Event
{
private ?User $user;
private ?User $user = null;

public function __construct(
public string $username,
Expand Down
1 change: 0 additions & 1 deletion ext/word_filter/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ private function filter(string $text): string
$search = "/\\b" . str_replace("/", "\\/", $search) . "\\b/i";
$text = preg_replace_ex($search, $replace, $text);
}
assert(is_string($text));
}
return $text;
}
Expand Down

0 comments on commit 6e709e8

Please sign in to comment.