İçeriğe geç

Boole öneki (ARCH7007)

Anahtar php.naming.boolean-prefix · Önem info · Kategori naming

Boole tipli üye ve erişimciler is, has, can veya should gibi sorgu öneki taşımalıdır. Önek olmadan koşullar doğal dilde kötü okunur ve niyet belirsizleşir.

<?php
class Account
{
public function active(): bool
{
return $this->status === 'open';
}
}
<?php
class Account
{
public function isActive(): bool
{
return $this->status === 'open';
}
}

Boole erişimcisine is/has/can/should gibi bir sorgu öneki ekleyin.