- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: php-code-style/no-unreachable
Language: PHP
Severity: Warning
Category: Error Prone
This rule requires that all code in a function or method must be reachable, and dead code (code that can never be executed) should be avoided. This rule is important because dead code can make the program more difficult to understand and maintain. It can also lead to confusion and bugs if other developers mistakenly believe the dead code is doing something.
Dead code often occurs when developers leave behind commented-out code or functions that are no longer called. It can also happen when a return statement or an exception is thrown before the code.
To ensure compliance with this rule, always remove code that is no longer needed. Use version control systems to keep track of changes instead of leaving old code in comments. Be mindful of the flow of your functions and methods to ensure all code is reachable. For example, if you have a return
statement in your function, make sure it’s the last operation in your function.
<?php
function test() {
echo "test";
return;
echo "testing";
}
<?php
function test() {
echo "test";
echo "testing";
return;
}
|
|
For more information, please read the Code Analysis documentation
Identify code vulnerabilities directly in yourVS Code editor
Identify code vulnerabilities directly inJetBrains products