Skip to content

Commit

Permalink
Merge pull request #11 from skoro/fix-php74-errors
Browse files Browse the repository at this point in the history
Fix php74 errors
  • Loading branch information
skoro authored Oct 28, 2022
2 parents 5dbaba5 + 9de5cd2 commit 404f888
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tkui;

use Stringable;

/**
* Contract for graphic images.
*
* TODO: extends Stringable
*/
interface Image extends Stringable
interface Image
{
public function width(): int;

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/TreeView/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function header(): Header
return $this->header;
}

public static function create(string $id, string $header): static
public static function create(string $id, string $header): self
{
return new static($id, new Header($header));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/TreeView/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function options(): Options
return $this->options;
}

public static function values(array $values): static
public static function values(array $values): self
{
return new static($values);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Widgets/TreeView/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ protected function initWidgetOptions(): Options
]);
}

public function onSelect(callable $callback): static
public function onSelect(callable $callback): self
{
$this->bind('<<TreeviewSelect>>', fn () => $callback($this->selected(), $this));
return $this;
}

public function onOpen(callable $callback): static
public function onOpen(callable $callback): self
{
$this->bind('<<TreeviewOpen>>', fn () => $callback($this));
return $this;
}

public function onClose(callable $callback): static
public function onClose(callable $callback): self
{
$this->bind('<<TreeviewClose>>', fn () => $callback($this));
return $this;
Expand All @@ -101,21 +101,21 @@ private function setColumnHeader(Column $column): void
$this->call('heading', $column->id, '-text', $column->header()->text);
}

public function add(Item $item, string $parentId = ''): static
public function add(Item $item, string $parentId = ''): self
{
$args = $item->options()->asStringArray();
$this->call('insert', $parentId ?: '{}', 'end', ...$args);
return $this;
}

public function delete(Item ...$items): static
public function delete(Item ...$items): self
{
$ids = array_map(fn (Item $item) => $item->id, $items);
$this->call('delete', ...$ids);
return $this;
}

public function focusItem(Item $item): static
public function focusItem(Item $item): self
{
$this->call('focus', $item->id);
return $this;
Expand Down Expand Up @@ -171,7 +171,7 @@ public function getPrevItemId(string $itemId): string
/**
* Sets the viewport to the specified item.
*/
public function seeItemId(string $itemId): static
public function seeItemId(string $itemId): self
{
$this->call('see', $itemId);
return $this;
Expand Down
5 changes: 4 additions & 1 deletion tests/Widgets/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Tkui\Widgets\Text\Text;
use Tkui\Widgets\Text\TextIndex;
use PHPUnit\Framework\MockObject\MockObject;
use Tkui\TclTk\TkImage;

class TextTest extends TestCase
{
Expand Down Expand Up @@ -174,7 +175,9 @@ public function insert_embedded_image_into_specified_position()
]);

/** @var Image|MockObject */
$image = $this->createMock(Image::class);
// FIXME: Since Image doesn't have Stringable TkImage is used here, after switching
// to PHP8 it must be changed to Image interface instead of TkImage.
$image = $this->createMock(TkImage::class);
$image->expects($this->once())
->method('__toString')
->willReturn('i0')
Expand Down

0 comments on commit 404f888

Please sign in to comment.