summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /scripts
downloadphp2-php-5.4.13.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.frag52
-rwxr-xr-xscripts/apache/apconf-conv.sh24
-rwxr-xr-xscripts/apache/aphtaccess-conv.sh24
-rw-r--r--scripts/apache/conffix.awk23
-rw-r--r--scripts/apache/htaccessfix.awk23
-rw-r--r--scripts/dev/check_parameters.php373
-rwxr-xr-xscripts/dev/conv_proto30
-rwxr-xr-xscripts/dev/conv_z_macros61
-rwxr-xr-xscripts/dev/credits27
-rw-r--r--scripts/dev/extern_c.php45
-rw-r--r--scripts/dev/find_tested.php222
-rw-r--r--scripts/dev/generate-phpt.pharbin0 -> 52353 bytes
-rwxr-xr-xscripts/dev/generate-phpt/build.xml15
-rw-r--r--scripts/dev/generate-phpt/gtPackage.php30
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/array.txt9
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/boolean.txt6
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/commentEnd.txt2
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/commentStart.txt2
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/emptyUnsetUndefNull.txt11
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/float.txt7
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/int.txt6
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/loopClose.txt1
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/loopStart.txt1
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/object.txt25
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/skipif64b.txt1
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/skipifnot64b.txt1
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/skipifnotwin.txt1
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/skipifwin.txt1
-rw-r--r--scripts/dev/generate-phpt/src/codeSnippets/string.txt10
-rw-r--r--scripts/dev/generate-phpt/src/generate-phpt.php115
-rw-r--r--scripts/dev/generate-phpt/src/gtAutoload.php63
-rw-r--r--scripts/dev/generate-phpt/src/gtClassMap.php48
-rw-r--r--scripts/dev/generate-phpt/src/gtCodeSnippet.php72
-rw-r--r--scripts/dev/generate-phpt/src/gtFunction.php48
-rw-r--r--scripts/dev/generate-phpt/src/gtMethod.php139
-rw-r--r--scripts/dev/generate-phpt/src/gtTestCaseWriter.php27
-rw-r--r--scripts/dev/generate-phpt/src/gtTestSubject.php166
-rw-r--r--scripts/dev/generate-phpt/src/gtText.php27
-rw-r--r--scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php7
-rw-r--r--scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php7
-rw-r--r--scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php7
-rw-r--r--scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php6
-rw-r--r--scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php98
-rw-r--r--scripts/dev/generate-phpt/src/setup/gtOptionalSections.php85
-rw-r--r--scripts/dev/generate-phpt/src/setup/gtPreCondition.php14
-rw-r--r--scripts/dev/generate-phpt/src/setup/gtPreConditionList.php33
-rw-r--r--scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php24
-rw-r--r--scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php21
-rw-r--r--scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php21
-rw-r--r--scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php24
-rw-r--r--scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php25
-rw-r--r--scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php28
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtBasicTestCase.php37
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseFunction.php62
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseMethod.php52
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtErrorTestCase.php53
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseFunction.php57
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseMethod.php59
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtTestCase.php230
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtVariationContainer.php54
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtVariationContainerFunction.php43
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtVariationContainerMethod.php46
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtVariationTestCase.php55
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseFunction.php64
-rw-r--r--scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseMethod.php68
-rw-r--r--scripts/dev/generate-phpt/src/texts/functionOrMethodNotSpecified.txt3
-rw-r--r--scripts/dev/generate-phpt/src/texts/help.txt14
-rw-r--r--scripts/dev/generate-phpt/src/texts/methodNotSpecified.txt4
-rw-r--r--scripts/dev/generate-phpt/src/texts/testTypeNotSpecified.txt3
-rw-r--r--scripts/dev/generate-phpt/src/texts/unknownClass.txt4
-rw-r--r--scripts/dev/generate-phpt/src/texts/unknownFunction.txt4
-rw-r--r--scripts/dev/generate-phpt/src/texts/unknownMethod.txt4
-rw-r--r--scripts/dev/generate-phpt/tests/gtBasicTestCaseFunctionTest.php24
-rw-r--r--scripts/dev/generate-phpt/tests/gtBasicTestCaseMethodTest.php28
-rw-r--r--scripts/dev/generate-phpt/tests/gtCodeSnippetTest.php15
-rw-r--r--scripts/dev/generate-phpt/tests/gtCommandLineOptionsTest.php46
-rw-r--r--scripts/dev/generate-phpt/tests/gtErrorTestCaseFunctionTest.php28
-rw-r--r--scripts/dev/generate-phpt/tests/gtErrorTestCaseMethodTest.php30
-rw-r--r--scripts/dev/generate-phpt/tests/gtFunctionTest.php71
-rw-r--r--scripts/dev/generate-phpt/tests/gtIfClassHasMethodTest.php41
-rw-r--r--scripts/dev/generate-phpt/tests/gtIsSpecifiedFunctionOrMethodTest.php41
-rw-r--r--scripts/dev/generate-phpt/tests/gtIsSpecifiedTestTypeTest.php32
-rw-r--r--scripts/dev/generate-phpt/tests/gtIsValidClassTest.php41
-rw-r--r--scripts/dev/generate-phpt/tests/gtIsValidFunctionTest.php40
-rw-r--r--scripts/dev/generate-phpt/tests/gtIsValidMethodTest.php40
-rw-r--r--scripts/dev/generate-phpt/tests/gtMethodTest.php82
-rw-r--r--scripts/dev/generate-phpt/tests/gtOptionalSectionsTest.php58
-rw-r--r--scripts/dev/generate-phpt/tests/gtVariationTestCaseFunctionTest.php59
-rw-r--r--scripts/dev/generate-phpt/tests/gtVariationTestCaseMethodTest.php27
-rwxr-xr-xscripts/dev/phpextdist27
-rwxr-xr-xscripts/dev/search_underscores.php97
-rw-r--r--scripts/man1/php-config.1.in81
-rw-r--r--scripts/man1/phpize.1.in48
-rw-r--r--scripts/php-config.in90
-rw-r--r--scripts/phpize.in209
-rw-r--r--scripts/phpize.m4202
96 files changed, 4511 insertions, 0 deletions
diff --git a/scripts/Makefile.frag b/scripts/Makefile.frag
new file mode 100644
index 0000000..00272b0
--- /dev/null
+++ b/scripts/Makefile.frag
@@ -0,0 +1,52 @@
+
+#
+# Build environment install
+#
+
+phpincludedir = $(includedir)/php
+phpbuilddir = $(libdir)/build
+
+BUILD_FILES = \
+ scripts/phpize.m4 \
+ build/mkdep.awk \
+ build/scan_makefile_in.awk \
+ build/libtool.m4 \
+ Makefile.global \
+ acinclude.m4 \
+ ltmain.sh \
+ run-tests.php
+
+BUILD_FILES_EXEC = \
+ build/shtool \
+ config.guess \
+ config.sub
+
+bin_SCRIPTS = phpize php-config
+man_PAGES = phpize php-config
+
+install-build:
+ @echo "Installing build environment: $(INSTALL_ROOT)$(phpbuilddir)/"
+ @$(mkinstalldirs) $(INSTALL_ROOT)$(phpbuilddir) $(INSTALL_ROOT)$(bindir) && \
+ (cd $(top_srcdir) && \
+ $(INSTALL) $(BUILD_FILES_EXEC) $(INSTALL_ROOT)$(phpbuilddir) && \
+ $(INSTALL_DATA) $(BUILD_FILES) $(INSTALL_ROOT)$(phpbuilddir))
+
+install-programs: $(builddir)/phpize $(builddir)/php-config
+ @echo "Installing helper programs: $(INSTALL_ROOT)$(bindir)/"
+ @$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
+ @for prog in $(bin_SCRIPTS); do \
+ echo " program: $(program_prefix)$${prog}$(program_suffix)"; \
+ $(INSTALL) -m 755 $(builddir)/$${prog} $(INSTALL_ROOT)$(bindir)/$(program_prefix)$${prog}$(program_suffix); \
+ done
+ @echo "Installing man pages: $(INSTALL_ROOT)$(mandir)/man1/"
+ @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1
+ @for page in $(man_PAGES); do \
+ echo " page: $(program_prefix)$${page}$(program_suffix).1"; \
+ $(INSTALL_DATA) $(builddir)/man1/$${page}.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)$${page}$(program_suffix).1; \
+ done
+
+$(builddir)/phpize: $(srcdir)/phpize.in $(top_builddir)/config.status
+ (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status)
+
+$(builddir)/php-config: $(srcdir)/php-config.in $(top_builddir)/config.status
+ (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status)
diff --git a/scripts/apache/apconf-conv.sh b/scripts/apache/apconf-conv.sh
new file mode 100755
index 0000000..6126bdc
--- /dev/null
+++ b/scripts/apache/apconf-conv.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$1" = "" ]; then
+ echo "Usage: $0 /somewhere/httpd.conf"
+ exit 1
+fi
+
+if [ ! -w $1 ]; then
+ echo "You cannot write to $1"
+ exit 1
+fi
+
+TMPFILE=tmpfile.$$
+
+awk -f conffix.awk <$1 >$TMPFILE
+
+if [ "$?" != 0 ]; then
+ exit 1
+fi
+
+mv -f $1 $1.orig
+mv -f $TMPFILE $1
+exit 0
+
diff --git a/scripts/apache/aphtaccess-conv.sh b/scripts/apache/aphtaccess-conv.sh
new file mode 100755
index 0000000..1af59d2
--- /dev/null
+++ b/scripts/apache/aphtaccess-conv.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$1" = "" ]; then
+ echo "Usage: $0 /somewhere/.htaccess"
+ exit 1
+fi
+
+if [ ! -w $1 ]; then
+ echo "You cannot write to $1"
+ exit 1
+fi
+
+TMPFILE=tmpfile.$$
+
+awk -f htaccessfix.awk <$1 >$TMPFILE
+
+if [ "$?" != 0 ]; then
+ exit 1
+fi
+
+mv -f $1 $1.orig
+mv -f $TMPFILE $1
+exit 0
+
diff --git a/scripts/apache/conffix.awk b/scripts/apache/conffix.awk
new file mode 100644
index 0000000..88be6fa
--- /dev/null
+++ b/scripts/apache/conffix.awk
@@ -0,0 +1,23 @@
+# $Id$
+
+/^[ \t]*php3_*/ {
+ phpcommand=substr($1,6)
+ phpvalue=tolower($2)
+ print "<IfModule mod_php3.c>"
+ print $0
+ print "</IfModule>"
+ print "<IfModule mod_php4.c>"
+ if (phpvalue=="on") {
+ print "php_admin_flag " phpcommand " on"
+ } else if (phpvalue=="off") {
+ print "php_admin_flag " phpcommand " off"
+ } else {
+ print "php_admin_value " phpcommand " " substr($0,index($0,$1)+length($1)+1)
+ }
+ print "</IfModule>"
+}
+
+! /^[ \t]*php3_*/ {
+ print $0
+}
+
diff --git a/scripts/apache/htaccessfix.awk b/scripts/apache/htaccessfix.awk
new file mode 100644
index 0000000..3c784cd
--- /dev/null
+++ b/scripts/apache/htaccessfix.awk
@@ -0,0 +1,23 @@
+# $Id$
+
+/^[ \t]*php3_*/ {
+ phpcommand=substr($1,6)
+ phpvalue=tolower($2)
+ print "<IfModule mod_php3.c>"
+ print $0
+ print "</IfModule>"
+ print "<IfModule mod_php4.c>"
+ if (phpvalue=="on") {
+ print "php_flag " phpcommand " on"
+ } else if (phpvalue=="off") {
+ print "php_flag " phpcommand " off"
+ } else {
+ print "php_value " phpcommand " " substr($0,index($0,$1)+length($1)+1)
+ }
+ print "</IfModule>"
+}
+
+! /^[ \t]*php3_*/ {
+ print $0
+}
+
diff --git a/scripts/dev/check_parameters.php b/scripts/dev/check_parameters.php
new file mode 100644
index 0000000..c9f5169
--- /dev/null
+++ b/scripts/dev/check_parameters.php
@@ -0,0 +1,373 @@
+<?php
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 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://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Nuno Lopes <nlopess@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+
+define('REPORT_LEVEL', 2); // 0 reports less false-positives. up to level 5.
+define('VERSION', '5.2'); // minimum is 5.2
+define('PHPDIR', realpath(dirname(__FILE__) . '/../..'));
+
+
+// be sure you have enough memory and stack for PHP. pcre will push the limits!
+ini_set('pcre.backtrack_limit', 10000000);
+
+
+// ------------------------ end of config ----------------------------
+
+
+$API_params = array(
+ 'a' => array('zval**'), // array as zval*
+ 'b' => array('zend_bool*'), // boolean
+ 'C' => array('zend_class_entry**'), // class
+ 'd' => array('double*'), // double
+ 'f' => array('zend_fcall_info*', 'zend_fcall_info_cache*'), // function
+ 'h' => array('HashTable**'), // array as an HashTable*
+ 'l' => array('long*'), // long
+ 'o' => array('zval**'), //object
+ 'O' => array('zval**', 'zend_class_entry*'), // object of given type
+ 'r' => array('zval**'), // resource
+ 's' => array('char**', 'int*'), // string
+ 'z' => array('zval**'), // zval*
+ 'Z' => array('zval***') // zval**
+);
+
+// specific to PHP >= 6
+if (version_compare(VERSION, '6', 'ge')) {
+ $API_params['S'] = $API_params['s']; // binary string
+ $API_params['t'] = array('zstr*', 'int*', 'zend_uchar*'); // text
+ $API_params['T'] = $API_params['t'];
+ $API_params['u'] = array('UChar**', 'int*'); // unicode
+ $API_params['U'] = $API_params['u'];
+}
+
+
+/** reports an error, according to its level */
+function error($str, $level = 0)
+{
+ global $current_file, $current_function, $line;
+
+ if ($level <= REPORT_LEVEL) {
+ if (strpos($current_file,PHPDIR) === 0) {
+ $filename = substr($current_file, strlen(PHPDIR)+1);
+ } else {
+ $filename = $current_file;
+ }
+ echo $filename , " [$line] $current_function : $str\n";
+ }
+}
+
+
+/** this updates the global var $line (for error reporting) */
+function update_lineno($offset)
+{
+ global $lines_offset, $line;
+
+ $left = 0;
+ $right = $count = count($lines_offset)-1;
+
+ // a nice binary search :)
+ do {
+ $mid = intval(($left + $right)/2);
+ $val = $lines_offset[$mid];
+
+ if ($val < $offset) {
+ if (++$mid > $count || $lines_offset[$mid] > $offset) {
+ $line = $mid;
+ return;
+ } else {
+ $left = $mid;
+ }
+ } else if ($val > $offset) {
+ if ($lines_offset[--$mid] < $offset) {
+ $line = $mid+1;
+ return;
+ } else {
+ $right = $mid;
+ }
+ } else {
+ $line = $mid+1;
+ return;
+ }
+ } while (true);
+}
+
+
+/** parses the sources and fetches its vars name, type and if they are initialized or not */
+function get_vars($txt)
+{
+ $ret = array();
+ preg_match_all('/((?:(?:unsigned|struct)\s+)?\w+)(?:\s*(\*+)\s+|\s+(\**))(\w+(?:\[\s*\w*\s*\])?)\s*(?:(=)[^,;]+)?((?:\s*,\s*\**\s*\w+(?:\[\s*\w*\s*\])?\s*(?:=[^,;]+)?)*)\s*;/S', $txt, $m, PREG_SET_ORDER);
+
+ foreach ($m as $x) {
+ // the first parameter is special
+ if (!in_array($x[1], array('else', 'endif', 'return'))) // hack to skip reserved words
+ $ret[$x[4]] = array($x[1] . $x[2] . $x[3], $x[5]);
+
+ // are there more vars?
+ if ($x[6]) {
+ preg_match_all('/(\**)\s*(\w+(?:\[\s*\w*\s*\])?)\s*(=?)/S', $x[6], $y, PREG_SET_ORDER);
+ foreach ($y as $z) {
+ $ret[$z[2]] = array($x[1] . $z[1], $z[3]);
+ }
+ }
+ }
+
+// if ($GLOBALS['current_function'] == 'for_debugging') { print_r($m);print_r($ret); }
+ return $ret;
+}
+
+
+/** run diagnostic checks against one var. */
+function check_param($db, $idx, $exp, $optional)
+{
+ global $error_few_vars_given;
+
+ if ($idx >= count($db)) {
+ if (!$error_few_vars_given) {
+ error("too few variables passed to function");
+ $error_few_vars_given = true;
+ }
+ return;
+ } elseif ($db[$idx][0] === '**dummy**') {
+ return;
+ }
+
+ if ($db[$idx][1] != $exp) {
+ error("{$db[$idx][0]}: expected '$exp' but got '{$db[$idx][1]}' [".($idx+1).']');
+ }
+
+ if ($optional && !$db[$idx][2]) {
+ error("optional var not initialized: {$db[$idx][0]} [".($idx+1).']', 1);
+
+ } elseif (!$optional && $db[$idx][2]) {
+ error("not optional var is initialized: {$db[$idx][0]} [".($idx+1).']', 2);
+ }
+}
+
+
+/** fetch params passed to zend_parse_params*() */
+function get_params($vars, $str)
+{
+ $ret = array();
+ preg_match_all('/(?:\([^)]+\))?(&?)([\w>.()-]+(?:\[\w+\])?)\s*,?((?:\)*\s*=)?)/S', $str, $m, PREG_SET_ORDER);
+
+ foreach ($m as $x) {
+ $name = $x[2];
+
+ // little hack for last parameter
+ if (strpos($name, '(') === false) {
+ $name = rtrim($name, ')');
+ }
+
+ if (empty($vars[$name][0])) {
+ error("variable not found: '$name'", 3);
+ $ret[][] = '**dummy**';
+
+ } else {
+ $ret[] = array($name, $vars[$name][0] . ($x[1] ? '*' : ''), $vars[$name][1]);
+ }
+
+ // the end (yes, this is a little hack :P)
+ if ($x[3]) {
+ break;
+ }
+ }
+
+// if ($GLOBALS['current_function'] == 'for_debugging') { var_dump($m); var_dump($ret); }
+ return $ret;
+}
+
+
+/** run tests on a function. the code is passed in $txt */
+function check_function($name, $txt, $offset)
+{
+ global $API_params;
+
+ if (preg_match_all('/zend_parse_parameters(?:_ex\s*\([^,]+,[^,]+|\s*\([^,]+),\s*"([^"]*)"\s*,\s*([^{;]*)/S', $txt, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
+
+ $GLOBALS['current_function'] = $name;
+
+ foreach ($matches as $m) {
+ $GLOBALS['error_few_vars_given'] = false;
+ update_lineno($offset + $m[2][1]);
+
+ $vars = get_vars(substr($txt, 0, $m[0][1])); // limit var search to current location
+ $params = get_params($vars, $m[2][0]);
+ $optional = $varargs = false;
+ $last_last_char = $last_char = '';
+ $j = -1;
+ $len = strlen($m[1][0]);
+
+ for ($i = 0; $i < $len; ++$i) {
+ switch($char = $m[1][0][$i]) {
+ // separator for optional parameters
+ case '|':
+ if ($optional) {
+ error("more than one optional separator at char #$i");
+ } else {
+ $optional = true;
+ if ($i == $len-1) {
+ error("unnecessary optional separator");
+ }
+ }
+ break;
+
+ // separate_zval_if_not_ref
+ case '/':
+ if (!in_array($last_char, array('r', 'z'))) {
+ error("the '/' specifier cannot be applied to '$last_char'");
+ }
+ break;
+
+ // nullable arguments
+ case '!':
+ if (!in_array($last_char, array('a', 'C', 'f', 'h', 'o', 'O', 'r', 's', 't', 'z', 'Z'))) {
+ error("the '!' specifier cannot be applied to '$last_char'");
+ }
+ break;
+
+ case '&':
+ if (version_compare(VERSION, '6', 'ge')) {
+ if ($last_char == 's' || ($last_last_char == 's' && $last_char == '!')) {
+ check_param($params, ++$j, 'UConverter*', $optional);
+
+ } else {
+ error("the '&' specifier cannot be applied to '$last_char'");
+ }
+ } else {
+ error("unknown char ('&') at column $i");
+ }
+ break;
+
+ case '+':
+ case '*':
+ if (version_compare(VERSION, '6', 'ge')) {
+ if ($varargs) {
+ error("A varargs specifier can only be used once. repeated char at column $i");
+ } else {
+ check_param($params, ++$j, 'zval****', $optional);
+ check_param($params, ++$j, 'int*', $optional);
+ $varargs = true;
+ }
+ } else {
+ error("unknown char ('$char') at column $i");
+ }
+ break;
+
+ default:
+ if (isset($API_params[$char])) {
+ foreach($API_params[$char] as $exp) {
+ check_param($params, ++$j, $exp, $optional);
+ }
+ } else {
+ error("unknown char ('$char') at column $i");
+ }
+ }
+
+ $last_last_char = $last_char;
+ $last_char = $char;
+ }
+ }
+ }
+}
+
+
+/** the main recursion function. splits files in functions and calls the other functions */
+function recurse($path)
+{
+ foreach (scandir($path) as $file) {
+ if ($file == '.' || $file == '..' || $file == 'CVS') continue;
+
+ $file = "$path/$file";
+ if (is_dir($file)) {
+ recurse($file);
+ continue;
+ }
+
+ // parse only .c and .cpp files
+ if (substr_compare($file, '.c', -2) && substr_compare($file, '.cpp', -4)) continue;
+
+ $txt = file_get_contents($file);
+ // remove comments (but preserve the number of lines)
+ $txt = preg_replace(array('@//.*@S', '@/\*.*\*/@SsUe'), array('', 'preg_replace("/[^\r\n]+/S", "", \'$0\')'), $txt);
+
+
+ $split = preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', $txt, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
+
+ if (count($split) < 2) continue; // no functions defined on this file
+ array_shift($split); // the first part isn't relevant
+
+
+ // generate the line offsets array
+ $j = 0;
+ $lines = preg_split("/(\r\n?|\n)/S", $txt, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $lines_offset = array();
+
+ for ($i = 0; $i < count($lines); ++$i) {
+ $j += strlen($lines[$i]) + strlen(@$lines[++$i]);
+ $lines_offset[] = $j;
+ }
+
+ $GLOBALS['lines_offset'] = $lines_offset;
+ $GLOBALS['current_file'] = $file;
+
+
+ for ($i = 0; $i < count($split); $i+=2) {
+ // if the /* }}} */ comment is found use it to reduce false positives
+ // TODO: check the other indexes
+ list($f) = preg_split('@/\*\s*}}}\s*\*/@S', $split[$i+1][0]);
+ check_function(preg_replace('/\s*,\s*/S', '::', $split[$i][0]), $f, $split[$i][1]);
+ }
+ }
+}
+
+$dirs = array();
+
+if (isset($argc) && $argc > 1) {
+ if ($argv[1] == '-h' || $argv[1] == '-help' || $argv[1] == '--help') {
+ echo <<<HELP
+Synopsis:
+ php check_parameters.php [directories]
+
+HELP;
+ exit(0);
+ }
+ for ($i = 1; $i < $argc; $i++) {
+ $dirs[] = $argv[$i];
+ }
+} else {
+ $dirs[] = PHPDIR;
+}
+
+foreach($dirs as $dir) {
+ if (is_dir($dir)) {
+ if (!is_readable($dir)) {
+ echo "ERROR: directory '", $dir ,"' is not readable\n";
+ exit(1);
+ }
+ } else {
+ echo "ERROR: bogus directory '", $dir ,"'\n";
+ exit(1);
+ }
+}
+
+foreach ($dirs as $dir) {
+ recurse(realpath($dir));
+}
diff --git a/scripts/dev/conv_proto b/scripts/dev/conv_proto
new file mode 100755
index 0000000..fad9cfa
--- /dev/null
+++ b/scripts/dev/conv_proto
@@ -0,0 +1,30 @@
+#! /bin/sh
+#
+# do some automatic conversion of prototypes
+#
+
+if test "$1" = "" ; then
+ echo "usage: $0 list-of-files"
+ exit 1
+fi
+
+tmpfile=`mktemp -q /tmp/asd.XXXXXX`
+
+if test "$?" != "0" ; then
+ echo "$0: cannot create temporary file"
+ exit 1
+fi
+
+for file in ${1+"$@"} ; do
+ echo "working on $file"
+ cat $file | \
+ sed -e \
+ 's/void php3_\(.*\)(INTERNAL_FUNCTION_PARAMETERS)/PHP_FUNCTION(\1)/' \
+ -e 's/^extern void /void /' \
+ -e 's/^extern PHP_FUNCTION/PHP_FUNCTION/' > $tmpfile
+ cp $tmpfile $file
+done
+
+rm -f $tmpfile
+
+exit 0
diff --git a/scripts/dev/conv_z_macros b/scripts/dev/conv_z_macros
new file mode 100755
index 0000000..ea45bc2
--- /dev/null
+++ b/scripts/dev/conv_z_macros
@@ -0,0 +1,61 @@
+#! /bin/sh
+#
+# +----------------------------------------------------------------------+
+# | PHP Version 5 |
+# +----------------------------------------------------------------------+
+# | Copyright (c) 1997-2007 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://www.php.net/license/3_01.txt |
+# | If you did not receive a copy of the PHP license and are unable to |
+# | obtain it through the world-wide-web, please send a note to |
+# | license@php.net so we can mail you a copy immediately. |
+# +----------------------------------------------------------------------+
+# | Author: Sascha Schumann <sascha@schumann.cx> |
+# +----------------------------------------------------------------------+
+#
+# $Id$
+
+for i in $@; do
+ echo -n "Processing $i... "
+ sed \
+ -e 's/(\*\([^()]\+\))->type/Z_TYPE_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->type/Z_TYPE_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.type/Z_TYPE(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.dval/Z_DVAL_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.dval/Z_DVAL_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.dval/Z_DVAL(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.lval/Z_LVAL_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.lval/Z_LVAL_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.lval/Z_LVAL(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.ht/Z_ARRVAL_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.ht/Z_ARRVAL_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.ht/Z_ARRVAL(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.str\.val/Z_STRVAL_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.str\.val/Z_STRVAL_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.str\.val/Z_STRVAL(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.str\.len/Z_STRLEN_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.str\.len/Z_STRLEN_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.str\.len/Z_STRLEN(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.obj\.properties/Z_OBJPROP_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.obj\.properties/Z_OBJPROP_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.obj\.properties/Z_OBJPROP(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.obj\.ce/Z_OBJCE_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.obj\.ce/Z_OBJCE_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.obj\.ce/Z_OBJCE(\1)/g' \
+ -e 's/(\*\([^()]\+\))->value\.obj/Z_OBJ_PP(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)->value\.obj/Z_OBJ_P(\1)/g' \
+ -e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.obj/Z_OBJ(\1)/g' \
+ -e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)->Z_\([A-Z_]\+\)(/Z_\2(\1->/g' \
+ -e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)->Z_\([A-Z_]\+\)(/Z_\2(\1->/g' \
+ -e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)->Z_\([A-Z_]\+\)(/Z_\2(\1->/g' \
+ -e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)\.Z_\([A-Z_]\+\)(/Z_\2(\1./g' \
+ -e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)\.Z_\([A-Z_]\+\)(/Z_\2(\1./g' \
+ -e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)\.Z_\([A-Z_]\+\)(/Z_\2(\1./g' \
+ < $i > tmp && cp tmp $i
+ echo "DONE"
+done
+
+rm -f tmp
diff --git a/scripts/dev/credits b/scripts/dev/credits
new file mode 100755
index 0000000..801637c
--- /dev/null
+++ b/scripts/dev/credits
@@ -0,0 +1,27 @@
+#!/bin/sh
+awkprog='
+BEGIN { FS = "\n|\r\n|\r"; RS = "" }
+{ print "CREDIT_LINE(\""$1"\", \""$2"\");" }'
+
+for what in ext sapi
+do
+ file=ext/standard/credits_$what.h
+ cat >$file <<END
+/*
+ DO NOT EDIT THIS FILE!
+
+ it has been automaticaly created by php5/scripts/credits from
+ the information found in the various php5/ext/.../CREDITS and
+ php5/sapi/.../CREDITS files
+
+ if you want to change an entry you have to edit the appropriate
+ CREDITS file instead
+
+*/
+
+END
+ # Do not process skeleton #
+ files=`find "$what" -name CREDITS | grep -v "$what"/skeleton/CREDITS`
+ awk "$awkprog" $files | sort -f | uniq >> $file
+ echo "Updated $file"
+done
diff --git a/scripts/dev/extern_c.php b/scripts/dev/extern_c.php
new file mode 100644
index 0000000..72c7edc
--- /dev/null
+++ b/scripts/dev/extern_c.php
@@ -0,0 +1,45 @@
+<?php
+
+function scan_dir($dir) {
+ if (!is_dir($dir)) return;
+
+ foreach (glob("$dir/*") as $file) {
+ if (is_dir($file)) {
+ if (basename($file) != "CVS") {
+ scan_dir($file);
+ }
+ } else if (fnmatch("*.h", $file)) {
+ scan_file($file);
+ }
+ }
+}
+
+function scan_file($file) {
+ $flag = false;
+
+ foreach (file($file) as $nr => $line) {
+ if (ereg("^[[:space:]]*BEGIN_EXTERN_C", $line)) {
+# echo "$file:".($nr+1)." $line";
+ $flag = true;
+ } else if (ereg("^[[:space:]]*END_EXTERN_C", $line)) {
+# echo "$file:".($nr+1)." $line";
+ $flag = false;
+ } else if ( (ereg("^[[:space:]]*PHPAPI[[:space:]]*", $line))
+ ||(ereg("^[[:space:]]*ZEND_API[[:space:]]*", $line))) {
+ if (strstr($line,"(")) {
+ if (!$flag) echo "$file:".($nr+1)." $line";
+ }
+ }
+ }
+}
+
+array_shift($_SERVER["argv"]);
+
+if (count($_SERVER["argv"])) {
+ foreach ($_SERVER["argv"] as $dir) {
+ scan_dir($dir);
+ }
+} else {
+ scan_dir(".");
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/find_tested.php b/scripts/dev/find_tested.php
new file mode 100644
index 0000000..f95c462
--- /dev/null
+++ b/scripts/dev/find_tested.php
@@ -0,0 +1,222 @@
+<?php
+
+
+$usage = <<<USAGE
+
+Usage: php find_tested.php [path_to_test_files] ([extension])
+
+Outputs test coverage information for functions and methods in csv format.
+Supplying an optional extension name outputs only information for functions and methods from that extension.
+
+Output format:
+Extension, Class Name, Method/Function Name, Test Status, Test Files
+
+A test status of "verify" for a method means that there is at least one other method of the same name, so test coverage must be verified manually.
+
+USAGE;
+
+
+/* method record fields */
+define("CLASS_NAME", "CLASS_NAME");
+define("METHOD_NAME", "METHOD_NAME");
+define("EXTENSION_NAME", "EXTENSION_NAME");
+define("IS_DUPLICATE", "IS_DUPLICATE");
+define("IS_TESTED", "IS_TESTED");
+define("TESTS", "TESTS");
+
+
+// process command line args
+$num_params = $argc;
+if ($num_params < 2 || $num_params > 3) {
+ die($usage);
+}
+
+$extension_test_path = $argv[1];
+
+if ($num_params == 3) {
+ $extension_name = $argv[2];
+
+ // check extension exists
+ $extensions = get_loaded_extensions();
+ if (!in_array($extension_name, $extensions)) {
+ echo "Error: extension $extension_name is not loaded. Loaded extensions:\n";
+ foreach($extensions as $extension) {
+ echo "$extension\n";
+ }
+ die();
+ }
+} else {
+ $extension_name = false;
+}
+
+
+$method_info = populate_method_info();
+
+if ($extension_name != false) {
+ // get only the methods from the extension we are querying
+ $extension_method_info = array();
+ foreach($method_info as $method_record) {
+ if (strcasecmp($extension_name, $method_record[EXTENSION_NAME]) == 0) {
+ $extension_method_info[] = $method_record;
+ }
+ }
+} else {
+ $extension_method_info = $method_info;
+}
+
+get_phpt_files($extension_test_path, $count, $phpt_files);
+
+$extension_method_info = mark_methods_as_tested($extension_method_info, $phpt_files);
+
+
+foreach($extension_method_info as $record) {
+ echo $record[EXTENSION_NAME] . ",";
+ echo $record[CLASS_NAME] . ",";
+ echo $record[METHOD_NAME] . ",";
+ echo $record[IS_TESTED] . ",";
+ echo $record[TESTS] . "\n";
+}
+
+/**
+ * Marks the "tested" status of methods in $method_info according
+ * to whether they are tested in $phpt_files
+ */
+function mark_methods_as_tested($method_info, $phpt_files) {
+
+ foreach($phpt_files as $phpt_file) {
+ $tested_functions = extract_tests($phpt_file);
+
+ foreach($tested_functions as $tested_function) {
+
+ // go through method info array marking this funtion as tested
+ foreach($method_info as &$current_method_record) {
+ if (strcasecmp($tested_function, $current_method_record[METHOD_NAME]) == 0) {
+ // matched the method name
+ if ($current_method_record[IS_DUPLICATE] == true) {
+ // we cannot be sure which class this method corresponds to,
+ // so mark method as needing to be verified
+ $current_method_record[IS_TESTED] = "verify";
+ } else {
+ $current_method_record[IS_TESTED] = "yes";
+ }
+ $current_method_record[TESTS] .= $phpt_file . "; ";
+ }
+ }
+ }
+ }
+ return $method_info;
+}
+
+/**
+ * returns an array containing a record for each defined method.
+ */
+function populate_method_info() {
+
+ $method_info = array();
+
+ // get functions
+ $all_functions = get_defined_functions();
+ $internal_functions = $all_functions["internal"];
+
+ foreach ($internal_functions as $function) {
+ // populate new method record
+ $function_record = array();
+ $function_record[CLASS_NAME] = "Function";
+ $function_record[METHOD_NAME] = $function;
+ $function_record[IS_TESTED] = "no";
+ $function_record[TESTS] = "";
+ $function_record[IS_DUPLICATE] = false;
+
+ // record the extension that the function belongs to
+ $reflectionFunction = new ReflectionFunction($function);
+ $extension = $reflectionFunction->getExtension();
+ if ($extension != null) {
+ $function_record[EXTENSION_NAME] = $extension->getName();
+ } else {
+ $function_record[EXTENSION_NAME] = "";
+ }
+ // insert new method record into info array
+ $method_info[] = $function_record;
+ }
+
+ // get methods
+ $all_classes = get_declared_classes();
+ foreach ($all_classes as $class) {
+ $reflectionClass = new ReflectionClass($class);
+ $methods = $reflectionClass->getMethods();
+ foreach ($methods as $method) {
+ // populate new method record
+ $new_method_record = array();
+ $new_method_record[CLASS_NAME] = $reflectionClass->getName();
+ $new_method_record[METHOD_NAME] = $method->getName();
+ $new_method_record[IS_TESTED] = "no";
+ $new_method_record[TESTS] = "";
+
+ $extension = $reflectionClass->getExtension();
+ if ($extension != null) {
+ $new_method_record[EXTENSION_NAME] = $extension->getName();
+ } else {
+ $new_method_record[EXTENSION_NAME] = "";
+ }
+
+ // check for duplicate method names
+ $new_method_record[IS_DUPLICATE] = false;
+ foreach ($method_info as &$current_record) {
+ if (strcmp($current_record[METHOD_NAME], $new_method_record[METHOD_NAME]) == 0) {
+ $new_method_record[IS_DUPLICATE] = true;
+ $current_record[IS_DUPLICATE] = true;
+ }
+ }
+ // insert new method record into info array
+ $method_info[] = $new_method_record;
+ }
+ }
+
+ return $method_info;
+}
+
+function get_phpt_files($dir, &$phpt_file_count, &$all_phpt)
+{
+ $thisdir = dir($dir.'/'); //include the trailing slash
+ while(($file = $thisdir->read()) !== false) {
+ if ($file != '.' && $file != '..') {
+ $path = $thisdir->path.$file;
+ if(is_dir($path) == true) {
+ get_phpt_files($path , $phpt_file_count , $all_phpt);
+ } else {
+ if (preg_match("/\w+\.phpt$/", $file)) {
+ $all_phpt[$phpt_file_count] = $path;
+ $phpt_file_count++;
+ }
+ }
+ }
+ }
+}
+
+function extract_tests($file) {
+ $code = file_get_contents($file);
+
+ if (!preg_match('/--FILE--\s*(.*)\s*--(EXPECTF|EXPECTREGEX|EXPECT)?--/is', $code, $r)) {
+// print "Unable to get code in ".$file."\n";
+ return array();
+ }
+
+ $tokens = token_get_all($r[1]);
+ $functions = array_filter($tokens, 'filter_functions');
+ $functions = array_map( 'map_token_value',$functions);
+ $functions = array_unique($functions);
+
+ return $functions;
+}
+
+function filter_functions($x) {
+ return $x[0] == 307;
+}
+
+function map_token_value($x) {
+ return $x[1];
+}
+
+
+?>
+
diff --git a/scripts/dev/generate-phpt.phar b/scripts/dev/generate-phpt.phar
new file mode 100644
index 0000000..d9e6ce4
--- /dev/null
+++ b/scripts/dev/generate-phpt.phar
Binary files differ
diff --git a/scripts/dev/generate-phpt/build.xml b/scripts/dev/generate-phpt/build.xml
new file mode 100755
index 0000000..c01954b
--- /dev/null
+++ b/scripts/dev/generate-phpt/build.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+
+<project name="generate" default="test" basedir=".">
+
+ <property name="build.dir" value="_build" />
+
+ <target name="docs" description="Create API documentation.">
+ <exec command="doxygen doxygen.conf" />
+ </target>
+
+ <target name="test" description="Run all unit tests.">
+ <exec command="phpunit --coverage-html coverage tests" passthru="true" />
+ </target>
+
+</project>
diff --git a/scripts/dev/generate-phpt/gtPackage.php b/scripts/dev/generate-phpt/gtPackage.php
new file mode 100644
index 0000000..566899d
--- /dev/null
+++ b/scripts/dev/generate-phpt/gtPackage.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * This creates a standalone phar file with all of the PHP source included. To run the
+ * phar just type 'php generate-phpt.phar <options>' at the command line.
+ */
+
+if (Phar::canWrite()) {
+ echo "Writing phar archive\n";
+} else {
+ echo "Unable to write archive, check that phar.readonly is 0 in your php.ini\n";
+ exit();
+}
+$thisDir = dirname(__FILE__);
+$pharPath = substr($thisDir, 0, -strlen('/generate-phpt'));
+
+$phar = new Phar($pharPath.'/generate-phpt.phar');
+
+$phar->buildFromDirectory($thisDir.'/src');
+
+$stub = <<<ENDSTUB
+<?php
+Phar::mapPhar('generate-phpt.phar');
+require 'phar://generate-phpt.phar/generate-phpt.php';
+__HALT_COMPILER();
+ENDSTUB;
+
+$phar->setStub($stub);
+
+?>
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/array.txt b/scripts/dev/generate-phpt/src/codeSnippets/array.txt
new file mode 100644
index 0000000..69a4af7
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/array.txt
@@ -0,0 +1,9 @@
+$index_array = array(1, 2, 3);
+$assoc_array = array(1 => 'one', 2 => 'two');
+
+$variation_array = array(
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/boolean.txt b/scripts/dev/generate-phpt/src/codeSnippets/boolean.txt
new file mode 100644
index 0000000..53db40d
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/boolean.txt
@@ -0,0 +1,6 @@
+$variation_array = array(
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/commentEnd.txt b/scripts/dev/generate-phpt/src/codeSnippets/commentEnd.txt
new file mode 100644
index 0000000..d116022
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/commentEnd.txt
@@ -0,0 +1,2 @@
+ *
+ */ \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/commentStart.txt b/scripts/dev/generate-phpt/src/codeSnippets/commentStart.txt
new file mode 100644
index 0000000..e3466d5
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/commentStart.txt
@@ -0,0 +1,2 @@
+/**
+ * \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/emptyUnsetUndefNull.txt b/scripts/dev/generate-phpt/src/codeSnippets/emptyUnsetUndefNull.txt
new file mode 100644
index 0000000..7e28494
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/emptyUnsetUndefNull.txt
@@ -0,0 +1,11 @@
+$unset_var = 10;
+unset($unset_var);
+
+$variation_array = array(
+ 'unset var' => @$unset_var,
+ 'undefined var' => @$undefined_var,
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/float.txt b/scripts/dev/generate-phpt/src/codeSnippets/float.txt
new file mode 100644
index 0000000..75c2b6c
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/float.txt
@@ -0,0 +1,7 @@
+$variation_array = array(
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/int.txt b/scripts/dev/generate-phpt/src/codeSnippets/int.txt
new file mode 100644
index 0000000..cdd28ae
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/int.txt
@@ -0,0 +1,6 @@
+$variation_array = array (
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/loopClose.txt b/scripts/dev/generate-phpt/src/codeSnippets/loopClose.txt
new file mode 100644
index 0000000..ff30235
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/loopClose.txt
@@ -0,0 +1 @@
+} \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/loopStart.txt b/scripts/dev/generate-phpt/src/codeSnippets/loopStart.txt
new file mode 100644
index 0000000..8fd5eb2
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/loopStart.txt
@@ -0,0 +1 @@
+foreach ( $variation_array as $var ) { \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/object.txt b/scripts/dev/generate-phpt/src/codeSnippets/object.txt
new file mode 100644
index 0000000..28ee61b
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/object.txt
@@ -0,0 +1,25 @@
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+
+
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+$variation_array = array(
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/skipif64b.txt b/scripts/dev/generate-phpt/src/codeSnippets/skipif64b.txt
new file mode 100644
index 0000000..f05e980
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/skipif64b.txt
@@ -0,0 +1 @@
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/skipifnot64b.txt b/scripts/dev/generate-phpt/src/codeSnippets/skipifnot64b.txt
new file mode 100644
index 0000000..e44071a
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/skipifnot64b.txt
@@ -0,0 +1 @@
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/skipifnotwin.txt b/scripts/dev/generate-phpt/src/codeSnippets/skipifnotwin.txt
new file mode 100644
index 0000000..75ea3e1
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/skipifnotwin.txt
@@ -0,0 +1 @@
+if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/skipifwin.txt b/scripts/dev/generate-phpt/src/codeSnippets/skipifwin.txt
new file mode 100644
index 0000000..f712116
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/skipifwin.txt
@@ -0,0 +1 @@
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test is not for Windows platforms");
diff --git a/scripts/dev/generate-phpt/src/codeSnippets/string.txt b/scripts/dev/generate-phpt/src/codeSnippets/string.txt
new file mode 100644
index 0000000..a1d4237
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/codeSnippets/string.txt
@@ -0,0 +1,10 @@
+$heredoc = <<<EOT
+hello world
+EOT;
+
+$variation_array = array(
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+ ); \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/generate-phpt.php b/scripts/dev/generate-phpt/src/generate-phpt.php
new file mode 100644
index 0000000..4f57a70
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/generate-phpt.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * Main code for test case generation
+ */
+
+require_once dirname(__FILE__) . '/gtAutoload.php';
+
+//Version check. Will not run on less than PHP53;
+
+list($major, $minor, $bug) = explode(".", phpversion(), 3);
+ if($major == 5) {
+ if($minor < 3) { die("Sorry, you need PHP version 5.3 or greater to run this.\n"); }
+ }
+ if ($major < 5) { die ("Seriously, you need to upgrade you PHP level\n"); }
+
+
+$options = new gtCommandLineOptions();
+$optionalSections = new gtOptionalSections();
+
+try{
+ $options->parse($argv);
+} catch (exception $e) {
+ echo $e->getMessage()."\n";
+ die();
+}
+
+if($options->hasOption('h')) {
+ die(gtText::get('help'));
+}
+
+try {
+ $preConditions = new gtPreConditionList();
+ $preConditions->check($options);
+} catch (exception $e) {
+ echo $e->getMessage()."\n";
+ die();
+}
+
+if($options->hasOption('s')) {
+ $optionalSections->setOptions($options);
+}
+
+
+
+if($options->hasOption('c')) {
+ $name = $options->getOption('c')."_".$options->getOption('m');
+ $method = new gtMethod($options->getOption('c'), $options->getOption('m'));
+
+ $method->setArgumentNames();
+ $method->setArgumentLists();
+ $method->setInitialisationStatements();
+
+ $method->setConstructorArgumentNames();
+ $method->setConstructorInitStatements();
+ $method->setConstructorArgumentList();
+}
+
+if($options->hasOption('f')) {
+ $name = $options->getOption('f');
+ $function = new gtFunction($name);
+ $function->setArgumentNames();
+ $function->setArgumentLists();
+ $function->setInitialisationStatements();
+}
+
+
+if($options->hasOption('b')) {
+ if($options->hasOption('c')) {
+ $testCase = gtBasicTestCase::getInstance($optionalSections, 'method');
+ $testCase->setMethod($method);
+ } else {
+ $testCase = gtBasicTestCase::getInstance($optionalSections);
+ $testCase->setFunction($function);
+ }
+
+ $testCase->constructTestCase();
+ gtTestCaseWriter::write($name, $testCase->toString(), 'b');
+}
+
+if($options->hasOption('e')) {
+ if($options->hasOption('c')) {
+ $testCase = gtErrorTestCase::getInstance($optionalSections, 'method');
+ $testCase->setMethod($method);
+ } else {
+ $testCase = gtErrorTestCase::getInstance($optionalSections);
+ $testCase->setFunction($function);
+ }
+
+ $testCase->constructTestCase();
+ gtTestCaseWriter::write($name, $testCase->toString(), 'e');
+}
+
+
+
+if($options->hasOption('v')) {
+ if($options->hasOption('c')) {
+ $testCaseContainer = gtVariationContainer::getInstance($optionalSections, 'method');
+ $testCaseContainer->setMethod($method);
+ } else {
+ $testCaseContainer = gtVariationContainer::getInstance ($optionalSections);
+ $testCaseContainer->setFunction($function);
+ }
+
+ $testCaseContainer->constructAll();
+
+ $tests = $testCaseContainer->getVariationTests();
+
+ $count = 1;
+ foreach($tests as $test) {
+ gtTestCaseWriter::write($name, $test, 'v', $count);
+ $count++;
+ }
+
+}
+?>
diff --git a/scripts/dev/generate-phpt/src/gtAutoload.php b/scripts/dev/generate-phpt/src/gtAutoload.php
new file mode 100644
index 0000000..8c18c17
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtAutoload.php
@@ -0,0 +1,63 @@
+<?php
+
+
+gtAutoload::init();
+
+/**
+ * Autoloader using a map file (gtClassMap.php)
+ * defining the file to load each class from.
+ */
+class gtAutoload
+{
+ /**
+ * @var array
+ */
+ protected static $classMap;
+
+ /**
+ * @var string
+ */
+ protected static $classPath;
+
+
+ /**
+ * Initialize the autoloader
+ *
+ * @return null
+ */
+ public static function init()
+ {
+ self::$classPath = dirname(__FILE__);
+
+ if (substr(self::$classPath, -1) != '/') {
+ self::$classPath .= '/';
+ }
+
+ if (file_exists(self::$classPath . 'gtClassMap.php')) {
+ include self::$classPath . 'gtClassMap.php';
+ self::$classMap = $gtClassMap;
+ }
+
+ if (function_exists('__autoload')) {
+ spl_autoload_register('__autoload');
+ }
+
+ spl_autoload_register(array('gtAutoload', 'autoload'));
+ }
+
+
+ /**
+ * Autoload method
+ *
+ * @param string $class Class name to autoload
+ * @return null
+ */
+ public static function autoload($class)
+ {
+ if (isset(self::$classMap[$class])) {
+ include self::$classPath . self::$classMap[$class];
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/gtClassMap.php b/scripts/dev/generate-phpt/src/gtClassMap.php
new file mode 100644
index 0000000..3e45b47
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtClassMap.php
@@ -0,0 +1,48 @@
+<?php
+
+ $gtClassMap = array(
+
+ 'gtCodeSnippet' => 'gtCodeSnippet.php',
+ 'gtTestSubject' => 'gtTestSubject.php',
+ 'gtFunction' => 'gtFunction.php',
+ 'gtMethod' => 'gtMethod.php',
+ 'gtTestCaseWriter' => 'gtTestCaseWriter.php',
+ 'gtText' => 'gtText.php',
+
+
+
+ 'gtCommandLineOptions' => 'setup/gtCommandLineOptions.php',
+ 'gtOptionalSections' => 'setup/gtOptionalSections.php',
+ 'gtMissingArgumentException' => 'setup/exceptions/gtMissingArgumentException.php',
+ 'gtUnknownOptionException' => 'setup/exceptions/gtUnknownOptionException.php',
+ 'gtUnknownSectionException' => 'setup/exceptions/gtUnknownSectionException.php',
+ 'gtMissingOptionsException' => 'setup/exceptions/gtMissingOptionsException.php',
+
+ 'gtPreCondition' => 'setup/gtPreCondition.php',
+ 'gtPreConditionList' => 'setup/gtPreConditionList.php',
+ 'gtIsSpecifiedTestType' => 'setup/preconditions/gtIsSpecifiedTestType.php',
+ 'gtIfClassHasMethod' => 'setup/preconditions/gtIfClassHasMethod.php',
+ 'gtIsSpecifiedFunctionOrMethod' => 'setup/preconditions/gtIsSpecifiedFunctionOrMethod.php',
+ 'gtIsValidClass' => 'setup/preconditions/gtIsValidClass.php',
+ 'gtIsValidMethod' => 'setup/preconditions/gtIsValidMethod.php',
+ 'gtIsValidFunction' => 'setup/preconditions/gtIsValidFunction.php',
+
+
+ 'gtTestCase' => 'testcase/gtTestCase.php',
+ 'gtVariationTestCase' => 'testcase/gtVariationTestCase.php',
+ 'gtVariationTestCaseFunction' => 'testcase/gtVariationTestCaseFunction.php',
+ 'gtVariationTestCaseMethod' => 'testcase/gtVariationTestCaseMethod.php',
+
+ 'gtBasicTestCase' => 'testcase/gtBasicTestCase.php',
+ 'gtBasicTestCaseFunction' => 'testcase/gtBasicTestCaseFunction.php',
+ 'gtBasicTestCaseMethod' => 'testcase/gtBasicTestCaseMethod.php',
+
+ 'gtErrorTestCase' => 'testcase/gtErrorTestCase.php',
+ 'gtErrorTestCaseFunction' => 'testcase/gtErrorTestCaseFunction.php',
+ 'gtErrorTestCaseMethod' => 'testcase/gtErrorTestCaseMethod.php',
+
+ 'gtVariationContainer' => 'testcase/gtVariationContainer.php',
+ 'gtVariationContainerMethod' => 'testcase/gtVariationContainerMethod.php',
+ 'gtVariationContainerFunction' => 'testcase/gtVariationContainerFunction.php',
+ );
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/gtCodeSnippet.php b/scripts/dev/generate-phpt/src/gtCodeSnippet.php
new file mode 100644
index 0000000..220fbdf
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtCodeSnippet.php
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * Retrieves code snippets for adding to test cases
+ *
+ */
+class gtCodeSnippet
+{
+
+ /**
+ * get the code snippet and initialise an array with it
+ *
+ * @param string $name
+ * @return array
+ */
+ public static function get($name) {
+
+ $filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';
+
+ if (!file_exists($filename)) {
+ throw new LogicException('The code snippet ' . $name . ' does not exist');
+ }
+
+ $lines = file($filename);
+ foreach($lines as $l) {
+ $array[] = rtrim($l);
+ }
+ return $array;
+ }
+
+
+ /**
+ * Append the code snippet on to an existing array
+ *
+ * @param string $name
+ * @param array $array
+ * @return array
+ */
+ public static function append($name, $array) {
+ $filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';
+
+ if (!file_exists($filename)) {
+ throw new LogicException('The code snippet ' . $name . ' does not exist');
+ }
+
+ $text = file($filename);
+ foreach ($text as $t) {
+ $array[] = rtrim($t);
+ }
+
+ return $array;
+ }
+
+
+ /**
+ * Appends blank entries on to an array
+ *
+ * @param int $numberOfLines
+ * @param array $array
+ * @return array
+ */
+ public static function appendBlankLines($numberOfLines, $array) {
+
+ for ($i=0; $i< $numberOfLines; $i++) {
+ $array[] = "";
+ }
+
+ return $array;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/gtFunction.php b/scripts/dev/generate-phpt/src/gtFunction.php
new file mode 100644
index 0000000..7405821
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtFunction.php
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * Class reperesents a single PHP function.
+ *
+ */
+class gtFunction extends gtTestSubject {
+
+ private $functionName;
+
+ /**
+ * Set the name of the name of the function
+ *
+ * @param string $functionName
+ */
+ public function __construct($functionName) {
+ $this->functionName = $functionName;
+ }
+
+
+ /**
+ * Get the names of function argments and initialise mandatory and optional argument arrays
+ *
+ */
+ public function setArgumentNames() {
+ $function= new ReflectionFunction($this->functionName);
+
+ foreach ($function->getParameters() as $i => $param) {
+ if($param->isOptional()) {
+ $this->optionalArgumentNames[] = $param->getName();
+ } else {
+ $this->mandatoryArgumentNames[] = $param->getName();
+ }
+ }
+ }
+
+
+ /**
+ * Return the name of the function
+ *
+ * @return string
+ */
+ public function getName() {
+ return $this->functionName;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/gtMethod.php b/scripts/dev/generate-phpt/src/gtMethod.php
new file mode 100644
index 0000000..820d7e0
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtMethod.php
@@ -0,0 +1,139 @@
+<?php
+
+/**
+ * Class for method under test (see gtFunction for non-OO tests)
+ */
+class gtMethod extends gtTestSubject {
+
+ private $className;
+ private $methodName;
+ private $constructorArgumentNames;
+ private $constructorArgumentList = '';
+ private $constructorInitialisationStatements;
+
+
+
+ /**
+ * Construct gtMethod object from the class and method names
+ *
+ * @param string $className
+ * @param string $methodName
+ */
+ public function __construct($className, $methodName) {
+ $this->className = $className;
+ $this->methodName = $methodName;
+ }
+
+
+ /**
+ * Set the names of the class constructor arguments. Take only mandatory argument names.
+ *
+ */
+ public function setConstructorArgumentNames() {
+ $reflectionClass = new ReflectionClass($this->className);
+ $constructor = $reflectionClass->getConstructor();
+ foreach($constructor->getParameters() as $i => $param) {
+ //if(!$param->isOptional()) {
+ $this->constructorArgumentNames[] = $param->getName();
+ //}
+ }
+ }
+
+
+ /**
+ * Set the names of the mandatory and optional arguments to the method
+ *
+ */
+ public function setArgumentNames() {
+
+ $methodClass = new reflectionMethod($this->className, $this->methodName);
+ $parameters = $methodClass->getParameters();
+
+ foreach ($methodClass->getParameters() as $i => $param) {
+ if($param->isOptional()) {
+ $this->optionalArgumentNames[] = $param->getName();
+ } else {
+ $this->mandatoryArgumentNames[] = $param->getName();
+ }
+
+ }
+ }
+
+
+ /**
+ * Return the list of constructor argument names
+ *
+ * @return array
+ */
+ public function getConstructorArgumentNames() {
+ return $this->constructorArgumentNames;
+ }
+
+ /**
+ * Return the name of the method
+ *
+ * @return string
+ */
+ public function getName() {
+ return $this->methodName;
+ }
+
+
+ /**
+ * Return the name of the class
+ *
+ * @return string
+ */
+ public function getClassName() {
+ return $this->className;
+ }
+
+ /**
+ * Set the list of arguments to be passed to the constructor
+ *
+ */
+ public function setConstructorArgumentList() {
+ if(count ($this->constructorArgumentNames) > 0) {
+
+ for( $i = 0; $i < count( $this->constructorArgumentNames ); $i++) {
+ $this->constructorArgumentList .= "\$".$this->constructorArgumentNames[$i].", ";
+ }
+ $this->constructorArgumentList = substr($this->constructorArgumentList, 0, -2);
+ }
+ }
+
+
+ /**
+ * Return the list of the arguments to be passed to the constructor
+ *
+ * @return string
+ */
+ public function getConstructorArgumentList() {
+ return $this->constructorArgumentList;
+ }
+
+
+ /**
+ * Set up the source statements that initialise constructor arguments;
+ *
+ */
+ public function setConstructorInitStatements() {
+ if(count ($this->constructorArgumentNames) > 0) {
+ foreach( $this->constructorArgumentNames as $name) {
+ $this->constructorInitialisationStatements[] = "\$".$name." = ";
+ }
+ }
+
+ }
+
+
+ /**
+ * Return the constructor initialisation statements
+ *
+ * @return array
+ */
+ public function getConstructorInitStatements() {
+ return $this->constructorInitialisationStatements;
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/gtTestCaseWriter.php b/scripts/dev/generate-phpt/src/gtTestCaseWriter.php
new file mode 100644
index 0000000..cc57863
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtTestCaseWriter.php
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Writes a single test case to a file
+ *
+ */
+class gtTestCaseWriter {
+
+ public static function write($name, $string, $type, $count = 0) {
+ if ($type == 'b') {
+ $fileName = $name."_basic.phpt";
+ }
+
+ if ($type == 'e') {
+ $fileName = $name."_error.phpt";
+ }
+
+ if ($type == 'v') {
+ $fileName = $name."_variation".$count.".phpt";
+ }
+
+ $fh = fopen($fileName, 'w');
+ fwrite ($fh, $string);
+ fclose($fh);
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/gtTestSubject.php b/scripts/dev/generate-phpt/src/gtTestSubject.php
new file mode 100644
index 0000000..ccf3caa
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtTestSubject.php
@@ -0,0 +1,166 @@
+<?php
+abstract class gtTestSubject {
+
+ protected $optionalArgumentNames;
+ protected $mandatoryArgumentNames;
+
+ protected $extraArgumentList = '';
+ protected $shortArgumentList = '';
+
+ protected $allowedArgumentLists;
+
+ protected $maximumArgumentList;
+
+ protected $initialisationStatements;
+
+
+ /** Return the list of all mandatory argument names
+ *
+ * @return array
+ */
+ public function getMandatoryArgumentNames() {
+ return $this->mandatoryArgumentNames;
+ }
+
+
+ /**
+ * Return the list of all optional argument names
+ *
+ * @return array
+ */
+ public function getOptionalArgumentNames() {
+ return $this->optionalArgumentNames;
+ }
+
+ public function setArgumentLists() {
+ $this->setValidArgumentLists();
+ $this->setExtraArgumentList();
+ $this->setShortArgumentList();
+ }
+
+ /**
+ * Set the argument list to call the subject with. Adds one extra argument.
+ *
+ */
+ public function setExtraArgumentList() {
+ if(count ($this->mandatoryArgumentNames) > 0) {
+ for( $i = 0; $i < count( $this->mandatoryArgumentNames ); $i++) {
+ $this->extraArgumentList .= "\$".$this->mandatoryArgumentNames[$i].", ";
+ }
+ }
+
+ if(count ($this->optionalArgumentNames) > 0) {
+ for( $i = 0; $i < count( $this->optionalArgumentNames ); $i++) {
+ $this->extraArgumentList .= "\$".$this->optionalArgumentNames[$i].", ";
+ }
+ }
+
+ $this->extraArgumentList= $this->extraArgumentList. "\$extra_arg";
+ }
+
+
+ /**
+ * Return the list of arguments as it appears in the function call
+ *
+ * @return string - list of arguments
+ */
+ public function getExtraArgumentList() {
+ return $this->extraArgumentList;
+ }
+
+
+ /**
+ * Set the list of function arguments to be one less that the number of mandatory arguments
+ *
+ */
+ public function setShortArgumentList() {
+
+ if(count ($this->mandatoryArgumentNames) > 0) {
+ for( $i = 0; $i < count( $this->mandatoryArgumentNames ) - 1; $i++) {
+ $this->shortArgumentList .= "\$".$this->mandatoryArgumentNames[$i].", ";
+ }
+ $this->shortArgumentList = substr($this->shortArgumentList, 0, -2);
+ }
+ }
+
+
+ /**
+ * Return the short list of arguments
+ *
+ * @return string - list of arguments
+ */
+ public function getShortArgumentList() {
+ return $this->shortArgumentList;
+ }
+
+
+ /**
+ * Construct the list of all possible ways to call the subject (function or method)
+ *
+ */
+ public function setValidArgumentLists() {
+ $this->allowedArgumentLists[0] = '';
+ if(count ($this->mandatoryArgumentNames) > 0) {
+ for( $i = 0; $i < count( $this->mandatoryArgumentNames ); $i++) {
+ $this->allowedArgumentLists[0] .= "\$".$this->mandatoryArgumentNames[$i].", ";
+ }
+ }
+
+ if(count ($this->optionalArgumentNames) > 0) {
+ for( $i = 0; $i < count( $this->optionalArgumentNames ); $i++) {
+ $this->allowedArgumentLists[] = $this->allowedArgumentLists[$i]."\$".$this->optionalArgumentNames[$i].", ";
+ $this->allowedArgumentLists[$i] = substr ($this->allowedArgumentLists[$i], 0, -2);
+ }
+ }
+
+ $this->allowedArgumentLists[count($this->allowedArgumentLists) -1 ] = substr($this->allowedArgumentLists[count($this->allowedArgumentLists) -1 ], 0, -2);
+ }
+
+
+ /**
+ * Return the array of all possible sets of method/function arguments
+ *
+ * @return unknown
+ */
+ public function getValidArgumentLists() {
+ return $this->allowedArgumentLists;
+ }
+
+
+ /**
+ * Returns the argument list with the greatest possible number of arguments.
+ *
+ * @return string
+ */
+ public function getMaximumArgumentList() {
+ return end($this->allowedArgumentLists);
+ }
+
+
+ /**
+ * Write initialisation statemenst for all the variables that might be used
+ *
+ */
+ public function setInitialisationStatements() {
+ if(count ($this->mandatoryArgumentNames) > 0) {
+ foreach( $this->mandatoryArgumentNames as $name) {
+ $this->initialisationStatements[] = "\$".$name." = ";
+ }
+ }
+ if(count ($this->optionalArgumentNames) > 0) {
+ foreach( $this->optionalArgumentNames as $name) {
+ $this->initialisationStatements[] = "\$".$name." = ";
+ }
+ }
+ }
+
+ /**
+ * Return the initialisation statements
+ *
+ * @return unknown
+ */
+ public function getInitialisationStatements() {
+ return $this->initialisationStatements;
+ }
+}
+?>
diff --git a/scripts/dev/generate-phpt/src/gtText.php b/scripts/dev/generate-phpt/src/gtText.php
new file mode 100644
index 0000000..8cbd165
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/gtText.php
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Get a text message
+ *
+ */
+class gtText
+{
+
+ /**
+ * Get the text message and return it
+ *
+ * @param string $name
+ * @return string
+ */
+ public static function get($name) {
+ $filename = dirname(__FILE__) . '/texts/' . $name . '.txt';
+
+ if (!file_exists($filename)) {
+ throw new LogicException('The text ' . $name . ' does not exist');
+ }
+
+ return file_get_contents($filename);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php
new file mode 100644
index 0000000..91638e5
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php
@@ -0,0 +1,7 @@
+<?php
+
+ class gtMissingArgumentException extends RuntimeException
+ {
+ }
+
+?>
diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php
new file mode 100644
index 0000000..5bff5e0
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php
@@ -0,0 +1,7 @@
+<?php
+
+ class gtMissingOptionsException extends RuntimeException
+ {
+ }
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php
new file mode 100644
index 0000000..9b1a820
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php
@@ -0,0 +1,7 @@
+<?php
+
+ class gtUnknownOptionException extends RuntimeException
+ {
+ }
+
+?>
diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php
new file mode 100644
index 0000000..c484324
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php
@@ -0,0 +1,6 @@
+<?php
+
+class gtUnknownSectionException extends RuntimeException
+ {
+ }
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php b/scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php
new file mode 100644
index 0000000..0e4d878
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ * Parse command line options
+ *
+ */
+class gtCommandLineOptions {
+
+ protected $shortOptions = array(
+ 'b',
+ 'e',
+ 'v',
+ 'h',
+ );
+
+ protected $shortOptionsWithArgs = array(
+ 'c',
+ 'm',
+ 'f',
+ 'i',
+ 's',
+ 'x',
+ 'k',
+ );
+
+ protected $options;
+
+ protected function isShortOption($arg)
+ {
+ return (substr($arg, 0, 1) == '-') && (substr($arg, 1, 1) != '-');
+ }
+
+ public function isValidOptionArg($array, $index) {
+ if (!isset($array[$index]))
+ {
+ return false;
+ }
+ return substr($array[$index], 0, 1) != '-';
+ }
+
+
+ public function parse($argv)
+ {
+ if(count($argv) < 2) {
+ throw new gtMissingOptionsException('Command line options are required');
+ }
+
+ for ($i=1; $i<count($argv); $i++) {
+
+ if ($this->isShortOption($argv[$i])) {
+ $option = substr($argv[$i], 1);
+ } else {
+ throw new gtUnknownOptionException('Unrecognised command line option ' . $argv[$i]);
+ }
+
+ if (!in_array($option, array_merge($this->shortOptions, $this->shortOptionsWithArgs)))
+ {
+ throw new gtUnknownOptionException('Unknown option ' . $argv[$i]);
+ }
+
+ if (in_array($option, $this->shortOptions)) {
+ $this->options[$option] = true;
+ continue;
+ }
+
+ if (!$this->isValidOptionArg($argv, $i + 1))
+ {
+ throw new gtMissingArgumentException('Missing argument for command line option ' . $argv[$i]);
+ }
+
+ $i++;
+ $this->options[$option] = $argv[$i];
+ }
+ }
+
+ /**
+ *
+ */
+ public function getOption($option)
+ {
+ if (!isset($this->options[$option])) {
+ return false;
+ }
+ return $this->options[$option];
+ }
+
+
+ /**
+ * Check whether an option exists
+ */
+ public function hasOption($option)
+ {
+ return isset($this->options[$option]);
+ }
+
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/gtOptionalSections.php b/scripts/dev/generate-phpt/src/setup/gtOptionalSections.php
new file mode 100644
index 0000000..1d2a163
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/gtOptionalSections.php
@@ -0,0 +1,85 @@
+<?php
+class gtOptionalSections {
+
+ private $optSections = array(
+ 'skipif' => false,
+ 'ini' => false,
+ 'clean' => false,
+ 'done' => false,
+ );
+
+ private $skipifKey = '';
+ private $skipifExt = '';
+
+
+ public function setOptions($commandLineOptions) {
+ if($commandLineOptions->hasOption('s')) {
+ $options = explode(':', $commandLineOptions->getOption('s'));
+
+ foreach($options as $option) {
+
+ if(array_key_exists($option, $this->optSections )) {
+ $this->optSections[$option] = true;
+ } else {
+ throw new gtUnknownSectionException('Unrecognised optional section');
+ }
+ }
+
+ if($commandLineOptions->hasOption('k')) {
+ $this->skipifKey = $commandLineOptions->getOption('k');
+ }
+
+ if($commandLineOptions->hasOption('x')) {
+ $this->skipifExt = $commandLineOptions->getOption('x');
+ }
+
+ }
+ }
+
+
+
+ public function getOptions() {
+ return $this->optSections;
+ }
+
+
+ public function getSkipifKey() {
+ return $this->skipifKey;
+ }
+
+ public function getSkipifExt() {
+ return $this->skipifExt;
+ }
+
+ public function hasSkipif() {
+ return $this->optSections['skipif'];
+ }
+
+ public function hasSkipifKey() {
+ if($this->skipifKey != '') {
+ return true;
+ }
+ return false;
+ }
+
+ public function hasSkipifExt() {
+ if($this->skipifExt != '') {
+ return true;
+ }
+ return false;
+ }
+ public function hasIni() {
+ return $this->optSections['ini'];
+ }
+
+ public function hasClean() {
+ return $this->optSections['clean'];
+ }
+
+ public function hasDone() {
+ return $this->optSections['done'];
+ }
+
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/gtPreCondition.php b/scripts/dev/generate-phpt/src/setup/gtPreCondition.php
new file mode 100644
index 0000000..858395b
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/gtPreCondition.php
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * parent class for preconditions
+ *
+ */
+abstract class gtPreCondition {
+
+ abstract public function check($clo);
+
+ abstract public function getMessage();
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/gtPreConditionList.php b/scripts/dev/generate-phpt/src/setup/gtPreConditionList.php
new file mode 100644
index 0000000..06c1752
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/gtPreConditionList.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * List of preconditions.
+ *
+ */
+class gtPreConditionList {
+
+ private $preConditions = array(
+ 'gtIsSpecifiedTestType',
+ 'gtIsSpecifiedFunctionOrMethod',
+ 'gtIfClassHasMethod',
+ 'gtIsValidClass',
+ 'gtIsValidFunction',
+ 'gtIsValidMethod',
+ );
+
+
+ /**
+ * Create an instance of each pre-condition and run their check methods
+ *
+ */
+ public function check($clo) {
+ foreach ($this->preConditions as $preCon) {
+ $checkThis = new $preCon;
+ if(!$checkThis->check($clo)) {
+ echo $checkThis->getMessage();
+ die(gtText::get('help'));
+ }
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php
new file mode 100644
index 0000000..c91b210
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * If use has requested a class check that method is specified
+ *
+ */
+class gtIfClassHasMethod extends gtPreCondition {
+
+ public function check( $clo) {
+ if($clo->hasOption('c')) {
+ if(!$clo->hasOption('m')) {
+ return false;
+ }
+ return true;
+ }
+ return true;
+ }
+
+ public function getMessage() {
+ return gtText::get('methodNotSpecified');
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php
new file mode 100644
index 0000000..7495c73
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Check that either a method or a function is specified
+ *
+ */
+class gtIsSpecifiedFunctionOrMethod extends gtPreCondition {
+
+ public function check( $clo) {
+ if($clo->hasOption('f') || $clo->hasOption('m')) {
+
+ return true;
+ }
+ return false;
+ }
+
+ public function getMessage() {
+ return gtText::get('functionOrMethodNotSpecified');
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php
new file mode 100644
index 0000000..40530f3
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Check that b|c|v is specified
+ *
+ */
+class gtIsSpecifiedTestType extends gtPreCondition {
+
+ public function check( $clo) {
+ if($clo->hasOption('b') || $clo->hasOption('e') || $clo->hasOption('v') ) {
+
+ return true;
+ }
+ return false;
+ }
+
+ public function getMessage() {
+ return gtText::get('testTypeNotSpecified');
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php
new file mode 100644
index 0000000..a39bab4
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Check that the class name is valid
+ *
+ */
+class gtIsValidClass extends gtPreCondition {
+
+ public function check( $clo) {
+ if($clo->hasOption('c') ) {
+ $className = $clo->getOption('c');
+ if( in_array( $className, get_declared_classes() ) ) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ public function getMessage() {
+ return gtText::get('unknownClass');
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php
new file mode 100644
index 0000000..ed91c2c
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * Check that the function name is valid
+ *
+ */
+class gtIsValidFunction extends gtPreCondition {
+
+ public function check( $clo) {
+ if($clo->hasOption('f') ) {
+ $function = $clo->getOption('f');
+ $functions = get_defined_functions();
+ if( in_array( $function, $functions['internal'] ) ) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ public function getMessage() {
+ return gtText::get('unknownFunction');
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php
new file mode 100644
index 0000000..a52988a
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Check that the method name is valid
+ *
+ */
+class gtIsValidMethod extends gtPreCondition {
+
+ public function check( $clo) {
+ if($clo->hasOption('m') ) {
+ $className = $clo->getOption('c');
+ $class = new ReflectionClass($className);
+ $methods = $class->getMethods();
+ foreach($methods as $method) {
+ if($clo->getOption('m') == $method->getName()) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ public function getMessage() {
+ return gtText::get('unknownMethod');
+ }
+}
+?>
diff --git a/scripts/dev/generate-phpt/src/testcase/gtBasicTestCase.php b/scripts/dev/generate-phpt/src/testcase/gtBasicTestCase.php
new file mode 100644
index 0000000..684c24d
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtBasicTestCase.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Class for basic test case construction
+ */
+
+abstract class gtBasicTestCase extends gtTestCase {
+
+ protected $subject;
+
+
+ /**
+ * Returns an instance of a test case for a method or a function
+ *
+ * @param string $type
+ * @return test case object
+ */
+ public static function getInstance($optionalSections, $type = 'function') {
+ if($type == 'function') {
+ return new gtBasicTestCaseFunction($optionalSections);
+ }
+ if($type =='method') {
+ return new gtBasicTestCaseMethod($optionalSections);
+ }
+ }
+
+ public function constructSubjectCalls() {
+ $this->argInit();
+ $this->subjectCalls();
+ }
+
+ public function addBasicEcho() {
+ $this->testCase[] = "echo \"*** Test by calling method or function with its expected arguments ***\\n\";";
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseFunction.php b/scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseFunction.php
new file mode 100644
index 0000000..f64c6da
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseFunction.php
@@ -0,0 +1,62 @@
+<?php
+
+/**
+ * Basic test case for a PHP function
+ *
+ */
+class gtBasicTestCaseFunction extends gtBasicTestCase {
+
+
+ public function __construct($opt) {
+ $this->optionalSections = $opt;
+ }
+
+ /**
+ * Set the function name
+ *
+ * @param gtFunction $function
+ */
+ public function setFunction($function) {
+ $this->subject = $function;
+ }
+
+ public function constructTestCase() {
+ $this->constructCommonHeaders();
+
+ $this->addBasicEcho();
+
+ $this->constructSubjectCalls();
+
+ $this->constructCommonClosing();
+
+ }
+
+
+ /**
+ * Construct test case header
+ *
+ */
+ public function testHeader() {
+ //Opening section and start of test case array.
+ $this->testCase[] = "--TEST--";
+ $this->testCase[] = "Test function ".$this->subject->getName()."() by calling it with its expected arguments";
+ }
+
+ /**
+ * Add the test section to call the function
+ *
+ */
+ public function subjectCalls() {
+ // Construct the argument list to pass to the function being tested
+ $lists = $this->subject->getValidArgumentLists();
+
+ foreach($lists as $list){
+
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ $this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
+ }
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseMethod.php b/scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseMethod.php
new file mode 100644
index 0000000..3d3896e
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtBasicTestCaseMethod.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Class for basic test case construction for class methods
+ */
+class gtBasicTestCaseMethod extends gtBasicTestCase {
+
+ public function __construct($opt) {
+ $this->optionalSections = $opt;
+ }
+
+ /**
+ * Set the method
+ *
+ * @param gtMethod $method
+ */
+ public function setMethod($method) {
+ $this->subject = $method;
+ }
+
+public function constructTestCase() {
+ $this->constructCommonHeaders();
+
+ $this->addBasicEcho();
+
+ $this->constructorArgInit();
+ $this->constructorCreateInstance();
+
+ $this->constructSubjectCalls();
+
+ $this->constructCommonClosing();
+
+ }
+
+ public function testHeader() {
+ $this->testCase[] = "--TEST--";
+ $this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by calling it with its expected arguments";
+
+ }
+
+ public function subjectCalls() {
+ $lists = $this->subject->getValidArgumentLists();
+
+ foreach($lists as $list){
+ $this->testCase[] = "var_dump( \$class->".$this->subject->getName()."( ".$list." ) );";
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ }
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtErrorTestCase.php b/scripts/dev/generate-phpt/src/testcase/gtErrorTestCase.php
new file mode 100644
index 0000000..214e3d2
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtErrorTestCase.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Class for simple errors - one too many args and one too few
+ */
+
+abstract class gtErrorTestCase extends gtTestCase {
+
+ protected $shortArgumentList = '';
+ protected $longArgumentList = '';
+
+
+ /**
+ * Return instance of either method or function error test case
+ *
+ * @param string $type
+ * @return test case object
+ */
+ public static function getInstance($optionalSections, $type = 'function') {
+
+ if($type == 'function') {
+ return new gtErrorTestCaseFunction($optionalSections);
+ }
+ if($type =='method') {
+ return new gtErrorTestCaseMethod($optionalSections);
+ }
+
+ }
+
+ public function getShortArgumentList() {
+ return $this->shortArgumentList;
+ }
+
+ public function getLongArgumentList() {
+ return $this->longArgumentList;
+ }
+
+ public function constructSubjectCalls() {
+ $this->argInit();
+
+ //Initialise the additional argument
+ $this->testCase[] = "\$extra_arg = ";
+
+ $this->subjectCalls();
+ }
+
+ public function addErrorEcho() {
+ $this->testCase[] = "echo \"*** Test by calling method or function with incorrect numbers of arguments ***\\n\";";
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ }
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseFunction.php b/scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseFunction.php
new file mode 100644
index 0000000..2453acf
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseFunction.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Error test case for a PHP function
+ *
+ */
+class gtErrorTestCaseFunction extends gtErrorTestCase {
+
+ public function __construct($opt) {
+ $this->optionalSections = $opt;
+ }
+
+ /**
+ * Set the function name
+ *
+ * @param string $function
+ */
+ public function setFunction($function) {
+ $this->subject = $function;
+ }
+
+
+ /**
+ * Construct the test case as an array of strings
+ *
+ */
+ public function constructTestCase() {
+ $this->constructCommonHeaders();
+
+ $this->addErrorEcho();
+
+ $this->constructSubjectCalls();
+
+ $this->constructCommonClosing();
+
+ }
+
+
+ public function testHeader() {
+ $this->testCase[] = "--TEST--";
+ $this->testCase[] = "Test function ".$this->subject->getName()."() by calling it more than or less than its expected arguments";
+ }
+
+ public function subjectCalls() {
+ // Construct the argument lists to pass to the function being tested
+ $list = $this->subject->getExtraArgumentList();
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ $this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
+
+ $list = $this->subject->getShortArgumentList();
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ $this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseMethod.php b/scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseMethod.php
new file mode 100644
index 0000000..647e52f
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtErrorTestCaseMethod.php
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * Error test case for a PHP method
+ *
+ */
+class gtErrorTestCaseMethod extends gtErrorTestCase {
+
+ public function __construct($opt) {
+ $this->optionalSections = $opt;
+ }
+ private $method;
+
+ /**
+ * Set the method name
+ *
+ * @param string $method
+ */
+ public function setMethod($method) {
+ $this->subject = $method;
+ }
+
+
+ /**
+ * Construct the test case as an array of strings
+ *
+ */
+ public function constructTestCase() {
+ $this->constructCommonHeaders();
+
+ $this->addErrorEcho();
+
+ $this->constructorArgInit();
+ $this->constructorCreateInstance();
+
+ $this->constructSubjectCalls();
+
+ $this->constructCommonClosing();
+ }
+
+ public function testHeader() {
+ $this->testCase[] = "--TEST--";
+ $this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by calling it more than or less than its expected arguments";
+ }
+
+ public function subjectCalls() {
+
+ // Construct the argument list to pass to the method being tested
+ $list = $this->subject->getExtraArgumentList();
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ $this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
+
+ $list = $this->subject->getShortArgumentList();
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ $this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
+
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtTestCase.php b/scripts/dev/generate-phpt/src/testcase/gtTestCase.php
new file mode 100644
index 0000000..cc5e19a
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtTestCase.php
@@ -0,0 +1,230 @@
+<?php
+
+/**
+ * Class for all test cases
+ */
+abstract class gtTestCase {
+
+
+ /**
+ * The subject of the test, may be either a function (gtFunction) or a method (gtMethod)
+ *
+ * @var gtMethod or gtFunction
+ */
+ protected $subject;
+
+
+ /**
+ * Arry of strings containing the test case
+ *
+ * @var array
+ */
+ protected $testCase;
+
+
+ /**
+ * Object containing the optional sections that may be added to the test case
+ *
+ * @var gtOptionalSections
+ */
+ protected $optionalSections;
+
+
+ /**
+ * Convert test case from array to string
+ *
+ * @return string
+ */
+ public function toString() {
+ $testCaseString = "";
+ foreach($this->testCase as $line) {
+ $testCaseString .= $line."\n";
+ }
+ return $testCaseString;
+ }
+
+
+
+ /**
+ * Returns test case as a array
+ *
+ * @return array
+ */
+ public function getTestCase() {
+ return $this->testCase;
+ }
+
+
+ /**
+ * Construct the common headers (title, file section..) of the test case
+ *
+ */
+ public function ConstructCommonHeaders() {
+ $this->testHeader();
+
+ if($this->optionalSections->hasSkipif()) {
+ $this->addSkipif();
+ }
+
+ if($this->optionalSections->hasIni()) {
+ $this->addIni();
+ }
+
+ $this->fileOpening();
+ }
+
+
+ /**
+ * Construct the common closing statements (clean, done, EXPECTF...)
+ *
+ */
+ public function ConstructCommonClosing() {
+ $this->fileClosing();
+
+ if ($this->optionalSections->hasDone()) {
+ $this->addDone();
+ }
+
+ if ($this->optionalSections->hasClean()) {
+ $this->addClean();
+ }
+
+ $this->addExpectf();
+ }
+
+ /**
+ * Start the FILE section of the test
+ *
+ */
+ public function fileOpening() {
+ $this->testCase[] = "--FILE--";
+ $this->testCase[] = "<?php";
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+
+ /**
+ * Add contructor argument initialisation to test case
+ *
+ */
+ public function constructorArgInit() {
+ $conStatements = $this->subject->getConstructorInitStatements();
+ foreach($conStatements as $statement) {
+ $this->testCase[] = $statement;
+ }
+ }
+
+
+ /**
+ * Create instance of class in the test case
+ *
+ */
+ public function constructorCreateInstance() {
+ $constructorList = $this->subject->getConstructorArgumentList();
+ $this->testCase[] = "\$class = new ".$this->subject->getClassName()."( ".$constructorList." );";
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+
+ /**
+ * Add function or method initilaisation statements to the test case
+ *
+ */
+ public function argInit() {
+ $statements = $this->subject->getInitialisationStatements();
+ foreach($statements as $statement) {
+ $this->testCase[] = $statement;
+ }
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+
+ /**
+ * Add FILE section closing tag to the test case
+ *
+ */
+ public function fileClosing() {
+ $this->testCase[] = "?>";
+ }
+
+
+ /**
+ * Add a skipif section to the test case
+ *
+ */
+ public function addSkipif() {
+ $this->testCase[] = "--SKIPIF--";
+ $this->testCase[] = "<?php";
+ if($this->optionalSections->hasSkipifKey()) {
+ $key = $this->optionalSections->getSkipifKey();
+ //test standard skipif sections
+ if($key == 'win') {
+ $this->testCase = gtCodeSnippet::append('skipifwin', $this->testCase);
+ }
+ if($key == 'notwin' ) {
+ $this->testCase = gtCodeSnippet::append('skipifnotwin', $this->testCase);
+ }
+
+ if($key == '64b' ) {
+ $this->testCase = gtCodeSnippet::append('skipif64b', $this->testCase);
+ }
+
+ if($key == 'not64b' ) {
+ $this->testCase = gtCodeSnippet::append('skipifnot64b', $this->testCase);
+ }
+ }
+
+ if($this->optionalSections->hasSkipifExt()) {
+ $ext = $this->optionalSections->getSkipifExt();
+ $this->testCase[] = "if (!extension_loaded('$ext')) die ('skip $ext extension not available in this build');";
+ }
+ $this->testCase[] = "?>";
+ }
+
+
+ /**
+ * Add an INI section to the test case
+ *
+ */
+ public function addIni() {
+ $this->testCase[] = "--INI--";
+ $this->testCase[] = "";
+ }
+
+
+ /**
+ * Add a clean section to the test case
+ *
+ */
+ public function addClean() {
+ $this->testCase[] = "--CLEAN--";
+ $this->testCase[] = "<?php";
+ $this->testCase[] = "?>";
+ }
+
+
+ /**
+ * Add a ===DONE=== statement to the test case
+ *
+ */
+ public function addDone() {
+ $this->testCase[] = "===DONE===";
+ }
+
+
+ /**
+ * Add an EXPECTF section
+ *
+ */
+ public function addExpectf() {
+ $this->testCase[] = "--EXPECTF--";
+ if ($this->optionalSections->hasDone() ){
+ $this->testCase[] = '===DONE===';
+ }
+ }
+
+ public function getOpt() {
+ return $this->optionalSections;
+ }
+}
+?>
diff --git a/scripts/dev/generate-phpt/src/testcase/gtVariationContainer.php b/scripts/dev/generate-phpt/src/testcase/gtVariationContainer.php
new file mode 100644
index 0000000..5995170
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtVariationContainer.php
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * Container for all possible variation test cases
+ */
+abstract class gtVariationContainer {
+
+ protected $variationTests;
+
+ protected $dataTypes = array (
+ 'array',
+ 'boolean',
+ 'emptyUnsetUndefNull',
+ 'float',
+ 'int',
+ 'object',
+ 'string',
+ );
+
+
+
+ /**
+ * Return an instance of a containers for either function or method tests
+ *
+ * @param string $type
+ * @return variation test container
+ */
+ public static function getInstance ($optionalSections, $type = 'function') {
+
+ if($type == 'function') {
+ return new gtVariationContainerFunction($optionalSections);
+ }
+ if($type =='method') {
+ return new gtVariationContainerMethod($optionalSections);
+ }
+
+ }
+
+
+ public function constructAll() {
+ }
+
+
+ /**
+ * Returns all varaition tests as an array of arrays
+ *
+ * @return string
+ */
+ public function getVariationTests() {
+ return $this->variationTests;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtVariationContainerFunction.php b/scripts/dev/generate-phpt/src/testcase/gtVariationContainerFunction.php
new file mode 100644
index 0000000..dfee4ea
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtVariationContainerFunction.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * Container for all possible variation test cases of functions
+ */
+class gtVariationContainerFunction extends gtVariationContainer {
+
+ protected $function;
+ protected $optionalSections;
+
+ public function __construct($osl) {
+ $this->optionalSections = $osl;
+ }
+
+ /**
+ * Sets function being tested
+ *
+ * @param gtFunction $function
+ */
+ public function setFunction(gtFunction $function) {
+ $this->function = $function;
+ }
+
+
+ /**
+ * Constucts all possible variation testcases in array $this->variationTests
+ *
+ */
+ public function constructAll() {
+
+
+ $numberOfArguments = count($this->function->getMandatoryArgumentNames()) + count($this->function->getOptionalArgumentNames());
+ for($i = 1; $i <= $numberOfArguments; $i++) {
+ foreach ($this->dataTypes as $d) {
+ $testCase = gtVariationTestCase::getInstance($this->optionalSections);
+ $testCase->setUp($this->function, $i, $d);
+ $testCase->constructTestCase();
+ $this->variationTests[] = $testCase->toString();
+ }
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtVariationContainerMethod.php b/scripts/dev/generate-phpt/src/testcase/gtVariationContainerMethod.php
new file mode 100644
index 0000000..bee26b0
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtVariationContainerMethod.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Container for all possible variation test cases for a method
+ */
+class gtVariationContainerMethod extends gtVariationContainer {
+
+ protected $method;
+ protected $optionalSections;
+
+ public function __construct($osl) {
+ $this->optionalSections = $osl;
+ }
+
+
+ /**
+ * Sets the method to be tested
+ *
+ * @param gtMethod $method
+ */
+ public function setMethod(gtMethod $method) {
+ $this->method = $method;
+ }
+
+
+ /**
+ * Constructs all variation tests in $this_variationTests
+ *
+ */
+ public function constructAll() {
+
+ $numberOfArguments = count($this->method->getMandatoryArgumentNames()) + count($this->method->getOptionalArgumentNames());
+
+ for($i = 1; $i <= $numberOfArguments; $i++) {
+
+ foreach ($this->dataTypes as $d) {
+
+ $testCase = gtVariationTestCase::getInstance($this->optionalSections, 'method');
+ $testCase->setUp($this->method, $i, $d);
+ $testCase->constructTestCase();
+ $this->variationTests[] = $testCase->toString();
+
+ }
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtVariationTestCase.php b/scripts/dev/generate-phpt/src/testcase/gtVariationTestCase.php
new file mode 100644
index 0000000..039367d
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtVariationTestCase.php
@@ -0,0 +1,55 @@
+
+<?php
+
+/**
+ * Class for extended variations. Needs 'data type' and argument to vary
+ */
+
+abstract class gtVariationTestCase extends gtTestCase {
+
+
+ /**
+ * Returns an instance of a test case for a method or a function
+ *
+ * @param string $type
+ * @return test case object
+ */
+ public static function getInstance($optionalSections, $type = 'function') {
+
+ if($type == 'function') {
+ return new gtVariationTestCaseFunction($optionalSections);
+ }
+ if($type =='method') {
+ return new gtVariationTestCaseMethod($optionalSections);
+ }
+
+ }
+
+ public function argInitVariation() {
+ $statements = $this->subject->getInitialisationStatements();
+ for($i=0; $i<count($statements); $i++) {
+ if($i != ( $this->argumentNumber -1) ) {
+ $this->testCase[] = $statements[$i];
+ }
+ }
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+ public function addVariationCode() {
+ $this->testCase = gtCodeSnippet::append($this->variationData, $this->testCase);
+ $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
+ }
+
+ public function constructSubjectCalls() {
+ $this->argInitVariation();
+ $this->addVariationCode();
+ $this->subjectCalls();
+ }
+
+ public function addVariationEcho() {
+ $this->testCase[] = "echo \"*** Test substituting argument ".$this->argumentNumber." with ".$this->variationData." values ***\\n\";";
+ $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseFunction.php b/scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseFunction.php
new file mode 100644
index 0000000..7bf1c8b
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseFunction.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * Class for variation tests for a PHP function
+ */
+class gtVariationTestCaseFunction extends gtVariationTestCase {
+
+ protected $argumentNumber;
+ protected $variationData;
+ protected $testCase;
+
+ public function __construct($opt) {
+ $this->optionalSections = $opt;
+ }
+ /**
+ * Set data neede to construct variation tests
+ *
+ * @param gtfunction $function
+ * @param string $argumentNumber
+ * @param string $variationData
+ */
+ public function setUp(gtfunction $function, $argumentNumber, $variationData) {
+ $this->subject = $function;
+ $this->argumentNumber = $argumentNumber;
+ $this->variationData = $variationData;
+
+ }
+
+
+ /**
+ * Constructs the test case as a array of strings
+ *
+ */
+ public function constructTestCase() {
+ $this->constructCommonHeaders();
+
+ $this->addVariationEcho();
+
+ $this->constructSubjectCalls();
+
+ $this->constructCommonClosing();
+
+ }
+ public function testHeader() {
+ $this->testCase[] = "--TEST--";
+ $this->testCase[] = "Test function ".$this->subject->getName()."() by substituting argument ".$this->argumentNumber." with ".$this->variationData." values.";
+ }
+
+
+ public function subjectCalls() {
+ $this->testCase = gtCodeSnippet::append('loopStart', $this->testCase);
+
+ // Construct the argument list to pass to the function being tested
+ $argumentList = explode(",", $this->subject->getMaximumArgumentList());
+ $argumentList[$this->argumentNumber -1 ] = "\$var ";
+ $list = implode(", ", $argumentList);
+
+
+ $this->testCase[] = " var_dump(".$this->subject->getName()."( ".$list." ) );";
+ $this->testCase = gtCodeSnippet::append('loopClose', $this->testCase);
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseMethod.php b/scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseMethod.php
new file mode 100644
index 0000000..a9c921f
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseMethod.php
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * Class for variation tests for a PHP method
+ */
+class gtVariationTestCaseMethod extends gtVariationTestCase {
+
+ protected $subject;
+ protected $argumentNumber;
+ protected $variationData;
+ protected $testCase;
+
+ public function __construct($opt) {
+ $this->optionalSections = $opt;
+ }
+
+ /**
+ * Set data neede to construct variation tests
+ *
+ * @param gtMethod $method
+ * @param string $argumentNumber
+ * @param string $variationData
+ */
+ public function setUp(gtMethod $method, $argumentNumber, $variationData) {
+ $this->subject = $method;
+ $this->argumentNumber = $argumentNumber;
+ $this->variationData = $variationData;
+ }
+
+
+ /**
+ * Constructs the test case as a array of strings
+ *
+ */
+ public function constructTestCase() {
+ $this->constructCommonHeaders();
+
+ $this->addVariationEcho();
+
+ $this->constructorArgInit();
+ $this->constructorCreateInstance();
+
+ $this->constructSubjectcalls();
+ $this->constructCommonClosing();
+
+ }
+
+ public function testHeader() {
+ $this->testCase[] = "--TEST--";
+ $this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by substituting argument ".$this->argumentNumber." with ".$this->variationData." values.";
+ }
+
+ public function subjectCalls() {
+ $this->testCase = gtCodeSnippet::append('loopStart', $this->testCase);
+ // Construct the argument list to pass to the method being tested
+ $argumentList = explode(",", $this->subject->getMaximumArgumentList());
+ $argumentList[$this->argumentNumber -1 ] = "\$var ";
+ $list = implode(", ", $argumentList);
+
+
+ $this->testCase[] = " var_dump(\$class->".$this->subject->getName()."( ".$list." ) );";
+ $this->testCase = gtCodeSnippet::append('loopClose', $this->testCase);
+
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/src/texts/functionOrMethodNotSpecified.txt b/scripts/dev/generate-phpt/src/texts/functionOrMethodNotSpecified.txt
new file mode 100644
index 0000000..b497682
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/functionOrMethodNotSpecified.txt
@@ -0,0 +1,3 @@
+
+Please supply a function or method name to be tested.
+
diff --git a/scripts/dev/generate-phpt/src/texts/help.txt b/scripts/dev/generate-phpt/src/texts/help.txt
new file mode 100644
index 0000000..cfc3b62
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/help.txt
@@ -0,0 +1,14 @@
+Usage:
+php generate-phpt.php -f <function_name> |-c <class_name> -m <method_name> -b|e|v [-s skipif:ini:clean:done] [-k win|notwin|64b|not64b] [-x ext]
+
+Where:
+-f function_name ................. Name of PHP function, eg cos
+-c class name .....................Name of class, eg DOMDocument
+-m method name ....................Name of method, eg createAttribute
+-b ............................... Generate basic tests
+-e ............................... Generate error tests
+-v ............................... Generate variation tests
+-s sections....................... Create optional sections, colon separated list
+-k skipif key..................... Skipif option, only used if -s skipif is used.
+-x extension.......................Skipif option, specify extension to check for
+-h ............................... Print this message
diff --git a/scripts/dev/generate-phpt/src/texts/methodNotSpecified.txt b/scripts/dev/generate-phpt/src/texts/methodNotSpecified.txt
new file mode 100644
index 0000000..1f11a3a
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/methodNotSpecified.txt
@@ -0,0 +1,4 @@
+
+You have given a class name but not supplied a method name to test.
+The method name is required.
+
diff --git a/scripts/dev/generate-phpt/src/texts/testTypeNotSpecified.txt b/scripts/dev/generate-phpt/src/texts/testTypeNotSpecified.txt
new file mode 100644
index 0000000..e83ddbb
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/testTypeNotSpecified.txt
@@ -0,0 +1,3 @@
+
+Please specify basic, error or variation tests.
+
diff --git a/scripts/dev/generate-phpt/src/texts/unknownClass.txt b/scripts/dev/generate-phpt/src/texts/unknownClass.txt
new file mode 100644
index 0000000..b0a47ca
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/unknownClass.txt
@@ -0,0 +1,4 @@
+
+The class name is not a valid PHP class name.
+Check that the extension containing the class is loaded.
+
diff --git a/scripts/dev/generate-phpt/src/texts/unknownFunction.txt b/scripts/dev/generate-phpt/src/texts/unknownFunction.txt
new file mode 100644
index 0000000..2e76978
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/unknownFunction.txt
@@ -0,0 +1,4 @@
+
+The function name is not a valid PHP function name.
+Check that the extension containing the function is loaded.
+
diff --git a/scripts/dev/generate-phpt/src/texts/unknownMethod.txt b/scripts/dev/generate-phpt/src/texts/unknownMethod.txt
new file mode 100644
index 0000000..8cc9eae
--- /dev/null
+++ b/scripts/dev/generate-phpt/src/texts/unknownMethod.txt
@@ -0,0 +1,4 @@
+
+The method name is not a valid PHP method name.
+Check that the extension containing the method is loaded.
+
diff --git a/scripts/dev/generate-phpt/tests/gtBasicTestCaseFunctionTest.php b/scripts/dev/generate-phpt/tests/gtBasicTestCaseFunctionTest.php
new file mode 100644
index 0000000..dbba0d6
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtBasicTestCaseFunctionTest.php
@@ -0,0 +1,24 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+class gtBasicTestCaseFunctionTest extends PHPUnit_Framework_TestCase {
+
+
+ public function testTestCase() {
+
+ $f = new gtFunction('cos');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+ $f->setInitialisationStatements();
+ $optSect = new gtOptionalSections();
+
+ $btc = gtBasicTestCase::getInstance($optSect);
+ $btc->setFunction($f);
+ $btc->constructTestCase();
+
+ $fs = $btc->toString();
+ $this->assertTrue(is_string($fs));
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtBasicTestCaseMethodTest.php b/scripts/dev/generate-phpt/tests/gtBasicTestCaseMethodTest.php
new file mode 100644
index 0000000..81307f1
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtBasicTestCaseMethodTest.php
@@ -0,0 +1,28 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+class gtBasicTestCaseMethodTest extends PHPUnit_Framework_TestCase {
+
+
+ public function testTestCase() {
+
+ $f = new gtMethod('DOMDocument','createAttribute');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+ $f->setInitialisationStatements();
+ $f->setConstructorArgumentNames();
+ $f->setConstructorInitStatements();
+
+ $optSect = new gtOptionalSections();
+ $btc = gtBasicTestCaseMethod::getInstance($optSect, 'method');
+ $btc->setMethod($f);
+ $btc->constructTestCase();
+
+
+ $fs = $btc->toString();
+ $this->assertTrue(is_string($fs));
+
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtCodeSnippetTest.php b/scripts/dev/generate-phpt/tests/gtCodeSnippetTest.php
new file mode 100644
index 0000000..bc0c48a
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtCodeSnippetTest.php
@@ -0,0 +1,15 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtCodeSnippetTest extends PHPUnit_Framework_TestCase
+{
+
+ public function testAppend() {
+ $array = array('something', 'nothing');
+ $array = gtCodeSnippet::append('loopClose', $array);
+ $this->assertEquals($array[2], '}');
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtCommandLineOptionsTest.php b/scripts/dev/generate-phpt/tests/gtCommandLineOptionsTest.php
new file mode 100644
index 0000000..2fd6818
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtCommandLineOptionsTest.php
@@ -0,0 +1,46 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+ require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+ class gtCommandLineOptionsTest extends PHPUnit_Framework_TestCase
+ {
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testNoOption() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php'));
+ }
+
+ public function testShortOption() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-h'));
+ $this->assertTrue($clo->hasOption('h'));
+ }
+
+ public function testShortOptionArgument() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-f', 'some-function'));
+ $this->assertTrue($clo->hasOption('f'));
+ $this->assertEquals('some-function', $clo->getOption('f'));
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testInvalidOption() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-z'));
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testMissingArgument() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-f'));
+ }
+ }
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtErrorTestCaseFunctionTest.php b/scripts/dev/generate-phpt/tests/gtErrorTestCaseFunctionTest.php
new file mode 100644
index 0000000..5b72fcc
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtErrorTestCaseFunctionTest.php
@@ -0,0 +1,28 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+class gtErrorTestCaseFunctionTest extends PHPUnit_Framework_TestCase {
+
+
+ public function testTestCase() {
+
+ $f = new gtFunction('cos');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+ $f->setInitialisationStatements();
+
+ $optSect = new gtOptionalSections();
+
+ $btc = gtErrorTestCase::getInstance($optSect);
+ $btc->setFunction($f);
+ $btc->constructTestCase();
+
+
+ $fs = $btc->toString();
+ $this->assertTrue(is_string($fs));
+
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtErrorTestCaseMethodTest.php b/scripts/dev/generate-phpt/tests/gtErrorTestCaseMethodTest.php
new file mode 100644
index 0000000..7077881
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtErrorTestCaseMethodTest.php
@@ -0,0 +1,30 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+class gtErrorTestCaseMethodTest extends PHPUnit_Framework_TestCase {
+
+
+ public function testTestCase() {
+
+ $f = new gtMethod('DOMDocument', 'createAttribute');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+
+ $f->setInitialisationStatements();
+
+ $f->setConstructorArgumentNames();
+ $f->setConstructorInitStatements();
+
+ $optSect = new gtOptionalSections();
+
+ $btc = gtErrorTestCase::getInstance($optSect,'method');
+ $btc->setMethod($f);
+ $btc->constructTestCase();
+
+
+ $fs = $btc->toString();
+ $this->assertTrue(is_string($fs));
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtFunctionTest.php b/scripts/dev/generate-phpt/tests/gtFunctionTest.php
new file mode 100644
index 0000000..0aa7eac
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtFunctionTest.php
@@ -0,0 +1,71 @@
+cd
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtFunctionTest extends PHPUnit_Framework_TestCase
+{
+ public function testArguments() {
+
+ $f = new gtFunction('cos');
+ $f->setArgumentNames();
+ $m = $f->getMandatoryArgumentNames();
+ $this->assertEquals($m[0], 'number');
+ }
+
+ public function testArguments2() {
+
+ $f = new gtFunction('version_compare');
+ $f->setArgumentNames();
+ $m = $f->getMandatoryArgumentNames();
+ $o = $f->getOptionalArgumentNames();
+ $this->assertEquals($m[0], 'ver1');
+ $this->assertEquals($m[1], 'ver2');
+ $this->assertEquals($o[0], 'oper');
+
+ }
+
+ public function testExtraArguments() {
+
+ $f = new gtFunction('version_compare');
+ $f->setArgumentNames();
+ $f->setExtraArgumentList();
+
+ $this->assertEquals('$ver1, $ver2, $oper, $extra_arg', $f->getExtraArgumentList());
+ }
+
+ public function testShortArguments() {
+
+ $f = new gtFunction('version_compare');
+ $f->setArgumentNames();
+ $f->setShortArgumentList();
+
+ $this->assertEquals('$ver1', $f->getShortArgumentList());
+ }
+
+ public function testAllArgumentList() {
+
+ $f = new gtFunction('version_compare');
+ $f->setArgumentNames();
+ $f->setValidArgumentLists();
+ $a = $f->getValidArgumentLists();
+
+ $this->assertEquals('$ver1, $ver2', $a[0]);
+ $this->assertEquals('$ver1, $ver2, $oper', $a[1]);
+ }
+
+ public function testInitialisation() {
+
+ $f = new gtFunction('version_compare');
+ $f->setArgumentNames();
+ $f->setInitialisationStatements();
+ $a = $f->getInitialisationStatements();
+
+ $this->assertEquals('$ver1 = ', $a[0]);
+ $this->assertEquals('$ver2 = ', $a[1]);
+ $this->assertEquals('$oper = ', $a[2]);
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtIfClassHasMethodTest.php b/scripts/dev/generate-phpt/tests/gtIfClassHasMethodTest.php
new file mode 100644
index 0000000..b9f2410
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtIfClassHasMethodTest.php
@@ -0,0 +1,41 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtIfClassHasMethodTest extends PHPUnit_Framework_TestCase {
+
+ public function testValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah', '-m', 'blah'));
+ $ch = new gtIfClassHasMethod();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testNotValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIfClassHasMethod();
+ $this->assertFalse($ch->check($clo));
+ }
+
+ public function testNotSpecified() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-b'));
+ $ch = new gtIfClassHasMethod();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testMessage() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIfClassHasMethod();
+ $this->assertEquals($ch->getMessage(), gtText::get('methodNotSpecified'));
+ }
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtIsSpecifiedFunctionOrMethodTest.php b/scripts/dev/generate-phpt/tests/gtIsSpecifiedFunctionOrMethodTest.php
new file mode 100644
index 0000000..064edf3
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtIsSpecifiedFunctionOrMethodTest.php
@@ -0,0 +1,41 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtIsSpecifiedFunctionOrMethodTest extends PHPUnit_Framework_TestCase {
+
+ public function testValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-m', 'blah'));
+ $ch = new gtIsSpecifiedFunctionOrMethod();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testValid2() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-f', 'blah'));
+ $ch = new gtIsSpecifiedFunctionOrMethod();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testNotValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-b'));
+ $ch = new gtIsSpecifiedFunctionOrMethod();
+ $this->assertFalse($ch->check($clo));
+
+ }
+
+ public function testMessage() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIsSpecifiedFunctionOrMethod();
+ $this->assertEquals($ch->getMessage(), gtText::get('functionOrMethodNotSpecified'));
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtIsSpecifiedTestTypeTest.php b/scripts/dev/generate-phpt/tests/gtIsSpecifiedTestTypeTest.php
new file mode 100644
index 0000000..c8b0a4e
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtIsSpecifiedTestTypeTest.php
@@ -0,0 +1,32 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtIsSpecifiedTestTypeTest extends PHPUnit_Framework_TestCase {
+
+ public function testValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'DOMDocument','-b'));
+ $ch = new gtIsSpecifiedTestType();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testNotValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'DOMDocument'));
+ $ch = new gtIsSpecifiedTestType();
+ $this->assertFalse($ch->check($clo));
+ }
+
+ public function testMessage() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIsSpecifiedtestType();
+ $this->assertEquals($ch->getMessage(), gtText::get('testTypeNotSpecified'));
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtIsValidClassTest.php b/scripts/dev/generate-phpt/tests/gtIsValidClassTest.php
new file mode 100644
index 0000000..51ca878
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtIsValidClassTest.php
@@ -0,0 +1,41 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtIsValidClassTest extends PHPUnit_Framework_TestCase {
+
+ public function testValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'DOMDocument'));
+ $ch = new gtIsValidClass();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testNotValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIsValidClass();
+ $this->assertFalse($ch->check($clo));
+ }
+
+ public function testNotGiven() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php','-b'));
+ $ch = new gtIsValidClass();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testMessage() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIsvalidClass();
+ $this->assertEquals($ch->getMessage(), gtText::get('unknownClass'));
+ }
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtIsValidFunctionTest.php b/scripts/dev/generate-phpt/tests/gtIsValidFunctionTest.php
new file mode 100644
index 0000000..d4700b9
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtIsValidFunctionTest.php
@@ -0,0 +1,40 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtIsValidFunctionTest extends PHPUnit_Framework_TestCase {
+
+ public function testValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-f', 'cos'));
+ $ch = new gtIsValidFunction();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testNotValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-f', 'blah'));
+ $ch = new gtIsValidFunction();
+ $this->assertFalse($ch->check($clo));
+ }
+
+ public function testNotSupplied() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php','-b'));
+ $ch = new gtIsValidFunction();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testMessage() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIsvalidFunction();
+ $this->assertEquals($ch->getMessage(), gtText::get('unknownFunction'));
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtIsValidMethodTest.php b/scripts/dev/generate-phpt/tests/gtIsValidMethodTest.php
new file mode 100644
index 0000000..fe06997
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtIsValidMethodTest.php
@@ -0,0 +1,40 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtIsValidMethodTest extends PHPUnit_Framework_TestCase {
+
+ public function testValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'DOMDocument', '-m', 'createAttribute'));
+ $ch = new gtIsValidMethod();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testNotValid() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'DOMDocument', '-m', 'blah'));
+ $ch = new gtIsValidMethod();
+ $this->assertFalse($ch->check($clo));
+ }
+
+ public function testNotGiven() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php','-b'));
+ $ch = new gtIsValidMethod();
+ $this->assertTrue($ch->check($clo));
+ }
+
+ public function testMessage() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-c', 'blah'));
+ $ch = new gtIsvalidMethod();
+ $this->assertEquals($ch->getMessage(), gtText::get('unknownMethod'));
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtMethodTest.php b/scripts/dev/generate-phpt/tests/gtMethodTest.php
new file mode 100644
index 0000000..430161e
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtMethodTest.php
@@ -0,0 +1,82 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtMethodTest extends PHPUnit_Framework_TestCase
+{
+ public function testGetParams() {
+ $m = new gtMethod('DOMDocument', 'createAttribute');
+ $m->setArgumentNames();
+ $a = $m->getMandatoryArgumentNames();
+ $this->assertEquals($a[0], 'name');
+ }
+
+ public function testConstructor() {
+ $m = new gtMethod('DOMDocument', 'createAttribute');
+ $m->setConstructorArgumentNames();
+ $a = $m->getConstructorArgumentNames();
+ $this->assertEquals($a[0], 'version');
+ $this->assertEquals($a[1], 'encoding');
+ }
+
+ public function testExtraParamList() {
+ $m = new gtMethod('DOMDocument', 'createAttribute');
+ $m->setArgumentNames();
+ $m->setExtraArgumentList();
+ $this->assertEquals('$name, $extra_arg',$m->getExtraArgumentList());
+ }
+
+ public function testShortParamList() {
+ $m = new gtMethod('DOMDocument', 'createAttribute');
+ $m->setArgumentNames();
+ $m->setShortArgumentList();
+ $this->assertEquals('',$m->getShortArgumentList());
+ }
+
+ public function testAllParamList() {
+ $m = new gtMethod('DOMDocument', 'createAttribute');
+ $m->setArgumentNames();
+ $m->setValidArgumentLists();
+ $a = $m->getValidArgumentLists();
+ $this->assertEquals('$name',$a[0]);
+ }
+
+ public function testMaxParamList() {
+ $m = new gtMethod('DOMDocument', 'createAttribute');
+ $m->setArgumentNames();
+ $m->setValidArgumentLists();
+ $this->assertEquals('$name',$m->getMaximumArgumentList());
+ }
+
+
+
+ public function testConstructorList() {
+ $m = new gtMethod('Phar', 'buildFromDirectory');
+ $m->setArgumentNames();
+ $m->setConstructorArgumentNames();
+
+ $m->setConstructorArgumentList();
+ $this->assertEquals('$filename, $flags, $alias, $fileformat',$m->getConstructorArgumentList());
+
+ }
+
+ public function testConstructorInit() {
+ $m = new gtMethod('Phar', 'buildFromDirectory');
+ $m->setArgumentNames();
+ $m->setConstructorArgumentNames();
+
+ $m->setConstructorInitStatements();
+ $a = $m->getConstructorInitStatements();
+ $this->assertEquals('$filename = ',$a[0]);
+ $this->assertEquals('$flags = ',$a[1]);
+ $this->assertEquals('$alias = ',$a[2]);
+ $this->assertEquals('$fileformat = ',$a[3]);
+ }
+
+
+
+
+}
+
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtOptionalSectionsTest.php b/scripts/dev/generate-phpt/tests/gtOptionalSectionsTest.php
new file mode 100644
index 0000000..dbf2994
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtOptionalSectionsTest.php
@@ -0,0 +1,58 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+
+class gtOptionalSectionsTest extends PHPUnit_Framework_TestCase
+{
+ public function testBasic() {
+
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-s', 'skipif:ini'));
+
+ $opt = new gtOptionalSections();
+ $opt->setOptions($clo);
+ $a = $opt->getOptions();
+ $this->assertEquals(true, $a['skipif']);
+ $this->assertEquals(true, $a['ini']);
+ $this->assertEquals(false, $a['clean']);
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testException() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-s', 'blah'));
+ $opt = new gtOptionalSections();
+ $opt->setOptions($clo);
+ }
+
+ public function testSkip() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-s', 'skipif', '-x', 'standard'));
+ $opt = new gtOptionalSections();
+ $opt->setOptions($clo);
+
+ $opt = new gtOptionalSections();
+ $opt->setOptions($clo);
+
+ $this->assertEquals('standard', $opt->getSkipifExt() );
+
+ }
+
+ public function testSkipKey() {
+ $clo = new gtCommandLineOptions();
+ $clo->parse(array('generate-phpt.php', '-s', 'skipif', '-k', 'win'));
+ $opt = new gtOptionalSections();
+ $opt->setOptions($clo);
+
+ $opt = new gtOptionalSections();
+ $opt->setOptions($clo);
+
+ $this->assertEquals('win', $opt->getSkipifKey() );
+
+ }
+
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtVariationTestCaseFunctionTest.php b/scripts/dev/generate-phpt/tests/gtVariationTestCaseFunctionTest.php
new file mode 100644
index 0000000..df9f21c
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtVariationTestCaseFunctionTest.php
@@ -0,0 +1,59 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+class gtVariationTestCaseFunctionTest extends PHPUnit_Framework_TestCase {
+
+ public function testTestCase() {
+
+ $f = new gtFunction('cos');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+
+ $optSect = new gtOptionalSections();
+
+ $vtc = gtVariationTestCase::getInstance($optSect);
+ $vtc->setUp($f, 1, 'int');
+ $vtc->constructTestCase();
+
+ $fs = $vtc->toString();
+ $this->assertTrue(is_string($fs));
+
+ }
+
+ public function testTestCase2() {
+
+ $f = new gtFunction('date_sunrise');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+ $a = $f->getMandatoryArgumentNames();
+
+ $optSect = new gtOptionalSections();
+
+ $vtc = gtVariationTestCase::getInstance($optSect);
+ $vtc->setUp($f, 6, 'int');
+ $vtc->constructTestCase();
+
+ $fs = $vtc->toString();
+ $this->assertTrue(is_string($fs));
+
+ }
+
+ public function testTestCase3() {
+
+ $f = new gtFunction('date_sunrise');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+
+ $optSect = new gtOptionalSections();
+
+ $vtc = gtVariationTestCase::getInstance($optSect);
+ $vtc->setUp($f, 6, 'array');
+ $vtc->constructTestCase();
+
+ $fs = $vtc->toString();
+ $this->assertTrue(is_string($fs));
+
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/generate-phpt/tests/gtVariationTestCaseMethodTest.php b/scripts/dev/generate-phpt/tests/gtVariationTestCaseMethodTest.php
new file mode 100644
index 0000000..d99b656
--- /dev/null
+++ b/scripts/dev/generate-phpt/tests/gtVariationTestCaseMethodTest.php
@@ -0,0 +1,27 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '/../src/gtAutoload.php';
+
+class gtVariationTestCaseMethodTest extends PHPUnit_Framework_TestCase {
+
+ public function testTestCase() {
+
+ $f = new gtMethod('DOMDocument','createAttribute');
+ $f->setArgumentNames();
+ $f->setArgumentLists();
+
+ $f->setConstructorArgumentNames();
+ $f->setConstructorInitStatements();
+
+ $optSect = new gtOptionalSections();
+
+ $vtc = gtVariationTestCase::getInstance($optSect, 'method');
+ $vtc->setUp($f, 1, 'int');
+ $vtc->constructTestCase();
+ $fs = $vtc->toString();
+
+ $this->assertTrue(is_string($fs));
+
+ }
+}
+?> \ No newline at end of file
diff --git a/scripts/dev/phpextdist b/scripts/dev/phpextdist
new file mode 100755
index 0000000..97df700
--- /dev/null
+++ b/scripts/dev/phpextdist
@@ -0,0 +1,27 @@
+#! /bin/sh
+if test $# -lt 2; then
+ echo "usage: phpextdist <extension> <version>";
+ exit 1
+fi
+
+phpize=`php-config --prefix`/bin/phpize
+distname="$1-$2"
+
+if test ! -f Makefile.in || test ! -f config.m4; then
+ echo "Did not find required files in current directory"
+ exit 1
+fi
+
+rm -rf modules *.lo *.o *.la config.status config.cache \
+config.log libtool php_config.h config_vars.mk Makefile
+
+myname=`basename \`pwd\``
+cd ..
+cp -rp $myname $distname
+cd $distname
+$phpize
+cd ..
+tar cf $distname.tar $distname
+rm -rf $distname $distname.tar.*
+gzip --best $distname.tar
+mv $distname.tar.gz $myname
diff --git a/scripts/dev/search_underscores.php b/scripts/dev/search_underscores.php
new file mode 100755
index 0000000..445228b
--- /dev/null
+++ b/scripts/dev/search_underscores.php
@@ -0,0 +1,97 @@
+#! /usr/local/bin/php -n
+<?php
+
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2006 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://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+/* This script lists extension-, class- and method names that contain any
+ underscores. It omits magic names (e.g. anything that starts with two
+ underscores but no more).
+ */
+
+$cnt_modules = 0;
+$cnt_classes = 0;
+$cnt_methods = 0;
+$err = 0;
+
+$classes = array_merge(get_declared_classes(), get_declared_interfaces());
+
+$extensions = array();
+
+foreach(get_loaded_extensions() as $ext) {
+ $cnt_modules++;
+ if (strpos($ext, "_") !== false) {
+ $err++;
+ $extensions[$ext] = array();
+ }
+}
+
+$cnt_classes = count($classes);
+
+foreach($classes as $c) {
+ if (strpos($c, "_") !== false) {
+ $err++;
+ $ref = new ReflectionClass($c);
+ if (!($ext = $ref->getExtensionName())) {;
+ $ext = $ref->isInternal() ? "<internal>" : "<user>";
+ }
+ if (!array_key_exists($ext, $extensions)) {
+ $extensions[$ext] = array();
+ }
+ $extensions[$ext][$c] = array();
+ foreach(get_class_methods($c) as $method) {
+ $cnt_methods++;
+ if (strpos(substr($method, substr($method, 0, 2) != "__" ? 0 : 2), "_") !== false) {
+ $err++;
+ $extensions[$ext][$c][] = $method;
+ }
+ }
+ }
+ else
+ {
+ $cnt_methods += count(get_class_methods($c));
+ }
+}
+
+$cnt = $cnt_modules + $cnt_classes + $cnt_methods;
+
+printf("\n");
+printf("Modules: %5d\n", $cnt_modules);
+printf("Classes: %5d\n", $cnt_classes);
+printf("Methods: %5d\n", $cnt_methods);
+printf("\n");
+printf("Names: %5d\n", $cnt);
+printf("Errors: %5d (%.1f%%)\n", $err, round($err * 100 / $cnt, 1));
+printf("\n");
+
+ksort($extensions);
+foreach($extensions as $ext => &$classes) {
+ echo "Extension: $ext\n";
+ ksort($classes);
+ foreach($classes as $classname => &$methods) {
+ echo " Class: $classname\n";
+ ksort($methods);
+ foreach($methods as $method) {
+ echo " Method: $method\n";
+ }
+ }
+}
+
+printf("\n");
+
+?> \ No newline at end of file
diff --git a/scripts/man1/php-config.1.in b/scripts/man1/php-config.1.in
new file mode 100644
index 0000000..5c60408
--- /dev/null
+++ b/scripts/man1/php-config.1.in
@@ -0,0 +1,81 @@
+.TH php\-config 1 "2010" "The PHP Group" "Scripting Language"
+.SH NAME
+php\-config \- get information about PHP configuration and compile options
+.SH SYNOPSIS
+.B php\-config
+[options]
+.LP
+.SH DESCRIPTION
+.B php\-config
+is a simple shell script for obtaining information about installed PHP configuration.
+.SH OPTIONS
+.TP 15
+.PD 0
+.B \-\-prefix
+Directory prefix where PHP is installed, e.g. /usr/local
+.TP
+.PD 0
+.B \-\-includes
+List of \-I options with all include files
+.TP
+.PD 0
+.B \-\-ldflags
+LD Flags which PHP was compiled with
+.TP
+.PD 0
+.B \-\-libs
+Extra libraries which PHP was compiled with
+.TP
+.PD 0
+.B \-\-man-dir
+The directory prefix where the manpages is installed
+.TP
+.PD 0
+.B \-\-extension-dir
+Directory where extensions are searched by default
+.TP
+.PD 0
+.B \-\-include-dir
+Directory prefix where header files are installed by default
+.TP
+.PD 0
+.B \-\-php-binary
+Full path to php CLI or CGI binary
+.TP
+.PD 0
+.B \-\-php-sapis
+Show all SAPI modules available
+.TP
+.PD 0
+.B \-\-configure-options
+Configure options to recreate configuration of current PHP installation
+.TP
+.PD 0
+.B \-\-version
+PHP version
+.TP
+.PD 0
+.B \-\-vernum
+PHP version as integer
+.TP
+.PD 1
+.P
+.SH SEE ALSO
+.BR php (1)
+.SH VERSION INFORMATION
+This manpage describes \fBphp\fP, version @PHP_VERSION@.
+.SH COPYRIGHT
+Copyright \(co 1997\-2010 The PHP Group
+.LP
+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:
+.PD 0
+.P
+.B http://www.php.net/license/3_01.txt
+.PD 1
+.P
+If you did not receive a copy of the PHP license and are unable to
+obtain it through the world-wide-web, please send a note to
+.B license@php.net
+so we can mail you a copy immediately.
diff --git a/scripts/man1/phpize.1.in b/scripts/man1/phpize.1.in
new file mode 100644
index 0000000..8f62f86
--- /dev/null
+++ b/scripts/man1/phpize.1.in
@@ -0,0 +1,48 @@
+.TH phpize 1 "2010" "The PHP Group" "Scripting Language"
+.SH NAME
+phpize \- prepare a PHP extension for compiling
+.SH SYNOPSIS
+.B phpize
+[options]
+.LP
+.SH DESCRIPTION
+.B phpize
+is a shell script to prepare PHP extension for compiling.
+.SH OPTIONS
+.TP 15
+.PD 0
+.B \-\-clean
+Remove all created files
+.TP
+.PD 0
+.B \-\-help
+Prints usage information
+.TP
+.PD 0
+.B \-\-version
+.TP
+.PD 1
+.B \-v
+Prints API version information
+.TP
+.PD 1
+.P
+.SH SEE ALSO
+.BR php (1)
+.SH VERSION INFORMATION
+This manpage describes \fBphp\fP, version @PHP_VERSION@.
+.SH COPYRIGHT
+Copyright \(co 1997\-2010 The PHP Group
+.LP
+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:
+.PD 0
+.P
+.B http://www.php.net/license/3_01.txt
+.PD 1
+.P
+If you did not receive a copy of the PHP license and are unable to
+obtain it through the world-wide-web, please send a note to
+.B license@php.net
+so we can mail you a copy immediately.
diff --git a/scripts/php-config.in b/scripts/php-config.in
new file mode 100644
index 0000000..d6c62cc
--- /dev/null
+++ b/scripts/php-config.in
@@ -0,0 +1,90 @@
+#! /bin/sh
+
+SED="@SED@"
+prefix="@prefix@"
+datarootdir="@datarootdir@"
+exec_prefix="@exec_prefix@"
+version="@PHP_VERSION@"
+vernum="@PHP_VERSION_ID@"
+include_dir="@includedir@/php"
+includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
+ldflags="@PHP_LDFLAGS@"
+libs="@EXTRA_LIBS@"
+extension_dir='@EXTENSION_DIR@'
+man_dir=`eval echo @mandir@`
+program_prefix="@program_prefix@"
+program_suffix="@program_suffix@"
+exe_extension="@EXEEXT@"
+php_cli_binary=NONE
+php_cgi_binary=NONE
+configure_options="@CONFIGURE_OPTIONS@"
+php_sapis="@PHP_INSTALLED_SAPIS@"
+
+# Set php_cli_binary and php_cgi_binary if available
+for sapi in $php_sapis; do
+ case $sapi in
+ cli)
+ php_cli_binary="@bindir@/${program_prefix}php${program_suffix}${exe_extension}"
+ ;;
+ cgi)
+ php_cgi_binary="@bindir@/${program_prefix}php-cgi${program_suffix}${exe_extension}"
+ ;;
+ esac
+done
+
+# Determine which (if any) php binary is available
+if test "$php_cli_binary" != "NONE"; then
+ php_binary="$php_cli_binary"
+else
+ php_binary="$php_cgi_binary"
+fi
+
+# Remove quotes
+configure_options=`echo $configure_options | $SED -e "s#'##g"`
+
+case "$1" in
+--prefix)
+ echo $prefix;;
+--includes)
+ echo $includes;;
+--ldflags)
+ echo $ldflags;;
+--libs)
+ echo $libs;;
+--extension-dir)
+ echo $extension_dir;;
+--include-dir)
+ echo $include_dir;;
+--php-binary)
+ echo $php_binary;;
+--php-sapis)
+ echo $php_sapis;;
+--configure-options)
+ echo $configure_options;;
+--man-dir)
+ echo $man_dir;;
+--version)
+ echo $version;;
+--vernum)
+ echo $vernum;;
+*)
+ cat << EOF
+Usage: $0 [OPTION]
+Options:
+ --prefix [$prefix]
+ --includes [$includes]
+ --ldflags [$ldflags]
+ --libs [$libs]
+ --extension-dir [$extension_dir]
+ --include-dir [$include_dir]
+ --man-dir [$man_dir]
+ --php-binary [$php_binary]
+ --php-sapis [$php_sapis]
+ --configure-options [$configure_options]
+ --version [$version]
+ --vernum [$vernum]
+EOF
+ exit 1;;
+esac
+
+exit 0
diff --git a/scripts/phpize.in b/scripts/phpize.in
new file mode 100644
index 0000000..43cd8d3
--- /dev/null
+++ b/scripts/phpize.in
@@ -0,0 +1,209 @@
+#!/bin/sh
+
+# Variable declaration
+prefix='@prefix@'
+datarootdir='@datarootdir@'
+exec_prefix="`eval echo @exec_prefix@`"
+phpdir="`eval echo @libdir@`/build"
+includedir="`eval echo @includedir@`/php"
+builddir="`pwd`"
+SED="@SED@"
+
+FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool libtool.m4"
+FILES="acinclude.m4 Makefile.global config.sub config.guess ltmain.sh run-tests*.php"
+CLEAN_FILES="$FILES *.o *.lo *.la .deps .libs/ build/ include/ modules/ install-sh \
+ mkinstalldirs missing config.nice config.sub config.guess configure configure.in \
+ aclocal.m4 config.h config.h.in conftest* ltmain.sh libtool config.cache autom4te.cache/ \
+ config.log config.status Makefile Makefile.fragments Makefile.objects confdefs.h \
+ run-tests*.php tests/*.diff tests/*.exp tests/*.log tests/*.out tests/*.php"
+
+# function declaration
+phpize_usage()
+{
+ echo "Usage: $0 [--clean|--help|--version|-v]"
+}
+
+phpize_no_configm4()
+{
+ if test $@ -eq 1; then
+ clean=" --clean"
+ fi
+
+ echo "Cannot find config.m4. "
+ echo "Make sure that you run '$0$clean' in the top level source directory of the module"
+ echo
+}
+
+phpize_clean()
+{
+ echo "Cleaning.."
+ for i in $CLEAN_FILES; do
+ if test -f "$i"; then
+ rm -f $i
+ elif test -d "$i"; then
+ rm -rf $i
+ fi
+ done
+}
+
+phpize_check_configm4()
+{
+ if test ! -r config.m4; then
+ phpize_no_configm4 $@
+ exit 1
+ fi
+
+}
+
+phpize_get_api_numbers()
+{
+ # extracting API NOs:
+ PHP_API_VERSION=`grep '#define PHP_API_VERSION' $includedir/main/php.h|$SED 's/#define PHP_API_VERSION//'`
+ ZEND_MODULE_API_NO=`grep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO//'`
+ ZEND_EXTENSION_API_NO=`grep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|$SED 's/#define ZEND_EXTENSION_API_NO//'`
+}
+
+phpize_print_api_numbers()
+{
+ phpize_get_api_numbers
+ echo "Configuring for:"
+ echo "PHP Api Version: "$PHP_API_VERSION
+ echo "Zend Module Api No: "$ZEND_MODULE_API_NO
+ echo "Zend Extension Api No: "$ZEND_EXTENSION_API_NO
+}
+
+phpize_check_build_files()
+{
+ if test ! -d "$phpdir"; then
+ cat <<EOF
+Cannot find build files at '$phpdir'. Please check your PHP installation.
+
+EOF
+ exit 1
+ fi
+
+ case "$phpdir" in
+ *\ * | *\ *)
+ cat <<EOF
+Invalid source path '$phpdir'. Whitespace is not allowed in source path.
+
+EOF
+ exit 1;;
+ esac
+
+ case "$builddir" in
+ *\ * | *\ *)
+ cat <<EOF
+Invalid build path '$builddir'. Whitespace is not allowed in build path.
+
+EOF
+ exit 1;;
+ esac
+}
+
+phpize_check_shtool()
+{
+ test -x "$builddir/build/shtool" || chmod +x "$builddir/build/shtool"
+
+ if test ! -x "$builddir/build/shtool"; then
+ cat <<EOF
+shtool at '$builddir/build/shtool' does not exist or is not executable.
+Make sure that the file exists and is executable and then rerun this script.
+
+EOF
+ exit 1
+ else
+ php_shtool=$builddir/build/shtool
+ fi
+}
+
+phpize_check_autotools()
+{
+ test -z "$PHP_AUTOCONF" && PHP_AUTOCONF=autoconf
+ test -z "$PHP_AUTOHEADER" && PHP_AUTOHEADER=autoheader
+
+ if test ! -x "$PHP_AUTOCONF" && test ! -x "`$php_shtool path $PHP_AUTOCONF`"; then
+ cat <<EOF
+Cannot find autoconf. Please check your autoconf installation and the
+\$PHP_AUTOCONF environment variable. Then, rerun this script.
+
+EOF
+ exit 1
+ fi
+ if test ! -x "$PHP_AUTOHEADER" && test ! -x "`$php_shtool path $PHP_AUTOHEADER`"; then
+ cat <<EOF
+Cannot find autoheader. Please check your autoconf installation and the
+\$PHP_AUTOHEADER environment variable. Then, rerun this script.
+
+EOF
+ exit 1
+ fi
+}
+
+phpize_copy_files()
+{
+ test -d build || mkdir build
+
+ (cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
+ (cd "$phpdir" && cp $FILES "$builddir")
+ (cd "$builddir" && cat acinclude.m4 ./build/libtool.m4 > aclocal.m4)
+}
+
+phpize_replace_prefix()
+{
+ $SED \
+ -e "s#@prefix@#$prefix#" \
+ < "$phpdir/phpize.m4" > configure.in
+}
+
+phpize_autotools()
+{
+ $PHP_AUTOCONF || exit 1
+ $PHP_AUTOHEADER || exit 1
+}
+
+# Main script
+
+case "$1" in
+ # Cleanup
+ --clean)
+ phpize_check_configm4 1
+ phpize_clean
+ exit 0
+ ;;
+
+ # Usage
+ --help)
+ phpize_usage
+ exit 0
+ ;;
+
+ # Version
+ --version|-v)
+ phpize_print_api_numbers
+ exit 0
+ ;;
+
+ # Default
+ *)
+ phpize_check_configm4 0
+
+ phpize_check_build_files
+
+ phpize_print_api_numbers
+
+ phpize_copy_files
+
+ phpize_replace_prefix
+
+ touch install-sh mkinstalldirs missing
+
+ phpize_check_shtool
+
+ phpize_check_autotools
+
+ phpize_autotools
+ ;;
+esac
+
+exit 0
diff --git a/scripts/phpize.m4 b/scripts/phpize.m4
new file mode 100644
index 0000000..d745ca7
--- /dev/null
+++ b/scripts/phpize.m4
@@ -0,0 +1,202 @@
+dnl This file becomes configure.in for self-contained extensions.
+
+AC_PREREQ(2.59)
+AC_INIT(config.m4)
+ifdef([AC_PRESERVE_HELP_ORDER], [AC_PRESERVE_HELP_ORDER], [])
+
+PHP_CONFIG_NICE(config.nice)
+
+dnl
+AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl
+AC_DEFUN([PHP_EXT_DIR],[""])dnl
+AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl
+AC_DEFUN([PHP_ALWAYS_SHARED],[
+ ext_output="yes, shared"
+ ext_shared=yes
+ test "[$]$1" = "no" && $1=yes
+])dnl
+dnl
+
+test -z "$CFLAGS" && auto_cflags=1
+
+abs_srcdir=`(cd $srcdir && pwd)`
+abs_builddir=`pwd`
+
+AC_PROG_CC([cc gcc])
+PHP_DETECT_ICC
+PHP_DETECT_SUNCC
+AC_PROG_CC_C_O
+
+dnl Support systems with system libraries in e.g. /usr/lib64
+PHP_ARG_WITH(libdir, for system library directory,
+[ --with-libdir=NAME Look for libraries in .../NAME rather than .../lib], lib, no)
+
+PHP_RUNPATH_SWITCH
+PHP_SHLIB_SUFFIX_NAMES
+
+dnl Find php-config script
+PHP_ARG_WITH(php-config,,
+[ --with-php-config=PATH Path to php-config [php-config]], php-config, no)
+
+dnl For BC
+PHP_CONFIG=$PHP_PHP_CONFIG
+prefix=`$PHP_CONFIG --prefix 2>/dev/null`
+phpincludedir=`$PHP_CONFIG --include-dir 2>/dev/null`
+INCLUDES=`$PHP_CONFIG --includes 2>/dev/null`
+EXTENSION_DIR=`$PHP_CONFIG --extension-dir 2>/dev/null`
+PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null`
+
+if test -z "$prefix"; then
+ AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH])
+fi
+
+php_shtool=$srcdir/build/shtool
+PHP_INIT_BUILD_SYSTEM
+
+AC_MSG_CHECKING([for PHP prefix])
+AC_MSG_RESULT([$prefix])
+AC_MSG_CHECKING([for PHP includes])
+AC_MSG_RESULT([$INCLUDES])
+AC_MSG_CHECKING([for PHP extension directory])
+AC_MSG_RESULT([$EXTENSION_DIR])
+AC_MSG_CHECKING([for PHP installed headers prefix])
+AC_MSG_RESULT([$phpincludedir])
+
+dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS
+AC_MSG_CHECKING([if debug is enabled])
+old_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="-I$phpincludedir"
+AC_EGREP_CPP(php_debug_is_enabled,[
+#include <main/php_config.h>
+#if ZEND_DEBUG
+php_debug_is_enabled
+#endif
+],[
+ PHP_DEBUG=yes
+],[
+ PHP_DEBUG=no
+])
+CPPFLAGS=$old_CPPFLAGS
+AC_MSG_RESULT([$PHP_DEBUG])
+
+AC_MSG_CHECKING([if zts is enabled])
+old_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="-I$phpincludedir"
+AC_EGREP_CPP(php_zts_is_enabled,[
+#include <main/php_config.h>
+#if ZTS
+php_zts_is_enabled
+#endif
+],[
+ PHP_THREAD_SAFETY=yes
+],[
+ PHP_THREAD_SAFETY=no
+])
+CPPFLAGS=$old_CPPFLAGS
+AC_MSG_RESULT([$PHP_DEBUG])
+
+dnl Support for building and testing Zend extensions
+ZEND_EXT_TYPE="zend_extension"
+PHP_SUBST(ZEND_EXT_TYPE)
+
+dnl Discard optimization flags when debugging is enabled
+if test "$PHP_DEBUG" = "yes"; then
+ PHP_DEBUG=1
+ ZEND_DEBUG=yes
+ changequote({,})
+ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
+ CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
+ changequote([,])
+ dnl add -O0 only if GCC or ICC is used
+ if test "$GCC" = "yes" || test "$ICC" = "yes"; then
+ CFLAGS="$CFLAGS -O0"
+ CXXFLAGS="$CXXFLAGS -g -O0"
+ fi
+ if test "$SUNCC" = "yes"; then
+ if test -n "$auto_cflags"; then
+ CFLAGS="-g"
+ CXXFLAGS="-g"
+ else
+ CFLAGS="$CFLAGS -g"
+ CXXFLAGS="$CFLAGS -g"
+ fi
+ fi
+else
+ PHP_DEBUG=0
+ ZEND_DEBUG=no
+fi
+
+dnl Always shared
+PHP_BUILD_SHARED
+
+dnl Required programs
+PHP_PROG_RE2C
+PHP_PROG_AWK
+
+sinclude(config.m4)
+
+enable_static=no
+enable_shared=yes
+
+dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX).
+dnl Otherwise AC_PROG_LIBTOOL fails if there is no working C++ compiler.
+AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
+ undefine([AC_PROG_CXX])
+ AC_DEFUN([AC_PROG_CXX], [])
+ undefine([AC_PROG_CXXCPP])
+ AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
+])
+AC_PROG_LIBTOOL
+
+all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)'
+install_targets="install-modules install-headers"
+phplibdir="`pwd`/modules"
+CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
+CFLAGS_CLEAN='$(CFLAGS)'
+CXXFLAGS_CLEAN='$(CXXFLAGS)'
+
+test "$prefix" = "NONE" && prefix="/usr/local"
+test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
+
+PHP_SUBST(PHP_MODULES)
+PHP_SUBST(PHP_ZEND_EX)
+
+PHP_SUBST(all_targets)
+PHP_SUBST(install_targets)
+
+PHP_SUBST(prefix)
+PHP_SUBST(exec_prefix)
+PHP_SUBST(libdir)
+PHP_SUBST(prefix)
+PHP_SUBST(phplibdir)
+PHP_SUBST(phpincludedir)
+
+PHP_SUBST(CC)
+PHP_SUBST(CFLAGS)
+PHP_SUBST(CFLAGS_CLEAN)
+PHP_SUBST(CPP)
+PHP_SUBST(CPPFLAGS)
+PHP_SUBST(CXX)
+PHP_SUBST(CXXFLAGS)
+PHP_SUBST(CXXFLAGS_CLEAN)
+PHP_SUBST(EXTENSION_DIR)
+PHP_SUBST(PHP_EXECUTABLE)
+PHP_SUBST(EXTRA_LDFLAGS)
+PHP_SUBST(EXTRA_LIBS)
+PHP_SUBST(INCLUDES)
+PHP_SUBST(LFLAGS)
+PHP_SUBST(LDFLAGS)
+PHP_SUBST(SHARED_LIBTOOL)
+PHP_SUBST(LIBTOOL)
+PHP_SUBST(SHELL)
+PHP_SUBST(INSTALL_HEADERS)
+
+PHP_GEN_BUILD_DIRS
+PHP_GEN_GLOBAL_MAKEFILE
+
+test -d modules || $php_shtool mkdir modules
+touch .deps
+
+AC_CONFIG_HEADER(config.h)
+
+AC_OUTPUT()