doctrine / doctrine/coding-standard

Forbid more functions

Open
#200 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
320
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Hi... I recently opened this #199

Instead of going wild and opening one by one a PR I thought about initiating a discussion here.

I believe there are more functions that can be forbidden:

```php
'__autoload' => null, // no reason to use this function since composer is out there

'define' => null,
'each' => null, // @see http://php.net/manual/en/migration72.deprecated.php
'create_function' => null, // why using this?

// debug functions
'debug_backtrace' => null,
'debug_print_backtrace' => null,
'die' => null,
'exit' => null,
'phpinfo' => null,
'print_r' => null,
'var_dump' => null,

// Use a logger lib (preferably a PSR-3 one)
'error_log' => null,

// Framework debug functions
'dd' => null,
'dump' => null,

// use an HttpClient library instead.
'curl_exec' => null,
'curl_init' => null,
'curl_multi_exec' => null,

// Use a process library..
'exec' => null,

// The following functions should not be allowed inside a project and they should be set by your php.ini unless if you are building a very specific library.
'ini_alter' => null,
'ini_restore' => null,
'ini_set' => null,
'date_default_timezone_set' => null,

'apache_request_headers' => null, // Exists only on Apache webservers
'apache_response_headers' => null, // Exists only on Apache webservers
'getallheaders' => null, // Is an alias of apache_request_headers()

'putenv' => null, // use $_SERVER or $_ENV variable directly // https://github.com/laravel/framework/issues/7354
'getenv' => null,
```

ofc users can override this on their projects but it would be good to promote these as a good practice.

Let me know WDYT.. maybe discussing all this in one issue might be an overhead and I should open smaller ones?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.