研修用

This commit is contained in:
ryo.takaki 2022-08-02 22:20:43 +09:00
parent bc7de77181
commit 5678a53db3
19 changed files with 451 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
bin
obj
*.sln.DotSettings.user
.vs

View File

@ -1,3 +1,7 @@
# 高木追記
php8のバイナリをgitにあげているので以下コマンドで一時的にパスを通してください
export PATH=./bin:$PATH
# GildedRose Kata - PHP Version
See the [top level readme](../README.md) for general information about this exercise. This is the PHP version of the

28
php/bin/pear Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
PHP="$PHP_PEAR_PHP_BIN"
else
if test "/Applications/MAMP/bin/php/php8.0.8/bin/php" = '@'php_bin'@'; then
PHP=php
else
PHP="/Applications/MAMP/bin/php/php8.0.8/bin/php"
fi
fi
# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
INCDIR=$PHP_PEAR_INSTALL_DIR
INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
if test "/Applications/MAMP/bin/php/php8.0.8/lib/php" = '@'php_dir'@'; then
INCDIR=`dirname $0`
INCARG=""
else
INCDIR="/Applications/MAMP/bin/php/php8.0.8/lib/php"
INCARG="-d include_path=/Applications/MAMP/bin/php/php8.0.8/lib/php"
fi
fi
exec $PHP -C -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" $INCDIR/pearcmd.php "$@"

28
php/bin/peardev Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
PHP="$PHP_PEAR_PHP_BIN"
else
if test "/Applications/MAMP/bin/php/php8.0.8/bin/php" = '@'php_bin'@'; then
PHP=php
else
PHP="/Applications/MAMP/bin/php/php8.0.8/bin/php"
fi
fi
# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
INCDIR=$PHP_PEAR_INSTALL_DIR
INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
if test "/Applications/MAMP/bin/php/php8.0.8/lib/php" = '@'php_dir'@'; then
INCDIR=`dirname $0`
INCARG=""
else
INCDIR="/Applications/MAMP/bin/php/php8.0.8/lib/php"
INCARG="-d include_path=/Applications/MAMP/bin/php/php8.0.8/lib/php"
fi
fi
exec $PHP -d date.timezone=UTC -d memory_limit="-1" -C -q $INCARG -d output_buffering=1 -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d variables_order=EGPCS -d auto_append_file="" $INCDIR/pearcmd.php "$@"

28
php/bin/pecl Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
PHP="$PHP_PEAR_PHP_BIN"
else
if test "/Applications/MAMP/bin/php/php8.0.8/bin/php" = '@'php_bin'@'; then
PHP=php
else
PHP="/Applications/MAMP/bin/php/php8.0.8/bin/php"
fi
fi
# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
INCDIR=$PHP_PEAR_INSTALL_DIR
INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
if test "/Applications/MAMP/bin/php/php8.0.8/lib/php" = '@'php_dir'@'; then
INCDIR=`dirname $0`
INCARG=""
else
INCDIR="/Applications/MAMP/bin/php/php8.0.8/lib/php"
INCARG="-d include_path=/Applications/MAMP/bin/php/php8.0.8/lib/php"
fi
fi
exec $PHP -C -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"

BIN
php/bin/phar Executable file

Binary file not shown.

BIN
php/bin/phar.phar Executable file

Binary file not shown.

BIN
php/bin/php Executable file

Binary file not shown.

BIN
php/bin/php-cgi Executable file

Binary file not shown.

98
php/bin/php-config Executable file
View File

@ -0,0 +1,98 @@
#! /bin/sh
SED="/usr/bin/sed"
prefix="/Applications/MAMP/bin/php/php8.0.8"
datarootdir="/Applications/MAMP/bin/php/php8.0.8/php"
exec_prefix="/Applications/MAMP/bin/php/php8.0.8"
version="8.0.8"
vernum="80008"
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/Applications/MAMP/Library/lib"
libs=" -largon2 -lreadline -lncurses -lldap -llber -lstdc++ -liconv -lintl -lbz2 -lnetwork -lm -lresolv -lxml2 -lkrb5 -lssl -lcrypto -lsqlite3 -lz -lcurl -lssl -lcrypto -lxml2 -lssl -lcrypto -lz -lpng16 -lz -lwebp -ljpeg -lfreetype -licuio -licui18n -licuuc -licudata -lonig -lsqlite3 -lxml2 -lxml2 -lsodium -largon2 -lxml2 -lxml2 -lxml2 -lxslt -lxml2 -lz -llzma -lpthread -liconv -licui18n -licuuc -licudata -lm -lxml2 -lexslt -lxslt -lxml2 -lz -llzma -lpthread -liconv -licui18n -licuuc -licudata -lm -lxml2 -lzip -lz -lssl -lcrypto "
extension_dir='/Applications/MAMP/bin/php/php8.0.8/lib/php/extensions/no-debug-non-zts-20200930'
man_dir=`eval echo ${datarootdir}/man`
program_prefix=""
program_suffix=""
exe_extension=""
php_cli_binary=NONE
php_cgi_binary=NONE
configure_options=" '--with-apxs2=/Applications/MAMP/Library/bin/apxs' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php8.0.8' '--exec-prefix=/Applications/MAMP/bin/php/php8.0.8' '--sysconfdir=/Applications/MAMP/bin/php/php8.0.8/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php8.0.8/conf' '--enable-ftp' '--with-bz2=/Applications/MAMP/Library' '--with-mysqli=mysqlnd' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--enable-soap' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-openssl=/Applications/MAMP/Library' '--enable-opcache' '--with-tidy=shared,/Applications/MAMP/Library' '--with-readline' '--with-mhash' '--with-sodium=/Applications/MAMP/Library' '--with-password-argon2=/Applications/MAMP/Library' '--with-zip' '--with-xmlrpc' '--with-kerberos' '--with-pdo-sqlite' '--with-sqlite3' '--with-ldap=/Applications/MAMP/Library' '--with-ldap-sasl' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f/lib' '--with-imap-ssl=/Applications/MAMP/Library' '--disable-phpdbg' '--enable-cgi' '--with-webp' '--with-jpeg' '--with-freetype' '--enable-pcntl' '--enable-intl' '--with-iconv=/Applications/MAMP/Library' '--with-gettext=/Applications/MAMP/Library' '--enable-gd' 'KERBEROS_CFLAGS=-I/usr/include' 'KERBEROS_LIBS=-lkrb5' 'SQLITE_CFLAGS= ' 'SQLITE_LIBS=-lsqlite3' 'JPEG_CFLAGS= ' 'JPEG_LIBS=-ljpeg' 'SASL_CFLAGS=-I/usr/include/sasl' 'SASL_LIBS=-lsasl2'"
php_sapis=" apache2handler cli cgi"
ini_dir=""
ini_path="/Applications/MAMP/bin/php/php8.0.8/conf"
# 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
php/bin/phpdbg Executable file

Binary file not shown.

211
php/bin/phpize Executable file
View File

@ -0,0 +1,211 @@
#!/bin/sh
# Variable declaration
prefix='/Applications/MAMP/bin/php/php8.0.8'
datarootdir='/Applications/MAMP/bin/php/php8.0.8/php'
exec_prefix="`eval echo /Applications/MAMP/bin/php/php8.0.8`"
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 gen_stub.php"
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#/Applications/MAMP/bin/php/php8.0.8#$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

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests;
use ApprovalTests\Approvals;
use GildedRose\GildedRose;
use GildedRose\Item;
use PHPUnit\Framework\TestCase;
@ -17,4 +18,30 @@ class GildedRoseTest extends TestCase
$gildedRose->updateQuality();
$this->assertSame('fixme', $items[0]->name);
}
}
public function testApproveArray()
{
$list = ['zero', 'oxe', 'two', 'three', 'four', 'five'];
Approvals::approveList($list);
}
public function testApproveMap()
{
$list = [
'zero' => 'Lance',
'one' => 'Jam',
'two' => 'James',
'three' => 'LLewellyn',
'four' => 'Asaph',
'five' => 'Dana'
];
Approvals::approveList($list);
}
public function testApproveString()
{
$fudge = 'fadge';
Approvals::approveString($fudge);
}
}

View File

@ -0,0 +1,6 @@
[0] -> zero
[1] -> one
[2] -> two
[3] -> three
[4] -> four
[5] -> five

View File

@ -0,0 +1,6 @@
[0] -> zero
[1] -> oxe
[2] -> two
[3] -> three
[4] -> four
[5] -> five

View File

@ -0,0 +1,6 @@
[zero] -> Lance
[one] -> Jim
[two] -> James
[three] -> LLewellyn
[four] -> Asaph
[five] -> Dana

View File

@ -0,0 +1,6 @@
[zero] -> Lance
[one] -> Jam
[two] -> James
[three] -> LLewellyn
[four] -> Asaph
[five] -> Dana

View File

@ -0,0 +1 @@
fudge

View File

@ -0,0 +1 @@
fadge