4
0
Fork 0

Initial commit

This commit is contained in:
Alexander Postol 2024-09-19 23:32:21 +03:00
commit 066a7e4635
96 changed files with 38693 additions and 0 deletions

1
bin/phar Symbolic link
View File

@ -0,0 +1 @@
phar.phar

BIN
bin/phar.phar Executable file

Binary file not shown.

BIN
bin/php Executable file

Binary file not shown.

BIN
bin/php-cgi Executable file

Binary file not shown.

98
bin/php-config Executable file
View File

@ -0,0 +1,98 @@
#! /bin/sh
SED="/usr/bin/sed"
prefix="/Users/sanek/.phpbrew/php/php-7.4.32"
datarootdir="/Users/sanek/.phpbrew/php/php-7.4.32/php"
exec_prefix="${prefix}"
version="7.4.32"
vernum="70432"
include_dir="${prefix}/include/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=" -L/usr/local/Cellar/libxml2/2.13.4/lib -L/usr/local/Cellar/openssl@1.1/1.1.1w/lib -L/usr/local/opt/bzip2/lib -L/usr/local/Cellar/curl/8.10.1/lib -L/usr/local/Cellar/oniguruma/6.9.9/lib -L/usr/local/opt/readline/lib -L/usr/local/Cellar/libzip/1.10.1/lib"
libs=" -lresolv -lreadline -lncurses -lbz2 -lm -lxml2 -lssl -lcrypto -lcurl -lssl -lcrypto -lxml2 -lonig -lxml2 -lxml2 -lxml2 -lxml2 -lxslt -lxml2 -lexslt -lxslt -lxml2 -lzip -lz -lssl -lcrypto "
extension_dir='/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/extensions/no-debug-non-zts-20190902'
man_dir=`eval echo ${datarootdir}/man`
program_prefix=""
program_suffix=""
exe_extension=""
php_cli_binary=NONE
php_cgi_binary=NONE
configure_options=" '--cache-file=/Users/sanek/.phpbrew/cache/config.cache' '--prefix=/Users/sanek/.phpbrew/php/php-7.4.32' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-openssl' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr/local/opt/bzip2' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash=/usr/local' '--enable-pcntl' '--enable-pdo' '--with-pear=/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear' '--enable-posix' '--with-readline=/usr/local/opt/readline' '--enable-sockets' '--with-curl' '--with-zip' '--disable-zts' '--with-config-file-path=/Users/sanek/.phpbrew/php/php-7.4.32/etc/cli' '--with-config-file-scan-dir=/Users/sanek/.phpbrew/php/php-7.4.32/var/db/cli' 'PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig'"
php_sapis=" cli phpdbg cgi"
ini_dir="/Users/sanek/.phpbrew/php/php-7.4.32/var/db/cli"
ini_path="/Users/sanek/.phpbrew/php/php-7.4.32/etc/cli"
# Set php_cli_binary and php_cgi_binary if available
for sapi in $php_sapis; do
case $sapi in
cli)
php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"
;;
cgi)
php_cgi_binary="${exec_prefix}/bin/${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;;
--ini-path)
echo $ini_path;;
--ini-dir)
echo $ini_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]
--ini-path [$ini_path]
--ini-dir [$ini_dir]
--configure-options [$configure_options]
--version [$version]
--vernum [$vernum]
EOF
exit 1;;
esac
exit 0

BIN
bin/phpdbg Executable file

Binary file not shown.

210
bin/phpize Executable file
View File

@ -0,0 +1,210 @@
#!/bin/sh
# Variable declaration
prefix='/Users/sanek/.phpbrew/php/php-7.4.32'
datarootdir='/Users/sanek/.phpbrew/php/php-7.4.32/php'
exec_prefix="`eval echo ${prefix}`"
phpdir="`eval echo ${exec_prefix}/lib/php`/build"
includedir="`eval echo ${prefix}/include`/php"
builddir="`pwd`"
SED="/usr/bin/sed"
FILES_BUILD="php.m4 shtool libtool.m4 ax_check_compile_flag.m4 ax_gcc_func_attribute.m4 php_cxx_compile_stdcxx.m4 pkg.m4 config.guess config.sub ltmain.sh Makefile.global"
FILES="run-tests*.php"
CLEAN_FILES="$FILES *.o *.lo *.la .libs/ build/ modules/ \
config.nice configure configure.ac \
config.h config.h.in conftest* 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")
}
phpize_replace_prefix()
{
$SED \
-e "s#/Users/sanek/.phpbrew/php/php-7.4.32#$prefix#" \
< "$phpdir/phpize.m4" > configure.ac
}
phpize_autotools()
{
# Remove aclocal.m4 if present. It is automatically included by autoconf but
# not used by the PHP build system since PHP 7.4.
rm -f aclocal.m4
$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
phpize_check_shtool
phpize_check_autotools
phpize_autotools
;;
esac
exit 0

1945
etc/cli/php.ini Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,147 @@
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
all: $(all_targets)
@echo
@echo "Build complete."
@echo "Don't forget to run 'make test'."
@echo
build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)
build-binaries: $(PHP_BINARIES)
libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so
install: $(all_targets) $(install_targets)
install-sapi: $(OVERALL_TARGET)
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-@if test ! -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); \
break; \
fi; \
done; \
fi
@$(INSTALL_IT)
install-binaries: build-binaries $(install_binary_targets)
install-modules: build-modules
@test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
@echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/"
@rm -f modules/*.la >/dev/null 2>&1
@$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
install-headers:
-@if test "$(INSTALL_HEADERS)"; then \
for i in `echo $(INSTALL_HEADERS)`; do \
i=`$(top_srcdir)/build/shtool path -d $$i`; \
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
else \
src=$$i; \
fi; \
if test -f "$(top_srcdir)/$$src"; then \
$(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
elif test -f "$(top_builddir)/$$src"; then \
$(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
else \
(cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \
cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \
fi \
done; \
fi
PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
PHP_TEST_SHARED_EXTENSIONS = ` \
if test "x$(PHP_MODULES)" != "x"; then \
for i in $(PHP_MODULES)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
done; \
fi; \
if test "x$(PHP_ZEND_EX)" != "x"; then \
for i in $(PHP_ZEND_EX)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d zend_extension=$(top_builddir)/modules/$$dlname"; \
done; \
fi`
PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
test: all
@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
TEST_RESULT_EXIT_CODE=$$?; \
rm $(top_builddir)/tmp-php.ini; \
exit $$TEST_RESULT_EXIT_CODE; \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
clean:
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
distclean: clean
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h
rm -f main/build-defs.h scripts/phpize
rm -f ext/date/lib/timelib_config.h ext/mbstring/libmbfl/config.h ext/oci8/oci8_dtrace_gen.h ext/oci8/oci8_dtrace_gen.h.bak
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 sapi/phpdbg/phpdbg.1 ext/phar/phar.1 ext/phar/phar.phar.1
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/iconv/php_have_bsd_iconv.h ext/iconv/php_have_glibc_iconv.h ext/iconv/php_have_ibm_iconv.h ext/iconv/php_have_iconv.h ext/iconv/php_have_libiconv.h ext/iconv/php_iconv_aliased_libiconv.h ext/iconv/php_iconv_supports_errno.h ext/iconv/php_php_iconv_h_path.h ext/iconv/php_php_iconv_impl.h
rm -f ext/phar/phar.phar ext/phar/phar.php
if test "$(srcdir)" != "$(builddir)"; then \
rm -f ext/phar/phar/phar.inc; \
fi
$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
prof-gen:
CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-generate all
prof-clean:
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
prof-use:
CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
.PHONY: all clean install distclean test prof-gen prof-clean prof-use
.NOEXPORT:

View File

@ -0,0 +1,53 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

View File

@ -0,0 +1,241 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
#
# DESCRIPTION
#
# This macro checks if the compiler supports one of GCC's function
# attributes; many other compilers also provide function attributes with
# the same syntax. Compiler warnings are used to detect supported
# attributes as unsupported ones are ignored by default so quieting
# warnings when using this macro will yield false positives.
#
# The ATTRIBUTE parameter holds the name of the attribute to be checked.
#
# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
#
# The macro caches its result in the ax_cv_have_func_attribute_<attribute>
# variable.
#
# The macro currently supports the following function attributes:
#
# alias
# aligned
# alloc_size
# always_inline
# artificial
# cold
# const
# constructor
# constructor_priority for constructor attribute with priority
# deprecated
# destructor
# dllexport
# dllimport
# error
# externally_visible
# fallthrough
# flatten
# format
# format_arg
# gnu_inline
# hot
# ifunc
# leaf
# malloc
# noclone
# noinline
# nonnull
# noreturn
# nothrow
# optimize
# pure
# sentinel
# sentinel_position
# unused
# used
# visibility
# warning
# warn_unused_result
# weak
# weakref
#
# Unsupported function attributes will be tested with a prototype
# returning an int and not accepting any arguments and the result of the
# check might be wrong or meaningless so use with care.
#
# LICENSE
#
# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 9
AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
m4_case([$1],
[alias], [
int foo( void ) { return 0; }
int bar( void ) __attribute__(($1("foo")));
],
[aligned], [
int foo( void ) __attribute__(($1(32)));
],
[alloc_size], [
void *foo(int a) __attribute__(($1(1)));
],
[always_inline], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[artificial], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[cold], [
int foo( void ) __attribute__(($1));
],
[const], [
int foo( void ) __attribute__(($1));
],
[constructor_priority], [
int foo( void ) __attribute__((__constructor__(65535/2)));
],
[constructor], [
int foo( void ) __attribute__(($1));
],
[deprecated], [
int foo( void ) __attribute__(($1("")));
],
[destructor], [
int foo( void ) __attribute__(($1));
],
[dllexport], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[dllimport], [
int foo( void ) __attribute__(($1));
],
[error], [
int foo( void ) __attribute__(($1("")));
],
[externally_visible], [
int foo( void ) __attribute__(($1));
],
[fallthrough], [
int foo( void ) {switch (0) { case 1: __attribute__(($1)); case 2: break ; }};
],
[flatten], [
int foo( void ) __attribute__(($1));
],
[format], [
int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
],
[format_arg], [
char *foo(const char *p) __attribute__(($1(1)));
],
[gnu_inline], [
inline __attribute__(($1)) int foo( void ) { return 0; }
],
[hot], [
int foo( void ) __attribute__(($1));
],
[ifunc], [
int my_foo( void ) { return 0; }
static int (*resolve_foo(void))(void) { return my_foo; }
int foo( void ) __attribute__(($1("resolve_foo")));
],
[leaf], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[malloc], [
void *foo( void ) __attribute__(($1));
],
[noclone], [
int foo( void ) __attribute__(($1));
],
[noinline], [
__attribute__(($1)) int foo( void ) { return 0; }
],
[nonnull], [
int foo(char *p) __attribute__(($1(1)));
],
[noreturn], [
void foo( void ) __attribute__(($1));
],
[nothrow], [
int foo( void ) __attribute__(($1));
],
[optimize], [
__attribute__(($1(3))) int foo( void ) { return 0; }
],
[pure], [
int foo( void ) __attribute__(($1));
],
[sentinel], [
int foo(void *p, ...) __attribute__(($1));
],
[sentinel_position], [
int foo(void *p, ...) __attribute__(($1(1)));
],
[returns_nonnull], [
void *foo( void ) __attribute__(($1));
],
[unused], [
int foo( void ) __attribute__(($1));
],
[used], [
int foo( void ) __attribute__(($1));
],
[visibility], [
int foo_def( void ) __attribute__(($1("default")));
int foo_hid( void ) __attribute__(($1("hidden")));
int foo_int( void ) __attribute__(($1("internal")));
int foo_pro( void ) __attribute__(($1("protected")));
],
[warning], [
int foo( void ) __attribute__(($1("")));
],
[warn_unused_result], [
int foo( void ) __attribute__(($1));
],
[weak], [
int foo( void ) __attribute__(($1));
],
[weakref], [
static int foo( void ) { return 0; }
static int bar( void ) __attribute__(($1("foo")));
],
[target], [
static int bar( void ) __attribute__(($1("sse2")));
],
[
m4_warn([syntax], [Unsupported attribute $1, the test may fail])
int foo( void ) __attribute__(($1));
]
)], [])
],
dnl GCC doesn't exit with an error if an unknown attribute is
dnl provided but only outputs a warning, so accept the attribute
dnl only if no warning were issued.
[AS_IF([test -s conftest.err],
[AS_VAR_SET([ac_var], [no])],
[AS_VAR_SET([ac_var], [yes])])],
[AS_VAR_SET([ac_var], [no])])
])
AS_IF([test yes = AS_VAR_GET([ac_var])],
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
[Define to 1 if the system has the `$1' function attribute])], [])
AS_VAR_POPDEF([ac_var])
])

1748
lib/php/build/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1884
lib/php/build/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

6361
lib/php/build/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

6957
lib/php/build/ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

2718
lib/php/build/php.m4 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,911 @@
dnl
dnl Based on https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
dnl Author: Anatol Belski <ab@php.net>
dnl
dnl PHP_CXX_COMPILE_STDCXX(version, mandatory|optional, var_name_to_put_switch_in)
dnl
dnl ARGUMENTS
dnl
dnl first arg - version as 11, 14 or 17
dnl second arg - if mandatory, the configure will fail when no features found.
dnl Optional will make configure silently continue
dnl third arg - a variable name where the corresponding switch would be put. If
dnl the variable is already defined, its contents will be overwritten.
dnl
dnl EXAMPLE
dnl
dnl PHP_CXX_COMPILE_STDCXX(14, mandatory, MY_STDCXX_SWiTCH)
dnl echo $MY_STDCXX_SWITCH
dnl
dnl
dnl PHP specific implementation start.
dnl
AC_DEFUN([PHP_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[m4_fatal([invalid first argument `$1' to PHP_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx$1_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$2], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$2' to PHP_CXX_COMPILE_STDCXX])])dnl
AC_LANG_PUSH([C++])dnl
ac_success=no
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
eval AS_TR_SH([$3])="$switch"
ac_success=yes
break
fi
done
if test x$ac_success = xyes; then
break
fi
done
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
fi
if test x$ac_success = xno; then
AC_MSG_NOTICE([No compiler with C++$1 support was found])
fi
AC_SUBST(HAVE_CXX$1)
])
dnl
dnl PHP specific implementation end.
dnl The relevant part of the unchanged original implementation is below.
dnl
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
virtual ~Derived() override {}
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_separators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])
dnl Tests for new features in C++17
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201703L
#error "This is not a C++17 compiler"
#else
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
namespace test_constexpr_lambdas
{
constexpr int foo = [](){return 42;}();
}
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
namespace test_template_argument_deduction_for_class_templates
{
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
namespace test_structured_bindings
{
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
namespace test_exception_spec_type_system
{
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus < 201703L
]])

215
lib/php/build/phpize.m4 Normal file
View File

@ -0,0 +1,215 @@
dnl This file becomes configure.ac for self-contained extensions.
dnl Include external macro definitions before the AC_INIT to also remove
dnl comments starting with # and empty newlines from the included files.
m4_include([build/ax_check_compile_flag.m4])
m4_include([build/ax_gcc_func_attribute.m4])
m4_include([build/libtool.m4])
m4_include([build/php_cxx_compile_stdcxx.m4])
m4_include([build/php.m4])
m4_include([build/pkg.m4])
AC_PREREQ([2.68])
AC_INIT
AC_CONFIG_SRCDIR([config.m4])
AC_CONFIG_AUX_DIR([build])
AC_PRESERVE_HELP_ORDER
PHP_CONFIG_NICE(config.nice)
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
test -z "$CFLAGS" && auto_cflags=1
abs_srcdir=`(cd $srcdir && pwd)`
abs_builddir=`pwd`
PKG_PROG_PKG_CONFIG
AC_PROG_CC([cc gcc])
PHP_DETECT_ICC
PHP_DETECT_SUNCC
dnl Support systems with system libraries in e.g. /usr/lib64.
PHP_ARG_WITH([libdir],
[for system library directory],
[AS_HELP_STRING([--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],,
[AS_HELP_STRING([--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_THREAD_SAFETY])
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_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
dnl PHP_REQUIRE_CXX). Otherwise AC_PROG_LIBTOOL fails if there is no working C++
dnl 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
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([config.h.in])])
AC_OUTPUT

275
lib/php/build/pkg.m4 Normal file
View File

@ -0,0 +1,275 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if you
dnl distribute this file as part of a program that contains a
dnl configuration script generated by Autoconf, you may include it under
dnl the same distribution terms that you use for the rest of that
dnl program.
dnl PKG_PREREQ(MIN-VERSION)
dnl -----------------------
dnl Since: 0.29
dnl
dnl Verify that the version of the pkg-config macros are at least
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
dnl installed version of pkg-config, this checks the developer's version
dnl of pkg.m4 when generating configure.
dnl
dnl To ensure that this macro is defined, also add:
dnl m4_ifndef([PKG_PREREQ],
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
dnl ----------------------------------
dnl Since: 0.16
dnl
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
dnl first found in the path. Checks that the version of pkg-config found
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
dnl used since that's the first version where most current features of
dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])dnl PKG_PROG_PKG_CONFIG
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------------------------------
dnl Since: 0.18
dnl
dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
dnl
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
dnl only at the first occurrence in configure.ac, so if the first place
dnl it's called might be skipped (such as if it is within an "if", you
dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
dnl ---------------------------------------------
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])dnl _PKG_CONFIG
dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl ---------------------------
dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------
dnl Since: 0.4.0
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $2])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])dnl PKG_CHECK_MODULES
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl ---------------------------------------------------------------------
dnl Since: 0.29
dnl
dnl Checks for existence of MODULES and gathers its build flags with
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
dnl and VARIABLE-PREFIX_LIBS from --libs.
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
dnl configure.ac.
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
_save_PKG_CONFIG=$PKG_CONFIG
PKG_CONFIG="$PKG_CONFIG --static"
PKG_CHECK_MODULES($@)
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
])dnl PKG_CHECK_MODULES_STATIC
dnl PKG_INSTALLDIR([DIRECTORY])
dnl -------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable pkgconfigdir as the location where a module
dnl should install pkg-config .pc files. By default the directory is
dnl $libdir/pkgconfig, but the default can be changed by passing
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
[with_pkgconfigdir=]pkg_default)
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
])dnl PKG_INSTALLDIR
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
dnl --------------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
dnl module should install arch-independent pkg-config .pc files. By
dnl default the directory is $datadir/pkgconfig, but the default can be
dnl changed by passing DIRECTORY. The user can override through the
dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([noarch-pkgconfigdir],
[AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
[with_noarch_pkgconfigdir=]pkg_default)
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
])dnl PKG_NOARCH_INSTALLDIR
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------
dnl Since: 0.28
dnl
dnl Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR

3662
lib/php/build/run-tests.php Normal file

File diff suppressed because it is too large Load Diff

1814
lib/php/build/shtool Executable file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
pear.php.net

View File

@ -0,0 +1 @@
pecl.php.net

View File

@ -0,0 +1 @@
doc.php.net

View File

@ -0,0 +1 @@
a:4:{s:4:"name";s:5:"__uri";s:7:"servers";a:1:{s:7:"primary";a:1:{s:4:"rest";a:1:{s:7:"baseurl";a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.0";}s:8:"_content";s:4:"****";}}}}s:7:"summary";s:34:"Pseudo-channel for static packages";s:13:"_lastmodified";i:1726776280;}

View File

@ -0,0 +1 @@
a:5:{s:14:"suggestedalias";s:7:"phpdocs";s:4:"name";s:11:"doc.php.net";s:7:"summary";s:22:"PHP Documentation Team";s:7:"servers";a:1:{s:7:"primary";a:1:{s:4:"rest";a:1:{s:7:"baseurl";a:3:{i:0;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.0";}s:8:"_content";s:24:"http://doc.php.net/rest/";}i:1;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.1";}s:8:"_content";s:24:"http://doc.php.net/rest/";}i:2;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.3";}s:8:"_content";s:24:"http://doc.php.net/rest/";}}}}}s:13:"_lastmodified";i:1726776280;}

View File

@ -0,0 +1 @@
a:5:{s:14:"suggestedalias";s:4:"pear";s:4:"name";s:12:"pear.php.net";s:7:"summary";s:40:"PHP Extension and Application Repository";s:7:"servers";a:1:{s:7:"primary";a:1:{s:4:"rest";a:1:{s:7:"baseurl";a:3:{i:0;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.0";}s:8:"_content";s:25:"http://pear.php.net/rest/";}i:1;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.1";}s:8:"_content";s:25:"http://pear.php.net/rest/";}i:2;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.3";}s:8:"_content";s:25:"http://pear.php.net/rest/";}}}}}s:13:"_lastmodified";i:1726776280;}

View File

@ -0,0 +1 @@
a:6:{s:14:"suggestedalias";s:4:"pecl";s:4:"name";s:12:"pecl.php.net";s:7:"summary";s:31:"PHP Extension Community Library";s:7:"servers";a:1:{s:7:"primary";a:1:{s:4:"rest";a:1:{s:7:"baseurl";a:2:{i:0;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.0";}s:8:"_content";s:25:"http://pecl.php.net/rest/";}i:1;a:2:{s:7:"attribs";a:1:{s:4:"type";s:7:"REST1.1";}s:8:"_content";s:25:"http://pecl.php.net/rest/";}}}}}s:15:"validatepackage";a:2:{s:8:"_content";s:19:"PEAR_Validator_PECL";s:7:"attribs";a:1:{s:7:"version";s:3:"1.0";}}s:13:"_lastmodified";i:1726776280;}

1
lib/php/pear/.depdb Normal file
View File

@ -0,0 +1 @@
a:2:{s:8:"_version";s:3:"1.0";s:12:"dependencies";a:0:{}}

0
lib/php/pear/.depdblock Normal file
View File

1
lib/php/pear/.filemap Normal file
View File

@ -0,0 +1 @@
a:3:{s:3:"php";a:7:{s:15:"Archive/Tar.php";s:11:"archive_tar";s:18:"Console/Getopt.php";s:14:"console_getopt";s:44:"Structures/Graph/Manipulator/AcyclicTest.php";s:16:"structures_graph";s:50:"Structures/Graph/Manipulator/TopologicalSorter.php";s:16:"structures_graph";s:25:"Structures/Graph/Node.php";s:16:"structures_graph";s:20:"Structures/Graph.php";s:16:"structures_graph";s:12:"XML/Util.php";s:8:"xml_util";}s:3:"doc";a:5:{s:32:"archive_tar/docs/Archive_Tar.txt";s:11:"archive_tar";s:69:"structures_graph/docs/tutorials/Structures_Graph/Structures_Graph.pkg";s:16:"structures_graph";s:24:"structures_graph/LICENSE";s:16:"structures_graph";s:29:"xml_util/examples/example.php";s:8:"xml_util";s:30:"xml_util/examples/example2.php";s:8:"xml_util";}s:4:"test";a:31:{s:36:"console_getopt/tests/001-getopt.phpt";s:14:"console_getopt";s:34:"console_getopt/tests/bug10557.phpt";s:14:"console_getopt";s:34:"console_getopt/tests/bug11068.phpt";s:14:"console_getopt";s:34:"console_getopt/tests/bug13140.phpt";s:14:"console_getopt";s:35:"structures_graph/tests/AllTests.php";s:16:"structures_graph";s:41:"structures_graph/tests/BasicGraphTest.php";s:16:"structures_graph";s:48:"structures_graph/tests/TopologicalSorterTest.php";s:16:"structures_graph";s:42:"structures_graph/tests/AcyclicTestTest.php";s:16:"structures_graph";s:33:"structures_graph/tests/helper.inc";s:16:"structures_graph";s:36:"xml_util/tests/AbstractUnitTests.php";s:8:"xml_util";s:34:"xml_util/tests/ApiVersionTests.php";s:8:"xml_util";s:42:"xml_util/tests/AttributesToStringTests.php";s:8:"xml_util";s:41:"xml_util/tests/CollapseEmptyTagsTests.php";s:8:"xml_util";s:42:"xml_util/tests/CreateCDataSectionTests.php";s:8:"xml_util";s:37:"xml_util/tests/CreateCommentTests.php";s:8:"xml_util";s:40:"xml_util/tests/CreateEndElementTests.php";s:8:"xml_util";s:42:"xml_util/tests/CreateStartElementTests.php";s:8:"xml_util";s:33:"xml_util/tests/CreateTagTests.php";s:8:"xml_util";s:42:"xml_util/tests/CreateTagFromArrayTests.php";s:8:"xml_util";s:45:"xml_util/tests/GetDocTypeDeclarationTests.php";s:8:"xml_util";s:41:"xml_util/tests/GetXmlDeclarationTests.php";s:8:"xml_util";s:35:"xml_util/tests/IsValidNameTests.php";s:8:"xml_util";s:34:"xml_util/tests/RaiseErrorTests.php";s:8:"xml_util";s:39:"xml_util/tests/ReplaceEntitiesTests.php";s:8:"xml_util";s:39:"xml_util/tests/ReverseEntitiesTests.php";s:8:"xml_util";s:42:"xml_util/tests/SplitQualifiedNameTests.php";s:8:"xml_util";s:31:"xml_util/tests/Bug4950Tests.php";s:8:"xml_util";s:31:"xml_util/tests/Bug5392Tests.php";s:8:"xml_util";s:32:"xml_util/tests/Bug18343Tests.php";s:8:"xml_util";s:32:"xml_util/tests/Bug21177Tests.php";s:8:"xml_util";s:32:"xml_util/tests/Bug21184Tests.php";s:8:"xml_util";}}

0
lib/php/pear/.lock Normal file
View File

View File

@ -0,0 +1,54 @@
a:24:{s:7:"attribs";a:6:{s:15:"packagerversion";s:7:"1.10.12";s:7:"version";s:3:"2.0";s:5:"xmlns";s:35:"http://pear.php.net/dtd/package-2.0";s:11:"xmlns:tasks";s:33:"http://pear.php.net/dtd/tasks-1.0";s:9:"xmlns:xsi";s:41:"http://www.w3.org/2001/XMLSchema-instance";s:18:"xsi:schemaLocation";s:147:"http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd";}s:4:"name";s:11:"Archive_Tar";s:7:"channel";s:12:"pear.php.net";s:7:"summary";s:25:"Tar file management class";s:11:"description";s:321:"This class provides handling of tar files in PHP.
It supports creating, listing, extracting and adding to tar files.
Gzip support is available if PHP has the zlib extension built-in or
loaded. Bz2 compression is also supported with the bz2 extension loaded.
Also Lzma2 compressed archives are supported with xz extension.";s:4:"lead";a:3:{i:0;a:4:{s:4:"name";s:14:"Vincent Blavet";s:4:"user";s:7:"vblavet";s:5:"email";s:22:"vincent@phpconcept.net";s:6:"active";s:2:"no";}i:1;a:4:{s:4:"name";s:11:"Greg Beaver";s:4:"user";s:6:"cellog";s:5:"email";s:22:"greg@chiaraquartet.net";s:6:"active";s:2:"no";}i:2;a:4:{s:4:"name";s:12:"Michiel Rook";s:4:"user";s:5:"mrook";s:5:"email";s:13:"mrook@php.net";s:6:"active";s:3:"yes";}}s:6:"helper";a:4:{s:4:"name";s:11:"Stig Bakken";s:4:"user";s:3:"ssb";s:5:"email";s:12:"stig@php.net";s:6:"active";s:2:"no";}s:4:"date";s:10:"2021-07-20";s:4:"time";s:8:"19:35:29";s:7:"version";a:2:{s:7:"release";s:6:"1.4.14";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:60:"* Properly fix symbolic link path traversal (CVE-2021-32610)";s:8:"contents";a:1:{s:3:"dir";a:2:{s:7:"attribs";a:1:{s:4:"name";s:1:"/";}s:4:"file";a:2:{i:0;a:1:{s:7:"attribs";a:4:{s:14:"baseinstalldir";s:1:"/";s:6:"md5sum";s:32:"95f04c226245ad192b52c9164c1287ad";s:4:"name";s:15:"Archive/Tar.php";s:4:"role";s:3:"php";}}i:1;a:1:{s:7:"attribs";a:4:{s:14:"baseinstalldir";s:1:"/";s:6:"md5sum";s:32:"2fb90f0be7089a45c09a0d1182792419";s:4:"name";s:20:"docs/Archive_Tar.txt";s:4:"role";s:3:"doc";}}}}}s:10:"compatible";a:4:{s:4:"name";s:4:"PEAR";s:7:"channel";s:12:"pear.php.net";s:3:"min";s:5:"1.8.0";s:3:"max";s:7:"1.10.10";}s:12:"dependencies";a:1:{s:8:"required";a:2:{s:3:"php";a:1:{s:3:"min";s:5:"5.2.0";}s:13:"pearinstaller";a:1:{s:3:"min";s:5:"1.9.0";}}}s:10:"phprelease";s:0:"";s:9:"changelog";a:1:{s:7:"release";a:39:{i:0;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.4.13";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2021-02-16";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:81:"* Fix Bug #27010: Relative symlinks failing (out-of path file extraction) [mrook]";}i:1;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.4.12";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2021-01-18";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:82:"* Fix Bug #27008: Symlink out-of-path write vulnerability (CVE-2020-36193) [mrook]";}i:2;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.4.11";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2020-11-19";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:97:"* Fix Bug #27002: Filename manipulation vulnerabilities (CVE-2020-28948 / CVE-2020-28949) [mrook]";}i:3;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.4.10";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2020-09-15";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:165:"* Fix block padding when the file buffer length is a multiple of 512 and smaller than Archive_Tar buffer length
* Don't try to copy username/groupname in chroot jail";}i:4;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.9";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2019-12-04";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:67:"* Implement Feature #23861: Add option to disallow symlinks [mrook]";}i:5;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.8";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2019-10-21";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:79:"* Fix Bug #23852: PHP 7.4 - Archive_Tar->_readHeader throws deprecation [mrook]";}i:6;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.7";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2019-04-08";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:53:"* Improved performance by increasing read buffer size";}i:7;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.6";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2019-02-01";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:67:"* Improve path traversal detection for forward and backward slashes";}i:8;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.5";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2019-01-02";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:54:"* Fix Bug #23788: Relative symlinks are broken [mrook]";}i:9;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.4";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2018-12-20";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:127:"* Fix Bug #21058: Long symlinks are not supported [mrook]
* Fix Bug #23782: Prevent phar:// files from being extracted [mrook]";}i:10;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.3";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2017-06-11";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:103:"* Fix Bug #21218: Cannot use result of built-in function in write context in PHP
7.2.0alpha1 [mrook]";}i:11;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.2";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2016-02-25";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:164:"* Fix reading of archives with files > 8GB
* Performance optimizations
* Do not try to call require_once on PEAR.php if it has already been loaded by the autoloader";}i:12;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.1";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2015-08-05";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:60:"* Update composer.json to use pear-core-minimal 1.10.0alpha2";}i:13;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.4.0";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2015-07-20";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:104:"* Add support for PHP 7
* Drop support for PHP 4
* Add visibility declarations to methods and properties";}i:14;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.16";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2015-04-14";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:73:"* Fix Bug #20514: invalid package.xml; not installable with pyrus [mrook]";}i:15;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.15";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2015-03-05";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:33:"* Fixes composer.json parse error";}i:16;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.14";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2015-02-26";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:74:"* Fix Bug #18505: Possible incorrect handling of file names in TAR [mrook]";}i:17;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.13";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2014-09-02";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:16:"New BSD
License";}s:5:"notes";s:36:"* Fix Bug #20382: gzopen fix [mrook]";}i:18;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.12";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2014-08-04";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:16:"New BSD
License";}s:5:"notes";s:350:"* Fix Bug #19964: Memory leaking in Archive_Tar [mrook]
* Fix Bug #20246: Broken with php 5.5.9 [mrook]
* Fix Bug #20275: "pax_global_header" looks like a regular file
* [mrook]
* Implement Feature #19827: pass filename to _addFile function - downstream
* patch [mrook]
* Implement Feature #20132: Add custom mode/uid/gid to addString() [mrook]";}i:19;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.11";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2013-02-09";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:18:"New BSD
License";}s:5:"notes";s:128:"* Fix Bug #19746: Broken with PHP 5.5 [mrook]
* Implement Feature #11258: Custom date/time in files added on-the-fly
* [mrook]";}i:20;a:5:{s:7:"version";a:2:{s:7:"release";s:6:"1.3.10";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2012-04-10";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:18:"New BSD
License";}s:5:"notes";s:143:"* Fix Bug #13361: Unable to add() some files (ex. mp3) [mrook]
* Fix Bug #19330: Class creates incorrect (non-readable) tar.gz file
* [mrook]";}i:21;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.9";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2012-02-27";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:17:"New BSD License";}s:5:"notes";s:259:"* Fix Bug #16759: No error thrown from missing PHP zlib functions [mrook]
* Fix Bug #18877: Incorrect handling of backslashes in filenames on Linux [mrook]
* Fix Bug #19085: Error while packaging [mrook]
* Fix Bug #19289: Invalid tar file generated [mrook]";}i:22;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.8";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2011-10-14";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:449:"* Fix Bug #17853: Test failure: dirtraversal.phpt [mrook]
* Fix Bug #18512: dead links are not saved in tar file [mrook]
* Fix Bug #18702: Unpacks incorrectly on long file names using header prefix [mrook]
* Implement Feature #10145: Patch to return a Pear Error Object on failure [mrook]
* Implement Feature #17491: Option to preserve permissions [mrook]
* Implement Feature #17813: Prevent PHP notice when extracting corrupted archive [mrook]";}i:23;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.7";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2010-04-26";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:25:"PEAR compatibility update";}i:24;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.6";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2010-03-09";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:168:"* Fix Bug #16963: extractList can't extract zipped files from big tar [mrook]
* Implement Feature #4013: Ignoring files and directories on creating an archive. [mrook]";}i:25;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.5";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2009-12-31";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:64:"* Fix Bug #16958: Update 'compatible' tag in package.xml [mrook]";}i:26;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.4";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2009-12-30";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:338:"* Fix Bug #11871: wrong result of ::listContent() if filename begins or ends with space [mrook]
* Fix Bug #12462: invalid tar magic [mrook]
* Fix Bug #13918: Long filenames may get up to 511 0x00 bytes appended on read [mrook]
* Fix Bug #16202: Bogus modification times [mrook]
* Implement Feature #16212: Die is not exception [mrook]";}i:27;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.3";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2009-03-27";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:50:"http://www.opensource.org/licenses/bsd-license.php";}s:8:"_content";s:15:"New BSD License";}s:5:"notes";s:249:"Change the license to New BSD license
minor bugfix release
* fix Bug #9921 compression with bzip2 fails [cellog]
* fix Bug #11594 _readLongHeader leaves 0 bytes in filename [jamessas]
* fix Bug #11769 Incorrect symlink handing [fajar99]";}i:28;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.2";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2007-01-03";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:484:"Correct Bug #4016
Remove duplicate remove error display with '@'
Correct Bug #3909 : Check existence of OS_WINDOWS constant
Correct Bug #5452 fix for "lone zero block" when untarring packages
Change filemode (from pear-core/Archive/Tar.php v.1.21)
Correct Bug #6486 Can not extract symlinks
Correct Bug #6933 Archive_Tar (Tar file management class) Directory traversal
Correct Bug #8114 Files added on-the-fly not storing date
Correct Bug #9352 Bug on _dirCheck function over nfs path";}i:29;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.1";s:3:"api";s:5:"1.3.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2005-03-17";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:17:"Correct Bug #3855";}i:30;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.3.0";s:3:"api";s:5:"1.3.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2005-03-06";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:40:"Bugs correction (2475, 2488, 2135, 2176)";}i:31;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"1.2";s:3:"api";s:3:"1.2";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2004-05-08";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:71:"Add support for other separator than the space char and bug
correction";}i:32;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"1.1";s:3:"api";s:3:"1.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2003-05-28";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:141:"* Add support for BZ2 compression
* Add support for add and extract without using temporary files : methods addString() and extractInString()";}i:33;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"1.0";s:3:"api";s:3:"1.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2003-01-24";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:23:"Change status to stable";}i:34;a:5:{s:7:"version";a:2:{s:7:"release";s:7:"0.10-b1";s:3:"api";s:7:"0.10-b1";}s:9:"stability";a:2:{s:7:"release";s:4:"beta";s:3:"api";s:4:"beta";}s:4:"date";s:10:"2003-01-08";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:59:"Add support for long filenames (greater than 99 characters)";}i:35;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"0.9";s:3:"api";s:3:"0.9";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2002-05-27";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:25:"Auto-detect gzip'ed files";}i:36;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"0.4";s:3:"api";s:3:"0.4";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2002-05-20";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:51:"Windows bugfix: use forward slashes inside archives";}i:37;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"0.2";s:3:"api";s:3:"0.2";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2002-02-18";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:29:"From initial commit to stable";}i:38;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"0.3";s:3:"api";s:3:"0.3";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2002-04-13";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:47:"Windows bugfix: used wrong directory separators";}}}s:8:"filelist";a:2:{s:15:"Archive/Tar.php";a:5:{s:14:"baseinstalldir";s:1:"/";s:6:"md5sum";s:32:"95f04c226245ad192b52c9164c1287ad";s:4:"name";s:15:"Archive/Tar.php";s:4:"role";s:3:"php";s:12:"installed_as";s:65:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/Archive/Tar.php";}s:20:"docs/Archive_Tar.txt";a:5:{s:14:"baseinstalldir";s:1:"/";s:6:"md5sum";s:32:"2fb90f0be7089a45c09a0d1182792419";s:4:"name";s:20:"docs/Archive_Tar.txt";s:4:"role";s:3:"doc";s:12:"installed_as";s:86:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/doc/Archive_Tar/docs/Archive_Tar.txt";}}s:12:"_lastversion";N;s:7:"dirtree";a:3:{s:57:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/Archive";b:1;s:70:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/doc/Archive_Tar/docs";b:1;s:65:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/doc/Archive_Tar";b:1;}s:3:"old";a:7:{s:7:"version";s:6:"1.4.14";s:12:"release_date";s:10:"2021-07-20";s:13:"release_state";s:6:"stable";s:15:"release_license";s:15:"New BSD License";s:13:"release_notes";s:60:"* Properly fix symbolic link path traversal (CVE-2021-32610)";s:12:"release_deps";a:2:{i:0;a:4:{s:4:"type";s:3:"php";s:3:"rel";s:2:"ge";s:7:"version";s:5:"5.2.0";s:8:"optional";s:2:"no";}i:1;a:6:{s:4:"type";s:3:"pkg";s:7:"channel";s:12:"pear.php.net";s:4:"name";s:4:"PEAR";s:3:"rel";s:2:"ge";s:7:"version";s:5:"1.9.0";s:8:"optional";s:2:"no";}}s:11:"maintainers";a:4:{i:0;a:5:{s:4:"name";s:14:"Vincent Blavet";s:5:"email";s:22:"vincent@phpconcept.net";s:6:"active";s:2:"no";s:6:"handle";s:7:"vblavet";s:4:"role";s:4:"lead";}i:1;a:5:{s:4:"name";s:11:"Greg Beaver";s:5:"email";s:22:"greg@chiaraquartet.net";s:6:"active";s:2:"no";s:6:"handle";s:6:"cellog";s:4:"role";s:4:"lead";}i:2;a:5:{s:4:"name";s:12:"Michiel Rook";s:5:"email";s:13:"mrook@php.net";s:6:"active";s:3:"yes";s:6:"handle";s:5:"mrook";s:4:"role";s:4:"lead";}i:3;a:5:{s:4:"name";s:11:"Stig Bakken";s:5:"email";s:12:"stig@php.net";s:6:"active";s:2:"no";s:6:"handle";s:3:"ssb";s:4:"role";s:6:"helper";}}}s:10:"xsdversion";s:3:"2.0";s:13:"_lastmodified";i:1726776280;}

View File

@ -0,0 +1,9 @@
a:25:{s:7:"attribs";a:6:{s:15:"packagerversion";s:7:"1.10.10";s:7:"version";s:3:"2.0";s:5:"xmlns";s:35:"http://pear.php.net/dtd/package-2.0";s:11:"xmlns:tasks";s:33:"http://pear.php.net/dtd/tasks-1.0";s:9:"xmlns:xsi";s:41:"http://www.w3.org/2001/XMLSchema-instance";s:18:"xsi:schemaLocation";s:147:"http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd";}s:4:"name";s:14:"Console_Getopt";s:7:"channel";s:12:"pear.php.net";s:7:"summary";s:26:"Command-line option parser";s:11:"description";s:80:"This is a PHP implementation of "getopt" supporting both
short and long options.";s:4:"lead";a:4:{s:4:"name";s:15:"Andrei Zmievski";s:4:"user";s:6:"andrei";s:5:"email";s:14:"andrei@php.net";s:6:"active";s:2:"no";}s:9:"developer";a:4:{s:4:"name";s:11:"Stig Bakken";s:4:"user";s:3:"ssb";s:5:"email";s:12:"stig@php.net";s:6:"active";s:2:"no";}s:6:"helper";a:4:{s:4:"name";s:11:"Greg Beaver";s:4:"user";s:6:"cellog";s:5:"email";s:14:"cellog@php.net";s:6:"active";s:2:"no";}s:4:"date";s:10:"2019-11-20";s:4:"time";s:8:"18:27:07";s:7:"version";a:2:{s:7:"release";s:5:"1.4.3";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:46:"http://opensource.org/licenses/bsd-license.php";}s:8:"_content";s:12:"BSD-2-Clause";}s:5:"notes";s:98:"* PR #4: Fix PHP 7.4 deprecation: array/string curly braces access
* PR #5: fix phplint warnings";s:8:"contents";a:1:{s:3:"dir";a:2:{s:7:"attribs";a:1:{s:4:"name";s:1:"/";}s:4:"file";a:5:{i:0;a:1:{s:7:"attribs";a:3:{s:6:"md5sum";s:32:"63da5909aa85a0eb76e0ad0b5e00811a";s:4:"name";s:18:"Console/Getopt.php";s:4:"role";s:3:"php";}}i:1;a:1:{s:7:"attribs";a:3:{s:6:"md5sum";s:32:"5a6fa63ce6f2370cdad11dc24a5addd0";s:4:"name";s:21:"tests/001-getopt.phpt";s:4:"role";s:4:"test";}}i:2;a:1:{s:7:"attribs";a:3:{s:6:"md5sum";s:32:"7540b630cb8e7bfd8bb06fb65a010ae9";s:4:"name";s:19:"tests/bug10557.phpt";s:4:"role";s:4:"test";}}i:3;a:1:{s:7:"attribs";a:3:{s:6:"md5sum";s:32:"e469de3628de85779118103b3248a44f";s:4:"name";s:19:"tests/bug11068.phpt";s:4:"role";s:4:"test";}}i:4;a:1:{s:7:"attribs";a:3:{s:6:"md5sum";s:32:"cdc108b084ad8e82eeb2417f04b49ec8";s:4:"name";s:19:"tests/bug13140.phpt";s:4:"role";s:4:"test";}}}}}s:10:"compatible";a:4:{s:4:"name";s:4:"PEAR";s:7:"channel";s:12:"pear.php.net";s:3:"min";s:5:"1.4.0";s:3:"max";s:9:"1.999.999";}s:12:"dependencies";a:1:{s:8:"required";a:2:{s:3:"php";a:1:{s:3:"min";s:5:"5.4.0";}s:13:"pearinstaller";a:1:{s:3:"min";s:5:"1.8.0";}}}s:10:"phprelease";s:0:"";s:9:"changelog";a:1:{s:7:"release";a:14:{i:0;a:5:{s:4:"date";s:10:"2019-11-20";s:7:"version";a:2:{s:7:"release";s:5:"1.4.3";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:46:"http://opensource.org/licenses/bsd-license.php";}s:8:"_content";s:12:"BSD-2-Clause";}s:5:"notes";s:98:"* PR #4: Fix PHP 7.4 deprecation: array/string curly braces access
* PR #5: fix phplint warnings";}i:1;a:5:{s:4:"date";s:10:"2019-02-06";s:7:"version";a:2:{s:7:"release";s:5:"1.4.2";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:46:"http://opensource.org/licenses/bsd-license.php";}s:8:"_content";s:12:"BSD-2-Clause";}s:5:"notes";s:49:"* Remove use of each(), which is removed in PHP 8";}i:2;a:5:{s:4:"date";s:10:"2015-07-20";s:7:"version";a:2:{s:7:"release";s:5:"1.4.1";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:46:"http://opensource.org/licenses/bsd-license.php";}s:8:"_content";s:12:"BSD-2-Clause";}s:5:"notes";s:34:"* Fix unit test on PHP 7 [cweiske]";}i:3;a:5:{s:4:"date";s:10:"2015-02-22";s:7:"version";a:2:{s:7:"release";s:5:"1.4.0";s:3:"api";s:5:"1.4.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:46:"http://opensource.org/licenses/bsd-license.php";}s:8:"_content";s:12:"BSD-2-Clause";}s:5:"notes";s:111:"* Change license to BSD-2-Clause
* Set minimum PHP version to 5.4.0
* Mark static methods with "static" keyword";}i:4;a:5:{s:4:"date";s:10:"2011-03-07";s:7:"version";a:2:{s:7:"release";s:5:"1.3.1";s:3:"api";s:5:"1.3.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:51:"* Change the minimum PEAR installer dep to be lower";}i:5;a:6:{s:4:"date";s:10:"2010-12-11";s:4:"time";s:8:"20:20:13";s:7:"version";a:2:{s:7:"release";s:5:"1.3.0";s:3:"api";s:5:"1.3.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:106:"* Implement Request #13140: [PATCH] to skip unknown parameters. [patch by rquadling, improved on by dufuz]";}i:6;a:5:{s:4:"date";s:10:"2007-06-12";s:7:"version";a:2:{s:7:"release";s:5:"1.2.3";s:3:"api";s:5:"1.2.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:58:"* fix Bug #11068: No way to read plain "-" option [cardoe]";}i:7;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.2.2";s:3:"api";s:5:"1.2.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2007-02-17";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:165:"* fix Bug #4475: An ambiguous error occurred when specifying similar longoption name.
* fix Bug #10055: Not failing properly on short options missing required values";}i:8;a:5:{s:7:"version";a:2:{s:7:"release";s:5:"1.2.1";s:3:"api";s:5:"1.2.1";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2006-12-08";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:126:"Fixed bugs #4448 (Long parameter values truncated with longoption parameter) and #7444 (Trailing spaces after php closing tag)";}i:9;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"1.2";s:3:"api";s:3:"1.2";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2003-12-11";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:69:"Fix to preserve BC with 1.0 and allow correct behaviour for new users";}i:10;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"1.0";s:3:"api";s:3:"1.0";}s:9:"stability";a:2:{s:7:"release";s:6:"stable";s:3:"api";s:6:"stable";}s:4:"date";s:10:"2002-09-13";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:14:"Stable release";}i:11;a:5:{s:7:"version";a:2:{s:7:"release";s:4:"0.11";s:3:"api";s:4:"0.11";}s:9:"stability";a:2:{s:7:"release";s:4:"beta";s:3:"api";s:4:"beta";}s:4:"date";s:10:"2002-05-26";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:89:"POSIX getopt compatibility fix: treat first element of args
array as command name";}i:12;a:5:{s:7:"version";a:2:{s:7:"release";s:4:"0.10";s:3:"api";s:4:"0.10";}s:9:"stability";a:2:{s:7:"release";s:4:"beta";s:3:"api";s:4:"beta";}s:4:"date";s:10:"2002-05-12";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:13:"Packaging fix";}i:13;a:5:{s:7:"version";a:2:{s:7:"release";s:3:"0.9";s:3:"api";s:3:"0.9";}s:9:"stability";a:2:{s:7:"release";s:4:"beta";s:3:"api";s:4:"beta";}s:4:"date";s:10:"2002-05-12";s:7:"license";a:2:{s:7:"attribs";a:1:{s:3:"uri";s:26:"http://www.php.net/license";}s:8:"_content";s:11:"PHP License";}s:5:"notes";s:15:"Initial release";}}}s:8:"filelist";a:5:{s:18:"Console/Getopt.php";a:4:{s:6:"md5sum";s:32:"63da5909aa85a0eb76e0ad0b5e00811a";s:4:"name";s:18:"Console/Getopt.php";s:4:"role";s:3:"php";s:12:"installed_as";s:68:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/Console/Getopt.php";}s:21:"tests/001-getopt.phpt";a:4:{s:6:"md5sum";s:32:"5a6fa63ce6f2370cdad11dc24a5addd0";s:4:"name";s:21:"tests/001-getopt.phpt";s:4:"role";s:4:"test";s:12:"installed_as";s:91:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/test/Console_Getopt/tests/001-getopt.phpt";}s:19:"tests/bug10557.phpt";a:4:{s:6:"md5sum";s:32:"7540b630cb8e7bfd8bb06fb65a010ae9";s:4:"name";s:19:"tests/bug10557.phpt";s:4:"role";s:4:"test";s:12:"installed_as";s:89:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/test/Console_Getopt/tests/bug10557.phpt";}s:19:"tests/bug11068.phpt";a:4:{s:6:"md5sum";s:32:"e469de3628de85779118103b3248a44f";s:4:"name";s:19:"tests/bug11068.phpt";s:4:"role";s:4:"test";s:12:"installed_as";s:89:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/test/Console_Getopt/tests/bug11068.phpt";}s:19:"tests/bug13140.phpt";a:4:{s:6:"md5sum";s:32:"cdc108b084ad8e82eeb2417f04b49ec8";s:4:"name";s:19:"tests/bug13140.phpt";s:4:"role";s:4:"test";s:12:"installed_as";s:89:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/test/Console_Getopt/tests/bug13140.phpt";}}s:12:"_lastversion";N;s:7:"dirtree";a:3:{s:57:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/Console";b:1;s:75:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/test/Console_Getopt/tests";b:1;s:69:"/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear/test/Console_Getopt";b:1;}s:3:"old";a:7:{s:7:"version";s:5:"1.4.3";s:12:"release_date";s:10:"2019-11-20";s:13:"release_state";s:6:"stable";s:15:"release_license";s:12:"BSD-2-Clause";s:13:"release_notes";s:98:"* PR #4: Fix PHP 7.4 deprecation: array/string curly braces access
* PR #5: fix phplint warnings";s:12:"release_deps";a:2:{i:0;a:4:{s:4:"type";s:3:"php";s:3:"rel";s:2:"ge";s:7:"version";s:5:"5.4.0";s:8:"optional";s:2:"no";}i:1;a:6:{s:4:"type";s:3:"pkg";s:7:"channel";s:12:"pear.php.net";s:4:"name";s:4:"PEAR";s:3:"rel";s:2:"ge";s:7:"version";s:5:"1.8.0";s:8:"optional";s:2:"no";}}s:11:"maintainers";a:3:{i:0;a:5:{s:4:"name";s:15:"Andrei Zmievski";s:5:"email";s:14:"andrei@php.net";s:6:"active";s:2:"no";s:6:"handle";s:6:"andrei";s:4:"role";s:4:"lead";}i:1;a:5:{s:4:"name";s:11:"Stig Bakken";s:5:"email";s:12:"stig@php.net";s:6:"active";s:2:"no";s:6:"handle";s:3:"ssb";s:4:"role";s:9:"developer";}i:2;a:5:{s:4:"name";s:11:"Greg Beaver";s:5:"email";s:14:"cellog@php.net";s:6:"active";s:2:"no";s:6:"handle";s:6:"cellog";s:4:"role";s:6:"helper";}}}s:10:"xsdversion";s:3:"2.0";s:13:"_lastmodified";i:1726776280;}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2530
lib/php/pear/Archive/Tar.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,365 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
/**
* PHP Version 5
*
* Copyright (c) 2001-2015, The PEAR developers
*
* This source file is subject to the BSD-2-Clause license,
* that is bundled with this package in the file LICENSE, and is
* available through the world-wide-web at the following url:
* http://opensource.org/licenses/bsd-license.php.
*
* @category Console
* @package Console_Getopt
* @author Andrei Zmievski <andrei@php.net>
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
* @version CVS: $Id$
* @link http://pear.php.net/package/Console_Getopt
*/
require_once 'PEAR.php';
/**
* Command-line options parsing class.
*
* @category Console
* @package Console_Getopt
* @author Andrei Zmievski <andrei@php.net>
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
* @link http://pear.php.net/package/Console_Getopt
*/
class Console_Getopt
{
/**
* Parses the command-line options.
*
* The first parameter to this function should be the list of command-line
* arguments without the leading reference to the running program.
*
* The second parameter is a string of allowed short options. Each of the
* option letters can be followed by a colon ':' to specify that the option
* requires an argument, or a double colon '::' to specify that the option
* takes an optional argument.
*
* The third argument is an optional array of allowed long options. The
* leading '--' should not be included in the option name. Options that
* require an argument should be followed by '=', and options that take an
* option argument should be followed by '=='.
*
* The return value is an array of two elements: the list of parsed
* options and the list of non-option command-line arguments. Each entry in
* the list of parsed options is a pair of elements - the first one
* specifies the option, and the second one specifies the option argument,
* if there was one.
*
* Long and short options can be mixed.
*
* Most of the semantics of this function are based on GNU getopt_long().
*
* @param array $args an array of command-line arguments
* @param string $short_options specifies the list of allowed short options
* @param array $long_options specifies the list of allowed long options
* @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option
*
* @return array two-element array containing the list of parsed options and
* the non-option arguments
*/
public static function getopt2($args, $short_options, $long_options = null, $skip_unknown = false)
{
return Console_Getopt::doGetopt(2, $args, $short_options, $long_options, $skip_unknown);
}
/**
* This function expects $args to start with the script name (POSIX-style).
* Preserved for backwards compatibility.
*
* @param array $args an array of command-line arguments
* @param string $short_options specifies the list of allowed short options
* @param array $long_options specifies the list of allowed long options
*
* @see getopt2()
* @return array two-element array containing the list of parsed options and
* the non-option arguments
*/
public static function getopt($args, $short_options, $long_options = null, $skip_unknown = false)
{
return Console_Getopt::doGetopt(1, $args, $short_options, $long_options, $skip_unknown);
}
/**
* The actual implementation of the argument parsing code.
*
* @param int $version Version to use
* @param array $args an array of command-line arguments
* @param string $short_options specifies the list of allowed short options
* @param array $long_options specifies the list of allowed long options
* @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option
*
* @return array
*/
public static function doGetopt($version, $args, $short_options, $long_options = null, $skip_unknown = false)
{
// in case you pass directly readPHPArgv() as the first arg
if (PEAR::isError($args)) {
return $args;
}
if (empty($args)) {
return array(array(), array());
}
$non_opts = $opts = array();
settype($args, 'array');
if ($long_options) {
sort($long_options);
}
/*
* Preserve backwards compatibility with callers that relied on
* erroneous POSIX fix.
*/
if ($version < 2) {
if (isset($args[0][0]) && $args[0][0] != '-') {
array_shift($args);
}
}
for ($i = 0; $i < count($args); $i++) {
$arg = $args[$i];
/* The special element '--' means explicit end of
options. Treat the rest of the arguments as non-options
and end the loop. */
if ($arg == '--') {
$non_opts = array_merge($non_opts, array_slice($args, $i + 1));
break;
}
if ($arg[0] != '-' || (strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) {
$non_opts = array_merge($non_opts, array_slice($args, $i));
break;
} elseif (strlen($arg) > 1 && $arg[1] == '-') {
$error = Console_Getopt::_parseLongOption(substr($arg, 2),
$long_options,
$opts,
$i,
$args,
$skip_unknown);
if (PEAR::isError($error)) {
return $error;
}
} elseif ($arg == '-') {
// - is stdin
$non_opts = array_merge($non_opts, array_slice($args, $i));
break;
} else {
$error = Console_Getopt::_parseShortOption(substr($arg, 1),
$short_options,
$opts,
$i,
$args,
$skip_unknown);
if (PEAR::isError($error)) {
return $error;
}
}
}
return array($opts, $non_opts);
}
/**
* Parse short option
*
* @param string $arg Argument
* @param string[] $short_options Available short options
* @param string[][] &$opts
* @param int &$argIdx
* @param string[] $args
* @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option
*
* @return void
*/
protected static function _parseShortOption($arg, $short_options, &$opts, &$argIdx, $args, $skip_unknown)
{
for ($i = 0; $i < strlen($arg); $i++) {
$opt = $arg[$i];
$opt_arg = null;
/* Try to find the short option in the specifier string. */
if (($spec = strstr($short_options, $opt)) === false || $arg[$i] == ':') {
if ($skip_unknown === true) {
break;
}
$msg = "Console_Getopt: unrecognized option -- $opt";
return PEAR::raiseError($msg);
}
if (strlen($spec) > 1 && $spec[1] == ':') {
if (strlen($spec) > 2 && $spec[2] == ':') {
if ($i + 1 < strlen($arg)) {
/* Option takes an optional argument. Use the remainder of
the arg string if there is anything left. */
$opts[] = array($opt, substr($arg, $i + 1));
break;
}
} else {
/* Option requires an argument. Use the remainder of the arg
string if there is anything left. */
if ($i + 1 < strlen($arg)) {
$opts[] = array($opt, substr($arg, $i + 1));
break;
} else if (isset($args[++$argIdx])) {
$opt_arg = $args[$argIdx];
/* Else use the next argument. */;
if (Console_Getopt::_isShortOpt($opt_arg)
|| Console_Getopt::_isLongOpt($opt_arg)) {
$msg = "option requires an argument --$opt";
return PEAR::raiseError("Console_Getopt: " . $msg);
}
} else {
$msg = "option requires an argument --$opt";
return PEAR::raiseError("Console_Getopt: " . $msg);
}
}
}
$opts[] = array($opt, $opt_arg);
}
}
/**
* Checks if an argument is a short option
*
* @param string $arg Argument to check
*
* @return bool
*/
protected static function _isShortOpt($arg)
{
return strlen($arg) == 2 && $arg[0] == '-'
&& preg_match('/[a-zA-Z]/', $arg[1]);
}
/**
* Checks if an argument is a long option
*
* @param string $arg Argument to check
*
* @return bool
*/
protected static function _isLongOpt($arg)
{
return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' &&
preg_match('/[a-zA-Z]+$/', substr($arg, 2));
}
/**
* Parse long option
*
* @param string $arg Argument
* @param string[] $long_options Available long options
* @param string[][] &$opts
* @param int &$argIdx
* @param string[] $args
*
* @return void|PEAR_Error
*/
protected static function _parseLongOption($arg, $long_options, &$opts, &$argIdx, $args, $skip_unknown)
{
@list($opt, $opt_arg) = explode('=', $arg, 2);
$opt_len = strlen($opt);
for ($i = 0; $i < count($long_options); $i++) {
$long_opt = $long_options[$i];
$opt_start = substr($long_opt, 0, $opt_len);
$long_opt_name = str_replace('=', '', $long_opt);
/* Option doesn't match. Go on to the next one. */
if ($long_opt_name != $opt) {
continue;
}
$opt_rest = substr($long_opt, $opt_len);
/* Check that the options uniquely matches one of the allowed
options. */
if ($i + 1 < count($long_options)) {
$next_option_rest = substr($long_options[$i + 1], $opt_len);
} else {
$next_option_rest = '';
}
if ($opt_rest != '' && $opt[0] != '=' &&
$i + 1 < count($long_options) &&
$opt == substr($long_options[$i+1], 0, $opt_len) &&
$next_option_rest != '' &&
$next_option_rest[0] != '=') {
$msg = "Console_Getopt: option --$opt is ambiguous";
return PEAR::raiseError($msg);
}
if (substr($long_opt, -1) == '=') {
if (substr($long_opt, -2) != '==') {
/* Long option requires an argument.
Take the next argument if one wasn't specified. */;
if (!strlen($opt_arg)) {
if (!isset($args[++$argIdx])) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
$opt_arg = $args[$argIdx];
}
if (Console_Getopt::_isShortOpt($opt_arg)
|| Console_Getopt::_isLongOpt($opt_arg)) {
$msg = "Console_Getopt: option requires an argument --$opt";
return PEAR::raiseError($msg);
}
}
} else if ($opt_arg) {
$msg = "Console_Getopt: option --$opt doesn't allow an argument";
return PEAR::raiseError($msg);
}
$opts[] = array('--' . $opt, $opt_arg);
return;
}
if ($skip_unknown === true) {
return;
}
return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
}
/**
* Safely read the $argv PHP array across different PHP configurations.
* Will take care on register_globals and register_argc_argv ini directives
*
* @return mixed the $argv PHP array or PEAR error if not registered
*/
public static function readPHPArgv()
{
global $argv;
if (!is_array($argv)) {
if (!@is_array($_SERVER['argv'])) {
if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) {
$msg = "Could not read cmd args (register_argc_argv=Off?)";
return PEAR::raiseError("Console_Getopt: " . $msg);
}
return $GLOBALS['HTTP_SERVER_VARS']['argv'];
}
return $_SERVER['argv'];
}
return $argv;
}
}

View File

@ -0,0 +1,176 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +-----------------------------------------------------------------------------+
// | Copyright (c) 2003 Sérgio Gonçalves Carvalho |
// +-----------------------------------------------------------------------------+
// | This file is part of Structures_Graph. |
// | |
// | Structures_Graph is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or |
// | (at your option) any later version. |
// | |
// | Structures_Graph is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with Structures_Graph; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
// | 02111-1307 USA |
// +-----------------------------------------------------------------------------+
// | Author: Sérgio Carvalho <sergio.carvalho@portugalmail.com> |
// +-----------------------------------------------------------------------------+
//
/**
* The Graph.php file contains the definition of the Structures_Graph class
*
* @package Structures_Graph
*/
/* dependencies {{{ */
require_once 'PEAR.php';
require_once 'Structures/Graph/Node.php';
/* }}} */
define('STRUCTURES_GRAPH_ERROR_GENERIC', 100);
/* class Structures_Graph {{{ */
/**
* The Structures_Graph class represents a graph data structure.
*
* A Graph is a data structure composed by a set of nodes, connected by arcs.
* Graphs may either be directed or undirected. In a directed graph, arcs are
* directional, and can be traveled only one way. In an undirected graph, arcs
* are bidirectional, and can be traveled both ways.
*
* @author Sérgio Carvalho <sergio.carvalho@portugalmail.com>
* @copyright (c) 2004 by Sérgio Carvalho
* @package Structures_Graph
*/
/* }}} */
class Structures_Graph
{
/**
* List of node objects in this graph
* @access private
*/
var $_nodes = array();
/**
* If the graph is directed or not
* @access private
*/
var $_directed = false;
/**
* Constructor
*
* @param boolean $directed Set to true if the graph is directed.
* Set to false if it is not directed.
*/
public function __construct($directed = true)
{
$this->_directed = $directed;
}
/**
* Old constructor (PHP4-style; kept for BC with extending classes)
*
* @param boolean $directed Set to true if the graph is directed.
* Set to false if it is not directed.
*
* @return void
*/
public function Structures_Graph($directed = true)
{
$this->__construct($directed);
}
/**
* Return true if a graph is directed
*
* @return boolean true if the graph is directed
*/
public function isDirected()
{
return (boolean) $this->_directed;
}
/**
* Add a Node to the Graph
*
* @param Structures_Graph_Node $newNode The node to be added.
*
* @return void
*/
public function addNode(&$newNode)
{
// We only add nodes
if (!is_a($newNode, 'Structures_Graph_Node')) {
return Pear::raiseError(
'Structures_Graph::addNode received an object that is not'
. ' a Structures_Graph_Node',
STRUCTURES_GRAPH_ERROR_GENERIC
);
}
//Graphs are node *sets*, so duplicates are forbidden.
// We allow nodes that are exactly equal, but disallow equal references.
foreach ($this->_nodes as $key => $node) {
/*
ZE1 equality operators choke on the recursive cycle introduced
by the _graph field in the Node object.
So, we'll check references the hard way
(change $this->_nodes[$key] and check if the change reflects in
$node)
*/
$savedData = $this->_nodes[$key];
$referenceIsEqualFlag = false;
$this->_nodes[$key] = true;
if ($node === true) {
$this->_nodes[$key] = false;
if ($node === false) {
$referenceIsEqualFlag = true;
}
}
$this->_nodes[$key] = $savedData;
if ($referenceIsEqualFlag) {
return Pear::raiseError(
'Structures_Graph::addNode received an object that is'
. ' a duplicate for this dataset',
STRUCTURES_GRAPH_ERROR_GENERIC
);
}
}
$this->_nodes[] =& $newNode;
$newNode->setGraph($this);
}
/**
* Remove a Node from the Graph
*
* @param Structures_Graph_Node $node The node to be removed from the graph
*
* @return void
* @todo This is unimplemented
*/
public function removeNode(&$node)
{
}
/**
* Return the node set, in no particular order.
* For ordered node sets, use a Graph Manipulator insted.
*
* @return array The set of nodes in this graph
* @see Structures_Graph_Manipulator_TopologicalSorter
*/
public function &getNodes()
{
return $this->_nodes;
}
}
?>

View File

@ -0,0 +1,134 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +-----------------------------------------------------------------------------+
// | Copyright (c) 2003 Sérgio Gonçalves Carvalho |
// +-----------------------------------------------------------------------------+
// | This file is part of Structures_Graph. |
// | |
// | Structures_Graph is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or |
// | (at your option) any later version. |
// | |
// | Structures_Graph is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with Structures_Graph; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
// | 02111-1307 USA |
// +-----------------------------------------------------------------------------+
// | Author: Sérgio Carvalho <sergio.carvalho@portugalmail.com> |
// +-----------------------------------------------------------------------------+
//
/**
* This file contains the definition of the Structures_Graph_Manipulator_AcyclicTest graph manipulator.
*
* @see Structures_Graph_Manipulator_AcyclicTest
* @package Structures_Graph
*/
/* dependencies {{{ */
/** */
require_once 'PEAR.php';
/** */
require_once 'Structures/Graph.php';
/** */
require_once 'Structures/Graph/Node.php';
/* }}} */
/* class Structures_Graph_Manipulator_AcyclicTest {{{ */
/**
* The Structures_Graph_Manipulator_AcyclicTest is a graph manipulator
* which tests whether a graph contains a cycle.
*
* The definition of an acyclic graph used in this manipulator is that of a
* DAG. The graph must be directed, or else it is considered cyclic, even when
* there are no arcs.
*
* @author Sérgio Carvalho <sergio.carvalho@portugalmail.com>
* @copyright (c) 2004 by Sérgio Carvalho
* @package Structures_Graph
*/
class Structures_Graph_Manipulator_AcyclicTest {
/* _nonVisitedInDegree {{{ */
/**
*
* This is a variant of Structures_Graph::inDegree which does
* not count nodes marked as visited.
*
* @return integer Number of non-visited nodes that link to this one
*/
protected static function _nonVisitedInDegree(&$node) {
$result = 0;
$graphNodes =& $node->_graph->getNodes();
foreach (array_keys($graphNodes) as $key) {
if ((!$graphNodes[$key]->getMetadata('acyclic-test-visited')) && $graphNodes[$key]->connectsTo($node)) $result++;
}
return $result;
}
/* }}} */
/* _isAcyclic {{{ */
/**
* Check if the graph is acyclic
*/
protected static function _isAcyclic(&$graph) {
// Mark every node as not visited
$nodes =& $graph->getNodes();
$nodeKeys = array_keys($nodes);
$refGenerator = array();
foreach($nodeKeys as $key) {
$refGenerator[] = false;
$nodes[$key]->setMetadata('acyclic-test-visited', $refGenerator[sizeof($refGenerator) - 1]);
}
// Iteratively peel off leaf nodes
do {
// Find out which nodes are leafs (excluding visited nodes)
$leafNodes = array();
foreach($nodeKeys as $key) {
if ((!$nodes[$key]->getMetadata('acyclic-test-visited')) && Structures_Graph_Manipulator_AcyclicTest::_nonVisitedInDegree($nodes[$key]) == 0) {
$leafNodes[] =& $nodes[$key];
}
}
// Mark leafs as visited
for ($i=sizeof($leafNodes) - 1; $i>=0; $i--) {
$visited =& $leafNodes[$i]->getMetadata('acyclic-test-visited');
$visited = true;
$leafNodes[$i]->setMetadata('acyclic-test-visited', $visited);
}
} while (sizeof($leafNodes) > 0);
// If graph is a DAG, there should be no non-visited nodes. Let's try to prove otherwise
$result = true;
foreach($nodeKeys as $key) if (!$nodes[$key]->getMetadata('acyclic-test-visited')) $result = false;
// Cleanup visited marks
foreach($nodeKeys as $key) $nodes[$key]->unsetMetadata('acyclic-test-visited');
return $result;
}
/* }}} */
/* isAcyclic {{{ */
/**
*
* isAcyclic returns true if a graph contains no cycles, false otherwise.
*
* @return boolean true iff graph is acyclic
*/
public static function isAcyclic(&$graph) {
// We only test graphs
if (!is_a($graph, 'Structures_Graph')) return Pear::raiseError('Structures_Graph_Manipulator_AcyclicTest::isAcyclic received an object that is not a Structures_Graph', STRUCTURES_GRAPH_ERROR_GENERIC);
if (!$graph->isDirected()) return false; // Only directed graphs may be acyclic
return Structures_Graph_Manipulator_AcyclicTest::_isAcyclic($graph);
}
/* }}} */
}
/* }}} */
?>

View File

@ -0,0 +1,176 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +-----------------------------------------------------------------------------+
// | Copyright (c) 2003 Sérgio Gonçalves Carvalho |
// +-----------------------------------------------------------------------------+
// | This file is part of Structures_Graph. |
// | |
// | Structures_Graph is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or |
// | (at your option) any later version. |
// | |
// | Structures_Graph is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with Structures_Graph; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
// | 02111-1307 USA |
// +-----------------------------------------------------------------------------+
// | Author: Sérgio Carvalho <sergio.carvalho@portugalmail.com> |
// +-----------------------------------------------------------------------------+
//
/**
* This file contains the definition of the Structures_Graph_Manipulator_TopologicalSorter class.
*
* @package Structures_Graph
*/
require_once 'PEAR.php';
require_once 'Structures/Graph.php';
require_once 'Structures/Graph/Node.php';
require_once 'Structures/Graph/Manipulator/AcyclicTest.php';
/**
* The Structures_Graph_Manipulator_TopologicalSorter is a manipulator
* which is able to return the set of nodes in a graph, sorted by topological
* order.
*
* A graph may only be sorted topologically iff it's a DAG. You can test it
* with the Structures_Graph_Manipulator_AcyclicTest.
*
* @author Sérgio Carvalho <sergio.carvalho@portugalmail.com>
* @copyright (c) 2004 by Sérgio Carvalho
* @see Structures_Graph_Manipulator_AcyclicTest
* @package Structures_Graph
*/
class Structures_Graph_Manipulator_TopologicalSorter
{
/**
* This is a variant of Structures_Graph::inDegree which does
* not count nodes marked as visited.
*
* @param object $node Node to check
*
* @return integer Number of non-visited nodes that link to this one
*/
protected static function _nonVisitedInDegree(&$node)
{
$result = 0;
$graphNodes =& $node->_graph->getNodes();
foreach (array_keys($graphNodes) as $key) {
if ((!$graphNodes[$key]->getMetadata('topological-sort-visited'))
&& $graphNodes[$key]->connectsTo($node)
) {
$result++;
}
}
return $result;
}
/**
* Sort implementation
*
* @param object $graph Graph to sort
*
* @return void
*/
protected static function _sort(&$graph)
{
// Mark every node as not visited
$nodes =& $graph->getNodes();
$nodeKeys = array_keys($nodes);
$refGenerator = array();
foreach ($nodeKeys as $key) {
$refGenerator[] = false;
$nodes[$key]->setMetadata(
'topological-sort-visited',
$refGenerator[sizeof($refGenerator) - 1]
);
}
// Iteratively peel off leaf nodes
$topologicalLevel = 0;
do {
// Find out which nodes are leafs (excluding visited nodes)
$leafNodes = array();
foreach ($nodeKeys as $key) {
if ((!$nodes[$key]->getMetadata('topological-sort-visited'))
&& static::_nonVisitedInDegree($nodes[$key]) == 0
) {
$leafNodes[] =& $nodes[$key];
}
}
// Mark leafs as visited
$refGenerator[] = $topologicalLevel;
for ($i = sizeof($leafNodes) - 1; $i>=0; $i--) {
$visited =& $leafNodes[$i]->getMetadata('topological-sort-visited');
$visited = true;
$leafNodes[$i]->setMetadata('topological-sort-visited', $visited);
$leafNodes[$i]->setMetadata(
'topological-sort-level',
$refGenerator[sizeof($refGenerator) - 1]
);
}
$topologicalLevel++;
} while (sizeof($leafNodes) > 0);
// Cleanup visited marks
foreach ($nodeKeys as $key) {
$nodes[$key]->unsetMetadata('topological-sort-visited');
}
}
/**
* Sort returns the graph's nodes, sorted by topological order.
*
* The result is an array with as many entries as topological levels.
* Each entry in this array is an array of nodes within
* the given topological level.
*
* @param object $graph Graph to sort
*
* @return array The graph's nodes, sorted by topological order.
*/
public static function sort(&$graph)
{
// We only sort graphs
if (!is_a($graph, 'Structures_Graph')) {
return Pear::raiseError(
'Structures_Graph_Manipulator_TopologicalSorter::sort received'
. ' an object that is not a Structures_Graph',
STRUCTURES_GRAPH_ERROR_GENERIC
);
}
if (!Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph)) {
return Pear::raiseError(
'Structures_Graph_Manipulator_TopologicalSorter::sort'
. ' received an graph that has cycles',
STRUCTURES_GRAPH_ERROR_GENERIC
);
}
Structures_Graph_Manipulator_TopologicalSorter::_sort($graph);
$result = array();
// Fill out result array
$nodes =& $graph->getNodes();
$nodeKeys = array_keys($nodes);
foreach ($nodeKeys as $key) {
if (!array_key_exists($nodes[$key]->getMetadata('topological-sort-level'), $result)) {
$result[$nodes[$key]->getMetadata('topological-sort-level')]
= array();
}
$result[$nodes[$key]->getMetadata('topological-sort-level')][]
=& $nodes[$key];
$nodes[$key]->unsetMetadata('topological-sort-level');
}
return $result;
}
}
?>

View File

@ -0,0 +1,342 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +-----------------------------------------------------------------------------+
// | Copyright (c) 2003 Sérgio Gonçalves Carvalho |
// +-----------------------------------------------------------------------------+
// | This file is part of Structures_Graph. |
// | |
// | Structures_Graph is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or |
// | (at your option) any later version. |
// | |
// | Structures_Graph is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with Structures_Graph; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
// | 02111-1307 USA |
// +-----------------------------------------------------------------------------+
// | Author: Sérgio Carvalho <sergio.carvalho@portugalmail.com> |
// +-----------------------------------------------------------------------------+
//
/**
* This file contains the definition of the Structures_Graph_Node class
*
* @see Structures_Graph_Node
* @package Structures_Graph
*/
/* dependencies {{{ */
/** */
require_once 'PEAR.php';
/** */
require_once 'Structures/Graph.php';
/* }}} */
/* class Structures_Graph_Node {{{ */
/**
* The Structures_Graph_Node class represents a Node that can be member of a
* graph node set.
*
* A graph node can contain data. Under this API, the node contains default data,
* and key index data. It behaves, thus, both as a regular data node, and as a
* dictionary (or associative array) node.
*
* Regular data is accessed via getData and setData. Key indexed data is accessed
* via getMetadata and setMetadata.
*
* @author Sérgio Carvalho <sergio.carvalho@portugalmail.com>
* @copyright (c) 2004 by Sérgio Carvalho
* @package Structures_Graph
*/
/* }}} */
class Structures_Graph_Node {
/* fields {{{ */
/**
* @access private
*/
var $_data = null;
/** @access private */
var $_metadata = array();
/** @access private */
var $_arcs = array();
/** @access private */
var $_graph = null;
/* }}} */
/* Constructor {{{ */
/**
*
* Constructor
*
* @access public
*/
function __construct() {
}
/* }}} */
/* getGraph {{{ */
/**
*
* Node graph getter
*
* @return Structures_Graph Graph where node is stored
* @access public
*/
function &getGraph() {
return $this->_graph;
}
/* }}} */
/* setGraph {{{ */
/**
*
* Node graph setter. This method should not be called directly. Use Graph::addNode instead.
*
* @param Structures_Graph Set the graph for this node.
* @see Structures_Graph::addNode()
* @access public
*/
function setGraph(&$graph) {
$this->_graph =& $graph;
}
/* }}} */
/* getData {{{ */
/**
*
* Node data getter.
*
* Each graph node can contain a reference to one variable. This is the getter for that reference.
*
* @return mixed Data stored in node
* @access public
*/
function &getData() {
return $this->_data;
}
/* }}} */
/* setData {{{ */
/**
*
* Node data setter
*
* Each graph node can contain a reference to one variable. This is the setter for that reference.
*
* @return mixed Data to store in node
* @access public
*/
function setData(&$data) {
$this->_data =& $data;
}
/* }}} */
/* metadataKeyExists {{{ */
/**
*
* Test for existence of metadata under a given key.
*
* Each graph node can contain multiple 'metadata' entries, each stored under a different key, as in an
* associative array or in a dictionary. This method tests whether a given metadata key exists for this node.
*
* @param string Key to test
* @return boolean
* @access public
*/
function metadataKeyExists($key) {
return array_key_exists($key, $this->_metadata);
}
/* }}} */
/* getMetadata {{{ */
/**
*
* Node metadata getter
*
* Each graph node can contain multiple 'metadata' entries, each stored under a different key, as in an
* associative array or in a dictionary. This method gets the data under the given key. If the key does
* not exist, an error will be thrown, so testing using metadataKeyExists might be needed.
*
* @param string Key
* @param boolean nullIfNonexistent (defaults to false).
* @return mixed Metadata Data stored in node under given key
* @see metadataKeyExists
* @access public
*/
function &getMetadata($key, $nullIfNonexistent = false) {
if (array_key_exists($key, $this->_metadata)) {
return $this->_metadata[$key];
} else {
if ($nullIfNonexistent) {
$a = null;
return $a;
} else {
$a = Pear::raiseError('Structures_Graph_Node::getMetadata: Requested key does not exist', STRUCTURES_GRAPH_ERROR_GENERIC);
return $a;
}
}
}
/* }}} */
/* unsetMetadata {{{ */
/**
*
* Delete metadata by key
*
* Each graph node can contain multiple 'metadata' entries, each stored under a different key, as in an
* associative array or in a dictionary. This method removes any data that might be stored under the provided key.
* If the key does not exist, no error is thrown, so it is safe using this method without testing for key existence.
*
* @param string Key
* @access public
*/
function unsetMetadata($key) {
if (array_key_exists($key, $this->_metadata)) unset($this->_metadata[$key]);
}
/* }}} */
/* setMetadata {{{ */
/**
*
* Node metadata setter
*
* Each graph node can contain multiple 'metadata' entries, each stored under a different key, as in an
* associative array or in a dictionary. This method stores data under the given key. If the key already exists,
* previously stored data is discarded.
*
* @param string Key
* @param mixed Data
* @access public
*/
function setMetadata($key, &$data) {
$this->_metadata[$key] =& $data;
}
/* }}} */
/* _connectTo {{{ */
/** @access private */
function _connectTo(&$destinationNode) {
$this->_arcs[] =& $destinationNode;
}
/* }}} */
/* connectTo {{{ */
/**
*
* Connect this node to another one.
*
* If the graph is not directed, the reverse arc, connecting $destinationNode to $this is also created.
*
* @param Structures_Graph_Node Node to connect to
* @access public
*/
function connectTo(&$destinationNode) {
// We only connect to nodes
if (!is_a($destinationNode, 'Structures_Graph_Node')) return Pear::raiseError('Structures_Graph_Node::connectTo received an object that is not a Structures_Graph_Node', STRUCTURES_GRAPH_ERROR_GENERIC);
// Nodes must already be in graphs to be connected
if ($this->_graph == null) return Pear::raiseError('Structures_Graph_Node::connectTo Tried to connect a node that is not in a graph', STRUCTURES_GRAPH_ERROR_GENERIC);
if ($destinationNode->getGraph() == null) return Pear::raiseError('Structures_Graph_Node::connectTo Tried to connect to a node that is not in a graph', STRUCTURES_GRAPH_ERROR_GENERIC);
// Connect here
$this->_connectTo($destinationNode);
// If graph is undirected, connect back
if (!$this->_graph->isDirected()) {
$destinationNode->_connectTo($this);
}
}
/* }}} */
/* getNeighbours {{{ */
/**
*
* Return nodes connected to this one.
*
* @return array Array of nodes
* @access public
*/
function getNeighbours() {
return $this->_arcs;
}
/* }}} */
/* connectsTo {{{ */
/**
*
* Test wether this node has an arc to the target node
*
* @return boolean True if the two nodes are connected
* @access public
*/
function connectsTo(&$target) {
if (version_compare(PHP_VERSION, '5.0.0') >= 0) {
return in_array($target, $this->getNeighbours(), true);
}
$copy = $target;
$arcKeys = array_keys($this->_arcs);
foreach($arcKeys as $key) {
/* ZE1 chokes on this expression:
if ($target === $arc) return true;
so, we'll use more convoluted stuff
*/
$arc =& $this->_arcs[$key];
$target = true;
if ($arc === true) {
$target = false;
if ($arc === false) {
$target = $copy;
return true;
}
}
}
$target = $copy;
return false;
}
/* }}} */
/* inDegree {{{ */
/**
*
* Calculate the in degree of the node.
*
* The indegree for a node is the number of arcs entering the node. For non directed graphs,
* the indegree is equal to the outdegree.
*
* @return integer In degree of the node
* @access public
*/
function inDegree() {
if ($this->_graph == null) return 0;
if (!$this->_graph->isDirected()) return $this->outDegree();
$result = 0;
$graphNodes =& $this->_graph->getNodes();
foreach (array_keys($graphNodes) as $key) {
if ($graphNodes[$key]->connectsTo($this)) $result++;
}
return $result;
}
/* }}} */
/* outDegree {{{ */
/**
*
* Calculate the out degree of the node.
*
* The outdegree for a node is the number of arcs exiting the node. For non directed graphs,
* the outdegree is always equal to the indegree.
*
* @return integer Out degree of the node
* @access public
*/
function outDegree() {
if ($this->_graph == null) return 0;
return sizeof($this->_arcs);
}
/* }}} */
}
?>

963
lib/php/pear/XML/Util.php Normal file
View File

@ -0,0 +1,963 @@
<?php
/**
* XML_Util
*
* XML Utilities package
*
* PHP versions 4 and 5
*
* LICENSE:
*
* Copyright (c) 2003-2008 Stephan Schmidt <schst@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
* @package XML_Util
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
* @link http://pear.php.net/package/XML_Util
*/
/**
* Error code for invalid chars in XML name
*/
define('XML_UTIL_ERROR_INVALID_CHARS', 51);
/**
* Error code for invalid chars in XML name
*/
define('XML_UTIL_ERROR_INVALID_START', 52);
/**
* Error code for non-scalar tag content
*/
define('XML_UTIL_ERROR_NON_SCALAR_CONTENT', 60);
/**
* Error code for missing tag name
*/
define('XML_UTIL_ERROR_NO_TAG_NAME', 61);
/**
* Replace XML entities
*/
define('XML_UTIL_REPLACE_ENTITIES', 1);
/**
* Embedd content in a CData Section
*/
define('XML_UTIL_CDATA_SECTION', 5);
/**
* Do not replace entitites
*/
define('XML_UTIL_ENTITIES_NONE', 0);
/**
* Replace all XML entitites
* This setting will replace <, >, ", ' and &
*/
define('XML_UTIL_ENTITIES_XML', 1);
/**
* Replace only required XML entitites
* This setting will replace <, " and &
*/
define('XML_UTIL_ENTITIES_XML_REQUIRED', 2);
/**
* Replace HTML entitites
* @link http://www.php.net/htmlentities
*/
define('XML_UTIL_ENTITIES_HTML', 3);
/**
* Do not collapse any empty tags.
*/
define('XML_UTIL_COLLAPSE_NONE', 0);
/**
* Collapse all empty tags.
*/
define('XML_UTIL_COLLAPSE_ALL', 1);
/**
* Collapse only empty XHTML tags that have no end tag.
*/
define('XML_UTIL_COLLAPSE_XHTML_ONLY', 2);
/**
* Utility class for working with XML documents
*
* @category XML
* @package XML_Util
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version Release: 1.4.5
* @link http://pear.php.net/package/XML_Util
*/
class XML_Util
{
/**
* Return API version
*
* @return string $version API version
*/
public static function apiVersion()
{
return '1.4';
}
/**
* Replace XML entities
*
* With the optional second parameter, you may select, which
* entities should be replaced.
*
* <code>
* require_once 'XML/Util.php';
*
* // replace XML entites:
* $string = XML_Util::replaceEntities('This string contains < & >.');
* </code>
*
* With the optional third parameter, you may pass the character encoding
* <code>
* require_once 'XML/Util.php';
*
* // replace XML entites in UTF-8:
* $string = XML_Util::replaceEntities(
* 'This string contains < & > as well as ä, ö, ß, à and ê',
* XML_UTIL_ENTITIES_HTML,
* 'UTF-8'
* );
* </code>
*
* @param string $string string where XML special chars
* should be replaced
* @param int $replaceEntities setting for entities in attribute values
* (one of XML_UTIL_ENTITIES_XML,
* XML_UTIL_ENTITIES_XML_REQUIRED,
* XML_UTIL_ENTITIES_HTML)
* @param string $encoding encoding value (if any)...
* must be a valid encoding as determined
* by the htmlentities() function
*
* @return string string with replaced chars
* @see reverseEntities()
*/
public static function replaceEntities(
$string, $replaceEntities = XML_UTIL_ENTITIES_XML, $encoding = 'ISO-8859-1'
) {
switch ($replaceEntities) {
case XML_UTIL_ENTITIES_XML:
return strtr(
$string,
array(
'&' => '&amp;',
'>' => '&gt;',
'<' => '&lt;',
'"' => '&quot;',
'\'' => '&apos;'
)
);
break;
case XML_UTIL_ENTITIES_XML_REQUIRED:
return strtr(
$string,
array(
'&' => '&amp;',
'<' => '&lt;',
'"' => '&quot;'
)
);
break;
case XML_UTIL_ENTITIES_HTML:
return htmlentities($string, ENT_COMPAT, $encoding);
break;
}
return $string;
}
/**
* Reverse XML entities
*
* With the optional second parameter, you may select, which
* entities should be reversed.
*
* <code>
* require_once 'XML/Util.php';
*
* // reverse XML entites:
* $string = XML_Util::reverseEntities('This string contains &lt; &amp; &gt;.');
* </code>
*
* With the optional third parameter, you may pass the character encoding
* <code>
* require_once 'XML/Util.php';
*
* // reverse XML entites in UTF-8:
* $string = XML_Util::reverseEntities(
* 'This string contains &lt; &amp; &gt; as well as'
* . ' &auml;, &ouml;, &szlig;, &agrave; and &ecirc;',
* XML_UTIL_ENTITIES_HTML,
* 'UTF-8'
* );
* </code>
*
* @param string $string string where XML special chars
* should be replaced
* @param int $replaceEntities setting for entities in attribute values
* (one of XML_UTIL_ENTITIES_XML,
* XML_UTIL_ENTITIES_XML_REQUIRED,
* XML_UTIL_ENTITIES_HTML)
* @param string $encoding encoding value (if any)...
* must be a valid encoding as determined
* by the html_entity_decode() function
*
* @return string string with replaced chars
* @see replaceEntities()
*/
public static function reverseEntities(
$string, $replaceEntities = XML_UTIL_ENTITIES_XML, $encoding = 'ISO-8859-1'
) {
switch ($replaceEntities) {
case XML_UTIL_ENTITIES_XML:
return strtr(
$string,
array(
'&amp;' => '&',
'&gt;' => '>',
'&lt;' => '<',
'&quot;' => '"',
'&apos;' => '\''
)
);
break;
case XML_UTIL_ENTITIES_XML_REQUIRED:
return strtr(
$string,
array(
'&amp;' => '&',
'&lt;' => '<',
'&quot;' => '"'
)
);
break;
case XML_UTIL_ENTITIES_HTML:
return html_entity_decode($string, ENT_COMPAT, $encoding);
break;
}
return $string;
}
/**
* Build an xml declaration
*
* <code>
* require_once 'XML/Util.php';
*
* // get an XML declaration:
* $xmlDecl = XML_Util::getXMLDeclaration('1.0', 'UTF-8', true);
* </code>
*
* @param string $version xml version
* @param string $encoding character encoding
* @param bool $standalone document is standalone (or not)
*
* @return string xml declaration
* @uses attributesToString() to serialize the attributes of the
* XML declaration
*/
public static function getXMLDeclaration(
$version = '1.0', $encoding = null, $standalone = null
) {
$attributes = array(
'version' => $version,
);
// add encoding
if ($encoding !== null) {
$attributes['encoding'] = $encoding;
}
// add standalone, if specified
if ($standalone !== null) {
$attributes['standalone'] = $standalone ? 'yes' : 'no';
}
return sprintf(
'<?xml%s?>',
XML_Util::attributesToString($attributes, false)
);
}
/**
* Build a document type declaration
*
* <code>
* require_once 'XML/Util.php';
*
* // get a doctype declaration:
* $xmlDecl = XML_Util::getDocTypeDeclaration('rootTag','myDocType.dtd');
* </code>
*
* @param string $root name of the root tag
* @param string $uri uri of the doctype definition
* (or array with uri and public id)
* @param string $internalDtd internal dtd entries
*
* @return string doctype declaration
* @since 0.2
*/
public static function getDocTypeDeclaration(
$root, $uri = null, $internalDtd = null
) {
if (is_array($uri)) {
$ref = sprintf(' PUBLIC "%s" "%s"', $uri['id'], $uri['uri']);
} elseif (!empty($uri)) {
$ref = sprintf(' SYSTEM "%s"', $uri);
} else {
$ref = '';
}
if (empty($internalDtd)) {
return sprintf('<!DOCTYPE %s%s>', $root, $ref);
} else {
return sprintf("<!DOCTYPE %s%s [\n%s\n]>", $root, $ref, $internalDtd);
}
}
/**
* Create string representation of an attribute list
*
* <code>
* require_once 'XML/Util.php';
*
* // build an attribute string
* $att = array(
* 'foo' => 'bar',
* 'argh' => 'tomato'
* );
*
* $attList = XML_Util::attributesToString($att);
* </code>
*
* @param array $attributes attribute array
* @param bool|array $sort sort attribute list alphabetically,
* may also be an assoc array containing
* the keys 'sort', 'multiline', 'indent',
* 'linebreak' and 'entities'
* @param bool $multiline use linebreaks, if more than
* one attribute is given
* @param string $indent string used for indentation of
* multiline attributes
* @param string $linebreak string used for linebreaks of
* multiline attributes
* @param int $entities setting for entities in attribute values
* (one of XML_UTIL_ENTITIES_NONE,
* XML_UTIL_ENTITIES_XML,
* XML_UTIL_ENTITIES_XML_REQUIRED,
* XML_UTIL_ENTITIES_HTML)
*
* @return string string representation of the attributes
* @uses replaceEntities() to replace XML entities in attribute values
* @todo allow sort also to be an options array
*/
public static function attributesToString(
$attributes, $sort = true, $multiline = false,
$indent = ' ', $linebreak = "\n", $entities = XML_UTIL_ENTITIES_XML
) {
/*
* second parameter may be an array
*/
if (is_array($sort)) {
if (isset($sort['multiline'])) {
$multiline = $sort['multiline'];
}
if (isset($sort['indent'])) {
$indent = $sort['indent'];
}
if (isset($sort['linebreak'])) {
$multiline = $sort['linebreak'];
}
if (isset($sort['entities'])) {
$entities = $sort['entities'];
}
if (isset($sort['sort'])) {
$sort = $sort['sort'];
} else {
$sort = true;
}
}
$string = '';
if (is_array($attributes) && !empty($attributes)) {
if ($sort) {
ksort($attributes);
}
if (!$multiline || count($attributes) == 1) {
foreach ($attributes as $key => $value) {
if ($entities != XML_UTIL_ENTITIES_NONE) {
if ($entities === XML_UTIL_CDATA_SECTION) {
$entities = XML_UTIL_ENTITIES_XML;
}
$value = XML_Util::replaceEntities($value, $entities);
}
$string .= ' ' . $key . '="' . $value . '"';
}
} else {
$first = true;
foreach ($attributes as $key => $value) {
if ($entities != XML_UTIL_ENTITIES_NONE) {
$value = XML_Util::replaceEntities($value, $entities);
}
if ($first) {
$string .= ' ' . $key . '="' . $value . '"';
$first = false;
} else {
$string .= $linebreak . $indent . $key . '="' . $value . '"';
}
}
}
}
return $string;
}
/**
* Collapses empty tags.
*
* @param string $xml XML
* @param int $mode Whether to collapse all empty tags (XML_UTIL_COLLAPSE_ALL)
* or only XHTML (XML_UTIL_COLLAPSE_XHTML_ONLY) ones.
*
* @return string XML
*/
public static function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL)
{
if (preg_match('~<([^>])+/>~s', $xml, $matches)) {
// it's already an empty tag
return $xml;
}
switch ($mode) {
case XML_UTIL_COLLAPSE_ALL:
$preg1 =
'~<' .
'(?:' .
'(https?://[^:\s]+:\w+)' . // <http://foo.com:bar ($1)
'|(\w+:\w+)' . // <foo:bar ($2)
'|(\w+)' . // <foo ($3)
')+' .
'([^>]*)' . // attributes ($4)
'>' .
'<\/(\1|\2|\3)>' . // 1, 2, or 3 again ($5)
'~s'
;
$preg2 =
'<' .
'${1}${2}${3}' . // tag (only one should have been populated)
'${4}' . // attributes
' />'
;
return (preg_replace($preg1, $preg2, $xml)?:$xml);
break;
case XML_UTIL_COLLAPSE_XHTML_ONLY:
return (
preg_replace(
'/<(area|base(?:font)?|br|col|frame|hr|img|input|isindex|link|meta|'
. 'param)([^>]*)><\/\\1>/s',
'<\\1\\2 />',
$xml
) ?: $xml
);
break;
case XML_UTIL_COLLAPSE_NONE:
// fall thru
default:
return $xml;
}
}
/**
* Create a tag
*
* This method will call XML_Util::createTagFromArray(), which
* is more flexible.
*
* <code>
* require_once 'XML/Util.php';
*
* // create an XML tag:
* $tag = XML_Util::createTag('myNs:myTag',
* array('foo' => 'bar'),
* 'This is inside the tag',
* 'http://www.w3c.org/myNs#');
* </code>
*
* @param string $qname qualified tagname (including namespace)
* @param array $attributes array containg attributes
* @param mixed $content the content
* @param string $namespaceUri URI of the namespace
* @param int $replaceEntities whether to replace XML special chars in
* content, embedd it in a CData section
* or none of both
* @param bool $multiline whether to create a multiline tag where
* each attribute gets written to a single line
* @param string $indent string used to indent attributes
* (_auto indents attributes so they start
* at the same column)
* @param string $linebreak string used for linebreaks
* @param bool $sortAttributes Whether to sort the attributes or not
* @param int $collapseTagMode How to handle a content-less, and thus collapseable, tag
*
* @return string XML tag
* @see createTagFromArray()
* @uses createTagFromArray() to create the tag
*/
public static function createTag(
$qname, $attributes = array(), $content = null,
$namespaceUri = null, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
$multiline = false, $indent = '_auto', $linebreak = "\n",
$sortAttributes = true, $collapseTagMode = XML_UTIL_COLLAPSE_ALL
) {
$tag = array(
'qname' => $qname,
'attributes' => $attributes
);
// add tag content
if ($content !== null) {
$tag['content'] = $content;
}
// add namespace Uri
if ($namespaceUri !== null) {
$tag['namespaceUri'] = $namespaceUri;
}
return XML_Util::createTagFromArray(
$tag, $replaceEntities, $multiline,
$indent, $linebreak, $sortAttributes,
$collapseTagMode
);
}
/**
* Create a tag from an array.
* This method awaits an array in the following format
* <pre>
* array(
* // qualified name of the tag
* 'qname' => $qname
*
* // namespace prefix (optional, if qname is specified or no namespace)
* 'namespace' => $namespace
*
* // local part of the tagname (optional, if qname is specified)
* 'localpart' => $localpart,
*
* // array containing all attributes (optional)
* 'attributes' => array(),
*
* // tag content (optional)
* 'content' => $content,
*
* // namespaceUri for the given namespace (optional)
* 'namespaceUri' => $namespaceUri
* )
* </pre>
*
* <code>
* require_once 'XML/Util.php';
*
* $tag = array(
* 'qname' => 'foo:bar',
* 'namespaceUri' => 'http://foo.com',
* 'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
* 'content' => 'I\'m inside the tag',
* );
* // creating a tag with qualified name and namespaceUri
* $string = XML_Util::createTagFromArray($tag);
* </code>
*
* @param array $tag tag definition
* @param int $replaceEntities whether to replace XML special chars in
* content, embedd it in a CData section
* or none of both
* @param bool $multiline whether to create a multiline tag where each
* attribute gets written to a single line
* @param string $indent string used to indent attributes
* (_auto indents attributes so they start
* at the same column)
* @param string $linebreak string used for linebreaks
* @param bool $sortAttributes Whether to sort the attributes or not
* @param int $collapseTagMode How to handle a content-less, and thus collapseable, tag
*
* @return string XML tag
*
* @see createTag()
* @uses attributesToString() to serialize the attributes of the tag
* @uses splitQualifiedName() to get local part and namespace of a qualified name
* @uses createCDataSection()
* @uses collapseEmptyTags()
* @uses raiseError()
*/
public static function createTagFromArray(
$tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,
$multiline = false, $indent = '_auto', $linebreak = "\n",
$sortAttributes = true, $collapseTagMode = XML_UTIL_COLLAPSE_ALL
) {
if (isset($tag['content']) && !is_scalar($tag['content'])) {
return XML_Util::raiseError(
'Supplied non-scalar value as tag content',
XML_UTIL_ERROR_NON_SCALAR_CONTENT
);
}
if (!isset($tag['qname']) && !isset($tag['localPart'])) {
return XML_Util::raiseError(
'You must either supply a qualified name '
. '(qname) or local tag name (localPart).',
XML_UTIL_ERROR_NO_TAG_NAME
);
}
// if no attributes hav been set, use empty attributes
if (!isset($tag['attributes']) || !is_array($tag['attributes'])) {
$tag['attributes'] = array();
}
if (isset($tag['namespaces'])) {
foreach ($tag['namespaces'] as $ns => $uri) {
$tag['attributes']['xmlns:' . $ns] = $uri;
}
}
if (!isset($tag['qname'])) {
// qualified name is not given
// check for namespace
if (isset($tag['namespace']) && !empty($tag['namespace'])) {
$tag['qname'] = $tag['namespace'] . ':' . $tag['localPart'];
} else {
$tag['qname'] = $tag['localPart'];
}
} elseif (isset($tag['namespaceUri']) && !isset($tag['namespace'])) {
// namespace URI is set, but no namespace
$parts = XML_Util::splitQualifiedName($tag['qname']);
$tag['localPart'] = $parts['localPart'];
if (isset($parts['namespace'])) {
$tag['namespace'] = $parts['namespace'];
}
}
if (isset($tag['namespaceUri']) && !empty($tag['namespaceUri'])) {
// is a namespace given
if (isset($tag['namespace']) && !empty($tag['namespace'])) {
$tag['attributes']['xmlns:' . $tag['namespace']]
= $tag['namespaceUri'];
} else {
// define this Uri as the default namespace
$tag['attributes']['xmlns'] = $tag['namespaceUri'];
}
}
if (!array_key_exists('content', $tag)) {
$tag['content'] = '';
}
// check for multiline attributes
if ($multiline === true) {
if ($indent === '_auto') {
$indent = str_repeat(' ', (strlen($tag['qname'])+2));
}
}
// create attribute list
$attList = XML_Util::attributesToString(
$tag['attributes'],
$sortAttributes, $multiline, $indent, $linebreak
);
switch ($replaceEntities) {
case XML_UTIL_ENTITIES_NONE:
break;
case XML_UTIL_CDATA_SECTION:
$tag['content'] = XML_Util::createCDataSection($tag['content']);
break;
default:
$tag['content'] = XML_Util::replaceEntities(
$tag['content'], $replaceEntities
);
break;
}
$tag = sprintf(
'<%s%s>%s</%s>', $tag['qname'], $attList, $tag['content'],
$tag['qname']
);
return self::collapseEmptyTags($tag, $collapseTagMode);
}
/**
* Create a start element
*
* <code>
* require_once 'XML/Util.php';
*
* // create an XML start element:
* $tag = XML_Util::createStartElement('myNs:myTag',
* array('foo' => 'bar') ,'http://www.w3c.org/myNs#');
* </code>
*
* @param string $qname qualified tagname (including namespace)
* @param array $attributes array containg attributes
* @param string $namespaceUri URI of the namespace
* @param bool $multiline whether to create a multiline tag where each
* attribute gets written to a single line
* @param string $indent string used to indent attributes (_auto indents
* attributes so they start at the same column)
* @param string $linebreak string used for linebreaks
* @param bool $sortAttributes Whether to sort the attributes or not
*
* @return string XML start element
* @see createEndElement(), createTag()
*/
public static function createStartElement(
$qname, $attributes = array(), $namespaceUri = null,
$multiline = false, $indent = '_auto', $linebreak = "\n",
$sortAttributes = true
) {
// if no attributes hav been set, use empty attributes
if (!isset($attributes) || !is_array($attributes)) {
$attributes = array();
}
if ($namespaceUri != null) {
$parts = XML_Util::splitQualifiedName($qname);
}
// check for multiline attributes
if ($multiline === true) {
if ($indent === '_auto') {
$indent = str_repeat(' ', (strlen($qname)+2));
}
}
if ($namespaceUri != null) {
// is a namespace given
if (isset($parts['namespace']) && !empty($parts['namespace'])) {
$attributes['xmlns:' . $parts['namespace']] = $namespaceUri;
} else {
// define this Uri as the default namespace
$attributes['xmlns'] = $namespaceUri;
}
}
// create attribute list
$attList = XML_Util::attributesToString(
$attributes, $sortAttributes,
$multiline, $indent, $linebreak
);
$element = sprintf('<%s%s>', $qname, $attList);
return $element;
}
/**
* Create an end element
*
* <code>
* require_once 'XML/Util.php';
*
* // create an XML start element:
* $tag = XML_Util::createEndElement('myNs:myTag');
* </code>
*
* @param string $qname qualified tagname (including namespace)
*
* @return string XML end element
* @see createStartElement(), createTag()
*/
public static function createEndElement($qname)
{
$element = sprintf('</%s>', $qname);
return $element;
}
/**
* Create an XML comment
*
* <code>
* require_once 'XML/Util.php';
*
* // create an XML start element:
* $tag = XML_Util::createComment('I am a comment');
* </code>
*
* @param string $content content of the comment
*
* @return string XML comment
*/
public static function createComment($content)
{
$comment = sprintf('<!-- %s -->', $content);
return $comment;
}
/**
* Create a CData section
*
* <code>
* require_once 'XML/Util.php';
*
* // create a CData section
* $tag = XML_Util::createCDataSection('I am content.');
* </code>
*
* @param string $data data of the CData section
*
* @return string CData section with content
*/
public static function createCDataSection($data)
{
return sprintf(
'<![CDATA[%s]]>',
preg_replace('/\]\]>/', ']]]]><![CDATA[>', strval($data))
);
}
/**
* Split qualified name and return namespace and local part
*
* <code>
* require_once 'XML/Util.php';
*
* // split qualified tag
* $parts = XML_Util::splitQualifiedName('xslt:stylesheet');
* </code>
* the returned array will contain two elements:
* <pre>
* array(
* 'namespace' => 'xslt',
* 'localPart' => 'stylesheet'
* );
* </pre>
*
* @param string $qname qualified tag name
* @param string $defaultNs default namespace (optional)
*
* @return array array containing namespace and local part
*/
public static function splitQualifiedName($qname, $defaultNs = null)
{
if (strstr($qname, ':')) {
$tmp = explode(':', $qname);
return array(
'namespace' => $tmp[0],
'localPart' => $tmp[1]
);
}
return array(
'namespace' => $defaultNs,
'localPart' => $qname
);
}
/**
* Check, whether string is valid XML name
*
* <p>XML names are used for tagname, attribute names and various
* other, lesser known entities.</p>
* <p>An XML name may only consist of alphanumeric characters,
* dashes, undescores and periods, and has to start with a letter
* or an underscore.</p>
*
* <code>
* require_once 'XML/Util.php';
*
* // verify tag name
* $result = XML_Util::isValidName('invalidTag?');
* if (is_a($result, 'PEAR_Error')) {
* print 'Invalid XML name: ' . $result->getMessage();
* }
* </code>
*
* @param string $string string that should be checked
*
* @return mixed true, if string is a valid XML name, PEAR error otherwise
*
* @todo support for other charsets
* @todo PEAR CS - unable to avoid 85-char limit on second preg_match
*/
public static function isValidName($string)
{
// check for invalid chars
if (!is_string($string) || !strlen($string) || !preg_match('/^[[:alpha:]_]\\z/', $string[0])) {
return XML_Util::raiseError(
'XML names may only start with letter or underscore',
XML_UTIL_ERROR_INVALID_START
);
}
// check for invalid chars
$match = preg_match(
'/^([[:alpha:]_]([[:alnum:]\-\.]*)?:)?'
. '[[:alpha:]_]([[:alnum:]\_\-\.]+)?\\z/',
$string
);
if (!$match) {
return XML_Util::raiseError(
'XML names may only contain alphanumeric '
. 'chars, period, hyphen, colon and underscores',
XML_UTIL_ERROR_INVALID_CHARS
);
}
// XML name is valid
return true;
}
/**
* Replacement for XML_Util::raiseError
*
* Avoids the necessity to always require
* PEAR.php
*
* @param string $msg error message
* @param int $code error code
*
* @return PEAR_Error
* @todo PEAR CS - should this use include_once instead?
*/
public static function raiseError($msg, $code)
{
include_once 'PEAR.php';
return PEAR::raiseError($msg, $code);
}
}
?>

View File

@ -0,0 +1,475 @@
Documentation for class Archive_Tar
===================================
Last update : 2001-08-15
Overview :
----------
The Archive_Tar class helps in creating and managing GNU TAR format
files compressed by GNU ZIP or not.
The class offers basic functions like creating an archive, adding
files in the archive, extracting files from the archive and listing
the archive content.
It also provide advanced functions that allow the adding and
extraction of files with path manipulation.
Sample :
--------
// ----- Creating the object (uncompressed archive)
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
// ----- Creating the archive
$v_list[0]="file.txt";
$v_list[1]="data/";
$v_list[2]="file.log";
$tar_object->create($v_list);
// ----- Adding files
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/";
$v_list[2]="log/file.log";
$tar_object->add($v_list);
// ----- Adding more files
$tar_object->add("release/newfile.log release/readme.txt");
// ----- Listing the content
if (($v_list = $tar_object->listContent()) != 0)
for ($i=0; $i<sizeof($v_list); $i++)
{
echo "Filename :'".$v_list[$i][filename]."'<br>";
echo " .size :'".$v_list[$i][size]."'<br>";
echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
echo " .mode :'".$v_list[$i][mode]."'<br>";
echo " .uid :'".$v_list[$i][uid]."'<br>";
echo " .gid :'".$v_list[$i][gid]."'<br>";
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
}
// ----- Extracting the archive in directory "install"
$tar_object->extract("install");
Public arguments :
------------------
None
Public Methods :
----------------
Method : Archive_Tar($p_tarname, $compress = null)
Description :
Archive_Tar Class constructor. This flavour of the constructor only
declare a new Archive_Tar object, identifying it by the name of the
tar file.
If the compress argument is set the tar will be read or created as a
gzip or bz2 compressed TAR file.
Arguments :
$p_tarname : A valid filename for the tar archive file.
$p_compress : can be null, 'gz' or 'bz2'. For
compatibility reason it can also be true. This
parameter indicates if gzip or bz2 compression
is required.
Return value :
The Archive_Tar object.
Sample :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object_compressed = new Archive_Tar("tarname.tgz", true);
How it works :
Initialize the object.
Method : create($p_filelist)
Description :
This method creates the archive file and add the files / directories
that are listed in $p_filelist.
If the file already exists and is writable, it is replaced by the
new tar. It is a create and not an add. If the file exists and is
read-only or is a directory it is not replaced. The method return
false and a PEAR error text.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
See also createModify() method for more details.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$v_list[0]="file.txt";
$v_list[1]="data/"; (Optional '/' at the end)
$v_list[2]="file.log";
$tar_object->create($v_list);
Sample 2 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$tar_object->create("file.txt data/ file.log");
How it works :
Just calling the createModify() method with the right parameters.
Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "")
Description :
This method creates the archive file and add the files / directories
that are listed in $p_filelist.
If the file already exists and is writable, it is replaced by the
new tar. It is a create and not an add. If the file exists and is
read-only or is a directory it is not replaced. The method return
false and a PEAR error text.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
The path indicated in $p_remove_dir will be removed from the
memorized path of each file / directory listed when this path
exists. By default nothing is removed (empty path "")
The path indicated in $p_add_dir will be added at the beginning of
the memorized path of each file / directory listed. However it can
be set to empty "". The adding of a path is done after the removing
of path.
The path add/remove ability enables the user to prepare an archive
for extraction in a different path than the origin files are.
See also addModify() method for file adding properties.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
$p_add_dir : A string which contains a path to be added to the
memorized path of each element in the list.
$p_remove_dir : A string which contains a path to be removed from
the memorized path of each element in the list, when
relevant.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$v_list[0]="file.txt";
$v_list[1]="data/"; (Optional '/' at the end)
$v_list[2]="file.log";
$tar_object->createModify($v_list, "install");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/file.log
Sample 2 :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->createModify($v_list, "install", "dev");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/log/file.log
How it works :
Open the file in write mode (erasing the existing one if one),
call the _addList() method for adding the files in an empty archive,
add the tar footer (512 bytes block), close the tar file.
Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="")
Description :
This method add the files / directories listed in $p_filelist at the
end of the existing archive. If the archive does not yet exists it
is created.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
The path indicated in $p_remove_dir will be removed from the
memorized path of each file / directory listed when this path
exists. By default nothing is removed (empty path "")
The path indicated in $p_add_dir will be added at the beginning of
the memorized path of each file / directory listed. However it can
be set to empty "". The adding of a path is done after the removing
of path.
The path add/remove ability enables the user to prepare an archive
for extraction in a different path than the origin files are.
If a file/dir is already in the archive it will only be added at the
end of the archive. There is no update of the existing archived
file/dir. However while extracting the archive, the last file will
replace the first one. This results in a none optimization of the
archive size.
If a file/dir does not exist the file/dir is ignored. However an
error text is send to PEAR error.
If a file/dir is not readable the file/dir is ignored. However an
error text is send to PEAR error.
If the resulting filename/dirname (after the add/remove option or
not) string is greater than 99 char, the file/dir is
ignored. However an error text is send to PEAR error.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
$p_add_dir : A string which contains a path to be added to the
memorized path of each element in the list.
$p_remove_dir : A string which contains a path to be removed from
the memorized path of each element in the list, when
relevant.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->addModify($v_list, "install");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/file.log
Sample 2 :
$tar_object = new Archive_Tar("tarname.tar");
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->addModify($v_list, "install", "dev");
// files are stored in the archive as :
// install/file.txt
// install/data
// install/data/file1.txt
// install/data/... all the files and sub-dirs of data/
// install/log/file.log
How it works :
If the archive does not exists it create it and add the files.
If the archive does exists and is not compressed, it open it, jump
before the last empty 512 bytes block (tar footer) and add the files
at this point.
If the archive does exists and is compressed, a temporary copy file
is created. This temporary file is then 'gzip' read block by block
until the last empty block. The new files are then added in the
compressed file.
The adding of files is done by going through the file/dir list,
adding files per files, in a recursive way through the
directory. Each time a path need to be added/removed it is done
before writing the file header in the archive.
Method : add($p_filelist)
Description :
This method add the files / directories listed in $p_filelist at the
end of the existing archive. If the archive does not yet exists it
is created.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
See addModify() method for details and limitations.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
Return value :
true on success, false on error.
Sample 1 :
$tar_object = new Archive_Tar("tarname.tar");
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->add($v_list);
Sample 2 :
$tar_object = new Archive_Tar("tarname.tgz", true);
[...]
$v_list[0]="dev/file.txt";
$v_list[1]="dev/data/"; (Optional '/' at the end)
$v_list[2]="log/file.log";
$tar_object->add($v_list);
How it works :
Simply call the addModify() method with the right parameters.
Method : addString($p_filename, $p_string, $p_datetime, $p_params)
Description :
This method add a single string as a file at the
end of the existing archive. If the archive does not yet exists it
is created.
Arguments :
$p_filename : A string which contains the full filename path
that will be associated with the string.
$p_string : The content of the file added in the archive.
$p_datetime : (Optional) Timestamp of the file (default = now)
$p_params : (Optional) Various file metadata:
stamp - As above, timestamp of the file
mode - UNIX-style permissions (default 0600)
type - Is this a regular file or link (see TAR
format spec for how to create a hard/symlink)
uid - UNIX-style user ID (default 0 = root)
gid - UNIX-style group ID (default 0 = root)
Return value :
true on success, false on error.
Sample 1 :
$v_archive = & new Archive_Tar($p_filename);
$v_archive->setErrorHandling(PEAR_ERROR_PRINT);
$v_result = $v_archive->addString('data/test.txt', 'This is the text of the string');
$v_result = $v_archive->addString(
'data/test.sh',
"#!/bin/sh\necho 'Hello'",
time(),
array( "mode" => 0755, "uid" => 34 )
);
Method : extract($p_path = "")
Description :
This method extract all the content of the archive in the directory
indicated by $p_path.If $p_path is optional, if not set the archive
is extracted in the current directory.
While extracting a file, if the directory path does not exists it is
created.
See extractModify() for details and limitations.
Arguments :
$p_path : Optional path where the files/dir need to by extracted.
Return value :
true on success, false on error.
Sample :
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->extract();
How it works :
Simply call the extractModify() method with appropriate parameters.
Method : extractModify($p_path, $p_remove_path)
Description :
This method extract all the content of the archive in the directory
indicated by $p_path. When relevant the memorized path of the
files/dir can be modified by removing the $p_remove_path path at the
beginning of the file/dir path.
While extracting a file, if the directory path does not exists it is
created.
While extracting a file, if the file already exists it is replaced
without looking for last modification date.
While extracting a file, if the file already exists and is write
protected, the extraction is aborted.
While extracting a file, if a directory with the same name already
exists, the extraction is aborted.
While extracting a directory, if a file with the same name already
exists, the extraction is aborted.
While extracting a file/directory if the destination directory exist
and is write protected, or does not exist but can not be created,
the extraction is aborted.
If after extraction an extracted file does not show the correct
stored file size, the extraction is aborted.
When the extraction is aborted, a PEAR error text is set and false
is returned. However the result can be a partial extraction that may
need to be manually cleaned.
Arguments :
$p_path : The path of the directory where the files/dir need to by
extracted.
$p_remove_path : Part of the memorized path that can be removed if
present at the beginning of the file/dir path.
Return value :
true on success, false on error.
Sample :
// Imagine tarname.tar with files :
// dev/data/file.txt
// dev/data/log.txt
// readme.txt
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->extractModify("install", "dev");
// Files will be extracted there :
// install/data/file.txt
// install/data/log.txt
// install/readme.txt
How it works :
Open the archive and call a more generic function that can extract
only a part of the archive or all the archive.
See extractList() method for more details.
Method : extractInString($p_filename)
Description :
This method extract from the archive one file identified by $p_filename.
The return value is a string with the file content, or NULL on error.
Arguments :
$p_filename : The path of the file to extract in a string.
Return value :
a string with the file content or NULL.
Sample :
// Imagine tarname.tar with files :
// dev/data/file.txt
// dev/data/log.txt
// dev/readme.txt
$v_archive = & new Archive_Tar('tarname.tar');
$v_archive->setErrorHandling(PEAR_ERROR_PRINT);
$v_string = $v_archive->extractInString('dev/readme.txt');
echo $v_string;
Method : listContent()
Description :
This method returns an array of arrays that describe each
file/directory present in the archive.
The array is not sorted, so it show the position of the file in the
archive.
The file informations are :
$file[filename] : Name and path of the file/dir.
$file[mode] : File permissions (result of fileperms())
$file[uid] : user id
$file[gid] : group id
$file[size] : filesize
$file[mtime] : Last modification time (result of filemtime())
$file[typeflag] : "" for file, "5" for directory
Arguments :
Return value :
An array of arrays or 0 on error.
Sample :
$tar_object = new Archive_Tar("tarname.tar");
if (($v_list = $tar_object->listContent()) != 0)
for ($i=0; $i<sizeof($v_list); $i++)
{
echo "Filename :'".$v_list[$i][filename]."'<br>";
echo " .size :'".$v_list[$i][size]."'<br>";
echo " .mtime :'".$v_list[$i][mtime]."' (".
date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
echo " .mode :'".$v_list[$i][mode]."'<br>";
echo " .uid :'".$v_list[$i][uid]."'<br>";
echo " .gid :'".$v_list[$i][gid]."'<br>";
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
}
How it works :
Call the same function as an extract however with a flag to only go
through the archive without extracting the files.
Method : extractList($p_filelist, $p_path = "", $p_remove_path = "")
Description :
This method extract from the archive only the files indicated in the
$p_filelist. These files are extracted in the current directory or
in the directory indicated by the optional $p_path parameter.
If indicated the $p_remove_path can be used in the same way as it is
used in extractModify() method.
Arguments :
$p_filelist : An array of filenames and directory names, or a single
string with names separated by a single blank space.
$p_path : The path of the directory where the files/dir need to by
extracted.
$p_remove_path : Part of the memorized path that can be removed if
present at the beginning of the file/dir path.
Return value :
true on success, false on error.
Sample :
// Imagine tarname.tar with files :
// dev/data/file.txt
// dev/data/log.txt
// readme.txt
$tar_object = new Archive_Tar("tarname.tar");
$tar_object->extractList("dev/data/file.txt readme.txt", "install",
"dev");
// Files will be extracted there :
// install/data/file.txt
// install/readme.txt
How it works :
Go through the archive and extract only the files present in the
list.

View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -0,0 +1,98 @@
<refentry id="{@id package.database.structures_graph.tutorial}">
<refnamediv>
<refname><classname>Structures_Graph</classname> Tutorial</refname>
<refpurpose>A first tour of graph datastructure manipulation</refpurpose>
</refnamediv>
<refsect1 id="{@id package.database.structures_graph.tutorial.intro}">
<title>Introduction</title>
<para>
Structures_Graph is a package for creating and manipulating graph datastructures. A graph is a set of objects, called nodes, connected by arcs. When used as a datastructure, usually nodes contain data, and arcs represent relationships between nodes. When arcs have a direction, and can be travelled only one way, graphs are said to be directed. When arcs have no direction, and can always be travelled both ways, graphs are said to be non directed.
</para>
<para>
Structures_Graph provides an object oriented API to create and directly query a graph, as well as a set of Manipulator classes to extract information from the graph.
</para>
</refsect1>
<refsect1 id="{@id package.database.structures_graph.tutorial.creation}">
<title>Creating a Graph</title>
<para>
Creating a graph is done using the simple constructor:
<programlisting>
<![CDATA[
require_once 'Structures/Graph.php';
$directedGraph =& new Structures_Graph(true);
$nonDirectedGraph =& new Structures_Graph(false);
]]>
</programlisting>
and passing the constructor a flag telling it whether the graph should be directed. A directed graph will always be directed during its lifetime. It's a permanent characteristic.
</para>
<para>
To fill out the graph, we'll need to create some nodes, and then call Graph::addNode.
<programlisting>
<![CDATA[
require_once 'Structures/Graph/Node.php';
$nodeOne =& new Structures_Graph_Node();
$nodeTwo =& new Structures_Graph_Node();
$nodeThree =& new Structures_Graph_Node();
$directedGraph->addNode(&$nodeOne);
$directedGraph->addNode(&$nodeTwo);
$directedGraph->addNode(&$nodeThree);
]]>
</programlisting>
and then setup the arcs:
<programlisting>
<![CDATA[
$nodeOne->connectTo($nodeTwo);
$nodeOne->connectTo($nodeThree);
]]>
</programlisting>
Note that arcs can only be created after the nodes have been inserted into the graph.
</para>
</refsect1>
<refsect1 id="{@id package.database.structures_graph.tutorial.nodesanddata}">
<title>Associating Data</title>
<para>
Graphs are only useful as datastructures if they can hold data. Structure_Graph stores data in nodes. Each node contains a setter and a getter for its data.
<programlisting>
<![CDATA[
$nodeOne->setData("Node One's Data is a String");
$nodeTwo->setData(1976);
$nodeThree->setData('Some other string');
print("NodeTwo's Data is an integer: " . $nodeTwo->getData());
]]>
</programlisting>
</para>
<para>
Structure_Graph nodes can also store metadata, alongside with the main data. Metadata differs from regular data just because it is stored under a key, making it possible to store more than one data reference per node. The metadata getter and setter need the key to perform the operation:
<programlisting>
<![CDATA[
$nodeOne->setMetadata('example key', "Node One's Sample Metadata");
print("Metadata stored under key 'example key' in node one: " . $nodeOne->getMetadata('example key'));
$nodeOne->unsetMetadata('example key');
]]>
</programlisting>
</para>
</refsect1>
<refsect1 id="{@id package.database.structures_graph.tutorial.querying}">
<title>Querying a Graph</title>
<para>
Structures_Graph provides for basic querying of the graph:
<programlisting>
<![CDATA[
// Nodes are able to calculate their indegree and outdegree
print("NodeOne's inDegree: " . $nodeOne->inDegree());
print("NodeOne's outDegree: " . $nodeOne->outDegree());
// and naturally, nodes can report on their arcs
$arcs = $nodeOne->getNeighbours();
for ($i=0;$i<sizeof($arcs);$i++) {
print("NodeOne has an arc to " . $arcs[$i]->getData());
}
]]>
</programlisting>
</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,299 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Examples (file #1)
*
* several examples for the methods of XML_Util
*
* PHP versions 4 and 5
*
* LICENSE:
*
* Copyright (c) 2003-2008 Stephan Schmidt <schst@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
* @package XML_Util
* @subpackage Examples
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
* @link http://pear.php.net/package/XML_Util
*/
/**
* set error level
*/
error_reporting(E_ALL);
require_once 'XML/Util.php';
/**
* replacing XML entities
*/
print 'replace XML entities:<br>';
print XML_Util::replaceEntities('This string contains < & >.');
print "\n<br><br>\n";
/**
* reversing XML entities
*/
print 'replace XML entities:<br>';
print XML_Util::reverseEntities('This string contains &lt; &amp; &gt;.');
print "\n<br><br>\n";
/**
* building XML declaration
*/
print 'building XML declaration:<br>';
print htmlspecialchars(XML_Util::getXMLDeclaration());
print "\n<br><br>\n";
print 'building XML declaration with additional attributes:<br>';
print htmlspecialchars(XML_Util::getXMLDeclaration('1.0', 'UTF-8', true));
print "\n<br><br>\n";
/**
* building document type declaration
*/
print 'building DocType declaration:<br>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
'http://pear.php.net/dtd/package-1.0'));
print "\n<br><br>\n";
print 'building DocType declaration with public ID (does not exist):<br>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
array('uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1')));
print "\n<br><br>\n";
print 'building DocType declaration with internal DTD:<br>';
print '<pre>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package',
'http://pear.php.net/dtd/package-1.0',
'<!ELEMENT additionalInfo (#PCDATA)>'));
print '</pre>';
print "\n<br><br>\n";
/**
* creating an attribute string
*/
$att = array(
'foo' => 'bar',
'argh' => 'tomato'
);
print 'converting array to string:<br>';
print XML_Util::attributesToString($att);
print "\n<br><br>\n";
/**
* creating an attribute string with linebreaks
*/
$att = array(
'foo' => 'bar',
'argh' => 'tomato'
);
print 'converting array to string (including line breaks):<br>';
print '<pre>';
print XML_Util::attributesToString($att, true, true);
print '</pre>';
print "\n<br><br>\n";
/**
* splitting a qualified tag name
*/
print 'splitting qualified tag name:<br>';
print '<pre>';
print_r(XML_Util::splitQualifiedName('xslt:stylesheet'));
print '</pre>';
print "\n<br>\n";
/**
* splitting a qualified tag name (no namespace)
*/
print 'splitting qualified tag name (no namespace):<br>';
print '<pre>';
print_r(XML_Util::splitQualifiedName('foo'));
print '</pre>';
print "\n<br>\n";
/**
* splitting a qualified tag name (no namespace, but default namespace specified)
*/
print 'splitting qualified tag name '
. '(no namespace, but default namespace specified):<br>';
print '<pre>';
print_r(XML_Util::splitQualifiedName('foo', 'bar'));
print '</pre>';
print "\n<br>\n";
/**
* verifying XML names
*/
print 'verifying \'My private tag\':<br>';
print '<pre>';
print_r(XML_Util::isValidname('My Private Tag'));
print '</pre>';
print "\n<br><br>\n";
print 'verifying \'-MyTag\':<br>';
print '<pre>';
print_r(XML_Util::isValidname('-MyTag'));
print '</pre>';
print "\n<br><br>\n";
/**
* creating an XML tag
*/
$tag = array(
'namespace' => 'foo',
'localPart' => 'bar',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag'
);
print 'creating a tag with namespace and local part:<br>';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n<br><br>\n";
/**
* creating an XML tag
*/
$tag = array(
'qname' => 'foo:bar',
'namespaceUri' => 'http://foo.com',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag'
);
print 'creating a tag with qualified name and namespaceUri:<br>';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n<br><br>\n";
/**
* creating an XML tag
*/
$tag = array(
'qname' => 'bar',
'namespaceUri' => 'http://foo.com',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable')
);
print 'creating an empty tag without namespace but namespace Uri:<br>';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n<br><br>\n";
/**
* creating an XML tag with more namespaces
*/
$tag = array(
'namespace' => 'foo',
'localPart' => 'bar',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag',
'namespaces' => array(
'bar' => 'http://bar.com',
'pear' => 'http://pear.php.net',
)
);
print 'creating an XML tag with more namespaces:<br />';
print htmlentities(XML_Util::createTagFromArray($tag));
print "\n<br><br>\n";
/**
* creating an XML tag with a CData Section
*/
$tag = array(
'qname' => 'foo',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag'
);
print 'creating a tag with CData section:<br>';
print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_CDATA_SECTION));
print "\n<br><br>\n";
/**
* creating an XML tag with a CData Section
*/
$tag = array(
'qname' => 'foo',
'attributes' => array('key' => 'value', 'argh' => 'tütü'),
'content' =>
'Also XHTML-tags can be created '
. 'and HTML entities can be replaced Ä ä Ü ö <>.'
);
print 'creating a tag with HTML entities:<br>';
print htmlentities(XML_Util::createTagFromArray($tag, XML_UTIL_ENTITIES_HTML));
print "\n<br><br>\n";
/**
* creating an XML tag with createTag
*/
print 'creating a tag with createTag:<br>';
print htmlentities(XML_Util::createTag('myNs:myTag',
array('foo' => 'bar'),
'This is inside the tag',
'http://www.w3c.org/myNs#'));
print "\n<br><br>\n";
/**
* trying to create an XML tag with an array as content
*/
$tag = array(
'qname' => 'bar',
'content' => array('foo' => 'bar')
);
print 'trying to create an XML tag with an array as content:<br>';
print '<pre>';
print_r(XML_Util::createTagFromArray($tag));
print '</pre>';
print "\n<br><br>\n";
/**
* trying to create an XML tag without a name
*/
$tag = array(
'attributes' => array('foo' => 'bar'),
);
print 'trying to create an XML tag without a name:<br>';
print '<pre>';
print_r(XML_Util::createTagFromArray($tag));
print '</pre>';
print "\n<br><br>\n";
?>

View File

@ -0,0 +1,145 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Examples (file #2)
*
* several examples for the methods of XML_Util
*
* PHP versions 4 and 5
*
* LICENSE:
*
* Copyright (c) 2003-2008 Stephan Schmidt <schst@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
* @package XML_Util
* @subpackage Examples
* @author Stephan Schmidt <schst@php.net>
* @copyright 2003-2008 Stephan Schmidt <schst@php.net>
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id$
* @link http://pear.php.net/package/XML_Util
*/
/**
* set error level
*/
error_reporting(E_ALL);
require_once 'XML/Util.php';
/**
* creating a start element
*/
print 'creating a start element:<br>';
print htmlentities(XML_Util::createStartElement('myNs:myTag',
array('foo' => 'bar'), 'http://www.w3c.org/myNs#'));
print "\n<br><br>\n";
/**
* creating a start element
*/
print 'creating a start element:<br>';
print htmlentities(XML_Util::createStartElement('myTag',
array(), 'http://www.w3c.org/myNs#'));
print "\n<br><br>\n";
/**
* creating a start element
*/
print 'creating a start element:<br>';
print '<pre>';
print htmlentities(XML_Util::createStartElement('myTag',
array('foo' => 'bar', 'argh' => 'tomato'),
'http://www.w3c.org/myNs#', true));
print '</pre>';
print "\n<br><br>\n";
/**
* creating an end element
*/
print 'creating an end element:<br>';
print htmlentities(XML_Util::createEndElement('myNs:myTag'));
print "\n<br><br>\n";
/**
* creating a CData section
*/
print 'creating a CData section:<br>';
print htmlentities(XML_Util::createCDataSection('I am content.'));
print "\n<br><br>\n";
/**
* creating a comment
*/
print 'creating a comment:<br>';
print htmlentities(XML_Util::createComment('I am a comment.'));
print "\n<br><br>\n";
/**
* creating an XML tag with multiline mode
*/
$tag = array(
'qname' => 'foo:bar',
'namespaceUri' => 'http://foo.com',
'attributes' => array('key' => 'value', 'argh' => 'fruit&vegetable'),
'content' => 'I\'m inside the tag & contain dangerous chars'
);
print 'creating a tag with qualified name and namespaceUri:<br>';
print '<pre>';
print htmlentities(XML_Util::createTagFromArray($tag,
XML_UTIL_REPLACE_ENTITIES, true));
print '</pre>';
print "\n<br><br>\n";
/**
* create an attribute string without replacing the entities
*/
$atts = array('series' => 'Starsky &amp; Hutch', 'channel' => 'ABC');
print 'creating a attribute string, '
. 'entities in values already had been replaced:<br>';
print htmlentities(XML_Util::attributesToString($atts,
true, false, false, false, XML_UTIL_ENTITIES_NONE));
print "\n<br><br>\n";
/**
* using the array-syntax for attributesToString()
*/
$atts = array('series' => 'Starsky &amp; Hutch', 'channel' => 'ABC');
print 'using the array-syntax for attributesToString()<br>';
print htmlentities(XML_Util::attributesToString($atts,
array('entities' => XML_UTIL_ENTITIES_NONE)));
print "\n<br><br>\n";
?>

View File

@ -0,0 +1,63 @@
--TEST--
Console_Getopt
--FILE--
<?php
require_once 'Console/Getopt.php';
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s\n\n");
function test($argstr, $optstr) {
$argv = preg_split('/[[:space:]]+/', $argstr);
if (PEAR::isError($options = Console_Getopt::getopt($argv, $optstr))) {
return;
}
$opts = $options[0];
$non_opts = $options[1];
$i = 0;
print "options: ";
foreach ($opts as $o => $d) {
if ($i++ > 0) {
print ", ";
}
print $d[0] . '=' . $d[1];
}
print "\n";
print "params: " . implode(", ", $non_opts) . "\n";
print "\n";
}
test("-abc", "abc");
test("-abc foo", "abc");
test("-abc foo", "abc:");
test("-abc foo bar gazonk", "abc");
test("-abc foo bar gazonk", "abc:");
test("-a -b -c", "abc");
test("-a -b -c", "abc:");
test("-abc", "ab:c");
test("-abc foo -bar gazonk", "abc");
?>
--EXPECT--
options: a=, b=, c=
params:
options: a=, b=, c=
params: foo
options: a=, b=, c=foo
params:
options: a=, b=, c=
params: foo, bar, gazonk
options: a=, b=, c=foo
params: bar, gazonk
options: a=, b=, c=
params:
Console_Getopt: option requires an argument --c
options: a=, b=c
params:
options: a=, b=, c=
params: foo, -bar, gazonk

View File

@ -0,0 +1,22 @@
--TEST--
Console_Getopt [bug 10557]
--SKIPIF--
--FILE--
<?php
$_SERVER['argv'] =
$argv = array('hi', '-fjjohnston@mail.com', '--to', '--mailpack', '--debug');
require_once 'Console/Getopt.php';
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
array('from=','to=','mailpack=','direction=','verbose','debug'));
if(PEAR::isError($ret))
{
echo $ret->getMessage()."\n";
echo 'FATAL';
exit;
}
print_r($ret);
?>
--EXPECT--
Console_Getopt: option requires an argument --to
FATAL

View File

@ -0,0 +1,44 @@
--TEST--
Console_Getopt [bug 11068]
--SKIPIF--
--FILE--
<?php
$_SERVER['argv'] =
$argv = array('hi', '-fjjohnston@mail.com', '--to', 'hi', '-');
require_once 'Console/Getopt.php';
$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
array('from=','to=','mailpack=','direction=','verbose','debug'));
if(PEAR::isError($ret))
{
echo $ret->getMessage()."\n";
echo 'FATAL';
exit;
}
print_r($ret);
?>
--EXPECT--
Array
(
[0] => Array
(
[0] => Array
(
[0] => f
[1] => jjohnston@mail.com
)
[1] => Array
(
[0] => --to
[1] => hi
)
)
[1] => Array
(
[0] => -
)
)

View File

@ -0,0 +1,75 @@
--TEST--
Console_Getopt [bug 13140]
--SKIPIF--
--FILE--
<?php
$_SERVER['argv'] = $argv =
array('--bob', '--foo' , '-bar', '--test', '-rq', 'thisshouldbehere');
require_once 'Console/Getopt.php';
$cg = new Console_GetOpt();
print_r($cg->getopt2($cg->readPHPArgv(), 't', array('test'), true));
print_r($cg->getopt2($cg->readPHPArgv(), 'bar', array('foo'), true));
?>
--EXPECT--
Array
(
[0] => Array
(
[0] => Array
(
[0] => --test
[1] =>
)
)
[1] => Array
(
[0] => thisshouldbehere
)
)
Array
(
[0] => Array
(
[0] => Array
(
[0] => --foo
[1] =>
)
[1] => Array
(
[0] => b
[1] =>
)
[2] => Array
(
[0] => a
[1] =>
)
[3] => Array
(
[0] => r
[1] =>
)
[4] => Array
(
[0] => r
[1] =>
)
)
[1] => Array
(
[0] => thisshouldbehere
)
)

View File

@ -0,0 +1,49 @@
<?php
require_once dirname(__FILE__) . '/helper.inc';
require_once 'Structures/Graph/Manipulator/AcyclicTest.php';
class AcyclicTestTest extends PHPUnit_Framework_TestCase
{
public function testIsAcyclicFalse()
{
$graph = new Structures_Graph();
$node1 = new Structures_Graph_Node();
$graph->addNode($node1);
$node2 = new Structures_Graph_Node();
$graph->addNode($node2);
$node1->connectTo($node2);
$node3 = new Structures_Graph_Node();
$graph->addNode($node3);
$node2->connectTo($node3);
$node3->connectTo($node1);
$this->assertFalse(
Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph),
'Graph is cyclic'
);
}
public function testIsAcyclicTrue()
{
$graph = new Structures_Graph();
$node1 = new Structures_Graph_Node();
$graph->addNode($node1);
$node2 = new Structures_Graph_Node();
$graph->addNode($node2);
$node1->connectTo($node2);
$node3 = new Structures_Graph_Node();
$graph->addNode($node3);
$node2->connectTo($node3);
$this->assertTrue(
Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph),
'Graph is acyclic'
);
}
}
?>

View File

@ -0,0 +1,20 @@
<?php
require_once dirname(__FILE__) . '/helper.inc';
class Structures_Graph_AllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('Structures_Graph Tests');
$dir = new GlobIterator(dirname(__FILE__) . '/*Test.php');
$suite->addTestFiles($dir);
return $suite;
}
}

View File

@ -0,0 +1,170 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +-----------------------------------------------------------------------------+
// | Copyright (c) 2003 Sérgio Gonçalves Carvalho |
// +-----------------------------------------------------------------------------+
// | This file is part of Structures_Graph. |
// | |
// | Structures_Graph is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or |
// | (at your option) any later version. |
// | |
// | Structures_Graph is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with Structures_Graph; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
// | 02111-1307 USA |
// +-----------------------------------------------------------------------------+
// | Author: Sérgio Carvalho <sergio.carvalho@portugalmail.com> |
// +-----------------------------------------------------------------------------+
//
require_once dirname(__FILE__) . '/helper.inc';
/**
* @access private
*/
class BasicGraph extends PHPUnit_Framework_TestCase
{
var $_graph = null;
function test_create_graph() {
$this->_graph = new Structures_Graph();
$this->assertTrue(is_a($this->_graph, 'Structures_Graph'));
}
function test_add_node() {
$this->_graph = new Structures_Graph();
$data = 1;
$node = new Structures_Graph_Node($data);
$this->_graph->addNode($node);
$node = new Structures_Graph_Node($data);
$this->_graph->addNode($node);
$node = new Structures_Graph_Node($data);
$this->_graph->addNode($node);
}
function test_connect_node() {
$this->_graph = new Structures_Graph();
$data = 1;
$node1 = new Structures_Graph_Node($data);
$node2 = new Structures_Graph_Node($data);
$this->_graph->addNode($node1);
$this->_graph->addNode($node2);
$node1->connectTo($node2);
$node =& $this->_graph->getNodes();
$node =& $node[0];
$node = $node->getNeighbours();
$node =& $node[0];
/*
ZE1 == and === operators fail on $node,$node2 because of the recursion introduced
by the _graph field in the Node object. So, we'll use the stupid method for reference
testing
*/
$node = true;
$this->assertTrue($node2);
$node = false;
$this->assertFalse($node2);
}
function test_data_references() {
$this->_graph = new Structures_Graph();
$data = 1;
$node = new Structures_Graph_Node();
$node->setData($data);
$this->_graph->addNode($node);
$data = 2;
$dataInNode =& $this->_graph->getNodes();
$dataInNode =& $dataInNode[0];
$dataInNode =& $dataInNode->getData();
$this->assertEquals($data, $dataInNode);
}
function test_metadata_references() {
$this->_graph = new Structures_Graph();
$data = 1;
$node = new Structures_Graph_Node();
$node->setMetadata('5', $data);
$data = 2;
$dataInNode =& $node->getMetadata('5');
$this->assertEquals($data, $dataInNode);
}
function test_metadata_key_exists() {
$this->_graph = new Structures_Graph();
$data = 1;
$node = new Structures_Graph_Node();
$node->setMetadata('5', $data);
$this->assertTrue($node->metadataKeyExists('5'));
$this->assertFalse($node->metadataKeyExists('1'));
}
function test_directed_degree() {
$this->_graph = new Structures_Graph(true);
$node = array();
$node[] = new Structures_Graph_Node();
$node[] = new Structures_Graph_Node();
$node[] = new Structures_Graph_Node();
$this->_graph->addNode($node[0]);
$this->_graph->addNode($node[1]);
$this->_graph->addNode($node[2]);
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 0 arcs');
$this->assertEquals(0, $node[1]->inDegree(), 'inDegree test failed for node 1 with 0 arcs');
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 0 arcs');
$this->assertEquals(0, $node[0]->outDegree(), 'outDegree test failed for node 0 with 0 arcs');
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 0 arcs');
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 0 arcs');
$node[0]->connectTo($node[1]);
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 1 arc');
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 1 arc');
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 1 arc');
$this->assertEquals(1, $node[0]->outDegree(), 'outDegree test failed for node 0 with 1 arc');
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 1 arc');
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 1 arc');
$node[0]->connectTo($node[2]);
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 2 arcs');
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 2 arcs');
$this->assertEquals(1, $node[2]->inDegree(), 'inDegree test failed for node 2 with 2 arcs');
$this->assertEquals(2, $node[0]->outDegree(), 'outDegree test failed for node 0 with 2 arcs');
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 2 arcs');
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 2 arcs');
}
function test_undirected_degree() {
$this->_graph = new Structures_Graph(false);
$node = array();
$node[] = new Structures_Graph_Node();
$node[] = new Structures_Graph_Node();
$node[] = new Structures_Graph_Node();
$this->_graph->addNode($node[0]);
$this->_graph->addNode($node[1]);
$this->_graph->addNode($node[2]);
$this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 0 arcs');
$this->assertEquals(0, $node[1]->inDegree(), 'inDegree test failed for node 1 with 0 arcs');
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 0 arcs');
$this->assertEquals(0, $node[0]->outDegree(), 'outDegree test failed for node 0 with 0 arcs');
$this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 0 arcs');
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 0 arcs');
$node[0]->connectTo($node[1]);
$this->assertEquals(1, $node[0]->inDegree(), 'inDegree test failed for node 0 with 1 arc');
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 1 arc');
$this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 1 arc');
$this->assertEquals(1, $node[0]->outDegree(), 'outDegree test failed for node 0 with 1 arc');
$this->assertEquals(1, $node[1]->outDegree(), 'outDegree test failed for node 1 with 1 arc');
$this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 1 arc');
$node[0]->connectTo($node[2]);
$this->assertEquals(2, $node[0]->inDegree(), 'inDegree test failed for node 0 with 2 arcs');
$this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 2 arcs');
$this->assertEquals(1, $node[2]->inDegree(), 'inDegree test failed for node 2 with 2 arcs');
$this->assertEquals(2, $node[0]->outDegree(), 'outDegree test failed for node 0 with 2 arcs');
$this->assertEquals(1, $node[1]->outDegree(), 'outDegree test failed for node 1 with 2 arcs');
$this->assertEquals(1, $node[2]->outDegree(), 'outDegree test failed for node 2 with 2 arcs');
}
}
?>

View File

@ -0,0 +1,59 @@
<?php
require_once dirname(__FILE__) . '/helper.inc';
require_once 'Structures/Graph/Manipulator/TopologicalSorter.php';
class TopologicalSorterTest extends PHPUnit_Framework_TestCase
{
public function testSort()
{
$graph = new Structures_Graph();
$name1 = 'node1';
$node1 = new Structures_Graph_Node();
$node1->setData($name1);
$graph->addNode($node1);
$name11 = 'node11';
$node11 = new Structures_Graph_Node();
$node11->setData($name11);
$graph->addNode($node11);
$node1->connectTo($node11);
$name12 = 'node12';
$node12 = new Structures_Graph_Node();
$node12->setData($name12);
$graph->addNode($node12);
$node1->connectTo($node12);
$name121 = 'node121';
$node121 = new Structures_Graph_Node();
$node121->setData($name121);
$graph->addNode($node121);
$node12->connectTo($node121);
$name2 = 'node2';
$node2 = new Structures_Graph_Node();
$node2->setData($name2);
$graph->addNode($node2);
$name21 = 'node21';
$node21 = new Structures_Graph_Node();
$node21->setData($name21);
$graph->addNode($node21);
$node2->connectTo($node21);
$nodes = Structures_Graph_Manipulator_TopologicalSorter::sort($graph);
$this->assertCount(2, $nodes[0]);
$this->assertEquals('node1', $nodes[0][0]->getData());
$this->assertEquals('node2', $nodes[0][1]->getData());
$this->assertCount(3, $nodes[1]);
$this->assertEquals('node11', $nodes[1][0]->getData());
$this->assertEquals('node12', $nodes[1][1]->getData());
$this->assertEquals('node21', $nodes[1][2]->getData());
$this->assertCount(1, $nodes[2]);
$this->assertEquals('node121', $nodes[2][0]->getData());
}
}
?>

View File

@ -0,0 +1,10 @@
<?php
if ('/Users/sanek/.phpbrew/php/php-7.4.32/lib/php/pear' == '@'.'php_dir'.'@') {
// This package hasn't been installed.
// Adjust path to ensure includes find files in working directory.
set_include_path(dirname(dirname(__FILE__))
. PATH_SEPARATOR . dirname(__FILE__)
. PATH_SEPARATOR . get_include_path());
}
require_once 'Structures/Graph.php';

View File

@ -0,0 +1,17 @@
<?php
/*
* Allow for PHPUnit 4.* while XML_Util is still usable on PHP 5.4
*/
if (!class_exists('PHPUnit_Framework_TestCase')) {
class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase {}
}
abstract class AbstractUnitTests extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
// ensure the class is defined, and thus its constants are declared
new XML_Util();
}
}

View File

@ -0,0 +1,12 @@
<?php
class ApiVersionTests extends AbstractUnitTests
{
/**
* @covers XML_Util::apiVersion()
*/
public function testApiVersion()
{
$this->assertEquals('1.4', XML_Util::apiVersion());
}
}

View File

@ -0,0 +1,217 @@
<?php
class AttributesToStringTests extends AbstractUnitTests
{
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringBasicUsage()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\" foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitSortTrue()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\" foo=\"bar\"";
$sort = true;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitSortFalse()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " foo=\"bar\" boo=\"baz\"";
$sort = false;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithMultilineFalse()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\" foo=\"bar\"";
$sort = true;
$multiline = false;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithMultilineTrue()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected =
<<< EOF
boo="baz"
foo="bar"
EOF;
$sort = true;
$multiline = true;
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitIndent()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\"\n foo=\"bar\"";
$sort = true;
$multiline = true;
$indent = ' '; // 8 spaces
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $indent));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithExplicitLinebreak()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$expected = " boo=\"baz\"\n^foo=\"bar\"";
$sort = true;
$multiline = true;
$linebreak = '^'; // some dummy character
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithOptionsThatIncludesSort()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$options = array(
'multiline' => true,
'indent' => '----',
'linebreak' => "^",
'entities' => XML_UTIL_ENTITIES_XML,
'sort' => true,
);
$expected = " boo=\"baz\"\n----foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithOptionsThatExcludesSort()
{
$original = array('foo' => 'bar','boo' => 'baz',);
$options = array(
'multiline' => true,
'indent' => '----',
'linebreak' => "^",
'entities' => XML_UTIL_ENTITIES_XML,
);
$expected = " boo=\"baz\"\n----foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesNone()
{
$original = array("foo" => "b@&r", "boo" => "b><z");
$expected = " boo=\"b><z\" foo=\"b@&r\"";
$sort = true;
$multiline = false;
$linebreak = ' ';
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_NONE));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesXml()
{
$original = array("foo" => "b@&r", "boo" => "b><z");
$expected = " boo=\"b&gt;&lt;z\" foo=\"b@&amp;r\"";
$sort = true;
$multiline = false;
$linebreak = ' ';
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_XML));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesXmlRequired()
{
$original = array("foo" => "b@&r", "boo" => "b><z");
$expected = " boo=\"b>&lt;z\" foo=\"b@&amp;r\"";
$sort = true;
$multiline = false;
$linebreak = ' ';
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_XML_REQUIRED));
}
/**
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithEntitiesHtml()
{
$original = array("foo" => "b@&r", "boo" => "b><z");
$expected = " boo=\"b&gt;&lt;z\" foo=\"b@&amp;r\"";
$sort = true;
$multiline = false;
$linebreak = ' ';
$this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_HTML));
}
/**
* Tag attributes should not be treated as CDATA,
* so the operation will instead quietly use XML_UTIL_ENTITIES_XML.
*
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithCDataSectionForSingleAttribute()
{
$original = array('foo' => 'bar'); // need exactly one attribute here
$options = array(
'sort' => true, // doesn't matter for this testcase
'multiline' => false, // doesn't matter for this testcase
'indent' => null, // doesn't matter for this testcase
'linebreak' => null, // doesn't matter for this testcase
'entities' => XML_UTIL_CDATA_SECTION, // DOES matter for this testcase
);
$expected = " foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
/**
* Tag attributes should not be treated as CDATA,
* so the operation will instead quietly use XML_UTIL_ENTITIES_XML.
*
* @covers XML_Util::attributesToString()
*/
public function testAttributesToStringWithCDataSectionForMultipleAttributesAndMultilineFalse()
{
$original = array('foo' => 'bar', 'boo' => 'baz'); // need more than one attribute here
$options = array(
'sort' => true, // doesn't matter for this testcase
'multiline' => false, // DOES matter for this testcase, must be false
'indent' => null, // doesn't matter for this testcase
'linebreak' => null, // doesn't matter for this testcase
'entities' => XML_UTIL_CDATA_SECTION, // DOES matter for this testcase
);
$expected = " boo=\"baz\" foo=\"bar\"";
$this->assertEquals($expected, XML_Util::attributesToString($original, $options));
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* Bug #18343 "Entities in file names decoded during packaging"
*
* No matter what flags are given to createTagFromArray(),
* an attribute must *always* be at least ENTITIES_XML encoded.
*
* @link https://pear.php.net/bugs/bug.php?id=18343
*/
class Bug18343Tests extends AbstractUnitTests
{
private $tagArray = array(
"qname" => "install",
"attributes" => array(
"as" => "Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek",
"name" => "test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek",
)
);
public function getFlagsToTest()
{
new XML_Util(); // for constants to be declared
return array(
array('no flag', null),
array('false', false),
array('ENTITIES_NONE', XML_UTIL_ENTITIES_NONE),
array('ENTITIES_XML', XML_UTIL_ENTITIES_XML),
array('ENTITIES_XML_REQUIRED', XML_UTIL_ENTITIES_XML_REQUIRED),
array('ENTITIES_HTML', XML_UTIL_ENTITIES_HTML),
array('REPLACE_ENTITIES', XML_UTIL_REPLACE_ENTITIES),
);
}
/**
* @dataProvider getFlagsToTest()
*/
public function testCreateTagFromArrayForBug18343($key, $flag)
{
// all flags for the candidate input should return the same result
$expected =
<<< EOF
<install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&amp;s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&amp;s=Newsweek" />
EOF;
$this->assertEquals($expected, XML_Util::createTagFromArray($this->tagArray, $flag), "Failed bugcheck for $key.");
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* Bug #21177 "XML_Util::collapseEmptyTags() can return NULL"
*
* PREG returns NULL when it encounters an error.
* In this case, it was encountering PREG_BACKTRACK_LIMIT_ERROR.
*
* @link https://pear.php.net/bugs/bug.php?id=21177
*/
class Bug21177Tests extends AbstractUnitTests
{
public function getTestCandidate()
{
$expected = '<id_mytest_yesorno />';
return array(
array('<idmytestyesorno></idmytestyesorno>', '<idmytestyesorno />'),
array('<idmytestyesorno />', '<idmytestyesorno />'),
array('<id_mytest_yesorno></id_mytest_yesorno>', '<id_mytest_yesorno />'),
array('<id_mytest_yesorno />', '<id_mytest_yesorno />'),
);
}
/**
* @dataProvider getTestCandidate()
*/
public function testCollapseEmptyTagsForBug21177($original, $expected)
{
$this->assertEquals($expected, XML_Util::collapseEmptyTags($original, XML_UTIL_COLLAPSE_ALL), "Failed bugcheck.");
}
}

View File

@ -0,0 +1,18 @@
<?php
/**
* Bug #21184
*
* PREG returns NULL when it encounters an error.
* In this case, it was encountering PREG_BACKTRACK_LIMIT_ERROR.
*
* @link https://pear.php.net/bugs/bug.php?id=21177
*/
class Bug21184 extends AbstractUnitTests
{
public function testBug21184()
{
$xml = '<XML_Serializer_Tag>one</XML_Serializer_Tag>';
$this->assertEquals($xml, XML_Util::collapseEmptyTags($xml, XML_UTIL_COLLAPSE_ALL));
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* Bug #4950 "Incorrect CDATA serializing"
*
* Content that looks like CDATA end characters and tags
* should still be recognized solely as content text.
*
* @link https://pear.php.net/bugs/bug.php?id=4950
*/
class Bug4950Tests extends AbstractUnitTests
{
public function testCreateTagForBug4950()
{
$qname = "test";
$attributes = array();
$content = "Content ]]></test> here!";
$namespaceUrl = null;
$expected = "<test><![CDATA[Content ]]]]><![CDATA[></test> here!]]></test>";
$result = XML_Util::createTag($qname, $attributes, $content, $namespaceUrl, XML_UTIL_CDATA_SECTION);
$this->assertEquals($expected, $result, "Failed bugcheck.");
}
}

View File

@ -0,0 +1,20 @@
<?php
/**
* Bug #5392 "encoding of ISO-8859-1 is the only supported encoding"
*
* Original characters of the given encoding that are "replaced"
* should then "reverse" back to perfectly match the original.
*
* @link https://pear.php.net/bugs/bug.php?id=5392
*/
class Bug5392Tests extends AbstractUnitTests
{
public function testReplaceEntitiesForBug5392()
{
$original = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
$replacedResult = XML_Util::replaceEntities($original, XML_UTIL_ENTITIES_HTML, "UTF-8");
$reversedResult = XML_Util::reverseEntities($replacedResult, XML_UTIL_ENTITIES_HTML, "UTF-8");
$this->assertEquals($original, $reversedResult, "Failed bugcheck.");
}
}

View File

@ -0,0 +1,122 @@
<?php
class CollapseEmptyTagsTests extends AbstractUnitTests
{
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsBasicUsage()
{
$emptyTag = "<foo></foo>";
$expected = "<foo />";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsBasicUsageAlongsideNonemptyTag()
{
$emptyTag = "<foo></foo>";
$otherTag = "<bar>baz</bar>";
$expected = "<foo /><bar>baz</bar>";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseAll()
{
$emptyTag = "<foo></foo>";
$expected = "<foo />";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseAll()
{
$emptyTag = "<foo></foo>";
$otherTag = "<bar>baz</bar>";
$expected = "<foo /><bar>baz</bar>";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagAlongsideEmptyTagWithCollapseAll()
{
$emptyTag = "<foo></foo>";
$otherTag = "<bar>baz</bar>";
$expected = "<foo /><bar>baz</bar><foo />";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyPrefixedTagAlongsideNonemptyTagAlongsideEmptyPrefixedTagWithCollapseAll()
{
$emptyTag = "<foo:foo2></foo:foo2>";
$otherTag = "<bar>baz</bar>";
$expected = "<foo:foo2 /><bar>baz</bar><foo:foo2 />";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyNsPrefixedTagAlongsideNonemptyTagAlongsideEmptyNsPrefixedTagWithCollapseAll()
{
$emptyTag = "<http://foo.com:foo2></http://foo.com:foo2>";
$otherTag = "<bar>baz</bar>";
$expected = "<http://foo.com:foo2 /><bar>baz</bar><http://foo.com:foo2 />";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseXhtml()
{
$emptyTag = "<foo></foo>";
$expected = "<foo></foo>";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_XHTML_ONLY));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseXhtml()
{
$emptyTag = "<foo></foo>";
$otherTag = "<bar>baz</bar>";
$xhtmlTag = "<br></br>";
$expected = "<foo></foo><br /><bar>baz</bar>";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL_COLLAPSE_XHTML_ONLY));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseNone()
{
$emptyTag = "<foo></foo>";
$expected = "<foo></foo>";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_NONE));
}
/**
* @covers XML_Util::collapseEmptyTags()
*/
public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseNone()
{
$emptyTag = "<foo></foo>";
$otherTag = "<bar>baz</bar>";
$expected = "<foo></foo><bar>baz</bar>";
$this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_NONE));
}
}

View File

@ -0,0 +1,14 @@
<?php
class CreateCDataSectionTests extends AbstractUnitTests
{
/**
* @covers XML_Util::createCDataSection()
*/
public function testCreateCDataSectionBasicUsage()
{
$original = "I am content.";
$expected ="<![CDATA[I am content.]]>";
$this->assertEquals($expected, XML_Util::createCDataSection($original));
}
}

View File

@ -0,0 +1,14 @@
<?php
class CreateCommentTests extends AbstractUnitTests
{
/**
* @covers XML_Util::createComment()
*/
public function testCreateCommentBasicUsage()
{
$original = "I am comment.";
$expected = "<!-- I am comment. -->";
$this->assertEquals($expected, XML_Util::createComment($original));
}
}

View File

@ -0,0 +1,24 @@
<?php
class CreateEndElementTests extends AbstractUnitTests
{
/**
* @covers XML_Util::createEndElement()
*/
public function testCreateEndElementBasicUsage()
{
$original = "myTag";
$expected = "</myTag>";
$this->assertEquals($expected, XML_Util::createEndElement($original));
}
/**
* @covers XML_Util::createEndElement()
*/
public function testCreateEndElementWithNamespacedTag()
{
$original = "myNs:myTag";
$expected = "</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createEndElement($original));
}
}

View File

@ -0,0 +1,142 @@
<?php
class CreateStartElementTests extends AbstractUnitTests
{
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagOnly()
{
$original = "myNs:myTag";
$expected = "<myNs:myTag>";
$this->assertEquals($expected, XML_Util::createStartElement($original));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributes()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$expected = "<myNs:myTag foo=\"bar\">";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithEmptyAttributes()
{
$originalTag = "myNs:myTag";
$originalAttributes = "";
$expected = "<myNs:myTag>";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespace()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithEmptyAttributesAndNonUriNamespace()
{
$originalTag = "myTag";
$originalAttributes = "";
$originalNamespace = "foo";
$expected = "<myTag xmlns=\"foo\">";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultiline()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected =
<<< EOF
<myNs:myTag foo="bar"
xmlns:myNs="http://www.w3c.org/myNs#">
EOF;
$multiline = true;
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndent()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected =
<<< EOF
<myNs:myTag foo="bar"
xmlns:myNs="http://www.w3c.org/myNs#">
EOF;
$multiline = true;
$indent = " ";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreak()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">";
$multiline = true;
$indent = " ";
$linebreak = "^";
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreakAndSortAttributesIsTrue()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag boo=\"baz\"^ foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = true;
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createStartElement()
*/
public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreakAndSortAttributesIsFalse()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag foo=\"bar\"^ boo=\"baz\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = false;
$this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak, $sortAttributes));
}
}

View File

@ -0,0 +1,350 @@
<?php
class CreateTagFromArrayTests extends AbstractUnitTests
{
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQname()
{
$original = array(
"qname" => "foo:bar",
);
$expected = "<foo:bar />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespace()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
);
$expected = "<foo:bar xmlns:foo=\"http://foo.com\" />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributes()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
);
$expected = "<foo:bar argh=\"fruit&amp;vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\" />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContent()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "<foo:bar argh=\"fruit&amp;vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndAttributesAndContent()
{
$original = array(
"qname" => "foo:bar",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "<foo:bar argh=\"fruit&amp;vegetable\" key=\"value\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndContent()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"content" => "I'm inside the tag",
);
$expected = "<foo:bar xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithEntitiesNone()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "<foo:bar argh=\"fruit&amp;vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_ENTITIES_NONE));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntities()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expected = "<foo:bar argh=\"fruit&amp;vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineFalse()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = false;
$expected = "<foo:bar argh=\"fruit&amp;vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrue()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$expected =
<<< EOF
<foo:bar argh="fruit&amp;vegetable"
key="value"
xmlns:foo="http://foo.com">I&apos;m inside the tag</foo:bar>
EOF;
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndent()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$expected =
<<< EOF
<foo:bar argh="fruit&amp;vegetable"
key="value"
xmlns:foo="http://foo.com">I&apos;m inside the tag</foo:bar>
EOF;
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreak()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$linebreak = "^";
$expected = "<foo:bar argh=\"fruit&amp;vegetable\"^ key=\"value\"^ xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesTrue()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = true;
$expected = "<foo:bar argh=\"fruit&amp;vegetable\"^ key=\"value\"^ xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesFalse()
{
$original = array(
"qname" => "foo:bar",
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = false;
$expected = "<foo:bar key=\"value\"^ argh=\"fruit&amp;vegetable\"^ xmlns:foo=\"http://foo.com\">I&apos;m inside the tag</foo:bar>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithInvalidArray()
{
$badArray = array(
"foo" => "bar",
);
$expectedError = "You must either supply a qualified name (qname) or local tag name (localPart).";
$this->assertEquals($expectedError, XML_Util::createTagFromArray($badArray));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithNamespaceAndAttributesAndContentButWithoutQname()
{
$original = array(
"namespaceUri" => "http://foo.com",
"attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ),
"content" => "I'm inside the tag",
);
$expectedError = "You must either supply a qualified name (qname) or local tag name (localPart).";
$this->assertEquals($expectedError, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithNonScalarContent()
{
$badArray = array(
'content' => array('foo', 'bar'),
);
$expectedError = "Supplied non-scalar value as tag content";
$this->assertEquals($expectedError, XML_Util::createTagFromArray($badArray));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithArrayOfNamespaces()
{
$original = array(
'qname' => 'foo:bar',
'namespaces' => array('ns1' => 'uri1', 'ns2' => 'uri2'),
);
$expected = "<foo:bar xmlns:ns1=\"uri1\" xmlns:ns2=\"uri2\" />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameDerivedFromNamespaceUriAndLocalPart()
{
$original = array(
'namespaceUri' => 'http://bar.org',
'localPart' => 'foo'
);
$expected = "<foo xmlns=\"http://bar.org\" />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameDerivedFromNamespaceAndLocalPart()
{
$original = array(
'namespace' => 'http://foo.org',
'localPart' => 'bar'
);
$expected = "<http://foo.org:bar />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithQnameDerivedFromLocalPart()
{
$original = array(
'namespace' => '',
'localPart' => 'bar'
);
$expected = "<bar />";
$this->assertEquals($expected, XML_Util::createTagFromArray($original));
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayWithImplicitlyEmptyContentAndCollapseNoneDoesNotCollapseTag()
{
$original = array('qname' => 'tag1');
$expected = "<tag1></tag1>";
$actual = XML_Util::createTagFromArray(
$original,
XML_UTIL_REPLACE_ENTITIES, // default $replaceEntities
false, // default $multiline
'_auto', // default $indent
"\n", // default $linebreak
true, // default $sortAttributes
XML_UTIL_COLLAPSE_NONE
);
$this->assertEquals($expected, $actual);
}
/**
* @covers XML_Util::createTagFromArray()
*/
public function testCreateTagFromArrayForCdataWithExplicitlyEmptyContentDoesNotCollapseTag()
{
$original = array('qname' => 'tag1', 'content' => '');
$expected = "<tag1><![CDATA[]]></tag1>";
$this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_CDATA_SECTION));
}
}

View File

@ -0,0 +1,169 @@
<?php
class CreateTagTests extends AbstractUnitTests
{
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributes()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$expected = "<myNs:myTag foo=\"bar\" />";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContent()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag";
$expected = "<myNs:myTag foo=\"bar\">This is inside the tag</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespace()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag";
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithCDataSection()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\"><![CDATA[This is inside the tag and has < & @ > in it]]></myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_CDATA_SECTION));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntities()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineFalse()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = false;
$expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrue()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$expected =
<<< EOF
<myNs:myTag foo="bar"
xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>
EOF;
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndent()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$expected =
<<< EOF
<myNs:myTag foo="bar"
xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>
EOF;
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreak()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$linebreak = "^";
$expected = "<myNs:myTag foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesTrue()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = true;
$expected = "<myNs:myTag boo=\"baz\"^ foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
/**
* @covers XML_Util::createTag()
*/
public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesFalse()
{
$originalTag = "myNs:myTag";
$originalAttributes = array("foo" => "bar", "boo" => "baz");
$originalContent = "This is inside the tag and has < & @ > in it";
$originalNamespace = "http://www.w3c.org/myNs#";
$multiline = true;
$indent = " ";
$linebreak = "^";
$sortAttributes = false;
$expected = "<myNs:myTag foo=\"bar\"^ boo=\"baz\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has &lt; &amp; @ &gt; in it</myNs:myTag>";
$this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes));
}
}

View File

@ -0,0 +1,54 @@
<?php
class GetDocTypeDeclarationTests extends AbstractUnitTests
{
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRoot()
{
$expected = "<!DOCTYPE rootTag>";
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag"));
}
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRootAndStringUri()
{
$expected = "<!DOCTYPE rootTag SYSTEM \"myDocType.dtd\">";
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd"));
}
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRootAndArrayUri()
{
$uri = array(
'uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
);
$expected = "<!DOCTYPE rootTag PUBLIC \"-//PHP//PEAR/DTD PACKAGE 0.1\" \"http://pear.php.net/dtd/package-1.0\">";
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", $uri));
}
/**
* @covers XML_Util::getDocTypeDeclaration()
*/
public function testGetDocTypeDeclarationUsingRootAndArrayUriAndInternalDtd()
{
$uri = array(
'uri' => 'http://pear.php.net/dtd/package-1.0',
'id' => '-//PHP//PEAR/DTD PACKAGE 0.1'
);
$dtdEntry = '<!ELEMENT additionalInfo (#PCDATA)>';
$expected =
<<< EOF
<!DOCTYPE rootTag PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0" [
<!ELEMENT additionalInfo (#PCDATA)>
]>
EOF;
$this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", $uri, $dtdEntry));
}
}

View File

@ -0,0 +1,38 @@
<?php
class GetXMLDeclarationTests extends AbstractUnitTests
{
/**
* @covers XML_Util::getXMLDeclaration()
*/
public function testGetXMLDeclarationUsingVersion()
{
$version = "1.0";
$expected = "<?xml version=\"1.0\"?>";
$this->assertEquals($expected, XML_Util::getXMLDeclaration($version));
}
/**
* @covers XML_Util::getXMLDeclaration()
*/
public function testGetXMLDeclarationUsingVersionAndEncodingAndStandalone()
{
$version = "1.0";
$encoding = "UTF-8";
$standalone = true;
$expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
$this->assertEquals($expected, XML_Util::getXMLDeclaration($version, $encoding, $standalone));
}
/**
* @covers XML_Util::getXMLDeclaration()
*/
public function testGetXMLDeclarationUsingVersionAndStandalone()
{
$version = "1.0";
$encoding = null;
$standalone = true;
$expected = "<?xml version=\"1.0\" standalone=\"yes\"?>";
$this->assertEquals($expected, XML_Util::getXMLDeclaration($version, $encoding, $standalone));
}
}

View File

@ -0,0 +1,62 @@
<?php
class IsValidNameTests extends AbstractUnitTests
{
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForTagNameThatIsValid()
{
$tagName = "alpha-x_y_z.123";
$result = XML_Util::isValidName($tagName);
$this->assertTrue($result);
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForTagNameWithInvalidCharacter()
{
$tagName = "invalidTag?";
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only contain alphanumeric chars, period, hyphen, colon and underscores";
$this->assertEquals($expectedError, $result->getMessage());
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForTagNameWithInvalidStartingCharacter()
{
$tagName = "1234five";
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only start with letter or underscore";
$this->assertEquals($expectedError, $result->getMessage());
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForInt()
{
$tagName = 1;
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only start with letter or underscore";
$this->assertEquals($expectedError, $result->getMessage());
}
/**
* @covers XML_Util::isValidName()
*/
public function testIsValidNameForEmptyString()
{
$tagName = '';
$result = XML_Util::isValidName($tagName);
$this->assertInstanceOf('PEAR_Error', $result);
$expectedError = "XML names may only start with letter or underscore";
$this->assertEquals($expectedError, $result->getMessage());
}
}

View File

@ -0,0 +1,17 @@
<?php
class RaiseErrorTests extends AbstractUnitTests
{
/**
* @covers XML_Util::raiseError()
*/
public function testRaiseError()
{
$code = 12345;
$message = "I am an error";
$error = XML_Util::raiseError($message, $code);
$this->assertInstanceOf('PEAR_Error', $error);
$this->assertEquals($message, $error->getMessage());
$this->assertEquals($code, $error->getCode());
}
}

View File

@ -0,0 +1,119 @@
<?php
class ReplaceEntitiesTests extends AbstractUnitTests
{
protected function getSimpleData()
{
return 'This string contains < & >.';
}
protected function getUtf8Data()
{
return 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleData()
{
$expected = "This string contains &lt; &amp; &gt;.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData()));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), 'INVALID_OPTION'));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXml()
{
$expected = "This string contains &lt; &amp; &gt;.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains &lt; &amp; &gt;.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForUtf8DataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like &lt;, &gt;, &amp; and &quot; as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXmlRequired()
{
$expected = "This string contains &lt; &amp; >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains &lt; &amp; >.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like &lt;, >, &amp; and &quot; as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesHtml()
{
$expected = "This string contains &lt; &amp; &gt;.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForSimpleDataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains &lt; &amp; &gt;.";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding));
}
/**
* @covers XML_Util::replaceEntities()
*/
public function testReplaceEntitiesForUtf8DataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like &lt;, &gt;, &amp; and &quot; as well as &auml;, &ouml;, &szlig;, &agrave; and &ecirc;";
$this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding));
}
}

View File

@ -0,0 +1,119 @@
<?php
class ReverseEntitiesTests extends AbstractUnitTests
{
protected function getSimpleData()
{
return 'This string contains &lt; &amp; &gt;.';
}
protected function getUtf8Data()
{
return 'This data contains special chars like &lt;, &gt;, &amp; and &quot; as well as &auml;, &ouml;, &szlig;, &agrave; and &ecirc;';
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleData()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData()));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData()
{
$expected = "This string contains &lt; &amp; &gt;.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), 'INVALID_OPTION'));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXml()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML), $encoding);
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForUtf8DataWithEntitiesXmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and \" as well as &auml;, &ouml;, &szlig;, &agrave; and &ecirc;";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML), $encoding);
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequired()
{
$expected = "This string contains < & &gt;.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & &gt;.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, &gt;, & and \" as well as &auml;, &ouml;, &szlig;, &agrave; and &ecirc;";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesHtml()
{
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForSimpleDataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This string contains < & >.";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding));
}
/**
* @covers XML_Util::reverseEntities()
*/
public function testReverseEntitiesForUtf8DataWithEntitiesHtmlAndEncoding()
{
$encoding = "UTF-8";
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding));
}
}

View File

@ -0,0 +1,31 @@
<?php
class SplitQualifiedNameTests extends AbstractUnitTests
{
/**
* @covers XML_Util::splitQualifiedName()
*/
public function testSplitQualifiedNameWithoutNamespace()
{
$original = "xslt:stylesheet";
$expected = array(
'namespace' => 'xslt',
'localPart' => 'stylesheet',
);
$this->assertEquals($expected, XML_Util::splitQualifiedName($original));
}
/**
* @covers XML_Util::splitQualifiedName()
*/
public function testSplitQualifiedNameWithNamespace()
{
$original = "stylesheet";
$namespace = "myNs";
$expected = array(
'namespace' => 'myNs',
'localPart' => 'stylesheet',
);
$this->assertEquals($expected, XML_Util::splitQualifiedName($original, $namespace));
}
}

523
php/man/man1/phar.1 Normal file
View File

@ -0,0 +1,523 @@
.TH PHAR 1 "2021" "The PHP Group" "User Commands"
.SH NAME
phar, phar.phar \- PHAR (PHP archive) command line tool
.SH SYNOPSIS
.B phar
<command> [options] ...
.LP
.SH DESCRIPTION
The \fBPHAR\fP file format provides a way to put entire PHP applications into a single
file called a "phar" (PHP Archive) for easy distribution and installation.
.P
With the \fBphar\fP command you can create, update or extract PHP archives.
.P
Commands:
add compress delete extract help help-list info list meta-del
meta-get meta-set pack sign stub-get stub-set tree version
.SH add command
Add entries to a PHAR package.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B ...
Any number of input files and directories. If -i is in
use then ONLY files and matching the given regular
expression are being packed. If -x is given then files
matching that regular expression are NOT being packed.
.P
Optional arguments:
.TP 15
.PD
.B \-a \fIalias\fP
Provide an \fIalias\fP name for the phar file.
.TP
.PD
.B \-c \fIalgo\fP
Compression algorithm (see
.SM
.B COMPRESSION
)
.TP
.PD
.B \-i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B \-l \fIlevel\fP
Number of preceding subdirectories to strip from file entries
.TP
.PD
.B \-x \fIregex\fP
Regular expression for input files to exclude.
.SH compress command
Compress or uncompress all files or a selected entry.
.P
Required arguments:
.TP 15
.PD
.B \-c \fIalgo\fP
Compression algorithm (see
.SM
.B COMPRESSION
)
.TP
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.SH delete command
Delete entry from a PHAR archive
.P
Required arguments:
.TP 15
.PD
.B \-e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.SH extract command
Extract a PHAR package to a directory.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B -x \fIregex\fP
Regular expression for input files to exclude.
.TP
.PD
.B ...
Directory to extract to (defaults to '.').
.SH help command
This help or help for a selected command.
.P
Optional arguments:
.TP 15
.PD
.B ...
Optional command to retrieve help for.
.SH help-list command
Lists available commands.
.SH info command
Get information about a PHAR package.
.P
By using -k it is possible to return a single value.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH list command
List contents of a PHAR archive.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B -x \fIregex\fP
Regular expression for input files to exclude.
.SH meta-del command
Delete meta information of a PHAR entry or a PHAR package.
.P
If -k is given then the metadata is expected to be an array and the
given index is being deleted.
.P
If something was deleted the return value is 0 otherwise it is 1.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH meta-get command
Get meta information of a PHAR entry or a PHAR package in serialized from. If
no output file is specified for meta data then stdout is being used.
You can also specify a particular index using -k. In that case the
metadata is expected to be an array and the value of the given index
is returned using echo rather than using serialize. If that index does
not exist or no meta data is present then the return value is 1.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH meta-set command
Set meta data of a PHAR entry or a PHAR package using serialized input. If no
input file is specified for meta data then stdin is being used. You can
also specify a particular index using -k. In that case the metadata is
expected to be an array and the value of the given index is being set.
If the metadata is not present or empty a new array will be created.
If the metadata is present and a flat value then the return value is
1. Also using -k the input is been taken directly rather then being
serialized.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B -m \fImeta\fP
Meta data to store with entry (serialized php data).
.P
Optional arguments:
.TP 15
.PD
.B -e \fIentry\fP
Name of \fIentry\fP to work on (must include PHAR internal
directory name if any).
.TP
.PD
.B -k \fIindex\fP
Subscription \fIindex\fP to work on.
.SH pack command
Pack files into a PHAR archive.
.P
When using -s <stub>, then the stub file is being excluded from the
list of input files/dirs.To create an archive that contains PEAR class
PHP_Archive then point -p argument to PHP/Archive.php.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B ...
Any number of input files and directories. If -i is in
use then ONLY files and matching the given regular
expression are being packed. If -x is given then files
matching that regular expression are NOT being packed.
.P
Optional arguments:
.TP 15
.PD
.B \-a \fIalias\fP
Provide an \fIalias\fP name for the phar file.
.TP
.PD
.B \-b \fIbang\fP
Hash-bang line to start the archive (e.g. #!/usr/bin/php).
The hash mark itself '#!' and the newline character are optional.
.TP
.PD
.B \-c \fIalgo\fP
Compression algorithm (see
.SM
.B COMPRESSION
)
.TP
.PD
.B \-h \fIhash\fP
Selects the \fIhash\fP algorithm (see
.SM
.B HASH
)
.TP
.PD
.B \-i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B \-l \fIlevel\fP
Number of preceding subdirectories to strip from file entries
.TP
.PD
.B \-p \fIloader\fP
Location of PHP_Archive class file (pear list-files
PHP_Archive).You can use '0' or '1' to locate it
automatically using the mentioned pear command. When
using '0' the command does not error out when the class
file cannot be located. This switch also adds some code
around the stub so that class PHP_Archive gets
registered as phar:// stream wrapper if necessary. And
finally this switch will add the file phar.inc from
this package and load it to ensure class Phar is
present.
.TP
.PD
.B \-s \fIstub\fP
Select the \fIstub\fP file.
.TP
.PD
.B \-x \fIregex\fP
Regular expression for input files to exclude.
.TP
.PD
.B \-y \fIkey\fP
Private \fIkey\fP for OpenSSL signing.
.SH sign command
Set signature hash algorithm.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.TP
.PD
.B \-h \fIhash\fP
Selects the \fIhash\fP algorithm (see
.SM
.B HASH
)
.P
Optional arguments:
.TP 15
.PD
.B \-y \fIkey\fP
Private \fIkey\fP for OpenSSL signing.
.SH stub-get command
Get the stub of a PHAR file. If no output file is specified as stub then stdout
is being used.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B \-s \fIstub\fP
Select the \fIstub\fP file.
.SH stub-set command
Set the stub of a PHAR file. If no input file is specified as stub then stdin
is being used.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B \-b \fIbang\fP
Hash-bang line to start the archive (e.g. #!/usr/bin/php).
The hash mark itself '#!' and the newline character are optional.
.TP
.PD
.B \-p \fIloader\fP
Location of PHP_Archive class file (pear list-files
PHP_Archive).You can use '0' or '1' to locate it
automatically using the mentioned pear command. When
using '0' the command does not error out when the class
file cannot be located. This switch also adds some code
around the stub so that class PHP_Archive gets
registered as phar:// stream wrapper if necessary. And
finally this switch will add the file phar.inc from
this package and load it to ensure class Phar is
present.
.TP
.PD
.B \-s \fIstub\fP
Select the \fIstub\fP file.
.SH tree command
Get a directory tree for a PHAR archive.
.P
Required arguments:
.TP 15
.PD
.B -f \fIfile\fP
Specifies the phar \fIfile\fP to work on.
.P
Optional arguments:
.TP 15
.PD
.B \-i \fIregex\fP
Specifies a regular expression for input files.
.TP
.PD
.B \-x \fIregex\fP
Regular expression for input files to exclude.
.SH version command
Get information about the PHAR environment and the tool version.
.SH COMPRESSION
Algorithms:
.TP 15
.PD
.B 0
No compression
.TP
.PD
.B none
No compression
.TP
.PD
.B auto
Automatically select compression algorithm
.TP
.PD
.B gz
GZip compression
.TP
.PD
.B gzip
GZip compression
.TP
.PD
.B bz2
BZip2 compression
.TP
.PD
.B bzip2
BZip2 compression
.SH HASH
Algorithms:
.TP 15
.PD
.TP
.PD
.B md5
MD5
.TP
.PD
.B sha1
SHA1
.TP
.PD
.B sha256
SHA256
.TP
.PD
.B sha512
SHA512
.TP
.PD
.B openssl
OpenSSL
.SH SEE ALSO
For a more or less complete description of PHAR look here:
.PD 0
.P
.B http://php.net/phar
.PD 1
.P
.SH BUGS
You can view the list of known bugs or report any new bug you
found at:
.PD 0
.P
.B http://bugs.php.net
.PD 1
.SH AUTHORS
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
.P
Work for the PHP archive was done by Gregory Beaver, Marcus Boerger.
.P
A List of active developers can be found here:
.PD 0
.P
.B http://www.php.net/credits.php
.PD 1
.P
And last but not least PHP was developed with the help of a huge amount of
contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphar\fP, version 7.4.32.
.SH COPYRIGHT
Copyright \(co 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.

1
php/man/man1/phar.phar.1 Normal file
View File

@ -0,0 +1 @@
.so man1/phar.1

1
php/man/man1/php-cgi.1 Normal file
View File

@ -0,0 +1 @@
.so man1/php.1

81
php/man/man1/php-config.1 Normal file
View File

@ -0,0 +1,81 @@
.TH php\-config 1 "2021" "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
.RS
.PD 1
.P
.SH SEE ALSO
.BR php (1)
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version 7.4.32.
.SH COPYRIGHT
Copyright \(co 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.

470
php/man/man1/php.1 Normal file
View File

@ -0,0 +1,470 @@
.TH php 1 "2021" "The PHP Group" "Scripting Language"
.SH NAME
php \- PHP Command Line Interface 'CLI'
.P
php-cgi \- PHP Common Gateway Interface 'CGI' command
.SH SYNOPSIS
.B php
[options] [
.B \-f\fP ]
.IR file
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options]
.B \-r
.IR code
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options] [\-B
.IR begin_code ]
.B \-R
.IR code
[\-E
.IR end_code ]
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options] [\-B
.IR begin_code ]
.B \-F
.IR file
[\-E
.IR end_code ]
[[\-\-]
.IR args.\|.\|. ]
.LP
.B php
[options] \-\- [
.IR args.\|.\|. ]
.LP
\fBphp \fP[options] \fB\-a\fP
.LP
.B php
[options] \-S
.IR addr:port
[\-t
.IR docroot ]
.LP
.SH DESCRIPTION
\fBPHP\fP is a widely\-used general\-purpose scripting language that is especially suited for
Web development and can be embedded into HTML. This is the command line interface
that enables you to do the following:
.P
You can parse and execute files by using parameter \-f followed by the name of the
.IR file
to be executed.
.LP
Using parameter \-r you can directly execute PHP
.IR code
simply as you would do inside a
.B \.php
file when using the
.B eval()
function.
.LP
It is also possible to process the standard input line by line using either
the parameter \-R or \-F. In this mode each separate input line causes the
.IR code
specified by \-R or the
.IR file
specified by \-F to be executed.
You can access the input line by \fB$argn\fP. While processing the input lines
.B $argi
contains the number of the actual line being processed. Further more
the parameters \-B and \-E can be used to execute
.IR code
(see \-r) before and
after all input lines have been processed respectively. Notice that the
input is read from
.B STDIN
and therefore reading from
.B STDIN
explicitly changes the next input line or skips input lines.
.LP
PHP also contains an built-in web server for application development purpose. By using the \-S option where
.B addr:port
point to a local address and port PHP will listen to HTTP requests on that address and port and serve files from the current working directory or the
.B docroot
passed by the \-t option.
.LP
If none of \-r \-f \-B \-R \-F \-E or \-S is present but a single parameter is given
then this parameter is taken as the filename to parse and execute (same as
with \-f). If no parameter is present then the standard input is read and
executed.
.SH OPTIONS
.TP 15
.PD 0
.B \-\-interactive
.TP
.PD 1
.B \-a
Run PHP interactively. This lets you enter snippets of PHP code that directly
get executed. When readline support is enabled you can edit the lines and also
have history support.
.TP
.PD 0
.B \-\-bindpath \fIaddress:port\fP|\fIport\fP
.TP
.PD 1
.B \-b \fIaddress:port\fP|\fIport\fP
Bind Path for external FASTCGI Server mode (CGI only).
.TP
.PD 0
.B \-\-no\-chdir
.TP
.PD 1
.B \-C
Do not chdir to the script's directory (CGI only).
.TP
.PD 0
.B \-\-no\-header
.TP
.PD 1
.B \-q
Quiet-mode. Suppress HTTP header output (CGI only).
.TP
.PD 0
.B \-\-timing \fIcount\fP
.TP
.PD 1
.B \-T \fIcount\fP
Measure execution time of script repeated count times (CGI only).
.TP
.PD 0
.B \-\-php\-ini \fIpath\fP|\fIfile\fP
.TP
.PD 1
.B \-c \fIpath\fP|\fIfile\fP
Look for
.B php.ini
file in the directory
.IR path
or use the specified
.IR file
.TP
.PD 0
.B \-\-no\-php\-ini
.TP
.PD 1
.B \-n
No
.B php.ini
file will be used
.TP
.PD 0
.B \-\-define \fIfoo\fP[=\fIbar\fP]
.TP
.PD 1
.B \-d \fIfoo\fP[=\fIbar\fP]
Define INI entry
.IR foo
with value
.IR bar
.TP
.B \-e
Generate extended information for debugger/profiler
.TP
.PD 0
.B \-\-file \fIfile\fP
.TP
.PD 1
.B \-f \fIfile\fP
Parse and execute
.IR file
.TP
.PD 0
.B \-\-help
.TP
.PD 1
.B \-h
This help
.TP
.PD 0
.B \-\-hide\-args
.TP
.PD 1
.B \-H
Hide script name (\fIfile\fP) and parameters (\fIargs\.\.\.\fP) from external
tools. For example you may want to use this when a php script is started as
a daemon and the command line contains sensitive data such as passwords.
.TP
.PD 0
.B \-\-info
.TP
.PD 1
.B \-i
PHP information and configuration
.TP
.PD 0
.B \-\-syntax\-check
.TP
.PD 1
.B \-l
Syntax check only (lint)
.TP
.PD 0
.B \-\-modules
.TP
.PD 1
.B \-m
Show compiled in modules
.TP
.PD 0
.B \-\-run \fIcode\fP
.TP
.PD 1
.B \-r \fIcode\fP
Run PHP
.IR code
without using script tags
.B '<?..?>'
.TP
.PD 0
.B \-\-process\-begin \fIcode\fP
.TP
.PD 1
.B \-B \fIbegin_code\fP
Run PHP
.IR begin_code
before processing input lines
.TP
.PD 0
.B \-\-process\-code \fIcode\fP
.TP
.PD 1
.B \-R \fIcode\fP
Run PHP
.IR code
for every input line
.TP
.PD 0
.B \-\-process\-file \fIfile\fP
.TP
.PD 1
.B \-F \fIfile\fP
Parse and execute
.IR file
for every input line
.TP
.PD 0
.B \-\-process\-end \fIcode\fP
.TP
.PD 1
.B \-E \fIend_code\fP
Run PHP
.IR end_code
after processing all input lines
.TP
.PD 0
.B \-\-syntax\-highlight
.TP
.PD 1
.B \-s
Output HTML syntax highlighted source
.TP
.PD 0
.B \-\-server \fIaddr:port\fP
.TP
.PD 1
.B \-S \fIaddr:port\fP
Start built-in web server on the given local address and port
.TP
.PD 0
.B \-\-docroot \fIdocroot\fP
.TP
.PD 1
.B \-t \fIdocroot\fP
Specify the document root to be used by the built-in web server
.TP
.PD 0
.B \-\-version
.TP
.PD 1
.B \-v
Version number
.TP
.PD 0
.B \-\-strip
.TP
.PD 1
.B \-w
Output source with stripped comments and whitespace
.TP
.PD 0
.B \-\-zend\-extension \fIfile\fP
.TP
.PD 1
.B \-z \fIfile\fP
Load Zend extension
.IR file
.TP
.IR args.\|.\|.
Arguments passed to script. Use
.B '\-\-'
.IR args
when first argument starts with
.B '\-'
or script is read from stdin
.TP
.PD 0
.B \-\-rfunction
.IR name
.TP
.PD 1
.B \-\-rf
.IR name
Shows information about function
.B name
.TP
.PD 0
.B \-\-rclass
.IR name
.TP
.PD 1
.B \-\-rc
.IR name
Shows information about class
.B name
.TP
.PD 0
.B \-\-rextension
.IR name
.TP
.PD 1
.B \-\-re
.IR name
Shows information about extension
.B name
.TP
.PD 0
.B \-\-rzendextension
.IR name
.TP
.PD 1
.B \-\-rz
.IR name
Shows information about Zend extension
.B name
.TP
.PD 0
.B \-\-rextinfo
.IR name
.TP
.PD 1
.B \-\-ri
.IR name
Shows configuration for extension
.B name
.TP
.B \-\-ini
Show configuration file names
.SH FILES
.TP 15
.B php\-cli.ini
The configuration file for the CLI version of PHP.
.TP
.B php.ini
The standard configuration file will only be used when
.B php\-cli.ini
cannot be found.
.SH EXAMPLES
.TP 5
\fIphp \-r 'echo "Hello World\\n";'\fP
This command simply writes the text "Hello World" to standard out.
.TP
\fIphp \-r 'print_r(gd_info());'\fP
This shows the configuration of your gd extension. You can use this
to easily check which image formats you can use. If you have any
dynamic modules you may want to use the same ini file that php uses
when executed from your webserver. There are more extensions which
have such a function. For dba use:
.RS
\fIphp \-r 'print_r(dba_handlers(1));'\fP
.RE
.TP
\fIphp \-R 'echo strip_tags($argn)."\\n";'\fP
This PHP command strips off the HTML tags line by line and outputs the
result. To see how it works you can first look at the following PHP command
\'\fIphp \-d html_errors=1 \-i\fP\' which uses PHP to output HTML formatted
configuration information. If you then combine those two
\'\fIphp \.\.\.|php \.\.\.\fP\' you'll see what happens.
.TP
\fIphp \-E 'echo "Lines: $argi\\n";'\fP
Using this PHP command you can count the lines being input.
.TP
\fIphp \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
In this example PHP expects each input line being a file. It counts all lines
of the files specified by each input line and shows the summarized result.
You may combine this with tools like find and change the php scriptlet.
.TP
\fIphp \-R 'echo "$argn\\n"; fgets(STDIN);'\fP
Since you have access to STDIN from within \-B \-R \-F and \-E you can skip
certain input lines with your code. But note that in such cases $argi only
counts the lines being processed by php itself. Having read this you will
guess what the above program does: skipping every second input line.
.SH TIPS
You can use a shebang line to automatically invoke php
from scripts. Only the CLI version of PHP will ignore
such a first line as shown below:
.P
.PD 0
.RS
#!/bin/php
.P
<?php
.P
// your script
.P
?>
.RE
.PD 1
.P
.SH SEE ALSO
For a more or less complete description of PHP look here:
.PD 0
.P
.B http://www.php.net/manual/
.PD 1
.P
.SH BUGS
You can view the list of known bugs or report any new bug you
found at:
.PD 0
.P
.B http://bugs.php.net
.PD 1
.SH AUTHORS
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
.P
Additional work for the CLI sapi was done by Edin Kadribasic, Marcus Boerger and Johannes Schlueter.
.P
A List of active developers can be found here:
.PD 0
.P
.B http://www.php.net/credits.php
.PD 1
.P
And last but not least PHP was developed with the help of a huge amount of
contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version 7.4.32.
.SH COPYRIGHT
Copyright \(co 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.

150
php/man/man1/phpdbg.1 Normal file
View File

@ -0,0 +1,150 @@
.TH phpdbg 1 "2021" "The PHP Group" "Scripting Language"
.SH NAME
phpdbg \- The interactive PHP debugger
.SH SYNOPSIS
.B phpdbg
[options]
[\fIfile\fP]
[\fIargs...\fP]
.SH DESCRIPTION
.B phpdbg
is a lightweight, powerful, easy to use debugging platform for PHP.
.SH OPTIONS
.TP 15
.B \-c \fIpath\fB|\fIfile\fR
Look for
.B php.ini
file in the directory
.IR path
or use the specified
.IR file
.TP
.B \-d \fIfoo\fP[=\fIbar\fP]
Define INI entry
.IR foo
with value
.IR bar
.TP
.B \-n
No
.B php.ini
file will be used
.TP
.B \-z \fIfile\fR
Load Zend extension
.IR file
.TP
.BR \-q
Do not print banner on startup
.TP
.B \-v
Enable oplog output
.TP
.B \-b
Disables use of color on the console
.TP
.B \-i \fIpath\fB|\fIfile\fR
Override .phpgdbinit location (implies -I)
.TP
.B \-I
Ignore .phpdbginit (default init file)
.TP
.B \-O \fIfile\fR
Set oplog output to
.IR file
.TP
.B \-r
Jump straight to run
.TP
.B -e
Generate extended information for debugger/profiler
.TP
.B \-E
Enable step through eval()
.TP
.B \-s \fIdelimiter\fP
Read code to execute from stdin with an optional
.IR delimiter
.TP
.B \-S \fIsapi_name\fP
Override SAPI name
.TP
.B \-l \fIport\fP
Setup remote console port
.TP
.B \-a \fIaddress\fP
Setup remote console bind address
.TP
.B \-x
Enable XML output
.TP
.B \-p \fIopcode\fP
Output opcodes and quit
.TP
.B \-h
Print the help overview
.TP
.B \-V
Version number
.TP
.IR args.\|.\|.
Arguments passed to script. Use
.B '\-\-'
.IR args
when first argument starts with
.B '\-'
or script is read from stdin
.SH NOTES
Passing
.B \-rr
will cause
.B phpdbg
to quit after execution, rather than returning to the console
.SH FILES
.TP 15
.B php.ini
The standard configuration file
.TP
.B .phpdbginit
The init file
.SH SEE ALSO
The online manual can be found at
.PD 0
.P
.B http://php.net/manual/book.phpdbg.php
.PD 1
.SH BUGS
You can view the list of known bugs or report any new bug you
found at
.PD 0
.P
.B http://bugs.php.net/
.PD 1
.SH AUTHORS
Written by Felipe Pena, Joe Watkins and Bob Weinand, formatted by Ondřej Surý for Debian project.
.P
A List of active developers can be found at
.PD 0
.P
.B http://www.php.net/credits.php
.PD 1
.P
And last but not least PHP was developed with the help of a huge amount of
contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphpdbg\fP, for PHP version 7.4.32.
.SH COPYRIGHT
Copyright \(co 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.

48
php/man/man1/phpize.1 Normal file
View File

@ -0,0 +1,48 @@
.TH phpize 1 "2021" "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
.RS
.PD 1
.P
.SH SEE ALSO
.BR php (1)
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version 7.4.32.
.SH COPYRIGHT
Copyright \(co 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.

1
phpbrew.variants Normal file
View File

@ -0,0 +1 @@
a:3:{s:16:"enabled_variants";a:28:{s:5:"mysql";N;s:7:"openssl";s:26:"/usr/local/opt/openssl@1.1";s:3:"xml";N;s:7:"opcache";N;s:6:"bcmath";N;s:3:"bz2";N;s:8:"calendar";N;s:3:"cli";N;s:5:"ctype";N;s:3:"dom";N;s:8:"fileinfo";N;s:6:"filter";N;s:3:"ipc";N;s:4:"json";N;s:7:"mbregex";N;s:8:"mbstring";N;s:5:"mhash";N;s:5:"pcntl";N;s:4:"pcre";N;s:3:"pdo";N;s:4:"pear";N;s:4:"phar";N;s:5:"posix";N;s:8:"readline";N;s:7:"sockets";N;s:9:"tokenizer";N;s:4:"curl";N;s:3:"zip";N;}s:17:"disabled_variants";a:0:{}s:13:"extra_options";a:1:{i:0;s:13:"--disable-zts";}}

1
phpbrew_status Normal file
View File

@ -0,0 +1 @@
5

1
var/db/lz4.ini Normal file
View File

@ -0,0 +1 @@
extension=lz4.so

1
var/db/msgpack.ini Normal file
View File

@ -0,0 +1 @@
extension=msgpack.so

1
var/db/xdiff.ini Normal file
View File

@ -0,0 +1 @@
extension=xdiff.so