internals:reciew_comments
Differences
This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
internals:reciew_comments [2012/12/27 19:40] – created johannes | internals:reciew_comments [2012/12/27 20:20] – redirect to correct name johannes | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | While reviewing PECL proposals there are some common issues which can be observed. This page collects some of those to provide extended information and saving reviewers from explaining those multiple times. This is different from other sections on this wiki a it focusses on review perspective. | + | See [[internals:review_comments|Review comments]] |
- | + | ||
- | **Note to documentation team:** When adding this information to the manual please keep a reference on this page! | + | |
- | + | ||
- | ====== php_$extname.h should be minimal ====== | + | |
- | + | ||
- | When reviewing extensions one can often see long // | + | |
- | + | ||
- | If needed it may contain some public C-level APIs for other extensions. If there' | + | |
- | + | ||
- | The reason for this is that for a static build of the extension as part of the main PHP build the PHP configure script will create // | + | |
- | + | ||
- | A good starting point for a // | + | |
- | + | ||
- | < | + | |
- | /* | + | |
- | +----------------------------------------------------------------------+ | + | |
- | | PHP Version 5 | | + | |
- | +----------------------------------------------------------------------+ | + | |
- | | Copyright (c) 1997-2012 The PHP Group | | + | |
- | +----------------------------------------------------------------------+ | + | |
- | | This source file is subject to version 3.01 of the PHP license, | + | |
- | | that is bundled with this package in the file LICENSE, and is | | + | |
- | | available through the world-wide-web at the following url: | | + | |
- | | http:// | + | |
- | | If you did not receive a copy of the PHP license and are unable to | | + | |
- | | obtain it through the world-wide-web, | + | |
- | | license@php.net so we can mail you a copy immediately. | + | |
- | +----------------------------------------------------------------------+ | + | |
- | | Author: Ted User < | + | |
- | +----------------------------------------------------------------------+ | + | |
- | */ | + | |
- | + | ||
- | #ifndef PHP_EXTNAME_H | + | |
- | #define PHP_EXTNAME_H | + | |
- | + | ||
- | extern zend_module_entry extname_module_entry; | + | |
- | #define phpext_extname_ptr & | + | |
- | + | ||
- | #endif | + | |
- | </ | + | |
- | + | ||
- | ====== Don't use zend_error ====== | + | |
- | + | ||
- | // | + | |
- | + | ||
- | ====== If zend_parse_parameters() fails do a simple return ====== | + | |
- | + | ||
- | The // | + | |
- | + | ||
- | > **Note:** If the parameters given to a function are not what it expects, such as passing an array where a string is expected, the return value of the function is undefined. In this case it will likely return **NULL** but this is just a convention, and cannot be relied upon. | + | |
- | (Source: | + | |
- | + | ||
- | Even though this is a convention this rule should be followed unless there are good reasons. | + | |
- | + | ||
- | Those are wrong: | + | |
- | + | ||
- | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, " | + | |
- | RETURN_FALSE; | + | |
- | } | + | |
- | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, " | + | |
- | php_error_docref(NULL, | + | |
- | return; | + | |
- | } | + | |
- | + | ||
- | This form is suggested: | + | |
- | + | ||
- | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, " | + | |
- | return; | + | |
- | } | + | |
- | + | ||
- | See also README.PARAMETER_PARSING_API in the PHP source tree for your version of PHP. | + |
internals/reciew_comments.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1