Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tasso85's avatar

Segmenentation fault when running artisan tinker

I was using the "tinker" artisan's command to try out if I understood models local scopes correcty, by running this command:

$ art tinker
Psy Shell v0.12.3 (PHP 8.3.7 — cli) by Justin Hileman
> Company::master()->get();
[!] Aliasing 'Company' to 'App\Models\Company' for this Tinker session.
Segmentation fault

Here is how I defined my Company model:

class Company extends Model {
	use HasFactory, HasUuids, SoftDeletes;

	protected $fillable = [
		'name',
	];

	public function users(): HasMany {
		return $this->hasMany(User::class);
	}

	public function quotes(): HasManyThrough {
		return $this->hasManyThrough(Quote::class, User::class);
	}

	public function scopeMaster(Builder $query) {
		$query->where('is_master', 1);
	}
}

I thought the problem was in the scope method I created, but it segfaults even if I do not use it:

$ art tinker
Psy Shell v0.12.3 (PHP 8.3.7 — cli) by Justin Hileman
> Company::all()->get();
[!] Aliasing 'Company' to 'App\Models\Company' for this Tinker session.
Segmentation fault
0 likes
1 reply
tasso85's avatar

... It seems that I have found the problem: in the scope method, I had used class Illuminate\Database\Query\Builder instead of Illuminate\Database\Eloquent\Builder for the type hint; this was clearly shown in the seeding process, but not while tinkering.

Please or to participate in this conversation.