Ir al contenido

Boolean Prefix (ARCH7007)

Esta página aún no está disponible en tu idioma.

Key php.naming.boolean-prefix · Severity info · Category naming

Boolean-typed members and accessors should carry an interrogative prefix such as is, has, can, or should. Without one, conditionals read poorly and intent is unclear.

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

Add an interrogative prefix such as is/has/can/should to the boolean accessor.