Skip to content

Commit

Permalink
declare_strict_types
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Jan 11, 2025
1 parent b227300 commit d692f56
Show file tree
Hide file tree
Showing 51 changed files with 120 additions and 17 deletions.
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
"require": {
"php": "^8.2",
"spatie/laravel-package-tools": "^1.16",
"illuminate/contracts": "^10.0||^11.0"
"illuminate/contracts": "^11.0"
},
"require-dev": {
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1.1||^7.10.0",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^9.0.0||^8.22.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3"
"laravel/pint": "^1.0",
"nunomaduro/collision": "^8.1",
"larastan/larastan": "^3.0.0",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^3.0",
"pestphp/pest-plugin-arch": "^3.0",
"pestphp/pest-plugin-laravel": "^3.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0"
},
"autoload": {
"files": [
Expand Down
2 changes: 2 additions & 0 deletions config/seo.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

return [

'defaults' => [
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ parameters:
- database
tmpDir: build/phpstan
checkOctaneCompatibility: true
noEnvCallsOutsideOfConfig: false
checkModelProperties: true
6 changes: 6 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"preset": "laravel",
"rules": {
"declare_strict_types": true
}
}
2 changes: 2 additions & 0 deletions src/Concerns/HasSeo.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Concerns;

use Elegantly\Seo\SeoManager;
Expand Down
2 changes: 2 additions & 0 deletions src/Contracts/Taggable.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Contracts;

use Elegantly\Seo\SeoTags;
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/SeoManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Facades;

use Illuminate\Support\Facades\Facade;
Expand Down
2 changes: 2 additions & 0 deletions src/Middleware/SeoNoIndexMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Middleware;

use Closure;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Audio.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Image.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Locale.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/OpenGraph.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Verticals/Article.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph\Verticals;

use Carbon\Carbon;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Verticals/Book.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph\Verticals;

use Carbon\Carbon;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Verticals/Profile.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph\Verticals;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Verticals/Vertical.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph\Verticals;

use Carbon\Carbon;
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Verticals/Website.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph\Verticals;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/OpenGraph/Video.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\OpenGraph;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/Schemas/Schema.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Schemas;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/Schemas/WebPage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Schemas;

use Illuminate\Support\Facades\Request;
Expand Down
2 changes: 2 additions & 0 deletions src/SeoImage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo;

use Elegantly\Seo\OpenGraph\Image;
Expand Down
12 changes: 7 additions & 5 deletions src/SeoManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo;

use Closure;
Expand Down Expand Up @@ -227,7 +229,7 @@ public function setImage(null|SeoImage|string $value): static
$this->twitter->image = $value?->toTwitter();
}
if ($this->webpage) {
$this->webpage->put('image', $value?->secure_url ?? $value?->url);
$this->webpage->put('image', $value->secure_url ?? $value?->url);
}

return $this;
Expand Down Expand Up @@ -266,7 +268,7 @@ public function setLocale(
if ($this->opengraph) {
$this->opengraph->locale = new Locale(
locale: $value,
alternate: $this->opengraph->locale?->alternate ?? [],
alternate: $this->opengraph->locale->alternate ?? [],
);
}

Expand All @@ -286,7 +288,7 @@ public function setAlternates(?array $value): static
return $href;
}

return new Alternate($hrelang, $href);
return new Alternate((string) $hrelang, $href);
})
->values()
->all();
Expand All @@ -298,7 +300,7 @@ public function setAlternates(?array $value): static

if ($this->opengraph) {
$this->opengraph->locale = new Locale(
locale: $this->opengraph->locale?->locale ?? App::getLocale(),
locale: $this->opengraph->locale->locale ?? App::getLocale(),
alternate: collect($value)
->where('hreflang', '!=', 'x-default')
->map(fn ($item) => $item->toOpenGraph())
Expand Down Expand Up @@ -389,7 +391,7 @@ public static function default(
title: $title,
url: $url,
description: $description,
image: $image?->secure_url ?? $image?->url,
image: $image->secure_url ?? $image?->url,
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/SeoServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo;

use Spatie\LaravelPackageTools\Package;
Expand Down
2 changes: 2 additions & 0 deletions src/SeoTags.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo;

use Elegantly\Seo\Tags\TagVoid;
Expand Down
2 changes: 2 additions & 0 deletions src/Standard/Alternate.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Standard;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/Standard/Standard.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Standard;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/Tags/Link.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Tags;

use Illuminate\Support\Collection;
Expand Down
2 changes: 2 additions & 0 deletions src/Tags/Meta.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Tags;

use Illuminate\Support\Collection;
Expand Down
2 changes: 2 additions & 0 deletions src/Tags/Script.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Tags;

use Illuminate\Support\Collection;
Expand Down
2 changes: 2 additions & 0 deletions src/Tags/Tag.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Tags;

abstract class Tag extends TagVoid
Expand Down
4 changes: 3 additions & 1 deletion src/Tags/TagVoid.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Tags;

use Elegantly\Seo\Traits\DeepClone;
Expand All @@ -18,7 +20,7 @@ abstract class TagVoid implements Htmlable
public ?Collection $properties = null;

/**
* @return Collection<string, string>
* @return Collection<string, non-falsy-string>
*/
public function toProperties(): Collection
{
Expand Down
2 changes: 2 additions & 0 deletions src/Tags/Title.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Tags;

class Title extends Tag
Expand Down
2 changes: 2 additions & 0 deletions src/Traits/DeepClone.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Traits;

trait DeepClone
Expand Down
2 changes: 2 additions & 0 deletions src/Twitter/Cards/Card.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Twitter\Cards;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/Twitter/Cards/Summary.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Twitter\Cards;

use Elegantly\Seo\Twitter\Image;
Expand Down
2 changes: 2 additions & 0 deletions src/Twitter/Cards/SummaryLargeImage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Twitter\Cards;

class SummaryLargeImage extends Summary
Expand Down
2 changes: 2 additions & 0 deletions src/Twitter/Image.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Elegantly\Seo\Twitter;

use Elegantly\Seo\Contracts\Taggable;
Expand Down
2 changes: 2 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Elegantly\Seo\Concerns\HasSeo;
use Elegantly\Seo\SeoManager;

Expand Down
2 changes: 2 additions & 0 deletions tests/ArchTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

arch('it will not use debugging functions')
->expect(['dd', 'dump', 'ray'])
->each->not->toBeUsed();
2 changes: 2 additions & 0 deletions tests/Features/SeoManagerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Elegantly\Seo\Facades\SeoManager;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Request;
Expand Down
Loading

0 comments on commit d692f56

Please sign in to comment.