Skip to content

Commit f496aac

Browse files
Yasuo Ohgakismalyshev
Yasuo Ohgaki
authored andcommitted
Update source docs
1 parent 76c0983 commit f496aac

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

CODING_STANDARDS

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Exceptions:
8282
library may need to control or free the memory, or when the memory in
8383
question needs to survive between multiple requests.
8484

85-
Naming Conventions
85+
User Functions/Methods Naming Conventions
8686
------------------
8787

8888
1. Function names for user-level functions should be enclosed with in
@@ -163,6 +163,25 @@ Naming Conventions
163163
'foobar'
164164
'foo_bar'
165165

166+
Internal Function Naming Convensions
167+
----------------------
168+
169+
1. Exposed module API must be named 'php_modulename_function()' to avoid
170+
symbol collision. They should be in lowercase, with words underscore
171+
delimited. Exposed API must be defined in 'php_modulename.h'.
172+
173+
PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS);
174+
175+
Unexposed module function should be static and should not be defined in
176+
'php_modulename.h'.
177+
178+
static int php_session_destroy(TSRMLS_D)
179+
180+
2. Main module source file must be named 'modulename.c'.
181+
182+
3. Header file that are used by other sources must be named 'php_modulename.h'.
183+
184+
166185
Syntax and indentation
167186
----------------------
168187

@@ -181,9 +200,9 @@ Syntax and indentation
181200
of PHP or one of its standard modules, please maintain the K&R
182201
style. This applies to just about everything, starting with
183202
indentation and comment styles and up to function declaration
184-
syntax. Also see Indentstyle_.
203+
syntax. Also see Indentstyle.
185204

186-
.. _Indentstyle: http://www.catb.org/~esr/jargon/html/I/indent-style.html
205+
Indentstyle: http://www.catb.org/~esr/jargon/html/I/indent-style.html
187206

188207
3. Be generous with whitespace and braces. Keep one empty line between the
189208
variable declaration section and the statements in a block, as well as

README.EXTENSIONS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
This file describes extension module API details. Refer to
2+
README.EXT_SKEL to create extension skeleton files. Refer to
3+
Hacker's Guide for PHP internals.
4+
5+
http://www.php.net/manual/en/internals2.php
6+
7+
8+
19
Between PHP 4.0.6 and 4.1.0, the Zend module struct changed in a way
210
that broke both source and binary compatibility. If you are
311
maintaining a third party extension, here's how to update it:

README.EXT_SKEL

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,29 @@ HOW TO USE IT
4545

4646
--proto=filename.
4747

48+
SOURCE AND HEADER FILE NAME
49+
50+
./ext_skel generates 'module_name.c' and 'php_module_name.h' as main source
51+
and header files. Keep these names.
52+
53+
Module functions (User functions) must be named
54+
55+
module_name_function()
56+
57+
When you need to expose module functions to other modules, expose functions
58+
strictly needed by others. Exposed internal function must be named
59+
60+
php_module_name_function()
61+
62+
See also CODING_STANDARDS.
63+
64+
4865
FORMAT OF FUNCTION DEFINITIONS FILE
4966

5067
All the definitions must be on one line. In it's simplest form, it's just
5168
the function name, e.g.
5269

53-
my_function
70+
module_name_function
5471

5572
but then you'll be left with an almost empty function body without any
5673
argument handling.
@@ -72,8 +89,9 @@ FORMAT OF FUNCTION DEFINITIONS FILE
7289

7390
An example:
7491

75-
my_function(int arg1, int arg2 [, int arg3 [, int arg4]]) this is my 1st
92+
module_name_function(int arg1, int arg2 [, int arg3 [, int arg4]])
7693

94+
Arguments arg1 and arg2 is required.
7795
Arguments arg3 and arg4 are optional.
7896

7997
If possible, the function definition should also contain it's return type
@@ -133,15 +151,15 @@ EXAMPLE
133151

134152
The following _one_ line
135153

136-
bool my_drawtext(resource image, string text, resource font, int x, int y [, int color])
154+
bool module_name_drawtext(resource image, string text, resource font, int x, int y [, int color])
137155

138156
will create this function definition for you (note that there are a few
139157
question marks to be replaced by you, and you must of course add your own
140158
value definitions too):
141159

142-
/* {{{ proto bool my_drawtext(resource image, string text, resource font, int x, int y [, int color])
160+
/* {{{ proto bool module_name_drawtext(resource image, string text, resource font, int x, int y [, int color])
143161
*/
144-
PHP_FUNCTION(my_drawtext)
162+
PHP_FUNCTION(module_name_drawtext)
145163
{
146164
char *text = NULL;
147165
int argc = ZEND_NUM_ARGS();
@@ -164,7 +182,7 @@ PHP_FUNCTION(my_drawtext)
164182
ZEND_FETCH_RESOURCE(???, ???, font, font_id, "???", ???_rsrc_id);
165183
}
166184

167-
php_error(E_WARNING, "my_drawtext: not yet implemented");
185+
php_error(E_WARNING, "module_name_drawtext: not yet implemented");
168186
}
169187
/* }}} */
170188

README.SUBMITTING_PATCH

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ Please make the mail subject prefix "[PATCH]". If attaching a patch,
5050
ensure it has a file extension of ".txt". This is because only MIME
5151
attachments of type 'text/*' are accepted.
5252

53+
Preferred way to propose PHP patch is sending pull request from github.
54+
55+
https://github.com/php/php-src
56+
57+
Fork official PHP repository and send pull request. It will be notified
58+
to pull request mailing list. You can add pull requests to
59+
http://bugs.php.net/ reports also.
60+
5361

5462
PHP Documentation Patches
5563
-------------------------

0 commit comments

Comments
 (0)