---
title: Avoid short method names
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Avoid short method names
---

# Avoid short method names

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `php-code-style/short-method-name`

**Language:** PHP

**Severity:** Notice

**Category:** Code Style

## Description{% #description %}

This rule emphasizes the importance of avoiding short method names in your PHP code. Short method names such as 'a' or 'b' provide little to no context about what the function does, making it harder for others and yourself to understand the code. This can lead to confusion, misinterpretation, and mistakes during code maintenance or enhancement.

The importance of this rule lies in the clarity and maintainability of your code. Clear, descriptive method names make it easier to understand the function's purpose without needing to read and understand its internal implementation. This not only improves readability, but also reduces the time needed to understand the code, making it more efficient to work with.

To avoid this, always use meaningful, descriptive names for your methods. Good method names should accurately represent what the method does. For example, a method that calculates the total price could be named `calculateTotalPrice()`. By following this practice, you contribute to creating clean, understandable, and maintainable code.

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```php
<?php
function a() {

}

class Foo {
    function b() {

    }
}
```

## Compliant Code Examples{% #compliant-code-examples %}

```php
<?php
function foo() {

}

class Foo {
    function bar() {

    }
}
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 