Skip to content
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 config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
|
*/

'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_').'_cache_'),

];
2 changes: 1 addition & 1 deletion config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel'), '_').'_database_'),
],

'default' => [
Expand Down
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
Str::slug((string) env('APP_NAME', 'laravel'), '_').'_session'
),

];
22 changes: 0 additions & 22 deletions database/factories/ActivityFactory.php

This file was deleted.

2 changes: 1 addition & 1 deletion database/factories/NetworkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function definition(): array
'key' => Str::slug($name),
'locale' => LocaleEnum::DE->value,
'name' => $name,
'category' => $this->faker->randomElement(NetworkCategoryEnum::cases())->value,
'category' => collect(NetworkCategoryEnum::cases())->random()->value,
'status' => NetworkStatusEnum::ACTIVE->value,
'cover_url' => null,
'tier_label' => null,
Expand Down
2 changes: 1 addition & 1 deletion database/factories/NewsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function definition(): array
$title = fake()->unique()->sentence();

return [
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
'locale' => collect(LocaleEnum::cases())->random()->value,
'title' => $title,
'slug' => str($title)->slug(),
'teaser' => fake()->sentence(),
Expand Down
4 changes: 2 additions & 2 deletions database/factories/OpenSourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/
public function definition(): array
{
$title = fake()->unique()->words(3, true);
$title = (string) fake()->unique()->words(3, true);

Check failure on line 21 in database/factories/OpenSourceFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Cannot cast array|string to string.

return [
'published' => true,
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
'locale' => collect(LocaleEnum::cases())->random()->value,
'title' => $title,
'slug' => str($title)->slug(),

Check failure on line 27 in database/factories/OpenSourceFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Parameter #1 $string of function str expects string|null, mixed given.
'teaser' => fake()->sentence(),
'content' => fake()->paragraphs(3, true),
'image' => fake()->imageUrl(),
Expand Down
4 changes: 2 additions & 2 deletions database/factories/ProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
public function definition(): array
{
$name = fake()->unique()->words(3, true);
$name = (string) fake()->unique()->words(3, true);

Check failure on line 21 in database/factories/ProductFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Cannot cast array|string to string.

return [
'published' => true,
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
'locale' => collect(LocaleEnum::cases())->random()->value,
'order' => fake()->numberBetween(1, 100),
'name' => $name,
'teaser' => fake()->sentence(),
'slug' => str($name)->slug(),

Check failure on line 29 in database/factories/ProductFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Parameter #1 $string of function str expects string|null, mixed given.
'content' => fake()->paragraphs(3, true),
'image' => fake()->imageUrl(),
'url' => fake()->url(),
Expand Down
4 changes: 2 additions & 2 deletions database/factories/ServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
*/
public function definition(): array
{
$name = fake()->unique()->words(3, true);
$name = (string) fake()->unique()->words(3, true);

Check failure on line 21 in database/factories/ServiceFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Cannot cast array|string to string.

return [
'published' => true,
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
'locale' => collect(LocaleEnum::cases())->random()->value,
'group' => fake()->word(),
'order' => fake()->numberBetween(1, 100),
'name' => $name,
'teaser' => fake()->sentence(),
'slug' => str($name)->slug(),

Check failure on line 30 in database/factories/ServiceFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Parameter #1 $string of function str expects string|null, mixed given.
'content' => fake()->paragraphs(3, true),
'image' => fake()->imageUrl(),
'url' => fake()->url(),
Expand Down
4 changes: 2 additions & 2 deletions database/factories/TechnologyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
public function definition(): array
{
$title = fake()->unique()->words(3, true);
$title = (string) fake()->unique()->words(3, true);

Check failure on line 21 in database/factories/TechnologyFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Cannot cast array|string to string.

return [
'published' => true,
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
'locale' => collect(LocaleEnum::cases())->random()->value,
'group' => fake()->word(),
'order' => fake()->numberBetween(1, 100),
'title' => $title,
'slug' => str($title)->slug(),

Check failure on line 29 in database/factories/TechnologyFactory.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Parameter #1 $string of function str expects string|null, mixed given.
'teaser' => fake()->sentence(),
'content' => fake()->paragraphs(3, true),
'image' => fake()->imageUrl(),
Expand Down
24 changes: 22 additions & 2 deletions database/seeders/Concerns/ReadsCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,40 @@ private function readCsv(string $filename): array
{
$handle = fopen(database_path("seeders/data/{$filename}"), 'r');

if ($handle === false) {
throw new \RuntimeException("Unable to open seeders/data/{$filename}.");
}

$header = fgetcsv($handle, 0, ';');

if ($header === false || in_array(null, $header, true)) {
fclose($handle);

throw new \RuntimeException("Missing CSV header in seeders/data/{$filename}.");
}

/** @var list<string> $header */
$rows = [];

while (($row = fgetcsv($handle, 0, ';')) !== false) {
$rows[] = array_combine($header, $row);
$rows[] = array_combine(
$header,
array_map(fn (?string $value): string => (string) $value, $row),
);
}

fclose($handle);

return $rows;
}

/**
* @return array<mixed>
*/
private function decodeJson(string $value): array
{
return $value === '' ? [] : json_decode($value, true);
$decoded = $value === '' ? [] : json_decode($value, true);

return is_array($decoded) ? $decoded : [];
}
}
18 changes: 15 additions & 3 deletions database/seeders/OpenSourceTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,18 @@ public function run(): void
);
}

private function seed(string $sharedSlug, array $localizedData): void
{
$entries = collect($localizedData)->map(function ($data, $locale) use ($sharedSlug) {
/**
* @param array<string, array<string, mixed>> $localizedData
*/
private function seed(
string $sharedSlug,
array $localizedData,
?string $link = null,
int $downloads = 0,
string $version = '',
?string $identifier = null,
): void {
$entries = collect($localizedData)->map(function (array $data, string $locale) use ($sharedSlug, $link, $downloads, $version) {
$slug = Str::slug($sharedSlug, '-', $locale);

return OpenSource::updateOrCreate(
Expand All @@ -352,6 +361,9 @@ private function seed(string $sharedSlug, array $localizedData): void
'image' => Arr::get($data, 'image', ''),
'tags' => Arr::get($data, 'tags', []),
'content' => Arr::get($data, 'content'),
'link' => $link,
'downloads' => $downloads,
'version' => $version,
]
);
});
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ parameters:
ignoreErrors:

excludePaths:
# Vendor-published migration (spatie/laravel-permission) — not our code.
- database/migrations/2024_06_06_100452_create_permission_tables.php
# Nova is not installed; this config references Laravel\Nova classes.
- config/nova.php
Loading