HelPHP

test_naming_convention.php

Table of Contents

Constants

ALLOWED_VARS  = ['$_SESSION', '$_POST', '$_GET', '$_SERVER', '$_COOKIE', '$_FILES', '$_ENV', '$_REQUEST', '$CONFIG', '$DB']
Naming convention checker for helPHP converted modules.

Functions

is_camel_case()  : bool
to_snake_case()  : string
bare_name()  : string
check_file()  : array<string|int, mixed>
apply_renames()  : string
interactive_rename()  : void

Constants

ALLOWED_VARS

Naming convention checker for helPHP converted modules.

public mixed ALLOWED_VARS = ['$_SESSION', '$_POST', '$_GET', '$_SERVER', '$_COOKIE', '$_FILES', '$_ENV', '$_REQUEST', '$CONFIG', '$DB']

Detects camelCase identifiers that should be snake_case. When run from a terminal, proposes and applies renames interactively.

Checks:

  • variable names ($myVar → $my_var)
  • function definitions (function getData → function get_data)
  • instance method/property calls ($obj->getData → $obj->get_data)
  • static method calls (Class::getData → Class::get_data)

Usage: php test_naming_convention.php path/to/Module.php [more.php|dir/]

Functions

is_camel_case()

is_camel_case(string $name) : bool
Parameters
$name : string
Return values
bool

to_snake_case()

to_snake_case(string $name) : string
Parameters
$name : string
Return values
string

bare_name()

bare_name(string $kind, string $display) : string
Parameters
$kind : string
$display : string
Return values
string

check_file()

check_file(string $path) : array<string|int, mixed>
Parameters
$path : string
Return values
array<string|int, mixed>

apply_renames()

apply_renames(string $content, array<string|int, mixed> $renames) : string
Parameters
$content : string
$renames : array<string|int, mixed>
Return values
string

interactive_rename()

interactive_rename(string $file, array<string|int, mixed> $violations[, bool $auto = false ]) : void
Parameters
$file : string
$violations : array<string|int, mixed>
$auto : bool = false

        
On this page

Search results