Skip to content

Commit 95c38a5

Browse files
committed
remove #include comments
Several PHP maintainers have argued that code comments explaining include directives are bad. - @dstogov wrote "It adds almost useless comments that are not goigg to be kept as to date" https://marc.info/?l=php-internals&m=167403155727727&w=2 - @derickr wrote "Adding comments that go out of date as to why a header is included is also clutter." https://marc.info/?l=php-internals&m=167405646312575&w=2 - @kamil-tekiela wrote "I am against putting comments on #includes. Comments are noise in code and often go out of date." https://marc.info/?l=php-internals&m=167406432218721&w=2 I don't agree with them; I believe that code comments help others understand and maintain the code. Of course, like any code comment, they become obsolete and wrong, but outdated comments are still better than no comment at all. With this argument, you can easily say that nobody should ever write a code comment. My RFC https://wiki.php.net/rfc/include_cleanup contains a vote on whether #includes are allowed to have explanatory code comments; if this is denied, then please merge this PR to get rid of many existing comments which my work has imitated.
1 parent 908d954 commit 95c38a5

File tree

24 files changed

+32
-32
lines changed

24 files changed

+32
-32
lines changed

ext/fileinfo/fileinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
#include "php_ini.h"
2929
#include "ext/standard/info.h"
30-
#include "ext/standard/file.h" /* needed for context stuff */
30+
#include "ext/standard/file.h"
3131
#include "php_fileinfo.h"
3232
#include "fileinfo_arginfo.h"
33-
#include "fopen_wrappers.h" /* needed for is_url */
33+
#include "fopen_wrappers.h"
3434
#include "Zend/zend_exceptions.h"
3535

3636
/* {{{ macros and type definitions */

ext/hash/murmur/PMurHash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ on big endian machines, or a byte-by-byte read if the endianess is unknown.
7070
/* Find best way to ROTL */
7171
#if defined(_MSC_VER)
7272
#define FORCE_INLINE static __forceinline
73-
#include <stdlib.h> /* Microsoft put _rotl declaration in here */
73+
#include <stdlib.h>
7474
#define ROTL32(x,y) _rotl(x,y)
7575
#else
7676
#define FORCE_INLINE static inline __attribute__((always_inline))

ext/hash/murmur/PMurHash128.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ on big endian machines.
6262
/* Find best way to ROTL */
6363
#if defined(_MSC_VER)
6464
#define FORCE_INLINE static __forceinline
65-
#include <stdlib.h> /* Microsoft put _rotl declaration in here */
65+
#include <stdlib.h>
6666
#define ROTL32(x,y) _rotl(x,y)
6767
#define ROTL64(x,y) _rotl64(x,y)
6868
#define BIG_CONSTANT(x) (x)

ext/hash/xxhash/xxhash.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ XXH_PUBLIC_API unsigned XXH_versionNumber (void);
339339
/* ****************************
340340
* Common basic types
341341
******************************/
342-
#include <stddef.h> /* size_t */
342+
#include <stddef.h>
343343
typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
344344

345345

@@ -1482,7 +1482,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
14821482
return memcpy(dest,src,size);
14831483
}
14841484

1485-
#include <limits.h> /* ULLONG_MAX */
1485+
#include <limits.h>
14861486

14871487

14881488
/* *************************************
@@ -5445,7 +5445,7 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state)
54455445

54465446
/* 128-bit utility functions */
54475447

5448-
#include <string.h> /* memcmp, memcpy */
5448+
#include <string.h>
54495449

54505450
/* return : 1 is equal, 0 if different */
54515451
/*! @ingroup xxh3_family */

ext/mbstring/php_mbregex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "mbstring.h"
2828
#include "libmbfl/filters/mbfilter_utf8.h"
2929

30-
#include "php_onig_compat.h" /* must come prior to the oniguruma header */
30+
#include "php_onig_compat.h"
3131
#include <oniguruma.h>
3232
#undef UChar
3333

ext/mysqlnd/config-win.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file is public domain and comes with NO WARRANTY of any kind */
88

99
#include <sys/locking.h>
1010
#include <windows.h>
11-
#include <math.h> /* Because of rint() */
11+
#include <math.h>
1212
#include <fcntl.h>
1313
#include <io.h>
1414
#include <malloc.h>

ext/opcache/jit/vtune/ittnotify_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ typedef struct ___itt_thread_info
395395
struct ___itt_thread_info* next;
396396
} __itt_thread_info;
397397

398-
#include "ittnotify_types.h" /* For __itt_group_id definition */
398+
#include "ittnotify_types.h"
399399

400400
typedef struct ___itt_api_info_20101001
401401
{

ext/sockets/conversions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#endif
55
#include "sockaddr_conv.h"
66
#include "conversions.h"
7-
#include "sendrecvmsg.h" /* for ancillary registry */
7+
#include "sendrecvmsg.h"
88
#ifdef PHP_WIN32
99
# include "windows_common.h"
1010
#endif

ext/sockets/sockaddr_conv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define PHP_SOCKADR_CONV_H
33

44
#include <php_network.h>
5-
#include "php_sockets.h" /* php_socket */
5+
#include "php_sockets.h"
66

77
#ifndef PHP_WIN32
88
# include <netinet/in.h>

ext/sockets/windows_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <Winsock2.h>
1818
#define NTDDI_XP NTDDI_WINXP /* bug in SDK */
19-
#include <IPHlpApi.h> /* conflicting definition of CMSG_DATA */
19+
#include <IPHlpApi.h>
2020
#undef NTDDI_XP
2121

2222
#define HAVE_IF_NAMETOINDEX 1

ext/standard/formatted_print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#include <math.h> /* modf() */
17+
#include <math.h>
1818
#include "php.h"
1919
#include "ext/standard/head.h"
2020
#include "php_string.h"

ext/standard/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "SAPI.h"
2828
#include <time.h>
2929
#include "php_main.h"
30-
#include "zend_globals.h" /* needs ELS */
30+
#include "zend_globals.h"
3131
#include "zend_extensions.h"
3232
#include "zend_highlight.h"
3333
#ifdef HAVE_SYS_UTSNAME_H

ext/standard/php_http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define PHP_HTTP_H
1919

2020
#include "php.h"
21-
#include "zend_types.h" /* for zend_string */
21+
#include "zend_types.h"
2222
#include "zend_smart_str.h"
2323

2424
PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,

main/reentrancy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#endif
2323

2424
#include "php_reentrancy.h"
25-
#include "ext/random/php_random.h" /* for PHP_RAND_MAX */
25+
#include "ext/random/php_random.h"
2626

2727
enum {
2828
LOCALTIME_R,

main/streams/streams.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "php_network.h"
2727
#include "php_open_temporary_file.h"
2828
#include "ext/standard/file.h"
29-
#include "ext/standard/basic_functions.h" /* for BG(CurrentStatFile) */
30-
#include "ext/standard/php_string.h" /* for php_memnstr, used by php_stream_get_record() */
29+
#include "ext/standard/basic_functions.h"
30+
#include "ext/standard/php_string.h"
3131
#include <stddef.h>
3232
#include <fcntl.h>
3333
#include "php_streams_int.h"

sapi/cli/php_cli_server.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@
9090
# define SOCK_EADDRINUSE WSAEADDRINUSE
9191
#endif
9292

93-
#include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */
93+
#include "ext/standard/file.h"
9494
#include "zend_smart_str.h"
9595
#include "ext/standard/html.h"
96-
#include "ext/standard/url.h" /* for php_raw_url_decode() */
97-
#include "ext/standard/php_string.h" /* for php_dirname() */
98-
#include "ext/date/php_date.h" /* for php_format_date() */
96+
#include "ext/standard/url.h"
97+
#include "ext/standard/php_string.h"
98+
#include "ext/date/php_date.h"
9999
#include "php_network.h"
100100

101101
#include "php_http_parser.h"

sapi/cli/ps_title.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ extern char** environ;
5151
#include <stdlib.h>
5252

5353
#ifdef HAVE_SYS_PSTAT_H
54-
#include <sys/pstat.h> /* for HP-UX */
54+
#include <sys/pstat.h>
5555
#endif
5656
#ifdef HAVE_PS_STRINGS
57-
#include <machine/vmparam.h> /* for old BSD */
57+
#include <machine/vmparam.h>
5858
#include <sys/exec.h>
5959
#endif
6060
#if defined(DARWIN)

sapi/fpm/fpm/fpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "fpm_config.h"
44

5-
#include <stdlib.h> /* for exit */
5+
#include <stdlib.h>
66

77
#include "fpm.h"
88
#include "fpm_children.h"

sapi/fpm/fpm/fpm_clock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "fpm_config.h"
44

55
#ifdef HAVE_CLOCK_GETTIME
6-
#include <time.h> /* for CLOCK_MONOTONIC */
6+
#include <time.h>
77
#endif
88

99
#include "fpm_clock.h"

sapi/fpm/fpm/fpm_events.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <unistd.h>
66
#include <errno.h>
7-
#include <stdlib.h> /* for putenv */
7+
#include <stdlib.h>
88
#include <string.h>
99

1010
#include <php.h>

sapi/fpm/fpm/fpm_php.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <TSRM.h>
77

88
#include "php.h"
9-
#include "build-defs.h" /* for PHP_ defines */
9+
#include "build-defs.h"
1010
#include "fpm/fpm_conf.h"
1111

1212
#define FPM_PHP_INI_TO_EXPAND \

sapi/fpm/fpm/fpm_sockets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <alloca.h>
77
#endif
88
#include <sys/types.h>
9-
#include <sys/stat.h> /* for chmod(2) */
9+
#include <sys/stat.h>
1010
#include <sys/socket.h>
1111
#include <netinet/in.h>
1212
#include <arpa/inet.h>

win32/sendmail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
#include "php.h" /*php specific */
20+
#include "php.h"
2121
#include <stdio.h>
2222
#include <stdlib.h>
2323
#include <winsock2.h>

win32/wsyslog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* Lift a leg, Yunie. Luv ya forever!!!!
5151
*/
5252

53-
#include "php.h" /*php specific */
53+
#include "php.h"
5454
#include "syslog.h"
5555
#include <stdio.h>
5656
#include <fcntl.h>

0 commit comments

Comments
 (0)