Boolean Prefix (ARCH7007)
هذا المحتوى غير متوفر بلغتك بعد.
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.
Incorrect
Section titled “Incorrect”<?php
class Account{ public function active(): bool { return $this->status === 'open'; }}Correct
Section titled “Correct”<?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.