Skip to content

Commit

Permalink
Merge pull request #318 from plank/update-psr-message-dep
Browse files Browse the repository at this point in the history
update psr/http-message requirement to 2.0
  • Loading branch information
frasmage committed May 17, 2023
2 parents 7f0f3ca + cca978f commit c9d72a7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
"illuminate/filesystem": "^8.83.3|^9.0|^10.0",
"illuminate/database": "^8.83.3|^9.0|^10.0",
"league/flysystem": "^1.1.9|^2.4.2|^3.0.4",
"psr/http-message": "^1.0.1",
"psr/http-message": "^2.0",
"intervention/image": "^2.7.1",
"guzzlehttp/guzzle": "^6.5.5|^7.4.1",
"symfony/http-foundation": "^5.0.11|^6.0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/Media.php
Expand Up @@ -553,7 +553,7 @@ protected function handleMediaDeletion(): void
->where('media_id', $this->getKey())
->delete();
}
// unlink associated file on delete
// unlink associated file on delete
} elseif ($this->storage()->has($this->getDiskPath())) {
$this->storage()->delete($this->getDiskPath());
}
Expand Down
22 changes: 11 additions & 11 deletions src/MediaUploader.php
Expand Up @@ -878,17 +878,17 @@ private function handleDuplicate(Media $model): Media
$this->deleteExistingMedia($model, true);
break;
case static::ON_DUPLICATE_UPDATE:
$original = $model->newQuery()
->where('disk', $model->disk)
->where('directory', $model->directory)
->where('filename', $model->filename)
->where('extension', $model->extension)
->first();

if ($original) {
$model->{$model->getKeyName()} = $original->getKey();
$model->exists = true;
}
$original = $model->newQuery()
->where('disk', $model->disk)
->where('directory', $model->directory)
->where('filename', $model->filename)
->where('extension', $model->extension)
->first();

if ($original) {
$model->{$model->getKeyName()} = $original->getKey();
$model->exists = true;
}
break;
case static::ON_DUPLICATE_INCREMENT:
default:
Expand Down
2 changes: 1 addition & 1 deletion src/Mediable.php
Expand Up @@ -569,7 +569,7 @@ protected function handleMediableDeletion(): void
if (config('mediable.detach_on_soft_delete')) {
$this->media()->detach();
}
// always cascade for hard deletes
// always cascade for hard deletes
} else {
$this->media()->detach();
}
Expand Down
30 changes: 14 additions & 16 deletions src/Stream.php
Expand Up @@ -90,7 +90,7 @@ public function __destruct()
/**
* {@inheritdoc}
*/
public function __toString()
public function __toString(): string
{
try {
$this->seek(0);
Expand All @@ -103,7 +103,7 @@ public function __toString()
/**
* {@inheritdoc}
*/
public function getContents()
public function getContents(): string
{
$contents = stream_get_contents($this->resource);

Expand All @@ -117,7 +117,7 @@ public function getContents()
/**
* {@inheritdoc}
*/
public function close()
public function close(): void
{
if (!$this->resource) {
return;
Expand Down Expand Up @@ -148,7 +148,7 @@ public function detach()
/**
* {@inheritdoc}
*/
public function getSize()
public function getSize(): ?int
{
if ($this->size !== null) {
return $this->size;
Expand Down Expand Up @@ -176,39 +176,39 @@ public function getSize()
/**
* {@inheritdoc}
*/
public function isReadable()
public function isReadable(): bool
{
return $this->readable;
}

/**
* {@inheritdoc}
*/
public function isWritable()
public function isWritable(): bool
{
return $this->writable;
}

/**
* {@inheritdoc}
*/
public function isSeekable()
public function isSeekable(): bool
{
return $this->seekable;
}

/**
* {@inheritdoc}
*/
public function eof()
public function eof(): bool
{
return !$this->resource || feof($this->resource);
}

/**
* {@inheritdoc}
*/
public function tell()
public function tell(): int
{
if (!$this->resource) {
throw new \RuntimeException('No resource available; cannot tell position');
Expand All @@ -226,15 +226,15 @@ public function tell()
/**
* {@inheritdoc}
*/
public function rewind()
public function rewind(): void
{
$this->seek(0);
}

/**
* {@inheritdoc}
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET): void
{
if (!$this->resource) {
throw new \RuntimeException('No resource available; cannot seek position');
Expand All @@ -250,14 +250,12 @@ public function seek($offset, $whence = SEEK_SET)
throw new \RuntimeException('Unable to seek to stream position '
. $offset . ' with whence ' . var_export($whence, true));
}

return true;
}

/**
* {@inheritdoc}
*/
public function read($length)
public function read(int $length): string
{
if (!$this->resource) {
throw new \RuntimeException('No resource available; cannot read');
Expand All @@ -279,7 +277,7 @@ public function read($length)
/**
* {@inheritdoc}
*/
public function write($string)
public function write(string $string): int
{
if (!$this->resource) {
throw new \RuntimeException('No resource available; cannot write');
Expand All @@ -303,7 +301,7 @@ public function write($string)
/**
* {@inheritdoc}
*/
public function getMetadata($key = null)
public function getMetadata(?string $key = null)
{
$metadata = stream_get_meta_data($this->resource);

Expand Down
1 change: 1 addition & 0 deletions tests/TestCase.php
Expand Up @@ -5,6 +5,7 @@
use Dotenv\Dotenv;
use Faker\Factory;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Filesystem\Filesystem;
use Orchestra\Testbench\TestCase as BaseTestCase;
use Plank\Mediable\Media;
Expand Down

0 comments on commit c9d72a7

Please sign in to comment.