Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more phpstan 2.0 stuff #1336

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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